.. | .. |
---|
11 | 11 | #include <linux/kernel.h> |
---|
12 | 12 | #include <linux/bug.h> |
---|
13 | 13 | #include <linux/err.h> |
---|
14 | | -#include <linux/gpio.h> |
---|
15 | | -#include <linux/of_gpio.h> |
---|
| 14 | +#include <linux/gpio/consumer.h> |
---|
16 | 15 | #include <linux/slab.h> |
---|
17 | 16 | #include <linux/platform_device.h> |
---|
18 | 17 | #include <linux/regulator/driver.h> |
---|
.. | .. |
---|
76 | 75 | }; |
---|
77 | 76 | |
---|
78 | 77 | struct max77686_data { |
---|
| 78 | + struct device *dev; |
---|
79 | 79 | DECLARE_BITMAP(gpio_enabled, MAX77686_REGULATORS); |
---|
80 | 80 | |
---|
81 | 81 | /* Array indexed by regulator id */ |
---|
.. | .. |
---|
250 | 250 | struct regulator_config *config) |
---|
251 | 251 | { |
---|
252 | 252 | struct max77686_data *max77686 = config->driver_data; |
---|
| 253 | + int ret; |
---|
253 | 254 | |
---|
254 | 255 | switch (desc->id) { |
---|
255 | 256 | case MAX77686_BUCK8: |
---|
256 | 257 | case MAX77686_BUCK9: |
---|
257 | 258 | case MAX77686_LDO20 ... MAX77686_LDO22: |
---|
258 | | - config->ena_gpio = of_get_named_gpio(np, |
---|
259 | | - "maxim,ena-gpios", 0); |
---|
260 | | - config->ena_gpio_flags = GPIOF_OUT_INIT_HIGH; |
---|
261 | | - config->ena_gpio_initialized = true; |
---|
| 259 | + config->ena_gpiod = fwnode_gpiod_get_index( |
---|
| 260 | + of_fwnode_handle(np), |
---|
| 261 | + "maxim,ena", |
---|
| 262 | + 0, |
---|
| 263 | + GPIOD_OUT_HIGH | GPIOD_FLAGS_BIT_NONEXCLUSIVE, |
---|
| 264 | + "max77686-regulator"); |
---|
| 265 | + if (IS_ERR(config->ena_gpiod)) |
---|
| 266 | + config->ena_gpiod = NULL; |
---|
262 | 267 | break; |
---|
263 | 268 | default: |
---|
264 | 269 | return 0; |
---|
265 | 270 | } |
---|
266 | 271 | |
---|
267 | | - if (gpio_is_valid(config->ena_gpio)) { |
---|
| 272 | + if (config->ena_gpiod) { |
---|
268 | 273 | set_bit(desc->id, max77686->gpio_enabled); |
---|
269 | 274 | |
---|
270 | | - return regmap_update_bits(config->regmap, desc->enable_reg, |
---|
271 | | - desc->enable_mask, |
---|
272 | | - MAX77686_GPIO_CONTROL); |
---|
| 275 | + ret = regmap_update_bits(config->regmap, desc->enable_reg, |
---|
| 276 | + desc->enable_mask, |
---|
| 277 | + MAX77686_GPIO_CONTROL); |
---|
| 278 | + if (ret) { |
---|
| 279 | + gpiod_put(config->ena_gpiod); |
---|
| 280 | + config->ena_gpiod = NULL; |
---|
| 281 | + } |
---|
273 | 282 | } |
---|
274 | 283 | |
---|
275 | 284 | return 0; |
---|
.. | .. |
---|
507 | 516 | if (!max77686) |
---|
508 | 517 | return -ENOMEM; |
---|
509 | 518 | |
---|
| 519 | + max77686->dev = &pdev->dev; |
---|
510 | 520 | config.dev = iodev->dev; |
---|
511 | 521 | config.regmap = iodev->regmap; |
---|
512 | 522 | config.driver_data = max77686; |
---|