From: s.hauer@pengutronix.de (Sascha Hauer)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 5/9] pwm i.MX: add devicetree support
Date: Tue, 28 Aug 2012 13:48:20 +0200 [thread overview]
Message-ID: <1346154504-5623-6-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1346154504-5623-1-git-send-email-s.hauer@pengutronix.de>
From: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/pwm/pwm-imx.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/drivers/pwm/pwm-imx.c b/drivers/pwm/pwm-imx.c
index a689144..dfc1bae 100644
--- a/drivers/pwm/pwm-imx.c
+++ b/drivers/pwm/pwm-imx.c
@@ -16,9 +16,9 @@
#include <linux/clk.h>
#include <linux/io.h>
#include <linux/pwm.h>
+#include <linux/of_device.h>
#include <mach/hardware.h>
-
/* i.MX1 and i.MX21 share the same PWM function block: */
#define MX1_PWMC 0x00 /* PWM Control Register */
@@ -203,8 +203,17 @@ static struct pwm_ops imx_pwm_ops = {
.owner = THIS_MODULE,
};
+static const struct of_device_id imx_pwm_dt_ids[] = {
+ { .compatible = "fsl,imx1-pwm", .data = &imx_pwm_config_v1, },
+ { .compatible = "fsl,imx27-pwm", .data = &imx_pwm_config_v2, },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, imx_pwm_of_match);
+
static int __devinit imx_pwm_probe(struct platform_device *pdev)
{
+ const struct of_device_id *of_id =
+ of_match_device(imx_pwm_dt_ids, &pdev->dev);
struct imx_chip *imx;
struct resource *r;
int ret = 0;
@@ -235,12 +244,16 @@ static int __devinit imx_pwm_probe(struct platform_device *pdev)
if (imx->mmio_base == NULL)
return -EADDRNOTAVAIL;
- if (cpu_is_mx1() || cpu_is_mx21()) {
- imx->config = imx_pwm_config_v1;
- imx->set_enable = imx_pwm_set_enable_v1;
+ if (of_id) {
+ imx->config = of_id->data;
} else {
- imx->config = imx_pwm_config_v2;
- imx->set_enable = imx_pwm_set_enable_v2;
+ if (cpu_is_mx1() || cpu_is_mx21()) {
+ imx->config = imx_pwm_config_v1;
+ imx->set_enable = imx_pwm_set_enable_v1;
+ } else {
+ imx->config = imx_pwm_config_v2;
+ imx->set_enable = imx_pwm_set_enable_v2;
+ }
}
ret = pwmchip_add(&imx->chip);
--
1.7.10.4
next prev parent reply other threads:[~2012-08-28 11:48 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-28 11:48 i.MX pwm patches Sascha Hauer
2012-08-28 11:48 ` [PATCH 1/9] pwm i.MX: factor out SoC specific functions Sascha Hauer
2012-08-28 11:48 ` [PATCH 2/9] pwm i.MX: remove unnecessary if in pwm_[en|dis]able Sascha Hauer
2012-08-28 11:48 ` [PATCH 3/9] pwm i.MX: add functions to enable/disable pwm Sascha Hauer
2012-08-28 11:48 ` [PATCH 4/9] pwm i.MX: Use module_platform_driver Sascha Hauer
2012-08-28 11:48 ` Sascha Hauer [this message]
2012-08-30 22:26 ` [PATCH 5/9] pwm i.MX: add devicetree support Shawn Guo
2012-08-28 11:48 ` [PATCH 6/9] pwm i.MX: use per clock unconditionally Sascha Hauer
2012-08-28 11:48 ` [PATCH 7/9] pwm i.MX: fix clock lookup Sascha Hauer
2012-08-28 11:48 ` [PATCH 8/9] ARM i.MX53: Add pwms to dtsi Sascha Hauer
2012-08-30 22:32 ` Shawn Guo
2012-08-31 13:07 ` Sascha Hauer
2012-08-31 0:16 ` Shawn Guo
2012-09-07 13:29 ` Thierry Reding
2012-09-07 17:26 ` Sascha Hauer
2012-09-07 20:10 ` Thierry Reding
2012-08-28 11:48 ` [PATCH 9/9] pwm i.MX: add devicetree support Sascha Hauer
2012-08-30 22:28 ` Shawn Guo
2012-08-30 21:45 ` i.MX pwm patches Shawn Guo
2012-08-31 13:05 ` Sascha Hauer
-- strict thread matches above, loose matches on Subject: below --
2012-09-06 12:48 [PATCH v3] pwm i.MX: add devicetree support Sascha Hauer
2012-09-06 12:48 ` [PATCH 5/9] " Sascha Hauer
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=1346154504-5623-6-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
/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).