diff options
-rw-r--r-- | arch/arm/mach-pxa/pwm.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/arch/arm/mach-pxa/pwm.c b/arch/arm/mach-pxa/pwm.c index 92fef391d990..7c86dd1d108f 100644 --- a/arch/arm/mach-pxa/pwm.c +++ b/arch/arm/mach-pxa/pwm.c | |||
@@ -36,6 +36,7 @@ struct pwm_device { | |||
36 | 36 | ||
37 | const char *label; | 37 | const char *label; |
38 | struct clk *clk; | 38 | struct clk *clk; |
39 | int clk_enabled; | ||
39 | void __iomem *mmio_base; | 40 | void __iomem *mmio_base; |
40 | 41 | ||
41 | unsigned int use_count; | 42 | unsigned int use_count; |
@@ -87,13 +88,23 @@ EXPORT_SYMBOL(pwm_config); | |||
87 | 88 | ||
88 | int pwm_enable(struct pwm_device *pwm) | 89 | int pwm_enable(struct pwm_device *pwm) |
89 | { | 90 | { |
90 | return clk_enable(pwm->clk); | 91 | int rc = 0; |
92 | |||
93 | if (!pwm->clk_enabled) { | ||
94 | rc = clk_enable(pwm->clk); | ||
95 | if (!rc) | ||
96 | pwm->clk_enabled = 1; | ||
97 | } | ||
98 | return rc; | ||
91 | } | 99 | } |
92 | EXPORT_SYMBOL(pwm_enable); | 100 | EXPORT_SYMBOL(pwm_enable); |
93 | 101 | ||
94 | void pwm_disable(struct pwm_device *pwm) | 102 | void pwm_disable(struct pwm_device *pwm) |
95 | { | 103 | { |
96 | clk_disable(pwm->clk); | 104 | if (pwm->clk_enabled) { |
105 | clk_disable(pwm->clk); | ||
106 | pwm->clk_enabled = 0; | ||
107 | } | ||
97 | } | 108 | } |
98 | EXPORT_SYMBOL(pwm_disable); | 109 | EXPORT_SYMBOL(pwm_disable); |
99 | 110 | ||
@@ -161,6 +172,7 @@ static struct pwm_device *pwm_probe(struct platform_device *pdev, | |||
161 | ret = PTR_ERR(pwm->clk); | 172 | ret = PTR_ERR(pwm->clk); |
162 | goto err_free; | 173 | goto err_free; |
163 | } | 174 | } |
175 | pwm->clk_enabled = 0; | ||
164 | 176 | ||
165 | pwm->use_count = 0; | 177 | pwm->use_count = 0; |
166 | pwm->pwm_id = pwm_id; | 178 | pwm->pwm_id = pwm_id; |