From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH] mfd: stmpe: Add devicetree probe support
Date: Thu, 6 Jun 2013 16:20:09 +0200 [thread overview]
Message-ID: <1370528409-3439-1-git-send-email-s.hauer@pengutronix.de> (raw)
Our driver matches stmpe-i2c and stmpe-spi. It seems the device
we really support is the stmpe1601, so use this one for matching
the devicetree compatible.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/mfd/stmpe-i2c.c | 32 ++++++++++++++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
diff --git a/drivers/mfd/stmpe-i2c.c b/drivers/mfd/stmpe-i2c.c
index d87620e..d785430 100644
--- a/drivers/mfd/stmpe-i2c.c
+++ b/drivers/mfd/stmpe-i2c.c
@@ -106,6 +106,25 @@ static struct file_operations stmpe_fops = {
.write = stmpe_write,
};
+static struct stmpe_platform_data *stmpe_of_probe(struct device_d *dev)
+{
+ struct stmpe_platform_data *pdata;
+ struct device_node *node;
+
+ if (!IS_ENABLED(CONFIG_OFDEVICE) || !dev->device_node)
+ return NULL;
+
+ pdata = xzalloc(sizeof(*pdata));
+
+ device_node_for_nach_child(dev->device_node, node) {
+ if (!strcmp(node->name, "stmpe_gpio")) {
+ pdata->blocks |= STMPE_BLOCK_GPIO;
+ }
+ }
+
+ return pdata;
+}
+
static int stmpe_probe(struct device_d *dev)
{
struct stmpe_platform_data *pdata = dev->platform_data;
@@ -113,8 +132,11 @@ static int stmpe_probe(struct device_d *dev)
struct stmpe_client_info *i2c_ci;
if (!pdata) {
- dev_dbg(dev, "no platform data\n");
- return -ENODEV;
+ pdata = stmpe_of_probe(dev);
+ if (!pdata) {
+ dev_dbg(dev, "no platform data\n");
+ return -ENODEV;
+ }
}
stmpe_dev = xzalloc(sizeof(struct stmpe));
@@ -140,9 +162,15 @@ static int stmpe_probe(struct device_d *dev)
return 0;
}
+static struct platform_device_id stmpe_i2c_id[] = {
+ { "stmpe1601", 0 },
+ { }
+};
+
static struct driver_d stmpe_driver = {
.name = DRIVERNAME,
.probe = stmpe_probe,
+ .id_table = stmpe_i2c_id,
};
static int stmpe_init(void)
--
1.8.2.rc2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
reply other threads:[~2013-06-06 14:20 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1370528409-3439-1-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@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