aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/tps6507x-regulator.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/regulator/tps6507x-regulator.c')
-rw-r--r--drivers/regulator/tps6507x-regulator.c98
1 files changed, 28 insertions, 70 deletions
diff --git a/drivers/regulator/tps6507x-regulator.c b/drivers/regulator/tps6507x-regulator.c
index da38be1016aa..07d01ccdf308 100644
--- a/drivers/regulator/tps6507x-regulator.c
+++ b/drivers/regulator/tps6507x-regulator.c
@@ -43,58 +43,40 @@
43/* Number of total regulators available */ 43/* Number of total regulators available */
44#define TPS6507X_NUM_REGULATOR (TPS6507X_NUM_DCDC + TPS6507X_NUM_LDO) 44#define TPS6507X_NUM_REGULATOR (TPS6507X_NUM_DCDC + TPS6507X_NUM_LDO)
45 45
46/* Supported voltage values for regulators (in milliVolts) */ 46/* Supported voltage values for regulators (in microVolts) */
47static const u16 VDCDCx_VSEL_table[] = { 47static const unsigned int VDCDCx_VSEL_table[] = {
48 725, 750, 775, 800, 48 725000, 750000, 775000, 800000,
49 825, 850, 875, 900, 49 825000, 850000, 875000, 900000,
50 925, 950, 975, 1000, 50 925000, 950000, 975000, 1000000,
51 1025, 1050, 1075, 1100, 51 1025000, 1050000, 1075000, 1100000,
52 1125, 1150, 1175, 1200, 52 1125000, 1150000, 1175000, 1200000,
53 1225, 1250, 1275, 1300, 53 1225000, 1250000, 1275000, 1300000,
54 1325, 1350, 1375, 1400, 54 1325000, 1350000, 1375000, 1400000,
55 1425, 1450, 1475, 1500, 55 1425000, 1450000, 1475000, 1500000,
56 1550, 1600, 1650, 1700, 56 1550000, 1600000, 1650000, 1700000,
57 1750, 1800, 1850, 1900, 57 1750000, 1800000, 1850000, 1900000,
58 1950, 2000, 2050, 2100, 58 1950000, 2000000, 2050000, 2100000,
59 2150, 2200, 2250, 2300, 59 2150000, 2200000, 2250000, 2300000,
60 2350, 2400, 2450, 2500, 60 2350000, 2400000, 2450000, 2500000,
61 2550, 2600, 2650, 2700, 61 2550000, 2600000, 2650000, 2700000,
62 2750, 2800, 2850, 2900, 62 2750000, 2800000, 2850000, 2900000,
63 3000, 3100, 3200, 3300, 63 3000000, 3100000, 3200000, 3300000,
64}; 64};
65 65
66static const u16 LDO1_VSEL_table[] = { 66static const unsigned int LDO1_VSEL_table[] = {
67 1000, 1100, 1200, 1250, 67 1000000, 1100000, 1200000, 1250000,
68 1300, 1350, 1400, 1500, 68 1300000, 1350000, 1400000, 1500000,
69 1600, 1800, 2500, 2750, 69 1600000, 1800000, 2500000, 2750000,
70 2800, 3000, 3100, 3300, 70 2800000, 3000000, 3100000, 3300000,
71}; 71};
72 72
73static const u16 LDO2_VSEL_table[] = { 73/* The voltage mapping table for LDO2 is the same as VDCDCx */
74 725, 750, 775, 800, 74#define LDO2_VSEL_table VDCDCx_VSEL_table
75 825, 850, 875, 900,
76 925, 950, 975, 1000,
77 1025, 1050, 1075, 1100,
78 1125, 1150, 1175, 1200,
79 1225, 1250, 1275, 1300,
80 1325, 1350, 1375, 1400,
81 1425, 1450, 1475, 1500,
82 1550, 1600, 1650, 1700,
83 1750, 1800, 1850, 1900,
84 1950, 2000, 2050, 2100,
85 2150, 2200, 2250, 2300,
86 2350, 2400, 2450, 2500,
87 2550, 2600, 2650, 2700,
88 2750, 2800, 2850, 2900,
89 3000, 3100, 3200, 3300,
90};
91 75
92struct tps_info { 76struct tps_info {
93 const char *name; 77 const char *name;
94 unsigned min_uV;
95 unsigned max_uV;
96 u8 table_len; 78 u8 table_len;
97 const u16 *table; 79 const unsigned int *table;
98 80
99 /* Does DCDC high or the low register defines output voltage? */ 81 /* Does DCDC high or the low register defines output voltage? */
100 bool defdcdc_default; 82 bool defdcdc_default;
@@ -103,36 +85,26 @@ struct tps_info {
103static struct tps_info tps6507x_pmic_regs[] = { 85static struct tps_info tps6507x_pmic_regs[] = {
104 { 86 {
105 .name = "VDCDC1", 87 .name = "VDCDC1",
106 .min_uV = 725000,
107 .max_uV = 3300000,
108 .table_len = ARRAY_SIZE(VDCDCx_VSEL_table), 88 .table_len = ARRAY_SIZE(VDCDCx_VSEL_table),
109 .table = VDCDCx_VSEL_table, 89 .table = VDCDCx_VSEL_table,
110 }, 90 },
111 { 91 {
112 .name = "VDCDC2", 92 .name = "VDCDC2",
113 .min_uV = 725000,
114 .max_uV = 3300000,
115 .table_len = ARRAY_SIZE(VDCDCx_VSEL_table), 93 .table_len = ARRAY_SIZE(VDCDCx_VSEL_table),
116 .table = VDCDCx_VSEL_table, 94 .table = VDCDCx_VSEL_table,
117 }, 95 },
118 { 96 {
119 .name = "VDCDC3", 97 .name = "VDCDC3",
120 .min_uV = 725000,
121 .max_uV = 3300000,
122 .table_len = ARRAY_SIZE(VDCDCx_VSEL_table), 98 .table_len = ARRAY_SIZE(VDCDCx_VSEL_table),
123 .table = VDCDCx_VSEL_table, 99 .table = VDCDCx_VSEL_table,
124 }, 100 },
125 { 101 {
126 .name = "LDO1", 102 .name = "LDO1",
127 .min_uV = 1000000,
128 .max_uV = 3300000,
129 .table_len = ARRAY_SIZE(LDO1_VSEL_table), 103 .table_len = ARRAY_SIZE(LDO1_VSEL_table),
130 .table = LDO1_VSEL_table, 104 .table = LDO1_VSEL_table,
131 }, 105 },
132 { 106 {
133 .name = "LDO2", 107 .name = "LDO2",
134 .min_uV = 725000,
135 .max_uV = 3300000,
136 .table_len = ARRAY_SIZE(LDO2_VSEL_table), 108 .table_len = ARRAY_SIZE(LDO2_VSEL_table),
137 .table = LDO2_VSEL_table, 109 .table = LDO2_VSEL_table,
138 }, 110 },
@@ -375,28 +347,13 @@ static int tps6507x_pmic_set_voltage_sel(struct regulator_dev *dev,
375 return tps6507x_pmic_reg_write(tps, reg, data); 347 return tps6507x_pmic_reg_write(tps, reg, data);
376} 348}
377 349
378static int tps6507x_pmic_list_voltage(struct regulator_dev *dev,
379 unsigned selector)
380{
381 struct tps6507x_pmic *tps = rdev_get_drvdata(dev);
382 int rid = rdev_get_id(dev);
383
384 if (rid < TPS6507X_DCDC_1 || rid > TPS6507X_LDO_2)
385 return -EINVAL;
386
387 if (selector >= tps->info[rid]->table_len)
388 return -EINVAL;
389 else
390 return tps->info[rid]->table[selector] * 1000;
391}
392
393static struct regulator_ops tps6507x_pmic_ops = { 350static struct regulator_ops tps6507x_pmic_ops = {
394 .is_enabled = tps6507x_pmic_is_enabled, 351 .is_enabled = tps6507x_pmic_is_enabled,
395 .enable = tps6507x_pmic_enable, 352 .enable = tps6507x_pmic_enable,
396 .disable = tps6507x_pmic_disable, 353 .disable = tps6507x_pmic_disable,
397 .get_voltage_sel = tps6507x_pmic_get_voltage_sel, 354 .get_voltage_sel = tps6507x_pmic_get_voltage_sel,
398 .set_voltage_sel = tps6507x_pmic_set_voltage_sel, 355 .set_voltage_sel = tps6507x_pmic_set_voltage_sel,
399 .list_voltage = tps6507x_pmic_list_voltage, 356 .list_voltage = regulator_list_voltage_table,
400}; 357};
401 358
402static __devinit int tps6507x_pmic_probe(struct platform_device *pdev) 359static __devinit int tps6507x_pmic_probe(struct platform_device *pdev)
@@ -449,6 +406,7 @@ static __devinit int tps6507x_pmic_probe(struct platform_device *pdev)
449 tps->desc[i].name = info->name; 406 tps->desc[i].name = info->name;
450 tps->desc[i].id = i; 407 tps->desc[i].id = i;
451 tps->desc[i].n_voltages = info->table_len; 408 tps->desc[i].n_voltages = info->table_len;
409 tps->desc[i].volt_table = info->table;
452 tps->desc[i].ops = &tps6507x_pmic_ops; 410 tps->desc[i].ops = &tps6507x_pmic_ops;
453 tps->desc[i].type = REGULATOR_VOLTAGE; 411 tps->desc[i].type = REGULATOR_VOLTAGE;
454 tps->desc[i].owner = THIS_MODULE; 412 tps->desc[i].owner = THIS_MODULE;