aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorSteve Twiss <stwiss.opensource@diasemi.com>2016-07-15 05:29:41 -0400
committerMark Brown <broonie@kernel.org>2016-07-15 06:45:26 -0400
commit2d0cf04ce166581c617f8943a116587a730f40b6 (patch)
tree09ddd54669b573f953f7d891cc2254dc4f216cdb /drivers/regulator
parent1a695a905c18548062509178b98bc91e67510864 (diff)
regulator: da9210: addition of device tree support
Addition of device tree support for DA9210. Two files are modified, the driver source file and the binding document. Updates for the regulator source file include an .of_match_table entry and node match checking in the probe() function for a compatible da9210 string. Minor binding documentation changes have been made to the title and the example. Tested-by: Steve Twiss <stwiss.opensource@diasemi.com> Signed-off-by: Steve Twiss <stwiss.opensource@diasemi.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/da9210-regulator.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/drivers/regulator/da9210-regulator.c b/drivers/regulator/da9210-regulator.c
index 01c0e3709b66..d0496d6b0934 100644
--- a/drivers/regulator/da9210-regulator.c
+++ b/drivers/regulator/da9210-regulator.c
@@ -21,12 +21,11 @@
21#include <linux/err.h> 21#include <linux/err.h>
22#include <linux/i2c.h> 22#include <linux/i2c.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/init.h>
25#include <linux/interrupt.h> 24#include <linux/interrupt.h>
26#include <linux/irq.h> 25#include <linux/irq.h>
27#include <linux/slab.h>
28#include <linux/regulator/driver.h> 26#include <linux/regulator/driver.h>
29#include <linux/regulator/machine.h> 27#include <linux/regulator/machine.h>
28#include <linux/of_device.h>
30#include <linux/regulator/of_regulator.h> 29#include <linux/regulator/of_regulator.h>
31#include <linux/regmap.h> 30#include <linux/regmap.h>
32 31
@@ -179,6 +178,13 @@ error_i2c:
179/* 178/*
180 * I2C driver interface functions 179 * I2C driver interface functions
181 */ 180 */
181
182static const struct of_device_id da9210_dt_ids[] = {
183 { .compatible = "dlg,da9210", },
184 { }
185};
186MODULE_DEVICE_TABLE(of, da9210_dt_ids);
187
182static int da9210_i2c_probe(struct i2c_client *i2c, 188static int da9210_i2c_probe(struct i2c_client *i2c,
183 const struct i2c_device_id *id) 189 const struct i2c_device_id *id)
184{ 190{
@@ -188,6 +194,16 @@ static int da9210_i2c_probe(struct i2c_client *i2c,
188 struct regulator_dev *rdev = NULL; 194 struct regulator_dev *rdev = NULL;
189 struct regulator_config config = { }; 195 struct regulator_config config = { };
190 int error; 196 int error;
197 const struct of_device_id *match;
198
199 if (i2c->dev.of_node && !pdata) {
200 match = of_match_device(of_match_ptr(da9210_dt_ids),
201 &i2c->dev);
202 if (!match) {
203 dev_err(&i2c->dev, "Error: No device match found\n");
204 return -ENODEV;
205 }
206 }
191 207
192 chip = devm_kzalloc(&i2c->dev, sizeof(struct da9210), GFP_KERNEL); 208 chip = devm_kzalloc(&i2c->dev, sizeof(struct da9210), GFP_KERNEL);
193 if (!chip) 209 if (!chip)
@@ -264,6 +280,7 @@ MODULE_DEVICE_TABLE(i2c, da9210_i2c_id);
264static struct i2c_driver da9210_regulator_driver = { 280static struct i2c_driver da9210_regulator_driver = {
265 .driver = { 281 .driver = {
266 .name = "da9210", 282 .name = "da9210",
283 .of_match_table = of_match_ptr(da9210_dt_ids),
267 }, 284 },
268 .probe = da9210_i2c_probe, 285 .probe = da9210_i2c_probe,
269 .id_table = da9210_i2c_id, 286 .id_table = da9210_i2c_id,