Linux 3.3-rc6
[linux/fpc-iii.git] / drivers / regulator / lp3972.c
blob49a15eefe5fe25390bdaf52cd0455675565cb516
1 /*
2 * Regulator driver for National Semiconductors LP3972 PMIC chip
4 * Based on lp3971.c
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
12 #include <linux/bug.h>
13 #include <linux/err.h>
14 #include <linux/i2c.h>
15 #include <linux/module.h>
16 #include <linux/kernel.h>
17 #include <linux/regulator/driver.h>
18 #include <linux/regulator/lp3972.h>
19 #include <linux/slab.h>
21 struct lp3972 {
22 struct device *dev;
23 struct mutex io_lock;
24 struct i2c_client *i2c;
25 int num_regulators;
26 struct regulator_dev **rdev;
29 /* LP3972 Control Registers */
30 #define LP3972_SCR_REG 0x07
31 #define LP3972_OVER1_REG 0x10
32 #define LP3972_OVSR1_REG 0x11
33 #define LP3972_OVER2_REG 0x12
34 #define LP3972_OVSR2_REG 0x13
35 #define LP3972_VCC1_REG 0x20
36 #define LP3972_ADTV1_REG 0x23
37 #define LP3972_ADTV2_REG 0x24
38 #define LP3972_AVRC_REG 0x25
39 #define LP3972_CDTC1_REG 0x26
40 #define LP3972_CDTC2_REG 0x27
41 #define LP3972_SDTV1_REG 0x29
42 #define LP3972_SDTV2_REG 0x2A
43 #define LP3972_MDTV1_REG 0x32
44 #define LP3972_MDTV2_REG 0x33
45 #define LP3972_L2VCR_REG 0x39
46 #define LP3972_L34VCR_REG 0x3A
47 #define LP3972_SCR1_REG 0x80
48 #define LP3972_SCR2_REG 0x81
49 #define LP3972_OEN3_REG 0x82
50 #define LP3972_OSR3_REG 0x83
51 #define LP3972_LOER4_REG 0x84
52 #define LP3972_B2TV_REG 0x85
53 #define LP3972_B3TV_REG 0x86
54 #define LP3972_B32RC_REG 0x87
55 #define LP3972_ISRA_REG 0x88
56 #define LP3972_BCCR_REG 0x89
57 #define LP3972_II1RR_REG 0x8E
58 #define LP3972_II2RR_REG 0x8F
60 #define LP3972_SYS_CONTROL1_REG LP3972_SCR1_REG
61 /* System control register 1 initial value,
62 * bits 5, 6 and 7 are EPROM programmable */
63 #define SYS_CONTROL1_INIT_VAL 0x02
64 #define SYS_CONTROL1_INIT_MASK 0x1F
66 #define LP3972_VOL_CHANGE_REG LP3972_VCC1_REG
67 #define LP3972_VOL_CHANGE_FLAG_GO 0x01
68 #define LP3972_VOL_CHANGE_FLAG_MASK 0x03
70 /* LDO output enable mask */
71 #define LP3972_OEN3_L1EN BIT(0)
72 #define LP3972_OVER2_LDO2_EN BIT(2)
73 #define LP3972_OVER2_LDO3_EN BIT(3)
74 #define LP3972_OVER2_LDO4_EN BIT(4)
75 #define LP3972_OVER1_S_EN BIT(2)
77 static const int ldo1_voltage_map[] = {
78 1700, 1725, 1750, 1775, 1800, 1825, 1850, 1875,
79 1900, 1925, 1950, 1975, 2000,
82 static const int ldo23_voltage_map[] = {
83 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500,
84 2600, 2700, 2800, 2900, 3000, 3100, 3200, 3300,
87 static const int ldo4_voltage_map[] = {
88 1000, 1050, 1100, 1150, 1200, 1250, 1300, 1350,
89 1400, 1500, 1800, 1900, 2500, 2800, 3000, 3300,
92 static const int ldo5_voltage_map[] = {
93 0, 0, 0, 0, 0, 850, 875, 900,
94 925, 950, 975, 1000, 1025, 1050, 1075, 1100,
95 1125, 1150, 1175, 1200, 1225, 1250, 1275, 1300,
96 1325, 1350, 1375, 1400, 1425, 1450, 1475, 1500,
99 static const int buck1_voltage_map[] = {
100 725, 750, 775, 800, 825, 850, 875, 900,
101 925, 950, 975, 1000, 1025, 1050, 1075, 1100,
102 1125, 1150, 1175, 1200, 1225, 1250, 1275, 1300,
103 1325, 1350, 1375, 1400, 1425, 1450, 1475, 1500,
106 static const int buck23_voltage_map[] = {
107 0, 800, 850, 900, 950, 1000, 1050, 1100,
108 1150, 1200, 1250, 1300, 1350, 1400, 1450, 1500,
109 1550, 1600, 1650, 1700, 1800, 1900, 2500, 2800,
110 3000, 3300,
113 static const int *ldo_voltage_map[] = {
114 ldo1_voltage_map,
115 ldo23_voltage_map,
116 ldo23_voltage_map,
117 ldo4_voltage_map,
118 ldo5_voltage_map,
121 static const int *buck_voltage_map[] = {
122 buck1_voltage_map,
123 buck23_voltage_map,
124 buck23_voltage_map,
127 static const int ldo_output_enable_mask[] = {
128 LP3972_OEN3_L1EN,
129 LP3972_OVER2_LDO2_EN,
130 LP3972_OVER2_LDO3_EN,
131 LP3972_OVER2_LDO4_EN,
132 LP3972_OVER1_S_EN,
135 static const int ldo_output_enable_addr[] = {
136 LP3972_OEN3_REG,
137 LP3972_OVER2_REG,
138 LP3972_OVER2_REG,
139 LP3972_OVER2_REG,
140 LP3972_OVER1_REG,
143 static const int ldo_vol_ctl_addr[] = {
144 LP3972_MDTV1_REG,
145 LP3972_L2VCR_REG,
146 LP3972_L34VCR_REG,
147 LP3972_L34VCR_REG,
148 LP3972_SDTV1_REG,
151 static const int buck_vol_enable_addr[] = {
152 LP3972_OVER1_REG,
153 LP3972_OEN3_REG,
154 LP3972_OEN3_REG,
157 static const int buck_base_addr[] = {
158 LP3972_ADTV1_REG,
159 LP3972_B2TV_REG,
160 LP3972_B3TV_REG,
163 #define LP3972_LDO_VOL_VALUE_MAP(x) (ldo_voltage_map[x])
164 #define LP3972_LDO_OUTPUT_ENABLE_MASK(x) (ldo_output_enable_mask[x])
165 #define LP3972_LDO_OUTPUT_ENABLE_REG(x) (ldo_output_enable_addr[x])
167 /* LDO voltage control registers shift:
168 LP3972_LDO1 -> 0, LP3972_LDO2 -> 4
169 LP3972_LDO3 -> 0, LP3972_LDO4 -> 4
170 LP3972_LDO5 -> 0
172 #define LP3972_LDO_VOL_CONTR_SHIFT(x) (((x) & 1) << 2)
173 #define LP3972_LDO_VOL_CONTR_REG(x) (ldo_vol_ctl_addr[x])
174 #define LP3972_LDO_VOL_CHANGE_SHIFT(x) ((x) ? 4 : 6)
176 #define LP3972_LDO_VOL_MASK(x) (((x) % 4) ? 0x0f : 0x1f)
177 #define LP3972_LDO_VOL_MIN_IDX(x) (((x) == 4) ? 0x05 : 0x00)
178 #define LP3972_LDO_VOL_MAX_IDX(x) ((x) ? (((x) == 4) ? 0x1f : 0x0f) : 0x0c)
180 #define LP3972_BUCK_VOL_VALUE_MAP(x) (buck_voltage_map[x])
181 #define LP3972_BUCK_VOL_ENABLE_REG(x) (buck_vol_enable_addr[x])
182 #define LP3972_BUCK_VOL1_REG(x) (buck_base_addr[x])
183 #define LP3972_BUCK_VOL_MASK 0x1f
184 #define LP3972_BUCK_VOL_MIN_IDX(x) ((x) ? 0x01 : 0x00)
185 #define LP3972_BUCK_VOL_MAX_IDX(x) ((x) ? 0x19 : 0x1f)
187 static int lp3972_i2c_read(struct i2c_client *i2c, char reg, int count,
188 u16 *dest)
190 int ret;
192 if (count != 1)
193 return -EIO;
194 ret = i2c_smbus_read_byte_data(i2c, reg);
195 if (ret < 0)
196 return ret;
198 *dest = ret;
199 return 0;
202 static int lp3972_i2c_write(struct i2c_client *i2c, char reg, int count,
203 const u16 *src)
205 if (count != 1)
206 return -EIO;
207 return i2c_smbus_write_byte_data(i2c, reg, *src);
210 static u8 lp3972_reg_read(struct lp3972 *lp3972, u8 reg)
212 u16 val = 0;
214 mutex_lock(&lp3972->io_lock);
216 lp3972_i2c_read(lp3972->i2c, reg, 1, &val);
218 dev_dbg(lp3972->dev, "reg read 0x%02x -> 0x%02x\n", (int)reg,
219 (unsigned)val & 0xff);
221 mutex_unlock(&lp3972->io_lock);
223 return val & 0xff;
226 static int lp3972_set_bits(struct lp3972 *lp3972, u8 reg, u16 mask, u16 val)
228 u16 tmp;
229 int ret;
231 mutex_lock(&lp3972->io_lock);
233 ret = lp3972_i2c_read(lp3972->i2c, reg, 1, &tmp);
234 tmp = (tmp & ~mask) | val;
235 if (ret == 0) {
236 ret = lp3972_i2c_write(lp3972->i2c, reg, 1, &tmp);
237 dev_dbg(lp3972->dev, "reg write 0x%02x -> 0x%02x\n", (int)reg,
238 (unsigned)val & 0xff);
240 mutex_unlock(&lp3972->io_lock);
242 return ret;
245 static int lp3972_ldo_list_voltage(struct regulator_dev *dev, unsigned index)
247 int ldo = rdev_get_id(dev) - LP3972_LDO1;
248 return 1000 * LP3972_LDO_VOL_VALUE_MAP(ldo)[index];
251 static int lp3972_ldo_is_enabled(struct regulator_dev *dev)
253 struct lp3972 *lp3972 = rdev_get_drvdata(dev);
254 int ldo = rdev_get_id(dev) - LP3972_LDO1;
255 u16 mask = LP3972_LDO_OUTPUT_ENABLE_MASK(ldo);
256 u16 val;
258 val = lp3972_reg_read(lp3972, LP3972_LDO_OUTPUT_ENABLE_REG(ldo));
259 return !!(val & mask);
262 static int lp3972_ldo_enable(struct regulator_dev *dev)
264 struct lp3972 *lp3972 = rdev_get_drvdata(dev);
265 int ldo = rdev_get_id(dev) - LP3972_LDO1;
266 u16 mask = LP3972_LDO_OUTPUT_ENABLE_MASK(ldo);
268 return lp3972_set_bits(lp3972, LP3972_LDO_OUTPUT_ENABLE_REG(ldo),
269 mask, mask);
272 static int lp3972_ldo_disable(struct regulator_dev *dev)
274 struct lp3972 *lp3972 = rdev_get_drvdata(dev);
275 int ldo = rdev_get_id(dev) - LP3972_LDO1;
276 u16 mask = LP3972_LDO_OUTPUT_ENABLE_MASK(ldo);
278 return lp3972_set_bits(lp3972, LP3972_LDO_OUTPUT_ENABLE_REG(ldo),
279 mask, 0);
282 static int lp3972_ldo_get_voltage(struct regulator_dev *dev)
284 struct lp3972 *lp3972 = rdev_get_drvdata(dev);
285 int ldo = rdev_get_id(dev) - LP3972_LDO1;
286 u16 mask = LP3972_LDO_VOL_MASK(ldo);
287 u16 val, reg;
289 reg = lp3972_reg_read(lp3972, LP3972_LDO_VOL_CONTR_REG(ldo));
290 val = (reg >> LP3972_LDO_VOL_CONTR_SHIFT(ldo)) & mask;
292 return 1000 * LP3972_LDO_VOL_VALUE_MAP(ldo)[val];
295 static int lp3972_ldo_set_voltage(struct regulator_dev *dev,
296 int min_uV, int max_uV,
297 unsigned int *selector)
299 struct lp3972 *lp3972 = rdev_get_drvdata(dev);
300 int ldo = rdev_get_id(dev) - LP3972_LDO1;
301 int min_vol = min_uV / 1000, max_vol = max_uV / 1000;
302 const int *vol_map = LP3972_LDO_VOL_VALUE_MAP(ldo);
303 u16 val;
304 int shift, ret;
306 if (min_vol < vol_map[LP3972_LDO_VOL_MIN_IDX(ldo)] ||
307 min_vol > vol_map[LP3972_LDO_VOL_MAX_IDX(ldo)])
308 return -EINVAL;
310 for (val = LP3972_LDO_VOL_MIN_IDX(ldo);
311 val <= LP3972_LDO_VOL_MAX_IDX(ldo); val++)
312 if (vol_map[val] >= min_vol)
313 break;
315 if (val > LP3972_LDO_VOL_MAX_IDX(ldo) || vol_map[val] > max_vol)
316 return -EINVAL;
318 *selector = val;
320 shift = LP3972_LDO_VOL_CONTR_SHIFT(ldo);
321 ret = lp3972_set_bits(lp3972, LP3972_LDO_VOL_CONTR_REG(ldo),
322 LP3972_LDO_VOL_MASK(ldo) << shift, val << shift);
324 if (ret)
325 return ret;
328 * LDO1 and LDO5 support voltage control by either target voltage1
329 * or target voltage2 register.
330 * We use target voltage1 register for LDO1 and LDO5 in this driver.
331 * We need to update voltage change control register(0x20) to enable
332 * LDO1 and LDO5 to change to their programmed target values.
334 switch (ldo) {
335 case LP3972_LDO1:
336 case LP3972_LDO5:
337 shift = LP3972_LDO_VOL_CHANGE_SHIFT(ldo);
338 ret = lp3972_set_bits(lp3972, LP3972_VOL_CHANGE_REG,
339 LP3972_VOL_CHANGE_FLAG_MASK << shift,
340 LP3972_VOL_CHANGE_FLAG_GO << shift);
341 if (ret)
342 return ret;
344 ret = lp3972_set_bits(lp3972, LP3972_VOL_CHANGE_REG,
345 LP3972_VOL_CHANGE_FLAG_MASK << shift, 0);
346 break;
349 return ret;
352 static struct regulator_ops lp3972_ldo_ops = {
353 .list_voltage = lp3972_ldo_list_voltage,
354 .is_enabled = lp3972_ldo_is_enabled,
355 .enable = lp3972_ldo_enable,
356 .disable = lp3972_ldo_disable,
357 .get_voltage = lp3972_ldo_get_voltage,
358 .set_voltage = lp3972_ldo_set_voltage,
361 static int lp3972_dcdc_list_voltage(struct regulator_dev *dev, unsigned index)
363 int buck = rdev_get_id(dev) - LP3972_DCDC1;
364 return 1000 * buck_voltage_map[buck][index];
367 static int lp3972_dcdc_is_enabled(struct regulator_dev *dev)
369 struct lp3972 *lp3972 = rdev_get_drvdata(dev);
370 int buck = rdev_get_id(dev) - LP3972_DCDC1;
371 u16 mask = 1 << (buck * 2);
372 u16 val;
374 val = lp3972_reg_read(lp3972, LP3972_BUCK_VOL_ENABLE_REG(buck));
375 return !!(val & mask);
378 static int lp3972_dcdc_enable(struct regulator_dev *dev)
380 struct lp3972 *lp3972 = rdev_get_drvdata(dev);
381 int buck = rdev_get_id(dev) - LP3972_DCDC1;
382 u16 mask = 1 << (buck * 2);
383 u16 val;
385 val = lp3972_set_bits(lp3972, LP3972_BUCK_VOL_ENABLE_REG(buck),
386 mask, mask);
387 return val;
390 static int lp3972_dcdc_disable(struct regulator_dev *dev)
392 struct lp3972 *lp3972 = rdev_get_drvdata(dev);
393 int buck = rdev_get_id(dev) - LP3972_DCDC1;
394 u16 mask = 1 << (buck * 2);
395 u16 val;
397 val = lp3972_set_bits(lp3972, LP3972_BUCK_VOL_ENABLE_REG(buck),
398 mask, 0);
399 return val;
402 static int lp3972_dcdc_get_voltage(struct regulator_dev *dev)
404 struct lp3972 *lp3972 = rdev_get_drvdata(dev);
405 int buck = rdev_get_id(dev) - LP3972_DCDC1;
406 u16 reg;
407 int val;
409 reg = lp3972_reg_read(lp3972, LP3972_BUCK_VOL1_REG(buck));
410 reg &= LP3972_BUCK_VOL_MASK;
411 if (reg <= LP3972_BUCK_VOL_MAX_IDX(buck))
412 val = 1000 * buck_voltage_map[buck][reg];
413 else {
414 val = 0;
415 dev_warn(&dev->dev, "chip reported incorrect voltage value."
416 " reg = %d\n", reg);
419 return val;
422 static int lp3972_dcdc_set_voltage(struct regulator_dev *dev,
423 int min_uV, int max_uV,
424 unsigned int *selector)
426 struct lp3972 *lp3972 = rdev_get_drvdata(dev);
427 int buck = rdev_get_id(dev) - LP3972_DCDC1;
428 int min_vol = min_uV / 1000, max_vol = max_uV / 1000;
429 const int *vol_map = buck_voltage_map[buck];
430 u16 val;
431 int ret;
433 if (min_vol < vol_map[LP3972_BUCK_VOL_MIN_IDX(buck)] ||
434 min_vol > vol_map[LP3972_BUCK_VOL_MAX_IDX(buck)])
435 return -EINVAL;
437 for (val = LP3972_BUCK_VOL_MIN_IDX(buck);
438 val <= LP3972_BUCK_VOL_MAX_IDX(buck); val++)
439 if (vol_map[val] >= min_vol)
440 break;
442 if (val > LP3972_BUCK_VOL_MAX_IDX(buck) ||
443 vol_map[val] > max_vol)
444 return -EINVAL;
446 *selector = val;
448 ret = lp3972_set_bits(lp3972, LP3972_BUCK_VOL1_REG(buck),
449 LP3972_BUCK_VOL_MASK, val);
450 if (ret)
451 return ret;
453 if (buck != 0)
454 return ret;
456 ret = lp3972_set_bits(lp3972, LP3972_VOL_CHANGE_REG,
457 LP3972_VOL_CHANGE_FLAG_MASK, LP3972_VOL_CHANGE_FLAG_GO);
458 if (ret)
459 return ret;
461 return lp3972_set_bits(lp3972, LP3972_VOL_CHANGE_REG,
462 LP3972_VOL_CHANGE_FLAG_MASK, 0);
465 static struct regulator_ops lp3972_dcdc_ops = {
466 .list_voltage = lp3972_dcdc_list_voltage,
467 .is_enabled = lp3972_dcdc_is_enabled,
468 .enable = lp3972_dcdc_enable,
469 .disable = lp3972_dcdc_disable,
470 .get_voltage = lp3972_dcdc_get_voltage,
471 .set_voltage = lp3972_dcdc_set_voltage,
474 static struct regulator_desc regulators[] = {
476 .name = "LDO1",
477 .id = LP3972_LDO1,
478 .ops = &lp3972_ldo_ops,
479 .n_voltages = ARRAY_SIZE(ldo1_voltage_map),
480 .type = REGULATOR_VOLTAGE,
481 .owner = THIS_MODULE,
484 .name = "LDO2",
485 .id = LP3972_LDO2,
486 .ops = &lp3972_ldo_ops,
487 .n_voltages = ARRAY_SIZE(ldo23_voltage_map),
488 .type = REGULATOR_VOLTAGE,
489 .owner = THIS_MODULE,
492 .name = "LDO3",
493 .id = LP3972_LDO3,
494 .ops = &lp3972_ldo_ops,
495 .n_voltages = ARRAY_SIZE(ldo23_voltage_map),
496 .type = REGULATOR_VOLTAGE,
497 .owner = THIS_MODULE,
500 .name = "LDO4",
501 .id = LP3972_LDO4,
502 .ops = &lp3972_ldo_ops,
503 .n_voltages = ARRAY_SIZE(ldo4_voltage_map),
504 .type = REGULATOR_VOLTAGE,
505 .owner = THIS_MODULE,
508 .name = "LDO5",
509 .id = LP3972_LDO5,
510 .ops = &lp3972_ldo_ops,
511 .n_voltages = ARRAY_SIZE(ldo5_voltage_map),
512 .type = REGULATOR_VOLTAGE,
513 .owner = THIS_MODULE,
516 .name = "DCDC1",
517 .id = LP3972_DCDC1,
518 .ops = &lp3972_dcdc_ops,
519 .n_voltages = ARRAY_SIZE(buck1_voltage_map),
520 .type = REGULATOR_VOLTAGE,
521 .owner = THIS_MODULE,
524 .name = "DCDC2",
525 .id = LP3972_DCDC2,
526 .ops = &lp3972_dcdc_ops,
527 .n_voltages = ARRAY_SIZE(buck23_voltage_map),
528 .type = REGULATOR_VOLTAGE,
529 .owner = THIS_MODULE,
532 .name = "DCDC3",
533 .id = LP3972_DCDC3,
534 .ops = &lp3972_dcdc_ops,
535 .n_voltages = ARRAY_SIZE(buck23_voltage_map),
536 .type = REGULATOR_VOLTAGE,
537 .owner = THIS_MODULE,
541 static int __devinit setup_regulators(struct lp3972 *lp3972,
542 struct lp3972_platform_data *pdata)
544 int i, err;
546 lp3972->num_regulators = pdata->num_regulators;
547 lp3972->rdev = kcalloc(pdata->num_regulators,
548 sizeof(struct regulator_dev *), GFP_KERNEL);
549 if (!lp3972->rdev) {
550 err = -ENOMEM;
551 goto err_nomem;
554 /* Instantiate the regulators */
555 for (i = 0; i < pdata->num_regulators; i++) {
556 struct lp3972_regulator_subdev *reg = &pdata->regulators[i];
557 lp3972->rdev[i] = regulator_register(&regulators[reg->id],
558 lp3972->dev, reg->initdata, lp3972, NULL);
560 if (IS_ERR(lp3972->rdev[i])) {
561 err = PTR_ERR(lp3972->rdev[i]);
562 dev_err(lp3972->dev, "regulator init failed: %d\n",
563 err);
564 goto error;
568 return 0;
569 error:
570 while (--i >= 0)
571 regulator_unregister(lp3972->rdev[i]);
572 kfree(lp3972->rdev);
573 lp3972->rdev = NULL;
574 err_nomem:
575 return err;
578 static int __devinit lp3972_i2c_probe(struct i2c_client *i2c,
579 const struct i2c_device_id *id)
581 struct lp3972 *lp3972;
582 struct lp3972_platform_data *pdata = i2c->dev.platform_data;
583 int ret;
584 u16 val;
586 if (!pdata) {
587 dev_dbg(&i2c->dev, "No platform init data supplied\n");
588 return -ENODEV;
591 lp3972 = kzalloc(sizeof(struct lp3972), GFP_KERNEL);
592 if (!lp3972)
593 return -ENOMEM;
595 lp3972->i2c = i2c;
596 lp3972->dev = &i2c->dev;
598 mutex_init(&lp3972->io_lock);
600 /* Detect LP3972 */
601 ret = lp3972_i2c_read(i2c, LP3972_SYS_CONTROL1_REG, 1, &val);
602 if (ret == 0 &&
603 (val & SYS_CONTROL1_INIT_MASK) != SYS_CONTROL1_INIT_VAL) {
604 ret = -ENODEV;
605 dev_err(&i2c->dev, "chip reported: val = 0x%x\n", val);
607 if (ret < 0) {
608 dev_err(&i2c->dev, "failed to detect device. ret = %d\n", ret);
609 goto err_detect;
612 ret = setup_regulators(lp3972, pdata);
613 if (ret < 0)
614 goto err_detect;
616 i2c_set_clientdata(i2c, lp3972);
617 return 0;
619 err_detect:
620 kfree(lp3972);
621 return ret;
624 static int __devexit lp3972_i2c_remove(struct i2c_client *i2c)
626 struct lp3972 *lp3972 = i2c_get_clientdata(i2c);
627 int i;
629 for (i = 0; i < lp3972->num_regulators; i++)
630 regulator_unregister(lp3972->rdev[i]);
631 kfree(lp3972->rdev);
632 kfree(lp3972);
634 return 0;
637 static const struct i2c_device_id lp3972_i2c_id[] = {
638 { "lp3972", 0 },
641 MODULE_DEVICE_TABLE(i2c, lp3972_i2c_id);
643 static struct i2c_driver lp3972_i2c_driver = {
644 .driver = {
645 .name = "lp3972",
646 .owner = THIS_MODULE,
648 .probe = lp3972_i2c_probe,
649 .remove = __devexit_p(lp3972_i2c_remove),
650 .id_table = lp3972_i2c_id,
653 static int __init lp3972_module_init(void)
655 return i2c_add_driver(&lp3972_i2c_driver);
657 subsys_initcall(lp3972_module_init);
659 static void __exit lp3972_module_exit(void)
661 i2c_del_driver(&lp3972_i2c_driver);
663 module_exit(lp3972_module_exit);
665 MODULE_LICENSE("GPL");
666 MODULE_AUTHOR("Axel Lin <axel.lin@gmail.com>");
667 MODULE_DESCRIPTION("LP3972 PMIC driver");