The DT probe uses a dynamically allocated base by pwm core. The actual pwm
device number depends on the probe order of the devices in the DT. This not
intuitive and sometimes hard for users to map the Linux pwm number to the
actual hardware pin. (Especially on the mx25, where pwm4 is probed first.)

Use alias to identify the id of pwm port and pass it as base to the pwm core.
If an alias is not defined in device tree, a base number dynamically allocated
by pwm core will be used.

Signed-off-by: Marc Kleine-Budde <[email protected]>
---
 drivers/pwm/pwm-imx.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/pwm/pwm-imx.c b/drivers/pwm/pwm-imx.c
index 66d6f0c5c421..9a2a46337d82 100644
--- a/drivers/pwm/pwm-imx.c
+++ b/drivers/pwm/pwm-imx.c
@@ -276,11 +276,15 @@ static int imx_pwm_probe(struct platform_device *pdev)
        const struct imx_pwm_data *data;
        struct imx_chip *imx;
        struct resource *r;
-       int ret = 0;
+       int base, ret = 0;
 
        if (!of_id)
                return -ENODEV;
 
+       base = of_alias_get_id(pdev->dev.of_node, "pwm");
+       if (base < 0)
+               base = -1;
+
        imx = devm_kzalloc(&pdev->dev, sizeof(*imx), GFP_KERNEL);
        if (imx == NULL)
                return -ENOMEM;
@@ -301,7 +305,7 @@ static int imx_pwm_probe(struct platform_device *pdev)
 
        imx->chip.ops = &imx_pwm_ops;
        imx->chip.dev = &pdev->dev;
-       imx->chip.base = -1;
+       imx->chip.base = base;
        imx->chip.npwm = 1;
        imx->chip.can_sleep = true;
 
-- 
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe linux-pwm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to