diff mbox series

drm/bridge: cdns-dsi: Add support for pre_enable and post_enable control functions.

Message ID 20220411140606.15654-1-jpawar@cadence.com (mailing list archive)
State New, archived
Headers show
Series drm/bridge: cdns-dsi: Add support for pre_enable and post_enable control functions. | expand

Commit Message

Jayshri Pawar April 11, 2022, 2:06 p.m. UTC
From: jpawar <jpawar@cadence.com>

Add support for pre_enable and post_enable drm bridge control functions.
Making sure that host to be prepared before panel is powered up,
for the panels like TC358762.

Signed-off-by: jpawar <jpawar@cadence.com>
---
 drivers/gpu/drm/bridge/cdns-dsi.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

Comments

Robert Foss May 11, 2022, 12:30 p.m. UTC | #1
On Mon, 11 Apr 2022 at 16:07, Jayshri Pawar <jpawar@cadence.com> wrote:
>
> From: jpawar <jpawar@cadence.com>

This should be "Jayshri Pawar <jpawar@cadence.com>"

>
> Add support for pre_enable and post_enable drm bridge control functions.
> Making sure that host to be prepared before panel is powered up,
> for the panels like TC358762.
>
> Signed-off-by: jpawar <jpawar@cadence.com>

Again, your full name should be used.

> ---
>  drivers/gpu/drm/bridge/cdns-dsi.c | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
>
> diff --git a/drivers/gpu/drm/bridge/cdns-dsi.c b/drivers/gpu/drm/bridge/cdns-dsi.c
> index 829e1a144656..20bece84ff8c 100644
> --- a/drivers/gpu/drm/bridge/cdns-dsi.c
> +++ b/drivers/gpu/drm/bridge/cdns-dsi.c
> @@ -462,6 +462,7 @@ struct cdns_dsi {
>         struct reset_control *dsi_p_rst;
>         struct clk *dsi_sys_clk;
>         bool link_initialized;
> +       bool phy_initialized;
>         struct phy *dphy;
>  };
>
> @@ -711,11 +712,21 @@ static void cdns_dsi_bridge_disable(struct drm_bridge *bridge)
>         pm_runtime_put(dsi->base.dev);
>  }
>
> +static void cdns_dsi_bridge_post_disable(struct drm_bridge *bridge)
> +{
> +       struct cdns_dsi_input *input = bridge_to_cdns_dsi_input(bridge);
> +       struct cdns_dsi *dsi = input_to_dsi(input);
> +
> +       pm_runtime_put(dsi->base.dev);
> +}
> +
>  static void cdns_dsi_hs_init(struct cdns_dsi *dsi)
>  {
>         struct cdns_dsi_output *output = &dsi->output;
>         u32 status;
>
> +       if (dsi->phy_initialized)
> +               return;
>         /*
>          * Power all internal DPHY blocks down and maintain their reset line
>          * asserted before changing the DPHY config.
> @@ -739,6 +750,7 @@ static void cdns_dsi_hs_init(struct cdns_dsi *dsi)
>         writel(DPHY_CMN_PSO | DPHY_ALL_D_PDN | DPHY_C_PDN | DPHY_CMN_PDN |
>                DPHY_D_RSTB(output->dev->lanes) | DPHY_C_RSTB,
>                dsi->regs + MCTL_DPHY_CFG0);
> +       dsi->phy_initialized = true;
>  }
>
>  static void cdns_dsi_init_link(struct cdns_dsi *dsi)
> @@ -914,11 +926,25 @@ static void cdns_dsi_bridge_enable(struct drm_bridge *bridge)
>         writel(tmp, dsi->regs + MCTL_MAIN_EN);
>  }
>
> +static void cdns_dsi_bridge_pre_enable(struct drm_bridge *bridge)
> +{
> +       struct cdns_dsi_input *input = bridge_to_cdns_dsi_input(bridge);
> +       struct cdns_dsi *dsi = input_to_dsi(input);
> +
> +       if (WARN_ON(pm_runtime_get_sync(dsi->base.dev) < 0))
> +               return;
> +
> +       cdns_dsi_init_link(dsi);
> +       cdns_dsi_hs_init(dsi);
> +}
> +
>  static const struct drm_bridge_funcs cdns_dsi_bridge_funcs = {
>         .attach = cdns_dsi_bridge_attach,
>         .mode_valid = cdns_dsi_bridge_mode_valid,
>         .disable = cdns_dsi_bridge_disable,
> +       .pre_enable = cdns_dsi_bridge_pre_enable,
>         .enable = cdns_dsi_bridge_enable,
> +       .post_disable = cdns_dsi_bridge_post_disable,
>  };
>
>  static int cdns_dsi_attach(struct mipi_dsi_host *host,

Cadence seems to have DKIM mail server failure, which is preventing b4
from importing this patch. Log attached below.

I've manually fixed this author string issues.

Reviewed-by: Robert Foss <robert.foss@linaro.org>

Applied to drm-misc-next.


----

Checking attestation on all messages, may take a moment...
Traceback (most recent call last):
  File "/usr/bin/b4", line 33, in <module>
    sys.exit(load_entry_point('b4==0.8.0', 'console_scripts', 'b4')())
  File "/usr/lib/python3/dist-packages/b4/command.py", line 246, in cmd
    cmdargs.func(cmdargs)
  File "/usr/lib/python3/dist-packages/b4/command.py", line 51, in cmd_am
    b4.mbox.main(cmdargs)
  File "/usr/lib/python3/dist-packages/b4/mbox.py", line 593, in main
    make_am(msgs, cmdargs, msgid)
  File "/usr/lib/python3/dist-packages/b4/mbox.py", line 92, in make_am
    am_msgs = lser.get_am_ready(noaddtrailers=cmdargs.noaddtrailers,
  File "/usr/lib/python3/dist-packages/b4/__init__.py", line 523, in
get_am_ready
    checkmark, trailers, attcrit =
lmsg.get_attestation_trailers(attpolicy, maxdays)
  File "/usr/lib/python3/dist-packages/b4/__init__.py", line 1173, in
get_attestation_trailers
    for attestor in self.attestors:
  File "/usr/lib/python3/dist-packages/b4/__init__.py", line 1028, in attestors
    self._load_dkim_attestors()
  File "/usr/lib/python3/dist-packages/b4/__init__.py", line 1071, in
_load_dkim_attestors
    res = dkim.verify(self.msg.as_bytes(), logger=dkimlogger)
  File "/usr/lib/python3/dist-packages/dkim/__init__.py", line 1352, in verify
    return d.verify(dnsfunc=dnsfunc)
  File "/usr/lib/python3/dist-packages/dkim/__init__.py", line 940, in verify
    return self.verify_sig(sig, include_headers, sigheaders[idx], dnsfunc)
  File "/usr/lib/python3/dist-packages/dkim/__init__.py", line 773, in
verify_sig
    self.pk, self.keysize, self.ktag, self.seqtlsrpt = load_pk_from_dns(name,
  File "/usr/lib/python3/dist-packages/dkim/__init__.py", line 481, in
load_pk_from_dns
    s = dnsfunc(name, timeout=timeout)
  File "/usr/lib/python3/dist-packages/dkim/dnsplug.py", line 88, in get_txt
    txt = _get_txt(unicode_name, timeout)
  File "/usr/lib/python3/dist-packages/dkim/dnsplug.py", line 31, in
get_txt_dnspython
    a = dns.resolver.query(name,
dns.rdatatype.TXT,raise_on_no_answer=False, lifetime=timeout)
  File "/usr/lib/python3/dist-packages/dns/resolver.py", line 1321, in query
    return resolve(qname, rdtype, rdclass, tcp, source,
  File "/usr/lib/python3/dist-packages/dns/resolver.py", line 1305, in resolve
    return get_default_resolver().resolve(qname, rdtype, rdclass, tcp, source,
  File "/usr/lib/python3/dist-packages/dns/resolver.py", line 1176, in resolve
    timeout = self._compute_timeout(start, lifetime)
  File "/usr/lib/python3/dist-packages/dns/resolver.py", line 997, in
_compute_timeout
    raise Timeout(timeout=duration)
dns.exception.Timeout: The DNS operation timed out after
5.402302026748657 seconds
Laurent Pinchart May 11, 2022, 3:01 p.m. UTC | #2
Hi Jayshri,

Thank you for the patch.

On Mon, Apr 11, 2022 at 04:06:06PM +0200, Jayshri Pawar wrote:
> From: jpawar <jpawar@cadence.com>
> 
> Add support for pre_enable and post_enable drm bridge control functions.
> Making sure that host to be prepared before panel is powered up,
> for the panels like TC358762.
> 
> Signed-off-by: jpawar <jpawar@cadence.com>
> ---
>  drivers/gpu/drm/bridge/cdns-dsi.c | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/drivers/gpu/drm/bridge/cdns-dsi.c b/drivers/gpu/drm/bridge/cdns-dsi.c
> index 829e1a144656..20bece84ff8c 100644
> --- a/drivers/gpu/drm/bridge/cdns-dsi.c
> +++ b/drivers/gpu/drm/bridge/cdns-dsi.c
> @@ -462,6 +462,7 @@ struct cdns_dsi {
>  	struct reset_control *dsi_p_rst;
>  	struct clk *dsi_sys_clk;
>  	bool link_initialized;
> +	bool phy_initialized;
>  	struct phy *dphy;
>  };
>  
> @@ -711,11 +712,21 @@ static void cdns_dsi_bridge_disable(struct drm_bridge *bridge)
>  	pm_runtime_put(dsi->base.dev);
>  }
>  
> +static void cdns_dsi_bridge_post_disable(struct drm_bridge *bridge)
> +{
> +	struct cdns_dsi_input *input = bridge_to_cdns_dsi_input(bridge);
> +	struct cdns_dsi *dsi = input_to_dsi(input);
> +
> +	pm_runtime_put(dsi->base.dev);
> +}
> +
>  static void cdns_dsi_hs_init(struct cdns_dsi *dsi)
>  {
>  	struct cdns_dsi_output *output = &dsi->output;
>  	u32 status;
>  
> +	if (dsi->phy_initialized)
> +		return;
>  	/*
>  	 * Power all internal DPHY blocks down and maintain their reset line
>  	 * asserted before changing the DPHY config.
> @@ -739,6 +750,7 @@ static void cdns_dsi_hs_init(struct cdns_dsi *dsi)
>  	writel(DPHY_CMN_PSO | DPHY_ALL_D_PDN | DPHY_C_PDN | DPHY_CMN_PDN |
>  	       DPHY_D_RSTB(output->dev->lanes) | DPHY_C_RSTB,
>  	       dsi->regs + MCTL_DPHY_CFG0);
> +	dsi->phy_initialized = true;
>  }
>  
>  static void cdns_dsi_init_link(struct cdns_dsi *dsi)
> @@ -914,11 +926,25 @@ static void cdns_dsi_bridge_enable(struct drm_bridge *bridge)
>  	writel(tmp, dsi->regs + MCTL_MAIN_EN);
>  }
>  
> +static void cdns_dsi_bridge_pre_enable(struct drm_bridge *bridge)
> +{
> +	struct cdns_dsi_input *input = bridge_to_cdns_dsi_input(bridge);
> +	struct cdns_dsi *dsi = input_to_dsi(input);
> +
> +	if (WARN_ON(pm_runtime_get_sync(dsi->base.dev) < 0))

This should use pm_runtime_resume_and_get(), otherwise you need to call
pm_runtime_put_noidle() on failure.

> +		return;
> +
> +	cdns_dsi_init_link(dsi);
> +	cdns_dsi_hs_init(dsi);
> +}
> +
>  static const struct drm_bridge_funcs cdns_dsi_bridge_funcs = {
>  	.attach = cdns_dsi_bridge_attach,
>  	.mode_valid = cdns_dsi_bridge_mode_valid,
>  	.disable = cdns_dsi_bridge_disable,
> +	.pre_enable = cdns_dsi_bridge_pre_enable,
>  	.enable = cdns_dsi_bridge_enable,
> +	.post_disable = cdns_dsi_bridge_post_disable,
>  };
>  
>  static int cdns_dsi_attach(struct mipi_dsi_host *host,
diff mbox series

Patch

diff --git a/drivers/gpu/drm/bridge/cdns-dsi.c b/drivers/gpu/drm/bridge/cdns-dsi.c
index 829e1a144656..20bece84ff8c 100644
--- a/drivers/gpu/drm/bridge/cdns-dsi.c
+++ b/drivers/gpu/drm/bridge/cdns-dsi.c
@@ -462,6 +462,7 @@  struct cdns_dsi {
 	struct reset_control *dsi_p_rst;
 	struct clk *dsi_sys_clk;
 	bool link_initialized;
+	bool phy_initialized;
 	struct phy *dphy;
 };
 
@@ -711,11 +712,21 @@  static void cdns_dsi_bridge_disable(struct drm_bridge *bridge)
 	pm_runtime_put(dsi->base.dev);
 }
 
+static void cdns_dsi_bridge_post_disable(struct drm_bridge *bridge)
+{
+	struct cdns_dsi_input *input = bridge_to_cdns_dsi_input(bridge);
+	struct cdns_dsi *dsi = input_to_dsi(input);
+
+	pm_runtime_put(dsi->base.dev);
+}
+
 static void cdns_dsi_hs_init(struct cdns_dsi *dsi)
 {
 	struct cdns_dsi_output *output = &dsi->output;
 	u32 status;
 
+	if (dsi->phy_initialized)
+		return;
 	/*
 	 * Power all internal DPHY blocks down and maintain their reset line
 	 * asserted before changing the DPHY config.
@@ -739,6 +750,7 @@  static void cdns_dsi_hs_init(struct cdns_dsi *dsi)
 	writel(DPHY_CMN_PSO | DPHY_ALL_D_PDN | DPHY_C_PDN | DPHY_CMN_PDN |
 	       DPHY_D_RSTB(output->dev->lanes) | DPHY_C_RSTB,
 	       dsi->regs + MCTL_DPHY_CFG0);
+	dsi->phy_initialized = true;
 }
 
 static void cdns_dsi_init_link(struct cdns_dsi *dsi)
@@ -914,11 +926,25 @@  static void cdns_dsi_bridge_enable(struct drm_bridge *bridge)
 	writel(tmp, dsi->regs + MCTL_MAIN_EN);
 }
 
+static void cdns_dsi_bridge_pre_enable(struct drm_bridge *bridge)
+{
+	struct cdns_dsi_input *input = bridge_to_cdns_dsi_input(bridge);
+	struct cdns_dsi *dsi = input_to_dsi(input);
+
+	if (WARN_ON(pm_runtime_get_sync(dsi->base.dev) < 0))
+		return;
+
+	cdns_dsi_init_link(dsi);
+	cdns_dsi_hs_init(dsi);
+}
+
 static const struct drm_bridge_funcs cdns_dsi_bridge_funcs = {
 	.attach = cdns_dsi_bridge_attach,
 	.mode_valid = cdns_dsi_bridge_mode_valid,
 	.disable = cdns_dsi_bridge_disable,
+	.pre_enable = cdns_dsi_bridge_pre_enable,
 	.enable = cdns_dsi_bridge_enable,
+	.post_disable = cdns_dsi_bridge_post_disable,
 };
 
 static int cdns_dsi_attach(struct mipi_dsi_host *host,