|
28 | 28 | #include <linux/err.h>
|
29 | 29 | #include <linux/of.h>
|
30 | 30 | #include <linux/of_device.h>
|
31 |
| -#include <linux/of_gpio.h> |
32 | 31 | #include <linux/regulator/of_regulator.h>
|
33 | 32 | #include <linux/platform_device.h>
|
34 | 33 | #include <linux/regulator/driver.h>
|
35 | 34 | #include <linux/regulator/machine.h>
|
36 | 35 | #include <linux/regulator/tps62360.h>
|
37 |
| -#include <linux/gpio.h> |
| 36 | +#include <linux/gpio/consumer.h> |
38 | 37 | #include <linux/i2c.h>
|
39 | 38 | #include <linux/slab.h>
|
40 | 39 | #include <linux/regmap.h>
|
@@ -65,8 +64,8 @@ struct tps62360_chip {
|
65 | 64 | struct regulator_desc desc;
|
66 | 65 | struct regulator_dev *rdev;
|
67 | 66 | struct regmap *regmap;
|
68 |
| - int vsel0_gpio; |
69 |
| - int vsel1_gpio; |
| 67 | + struct gpio_desc *vsel0_gpio; |
| 68 | + struct gpio_desc *vsel1_gpio; |
70 | 69 | u8 voltage_reg_mask;
|
71 | 70 | bool en_internal_pulldn;
|
72 | 71 | bool en_discharge;
|
@@ -165,8 +164,8 @@ static int tps62360_dcdc_set_voltage_sel(struct regulator_dev *dev,
|
165 | 164 |
|
166 | 165 | /* Select proper VSET register vio gpios */
|
167 | 166 | if (tps->valid_gpios) {
|
168 |
| - gpio_set_value_cansleep(tps->vsel0_gpio, new_vset_id & 0x1); |
169 |
| - gpio_set_value_cansleep(tps->vsel1_gpio, |
| 167 | + gpiod_set_value_cansleep(tps->vsel0_gpio, new_vset_id & 0x1); |
| 168 | + gpiod_set_value_cansleep(tps->vsel1_gpio, |
170 | 169 | (new_vset_id >> 1) & 0x1);
|
171 | 170 | }
|
172 | 171 | return 0;
|
@@ -310,9 +309,6 @@ static struct tps62360_regulator_platform_data *
|
310 | 309 | return NULL;
|
311 | 310 | }
|
312 | 311 |
|
313 |
| - pdata->vsel0_gpio = of_get_named_gpio(np, "vsel0-gpio", 0); |
314 |
| - pdata->vsel1_gpio = of_get_named_gpio(np, "vsel1-gpio", 0); |
315 |
| - |
316 | 312 | if (of_find_property(np, "ti,vsel0-state-high", NULL))
|
317 | 313 | pdata->vsel0_def_state = 1;
|
318 | 314 |
|
@@ -349,6 +345,7 @@ static int tps62360_probe(struct i2c_client *client,
|
349 | 345 | int ret;
|
350 | 346 | int i;
|
351 | 347 | int chip_id;
|
| 348 | + int gpio_flags; |
352 | 349 |
|
353 | 350 | pdata = dev_get_platdata(&client->dev);
|
354 | 351 |
|
@@ -390,8 +387,6 @@ static int tps62360_probe(struct i2c_client *client,
|
390 | 387 |
|
391 | 388 | tps->en_discharge = pdata->en_discharge;
|
392 | 389 | tps->en_internal_pulldn = pdata->en_internal_pulldn;
|
393 |
| - tps->vsel0_gpio = pdata->vsel0_gpio; |
394 |
| - tps->vsel1_gpio = pdata->vsel1_gpio; |
395 | 390 | tps->dev = &client->dev;
|
396 | 391 |
|
397 | 392 | switch (chip_id) {
|
@@ -426,29 +421,27 @@ static int tps62360_probe(struct i2c_client *client,
|
426 | 421 | tps->lru_index[0] = tps->curr_vset_id;
|
427 | 422 | tps->valid_gpios = false;
|
428 | 423 |
|
429 |
| - if (gpio_is_valid(tps->vsel0_gpio) && gpio_is_valid(tps->vsel1_gpio)) { |
430 |
| - int gpio_flags; |
431 |
| - gpio_flags = (pdata->vsel0_def_state) ? |
432 |
| - GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW; |
433 |
| - ret = devm_gpio_request_one(&client->dev, tps->vsel0_gpio, |
434 |
| - gpio_flags, "tps62360-vsel0"); |
435 |
| - if (ret) { |
436 |
| - dev_err(&client->dev, |
437 |
| - "%s(): Could not obtain vsel0 GPIO %d: %d\n", |
438 |
| - __func__, tps->vsel0_gpio, ret); |
439 |
| - return ret; |
440 |
| - } |
| 424 | + gpio_flags = (pdata->vsel0_def_state) ? |
| 425 | + GPIOD_OUT_HIGH : GPIOD_OUT_LOW; |
| 426 | + tps->vsel0_gpio = devm_gpiod_get_optional(&client->dev, "vsel0", gpio_flags); |
| 427 | + if (IS_ERR(tps->vsel0_gpio)) { |
| 428 | + dev_err(&client->dev, |
| 429 | + "%s(): Could not obtain vsel0 GPIO: %ld\n", |
| 430 | + __func__, PTR_ERR(tps->vsel0_gpio)); |
| 431 | + return PTR_ERR(tps->vsel0_gpio); |
| 432 | + } |
441 | 433 |
|
442 |
| - gpio_flags = (pdata->vsel1_def_state) ? |
443 |
| - GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW; |
444 |
| - ret = devm_gpio_request_one(&client->dev, tps->vsel1_gpio, |
445 |
| - gpio_flags, "tps62360-vsel1"); |
446 |
| - if (ret) { |
447 |
| - dev_err(&client->dev, |
448 |
| - "%s(): Could not obtain vsel1 GPIO %d: %d\n", |
449 |
| - __func__, tps->vsel1_gpio, ret); |
450 |
| - return ret; |
451 |
| - } |
| 434 | + gpio_flags = (pdata->vsel1_def_state) ? |
| 435 | + GPIOD_OUT_HIGH : GPIOD_OUT_LOW; |
| 436 | + tps->vsel1_gpio = devm_gpiod_get_optional(&client->dev, "vsel1", gpio_flags); |
| 437 | + if (IS_ERR(tps->vsel1_gpio)) { |
| 438 | + dev_err(&client->dev, |
| 439 | + "%s(): Could not obtain vsel1 GPIO: %ld\n", |
| 440 | + __func__, PTR_ERR(tps->vsel1_gpio)); |
| 441 | + return PTR_ERR(tps->vsel1_gpio); |
| 442 | + } |
| 443 | + |
| 444 | + if (tps->vsel0_gpio != NULL && tps->vsel1_gpio != NULL) { |
452 | 445 | tps->valid_gpios = true;
|
453 | 446 |
|
454 | 447 | /*
|
|
0 commit comments