ARM Sunxi Platform Development
 help / color / mirror / Atom feed
From: Maxime Ripard <maxime@cerno.tech>
To: Samuel Holland <samuel@sholland.org>
Cc: Chen-Yu Tsai <wens@csie.org>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Daniel Vetter <daniel@ffwll.ch>, David Airlie <airlied@linux.ie>,
	Jagan Teki <jagan@amarulasolutions.com>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Rob Herring <robh+dt@kernel.org>,
	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
Date: Mon, 15 Aug 2022 08:42:48 +0200	[thread overview]
Message-ID: <20220815064248.4ujitfpvtw6y3k4k@houat> (raw)
In-Reply-To: <20220812074257.58254-4-samuel@sholland.org>

[-- Attachment #1: Type: text/plain, Size: 3443 bytes --]

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.
> 
> Signed-off-by: Samuel Holland <samuel@sholland.org>
> ---
> 
>  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(-)
> 
> diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/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 = {
>  
>  static int sun6i_dsi_probe(struct platform_device *pdev)
>  {
> +	const struct sun6i_dsi_variant *variant;
>  	struct device *dev = &pdev->dev;
> -	const char *bus_clk_name = NULL;
>  	struct sun6i_dsi *dsi;
>  	void __iomem *base;
>  	int ret;
>  
> +	variant = device_get_match_data(dev);
> +	if (!variant)
> +		return -EINVAL;
> +
>  	dsi = 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 = dev;
>  	dsi->host.ops = &sun6i_dsi_host_ops;
>  	dsi->host.dev = dev;
> -
> -	if (of_device_is_compatible(dev->of_node,
> -				    "allwinner,sun6i-a31-mipi-dsi"))
> -		bus_clk_name = "bus";
> +	dsi->variant = variant;
>  
>  	base = 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);
>  	}
>  
> -	dsi->bus_clk = devm_clk_get(dev, bus_clk_name);
> +	dsi->bus_clk = 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;
>  
> -	if (of_device_is_compatible(dev->of_node,
> -				    "allwinner,sun6i-a31-mipi-dsi")) {
> +	if (variant->has_mod_clk) {
>  		dsi->mod_clk = devm_clk_get(dev, "mod");
>  		if (IS_ERR(dsi->mod_clk)) {
>  			dev_err(dev, "Couldn't get the DSI mod clock\n");
>  			ret = PTR_ERR(dsi->mod_clk);
>  			goto err_attach_clk;
>  		}
> -	}
>  
> -	/*
> -	 * 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 = devm_phy_get(dev, "dphy");
>  	if (IS_ERR(dsi->dphy)) {
> @@ -1205,16 +1206,31 @@ static int sun6i_dsi_remove(struct platform_device *pdev)
>  
>  	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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  parent reply	other threads:[~2022-08-15  6:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-12  7:42 [PATCH 0/4] drm/sun4i: dsi: Support the A100/D1 controller variant Samuel Holland
2022-08-12  7:42 ` [PATCH 1/4] dt-bindings: display: sun6i-dsi: Fix clock conditional Samuel Holland
2022-08-12 10:48   ` Krzysztof Kozlowski
2022-08-12  7:42 ` [PATCH 2/4] dt-bindings: display: sun6i-dsi: Add the A100 variant Samuel Holland
2022-08-12 10:49   ` Krzysztof Kozlowski
2022-08-12 22:58     ` Samuel Holland
2022-08-16 10:15       ` Krzysztof Kozlowski
2022-08-12  7:42 ` [PATCH 3/4] drm/sun4i: dsi: Add a variant structure Samuel Holland
2022-08-14  7:46   ` Jernej Škrabec
2022-08-15  6:42   ` Maxime Ripard [this message]
2022-08-12  7:42 ` [PATCH 4/4] drm/sun4i: dsi: Add the A100 variant Samuel Holland
2022-08-14  7:47   ` Jernej Škrabec

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220815064248.4ujitfpvtw6y3k4k@houat \
    --to=maxime@cerno.tech \
    --cc=airlied@linux.ie \
    --cc=daniel@ffwll.ch \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jagan@amarulasolutions.com \
    --cc=jernej.skrabec@gmail.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=robh+dt@kernel.org \
    --cc=samuel@sholland.org \
    --cc=wens@csie.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox