diff mbox series

[1/1] firmware: imx: scu-pd: do not power off console domain

Message ID 1573995924-14752-1-git-send-email-aisheng.dong@nxp.com (mailing list archive)
State Not Applicable, archived
Headers show
Series [1/1] firmware: imx: scu-pd: do not power off console domain | expand

Commit Message

Aisheng Dong Nov. 17, 2019, 1:05 p.m. UTC
Do not power off console domain in runtime pm.

Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
---
 drivers/firmware/imx/scu-pd.c | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

Comments

Ulf Hansson Nov. 18, 2019, 4:13 p.m. UTC | #1
On Sun, 17 Nov 2019 at 14:07, Dong Aisheng <aisheng.dong@nxp.com> wrote:
>
> Do not power off console domain in runtime pm.

Would it be possible to configure a remote wakeup for the console
while the device becomes runtime suspended, rather than preventing the
power off altogether?

Kind regards
Uffe

>
> Cc: Shawn Guo <shawnguo@kernel.org>
> Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
> Cc: Ulf Hansson <ulf.hansson@linaro.org>
> Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> ---
>  drivers/firmware/imx/scu-pd.c | 28 +++++++++++++++++++++++++++-
>  1 file changed, 27 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/firmware/imx/scu-pd.c b/drivers/firmware/imx/scu-pd.c
> index b556612207e5..770e3681bbbf 100644
> --- a/drivers/firmware/imx/scu-pd.c
> +++ b/drivers/firmware/imx/scu-pd.c
> @@ -85,6 +85,8 @@ struct imx_sc_pd_soc {
>         u8 num_ranges;
>  };
>
> +int imx_con_rsrc;
> +
>  static const struct imx_sc_pd_range imx8qxp_scu_pd_ranges[] = {
>         /* LSIO SS */
>         { "pwm", IMX_SC_R_PWM_0, 8, true, 0 },
> @@ -173,6 +175,23 @@ to_imx_sc_pd(struct generic_pm_domain *genpd)
>         return container_of(genpd, struct imx_sc_pm_domain, pd);
>  }
>
> +static void imx_sc_pd_get_console_rsrc(void)
> +{
> +       struct of_phandle_args specs;
> +       int ret;
> +
> +       if (!of_stdout)
> +               return;
> +
> +       ret = of_parse_phandle_with_args(of_stdout, "power-domains",
> +                                        "#power-domain-cells",
> +                                        0, &specs);
> +       if (ret)
> +               return;
> +
> +       imx_con_rsrc = specs.args[0];
> +}
> +
>  static int imx_sc_pd_power(struct generic_pm_domain *domain, bool power_on)
>  {
>         struct imx_sc_msg_req_set_resource_power_mode msg;
> @@ -233,6 +252,7 @@ imx_scu_add_pm_domain(struct device *dev, int idx,
>                       const struct imx_sc_pd_range *pd_ranges)
>  {
>         struct imx_sc_pm_domain *sc_pd;
> +       bool is_off = true;
>         int ret;
>
>         sc_pd = devm_kzalloc(dev, sizeof(*sc_pd), GFP_KERNEL);
> @@ -251,6 +271,10 @@ imx_scu_add_pm_domain(struct device *dev, int idx,
>                          "%s", pd_ranges->name);
>
>         sc_pd->pd.name = sc_pd->name;
> +       if (imx_con_rsrc == sc_pd->rsrc) {
> +               sc_pd->pd.flags = GENPD_FLAG_RPM_ALWAYS_ON;
> +               is_off = false;
> +       }
>
>         if (sc_pd->rsrc >= IMX_SC_R_LAST) {
>                 dev_warn(dev, "invalid pd %s rsrc id %d found",
> @@ -260,7 +284,7 @@ imx_scu_add_pm_domain(struct device *dev, int idx,
>                 return NULL;
>         }
>
> -       ret = pm_genpd_init(&sc_pd->pd, NULL, true);
> +       ret = pm_genpd_init(&sc_pd->pd, NULL, is_off);
>         if (ret) {
>                 dev_warn(dev, "failed to init pd %s rsrc id %d",
>                          sc_pd->name, sc_pd->rsrc);
> @@ -326,6 +350,8 @@ static int imx_sc_pd_probe(struct platform_device *pdev)
>         if (!pd_soc)
>                 return -ENODEV;
>
> +       imx_sc_pd_get_console_rsrc();
> +
>         return imx_scu_init_pm_domains(&pdev->dev, pd_soc);
>  }
>
> --
> 2.23.0
>
Dong Aisheng Jan. 2, 2020, 10:03 a.m. UTC | #2
On Tue, Nov 19, 2019 at 12:13 AM Ulf Hansson <ulf.hansson@linaro.org> wrote:
>
> On Sun, 17 Nov 2019 at 14:07, Dong Aisheng <aisheng.dong@nxp.com> wrote:
> >
> > Do not power off console domain in runtime pm.
>
> Would it be possible to configure a remote wakeup for the console
> while the device becomes runtime suspended, rather than preventing the
> power off altogether?
>

Remote wakeup usually requires clock and power.
Not sure if this device can support it. Copy module owner (Fugang
Duan) to confirm.

The current lpuart driver seems not support.

Regards
Aisheng

> Kind regards
> Uffe
>
> >
> > Cc: Shawn Guo <shawnguo@kernel.org>
> > Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
> > Cc: Ulf Hansson <ulf.hansson@linaro.org>
> > Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> > ---
> >  drivers/firmware/imx/scu-pd.c | 28 +++++++++++++++++++++++++++-
> >  1 file changed, 27 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/firmware/imx/scu-pd.c b/drivers/firmware/imx/scu-pd.c
> > index b556612207e5..770e3681bbbf 100644
> > --- a/drivers/firmware/imx/scu-pd.c
> > +++ b/drivers/firmware/imx/scu-pd.c
> > @@ -85,6 +85,8 @@ struct imx_sc_pd_soc {
> >         u8 num_ranges;
> >  };
> >
> > +int imx_con_rsrc;
> > +
> >  static const struct imx_sc_pd_range imx8qxp_scu_pd_ranges[] = {
> >         /* LSIO SS */
> >         { "pwm", IMX_SC_R_PWM_0, 8, true, 0 },
> > @@ -173,6 +175,23 @@ to_imx_sc_pd(struct generic_pm_domain *genpd)
> >         return container_of(genpd, struct imx_sc_pm_domain, pd);
> >  }
> >
> > +static void imx_sc_pd_get_console_rsrc(void)
> > +{
> > +       struct of_phandle_args specs;
> > +       int ret;
> > +
> > +       if (!of_stdout)
> > +               return;
> > +
> > +       ret = of_parse_phandle_with_args(of_stdout, "power-domains",
> > +                                        "#power-domain-cells",
> > +                                        0, &specs);
> > +       if (ret)
> > +               return;
> > +
> > +       imx_con_rsrc = specs.args[0];
> > +}
> > +
> >  static int imx_sc_pd_power(struct generic_pm_domain *domain, bool power_on)
> >  {
> >         struct imx_sc_msg_req_set_resource_power_mode msg;
> > @@ -233,6 +252,7 @@ imx_scu_add_pm_domain(struct device *dev, int idx,
> >                       const struct imx_sc_pd_range *pd_ranges)
> >  {
> >         struct imx_sc_pm_domain *sc_pd;
> > +       bool is_off = true;
> >         int ret;
> >
> >         sc_pd = devm_kzalloc(dev, sizeof(*sc_pd), GFP_KERNEL);
> > @@ -251,6 +271,10 @@ imx_scu_add_pm_domain(struct device *dev, int idx,
> >                          "%s", pd_ranges->name);
> >
> >         sc_pd->pd.name = sc_pd->name;
> > +       if (imx_con_rsrc == sc_pd->rsrc) {
> > +               sc_pd->pd.flags = GENPD_FLAG_RPM_ALWAYS_ON;
> > +               is_off = false;
> > +       }
> >
> >         if (sc_pd->rsrc >= IMX_SC_R_LAST) {
> >                 dev_warn(dev, "invalid pd %s rsrc id %d found",
> > @@ -260,7 +284,7 @@ imx_scu_add_pm_domain(struct device *dev, int idx,
> >                 return NULL;
> >         }
> >
> > -       ret = pm_genpd_init(&sc_pd->pd, NULL, true);
> > +       ret = pm_genpd_init(&sc_pd->pd, NULL, is_off);
> >         if (ret) {
> >                 dev_warn(dev, "failed to init pd %s rsrc id %d",
> >                          sc_pd->name, sc_pd->rsrc);
> > @@ -326,6 +350,8 @@ static int imx_sc_pd_probe(struct platform_device *pdev)
> >         if (!pd_soc)
> >                 return -ENODEV;
> >
> > +       imx_sc_pd_get_console_rsrc();
> > +
> >         return imx_scu_init_pm_domains(&pdev->dev, pd_soc);
> >  }
> >
> > --
> > 2.23.0
> >
Andy Duan Jan. 2, 2020, 10:23 a.m. UTC | #3
From: Dong Aisheng <dongas86@gmail.com> Sent: Thursday, January 2, 2020 6:03 PM
> On Tue, Nov 19, 2019 at 12:13 AM Ulf Hansson <ulf.hansson@linaro.org>
> wrote:
> >
> > On Sun, 17 Nov 2019 at 14:07, Dong Aisheng <aisheng.dong@nxp.com>
> wrote:
> > >
> > > Do not power off console domain in runtime pm.
> >
> > Would it be possible to configure a remote wakeup for the console
> > while the device becomes runtime suspended, rather than preventing the
> > power off altogether?

From HW view, the wakeup features requires power on, but clocks can be off.

In fact, the standard flow is power domain driver should not power off the devices
that enable the wakeup feature.

NXP internal tree already supported runtime pm. I will upstream the patch.

Andy
> >
> 
> Remote wakeup usually requires clock and power.
> Not sure if this device can support it. Copy module owner (Fugang
> Duan) to confirm.
> 
> The current lpuart driver seems not support.
> 
> Regards
> Aisheng
> 
> > Kind regards
> > Uffe
> >
> > >
> > > Cc: Shawn Guo <shawnguo@kernel.org>
> > > Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
> > > Cc: Ulf Hansson <ulf.hansson@linaro.org>
> > > Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> > > ---
> > >  drivers/firmware/imx/scu-pd.c | 28 +++++++++++++++++++++++++++-
> > >  1 file changed, 27 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/firmware/imx/scu-pd.c
> > > b/drivers/firmware/imx/scu-pd.c index b556612207e5..770e3681bbbf
> > > 100644
> > > --- a/drivers/firmware/imx/scu-pd.c
> > > +++ b/drivers/firmware/imx/scu-pd.c
> > > @@ -85,6 +85,8 @@ struct imx_sc_pd_soc {
> > >         u8 num_ranges;
> > >  };
> > >
> > > +int imx_con_rsrc;
> > > +
> > >  static const struct imx_sc_pd_range imx8qxp_scu_pd_ranges[] = {
> > >         /* LSIO SS */
> > >         { "pwm", IMX_SC_R_PWM_0, 8, true, 0 }, @@ -173,6 +175,23
> @@
> > > to_imx_sc_pd(struct generic_pm_domain *genpd)
> > >         return container_of(genpd, struct imx_sc_pm_domain, pd);  }
> > >
> > > +static void imx_sc_pd_get_console_rsrc(void) {
> > > +       struct of_phandle_args specs;
> > > +       int ret;
> > > +
> > > +       if (!of_stdout)
> > > +               return;
> > > +
> > > +       ret = of_parse_phandle_with_args(of_stdout, "power-domains",
> > > +
> "#power-domain-cells",
> > > +                                        0, &specs);
> > > +       if (ret)
> > > +               return;
> > > +
> > > +       imx_con_rsrc = specs.args[0]; }
> > > +
> > >  static int imx_sc_pd_power(struct generic_pm_domain *domain, bool
> > > power_on)  {
> > >         struct imx_sc_msg_req_set_resource_power_mode msg; @@
> -233,6
> > > +252,7 @@ imx_scu_add_pm_domain(struct device *dev, int idx,
> > >                       const struct imx_sc_pd_range *pd_ranges)  {
> > >         struct imx_sc_pm_domain *sc_pd;
> > > +       bool is_off = true;
> > >         int ret;
> > >
> > >         sc_pd = devm_kzalloc(dev, sizeof(*sc_pd), GFP_KERNEL); @@
> > > -251,6 +271,10 @@ imx_scu_add_pm_domain(struct device *dev, int idx,
> > >                          "%s", pd_ranges->name);
> > >
> > >         sc_pd->pd.name = sc_pd->name;
> > > +       if (imx_con_rsrc == sc_pd->rsrc) {
> > > +               sc_pd->pd.flags = GENPD_FLAG_RPM_ALWAYS_ON;
> > > +               is_off = false;
> > > +       }
> > >
> > >         if (sc_pd->rsrc >= IMX_SC_R_LAST) {
> > >                 dev_warn(dev, "invalid pd %s rsrc id %d found", @@
> > > -260,7 +284,7 @@ imx_scu_add_pm_domain(struct device *dev, int idx,
> > >                 return NULL;
> > >         }
> > >
> > > -       ret = pm_genpd_init(&sc_pd->pd, NULL, true);
> > > +       ret = pm_genpd_init(&sc_pd->pd, NULL, is_off);
> > >         if (ret) {
> > >                 dev_warn(dev, "failed to init pd %s rsrc id %d",
> > >                          sc_pd->name, sc_pd->rsrc); @@ -326,6
> +350,8
> > > @@ static int imx_sc_pd_probe(struct platform_device *pdev)
> > >         if (!pd_soc)
> > >                 return -ENODEV;
> > >
> > > +       imx_sc_pd_get_console_rsrc();
> > > +
> > >         return imx_scu_init_pm_domains(&pdev->dev, pd_soc);  }
> > >
> > > --
> > > 2.23.0
> > >
diff mbox series

Patch

diff --git a/drivers/firmware/imx/scu-pd.c b/drivers/firmware/imx/scu-pd.c
index b556612207e5..770e3681bbbf 100644
--- a/drivers/firmware/imx/scu-pd.c
+++ b/drivers/firmware/imx/scu-pd.c
@@ -85,6 +85,8 @@  struct imx_sc_pd_soc {
 	u8 num_ranges;
 };
 
+int imx_con_rsrc;
+
 static const struct imx_sc_pd_range imx8qxp_scu_pd_ranges[] = {
 	/* LSIO SS */
 	{ "pwm", IMX_SC_R_PWM_0, 8, true, 0 },
@@ -173,6 +175,23 @@  to_imx_sc_pd(struct generic_pm_domain *genpd)
 	return container_of(genpd, struct imx_sc_pm_domain, pd);
 }
 
+static void imx_sc_pd_get_console_rsrc(void)
+{
+	struct of_phandle_args specs;
+	int ret;
+
+	if (!of_stdout)
+		return;
+
+	ret = of_parse_phandle_with_args(of_stdout, "power-domains",
+					 "#power-domain-cells",
+					 0, &specs);
+	if (ret)
+		return;
+
+	imx_con_rsrc = specs.args[0];
+}
+
 static int imx_sc_pd_power(struct generic_pm_domain *domain, bool power_on)
 {
 	struct imx_sc_msg_req_set_resource_power_mode msg;
@@ -233,6 +252,7 @@  imx_scu_add_pm_domain(struct device *dev, int idx,
 		      const struct imx_sc_pd_range *pd_ranges)
 {
 	struct imx_sc_pm_domain *sc_pd;
+	bool is_off = true;
 	int ret;
 
 	sc_pd = devm_kzalloc(dev, sizeof(*sc_pd), GFP_KERNEL);
@@ -251,6 +271,10 @@  imx_scu_add_pm_domain(struct device *dev, int idx,
 			 "%s", pd_ranges->name);
 
 	sc_pd->pd.name = sc_pd->name;
+	if (imx_con_rsrc == sc_pd->rsrc) {
+		sc_pd->pd.flags = GENPD_FLAG_RPM_ALWAYS_ON;
+		is_off = false;
+	}
 
 	if (sc_pd->rsrc >= IMX_SC_R_LAST) {
 		dev_warn(dev, "invalid pd %s rsrc id %d found",
@@ -260,7 +284,7 @@  imx_scu_add_pm_domain(struct device *dev, int idx,
 		return NULL;
 	}
 
-	ret = pm_genpd_init(&sc_pd->pd, NULL, true);
+	ret = pm_genpd_init(&sc_pd->pd, NULL, is_off);
 	if (ret) {
 		dev_warn(dev, "failed to init pd %s rsrc id %d",
 			 sc_pd->name, sc_pd->rsrc);
@@ -326,6 +350,8 @@  static int imx_sc_pd_probe(struct platform_device *pdev)
 	if (!pd_soc)
 		return -ENODEV;
 
+	imx_sc_pd_get_console_rsrc();
+
 	return imx_scu_init_pm_domains(&pdev->dev, pd_soc);
 }