aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pwm
diff options
context:
space:
mode:
authorCooper Jr., Franklin <fcooper@ti.com>2016-05-03 11:56:52 -0400
committerThierry Reding <thierry.reding@gmail.com>2016-07-08 11:53:37 -0400
commitae5200d2271691b28aff8d0409fbefd4644ff507 (patch)
treed1b36c46c5888d9e2f3abf97818bbdf6ffcaa850 /drivers/pwm
parente1aaf89a5415ab6514cb6798148c7fe04c0ee138 (diff)
pwm: pwm-ti*: Get the clock from the PWMSS parent when using old bindings
When using the old eCAP and ePWM bindings for AM335x and AM437x the clock can be retrieved from the PWMSS parent. Newer bindings will insure that this clock is provided via device tree. Therefore, update this driver to support the newer and older bindings. In the case of the older binding being used give a warning. Signed-off-by: Franklin S Cooper Jr <fcooper@ti.com> [thierry.reding@gmail.com: rewrite slightly for readability] Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
Diffstat (limited to 'drivers/pwm')
-rw-r--r--drivers/pwm/pwm-tiecap.c9
-rw-r--r--drivers/pwm/pwm-tiehrpwm.c9
2 files changed, 18 insertions, 0 deletions
diff --git a/drivers/pwm/pwm-tiecap.c b/drivers/pwm/pwm-tiecap.c
index 616af764a276..0dc5b97a7524 100644
--- a/drivers/pwm/pwm-tiecap.c
+++ b/drivers/pwm/pwm-tiecap.c
@@ -195,6 +195,7 @@ static const struct pwm_ops ecap_pwm_ops = {
195}; 195};
196 196
197static const struct of_device_id ecap_of_match[] = { 197static const struct of_device_id ecap_of_match[] = {
198 { .compatible = "ti,am3352-ecap" },
198 { .compatible = "ti,am33xx-ecap" }, 199 { .compatible = "ti,am33xx-ecap" },
199 {}, 200 {},
200}; 201};
@@ -202,6 +203,7 @@ MODULE_DEVICE_TABLE(of, ecap_of_match);
202 203
203static int ecap_pwm_probe(struct platform_device *pdev) 204static int ecap_pwm_probe(struct platform_device *pdev)
204{ 205{
206 struct device_node *np = pdev->dev.of_node;
205 int ret; 207 int ret;
206 struct resource *r; 208 struct resource *r;
207 struct clk *clk; 209 struct clk *clk;
@@ -214,6 +216,13 @@ static int ecap_pwm_probe(struct platform_device *pdev)
214 216
215 clk = devm_clk_get(&pdev->dev, "fck"); 217 clk = devm_clk_get(&pdev->dev, "fck");
216 if (IS_ERR(clk)) { 218 if (IS_ERR(clk)) {
219 if (of_device_is_compatible(np, "ti,am33xx-ecap")) {
220 dev_warn(&pdev->dev, "Binding is obsolete.\n");
221 clk = devm_clk_get(pdev->dev.parent, "fck");
222 }
223 }
224
225 if (IS_ERR(clk)) {
217 dev_err(&pdev->dev, "failed to get clock\n"); 226 dev_err(&pdev->dev, "failed to get clock\n");
218 return PTR_ERR(clk); 227 return PTR_ERR(clk);
219 } 228 }
diff --git a/drivers/pwm/pwm-tiehrpwm.c b/drivers/pwm/pwm-tiehrpwm.c
index 6a41e66015b6..c791720d27b0 100644
--- a/drivers/pwm/pwm-tiehrpwm.c
+++ b/drivers/pwm/pwm-tiehrpwm.c
@@ -426,6 +426,7 @@ static const struct pwm_ops ehrpwm_pwm_ops = {
426}; 426};
427 427
428static const struct of_device_id ehrpwm_of_match[] = { 428static const struct of_device_id ehrpwm_of_match[] = {
429 { .compatible = "ti,am3352-ehrpwm" },
429 { .compatible = "ti,am33xx-ehrpwm" }, 430 { .compatible = "ti,am33xx-ehrpwm" },
430 {}, 431 {},
431}; 432};
@@ -433,6 +434,7 @@ MODULE_DEVICE_TABLE(of, ehrpwm_of_match);
433 434
434static int ehrpwm_pwm_probe(struct platform_device *pdev) 435static int ehrpwm_pwm_probe(struct platform_device *pdev)
435{ 436{
437 struct device_node *np = pdev->dev.of_node;
436 int ret; 438 int ret;
437 struct resource *r; 439 struct resource *r;
438 struct clk *clk; 440 struct clk *clk;
@@ -445,6 +447,13 @@ static int ehrpwm_pwm_probe(struct platform_device *pdev)
445 447
446 clk = devm_clk_get(&pdev->dev, "fck"); 448 clk = devm_clk_get(&pdev->dev, "fck");
447 if (IS_ERR(clk)) { 449 if (IS_ERR(clk)) {
450 if (of_device_is_compatible(np, "ti,am33xx-ecap")) {
451 dev_warn(&pdev->dev, "Binding is obsolete.\n");
452 clk = devm_clk_get(pdev->dev.parent, "fck");
453 }
454 }
455
456 if (IS_ERR(clk)) {
448 dev_err(&pdev->dev, "failed to get clock\n"); 457 dev_err(&pdev->dev, "failed to get clock\n");
449 return PTR_ERR(clk); 458 return PTR_ERR(clk);
450 } 459 }