diff options
author | Axel Lin <axel.lin@gmail.com> | 2012-07-09 18:10:12 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-07-10 09:48:42 -0400 |
commit | b669e0adb9f667acff16162ea0ff4fc404495b3c (patch) | |
tree | 4a05e6779061ff41d4c91cc0d66944a80bde35ba /drivers/regulator/max8952.c | |
parent | aa851193bdf140c85b660c2a070e53316ad2a4d3 (diff) |
regulator: max8952: Use core GPIO enable support
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/max8952.c')
-rw-r--r-- | drivers/regulator/max8952.c | 59 |
1 files changed, 4 insertions, 55 deletions
diff --git a/drivers/regulator/max8952.c b/drivers/regulator/max8952.c index ea58a4404101..355ca7bad9d5 100644 --- a/drivers/regulator/max8952.c +++ b/drivers/regulator/max8952.c | |||
@@ -51,7 +51,6 @@ struct max8952_data { | |||
51 | 51 | ||
52 | bool vid0; | 52 | bool vid0; |
53 | bool vid1; | 53 | bool vid1; |
54 | bool en; | ||
55 | }; | 54 | }; |
56 | 55 | ||
57 | static int max8952_read_reg(struct max8952_data *max8952, u8 reg) | 56 | static int max8952_read_reg(struct max8952_data *max8952, u8 reg) |
@@ -80,38 +79,6 @@ static int max8952_list_voltage(struct regulator_dev *rdev, | |||
80 | return (max8952->pdata->dvs_mode[selector] * 10 + 770) * 1000; | 79 | return (max8952->pdata->dvs_mode[selector] * 10 + 770) * 1000; |
81 | } | 80 | } |
82 | 81 | ||
83 | static int max8952_is_enabled(struct regulator_dev *rdev) | ||
84 | { | ||
85 | struct max8952_data *max8952 = rdev_get_drvdata(rdev); | ||
86 | return max8952->en; | ||
87 | } | ||
88 | |||
89 | static int max8952_enable(struct regulator_dev *rdev) | ||
90 | { | ||
91 | struct max8952_data *max8952 = rdev_get_drvdata(rdev); | ||
92 | |||
93 | /* If not valid, assume "ALWAYS_HIGH" */ | ||
94 | if (gpio_is_valid(max8952->pdata->gpio_en)) | ||
95 | gpio_set_value(max8952->pdata->gpio_en, 1); | ||
96 | |||
97 | max8952->en = true; | ||
98 | return 0; | ||
99 | } | ||
100 | |||
101 | static int max8952_disable(struct regulator_dev *rdev) | ||
102 | { | ||
103 | struct max8952_data *max8952 = rdev_get_drvdata(rdev); | ||
104 | |||
105 | /* If not valid, assume "ALWAYS_HIGH" -> not permitted */ | ||
106 | if (gpio_is_valid(max8952->pdata->gpio_en)) | ||
107 | gpio_set_value(max8952->pdata->gpio_en, 0); | ||
108 | else | ||
109 | return -EPERM; | ||
110 | |||
111 | max8952->en = false; | ||
112 | return 0; | ||
113 | } | ||
114 | |||
115 | static int max8952_get_voltage_sel(struct regulator_dev *rdev) | 82 | static int max8952_get_voltage_sel(struct regulator_dev *rdev) |
116 | { | 83 | { |
117 | struct max8952_data *max8952 = rdev_get_drvdata(rdev); | 84 | struct max8952_data *max8952 = rdev_get_drvdata(rdev); |
@@ -146,9 +113,6 @@ static int max8952_set_voltage_sel(struct regulator_dev *rdev, | |||
146 | 113 | ||
147 | static struct regulator_ops max8952_ops = { | 114 | static struct regulator_ops max8952_ops = { |
148 | .list_voltage = max8952_list_voltage, | 115 | .list_voltage = max8952_list_voltage, |
149 | .is_enabled = max8952_is_enabled, | ||
150 | .enable = max8952_enable, | ||
151 | .disable = max8952_disable, | ||
152 | .get_voltage_sel = max8952_get_voltage_sel, | 116 | .get_voltage_sel = max8952_get_voltage_sel, |
153 | .set_voltage_sel = max8952_set_voltage_sel, | 117 | .set_voltage_sel = max8952_set_voltage_sel, |
154 | }; | 118 | }; |
@@ -193,6 +157,10 @@ static int __devinit max8952_pmic_probe(struct i2c_client *client, | |||
193 | config.init_data = &pdata->reg_data; | 157 | config.init_data = &pdata->reg_data; |
194 | config.driver_data = max8952; | 158 | config.driver_data = max8952; |
195 | 159 | ||
160 | config.ena_gpio = pdata->gpio_en; | ||
161 | if (pdata->reg_data.constraints.boot_on) | ||
162 | config.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; | ||
163 | |||
196 | max8952->rdev = regulator_register(®ulator, &config); | 164 | max8952->rdev = regulator_register(®ulator, &config); |
197 | 165 | ||
198 | if (IS_ERR(max8952->rdev)) { | 166 | if (IS_ERR(max8952->rdev)) { |
@@ -201,27 +169,9 @@ static int __devinit max8952_pmic_probe(struct i2c_client *client, | |||
201 | return ret; | 169 | return ret; |
202 | } | 170 | } |
203 | 171 | ||
204 | max8952->en = !!(pdata->reg_data.constraints.boot_on); | ||
205 | max8952->vid0 = pdata->default_mode & 0x1; | 172 | max8952->vid0 = pdata->default_mode & 0x1; |
206 | max8952->vid1 = (pdata->default_mode >> 1) & 0x1; | 173 | max8952->vid1 = (pdata->default_mode >> 1) & 0x1; |
207 | 174 | ||
208 | if (gpio_is_valid(pdata->gpio_en)) { | ||
209 | if (!gpio_request(pdata->gpio_en, "MAX8952 EN")) | ||
210 | gpio_direction_output(pdata->gpio_en, max8952->en); | ||
211 | else | ||
212 | err = 1; | ||
213 | } else | ||
214 | err = 2; | ||
215 | |||
216 | if (err) { | ||
217 | dev_info(max8952->dev, "EN gpio invalid: assume that EN" | ||
218 | "is always High\n"); | ||
219 | max8952->en = 1; | ||
220 | pdata->gpio_en = -1; /* Mark invalid */ | ||
221 | } | ||
222 | |||
223 | err = 0; | ||
224 | |||
225 | if (gpio_is_valid(pdata->gpio_vid0) && | 175 | if (gpio_is_valid(pdata->gpio_vid0) && |
226 | gpio_is_valid(pdata->gpio_vid1)) { | 176 | gpio_is_valid(pdata->gpio_vid1)) { |
227 | if (!gpio_request(pdata->gpio_vid0, "MAX8952 VID0")) | 177 | if (!gpio_request(pdata->gpio_vid0, "MAX8952 VID0")) |
@@ -307,7 +257,6 @@ static int __devexit max8952_pmic_remove(struct i2c_client *client) | |||
307 | 257 | ||
308 | gpio_free(pdata->gpio_vid0); | 258 | gpio_free(pdata->gpio_vid0); |
309 | gpio_free(pdata->gpio_vid1); | 259 | gpio_free(pdata->gpio_vid1); |
310 | gpio_free(pdata->gpio_en); | ||
311 | return 0; | 260 | return 0; |
312 | } | 261 | } |
313 | 262 | ||