aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/stmpe-i2c.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mfd/stmpe-i2c.c')
-rw-r--r--drivers/mfd/stmpe-i2c.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/drivers/mfd/stmpe-i2c.c b/drivers/mfd/stmpe-i2c.c
index 0da02e11d58e..a45f9c0a330a 100644
--- a/drivers/mfd/stmpe-i2c.c
+++ b/drivers/mfd/stmpe-i2c.c
@@ -14,6 +14,7 @@
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/types.h> 16#include <linux/types.h>
17#include <linux/of_device.h>
17#include "stmpe.h" 18#include "stmpe.h"
18 19
19static int i2c_reg_read(struct stmpe *stmpe, u8 reg) 20static int i2c_reg_read(struct stmpe *stmpe, u8 reg)
@@ -52,15 +53,41 @@ static struct stmpe_client_info i2c_ci = {
52 .write_block = i2c_block_write, 53 .write_block = i2c_block_write,
53}; 54};
54 55
56static const struct of_device_id stmpe_of_match[] = {
57 { .compatible = "st,stmpe610", .data = (void *)STMPE610, },
58 { .compatible = "st,stmpe801", .data = (void *)STMPE801, },
59 { .compatible = "st,stmpe811", .data = (void *)STMPE811, },
60 { .compatible = "st,stmpe1601", .data = (void *)STMPE1601, },
61 { .compatible = "st,stmpe1801", .data = (void *)STMPE1801, },
62 { .compatible = "st,stmpe2401", .data = (void *)STMPE2401, },
63 { .compatible = "st,stmpe2403", .data = (void *)STMPE2403, },
64 {},
65};
66MODULE_DEVICE_TABLE(of, stmpe_of_match);
67
55static int 68static int
56stmpe_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) 69stmpe_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
57{ 70{
71 int partnum;
72 const struct of_device_id *of_id;
73
58 i2c_ci.data = (void *)id; 74 i2c_ci.data = (void *)id;
59 i2c_ci.irq = i2c->irq; 75 i2c_ci.irq = i2c->irq;
60 i2c_ci.client = i2c; 76 i2c_ci.client = i2c;
61 i2c_ci.dev = &i2c->dev; 77 i2c_ci.dev = &i2c->dev;
62 78
63 return stmpe_probe(&i2c_ci, id->driver_data); 79 of_id = of_match_device(stmpe_of_match, &i2c->dev);
80 if (!of_id) {
81 /*
82 * This happens when the I2C ID matches the node name
83 * but no real compatible string has been given.
84 */
85 dev_info(&i2c->dev, "matching on node name, compatible is preferred\n");
86 partnum = id->driver_data;
87 } else
88 partnum = (int)of_id->data;
89
90 return stmpe_probe(&i2c_ci, partnum);
64} 91}
65 92
66static int stmpe_i2c_remove(struct i2c_client *i2c) 93static int stmpe_i2c_remove(struct i2c_client *i2c)
@@ -89,6 +116,7 @@ static struct i2c_driver stmpe_i2c_driver = {
89#ifdef CONFIG_PM 116#ifdef CONFIG_PM
90 .pm = &stmpe_dev_pm_ops, 117 .pm = &stmpe_dev_pm_ops,
91#endif 118#endif
119 .of_match_table = stmpe_of_match,
92 }, 120 },
93 .probe = stmpe_i2c_probe, 121 .probe = stmpe_i2c_probe,
94 .remove = stmpe_i2c_remove, 122 .remove = stmpe_i2c_remove,