aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-05-06 18:32:36 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-05-06 18:32:36 -0400
commitf87bb9ee62700fa11713c630ac5671f253233b94 (patch)
tree400e51578b6f2302d3a48d3b4a02208adc66aacf
parent99737982ca39065a58021bdc31486ea783f952d3 (diff)
parentaffb923df96d6c927f9a3dfb0e6f4be940b185cd (diff)
Merge tag 'for-3.10-rc1' of git://gitorious.org/linux-pwm/linux-pwm
Pull pwm changes from Thierry Reding: "Nothing very exciting this time around. A couple of bug fixes and a lot of cleanup across the board. The DaVinci 8xx family of SoCs now use the same driver as the AM33xx family. Many thanks to Axel Lin and Jingoo Han who have done a great job fixing various bugs and inconsistencies." * tag 'for-3.10-rc1' of git://gitorious.org/linux-pwm/linux-pwm: (27 commits) pwm: lpc32xx: Don't change PWM_ENABLE bit in lpc32xx_pwm_config pwm: lpc32xx: Properly set PWM_ENABLE bit in lpc32xx_pwm_[enable|disable] pwm: Constify OF match tables pwm: pwm-tiehrpwm: Update device-tree binding document pwm: pwm-tiecap: Update device-tree binding document pwm: puv3: Remove unused enabled filed from struct puv3_pwm_chip pwm: pxa: Remove PWM_ID_BASE macro pwm: spear: Remove unused *dev from struct spear_pwm_chip pwm: mxs: Remove unused *dev from struct mxs_pwm_chip pwm: twl: Return proper error if twl6030_pwm_enable() fails pwm: pxa: Remove clk_enabled field from struct pxa_pwm_chip pwm: imx: Remove enabled field from struct imx_chip pwm: twl: Add .owner to struct pwm_ops pwm: twl-led: Add .owner to struct pwm_ops pwm: atmel-tcb: Add .owner to struct pwm_ops pwm: ab8500: Add .owner to struct pwm_ops pwm: spear: Fix checking return value of clk_enable() and clk_prepare() pwm: tiehrpwm: Staticize non-exported symbols pwm: tiecap: Staticize non-exported symbols pwm: ab8500: Fix trivial typo in dev_err message ...
-rw-r--r--Documentation/devicetree/bindings/pwm/pwm-tiecap.txt12
-rw-r--r--Documentation/devicetree/bindings/pwm/pwm-tiehrpwm.txt12
-rw-r--r--drivers/pwm/Kconfig8
-rw-r--r--drivers/pwm/pwm-ab8500.c10
-rw-r--r--drivers/pwm/pwm-atmel-tcb.c1
-rw-r--r--drivers/pwm/pwm-imx.c6
-rw-r--r--drivers/pwm/pwm-lpc32xx.c27
-rw-r--r--drivers/pwm/pwm-mxs.c4
-rw-r--r--drivers/pwm/pwm-puv3.c1
-rw-r--r--drivers/pwm/pwm-pxa.c23
-rw-r--r--drivers/pwm/pwm-samsung.c20
-rw-r--r--drivers/pwm/pwm-spear.c11
-rw-r--r--drivers/pwm/pwm-tegra.c2
-rw-r--r--drivers/pwm/pwm-tiecap.c6
-rw-r--r--drivers/pwm/pwm-tiehrpwm.c6
-rw-r--r--drivers/pwm/pwm-tipwmss.c2
-rw-r--r--drivers/pwm/pwm-tipwmss.h2
-rw-r--r--drivers/pwm/pwm-twl-led.c4
-rw-r--r--drivers/pwm/pwm-twl.c6
-rw-r--r--drivers/video/backlight/pwm_bl.c7
20 files changed, 91 insertions, 79 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 @@
1TI SOC ECAP based APWM controller 1TI SOC ECAP based APWM controller
2 2
3Required properties: 3Required properties:
4- compatible: Must be "ti,am33xx-ecap" 4- compatible: Must be "ti,<soc>-ecap".
5 for am33xx - compatible = "ti,am33xx-ecap";
6 for da850 - compatible = "ti,da850-ecap", "ti,am33xx-ecap";
5- #pwm-cells: Should be 3. Number of cells being used to specify PWM property. 7- #pwm-cells: Should be 3. Number of cells being used to specify PWM property.
6 First cell specifies the per-chip index of the PWM to use, the second 8 First cell specifies the per-chip index of the PWM to use, the second
7 cell is the period in nanoseconds and bit 0 in the third cell is used to 9 cell is the period in nanoseconds and bit 0 in the third cell is used to
@@ -15,9 +17,15 @@ Optional properties:
15 17
16Example: 18Example:
17 19
18ecap0: ecap@0 { 20ecap0: ecap@0 { /* ECAP on am33xx */
19 compatible = "ti,am33xx-ecap"; 21 compatible = "ti,am33xx-ecap";
20 #pwm-cells = <3>; 22 #pwm-cells = <3>;
21 reg = <0x48300100 0x80>; 23 reg = <0x48300100 0x80>;
22 ti,hwmods = "ecap0"; 24 ti,hwmods = "ecap0";
23}; 25};
26
27ecap0: ecap@0 { /* ECAP on da850 */
28 compatible = "ti,da850-ecap", "ti,am33xx-ecap";
29 #pwm-cells = <3>;
30 reg = <0x306000 0x80>;
31};
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 @@
1TI SOC EHRPWM based PWM controller 1TI SOC EHRPWM based PWM controller
2 2
3Required properties: 3Required properties:
4- compatible : Must be "ti,am33xx-ehrpwm" 4- compatible: Must be "ti,<soc>-ehrpwm".
5 for am33xx - compatible = "ti,am33xx-ehrpwm";
6 for da850 - compatible = "ti,da850-ehrpwm", "ti,am33xx-ehrpwm";
5- #pwm-cells: Should be 3. Number of cells being used to specify PWM property. 7- #pwm-cells: Should be 3. Number of cells being used to specify PWM property.
6 First cell specifies the per-chip index of the PWM to use, the second 8 First cell specifies the per-chip index of the PWM to use, the second
7 cell is the period in nanoseconds and bit 0 in the third cell is used to 9 cell is the period in nanoseconds and bit 0 in the third cell is used to
@@ -15,9 +17,15 @@ Optional properties:
15 17
16Example: 18Example:
17 19
18ehrpwm0: ehrpwm@0 { 20ehrpwm0: ehrpwm@0 { /* EHRPWM on am33xx */
19 compatible = "ti,am33xx-ehrpwm"; 21 compatible = "ti,am33xx-ehrpwm";
20 #pwm-cells = <3>; 22 #pwm-cells = <3>;
21 reg = <0x48300200 0x100>; 23 reg = <0x48300200 0x100>;
22 ti,hwmods = "ehrpwm0"; 24 ti,hwmods = "ehrpwm0";
23}; 25};
26
27ehrpwm0: ehrpwm@0 { /* EHRPWM on da850 */
28 compatible = "ti,da850-ehrpwm", "ti,am33xx-ehrpwm";
29 #pwm-cells = <3>;
30 reg = <0x300000 0x2000>;
31};
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
147 147
148config PWM_TIECAP 148config PWM_TIECAP
149 tristate "ECAP PWM support" 149 tristate "ECAP PWM support"
150 depends on SOC_AM33XX 150 depends on SOC_AM33XX || ARCH_DAVINCI_DA8XX
151 select PWM_TIPWMSS
152 help 151 help
153 PWM driver support for the ECAP APWM controller found on AM33XX 152 PWM driver support for the ECAP APWM controller found on AM33XX
154 TI SOC 153 TI SOC
@@ -158,8 +157,7 @@ config PWM_TIECAP
158 157
159config PWM_TIEHRPWM 158config PWM_TIEHRPWM
160 tristate "EHRPWM PWM support" 159 tristate "EHRPWM PWM support"
161 depends on SOC_AM33XX 160 depends on SOC_AM33XX || ARCH_DAVINCI_DA8XX
162 select PWM_TIPWMSS
163 help 161 help
164 PWM driver support for the EHRPWM controller found on AM33XX 162 PWM driver support for the EHRPWM controller found on AM33XX
165 TI SOC 163 TI SOC
@@ -169,7 +167,7 @@ config PWM_TIEHRPWM
169 167
170config PWM_TIPWMSS 168config PWM_TIPWMSS
171 bool 169 bool
172 depends on SOC_AM33XX && (PWM_TIEHRPWM || PWM_TIECAP) 170 default y if SOC_AM33XX && (PWM_TIECAP || PWM_TIEHRPWM)
173 help 171 help
174 PWM Subsystem driver support for AM33xx SOC. 172 PWM Subsystem driver support for AM33xx SOC.
175 173
diff --git a/drivers/pwm/pwm-ab8500.c b/drivers/pwm/pwm-ab8500.c
index 4248d0418273..1d07a6f99375 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)
66 AB8500_MISC, AB8500_PWM_OUT_CTRL7_REG, 66 AB8500_MISC, AB8500_PWM_OUT_CTRL7_REG,
67 1 << (chip->base - 1), ENABLE_PWM); 67 1 << (chip->base - 1), ENABLE_PWM);
68 if (ret < 0) 68 if (ret < 0)
69 dev_err(chip->dev, "%s: Failed to disable PWM, Error %d\n", 69 dev_err(chip->dev, "%s: Failed to enable PWM, Error %d\n",
70 pwm->label, ret); 70 pwm->label, ret);
71 return ret; 71 return ret;
72} 72}
@@ -88,6 +88,7 @@ static const struct pwm_ops ab8500_pwm_ops = {
88 .config = ab8500_pwm_config, 88 .config = ab8500_pwm_config,
89 .enable = ab8500_pwm_enable, 89 .enable = ab8500_pwm_enable,
90 .disable = ab8500_pwm_disable, 90 .disable = ab8500_pwm_disable,
91 .owner = THIS_MODULE,
91}; 92};
92 93
93static int ab8500_pwm_probe(struct platform_device *pdev) 94static int ab8500_pwm_probe(struct platform_device *pdev)
@@ -99,7 +100,7 @@ static int ab8500_pwm_probe(struct platform_device *pdev)
99 * Nothing to be done in probe, this is required to get the 100 * Nothing to be done in probe, this is required to get the
100 * device which is required for ab8500 read and write 101 * device which is required for ab8500 read and write
101 */ 102 */
102 ab8500 = kzalloc(sizeof(*ab8500), GFP_KERNEL); 103 ab8500 = devm_kzalloc(&pdev->dev, sizeof(*ab8500), GFP_KERNEL);
103 if (ab8500 == NULL) { 104 if (ab8500 == NULL) {
104 dev_err(&pdev->dev, "failed to allocate memory\n"); 105 dev_err(&pdev->dev, "failed to allocate memory\n");
105 return -ENOMEM; 106 return -ENOMEM;
@@ -111,10 +112,8 @@ static int ab8500_pwm_probe(struct platform_device *pdev)
111 ab8500->chip.npwm = 1; 112 ab8500->chip.npwm = 1;
112 113
113 err = pwmchip_add(&ab8500->chip); 114 err = pwmchip_add(&ab8500->chip);
114 if (err < 0) { 115 if (err < 0)
115 kfree(ab8500);
116 return err; 116 return err;
117 }
118 117
119 dev_dbg(&pdev->dev, "pwm probe successful\n"); 118 dev_dbg(&pdev->dev, "pwm probe successful\n");
120 platform_set_drvdata(pdev, ab8500); 119 platform_set_drvdata(pdev, ab8500);
@@ -132,7 +131,6 @@ static int ab8500_pwm_remove(struct platform_device *pdev)
132 return err; 131 return err;
133 132
134 dev_dbg(&pdev->dev, "pwm driver removed\n"); 133 dev_dbg(&pdev->dev, "pwm driver removed\n");
135 kfree(ab8500);
136 134
137 return 0; 135 return 0;
138} 136}
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 = {
358 .set_polarity = atmel_tcb_pwm_set_polarity, 358 .set_polarity = atmel_tcb_pwm_set_polarity,
359 .enable = atmel_tcb_pwm_enable, 359 .enable = atmel_tcb_pwm_enable,
360 .disable = atmel_tcb_pwm_disable, 360 .disable = atmel_tcb_pwm_disable,
361 .owner = THIS_MODULE,
361}; 362};
362 363
363static int atmel_tcb_pwm_probe(struct platform_device *pdev) 364static int atmel_tcb_pwm_probe(struct platform_device *pdev)
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 {
43 struct clk *clk_per; 43 struct clk *clk_per;
44 struct clk *clk_ipg; 44 struct clk *clk_ipg;
45 45
46 int enabled;
47 void __iomem *mmio_base; 46 void __iomem *mmio_base;
48 47
49 struct pwm_chip chip; 48 struct pwm_chip chip;
@@ -135,7 +134,7 @@ static int imx_pwm_config_v2(struct pwm_chip *chip,
135 MX3_PWMCR_DOZEEN | MX3_PWMCR_WAITEN | 134 MX3_PWMCR_DOZEEN | MX3_PWMCR_WAITEN |
136 MX3_PWMCR_DBGEN | MX3_PWMCR_CLKSRC_IPG_HIGH; 135 MX3_PWMCR_DBGEN | MX3_PWMCR_CLKSRC_IPG_HIGH;
137 136
138 if (imx->enabled) 137 if (test_bit(PWMF_ENABLED, &pwm->flags))
139 cr |= MX3_PWMCR_EN; 138 cr |= MX3_PWMCR_EN;
140 139
141 writel(cr, imx->mmio_base + MX3_PWMCR); 140 writel(cr, imx->mmio_base + MX3_PWMCR);
@@ -186,8 +185,6 @@ static int imx_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
186 185
187 imx->set_enable(chip, true); 186 imx->set_enable(chip, true);
188 187
189 imx->enabled = 1;
190
191 return 0; 188 return 0;
192} 189}
193 190
@@ -198,7 +195,6 @@ static void imx_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
198 imx->set_enable(chip, false); 195 imx->set_enable(chip, false);
199 196
200 clk_disable_unprepare(imx->clk_per); 197 clk_disable_unprepare(imx->clk_per);
201 imx->enabled = 0;
202} 198}
203 199
204static struct pwm_ops imx_pwm_ops = { 200static struct pwm_ops imx_pwm_ops = {
diff --git a/drivers/pwm/pwm-lpc32xx.c b/drivers/pwm/pwm-lpc32xx.c
index b3f0d0dfd748..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,
37 struct lpc32xx_pwm_chip *lpc32xx = to_lpc32xx_pwm_chip(chip); 37 struct lpc32xx_pwm_chip *lpc32xx = to_lpc32xx_pwm_chip(chip);
38 unsigned long long c; 38 unsigned long long c;
39 int period_cycles, duty_cycles; 39 int period_cycles, duty_cycles;
40 u32 val;
40 41
41 c = clk_get_rate(lpc32xx->clk) / 256; 42 c = clk_get_rate(lpc32xx->clk) / 256;
42 c = c * period_ns; 43 c = c * period_ns;
@@ -68,8 +69,10 @@ static int lpc32xx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
68 c = 255; 69 c = 255;
69 duty_cycles = 256 - c; 70 duty_cycles = 256 - c;
70 71
71 writel(PWM_ENABLE | PWM_RELOADV(period_cycles) | PWM_DUTY(duty_cycles), 72 val = readl(lpc32xx->base + (pwm->hwpwm << 2));
72 lpc32xx->base + (pwm->hwpwm << 2)); 73 val &= ~0xFFFF;
74 val |= PWM_RELOADV(period_cycles) | PWM_DUTY(duty_cycles);
75 writel(val, lpc32xx->base + (pwm->hwpwm << 2));
73 76
74 return 0; 77 return 0;
75} 78}
@@ -77,15 +80,29 @@ static int lpc32xx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
77static int lpc32xx_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) 80static int lpc32xx_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
78{ 81{
79 struct lpc32xx_pwm_chip *lpc32xx = to_lpc32xx_pwm_chip(chip); 82 struct lpc32xx_pwm_chip *lpc32xx = to_lpc32xx_pwm_chip(chip);
83 u32 val;
84 int ret;
85
86 ret = clk_enable(lpc32xx->clk);
87 if (ret)
88 return ret;
80 89
81 return clk_enable(lpc32xx->clk); 90 val = readl(lpc32xx->base + (pwm->hwpwm << 2));
91 val |= PWM_ENABLE;
92 writel(val, lpc32xx->base + (pwm->hwpwm << 2));
93
94 return 0;
82} 95}
83 96
84static void lpc32xx_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) 97static void lpc32xx_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
85{ 98{
86 struct lpc32xx_pwm_chip *lpc32xx = to_lpc32xx_pwm_chip(chip); 99 struct lpc32xx_pwm_chip *lpc32xx = to_lpc32xx_pwm_chip(chip);
100 u32 val;
101
102 val = readl(lpc32xx->base + (pwm->hwpwm << 2));
103 val &= ~PWM_ENABLE;
104 writel(val, lpc32xx->base + (pwm->hwpwm << 2));
87 105
88 writel(0, lpc32xx->base + (pwm->hwpwm << 2));
89 clk_disable(lpc32xx->clk); 106 clk_disable(lpc32xx->clk);
90} 107}
91 108
@@ -145,7 +162,7 @@ static int lpc32xx_pwm_remove(struct platform_device *pdev)
145 return pwmchip_remove(&lpc32xx->chip); 162 return pwmchip_remove(&lpc32xx->chip);
146} 163}
147 164
148static struct of_device_id lpc32xx_pwm_dt_ids[] = { 165static const struct of_device_id lpc32xx_pwm_dt_ids[] = {
149 { .compatible = "nxp,lpc3220-pwm", }, 166 { .compatible = "nxp,lpc3220-pwm", },
150 { /* sentinel */ } 167 { /* sentinel */ }
151}; 168};
diff --git a/drivers/pwm/pwm-mxs.c b/drivers/pwm/pwm-mxs.c
index a53d3094b75a..3febdddf71f9 100644
--- a/drivers/pwm/pwm-mxs.c
+++ b/drivers/pwm/pwm-mxs.c
@@ -38,7 +38,6 @@
38 38
39struct mxs_pwm_chip { 39struct mxs_pwm_chip {
40 struct pwm_chip chip; 40 struct pwm_chip chip;
41 struct device *dev;
42 struct clk *clk; 41 struct clk *clk;
43 void __iomem *base; 42 void __iomem *base;
44}; 43};
@@ -166,7 +165,6 @@ static int mxs_pwm_probe(struct platform_device *pdev)
166 return ret; 165 return ret;
167 } 166 }
168 167
169 mxs->dev = &pdev->dev;
170 platform_set_drvdata(pdev, mxs); 168 platform_set_drvdata(pdev, mxs);
171 169
172 stmp_reset_block(mxs->base); 170 stmp_reset_block(mxs->base);
@@ -181,7 +179,7 @@ static int mxs_pwm_remove(struct platform_device *pdev)
181 return pwmchip_remove(&mxs->chip); 179 return pwmchip_remove(&mxs->chip);
182} 180}
183 181
184static struct of_device_id mxs_pwm_dt_ids[] = { 182static const struct of_device_id mxs_pwm_dt_ids[] = {
185 { .compatible = "fsl,imx23-pwm", }, 183 { .compatible = "fsl,imx23-pwm", },
186 { /* sentinel */ } 184 { /* sentinel */ }
187}; 185};
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 {
27 struct pwm_chip chip; 27 struct pwm_chip chip;
28 void __iomem *base; 28 void __iomem *base;
29 struct clk *clk; 29 struct clk *clk;
30 bool enabled;
31}; 30};
32 31
33static inline struct puv3_pwm_chip *to_puv3(struct pwm_chip *chip) 32static inline struct puv3_pwm_chip *to_puv3(struct pwm_chip *chip)
diff --git a/drivers/pwm/pwm-pxa.c b/drivers/pwm/pwm-pxa.c
index 20370e61de5a..dee6ab552a0a 100644
--- a/drivers/pwm/pwm-pxa.c
+++ b/drivers/pwm/pwm-pxa.c
@@ -23,14 +23,13 @@
23#include <asm/div64.h> 23#include <asm/div64.h>
24 24
25#define HAS_SECONDARY_PWM 0x10 25#define HAS_SECONDARY_PWM 0x10
26#define PWM_ID_BASE(d) ((d) & 0xf)
27 26
28static const struct platform_device_id pwm_id_table[] = { 27static const struct platform_device_id pwm_id_table[] = {
29 /* PWM has_secondary_pwm? */ 28 /* PWM has_secondary_pwm? */
30 { "pxa25x-pwm", 0 }, 29 { "pxa25x-pwm", 0 },
31 { "pxa27x-pwm", 0 | HAS_SECONDARY_PWM }, 30 { "pxa27x-pwm", HAS_SECONDARY_PWM },
32 { "pxa168-pwm", 1 }, 31 { "pxa168-pwm", 0 },
33 { "pxa910-pwm", 1 }, 32 { "pxa910-pwm", 0 },
34 { }, 33 { },
35}; 34};
36MODULE_DEVICE_TABLE(platform, pwm_id_table); 35MODULE_DEVICE_TABLE(platform, pwm_id_table);
@@ -48,7 +47,6 @@ struct pxa_pwm_chip {
48 struct device *dev; 47 struct device *dev;
49 48
50 struct clk *clk; 49 struct clk *clk;
51 int clk_enabled;
52 void __iomem *mmio_base; 50 void __iomem *mmio_base;
53}; 51};
54 52
@@ -108,24 +106,15 @@ static int pxa_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
108static int pxa_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) 106static int pxa_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
109{ 107{
110 struct pxa_pwm_chip *pc = to_pxa_pwm_chip(chip); 108 struct pxa_pwm_chip *pc = to_pxa_pwm_chip(chip);
111 int rc = 0;
112 109
113 if (!pc->clk_enabled) { 110 return clk_prepare_enable(pc->clk);
114 rc = clk_prepare_enable(pc->clk);
115 if (!rc)
116 pc->clk_enabled++;
117 }
118 return rc;
119} 111}
120 112
121static void pxa_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) 113static void pxa_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
122{ 114{
123 struct pxa_pwm_chip *pc = to_pxa_pwm_chip(chip); 115 struct pxa_pwm_chip *pc = to_pxa_pwm_chip(chip);
124 116
125 if (pc->clk_enabled) { 117 clk_disable_unprepare(pc->clk);
126 clk_disable_unprepare(pc->clk);
127 pc->clk_enabled--;
128 }
129} 118}
130 119
131static struct pwm_ops pxa_pwm_ops = { 120static struct pwm_ops pxa_pwm_ops = {
@@ -152,8 +141,6 @@ static int pwm_probe(struct platform_device *pdev)
152 if (IS_ERR(pwm->clk)) 141 if (IS_ERR(pwm->clk))
153 return PTR_ERR(pwm->clk); 142 return PTR_ERR(pwm->clk);
154 143
155 pwm->clk_enabled = 0;
156
157 pwm->chip.dev = &pdev->dev; 144 pwm->chip.dev = &pdev->dev;
158 pwm->chip.ops = &pxa_pwm_ops; 145 pwm->chip.ops = &pxa_pwm_ops;
159 pwm->chip.base = -1; 146 pwm->chip.base = -1;
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)
289 return 0; 289 return 0;
290} 290}
291 291
292#ifdef CONFIG_PM 292#ifdef CONFIG_PM_SLEEP
293static int s3c_pwm_suspend(struct platform_device *pdev, pm_message_t state) 293static int s3c_pwm_suspend(struct device *dev)
294{ 294{
295 struct s3c_chip *s3c = platform_get_drvdata(pdev); 295 struct s3c_chip *s3c = dev_get_drvdata(dev);
296 296
297 /* No one preserve these values during suspend so reset them 297 /* No one preserve these values during suspend so reset them
298 * Otherwise driver leaves PWM unconfigured if same values 298 * 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)
304 return 0; 304 return 0;
305} 305}
306 306
307static int s3c_pwm_resume(struct platform_device *pdev) 307static int s3c_pwm_resume(struct device *dev)
308{ 308{
309 struct s3c_chip *s3c = platform_get_drvdata(pdev); 309 struct s3c_chip *s3c = dev_get_drvdata(dev);
310 unsigned long tcon; 310 unsigned long tcon;
311 311
312 /* Restore invertion */ 312 /* Restore invertion */
@@ -316,21 +316,19 @@ static int s3c_pwm_resume(struct platform_device *pdev)
316 316
317 return 0; 317 return 0;
318} 318}
319
320#else
321#define s3c_pwm_suspend NULL
322#define s3c_pwm_resume NULL
323#endif 319#endif
324 320
321static SIMPLE_DEV_PM_OPS(s3c_pwm_pm_ops, s3c_pwm_suspend,
322 s3c_pwm_resume);
323
325static struct platform_driver s3c_pwm_driver = { 324static struct platform_driver s3c_pwm_driver = {
326 .driver = { 325 .driver = {
327 .name = "s3c24xx-pwm", 326 .name = "s3c24xx-pwm",
328 .owner = THIS_MODULE, 327 .owner = THIS_MODULE,
328 .pm = &s3c_pwm_pm_ops,
329 }, 329 },
330 .probe = s3c_pwm_probe, 330 .probe = s3c_pwm_probe,
331 .remove = s3c_pwm_remove, 331 .remove = s3c_pwm_remove,
332 .suspend = s3c_pwm_suspend,
333 .resume = s3c_pwm_resume,
334}; 332};
335 333
336static int __init pwm_init(void) 334static int __init pwm_init(void)
diff --git a/drivers/pwm/pwm-spear.c b/drivers/pwm/pwm-spear.c
index 69a2d9eb34db..6d99e2cbdc73 100644
--- a/drivers/pwm/pwm-spear.c
+++ b/drivers/pwm/pwm-spear.c
@@ -49,13 +49,11 @@
49 * @mmio_base: base address of pwm chip 49 * @mmio_base: base address of pwm chip
50 * @clk: pointer to clk structure of pwm chip 50 * @clk: pointer to clk structure of pwm chip
51 * @chip: linux pwm chip representation 51 * @chip: linux pwm chip representation
52 * @dev: pointer to device structure of pwm chip
53 */ 52 */
54struct spear_pwm_chip { 53struct spear_pwm_chip {
55 void __iomem *mmio_base; 54 void __iomem *mmio_base;
56 struct clk *clk; 55 struct clk *clk;
57 struct pwm_chip chip; 56 struct pwm_chip chip;
58 struct device *dev;
59}; 57};
60 58
61static inline struct spear_pwm_chip *to_spear_pwm_chip(struct pwm_chip *chip) 59static inline struct spear_pwm_chip *to_spear_pwm_chip(struct pwm_chip *chip)
@@ -143,7 +141,7 @@ static int spear_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
143 u32 val; 141 u32 val;
144 142
145 rc = clk_enable(pc->clk); 143 rc = clk_enable(pc->clk);
146 if (!rc) 144 if (rc)
147 return rc; 145 return rc;
148 146
149 val = spear_pwm_readl(pc, pwm->hwpwm, PWMCR); 147 val = spear_pwm_readl(pc, pwm->hwpwm, PWMCR);
@@ -200,7 +198,6 @@ static int spear_pwm_probe(struct platform_device *pdev)
200 if (IS_ERR(pc->clk)) 198 if (IS_ERR(pc->clk))
201 return PTR_ERR(pc->clk); 199 return PTR_ERR(pc->clk);
202 200
203 pc->dev = &pdev->dev;
204 platform_set_drvdata(pdev, pc); 201 platform_set_drvdata(pdev, pc);
205 202
206 pc->chip.dev = &pdev->dev; 203 pc->chip.dev = &pdev->dev;
@@ -209,12 +206,12 @@ static int spear_pwm_probe(struct platform_device *pdev)
209 pc->chip.npwm = NUM_PWM; 206 pc->chip.npwm = NUM_PWM;
210 207
211 ret = clk_prepare(pc->clk); 208 ret = clk_prepare(pc->clk);
212 if (!ret) 209 if (ret)
213 return ret; 210 return ret;
214 211
215 if (of_device_is_compatible(np, "st,spear1340-pwm")) { 212 if (of_device_is_compatible(np, "st,spear1340-pwm")) {
216 ret = clk_enable(pc->clk); 213 ret = clk_enable(pc->clk);
217 if (!ret) { 214 if (ret) {
218 clk_unprepare(pc->clk); 215 clk_unprepare(pc->clk);
219 return ret; 216 return ret;
220 } 217 }
@@ -251,7 +248,7 @@ static int spear_pwm_remove(struct platform_device *pdev)
251 return pwmchip_remove(&pc->chip); 248 return pwmchip_remove(&pc->chip);
252} 249}
253 250
254static struct of_device_id spear_pwm_of_match[] = { 251static const struct of_device_id spear_pwm_of_match[] = {
255 { .compatible = "st,spear320-pwm" }, 252 { .compatible = "st,spear320-pwm" },
256 { .compatible = "st,spear1340-pwm" }, 253 { .compatible = "st,spear1340-pwm" },
257 { } 254 { }
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)
233 return pwmchip_remove(&pc->chip); 233 return pwmchip_remove(&pc->chip);
234} 234}
235 235
236static struct of_device_id tegra_pwm_of_match[] = { 236static const struct of_device_id tegra_pwm_of_match[] = {
237 { .compatible = "nvidia,tegra20-pwm" }, 237 { .compatible = "nvidia,tegra20-pwm" },
238 { .compatible = "nvidia,tegra30-pwm" }, 238 { .compatible = "nvidia,tegra30-pwm" },
239 { } 239 { }
diff --git a/drivers/pwm/pwm-tiecap.c b/drivers/pwm/pwm-tiecap.c
index 22e96e2bffd3..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)
295 return pwmchip_remove(&pc->chip); 295 return pwmchip_remove(&pc->chip);
296} 296}
297 297
298void ecap_pwm_save_context(struct ecap_pwm_chip *pc) 298static void ecap_pwm_save_context(struct ecap_pwm_chip *pc)
299{ 299{
300 pm_runtime_get_sync(pc->chip.dev); 300 pm_runtime_get_sync(pc->chip.dev);
301 pc->ctx.ecctl2 = readw(pc->mmio_base + ECCTL2); 301 pc->ctx.ecctl2 = readw(pc->mmio_base + ECCTL2);
@@ -304,13 +304,14 @@ void ecap_pwm_save_context(struct ecap_pwm_chip *pc)
304 pm_runtime_put_sync(pc->chip.dev); 304 pm_runtime_put_sync(pc->chip.dev);
305} 305}
306 306
307void ecap_pwm_restore_context(struct ecap_pwm_chip *pc) 307static void ecap_pwm_restore_context(struct ecap_pwm_chip *pc)
308{ 308{
309 writel(pc->ctx.cap3, pc->mmio_base + CAP3); 309 writel(pc->ctx.cap3, pc->mmio_base + CAP3);
310 writel(pc->ctx.cap4, pc->mmio_base + CAP4); 310 writel(pc->ctx.cap4, pc->mmio_base + CAP4);
311 writew(pc->ctx.ecctl2, pc->mmio_base + ECCTL2); 311 writew(pc->ctx.ecctl2, pc->mmio_base + ECCTL2);
312} 312}
313 313
314#ifdef CONFIG_PM_SLEEP
314static int ecap_pwm_suspend(struct device *dev) 315static int ecap_pwm_suspend(struct device *dev)
315{ 316{
316 struct ecap_pwm_chip *pc = dev_get_drvdata(dev); 317 struct ecap_pwm_chip *pc = dev_get_drvdata(dev);
@@ -337,6 +338,7 @@ static int ecap_pwm_resume(struct device *dev)
337 ecap_pwm_restore_context(pc); 338 ecap_pwm_restore_context(pc);
338 return 0; 339 return 0;
339} 340}
341#endif
340 342
341static SIMPLE_DEV_PM_OPS(ecap_pwm_pm_ops, ecap_pwm_suspend, ecap_pwm_resume); 343static SIMPLE_DEV_PM_OPS(ecap_pwm_pm_ops, ecap_pwm_suspend, ecap_pwm_resume);
342 344
diff --git a/drivers/pwm/pwm-tiehrpwm.c b/drivers/pwm/pwm-tiehrpwm.c
index 8b4c86fa99c8..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)
533 return pwmchip_remove(&pc->chip); 533 return pwmchip_remove(&pc->chip);
534} 534}
535 535
536void ehrpwm_pwm_save_context(struct ehrpwm_pwm_chip *pc) 536static void ehrpwm_pwm_save_context(struct ehrpwm_pwm_chip *pc)
537{ 537{
538 pm_runtime_get_sync(pc->chip.dev); 538 pm_runtime_get_sync(pc->chip.dev);
539 pc->ctx.tbctl = ehrpwm_read(pc->mmio_base, TBCTL); 539 pc->ctx.tbctl = ehrpwm_read(pc->mmio_base, TBCTL);
@@ -547,7 +547,7 @@ void ehrpwm_pwm_save_context(struct ehrpwm_pwm_chip *pc)
547 pm_runtime_put_sync(pc->chip.dev); 547 pm_runtime_put_sync(pc->chip.dev);
548} 548}
549 549
550void ehrpwm_pwm_restore_context(struct ehrpwm_pwm_chip *pc) 550static void ehrpwm_pwm_restore_context(struct ehrpwm_pwm_chip *pc)
551{ 551{
552 ehrpwm_write(pc->mmio_base, TBPRD, pc->ctx.tbprd); 552 ehrpwm_write(pc->mmio_base, TBPRD, pc->ctx.tbprd);
553 ehrpwm_write(pc->mmio_base, CMPA, pc->ctx.cmpa); 553 ehrpwm_write(pc->mmio_base, CMPA, pc->ctx.cmpa);
@@ -559,6 +559,7 @@ void ehrpwm_pwm_restore_context(struct ehrpwm_pwm_chip *pc)
559 ehrpwm_write(pc->mmio_base, TBCTL, pc->ctx.tbctl); 559 ehrpwm_write(pc->mmio_base, TBCTL, pc->ctx.tbctl);
560} 560}
561 561
562#ifdef CONFIG_PM_SLEEP
562static int ehrpwm_pwm_suspend(struct device *dev) 563static int ehrpwm_pwm_suspend(struct device *dev)
563{ 564{
564 struct ehrpwm_pwm_chip *pc = dev_get_drvdata(dev); 565 struct ehrpwm_pwm_chip *pc = dev_get_drvdata(dev);
@@ -594,6 +595,7 @@ static int ehrpwm_pwm_resume(struct device *dev)
594 ehrpwm_pwm_restore_context(pc); 595 ehrpwm_pwm_restore_context(pc);
595 return 0; 596 return 0;
596} 597}
598#endif
597 599
598static SIMPLE_DEV_PM_OPS(ehrpwm_pwm_pm_ops, ehrpwm_pwm_suspend, 600static SIMPLE_DEV_PM_OPS(ehrpwm_pwm_pm_ops, ehrpwm_pwm_suspend,
599 ehrpwm_pwm_resume); 601 ehrpwm_pwm_resume);
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)
101 return 0; 101 return 0;
102} 102}
103 103
104#ifdef CONFIG_PM_SLEEP
104static int pwmss_suspend(struct device *dev) 105static int pwmss_suspend(struct device *dev)
105{ 106{
106 struct pwmss_info *info = dev_get_drvdata(dev); 107 struct pwmss_info *info = dev_get_drvdata(dev);
@@ -118,6 +119,7 @@ static int pwmss_resume(struct device *dev)
118 writew(info->pwmss_clkconfig, info->mmio_base + PWMSS_CLKCONFIG); 119 writew(info->pwmss_clkconfig, info->mmio_base + PWMSS_CLKCONFIG);
119 return 0; 120 return 0;
120} 121}
122#endif
121 123
122static SIMPLE_DEV_PM_OPS(pwmss_pm_ops, pwmss_suspend, pwmss_resume); 124static SIMPLE_DEV_PM_OPS(pwmss_pm_ops, pwmss_suspend, pwmss_resume);
123 125
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 @@
18#ifndef __TIPWMSS_H 18#ifndef __TIPWMSS_H
19#define __TIPWMSS_H 19#define __TIPWMSS_H
20 20
21#ifdef CONFIG_PWM_TIPWMSS
22/* PWM substem clock gating */ 21/* PWM substem clock gating */
23#define PWMSS_ECAPCLK_EN BIT(0) 22#define PWMSS_ECAPCLK_EN BIT(0)
24#define PWMSS_ECAPCLK_STOP_REQ BIT(1) 23#define PWMSS_ECAPCLK_STOP_REQ BIT(1)
@@ -28,6 +27,7 @@
28#define PWMSS_ECAPCLK_EN_ACK BIT(0) 27#define PWMSS_ECAPCLK_EN_ACK BIT(0)
29#define PWMSS_EPWMCLK_EN_ACK BIT(8) 28#define PWMSS_EPWMCLK_EN_ACK BIT(8)
30 29
30#ifdef CONFIG_PWM_TIPWMSS
31extern u16 pwmss_submodule_state_change(struct device *dev, int set); 31extern u16 pwmss_submodule_state_change(struct device *dev, int set);
32#else 32#else
33static inline u16 pwmss_submodule_state_change(struct device *dev, int set) 33static inline u16 pwmss_submodule_state_change(struct device *dev, int set)
diff --git a/drivers/pwm/pwm-twl-led.c b/drivers/pwm/pwm-twl-led.c
index 83e25d45d640..29d1bba4804e 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 = {
271 .enable = twl4030_pwmled_enable, 271 .enable = twl4030_pwmled_enable,
272 .disable = twl4030_pwmled_disable, 272 .disable = twl4030_pwmled_disable,
273 .config = twl4030_pwmled_config, 273 .config = twl4030_pwmled_config,
274 .owner = THIS_MODULE,
274}; 275};
275 276
276static const struct pwm_ops twl6030_pwmled_ops = { 277static const struct pwm_ops twl6030_pwmled_ops = {
@@ -279,6 +280,7 @@ static const struct pwm_ops twl6030_pwmled_ops = {
279 .config = twl6030_pwmled_config, 280 .config = twl6030_pwmled_config,
280 .request = twl6030_pwmled_request, 281 .request = twl6030_pwmled_request,
281 .free = twl6030_pwmled_free, 282 .free = twl6030_pwmled_free,
283 .owner = THIS_MODULE,
282}; 284};
283 285
284static int twl_pwmled_probe(struct platform_device *pdev) 286static int twl_pwmled_probe(struct platform_device *pdev)
@@ -321,7 +323,7 @@ static int twl_pwmled_remove(struct platform_device *pdev)
321} 323}
322 324
323#ifdef CONFIG_OF 325#ifdef CONFIG_OF
324static struct of_device_id twl_pwmled_of_match[] = { 326static const struct of_device_id twl_pwmled_of_match[] = {
325 { .compatible = "ti,twl4030-pwmled" }, 327 { .compatible = "ti,twl4030-pwmled" },
326 { .compatible = "ti,twl6030-pwmled" }, 328 { .compatible = "ti,twl6030-pwmled" },
327 { }, 329 { },
diff --git a/drivers/pwm/pwm-twl.c b/drivers/pwm/pwm-twl.c
index bf3fda294223..eef910580eae 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)
248 twl->twl6030_toggle3 = val; 248 twl->twl6030_toggle3 = val;
249out: 249out:
250 mutex_unlock(&twl->mutex); 250 mutex_unlock(&twl->mutex);
251 return 0; 251 return ret;
252} 252}
253 253
254static void twl6030_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) 254static void twl6030_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
@@ -287,12 +287,14 @@ static const struct pwm_ops twl4030_pwm_ops = {
287 .disable = twl4030_pwm_disable, 287 .disable = twl4030_pwm_disable,
288 .request = twl4030_pwm_request, 288 .request = twl4030_pwm_request,
289 .free = twl4030_pwm_free, 289 .free = twl4030_pwm_free,
290 .owner = THIS_MODULE,
290}; 291};
291 292
292static const struct pwm_ops twl6030_pwm_ops = { 293static const struct pwm_ops twl6030_pwm_ops = {
293 .config = twl_pwm_config, 294 .config = twl_pwm_config,
294 .enable = twl6030_pwm_enable, 295 .enable = twl6030_pwm_enable,
295 .disable = twl6030_pwm_disable, 296 .disable = twl6030_pwm_disable,
297 .owner = THIS_MODULE,
296}; 298};
297 299
298static int twl_pwm_probe(struct platform_device *pdev) 300static int twl_pwm_probe(struct platform_device *pdev)
@@ -333,7 +335,7 @@ static int twl_pwm_remove(struct platform_device *pdev)
333} 335}
334 336
335#ifdef CONFIG_OF 337#ifdef CONFIG_OF
336static struct of_device_id twl_pwm_of_match[] = { 338static const struct of_device_id twl_pwm_of_match[] = {
337 { .compatible = "ti,twl4030-pwm" }, 339 { .compatible = "ti,twl4030-pwm" },
338 { .compatible = "ti,twl6030-pwm" }, 340 { .compatible = "ti,twl6030-pwm" },
339 { }, 341 { },
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)
274 return 0; 274 return 0;
275} 275}
276 276
277#ifdef CONFIG_PM 277#ifdef CONFIG_PM_SLEEP
278static int pwm_backlight_suspend(struct device *dev) 278static int pwm_backlight_suspend(struct device *dev)
279{ 279{
280 struct backlight_device *bl = dev_get_drvdata(dev); 280 struct backlight_device *bl = dev_get_drvdata(dev);
@@ -296,19 +296,16 @@ static int pwm_backlight_resume(struct device *dev)
296 backlight_update_status(bl); 296 backlight_update_status(bl);
297 return 0; 297 return 0;
298} 298}
299#endif
299 300
300static SIMPLE_DEV_PM_OPS(pwm_backlight_pm_ops, pwm_backlight_suspend, 301static SIMPLE_DEV_PM_OPS(pwm_backlight_pm_ops, pwm_backlight_suspend,
301 pwm_backlight_resume); 302 pwm_backlight_resume);
302 303
303#endif
304
305static struct platform_driver pwm_backlight_driver = { 304static struct platform_driver pwm_backlight_driver = {
306 .driver = { 305 .driver = {
307 .name = "pwm-backlight", 306 .name = "pwm-backlight",
308 .owner = THIS_MODULE, 307 .owner = THIS_MODULE,
309#ifdef CONFIG_PM
310 .pm = &pwm_backlight_pm_ops, 308 .pm = &pwm_backlight_pm_ops,
311#endif
312 .of_match_table = of_match_ptr(pwm_backlight_of_match), 309 .of_match_table = of_match_ptr(pwm_backlight_of_match),
313 }, 310 },
314 .probe = pwm_backlight_probe, 311 .probe = pwm_backlight_probe,