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

regulator: fixed: Convert to use GPIO descriptor only

As we augmented the regulator core to accept a GPIO descriptor instead
of a GPIO number, we can augment the fixed GPIO regulator to look up
and pass that descriptor directly from device tree or board GPIO
descriptor look up tables.

Some boards just auto-enumerate their fixed regulator platform devices
and I have assumed they get names like "fixed-regulator.0" but it's
pretty hard to guess this. I need some testing from board maintainers to
be sure. Other boards are straight forward, using just plain
"fixed-regulator" (ID -1) or "fixed-regulator.1" hammering down the
device ID.

It seems the da9055 and da9211 has never got around to actually passing
any enable gpio into its platform data (not the in-tree code anyway) so we
can just decide to simply pass a descriptor instead.

The fixed GPIO-controlled regulator in mach-pxa/ezx.c was confusingly named
"*_dummy_supply_device" while it is a very real device backed by a GPIO
line. There is nothing dummy about it at all, so I renamed it with the
infix *_regulator_* as part of this patch set.

Intel MID portions tested by Andy.

Tested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> # Check the x86 BCM stuff
Acked-by: Tony Lindgren <tony@atomide.com> # OMAP1,2,3 maintainer
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
Reviewed-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Linus Walleij and committed by
Mark Brown
efdfeb07 1efef7cc

+188 -63
+11 -1
arch/arm/mach-imx/mach-mx21ads.c
··· 18 18 #include <linux/mtd/mtd.h> 19 19 #include <linux/mtd/physmap.h> 20 20 #include <linux/gpio/driver.h> 21 + #include <linux/gpio/machine.h> 21 22 #include <linux/gpio.h> 22 23 #include <linux/regulator/fixed.h> 23 24 #include <linux/regulator/machine.h> ··· 176 175 DEFINE_RES_MEM_NAMED(MX21ADS_IO_REG, SZ_2, "dat"); 177 176 178 177 static struct bgpio_pdata mx21ads_mmgpio_pdata = { 178 + .label = "mx21ads-mmgpio", 179 179 .base = MX21ADS_MMGPIO_BASE, 180 180 .ngpio = 16, 181 181 }; ··· 205 203 static struct fixed_voltage_config mx21ads_lcd_regulator_pdata = { 206 204 .supply_name = "LCD", 207 205 .microvolts = 3300000, 208 - .gpio = MX21ADS_IO_LCDON, 209 206 .enable_high = 1, 210 207 .init_data = &mx21ads_lcd_regulator_init_data, 211 208 }; ··· 214 213 .id = PLATFORM_DEVID_AUTO, 215 214 .dev = { 216 215 .platform_data = &mx21ads_lcd_regulator_pdata, 216 + }, 217 + }; 218 + 219 + static struct gpiod_lookup_table mx21ads_lcd_regulator_gpiod_table = { 220 + .dev_id = "reg-fixed-voltage.0", /* Let's hope ID 0 is what we get */ 221 + .table = { 222 + GPIO_LOOKUP("mx21ads-mmgpio", 9, NULL, GPIO_ACTIVE_HIGH), 223 + { }, 217 224 }, 218 225 }; 219 226 ··· 320 311 { 321 312 imx21_add_mxc_mmc(0, &mx21ads_sdhc_pdata); 322 313 314 + gpiod_add_lookup_table(&mx21ads_lcd_regulator_gpiod_table); 323 315 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices)); 324 316 325 317 mx21ads_cs8900_resources[1].start =
+11 -1
arch/arm/mach-imx/mach-mx27ads.c
··· 16 16 #include <linux/gpio/driver.h> 17 17 /* Needed for gpio_to_irq() */ 18 18 #include <linux/gpio.h> 19 + #include <linux/gpio/machine.h> 19 20 #include <linux/platform_device.h> 20 21 #include <linux/mtd/mtd.h> 21 22 #include <linux/mtd/map.h> ··· 231 230 static struct fixed_voltage_config mx27ads_lcd_regulator_pdata = { 232 231 .supply_name = "LCD", 233 232 .microvolts = 3300000, 234 - .gpio = MX27ADS_LCD_GPIO, 235 233 .init_data = &mx27ads_lcd_regulator_init_data, 234 + }; 235 + 236 + static struct gpiod_lookup_table mx27ads_lcd_regulator_gpiod_table = { 237 + .dev_id = "reg-fixed-voltage.0", /* Let's hope ID 0 is what we get */ 238 + .table = { 239 + GPIO_LOOKUP("LCD", 0, NULL, GPIO_ACTIVE_HIGH), 240 + { }, 241 + }, 236 242 }; 237 243 238 244 static void __init mx27ads_regulator_init(void) ··· 254 246 vchip->direction_output = vgpio_dir_out; 255 247 vchip->set = vgpio_set; 256 248 gpiochip_add_data(vchip, NULL); 249 + 250 + gpiod_add_lookup_table(&mx27ads_lcd_regulator_gpiod_table); 257 251 258 252 platform_device_register_data(NULL, "reg-fixed-voltage", 259 253 PLATFORM_DEVID_AUTO,
+11 -1
arch/arm/mach-mmp/brownstone.c
··· 15 15 #include <linux/platform_device.h> 16 16 #include <linux/io.h> 17 17 #include <linux/gpio-pxa.h> 18 + #include <linux/gpio/machine.h> 18 19 #include <linux/regulator/machine.h> 19 20 #include <linux/regulator/max8649.h> 20 21 #include <linux/regulator/fixed.h> ··· 149 148 static struct fixed_voltage_config brownstone_v_5vp = { 150 149 .supply_name = "v_5vp", 151 150 .microvolts = 5000000, 152 - .gpio = GPIO_5V_ENABLE, 153 151 .enable_high = 1, 154 152 .enabled_at_boot = 1, 155 153 .init_data = &brownstone_v_5vp_data, ··· 159 159 .id = 1, 160 160 .dev = { 161 161 .platform_data = &brownstone_v_5vp, 162 + }, 163 + }; 164 + 165 + static struct gpiod_lookup_table brownstone_v_5vp_gpiod_table = { 166 + .dev_id = "reg-fixed-voltage.1", /* .id set to 1 above */ 167 + .table = { 168 + GPIO_LOOKUP("gpio-pxa", GPIO_5V_ENABLE, 169 + NULL, GPIO_ACTIVE_HIGH), 170 + { }, 162 171 }, 163 172 }; 164 173 ··· 226 217 mmp2_add_isram(&mmp2_isram_platdata); 227 218 228 219 /* enable 5v regulator */ 220 + gpiod_add_lookup_table(&brownstone_v_5vp_gpiod_table); 229 221 platform_device_register(&brownstone_v_5vp_device); 230 222 } 231 223
+10 -2
arch/arm/mach-omap1/board-ams-delta.c
··· 300 300 static struct fixed_voltage_config modem_nreset_config = { 301 301 .supply_name = "modem_nreset", 302 302 .microvolts = 3300000, 303 - .gpio = AMS_DELTA_GPIO_PIN_MODEM_NRESET, 304 303 .startup_delay = 25000, 305 304 .enable_high = 1, 306 305 .enabled_at_boot = 1, ··· 311 312 .id = -1, 312 313 .dev = { 313 314 .platform_data = &modem_nreset_config, 315 + }, 316 + }; 317 + 318 + static struct gpiod_lookup_table ams_delta_nreset_gpiod_table = { 319 + .dev_id = "reg-fixed-voltage", 320 + .table = { 321 + GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_MODEM_NRESET, 322 + NULL, GPIO_ACTIVE_HIGH), 323 + { }, 314 324 }, 315 325 }; 316 326 ··· 576 568 static struct fixed_voltage_config keybrd_pwr_config = { 577 569 .supply_name = "keybrd_pwr", 578 570 .microvolts = 5000000, 579 - .gpio = AMS_DELTA_GPIO_PIN_KEYBRD_PWR, 580 571 .enable_high = 1, 581 572 .init_data = &keybrd_pwr_initdata, 582 573 }; ··· 609 602 }; 610 603 611 604 static struct gpiod_lookup_table *ams_delta_gpio_tables[] __initdata = { 605 + &ams_delta_nreset_gpiod_table, 612 606 &ams_delta_audio_gpio_table, 613 607 &keybrd_pwr_gpio_table, 614 608 &ams_delta_lcd_gpio_table,
+15 -1
arch/arm/mach-omap2/pdata-quirks.c
··· 10 10 #include <linux/clk.h> 11 11 #include <linux/davinci_emac.h> 12 12 #include <linux/gpio.h> 13 + #include <linux/gpio/machine.h> 13 14 #include <linux/init.h> 14 15 #include <linux/kernel.h> 15 16 #include <linux/of_platform.h> ··· 329 328 static struct fixed_voltage_config pandora_vwlan = { 330 329 .supply_name = "vwlan", 331 330 .microvolts = 1800000, /* 1.8V */ 332 - .gpio = PANDORA_WIFI_NRESET_GPIO, 333 331 .startup_delay = 50000, /* 50ms */ 334 332 .enable_high = 1, 335 333 .init_data = &pandora_vmmc3, ··· 339 339 .id = 1, 340 340 .dev = { 341 341 .platform_data = &pandora_vwlan, 342 + }, 343 + }; 344 + 345 + static struct gpiod_lookup_table pandora_vwlan_gpiod_table = { 346 + .dev_id = "reg-fixed-voltage.1", 347 + .table = { 348 + /* 349 + * As this is a low GPIO number it should be at the first 350 + * GPIO bank. 351 + */ 352 + GPIO_LOOKUP("gpio-0-31", PANDORA_WIFI_NRESET_GPIO, 353 + NULL, GPIO_ACTIVE_HIGH), 354 + { }, 342 355 }, 343 356 }; 344 357 ··· 416 403 static void __init omap3_pandora_legacy_init(void) 417 404 { 418 405 platform_device_register(&pandora_backlight); 406 + gpiod_add_lookup_table(&pandora_vwlan_gpiod_table); 419 407 platform_device_register(&pandora_vwlan_device); 420 408 omap_hsmmc_init(pandora_mmc3); 421 409 omap_hsmmc_late_init(pandora_mmc3);
-1
arch/arm/mach-pxa/em-x270.c
··· 986 986 .supply_name = "camera_vdd", 987 987 .input_supply = "vcc cam", 988 988 .microvolts = 2800000, 989 - .gpio = -1, 990 989 .enable_high = 0, 991 990 .init_data = &camera_dummy_initdata, 992 991 };
+22 -11
arch/arm/mach-pxa/ezx.c
··· 21 21 #include <linux/regulator/fixed.h> 22 22 #include <linux/input.h> 23 23 #include <linux/gpio.h> 24 + #include <linux/gpio/machine.h> 24 25 #include <linux/gpio_keys.h> 25 26 #include <linux/leds-lp3944.h> 26 27 #include <linux/platform_data/i2c-pxa.h> ··· 699 698 700 699 #if defined(CONFIG_MACH_EZX_A780) || defined(CONFIG_MACH_EZX_A910) 701 700 /* camera */ 702 - static struct regulator_consumer_supply camera_dummy_supplies[] = { 701 + static struct regulator_consumer_supply camera_regulator_supplies[] = { 703 702 REGULATOR_SUPPLY("vdd", "0-005d"), 704 703 }; 705 704 706 - static struct regulator_init_data camera_dummy_initdata = { 707 - .consumer_supplies = camera_dummy_supplies, 708 - .num_consumer_supplies = ARRAY_SIZE(camera_dummy_supplies), 705 + static struct regulator_init_data camera_regulator_initdata = { 706 + .consumer_supplies = camera_regulator_supplies, 707 + .num_consumer_supplies = ARRAY_SIZE(camera_regulator_supplies), 709 708 .constraints = { 710 709 .valid_ops_mask = REGULATOR_CHANGE_STATUS, 711 710 }, 712 711 }; 713 712 714 - static struct fixed_voltage_config camera_dummy_config = { 713 + static struct fixed_voltage_config camera_regulator_config = { 715 714 .supply_name = "camera_vdd", 716 715 .microvolts = 2800000, 717 - .gpio = GPIO50_nCAM_EN, 718 716 .enable_high = 0, 719 - .init_data = &camera_dummy_initdata, 717 + .init_data = &camera_regulator_initdata, 720 718 }; 721 719 722 - static struct platform_device camera_supply_dummy_device = { 720 + static struct platform_device camera_supply_regulator_device = { 723 721 .name = "reg-fixed-voltage", 724 722 .id = 1, 725 723 .dev = { 726 - .platform_data = &camera_dummy_config, 724 + .platform_data = &camera_regulator_config, 725 + }, 726 + }; 727 + 728 + static struct gpiod_lookup_table camera_supply_gpiod_table = { 729 + .dev_id = "reg-fixed-voltage.1", 730 + .table = { 731 + GPIO_LOOKUP("gpio-pxa", GPIO50_nCAM_EN, 732 + NULL, GPIO_ACTIVE_HIGH), 733 + { }, 727 734 }, 728 735 }; 729 736 #endif ··· 809 800 810 801 static struct platform_device *a780_devices[] __initdata = { 811 802 &a780_gpio_keys, 812 - &camera_supply_dummy_device, 803 + &camera_supply_regulator_device, 813 804 }; 814 805 815 806 static void __init a780_init(void) ··· 832 823 if (a780_camera_init() == 0) 833 824 pxa_set_camera_info(&a780_pxacamera_platform_data); 834 825 826 + gpiod_add_lookup_table(&camera_supply_gpiod_table); 835 827 pwm_add_table(ezx_pwm_lookup, ARRAY_SIZE(ezx_pwm_lookup)); 836 828 platform_add_devices(ARRAY_AND_SIZE(ezx_devices)); 837 829 platform_add_devices(ARRAY_AND_SIZE(a780_devices)); ··· 1108 1098 1109 1099 static struct platform_device *a910_devices[] __initdata = { 1110 1100 &a910_gpio_keys, 1111 - &camera_supply_dummy_device, 1101 + &camera_supply_regulator_device, 1112 1102 }; 1113 1103 1114 1104 static void __init a910_init(void) ··· 1131 1121 if (a910_camera_init() == 0) 1132 1122 pxa_set_camera_info(&a910_pxacamera_platform_data); 1133 1123 1124 + gpiod_add_lookup_table(&camera_supply_gpiod_table); 1134 1125 pwm_add_table(ezx_pwm_lookup, ARRAY_SIZE(ezx_pwm_lookup)); 1135 1126 platform_add_devices(ARRAY_AND_SIZE(ezx_devices)); 1136 1127 platform_add_devices(ARRAY_AND_SIZE(a910_devices));
+1 -1
arch/arm/mach-pxa/magician.c
··· 18 18 #include <linux/platform_device.h> 19 19 #include <linux/delay.h> 20 20 #include <linux/gpio.h> 21 + #include <linux/gpio/machine.h> 21 22 #include <linux/gpio_keys.h> 22 23 #include <linux/input.h> 23 24 #include <linux/mfd/htc-pasic3.h> ··· 697 696 static struct fixed_voltage_config vads7846 = { 698 697 .supply_name = "vads7846", 699 698 .microvolts = 3300000, /* probably */ 700 - .gpio = -EINVAL, 701 699 .startup_delay = 0, 702 700 .init_data = &vads7846_regulator, 703 701 };
+10 -2
arch/arm/mach-pxa/raumfeld.c
··· 886 886 static struct fixed_voltage_config audio_va_config = { 887 887 .supply_name = "audio_va", 888 888 .microvolts = 5000000, 889 - .gpio = GPIO_AUDIO_VA_ENABLE, 890 889 .enable_high = 1, 891 890 .enabled_at_boot = 0, 892 891 .init_data = &audio_va_initdata, ··· 896 897 .id = 0, 897 898 .dev = { 898 899 .platform_data = &audio_va_config, 900 + }, 901 + }; 902 + 903 + static struct gpiod_lookup_table audio_va_gpiod_table = { 904 + .dev_id = "reg-fixed-voltage.0", 905 + .table = { 906 + GPIO_LOOKUP("gpio-pxa", GPIO_AUDIO_VA_ENABLE, 907 + NULL, GPIO_ACTIVE_HIGH), 908 + { }, 899 909 }, 900 910 }; 901 911 ··· 926 918 static struct fixed_voltage_config audio_dummy_config = { 927 919 .supply_name = "audio_vd", 928 920 .microvolts = 3300000, 929 - .gpio = -1, 930 921 .init_data = &audio_dummy_initdata, 931 922 }; 932 923 ··· 1040 1033 else 1041 1034 gpio_direction_output(GPIO_MCLK_RESET, 1); 1042 1035 1036 + gpiod_add_lookup_table(&audio_va_gpiod_table); 1043 1037 platform_add_devices(ARRAY_AND_SIZE(audio_regulator_devices)); 1044 1038 } 1045 1039
+21 -2
arch/arm/mach-pxa/zeus.c
··· 17 17 #include <linux/irq.h> 18 18 #include <linux/pm.h> 19 19 #include <linux/gpio.h> 20 + #include <linux/gpio/machine.h> 20 21 #include <linux/serial_8250.h> 21 22 #include <linux/dm9000.h> 22 23 #include <linux/mmc/host.h> ··· 411 410 static struct fixed_voltage_config can_regulator_pdata = { 412 411 .supply_name = "CAN_SHDN", 413 412 .microvolts = 3300000, 414 - .gpio = ZEUS_CAN_SHDN_GPIO, 415 413 .init_data = &can_regulator_init_data, 416 414 }; 417 415 ··· 419 419 .id = 0, 420 420 .dev = { 421 421 .platform_data = &can_regulator_pdata, 422 + }, 423 + }; 424 + 425 + static struct gpiod_lookup_table can_regulator_gpiod_table = { 426 + .dev_id = "reg-fixed-voltage.0", 427 + .table = { 428 + GPIO_LOOKUP("gpio-pxa", ZEUS_CAN_SHDN_GPIO, 429 + NULL, GPIO_ACTIVE_HIGH), 430 + { }, 422 431 }, 423 432 }; 424 433 ··· 547 538 static struct fixed_voltage_config zeus_ohci_regulator_config = { 548 539 .supply_name = "vbus2", 549 540 .microvolts = 5000000, /* 5.0V */ 550 - .gpio = ZEUS_USB2_PWREN_GPIO, 551 541 .enable_high = 1, 552 542 .startup_delay = 0, 553 543 .init_data = &zeus_ohci_regulator_data, ··· 557 549 .id = 1, 558 550 .dev = { 559 551 .platform_data = &zeus_ohci_regulator_config, 552 + }, 553 + }; 554 + 555 + static struct gpiod_lookup_table zeus_ohci_regulator_gpiod_table = { 556 + .dev_id = "reg-fixed-voltage.0", 557 + .table = { 558 + GPIO_LOOKUP("gpio-pxa", ZEUS_USB2_PWREN_GPIO, 559 + NULL, GPIO_ACTIVE_HIGH), 560 + { }, 560 561 }, 561 562 }; 562 563 ··· 872 855 873 856 pxa2xx_mfp_config(ARRAY_AND_SIZE(zeus_pin_config)); 874 857 858 + gpiod_add_lookup_table(&can_regulator_gpiod_table); 859 + gpiod_add_lookup_table(&zeus_ohci_regulator_gpiod_table); 875 860 platform_add_devices(zeus_devices, ARRAY_SIZE(zeus_devices)); 876 861 877 862 zeus_register_ohci();
-1
arch/arm/mach-s3c64xx/mach-crag6410.c
··· 352 352 .supply_name = "WALLVDD", 353 353 .microvolts = 5000000, 354 354 .init_data = &wallvdd_data, 355 - .gpio = -EINVAL, 356 355 }; 357 356 358 357 static struct platform_device wallvdd_device = {
-1
arch/arm/mach-s3c64xx/mach-smdk6410.c
··· 222 222 .supply_name = "B_PWR_5V", 223 223 .microvolts = 5000000, 224 224 .init_data = &smdk6410_b_pwr_5v_data, 225 - .gpio = -EINVAL, 226 225 }; 227 226 228 227 static struct platform_device smdk6410_b_pwr_5v = {
+14 -7
arch/arm/mach-sa1100/assabet.c
··· 101 101 102 102 assabet_bcr_gc = gc; 103 103 104 - return gc->base; 104 + return 0; 105 105 } 106 106 107 107 /* ··· 471 471 .enable_high = 1, 472 472 }; 473 473 474 + static struct gpiod_lookup_table assabet_cf_vcc_gpio_table = { 475 + .dev_id = "reg-fixed-voltage.0", 476 + .table = { 477 + GPIO_LOOKUP("assabet", 0, NULL, GPIO_ACTIVE_HIGH), 478 + { }, 479 + }, 480 + }; 481 + 474 482 static void __init assabet_init(void) 475 483 { 476 484 /* ··· 525 517 neponset_resources, ARRAY_SIZE(neponset_resources)); 526 518 #endif 527 519 } else { 520 + gpiod_add_lookup_table(&assabet_cf_vcc_gpio_table); 528 521 sa11x0_register_fixed_regulator(0, &assabet_cf_vcc_pdata, 529 - assabet_cf_vcc_consumers, 530 - ARRAY_SIZE(assabet_cf_vcc_consumers)); 522 + assabet_cf_vcc_consumers, 523 + ARRAY_SIZE(assabet_cf_vcc_consumers), 524 + true); 531 525 532 526 } 533 527 ··· 812 802 813 803 void __init assabet_init_irq(void) 814 804 { 815 - unsigned int assabet_gpio_base; 816 805 u32 def_val; 817 806 818 807 sa1100_init_irq(); ··· 826 817 * 827 818 * This must precede any driver calls to BCR_set() or BCR_clear(). 828 819 */ 829 - assabet_gpio_base = assabet_init_gpio((void *)&ASSABET_BCR, def_val); 830 - 831 - assabet_cf_vcc_pdata.gpio = assabet_gpio_base + 0; 820 + assabet_init_gpio((void *)&ASSABET_BCR, def_val); 832 821 } 833 822 834 823 MACHINE_START(ASSABET, "Intel-Assabet")
+3 -2
arch/arm/mach-sa1100/generic.c
··· 348 348 349 349 int __init sa11x0_register_fixed_regulator(int n, 350 350 struct fixed_voltage_config *cfg, 351 - struct regulator_consumer_supply *supplies, unsigned num_supplies) 351 + struct regulator_consumer_supply *supplies, unsigned num_supplies, 352 + bool uses_gpio) 352 353 { 353 354 struct regulator_init_data *id; 354 355 ··· 357 356 if (!cfg->init_data) 358 357 return -ENOMEM; 359 358 360 - if (cfg->gpio < 0) 359 + if (!uses_gpio) 361 360 id->constraints.always_on = 1; 362 361 id->constraints.name = cfg->supply_name; 363 362 id->constraints.min_uV = cfg->microvolts;
+2 -1
arch/arm/mach-sa1100/generic.h
··· 54 54 struct fixed_voltage_config; 55 55 struct regulator_consumer_supply; 56 56 int sa11x0_register_fixed_regulator(int n, struct fixed_voltage_config *cfg, 57 - struct regulator_consumer_supply *supplies, unsigned num_supplies); 57 + struct regulator_consumer_supply *supplies, unsigned num_supplies, 58 + bool uses_gpio);
+2 -2
arch/arm/mach-sa1100/shannon.c
··· 102 102 .supply_name = "cf-power", 103 103 .microvolts = 3300000, 104 104 .enabled_at_boot = 1, 105 - .gpio = -EINVAL, 106 105 }; 107 106 108 107 static void __init shannon_init(void) 109 108 { 110 109 sa11x0_register_fixed_regulator(0, &shannon_cf_vcc_pdata, 111 110 shannon_cf_vcc_consumers, 112 - ARRAY_SIZE(shannon_cf_vcc_consumers)); 111 + ARRAY_SIZE(shannon_cf_vcc_consumers), 112 + false); 113 113 sa11x0_register_pcmcia(0, &shannon_pcmcia0_gpio_table); 114 114 sa11x0_register_pcmcia(1, &shannon_pcmcia1_gpio_table); 115 115 sa11x0_ppc_configure_mcp();
+25 -2
arch/sh/boards/mach-ecovec24/setup.c
··· 633 633 static struct fixed_voltage_config cn12_power_info = { 634 634 .supply_name = "CN12 SD/MMC Vdd", 635 635 .microvolts = 3300000, 636 - .gpio = GPIO_PTB7, 637 636 .enable_high = 1, 638 637 .init_data = &cn12_power_init_data, 639 638 }; ··· 642 643 .id = 0, 643 644 .dev = { 644 645 .platform_data = &cn12_power_info, 646 + }, 647 + }; 648 + 649 + static struct gpiod_lookup_table cn12_power_gpiod_table = { 650 + .dev_id = "reg-fixed-voltage.0", 651 + .table = { 652 + /* Offset 7 on port B */ 653 + GPIO_LOOKUP("sh7724_pfc", GPIO_PTB7, 654 + NULL, GPIO_ACTIVE_HIGH), 655 + { }, 645 656 }, 646 657 }; 647 658 ··· 674 665 static struct fixed_voltage_config sdhi0_power_info = { 675 666 .supply_name = "CN11 SD/MMC Vdd", 676 667 .microvolts = 3300000, 677 - .gpio = GPIO_PTB6, 678 668 .enable_high = 1, 679 669 .init_data = &sdhi0_power_init_data, 680 670 }; ··· 683 675 .id = 1, 684 676 .dev = { 685 677 .platform_data = &sdhi0_power_info, 678 + }, 679 + }; 680 + 681 + static struct gpiod_lookup_table sdhi0_power_gpiod_table = { 682 + .dev_id = "reg-fixed-voltage.1", 683 + .table = { 684 + /* Offset 6 on port B */ 685 + GPIO_LOOKUP("sh7724_pfc", GPIO_PTB6, 686 + NULL, GPIO_ACTIVE_HIGH), 687 + { }, 686 688 }, 687 689 }; 688 690 ··· 1430 1412 CEU_BUFFER_MEMORY_SIZE - 1, 1431 1413 DMA_MEMORY_EXCLUSIVE); 1432 1414 platform_device_add(ecovec_ceu_devices[1]); 1415 + 1416 + gpiod_add_lookup_table(&cn12_power_gpiod_table); 1417 + #if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE) 1418 + gpiod_add_lookup_table(&sdhi0_power_gpiod_table); 1419 + #endif 1433 1420 1434 1421 return platform_add_devices(ecovec_devices, 1435 1422 ARRAY_SIZE(ecovec_devices));
+14 -3
arch/x86/platform/intel-mid/device_libs/platform_bcm43xx.c
··· 10 10 * of the License. 11 11 */ 12 12 13 - #include <linux/gpio.h> 13 + #include <linux/gpio/machine.h> 14 14 #include <linux/platform_device.h> 15 15 #include <linux/regulator/machine.h> 16 16 #include <linux/regulator/fixed.h> ··· 43 43 * real voltage and signaling are still 1.8V. 44 44 */ 45 45 .microvolts = 2000000, /* 1.8V */ 46 - .gpio = -EINVAL, 47 46 .startup_delay = 250 * 1000, /* 250ms */ 48 47 .enable_high = 1, /* active high */ 49 48 .enabled_at_boot = 0, /* disabled at boot */ ··· 57 58 }, 58 59 }; 59 60 61 + static struct gpiod_lookup_table bcm43xx_vmmc_gpio_table = { 62 + .dev_id = "reg-fixed-voltage.0", 63 + .table = { 64 + GPIO_LOOKUP("0000:00:0c.0", -1, NULL, GPIO_ACTIVE_LOW), 65 + {} 66 + }, 67 + }; 68 + 60 69 static int __init bcm43xx_regulator_register(void) 61 70 { 71 + struct gpiod_lookup_table *table = &bcm43xx_vmmc_gpio_table; 72 + struct gpiod_lookup *lookup = table->table; 62 73 int ret; 63 74 64 - bcm43xx_vmmc.gpio = get_gpio_by_name(WLAN_SFI_GPIO_ENABLE_NAME); 75 + lookup[0].chip_hwnum = get_gpio_by_name(WLAN_SFI_GPIO_ENABLE_NAME); 76 + gpiod_add_lookup_table(table); 77 + 65 78 ret = platform_device_register(&bcm43xx_vmmc_regulator); 66 79 if (ret) { 67 80 pr_err("%s: vmmc regulator register failed\n", __func__);
-1
drivers/regulator/fixed-helper.c
··· 43 43 } 44 44 45 45 data->cfg.microvolts = uv; 46 - data->cfg.gpio = -EINVAL; 47 46 data->cfg.enabled_at_boot = 1; 48 47 data->cfg.init_data = &data->init_data; 49 48
+16 -17
drivers/regulator/fixed.c
··· 24 24 #include <linux/platform_device.h> 25 25 #include <linux/regulator/driver.h> 26 26 #include <linux/regulator/fixed.h> 27 - #include <linux/gpio.h> 27 + #include <linux/gpio/consumer.h> 28 28 #include <linux/slab.h> 29 29 #include <linux/of.h> 30 - #include <linux/of_gpio.h> 31 30 #include <linux/regulator/of_regulator.h> 32 31 #include <linux/regulator/machine.h> 33 32 ··· 77 78 if (init_data->constraints.boot_on) 78 79 config->enabled_at_boot = true; 79 80 80 - config->gpio = of_get_named_gpio(np, "gpio", 0); 81 - if ((config->gpio < 0) && (config->gpio != -ENOENT)) 82 - return ERR_PTR(config->gpio); 83 - 84 81 of_property_read_u32(np, "startup-delay-us", &config->startup_delay); 85 82 86 83 config->enable_high = of_property_read_bool(np, "enable-active-high"); ··· 97 102 struct fixed_voltage_config *config; 98 103 struct fixed_voltage_data *drvdata; 99 104 struct regulator_config cfg = { }; 105 + enum gpiod_flags gflags; 100 106 int ret; 101 107 102 108 drvdata = devm_kzalloc(&pdev->dev, sizeof(struct fixed_voltage_data), ··· 146 150 147 151 drvdata->desc.fixed_uV = config->microvolts; 148 152 149 - if (gpio_is_valid(config->gpio)) { 150 - cfg.ena_gpio = config->gpio; 151 - if (pdev->dev.of_node) 152 - cfg.ena_gpio_initialized = true; 153 - } 154 153 cfg.ena_gpio_invert = !config->enable_high; 155 154 if (config->enabled_at_boot) { 156 155 if (config->enable_high) 157 - cfg.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; 156 + gflags = GPIOD_OUT_HIGH; 158 157 else 159 - cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW; 158 + gflags = GPIOD_OUT_LOW; 160 159 } else { 161 160 if (config->enable_high) 162 - cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW; 161 + gflags = GPIOD_OUT_LOW; 163 162 else 164 - cfg.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; 163 + gflags = GPIOD_OUT_HIGH; 165 164 } 166 - if (config->gpio_is_open_drain) 167 - cfg.ena_gpio_flags |= GPIOF_OPEN_DRAIN; 165 + if (config->gpio_is_open_drain) { 166 + if (gflags == GPIOD_OUT_HIGH) 167 + gflags = GPIOD_OUT_HIGH_OPEN_DRAIN; 168 + else 169 + gflags = GPIOD_OUT_LOW_OPEN_DRAIN; 170 + } 171 + 172 + cfg.ena_gpiod = devm_gpiod_get_optional(&pdev->dev, NULL, gflags); 173 + if (IS_ERR(cfg.ena_gpiod)) 174 + return PTR_ERR(cfg.ena_gpiod); 168 175 169 176 cfg.dev = &pdev->dev; 170 177 cfg.init_data = config->init_data;
-3
include/linux/regulator/fixed.h
··· 24 24 * @supply_name: Name of the regulator supply 25 25 * @input_supply: Name of the input regulator supply 26 26 * @microvolts: Output voltage of regulator 27 - * @gpio: GPIO to use for enable control 28 - * set to -EINVAL if not used 29 27 * @startup_delay: Start-up time in microseconds 30 28 * @gpio_is_open_drain: Gpio pin is open drain or normal type. 31 29 * If it is open drain type then HIGH will be set ··· 47 49 const char *supply_name; 48 50 const char *input_supply; 49 51 int microvolts; 50 - int gpio; 51 52 unsigned startup_delay; 52 53 unsigned gpio_is_open_drain:1; 53 54 unsigned enable_high:1;