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. Cc: Alexander Shiyan <shc_work@mail.ru> # i.MX boards user Cc: Haojian Zhuang <haojian.zhuang@gmail.com> # MMP2 maintainer Cc: Aaro Koskinen <aaro.koskinen@iki.fi> # OMAP1 maintainer Cc: Tony Lindgren <tony@atomide.com> # OMAP1,2,3 maintainer Cc: Mike Rapoport <rppt@linux.vnet.ibm.com> # EM-X270 maintainer Cc: Robert Jarzmik <robert.jarzmik@free.fr> # EZX maintainer Cc: Philipp Zabel <philipp.zabel@gmail.com> # Magician maintainer Cc: Petr Cvek <petr.cvek@tul.cz> # Magician Cc: Robert Jarzmik <robert.jarzmik@free.fr> # PXA Cc: Paul Parsons <lost.distance@yahoo.com> # hx4700 Cc: Daniel Mack <zonque@gmail.com> # Raumfeld maintainer Cc: Marc Zyngier <marc.zyngier@arm.com> # Zeus maintainer Cc: Geert Uytterhoeven <geert+renesas@glider.be> # SuperH pinctrl/GPIO maintainer Cc: Russell King <rmk+kernel@armlinux.org.uk> # SA1100 Tested-by: Marek Szyprowski <m.szyprowski@samsung.com> Tested-by: Janusz Krzysztofik <jmkrzyszt@gmail.com> #OMAP1 Amstrad Delta Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
d6cd33ad71
commit
01dc79cd6f
|
@ -205,7 +205,6 @@ 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,
|
||||||
.enable_high = 1,
|
|
||||||
.init_data = &mx21ads_lcd_regulator_init_data,
|
.init_data = &mx21ads_lcd_regulator_init_data,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -237,7 +237,7 @@ static struct fixed_voltage_config mx27ads_lcd_regulator_pdata = {
|
||||||
static struct gpiod_lookup_table mx27ads_lcd_regulator_gpiod_table = {
|
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 */
|
.dev_id = "reg-fixed-voltage.0", /* Let's hope ID 0 is what we get */
|
||||||
.table = {
|
.table = {
|
||||||
GPIO_LOOKUP("LCD", 0, NULL, GPIO_ACTIVE_HIGH),
|
GPIO_LOOKUP("LCD", 0, NULL, GPIO_ACTIVE_LOW),
|
||||||
{ },
|
{ },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -149,7 +149,6 @@ 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,
|
||||||
.enable_high = 1,
|
|
||||||
.enabled_at_boot = 1,
|
.enabled_at_boot = 1,
|
||||||
.init_data = &brownstone_v_5vp_data,
|
.init_data = &brownstone_v_5vp_data,
|
||||||
};
|
};
|
||||||
|
|
|
@ -267,7 +267,6 @@ static struct fixed_voltage_config modem_nreset_config = {
|
||||||
.supply_name = "modem_nreset",
|
.supply_name = "modem_nreset",
|
||||||
.microvolts = 3300000,
|
.microvolts = 3300000,
|
||||||
.startup_delay = 25000,
|
.startup_delay = 25000,
|
||||||
.enable_high = 1,
|
|
||||||
.enabled_at_boot = 1,
|
.enabled_at_boot = 1,
|
||||||
.init_data = &modem_nreset_data,
|
.init_data = &modem_nreset_data,
|
||||||
};
|
};
|
||||||
|
@ -533,7 +532,6 @@ static struct regulator_init_data keybrd_pwr_initdata = {
|
||||||
static struct fixed_voltage_config keybrd_pwr_config = {
|
static struct fixed_voltage_config keybrd_pwr_config = {
|
||||||
.supply_name = "keybrd_pwr",
|
.supply_name = "keybrd_pwr",
|
||||||
.microvolts = 5000000,
|
.microvolts = 5000000,
|
||||||
.enable_high = 1,
|
|
||||||
.init_data = &keybrd_pwr_initdata,
|
.init_data = &keybrd_pwr_initdata,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -330,7 +330,6 @@ static struct fixed_voltage_config pandora_vwlan = {
|
||||||
.supply_name = "vwlan",
|
.supply_name = "vwlan",
|
||||||
.microvolts = 1800000, /* 1.8V */
|
.microvolts = 1800000, /* 1.8V */
|
||||||
.startup_delay = 50000, /* 50ms */
|
.startup_delay = 50000, /* 50ms */
|
||||||
.enable_high = 1,
|
|
||||||
.init_data = &pandora_vmmc3,
|
.init_data = &pandora_vmmc3,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -976,7 +976,6 @@ 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,
|
||||||
.enable_high = 0,
|
|
||||||
.init_data = &camera_dummy_initdata,
|
.init_data = &camera_dummy_initdata,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -714,7 +714,6 @@ static struct regulator_init_data camera_regulator_initdata = {
|
||||||
static struct fixed_voltage_config camera_regulator_config = {
|
static struct fixed_voltage_config camera_regulator_config = {
|
||||||
.supply_name = "camera_vdd",
|
.supply_name = "camera_vdd",
|
||||||
.microvolts = 2800000,
|
.microvolts = 2800000,
|
||||||
.enable_high = 0,
|
|
||||||
.init_data = &camera_regulator_initdata,
|
.init_data = &camera_regulator_initdata,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -730,7 +729,7 @@ static struct gpiod_lookup_table camera_supply_gpiod_table = {
|
||||||
.dev_id = "reg-fixed-voltage.1",
|
.dev_id = "reg-fixed-voltage.1",
|
||||||
.table = {
|
.table = {
|
||||||
GPIO_LOOKUP("gpio-pxa", GPIO50_nCAM_EN,
|
GPIO_LOOKUP("gpio-pxa", GPIO50_nCAM_EN,
|
||||||
NULL, GPIO_ACTIVE_HIGH),
|
NULL, GPIO_ACTIVE_LOW),
|
||||||
{ },
|
{ },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -883,7 +883,6 @@ 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,
|
||||||
.enable_high = 1,
|
|
||||||
.enabled_at_boot = 0,
|
.enabled_at_boot = 0,
|
||||||
.init_data = &audio_va_initdata,
|
.init_data = &audio_va_initdata,
|
||||||
};
|
};
|
||||||
|
|
|
@ -426,7 +426,7 @@ static struct gpiod_lookup_table can_regulator_gpiod_table = {
|
||||||
.dev_id = "reg-fixed-voltage.0",
|
.dev_id = "reg-fixed-voltage.0",
|
||||||
.table = {
|
.table = {
|
||||||
GPIO_LOOKUP("gpio-pxa", ZEUS_CAN_SHDN_GPIO,
|
GPIO_LOOKUP("gpio-pxa", ZEUS_CAN_SHDN_GPIO,
|
||||||
NULL, GPIO_ACTIVE_HIGH),
|
NULL, GPIO_ACTIVE_LOW),
|
||||||
{ },
|
{ },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -547,7 +547,6 @@ 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 */
|
||||||
.enable_high = 1,
|
|
||||||
.startup_delay = 0,
|
.startup_delay = 0,
|
||||||
.init_data = &zeus_ohci_regulator_data,
|
.init_data = &zeus_ohci_regulator_data,
|
||||||
};
|
};
|
||||||
|
|
|
@ -469,7 +469,6 @@ static struct regulator_consumer_supply assabet_cf_vcc_consumers[] = {
|
||||||
static struct fixed_voltage_config assabet_cf_vcc_pdata __initdata = {
|
static struct fixed_voltage_config assabet_cf_vcc_pdata __initdata = {
|
||||||
.supply_name = "cf-power",
|
.supply_name = "cf-power",
|
||||||
.microvolts = 3300000,
|
.microvolts = 3300000,
|
||||||
.enable_high = 1,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct gpiod_lookup_table assabet_cf_vcc_gpio_table = {
|
static struct gpiod_lookup_table assabet_cf_vcc_gpio_table = {
|
||||||
|
|
|
@ -630,7 +630,6 @@ 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,
|
||||||
.enable_high = 1,
|
|
||||||
.init_data = &cn12_power_init_data,
|
.init_data = &cn12_power_init_data,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -671,7 +670,6 @@ 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,
|
||||||
.enable_high = 1,
|
|
||||||
.init_data = &sdhi0_power_init_data,
|
.init_data = &sdhi0_power_init_data,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,6 @@ static struct fixed_voltage_config bcm43xx_vmmc = {
|
||||||
*/
|
*/
|
||||||
.microvolts = 2000000, /* 1.8V */
|
.microvolts = 2000000, /* 1.8V */
|
||||||
.startup_delay = 250 * 1000, /* 250ms */
|
.startup_delay = 250 * 1000, /* 250ms */
|
||||||
.enable_high = 1, /* active high */
|
|
||||||
.enabled_at_boot = 0, /* disabled at boot */
|
.enabled_at_boot = 0, /* disabled at boot */
|
||||||
.init_data = &bcm43xx_vmmc_data,
|
.init_data = &bcm43xx_vmmc_data,
|
||||||
};
|
};
|
||||||
|
|
|
@ -82,7 +82,6 @@ struct regulator_enable_gpio {
|
||||||
struct gpio_desc *gpiod;
|
struct gpio_desc *gpiod;
|
||||||
u32 enable_count; /* a number of enabled shared GPIO */
|
u32 enable_count; /* a number of enabled shared GPIO */
|
||||||
u32 request_count; /* a number of requested shared GPIO */
|
u32 request_count; /* a number of requested shared GPIO */
|
||||||
unsigned int ena_gpio_invert:1;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2268,7 +2267,6 @@ static int regulator_ena_gpio_request(struct regulator_dev *rdev,
|
||||||
}
|
}
|
||||||
|
|
||||||
pin->gpiod = gpiod;
|
pin->gpiod = gpiod;
|
||||||
pin->ena_gpio_invert = config->ena_gpio_invert;
|
|
||||||
list_add(&pin->list, ®ulator_ena_gpio_list);
|
list_add(&pin->list, ®ulator_ena_gpio_list);
|
||||||
|
|
||||||
update_ena_gpio_to_rdev:
|
update_ena_gpio_to_rdev:
|
||||||
|
@ -2319,8 +2317,7 @@ static int regulator_ena_gpio_ctrl(struct regulator_dev *rdev, bool enable)
|
||||||
if (enable) {
|
if (enable) {
|
||||||
/* Enable GPIO at initial use */
|
/* Enable GPIO at initial use */
|
||||||
if (pin->enable_count == 0)
|
if (pin->enable_count == 0)
|
||||||
gpiod_set_value_cansleep(pin->gpiod,
|
gpiod_set_value_cansleep(pin->gpiod, 1);
|
||||||
!pin->ena_gpio_invert);
|
|
||||||
|
|
||||||
pin->enable_count++;
|
pin->enable_count++;
|
||||||
} else {
|
} else {
|
||||||
|
@ -2331,8 +2328,7 @@ static int regulator_ena_gpio_ctrl(struct regulator_dev *rdev, bool enable)
|
||||||
|
|
||||||
/* Disable GPIO if not used */
|
/* Disable GPIO if not used */
|
||||||
if (pin->enable_count <= 1) {
|
if (pin->enable_count <= 1) {
|
||||||
gpiod_set_value_cansleep(pin->gpiod,
|
gpiod_set_value_cansleep(pin->gpiod, 0);
|
||||||
pin->ena_gpio_invert);
|
|
||||||
pin->enable_count = 0;
|
pin->enable_count = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -457,7 +457,6 @@ static int da9055_gpio_init(struct da9055_regulator *regulator,
|
||||||
int gpio_mux = pdata->gpio_ren[id];
|
int gpio_mux = pdata->gpio_ren[id];
|
||||||
|
|
||||||
config->ena_gpiod = pdata->ena_gpiods[id];
|
config->ena_gpiod = pdata->ena_gpiods[id];
|
||||||
config->ena_gpio_invert = 1;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GPI pin is muxed with regulator to control the
|
* GPI pin is muxed with regulator to control the
|
||||||
|
|
|
@ -79,15 +79,6 @@ of_get_fixed_voltage_config(struct device *dev,
|
||||||
|
|
||||||
of_property_read_u32(np, "startup-delay-us", &config->startup_delay);
|
of_property_read_u32(np, "startup-delay-us", &config->startup_delay);
|
||||||
|
|
||||||
/*
|
|
||||||
* FIXME: we pulled active low/high and open drain handling into
|
|
||||||
* gpiolib so it will be handled there. Delete this in the second
|
|
||||||
* step when we also remove the custom inversion handling for all
|
|
||||||
* legacy boardfiles.
|
|
||||||
*/
|
|
||||||
config->enable_high = 1;
|
|
||||||
config->gpio_is_open_drain = 0;
|
|
||||||
|
|
||||||
if (of_find_property(np, "vin-supply", NULL))
|
if (of_find_property(np, "vin-supply", NULL))
|
||||||
config->input_supply = "vin";
|
config->input_supply = "vin";
|
||||||
|
|
||||||
|
@ -151,24 +142,14 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
drvdata->desc.fixed_uV = config->microvolts;
|
drvdata->desc.fixed_uV = config->microvolts;
|
||||||
|
|
||||||
cfg.ena_gpio_invert = !config->enable_high;
|
/*
|
||||||
if (config->enabled_at_boot) {
|
* The signal will be inverted by the GPIO core if flagged so in the
|
||||||
if (config->enable_high)
|
* decriptor.
|
||||||
gflags = GPIOD_OUT_HIGH;
|
*/
|
||||||
else
|
if (config->enabled_at_boot)
|
||||||
gflags = GPIOD_OUT_LOW;
|
gflags = GPIOD_OUT_HIGH;
|
||||||
} else {
|
else
|
||||||
if (config->enable_high)
|
gflags = GPIOD_OUT_LOW;
|
||||||
gflags = GPIOD_OUT_LOW;
|
|
||||||
else
|
|
||||||
gflags = GPIOD_OUT_HIGH;
|
|
||||||
}
|
|
||||||
if (config->gpio_is_open_drain) {
|
|
||||||
if (gflags == GPIOD_OUT_HIGH)
|
|
||||||
gflags = GPIOD_OUT_HIGH_OPEN_DRAIN;
|
|
||||||
else
|
|
||||||
gflags = GPIOD_OUT_LOW_OPEN_DRAIN;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Some fixed regulators share the enable line between two
|
* Some fixed regulators share the enable line between two
|
||||||
|
|
|
@ -25,14 +25,6 @@ struct regulator_init_data;
|
||||||
* @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
|
||||||
* @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.
|
|
||||||
* If it is open drain type then HIGH will be set
|
|
||||||
* through PULL-UP with setting gpio as input
|
|
||||||
* and low will be set as gpio-output with driven
|
|
||||||
* to low. For non-open-drain case, the gpio will
|
|
||||||
* will be in output and drive to low/high accordingly.
|
|
||||||
* @enable_high: Polarity of enable GPIO
|
|
||||||
* 1 = Active high, 0 = Active low
|
|
||||||
* @enabled_at_boot: Whether regulator has been enabled at
|
* @enabled_at_boot: Whether regulator has been enabled at
|
||||||
* boot or not. 1 = Yes, 0 = No
|
* boot or not. 1 = Yes, 0 = No
|
||||||
* This is used to keep the regulator at
|
* This is used to keep the regulator at
|
||||||
|
@ -48,8 +40,6 @@ struct fixed_voltage_config {
|
||||||
const char *input_supply;
|
const char *input_supply;
|
||||||
int microvolts;
|
int microvolts;
|
||||||
unsigned startup_delay;
|
unsigned startup_delay;
|
||||||
unsigned gpio_is_open_drain:1;
|
|
||||||
unsigned enable_high:1;
|
|
||||||
unsigned enabled_at_boot:1;
|
unsigned enabled_at_boot:1;
|
||||||
struct regulator_init_data *init_data;
|
struct regulator_init_data *init_data;
|
||||||
};
|
};
|
||||||
|
|
|
@ -46,10 +46,6 @@ 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
|
|
||||||
* 1 = Active high, 0 = Active low
|
|
||||||
* @enabled_at_boot: Whether regulator has been enabled at
|
* @enabled_at_boot: Whether regulator has been enabled at
|
||||||
* boot or not. 1 = Yes, 0 = No
|
* boot or not. 1 = Yes, 0 = No
|
||||||
* This is used to keep the regulator at
|
* This is used to keep the regulator at
|
||||||
|
@ -71,8 +67,6 @@ 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 enabled_at_boot:1;
|
unsigned enabled_at_boot:1;
|
||||||
unsigned startup_delay;
|
unsigned startup_delay;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue