]> git.karo-electronics.de Git - linux-beck.git/commitdiff
pwm: pwm-ti*: Get the clock from the PWMSS parent when using old bindings
authorCooper Jr., Franklin <fcooper@ti.com>
Tue, 3 May 2016 15:56:52 +0000 (10:56 -0500)
committerThierry Reding <thierry.reding@gmail.com>
Fri, 8 Jul 2016 15:53:37 +0000 (17:53 +0200)
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>
drivers/pwm/pwm-tiecap.c
drivers/pwm/pwm-tiehrpwm.c

index 616af764a27682ed0301e897ab731f5ffe8c5a13..0dc5b97a752460656ecd8f7c07fba91b1e375da0 100644 (file)
@@ -195,6 +195,7 @@ static const struct pwm_ops ecap_pwm_ops = {
 };
 
 static const struct of_device_id ecap_of_match[] = {
+       { .compatible   = "ti,am3352-ecap" },
        { .compatible   = "ti,am33xx-ecap" },
        {},
 };
@@ -202,6 +203,7 @@ MODULE_DEVICE_TABLE(of, ecap_of_match);
 
 static int ecap_pwm_probe(struct platform_device *pdev)
 {
+       struct device_node *np = pdev->dev.of_node;
        int ret;
        struct resource *r;
        struct clk *clk;
@@ -213,6 +215,13 @@ static int ecap_pwm_probe(struct platform_device *pdev)
                return -ENOMEM;
 
        clk = devm_clk_get(&pdev->dev, "fck");
+       if (IS_ERR(clk)) {
+               if (of_device_is_compatible(np, "ti,am33xx-ecap")) {
+                       dev_warn(&pdev->dev, "Binding is obsolete.\n");
+                       clk = devm_clk_get(pdev->dev.parent, "fck");
+               }
+       }
+
        if (IS_ERR(clk)) {
                dev_err(&pdev->dev, "failed to get clock\n");
                return PTR_ERR(clk);
index 6a41e66015b67fa84865891cbc3e97e12de6539f..c791720d27b0965590c7427ac89d484cdb4880a1 100644 (file)
@@ -426,6 +426,7 @@ static const struct pwm_ops ehrpwm_pwm_ops = {
 };
 
 static const struct of_device_id ehrpwm_of_match[] = {
+       { .compatible   = "ti,am3352-ehrpwm" },
        { .compatible   = "ti,am33xx-ehrpwm" },
        {},
 };
@@ -433,6 +434,7 @@ MODULE_DEVICE_TABLE(of, ehrpwm_of_match);
 
 static int ehrpwm_pwm_probe(struct platform_device *pdev)
 {
+       struct device_node *np = pdev->dev.of_node;
        int ret;
        struct resource *r;
        struct clk *clk;
@@ -444,6 +446,13 @@ static int ehrpwm_pwm_probe(struct platform_device *pdev)
                return -ENOMEM;
 
        clk = devm_clk_get(&pdev->dev, "fck");
+       if (IS_ERR(clk)) {
+               if (of_device_is_compatible(np, "ti,am33xx-ecap")) {
+                       dev_warn(&pdev->dev, "Binding is obsolete.\n");
+                       clk = devm_clk_get(pdev->dev.parent, "fck");
+               }
+       }
+
        if (IS_ERR(clk)) {
                dev_err(&pdev->dev, "failed to get clock\n");
                return PTR_ERR(clk);