2 * tps65910.c -- TI tps65910
4 * Copyright 2010 Texas Instruments Inc.
6 * Author: Graeme Gregory <gg@slimlogic.co.uk>
7 * Author: Jorge Eduardo Candelaria <jedu@slimlogic.co.uk>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
16 #include <linux/kernel.h>
17 #include <linux/module.h>
18 #include <linux/init.h>
19 #include <linux/err.h>
20 #include <linux/platform_device.h>
21 #include <linux/regulator/driver.h>
22 #include <linux/regulator/machine.h>
23 #include <linux/delay.h>
24 #include <linux/slab.h>
25 #include <linux/gpio.h>
26 #include <linux/mfd/tps65910.h>
28 #define TPS65910_REG_VRTC 0
29 #define TPS65910_REG_VIO 1
30 #define TPS65910_REG_VDD1 2
31 #define TPS65910_REG_VDD2 3
32 #define TPS65910_REG_VDD3 4
33 #define TPS65910_REG_VDIG1 5
34 #define TPS65910_REG_VDIG2 6
35 #define TPS65910_REG_VPLL 7
36 #define TPS65910_REG_VDAC 8
37 #define TPS65910_REG_VAUX1 9
38 #define TPS65910_REG_VAUX2 10
39 #define TPS65910_REG_VAUX33 11
40 #define TPS65910_REG_VMMC 12
42 #define TPS65911_REG_VDDCTRL 4
43 #define TPS65911_REG_LDO1 5
44 #define TPS65911_REG_LDO2 6
45 #define TPS65911_REG_LDO3 7
46 #define TPS65911_REG_LDO4 8
47 #define TPS65911_REG_LDO5 9
48 #define TPS65911_REG_LDO6 10
49 #define TPS65911_REG_LDO7 11
50 #define TPS65911_REG_LDO8 12
52 #define TPS65910_NUM_REGULATOR 13
53 #define TPS65910_SUPPLY_STATE_ENABLED 0x1
55 /* supported VIO voltages in milivolts */
56 static const u16 VIO_VSEL_table
[] = {
57 1500, 1800, 2500, 3300,
60 /* VSEL tables for TPS65910 specific LDOs and dcdc's */
62 /* supported VDD3 voltages in milivolts */
63 static const u16 VDD3_VSEL_table
[] = {
67 /* supported VDIG1 voltages in milivolts */
68 static const u16 VDIG1_VSEL_table
[] = {
69 1200, 1500, 1800, 2700,
72 /* supported VDIG2 voltages in milivolts */
73 static const u16 VDIG2_VSEL_table
[] = {
74 1000, 1100, 1200, 1800,
77 /* supported VPLL voltages in milivolts */
78 static const u16 VPLL_VSEL_table
[] = {
79 1000, 1100, 1800, 2500,
82 /* supported VDAC voltages in milivolts */
83 static const u16 VDAC_VSEL_table
[] = {
84 1800, 2600, 2800, 2850,
87 /* supported VAUX1 voltages in milivolts */
88 static const u16 VAUX1_VSEL_table
[] = {
89 1800, 2500, 2800, 2850,
92 /* supported VAUX2 voltages in milivolts */
93 static const u16 VAUX2_VSEL_table
[] = {
94 1800, 2800, 2900, 3300,
97 /* supported VAUX33 voltages in milivolts */
98 static const u16 VAUX33_VSEL_table
[] = {
99 1800, 2000, 2800, 3300,
102 /* supported VMMC voltages in milivolts */
103 static const u16 VMMC_VSEL_table
[] = {
104 1800, 2800, 3000, 3300,
115 static struct tps_info tps65910_regs
[] = {
123 .table_len
= ARRAY_SIZE(VIO_VSEL_table
),
124 .table
= VIO_VSEL_table
,
140 .table_len
= ARRAY_SIZE(VDD3_VSEL_table
),
141 .table
= VDD3_VSEL_table
,
147 .table_len
= ARRAY_SIZE(VDIG1_VSEL_table
),
148 .table
= VDIG1_VSEL_table
,
154 .table_len
= ARRAY_SIZE(VDIG2_VSEL_table
),
155 .table
= VDIG2_VSEL_table
,
161 .table_len
= ARRAY_SIZE(VPLL_VSEL_table
),
162 .table
= VPLL_VSEL_table
,
168 .table_len
= ARRAY_SIZE(VDAC_VSEL_table
),
169 .table
= VDAC_VSEL_table
,
175 .table_len
= ARRAY_SIZE(VAUX1_VSEL_table
),
176 .table
= VAUX1_VSEL_table
,
182 .table_len
= ARRAY_SIZE(VAUX2_VSEL_table
),
183 .table
= VAUX2_VSEL_table
,
189 .table_len
= ARRAY_SIZE(VAUX33_VSEL_table
),
190 .table
= VAUX33_VSEL_table
,
196 .table_len
= ARRAY_SIZE(VMMC_VSEL_table
),
197 .table
= VMMC_VSEL_table
,
201 static struct tps_info tps65911_regs
[] = {
206 .table_len
= ARRAY_SIZE(VIO_VSEL_table
),
207 .table
= VIO_VSEL_table
,
266 struct tps65910_reg
{
267 struct regulator_desc desc
[TPS65910_NUM_REGULATOR
];
268 struct tps65910
*mfd
;
269 struct regulator_dev
*rdev
[TPS65910_NUM_REGULATOR
];
270 struct tps_info
*info
[TPS65910_NUM_REGULATOR
];
273 int (*get_ctrl_reg
)(int);
276 static inline int tps65910_read(struct tps65910_reg
*pmic
, u8 reg
)
281 err
= pmic
->mfd
->read(pmic
->mfd
, reg
, 1, &val
);
288 static inline int tps65910_write(struct tps65910_reg
*pmic
, u8 reg
, u8 val
)
290 return pmic
->mfd
->write(pmic
->mfd
, reg
, 1, &val
);
293 static int tps65910_modify_bits(struct tps65910_reg
*pmic
, u8 reg
,
294 u8 set_mask
, u8 clear_mask
)
298 mutex_lock(&pmic
->mutex
);
300 data
= tps65910_read(pmic
, reg
);
302 dev_err(pmic
->mfd
->dev
, "Read from reg 0x%x failed\n", reg
);
309 err
= tps65910_write(pmic
, reg
, data
);
311 dev_err(pmic
->mfd
->dev
, "Write for reg 0x%x failed\n", reg
);
314 mutex_unlock(&pmic
->mutex
);
318 static int tps65910_reg_read(struct tps65910_reg
*pmic
, u8 reg
)
322 mutex_lock(&pmic
->mutex
);
324 data
= tps65910_read(pmic
, reg
);
326 dev_err(pmic
->mfd
->dev
, "Read from reg 0x%x failed\n", reg
);
328 mutex_unlock(&pmic
->mutex
);
332 static int tps65910_reg_write(struct tps65910_reg
*pmic
, u8 reg
, u8 val
)
336 mutex_lock(&pmic
->mutex
);
338 err
= tps65910_write(pmic
, reg
, val
);
340 dev_err(pmic
->mfd
->dev
, "Write for reg 0x%x failed\n", reg
);
342 mutex_unlock(&pmic
->mutex
);
346 static int tps65910_get_ctrl_register(int id
)
349 case TPS65910_REG_VRTC
:
350 return TPS65910_VRTC
;
351 case TPS65910_REG_VIO
:
353 case TPS65910_REG_VDD1
:
354 return TPS65910_VDD1
;
355 case TPS65910_REG_VDD2
:
356 return TPS65910_VDD2
;
357 case TPS65910_REG_VDD3
:
358 return TPS65910_VDD3
;
359 case TPS65910_REG_VDIG1
:
360 return TPS65910_VDIG1
;
361 case TPS65910_REG_VDIG2
:
362 return TPS65910_VDIG2
;
363 case TPS65910_REG_VPLL
:
364 return TPS65910_VPLL
;
365 case TPS65910_REG_VDAC
:
366 return TPS65910_VDAC
;
367 case TPS65910_REG_VAUX1
:
368 return TPS65910_VAUX1
;
369 case TPS65910_REG_VAUX2
:
370 return TPS65910_VAUX2
;
371 case TPS65910_REG_VAUX33
:
372 return TPS65910_VAUX33
;
373 case TPS65910_REG_VMMC
:
374 return TPS65910_VMMC
;
380 static int tps65911_get_ctrl_register(int id
)
383 case TPS65910_REG_VRTC
:
384 return TPS65910_VRTC
;
385 case TPS65910_REG_VIO
:
387 case TPS65910_REG_VDD1
:
388 return TPS65910_VDD1
;
389 case TPS65910_REG_VDD2
:
390 return TPS65910_VDD2
;
391 case TPS65911_REG_VDDCTRL
:
392 return TPS65911_VDDCTRL
;
393 case TPS65911_REG_LDO1
:
394 return TPS65911_LDO1
;
395 case TPS65911_REG_LDO2
:
396 return TPS65911_LDO2
;
397 case TPS65911_REG_LDO3
:
398 return TPS65911_LDO3
;
399 case TPS65911_REG_LDO4
:
400 return TPS65911_LDO4
;
401 case TPS65911_REG_LDO5
:
402 return TPS65911_LDO5
;
403 case TPS65911_REG_LDO6
:
404 return TPS65911_LDO6
;
405 case TPS65911_REG_LDO7
:
406 return TPS65911_LDO7
;
407 case TPS65911_REG_LDO8
:
408 return TPS65911_LDO8
;
414 static int tps65910_is_enabled(struct regulator_dev
*dev
)
416 struct tps65910_reg
*pmic
= rdev_get_drvdata(dev
);
417 int reg
, value
, id
= rdev_get_id(dev
);
419 reg
= pmic
->get_ctrl_reg(id
);
423 value
= tps65910_reg_read(pmic
, reg
);
427 return value
& TPS65910_SUPPLY_STATE_ENABLED
;
430 static int tps65910_enable(struct regulator_dev
*dev
)
432 struct tps65910_reg
*pmic
= rdev_get_drvdata(dev
);
433 struct tps65910
*mfd
= pmic
->mfd
;
434 int reg
, id
= rdev_get_id(dev
);
436 reg
= pmic
->get_ctrl_reg(id
);
440 return tps65910_set_bits(mfd
, reg
, TPS65910_SUPPLY_STATE_ENABLED
);
443 static int tps65910_disable(struct regulator_dev
*dev
)
445 struct tps65910_reg
*pmic
= rdev_get_drvdata(dev
);
446 struct tps65910
*mfd
= pmic
->mfd
;
447 int reg
, id
= rdev_get_id(dev
);
449 reg
= pmic
->get_ctrl_reg(id
);
453 return tps65910_clear_bits(mfd
, reg
, TPS65910_SUPPLY_STATE_ENABLED
);
457 static int tps65910_set_mode(struct regulator_dev
*dev
, unsigned int mode
)
459 struct tps65910_reg
*pmic
= rdev_get_drvdata(dev
);
460 struct tps65910
*mfd
= pmic
->mfd
;
461 int reg
, value
, id
= rdev_get_id(dev
);
463 reg
= pmic
->get_ctrl_reg(id
);
468 case REGULATOR_MODE_NORMAL
:
469 return tps65910_modify_bits(pmic
, reg
, LDO_ST_ON_BIT
,
471 case REGULATOR_MODE_IDLE
:
472 value
= LDO_ST_ON_BIT
| LDO_ST_MODE_BIT
;
473 return tps65910_set_bits(mfd
, reg
, value
);
474 case REGULATOR_MODE_STANDBY
:
475 return tps65910_clear_bits(mfd
, reg
, LDO_ST_ON_BIT
);
481 static unsigned int tps65910_get_mode(struct regulator_dev
*dev
)
483 struct tps65910_reg
*pmic
= rdev_get_drvdata(dev
);
484 int reg
, value
, id
= rdev_get_id(dev
);
486 reg
= pmic
->get_ctrl_reg(id
);
490 value
= tps65910_reg_read(pmic
, reg
);
494 if (value
& LDO_ST_ON_BIT
)
495 return REGULATOR_MODE_STANDBY
;
496 else if (value
& LDO_ST_MODE_BIT
)
497 return REGULATOR_MODE_IDLE
;
499 return REGULATOR_MODE_NORMAL
;
502 static int tps65910_get_voltage_dcdc(struct regulator_dev
*dev
)
504 struct tps65910_reg
*pmic
= rdev_get_drvdata(dev
);
505 int id
= rdev_get_id(dev
), voltage
= 0;
506 int opvsel
= 0, srvsel
= 0, vselmax
= 0, mult
= 0, sr
= 0;
509 case TPS65910_REG_VDD1
:
510 opvsel
= tps65910_reg_read(pmic
, TPS65910_VDD1_OP
);
511 mult
= tps65910_reg_read(pmic
, TPS65910_VDD1
);
512 mult
= (mult
& VDD1_VGAIN_SEL_MASK
) >> VDD1_VGAIN_SEL_SHIFT
;
513 srvsel
= tps65910_reg_read(pmic
, TPS65910_VDD1_SR
);
514 sr
= opvsel
& VDD1_OP_CMD_MASK
;
515 opvsel
&= VDD1_OP_SEL_MASK
;
516 srvsel
&= VDD1_SR_SEL_MASK
;
519 case TPS65910_REG_VDD2
:
520 opvsel
= tps65910_reg_read(pmic
, TPS65910_VDD2_OP
);
521 mult
= tps65910_reg_read(pmic
, TPS65910_VDD2
);
522 mult
= (mult
& VDD2_VGAIN_SEL_MASK
) >> VDD2_VGAIN_SEL_SHIFT
;
523 srvsel
= tps65910_reg_read(pmic
, TPS65910_VDD2_SR
);
524 sr
= opvsel
& VDD2_OP_CMD_MASK
;
525 opvsel
&= VDD2_OP_SEL_MASK
;
526 srvsel
&= VDD2_SR_SEL_MASK
;
529 case TPS65911_REG_VDDCTRL
:
530 opvsel
= tps65910_reg_read(pmic
, TPS65911_VDDCTRL_OP
);
531 srvsel
= tps65910_reg_read(pmic
, TPS65911_VDDCTRL_SR
);
532 sr
= opvsel
& VDDCTRL_OP_CMD_MASK
;
533 opvsel
&= VDDCTRL_OP_SEL_MASK
;
534 srvsel
&= VDDCTRL_SR_SEL_MASK
;
539 /* multiplier 0 == 1 but 2,3 normal */
544 /* normalise to valid range */
547 if (srvsel
> vselmax
)
551 voltage
= (srvsel
* VDD1_2_OFFSET
+ VDD1_2_MIN_VOLT
) * 100;
554 /* normalise to valid range*/
557 if (opvsel
> vselmax
)
561 voltage
= (opvsel
* VDD1_2_OFFSET
+ VDD1_2_MIN_VOLT
) * 100;
569 static int tps65910_get_voltage(struct regulator_dev
*dev
)
571 struct tps65910_reg
*pmic
= rdev_get_drvdata(dev
);
572 int reg
, value
, id
= rdev_get_id(dev
), voltage
= 0;
574 reg
= pmic
->get_ctrl_reg(id
);
578 value
= tps65910_reg_read(pmic
, reg
);
583 case TPS65910_REG_VIO
:
584 case TPS65910_REG_VDIG1
:
585 case TPS65910_REG_VDIG2
:
586 case TPS65910_REG_VPLL
:
587 case TPS65910_REG_VDAC
:
588 case TPS65910_REG_VAUX1
:
589 case TPS65910_REG_VAUX2
:
590 case TPS65910_REG_VAUX33
:
591 case TPS65910_REG_VMMC
:
592 value
&= LDO_SEL_MASK
;
593 value
>>= LDO_SEL_SHIFT
;
599 voltage
= pmic
->info
[id
]->table
[value
] * 1000;
604 static int tps65910_get_voltage_vdd3(struct regulator_dev
*dev
)
606 return 5 * 1000 * 1000;
609 static int tps65911_get_voltage(struct regulator_dev
*dev
)
611 struct tps65910_reg
*pmic
= rdev_get_drvdata(dev
);
612 int step_mv
, id
= rdev_get_id(dev
);
615 reg
= pmic
->get_ctrl_reg(id
);
617 value
= tps65910_reg_read(pmic
, reg
);
620 case TPS65911_REG_LDO1
:
621 case TPS65911_REG_LDO2
:
622 case TPS65911_REG_LDO4
:
623 value
&= LDO1_SEL_MASK
;
624 value
>>= LDO_SEL_SHIFT
;
625 /* The first 5 values of the selector correspond to 1V */
633 case TPS65911_REG_LDO3
:
634 case TPS65911_REG_LDO5
:
635 case TPS65911_REG_LDO6
:
636 case TPS65911_REG_LDO7
:
637 case TPS65911_REG_LDO8
:
638 value
&= LDO3_SEL_MASK
;
639 value
>>= LDO_SEL_SHIFT
;
640 /* The first 3 values of the selector correspond to 1V */
648 case TPS65910_REG_VIO
:
649 return pmic
->info
[id
]->table
[value
] * 1000;
655 return (LDO_MIN_VOLT
+ value
* step_mv
) * 1000;
658 static int tps65910_set_voltage_dcdc(struct regulator_dev
*dev
,
661 struct tps65910_reg
*pmic
= rdev_get_drvdata(dev
);
662 int id
= rdev_get_id(dev
), vsel
;
666 case TPS65910_REG_VDD1
:
667 dcdc_mult
= (selector
/ VDD1_2_NUM_VOLTS
) + 1;
670 vsel
= (selector
% VDD1_2_NUM_VOLTS
) + 3;
672 tps65910_modify_bits(pmic
, TPS65910_VDD1
,
673 (dcdc_mult
<< VDD1_VGAIN_SEL_SHIFT
),
674 VDD1_VGAIN_SEL_MASK
);
675 tps65910_reg_write(pmic
, TPS65910_VDD1_OP
, vsel
);
677 case TPS65910_REG_VDD2
:
678 dcdc_mult
= (selector
/ VDD1_2_NUM_VOLTS
) + 1;
681 vsel
= (selector
% VDD1_2_NUM_VOLTS
) + 3;
683 tps65910_modify_bits(pmic
, TPS65910_VDD2
,
684 (dcdc_mult
<< VDD2_VGAIN_SEL_SHIFT
),
685 VDD1_VGAIN_SEL_MASK
);
686 tps65910_reg_write(pmic
, TPS65910_VDD2_OP
, vsel
);
688 case TPS65911_REG_VDDCTRL
:
690 tps65910_reg_write(pmic
, TPS65911_VDDCTRL_OP
, vsel
);
696 static int tps65910_set_voltage(struct regulator_dev
*dev
, unsigned selector
)
698 struct tps65910_reg
*pmic
= rdev_get_drvdata(dev
);
699 int reg
, id
= rdev_get_id(dev
);
701 reg
= pmic
->get_ctrl_reg(id
);
706 case TPS65910_REG_VIO
:
707 case TPS65910_REG_VDIG1
:
708 case TPS65910_REG_VDIG2
:
709 case TPS65910_REG_VPLL
:
710 case TPS65910_REG_VDAC
:
711 case TPS65910_REG_VAUX1
:
712 case TPS65910_REG_VAUX2
:
713 case TPS65910_REG_VAUX33
:
714 case TPS65910_REG_VMMC
:
715 return tps65910_modify_bits(pmic
, reg
,
716 (selector
<< LDO_SEL_SHIFT
), LDO_SEL_MASK
);
722 static int tps65911_set_voltage(struct regulator_dev
*dev
, unsigned selector
)
724 struct tps65910_reg
*pmic
= rdev_get_drvdata(dev
);
725 int reg
, id
= rdev_get_id(dev
);
727 reg
= pmic
->get_ctrl_reg(id
);
732 case TPS65911_REG_LDO1
:
733 case TPS65911_REG_LDO2
:
734 case TPS65911_REG_LDO4
:
735 return tps65910_modify_bits(pmic
, reg
,
736 (selector
<< LDO_SEL_SHIFT
), LDO1_SEL_MASK
);
737 case TPS65911_REG_LDO3
:
738 case TPS65911_REG_LDO5
:
739 case TPS65911_REG_LDO6
:
740 case TPS65911_REG_LDO7
:
741 case TPS65911_REG_LDO8
:
742 case TPS65910_REG_VIO
:
743 return tps65910_modify_bits(pmic
, reg
,
744 (selector
<< LDO_SEL_SHIFT
), LDO3_SEL_MASK
);
751 static int tps65910_list_voltage_dcdc(struct regulator_dev
*dev
,
754 int volt
, mult
= 1, id
= rdev_get_id(dev
);
757 case TPS65910_REG_VDD1
:
758 case TPS65910_REG_VDD2
:
759 mult
= (selector
/ VDD1_2_NUM_VOLTS
) + 1;
760 volt
= VDD1_2_MIN_VOLT
+
761 (selector
% VDD1_2_NUM_VOLTS
) * VDD1_2_OFFSET
;
762 case TPS65911_REG_VDDCTRL
:
763 volt
= VDDCTRL_MIN_VOLT
+ (selector
* VDDCTRL_OFFSET
);
766 return volt
* 100 * mult
;
769 static int tps65910_list_voltage(struct regulator_dev
*dev
,
772 struct tps65910_reg
*pmic
= rdev_get_drvdata(dev
);
773 int id
= rdev_get_id(dev
), voltage
;
775 if (id
< TPS65910_REG_VIO
|| id
> TPS65910_REG_VMMC
)
778 if (selector
>= pmic
->info
[id
]->table_len
)
781 voltage
= pmic
->info
[id
]->table
[selector
] * 1000;
786 static int tps65911_list_voltage(struct regulator_dev
*dev
, unsigned selector
)
788 struct tps65910_reg
*pmic
= rdev_get_drvdata(dev
);
789 int step_mv
= 0, id
= rdev_get_id(dev
);
792 case TPS65911_REG_LDO1
:
793 case TPS65911_REG_LDO2
:
794 case TPS65911_REG_LDO4
:
795 /* The first 5 values of the selector correspond to 1V */
803 case TPS65911_REG_LDO3
:
804 case TPS65911_REG_LDO5
:
805 case TPS65911_REG_LDO6
:
806 case TPS65911_REG_LDO7
:
807 case TPS65911_REG_LDO8
:
808 /* The first 3 values of the selector correspond to 1V */
816 case TPS65910_REG_VIO
:
817 return pmic
->info
[id
]->table
[selector
] * 1000;
822 return (LDO_MIN_VOLT
+ selector
* step_mv
) * 1000;
825 /* Regulator ops (except VRTC) */
826 static struct regulator_ops tps65910_ops_dcdc
= {
827 .is_enabled
= tps65910_is_enabled
,
828 .enable
= tps65910_enable
,
829 .disable
= tps65910_disable
,
830 .set_mode
= tps65910_set_mode
,
831 .get_mode
= tps65910_get_mode
,
832 .get_voltage
= tps65910_get_voltage_dcdc
,
833 .set_voltage_sel
= tps65910_set_voltage_dcdc
,
834 .list_voltage
= tps65910_list_voltage_dcdc
,
837 static struct regulator_ops tps65910_ops_vdd3
= {
838 .is_enabled
= tps65910_is_enabled
,
839 .enable
= tps65910_enable
,
840 .disable
= tps65910_disable
,
841 .set_mode
= tps65910_set_mode
,
842 .get_mode
= tps65910_get_mode
,
843 .get_voltage
= tps65910_get_voltage_vdd3
,
844 .list_voltage
= tps65910_list_voltage
,
847 static struct regulator_ops tps65910_ops
= {
848 .is_enabled
= tps65910_is_enabled
,
849 .enable
= tps65910_enable
,
850 .disable
= tps65910_disable
,
851 .set_mode
= tps65910_set_mode
,
852 .get_mode
= tps65910_get_mode
,
853 .get_voltage
= tps65910_get_voltage
,
854 .set_voltage_sel
= tps65910_set_voltage
,
855 .list_voltage
= tps65910_list_voltage
,
858 static struct regulator_ops tps65911_ops
= {
859 .is_enabled
= tps65910_is_enabled
,
860 .enable
= tps65910_enable
,
861 .disable
= tps65910_disable
,
862 .set_mode
= tps65910_set_mode
,
863 .get_mode
= tps65910_get_mode
,
864 .get_voltage
= tps65911_get_voltage
,
865 .set_voltage_sel
= tps65911_set_voltage
,
866 .list_voltage
= tps65911_list_voltage
,
869 static __devinit
int tps65910_probe(struct platform_device
*pdev
)
871 struct tps65910
*tps65910
= dev_get_drvdata(pdev
->dev
.parent
);
872 struct tps_info
*info
;
873 struct regulator_init_data
*reg_data
;
874 struct regulator_dev
*rdev
;
875 struct tps65910_reg
*pmic
;
876 struct tps65910_board
*pmic_plat_data
;
879 pmic_plat_data
= dev_get_platdata(tps65910
->dev
);
883 reg_data
= pmic_plat_data
->tps65910_pmic_init_data
;
885 pmic
= kzalloc(sizeof(*pmic
), GFP_KERNEL
);
889 mutex_init(&pmic
->mutex
);
890 pmic
->mfd
= tps65910
;
891 platform_set_drvdata(pdev
, pmic
);
893 /* Give control of all register to control port */
894 tps65910_set_bits(pmic
->mfd
, TPS65910_DEVCTRL
,
895 DEVCTRL_SR_CTL_I2C_SEL_MASK
);
897 switch(tps65910_chip_id(tps65910
)) {
899 pmic
->get_ctrl_reg
= &tps65910_get_ctrl_register
;
900 info
= tps65910_regs
;
902 pmic
->get_ctrl_reg
= &tps65911_get_ctrl_register
;
903 info
= tps65911_regs
;
905 pr_err("Invalid tps chip version\n");
909 for (i
= 0; i
< TPS65910_NUM_REGULATOR
; i
++, info
++, reg_data
++) {
910 /* Register the regulators */
911 pmic
->info
[i
] = info
;
913 pmic
->desc
[i
].name
= info
->name
;
914 pmic
->desc
[i
].id
= i
;
915 pmic
->desc
[i
].n_voltages
= info
->table_len
;
917 if (i
== TPS65910_REG_VDD1
|| i
== TPS65910_REG_VDD2
) {
918 pmic
->desc
[i
].ops
= &tps65910_ops_dcdc
;
919 } else if (i
== TPS65910_REG_VDD3
) {
920 if (tps65910_chip_id(tps65910
) == TPS65910
)
921 pmic
->desc
[i
].ops
= &tps65910_ops_vdd3
;
923 pmic
->desc
[i
].ops
= &tps65910_ops_dcdc
;
925 if (tps65910_chip_id(tps65910
) == TPS65910
)
926 pmic
->desc
[i
].ops
= &tps65910_ops
;
928 pmic
->desc
[i
].ops
= &tps65911_ops
;
931 pmic
->desc
[i
].type
= REGULATOR_VOLTAGE
;
932 pmic
->desc
[i
].owner
= THIS_MODULE
;
934 rdev
= regulator_register(&pmic
->desc
[i
],
935 tps65910
->dev
, reg_data
, pmic
);
937 dev_err(tps65910
->dev
,
938 "failed to register %s regulator\n",
944 /* Save regulator for cleanup */
945 pmic
->rdev
[i
] = rdev
;
951 regulator_unregister(pmic
->rdev
[i
]);
957 static int __devexit
tps65910_remove(struct platform_device
*pdev
)
959 struct tps65910_reg
*tps65910_reg
= platform_get_drvdata(pdev
);
962 for (i
= 0; i
< TPS65910_NUM_REGULATOR
; i
++)
963 regulator_unregister(tps65910_reg
->rdev
[i
]);
969 static struct platform_driver tps65910_driver
= {
971 .name
= "tps65910-pmic",
972 .owner
= THIS_MODULE
,
974 .probe
= tps65910_probe
,
975 .remove
= __devexit_p(tps65910_remove
),
978 static int __init
tps65910_init(void)
980 return platform_driver_register(&tps65910_driver
);
982 subsys_initcall(tps65910_init
);
984 static void __exit
tps65910_cleanup(void)
986 platform_driver_unregister(&tps65910_driver
);
988 module_exit(tps65910_cleanup
);
990 MODULE_AUTHOR("Graeme Gregory <gg@slimlogic.co.uk>");
991 MODULE_DESCRIPTION("TPS6507x voltage regulator driver");
992 MODULE_LICENSE("GPL v2");
993 MODULE_ALIAS("platform:tps65910-pmic");