devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Maxime Ripard <maxime.ripard@free-electrons.com>
To: Chen-Yu Tsai <wens@csie.org>
Cc: David Airlie <airlied@linux.ie>, Rob Herring <robh+dt@kernel.org>,
	Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@codeaurora.org>,
	dri-devel@lists.freedesktop.org,
	linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org,
	linux-clk@vger.kernel.org, linux-sunxi@googlegroups.com
Subject: Re: [PATCH 13/19] drm/sun4i: hdmi: Add support for controller hardware variants
Date: Fri, 2 Jun 2017 21:38:27 +0200	[thread overview]
Message-ID: <20170602193827.rnjum6x5ra4x5wef@flea.lan> (raw)
In-Reply-To: <20170602101024.18940-14-wens@csie.org>

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

On Fri, Jun 02, 2017 at 06:10:18PM +0800, Chen-Yu Tsai wrote:
> The HDMI controller found in earlier Allwinner SoCs have slight
> differences:
> 
>   - Need different initial values for the PLL related registers
> 
>   - Different behavior of the DDC and TMDS clocks
> 
>   - Different register layout for the DDC portion
> 
>   - Separate DDC parent clock on the A31
> 
>   - Explicit reset control
> 
> The clock variants are supported within their implementations,
> which only expose a create function for each variant.
> 
> The different layout of the DDC registers necessitates a separate
> version of struct drm_connector_helper_funcs.
> 
> A new variant data structure is created to store pointers to the
> above functions, structures, and the different initial values.
> Another flag notates whether there is a separate DDC parent clock.
> If not, the TMDS clock is passed to the DDC clock create function,
> as before.
> 
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> ---
>  drivers/clk/sunxi-ng/ccu-sun6i-a31.c   |   2 +-
>  drivers/gpu/drm/sun4i/sun4i_hdmi.h     |   8 +++
>  drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c | 114 ++++++++++++++++++++++++++-------
>  3 files changed, 100 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/clk/sunxi-ng/ccu-sun6i-a31.c b/drivers/clk/sunxi-ng/ccu-sun6i-a31.c
> index 4d6078fca9ac..e48186985a51 100644
> --- a/drivers/clk/sunxi-ng/ccu-sun6i-a31.c
> +++ b/drivers/clk/sunxi-ng/ccu-sun6i-a31.c
> @@ -610,7 +610,7 @@ static SUNXI_CCU_M_WITH_MUX_GATE(hdmi_clk, "hdmi", lcd_ch1_parents,
>  
>  static SUNXI_CCU_GATE(hdmi_ddc_clk, "hdmi-ddc", "osc24M", 0x150, BIT(30), 0);
>  
> -static SUNXI_CCU_GATE(ps_clk, "ps", "lcd1-ch1", 0x140, BIT(31), 0);
> +static SUNXI_CCU_GATE(ps_clk, "ps", "lcd1-ch1", 0x154, BIT(31), 0);

Unrelated change?

>  
>  static const char * const mbus_parents[] = { "osc24M", "pll-periph",
>  					     "pll-ddr" };
> diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi.h b/drivers/gpu/drm/sun4i/sun4i_hdmi.h
> index c39c2a245339..c63d0bd95963 100644
> --- a/drivers/gpu/drm/sun4i/sun4i_hdmi.h
> +++ b/drivers/gpu/drm/sun4i/sun4i_hdmi.h
> @@ -155,6 +155,8 @@ enum sun4i_hdmi_pkt_type {
>  	SUN4I_HDMI_PKT_END = 15,
>  };
>  
> +struct sun4i_hdmi_variant;
> +
>  struct sun4i_hdmi {
>  	struct drm_connector	connector;
>  	struct drm_encoder	encoder;
> @@ -162,9 +164,13 @@ struct sun4i_hdmi {
>  
>  	void __iomem		*base;
>  
> +	/* Reset control */
> +	struct reset_control	*reset;
> +
>  	/* Parent clocks */
>  	struct clk		*bus_clk;
>  	struct clk		*mod_clk;
> +	struct clk		*ddc_parent_clk;
>  	struct clk		*pll0_clk;
>  	struct clk		*pll1_clk;
>  
> @@ -175,6 +181,8 @@ struct sun4i_hdmi {
>  	struct sun4i_drv	*drv;
>  
>  	bool			hdmi_monitor;
> +
> +	const struct sun4i_hdmi_variant	*variant;
>  };
>  
>  int sun4i_ddc_create(struct sun4i_hdmi *hdmi, struct clk *clk);
> diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
> index 457614073501..9ded40aaed32 100644
> --- a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
> +++ b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
> @@ -20,8 +20,10 @@
>  #include <linux/clk.h>
>  #include <linux/component.h>
>  #include <linux/iopoll.h>
> +#include <linux/of_device.h>
>  #include <linux/platform_device.h>
>  #include <linux/pm_runtime.h>
> +#include <linux/reset.h>
>  
>  #include "sun4i_backend.h"
>  #include "sun4i_crtc.h"
> @@ -315,6 +317,56 @@ static const struct drm_connector_funcs sun4i_hdmi_connector_funcs = {
>  	.atomic_destroy_state	= drm_atomic_helper_connector_destroy_state,
>  };
>  
> +struct sun4i_hdmi_variant {
> +	const struct drm_connector_helper_funcs *connector_helpers;
> +	int (*ddc_create)(struct sun4i_hdmi *hdmi, struct clk *clk);
> +	int (*tmds_create)(struct sun4i_hdmi *hdmi);
> +	bool has_ddc_parent_clk;
> +	bool has_reset_control;
> +
> +	u32 pad_ctrl0_init_val;
> +	u32 pad_ctrl1_init_val;
> +	u32 pll_ctrl_init_val;
> +};
> +
> +#define SUN4I_HDMI_PAD_CTRL1_MASK	(GENMASK(24, 7) | GENMASK(5, 0))
> +#define SUN4I_HDMI_PLL_CTRL_MASK	(GENMASK(31, 8) | GENMASK(3, 0))
> +
> +static const struct sun4i_hdmi_variant sun5i_variant = {
> +	.connector_helpers	= &sun4i_hdmi_connector_helper_funcs,
> +	.ddc_create		= sun4i_ddc_create,
> +	.tmds_create		= sun4i_tmds_create,

If we store the variants info for those clocks in that structure, we
don't need those functions anymore. This would be cleaner imho.

> +	.has_ddc_parent_clk	= false,
> +	.has_reset_control	= false,

Those two are the default values


Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

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

  reply	other threads:[~2017-06-02 19:38 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-02 10:10 [PATCH 00/19] drm/sun4i: hdmi: Support HDMI controller on A31 Chen-Yu Tsai
2017-06-02 10:10 ` [PATCH 02/19] drm/sun4i: add components in two passes with encoders added in second pass Chen-Yu Tsai
2017-06-02 19:18   ` Maxime Ripard
2017-06-02 10:10 ` [PATCH 07/19] drm/sun4i: hdmi: Support different variants of the TMDS clock Chen-Yu Tsai
     [not found] ` <20170602101024.18940-1-wens-jdAy2FN1RRM@public.gmane.org>
2017-06-02 10:10   ` [PATCH 01/19] drm/sun4i: call drm_vblank_init with correct number of crtcs Chen-Yu Tsai
2017-06-02 10:10   ` [PATCH 03/19] drm/sun4i: tcon: Add support for demuxing TCON output on A31 Chen-Yu Tsai
2017-06-02 10:10   ` [PATCH 04/19] drm/sun4i: hdmi: Disable clks in bind function error path and unbind function Chen-Yu Tsai
2017-06-02 10:10   ` [PATCH 05/19] drm/sun4i: hdmi: Allow using second PLL as TMDS clk parent Chen-Yu Tsai
2017-06-02 10:10   ` [PATCH 06/19] dt-bindings: display: sun4i: Add binding for A31 HDMI controller Chen-Yu Tsai
     [not found]     ` <20170602101024.18940-7-wens-jdAy2FN1RRM@public.gmane.org>
2017-06-07 22:37       ` Rob Herring
2017-06-02 10:10   ` [PATCH 08/19] drm/sun4i: hdmi: Support the TMDS clock in the A31's " Chen-Yu Tsai
2017-06-02 10:10   ` [PATCH 09/19] drm/sun4i: hdmi: Support different variants of the DDC clock Chen-Yu Tsai
2017-06-02 10:10   ` [PATCH 10/19] drm/sun4i: hdmi: Rename internal DDC clock to avoid name collision Chen-Yu Tsai
2017-06-02 19:30     ` Maxime Ripard
2017-06-03 14:33       ` Chen-Yu Tsai
     [not found]         ` <CAGb2v64Vgdjm1MAwn+L0PVc0CA0QOCn=0RONKoGDWLpzVBzvmQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-06-05 14:00           ` Maxime Ripard
     [not found]             ` <20170605140012.rlx7rm7xhriwqaza-ZC1Zs529Oq4@public.gmane.org>
2017-06-23  9:37               ` Chen-Yu Tsai
2017-06-02 10:10   ` [PATCH 11/19] drm/sun4i: hdmi: Add A31 specific DDC register definitions Chen-Yu Tsai
2017-06-02 10:10   ` [PATCH 12/19] drm/sun4i: hdmi: Support the DDC clock in the A31's HDMI controller Chen-Yu Tsai
     [not found]     ` <20170602101024.18940-13-wens-jdAy2FN1RRM@public.gmane.org>
2017-06-02 19:31       ` Maxime Ripard
2017-06-02 10:10   ` [PATCH 13/19] drm/sun4i: hdmi: Add support for controller hardware variants Chen-Yu Tsai
2017-06-02 19:38     ` Maxime Ripard [this message]
     [not found]       ` <20170602193827.rnjum6x5ra4x5wef-ZC1Zs529Oq4@public.gmane.org>
2017-06-03 14:58         ` Chen-Yu Tsai
2017-06-02 10:10   ` [PATCH 14/19] drm/sun4i: hdmi: Add support for A31's HDMI controller Chen-Yu Tsai
2017-06-02 19:41     ` Maxime Ripard
2017-06-03 15:19       ` Chen-Yu Tsai
     [not found]         ` <CAGb2v65eFAmAybmHkQcKjF+ZKxh+_G6q9i2GPzMs5854X8bQug-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-06-06 19:27           ` Maxime Ripard
2017-06-02 10:10   ` [PATCH 15/19] clk: sunxi-ng: sun6i: Export video PLLs Chen-Yu Tsai
2017-06-02 10:10   ` [PATCH 16/19] ARM: sun6i: a31: Add device node for HDMI controller Chen-Yu Tsai
2017-06-02 10:10   ` [PATCH 17/19] ARM: sun6i: a31: Enable HDMI support on the A31 Hummingbird Chen-Yu Tsai
2017-06-02 10:10   ` [PATCH 18/19] ARM: sun6i: a31s: Enable HDMI display output on the Sinlinx SinA31s Chen-Yu Tsai
2017-06-02 10:10   ` [PATCH 19/19] ARM: sun6i: a31s: Enable HDMI display output on the MSI Primo81 tablet Chen-Yu Tsai
     [not found]     ` <20170602101024.18940-20-wens-jdAy2FN1RRM@public.gmane.org>
2017-06-02 19:42       ` Maxime Ripard
     [not found]         ` <20170602194219.hiajr7dt2oikm52q-ZC1Zs529Oq4@public.gmane.org>
2017-06-03 15:31           ` Chen-Yu Tsai
2017-06-07 22:36           ` Rob Herring
2017-06-07 22:47             ` Ilia Mirkin
     [not found]               ` <CAKb7UvgKhgCpeNzUX1ecFPuF6j+KvAWW3vprZ9nnVMBBJFi_zQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-06-09 16:08                 ` Chen-Yu Tsai
2017-06-09 16:49                   ` Rob Herring

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=20170602193827.rnjum6x5ra4x5wef@flea.lan \
    --to=maxime.ripard@free-electrons.com \
    --cc=airlied@linux.ie \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-sunxi@googlegroups.com \
    --cc=mturquette@baylibre.com \
    --cc=robh+dt@kernel.org \
    --cc=sboyd@codeaurora.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;
as well as URLs for NNTP newsgroup(s).