History

regulator: fixed/gpio: Pull inversion/OD into gpiolib

This pushes the handling of inversion semantics and open drain settings to the GPIO descriptor and gpiolib. All affected board files are also augmented. This is especially nice since we don't have to have any confusing flags passed around to the left and right littering the fixed and GPIO regulator drivers and the regulator core. It is all just very straight-forward: the core asks the GPIO line to be asserted or deasserted and gpiolib deals with the rest depending on how the platform is configured: if the line is active low, it deals with that, if the line is open drain, it deals with that too.

Linus Walleij committed 7 years ago

Commit 01dc79c1 parent d6cd33a17 files · +13 −66Browse files

Unified · Split

17 files
  1. arch/arm/mach-imx/mach-mx21ads.c +0 −1
  2. arch/arm/mach-imx/mach-mx27ads.c +1 −1
  3. arch/arm/mach-mmp/brownstone.c +0 −1
  4. arch/arm/mach-omap1/board-ams-delta.c +0 −2
  5. arch/arm/mach-omap2/pdata-quirks.c +0 −1
  6. arch/arm/mach-pxa/em-x270.c +0 −1
  7. arch/arm/mach-pxa/ezx.c +1 −2
  8. arch/arm/mach-pxa/raumfeld.c +0 −1
  9. arch/arm/mach-pxa/zeus.c +1 −2
  10. arch/arm/mach-sa1100/assabet.c +0 −1
  11. arch/sh/boards/mach-ecovec24/setup.c +0 −2
  12. arch/x86/platform/intel-mid/device_libs/platform_bcm43xx.c +0 −1
  13. drivers/regulator/core.c +2 −6
  14. drivers/regulator/da9055-regulator.c +0 −1
  15. drivers/regulator/fixed.c +8 −27
  16. include/linux/regulator/fixed.h +0 −10
  17. include/linux/regulator/gpio-regulator.h +0 −6
arch/arm/mach-imx/mach-mx21ads.c+0−1
@@ -205,7 +205,6 @@ static struct regulator_init_data mx21ads_lcd_regulator_init_data = { · 204 unmodified lines
205205 static struct fixed_voltage_config mx21ads_lcd_regulator_pdata = {
206206 .supply_name = "LCD",
207207 .microvolts = 3300000,
208− .enable_high = 1,
209208 .init_data = &mx21ads_lcd_regulator_init_data,
210209 };
211210
arch/arm/mach-imx/mach-mx27ads.c+1−1
@@ -237,7 +237,7 @@ static struct fixed_voltage_config mx27ads_lcd_regulator_pdata = { · 236 unmodified lines
237237 static struct gpiod_lookup_table mx27ads_lcd_regulator_gpiod_table = {
238238 .dev_id = "reg-fixed-voltage.0", /* Let's hope ID 0 is what we get */
239239 .table = {
240− GPIO_LOOKUP("LCD", 0, NULL, GPIO_ACTIVE_HIGH),
240+ GPIO_LOOKUP("LCD", 0, NULL, GPIO_ACTIVE_LOW),
241241 { },
242242 },
243243 };
arch/arm/mach-mmp/brownstone.c+0−1
@@ -149,7 +149,6 @@ static struct regulator_init_data brownstone_v_5vp_data = { · 148 unmodified lines
149149 static struct fixed_voltage_config brownstone_v_5vp = {
150150 .supply_name = "v_5vp",
151151 .microvolts = 5000000,
152− .enable_high = 1,
153152 .enabled_at_boot = 1,
154153 .init_data = &brownstone_v_5vp_data,
155154 };
arch/arm/mach-omap1/board-ams-delta.c+0−2
@@ -267,7 +267,6 @@ static struct fixed_voltage_config modem_nreset_config = { · 266 unmodified lines
267267 .supply_name = "modem_nreset",
268268 .microvolts = 3300000,
269269 .startup_delay = 25000,
270− .enable_high = 1,
271270 .enabled_at_boot = 1,
272271 .init_data = &modem_nreset_data,
273272 };
@@ -533,7 +532,6 @@ static struct regulator_init_data keybrd_pwr_initdata = { · 259 unmodified lines
533532 static struct fixed_voltage_config keybrd_pwr_config = {
534533 .supply_name = "keybrd_pwr",
535534 .microvolts = 5000000,
536− .enable_high = 1,
537535 .init_data = &keybrd_pwr_initdata,
538536 };
539537
arch/arm/mach-omap2/pdata-quirks.c+0−1
@@ -330,7 +330,6 @@ static struct fixed_voltage_config pandora_vwlan = { · 329 unmodified lines
330330 .supply_name = "vwlan",
331331 .microvolts = 1800000, /* 1.8V */
332332 .startup_delay = 50000, /* 50ms */
333− .enable_high = 1,
334333 .init_data = &pandora_vmmc3,
335334 };
336335
arch/arm/mach-pxa/em-x270.c+0−1
@@ -976,7 +976,6 @@ static struct fixed_voltage_config camera_dummy_config = { · 975 unmodified lines
976976 .supply_name = "camera_vdd",
977977 .input_supply = "vcc cam",
978978 .microvolts = 2800000,
979− .enable_high = 0,
980979 .init_data = &camera_dummy_initdata,
981980 };
982981
arch/arm/mach-pxa/ezx.c+1−2
@@ -714,7 +714,6 @@ static struct regulator_init_data camera_regulator_initdata = { · 713 unmodified lines
714714 static struct fixed_voltage_config camera_regulator_config = {
715715 .supply_name = "camera_vdd",
716716 .microvolts = 2800000,
717− .enable_high = 0,
718717 .init_data = &camera_regulator_initdata,
719718 };
720719
@@ -730,7 +729,7 @@ static struct gpiod_lookup_table camera_supply_gpiod_table = { · 9 unmodified lines
730729 .dev_id = "reg-fixed-voltage.1",
731730 .table = {
732731 GPIO_LOOKUP("gpio-pxa", GPIO50_nCAM_EN,
733− NULL, GPIO_ACTIVE_HIGH),
732+ NULL, GPIO_ACTIVE_LOW),
734733 { },
735734 },
736735 };
arch/arm/mach-pxa/raumfeld.c+0−1
@@ -883,7 +883,6 @@ static struct regulator_init_data audio_va_initdata = { · 882 unmodified lines
883883 static struct fixed_voltage_config audio_va_config = {
884884 .supply_name = "audio_va",
885885 .microvolts = 5000000,
886− .enable_high = 1,
887886 .enabled_at_boot = 0,
888887 .init_data = &audio_va_initdata,
889888 };
arch/arm/mach-pxa/zeus.c+1−2
@@ -426,7 +426,7 @@ static struct gpiod_lookup_table can_regulator_gpiod_table = { · 425 unmodified lines
426426 .dev_id = "reg-fixed-voltage.0",
427427 .table = {
428428 GPIO_LOOKUP("gpio-pxa", ZEUS_CAN_SHDN_GPIO,
429− NULL, GPIO_ACTIVE_HIGH),
429+ NULL, GPIO_ACTIVE_LOW),
430430 { },
431431 },
432432 };
@@ -547,7 +547,6 @@ static struct regulator_init_data zeus_ohci_regulator_data = { · 114 unmodified lines
547547 static struct fixed_voltage_config zeus_ohci_regulator_config = {
548548 .supply_name = "vbus2",
549549 .microvolts = 5000000, /* 5.0V */
550− .enable_high = 1,
551550 .startup_delay = 0,
552551 .init_data = &zeus_ohci_regulator_data,
553552 };
arch/arm/mach-sa1100/assabet.c+0−1
@@ -469,7 +469,6 @@ static struct regulator_consumer_supply assabet_cf_vcc_consumers[] = { · 468 unmodified lines
469469 static struct fixed_voltage_config assabet_cf_vcc_pdata __initdata = {
470470 .supply_name = "cf-power",
471471 .microvolts = 3300000,
472− .enable_high = 1,
473472 };
474473
475474 static struct gpiod_lookup_table assabet_cf_vcc_gpio_table = {
arch/sh/boards/mach-ecovec24/setup.c+0−2
@@ -630,7 +630,6 @@ static struct regulator_init_data cn12_power_init_data = { · 629 unmodified lines
630630 static struct fixed_voltage_config cn12_power_info = {
631631 .supply_name = "CN12 SD/MMC Vdd",
632632 .microvolts = 3300000,
633− .enable_high = 1,
634633 .init_data = &cn12_power_init_data,
635634 };
636635
@@ -671,7 +670,6 @@ static struct regulator_init_data sdhi0_power_init_data = { · 34 unmodified lines
671670 static struct fixed_voltage_config sdhi0_power_info = {
672671 .supply_name = "CN11 SD/MMC Vdd",
673672 .microvolts = 3300000,
674− .enable_high = 1,
675673 .init_data = &sdhi0_power_init_data,
676674 };
677675
arch/x86/platform/intel-mid/device_libs/platform_bcm43xx.c+0−1
@@ -44,7 +44,6 @@ static struct fixed_voltage_config bcm43xx_vmmc = { · 43 unmodified lines
4444 */
4545 .microvolts = 2000000, /* 1.8V */
4646 .startup_delay = 250 * 1000, /* 250ms */
47− .enable_high = 1, /* active high */
4847 .enabled_at_boot = 0, /* disabled at boot */
4948 .init_data = &bcm43xx_vmmc_data,
5049 };
drivers/regulator/core.c+2−6
@@ -82,7 +82,6 @@ struct regulator_enable_gpio { · 81 unmodified lines
8282 struct gpio_desc *gpiod;
8383 u32 enable_count; /* a number of enabled shared GPIO */
8484 u32 request_count; /* a number of requested shared GPIO */
85− unsigned int ena_gpio_invert:1;
8685 };
8786
8887 /*
@@ -2268,7 +2267,6 @@ static int regulator_ena_gpio_request(struct regulator_dev *rdev, · 2179 unmodified lines
22682267 }
22692268
22702269 pin->gpiod = gpiod;
2271− pin->ena_gpio_invert = config->ena_gpio_invert;
22722270 list_add(&pin->list, &regulator_ena_gpio_list);
22732271
22742272 update_ena_gpio_to_rdev:
@@ -2319,8 +2317,7 @@ static int regulator_ena_gpio_ctrl(struct regulator_dev *rdev, bool enable) · 44 unmodified lines
23192317 if (enable) {
23202318 /* Enable GPIO at initial use */
23212319 if (pin->enable_count == 0)
2322− gpiod_set_value_cansleep(pin->gpiod,
2323− !pin->ena_gpio_invert);
2320+ gpiod_set_value_cansleep(pin->gpiod, 1);
23242321
23252322 pin->enable_count++;
23262323 } else {
@@ -2331,8 +2328,7 @@ static int regulator_ena_gpio_ctrl(struct regulator_dev *rdev, bool enable) · 4 unmodified lines
23312328
23322329 /* Disable GPIO if not used */
23332330 if (pin->enable_count <= 1) {
2334− gpiod_set_value_cansleep(pin->gpiod,
2335− pin->ena_gpio_invert);
2331+ gpiod_set_value_cansleep(pin->gpiod, 0);
23362332 pin->enable_count = 0;
23372333 }
23382334 }
drivers/regulator/da9055-regulator.c+0−1
@@ -457,7 +457,6 @@ static int da9055_gpio_init(struct da9055_regulator *regulator, · 456 unmodified lines
457457 int gpio_mux = pdata->gpio_ren[id];
458458
459459 config->ena_gpiod = pdata->ena_gpiods[id];
460− config->ena_gpio_invert = 1;
461460
462461 /*
463462 * GPI pin is muxed with regulator to control the
drivers/regulator/fixed.c+8−27
@@ -79,15 +79,6 @@ of_get_fixed_voltage_config(struct device *dev, · 78 unmodified lines
7979
8080 of_property_read_u32(np, "startup-delay-us", &config->startup_delay);
8181
82− /*
83− * FIXME: we pulled active low/high and open drain handling into
84− * gpiolib so it will be handled there. Delete this in the second
85− * step when we also remove the custom inversion handling for all
86− * legacy boardfiles.
87− */
88− config->enable_high = 1;
89− config->gpio_is_open_drain = 0;
90−
9182 if (of_find_property(np, "vin-supply", NULL))
9283 config->input_supply = "vin";
9384
@@ -151,24 +142,14 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev) · 57 unmodified lines
151142
152143 drvdata->desc.fixed_uV = config->microvolts;
153144
154− cfg.ena_gpio_invert = !config->enable_high;
155− if (config->enabled_at_boot) {
156− if (config->enable_high)
157− gflags = GPIOD_OUT_HIGH;
158− else
159− gflags = GPIOD_OUT_LOW;
160− } else {
161− if (config->enable_high)
162− gflags = GPIOD_OUT_LOW;
163− else
164− gflags = GPIOD_OUT_HIGH;
165− }
166− if (config->gpio_is_open_drain) {
167− if (gflags == GPIOD_OUT_HIGH)
168− gflags = GPIOD_OUT_HIGH_OPEN_DRAIN;
169− else
170− gflags = GPIOD_OUT_LOW_OPEN_DRAIN;
171− }
145+ /*
146+ * The signal will be inverted by the GPIO core if flagged so in the
147+ * decriptor.
148+ */
149+ if (config->enabled_at_boot)
150+ gflags = GPIOD_OUT_HIGH;
151+ else
152+ gflags = GPIOD_OUT_LOW;
172153
173154 /*
174155 * Some fixed regulators share the enable line between two
include/linux/regulator/fixed.h+0−10
@@ -25,14 +25,6 @@ struct regulator_init_data; · 24 unmodified lines
2525 * @input_supply: Name of the input regulator supply
2626 * @microvolts: Output voltage of regulator
2727 * @startup_delay: Start-up time in microseconds
28− * @gpio_is_open_drain: Gpio pin is open drain or normal type.
29− * If it is open drain type then HIGH will be set
30− * through PULL-UP with setting gpio as input
31− * and low will be set as gpio-output with driven
32− * to low. For non-open-drain case, the gpio will
33− * will be in output and drive to low/high accordingly.
34− * @enable_high: Polarity of enable GPIO
35− * 1 = Active high, 0 = Active low
3628 * @enabled_at_boot: Whether regulator has been enabled at
3729 * boot or not. 1 = Yes, 0 = No
3830 * This is used to keep the regulator at
@@ -48,8 +40,6 @@ struct fixed_voltage_config { · 9 unmodified lines
4840 const char *input_supply;
4941 int microvolts;
5042 unsigned startup_delay;
51− unsigned gpio_is_open_drain:1;
52− unsigned enable_high:1;
5343 unsigned enabled_at_boot:1;
5444 struct regulator_init_data *init_data;
5545 };
include/linux/regulator/gpio-regulator.h+0−6
@@ -46,10 +46,6 @@ struct gpio_regulator_state { · 45 unmodified lines
4646 /**
4747 * struct gpio_regulator_config - config structure
4848 * @supply_name: Name of the regulator supply
49− * @enable_gpio: GPIO to use for enable control
50− * set to -EINVAL if not used
51− * @enable_high: Polarity of enable GPIO
52− * 1 = Active high, 0 = Active low
5349 * @enabled_at_boot: Whether regulator has been enabled at
5450 * boot or not. 1 = Yes, 0 = No
5551 * This is used to keep the regulator at
@@ -71,8 +67,6 @@ struct gpio_regulator_state { · 15 unmodified lines
7167 struct gpio_regulator_config {
7268 const char *supply_name;
7369
74− int enable_gpio;
75− unsigned enable_high:1;
7670 unsigned enabled_at_boot:1;
7771 unsigned startup_delay;
7872

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t