diff options
author | Philip, Avinash <avinashphilip@ti.com> | 2012-11-27 03:48:12 -0500 |
---|---|---|
committer | Thierry Reding <thierry.reding@avionic-design.de> | 2012-11-28 09:16:16 -0500 |
commit | d91861dafda44d808272f55758ca91d962feda6e (patch) | |
tree | 95a9e83fef7076b3a23e2835de5b7b85bc812b38 /drivers/pwm | |
parent | 3db9b76d7b6aa6eee1f9be83cf807e531e74bf4f (diff) |
pwm: pwm-tiehrpwm: Adding TBCLK gating support.
Some platforms (like AM33XX) requires clock gating from control module
explicitly for TBCLK. Enabling of this clock required for the
functioning of the time base sub module in EHRPWM module. Adding support
for handling by enabling the clock on PWM device enable & disable on PWM
device disable. Platforms don't have explicit TBCLK gating has to add
dummy TBCLK node.
Signed-off-by: Philip, Avinash <avinashphilip@ti.com>
Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
Diffstat (limited to 'drivers/pwm')
-rw-r--r-- | drivers/pwm/pwm-tiehrpwm.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/pwm/pwm-tiehrpwm.c b/drivers/pwm/pwm-tiehrpwm.c index d3c1dff0a0dc..565f96ad2787 100644 --- a/drivers/pwm/pwm-tiehrpwm.c +++ b/drivers/pwm/pwm-tiehrpwm.c | |||
@@ -115,6 +115,7 @@ struct ehrpwm_pwm_chip { | |||
115 | void __iomem *mmio_base; | 115 | void __iomem *mmio_base; |
116 | unsigned long period_cycles[NUM_PWM_CHANNEL]; | 116 | unsigned long period_cycles[NUM_PWM_CHANNEL]; |
117 | enum pwm_polarity polarity[NUM_PWM_CHANNEL]; | 117 | enum pwm_polarity polarity[NUM_PWM_CHANNEL]; |
118 | struct clk *tbclk; | ||
118 | }; | 119 | }; |
119 | 120 | ||
120 | static inline struct ehrpwm_pwm_chip *to_ehrpwm_pwm_chip(struct pwm_chip *chip) | 121 | static inline struct ehrpwm_pwm_chip *to_ehrpwm_pwm_chip(struct pwm_chip *chip) |
@@ -335,6 +336,9 @@ static int ehrpwm_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) | |||
335 | /* Channels polarity can be configured from action qualifier module */ | 336 | /* Channels polarity can be configured from action qualifier module */ |
336 | configure_polarity(pc, pwm->hwpwm); | 337 | configure_polarity(pc, pwm->hwpwm); |
337 | 338 | ||
339 | /* Enable TBCLK before enabling PWM device */ | ||
340 | clk_enable(pc->tbclk); | ||
341 | |||
338 | /* Enable time counter for free_run */ | 342 | /* Enable time counter for free_run */ |
339 | ehrpwm_modify(pc->mmio_base, TBCTL, TBCTL_RUN_MASK, TBCTL_FREE_RUN); | 343 | ehrpwm_modify(pc->mmio_base, TBCTL, TBCTL_RUN_MASK, TBCTL_FREE_RUN); |
340 | return 0; | 344 | return 0; |
@@ -363,6 +367,9 @@ static void ehrpwm_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) | |||
363 | 367 | ||
364 | ehrpwm_modify(pc->mmio_base, AQCSFRC, aqcsfrc_mask, aqcsfrc_val); | 368 | ehrpwm_modify(pc->mmio_base, AQCSFRC, aqcsfrc_mask, aqcsfrc_val); |
365 | 369 | ||
370 | /* Disabling TBCLK on PWM disable */ | ||
371 | clk_disable(pc->tbclk); | ||
372 | |||
366 | /* Stop Time base counter */ | 373 | /* Stop Time base counter */ |
367 | ehrpwm_modify(pc->mmio_base, TBCTL, TBCTL_RUN_MASK, TBCTL_STOP_NEXT); | 374 | ehrpwm_modify(pc->mmio_base, TBCTL, TBCTL_RUN_MASK, TBCTL_STOP_NEXT); |
368 | 375 | ||
@@ -432,6 +439,13 @@ static int __devinit ehrpwm_pwm_probe(struct platform_device *pdev) | |||
432 | if (!pc->mmio_base) | 439 | if (!pc->mmio_base) |
433 | return -EADDRNOTAVAIL; | 440 | return -EADDRNOTAVAIL; |
434 | 441 | ||
442 | /* Acquire tbclk for Time Base EHRPWM submodule */ | ||
443 | pc->tbclk = devm_clk_get(&pdev->dev, "tbclk"); | ||
444 | if (IS_ERR(pc->tbclk)) { | ||
445 | dev_err(&pdev->dev, "Failed to get tbclk\n"); | ||
446 | return PTR_ERR(pc->tbclk); | ||
447 | } | ||
448 | |||
435 | ret = pwmchip_add(&pc->chip); | 449 | ret = pwmchip_add(&pc->chip); |
436 | if (ret < 0) { | 450 | if (ret < 0) { |
437 | dev_err(&pdev->dev, "pwmchip_add() failed: %d\n", ret); | 451 | dev_err(&pdev->dev, "pwmchip_add() failed: %d\n", ret); |