Skip to content

Commit b669e0a

Browse files
AxelLinbroonie
authored andcommitted
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>
1 parent aa85119 commit b669e0a

File tree

1 file changed

+4
-55
lines changed

1 file changed

+4
-55
lines changed

drivers/regulator/max8952.c

Lines changed: 4 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ struct max8952_data {
5151

5252
bool vid0;
5353
bool vid1;
54-
bool en;
5554
};
5655

5756
static int max8952_read_reg(struct max8952_data *max8952, u8 reg)
@@ -80,38 +79,6 @@ static int max8952_list_voltage(struct regulator_dev *rdev,
8079
return (max8952->pdata->dvs_mode[selector] * 10 + 770) * 1000;
8180
}
8281

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-
11582
static int max8952_get_voltage_sel(struct regulator_dev *rdev)
11683
{
11784
struct max8952_data *max8952 = rdev_get_drvdata(rdev);
@@ -146,9 +113,6 @@ static int max8952_set_voltage_sel(struct regulator_dev *rdev,
146113

147114
static struct regulator_ops max8952_ops = {
148115
.list_voltage = max8952_list_voltage,
149-
.is_enabled = max8952_is_enabled,
150-
.enable = max8952_enable,
151-
.disable = max8952_disable,
152116
.get_voltage_sel = max8952_get_voltage_sel,
153117
.set_voltage_sel = max8952_set_voltage_sel,
154118
};
@@ -193,6 +157,10 @@ static int __devinit max8952_pmic_probe(struct i2c_client *client,
193157
config.init_data = &pdata->reg_data;
194158
config.driver_data = max8952;
195159

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+
196164
max8952->rdev = regulator_register(&regulator, &config);
197165

198166
if (IS_ERR(max8952->rdev)) {
@@ -201,27 +169,9 @@ static int __devinit max8952_pmic_probe(struct i2c_client *client,
201169
return ret;
202170
}
203171

204-
max8952->en = !!(pdata->reg_data.constraints.boot_on);
205172
max8952->vid0 = pdata->default_mode & 0x1;
206173
max8952->vid1 = (pdata->default_mode >> 1) & 0x1;
207174

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-
225175
if (gpio_is_valid(pdata->gpio_vid0) &&
226176
gpio_is_valid(pdata->gpio_vid1)) {
227177
if (!gpio_request(pdata->gpio_vid0, "MAX8952 VID0"))
@@ -307,7 +257,6 @@ static int __devexit max8952_pmic_remove(struct i2c_client *client)
307257

308258
gpio_free(pdata->gpio_vid0);
309259
gpio_free(pdata->gpio_vid1);
310-
gpio_free(pdata->gpio_en);
311260
return 0;
312261
}
313262

0 commit comments

Comments
 (0)