linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] pmdomain: core: Introduce device_set/get_out_band_wakeup
@ 2025-08-01  4:34 Peng Fan
  2025-08-01  4:34 ` [PATCH v2 1/3] pmdomain: core: Introduce device_set/get_out_band_wakeup() Peng Fan
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Peng Fan @ 2025-08-01  4:34 UTC (permalink / raw)
  To: Ulf Hansson, Rafael J. Wysocki, Len Brown, Pavel Machek,
	Peter Chen, Greg Kroah-Hartman, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Thinh Nguyen,
	Vincent Guittot, Xu Yang
  Cc: linux-pm, linux-kernel, linux-usb, imx, arm-scmi,
	linux-arm-kernel, Peng Fan

This is pick up of [1] which does not have response in about 5 months.
This V2 patchset
- includes usb driver changes(patch 2,3) to give people a full picture on how it is used.
- Rebased next-20250729 to resolve conflicts

To i.MX95, USB2 and USB3 are in HSIOMIX, but there is always on logic
to make USB2 and USB3 has wakeup capability when HSIOMIX power domain
is in off state. Otherwise the HSIOMIX will be kept on when
USB2 and USB3 are configured to be wakeup source and Linux suspended.
With this patchset, HSIOMIX could be powered off and Linux could still
be woke up by USB hotplug event.

Patch 1 introduces device_set/get_out_band_wakeup
Patch 2 and 3 are drivers changes to use device_set_out_band_wakeup

[1]https://lore.kernel.org/linux-pm/20250311083239.3336439-1-peng.fan@oss.nxp.com/

More old discussions:
https://lore.kernel.org/linux-pm/20250311083239.3336439-1-peng.fan@oss.nxp.com/

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
Peng Fan (3):
      pmdomain: core: Introduce device_set/get_out_band_wakeup()
      usb: chipidea: ci_hdrc_imx: Set out of band wakeup for i.MX95
      usb: dwc3: imx8mp: Set out of band wakeup for i.MX95

 drivers/pmdomain/core.c            |  6 ++++--
 drivers/usb/chipidea/ci_hdrc_imx.c |  8 ++++++++
 drivers/usb/dwc3/dwc3-imx8mp.c     |  4 ++++
 include/linux/pm.h                 |  1 +
 include/linux/pm_wakeup.h          | 17 +++++++++++++++++
 include/linux/usb/chipidea.h       |  1 +
 6 files changed, 35 insertions(+), 2 deletions(-)
---
base-commit: 54efec8782214652b331c50646013f8526570e8d
change-id: 20250729-pm-243ff7097e44

Best regards,
-- 
Peng Fan <peng.fan@nxp.com>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2 1/3] pmdomain: core: Introduce device_set/get_out_band_wakeup()
  2025-08-01  4:34 [PATCH v2 0/3] pmdomain: core: Introduce device_set/get_out_band_wakeup Peng Fan
@ 2025-08-01  4:34 ` Peng Fan
  2025-08-22  5:22   ` Peng Fan
  2025-08-01  4:34 ` [PATCH v2 2/3] usb: chipidea: ci_hdrc_imx: Set out of band wakeup for i.MX95 Peng Fan
  2025-08-01  4:34 ` [PATCH v2 3/3] usb: dwc3: imx8mp: " Peng Fan
  2 siblings, 1 reply; 9+ messages in thread
From: Peng Fan @ 2025-08-01  4:34 UTC (permalink / raw)
  To: Ulf Hansson, Rafael J. Wysocki, Len Brown, Pavel Machek,
	Peter Chen, Greg Kroah-Hartman, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Thinh Nguyen,
	Vincent Guittot, Xu Yang
  Cc: linux-pm, linux-kernel, linux-usb, imx, arm-scmi,
	linux-arm-kernel, Peng Fan

For some cases, a device could still wakeup the system even if its power
domain is in off state, because the device's wakeup hardware logic is
in an always-on domain.

To support this case, introduce device_set/get_out_band_wakeup() to
allow device drivers to control the behaviour in genpd for a device
that is attached to it.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/pmdomain/core.c   |  6 ++++--
 include/linux/pm.h        |  1 +
 include/linux/pm_wakeup.h | 17 +++++++++++++++++
 3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c
index 0006ab3d078972cc72a6dd22a2144fb31443e3da..8e37758cea88a9ee051ad9fb13bdd3feb4f8745e 100644
--- a/drivers/pmdomain/core.c
+++ b/drivers/pmdomain/core.c
@@ -1549,7 +1549,8 @@ static int genpd_finish_suspend(struct device *dev,
 	if (ret)
 		return ret;
 
-	if (device_awake_path(dev) && genpd_is_active_wakeup(genpd))
+	if (device_awake_path(dev) && genpd_is_active_wakeup(genpd) &&
+	    !device_get_out_band_wakeup(dev))
 		return 0;
 
 	if (genpd->dev_ops.stop && genpd->dev_ops.start &&
@@ -1604,7 +1605,8 @@ static int genpd_finish_resume(struct device *dev,
 	if (IS_ERR(genpd))
 		return -EINVAL;
 
-	if (device_awake_path(dev) && genpd_is_active_wakeup(genpd))
+	if (device_awake_path(dev) && genpd_is_active_wakeup(genpd) &&
+	    !device_get_out_band_wakeup(dev))
 		return resume_noirq(dev);
 
 	genpd_lock(genpd);
diff --git a/include/linux/pm.h b/include/linux/pm.h
index cc7b2dc28574c24ece2f651352d4d23ecaf15f31..5b28a4f2e87e2aa34acc709e146ce729acace344 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -684,6 +684,7 @@ struct dev_pm_info {
 	bool			smart_suspend:1;	/* Owned by the PM core */
 	bool			must_resume:1;		/* Owned by the PM core */
 	bool			may_skip_resume:1;	/* Set by subsystems */
+	bool			out_band_wakeup:1;
 	bool			strict_midlayer:1;
 #else
 	bool			should_wakeup:1;
diff --git a/include/linux/pm_wakeup.h b/include/linux/pm_wakeup.h
index c838b4a30f876ef5a66972d16f461cfba9ff2814..c461c7edef6f7927d696b7d18b59a6a1147f53a3 100644
--- a/include/linux/pm_wakeup.h
+++ b/include/linux/pm_wakeup.h
@@ -94,6 +94,16 @@ static inline void device_set_wakeup_path(struct device *dev)
 	dev->power.wakeup_path = true;
 }
 
+static inline void device_set_out_band_wakeup(struct device *dev, bool capable)
+{
+	dev->power.out_band_wakeup = capable;
+}
+
+static inline bool device_get_out_band_wakeup(struct device *dev)
+{
+	return dev->power.out_band_wakeup;
+}
+
 /* drivers/base/power/wakeup.c */
 extern struct wakeup_source *wakeup_source_register(struct device *dev,
 						    const char *name);
@@ -162,6 +172,13 @@ static inline bool device_wakeup_path(struct device *dev)
 
 static inline void device_set_wakeup_path(struct device *dev) {}
 
+static inline void device_set_out_band_wakeup(struct device *dev, bool capable) {}
+
+static inline bool device_get_out_band_wakeup(struct device *dev)
+{
+	return false;
+}
+
 static inline void __pm_stay_awake(struct wakeup_source *ws) {}
 
 static inline void pm_stay_awake(struct device *dev) {}

-- 
2.37.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 2/3] usb: chipidea: ci_hdrc_imx: Set out of band wakeup for i.MX95
  2025-08-01  4:34 [PATCH v2 0/3] pmdomain: core: Introduce device_set/get_out_band_wakeup Peng Fan
  2025-08-01  4:34 ` [PATCH v2 1/3] pmdomain: core: Introduce device_set/get_out_band_wakeup() Peng Fan
@ 2025-08-01  4:34 ` Peng Fan
  2025-08-06  9:28   ` Xu Yang
  2025-08-01  4:34 ` [PATCH v2 3/3] usb: dwc3: imx8mp: " Peng Fan
  2 siblings, 1 reply; 9+ messages in thread
From: Peng Fan @ 2025-08-01  4:34 UTC (permalink / raw)
  To: Ulf Hansson, Rafael J. Wysocki, Len Brown, Pavel Machek,
	Peter Chen, Greg Kroah-Hartman, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Thinh Nguyen,
	Vincent Guittot, Xu Yang
  Cc: linux-pm, linux-kernel, linux-usb, imx, arm-scmi,
	linux-arm-kernel, Peng Fan

i.MX95 USB2 inside HSIOMIX could still wakeup Linux, even if HSIOMIX
power domain(Digital logic) is off. There is still always on logic
have the wakeup capability which is out band wakeup capbility.

So use device_set_out_band_wakeup for i.MX95 to make sure usb2 could
wakeup system even if HSIOMIX power domain is in off state.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/usb/chipidea/ci_hdrc_imx.c | 8 ++++++++
 include/linux/usb/chipidea.h       | 1 +
 2 files changed, 9 insertions(+)

diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
index e1ec9b38f5b9ba0568101b51fbf16b99461b6ee2..7a3360d8a0fd065394393de829108a12c27c85b9 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.c
+++ b/drivers/usb/chipidea/ci_hdrc_imx.c
@@ -79,6 +79,10 @@ static const struct ci_hdrc_imx_platform_flag imx8ulp_usb_data = {
 		CI_HDRC_HAS_PORTSC_PEC_MISSED,
 };
 
+static const struct ci_hdrc_imx_platform_flag imx95_usb_data = {
+	.flags = CI_HDRC_SUPPORTS_RUNTIME_PM | CI_HDRC_OUT_BAND_WAKEUP,
+};
+
 static const struct ci_hdrc_imx_platform_flag s32g_usb_data = {
 	.flags = CI_HDRC_DISABLE_HOST_STREAMING,
 };
@@ -94,6 +98,7 @@ static const struct of_device_id ci_hdrc_imx_dt_ids[] = {
 	{ .compatible = "fsl,imx7d-usb", .data = &imx7d_usb_data},
 	{ .compatible = "fsl,imx7ulp-usb", .data = &imx7ulp_usb_data},
 	{ .compatible = "fsl,imx8ulp-usb", .data = &imx8ulp_usb_data},
+	{ .compatible = "fsl,imx95-usb", .data = &imx95_usb_data},
 	{ .compatible = "nxp,s32g2-usb", .data = &s32g_usb_data},
 	{ /* sentinel */ }
 };
@@ -569,6 +574,9 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
 
 	device_set_wakeup_capable(dev, true);
 
+	if (pdata.flags & CI_HDRC_OUT_BAND_WAKEUP)
+		device_set_out_band_wakeup(dev, true);
+
 	return 0;
 
 disable_device:
diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h
index e17ebeee24e3ecc4b1c2d153d9ea9b656b5a3d35..c6451191d2de68607a9380482701d11f949d0ff7 100644
--- a/include/linux/usb/chipidea.h
+++ b/include/linux/usb/chipidea.h
@@ -66,6 +66,7 @@ struct ci_hdrc_platform_data {
 #define CI_HDRC_HAS_PORTSC_PEC_MISSED	BIT(17)
 #define CI_HDRC_FORCE_VBUS_ACTIVE_ALWAYS	BIT(18)
 #define	CI_HDRC_HAS_SHORT_PKT_LIMIT	BIT(19)
+#define	CI_HDRC_OUT_BAND_WAKEUP		BIT(20)
 	enum usb_dr_mode	dr_mode;
 #define CI_HDRC_CONTROLLER_RESET_EVENT		0
 #define CI_HDRC_CONTROLLER_STOPPED_EVENT	1

-- 
2.37.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 3/3] usb: dwc3: imx8mp: Set out of band wakeup for i.MX95
  2025-08-01  4:34 [PATCH v2 0/3] pmdomain: core: Introduce device_set/get_out_band_wakeup Peng Fan
  2025-08-01  4:34 ` [PATCH v2 1/3] pmdomain: core: Introduce device_set/get_out_band_wakeup() Peng Fan
  2025-08-01  4:34 ` [PATCH v2 2/3] usb: chipidea: ci_hdrc_imx: Set out of band wakeup for i.MX95 Peng Fan
@ 2025-08-01  4:34 ` Peng Fan
  2025-08-05 23:40   ` Thinh Nguyen
  2 siblings, 1 reply; 9+ messages in thread
From: Peng Fan @ 2025-08-01  4:34 UTC (permalink / raw)
  To: Ulf Hansson, Rafael J. Wysocki, Len Brown, Pavel Machek,
	Peter Chen, Greg Kroah-Hartman, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Thinh Nguyen,
	Vincent Guittot, Xu Yang
  Cc: linux-pm, linux-kernel, linux-usb, imx, arm-scmi,
	linux-arm-kernel, Peng Fan

i.MX95 DWC3 inside HSIOMIX could still wakeup Linux, even if HSIOMIX
power domain(Digital logic) is off. There is still always on logic
have the wakeup capability which is out band wakeup capbility.

So use device_set_out_band_wakeup for i.MX95 to make sure DWC3 could
wakeup system even if HSIOMIX power domain is in off state.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/usb/dwc3/dwc3-imx8mp.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/dwc3/dwc3-imx8mp.c b/drivers/usb/dwc3/dwc3-imx8mp.c
index bce6af82f54c24423c1e1fcc46913c8456b6f035..fde158d1f6e3d89d261ed3689a17d703878c7e37 100644
--- a/drivers/usb/dwc3/dwc3-imx8mp.c
+++ b/drivers/usb/dwc3/dwc3-imx8mp.c
@@ -248,6 +248,10 @@ static int dwc3_imx8mp_probe(struct platform_device *pdev)
 	}
 
 	device_set_wakeup_capable(dev, true);
+
+	if (device_is_compatible(dev, "fsl,imx95-dwc3"))
+		device_set_out_band_wakeup(dev, true);
+
 	pm_runtime_put(dev);
 
 	return 0;

-- 
2.37.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 3/3] usb: dwc3: imx8mp: Set out of band wakeup for i.MX95
  2025-08-01  4:34 ` [PATCH v2 3/3] usb: dwc3: imx8mp: " Peng Fan
@ 2025-08-05 23:40   ` Thinh Nguyen
  0 siblings, 0 replies; 9+ messages in thread
From: Thinh Nguyen @ 2025-08-05 23:40 UTC (permalink / raw)
  To: Peng Fan
  Cc: Ulf Hansson, Rafael J. Wysocki, Len Brown, Pavel Machek,
	Peter Chen, Greg Kroah-Hartman, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Thinh Nguyen,
	Vincent Guittot, Xu Yang, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
	imx@lists.linux.dev, arm-scmi@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org

On Fri, Aug 01, 2025, Peng Fan wrote:
> i.MX95 DWC3 inside HSIOMIX could still wakeup Linux, even if HSIOMIX
> power domain(Digital logic) is off. There is still always on logic
> have the wakeup capability which is out band wakeup capbility.
> 
> So use device_set_out_band_wakeup for i.MX95 to make sure DWC3 could
> wakeup system even if HSIOMIX power domain is in off state.
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  drivers/usb/dwc3/dwc3-imx8mp.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/usb/dwc3/dwc3-imx8mp.c b/drivers/usb/dwc3/dwc3-imx8mp.c
> index bce6af82f54c24423c1e1fcc46913c8456b6f035..fde158d1f6e3d89d261ed3689a17d703878c7e37 100644
> --- a/drivers/usb/dwc3/dwc3-imx8mp.c
> +++ b/drivers/usb/dwc3/dwc3-imx8mp.c
> @@ -248,6 +248,10 @@ static int dwc3_imx8mp_probe(struct platform_device *pdev)
>  	}
>  
>  	device_set_wakeup_capable(dev, true);
> +
> +	if (device_is_compatible(dev, "fsl,imx95-dwc3"))
> +		device_set_out_band_wakeup(dev, true);
> +
>  	pm_runtime_put(dev);
>  
>  	return 0;
> 
> -- 
> 2.37.1
> 

Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>

BR,
Thinh

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 2/3] usb: chipidea: ci_hdrc_imx: Set out of band wakeup for i.MX95
  2025-08-01  4:34 ` [PATCH v2 2/3] usb: chipidea: ci_hdrc_imx: Set out of band wakeup for i.MX95 Peng Fan
@ 2025-08-06  9:28   ` Xu Yang
  2025-08-19 16:21     ` Peng Fan
  0 siblings, 1 reply; 9+ messages in thread
From: Xu Yang @ 2025-08-06  9:28 UTC (permalink / raw)
  To: Peng Fan, jun.li
  Cc: Ulf Hansson, Rafael J. Wysocki, Len Brown, Pavel Machek,
	Peter Chen, Greg Kroah-Hartman, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Thinh Nguyen,
	Vincent Guittot, linux-pm, linux-kernel, linux-usb, imx, arm-scmi,
	linux-arm-kernel

Hi Peng,

On Fri, Aug 01, 2025 at 12:34:23PM +0800, Peng Fan wrote:
> i.MX95 USB2 inside HSIOMIX could still wakeup Linux, even if HSIOMIX
> power domain(Digital logic) is off. There is still always on logic
> have the wakeup capability which is out band wakeup capbility.
> 
> So use device_set_out_band_wakeup for i.MX95 to make sure usb2 could
> wakeup system even if HSIOMIX power domain is in off state.
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  drivers/usb/chipidea/ci_hdrc_imx.c | 8 ++++++++
>  include/linux/usb/chipidea.h       | 1 +
>  2 files changed, 9 insertions(+)
> 
> diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
> index e1ec9b38f5b9ba0568101b51fbf16b99461b6ee2..7a3360d8a0fd065394393de829108a12c27c85b9 100644
> --- a/drivers/usb/chipidea/ci_hdrc_imx.c
> +++ b/drivers/usb/chipidea/ci_hdrc_imx.c
> @@ -79,6 +79,10 @@ static const struct ci_hdrc_imx_platform_flag imx8ulp_usb_data = {
>  		CI_HDRC_HAS_PORTSC_PEC_MISSED,
>  };
>  
> +static const struct ci_hdrc_imx_platform_flag imx95_usb_data = {
> +	.flags = CI_HDRC_SUPPORTS_RUNTIME_PM | CI_HDRC_OUT_BAND_WAKEUP,
> +};
> +
>  static const struct ci_hdrc_imx_platform_flag s32g_usb_data = {
>  	.flags = CI_HDRC_DISABLE_HOST_STREAMING,
>  };
> @@ -94,6 +98,7 @@ static const struct of_device_id ci_hdrc_imx_dt_ids[] = {
>  	{ .compatible = "fsl,imx7d-usb", .data = &imx7d_usb_data},
>  	{ .compatible = "fsl,imx7ulp-usb", .data = &imx7ulp_usb_data},
>  	{ .compatible = "fsl,imx8ulp-usb", .data = &imx8ulp_usb_data},
> +	{ .compatible = "fsl,imx95-usb", .data = &imx95_usb_data},
>  	{ .compatible = "nxp,s32g2-usb", .data = &s32g_usb_data},
>  	{ /* sentinel */ }
>  };
> @@ -569,6 +574,9 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
>  
>  	device_set_wakeup_capable(dev, true);
>  
> +	if (pdata.flags & CI_HDRC_OUT_BAND_WAKEUP)
> +		device_set_out_band_wakeup(dev, true);
> +

In current design, ci_hdrc_imx_probe() will create another platform
device B which will be a child of current device A. Furthermore, device
A and device B will attached to a same power domain. In this case, some
conflict setting may happen. For example, if the user wants to enable
wakeup for this USB port, they may echo "enabled" to wakeup file for
both device A and device B as before. As a result, device A is out
band wakeup so it doesn't depend on power domain on, but device B has
also enabled wakeup so the power domain will keep on finally. Actually,
the power domain needs to be off for imx95.

So I think only letting the parent device A itself attach to power domain
should be enough. If it's the right way, then below change needs to be
included to avoid potential misbehavior.

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 694b4a8e4e1d..c2ca81fe5e09 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -915,6 +915,8 @@ struct platform_device *ci_hdrc_add_device(struct device *dev,
        if (ret)
                goto err;

+       dev_pm_domain_detach(&pdev->dev, false);
+
        return pdev;

Thanks,
Xu Yang

>  	return 0;
>  
>  disable_device:
> diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h
> index e17ebeee24e3ecc4b1c2d153d9ea9b656b5a3d35..c6451191d2de68607a9380482701d11f949d0ff7 100644
> --- a/include/linux/usb/chipidea.h
> +++ b/include/linux/usb/chipidea.h
> @@ -66,6 +66,7 @@ struct ci_hdrc_platform_data {
>  #define CI_HDRC_HAS_PORTSC_PEC_MISSED	BIT(17)
>  #define CI_HDRC_FORCE_VBUS_ACTIVE_ALWAYS	BIT(18)
>  #define	CI_HDRC_HAS_SHORT_PKT_LIMIT	BIT(19)
> +#define	CI_HDRC_OUT_BAND_WAKEUP		BIT(20)
>  	enum usb_dr_mode	dr_mode;
>  #define CI_HDRC_CONTROLLER_RESET_EVENT		0
>  #define CI_HDRC_CONTROLLER_STOPPED_EVENT	1
> 
> -- 
> 2.37.1
> 

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 2/3] usb: chipidea: ci_hdrc_imx: Set out of band wakeup for i.MX95
  2025-08-06  9:28   ` Xu Yang
@ 2025-08-19 16:21     ` Peng Fan
  2025-08-25  5:58       ` Xu Yang
  0 siblings, 1 reply; 9+ messages in thread
From: Peng Fan @ 2025-08-19 16:21 UTC (permalink / raw)
  To: Xu Yang
  Cc: Peng Fan, jun.li, Ulf Hansson, Rafael J. Wysocki, Len Brown,
	Pavel Machek, Peter Chen, Greg Kroah-Hartman, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Thinh Nguyen, Vincent Guittot, linux-pm, linux-kernel, linux-usb,
	imx, arm-scmi, linux-arm-kernel

On Wed, Aug 06, 2025 at 05:28:08PM +0800, Xu Yang wrote:
>Hi Peng,
>
>On Fri, Aug 01, 2025 at 12:34:23PM +0800, Peng Fan wrote:
>> i.MX95 USB2 inside HSIOMIX could still wakeup Linux, even if HSIOMIX
>> power domain(Digital logic) is off. There is still always on logic
>> have the wakeup capability which is out band wakeup capbility.
>> 
>> So use device_set_out_band_wakeup for i.MX95 to make sure usb2 could
>> wakeup system even if HSIOMIX power domain is in off state.
>> 
>> Signed-off-by: Peng Fan <peng.fan@nxp.com>
>> ---
>>  drivers/usb/chipidea/ci_hdrc_imx.c | 8 ++++++++
>>  include/linux/usb/chipidea.h       | 1 +
>>  2 files changed, 9 insertions(+)
>> 
>> diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
>> index e1ec9b38f5b9ba0568101b51fbf16b99461b6ee2..7a3360d8a0fd065394393de829108a12c27c85b9 100644
>> --- a/drivers/usb/chipidea/ci_hdrc_imx.c
>> +++ b/drivers/usb/chipidea/ci_hdrc_imx.c
>> @@ -79,6 +79,10 @@ static const struct ci_hdrc_imx_platform_flag imx8ulp_usb_data = {
>>  		CI_HDRC_HAS_PORTSC_PEC_MISSED,
>>  };
>>  
>> +static const struct ci_hdrc_imx_platform_flag imx95_usb_data = {
>> +	.flags = CI_HDRC_SUPPORTS_RUNTIME_PM | CI_HDRC_OUT_BAND_WAKEUP,
>> +};
>> +
>>  static const struct ci_hdrc_imx_platform_flag s32g_usb_data = {
>>  	.flags = CI_HDRC_DISABLE_HOST_STREAMING,
>>  };
>> @@ -94,6 +98,7 @@ static const struct of_device_id ci_hdrc_imx_dt_ids[] = {
>>  	{ .compatible = "fsl,imx7d-usb", .data = &imx7d_usb_data},
>>  	{ .compatible = "fsl,imx7ulp-usb", .data = &imx7ulp_usb_data},
>>  	{ .compatible = "fsl,imx8ulp-usb", .data = &imx8ulp_usb_data},
>> +	{ .compatible = "fsl,imx95-usb", .data = &imx95_usb_data},
>>  	{ .compatible = "nxp,s32g2-usb", .data = &s32g_usb_data},
>>  	{ /* sentinel */ }
>>  };
>> @@ -569,6 +574,9 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
>>  
>>  	device_set_wakeup_capable(dev, true);
>>  
>> +	if (pdata.flags & CI_HDRC_OUT_BAND_WAKEUP)
>> +		device_set_out_band_wakeup(dev, true);
>> +
>
>In current design, ci_hdrc_imx_probe() will create another platform
>device B which will be a child of current device A. Furthermore, device
>A and device B will attached to a same power domain. In this case, some
>conflict setting may happen. For example, if the user wants to enable
>wakeup for this USB port, they may echo "enabled" to wakeup file for
>both device A and device B as before. As a result, device A is out
>band wakeup so it doesn't depend on power domain on, but device B has
>also enabled wakeup so the power domain will keep on finally. Actually,
>the power domain needs to be off for imx95.
>
>So I think only letting the parent device A itself attach to power domain
>should be enough. If it's the right way, then below change needs to be
>included to avoid potential misbehavior.

Thanks for looking into this.
Just detaching the power domain may break others. I think the better one
should be:

if (device_get_out_band_wakeup(dev))
	device_set_out_band_wakeup(&pdev->dev);

Regards,
Peng
>
>diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
>index 694b4a8e4e1d..c2ca81fe5e09 100644
>--- a/drivers/usb/chipidea/core.c
>+++ b/drivers/usb/chipidea/core.c
>@@ -915,6 +915,8 @@ struct platform_device *ci_hdrc_add_device(struct device *dev,
>        if (ret)
>                goto err;
>
>+       dev_pm_domain_detach(&pdev->dev, false);

I think the 

>+
>        return pdev;
>
>Thanks,
>Xu Yang
>
>>  	return 0;
>>  
>>  disable_device:
>> diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h
>> index e17ebeee24e3ecc4b1c2d153d9ea9b656b5a3d35..c6451191d2de68607a9380482701d11f949d0ff7 100644
>> --- a/include/linux/usb/chipidea.h
>> +++ b/include/linux/usb/chipidea.h
>> @@ -66,6 +66,7 @@ struct ci_hdrc_platform_data {
>>  #define CI_HDRC_HAS_PORTSC_PEC_MISSED	BIT(17)
>>  #define CI_HDRC_FORCE_VBUS_ACTIVE_ALWAYS	BIT(18)
>>  #define	CI_HDRC_HAS_SHORT_PKT_LIMIT	BIT(19)
>> +#define	CI_HDRC_OUT_BAND_WAKEUP		BIT(20)
>>  	enum usb_dr_mode	dr_mode;
>>  #define CI_HDRC_CONTROLLER_RESET_EVENT		0
>>  #define CI_HDRC_CONTROLLER_STOPPED_EVENT	1
>> 
>> -- 
>> 2.37.1
>> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 1/3] pmdomain: core: Introduce device_set/get_out_band_wakeup()
  2025-08-01  4:34 ` [PATCH v2 1/3] pmdomain: core: Introduce device_set/get_out_band_wakeup() Peng Fan
@ 2025-08-22  5:22   ` Peng Fan
  0 siblings, 0 replies; 9+ messages in thread
From: Peng Fan @ 2025-08-22  5:22 UTC (permalink / raw)
  To: Peng Fan
  Cc: Ulf Hansson, Rafael J. Wysocki, Len Brown, Pavel Machek,
	Peter Chen, Greg Kroah-Hartman, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Thinh Nguyen,
	Vincent Guittot, Xu Yang, linux-pm, linux-kernel, linux-usb, imx,
	arm-scmi, linux-arm-kernel

Hi Ulf,

On Fri, Aug 01, 2025 at 12:34:22PM +0800, Peng Fan wrote:
>For some cases, a device could still wakeup the system even if its power
>domain is in off state, because the device's wakeup hardware logic is
>in an always-on domain.
>
>To support this case, introduce device_set/get_out_band_wakeup() to
>allow device drivers to control the behaviour in genpd for a device
>that is attached to it.

Would you please give a look on this patch? Is it the right way
to resolve the issue or any suggestions?

Thanks,
Peng

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 2/3] usb: chipidea: ci_hdrc_imx: Set out of band wakeup for i.MX95
  2025-08-19 16:21     ` Peng Fan
@ 2025-08-25  5:58       ` Xu Yang
  0 siblings, 0 replies; 9+ messages in thread
From: Xu Yang @ 2025-08-25  5:58 UTC (permalink / raw)
  To: Peng Fan
  Cc: Peng Fan, jun.li, Ulf Hansson, Rafael J. Wysocki, Len Brown,
	Pavel Machek, Peter Chen, Greg Kroah-Hartman, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	Thinh Nguyen, Vincent Guittot, linux-pm, linux-kernel, linux-usb,
	imx, arm-scmi, linux-arm-kernel

On Wed, Aug 20, 2025 at 12:21:33AM +0800, Peng Fan wrote:
> On Wed, Aug 06, 2025 at 05:28:08PM +0800, Xu Yang wrote:
> >Hi Peng,
> >
> >On Fri, Aug 01, 2025 at 12:34:23PM +0800, Peng Fan wrote:
> >> i.MX95 USB2 inside HSIOMIX could still wakeup Linux, even if HSIOMIX
> >> power domain(Digital logic) is off. There is still always on logic
> >> have the wakeup capability which is out band wakeup capbility.
> >> 
> >> So use device_set_out_band_wakeup for i.MX95 to make sure usb2 could
> >> wakeup system even if HSIOMIX power domain is in off state.
> >> 
> >> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> >> ---
> >>  drivers/usb/chipidea/ci_hdrc_imx.c | 8 ++++++++
> >>  include/linux/usb/chipidea.h       | 1 +
> >>  2 files changed, 9 insertions(+)
> >> 
> >> diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
> >> index e1ec9b38f5b9ba0568101b51fbf16b99461b6ee2..7a3360d8a0fd065394393de829108a12c27c85b9 100644
> >> --- a/drivers/usb/chipidea/ci_hdrc_imx.c
> >> +++ b/drivers/usb/chipidea/ci_hdrc_imx.c
> >> @@ -79,6 +79,10 @@ static const struct ci_hdrc_imx_platform_flag imx8ulp_usb_data = {
> >>  		CI_HDRC_HAS_PORTSC_PEC_MISSED,
> >>  };
> >>  
> >> +static const struct ci_hdrc_imx_platform_flag imx95_usb_data = {
> >> +	.flags = CI_HDRC_SUPPORTS_RUNTIME_PM | CI_HDRC_OUT_BAND_WAKEUP,
> >> +};
> >> +
> >>  static const struct ci_hdrc_imx_platform_flag s32g_usb_data = {
> >>  	.flags = CI_HDRC_DISABLE_HOST_STREAMING,
> >>  };
> >> @@ -94,6 +98,7 @@ static const struct of_device_id ci_hdrc_imx_dt_ids[] = {
> >>  	{ .compatible = "fsl,imx7d-usb", .data = &imx7d_usb_data},
> >>  	{ .compatible = "fsl,imx7ulp-usb", .data = &imx7ulp_usb_data},
> >>  	{ .compatible = "fsl,imx8ulp-usb", .data = &imx8ulp_usb_data},
> >> +	{ .compatible = "fsl,imx95-usb", .data = &imx95_usb_data},
> >>  	{ .compatible = "nxp,s32g2-usb", .data = &s32g_usb_data},
> >>  	{ /* sentinel */ }
> >>  };
> >> @@ -569,6 +574,9 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
> >>  
> >>  	device_set_wakeup_capable(dev, true);
> >>  
> >> +	if (pdata.flags & CI_HDRC_OUT_BAND_WAKEUP)
> >> +		device_set_out_band_wakeup(dev, true);
> >> +
> >
> >In current design, ci_hdrc_imx_probe() will create another platform
> >device B which will be a child of current device A. Furthermore, device
> >A and device B will attached to a same power domain. In this case, some
> >conflict setting may happen. For example, if the user wants to enable
> >wakeup for this USB port, they may echo "enabled" to wakeup file for
> >both device A and device B as before. As a result, device A is out
> >band wakeup so it doesn't depend on power domain on, but device B has
> >also enabled wakeup so the power domain will keep on finally. Actually,
> >the power domain needs to be off for imx95.
> >
> >So I think only letting the parent device A itself attach to power domain
> >should be enough. If it's the right way, then below change needs to be
> >included to avoid potential misbehavior.
> 
> Thanks for looking into this.
> Just detaching the power domain may break others. I think the better one
> should be:
> 
> if (device_get_out_band_wakeup(dev))
> 	device_set_out_band_wakeup(&pdev->dev);

I don't prefer such way. Firstly, The irq of pdev->dev is totally a in-band
interrupt. This will mislead the users. Secondly, it won't take effect if
call device_set_out_band_wakeup() in ci_hdrc_add_device() because the dev
hasn't set out-band wakeup yet.

Thanks,
Xu Yang

> 
> Regards,
> Peng
> >
> >diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
> >index 694b4a8e4e1d..c2ca81fe5e09 100644
> >--- a/drivers/usb/chipidea/core.c
> >+++ b/drivers/usb/chipidea/core.c
> >@@ -915,6 +915,8 @@ struct platform_device *ci_hdrc_add_device(struct device *dev,
> >        if (ret)
> >                goto err;
> >
> >+       dev_pm_domain_detach(&pdev->dev, false);
> 
> I think the 
> 
> >+
> >        return pdev;
> >
> >Thanks,
> >Xu Yang
> >
> >>  	return 0;
> >>  
> >>  disable_device:
> >> diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h
> >> index e17ebeee24e3ecc4b1c2d153d9ea9b656b5a3d35..c6451191d2de68607a9380482701d11f949d0ff7 100644
> >> --- a/include/linux/usb/chipidea.h
> >> +++ b/include/linux/usb/chipidea.h
> >> @@ -66,6 +66,7 @@ struct ci_hdrc_platform_data {
> >>  #define CI_HDRC_HAS_PORTSC_PEC_MISSED	BIT(17)
> >>  #define CI_HDRC_FORCE_VBUS_ACTIVE_ALWAYS	BIT(18)
> >>  #define	CI_HDRC_HAS_SHORT_PKT_LIMIT	BIT(19)
> >> +#define	CI_HDRC_OUT_BAND_WAKEUP		BIT(20)
> >>  	enum usb_dr_mode	dr_mode;
> >>  #define CI_HDRC_CONTROLLER_RESET_EVENT		0
> >>  #define CI_HDRC_CONTROLLER_STOPPED_EVENT	1
> >> 
> >> -- 
> >> 2.37.1
> >> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-08-25  6:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-01  4:34 [PATCH v2 0/3] pmdomain: core: Introduce device_set/get_out_band_wakeup Peng Fan
2025-08-01  4:34 ` [PATCH v2 1/3] pmdomain: core: Introduce device_set/get_out_band_wakeup() Peng Fan
2025-08-22  5:22   ` Peng Fan
2025-08-01  4:34 ` [PATCH v2 2/3] usb: chipidea: ci_hdrc_imx: Set out of band wakeup for i.MX95 Peng Fan
2025-08-06  9:28   ` Xu Yang
2025-08-19 16:21     ` Peng Fan
2025-08-25  5:58       ` Xu Yang
2025-08-01  4:34 ` [PATCH v2 3/3] usb: dwc3: imx8mp: " Peng Fan
2025-08-05 23:40   ` Thinh Nguyen

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).