Skip to content

Commit

Permalink
pwm: pwm-ti*: Get the clock from the PWMSS parent when using old bind…
Browse files Browse the repository at this point in the history
…ings

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>
  • Loading branch information
Cooper Jr., Franklin authored and Thierry Reding committed Jul 8, 2016
1 parent e1aaf89 commit ae5200d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions drivers/pwm/pwm-tiecap.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,15 @@ 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" },
{},
};
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;
Expand All @@ -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);
Expand Down
9 changes: 9 additions & 0 deletions drivers/pwm/pwm-tiehrpwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,13 +426,15 @@ 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" },
{},
};
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;
Expand All @@ -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);
Expand Down

0 comments on commit ae5200d

Please sign in to comment.