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

Unverified Commit 6059577c 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.

The OMAP didn't have proper label names on its GPIO chips so I have fixed
this with a separate patch to the GPIO tree, see
commit 088413bc
"gpio: omap: Give unique labels to each GPIO bank/chip"

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.

For the patch hunk hitting arch/blackfin I would say I do not expect
testing, review or ACKs anymore so if it works, it works.

The hunk hitting the x86 BCM43xx driver is especially tricky as the number
comes out of SFI which is a mystery to me. I definately need someone to
look at this. (Hi Andy.)

Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com> # Check the x86 BCM stuff
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: 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
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Acked-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: default avatarTony Lindgren <tony@atomide.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 37fa23db
Loading
Loading
Loading
Loading
+12 −1
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@
#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>
@@ -175,6 +176,7 @@ 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,
};
};
@@ -203,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,
	.gpio		= MX21ADS_IO_LCDON,
	.enable_high	= 1,
	.enable_high	= 1,
	.init_data	= &mx21ads_lcd_regulator_init_data,
	.init_data	= &mx21ads_lcd_regulator_init_data,
};
};
@@ -216,6 +217,15 @@ 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
@@ -311,6 +321,7 @@ 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 =
+11 −1
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@
#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>
@@ -230,10 +231,17 @@ 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;
@@ -247,6 +255,8 @@ 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,
+11 −1
Original line number Original line Diff line number Diff line
@@ -15,6 +15,7 @@
#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>
@@ -148,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,
	.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,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,
			    "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,
};
};
@@ -217,6 +226,7 @@ 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);
}
}


+13 −1
Original line number Original line Diff line number Diff line
@@ -12,6 +12,7 @@
 * 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>
@@ -203,6 +204,7 @@ 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,
};
};
@@ -272,7 +274,6 @@ 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,
@@ -287,6 +288,16 @@ 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;
};
};
@@ -570,6 +581,7 @@ 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");
+15 −1
Original line number Original line Diff line number Diff line
@@ -10,6 +10,7 @@
#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>
@@ -330,7 +331,6 @@ 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,6 +344,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,
			    "enable", GPIO_ACTIVE_HIGH),
		{ },
	},
};

static void pandora_wl1251_init_card(struct mmc_card *card)
static void pandora_wl1251_init_card(struct mmc_card *card)
{
{
	/*
	/*
@@ -405,6 +418,7 @@ 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);
Loading