Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

regulator: max8973: Finalize switch to GPIO descriptors

The dvs gpio was still using a legacy number passed from the
platform data. There are no in-tree users of the platform data
so just switch it to a gpio descriptor and obtain it in probe(),
the device tree users will work just as fine with this.

Drop the entirely unused enable_gpio from the platform data
as well. The device tree bindings mentions this but the driver
does not look for it and makes no use of it: it should probably
be implemented properly in a separate patch.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://msgid.link/r/20240220-descriptors-regulators-v1-1-097f608694be@linaro.org
Acked-by: Lee Jones <lee@kernel.org>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Linus Walleij and committed by
Mark Brown
4d52f575 132a85f1

+12 -30
+12 -24
drivers/regulator/max8973-regulator.c
··· 20 20 #include <linux/regulator/machine.h> 21 21 #include <linux/regulator/max8973-regulator.h> 22 22 #include <linux/regulator/of_regulator.h> 23 - #include <linux/gpio.h> 24 23 #include <linux/gpio/consumer.h> 25 - #include <linux/of_gpio.h> 26 24 #include <linux/i2c.h> 27 25 #include <linux/slab.h> 28 26 #include <linux/regmap.h> ··· 100 102 struct regulator_desc desc; 101 103 struct regmap *regmap; 102 104 bool enable_external_control; 103 - int dvs_gpio; 105 + struct gpio_desc *dvs_gpiod; 104 106 int lru_index[MAX8973_MAX_VOUT_REG]; 105 107 int curr_vout_val[MAX8973_MAX_VOUT_REG]; 106 108 int curr_vout_reg; ··· 182 184 * If gpios are available to select the VOUT register then least 183 185 * recently used register for new configuration. 184 186 */ 185 - if (gpio_is_valid(max->dvs_gpio)) 187 + if (max->dvs_gpiod) 186 188 found = find_voltage_set_register(max, vsel, 187 189 &vout_reg, &gpio_val); 188 190 ··· 199 201 } 200 202 201 203 /* Select proper VOUT register vio gpios */ 202 - if (gpio_is_valid(max->dvs_gpio)) { 203 - gpio_set_value_cansleep(max->dvs_gpio, gpio_val & 0x1); 204 + if (max->dvs_gpiod) { 205 + gpiod_set_value_cansleep(max->dvs_gpiod, gpio_val & 0x1); 204 206 max->curr_gpio_val = gpio_val; 205 207 } 206 208 return 0; ··· 529 531 530 532 pdata->enable_ext_control = of_property_read_bool(np, 531 533 "maxim,externally-enable"); 532 - pdata->dvs_gpio = of_get_named_gpio(np, "maxim,dvs-gpio", 0); 533 534 534 535 ret = of_property_read_u32(np, "maxim,dvs-default-state", &pval); 535 536 if (!ret) ··· 609 612 return -EIO; 610 613 } 611 614 612 - if (pdata->dvs_gpio == -EPROBE_DEFER) 613 - return -EPROBE_DEFER; 614 - 615 615 max = devm_kzalloc(&client->dev, sizeof(*max), GFP_KERNEL); 616 616 if (!max) 617 617 return -ENOMEM; 618 + 619 + max->dvs_gpiod = devm_gpiod_get_optional(&client->dev, "maxim,dvs", 620 + (pdata->dvs_def_state) ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW); 621 + if (IS_ERR(max->dvs_gpiod)) 622 + return dev_err_probe(&client->dev, PTR_ERR(max->dvs_gpiod), 623 + "failed to obtain dvs gpio\n"); 624 + gpiod_set_consumer_name(max->dvs_gpiod, "max8973-dvs"); 618 625 619 626 max->regmap = devm_regmap_init_i2c(client, &max8973_regmap_config); 620 627 if (IS_ERR(max->regmap)) { ··· 664 663 max->desc.ramp_delay_table = max8973_buck_ramp_table; 665 664 max->desc.n_ramp_values = ARRAY_SIZE(max8973_buck_ramp_table); 666 665 667 - max->dvs_gpio = (pdata->dvs_gpio) ? pdata->dvs_gpio : -EINVAL; 668 666 max->enable_external_control = pdata->enable_ext_control; 669 667 max->curr_gpio_val = pdata->dvs_def_state; 670 668 max->curr_vout_reg = MAX8973_VOUT + pdata->dvs_def_state; ··· 671 671 672 672 max->lru_index[0] = max->curr_vout_reg; 673 673 674 - if (gpio_is_valid(max->dvs_gpio)) { 675 - int gpio_flags; 674 + if (max->dvs_gpiod) { 676 675 int i; 677 - 678 - gpio_flags = (pdata->dvs_def_state) ? 679 - GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW; 680 - ret = devm_gpio_request_one(&client->dev, max->dvs_gpio, 681 - gpio_flags, "max8973-dvs"); 682 - if (ret) { 683 - dev_err(&client->dev, 684 - "gpio_request for gpio %d failed, err = %d\n", 685 - max->dvs_gpio, ret); 686 - return ret; 687 - } 688 676 689 677 /* 690 678 * Initialize the lru index with vout_reg id
-6
include/linux/regulator/max8973-regulator.h
··· 48 48 * control signal from EN input pin. If it is false then 49 49 * voltage output will be enabled/disabled through EN bit of 50 50 * device register. 51 - * @enable_gpio: Enable GPIO. If EN pin is controlled through GPIO from host 52 - * then GPIO number can be provided. If no GPIO controlled then 53 - * it should be -1. 54 - * @dvs_gpio: GPIO for dvs. It should be -1 if this is tied with fixed logic. 55 51 * @dvs_def_state: Default state of dvs. 1 if it is high else 0. 56 52 */ 57 53 struct max8973_regulator_platform_data { ··· 55 59 unsigned long control_flags; 56 60 unsigned long junction_temp_warning; 57 61 bool enable_ext_control; 58 - int enable_gpio; 59 - int dvs_gpio; 60 62 unsigned dvs_def_state:1; 61 63 }; 62 64