From: Marc Kleine-Budde <mkl@pengutronix.de>
To: linux-pwm@vger.kernel.org
Cc: Thierry Reding <thierry.reding@gmail.com>,
kernel@pengutronix.de, Marc Kleine-Budde <mkl@pengutronix.de>
Subject: [PATCH] pwm: imx: use of_alias_get_id() to get pwm base from DT alias
Date: Wed, 11 Nov 2015 14:24:01 +0100 [thread overview]
Message-ID: <1447248241-18352-1-git-send-email-mkl@pengutronix.de> (raw)
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 <mkl@pengutronix.de>
---
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
next reply other threads:[~2015-11-11 13:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-11 13:24 Marc Kleine-Budde [this message]
2015-11-12 12:43 ` [PATCH] pwm: imx: use of_alias_get_id() to get pwm base from DT alias Thierry Reding
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1447248241-18352-1-git-send-email-mkl@pengutronix.de \
--to=mkl@pengutronix.de \
--cc=kernel@pengutronix.de \
--cc=linux-pwm@vger.kernel.org \
--cc=thierry.reding@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).