From c791126b93e800c68557483235321b201c082910 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Mon, 25 Feb 2013 17:15:47 +0900 Subject: [PATCH 01/27] pwm_backlight: remove unnecessary ifdefs When the macro such as SIMPLE_DEV_PM_OPS is used, there is no need to use '#ifdef CONFIG_PM' to prevent build error. Thus, this patch removes unnecessary ifdefs. Signed-off-by: Jingoo Han Cc: Thierry Reding Signed-off-by: Thierry Reding --- drivers/video/backlight/pwm_bl.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index fa00304a63d8..1fea627394d7 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c @@ -274,7 +274,7 @@ static int pwm_backlight_remove(struct platform_device *pdev) return 0; } -#ifdef CONFIG_PM +#ifdef CONFIG_PM_SLEEP static int pwm_backlight_suspend(struct device *dev) { struct backlight_device *bl = dev_get_drvdata(dev); @@ -296,19 +296,16 @@ static int pwm_backlight_resume(struct device *dev) backlight_update_status(bl); return 0; } +#endif static SIMPLE_DEV_PM_OPS(pwm_backlight_pm_ops, pwm_backlight_suspend, pwm_backlight_resume); -#endif - static struct platform_driver pwm_backlight_driver = { .driver = { .name = "pwm-backlight", .owner = THIS_MODULE, -#ifdef CONFIG_PM .pm = &pwm_backlight_pm_ops, -#endif .of_match_table = of_match_ptr(pwm_backlight_of_match), }, .probe = pwm_backlight_probe, From 482467ad97b633b28f57c347440d97c108dc4bfb Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Fri, 8 Mar 2013 12:45:58 +0900 Subject: [PATCH 02/27] pwm: ab8500: use devm_kzalloc() Use devm_kzalloc() to make cleanup paths more simple. Signed-off-by: Jingoo Han Signed-off-by: Thierry Reding --- drivers/pwm/pwm-ab8500.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/pwm/pwm-ab8500.c b/drivers/pwm/pwm-ab8500.c index 4248d0418273..93af1bbf88ce 100644 --- a/drivers/pwm/pwm-ab8500.c +++ b/drivers/pwm/pwm-ab8500.c @@ -99,7 +99,7 @@ static int ab8500_pwm_probe(struct platform_device *pdev) * Nothing to be done in probe, this is required to get the * device which is required for ab8500 read and write */ - ab8500 = kzalloc(sizeof(*ab8500), GFP_KERNEL); + ab8500 = devm_kzalloc(&pdev->dev, sizeof(*ab8500), GFP_KERNEL); if (ab8500 == NULL) { dev_err(&pdev->dev, "failed to allocate memory\n"); return -ENOMEM; @@ -111,10 +111,8 @@ static int ab8500_pwm_probe(struct platform_device *pdev) ab8500->chip.npwm = 1; err = pwmchip_add(&ab8500->chip); - if (err < 0) { - kfree(ab8500); + if (err < 0) return err; - } dev_dbg(&pdev->dev, "pwm probe successful\n"); platform_set_drvdata(pdev, ab8500); @@ -132,7 +130,6 @@ static int ab8500_pwm_remove(struct platform_device *pdev) return err; dev_dbg(&pdev->dev, "pwm driver removed\n"); - kfree(ab8500); return 0; } From c509a8e521939ca1fd4ba31feca4718328044230 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Fri, 8 Mar 2013 13:03:31 +0900 Subject: [PATCH 03/27] pwm: samsung: convert s3c_pwm to dev_pm_ops Instead of using legacy suspend/resume methods, using newer dev_pm_ops structure allows better control over power management. Signed-off-by: Jingoo Han Signed-off-by: Thierry Reding --- drivers/pwm/pwm-samsung.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/pwm/pwm-samsung.c b/drivers/pwm/pwm-samsung.c index 5207e6cd8648..a0ece50d70bb 100644 --- a/drivers/pwm/pwm-samsung.c +++ b/drivers/pwm/pwm-samsung.c @@ -289,10 +289,10 @@ static int s3c_pwm_remove(struct platform_device *pdev) return 0; } -#ifdef CONFIG_PM -static int s3c_pwm_suspend(struct platform_device *pdev, pm_message_t state) +#ifdef CONFIG_PM_SLEEP +static int s3c_pwm_suspend(struct device *dev) { - struct s3c_chip *s3c = platform_get_drvdata(pdev); + struct s3c_chip *s3c = dev_get_drvdata(dev); /* No one preserve these values during suspend so reset them * Otherwise driver leaves PWM unconfigured if same values @@ -304,9 +304,9 @@ static int s3c_pwm_suspend(struct platform_device *pdev, pm_message_t state) return 0; } -static int s3c_pwm_resume(struct platform_device *pdev) +static int s3c_pwm_resume(struct device *dev) { - struct s3c_chip *s3c = platform_get_drvdata(pdev); + struct s3c_chip *s3c = dev_get_drvdata(dev); unsigned long tcon; /* Restore invertion */ @@ -316,21 +316,19 @@ static int s3c_pwm_resume(struct platform_device *pdev) return 0; } - -#else -#define s3c_pwm_suspend NULL -#define s3c_pwm_resume NULL #endif +static SIMPLE_DEV_PM_OPS(s3c_pwm_pm_ops, s3c_pwm_suspend, + s3c_pwm_resume); + static struct platform_driver s3c_pwm_driver = { .driver = { .name = "s3c24xx-pwm", .owner = THIS_MODULE, + .pm = &s3c_pwm_pm_ops, }, .probe = s3c_pwm_probe, .remove = s3c_pwm_remove, - .suspend = s3c_pwm_suspend, - .resume = s3c_pwm_resume, }; static int __init pwm_init(void) From b78f5fc92a836259b69d49129c6c1cad9b03c322 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Mon, 11 Mar 2013 11:12:58 +0900 Subject: [PATCH 04/27] pwm: pwm-tiecap: add CONFIG_PM_SLEEP to suspend/resume functions This patch adds CONFIG_PM_SLEEP to suspend/resume functions to fix the following build warning when CONFIG_PM_SLEEP is not selected. drivers/pwm/pwm-tiecap.c:314:12: warning: 'ecap_pwm_suspend' defined but not used [-Wunused-function] drivers/pwm/pwm-tiecap.c:328:12: warning: 'ecap_pwm_resume' defined but not used [-Wunused-function] Signed-off-by: Jingoo Han Signed-off-by: Thierry Reding --- drivers/pwm/pwm-tiecap.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/pwm/pwm-tiecap.c b/drivers/pwm/pwm-tiecap.c index 22e96e2bffd3..f024db06e6c4 100644 --- a/drivers/pwm/pwm-tiecap.c +++ b/drivers/pwm/pwm-tiecap.c @@ -311,6 +311,7 @@ void ecap_pwm_restore_context(struct ecap_pwm_chip *pc) writew(pc->ctx.ecctl2, pc->mmio_base + ECCTL2); } +#ifdef CONFIG_PM_SLEEP static int ecap_pwm_suspend(struct device *dev) { struct ecap_pwm_chip *pc = dev_get_drvdata(dev); @@ -337,6 +338,7 @@ static int ecap_pwm_resume(struct device *dev) ecap_pwm_restore_context(pc); return 0; } +#endif static SIMPLE_DEV_PM_OPS(ecap_pwm_pm_ops, ecap_pwm_suspend, ecap_pwm_resume); From c26e9bb4ac72312386dc8ffa4dc8c1b560d9b29b Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Mon, 11 Mar 2013 11:14:16 +0900 Subject: [PATCH 05/27] pwm: pwm-tipwmss: add CONFIG_PM_SLEEP to suspend/resume functions This patch adds CONFIG_PM_SLEEP to suspend/resume functions to fix the following build warning when CONFIG_PM_SLEEP is not selected. drivers/pwm/pwm-tipwmss.c:104:12: warning: 'pwmss_suspend' defined but not used [-Wunused-function] drivers/pwm/pwm-tipwmss.c:113:12: warning: 'pwmss_resume' defined but not used [-Wunused-function] Signed-off-by: Jingoo Han Signed-off-by: Thierry Reding --- drivers/pwm/pwm-tipwmss.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/pwm/pwm-tipwmss.c b/drivers/pwm/pwm-tipwmss.c index 17cbc59660ec..c9c3d3a1e0eb 100644 --- a/drivers/pwm/pwm-tipwmss.c +++ b/drivers/pwm/pwm-tipwmss.c @@ -101,6 +101,7 @@ static int pwmss_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM_SLEEP static int pwmss_suspend(struct device *dev) { struct pwmss_info *info = dev_get_drvdata(dev); @@ -118,6 +119,7 @@ static int pwmss_resume(struct device *dev) writew(info->pwmss_clkconfig, info->mmio_base + PWMSS_CLKCONFIG); return 0; } +#endif static SIMPLE_DEV_PM_OPS(pwmss_pm_ops, pwmss_suspend, pwmss_resume); From 29258b215af83dbb4ad143cefe7a1e5d0384a605 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Mon, 11 Mar 2013 11:14:41 +0900 Subject: [PATCH 06/27] pwm: pwm-tiehrpwm: add CONFIG_PM_SLEEP to suspend/resume functions This patch adds CONFIG_PM_SLEEP to suspend/resume functions to fix the following build warning when CONFIG_PM_SLEEP is not selected. drivers/pwm/pwm-tiehrpwm.c:562:12: warning: 'ehrpwm_pwm_suspend' defined but not used [-Wunused-function] drivers/pwm/pwm-tiehrpwm.c:580:12: warning: 'ehrpwm_pwm_resume' defined but not used [-Wunused-function Signed-off-by: Jingoo Han Signed-off-by: Thierry Reding --- drivers/pwm/pwm-tiehrpwm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/pwm/pwm-tiehrpwm.c b/drivers/pwm/pwm-tiehrpwm.c index 8b4c86fa99c8..d058ba90845b 100644 --- a/drivers/pwm/pwm-tiehrpwm.c +++ b/drivers/pwm/pwm-tiehrpwm.c @@ -559,6 +559,7 @@ void ehrpwm_pwm_restore_context(struct ehrpwm_pwm_chip *pc) ehrpwm_write(pc->mmio_base, TBCTL, pc->ctx.tbctl); } +#ifdef CONFIG_PM_SLEEP static int ehrpwm_pwm_suspend(struct device *dev) { struct ehrpwm_pwm_chip *pc = dev_get_drvdata(dev); @@ -594,6 +595,7 @@ static int ehrpwm_pwm_resume(struct device *dev) ehrpwm_pwm_restore_context(pc); return 0; } +#endif static SIMPLE_DEV_PM_OPS(ehrpwm_pwm_pm_ops, ehrpwm_pwm_suspend, ehrpwm_pwm_resume); From 1bf0f20bcc153f4f97bbcc52cd7f0596b427ef34 Mon Sep 17 00:00:00 2001 From: Philip Avinash Date: Wed, 20 Mar 2013 12:09:24 +0530 Subject: [PATCH 07/27] pwm: davinci: Add Kconfig support for ECAP & EHRPWM devices Add EHRPWM and ECAP support build support for DAVINCI_DA8XX platforms. Also, since DAVINCI platforms doesn't support TI-PWM-Subsystem module, remove the select option for CONFIG_PWM_TIPWMSS. Also, update CONFIG_PWM_TIPWMSS compiler directive appropriately in pwm-tipwmss.h to fix the below compiler error upon removal of CONFIG_PWM_TIPWMSS for DAVINCI platforms. drivers/pwm/pwm-tiecap.c: In function 'ecap_pwm_probe': drivers/pwm/pwm-tiecap.c:263:4: error: 'PWMSS_ECAPCLK_EN' undeclared (first use in this function) drivers/pwm/pwm-tiecap.c:263:4: note: each undeclared identifier is reported only once for each function it appears in drivers/pwm/pwm-tiecap.c:264:17: error: 'PWMSS_ECAPCLK_EN_ACK' undeclared (first use in this function) drivers/pwm/pwm-tiecap.c: In function 'ecap_pwm_remove': drivers/pwm/pwm-tiecap.c:291:49: error: 'PWMSS_ECAPCLK_STOP_REQ' undeclared (first use in this function) make[2]: *** [drivers/pwm/pwm-tiecap.o] Error 1 make[1]: *** [drivers/pwm] Error 2 make: *** [drivers] Error 2 Signed-off-by: Philip Avinash Signed-off-by: Thierry Reding --- drivers/pwm/Kconfig | 8 +++----- drivers/pwm/pwm-tipwmss.h | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig index 0e0bfa035083..115b64453493 100644 --- a/drivers/pwm/Kconfig +++ b/drivers/pwm/Kconfig @@ -147,8 +147,7 @@ config PWM_TEGRA config PWM_TIECAP tristate "ECAP PWM support" - depends on SOC_AM33XX - select PWM_TIPWMSS + depends on SOC_AM33XX || ARCH_DAVINCI_DA8XX help PWM driver support for the ECAP APWM controller found on AM33XX TI SOC @@ -158,8 +157,7 @@ config PWM_TIECAP config PWM_TIEHRPWM tristate "EHRPWM PWM support" - depends on SOC_AM33XX - select PWM_TIPWMSS + depends on SOC_AM33XX || ARCH_DAVINCI_DA8XX help PWM driver support for the EHRPWM controller found on AM33XX TI SOC @@ -169,7 +167,7 @@ config PWM_TIEHRPWM config PWM_TIPWMSS bool - depends on SOC_AM33XX && (PWM_TIEHRPWM || PWM_TIECAP) + default y if SOC_AM33XX && (PWM_TIECAP || PWM_TIEHRPWM) help PWM Subsystem driver support for AM33xx SOC. diff --git a/drivers/pwm/pwm-tipwmss.h b/drivers/pwm/pwm-tipwmss.h index 11f76a1e266b..10ad8040408b 100644 --- a/drivers/pwm/pwm-tipwmss.h +++ b/drivers/pwm/pwm-tipwmss.h @@ -18,7 +18,6 @@ #ifndef __TIPWMSS_H #define __TIPWMSS_H -#ifdef CONFIG_PWM_TIPWMSS /* PWM substem clock gating */ #define PWMSS_ECAPCLK_EN BIT(0) #define PWMSS_ECAPCLK_STOP_REQ BIT(1) @@ -28,6 +27,7 @@ #define PWMSS_ECAPCLK_EN_ACK BIT(0) #define PWMSS_EPWMCLK_EN_ACK BIT(8) +#ifdef CONFIG_PWM_TIPWMSS extern u16 pwmss_submodule_state_change(struct device *dev, int set); #else static inline u16 pwmss_submodule_state_change(struct device *dev, int set) From 622fc5d4452a20aab7b8f5107c2931c5610e5753 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Tue, 26 Mar 2013 22:34:50 +0800 Subject: [PATCH 08/27] pwm: ab8500: Fix trivial typo in dev_err message Signed-off-by: Axel Lin Signed-off-by: Thierry Reding --- drivers/pwm/pwm-ab8500.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pwm/pwm-ab8500.c b/drivers/pwm/pwm-ab8500.c index 93af1bbf88ce..3beb2b52bd2e 100644 --- a/drivers/pwm/pwm-ab8500.c +++ b/drivers/pwm/pwm-ab8500.c @@ -66,7 +66,7 @@ static int ab8500_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) AB8500_MISC, AB8500_PWM_OUT_CTRL7_REG, 1 << (chip->base - 1), ENABLE_PWM); if (ret < 0) - dev_err(chip->dev, "%s: Failed to disable PWM, Error %d\n", + dev_err(chip->dev, "%s: Failed to enable PWM, Error %d\n", pwm->label, ret); return ret; } From a38c9898574967c5a8ab670f1b27d9ecf71d32cc Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Tue, 26 Mar 2013 22:54:58 +0800 Subject: [PATCH 09/27] pwm: tiecap: Staticize non-exported symbols Both ecap_pwm_save_context() and ecap_pwm_restore_context() are only used in this file, make them static. Signed-off-by: Axel Lin Signed-off-by: Thierry Reding --- drivers/pwm/pwm-tiecap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pwm/pwm-tiecap.c b/drivers/pwm/pwm-tiecap.c index f024db06e6c4..0d65fb2e02c7 100644 --- a/drivers/pwm/pwm-tiecap.c +++ b/drivers/pwm/pwm-tiecap.c @@ -295,7 +295,7 @@ static int ecap_pwm_remove(struct platform_device *pdev) return pwmchip_remove(&pc->chip); } -void ecap_pwm_save_context(struct ecap_pwm_chip *pc) +static void ecap_pwm_save_context(struct ecap_pwm_chip *pc) { pm_runtime_get_sync(pc->chip.dev); pc->ctx.ecctl2 = readw(pc->mmio_base + ECCTL2); @@ -304,7 +304,7 @@ void ecap_pwm_save_context(struct ecap_pwm_chip *pc) pm_runtime_put_sync(pc->chip.dev); } -void ecap_pwm_restore_context(struct ecap_pwm_chip *pc) +static void ecap_pwm_restore_context(struct ecap_pwm_chip *pc) { writel(pc->ctx.cap3, pc->mmio_base + CAP3); writel(pc->ctx.cap4, pc->mmio_base + CAP4); From b343a1887ea4f798758d0023838d16a428f728d5 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Tue, 26 Mar 2013 22:55:57 +0800 Subject: [PATCH 10/27] pwm: tiehrpwm: Staticize non-exported symbols Both ehrpwm_pwm_save_context() and ehrpwm_pwm_restore_context() are only used in this file, make them static. Signed-off-by: Axel Lin Signed-off-by: Thierry Reding --- drivers/pwm/pwm-tiehrpwm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pwm/pwm-tiehrpwm.c b/drivers/pwm/pwm-tiehrpwm.c index d058ba90845b..6a217596942f 100644 --- a/drivers/pwm/pwm-tiehrpwm.c +++ b/drivers/pwm/pwm-tiehrpwm.c @@ -533,7 +533,7 @@ static int ehrpwm_pwm_remove(struct platform_device *pdev) return pwmchip_remove(&pc->chip); } -void ehrpwm_pwm_save_context(struct ehrpwm_pwm_chip *pc) +static void ehrpwm_pwm_save_context(struct ehrpwm_pwm_chip *pc) { pm_runtime_get_sync(pc->chip.dev); pc->ctx.tbctl = ehrpwm_read(pc->mmio_base, TBCTL); @@ -547,7 +547,7 @@ void ehrpwm_pwm_save_context(struct ehrpwm_pwm_chip *pc) pm_runtime_put_sync(pc->chip.dev); } -void ehrpwm_pwm_restore_context(struct ehrpwm_pwm_chip *pc) +static void ehrpwm_pwm_restore_context(struct ehrpwm_pwm_chip *pc) { ehrpwm_write(pc->mmio_base, TBPRD, pc->ctx.tbprd); ehrpwm_write(pc->mmio_base, CMPA, pc->ctx.cmpa); From 563861cd633ae52932843477bb6ca3f1c9e2f78b Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Sat, 30 Mar 2013 20:43:22 +0800 Subject: [PATCH 11/27] pwm: spear: Fix checking return value of clk_enable() and clk_prepare() The logic to check return value of clk_enable() and clk_prepare() is reversed, fix it. Signed-off-by: Axel Lin Cc: stable@vger.kernel.org Acked-by: Viresh Kumar Signed-off-by: Thierry Reding --- drivers/pwm/pwm-spear.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/pwm/pwm-spear.c b/drivers/pwm/pwm-spear.c index 69a2d9eb34db..3223b57e8f9c 100644 --- a/drivers/pwm/pwm-spear.c +++ b/drivers/pwm/pwm-spear.c @@ -143,7 +143,7 @@ static int spear_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) u32 val; rc = clk_enable(pc->clk); - if (!rc) + if (rc) return rc; val = spear_pwm_readl(pc, pwm->hwpwm, PWMCR); @@ -209,12 +209,12 @@ static int spear_pwm_probe(struct platform_device *pdev) pc->chip.npwm = NUM_PWM; ret = clk_prepare(pc->clk); - if (!ret) + if (ret) return ret; if (of_device_is_compatible(np, "st,spear1340-pwm")) { ret = clk_enable(pc->clk); - if (!ret) { + if (ret) { clk_unprepare(pc->clk); return ret; } From fa0abee9b89e3a0bab207823bd16372de53c3896 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Sun, 31 Mar 2013 11:14:02 +0800 Subject: [PATCH 12/27] pwm: ab8500: Add .owner to struct pwm_ops Add missing .owner of struct pwm_ops. This prevents the module from being removed from underneath its users. Signed-off-by: Axel Lin Signed-off-by: Thierry Reding --- drivers/pwm/pwm-ab8500.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/pwm/pwm-ab8500.c b/drivers/pwm/pwm-ab8500.c index 3beb2b52bd2e..1d07a6f99375 100644 --- a/drivers/pwm/pwm-ab8500.c +++ b/drivers/pwm/pwm-ab8500.c @@ -88,6 +88,7 @@ static const struct pwm_ops ab8500_pwm_ops = { .config = ab8500_pwm_config, .enable = ab8500_pwm_enable, .disable = ab8500_pwm_disable, + .owner = THIS_MODULE, }; static int ab8500_pwm_probe(struct platform_device *pdev) From 83c80dc5358270a665666ea5b9ddd24351d86354 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Sun, 31 Mar 2013 11:15:15 +0800 Subject: [PATCH 13/27] pwm: atmel-tcb: Add .owner to struct pwm_ops Add missing .owner of struct pwm_ops. This prevents the module from being removed from underneath its users. Signed-off-by: Axel Lin Signed-off-by: Thierry Reding --- drivers/pwm/pwm-atmel-tcb.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/pwm/pwm-atmel-tcb.c b/drivers/pwm/pwm-atmel-tcb.c index 16cb53092857..0a7b6582edb1 100644 --- a/drivers/pwm/pwm-atmel-tcb.c +++ b/drivers/pwm/pwm-atmel-tcb.c @@ -358,6 +358,7 @@ static const struct pwm_ops atmel_tcb_pwm_ops = { .set_polarity = atmel_tcb_pwm_set_polarity, .enable = atmel_tcb_pwm_enable, .disable = atmel_tcb_pwm_disable, + .owner = THIS_MODULE, }; static int atmel_tcb_pwm_probe(struct platform_device *pdev) From 7fa25314d534b9449d1705722eac412cad5c9042 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Sun, 31 Mar 2013 11:16:14 +0800 Subject: [PATCH 14/27] pwm: twl-led: Add .owner to struct pwm_ops Add missing .owner of struct pwm_ops. This prevents the module from being removed from underneath its users. Signed-off-by: Axel Lin Acked-by: Peter Ujfalusi Signed-off-by: Thierry Reding --- drivers/pwm/pwm-twl-led.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/pwm/pwm-twl-led.c b/drivers/pwm/pwm-twl-led.c index 83e25d45d640..f912e87aed88 100644 --- a/drivers/pwm/pwm-twl-led.c +++ b/drivers/pwm/pwm-twl-led.c @@ -271,6 +271,7 @@ static const struct pwm_ops twl4030_pwmled_ops = { .enable = twl4030_pwmled_enable, .disable = twl4030_pwmled_disable, .config = twl4030_pwmled_config, + .owner = THIS_MODULE, }; static const struct pwm_ops twl6030_pwmled_ops = { @@ -279,6 +280,7 @@ static const struct pwm_ops twl6030_pwmled_ops = { .config = twl6030_pwmled_config, .request = twl6030_pwmled_request, .free = twl6030_pwmled_free, + .owner = THIS_MODULE, }; static int twl_pwmled_probe(struct platform_device *pdev) From d5714e8b9de5d3a82347fe37a9038373c44afce0 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Sun, 31 Mar 2013 11:17:05 +0800 Subject: [PATCH 15/27] pwm: twl: Add .owner to struct pwm_ops Add missing .owner of struct pwm_ops. This prevents the module from being removed from underneath its users. Signed-off-by: Axel Lin Acked-by: Peter Ujfalusi Signed-off-by: Thierry Reding --- drivers/pwm/pwm-twl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/pwm/pwm-twl.c b/drivers/pwm/pwm-twl.c index bf3fda294223..ee7fa5ddba5d 100644 --- a/drivers/pwm/pwm-twl.c +++ b/drivers/pwm/pwm-twl.c @@ -287,12 +287,14 @@ static const struct pwm_ops twl4030_pwm_ops = { .disable = twl4030_pwm_disable, .request = twl4030_pwm_request, .free = twl4030_pwm_free, + .owner = THIS_MODULE, }; static const struct pwm_ops twl6030_pwm_ops = { .config = twl_pwm_config, .enable = twl6030_pwm_enable, .disable = twl6030_pwm_disable, + .owner = THIS_MODULE, }; static int twl_pwm_probe(struct platform_device *pdev) From 72da70e77f885ec9a79af9c13ff1c79b6136b75f Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Sun, 31 Mar 2013 22:59:47 +0800 Subject: [PATCH 16/27] pwm: imx: Remove enabled field from struct imx_chip We can test PWMF_ENABLED bit to know if pwm is enabled or not. Thus remove enabled field from struct imx_chip. Signed-off-by: Axel Lin Acked-by: Sascha Hauer Signed-off-by: Thierry Reding --- drivers/pwm/pwm-imx.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/pwm/pwm-imx.c b/drivers/pwm/pwm-imx.c index 3f5677b7690e..ec287989eafc 100644 --- a/drivers/pwm/pwm-imx.c +++ b/drivers/pwm/pwm-imx.c @@ -43,7 +43,6 @@ struct imx_chip { struct clk *clk_per; struct clk *clk_ipg; - int enabled; void __iomem *mmio_base; struct pwm_chip chip; @@ -135,7 +134,7 @@ static int imx_pwm_config_v2(struct pwm_chip *chip, MX3_PWMCR_DOZEEN | MX3_PWMCR_WAITEN | MX3_PWMCR_DBGEN | MX3_PWMCR_CLKSRC_IPG_HIGH; - if (imx->enabled) + if (test_bit(PWMF_ENABLED, &pwm->flags)) cr |= MX3_PWMCR_EN; writel(cr, imx->mmio_base + MX3_PWMCR); @@ -186,8 +185,6 @@ static int imx_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) imx->set_enable(chip, true); - imx->enabled = 1; - return 0; } @@ -198,7 +195,6 @@ static void imx_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) imx->set_enable(chip, false); clk_disable_unprepare(imx->clk_per); - imx->enabled = 0; } static struct pwm_ops imx_pwm_ops = { From b014a30c5991e67aa90b6ff9bd4ec16435bbcefd Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Sun, 31 Mar 2013 23:04:31 +0800 Subject: [PATCH 17/27] pwm: pxa: Remove clk_enabled field from struct pxa_pwm_chip clk_enable/clk_disable maintain an enable_count, clk_prepare and clk_unprepare also maintain a prepare_count. These APIs will do prepare/enable when the first user calling these APIs, and do disable/unprepare when the corresponding counter reach 0. Thus We don't need to maintain a clk_enabled counter here. Signed-off-by: Axel Lin Acked-by: Eric Miao Signed-off-by: Thierry Reding --- drivers/pwm/pwm-pxa.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/drivers/pwm/pwm-pxa.c b/drivers/pwm/pwm-pxa.c index 20370e61de5a..b78988255aee 100644 --- a/drivers/pwm/pwm-pxa.c +++ b/drivers/pwm/pwm-pxa.c @@ -48,7 +48,6 @@ struct pxa_pwm_chip { struct device *dev; struct clk *clk; - int clk_enabled; void __iomem *mmio_base; }; @@ -108,24 +107,15 @@ static int pxa_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, static int pxa_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) { struct pxa_pwm_chip *pc = to_pxa_pwm_chip(chip); - int rc = 0; - if (!pc->clk_enabled) { - rc = clk_prepare_enable(pc->clk); - if (!rc) - pc->clk_enabled++; - } - return rc; + return clk_prepare_enable(pc->clk); } static void pxa_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) { struct pxa_pwm_chip *pc = to_pxa_pwm_chip(chip); - if (pc->clk_enabled) { - clk_disable_unprepare(pc->clk); - pc->clk_enabled--; - } + clk_disable_unprepare(pc->clk); } static struct pwm_ops pxa_pwm_ops = { @@ -152,8 +142,6 @@ static int pwm_probe(struct platform_device *pdev) if (IS_ERR(pwm->clk)) return PTR_ERR(pwm->clk); - pwm->clk_enabled = 0; - pwm->chip.dev = &pdev->dev; pwm->chip.ops = &pxa_pwm_ops; pwm->chip.base = -1; From c8e4df3109646762f21c6e288187ec395fdf67be Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Sun, 31 Mar 2013 23:07:30 +0800 Subject: [PATCH 18/27] pwm: twl: Return proper error if twl6030_pwm_enable() fails Return proper error instead of 0 if twl6030_pwm_enable() fails. Signed-off-by: Axel Lin Acked-by: Peter Ujfalusi Signed-off-by: Thierry Reding --- drivers/pwm/pwm-twl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pwm/pwm-twl.c b/drivers/pwm/pwm-twl.c index ee7fa5ddba5d..2782001ba183 100644 --- a/drivers/pwm/pwm-twl.c +++ b/drivers/pwm/pwm-twl.c @@ -248,7 +248,7 @@ static int twl6030_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) twl->twl6030_toggle3 = val; out: mutex_unlock(&twl->mutex); - return 0; + return ret; } static void twl6030_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) From 4e61573df893abcb7b647fc4f3f4b60819704883 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Mon, 1 Apr 2013 10:48:13 +0800 Subject: [PATCH 19/27] pwm: mxs: Remove unused *dev from struct mxs_pwm_chip Signed-off-by: Axel Lin Acked-by: Shawn Guo Signed-off-by: Thierry Reding --- drivers/pwm/pwm-mxs.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/pwm/pwm-mxs.c b/drivers/pwm/pwm-mxs.c index a53d3094b75a..23d51806aeaa 100644 --- a/drivers/pwm/pwm-mxs.c +++ b/drivers/pwm/pwm-mxs.c @@ -38,7 +38,6 @@ struct mxs_pwm_chip { struct pwm_chip chip; - struct device *dev; struct clk *clk; void __iomem *base; }; @@ -166,7 +165,6 @@ static int mxs_pwm_probe(struct platform_device *pdev) return ret; } - mxs->dev = &pdev->dev; platform_set_drvdata(pdev, mxs); stmp_reset_block(mxs->base); From b3fef7f10010e7946b3db1a34d8e0208e4f10001 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Mon, 1 Apr 2013 12:29:48 +0800 Subject: [PATCH 20/27] pwm: spear: Remove unused *dev from struct spear_pwm_chip Signed-off-by: Axel Lin Acked-by: Shiraz Hashim Acked-by: Viresh Kumar Signed-off-by: Thierry Reding --- drivers/pwm/pwm-spear.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/pwm/pwm-spear.c b/drivers/pwm/pwm-spear.c index 3223b57e8f9c..9563599a117e 100644 --- a/drivers/pwm/pwm-spear.c +++ b/drivers/pwm/pwm-spear.c @@ -49,13 +49,11 @@ * @mmio_base: base address of pwm chip * @clk: pointer to clk structure of pwm chip * @chip: linux pwm chip representation - * @dev: pointer to device structure of pwm chip */ struct spear_pwm_chip { void __iomem *mmio_base; struct clk *clk; struct pwm_chip chip; - struct device *dev; }; static inline struct spear_pwm_chip *to_spear_pwm_chip(struct pwm_chip *chip) @@ -200,7 +198,6 @@ static int spear_pwm_probe(struct platform_device *pdev) if (IS_ERR(pc->clk)) return PTR_ERR(pc->clk); - pc->dev = &pdev->dev; platform_set_drvdata(pdev, pc); pc->chip.dev = &pdev->dev; From 22976a5dada65a0f44918e91c5f1fb5041dc1d5e Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Mon, 1 Apr 2013 15:41:22 +0800 Subject: [PATCH 21/27] pwm: pxa: Remove PWM_ID_BASE macro PWM_ID_BASE() is not used after convert to PWM framework, remove it. Also update driver_data field of struct platform_device_id accordingly. Signed-off-by: Axel Lin Acked-by: Eric Miao Signed-off-by: Thierry Reding --- drivers/pwm/pwm-pxa.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/pwm/pwm-pxa.c b/drivers/pwm/pwm-pxa.c index b78988255aee..dee6ab552a0a 100644 --- a/drivers/pwm/pwm-pxa.c +++ b/drivers/pwm/pwm-pxa.c @@ -23,14 +23,13 @@ #include #define HAS_SECONDARY_PWM 0x10 -#define PWM_ID_BASE(d) ((d) & 0xf) static const struct platform_device_id pwm_id_table[] = { /* PWM has_secondary_pwm? */ { "pxa25x-pwm", 0 }, - { "pxa27x-pwm", 0 | HAS_SECONDARY_PWM }, - { "pxa168-pwm", 1 }, - { "pxa910-pwm", 1 }, + { "pxa27x-pwm", HAS_SECONDARY_PWM }, + { "pxa168-pwm", 0 }, + { "pxa910-pwm", 0 }, { }, }; MODULE_DEVICE_TABLE(platform, pwm_id_table); From a46ef4d5723aca785e6b03b7972dd83e43e73977 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Sun, 31 Mar 2013 23:01:11 +0800 Subject: [PATCH 22/27] pwm: puv3: Remove unused enabled filed from struct puv3_pwm_chip Signed-off-by: Axel Lin Signed-off-by: Thierry Reding --- drivers/pwm/pwm-puv3.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/pwm/pwm-puv3.c b/drivers/pwm/pwm-puv3.c index db964e6ecf5c..d1eb499fb15d 100644 --- a/drivers/pwm/pwm-puv3.c +++ b/drivers/pwm/pwm-puv3.c @@ -27,7 +27,6 @@ struct puv3_pwm_chip { struct pwm_chip chip; void __iomem *base; struct clk *clk; - bool enabled; }; static inline struct puv3_pwm_chip *to_puv3(struct pwm_chip *chip) From 5df1b8fb6585a20cdf1d1fd50deecbf1983f2835 Mon Sep 17 00:00:00 2001 From: Philip Avinash Date: Mon, 25 Mar 2013 12:34:52 +0530 Subject: [PATCH 23/27] pwm: pwm-tiecap: Update device-tree binding document Update binding document of pwm-tiecap to reflect the usage of similar modules in da850 and am3xx SOCs. Signed-off-by: Philip Avinash Cc: Grant Likely Cc: Rob Herring Cc: Rob Landley Acked-by: Peter Korsgaard Signed-off-by: Thierry Reding --- Documentation/devicetree/bindings/pwm/pwm-tiecap.txt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/pwm/pwm-tiecap.txt b/Documentation/devicetree/bindings/pwm/pwm-tiecap.txt index 131e8c11d26f..681afad73778 100644 --- a/Documentation/devicetree/bindings/pwm/pwm-tiecap.txt +++ b/Documentation/devicetree/bindings/pwm/pwm-tiecap.txt @@ -1,7 +1,9 @@ TI SOC ECAP based APWM controller Required properties: -- compatible: Must be "ti,am33xx-ecap" +- compatible: Must be "ti,-ecap". + for am33xx - compatible = "ti,am33xx-ecap"; + for da850 - compatible = "ti,da850-ecap", "ti,am33xx-ecap"; - #pwm-cells: Should be 3. Number of cells being used to specify PWM property. First cell specifies the per-chip index of the PWM to use, the second cell is the period in nanoseconds and bit 0 in the third cell is used to @@ -15,9 +17,15 @@ Optional properties: Example: -ecap0: ecap@0 { +ecap0: ecap@0 { /* ECAP on am33xx */ compatible = "ti,am33xx-ecap"; #pwm-cells = <3>; reg = <0x48300100 0x80>; ti,hwmods = "ecap0"; }; + +ecap0: ecap@0 { /* ECAP on da850 */ + compatible = "ti,da850-ecap", "ti,am33xx-ecap"; + #pwm-cells = <3>; + reg = <0x306000 0x80>; +}; From bdd7cf97153d354f654379563483bdb5a774ef16 Mon Sep 17 00:00:00 2001 From: Philip Avinash Date: Mon, 25 Mar 2013 12:34:53 +0530 Subject: [PATCH 24/27] pwm: pwm-tiehrpwm: Update device-tree binding document Update binding document of pwm-tiehrpwm to reflect the usage of similar modules in da850 and am3xx SOCs. Signed-off-by: Philip Avinash Cc: Grant Likely Cc: Rob Herring Cc: Rob Landley Acked-by: Peter Korsgaard Signed-off-by: Thierry Reding --- .../devicetree/bindings/pwm/pwm-tiehrpwm.txt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/pwm/pwm-tiehrpwm.txt b/Documentation/devicetree/bindings/pwm/pwm-tiehrpwm.txt index 4fc7079d822e..337c6fc65d3f 100644 --- a/Documentation/devicetree/bindings/pwm/pwm-tiehrpwm.txt +++ b/Documentation/devicetree/bindings/pwm/pwm-tiehrpwm.txt @@ -1,7 +1,9 @@ TI SOC EHRPWM based PWM controller Required properties: -- compatible : Must be "ti,am33xx-ehrpwm" +- compatible: Must be "ti,-ehrpwm". + for am33xx - compatible = "ti,am33xx-ehrpwm"; + for da850 - compatible = "ti,da850-ehrpwm", "ti,am33xx-ehrpwm"; - #pwm-cells: Should be 3. Number of cells being used to specify PWM property. First cell specifies the per-chip index of the PWM to use, the second cell is the period in nanoseconds and bit 0 in the third cell is used to @@ -15,9 +17,15 @@ Optional properties: Example: -ehrpwm0: ehrpwm@0 { +ehrpwm0: ehrpwm@0 { /* EHRPWM on am33xx */ compatible = "ti,am33xx-ehrpwm"; #pwm-cells = <3>; reg = <0x48300200 0x100>; ti,hwmods = "ehrpwm0"; }; + +ehrpwm0: ehrpwm@0 { /* EHRPWM on da850 */ + compatible = "ti,da850-ehrpwm", "ti,am33xx-ehrpwm"; + #pwm-cells = <3>; + reg = <0x300000 0x2000>; +}; From f1a8870aeb5baeb58f0613d1f1e1dca967127fbd Mon Sep 17 00:00:00 2001 From: Thierry Reding Date: Thu, 18 Apr 2013 10:04:14 +0200 Subject: [PATCH 25/27] pwm: Constify OF match tables A few drivers already annotate this properly. Make the same change for all other OF supporting drivers. Signed-off-by: Thierry Reding Acked-by: Shawn Guo Acked-by: Alexandre Pereira da Silva Acked-by: Viresh Kumar --- drivers/pwm/pwm-lpc32xx.c | 2 +- drivers/pwm/pwm-mxs.c | 2 +- drivers/pwm/pwm-spear.c | 2 +- drivers/pwm/pwm-tegra.c | 2 +- drivers/pwm/pwm-twl-led.c | 2 +- drivers/pwm/pwm-twl.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/pwm/pwm-lpc32xx.c b/drivers/pwm/pwm-lpc32xx.c index b3f0d0dfd748..b55cc5c1d614 100644 --- a/drivers/pwm/pwm-lpc32xx.c +++ b/drivers/pwm/pwm-lpc32xx.c @@ -145,7 +145,7 @@ static int lpc32xx_pwm_remove(struct platform_device *pdev) return pwmchip_remove(&lpc32xx->chip); } -static struct of_device_id lpc32xx_pwm_dt_ids[] = { +static const struct of_device_id lpc32xx_pwm_dt_ids[] = { { .compatible = "nxp,lpc3220-pwm", }, { /* sentinel */ } }; diff --git a/drivers/pwm/pwm-mxs.c b/drivers/pwm/pwm-mxs.c index 23d51806aeaa..3febdddf71f9 100644 --- a/drivers/pwm/pwm-mxs.c +++ b/drivers/pwm/pwm-mxs.c @@ -179,7 +179,7 @@ static int mxs_pwm_remove(struct platform_device *pdev) return pwmchip_remove(&mxs->chip); } -static struct of_device_id mxs_pwm_dt_ids[] = { +static const struct of_device_id mxs_pwm_dt_ids[] = { { .compatible = "fsl,imx23-pwm", }, { /* sentinel */ } }; diff --git a/drivers/pwm/pwm-spear.c b/drivers/pwm/pwm-spear.c index 9563599a117e..6d99e2cbdc73 100644 --- a/drivers/pwm/pwm-spear.c +++ b/drivers/pwm/pwm-spear.c @@ -248,7 +248,7 @@ static int spear_pwm_remove(struct platform_device *pdev) return pwmchip_remove(&pc->chip); } -static struct of_device_id spear_pwm_of_match[] = { +static const struct of_device_id spear_pwm_of_match[] = { { .compatible = "st,spear320-pwm" }, { .compatible = "st,spear1340-pwm" }, { } diff --git a/drivers/pwm/pwm-tegra.c b/drivers/pwm/pwm-tegra.c index af3ab48cb7ef..3d75f4a88f98 100644 --- a/drivers/pwm/pwm-tegra.c +++ b/drivers/pwm/pwm-tegra.c @@ -233,7 +233,7 @@ static int tegra_pwm_remove(struct platform_device *pdev) return pwmchip_remove(&pc->chip); } -static struct of_device_id tegra_pwm_of_match[] = { +static const struct of_device_id tegra_pwm_of_match[] = { { .compatible = "nvidia,tegra20-pwm" }, { .compatible = "nvidia,tegra30-pwm" }, { } diff --git a/drivers/pwm/pwm-twl-led.c b/drivers/pwm/pwm-twl-led.c index f912e87aed88..29d1bba4804e 100644 --- a/drivers/pwm/pwm-twl-led.c +++ b/drivers/pwm/pwm-twl-led.c @@ -323,7 +323,7 @@ static int twl_pwmled_remove(struct platform_device *pdev) } #ifdef CONFIG_OF -static struct of_device_id twl_pwmled_of_match[] = { +static const struct of_device_id twl_pwmled_of_match[] = { { .compatible = "ti,twl4030-pwmled" }, { .compatible = "ti,twl6030-pwmled" }, { }, diff --git a/drivers/pwm/pwm-twl.c b/drivers/pwm/pwm-twl.c index 2782001ba183..eef910580eae 100644 --- a/drivers/pwm/pwm-twl.c +++ b/drivers/pwm/pwm-twl.c @@ -335,7 +335,7 @@ static int twl_pwm_remove(struct platform_device *pdev) } #ifdef CONFIG_OF -static struct of_device_id twl_pwm_of_match[] = { +static const struct of_device_id twl_pwm_of_match[] = { { .compatible = "ti,twl4030-pwm" }, { .compatible = "ti,twl6030-pwm" }, { }, From 08ee77b5a5de27ad63c92262ebcb4efe0da93b58 Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Tue, 23 Apr 2013 14:01:31 +0800 Subject: [PATCH 26/27] pwm: lpc32xx: Properly set PWM_ENABLE bit in lpc32xx_pwm_[enable|disable] According to the LPC32x0 User Manual [1]: For both PWM1 and PWM2 Control Registers: BIT 31: This bit gates the PWM_CLK signal and enables the external output pin to the PWM_PIN_STATE logical level. 0 = PWM disabled. (Default) 1 = PWM enabled So in lpc32xx_pwm_enable(), we should set PWM_ENABLE bit. In lpc32xx_pwm_disable(), we should just clear PWM_ENABLE bit rather than write 0 to the register which will also clear PWMx_RELOADV and PWMx_DUTY bits. [1] http://www.nxp.com/documents/user_manual/UM10326.pdf Signed-off-by: Axel Lin Tested-by: Roland Stigge Signed-off-by: Thierry Reding --- drivers/pwm/pwm-lpc32xx.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/pwm/pwm-lpc32xx.c b/drivers/pwm/pwm-lpc32xx.c index b55cc5c1d614..6b6272f61da5 100644 --- a/drivers/pwm/pwm-lpc32xx.c +++ b/drivers/pwm/pwm-lpc32xx.c @@ -77,15 +77,29 @@ static int lpc32xx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, static int lpc32xx_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) { struct lpc32xx_pwm_chip *lpc32xx = to_lpc32xx_pwm_chip(chip); + u32 val; + int ret; - return clk_enable(lpc32xx->clk); + ret = clk_enable(lpc32xx->clk); + if (ret) + return ret; + + val = readl(lpc32xx->base + (pwm->hwpwm << 2)); + val |= PWM_ENABLE; + writel(val, lpc32xx->base + (pwm->hwpwm << 2)); + + return 0; } static void lpc32xx_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) { struct lpc32xx_pwm_chip *lpc32xx = to_lpc32xx_pwm_chip(chip); + u32 val; + + val = readl(lpc32xx->base + (pwm->hwpwm << 2)); + val &= ~PWM_ENABLE; + writel(val, lpc32xx->base + (pwm->hwpwm << 2)); - writel(0, lpc32xx->base + (pwm->hwpwm << 2)); clk_disable(lpc32xx->clk); } From affb923df96d6c927f9a3dfb0e6f4be940b185cd Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Tue, 23 Apr 2013 14:02:49 +0800 Subject: [PATCH 27/27] pwm: lpc32xx: Don't change PWM_ENABLE bit in lpc32xx_pwm_config lpc32xx_pwm_config() is supposed to set duty_ns and period_ns, it should not change PWM_ENABLE bit. Signed-off-by: Axel Lin Tested-by: Roland Stigge Signed-off-by: Thierry Reding --- drivers/pwm/pwm-lpc32xx.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/pwm/pwm-lpc32xx.c b/drivers/pwm/pwm-lpc32xx.c index 6b6272f61da5..8272883c0d05 100644 --- a/drivers/pwm/pwm-lpc32xx.c +++ b/drivers/pwm/pwm-lpc32xx.c @@ -37,6 +37,7 @@ static int lpc32xx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, struct lpc32xx_pwm_chip *lpc32xx = to_lpc32xx_pwm_chip(chip); unsigned long long c; int period_cycles, duty_cycles; + u32 val; c = clk_get_rate(lpc32xx->clk) / 256; c = c * period_ns; @@ -68,8 +69,10 @@ static int lpc32xx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, c = 255; duty_cycles = 256 - c; - writel(PWM_ENABLE | PWM_RELOADV(period_cycles) | PWM_DUTY(duty_cycles), - lpc32xx->base + (pwm->hwpwm << 2)); + val = readl(lpc32xx->base + (pwm->hwpwm << 2)); + val &= ~0xFFFF; + val |= PWM_RELOADV(period_cycles) | PWM_DUTY(duty_cycles); + writel(val, lpc32xx->base + (pwm->hwpwm << 2)); return 0; }