blob: 297b3aa7c75320f382bafb7b4cf4e523db0b1d5c [file] [log] [blame]
Axel Linfd2f02f2019-05-03 13:36:37 +08001// SPDX-License-Identifier: GPL-2.0+
2//
3// da9211-regulator.c - Regulator device driver for DA9211/DA9212
4// /DA9213/DA9223/DA9214/DA9224/DA9215/DA9225
5// Copyright (C) 2015 Dialog Semiconductor Ltd.
James Ban1028a372014-07-14 13:48:45 +09006
7#include <linux/err.h>
James Ban1028a372014-07-14 13:48:45 +09008#include <linux/i2c.h>
9#include <linux/module.h>
10#include <linux/init.h>
11#include <linux/slab.h>
12#include <linux/regulator/driver.h>
13#include <linux/regulator/machine.h>
14#include <linux/regmap.h>
15#include <linux/irq.h>
16#include <linux/interrupt.h>
Linus Walleij11da04af2018-02-12 14:17:02 +010017#include <linux/gpio/consumer.h>
James Banbf3baca2014-08-27 11:47:07 +090018#include <linux/regulator/of_regulator.h>
James Ban1028a372014-07-14 13:48:45 +090019#include <linux/regulator/da9211.h>
Anand K Mistry6c8b6592020-07-02 13:15:22 +100020#include <dt-bindings/regulator/dlg,da9211-regulator.h>
James Ban1028a372014-07-14 13:48:45 +090021#include "da9211-regulator.h"
22
James Ban005547e2014-08-08 14:27:04 +090023/* DEVICE IDs */
24#define DA9211_DEVICE_ID 0x22
25#define DA9213_DEVICE_ID 0x23
James Ban7bd39352015-06-30 13:39:39 +090026#define DA9215_DEVICE_ID 0x24
James Ban005547e2014-08-08 14:27:04 +090027
James Ban1028a372014-07-14 13:48:45 +090028/* DA9211 REGULATOR IDs */
29#define DA9211_ID_BUCKA 0
30#define DA9211_ID_BUCKB 1
31
32struct da9211 {
33 struct device *dev;
34 struct regmap *regmap;
35 struct da9211_pdata *pdata;
36 struct regulator_dev *rdev[DA9211_MAX_REGULATORS];
37 int num_regulator;
38 int chip_irq;
James Ban005547e2014-08-08 14:27:04 +090039 int chip_id;
James Ban1028a372014-07-14 13:48:45 +090040};
41
42static const struct regmap_range_cfg da9211_regmap_range[] = {
43 {
44 .selector_reg = DA9211_REG_PAGE_CON,
45 .selector_mask = DA9211_REG_PAGE_MASK,
46 .selector_shift = DA9211_REG_PAGE_SHIFT,
47 .window_start = 0,
48 .window_len = 256,
49 .range_min = 0,
James Ban005547e2014-08-08 14:27:04 +090050 .range_max = 5*128,
James Ban1028a372014-07-14 13:48:45 +090051 },
52};
53
54static const struct regmap_config da9211_regmap_config = {
55 .reg_bits = 8,
56 .val_bits = 8,
James Ban005547e2014-08-08 14:27:04 +090057 .max_register = 5 * 128,
James Ban1028a372014-07-14 13:48:45 +090058 .ranges = da9211_regmap_range,
59 .num_ranges = ARRAY_SIZE(da9211_regmap_range),
60};
61
62/* Default limits measured in millivolts and milliamps */
63#define DA9211_MIN_MV 300
64#define DA9211_MAX_MV 1570
65#define DA9211_STEP_MV 10
66
James Ban005547e2014-08-08 14:27:04 +090067/* Current limits for DA9211 buck (uA) indices
68 * corresponds with register values
69 */
James Ban1028a372014-07-14 13:48:45 +090070static const int da9211_current_limits[] = {
71 2000000, 2200000, 2400000, 2600000, 2800000, 3000000, 3200000, 3400000,
72 3600000, 3800000, 4000000, 4200000, 4400000, 4600000, 4800000, 5000000
73};
James Ban005547e2014-08-08 14:27:04 +090074/* Current limits for DA9213 buck (uA) indices
75 * corresponds with register values
76 */
77static const int da9213_current_limits[] = {
78 3000000, 3200000, 3400000, 3600000, 3800000, 4000000, 4200000, 4400000,
79 4600000, 4800000, 5000000, 5200000, 5400000, 5600000, 5800000, 6000000
80};
James Ban7bd39352015-06-30 13:39:39 +090081/* Current limits for DA9215 buck (uA) indices
82 * corresponds with register values
83 */
84static const int da9215_current_limits[] = {
85 4000000, 4200000, 4400000, 4600000, 4800000, 5000000, 5200000, 5400000,
86 5600000, 5800000, 6000000, 6200000, 6400000, 6600000, 6800000, 7000000
87};
James Ban1028a372014-07-14 13:48:45 +090088
Anand K Mistry6f1f1a82020-07-02 13:15:24 +100089static unsigned int da9211_map_buck_mode(unsigned int mode)
90{
91 switch (mode) {
92 case DA9211_BUCK_MODE_SLEEP:
93 return REGULATOR_MODE_STANDBY;
94 case DA9211_BUCK_MODE_SYNC:
95 return REGULATOR_MODE_FAST;
96 case DA9211_BUCK_MODE_AUTO:
97 return REGULATOR_MODE_NORMAL;
98 default:
99 return REGULATOR_MODE_INVALID;
100 }
101}
102
James Ban1028a372014-07-14 13:48:45 +0900103static unsigned int da9211_buck_get_mode(struct regulator_dev *rdev)
104{
105 int id = rdev_get_id(rdev);
106 struct da9211 *chip = rdev_get_drvdata(rdev);
107 unsigned int data;
108 int ret, mode = 0;
109
110 ret = regmap_read(chip->regmap, DA9211_REG_BUCKA_CONF+id, &data);
111 if (ret < 0)
112 return ret;
113
114 switch (data & 0x03) {
115 case DA9211_BUCK_MODE_SYNC:
116 mode = REGULATOR_MODE_FAST;
117 break;
118 case DA9211_BUCK_MODE_AUTO:
119 mode = REGULATOR_MODE_NORMAL;
120 break;
121 case DA9211_BUCK_MODE_SLEEP:
122 mode = REGULATOR_MODE_STANDBY;
123 break;
124 }
125
126 return mode;
127}
128
129static int da9211_buck_set_mode(struct regulator_dev *rdev,
130 unsigned int mode)
131{
132 int id = rdev_get_id(rdev);
133 struct da9211 *chip = rdev_get_drvdata(rdev);
134 int val = 0;
135
136 switch (mode) {
137 case REGULATOR_MODE_FAST:
138 val = DA9211_BUCK_MODE_SYNC;
139 break;
140 case REGULATOR_MODE_NORMAL:
141 val = DA9211_BUCK_MODE_AUTO;
142 break;
143 case REGULATOR_MODE_STANDBY:
144 val = DA9211_BUCK_MODE_SLEEP;
145 break;
146 }
147
148 return regmap_update_bits(chip->regmap, DA9211_REG_BUCKA_CONF+id,
149 0x03, val);
150}
151
152static int da9211_set_current_limit(struct regulator_dev *rdev, int min,
153 int max)
154{
155 int id = rdev_get_id(rdev);
156 struct da9211 *chip = rdev_get_drvdata(rdev);
James Ban005547e2014-08-08 14:27:04 +0900157 int i, max_size;
158 const int *current_limits;
159
160 switch (chip->chip_id) {
161 case DA9211:
162 current_limits = da9211_current_limits;
163 max_size = ARRAY_SIZE(da9211_current_limits)-1;
164 break;
165 case DA9213:
166 current_limits = da9213_current_limits;
167 max_size = ARRAY_SIZE(da9213_current_limits)-1;
168 break;
James Ban7bd39352015-06-30 13:39:39 +0900169 case DA9215:
170 current_limits = da9215_current_limits;
171 max_size = ARRAY_SIZE(da9215_current_limits)-1;
172 break;
James Ban005547e2014-08-08 14:27:04 +0900173 default:
174 return -EINVAL;
175 }
James Ban1028a372014-07-14 13:48:45 +0900176
177 /* search for closest to maximum */
James Ban005547e2014-08-08 14:27:04 +0900178 for (i = max_size; i >= 0; i--) {
179 if (min <= current_limits[i] &&
180 max >= current_limits[i]) {
James Ban1028a372014-07-14 13:48:45 +0900181 return regmap_update_bits(chip->regmap,
182 DA9211_REG_BUCK_ILIM,
183 (0x0F << id*4), (i << id*4));
184 }
185 }
186
187 return -EINVAL;
188}
189
190static int da9211_get_current_limit(struct regulator_dev *rdev)
191{
192 int id = rdev_get_id(rdev);
193 struct da9211 *chip = rdev_get_drvdata(rdev);
194 unsigned int data;
195 int ret;
James Ban005547e2014-08-08 14:27:04 +0900196 const int *current_limits;
197
198 switch (chip->chip_id) {
199 case DA9211:
200 current_limits = da9211_current_limits;
201 break;
202 case DA9213:
203 current_limits = da9213_current_limits;
204 break;
James Ban7bd39352015-06-30 13:39:39 +0900205 case DA9215:
206 current_limits = da9215_current_limits;
207 break;
James Ban005547e2014-08-08 14:27:04 +0900208 default:
209 return -EINVAL;
210 }
James Ban1028a372014-07-14 13:48:45 +0900211
212 ret = regmap_read(chip->regmap, DA9211_REG_BUCK_ILIM, &data);
213 if (ret < 0)
214 return ret;
215
James Ban005547e2014-08-08 14:27:04 +0900216 /* select one of 16 values: 0000 (2000mA or 3000mA)
217 * to 1111 (5000mA or 6000mA).
218 */
James Ban1028a372014-07-14 13:48:45 +0900219 data = (data >> id*4) & 0x0F;
James Ban005547e2014-08-08 14:27:04 +0900220 return current_limits[data];
James Ban1028a372014-07-14 13:48:45 +0900221}
222
Julia Lawall71242b42015-12-19 16:07:09 +0100223static const struct regulator_ops da9211_buck_ops = {
James Ban1028a372014-07-14 13:48:45 +0900224 .get_mode = da9211_buck_get_mode,
225 .set_mode = da9211_buck_set_mode,
226 .enable = regulator_enable_regmap,
227 .disable = regulator_disable_regmap,
228 .is_enabled = regulator_is_enabled_regmap,
229 .set_voltage_sel = regulator_set_voltage_sel_regmap,
230 .get_voltage_sel = regulator_get_voltage_sel_regmap,
231 .list_voltage = regulator_list_voltage_linear,
232 .set_current_limit = da9211_set_current_limit,
233 .get_current_limit = da9211_get_current_limit,
234};
235
236#define DA9211_BUCK(_id) \
237{\
238 .name = #_id,\
239 .ops = &da9211_buck_ops,\
240 .type = REGULATOR_VOLTAGE,\
241 .id = DA9211_ID_##_id,\
242 .n_voltages = (DA9211_MAX_MV - DA9211_MIN_MV) / DA9211_STEP_MV + 1,\
243 .min_uV = (DA9211_MIN_MV * 1000),\
244 .uV_step = (DA9211_STEP_MV * 1000),\
245 .enable_reg = DA9211_REG_BUCKA_CONT + DA9211_ID_##_id,\
246 .enable_mask = DA9211_BUCKA_EN,\
247 .vsel_reg = DA9211_REG_VBUCKA_A + DA9211_ID_##_id * 2,\
248 .vsel_mask = DA9211_VBUCK_MASK,\
249 .owner = THIS_MODULE,\
Anand K Mistry6f1f1a82020-07-02 13:15:24 +1000250 .of_map_mode = da9211_map_buck_mode,\
James Ban1028a372014-07-14 13:48:45 +0900251}
252
253static struct regulator_desc da9211_regulators[] = {
254 DA9211_BUCK(BUCKA),
255 DA9211_BUCK(BUCKB),
256};
257
James Banbf3baca2014-08-27 11:47:07 +0900258#ifdef CONFIG_OF
259static struct of_regulator_match da9211_matches[] = {
Anand K Mistry6f1f1a82020-07-02 13:15:24 +1000260 [DA9211_ID_BUCKA] = {
261 .name = "BUCKA",
262 .desc = &da9211_regulators[DA9211_ID_BUCKA],
263 },
264 [DA9211_ID_BUCKB] = {
265 .name = "BUCKB",
266 .desc = &da9211_regulators[DA9211_ID_BUCKB],
267 },
James Banbf3baca2014-08-27 11:47:07 +0900268 };
269
270static struct da9211_pdata *da9211_parse_regulators_dt(
271 struct device *dev)
272{
273 struct da9211_pdata *pdata;
274 struct device_node *node;
275 int i, num, n;
276
277 node = of_get_child_by_name(dev->of_node, "regulators");
278 if (!node) {
279 dev_err(dev, "regulators node not found\n");
280 return ERR_PTR(-ENODEV);
281 }
282
283 num = of_regulator_match(dev, node, da9211_matches,
284 ARRAY_SIZE(da9211_matches));
285 of_node_put(node);
286 if (num < 0) {
287 dev_err(dev, "Failed to match regulators\n");
288 return ERR_PTR(-EINVAL);
289 }
290
291 pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
292 if (!pdata)
293 return ERR_PTR(-ENOMEM);
294
295 pdata->num_buck = num;
296
297 n = 0;
298 for (i = 0; i < ARRAY_SIZE(da9211_matches); i++) {
299 if (!da9211_matches[i].init_data)
300 continue;
301
302 pdata->init_data[n] = da9211_matches[i].init_data;
James Ban076c3b82015-01-16 12:13:27 +0900303 pdata->reg_node[n] = da9211_matches[i].of_node;
Dmitry Torokhov61d2fc32019-10-04 16:10:15 -0700304 pdata->gpiod_ren[n] = devm_fwnode_gpiod_get(dev,
305 of_fwnode_handle(pdata->reg_node[n]),
306 "enable",
307 GPIOD_OUT_HIGH |
308 GPIOD_FLAGS_BIT_NONEXCLUSIVE,
309 "da9211-enable");
Waibel Georg025bf3772019-06-20 21:37:08 +0000310 if (IS_ERR(pdata->gpiod_ren[n]))
311 pdata->gpiod_ren[n] = NULL;
James Banbf3baca2014-08-27 11:47:07 +0900312 n++;
Fengguang Wuc2a946e2014-08-29 12:41:59 +0100313 }
James Banbf3baca2014-08-27 11:47:07 +0900314
315 return pdata;
316}
317#else
318static struct da9211_pdata *da9211_parse_regulators_dt(
319 struct device *dev)
320{
321 return ERR_PTR(-ENODEV);
322}
323#endif
324
James Ban1028a372014-07-14 13:48:45 +0900325static irqreturn_t da9211_irq_handler(int irq, void *data)
326{
327 struct da9211 *chip = data;
328 int reg_val, err, ret = IRQ_NONE;
329
330 err = regmap_read(chip->regmap, DA9211_REG_EVENT_B, &reg_val);
331 if (err < 0)
332 goto error_i2c;
333
334 if (reg_val & DA9211_E_OV_CURR_A) {
Steve Twiss65378de2019-02-26 15:27:57 +0000335 regulator_lock(chip->rdev[0]);
James Ban1028a372014-07-14 13:48:45 +0900336 regulator_notifier_call_chain(chip->rdev[0],
Geert Uytterhoevena46a0732015-02-23 17:12:16 +0100337 REGULATOR_EVENT_OVER_CURRENT, NULL);
Steve Twiss65378de2019-02-26 15:27:57 +0000338 regulator_unlock(chip->rdev[0]);
James Ban1028a372014-07-14 13:48:45 +0900339
340 err = regmap_write(chip->regmap, DA9211_REG_EVENT_B,
341 DA9211_E_OV_CURR_A);
342 if (err < 0)
343 goto error_i2c;
344
345 ret = IRQ_HANDLED;
346 }
347
348 if (reg_val & DA9211_E_OV_CURR_B) {
Steve Twiss65378de2019-02-26 15:27:57 +0000349 regulator_lock(chip->rdev[1]);
James Ban1028a372014-07-14 13:48:45 +0900350 regulator_notifier_call_chain(chip->rdev[1],
Geert Uytterhoevena46a0732015-02-23 17:12:16 +0100351 REGULATOR_EVENT_OVER_CURRENT, NULL);
Steve Twiss65378de2019-02-26 15:27:57 +0000352 regulator_unlock(chip->rdev[1]);
James Ban1028a372014-07-14 13:48:45 +0900353
354 err = regmap_write(chip->regmap, DA9211_REG_EVENT_B,
355 DA9211_E_OV_CURR_B);
356 if (err < 0)
357 goto error_i2c;
358
359 ret = IRQ_HANDLED;
360 }
361
362 return ret;
363
364error_i2c:
365 dev_err(chip->dev, "I2C error : %d\n", err);
366 return IRQ_NONE;
367}
368
369static int da9211_regulator_init(struct da9211 *chip)
370{
371 struct regulator_config config = { };
372 int i, ret;
373 unsigned int data;
374
375 ret = regmap_read(chip->regmap, DA9211_REG_CONFIG_E, &data);
376 if (ret < 0) {
Geert Uytterhoeven767e8aa2015-02-23 17:11:07 +0100377 dev_err(chip->dev, "Failed to read CONFIG_E reg: %d\n", ret);
Axel Lin516c1512014-07-20 19:19:35 +0800378 return ret;
James Ban1028a372014-07-14 13:48:45 +0900379 }
380
381 data &= DA9211_SLAVE_SEL;
382 /* If configuration for 1/2 bucks is different between platform data
383 * and the register, driver should exit.
384 */
James Ban7bd39352015-06-30 13:39:39 +0900385 if (chip->pdata->num_buck == 1 && data == 0x00)
386 chip->num_regulator = 1;
387 else if (chip->pdata->num_buck == 2 && data != 0x00)
388 chip->num_regulator = 2;
389 else {
James Ban1028a372014-07-14 13:48:45 +0900390 dev_err(chip->dev, "Configuration is mismatched\n");
Axel Lin516c1512014-07-20 19:19:35 +0800391 return -EINVAL;
James Ban1028a372014-07-14 13:48:45 +0900392 }
393
394 for (i = 0; i < chip->num_regulator; i++) {
James Banbf3baca2014-08-27 11:47:07 +0900395 config.init_data = chip->pdata->init_data[i];
James Ban1028a372014-07-14 13:48:45 +0900396 config.dev = chip->dev;
397 config.driver_data = chip;
398 config.regmap = chip->regmap;
James Ban076c3b82015-01-16 12:13:27 +0900399 config.of_node = chip->pdata->reg_node[i];
James Ban1028a372014-07-14 13:48:45 +0900400
Linus Walleij11da04af2018-02-12 14:17:02 +0100401 if (chip->pdata->gpiod_ren[i])
402 config.ena_gpiod = chip->pdata->gpiod_ren[i];
403 else
404 config.ena_gpiod = NULL;
James Ban8c7dd8b2015-01-28 09:28:08 +0900405
Linus Walleijb23328d2018-12-06 13:43:48 +0100406 /*
407 * Hand the GPIO descriptor management over to the regulator
408 * core, remove it from GPIO devres management.
409 */
410 if (config.ena_gpiod)
411 devm_gpiod_unhinge(chip->dev, config.ena_gpiod);
James Ban1028a372014-07-14 13:48:45 +0900412 chip->rdev[i] = devm_regulator_register(chip->dev,
413 &da9211_regulators[i], &config);
414 if (IS_ERR(chip->rdev[i])) {
415 dev_err(chip->dev,
416 "Failed to register DA9211 regulator\n");
Axel Lin516c1512014-07-20 19:19:35 +0800417 return PTR_ERR(chip->rdev[i]);
James Ban1028a372014-07-14 13:48:45 +0900418 }
419
420 if (chip->chip_irq != 0) {
421 ret = regmap_update_bits(chip->regmap,
James Ban4e7089f2014-09-29 16:59:20 +0900422 DA9211_REG_MASK_B, DA9211_M_OV_CURR_A << i, 0);
James Ban1028a372014-07-14 13:48:45 +0900423 if (ret < 0) {
424 dev_err(chip->dev,
425 "Failed to update mask reg: %d\n", ret);
Axel Lin516c1512014-07-20 19:19:35 +0800426 return ret;
James Ban1028a372014-07-14 13:48:45 +0900427 }
428 }
429 }
430
431 return 0;
James Ban1028a372014-07-14 13:48:45 +0900432}
James Banbf3baca2014-08-27 11:47:07 +0900433
James Ban1028a372014-07-14 13:48:45 +0900434/*
435 * I2C driver interface functions
436 */
Axel Lin77e29592020-01-09 23:58:08 +0800437static int da9211_i2c_probe(struct i2c_client *i2c)
James Ban1028a372014-07-14 13:48:45 +0900438{
439 struct da9211 *chip;
440 int error, ret;
James Ban005547e2014-08-08 14:27:04 +0900441 unsigned int data;
James Ban1028a372014-07-14 13:48:45 +0900442
443 chip = devm_kzalloc(&i2c->dev, sizeof(struct da9211), GFP_KERNEL);
Axel Lin1d3e6a62014-08-17 18:34:48 +0800444 if (!chip)
445 return -ENOMEM;
James Ban1028a372014-07-14 13:48:45 +0900446
447 chip->dev = &i2c->dev;
448 chip->regmap = devm_regmap_init_i2c(i2c, &da9211_regmap_config);
449 if (IS_ERR(chip->regmap)) {
450 error = PTR_ERR(chip->regmap);
James Ban005547e2014-08-08 14:27:04 +0900451 dev_err(chip->dev, "Failed to allocate register map: %d\n",
James Ban1028a372014-07-14 13:48:45 +0900452 error);
453 return error;
454 }
455
456 i2c_set_clientdata(i2c, chip);
457
458 chip->pdata = i2c->dev.platform_data;
James Ban005547e2014-08-08 14:27:04 +0900459
460 ret = regmap_read(chip->regmap, DA9211_REG_DEVICE_ID, &data);
461 if (ret < 0) {
462 dev_err(chip->dev, "Failed to read DEVICE_ID reg: %d\n", ret);
463 return ret;
464 }
465
466 switch (data) {
467 case DA9211_DEVICE_ID:
468 chip->chip_id = DA9211;
469 break;
470 case DA9213_DEVICE_ID:
471 chip->chip_id = DA9213;
472 break;
James Ban7bd39352015-06-30 13:39:39 +0900473 case DA9215_DEVICE_ID:
474 chip->chip_id = DA9215;
475 break;
James Ban005547e2014-08-08 14:27:04 +0900476 default:
477 dev_err(chip->dev, "Unsupported device id = 0x%x.\n", data);
James Ban1028a372014-07-14 13:48:45 +0900478 return -ENODEV;
479 }
480
James Banbf3baca2014-08-27 11:47:07 +0900481 if (!chip->pdata)
482 chip->pdata = da9211_parse_regulators_dt(chip->dev);
483
484 if (IS_ERR(chip->pdata)) {
485 dev_err(chip->dev, "No regulators defined for the platform\n");
486 return PTR_ERR(chip->pdata);
487 }
488
James Ban1028a372014-07-14 13:48:45 +0900489 chip->chip_irq = i2c->irq;
490
491 if (chip->chip_irq != 0) {
492 ret = devm_request_threaded_irq(chip->dev, chip->chip_irq, NULL,
493 da9211_irq_handler,
494 IRQF_TRIGGER_LOW|IRQF_ONESHOT,
495 "da9211", chip);
496 if (ret != 0) {
497 dev_err(chip->dev, "Failed to request IRQ: %d\n",
498 chip->chip_irq);
499 return ret;
500 }
501 } else {
502 dev_warn(chip->dev, "No IRQ configured\n");
503 }
504
505 ret = da9211_regulator_init(chip);
506
507 if (ret < 0)
James Ban005547e2014-08-08 14:27:04 +0900508 dev_err(chip->dev, "Failed to initialize regulator: %d\n", ret);
James Ban1028a372014-07-14 13:48:45 +0900509
510 return ret;
511}
512
James Ban1028a372014-07-14 13:48:45 +0900513static const struct i2c_device_id da9211_i2c_id[] = {
Axel Lin6a52f562014-09-05 09:12:55 +0800514 {"da9211", DA9211},
James Ban7524c1c2016-06-29 16:49:32 +0900515 {"da9212", DA9212},
Axel Lin6a52f562014-09-05 09:12:55 +0800516 {"da9213", DA9213},
James Ban707ce9e2017-10-30 11:32:38 +0900517 {"da9223", DA9223},
James Ban7524c1c2016-06-29 16:49:32 +0900518 {"da9214", DA9214},
James Ban707ce9e2017-10-30 11:32:38 +0900519 {"da9224", DA9224},
James Ban7bd39352015-06-30 13:39:39 +0900520 {"da9215", DA9215},
James Ban707ce9e2017-10-30 11:32:38 +0900521 {"da9225", DA9225},
James Ban1028a372014-07-14 13:48:45 +0900522 {},
523};
James Ban1028a372014-07-14 13:48:45 +0900524MODULE_DEVICE_TABLE(i2c, da9211_i2c_id);
525
Axel Lin6a52f562014-09-05 09:12:55 +0800526#ifdef CONFIG_OF
527static const struct of_device_id da9211_dt_ids[] = {
528 { .compatible = "dlg,da9211", .data = &da9211_i2c_id[0] },
James Ban7524c1c2016-06-29 16:49:32 +0900529 { .compatible = "dlg,da9212", .data = &da9211_i2c_id[1] },
530 { .compatible = "dlg,da9213", .data = &da9211_i2c_id[2] },
James Ban707ce9e2017-10-30 11:32:38 +0900531 { .compatible = "dlg,da9223", .data = &da9211_i2c_id[3] },
532 { .compatible = "dlg,da9214", .data = &da9211_i2c_id[4] },
533 { .compatible = "dlg,da9224", .data = &da9211_i2c_id[5] },
534 { .compatible = "dlg,da9215", .data = &da9211_i2c_id[6] },
535 { .compatible = "dlg,da9225", .data = &da9211_i2c_id[7] },
Axel Lin6a52f562014-09-05 09:12:55 +0800536 {},
537};
538MODULE_DEVICE_TABLE(of, da9211_dt_ids);
539#endif
540
James Ban1028a372014-07-14 13:48:45 +0900541static struct i2c_driver da9211_regulator_driver = {
542 .driver = {
543 .name = "da9211",
Axel Lin6a52f562014-09-05 09:12:55 +0800544 .of_match_table = of_match_ptr(da9211_dt_ids),
James Ban1028a372014-07-14 13:48:45 +0900545 },
Axel Lin77e29592020-01-09 23:58:08 +0800546 .probe_new = da9211_i2c_probe,
James Ban1028a372014-07-14 13:48:45 +0900547 .id_table = da9211_i2c_id,
548};
549
550module_i2c_driver(da9211_regulator_driver);
551
552MODULE_AUTHOR("James Ban <James.Ban.opensource@diasemi.com>");
James Ban707ce9e2017-10-30 11:32:38 +0900553MODULE_DESCRIPTION("DA9211/DA9212/DA9213/DA9223/DA9214/DA9224/DA9215/DA9225 regulator driver");
James Ban7bd39352015-06-30 13:39:39 +0900554MODULE_LICENSE("GPL");