Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit efdfeb07 authored by Linus Walleij's avatar Linus Walleij Committed by Mark Brown
Browse files

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: default avatarLinus Walleij <linus.walleij@linaro.org>
Reviewed-by: default avatarJanusz Krzysztofik <jmkrzyszt@gmail.com>
Reviewed-by: default avatarMike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 1efef7cc
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#include <linux/mtd/mtd.h>
#include <linux/mtd/physmap.h>
#include <linux/gpio/driver.h>
#include <linux/gpio/machine.h>
#include <linux/gpio.h>
#include <linux/regulator/fixed.h>
#include <linux/regulator/machine.h>
@@ -175,6 +176,7 @@ static struct resource mx21ads_mmgpio_resource =
	DEFINE_RES_MEM_NAMED(MX21ADS_IO_REG, SZ_2, "dat");

static struct bgpio_pdata mx21ads_mmgpio_pdata = {
	.label	= "mx21ads-mmgpio",
	.base	= MX21ADS_MMGPIO_BASE,
	.ngpio	= 16,
};
@@ -203,7 +205,6 @@ static struct regulator_init_data mx21ads_lcd_regulator_init_data = {
static struct fixed_voltage_config mx21ads_lcd_regulator_pdata = {
	.supply_name	= "LCD",
	.microvolts	= 3300000,
	.gpio		= MX21ADS_IO_LCDON,
	.enable_high	= 1,
	.init_data	= &mx21ads_lcd_regulator_init_data,
};
@@ -216,6 +217,14 @@ 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, NULL, GPIO_ACTIVE_HIGH),
		{ },
	},
};

/*
 * Connected is a portrait Sharp-QVGA display
 * of type: LQ035Q7DB02
@@ -311,6 +320,7 @@ static void __init mx21ads_late_init(void)
{
	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));

	mx21ads_cs8900_resources[1].start =
+11 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
#include <linux/gpio/driver.h>
/* Needed for gpio_to_irq() */
#include <linux/gpio.h>
#include <linux/gpio/machine.h>
#include <linux/platform_device.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/map.h>
@@ -230,10 +231,17 @@ static struct regulator_init_data mx27ads_lcd_regulator_init_data = {
static struct fixed_voltage_config mx27ads_lcd_regulator_pdata = {
	.supply_name	= "LCD",
	.microvolts	= 3300000,
	.gpio		= MX27ADS_LCD_GPIO,
	.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, NULL, GPIO_ACTIVE_HIGH),
		{ },
	},
};

static void __init mx27ads_regulator_init(void)
{
	struct gpio_chip *vchip;
@@ -247,6 +255,8 @@ static void __init mx27ads_regulator_init(void)
	vchip->set		= vgpio_set;
	gpiochip_add_data(vchip, NULL);

	gpiod_add_lookup_table(&mx27ads_lcd_regulator_gpiod_table);

	platform_device_register_data(NULL, "reg-fixed-voltage",
				      PLATFORM_DEVID_AUTO,
				      &mx27ads_lcd_regulator_pdata,
+11 −1
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
#include <linux/platform_device.h>
#include <linux/io.h>
#include <linux/gpio-pxa.h>
#include <linux/gpio/machine.h>
#include <linux/regulator/machine.h>
#include <linux/regulator/max8649.h>
#include <linux/regulator/fixed.h>
@@ -148,7 +149,6 @@ static struct regulator_init_data brownstone_v_5vp_data = {
static struct fixed_voltage_config brownstone_v_5vp = {
	.supply_name		= "v_5vp",
	.microvolts		= 5000000,
	.gpio			= GPIO_5V_ENABLE,
	.enable_high		= 1,
	.enabled_at_boot	= 1,
	.init_data		= &brownstone_v_5vp_data,
@@ -162,6 +162,15 @@ 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,
			    NULL, GPIO_ACTIVE_HIGH),
		{ },
	},
};

static struct max8925_platform_data brownstone_max8925_info = {
	.irq_base		= MMP_NR_IRQS,
};
@@ -217,6 +226,7 @@ static void __init brownstone_init(void)
	mmp2_add_isram(&mmp2_isram_platdata);

	/* enable 5v regulator */
	gpiod_add_lookup_table(&brownstone_v_5vp_gpiod_table);
	platform_device_register(&brownstone_v_5vp_device);
}

+10 −2
Original line number Diff line number Diff line
@@ -300,7 +300,6 @@ static struct regulator_init_data modem_nreset_data = {
static struct fixed_voltage_config modem_nreset_config = {
	.supply_name		= "modem_nreset",
	.microvolts		= 3300000,
	.gpio			= AMS_DELTA_GPIO_PIN_MODEM_NRESET,
	.startup_delay		= 25000,
	.enable_high		= 1,
	.enabled_at_boot	= 1,
@@ -315,6 +314,15 @@ static struct platform_device modem_nreset_device = {
	},
};

static struct gpiod_lookup_table ams_delta_nreset_gpiod_table = {
	.dev_id = "reg-fixed-voltage",
	.table = {
		GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_MODEM_NRESET,
			    NULL, GPIO_ACTIVE_HIGH),
		{ },
	},
};

struct modem_private_data {
	struct regulator *regulator;
};
@@ -568,7 +576,6 @@ static struct regulator_init_data keybrd_pwr_initdata = {
static struct fixed_voltage_config keybrd_pwr_config = {
	.supply_name		= "keybrd_pwr",
	.microvolts		= 5000000,
	.gpio			= AMS_DELTA_GPIO_PIN_KEYBRD_PWR,
	.enable_high		= 1,
	.init_data		= &keybrd_pwr_initdata,
};
@@ -602,6 +609,7 @@ static struct platform_device *ams_delta_devices[] __initdata = {
};

static struct gpiod_lookup_table *ams_delta_gpio_tables[] __initdata = {
	&ams_delta_nreset_gpiod_table,
	&ams_delta_audio_gpio_table,
	&keybrd_pwr_gpio_table,
	&ams_delta_lcd_gpio_table,
+15 −1
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@
#include <linux/clk.h>
#include <linux/davinci_emac.h>
#include <linux/gpio.h>
#include <linux/gpio/machine.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/of_platform.h>
@@ -328,7 +329,6 @@ static struct regulator_init_data pandora_vmmc3 = {
static struct fixed_voltage_config pandora_vwlan = {
	.supply_name		= "vwlan",
	.microvolts		= 1800000, /* 1.8V */
	.gpio			= PANDORA_WIFI_NRESET_GPIO,
	.startup_delay		= 50000, /* 50ms */
	.enable_high		= 1,
	.init_data		= &pandora_vmmc3,
@@ -342,6 +342,19 @@ 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,
			    NULL, GPIO_ACTIVE_HIGH),
		{ },
	},
};

static void pandora_wl1251_init_card(struct mmc_card *card)
{
	/*
@@ -403,6 +416,7 @@ static void __init pandora_wl1251_init(void)
static void __init omap3_pandora_legacy_init(void)
{
	platform_device_register(&pandora_backlight);
	gpiod_add_lookup_table(&pandora_vwlan_gpiod_table);
	platform_device_register(&pandora_vwlan_device);
	omap_hsmmc_init(pandora_mmc3);
	omap_hsmmc_late_init(pandora_mmc3);
Loading