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.
Unified · Split
| @@ -205,7 +205,6 @@ static struct regulator_init_data mx21ads_lcd_regulator_init_data = { · 204 unmodified lines | |||
| 205 | static struct fixed_voltage_config mx21ads_lcd_regulator_pdata = { | 205 | static struct fixed_voltage_config mx21ads_lcd_regulator_pdata = { |
| 206 | .supply_name = "LCD", | 206 | .supply_name = "LCD", |
| 207 | .microvolts = 3300000, | 207 | .microvolts = 3300000, |
| 208 | .enable_high = 1, | ||
| 209 | .init_data = &mx21ads_lcd_regulator_init_data, | 208 | .init_data = &mx21ads_lcd_regulator_init_data, |
| 210 | }; | 209 | }; |
| 211 | 210 | ||
| @@ -237,7 +237,7 @@ static struct fixed_voltage_config mx27ads_lcd_regulator_pdata = { · 236 unmodified lines | |||
| 237 | static struct gpiod_lookup_table mx27ads_lcd_regulator_gpiod_table = { | 237 | static struct gpiod_lookup_table mx27ads_lcd_regulator_gpiod_table = { |
| 238 | .dev_id = "reg-fixed-voltage.0", /* Let's hope ID 0 is what we get */ | 238 | .dev_id = "reg-fixed-voltage.0", /* Let's hope ID 0 is what we get */ |
| 239 | .table = { | 239 | .table = { |
| 240 | GPIO_LOOKUP("LCD", 0, NULL, GPIO_ACTIVE_HIGH), | 240 | GPIO_LOOKUP("LCD", 0, NULL, GPIO_ACTIVE_LOW), |
| 241 | { }, | 241 | { }, |
| 242 | }, | 242 | }, |
| 243 | }; | 243 | }; |
| @@ -149,7 +149,6 @@ static struct regulator_init_data brownstone_v_5vp_data = { · 148 unmodified lines | |||
| 149 | static struct fixed_voltage_config brownstone_v_5vp = { | 149 | static struct fixed_voltage_config brownstone_v_5vp = { |
| 150 | .supply_name = "v_5vp", | 150 | .supply_name = "v_5vp", |
| 151 | .microvolts = 5000000, | 151 | .microvolts = 5000000, |
| 152 | .enable_high = 1, | ||
| 153 | .enabled_at_boot = 1, | 152 | .enabled_at_boot = 1, |
| 154 | .init_data = &brownstone_v_5vp_data, | 153 | .init_data = &brownstone_v_5vp_data, |
| 155 | }; | 154 | }; |
| @@ -267,7 +267,6 @@ static struct fixed_voltage_config modem_nreset_config = { · 266 unmodified lines | |||
| 267 | .supply_name = "modem_nreset", | 267 | .supply_name = "modem_nreset", |
| 268 | .microvolts = 3300000, | 268 | .microvolts = 3300000, |
| 269 | .startup_delay = 25000, | 269 | .startup_delay = 25000, |
| 270 | .enable_high = 1, | ||
| 271 | .enabled_at_boot = 1, | 270 | .enabled_at_boot = 1, |
| 272 | .init_data = &modem_nreset_data, | 271 | .init_data = &modem_nreset_data, |
| 273 | }; | 272 | }; |
| @@ -533,7 +532,6 @@ static struct regulator_init_data keybrd_pwr_initdata = { · 259 unmodified lines | |||
| 533 | static struct fixed_voltage_config keybrd_pwr_config = { | 532 | static struct fixed_voltage_config keybrd_pwr_config = { |
| 534 | .supply_name = "keybrd_pwr", | 533 | .supply_name = "keybrd_pwr", |
| 535 | .microvolts = 5000000, | 534 | .microvolts = 5000000, |
| 536 | .enable_high = 1, | ||
| 537 | .init_data = &keybrd_pwr_initdata, | 535 | .init_data = &keybrd_pwr_initdata, |
| 538 | }; | 536 | }; |
| 539 | 537 | ||
| @@ -330,7 +330,6 @@ static struct fixed_voltage_config pandora_vwlan = { · 329 unmodified lines | |||
| 330 | .supply_name = "vwlan", | 330 | .supply_name = "vwlan", |
| 331 | .microvolts = 1800000, /* 1.8V */ | 331 | .microvolts = 1800000, /* 1.8V */ |
| 332 | .startup_delay = 50000, /* 50ms */ | 332 | .startup_delay = 50000, /* 50ms */ |
| 333 | .enable_high = 1, | ||
| 334 | .init_data = &pandora_vmmc3, | 333 | .init_data = &pandora_vmmc3, |
| 335 | }; | 334 | }; |
| 336 | 335 | ||
| @@ -976,7 +976,6 @@ static struct fixed_voltage_config camera_dummy_config = { · 975 unmodified lines | |||
| 976 | .supply_name = "camera_vdd", | 976 | .supply_name = "camera_vdd", |
| 977 | .input_supply = "vcc cam", | 977 | .input_supply = "vcc cam", |
| 978 | .microvolts = 2800000, | 978 | .microvolts = 2800000, |
| 979 | .enable_high = 0, | ||
| 980 | .init_data = &camera_dummy_initdata, | 979 | .init_data = &camera_dummy_initdata, |
| 981 | }; | 980 | }; |
| 982 | 981 | ||
| @@ -714,7 +714,6 @@ static struct regulator_init_data camera_regulator_initdata = { · 713 unmodified lines | |||
| 714 | static struct fixed_voltage_config camera_regulator_config = { | 714 | static struct fixed_voltage_config camera_regulator_config = { |
| 715 | .supply_name = "camera_vdd", | 715 | .supply_name = "camera_vdd", |
| 716 | .microvolts = 2800000, | 716 | .microvolts = 2800000, |
| 717 | .enable_high = 0, | ||
| 718 | .init_data = &camera_regulator_initdata, | 717 | .init_data = &camera_regulator_initdata, |
| 719 | }; | 718 | }; |
| 720 | 719 | ||
| @@ -730,7 +729,7 @@ static struct gpiod_lookup_table camera_supply_gpiod_table = { · 9 unmodified lines | |||
| 730 | .dev_id = "reg-fixed-voltage.1", | 729 | .dev_id = "reg-fixed-voltage.1", |
| 731 | .table = { | 730 | .table = { |
| 732 | GPIO_LOOKUP("gpio-pxa", GPIO50_nCAM_EN, | 731 | GPIO_LOOKUP("gpio-pxa", GPIO50_nCAM_EN, |
| 733 | NULL, GPIO_ACTIVE_HIGH), | 732 | NULL, GPIO_ACTIVE_LOW), |
| 734 | { }, | 733 | { }, |
| 735 | }, | 734 | }, |
| 736 | }; | 735 | }; |
| @@ -883,7 +883,6 @@ static struct regulator_init_data audio_va_initdata = { · 882 unmodified lines | |||
| 883 | static struct fixed_voltage_config audio_va_config = { | 883 | static struct fixed_voltage_config audio_va_config = { |
| 884 | .supply_name = "audio_va", | 884 | .supply_name = "audio_va", |
| 885 | .microvolts = 5000000, | 885 | .microvolts = 5000000, |
| 886 | .enable_high = 1, | ||
| 887 | .enabled_at_boot = 0, | 886 | .enabled_at_boot = 0, |
| 888 | .init_data = &audio_va_initdata, | 887 | .init_data = &audio_va_initdata, |
| 889 | }; | 888 | }; |
| @@ -426,7 +426,7 @@ static struct gpiod_lookup_table can_regulator_gpiod_table = { · 425 unmodified lines | |||
| 426 | .dev_id = "reg-fixed-voltage.0", | 426 | .dev_id = "reg-fixed-voltage.0", |
| 427 | .table = { | 427 | .table = { |
| 428 | GPIO_LOOKUP("gpio-pxa", ZEUS_CAN_SHDN_GPIO, | 428 | GPIO_LOOKUP("gpio-pxa", ZEUS_CAN_SHDN_GPIO, |
| 429 | NULL, GPIO_ACTIVE_HIGH), | 429 | NULL, GPIO_ACTIVE_LOW), |
| 430 | { }, | 430 | { }, |
| 431 | }, | 431 | }, |
| 432 | }; | 432 | }; |
| @@ -547,7 +547,6 @@ static struct regulator_init_data zeus_ohci_regulator_data = { · 114 unmodified lines | |||
| 547 | static struct fixed_voltage_config zeus_ohci_regulator_config = { | 547 | static struct fixed_voltage_config zeus_ohci_regulator_config = { |
| 548 | .supply_name = "vbus2", | 548 | .supply_name = "vbus2", |
| 549 | .microvolts = 5000000, /* 5.0V */ | 549 | .microvolts = 5000000, /* 5.0V */ |
| 550 | .enable_high = 1, | ||
| 551 | .startup_delay = 0, | 550 | .startup_delay = 0, |
| 552 | .init_data = &zeus_ohci_regulator_data, | 551 | .init_data = &zeus_ohci_regulator_data, |
| 553 | }; | 552 | }; |
| @@ -469,7 +469,6 @@ static struct regulator_consumer_supply assabet_cf_vcc_consumers[] = { · 468 unmodified lines | |||
| 469 | static struct fixed_voltage_config assabet_cf_vcc_pdata __initdata = { | 469 | static struct fixed_voltage_config assabet_cf_vcc_pdata __initdata = { |
| 470 | .supply_name = "cf-power", | 470 | .supply_name = "cf-power", |
| 471 | .microvolts = 3300000, | 471 | .microvolts = 3300000, |
| 472 | .enable_high = 1, | ||
| 473 | }; | 472 | }; |
| 474 | 473 | ||
| 475 | static struct gpiod_lookup_table assabet_cf_vcc_gpio_table = { | 474 | static struct gpiod_lookup_table assabet_cf_vcc_gpio_table = { |
| @@ -630,7 +630,6 @@ static struct regulator_init_data cn12_power_init_data = { · 629 unmodified lines | |||
| 630 | static struct fixed_voltage_config cn12_power_info = { | 630 | static struct fixed_voltage_config cn12_power_info = { |
| 631 | .supply_name = "CN12 SD/MMC Vdd", | 631 | .supply_name = "CN12 SD/MMC Vdd", |
| 632 | .microvolts = 3300000, | 632 | .microvolts = 3300000, |
| 633 | .enable_high = 1, | ||
| 634 | .init_data = &cn12_power_init_data, | 633 | .init_data = &cn12_power_init_data, |
| 635 | }; | 634 | }; |
| 636 | 635 | ||
| @@ -671,7 +670,6 @@ static struct regulator_init_data sdhi0_power_init_data = { · 34 unmodified lines | |||
| 671 | static struct fixed_voltage_config sdhi0_power_info = { | 670 | static struct fixed_voltage_config sdhi0_power_info = { |
| 672 | .supply_name = "CN11 SD/MMC Vdd", | 671 | .supply_name = "CN11 SD/MMC Vdd", |
| 673 | .microvolts = 3300000, | 672 | .microvolts = 3300000, |
| 674 | .enable_high = 1, | ||
| 675 | .init_data = &sdhi0_power_init_data, | 673 | .init_data = &sdhi0_power_init_data, |
| 676 | }; | 674 | }; |
| 677 | 675 | ||
| @@ -44,7 +44,6 @@ static struct fixed_voltage_config bcm43xx_vmmc = { · 43 unmodified lines | |||
| 44 | */ | 44 | */ |
| 45 | .microvolts = 2000000, /* 1.8V */ | 45 | .microvolts = 2000000, /* 1.8V */ |
| 46 | .startup_delay = 250 * 1000, /* 250ms */ | 46 | .startup_delay = 250 * 1000, /* 250ms */ |
| 47 | .enable_high = 1, /* active high */ | ||
| 48 | .enabled_at_boot = 0, /* disabled at boot */ | 47 | .enabled_at_boot = 0, /* disabled at boot */ |
| 49 | .init_data = &bcm43xx_vmmc_data, | 48 | .init_data = &bcm43xx_vmmc_data, |
| 50 | }; | 49 | }; |
| @@ -82,7 +82,6 @@ struct regulator_enable_gpio { · 81 unmodified lines | |||
| 82 | struct gpio_desc *gpiod; | 82 | struct gpio_desc *gpiod; |
| 83 | u32 enable_count; /* a number of enabled shared GPIO */ | 83 | u32 enable_count; /* a number of enabled shared GPIO */ |
| 84 | u32 request_count; /* a number of requested shared GPIO */ | 84 | u32 request_count; /* a number of requested shared GPIO */ |
| 85 | unsigned int ena_gpio_invert:1; | ||
| 86 | }; | 85 | }; |
| 87 | 86 | ||
| 88 | /* | 87 | /* |
| @@ -2268,7 +2267,6 @@ static int regulator_ena_gpio_request(struct regulator_dev *rdev, · 2179 unmodified lines | |||
| 2268 | } | 2267 | } |
| 2269 | 2268 | ||
| 2270 | pin->gpiod = gpiod; | 2269 | pin->gpiod = gpiod; |
| 2271 | pin->ena_gpio_invert = config->ena_gpio_invert; | ||
| 2272 | list_add(&pin->list, ®ulator_ena_gpio_list); | 2270 | list_add(&pin->list, ®ulator_ena_gpio_list); |
| 2273 | 2271 | ||
| 2274 | update_ena_gpio_to_rdev: | 2272 | update_ena_gpio_to_rdev: |
| @@ -2319,8 +2317,7 @@ static int regulator_ena_gpio_ctrl(struct regulator_dev *rdev, bool enable) · 44 unmodified lines | |||
| 2319 | if (enable) { | 2317 | if (enable) { |
| 2320 | /* Enable GPIO at initial use */ | 2318 | /* Enable GPIO at initial use */ |
| 2321 | if (pin->enable_count == 0) | 2319 | if (pin->enable_count == 0) |
| 2322 | gpiod_set_value_cansleep(pin->gpiod, | 2320 | gpiod_set_value_cansleep(pin->gpiod, 1); |
| 2323 | !pin->ena_gpio_invert); | ||
| 2324 | 2321 | ||
| 2325 | pin->enable_count++; | 2322 | pin->enable_count++; |
| 2326 | } else { | 2323 | } else { |
| @@ -2331,8 +2328,7 @@ static int regulator_ena_gpio_ctrl(struct regulator_dev *rdev, bool enable) · 4 unmodified lines | |||
| 2331 | 2328 | ||
| 2332 | /* Disable GPIO if not used */ | 2329 | /* Disable GPIO if not used */ |
| 2333 | if (pin->enable_count <= 1) { | 2330 | if (pin->enable_count <= 1) { |
| 2334 | gpiod_set_value_cansleep(pin->gpiod, | 2331 | gpiod_set_value_cansleep(pin->gpiod, 0); |
| 2335 | pin->ena_gpio_invert); | ||
| 2336 | pin->enable_count = 0; | 2332 | pin->enable_count = 0; |
| 2337 | } | 2333 | } |
| 2338 | } | 2334 | } |
| @@ -457,7 +457,6 @@ static int da9055_gpio_init(struct da9055_regulator *regulator, · 456 unmodified lines | |||
| 457 | int gpio_mux = pdata->gpio_ren[id]; | 457 | int gpio_mux = pdata->gpio_ren[id]; |
| 458 | 458 | ||
| 459 | config->ena_gpiod = pdata->ena_gpiods[id]; | 459 | config->ena_gpiod = pdata->ena_gpiods[id]; |
| 460 | config->ena_gpio_invert = 1; | ||
| 461 | 460 | ||
| 462 | /* | 461 | /* |
| 463 | * GPI pin is muxed with regulator to control the | 462 | * GPI pin is muxed with regulator to control the |
| @@ -79,15 +79,6 @@ of_get_fixed_voltage_config(struct device *dev, · 78 unmodified lines | |||
| 79 | 79 | ||
| 80 | of_property_read_u32(np, "startup-delay-us", &config->startup_delay); | 80 | of_property_read_u32(np, "startup-delay-us", &config->startup_delay); |
| 81 | 81 | ||
| 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 | |||
| 91 | if (of_find_property(np, "vin-supply", NULL)) | 82 | if (of_find_property(np, "vin-supply", NULL)) |
| 92 | config->input_supply = "vin"; | 83 | config->input_supply = "vin"; |
| 93 | 84 | ||
| @@ -151,24 +142,14 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev) · 57 unmodified lines | |||
| 151 | 142 | ||
| 152 | drvdata->desc.fixed_uV = config->microvolts; | 143 | drvdata->desc.fixed_uV = config->microvolts; |
| 153 | 144 | ||
| 154 | cfg.ena_gpio_invert = !config->enable_high; | 145 | /* |
| 155 | if (config->enabled_at_boot) { | 146 | * The signal will be inverted by the GPIO core if flagged so in the |
| 156 | if (config->enable_high) | 147 | * decriptor. |
| 157 | gflags = GPIOD_OUT_HIGH; | 148 | */ |
| 158 | else | 149 | if (config->enabled_at_boot) |
| 159 | gflags = GPIOD_OUT_LOW; | 150 | gflags = GPIOD_OUT_HIGH; |
| 160 | } else { | 151 | else |
| 161 | if (config->enable_high) | 152 | gflags = GPIOD_OUT_LOW; |
| 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 | } | ||
| 172 | 153 | ||
| 173 | /* | 154 | /* |
| 174 | * Some fixed regulators share the enable line between two | 155 | * Some fixed regulators share the enable line between two |
| @@ -25,14 +25,6 @@ struct regulator_init_data; · 24 unmodified lines | |||
| 25 | * @input_supply: Name of the input regulator supply | 25 | * @input_supply: Name of the input regulator supply |
| 26 | * @microvolts: Output voltage of regulator | 26 | * @microvolts: Output voltage of regulator |
| 27 | * @startup_delay: Start-up time in microseconds | 27 | * @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 | ||
| 36 | * @enabled_at_boot: Whether regulator has been enabled at | 28 | * @enabled_at_boot: Whether regulator has been enabled at |
| 37 | * boot or not. 1 = Yes, 0 = No | 29 | * boot or not. 1 = Yes, 0 = No |
| 38 | * This is used to keep the regulator at | 30 | * This is used to keep the regulator at |
| @@ -48,8 +40,6 @@ struct fixed_voltage_config { · 9 unmodified lines | |||
| 48 | const char *input_supply; | 40 | const char *input_supply; |
| 49 | int microvolts; | 41 | int microvolts; |
| 50 | unsigned startup_delay; | 42 | unsigned startup_delay; |
| 51 | unsigned gpio_is_open_drain:1; | ||
| 52 | unsigned enable_high:1; | ||
| 53 | unsigned enabled_at_boot:1; | 43 | unsigned enabled_at_boot:1; |
| 54 | struct regulator_init_data *init_data; | 44 | struct regulator_init_data *init_data; |
| 55 | }; | 45 | }; |
| @@ -46,10 +46,6 @@ struct gpio_regulator_state { · 45 unmodified lines | |||
| 46 | /** | 46 | /** |
| 47 | * struct gpio_regulator_config - config structure | 47 | * struct gpio_regulator_config - config structure |
| 48 | * @supply_name: Name of the regulator supply | 48 | * @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 | ||
| 53 | * @enabled_at_boot: Whether regulator has been enabled at | 49 | * @enabled_at_boot: Whether regulator has been enabled at |
| 54 | * boot or not. 1 = Yes, 0 = No | 50 | * boot or not. 1 = Yes, 0 = No |
| 55 | * This is used to keep the regulator at | 51 | * This is used to keep the regulator at |
| @@ -71,8 +67,6 @@ struct gpio_regulator_state { · 15 unmodified lines | |||
| 71 | struct gpio_regulator_config { | 67 | struct gpio_regulator_config { |
| 72 | const char *supply_name; | 68 | const char *supply_name; |
| 73 | 69 | ||
| 74 | int enable_gpio; | ||
| 75 | unsigned enable_high:1; | ||
| 76 | unsigned enabled_at_boot:1; | 70 | unsigned enabled_at_boot:1; |
| 77 | unsigned startup_delay; | 71 | unsigned startup_delay; |
| 78 | 72 | ||