Skip to contentSkip to conversation

pwm: add support for Intel Low Power Subsystem PWM

PATCH Superseded Chew Chiau Ee 3 participants 4 messages Feb 28, 2014 – Mar 19, 2014

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 pwm: add support for Intel Low Power Subsystem PWM

From: Mika Westerberg <[email protected]>

Add support for Intel Low Power I/O subsystem PWM controllers found on Intel BayTrail SoC.

---
 drivers/pwm/Kconfig    |   10 +++
 drivers/pwm/Makefile   |    1 +
 drivers/pwm/pwm-lpss.c |  179 ++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 190 insertions(+), 0 deletions(-)
 create mode 100644 drivers/pwm/pwm-lpss.c
drivers/pwm/Kconfig +10 -0
index 0b7a3c9..aaa91cc 100644
@@ -119,6 +119,16 @@ config PWM_LPC32XX
 	  To compile this driver as a module, choose M here: the module
 	  will be called pwm-lpc32xx.
 
+config PWM_LPSS
+	tristate "Intel LPSS PWM support"
+	depends on ACPI
+	help
+	  Generic PWM framework driver for Intel Low Power Subsystem PWM
+	  controller.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called pwm-lpss.
+
 config PWM_MXS
 	tristate "Freescale MXS PWM support"
 	depends on ARCH_MXS && OF
drivers/pwm/Makefile +1 -0
index d8906ec..61bf073 100644
@@ -9,6 +9,7 @@ obj-$(CONFIG_PWM_IMX)		+= pwm-imx.o
 obj-$(CONFIG_PWM_JZ4740)	+= pwm-jz4740.o
 obj-$(CONFIG_PWM_LP3943)	+= pwm-lp3943.o
 obj-$(CONFIG_PWM_LPC32XX)	+= pwm-lpc32xx.o
+obj-$(CONFIG_PWM_LPSS)		+= pwm-lpss.o
 obj-$(CONFIG_PWM_MXS)		+= pwm-mxs.o
 obj-$(CONFIG_PWM_PCA9685)	+= pwm-pca9685.o
 obj-$(CONFIG_PWM_PUV3)		+= pwm-puv3.o
drivers/pwm/pwm-lpss.c new file +179 -0

179 lines not on this page · raw message

Signature · 1 line
1.7.4.4
#2 lore raw
In reply to Chew Chiau Ee
Quoted 9 lines · Chew Chiau Ee

From: Mika Westerberg <[email protected]>

Add support for Intel Low Power I/O subsystem PWM controllers found on Intel BayTrail SoC.

Quoted 6 lines
---
 drivers/pwm/Kconfig    |   10 +++
 drivers/pwm/Makefile   |    1 +
 drivers/pwm/pwm-lpss.c |  179 ++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 190 insertions(+), 0 deletions(-)
 create mode 100644 drivers/pwm/pwm-lpss.c

Sorry for taking so long to get back to you on this. Things have been somewhat crazy lately.

This generally looks very good, but I found two issues that escaped last time. See below.

Quoted 1 line
drivers/pwm/pwm-lpss.c +0 -0

[...]

Quoted 4 lines
drivers/pwm/pwm-lpss.c +4 -0
+static int pwm_lpss_config(struct pwm_chip *chip, struct pwm_device *pwm,
+			   int duty_ns, int period_ns)
+{
+	struct pwm_lpss_chip *lpwm = to_lpwm(chip);

drivers/pwm/pwm-lpss.c line 57

Quoted 10 lines
drivers/pwm/pwm-lpss.c +10 -0
+	u8 on_time_div;
+	unsigned long c = clk_get_rate(lpwm->clk);
+	unsigned long long base_unit, freq = NSECS_PER_SEC;
+	u32 ctrl;
+
+	do_div(freq, period_ns);
+
+	/* The equation is: base_unit = ((freq / c) * 65536) + correction */
+	base_unit = freq * 65536;
+	do_div(base_unit, c);

clk_get_rate() can return 0, so perhaps it would be safer to check for the validity of c before dividing by it. This will probably never happen for your driver or platform, but people may look at your driver for inspiration at some point, so it should still be handling this correctly.

drivers/pwm/pwm-lpss.c line 178

Quoted 3 lines
drivers/pwm/pwm-lpss.c +3 -0
+MODULE_DESCRIPTION("PWM driver for Intel LPSS");
+MODULE_AUTHOR("Mika Westerberg <[email protected]>");
+MODULE_LICENSE("GPLv2");

I think this needs to be "GPL v2".

Thierry

#3 lore raw
Quoted 38 lines · Chew Chiau Ee
Quoted 9 lines

From: Mika Westerberg <[email protected]>

Add support for Intel Low Power I/O subsystem PWM controllers found on Intel BayTrail SoC.

Signed-off-by Chang, Rebecca Swee Fun

<[email protected]>

Quoted 8 lines
---
 drivers/pwm/Kconfig    |   10 +++
 drivers/pwm/Makefile   |    1 +
 drivers/pwm/pwm-lpss.c |  179
++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 190 insertions(+), 0 deletions(-)  create mode

100644 drivers/pwm/pwm-lpss.c

Sorry for taking so long to get back to you on this. Things have been somewhat crazy lately.

This generally looks very good, but I found two issues that escaped last time. See below.

Quoted 1 line
drivers/pwm/pwm-lpss.c +0 -0

[...]

Quoted 11 lines
drivers/pwm/pwm-lpss.c +11 -0
+static int pwm_lpss_config(struct pwm_chip *chip, struct pwm_device *pwm,
+			   int duty_ns, int period_ns)
+{
+	struct pwm_lpss_chip *lpwm = to_lpwm(chip);
+	u8 on_time_div;
+	unsigned long c = clk_get_rate(lpwm->clk);
+	unsigned long long base_unit, freq = NSECS_PER_SEC;
+	u32 ctrl;
+
+	do_div(freq, period_ns);
+
Quoted 8 lines

drivers/pwm/pwm-lpss.c line 57

Quoted 3 lines
drivers/pwm/pwm-lpss.c +3 -0
+	/* The equation is: base_unit = ((freq / c) * 65536) + correction */
+	base_unit = freq * 65536;
+	do_div(base_unit, c);

clk_get_rate() can return 0, so perhaps it would be safer to check for the validity of c before dividing by it. This will probably never happen for your driver or platform, but people may look at your driver for inspiration at some point, so it should still be handling this correctly.

Agreed. Will update the code accordingly.

Quoted 6 lines
Quoted 1 line

+MODULE_DESCRIPTION("PWM driver for Intel LPSS");

MODULE_AUTHOR("Mika

drivers/pwm/pwm-lpss.c

Quoted 2 lines
drivers/pwm/pwm-lpss.c +2 -0
+Westerberg <[email protected]>");
+MODULE_LICENSE("GPLv2");

I think this needs to be "GPL v2".

Ok. Will update this as well.

Thanks for your review!

Quoted 2 lines

Thierry