2 * max8998.c - Voltage regulator driver for the Maxim 8998
4 * Copyright (C) 2009-2010 Samsung Electronics
5 * Kyungmin Park <kyungmin.park@samsung.com>
6 * Marek Szyprowski <m.szyprowski@samsung.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include <linux/module.h>
24 #include <linux/init.h>
25 #include <linux/i2c.h>
26 #include <linux/err.h>
27 #include <linux/gpio.h>
28 #include <linux/slab.h>
29 #include <linux/interrupt.h>
30 #include <linux/mutex.h>
31 #include <linux/delay.h>
32 #include <linux/platform_device.h>
33 #include <linux/regulator/driver.h>
34 #include <linux/mfd/max8998.h>
35 #include <linux/mfd/max8998-private.h>
39 struct max8998_dev *iodev;
41 struct regulator_dev **rdev;
42 u8 buck1_vol[4]; /* voltages for selection */
44 unsigned int buck1_idx; /* index to last changed voltage */
46 unsigned int buck2_idx;
49 struct voltage_map_desc {
56 static const struct voltage_map_desc ldo23_voltage_map_desc = {
57 .min = 800, .step = 50, .max = 1300,
59 static const struct voltage_map_desc ldo456711_voltage_map_desc = {
60 .min = 1600, .step = 100, .max = 3600,
62 static const struct voltage_map_desc ldo8_voltage_map_desc = {
63 .min = 3000, .step = 100, .max = 3600,
65 static const struct voltage_map_desc ldo9_voltage_map_desc = {
66 .min = 2800, .step = 100, .max = 3100,
68 static const struct voltage_map_desc ldo10_voltage_map_desc = {
69 .min = 950, .step = 50, .max = 1300,
71 static const struct voltage_map_desc ldo1213_voltage_map_desc = {
72 .min = 800, .step = 100, .max = 3300,
74 static const struct voltage_map_desc ldo1415_voltage_map_desc = {
75 .min = 1200, .step = 100, .max = 3300,
77 static const struct voltage_map_desc ldo1617_voltage_map_desc = {
78 .min = 1600, .step = 100, .max = 3600,
80 static const struct voltage_map_desc buck12_voltage_map_desc = {
81 .min = 750, .step = 25, .max = 1525,
83 static const struct voltage_map_desc buck3_voltage_map_desc = {
84 .min = 1600, .step = 100, .max = 3600,
86 static const struct voltage_map_desc buck4_voltage_map_desc = {
87 .min = 800, .step = 100, .max = 2300,
90 static const struct voltage_map_desc *ldo_voltage_map[] = {
93 &ldo23_voltage_map_desc, /* LDO2 */
94 &ldo23_voltage_map_desc, /* LDO3 */
95 &ldo456711_voltage_map_desc, /* LDO4 */
96 &ldo456711_voltage_map_desc, /* LDO5 */
97 &ldo456711_voltage_map_desc, /* LDO6 */
98 &ldo456711_voltage_map_desc, /* LDO7 */
99 &ldo8_voltage_map_desc, /* LDO8 */
100 &ldo9_voltage_map_desc, /* LDO9 */
101 &ldo10_voltage_map_desc, /* LDO10 */
102 &ldo456711_voltage_map_desc, /* LDO11 */
103 &ldo1213_voltage_map_desc, /* LDO12 */
104 &ldo1213_voltage_map_desc, /* LDO13 */
105 &ldo1415_voltage_map_desc, /* LDO14 */
106 &ldo1415_voltage_map_desc, /* LDO15 */
107 &ldo1617_voltage_map_desc, /* LDO16 */
108 &ldo1617_voltage_map_desc, /* LDO17 */
109 &buck12_voltage_map_desc, /* BUCK1 */
110 &buck12_voltage_map_desc, /* BUCK2 */
111 &buck3_voltage_map_desc, /* BUCK3 */
112 &buck4_voltage_map_desc, /* BUCK4 */
115 static inline int max8998_get_ldo(struct regulator_dev *rdev)
117 return rdev_get_id(rdev);
120 static int max8998_list_voltage(struct regulator_dev *rdev,
121 unsigned int selector)
123 const struct voltage_map_desc *desc;
124 int ldo = max8998_get_ldo(rdev);
127 if (ldo >= ARRAY_SIZE(ldo_voltage_map))
130 desc = ldo_voltage_map[ldo];
134 val = desc->min + desc->step * selector;
141 static int max8998_get_enable_register(struct regulator_dev *rdev,
142 int *reg, int *shift)
144 int ldo = max8998_get_ldo(rdev);
147 case MAX8998_LDO2 ... MAX8998_LDO5:
148 *reg = MAX8998_REG_ONOFF1;
149 *shift = 3 - (ldo - MAX8998_LDO2);
151 case MAX8998_LDO6 ... MAX8998_LDO13:
152 *reg = MAX8998_REG_ONOFF2;
153 *shift = 7 - (ldo - MAX8998_LDO6);
155 case MAX8998_LDO14 ... MAX8998_LDO17:
156 *reg = MAX8998_REG_ONOFF3;
157 *shift = 7 - (ldo - MAX8998_LDO14);
159 case MAX8998_BUCK1 ... MAX8998_BUCK4:
160 *reg = MAX8998_REG_ONOFF1;
161 *shift = 7 - (ldo - MAX8998_BUCK1);
163 case MAX8998_EN32KHZ_AP ... MAX8998_ENVICHG:
164 *reg = MAX8998_REG_ONOFF4;
165 *shift = 7 - (ldo - MAX8998_EN32KHZ_AP);
167 case MAX8998_ESAFEOUT1 ... MAX8998_ESAFEOUT2:
168 *reg = MAX8998_REG_CHGR2;
169 *shift = 7 - (ldo - MAX8998_ESAFEOUT1);
178 static int max8998_ldo_is_enabled(struct regulator_dev *rdev)
180 struct max8998_data *max8998 = rdev_get_drvdata(rdev);
181 struct i2c_client *i2c = max8998->iodev->i2c;
182 int ret, reg, shift = 8;
185 ret = max8998_get_enable_register(rdev, ®, &shift);
189 ret = max8998_read_reg(i2c, reg, &val);
193 return val & (1 << shift);
196 static int max8998_ldo_enable(struct regulator_dev *rdev)
198 struct max8998_data *max8998 = rdev_get_drvdata(rdev);
199 struct i2c_client *i2c = max8998->iodev->i2c;
200 int reg, shift = 8, ret;
202 ret = max8998_get_enable_register(rdev, ®, &shift);
206 return max8998_update_reg(i2c, reg, 1<<shift, 1<<shift);
209 static int max8998_ldo_disable(struct regulator_dev *rdev)
211 struct max8998_data *max8998 = rdev_get_drvdata(rdev);
212 struct i2c_client *i2c = max8998->iodev->i2c;
213 int reg, shift = 8, ret;
215 ret = max8998_get_enable_register(rdev, ®, &shift);
219 return max8998_update_reg(i2c, reg, 0, 1<<shift);
222 static int max8998_get_voltage_register(struct regulator_dev *rdev,
223 int *_reg, int *_shift, int *_mask)
225 int ldo = max8998_get_ldo(rdev);
226 struct max8998_data *max8998 = rdev_get_drvdata(rdev);
227 int reg, shift = 0, mask = 0xff;
230 case MAX8998_LDO2 ... MAX8998_LDO3:
231 reg = MAX8998_REG_LDO2_LDO3;
233 if (ldo == MAX8998_LDO2)
238 case MAX8998_LDO4 ... MAX8998_LDO7:
239 reg = MAX8998_REG_LDO4 + (ldo - MAX8998_LDO4);
241 case MAX8998_LDO8 ... MAX8998_LDO9:
242 reg = MAX8998_REG_LDO8_LDO9;
244 if (ldo == MAX8998_LDO8)
249 case MAX8998_LDO10 ... MAX8998_LDO11:
250 reg = MAX8998_REG_LDO10_LDO11;
251 if (ldo == MAX8998_LDO10) {
259 case MAX8998_LDO12 ... MAX8998_LDO17:
260 reg = MAX8998_REG_LDO12 + (ldo - MAX8998_LDO12);
263 reg = MAX8998_REG_BUCK1_VOLTAGE1 + max8998->buck1_idx;
266 reg = MAX8998_REG_BUCK2_VOLTAGE1 + max8998->buck2_idx;
269 reg = MAX8998_REG_BUCK3;
272 reg = MAX8998_REG_BUCK4;
285 static int max8998_get_voltage(struct regulator_dev *rdev)
287 struct max8998_data *max8998 = rdev_get_drvdata(rdev);
288 struct i2c_client *i2c = max8998->iodev->i2c;
289 int reg, shift = 0, mask, ret;
292 ret = max8998_get_voltage_register(rdev, ®, &shift, &mask);
296 ret = max8998_read_reg(i2c, reg, &val);
303 return max8998_list_voltage(rdev, val);
306 static int max8998_set_voltage_ldo(struct regulator_dev *rdev,
307 int min_uV, int max_uV, unsigned *selector)
309 struct max8998_data *max8998 = rdev_get_drvdata(rdev);
310 struct i2c_client *i2c = max8998->iodev->i2c;
311 int min_vol = min_uV / 1000, max_vol = max_uV / 1000;
312 const struct voltage_map_desc *desc;
313 int ldo = max8998_get_ldo(rdev);
314 int reg, shift = 0, mask, ret;
317 if (ldo >= ARRAY_SIZE(ldo_voltage_map))
320 desc = ldo_voltage_map[ldo];
324 if (max_vol < desc->min || min_vol > desc->max)
327 while (desc->min + desc->step*i < min_vol &&
328 desc->min + desc->step*i < desc->max)
331 if (desc->min + desc->step*i > max_vol)
336 ret = max8998_get_voltage_register(rdev, ®, &shift, &mask);
340 ret = max8998_update_reg(i2c, reg, i<<shift, mask<<shift);
345 static inline void buck1_gpio_set(int gpio1, int gpio2, int v)
347 gpio_set_value(gpio1, v & 0x1);
348 gpio_set_value(gpio2, (v >> 1) & 0x1);
351 static inline void buck2_gpio_set(int gpio, int v)
353 gpio_set_value(gpio, v & 0x1);
356 static int max8998_set_voltage_buck(struct regulator_dev *rdev,
357 int min_uV, int max_uV, int *selector)
359 struct max8998_data *max8998 = rdev_get_drvdata(rdev);
360 struct max8998_platform_data *pdata =
361 dev_get_platdata(max8998->iodev->dev);
362 struct i2c_client *i2c = max8998->iodev->i2c;
363 int min_vol = min_uV / 1000, max_vol = max_uV / 1000;
364 const struct voltage_map_desc *desc;
365 int buck = max8998_get_ldo(rdev);
366 int reg, shift = 0, mask, ret;
367 int difference = 0, i = 0, j = 0, previous_vol = 0;
369 static u8 buck1_last_val;
371 if (buck >= ARRAY_SIZE(ldo_voltage_map))
374 desc = ldo_voltage_map[buck];
379 if (max_vol < desc->min || min_vol > desc->max)
382 while (desc->min + desc->step*i < min_vol &&
383 desc->min + desc->step*i < desc->max)
386 if (desc->min + desc->step*i > max_vol)
391 ret = max8998_get_voltage_register(rdev, ®, &shift, &mask);
395 previous_vol = max8998_get_voltage(rdev);
397 /* Check if voltage needs to be changed */
398 /* if previous_voltage equal new voltage, return */
399 if (previous_vol == max8998_list_voltage(rdev, i)) {
400 dev_dbg(max8998->dev, "No voltage change, old:%d, new:%d\n",
401 previous_vol, max8998_list_voltage(rdev, i));
407 dev_dbg(max8998->dev,
408 "BUCK1, i:%d, buck1_vol1:%d, buck1_vol2:%d\n\
409 buck1_vol3:%d, buck1_vol4:%d\n",
410 i, max8998->buck1_vol[0], max8998->buck1_vol[1],
411 max8998->buck1_vol[2], max8998->buck1_vol[3]);
413 if (gpio_is_valid(pdata->buck1_set1) &&
414 gpio_is_valid(pdata->buck1_set2)) {
416 /* check if requested voltage */
417 /* value is already defined */
418 for (j = 0; j < ARRAY_SIZE(max8998->buck1_vol); j++) {
419 if (max8998->buck1_vol[j] == i) {
420 max8998->buck1_idx = j;
421 buck1_gpio_set(pdata->buck1_set1,
422 pdata->buck1_set2, j);
427 /* no predefine regulator found */
428 max8998->buck1_idx = (buck1_last_val % 2) + 2;
429 dev_dbg(max8998->dev, "max8998->buck1_idx:%d\n",
431 max8998->buck1_vol[max8998->buck1_idx] = i;
432 ret = max8998_get_voltage_register(rdev, ®,
435 ret = max8998_write_reg(i2c, reg, i);
436 buck1_gpio_set(pdata->buck1_set1,
437 pdata->buck1_set2, max8998->buck1_idx);
440 dev_dbg(max8998->dev, "%s: SET1:%d, SET2:%d\n",
441 i2c->name, gpio_get_value(pdata->buck1_set1),
442 gpio_get_value(pdata->buck1_set2));
445 ret = max8998_write_reg(i2c, reg, i);
450 dev_dbg(max8998->dev,
451 "BUCK2, i:%d buck2_vol1:%d, buck2_vol2:%d\n"
452 , i, max8998->buck2_vol[0], max8998->buck2_vol[1]);
453 if (gpio_is_valid(pdata->buck2_set3)) {
454 if (max8998->buck2_vol[0] == i) {
455 max8998->buck1_idx = 0;
456 buck2_gpio_set(pdata->buck2_set3, 0);
458 max8998->buck1_idx = 1;
459 ret = max8998_get_voltage_register(rdev, ®,
462 ret = max8998_write_reg(i2c, reg, i);
463 max8998->buck2_vol[1] = i;
464 buck2_gpio_set(pdata->buck2_set3, 1);
466 dev_dbg(max8998->dev, "%s: SET3:%d\n", i2c->name,
467 gpio_get_value(pdata->buck2_set3));
469 ret = max8998_write_reg(i2c, reg, i);
475 ret = max8998_update_reg(i2c, reg, i<<shift, mask<<shift);
479 /* Voltage stabilization */
480 max8998_read_reg(i2c, MAX8998_REG_ONOFF4, &val);
482 /* lp3974 hasn't got ENRAMP bit - ramp is assumed as true */
483 /* MAX8998 has ENRAMP bit implemented, so test it*/
484 if (max8998->iodev->type == TYPE_MAX8998 && !(val & MAX8998_ENRAMP))
487 difference = desc->min + desc->step*i - previous_vol/1000;
489 udelay(difference / ((val & 0x0f) + 1));
494 static struct regulator_ops max8998_ldo_ops = {
495 .list_voltage = max8998_list_voltage,
496 .is_enabled = max8998_ldo_is_enabled,
497 .enable = max8998_ldo_enable,
498 .disable = max8998_ldo_disable,
499 .get_voltage = max8998_get_voltage,
500 .set_voltage = max8998_set_voltage_ldo,
501 .set_suspend_enable = max8998_ldo_enable,
502 .set_suspend_disable = max8998_ldo_disable,
505 static struct regulator_ops max8998_buck_ops = {
506 .list_voltage = max8998_list_voltage,
507 .is_enabled = max8998_ldo_is_enabled,
508 .enable = max8998_ldo_enable,
509 .disable = max8998_ldo_disable,
510 .get_voltage = max8998_get_voltage,
511 .set_voltage = max8998_set_voltage_buck,
512 .set_suspend_enable = max8998_ldo_enable,
513 .set_suspend_disable = max8998_ldo_disable,
516 static struct regulator_ops max8998_others_ops = {
517 .is_enabled = max8998_ldo_is_enabled,
518 .enable = max8998_ldo_enable,
519 .disable = max8998_ldo_disable,
520 .set_suspend_enable = max8998_ldo_enable,
521 .set_suspend_disable = max8998_ldo_disable,
524 static struct regulator_desc regulators[] = {
528 .ops = &max8998_ldo_ops,
529 .type = REGULATOR_VOLTAGE,
530 .owner = THIS_MODULE,
534 .ops = &max8998_ldo_ops,
535 .type = REGULATOR_VOLTAGE,
536 .owner = THIS_MODULE,
540 .ops = &max8998_ldo_ops,
541 .type = REGULATOR_VOLTAGE,
542 .owner = THIS_MODULE,
546 .ops = &max8998_ldo_ops,
547 .type = REGULATOR_VOLTAGE,
548 .owner = THIS_MODULE,
552 .ops = &max8998_ldo_ops,
553 .type = REGULATOR_VOLTAGE,
554 .owner = THIS_MODULE,
558 .ops = &max8998_ldo_ops,
559 .type = REGULATOR_VOLTAGE,
560 .owner = THIS_MODULE,
564 .ops = &max8998_ldo_ops,
565 .type = REGULATOR_VOLTAGE,
566 .owner = THIS_MODULE,
570 .ops = &max8998_ldo_ops,
571 .type = REGULATOR_VOLTAGE,
572 .owner = THIS_MODULE,
576 .ops = &max8998_ldo_ops,
577 .type = REGULATOR_VOLTAGE,
578 .owner = THIS_MODULE,
582 .ops = &max8998_ldo_ops,
583 .type = REGULATOR_VOLTAGE,
584 .owner = THIS_MODULE,
588 .ops = &max8998_ldo_ops,
589 .type = REGULATOR_VOLTAGE,
590 .owner = THIS_MODULE,
594 .ops = &max8998_ldo_ops,
595 .type = REGULATOR_VOLTAGE,
596 .owner = THIS_MODULE,
600 .ops = &max8998_ldo_ops,
601 .type = REGULATOR_VOLTAGE,
602 .owner = THIS_MODULE,
606 .ops = &max8998_ldo_ops,
607 .type = REGULATOR_VOLTAGE,
608 .owner = THIS_MODULE,
612 .ops = &max8998_ldo_ops,
613 .type = REGULATOR_VOLTAGE,
614 .owner = THIS_MODULE,
618 .ops = &max8998_ldo_ops,
619 .type = REGULATOR_VOLTAGE,
620 .owner = THIS_MODULE,
624 .ops = &max8998_buck_ops,
625 .type = REGULATOR_VOLTAGE,
626 .owner = THIS_MODULE,
630 .ops = &max8998_buck_ops,
631 .type = REGULATOR_VOLTAGE,
632 .owner = THIS_MODULE,
636 .ops = &max8998_buck_ops,
637 .type = REGULATOR_VOLTAGE,
638 .owner = THIS_MODULE,
642 .ops = &max8998_buck_ops,
643 .type = REGULATOR_VOLTAGE,
644 .owner = THIS_MODULE,
646 .name = "EN32KHz AP",
647 .id = MAX8998_EN32KHZ_AP,
648 .ops = &max8998_others_ops,
649 .type = REGULATOR_VOLTAGE,
650 .owner = THIS_MODULE,
652 .name = "EN32KHz CP",
653 .id = MAX8998_EN32KHZ_CP,
654 .ops = &max8998_others_ops,
655 .type = REGULATOR_VOLTAGE,
656 .owner = THIS_MODULE,
659 .id = MAX8998_ENVICHG,
660 .ops = &max8998_others_ops,
661 .type = REGULATOR_VOLTAGE,
662 .owner = THIS_MODULE,
665 .id = MAX8998_ESAFEOUT1,
666 .ops = &max8998_others_ops,
667 .type = REGULATOR_VOLTAGE,
668 .owner = THIS_MODULE,
671 .id = MAX8998_ESAFEOUT2,
672 .ops = &max8998_others_ops,
673 .type = REGULATOR_VOLTAGE,
674 .owner = THIS_MODULE,
678 static __devinit int max8998_pmic_probe(struct platform_device *pdev)
680 struct max8998_dev *iodev = dev_get_drvdata(pdev->dev.parent);
681 struct max8998_platform_data *pdata = dev_get_platdata(iodev->dev);
682 struct regulator_dev **rdev;
683 struct max8998_data *max8998;
684 struct i2c_client *i2c;
688 dev_err(pdev->dev.parent, "No platform init data supplied\n");
692 max8998 = kzalloc(sizeof(struct max8998_data), GFP_KERNEL);
696 size = sizeof(struct regulator_dev *) * pdata->num_regulators;
697 max8998->rdev = kzalloc(size, GFP_KERNEL);
698 if (!max8998->rdev) {
703 rdev = max8998->rdev;
704 max8998->dev = &pdev->dev;
705 max8998->iodev = iodev;
706 max8998->num_regulators = pdata->num_regulators;
707 platform_set_drvdata(pdev, max8998);
708 i2c = max8998->iodev->i2c;
711 /* For unused GPIO NOT marked as -1 (thereof equal to 0) WARN_ON */
712 /* will be displayed */
714 /* Check if MAX8998 voltage selection GPIOs are defined */
715 if (gpio_is_valid(pdata->buck1_set1) &&
716 gpio_is_valid(pdata->buck1_set2)) {
717 /* Check if SET1 is not equal to 0 */
718 if (!pdata->buck1_set1) {
719 printk(KERN_ERR "MAX8998 SET1 GPIO defined as 0 !\n");
720 WARN_ON(!pdata->buck1_set1);
723 /* Check if SET2 is not equal to 0 */
724 if (!pdata->buck1_set2) {
725 printk(KERN_ERR "MAX8998 SET2 GPIO defined as 0 !\n");
726 WARN_ON(!pdata->buck1_set2);
730 gpio_request(pdata->buck1_set1, "MAX8998 BUCK1_SET1");
731 gpio_direction_output(pdata->buck1_set1,
732 max8998->buck1_idx & 0x1);
735 gpio_request(pdata->buck1_set2, "MAX8998 BUCK1_SET2");
736 gpio_direction_output(pdata->buck1_set2,
737 (max8998->buck1_idx >> 1) & 0x1);
738 /* Set predefined value for BUCK1 register 1 */
740 while (buck12_voltage_map_desc.min +
741 buck12_voltage_map_desc.step*i
742 != (pdata->buck1_max_voltage1 / 1000))
744 printk(KERN_ERR "i:%d, buck1_idx:%d\n", i, max8998->buck1_idx);
745 max8998->buck1_vol[0] = i;
746 ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE1, i);
748 /* Set predefined value for BUCK1 register 2 */
750 while (buck12_voltage_map_desc.min +
751 buck12_voltage_map_desc.step*i
752 != (pdata->buck1_max_voltage2 / 1000))
755 max8998->buck1_vol[1] = i;
756 printk(KERN_ERR "i:%d, buck1_idx:%d\n", i, max8998->buck1_idx);
757 ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE2, i)
764 if (gpio_is_valid(pdata->buck2_set3)) {
765 /* Check if SET3 is not equal to 0 */
766 if (!pdata->buck2_set3) {
767 printk(KERN_ERR "MAX8998 SET3 GPIO defined as 0 !\n");
768 WARN_ON(!pdata->buck2_set3);
771 gpio_request(pdata->buck2_set3, "MAX8998 BUCK2_SET3");
772 gpio_direction_output(pdata->buck2_set3,
773 max8998->buck2_idx & 0x1);
775 /* BUCK2 - set preset default voltage value to buck2_vol[0] */
777 while (buck12_voltage_map_desc.min +
778 buck12_voltage_map_desc.step*i
779 != (pdata->buck2_max_voltage / 1000))
781 printk(KERN_ERR "i:%d, buck2_idx:%d\n", i, max8998->buck2_idx);
782 max8998->buck2_vol[0] = i;
783 ret = max8998_write_reg(i2c, MAX8998_REG_BUCK2_VOLTAGE1, i);
789 for (i = 0; i < pdata->num_regulators; i++) {
790 const struct voltage_map_desc *desc;
791 int id = pdata->regulators[i].id;
792 int index = id - MAX8998_LDO2;
794 desc = ldo_voltage_map[id];
795 if (desc && regulators[index].ops != &max8998_others_ops) {
796 int count = (desc->max - desc->min) / desc->step + 1;
797 regulators[index].n_voltages = count;
799 rdev[i] = regulator_register(®ulators[index], max8998->dev,
800 pdata->regulators[i].initdata, max8998);
801 if (IS_ERR(rdev[i])) {
802 ret = PTR_ERR(rdev[i]);
803 dev_err(max8998->dev, "regulator init failed\n");
812 for (i = 0; i < max8998->num_regulators; i++)
814 regulator_unregister(rdev[i]);
816 kfree(max8998->rdev);
822 static int __devexit max8998_pmic_remove(struct platform_device *pdev)
824 struct max8998_data *max8998 = platform_get_drvdata(pdev);
825 struct regulator_dev **rdev = max8998->rdev;
828 for (i = 0; i < max8998->num_regulators; i++)
830 regulator_unregister(rdev[i]);
832 kfree(max8998->rdev);
838 static struct platform_driver max8998_pmic_driver = {
840 .name = "max8998-pmic",
841 .owner = THIS_MODULE,
843 .probe = max8998_pmic_probe,
844 .remove = __devexit_p(max8998_pmic_remove),
847 static int __init max8998_pmic_init(void)
849 return platform_driver_register(&max8998_pmic_driver);
851 subsys_initcall(max8998_pmic_init);
853 static void __exit max8998_pmic_cleanup(void)
855 platform_driver_unregister(&max8998_pmic_driver);
857 module_exit(max8998_pmic_cleanup);
859 MODULE_DESCRIPTION("MAXIM 8998 voltage regulator driver");
860 MODULE_AUTHOR("Kyungmin Park <kyungmin.park@samsung.com>");
861 MODULE_LICENSE("GPL");