summaryrefslogtreecommitdiffstats
path: root/drivers/mfd
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-06-06 13:43:50 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2013-06-06 16:17:17 +0200
commitb7ee4acb4a1554e967dacbfe8ccb981cf52e337d (patch)
tree63724cfa2e6b64de062de40e24695d581ab7115a /drivers/mfd
parent89825aed2928470947276790708389133cdd3e89 (diff)
downloadbarebox-b7ee4acb4a1554e967dacbfe8ccb981cf52e337d.tar.gz
barebox-b7ee4acb4a1554e967dacbfe8ccb981cf52e337d.tar.xz
mfd: stmpe: Add devicetree probe support
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>
Diffstat (limited to 'drivers/mfd')
-rw-r--r--drivers/mfd/stmpe-i2c.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/drivers/mfd/stmpe-i2c.c b/drivers/mfd/stmpe-i2c.c
index d87620e8ff..d785430d12 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)