Commit e536700e authored by Mark Brown's avatar Mark Brown

regulator: gpio: Revert

regulator: fixed/gpio: Revert GPIO descriptor changes due to platform breakage

Commit 6059577c "regulator: fixed: Convert to use GPIO descriptor
only" broke at least the ams-delta platform since the lookup tables
added to the board files use the function name "enable" while the driver
uses NULL causing the regulator to not acquire and control the enable
GPIOs.  Revert that and a couple of other commits that are caught up
with it to fix the issue:

2b6c00c1 "ARM: pxa, regulator: fix building ezx e680"
6059577c "regulator: fixed: Convert to use GPIO descriptor only"
37bed97f "regulator: gpio: Get enable GPIO using GPIO descriptor"
Reported-by: default avatarJanusz Krzysztofik <jmkrzyszt@gmail.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 2b6c00c1
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/physmap.h> #include <linux/mtd/physmap.h>
#include <linux/gpio/driver.h> #include <linux/gpio/driver.h>
#include <linux/gpio/machine.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/regulator/fixed.h> #include <linux/regulator/fixed.h>
#include <linux/regulator/machine.h> #include <linux/regulator/machine.h>
...@@ -176,7 +175,6 @@ static struct resource mx21ads_mmgpio_resource = ...@@ -176,7 +175,6 @@ static struct resource mx21ads_mmgpio_resource =
DEFINE_RES_MEM_NAMED(MX21ADS_IO_REG, SZ_2, "dat"); DEFINE_RES_MEM_NAMED(MX21ADS_IO_REG, SZ_2, "dat");
static struct bgpio_pdata mx21ads_mmgpio_pdata = { static struct bgpio_pdata mx21ads_mmgpio_pdata = {
.label = "mx21ads-mmgpio",
.base = MX21ADS_MMGPIO_BASE, .base = MX21ADS_MMGPIO_BASE,
.ngpio = 16, .ngpio = 16,
}; };
...@@ -205,6 +203,7 @@ static struct regulator_init_data mx21ads_lcd_regulator_init_data = { ...@@ -205,6 +203,7 @@ static struct regulator_init_data mx21ads_lcd_regulator_init_data = {
static struct fixed_voltage_config mx21ads_lcd_regulator_pdata = { static struct fixed_voltage_config mx21ads_lcd_regulator_pdata = {
.supply_name = "LCD", .supply_name = "LCD",
.microvolts = 3300000, .microvolts = 3300000,
.gpio = MX21ADS_IO_LCDON,
.enable_high = 1, .enable_high = 1,
.init_data = &mx21ads_lcd_regulator_init_data, .init_data = &mx21ads_lcd_regulator_init_data,
}; };
...@@ -217,15 +216,6 @@ static struct platform_device mx21ads_lcd_regulator = { ...@@ -217,15 +216,6 @@ static struct platform_device mx21ads_lcd_regulator = {
}, },
}; };
static struct gpiod_lookup_table mx21ads_lcd_regulator_gpiod_table = {
.dev_id = "reg-fixed-voltage.0", /* Let's hope ID 0 is what we get */
.table = {
GPIO_LOOKUP("mx21ads-mmgpio", 9,
"enable", GPIO_ACTIVE_HIGH),
{ },
},
};
/* /*
* Connected is a portrait Sharp-QVGA display * Connected is a portrait Sharp-QVGA display
* of type: LQ035Q7DB02 * of type: LQ035Q7DB02
...@@ -321,7 +311,6 @@ static void __init mx21ads_late_init(void) ...@@ -321,7 +311,6 @@ static void __init mx21ads_late_init(void)
{ {
imx21_add_mxc_mmc(0, &mx21ads_sdhc_pdata); imx21_add_mxc_mmc(0, &mx21ads_sdhc_pdata);
gpiod_add_lookup_table(&mx21ads_lcd_regulator_gpiod_table);
platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices)); platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
mx21ads_cs8900_resources[1].start = mx21ads_cs8900_resources[1].start =
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include <linux/gpio/driver.h> #include <linux/gpio/driver.h>
/* Needed for gpio_to_irq() */ /* Needed for gpio_to_irq() */
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/gpio/machine.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/map.h> #include <linux/mtd/map.h>
...@@ -231,17 +230,10 @@ static struct regulator_init_data mx27ads_lcd_regulator_init_data = { ...@@ -231,17 +230,10 @@ static struct regulator_init_data mx27ads_lcd_regulator_init_data = {
static struct fixed_voltage_config mx27ads_lcd_regulator_pdata = { static struct fixed_voltage_config mx27ads_lcd_regulator_pdata = {
.supply_name = "LCD", .supply_name = "LCD",
.microvolts = 3300000, .microvolts = 3300000,
.gpio = MX27ADS_LCD_GPIO,
.init_data = &mx27ads_lcd_regulator_init_data, .init_data = &mx27ads_lcd_regulator_init_data,
}; };
static struct gpiod_lookup_table mx27ads_lcd_regulator_gpiod_table = {
.dev_id = "reg-fixed-voltage.0", /* Let's hope ID 0 is what we get */
.table = {
GPIO_LOOKUP("LCD", 0, "enable", GPIO_ACTIVE_HIGH),
{ },
},
};
static void __init mx27ads_regulator_init(void) static void __init mx27ads_regulator_init(void)
{ {
struct gpio_chip *vchip; struct gpio_chip *vchip;
...@@ -255,8 +247,6 @@ static void __init mx27ads_regulator_init(void) ...@@ -255,8 +247,6 @@ static void __init mx27ads_regulator_init(void)
vchip->set = vgpio_set; vchip->set = vgpio_set;
gpiochip_add_data(vchip, NULL); gpiochip_add_data(vchip, NULL);
gpiod_add_lookup_table(&mx27ads_lcd_regulator_gpiod_table);
platform_device_register_data(NULL, "reg-fixed-voltage", platform_device_register_data(NULL, "reg-fixed-voltage",
PLATFORM_DEVID_AUTO, PLATFORM_DEVID_AUTO,
&mx27ads_lcd_regulator_pdata, &mx27ads_lcd_regulator_pdata,
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/gpio-pxa.h> #include <linux/gpio-pxa.h>
#include <linux/gpio/machine.h>
#include <linux/regulator/machine.h> #include <linux/regulator/machine.h>
#include <linux/regulator/max8649.h> #include <linux/regulator/max8649.h>
#include <linux/regulator/fixed.h> #include <linux/regulator/fixed.h>
...@@ -149,6 +148,7 @@ static struct regulator_init_data brownstone_v_5vp_data = { ...@@ -149,6 +148,7 @@ static struct regulator_init_data brownstone_v_5vp_data = {
static struct fixed_voltage_config brownstone_v_5vp = { static struct fixed_voltage_config brownstone_v_5vp = {
.supply_name = "v_5vp", .supply_name = "v_5vp",
.microvolts = 5000000, .microvolts = 5000000,
.gpio = GPIO_5V_ENABLE,
.enable_high = 1, .enable_high = 1,
.enabled_at_boot = 1, .enabled_at_boot = 1,
.init_data = &brownstone_v_5vp_data, .init_data = &brownstone_v_5vp_data,
...@@ -162,15 +162,6 @@ static struct platform_device brownstone_v_5vp_device = { ...@@ -162,15 +162,6 @@ static struct platform_device brownstone_v_5vp_device = {
}, },
}; };
static struct gpiod_lookup_table brownstone_v_5vp_gpiod_table = {
.dev_id = "reg-fixed-voltage.1", /* .id set to 1 above */
.table = {
GPIO_LOOKUP("gpio-pxa", GPIO_5V_ENABLE,
"enable", GPIO_ACTIVE_HIGH),
{ },
},
};
static struct max8925_platform_data brownstone_max8925_info = { static struct max8925_platform_data brownstone_max8925_info = {
.irq_base = MMP_NR_IRQS, .irq_base = MMP_NR_IRQS,
}; };
...@@ -226,7 +217,6 @@ static void __init brownstone_init(void) ...@@ -226,7 +217,6 @@ static void __init brownstone_init(void)
mmp2_add_isram(&mmp2_isram_platdata); mmp2_add_isram(&mmp2_isram_platdata);
/* enable 5v regulator */ /* enable 5v regulator */
gpiod_add_lookup_table(&brownstone_v_5vp_gpiod_table);
platform_device_register(&brownstone_v_5vp_device); platform_device_register(&brownstone_v_5vp_device);
} }
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
* published by the Free Software Foundation. * published by the Free Software Foundation.
*/ */
#include <linux/gpio/driver.h> #include <linux/gpio/driver.h>
#include <linux/gpio/machine.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -204,7 +203,6 @@ static struct resource latch2_resources[] = { ...@@ -204,7 +203,6 @@ static struct resource latch2_resources[] = {
}; };
static struct bgpio_pdata latch2_pdata = { static struct bgpio_pdata latch2_pdata = {
.label = "ams-delta-latch2",
.base = AMS_DELTA_LATCH2_GPIO_BASE, .base = AMS_DELTA_LATCH2_GPIO_BASE,
.ngpio = AMS_DELTA_LATCH2_NGPIO, .ngpio = AMS_DELTA_LATCH2_NGPIO,
}; };
...@@ -274,6 +272,7 @@ static struct regulator_init_data modem_nreset_data = { ...@@ -274,6 +272,7 @@ static struct regulator_init_data modem_nreset_data = {
static struct fixed_voltage_config modem_nreset_config = { static struct fixed_voltage_config modem_nreset_config = {
.supply_name = "modem_nreset", .supply_name = "modem_nreset",
.microvolts = 3300000, .microvolts = 3300000,
.gpio = AMS_DELTA_GPIO_PIN_MODEM_NRESET,
.startup_delay = 25000, .startup_delay = 25000,
.enable_high = 1, .enable_high = 1,
.enabled_at_boot = 1, .enabled_at_boot = 1,
...@@ -288,16 +287,6 @@ static struct platform_device modem_nreset_device = { ...@@ -288,16 +287,6 @@ static struct platform_device modem_nreset_device = {
}, },
}; };
static struct gpiod_lookup_table modem_nreset_gpiod_table = {
.dev_id = "reg-fixed-voltage",
.table = {
/* The AMS_DELTA_GPIO_PIN_MODEM_NRESET is at offset 12 */
GPIO_LOOKUP("ams-delta-latch2", 12,
"enable", GPIO_ACTIVE_HIGH),
{ },
},
};
struct modem_private_data { struct modem_private_data {
struct regulator *regulator; struct regulator *regulator;
}; };
...@@ -581,7 +570,6 @@ static int __init late_init(void) ...@@ -581,7 +570,6 @@ static int __init late_init(void)
platform_add_devices(late_devices, ARRAY_SIZE(late_devices)); platform_add_devices(late_devices, ARRAY_SIZE(late_devices));
gpiod_add_lookup_table(&modem_nreset_gpiod_table);
err = platform_device_register(&modem_nreset_device); err = platform_device_register(&modem_nreset_device);
if (err) { if (err) {
pr_err("Couldn't register the modem regulator device\n"); pr_err("Couldn't register the modem regulator device\n");
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/davinci_emac.h> #include <linux/davinci_emac.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/gpio/machine.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/of_platform.h> #include <linux/of_platform.h>
...@@ -331,6 +330,7 @@ static struct regulator_init_data pandora_vmmc3 = { ...@@ -331,6 +330,7 @@ static struct regulator_init_data pandora_vmmc3 = {
static struct fixed_voltage_config pandora_vwlan = { static struct fixed_voltage_config pandora_vwlan = {
.supply_name = "vwlan", .supply_name = "vwlan",
.microvolts = 1800000, /* 1.8V */ .microvolts = 1800000, /* 1.8V */
.gpio = PANDORA_WIFI_NRESET_GPIO,
.startup_delay = 50000, /* 50ms */ .startup_delay = 50000, /* 50ms */
.enable_high = 1, .enable_high = 1,
.init_data = &pandora_vmmc3, .init_data = &pandora_vmmc3,
...@@ -344,19 +344,6 @@ static struct platform_device pandora_vwlan_device = { ...@@ -344,19 +344,6 @@ static struct platform_device pandora_vwlan_device = {
}, },
}; };
static struct gpiod_lookup_table pandora_vwlan_gpiod_table = {
.dev_id = "reg-fixed-voltage.1",
.table = {
/*
* As this is a low GPIO number it should be at the first
* GPIO bank.
*/
GPIO_LOOKUP("gpio-0-31", PANDORA_WIFI_NRESET_GPIO,
"enable", GPIO_ACTIVE_HIGH),
{ },
},
};
static void pandora_wl1251_init_card(struct mmc_card *card) static void pandora_wl1251_init_card(struct mmc_card *card)
{ {
/* /*
...@@ -418,7 +405,6 @@ static void __init pandora_wl1251_init(void) ...@@ -418,7 +405,6 @@ static void __init pandora_wl1251_init(void)
static void __init omap3_pandora_legacy_init(void) static void __init omap3_pandora_legacy_init(void)
{ {
platform_device_register(&pandora_backlight); platform_device_register(&pandora_backlight);
gpiod_add_lookup_table(&pandora_vwlan_gpiod_table);
platform_device_register(&pandora_vwlan_device); platform_device_register(&pandora_vwlan_device);
omap_hsmmc_init(pandora_mmc3); omap_hsmmc_init(pandora_mmc3);
omap_hsmmc_late_init(pandora_mmc3); omap_hsmmc_late_init(pandora_mmc3);
......
...@@ -987,6 +987,7 @@ static struct fixed_voltage_config camera_dummy_config = { ...@@ -987,6 +987,7 @@ static struct fixed_voltage_config camera_dummy_config = {
.supply_name = "camera_vdd", .supply_name = "camera_vdd",
.input_supply = "vcc cam", .input_supply = "vcc cam",
.microvolts = 2800000, .microvolts = 2800000,
.gpio = -1,
.enable_high = 0, .enable_high = 0,
.init_data = &camera_dummy_initdata, .init_data = &camera_dummy_initdata,
}; };
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include <linux/regulator/fixed.h> #include <linux/regulator/fixed.h>
#include <linux/input.h> #include <linux/input.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/gpio/machine.h>
#include <linux/gpio_keys.h> #include <linux/gpio_keys.h>
#include <linux/leds-lp3944.h> #include <linux/leds-lp3944.h>
#include <linux/platform_data/i2c-pxa.h> #include <linux/platform_data/i2c-pxa.h>
...@@ -699,39 +698,31 @@ static struct pxa27x_keypad_platform_data e2_keypad_platform_data = { ...@@ -699,39 +698,31 @@ static struct pxa27x_keypad_platform_data e2_keypad_platform_data = {
#if defined(CONFIG_MACH_EZX_A780) || defined(CONFIG_MACH_EZX_A910) #if defined(CONFIG_MACH_EZX_A780) || defined(CONFIG_MACH_EZX_A910)
/* camera */ /* camera */
static struct regulator_consumer_supply camera_regulator_supplies[] = { static struct regulator_consumer_supply camera_dummy_supplies[] = {
REGULATOR_SUPPLY("vdd", "0-005d"), REGULATOR_SUPPLY("vdd", "0-005d"),
}; };
static struct regulator_init_data camera_regulator_initdata = { static struct regulator_init_data camera_dummy_initdata = {
.consumer_supplies = camera_regulator_supplies, .consumer_supplies = camera_dummy_supplies,
.num_consumer_supplies = ARRAY_SIZE(camera_regulator_supplies), .num_consumer_supplies = ARRAY_SIZE(camera_dummy_supplies),
.constraints = { .constraints = {
.valid_ops_mask = REGULATOR_CHANGE_STATUS, .valid_ops_mask = REGULATOR_CHANGE_STATUS,
}, },
}; };
static struct fixed_voltage_config camera_regulator_config = { static struct fixed_voltage_config camera_dummy_config = {
.supply_name = "camera_vdd", .supply_name = "camera_vdd",
.microvolts = 2800000, .microvolts = 2800000,
.gpio = GPIO50_nCAM_EN,
.enable_high = 0, .enable_high = 0,
.init_data = &camera_regulator_initdata, .init_data = &camera_dummy_initdata,
}; };
static struct platform_device camera_supply_regulator_device = { static struct platform_device camera_supply_dummy_device = {
.name = "reg-fixed-voltage", .name = "reg-fixed-voltage",
.id = 1, .id = 1,
.dev = { .dev = {
.platform_data = &camera_regulator_config, .platform_data = &camera_dummy_config,
},
};
static struct gpiod_lookup_table camera_supply_gpiod_table = {
.dev_id = "reg-fixed-voltage.1",
.table = {
GPIO_LOOKUP("gpio-pxa", GPIO50_nCAM_EN,
"enable", GPIO_ACTIVE_HIGH),
{ },
}, },
}; };
#endif #endif
...@@ -809,7 +800,7 @@ static struct i2c_board_info a780_i2c_board_info[] = { ...@@ -809,7 +800,7 @@ static struct i2c_board_info a780_i2c_board_info[] = {
static struct platform_device *a780_devices[] __initdata = { static struct platform_device *a780_devices[] __initdata = {
&a780_gpio_keys, &a780_gpio_keys,
&camera_supply_regulator_device, &camera_supply_dummy_device,
}; };
static void __init a780_init(void) static void __init a780_init(void)
...@@ -832,7 +823,6 @@ static void __init a780_init(void) ...@@ -832,7 +823,6 @@ static void __init a780_init(void)
if (a780_camera_init() == 0) if (a780_camera_init() == 0)
pxa_set_camera_info(&a780_pxacamera_platform_data); pxa_set_camera_info(&a780_pxacamera_platform_data);
gpiod_add_lookup_table(&camera_supply_gpiod_table);
pwm_add_table(ezx_pwm_lookup, ARRAY_SIZE(ezx_pwm_lookup)); pwm_add_table(ezx_pwm_lookup, ARRAY_SIZE(ezx_pwm_lookup));
platform_add_devices(ARRAY_AND_SIZE(ezx_devices)); platform_add_devices(ARRAY_AND_SIZE(ezx_devices));
platform_add_devices(ARRAY_AND_SIZE(a780_devices)); platform_add_devices(ARRAY_AND_SIZE(a780_devices));
...@@ -1108,7 +1098,7 @@ static struct i2c_board_info __initdata a910_i2c_board_info[] = { ...@@ -1108,7 +1098,7 @@ static struct i2c_board_info __initdata a910_i2c_board_info[] = {
static struct platform_device *a910_devices[] __initdata = { static struct platform_device *a910_devices[] __initdata = {
&a910_gpio_keys, &a910_gpio_keys,
&camera_supply_regulator_device, &camera_supply_dummy_device,
}; };
static void __init a910_init(void) static void __init a910_init(void)
...@@ -1131,7 +1121,6 @@ static void __init a910_init(void) ...@@ -1131,7 +1121,6 @@ static void __init a910_init(void)
if (a910_camera_init() == 0) if (a910_camera_init() == 0)
pxa_set_camera_info(&a910_pxacamera_platform_data); pxa_set_camera_info(&a910_pxacamera_platform_data);
gpiod_add_lookup_table(&camera_supply_gpiod_table);
pwm_add_table(ezx_pwm_lookup, ARRAY_SIZE(ezx_pwm_lookup)); pwm_add_table(ezx_pwm_lookup, ARRAY_SIZE(ezx_pwm_lookup));
platform_add_devices(ARRAY_AND_SIZE(ezx_devices)); platform_add_devices(ARRAY_AND_SIZE(ezx_devices));
platform_add_devices(ARRAY_AND_SIZE(a910_devices)); platform_add_devices(ARRAY_AND_SIZE(a910_devices));
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/fb.h> #include <linux/fb.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/gpio/machine.h>
#include <linux/gpio_keys.h> #include <linux/gpio_keys.h>
#include <linux/input.h> #include <linux/input.h>
#include <linux/input/navpoint.h> #include <linux/input/navpoint.h>
...@@ -712,6 +711,7 @@ static struct gpio_regulator_state bq24022_states[] = { ...@@ -712,6 +711,7 @@ static struct gpio_regulator_state bq24022_states[] = {
static struct gpio_regulator_config bq24022_info = { static struct gpio_regulator_config bq24022_info = {
.supply_name = "bq24022", .supply_name = "bq24022",
.enable_gpio = GPIO72_HX4700_BQ24022_nCHARGE_EN,
.enable_high = 0, .enable_high = 0,
.enabled_at_boot = 0, .enabled_at_boot = 0,
...@@ -733,15 +733,6 @@ static struct platform_device bq24022 = { ...@@ -733,15 +733,6 @@ static struct platform_device bq24022 = {
}, },
}; };
static struct gpiod_lookup_table bq24022_gpiod_table = {
.dev_id = "gpio-regulator",
.table = {
GPIO_LOOKUP("gpio-pxa", GPIO72_HX4700_BQ24022_nCHARGE_EN,
"enable", GPIO_ACTIVE_HIGH),
{ },
},
};
/* /*
* StrataFlash * StrataFlash
*/ */
...@@ -884,7 +875,6 @@ static void __init hx4700_init(void) ...@@ -884,7 +875,6 @@ static void __init hx4700_init(void)
pxa_set_btuart_info(NULL); pxa_set_btuart_info(NULL);
pxa_set_stuart_info(NULL); pxa_set_stuart_info(NULL);
gpiod_add_lookup_table(&bq24022_gpiod_table);
platform_add_devices(devices, ARRAY_SIZE(devices)); platform_add_devices(devices, ARRAY_SIZE(devices));
pwm_add_table(hx4700_pwm_lookup, ARRAY_SIZE(hx4700_pwm_lookup)); pwm_add_table(hx4700_pwm_lookup, ARRAY_SIZE(hx4700_pwm_lookup));
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/gpio/machine.h>
#include <linux/gpio_keys.h> #include <linux/gpio_keys.h>
#include <linux/input.h> #include <linux/input.h>
#include <linux/mfd/htc-pasic3.h> #include <linux/mfd/htc-pasic3.h>
...@@ -657,6 +656,7 @@ static struct gpio_regulator_state bq24022_states[] = { ...@@ -657,6 +656,7 @@ static struct gpio_regulator_state bq24022_states[] = {
static struct gpio_regulator_config bq24022_info = { static struct gpio_regulator_config bq24022_info = {
.supply_name = "bq24022", .supply_name = "bq24022",
.enable_gpio = GPIO30_MAGICIAN_BQ24022_nCHARGE_EN,
.enable_high = 0, .enable_high = 0,
.enabled_at_boot = 1, .enabled_at_boot = 1,
...@@ -678,15 +678,6 @@ static struct platform_device bq24022 = { ...@@ -678,15 +678,6 @@ static struct platform_device bq24022 = {
}, },
}; };
static struct gpiod_lookup_table bq24022_gpiod_table = {
.dev_id = "gpio-regulator",
.table = {
GPIO_LOOKUP("gpio-pxa", GPIO30_MAGICIAN_BQ24022_nCHARGE_EN,
"enable", GPIO_ACTIVE_HIGH),
{ },
},
};
/* /*
* fixed regulator for ads7846 * fixed regulator for ads7846
*/ */
...@@ -705,6 +696,7 @@ static struct regulator_init_data vads7846_regulator = { ...@@ -705,6 +696,7 @@ static struct regulator_init_data vads7846_regulator = {
static struct fixed_voltage_config vads7846 = { static struct fixed_voltage_config vads7846 = {
.supply_name = "vads7846", .supply_name = "vads7846",
.microvolts = 3300000, /* probably */ .microvolts = 3300000, /* probably */
.gpio = -EINVAL,
.startup_delay = 0, .startup_delay = 0,
.init_data = &vads7846_regulator, .init_data = &vads7846_regulator,
}; };
...@@ -1015,7 +1007,6 @@ static void __init magician_init(void) ...@@ -1015,7 +1007,6 @@ static void __init magician_init(void)
regulator_register_always_on(0, "power", pwm_backlight_supply, regulator_register_always_on(0, "power", pwm_backlight_supply,
ARRAY_SIZE(pwm_backlight_supply), 5000000); ARRAY_SIZE(pwm_backlight_supply), 5000000);
gpiod_add_lookup_table(&bq24022_gpiod_table);
platform_add_devices(ARRAY_AND_SIZE(devices)); platform_add_devices(ARRAY_AND_SIZE(devices));
} }
......
...@@ -886,6 +886,7 @@ static struct regulator_init_data audio_va_initdata = { ...@@ -886,6 +886,7 @@ static struct regulator_init_data audio_va_initdata = {
static struct fixed_voltage_config audio_va_config = { static struct fixed_voltage_config audio_va_config = {
.supply_name = "audio_va", .supply_name = "audio_va",
.microvolts = 5000000, .microvolts = 5000000,
.gpio = GPIO_AUDIO_VA_ENABLE,
.enable_high = 1, .enable_high = 1,
.enabled_at_boot = 0, .enabled_at_boot = 0,
.init_data = &audio_va_initdata, .init_data = &audio_va_initdata,
...@@ -899,15 +900,6 @@ static struct platform_device audio_va_device = { ...@@ -899,15 +900,6 @@ static struct platform_device audio_va_device = {
}, },
}; };
static struct gpiod_lookup_table audio_va_gpiod_table = {
.dev_id = "reg-fixed-voltage.0",
.table = {
GPIO_LOOKUP("gpio-pxa", GPIO_AUDIO_VA_ENABLE,
"enable", GPIO_ACTIVE_HIGH),
{ },
},
};
/* Dummy supplies for Codec's VD/VLC */ /* Dummy supplies for Codec's VD/VLC */
static struct regulator_consumer_supply audio_dummy_supplies[] = { static struct regulator_consumer_supply audio_dummy_supplies[] = {
...@@ -926,6 +918,7 @@ static struct regulator_init_data audio_dummy_initdata = { ...@@ -926,6 +918,7 @@ static struct regulator_init_data audio_dummy_initdata = {
static struct fixed_voltage_config audio_dummy_config = { static struct fixed_voltage_config audio_dummy_config = {
.supply_name = "audio_vd", .supply_name = "audio_vd",
.microvolts = 3300000, .microvolts = 3300000,
.gpio = -1,
.init_data = &audio_dummy_initdata, .init_data = &audio_dummy_initdata,
}; };
...@@ -1040,7 +1033,6 @@ static void __init raumfeld_audio_init(void) ...@@ -1040,7 +1033,6 @@ static void __init raumfeld_audio_init(void)
else else
gpio_direction_output(GPIO_MCLK_RESET, 1); gpio_direction_output(GPIO_MCLK_RESET, 1);
gpiod_add_lookup_table(&audio_va_gpiod_table);
platform_add_devices(ARRAY_AND_SIZE(audio_regulator_devices)); platform_add_devices(ARRAY_AND_SIZE(audio_regulator_devices));
} }
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/pm.h> #include <linux/pm.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/gpio/machine.h>
#include <linux/serial_8250.h> #include <linux/serial_8250.h>
#include <linux/dm9000.h> #include <linux/dm9000.h>
#include <linux/mmc/host.h> #include <linux/mmc/host.h>
...@@ -411,6 +410,7 @@ static struct regulator_init_data can_regulator_init_data = { ...@@ -411,6 +410,7 @@ static struct regulator_init_data can_regulator_init_data = {
static struct fixed_voltage_config can_regulator_pdata = { static struct fixed_voltage_config can_regulator_pdata = {
.supply_name = "CAN_SHDN", .supply_name = "CAN_SHDN",
.microvolts = 3300000, .microvolts = 3300000,
.gpio = ZEUS_CAN_SHDN_GPIO,
.init_data = &can_regulator_init_data, .init_data = &can_regulator_init_data,
}; };
...@@ -422,15 +422,6 @@ static struct platform_device can_regulator_device = { ...@@ -422,15 +422,6 @@ static struct platform_device can_regulator_device = {
}, },
}; };
static struct gpiod_lookup_table can_regulator_gpiod_table = {
.dev_id = "reg-fixed-voltage.0",
.table = {
GPIO_LOOKUP("gpio-pxa", ZEUS_CAN_SHDN_GPIO,
"enable", GPIO_ACTIVE_HIGH),
{ },
},
};
static struct mcp251x_platform_data zeus_mcp2515_pdata = { static struct mcp251x_platform_data zeus_mcp2515_pdata = {
.oscillator_frequency = 16*1000*1000, .oscillator_frequency = 16*1000*1000,
}; };
...@@ -547,6 +538,7 @@ static struct regulator_init_data zeus_ohci_regulator_data = { ...@@ -547,6 +538,7 @@ static struct regulator_init_data zeus_ohci_regulator_data = {
static struct fixed_voltage_config zeus_ohci_regulator_config = { static struct fixed_voltage_config zeus_ohci_regulator_config = {
.supply_name = "vbus2", .supply_name = "vbus2",
.microvolts = 5000000, /* 5.0V */ .microvolts = 5000000, /* 5.0V */
.gpio = ZEUS_USB2_PWREN_GPIO,
.enable_high = 1, .enable_high = 1,
.startup_delay = 0, .startup_delay = 0,
.init_data = &zeus_ohci_regulator_data, .init_data = &zeus_ohci_regulator_data,
...@@ -560,15 +552,6 @@ static struct platform_device zeus_ohci_regulator_device = { ...@@ -560,15 +552,6 @@ static struct platform_device zeus_ohci_regulator_device = {
}, },
}; };
static struct gpiod_lookup_table zeus_ohci_regulator_gpiod_table = {
.dev_id = "reg-fixed-voltage.0",
.table = {
GPIO_LOOKUP("gpio-pxa", ZEUS_USB2_PWREN_GPIO,
"enable", GPIO_ACTIVE_HIGH),
{ },
},
};
static struct pxaohci_platform_data zeus_ohci_platform_data = { static struct pxaohci_platform_data zeus_ohci_platform_data = {
.port_mode = PMM_NPS_MODE, .port_mode = PMM_NPS_MODE,
/* Clear Power Control Polarity Low and set Power Sense /* Clear Power Control Polarity Low and set Power Sense
...@@ -872,8 +855,6 @@ static void __init zeus_init(void) ...@@ -872,8 +855,6 @@ static void __init zeus_init(void)
pxa2xx_mfp_config(ARRAY_AND_SIZE(zeus_pin_config)); pxa2xx_mfp_config(ARRAY_AND_SIZE(zeus_pin_config));
gpiod_add_lookup_table(&can_regulator_gpiod_table);
gpiod_add_lookup_table(&zeus_ohci_regulator_gpiod_table);
platform_add_devices(zeus_devices, ARRAY_SIZE(zeus_devices)); platform_add_devices(zeus_devices, ARRAY_SIZE(zeus_devices));
zeus_register_ohci(); zeus_register_ohci();
......
...@@ -352,6 +352,7 @@ static struct fixed_voltage_config wallvdd_pdata = { ...@@ -352,6 +352,7 @@ static struct fixed_voltage_config wallvdd_pdata = {
.supply_name = "WALLVDD", .supply_name = "WALLVDD",
.microvolts = 5000000, .microvolts = 5000000,
.init_data = &wallvdd_data, .init_data = &wallvdd_data,
.gpio = -EINVAL,
}; };
static struct platform_device wallvdd_device = { static struct platform_device wallvdd_device = {
......
...@@ -222,6 +222,7 @@ static struct fixed_voltage_config smdk6410_b_pwr_5v_pdata = { ...@@ -222,6 +222,7 @@ static struct fixed_voltage_config smdk6410_b_pwr_5v_pdata = {
.supply_name = "B_PWR_5V", .supply_name = "B_PWR_5V",
.microvolts = 5000000, .microvolts = 5000000,
.init_data = &smdk6410_b_pwr_5v_data, .init_data = &smdk6410_b_pwr_5v_data,
.gpio = -EINVAL,
}; };
static struct platform_device smdk6410_b_pwr_5v = { static struct platform_device smdk6410_b_pwr_5v = {
......
...@@ -101,7 +101,7 @@ static int __init assabet_init_gpio(void __iomem *reg, u32 def_val) ...@@ -101,7 +101,7 @@ static int __init assabet_init_gpio(void __iomem *reg, u32 def_val)
assabet_bcr_gc = gc; assabet_bcr_gc = gc;
return 0; return gc->base;
} }
/* /*
...@@ -471,14 +471,6 @@ static struct fixed_voltage_config assabet_cf_vcc_pdata __initdata = { ...@@ -471,14 +471,6 @@ static struct fixed_voltage_config assabet_cf_vcc_pdata __initdata = {
.enable_high = 1, .enable_high = 1,
}; };
static struct gpiod_lookup_table assabet_cf_vcc_gpio_table = {
.dev_id = "reg-fixed-voltage.0",
.table = {
GPIO_LOOKUP("assabet", 0, "enable", GPIO_ACTIVE_HIGH),
{ },
},
};
static void __init assabet_init(void) static void __init assabet_init(void)
{ {
/* /*
...@@ -525,11 +517,9 @@ static void __init assabet_init(void) ...@@ -525,11 +517,9 @@ static void __init assabet_init(void)
neponset_resources, ARRAY_SIZE(neponset_resources)); neponset_resources, ARRAY_SIZE(neponset_resources));
#endif #endif
} else { } else {
gpiod_add_lookup_table(&assabet_cf_vcc_gpio_table);
sa11x0_register_fixed_regulator(0, &assabet_cf_vcc_pdata, sa11x0_register_fixed_regulator(0, &assabet_cf_vcc_pdata,
assabet_cf_vcc_consumers, assabet_cf_vcc_consumers,
ARRAY_SIZE(assabet_cf_vcc_consumers), ARRAY_SIZE(assabet_cf_vcc_consumers));
true);
} }
...@@ -812,6 +802,7 @@ fs_initcall(assabet_leds_init); ...@@ -812,6 +802,7 @@ fs_initcall(assabet_leds_init);
void __init assabet_init_irq(void) void __init assabet_init_irq(void)
{ {
unsigned int assabet_gpio_base;
u32 def_val; u32 def_val;
sa1100_init_irq(); sa1100_init_irq();
...@@ -826,7 +817,9 @@ void __init assabet_init_irq(void) ...@@ -826,7 +817,9 @@ void __init assabet_init_irq(void)
* *
* This must precede any driver calls to BCR_set() or BCR_clear(). * This must precede any driver calls to BCR_set() or BCR_clear().
*/ */
assabet_init_gpio((void *)&ASSABET_BCR, def_val); assabet_gpio_base = assabet_init_gpio((void *)&ASSABET_BCR, def_val);
assabet_cf_vcc_pdata.gpio = assabet_gpio_base + 0;
} }
MACHINE_START(ASSABET, "Intel-Assabet") MACHINE_START(ASSABET, "Intel-Assabet")
......
...@@ -348,8 +348,7 @@ void __init sa11x0_init_late(void) ...@@ -348,8 +348,7 @@ void __init sa11x0_init_late(void)
int __init sa11x0_register_fixed_regulator(int n, int __init sa11x0_register_fixed_regulator(int n,
struct fixed_voltage_config *cfg, struct fixed_voltage_config *cfg,
struct regulator_consumer_supply *supplies, unsigned num_supplies, struct regulator_consumer_supply *supplies, unsigned num_supplies)
bool uses_gpio)
{ {
struct regulator_init_data *id; struct regulator_init_data *id;
...@@ -357,7 +356,7 @@ int __init sa11x0_register_fixed_regulator(int n, ...@@ -357,7 +356,7 @@ int __init sa11x0_register_fixed_regulator(int n,
if (!cfg->init_data) if (!cfg->init_data)
return -ENOMEM; return -ENOMEM;
if (!uses_gpio) if (cfg->gpio < 0)
id->constraints.always_on = 1; id->constraints.always_on = 1;
id->constraints.name = cfg->supply_name; id->constraints.name = cfg->supply_name;
id->constraints.min_uV = cfg->microvolts; id->constraints.min_uV = cfg->microvolts;
......
...@@ -54,5 +54,4 @@ void sa11x0_register_pcmcia(int socket, struct gpiod_lookup_table *); ...@@ -54,5 +54,4 @@ void sa11x0_register_pcmcia(int socket, struct gpiod_lookup_table *);
struct fixed_voltage_config; struct fixed_voltage_config;
struct regulator_consumer_supply; struct regulator_consumer_supply;
int sa11x0_register_fixed_regulator(int n, struct fixed_voltage_config *cfg, int sa11x0_register_fixed_regulator(int n, struct fixed_voltage_config *cfg,
struct regulator_consumer_supply *supplies, unsigned num_supplies, struct regulator_consumer_supply *supplies, unsigned num_supplies);
bool uses_gpio);
...@@ -102,14 +102,14 @@ static struct fixed_voltage_config shannon_cf_vcc_pdata __initdata = { ...@@ -102,14 +102,14 @@ static struct fixed_voltage_config shannon_cf_vcc_pdata __initdata = {
.supply_name = "cf-power", .supply_name = "cf-power",
.microvolts = 3300000, .microvolts = 3300000,
.enabled_at_boot = 1, .enabled_at_boot = 1,
.gpio = -EINVAL,
}; };
static void __init shannon_init(void) static void __init shannon_init(void)
{ {
sa11x0_register_fixed_regulator(0, &shannon_cf_vcc_pdata, sa11x0_register_fixed_regulator(0, &shannon_cf_vcc_pdata,
shannon_cf_vcc_consumers, shannon_cf_vcc_consumers,
ARRAY_SIZE(shannon_cf_vcc_consumers), ARRAY_SIZE(shannon_cf_vcc_consumers));
false);
sa11x0_register_pcmcia(0, &shannon_pcmcia0_gpio_table); sa11x0_register_pcmcia(0, &shannon_pcmcia0_gpio_table);
sa11x0_register_pcmcia(1, &shannon_pcmcia1_gpio_table); sa11x0_register_pcmcia(1, &shannon_pcmcia1_gpio_table);
sa11x0_ppc_configure_mcp(); sa11x0_ppc_configure_mcp();
......
...@@ -633,6 +633,7 @@ static struct regulator_init_data cn12_power_init_data = { ...@@ -633,6 +633,7 @@ static struct regulator_init_data cn12_power_init_data = {
static struct fixed_voltage_config cn12_power_info = { static struct fixed_voltage_config cn12_power_info = {
.supply_name = "CN12 SD/MMC Vdd", .supply_name = "CN12 SD/MMC Vdd",
.microvolts = 3300000, .microvolts = 3300000,
.gpio = GPIO_PTB7,
.enable_high = 1, .enable_high = 1,
.init_data = &cn12_power_init_data, .init_data = &cn12_power_init_data,
}; };
...@@ -645,16 +646,6 @@ static struct platform_device cn12_power = { ...@@ -645,16 +646,6 @@ static struct platform_device cn12_power = {
}, },
}; };
static struct gpiod_lookup_table cn12_power_gpiod_table = {
.dev_id = "reg-fixed-voltage.0",
.table = {
/* Offset 7 on port B */
GPIO_LOOKUP("sh7724_pfc", GPIO_PTB7,
"enable", GPIO_ACTIVE_HIGH),
{ },
},
};
#if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE) #if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)
/* SDHI0 */ /* SDHI0 */
static struct regulator_consumer_supply sdhi0_power_consumers[] = static struct regulator_consumer_supply sdhi0_power_consumers[] =
...@@ -674,6 +665,7 @@ static struct regulator_init_data sdhi0_power_init_data = { ...@@ -674,6 +665,7 @@ static struct regulator_init_data sdhi0_power_init_data = {
static struct fixed_voltage_config sdhi0_power_info = { static struct fixed_voltage_config sdhi0_power_info = {
.supply_name = "CN11 SD/MMC Vdd", .supply_name = "CN11 SD/MMC Vdd",
.microvolts = 3300000, .microvolts = 3300000,
.gpio = GPIO_PTB6,
.enable_high = 1, .enable_high = 1,
.init_data = &sdhi0_power_init_data, .init_data = &sdhi0_power_init_data,
}; };
...@@ -686,16 +678,6 @@ static struct platform_device sdhi0_power = { ...@@ -686,16 +678,6 @@ static struct platform_device sdhi0_power = {
}, },
}; };
static struct gpiod_lookup_table sdhi0_power_gpiod_table = {
.dev_id = "reg-fixed-voltage.1",
.table = {
/* Offset 6 on port B */
GPIO_LOOKUP("sh7724_pfc", GPIO_PTB6,
"enable", GPIO_ACTIVE_HIGH),
{ },
},
};
static struct tmio_mmc_data sdhi0_info = { static struct tmio_mmc_data sdhi0_info = {
.chan_priv_tx = (void *)SHDMA_SLAVE_SDHI0_TX, .chan_priv_tx = (void *)SHDMA_SLAVE_SDHI0_TX,
.chan_priv_rx = (void *)SHDMA_SLAVE_SDHI0_RX, .chan_priv_rx = (void *)SHDMA_SLAVE_SDHI0_RX,
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* of the License. * of the License.
*/ */
#include <linux/gpio/machine.h> #include <linux/gpio.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/regulator/machine.h> #include <linux/regulator/machine.h>
#include <linux/regulator/fixed.h> #include <linux/regulator/fixed.h>
...@@ -43,6 +43,7 @@ static struct fixed_voltage_config bcm43xx_vmmc = { ...@@ -43,6 +43,7 @@ static struct fixed_voltage_config bcm43xx_vmmc = {
* real voltage and signaling are still 1.8V. * real voltage and signaling are still 1.8V.
*/ */
.microvolts = 2000000, /* 1.8V */ .microvolts = 2000000, /* 1.8V */
.gpio = -EINVAL,
.startup_delay = 250 * 1000, /* 250ms */ .startup_delay = 250 * 1000, /* 250ms */
.enable_high = 1, /* active high */ .enable_high = 1, /* active high */
.enabled_at_boot = 0, /* disabled at boot */ .enabled_at_boot = 0, /* disabled at boot */
...@@ -57,23 +58,11 @@ static struct platform_device bcm43xx_vmmc_regulator = { ...@@ -57,23 +58,11 @@ static struct platform_device bcm43xx_vmmc_regulator = {
}, },
}; };
static struct gpiod_lookup_table bcm43xx_vmmc_gpio_table = {
.dev_id = "reg-fixed-voltage.0",
.table = {
GPIO_LOOKUP("0000:00:0c.0", -1, "enable", GPIO_ACTIVE_LOW),
{}
},
};
static int __init bcm43xx_regulator_register(void) static int __init bcm43xx_regulator_register(void)
{ {
struct gpiod_lookup_table *table = &bcm43xx_vmmc_gpio_table;
struct gpiod_lookup *lookup = table->table;
int ret; int ret;
lookup[0].chip_hwnum = get_gpio_by_name(WLAN_SFI_GPIO_ENABLE_NAME); bcm43xx_vmmc.gpio = get_gpio_by_name(WLAN_SFI_GPIO_ENABLE_NAME);
gpiod_add_lookup_table(table);
ret = platform_device_register(&bcm43xx_vmmc_regulator); ret = platform_device_register(&bcm43xx_vmmc_regulator);
if (ret) { if (ret) {
pr_err("%s: vmmc regulator register failed\n", __func__); pr_err("%s: vmmc regulator register failed\n", __func__);
......
...@@ -43,6 +43,7 @@ struct platform_device *regulator_register_always_on(int id, const char *name, ...@@ -43,6 +43,7 @@ struct platform_device *regulator_register_always_on(int id, const char *name,
} }
data->cfg.microvolts = uv; data->cfg.microvolts = uv;
data->cfg.gpio = -EINVAL;
data->cfg.enabled_at_boot = 1; data->cfg.enabled_at_boot = 1;
data->cfg.init_data = &data->init_data; data->cfg.init_data = &data->init_data;
......
...@@ -24,9 +24,10 @@ ...@@ -24,9 +24,10 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/regulator/driver.h> #include <linux/regulator/driver.h>
#include <linux/regulator/fixed.h> #include <linux/regulator/fixed.h>
#include <linux/gpio/consumer.h> #include <linux/gpio.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_gpio.h>
#include <linux/regulator/of_regulator.h> #include <linux/regulator/of_regulator.h>
#include <linux/regulator/machine.h> #include <linux/regulator/machine.h>
...@@ -77,6 +78,10 @@ of_get_fixed_voltage_config(struct device *dev, ...@@ -77,6 +78,10 @@ of_get_fixed_voltage_config(struct device *dev,
if (init_data->constraints.boot_on) if (init_data->constraints.boot_on)
config->enabled_at_boot = true; config->enabled_at_boot = true;
config->gpio = of_get_named_gpio(np, "gpio", 0);
if ((config->gpio < 0) && (config->gpio != -ENOENT))
return ERR_PTR(config->gpio);
of_property_read_u32(np, "startup-delay-us", &config->startup_delay); of_property_read_u32(np, "startup-delay-us", &config->startup_delay);
config->enable_high = of_property_read_bool(np, "enable-active-high"); config->enable_high = of_property_read_bool(np, "enable-active-high");
...@@ -97,7 +102,6 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev) ...@@ -97,7 +102,6 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
struct fixed_voltage_config *config; struct fixed_voltage_config *config;
struct fixed_voltage_data *drvdata; struct fixed_voltage_data *drvdata;
struct regulator_config cfg = { }; struct regulator_config cfg = { };
enum gpiod_flags gflags;
int ret; int ret;
drvdata = devm_kzalloc(&pdev->dev, sizeof(struct fixed_voltage_data), drvdata = devm_kzalloc(&pdev->dev, sizeof(struct fixed_voltage_data),
...@@ -146,28 +150,25 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev) ...@@ -146,28 +150,25 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
drvdata->desc.fixed_uV = config->microvolts; drvdata->desc.fixed_uV = config->microvolts;
if (gpio_is_valid(config->gpio)) {
cfg.ena_gpio = config->gpio;
if (pdev->dev.of_node)
cfg.ena_gpio_initialized = true;
}
cfg.ena_gpio_invert = !config->enable_high; cfg.ena_gpio_invert = !config->enable_high;
if (config->enabled_at_boot) { if (config->enabled_at_boot) {
if (config->enable_high) if (config->enable_high)
gflags = GPIOD_OUT_HIGH; cfg.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH;
else else
gflags = GPIOD_OUT_LOW; cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW;
} else { } else {
if (config->enable_high) if (config->enable_high)
gflags = GPIOD_OUT_LOW; cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW;
else else
gflags = GPIOD_OUT_HIGH; cfg.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH;
} }
if (config->gpio_is_open_drain) { if (config->gpio_is_open_drain)
if (gflags == GPIOD_OUT_HIGH) cfg.ena_gpio_flags |= GPIOF_OPEN_DRAIN;
gflags = GPIOD_OUT_HIGH_OPEN_DRAIN;
else
gflags = GPIOD_OUT_LOW_OPEN_DRAIN;
}
cfg.ena_gpiod = devm_gpiod_get_optional(&pdev->dev, NULL, gflags);
if (IS_ERR(cfg.ena_gpiod))
return PTR_ERR(cfg.ena_gpiod);
cfg.dev = &pdev->dev; cfg.dev = &pdev->dev;
cfg.init_data = config->init_data; cfg.init_data = config->init_data;
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include <linux/regulator/of_regulator.h> #include <linux/regulator/of_regulator.h>
#include <linux/regulator/gpio-regulator.h> #include <linux/regulator/gpio-regulator.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/gpio/consumer.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_gpio.h> #include <linux/of_gpio.h>
...@@ -162,6 +161,10 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np, ...@@ -162,6 +161,10 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np,
of_property_read_u32(np, "startup-delay-us", &config->startup_delay); of_property_read_u32(np, "startup-delay-us", &config->startup_delay);
config->enable_gpio = of_get_named_gpio(np, "enable-gpio", 0);
if (config->enable_gpio < 0 && config->enable_gpio != -ENOENT)
return ERR_PTR(config->enable_gpio);
/* Fetch GPIOs. - optional property*/ /* Fetch GPIOs. - optional property*/
ret = of_gpio_count(np); ret = of_gpio_count(np);
if ((ret < 0) && (ret != -ENOENT)) if ((ret < 0) && (ret != -ENOENT))
...@@ -252,7 +255,6 @@ static int gpio_regulator_probe(struct platform_device *pdev) ...@@ -252,7 +255,6 @@ static int gpio_regulator_probe(struct platform_device *pdev)
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
struct gpio_regulator_data *drvdata; struct gpio_regulator_data *drvdata;
struct regulator_config cfg = { }; struct regulator_config cfg = { };
enum gpiod_flags gflags;
int ptr, ret, state; int ptr, ret, state;
drvdata = devm_kzalloc(&pdev->dev, sizeof(struct gpio_regulator_data), drvdata = devm_kzalloc(&pdev->dev, sizeof(struct gpio_regulator_data),
...@@ -338,22 +340,21 @@ static int gpio_regulator_probe(struct platform_device *pdev) ...@@ -338,22 +340,21 @@ static int gpio_regulator_probe(struct platform_device *pdev)
cfg.driver_data = drvdata; cfg.driver_data = drvdata;
cfg.of_node = np; cfg.of_node = np;
if (gpio_is_valid(config->enable_gpio)) {
cfg.ena_gpio = config->enable_gpio;
cfg.ena_gpio_initialized = true;
}
cfg.ena_gpio_invert = !config->enable_high; cfg.ena_gpio_invert = !config->enable_high;
if (config->enabled_at_boot) { if (config->enabled_at_boot) {
if (config->enable_high) if (config->enable_high)
gflags = GPIOD_OUT_HIGH; cfg.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH;
else else
gflags = GPIOD_OUT_LOW; cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW;
} else { } else {
if (config->enable_high) if (config->enable_high)
gflags = GPIOD_OUT_LOW; cfg.ena_gpio_flags |= GPIOF_OUT_INIT_LOW;
else else
gflags = GPIOD_OUT_HIGH; cfg.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH;
}
cfg.ena_gpiod = devm_gpiod_get_optional(&pdev->dev, "enable", gflags);
if (IS_ERR(cfg.ena_gpiod)) {
ret = PTR_ERR(cfg.ena_gpiod);
goto err_stategpio;
} }
drvdata->dev = regulator_register(&drvdata->desc, &cfg); drvdata->dev = regulator_register(&drvdata->desc, &cfg);
......
...@@ -24,6 +24,8 @@ struct regulator_init_data; ...@@ -24,6 +24,8 @@ struct regulator_init_data;
* @supply_name: Name of the regulator supply * @supply_name: Name of the regulator supply
* @input_supply: Name of the input regulator supply * @input_supply: Name of the input regulator supply
* @microvolts: Output voltage of regulator * @microvolts: Output voltage of regulator
* @gpio: GPIO to use for enable control
* set to -EINVAL if not used
* @startup_delay: Start-up time in microseconds * @startup_delay: Start-up time in microseconds
* @gpio_is_open_drain: Gpio pin is open drain or normal type. * @gpio_is_open_drain: Gpio pin is open drain or normal type.
* If it is open drain type then HIGH will be set * If it is open drain type then HIGH will be set
...@@ -47,6 +49,7 @@ struct fixed_voltage_config { ...@@ -47,6 +49,7 @@ struct fixed_voltage_config {
const char *supply_name; const char *supply_name;
const char *input_supply; const char *input_supply;
int microvolts; int microvolts;
int gpio;
unsigned startup_delay; unsigned startup_delay;
unsigned gpio_is_open_drain:1; unsigned gpio_is_open_drain:1;
unsigned enable_high:1; unsigned enable_high:1;
......
...@@ -44,6 +44,8 @@ struct gpio_regulator_state { ...@@ -44,6 +44,8 @@ struct gpio_regulator_state {
/** /**
* struct gpio_regulator_config - config structure * struct gpio_regulator_config - config structure
* @supply_name: Name of the regulator supply * @supply_name: Name of the regulator supply
* @enable_gpio: GPIO to use for enable control
* set to -EINVAL if not used
* @enable_high: Polarity of enable GPIO * @enable_high: Polarity of enable GPIO
* 1 = Active high, 0 = Active low * 1 = Active high, 0 = Active low
* @enabled_at_boot: Whether regulator has been enabled at * @enabled_at_boot: Whether regulator has been enabled at
...@@ -67,6 +69,7 @@ struct gpio_regulator_state { ...@@ -67,6 +69,7 @@ struct gpio_regulator_state {
struct gpio_regulator_config { struct gpio_regulator_config {
const char *supply_name; const char *supply_name;
int enable_gpio;
unsigned enable_high:1; unsigned enable_high:1;
unsigned enabled_at_boot:1; unsigned enabled_at_boot:1;
unsigned startup_delay; unsigned startup_delay;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment