diff options
author | Axel Lin <axel.lin@ingics.com> | 2012-12-17 20:34:13 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-12-24 11:34:11 -0500 |
commit | d645d591588c18f0ad61e292939ee743e43067f2 (patch) | |
tree | 3321d28cf99f501ffab4cb7185eb3a179267bdd8 /drivers/regulator/tps6586x-regulator.c | |
parent | 68f7506017ba67f1334cf086ffab76606f2c5ac4 (diff) |
regulator: tps6586x: Use apply_[reg|bit] with regmap based voltage_sel operations
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/tps6586x-regulator.c')
-rw-r--r-- | drivers/regulator/tps6586x-regulator.c | 54 |
1 files changed, 10 insertions, 44 deletions
diff --git a/drivers/regulator/tps6586x-regulator.c b/drivers/regulator/tps6586x-regulator.c index f86da672c758..e68382d0e1ea 100644 --- a/drivers/regulator/tps6586x-regulator.c +++ b/drivers/regulator/tps6586x-regulator.c | |||
@@ -61,10 +61,6 @@ struct tps6586x_regulator { | |||
61 | 61 | ||
62 | int enable_bit[2]; | 62 | int enable_bit[2]; |
63 | int enable_reg[2]; | 63 | int enable_reg[2]; |
64 | |||
65 | /* for DVM regulators */ | ||
66 | int go_reg; | ||
67 | int go_bit; | ||
68 | }; | 64 | }; |
69 | 65 | ||
70 | static inline struct device *to_tps6586x_dev(struct regulator_dev *rdev) | 66 | static inline struct device *to_tps6586x_dev(struct regulator_dev *rdev) |
@@ -72,37 +68,10 @@ static inline struct device *to_tps6586x_dev(struct regulator_dev *rdev) | |||
72 | return rdev_get_dev(rdev)->parent; | 68 | return rdev_get_dev(rdev)->parent; |
73 | } | 69 | } |
74 | 70 | ||
75 | static int tps6586x_set_voltage_sel(struct regulator_dev *rdev, | ||
76 | unsigned selector) | ||
77 | { | ||
78 | struct tps6586x_regulator *ri = rdev_get_drvdata(rdev); | ||
79 | struct device *parent = to_tps6586x_dev(rdev); | ||
80 | int ret, val, rid = rdev_get_id(rdev); | ||
81 | uint8_t mask; | ||
82 | |||
83 | val = selector << (ffs(rdev->desc->vsel_mask) - 1); | ||
84 | mask = rdev->desc->vsel_mask; | ||
85 | |||
86 | ret = tps6586x_update(parent, rdev->desc->vsel_reg, val, mask); | ||
87 | if (ret) | ||
88 | return ret; | ||
89 | |||
90 | /* Update go bit for DVM regulators */ | ||
91 | switch (rid) { | ||
92 | case TPS6586X_ID_LDO_2: | ||
93 | case TPS6586X_ID_LDO_4: | ||
94 | case TPS6586X_ID_SM_0: | ||
95 | case TPS6586X_ID_SM_1: | ||
96 | ret = tps6586x_set_bits(parent, ri->go_reg, 1 << ri->go_bit); | ||
97 | break; | ||
98 | } | ||
99 | return ret; | ||
100 | } | ||
101 | |||
102 | static struct regulator_ops tps6586x_regulator_ops = { | 71 | static struct regulator_ops tps6586x_regulator_ops = { |
103 | .list_voltage = regulator_list_voltage_table, | 72 | .list_voltage = regulator_list_voltage_table, |
104 | .get_voltage_sel = regulator_get_voltage_sel_regmap, | 73 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
105 | .set_voltage_sel = tps6586x_set_voltage_sel, | 74 | .set_voltage_sel = regulator_set_voltage_sel_regmap, |
106 | 75 | ||
107 | .is_enabled = regulator_is_enabled_regmap, | 76 | .is_enabled = regulator_is_enabled_regmap, |
108 | .enable = regulator_enable_regmap, | 77 | .enable = regulator_enable_regmap, |
@@ -142,7 +111,7 @@ static const unsigned int tps6586x_dvm_voltages[] = { | |||
142 | }; | 111 | }; |
143 | 112 | ||
144 | #define TPS6586X_REGULATOR(_id, _pin_name, vdata, vreg, shift, nbits, \ | 113 | #define TPS6586X_REGULATOR(_id, _pin_name, vdata, vreg, shift, nbits, \ |
145 | ereg0, ebit0, ereg1, ebit1) \ | 114 | ereg0, ebit0, ereg1, ebit1, goreg, gobit) \ |
146 | .desc = { \ | 115 | .desc = { \ |
147 | .supply_name = _pin_name, \ | 116 | .supply_name = _pin_name, \ |
148 | .name = "REG-" #_id, \ | 117 | .name = "REG-" #_id, \ |
@@ -156,29 +125,26 @@ static const unsigned int tps6586x_dvm_voltages[] = { | |||
156 | .enable_mask = 1 << (ebit0), \ | 125 | .enable_mask = 1 << (ebit0), \ |
157 | .vsel_reg = TPS6586X_##vreg, \ | 126 | .vsel_reg = TPS6586X_##vreg, \ |
158 | .vsel_mask = ((1 << (nbits)) - 1) << (shift), \ | 127 | .vsel_mask = ((1 << (nbits)) - 1) << (shift), \ |
128 | .apply_reg = (goreg), \ | ||
129 | .apply_bit = (gobit), \ | ||
159 | }, \ | 130 | }, \ |
160 | .enable_reg[0] = TPS6586X_SUPPLY##ereg0, \ | 131 | .enable_reg[0] = TPS6586X_SUPPLY##ereg0, \ |
161 | .enable_bit[0] = (ebit0), \ | 132 | .enable_bit[0] = (ebit0), \ |
162 | .enable_reg[1] = TPS6586X_SUPPLY##ereg1, \ | 133 | .enable_reg[1] = TPS6586X_SUPPLY##ereg1, \ |
163 | .enable_bit[1] = (ebit1), | 134 | .enable_bit[1] = (ebit1), |
164 | 135 | ||
165 | #define TPS6586X_REGULATOR_DVM_GOREG(goreg, gobit) \ | ||
166 | .go_reg = TPS6586X_##goreg, \ | ||
167 | .go_bit = (gobit), | ||
168 | |||
169 | #define TPS6586X_LDO(_id, _pname, vdata, vreg, shift, nbits, \ | 136 | #define TPS6586X_LDO(_id, _pname, vdata, vreg, shift, nbits, \ |
170 | ereg0, ebit0, ereg1, ebit1) \ | 137 | ereg0, ebit0, ereg1, ebit1) \ |
171 | { \ | 138 | { \ |
172 | TPS6586X_REGULATOR(_id, _pname, vdata, vreg, shift, nbits, \ | 139 | TPS6586X_REGULATOR(_id, _pname, vdata, vreg, shift, nbits, \ |
173 | ereg0, ebit0, ereg1, ebit1) \ | 140 | ereg0, ebit0, ereg1, ebit1, 0, 0) \ |
174 | } | 141 | } |
175 | 142 | ||
176 | #define TPS6586X_DVM(_id, _pname, vdata, vreg, shift, nbits, \ | 143 | #define TPS6586X_DVM(_id, _pname, vdata, vreg, shift, nbits, \ |
177 | ereg0, ebit0, ereg1, ebit1, goreg, gobit) \ | 144 | ereg0, ebit0, ereg1, ebit1, goreg, gobit) \ |
178 | { \ | 145 | { \ |
179 | TPS6586X_REGULATOR(_id, _pname, vdata, vreg, shift, nbits, \ | 146 | TPS6586X_REGULATOR(_id, _pname, vdata, vreg, shift, nbits, \ |
180 | ereg0, ebit0, ereg1, ebit1) \ | 147 | ereg0, ebit0, ereg1, ebit1, goreg, gobit) \ |
181 | TPS6586X_REGULATOR_DVM_GOREG(goreg, gobit) \ | ||
182 | } | 148 | } |
183 | 149 | ||
184 | #define TPS6586X_SYS_REGULATOR() \ | 150 | #define TPS6586X_SYS_REGULATOR() \ |
@@ -207,13 +173,13 @@ static struct tps6586x_regulator tps6586x_regulator[] = { | |||
207 | TPS6586X_LDO(SM_2, "vin-sm2", sm2, SUPPLYV2, 0, 5, ENC, 7, END, 7), | 173 | TPS6586X_LDO(SM_2, "vin-sm2", sm2, SUPPLYV2, 0, 5, ENC, 7, END, 7), |
208 | 174 | ||
209 | TPS6586X_DVM(LDO_2, "vinldo23", dvm, LDO2BV1, 0, 5, ENA, 3, | 175 | TPS6586X_DVM(LDO_2, "vinldo23", dvm, LDO2BV1, 0, 5, ENA, 3, |
210 | ENB, 3, VCC2, 6), | 176 | ENB, 3, TPS6586X_VCC2, BIT(6)), |
211 | TPS6586X_DVM(LDO_4, "vinldo4", ldo4, LDO4V1, 0, 5, ENC, 3, | 177 | TPS6586X_DVM(LDO_4, "vinldo4", ldo4, LDO4V1, 0, 5, ENC, 3, |
212 | END, 3, VCC1, 6), | 178 | END, 3, TPS6586X_VCC1, BIT(6)), |
213 | TPS6586X_DVM(SM_0, "vin-sm0", dvm, SM0V1, 0, 5, ENA, 1, | 179 | TPS6586X_DVM(SM_0, "vin-sm0", dvm, SM0V1, 0, 5, ENA, 1, |
214 | ENB, 1, VCC1, 2), | 180 | ENB, 1, TPS6586X_VCC1, BIT(2)), |
215 | TPS6586X_DVM(SM_1, "vin-sm1", dvm, SM1V1, 0, 5, ENA, 0, | 181 | TPS6586X_DVM(SM_1, "vin-sm1", dvm, SM1V1, 0, 5, ENA, 0, |
216 | ENB, 0, VCC1, 0), | 182 | ENB, 0, TPS6586X_VCC1, BIT(0)), |
217 | }; | 183 | }; |
218 | 184 | ||
219 | /* | 185 | /* |