diff options
author | Axel Lin <axel.lin@gmail.com> | 2012-06-05 20:36:37 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-06-07 19:37:29 -0400 |
commit | c49af95631a46e8a2664ae2067c900905c39f2b2 (patch) | |
tree | 88acced1d8ca314b6e6daece5d97984acce139fc /drivers/regulator/pcap-regulator.c | |
parent | fedd89b1aafd6b2bf7c0b4009fd616a02484ae80 (diff) |
regulator: pcap: Convert to regulator_list_voltage_table
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/pcap-regulator.c')
-rw-r--r-- | drivers/regulator/pcap-regulator.c | 95 |
1 files changed, 42 insertions, 53 deletions
diff --git a/drivers/regulator/pcap-regulator.c b/drivers/regulator/pcap-regulator.c index 8211101121f0..68777acc099f 100644 --- a/drivers/regulator/pcap-regulator.c +++ b/drivers/regulator/pcap-regulator.c | |||
@@ -18,80 +18,80 @@ | |||
18 | #include <linux/regulator/machine.h> | 18 | #include <linux/regulator/machine.h> |
19 | #include <linux/mfd/ezx-pcap.h> | 19 | #include <linux/mfd/ezx-pcap.h> |
20 | 20 | ||
21 | static const u16 V1_table[] = { | 21 | static const unsigned int V1_table[] = { |
22 | 2775, 1275, 1600, 1725, 1825, 1925, 2075, 2275, | 22 | 2775000, 1275000, 1600000, 1725000, 1825000, 1925000, 2075000, 2275000, |
23 | }; | 23 | }; |
24 | 24 | ||
25 | static const u16 V2_table[] = { | 25 | static const unsigned int V2_table[] = { |
26 | 2500, 2775, | 26 | 2500000, 2775000, |
27 | }; | 27 | }; |
28 | 28 | ||
29 | static const u16 V3_table[] = { | 29 | static const unsigned int V3_table[] = { |
30 | 1075, 1275, 1550, 1725, 1876, 1950, 2075, 2275, | 30 | 1075000, 1275000, 1550000, 1725000, 1876000, 1950000, 2075000, 2275000, |
31 | }; | 31 | }; |
32 | 32 | ||
33 | static const u16 V4_table[] = { | 33 | static const unsigned int V4_table[] = { |
34 | 1275, 1550, 1725, 1875, 1950, 2075, 2275, 2775, | 34 | 1275000, 1550000, 1725000, 1875000, 1950000, 2075000, 2275000, 2775000, |
35 | }; | 35 | }; |
36 | 36 | ||
37 | static const u16 V5_table[] = { | 37 | static const unsigned int V5_table[] = { |
38 | 1875, 2275, 2475, 2775, | 38 | 1875000, 2275000, 2475000, 2775000, |
39 | }; | 39 | }; |
40 | 40 | ||
41 | static const u16 V6_table[] = { | 41 | static const unsigned int V6_table[] = { |
42 | 2475, 2775, | 42 | 2475000, 2775000, |
43 | }; | 43 | }; |
44 | 44 | ||
45 | static const u16 V7_table[] = { | 45 | static const unsigned int V7_table[] = { |
46 | 1875, 2775, | 46 | 1875000, 2775000, |
47 | }; | 47 | }; |
48 | 48 | ||
49 | #define V8_table V4_table | 49 | #define V8_table V4_table |
50 | 50 | ||
51 | static const u16 V9_table[] = { | 51 | static const unsigned int V9_table[] = { |
52 | 1575, 1875, 2475, 2775, | 52 | 1575000, 1875000, 2475000, 2775000, |
53 | }; | 53 | }; |
54 | 54 | ||
55 | static const u16 V10_table[] = { | 55 | static const unsigned int V10_table[] = { |
56 | 5000, | 56 | 5000000, |
57 | }; | 57 | }; |
58 | 58 | ||
59 | static const u16 VAUX1_table[] = { | 59 | static const unsigned int VAUX1_table[] = { |
60 | 1875, 2475, 2775, 3000, | 60 | 1875000, 2475000, 2775000, 3000000, |
61 | }; | 61 | }; |
62 | 62 | ||
63 | #define VAUX2_table VAUX1_table | 63 | #define VAUX2_table VAUX1_table |
64 | 64 | ||
65 | static const u16 VAUX3_table[] = { | 65 | static const unsigned int VAUX3_table[] = { |
66 | 1200, 1200, 1200, 1200, 1400, 1600, 1800, 2000, | 66 | 1200000, 1200000, 1200000, 1200000, 1400000, 1600000, 1800000, 2000000, |
67 | 2200, 2400, 2600, 2800, 3000, 3200, 3400, 3600, | 67 | 2200000, 2400000, 2600000, 2800000, 3000000, 3200000, 3400000, 3600000, |
68 | }; | 68 | }; |
69 | 69 | ||
70 | static const u16 VAUX4_table[] = { | 70 | static const unsigned int VAUX4_table[] = { |
71 | 1800, 1800, 3000, 5000, | 71 | 1800000, 1800000, 3000000, 5000000, |
72 | }; | 72 | }; |
73 | 73 | ||
74 | static const u16 VSIM_table[] = { | 74 | static const unsigned int VSIM_table[] = { |
75 | 1875, 3000, | 75 | 1875000, 3000000, |
76 | }; | 76 | }; |
77 | 77 | ||
78 | static const u16 VSIM2_table[] = { | 78 | static const unsigned int VSIM2_table[] = { |
79 | 1875, | 79 | 1875000, |
80 | }; | 80 | }; |
81 | 81 | ||
82 | static const u16 VVIB_table[] = { | 82 | static const unsigned int VVIB_table[] = { |
83 | 1300, 1800, 2000, 3000, | 83 | 1300000, 1800000, 2000000, 3000000, |
84 | }; | 84 | }; |
85 | 85 | ||
86 | static const u16 SW1_table[] = { | 86 | static const unsigned int SW1_table[] = { |
87 | 900, 950, 1000, 1050, 1100, 1150, 1200, 1250, | 87 | 900000, 950000, 1000000, 1050000, 1100000, 1150000, 1200000, 1250000, |
88 | 1300, 1350, 1400, 1450, 1500, 1600, 1875, 2250, | 88 | 1300000, 1350000, 1400000, 1450000, 1500000, 1600000, 1875000, 2250000, |
89 | }; | 89 | }; |
90 | 90 | ||
91 | #define SW2_table SW1_table | 91 | #define SW2_table SW1_table |
92 | 92 | ||
93 | static const u16 SW3_table[] = { | 93 | static const unsigned int SW3_table[] = { |
94 | 4000, 4500, 5000, 5500, | 94 | 4000000, 4500000, 5000000, 5500000, |
95 | }; | 95 | }; |
96 | 96 | ||
97 | struct pcap_regulator { | 97 | struct pcap_regulator { |
@@ -100,8 +100,6 @@ struct pcap_regulator { | |||
100 | const u8 index; | 100 | const u8 index; |
101 | const u8 stby; | 101 | const u8 stby; |
102 | const u8 lowpwr; | 102 | const u8 lowpwr; |
103 | const u8 n_voltages; | ||
104 | const u16 *voltage_table; | ||
105 | }; | 103 | }; |
106 | 104 | ||
107 | #define NA 0xff | 105 | #define NA 0xff |
@@ -113,8 +111,6 @@ struct pcap_regulator { | |||
113 | .index = _index, \ | 111 | .index = _index, \ |
114 | .stby = _stby, \ | 112 | .stby = _stby, \ |
115 | .lowpwr = _lowpwr, \ | 113 | .lowpwr = _lowpwr, \ |
116 | .n_voltages = ARRAY_SIZE(_vreg##_table), \ | ||
117 | .voltage_table = _vreg##_table, \ | ||
118 | } | 114 | } |
119 | 115 | ||
120 | static struct pcap_regulator vreg_table[] = { | 116 | static struct pcap_regulator vreg_table[] = { |
@@ -157,11 +153,11 @@ static int pcap_regulator_set_voltage_sel(struct regulator_dev *rdev, | |||
157 | void *pcap = rdev_get_drvdata(rdev); | 153 | void *pcap = rdev_get_drvdata(rdev); |
158 | 154 | ||
159 | /* the regulator doesn't support voltage switching */ | 155 | /* the regulator doesn't support voltage switching */ |
160 | if (vreg->n_voltages == 1) | 156 | if (rdev->desc->n_voltages == 1) |
161 | return -EINVAL; | 157 | return -EINVAL; |
162 | 158 | ||
163 | return ezx_pcap_set_bits(pcap, vreg->reg, | 159 | return ezx_pcap_set_bits(pcap, vreg->reg, |
164 | (vreg->n_voltages - 1) << vreg->index, | 160 | (rdev->desc->n_voltages - 1) << vreg->index, |
165 | selector << vreg->index); | 161 | selector << vreg->index); |
166 | } | 162 | } |
167 | 163 | ||
@@ -171,11 +167,11 @@ static int pcap_regulator_get_voltage_sel(struct regulator_dev *rdev) | |||
171 | void *pcap = rdev_get_drvdata(rdev); | 167 | void *pcap = rdev_get_drvdata(rdev); |
172 | u32 tmp; | 168 | u32 tmp; |
173 | 169 | ||
174 | if (vreg->n_voltages == 1) | 170 | if (rdev->desc->n_voltages == 1) |
175 | return 0; | 171 | return 0; |
176 | 172 | ||
177 | ezx_pcap_read(pcap, vreg->reg, &tmp); | 173 | ezx_pcap_read(pcap, vreg->reg, &tmp); |
178 | tmp = ((tmp >> vreg->index) & (vreg->n_voltages - 1)); | 174 | tmp = ((tmp >> vreg->index) & (rdev->desc->n_voltages - 1)); |
179 | return tmp; | 175 | return tmp; |
180 | } | 176 | } |
181 | 177 | ||
@@ -214,16 +210,8 @@ static int pcap_regulator_is_enabled(struct regulator_dev *rdev) | |||
214 | return (tmp >> vreg->en) & 1; | 210 | return (tmp >> vreg->en) & 1; |
215 | } | 211 | } |
216 | 212 | ||
217 | static int pcap_regulator_list_voltage(struct regulator_dev *rdev, | ||
218 | unsigned int index) | ||
219 | { | ||
220 | struct pcap_regulator *vreg = &vreg_table[rdev_get_id(rdev)]; | ||
221 | |||
222 | return vreg->voltage_table[index] * 1000; | ||
223 | } | ||
224 | |||
225 | static struct regulator_ops pcap_regulator_ops = { | 213 | static struct regulator_ops pcap_regulator_ops = { |
226 | .list_voltage = pcap_regulator_list_voltage, | 214 | .list_voltage = regulator_list_voltage_table, |
227 | .set_voltage_sel = pcap_regulator_set_voltage_sel, | 215 | .set_voltage_sel = pcap_regulator_set_voltage_sel, |
228 | .get_voltage_sel = pcap_regulator_get_voltage_sel, | 216 | .get_voltage_sel = pcap_regulator_get_voltage_sel, |
229 | .enable = pcap_regulator_enable, | 217 | .enable = pcap_regulator_enable, |
@@ -236,6 +224,7 @@ static struct regulator_ops pcap_regulator_ops = { | |||
236 | .name = #_vreg, \ | 224 | .name = #_vreg, \ |
237 | .id = _vreg, \ | 225 | .id = _vreg, \ |
238 | .n_voltages = ARRAY_SIZE(_vreg##_table), \ | 226 | .n_voltages = ARRAY_SIZE(_vreg##_table), \ |
227 | .volt_table = _vreg##_table, \ | ||
239 | .ops = &pcap_regulator_ops, \ | 228 | .ops = &pcap_regulator_ops, \ |
240 | .type = REGULATOR_VOLTAGE, \ | 229 | .type = REGULATOR_VOLTAGE, \ |
241 | .owner = THIS_MODULE, \ | 230 | .owner = THIS_MODULE, \ |