Skip to contentSkip to conversation

pwm: dwc: allow suspend/resume for 16 channels

PATCH In review Raag Jadav 3 participants 3 messages Apr 15, 2024 PWM

lore
Share & tools
lore

Raag Jadav

author
#0 lore raw

PATCH v2 1/1 pwm: dwc: allow suspend/resume for 16 channels

With 16 channel pwm support, we're registering two instances of pwm_chip with 8 channels each. We need to update PM functions to use both instances of pwm_chip during power state transitions.

Introduce struct dwc_pwm_drvdata and use it as driver_data, which will maintain both instances of pwm_chip along with dwc_pwm_info and allow us to use them inside suspend/resume handles.

Fixes ebf2c89eb95e ("pwm: dwc: Add 16 channel support for Intel Elkhart Lake")

---
Changes since v1:
- Drop error message for -ENOMEM
- s/data/ddata/

 drivers/pwm/pwm-dwc-core.c |  1 -
 drivers/pwm/pwm-dwc.c      | 82 +++++++++++++++++++++++++-------------
 drivers/pwm/pwm-dwc.h      |  6 +++
 3 files changed, 60 insertions(+), 29 deletions(-)
drivers/pwm/pwm-dwc-core.c +0 -1
index 043736972cb9..c8425493b95d 100644
@@ -172,7 +172,6 @@ struct pwm_chip *dwc_pwm_alloc(struct device *dev)
 	dwc->clk_ns = 10;
 	chip->ops = &dwc_pwm_ops;
 
-	dev_set_drvdata(dev, chip);
 	return chip;
 }
 EXPORT_SYMBOL_GPL(dwc_pwm_alloc);
drivers/pwm/pwm-dwc.c +54 -28

130 lines not on this page · raw message

drivers/pwm/pwm-dwc.h +6 -0
index a8b074841ae8..c6e2df5a6122 100644
@@ -38,6 +38,12 @@ struct dwc_pwm_info {
 	unsigned int size;
 };
 
+struct dwc_pwm_drvdata {
+	const struct dwc_pwm_info *info;
+	void __iomem *io_base;
+	struct pwm_chip *chips[];
+};
+
 struct dwc_pwm_ctx {
 	u32 cnt;
 	u32 cnt2;
Signature · 1 line
2.35.3
Reviewed-by on v2 1/1
#1 lore raw
Quoted 7 lines · Raag Jadav

With 16 channel pwm support, we're registering two instances of pwm_chip with 8 channels each. We need to update PM functions to use both instances of pwm_chip during power state transitions.

Introduce struct dwc_pwm_drvdata and use it as driver_data, which will maintain both instances of pwm_chip along with dwc_pwm_info and allow us to use them inside suspend/resume handles.

FWIW,

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#2 lore raw
In reply to Raag Jadav

Hello,

Quoted 8 lines · Raag Jadav

With 16 channel pwm support, we're registering two instances of pwm_chip with 8 channels each. We need to update PM functions to use both instances of pwm_chip during power state transitions.

Introduce struct dwc_pwm_drvdata and use it as driver_data, which will maintain both instances of pwm_chip along with dwc_pwm_info and allow us to use them inside suspend/resume handles.

Quoted 6 lines
Fixes ebf2c89eb95e ("pwm: dwc: Add 16 channel support for Intel Elkhart Lake")

---
Changes since v1:
- Drop error message for -ENOMEM
- s/data/ddata/

Thanks for addressing these concerns. I applied this patch to
https://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux.git pwm/for-next now.

I consider sending this to Linus before v6.9, but I'd let it cook in next a few days before doing so.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |