pwm: lpss: Add support for multiple PWMs
Subsystems (2)
PATCH 1/3 pwm: lpss: Add support for multiple PWMs
New Intel SoCs such as Broxton will have four PWMs per PCI (or ACPI) device. Each PWM has 1k of register space allocated from the parent device. Add support for this.
--- drivers/pwm/pwm-lpss.c | 48 +++++++++++++++++++++++++++--------------------- drivers/pwm/pwm-lpss.h | 1 + 2 files changed, 28 insertions(+), 21 deletions(-)
drivers/pwm/pwm-lpss.c +27 -21
@@ -29,6 +29,9 @@#define PWM_LIMIT (0x8000 + PWM_DIVISION_CORRECTION)#define NSECS_PER_SEC 1000000000UL +/* Size of each PWM register space if multiple */ +#define PWM_SIZE 0x400 +struct pwm_lpss_chip {struct pwm_chip chip;void __iomem *regs;
@@ -37,13 +40,15 @@ struct pwm_lpss_chip {/* BayTrail */ const struct pwm_lpss_boardinfo pwm_lpss_byt_info = { - .clk_rate =25000000 + .clk_rate =25000000 , + .npwm =1 , };EXPORT_SYMBOL_GPL (pwm_lpss_byt_info);/* Braswell */ const struct pwm_lpss_boardinfo pwm_lpss_bsw_info = { - .clk_rate =19200000 + .clk_rate =19200000 , + .npwm =1 , };EXPORT_SYMBOL_GPL (pwm_lpss_bsw_info);
@@ -52,6 +57,20 @@ static inline struct pwm_lpss_chip *to_lpwm(struct pwm_chip *chip) return container_of(chip, struct pwm_lpss_chip, chip); } +static inline u32 pwm_lpss_read (const struct pwm_device *pwm) +{ +struct pwm_lpss_chip *lpwm =to_lpwm (pwm->chip); + +return readl (lpwm->regs + pwm->hwpwm *PWM_SIZE +PWM ); +} + +static inline void pwm_lpss_write (const struct pwm_device *pwm,u32 value) +{ +struct pwm_lpss_chip *lpwm =to_lpwm (pwm->chip); + +writel (value, lpwm->regs + pwm->hwpwm *PWM_SIZE +PWM ); +} +static int pwm_lpss_config (struct pwm_chip *chip,struct pwm_device *pwm,int duty_ns,int period_ns) {
@@ -79,38 +98,30 @@ static int pwm_lpss_config(struct pwm_chip *chip, struct pwm_device *pwm, duty_ns =1 ; on_time_div =255 - (255 * duty_ns / period_ns); - ctrl =readl (lpwm->regs +PWM ); + ctrl =pwm_lpss_read (pwm); ctrl &= ~(PWM_BASE_UNIT_MASK |PWM_ON_TIME_DIV_MASK ); ctrl |= (u16 ) base_unit <<PWM_BASE_UNIT_SHIFT ; ctrl |= on_time_div;/* request PWM to update on next cycle */ ctrl |=PWM_SW_UPDATE ; -writel (ctrl, lpwm->regs +PWM ); +pwm_lpss_write (pwm, ctrl);return 0 ; }static int pwm_lpss_enable (struct pwm_chip *chip,struct pwm_device *pwm) { -struct pwm_lpss_chip *lpwm =to_lpwm (chip); -u32 ctrl; - - ctrl =readl (lpwm->regs +PWM ); -writel (ctrl |PWM_ENABLE , lpwm->regs +PWM ); - +pwm_lpss_write (pwm,pwm_lpss_read (pwm) |PWM_ENABLE );return 0 ; }static void pwm_lpss_disable (struct pwm_chip *chip,struct pwm_device *pwm) { -struct pwm_lpss_chip *lpwm =to_lpwm (chip); -u32 ctrl; - - ctrl =readl (lpwm->regs +PWM ); -writel (ctrl & ~PWM_ENABLE , lpwm->regs +PWM ); +pwm_lpss_write (pwm,pwm_lpss_read (pwm) & ~PWM_ENABLE ); }static const struct pwm_ops pwm_lpss_ops = { + .free = pwm_lpss_disable, .config = pwm_lpss_config, .enable = pwm_lpss_enable, .disable = pwm_lpss_disable,
@@ -135,7 +146,7 @@ struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, struct resource *r, lpwm->chip.dev = dev; lpwm->chip.ops = &pwm_lpss_ops; lpwm->chip.base =-1 ; - lpwm->chip.npwm =1 ; + lpwm->chip.npwm = info->npwm; ret =pwmchip_add (&lpwm->chip);if (ret) {
@@ -149,11 +160,6 @@ EXPORT_SYMBOL_GPL(pwm_lpss_probe);int pwm_lpss_remove (struct pwm_lpss_chip *lpwm) { -u32 ctrl; - - ctrl =readl (lpwm->regs +PWM ); -writel (ctrl & ~PWM_ENABLE , lpwm->regs +PWM ); -return pwmchip_remove (&lpwm->chip); }EXPORT_SYMBOL_GPL (pwm_lpss_remove);
drivers/pwm/pwm-lpss.h +1 -0
@@ -20,6 +20,7 @@ struct pwm_lpss_chip;struct pwm_lpss_boardinfo {unsigned long clk_rate; +size_t npwm; };extern const struct pwm_lpss_boardinfo pwm_lpss_byt_info;
Signature · 1 line
2.6.1
PATCH 2/3 pwm: lpss: Support all four PWMs on Intel Broxton
Intel Broxton has similar PWM than Intel Braswell but instead of one it has four PWMs included in one PCI/ACPI device. This patch adds support for all the four PWMs and changes the PCI part of the driver to use 'pwm_lpss_bxt_info' instead.
--- drivers/pwm/pwm-lpss-pci.c | 4 ++-- drivers/pwm/pwm-lpss.c | 7 +++++++ drivers/pwm/pwm-lpss.h | 1 + 3 files changed, 10 insertions(+), 2 deletions(-)
drivers/pwm/pwm-lpss-pci.c +2 -2
@@ -44,10 +44,10 @@ static void pwm_lpss_remove_pci(struct pci_dev *pdev) }static const struct pci_device_id pwm_lpss_pci_ids[] = { - {PCI_VDEVICE (INTEL ,0x0ac8 ), (unsigned long )&pwm_lpss_bsw_info}, + {PCI_VDEVICE (INTEL ,0x0ac8 ), (unsigned long )&pwm_lpss_bxt_info}, {PCI_VDEVICE (INTEL ,0x0f08 ), (unsigned long )&pwm_lpss_byt_info}, {PCI_VDEVICE (INTEL ,0x0f09 ), (unsigned long )&pwm_lpss_byt_info}, - {PCI_VDEVICE (INTEL ,0x1ac8 ), (unsigned long )&pwm_lpss_bsw_info}, + {PCI_VDEVICE (INTEL ,0x1ac8 ), (unsigned long )&pwm_lpss_bxt_info}, {PCI_VDEVICE (INTEL ,0x2288 ), (unsigned long )&pwm_lpss_bsw_info}, {PCI_VDEVICE (INTEL ,0x2289 ), (unsigned long )&pwm_lpss_bsw_info}, { },
drivers/pwm/pwm-lpss.c +7 -0
@@ -52,6 +52,13 @@ const struct pwm_lpss_boardinfo pwm_lpss_bsw_info = { };EXPORT_SYMBOL_GPL (pwm_lpss_bsw_info); +/* Broxton */ +const struct pwm_lpss_boardinfo pwm_lpss_bxt_info = { + .clk_rate =19200000 , + .npwm =4 , +}; +EXPORT_SYMBOL_GPL (pwm_lpss_bxt_info); +static inline struct pwm_lpss_chip *to_lpwm (struct pwm_chip *chip) { return container_of(chip, struct pwm_lpss_chip, chip);
drivers/pwm/pwm-lpss.h +1 -0
@@ -25,6 +25,7 @@ struct pwm_lpss_boardinfo {extern const struct pwm_lpss_boardinfo pwm_lpss_byt_info;extern const struct pwm_lpss_boardinfo pwm_lpss_bsw_info; +extern const struct pwm_lpss_boardinfo pwm_lpss_bxt_info;struct pwm_lpss_chip *pwm_lpss_probe (struct device *dev,struct resource *r,const struct pwm_lpss_boardinfo *info);
Signature · 1 line
2.6.1
PATCH 3/3 pwm: lpss: Add more Intel Broxton IDs
In reply to Mika WesterbergAdd more Intel Broxton ACPI and PCI IDs to the driver supported devices list.
--- drivers/pwm/pwm-lpss-pci.c | 1 + drivers/pwm/pwm-lpss-platform.c | 1 + 2 files changed, 2 insertions(+)
drivers/pwm/pwm-lpss-pci.c +1 -0
@@ -50,6 +50,7 @@ static const struct pci_device_id pwm_lpss_pci_ids[] = { { PCI_VDEVICE(INTEL, 0x1ac8), (unsigned long)&pwm_lpss_bxt_info}, { PCI_VDEVICE(INTEL, 0x2288), (unsigned long)&pwm_lpss_bsw_info}, { PCI_VDEVICE(INTEL, 0x2289), (unsigned long)&pwm_lpss_bsw_info}, + { PCI_VDEVICE(INTEL, 0x5ac8), (unsigned long)&pwm_lpss_bxt_info}, { }, };MODULE_DEVICE_TABLE (pci, pwm_lpss_pci_ids);
drivers/pwm/pwm-lpss-platform.c +1 -0
@@ -49,6 +49,7 @@ static int pwm_lpss_remove_platform(struct platform_device *pdev)static const struct acpi_device_id pwm_lpss_acpi_match[] = { {"80860F09" , (unsigned long )&pwm_lpss_byt_info }, {"80862288" , (unsigned long )&pwm_lpss_bsw_info }, + {"80865AC8" , (unsigned long )&pwm_lpss_bxt_info }, { }, };MODULE_DEVICE_TABLE (acpi, pwm_lpss_acpi_match);
Signature · 1 line
2.6.1
Quoted 3 lines · Mika Westerberg
New Intel SoCs such as Broxton will have four PWMs per PCI (or ACPI) device. Each PWM has 1k of register space allocated from the parent device. Add support for this.
Hi Thierry,
Are you going to pick these up to PWM tree?
Thanks.
Quoted 9 lines · Mika Westerberg
New Intel SoCs such as Broxton will have four PWMs per PCI (or ACPI) device. Each PWM has 1k of register space allocated from the parent device. Add support for this.
Signed-off-by Mika Westerberg <[email protected]>--- drivers/pwm/pwm-lpss.c | 48 +++++++++++++++++++++++++++--------------------- drivers/pwm/pwm-lpss.h | 1 + 2 files changed, 28 insertions(+), 21 deletions(-)
Applied all three patches, with a minor cleanup, see below.
drivers/pwm/pwm-lpss.h struct pwm_lpss_chip; · line 24
Quoted 10 lines
drivers/pwm/pwm-lpss.h +1
-0@@ -20,6 +20,7 @@ struct pwm_lpss_chip;struct pwm_lpss_boardinfo {unsigned long clk_rate; +size_t npwm; };
I changed the type of npwm to unsigned int to match the definition of the pwm_chip.npwm field.
Thanks,
Thierry
Quoted 19 lines · Thierry Reding
Quoted 9 lines · Mika Westerberg
New Intel SoCs such as Broxton will have four PWMs per PCI (or ACPI) device. Each PWM has 1k of register space allocated from the parent device. Add support for this.
Signed-off-by Mika Westerberg <[email protected]>--- drivers/pwm/pwm-lpss.c | 48 +++++++++++++++++++++++++++--------------------- drivers/pwm/pwm-lpss.h | 1 + 2 files changed, 28 insertions(+), 21 deletions(-)Applied all three patches, with a minor cleanup, see below.
Quoted 6 lines
drivers/pwm/pwm-lpss.h +0
-0@@ -20,6 +20,7 @@ struct pwm_lpss_chip;
Quoted 7 lines
drivers/pwm/pwm-lpss.h struct pwm_lpss_chip; · line 24
Quoted 4 lines
drivers/pwm/pwm-lpss.h +1
-0struct pwm_lpss_boardinfo {unsigned long clk_rate; +size_t npwm; };I changed the type of npwm to unsigned int to match the definition of the pwm_chip.npwm field.
Thanks!