pwm: add support for Intel Low Power Subsystem PWM
Subsystems (2)
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
@@ -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
@@ -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
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.
Signed-off-by Mika Westerberg <[email protected]>Signed-off-by Chew, Kean Ho <[email protected]>Signed-off-by Chang, Rebecca Swee Fun <[email protected]>Signed-off-by Chew, Chiau Ee <[email protected]>
Hi Thierry,
Any comments to this patch? Could you consider merging it?
Thanks.
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.
Signed-off-by Mika Westerberg <[email protected]>Signed-off-by Chew, Kean Ho <[email protected]>Signed-off-by Chang, Rebecca Swee Fun <[email protected]>Signed-off-by Chew, Chiau Ee <[email protected]>
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
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 Mika Westerberg <[email protected]>Signed-off-by Chew, Kean Ho <[email protected]>Signed-off-by Chang, Rebecca Swee FunQuoted 8 lines
Signed-off-by Chew, Chiau Ee <[email protected]>--- drivers/pwm/Kconfig | 10 +++ drivers/pwm/Makefile | 1 + drivers/pwm/pwm-lpss.c | 179 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 190 insertions(+), 0 deletions(-) create mode100644
drivers/pwm/pwm-lpss.cSorry 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