From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85A9AC433E6 for ; Fri, 19 Feb 2021 14:01:48 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2CCFB64EB7 for ; Fri, 19 Feb 2021 14:01:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2CCFB64EB7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cerno.tech Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=btqX4gDmvdgs08kCp04FR1Khd0ucfnpGvRIZRd/2+e8=; b=DGV8v1EwvM5f8XV9uLgI3xUty GxqOc1kkqrDjDJuSIHBpyiwDuhPnUh1Aci7nsaKens04UH86d5a9L38b5c74wy6lt3YTB56vKeaFR HZRQJERGVdKVpYxUPk7TEAO8Q3T672kf/Mcv4bTt24yjfp1SsZih0Ueym6DM+oanPKGH4DVzPcdSG bAOETQMJCQ724tBLX3D7X/98L8SlGb9jKxlqtqHCKvYL9kT3AhZIqhgkyGFcSaR9J69gRPOoEYUyJ uKqLjbsElSA5pA31O0MroNJeQJ2i5XqY8mlKxZUIvvwupW11KanOLY5qiPeKOZ/M8xAxWh8q69Xzb s57tMmcww==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lD6K2-00085N-NF; Fri, 19 Feb 2021 13:59:54 +0000 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lD6Jv-00082A-BZ for linux-arm-kernel@lists.infradead.org; Fri, 19 Feb 2021 13:59:48 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id C390E816; Fri, 19 Feb 2021 08:59:45 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Fri, 19 Feb 2021 08:59:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=Tbh3a6kdyKzOE oFv3/SxTGtrVykwWzfjESwaCBMK/U0=; b=XYTBmxZvfrBH1wmBaz71V8UmOxNTG BuyzUMG6Qy2e3+GjPUaEwA8a53hmJV7KjGd41dXAeg/Det7liKFbL30Nlv66V41E BSydTX07xbptzPRObe+v05h+hwX98ZOKq9t6i1i9TxelDhyEYvJ+PXW92u4vkb/1 BVkbijHIECjpy6ctlmr1hsCD+r1J3H3rfhqoIthtLBjvBwiKZowNZxDp4lI9BJoZ er4xq3y6YhLn55SOxfLatbWn0yoA7P5TEDQnmb3V8otuDx8WbdJmxqpWwJiVlmwD J7qbmH1dY+PrIyJSskPgA6f8605rTLjFzzbbsUUqBWXTm1FyQWXTMFSzg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=Tbh3a6kdyKzOEoFv3/SxTGtrVykwWzfjESwaCBMK/U0=; b=MGOIhoIf frntwgjHJ3h5IvJMT3Ogog+5Eqd0Sbs3s1oBp3sXKaOSPlSI7zqQ2eX4vXNzuMD2 yRU+m+G968K9wON8kJin7Kth8n0TsXcABYaOADT63AE1rDediVezxRKbEt6B15Mg BsICGdIZqb/+f70e7NmDif6L1aqGmo68MriWi/EWfz7b8jMlmTQCE5S072Uti+Cu g/WFIbONPSDkx1UvnE/P2ui4DzKusq9eGo70slzJ+Zm6PoOCV0TI+SfMxihSagnT TBWovMXzCaP5DBPfiw0EtqdURIn4GNMZmiGGCGDAi32kOjmJ/DHrS+b1xNHkmSsX vPb7bOOyiWDa2Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrjeeigdehlecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihimhgv ucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrghtth gvrhhnpedvkeelveefffekjefhffeuleetleefudeifeehuddugffghffhffehveevheeh vdenucfkphepledtrdekledrieekrdejieenucevlhhushhtvghrufhiiigvpedtnecurf grrhgrmhepmhgrihhlfhhrohhmpehmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: from localhost (lfbn-tou-1-1502-76.w90-89.abo.wanadoo.fr [90.89.68.76]) by mail.messagingengine.com (Postfix) with ESMTPA id A2584240057; Fri, 19 Feb 2021 08:59:44 -0500 (EST) From: Maxime Ripard To: Laurent Pinchart , Chen-Yu Tsai , Maxime Ripard , Jernej Skrabec , Rob Herring , Frank Rowand , Daniel Vetter , David Airlie Subject: [PATCH v4 4/7] drm/sun4i: tcon: Refactor the LVDS and panel probing Date: Fri, 19 Feb 2021 14:59:31 +0100 Message-Id: <20210219135934.618684-5-maxime@cerno.tech> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210219135934.618684-1-maxime@cerno.tech> References: <20210219135934.618684-1-maxime@cerno.tech> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210219_085947_646404_48E85D5A X-CRM114-Status: GOOD ( 19.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The current code to parse the DT, deal with the older device trees, and register either the RGB or LVDS output has so far grown organically into the bind function and has become quite hard to extend properly. Let's move it into a single function that grabs all the resources it needs and registers the proper panel output. Reviewed-by: Chen-Yu Tsai Reviewed-by: Laurent Pinchart Signed-off-by: Maxime Ripard --- drivers/gpu/drm/sun4i/sun4i_tcon.c | 127 +++++++++++++---------------- 1 file changed, 58 insertions(+), 69 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c index 1e643bc7e786..32757175f86b 100644 --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c @@ -885,6 +885,63 @@ static int sun4i_tcon_init_regmap(struct device *dev, return 0; } +static int sun4i_tcon_register_panel(struct drm_device *drm, + struct sun4i_tcon *tcon) +{ + struct device_node *companion; + struct device_node *remote; + struct device *dev = tcon->dev; + int ret; + + /* + * If we have an LVDS panel connected to the TCON, we should + * just probe the LVDS connector. Otherwise, let's just register + * an RGB panel. + */ + remote = of_graph_get_remote_node(dev->of_node, 1, 0); + if (!tcon->quirks->supports_lvds || + !of_device_is_compatible(remote, "panel-lvds")) + return sun4i_rgb_init(drm, tcon); + + /* + * This can only be made optional since we've had DT + * nodes without the LVDS reset properties. + * + * If the property is missing, just disable LVDS, and + * print a warning. + */ + tcon->lvds_rst = devm_reset_control_get_optional(dev, "lvds"); + if (IS_ERR(tcon->lvds_rst)) { + dev_err(dev, "Couldn't get our reset line\n"); + return PTR_ERR(tcon->lvds_rst); + } else if (!tcon->lvds_rst) { + dev_warn(dev, "Missing LVDS reset property, please upgrade your DT\n"); + return -ENODEV; + } + + reset_control_reset(tcon->lvds_rst); + + /* + * This can only be made optional since we've had DT + * nodes without the LVDS clocks properties. + * + * If the property is missing, just disable LVDS, and + * print a warning. + */ + if (tcon->quirks->has_lvds_alt) { + tcon->lvds_pll = devm_clk_get_optional(dev, "lvds-alt"); + if (IS_ERR(tcon->lvds_pll)) { + dev_err(dev, "Couldn't get the LVDS PLL\n"); + return PTR_ERR(tcon->lvds_pll); + } else if (!tcon->lvds_pll) { + dev_warn(dev, "Missing LVDS PLL clock, please upgrade your DT\n"); + return -ENODEV; + } + } + + return sun4i_lvds_init(drm, tcon); +} + /* * On SoCs with the old display pipeline design (Display Engine 1.0), * the TCON is always tied to just one backend. Hence we can traverse @@ -1132,10 +1189,8 @@ static int sun4i_tcon_bind(struct device *dev, struct device *master, struct drm_device *drm = data; struct sun4i_drv *drv = drm->dev_private; struct sunxi_engine *engine; - struct device_node *remote; struct sun4i_tcon *tcon; struct reset_control *edp_rstc; - bool has_lvds_rst, has_lvds_alt, can_lvds; int ret; engine = sun4i_tcon_find_engine(drv, dev->of_node); @@ -1180,58 +1235,6 @@ static int sun4i_tcon_bind(struct device *dev, struct device *master, return ret; } - if (tcon->quirks->supports_lvds) { - /* - * This can only be made optional since we've had DT - * nodes without the LVDS reset properties. - * - * If the property is missing, just disable LVDS, and - * print a warning. - */ - tcon->lvds_rst = devm_reset_control_get_optional(dev, "lvds"); - if (IS_ERR(tcon->lvds_rst)) { - dev_err(dev, "Couldn't get our reset line\n"); - return PTR_ERR(tcon->lvds_rst); - } else if (tcon->lvds_rst) { - has_lvds_rst = true; - reset_control_reset(tcon->lvds_rst); - } else { - has_lvds_rst = false; - } - - /* - * This can only be made optional since we've had DT - * nodes without the LVDS reset properties. - * - * If the property is missing, just disable LVDS, and - * print a warning. - */ - if (tcon->quirks->has_lvds_alt) { - tcon->lvds_pll = devm_clk_get(dev, "lvds-alt"); - if (IS_ERR(tcon->lvds_pll)) { - if (PTR_ERR(tcon->lvds_pll) == -ENOENT) { - has_lvds_alt = false; - } else { - dev_err(dev, "Couldn't get the LVDS PLL\n"); - return PTR_ERR(tcon->lvds_pll); - } - } else { - has_lvds_alt = true; - } - } - - if (!has_lvds_rst || - (tcon->quirks->has_lvds_alt && !has_lvds_alt)) { - dev_warn(dev, "Missing LVDS properties, Please upgrade your DT\n"); - dev_warn(dev, "LVDS output disabled\n"); - can_lvds = false; - } else { - can_lvds = true; - } - } else { - can_lvds = false; - } - ret = sun4i_tcon_init_clocks(dev, tcon); if (ret) { dev_err(dev, "Couldn't init our TCON clocks\n"); @@ -1266,21 +1269,7 @@ static int sun4i_tcon_bind(struct device *dev, struct device *master, } if (tcon->quirks->has_channel_0) { - /* - * If we have an LVDS panel connected to the TCON, we should - * just probe the LVDS connector. Otherwise, just probe RGB as - * we used to. - */ - remote = of_graph_get_remote_node(dev->of_node, 1, 0); - if (of_device_is_compatible(remote, "panel-lvds")) - if (can_lvds) - ret = sun4i_lvds_init(drm, tcon); - else - ret = -EINVAL; - else - ret = sun4i_rgb_init(drm, tcon); - of_node_put(remote); - + ret = sun4i_tcon_register_panel(drm, tcon); if (ret < 0) goto err_free_dotclock; } -- 2.29.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel