Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2192106rwb; Mon, 15 Aug 2022 00:03:22 -0700 (PDT) X-Google-Smtp-Source: AA6agR7f1z/Rk9OVxE6qI5M8inctyCCBu6fnQeZ+zyiTxK2N2igrHK8xQZ4o10RdeCQkgsRaZXTj X-Received: by 2002:a17:90a:e68d:b0:1f8:91b8:d529 with SMTP id s13-20020a17090ae68d00b001f891b8d529mr24896040pjy.89.1660547002016; Mon, 15 Aug 2022 00:03:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660547002; cv=none; d=google.com; s=arc-20160816; b=aRsLln5QNQvM+5HfMASlJG3YeLeZ7/MRz/jJvvV9bMhF4lOgaA68LH5bBJamQlU6pa GVsZJMlnzy6+T+QC+SFePESBjGqQ8klC1KBriRo2RvWyRtJNw5g/GlkhM7L/mvH0ZkwD Imw9cda7qHLb9T/yj2sgnaMAxkDmyRTphK8MeV1FGgMQ4jW7V+whi7N+BKa0GTzIzzTA IOVFIaL1ADUzBi0pyoGsO2bDtnT9moAbcWPeoRBVBi8mQyKf9w3dpkdSeORWWvnw1dZ/ JRXPfsAfSEwpMep33Uz0H4a6o0i5TC/d16xEQInGXm4aAlN+UgP6HxvTOpCYw4azt3/d ppYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:feedback-id :dkim-signature:dkim-signature; bh=8v1UNNv97h9J2L3WvxkH00sK+2Af+0MdgE0J1dhPpWA=; b=LiZNIhgRf+Hpr1SBqz7ZbM1gg6Qz8pWuqhLBWeXVqjNMd0hzWJjErEcPQtwN6vnwoD uCP0WqkKkgebxdRLTQhCRSNddjQwwEHL68Wh/sg8FE0PUB65F6p2ykK2rbNvvaAy0Kcp stkQQFIQaiS5Jenx4L5qL40DH/T2f4aWB2ya2Kz8zJMK+f/+aUVnenQ35l61m0VUkoAm QTxxpN9GdxeRlNvzRMxSC+GFMVp1AK2clyTG8GH4wByKfAXs9AoQ/MhyWecn30iNilks A0Tme4Hop1T47YOXEsh13eYpVMEmaxsKpNYL1FsCwxItk3qA4DIgByXYlPuPdl+Wx8ZZ PqJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm3 header.b=QBYvXoFE; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=mYi0k5sz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h15-20020a056a00170f00b0050dcf85b9e1si10658897pfc.141.2022.08.15.00.03.03; Mon, 15 Aug 2022 00:03:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm3 header.b=QBYvXoFE; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=mYi0k5sz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240773AbiHOGnQ (ORCPT + 99 others); Mon, 15 Aug 2022 02:43:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239893AbiHOGnH (ORCPT ); Mon, 15 Aug 2022 02:43:07 -0400 Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CCDE1AF3F; Sun, 14 Aug 2022 23:43:04 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id E4D2C5C00B9; Mon, 15 Aug 2022 02:43:01 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 15 Aug 2022 02:43:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm3; t=1660545781; x=1660632181; bh=8v1UNNv97h 9J2L3WvxkH00sK+2Af+0MdgE0J1dhPpWA=; b=QBYvXoFE2expmhkMkPUa5b9q5J PJJ2hvuYdIuDuAStEHtfVpFxuE0rm9pi0n2MqT8brNudqMCmcIs9iMMb7udhtyQu Jku39EGmJVm1Ssj6AamPCjWZzdFFfLjumzy9QPcewvh8JfdmkDJ72G42IUMCw4FS dY4zC1H7DdhPpwZMMXrYLllHVJNk4cfil++OCi6mg3uIMKgtfIqhLTYzAI3s4CSZ bhjbP6E7sPa4hdayqvNaqYbabL06vdMam6fahFpUOQRojr4F8QBCosgYl9Dyx/NM Mo1XAE48Hm8nDCGZRWoClZnluZ4o7XD1+Ek+uFF8npJE7bCs2PTFxRE4RBag== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1660545781; x=1660632181; bh=8v1UNNv97h9J2L3WvxkH00sK+2Af +0MdgE0J1dhPpWA=; b=mYi0k5szCs5yZozk29RRx8q5qgOTdLBRsL8hGMEWLfnH ez8RFhJdZEdDQOdWsSA/wMS270RyUrecpyaq7QjdnNyttVRBu1quc4+SD867LYro 41Gr25rR0YctXAS0odKzpWTU8nY+23p+681+AmJwC5EW23NI1YaKhH9BkP5EwiAs 0lqhSPE6Id/EJ7TOOqf397/CPpWxA/txw8bCu09H7Md8jvNWABv2oFXgqqRbwt1b Mn6kBMDGLy67+47x6LXSwTvxDMjCFZjkv70itsEjcM6uXHs4U15dzrMoRhBuy+TC AAaaxtH845XqkVGyhhIR/lgsXSh8uZxVy4yNVFXiiw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdehuddgudduhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvvefukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepteefffefgfektdefgfeludfgtdejfeejvddttdekteeiffejvdfgheeh fffhvedunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 15 Aug 2022 02:43:00 -0400 (EDT) Date: Mon, 15 Aug 2022 08:42:48 +0200 From: Maxime Ripard To: Samuel Holland Cc: Chen-Yu Tsai , Jernej Skrabec , Daniel Vetter , David Airlie , Jagan Teki , Krzysztof Kozlowski , Rob Herring , devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-sunxi@lists.linux.dev Subject: Re: [PATCH 3/4] drm/sun4i: dsi: Add a variant structure Message-ID: <20220815064248.4ujitfpvtw6y3k4k@houat> References: <20220812074257.58254-1-samuel@sholland.org> <20220812074257.58254-4-samuel@sholland.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="fe5pr2l7i2tpjvdm" Content-Disposition: inline In-Reply-To: <20220812074257.58254-4-samuel@sholland.org> X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --fe5pr2l7i2tpjvdm Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Samuel, On Fri, Aug 12, 2022 at 02:42:55AM -0500, Samuel Holland wrote: > Replace the ad-hoc calls to of_device_is_compatible() with a structure > describing the differences between variants. This is in preparation for > adding more variants to the driver. >=20 > Signed-off-by: Samuel Holland > --- >=20 > drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 50 +++++++++++++++++--------- > drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h | 7 ++++ > 2 files changed, 40 insertions(+), 17 deletions(-) >=20 > diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun= 4i/sun6i_mipi_dsi.c > index b4dfa166eccd..6479ade416b9 100644 > --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > @@ -1101,12 +1101,16 @@ static const struct component_ops sun6i_dsi_ops = =3D { > =20 > static int sun6i_dsi_probe(struct platform_device *pdev) > { > + const struct sun6i_dsi_variant *variant; > struct device *dev =3D &pdev->dev; > - const char *bus_clk_name =3D NULL; > struct sun6i_dsi *dsi; > void __iomem *base; > int ret; > =20 > + variant =3D device_get_match_data(dev); > + if (!variant) > + return -EINVAL; > + > dsi =3D devm_kzalloc(dev, sizeof(*dsi), GFP_KERNEL); > if (!dsi) > return -ENOMEM; > @@ -1114,10 +1118,7 @@ static int sun6i_dsi_probe(struct platform_device = *pdev) > dsi->dev =3D dev; > dsi->host.ops =3D &sun6i_dsi_host_ops; > dsi->host.dev =3D dev; > - > - if (of_device_is_compatible(dev->of_node, > - "allwinner,sun6i-a31-mipi-dsi")) > - bus_clk_name =3D "bus"; > + dsi->variant =3D variant; > =20 > base =3D devm_platform_ioremap_resource(pdev, 0); > if (IS_ERR(base)) { > @@ -1142,7 +1143,7 @@ static int sun6i_dsi_probe(struct platform_device *= pdev) > return PTR_ERR(dsi->regs); > } > =20 > - dsi->bus_clk =3D devm_clk_get(dev, bus_clk_name); > + dsi->bus_clk =3D devm_clk_get(dev, variant->has_mod_clk ? "bus" : NULL); > if (IS_ERR(dsi->bus_clk)) > return dev_err_probe(dev, PTR_ERR(dsi->bus_clk), > "Couldn't get the DSI bus clock\n"); > @@ -1151,21 +1152,21 @@ static int sun6i_dsi_probe(struct platform_device= *pdev) > if (ret) > return ret; > =20 > - if (of_device_is_compatible(dev->of_node, > - "allwinner,sun6i-a31-mipi-dsi")) { > + if (variant->has_mod_clk) { > dsi->mod_clk =3D devm_clk_get(dev, "mod"); > if (IS_ERR(dsi->mod_clk)) { > dev_err(dev, "Couldn't get the DSI mod clock\n"); > ret =3D PTR_ERR(dsi->mod_clk); > goto err_attach_clk; > } > - } > =20 > - /* > - * In order to operate properly, that clock seems to be always > - * set to 297MHz. > - */ > - clk_set_rate_exclusive(dsi->mod_clk, 297000000); > + /* > + * In order to operate properly, the module clock on the > + * A31 variant always seems to be set to 297MHz. > + */ > + if (variant->set_mod_clk) > + clk_set_rate_exclusive(dsi->mod_clk, 297000000); > + } > > > dsi->dphy =3D devm_phy_get(dev, "dphy"); > if (IS_ERR(dsi->dphy)) { > @@ -1205,16 +1206,31 @@ static int sun6i_dsi_remove(struct platform_devic= e *pdev) > =20 > component_del(&pdev->dev, &sun6i_dsi_ops); > mipi_dsi_host_unregister(&dsi->host); > - clk_rate_exclusive_put(dsi->mod_clk); > + if (dsi->variant->has_mod_clk && dsi->variant->set_mod_clk) > + clk_rate_exclusive_put(dsi->mod_clk); There's also a clk_rate_exclusive_put call in the bind error path Maxime --fe5pr2l7i2tpjvdm Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCYvnq6AAKCRDj7w1vZxhR xRUgAQC+Q6FefSqQzlCuirg8gH0Zff7RElCM+/kmmzZdz/QEiwEA1K0JgOyS8Xbv pApMRj4LRfKxndHBOk/R4DCvHbcNxwk= =pvGf -----END PGP SIGNATURE----- --fe5pr2l7i2tpjvdm--