diff options
-rw-r--r-- | arch/arm/mach-sa1100/Kconfig | 4 | ||||
-rw-r--r-- | arch/arm/mach-sa1100/assabet.c | 39 | ||||
-rw-r--r-- | arch/arm/mach-sa1100/cerf.c | 18 | ||||
-rw-r--r-- | arch/arm/mach-sa1100/clock.c | 2 | ||||
-rw-r--r-- | arch/arm/mach-sa1100/generic.c | 44 | ||||
-rw-r--r-- | arch/arm/mach-sa1100/generic.h | 8 | ||||
-rw-r--r-- | arch/arm/mach-sa1100/h3xxx.c | 17 | ||||
-rw-r--r-- | arch/arm/mach-sa1100/include/mach/assabet.h | 6 | ||||
-rw-r--r-- | arch/arm/mach-sa1100/nanoengine.c | 23 | ||||
-rw-r--r-- | arch/arm/mach-sa1100/shannon.c | 38 | ||||
-rw-r--r-- | arch/arm/mach-sa1100/simpad.c | 11 | ||||
-rw-r--r-- | drivers/pcmcia/Makefile | 4 | ||||
-rw-r--r-- | drivers/pcmcia/sa1100_assabet.c | 100 | ||||
-rw-r--r-- | drivers/pcmcia/sa1100_cerf.c | 86 | ||||
-rw-r--r-- | drivers/pcmcia/sa1100_generic.c | 115 | ||||
-rw-r--r-- | drivers/pcmcia/sa1100_generic.h | 4 | ||||
-rw-r--r-- | drivers/pcmcia/sa1100_h3600.c | 16 | ||||
-rw-r--r-- | drivers/pcmcia/sa1100_nanoengine.c | 133 | ||||
-rw-r--r-- | drivers/pcmcia/sa1100_shannon.c | 104 | ||||
-rw-r--r-- | drivers/pcmcia/sa1100_simpad.c | 12 |
20 files changed, 307 insertions, 477 deletions
diff --git a/arch/arm/mach-sa1100/Kconfig b/arch/arm/mach-sa1100/Kconfig index 07df3a59b13f..fde7ef1ab192 100644 --- a/arch/arm/mach-sa1100/Kconfig +++ b/arch/arm/mach-sa1100/Kconfig @@ -6,6 +6,8 @@ config SA1100_ASSABET bool "Assabet" select ARM_SA1110_CPUFREQ select GPIO_REG + select REGULATOR + select REGULATOR_FIXED_VOLTAGE help Say Y here if you are using the Intel(R) StrongARM(R) SA-1110 Microprocessor Development Board (also known as the Assabet). @@ -137,6 +139,8 @@ config SA1100_PLEB config SA1100_SHANNON bool "Shannon" select ARM_SA1100_CPUFREQ + select REGULATOR + select REGULATOR_FIXED_VOLTAGE help The Shannon (also known as a Tuxscreen, and also as a IS2630) was a limited edition webphone produced by Philips. The Shannon is a SA1100 diff --git a/arch/arm/mach-sa1100/assabet.c b/arch/arm/mach-sa1100/assabet.c index f68241d995f2..575ec085cffa 100644 --- a/arch/arm/mach-sa1100/assabet.c +++ b/arch/arm/mach-sa1100/assabet.c @@ -14,8 +14,11 @@ #include <linux/module.h> #include <linux/errno.h> #include <linux/gpio/gpio-reg.h> +#include <linux/gpio/machine.h> #include <linux/ioport.h> #include <linux/platform_data/sa11x0-serial.h> +#include <linux/regulator/fixed.h> +#include <linux/regulator/machine.h> #include <linux/serial_core.h> #include <linux/platform_device.h> #include <linux/mfd/ucb1x00.h> @@ -445,6 +448,29 @@ static struct resource neponset_resources[] = { }; #endif +static struct gpiod_lookup_table assabet_cf_gpio_table = { + .dev_id = "sa11x0-pcmcia.1", + .table = { + GPIO_LOOKUP("gpio", 21, "ready", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("gpio", 22, "detect", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("gpio", 24, "bvd2", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("gpio", 25, "bvd1", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("assabet", 1, "reset", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("assabet", 7, "bus-enable", GPIO_ACTIVE_LOW), + { }, + }, +}; + +static struct regulator_consumer_supply assabet_cf_vcc_consumers[] = { + REGULATOR_SUPPLY("vcc", "sa11x0-pcmcia.1"), +}; + +static struct fixed_voltage_config assabet_cf_vcc_pdata __initdata = { + .supply_name = "cf-power", + .microvolts = 3300000, + .enable_high = 1, +}; + static void __init assabet_init(void) { /* @@ -490,6 +516,11 @@ static void __init assabet_init(void) platform_device_register_simple("neponset", 0, neponset_resources, ARRAY_SIZE(neponset_resources)); #endif + } else { + sa11x0_register_fixed_regulator(0, &assabet_cf_vcc_pdata, + assabet_cf_vcc_consumers, + ARRAY_SIZE(assabet_cf_vcc_consumers)); + } #ifndef ASSABET_PAL_VIDEO @@ -501,6 +532,9 @@ static void __init assabet_init(void) ARRAY_SIZE(assabet_flash_resources)); sa11x0_register_irda(&assabet_irda_data); sa11x0_register_mcp(&assabet_mcp_data); + + if (!machine_has_neponset()) + sa11x0_register_pcmcia(1, &assabet_cf_gpio_table); } /* @@ -768,6 +802,7 @@ fs_initcall(assabet_leds_init); void __init assabet_init_irq(void) { + unsigned int assabet_gpio_base; u32 def_val; sa1100_init_irq(); @@ -782,7 +817,9 @@ void __init assabet_init_irq(void) * * 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") diff --git a/arch/arm/mach-sa1100/cerf.c b/arch/arm/mach-sa1100/cerf.c index 2d25ececb415..b2a4b41626ef 100644 --- a/arch/arm/mach-sa1100/cerf.c +++ b/arch/arm/mach-sa1100/cerf.c @@ -11,6 +11,7 @@ */ #include <linux/init.h> +#include <linux/gpio/machine.h> #include <linux/kernel.h> #include <linux/tty.h> #include <linux/platform_data/sa11x0-serial.h> @@ -45,6 +46,19 @@ static struct platform_device cerfuart2_device = { .resource = cerfuart2_resources, }; +/* Compact Flash */ +static struct gpiod_lookup_table cerf_cf_gpio_table = { + .dev_id = "sa11x0-pcmcia.1", + .table = { + GPIO_LOOKUP("gpio", 19, "bvd2", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("gpio", 20, "bvd1", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("gpio", 21, "reset", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("gpio", 22, "ready", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("gpio", 23, "detect", GPIO_ACTIVE_LOW), + { }, + }, +}; + /* LEDs */ struct gpio_led cerf_gpio_leds[] = { { @@ -151,9 +165,6 @@ static void __init cerf_map_io(void) sa1100_register_uart(0, 3); sa1100_register_uart(1, 2); /* disable this and the uart2 device for sa1100_fir */ sa1100_register_uart(2, 1); - - /* set some GPDR bits here while it's safe */ - GPDR |= CERF_GPIO_CF_RESET; } static struct mcp_plat_data cerf_mcp_data = { @@ -167,6 +178,7 @@ static void __init cerf_init(void) platform_add_devices(cerf_devices, ARRAY_SIZE(cerf_devices)); sa11x0_register_mtd(&cerf_flash_data, &cerf_flash_resource, 1); sa11x0_register_mcp(&cerf_mcp_data); + sa11x0_register_pcmcia(1, &cerf_cf_gpio_table); } MACHINE_START(CERF, "Intrinsyc CerfBoard/CerfCube") diff --git a/arch/arm/mach-sa1100/clock.c b/arch/arm/mach-sa1100/clock.c index b2eb3d232e39..6199e87447ca 100644 --- a/arch/arm/mach-sa1100/clock.c +++ b/arch/arm/mach-sa1100/clock.c @@ -163,6 +163,8 @@ static struct clk_lookup sa11xx_clkregs[] = { CLKDEV_INIT("sa1100-rtc", NULL, NULL), CLKDEV_INIT("sa11x0-fb", NULL, &clk_cpu), CLKDEV_INIT("sa11x0-pcmcia", NULL, &clk_cpu), + CLKDEV_INIT("sa11x0-pcmcia.0", NULL, &clk_cpu), + CLKDEV_INIT("sa11x0-pcmcia.1", NULL, &clk_cpu), /* sa1111 names devices using internal offsets, PCMCIA is at 0x1800 */ CLKDEV_INIT("1800", NULL, &clk_cpu), CLKDEV_INIT(NULL, "OSTIMER0", &clk_36864), diff --git a/arch/arm/mach-sa1100/generic.c b/arch/arm/mach-sa1100/generic.c index 2eb00691b07d..7167ddf84a0e 100644 --- a/arch/arm/mach-sa1100/generic.c +++ b/arch/arm/mach-sa1100/generic.c @@ -10,6 +10,7 @@ * published by the Free Software Foundation. */ #include <linux/gpio.h> +#include <linux/gpio/machine.h> #include <linux/module.h> #include <linux/kernel.h> #include <linux/init.h> @@ -20,6 +21,8 @@ #include <linux/ioport.h> #include <linux/platform_device.h> #include <linux/reboot.h> +#include <linux/regulator/fixed.h> +#include <linux/regulator/machine.h> #include <linux/irqchip/irq-sa11x0.h> #include <video/sa1100fb.h> @@ -232,11 +235,20 @@ void sa11x0_register_lcd(struct sa1100fb_mach_info *inf) sa11x0_register_device(&sa11x0fb_device, inf); } +static bool sa11x0pcmcia_legacy = true; static struct platform_device sa11x0pcmcia_device = { .name = "sa11x0-pcmcia", .id = -1, }; +void sa11x0_register_pcmcia(int socket, struct gpiod_lookup_table *table) +{ + if (table) + gpiod_add_lookup_table(table); + platform_device_register_simple("sa11x0-pcmcia", socket, NULL, 0); + sa11x0pcmcia_legacy = false; +} + static struct platform_device sa11x0mtd_device = { .name = "sa1100-mtd", .id = -1, @@ -311,7 +323,6 @@ static struct platform_device *sa11x0_devices[] __initdata = { &sa11x0uart1_device, &sa11x0uart3_device, &sa11x0ssp_device, - &sa11x0pcmcia_device, &sa11x0rtc_device, &sa11x0dma_device, }; @@ -319,6 +330,12 @@ static struct platform_device *sa11x0_devices[] __initdata = { static int __init sa1100_init(void) { pm_power_off = sa1100_power_off; + + if (sa11x0pcmcia_legacy) + platform_device_register(&sa11x0pcmcia_device); + + regulator_has_full_constraints(); + return platform_add_devices(sa11x0_devices, ARRAY_SIZE(sa11x0_devices)); } @@ -329,6 +346,31 @@ void __init sa11x0_init_late(void) sa11x0_pm_init(); } +int __init sa11x0_register_fixed_regulator(int n, + struct fixed_voltage_config *cfg, + struct regulator_consumer_supply *supplies, unsigned num_supplies) +{ + struct regulator_init_data *id; + + cfg->init_data = id = kzalloc(sizeof(*cfg->init_data), GFP_KERNEL); + if (!cfg->init_data) + return -ENOMEM; + + if (cfg->gpio < 0) + id->constraints.always_on = 1; + id->constraints.name = cfg->supply_name; + id->constraints.min_uV = cfg->microvolts; + id->constraints.max_uV = cfg->microvolts; + id->constraints.valid_modes_mask = REGULATOR_MODE_NORMAL; + id->constraints.valid_ops_mask = REGULATOR_CHANGE_STATUS; + id->consumer_supplies = supplies; + id->num_consumer_supplies = num_supplies; + + platform_device_register_resndata(NULL, "reg-fixed-voltage", n, + NULL, 0, cfg, sizeof(*cfg)); + return 0; +} + /* * Common I/O mapping: * diff --git a/arch/arm/mach-sa1100/generic.h b/arch/arm/mach-sa1100/generic.h index 97502922a15d..5f3cb52fa6ab 100644 --- a/arch/arm/mach-sa1100/generic.h +++ b/arch/arm/mach-sa1100/generic.h @@ -47,3 +47,11 @@ static inline int sa11x0_pm_init(void) { return 0; } #endif int sa11xx_clk_init(void); + +struct gpiod_lookup_table; +void sa11x0_register_pcmcia(int socket, struct gpiod_lookup_table *); + +struct fixed_voltage_config; +struct regulator_consumer_supply; +int sa11x0_register_fixed_regulator(int n, struct fixed_voltage_config *cfg, + struct regulator_consumer_supply *supplies, unsigned num_supplies); diff --git a/arch/arm/mach-sa1100/h3xxx.c b/arch/arm/mach-sa1100/h3xxx.c index b69e76614d5b..36a78b0c106f 100644 --- a/arch/arm/mach-sa1100/h3xxx.c +++ b/arch/arm/mach-sa1100/h3xxx.c @@ -11,6 +11,7 @@ */ #include <linux/kernel.h> +#include <linux/gpio/machine.h> #include <linux/gpio.h> #include <linux/gpio_keys.h> #include <linux/input.h> @@ -264,8 +265,24 @@ static struct platform_device *h3xxx_devices[] = { &h3xxx_micro_asic, }; +static struct gpiod_lookup_table h3xxx_pcmcia_gpio_table = { + .dev_id = "sa11x0-pcmcia", + .table = { + GPIO_LOOKUP("gpio", H3XXX_GPIO_PCMCIA_CD0, + "pcmcia0-detect", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("gpio", H3XXX_GPIO_PCMCIA_IRQ0, + "pcmcia0-ready", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("gpio", H3XXX_GPIO_PCMCIA_CD1, + "pcmcia1-detect", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("gpio", H3XXX_GPIO_PCMCIA_IRQ1, + "pcmcia1-ready", GPIO_ACTIVE_HIGH), + { }, + }, +}; + void __init h3xxx_mach_init(void) { + gpiod_add_lookup_table(&h3xxx_pcmcia_gpio_table); sa1100_register_uart_fns(&h3xxx_port_fns); sa11x0_register_mtd(&h3xxx_flash_data, &h3xxx_flash_resource, 1); platform_add_devices(h3xxx_devices, ARRAY_SIZE(h3xxx_devices)); diff --git a/arch/arm/mach-sa1100/include/mach/assabet.h b/arch/arm/mach-sa1100/include/mach/assabet.h index 558b45323a2d..641a961653af 100644 --- a/arch/arm/mach-sa1100/include/mach/assabet.h +++ b/arch/arm/mach-sa1100/include/mach/assabet.h @@ -96,10 +96,4 @@ extern void assabet_uda1341_reset(int set); #define ASSABET_GPIO_BATT_LOW GPIO_GPIO (26) /* Low battery */ #define ASSABET_GPIO_RCLK GPIO_GPIO (26) /* CCLK/2 */ -/* These are gpiolib GPIO numbers, not bitmasks */ -#define ASSABET_GPIO_CF_IRQ 21 /* CF IRQ */ -#define ASSABET_GPIO_CF_CD 22 /* CF CD */ -#define ASSABET_GPIO_CF_BVD2 24 /* CF BVD / IOSPKR */ -#define ASSABET_GPIO_CF_BVD1 25 /* CF BVD / IOSTSCHG */ - #endif diff --git a/arch/arm/mach-sa1100/nanoengine.c b/arch/arm/mach-sa1100/nanoengine.c index f1cb3784d525..4d35258a7b32 100644 --- a/arch/arm/mach-sa1100/nanoengine.c +++ b/arch/arm/mach-sa1100/nanoengine.c @@ -12,6 +12,7 @@ */ #include <linux/init.h> +#include <linux/gpio/machine.h> #include <linux/kernel.h> #include <linux/platform_data/sa11x0-serial.h> #include <linux/mtd/mtd.h> @@ -99,8 +100,30 @@ static void __init nanoengine_map_io(void) Ser2HSCR0 = 0; } +static struct gpiod_lookup_table nanoengine_pcmcia0_gpio_table = { + .dev_id = "sa11x0-pcmcia.0", + .table = { + GPIO_LOOKUP("gpio", 11, "ready", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("gpio", 13, "detect", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("gpio", 15, "reset", GPIO_ACTIVE_HIGH), + { }, + }, +}; + +static struct gpiod_lookup_table nanoengine_pcmcia1_gpio_table = { + .dev_id = "sa11x0-pcmcia.1", + .table = { + GPIO_LOOKUP("gpio", 12, "ready", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("gpio", 14, "detect", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("gpio", 16, "reset", GPIO_ACTIVE_HIGH), + { }, + }, +}; + static void __init nanoengine_init(void) { + sa11x0_register_pcmcia(0, &nanoengine_pcmcia0_gpio_table); + sa11x0_register_pcmcia(1, &nanoengine_pcmcia1_gpio_table); sa11x0_register_mtd(&nanoengine_flash_data, nanoengine_flash_resources, ARRAY_SIZE(nanoengine_flash_resources)); } diff --git a/arch/arm/mach-sa1100/shannon.c b/arch/arm/mach-sa1100/shannon.c index 856664c783d9..22f7fe0b809f 100644 --- a/arch/arm/mach-sa1100/shannon.c +++ b/arch/arm/mach-sa1100/shannon.c @@ -5,11 +5,14 @@ #include <linux/init.h> #include <linux/device.h> +#include <linux/gpio/machine.h> #include <linux/kernel.h> #include <linux/platform_data/sa11x0-serial.h> #include <linux/tty.h> #include <linux/mtd/mtd.h> #include <linux/mtd/partitions.h> +#include <linux/regulator/fixed.h> +#include <linux/regulator/machine.h> #include <video/sa1100fb.h> @@ -72,8 +75,43 @@ static struct sa1100fb_mach_info shannon_lcd_info = { .lccr3 = LCCR3_ACBsDiv(512), }; +static struct gpiod_lookup_table shannon_pcmcia0_gpio_table = { + .dev_id = "sa11x0-pcmcia.0", + .table = { + GPIO_LOOKUP("gpio", 24, "detect", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("gpio", 26, "ready", GPIO_ACTIVE_HIGH), + { }, + }, +}; + +static struct gpiod_lookup_table shannon_pcmcia1_gpio_table = { + .dev_id = "sa11x0-pcmcia.1", + .table = { + GPIO_LOOKUP("gpio", 25, "detect", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("gpio", 27, "ready", GPIO_ACTIVE_HIGH), + { }, + }, +}; + +static struct regulator_consumer_supply shannon_cf_vcc_consumers[] = { + REGULATOR_SUPPLY("vcc", "sa11x0-pcmcia.0"), + REGULATOR_SUPPLY("vcc", "sa11x0-pcmcia.1"), +}; + +static struct fixed_voltage_config shannon_cf_vcc_pdata __initdata = { + .supply_name = "cf-power", + .microvolts = 3300000, + .enabled_at_boot = 1, + .gpio = -EINVAL, +}; + static void __init shannon_init(void) { + sa11x0_register_fixed_regulator(0, &shannon_cf_vcc_pdata, + shannon_cf_vcc_consumers, + ARRAY_SIZE(shannon_cf_vcc_consumers)); + sa11x0_register_pcmcia(0, &shannon_pcmcia0_gpio_table); + sa11x0_register_pcmcia(1, &shannon_pcmcia1_gpio_table); sa11x0_ppc_configure_mcp(); sa11x0_register_lcd(&shannon_lcd_info); sa11x0_register_mtd(&shannon_flash_data, &shannon_flash_resource, 1); diff --git a/arch/arm/mach-sa1100/simpad.c b/arch/arm/mach-sa1100/simpad.c index 7d4feb8a49ac..ace010479eb6 100644 --- a/arch/arm/mach-sa1100/simpad.c +++ b/arch/arm/mach-sa1100/simpad.c @@ -4,6 +4,7 @@ */ #include <linux/module.h> +#include <linux/gpio/machine.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/tty.h> @@ -364,6 +365,15 @@ static struct platform_device *devices[] __initdata = { &simpad_i2c, }; +/* Compact Flash */ +static struct gpiod_lookup_table simpad_cf_gpio_table = { + .dev_id = "sa11x0-pcmcia", + .table = { + GPIO_LOOKUP("gpio", GPIO_CF_IRQ, "cf-ready", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("gpio", GPIO_CF_CD, "cf-detect", GPIO_ACTIVE_HIGH), + { }, + }, +}; static int __init simpad_init(void) @@ -385,6 +395,7 @@ static int __init simpad_init(void) pm_power_off = simpad_power_off; + sa11x0_register_pcmcia(-1, &simpad_cf_gpio_table); sa11x0_ppc_configure_mcp(); sa11x0_register_mtd(&simpad_flash_data, simpad_flash_resources, ARRAY_SIZE(simpad_flash_resources)); diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile index f1f89ddb1bfd..28502bd159e0 100644 --- a/drivers/pcmcia/Makefile +++ b/drivers/pcmcia/Makefile @@ -43,13 +43,9 @@ sa1111_cs-$(CONFIG_SA1100_JORNADA720) += sa1111_jornada720.o sa1111_cs-$(CONFIG_ARCH_LUBBOCK) += sa1111_lubbock.o sa1100_cs-y += sa1100_generic.o -sa1100_cs-$(CONFIG_SA1100_ASSABET) += sa1100_assabet.o -sa1100_cs-$(CONFIG_SA1100_CERF) += sa1100_cerf.o sa1100_cs-$(CONFIG_SA1100_COLLIE) += pxa2xx_sharpsl.o sa1100_cs-$(CONFIG_SA1100_H3100) += sa1100_h3600.o sa1100_cs-$(CONFIG_SA1100_H3600) += sa1100_h3600.o -sa1100_cs-$(CONFIG_SA1100_NANOENGINE) += sa1100_nanoengine.o -sa1100_cs-$(CONFIG_SA1100_SHANNON) += sa1100_shannon.o sa1100_cs-$(CONFIG_SA1100_SIMPAD) += sa1100_simpad.o pxa2xx_cm_x2xx_cs-y += pxa2xx_cm_x2xx.o pxa2xx_cm_x255.o pxa2xx_cm_x270.o diff --git a/drivers/pcmcia/sa1100_assabet.c b/drivers/pcmcia/sa1100_assabet.c deleted file mode 100644 index 78ad2bba76db..000000000000 --- a/drivers/pcmcia/sa1100_assabet.c +++ /dev/null @@ -1,100 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * drivers/pcmcia/sa1100_assabet.c - * - * PCMCIA implementation routines for Assabet - * - */ -#include <linux/module.h> -#include <linux/kernel.h> -#include <linux/errno.h> -#include <linux/interrupt.h> -#include <linux/device.h> -#include <linux/init.h> -#include <linux/gpio.h> - -#include <asm/mach-types.h> -#include <mach/assabet.h> - -#include "sa1100_generic.h" - -static int assabet_pcmcia_hw_init(struct soc_pcmcia_socket *skt) -{ - skt->stat[SOC_STAT_CD].gpio = ASSABET_GPIO_CF_CD; - skt->stat[SOC_STAT_CD].name = "CF CD"; - skt->stat[SOC_STAT_BVD1].gpio = ASSABET_GPIO_CF_BVD1; - skt->stat[SOC_STAT_BVD1].name = "CF BVD1"; - skt->stat[SOC_STAT_BVD2].gpio = ASSABET_GPIO_CF_BVD2; - skt->stat[SOC_STAT_BVD2].name = "CF BVD2"; - skt->stat[SOC_STAT_RDY].gpio = ASSABET_GPIO_CF_IRQ; - skt->stat[SOC_STAT_RDY].name = "CF RDY"; - - return 0; -} - -static int -assabet_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_state_t *state) -{ - unsigned int mask; - - switch (state->Vcc) { - case 0: - mask = 0; - break; - - case 50: - printk(KERN_WARNING "%s(): CS asked for 5V, applying 3.3V...\n", - __func__); - - case 33: /* Can only apply 3.3V to the CF slot. */ - mask = ASSABET_BCR_CF_PWR; - break; - - default: - printk(KERN_ERR "%s(): unrecognized Vcc %u\n", __func__, - state->Vcc); - return -1; - } - - /* Silently ignore Vpp, speaker enable. */ - - if (state->flags & SS_RESET) - mask |= ASSABET_BCR_CF_RST; - if (!(state->flags & SS_OUTPUT_ENA)) - mask |= ASSABET_BCR_CF_BUS_OFF; - - ASSABET_BCR_frob(ASSABET_BCR_CF_RST | ASSABET_BCR_CF_PWR | - ASSABET_BCR_CF_BUS_OFF, mask); - - return 0; -} - -/* - * Disable card status IRQs on suspend. - */ -static void assabet_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt) -{ - /* - * Tristate the CF bus signals. Also assert CF - * reset as per user guide page 4-11. - */ - ASSABET_BCR_set(ASSABET_BCR_CF_BUS_OFF | ASSABET_BCR_CF_RST); -} - -static struct pcmcia_low_level assabet_pcmcia_ops = { - .owner = THIS_MODULE, - .hw_init = assabet_pcmcia_hw_init, - .socket_state = soc_common_cf_socket_state, - .configure_socket = assabet_pcmcia_configure_socket, - .socket_suspend = assabet_pcmcia_socket_suspend, -}; - -int pcmcia_assabet_init(struct device *dev) -{ - int ret = -ENODEV; - - if (machine_is_assabet() && !machine_has_neponset()) - ret = sa11xx_drv_pcmcia_probe(dev, &assabet_pcmcia_ops, 1, 1); - - return ret; -} diff --git a/drivers/pcmcia/sa1100_cerf.c b/drivers/pcmcia/sa1100_cerf.c deleted file mode 100644 index 2a54081d161d..000000000000 --- a/drivers/pcmcia/sa1100_cerf.c +++ /dev/null @@ -1,86 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * drivers/pcmcia/sa1100_cerf.c - * - * PCMCIA implementation routines for CerfBoard - * Based off the Assabet. - * - */ -#include <linux/module.h> -#include <linux/kernel.h> -#include <linux/device.h> -#include <linux/init.h> -#include <linux/delay.h> -#include <linux/gpio.h> - -#include <mach/hardware.h> -#include <asm/mach-types.h> -#include <asm/irq.h> -#include <mach/cerf.h> -#include "sa1100_generic.h" - -#define CERF_SOCKET 1 - -static int cerf_pcmcia_hw_init(struct soc_pcmcia_socket *skt) -{ - int ret; - - ret = gpio_request_one(CERF_GPIO_CF_RESET, GPIOF_OUT_INIT_LOW, "CF_RESET"); - if (ret) - return ret; - - skt->stat[SOC_STAT_CD].gpio = CERF_GPIO_CF_CD; - skt->stat[SOC_STAT_CD].name = "CF_CD"; - skt->stat[SOC_STAT_BVD1].gpio = CERF_GPIO_CF_BVD1; - skt->stat[SOC_STAT_BVD1].name = "CF_BVD1"; - skt->stat[SOC_STAT_BVD2].gpio = CERF_GPIO_CF_BVD2; - skt->stat[SOC_STAT_BVD2].name = "CF_BVD2"; - skt->stat[SOC_STAT_RDY].gpio = CERF_GPIO_CF_IRQ; - skt->stat[SOC_STAT_RDY].name = "CF_IRQ"; - - return 0; -} - -static void cerf_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt) -{ - gpio_free(CERF_GPIO_CF_RESET); -} - -static int -cerf_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, - const socket_state_t *state) -{ - switch (state->Vcc) { - case 0: - case 50: - case 33: - break; - - default: - printk(KERN_ERR "%s(): unrecognized Vcc %u\n", - __func__, state->Vcc); - return -1; - } - - gpio_set_value(CERF_GPIO_CF_RESET, !!(state->flags & SS_RESET)); - - return 0; -} - -static struct pcmcia_low_level cerf_pcmcia_ops = { - .owner = THIS_MODULE, - .hw_init = cerf_pcmcia_hw_init, - .hw_shutdown = cerf_pcmcia_hw_shutdown, - .socket_state = soc_common_cf_socket_state, - .configure_socket = cerf_pcmcia_configure_socket, -}; - -int pcmcia_cerf_init(struct device *dev) -{ - int ret = -ENODEV; - - if (machine_is_cerf()) - ret = sa11xx_drv_pcmcia_probe(dev, &cerf_pcmcia_ops, CERF_SOCKET, 1); - - return ret; -} diff --git a/drivers/pcmcia/sa1100_generic.c b/drivers/pcmcia/sa1100_generic.c index 66acdc85727c..47b060c57418 100644 --- a/drivers/pcmcia/sa1100_generic.c +++ b/drivers/pcmcia/sa1100_generic.c @@ -31,7 +31,9 @@ ======================================================================*/ #include <linux/module.h> +#include <linux/gpio/consumer.h> #include <linux/init.h> +#include <linux/regulator/consumer.h> #include <linux/slab.h> #include <linux/platform_device.h> @@ -41,24 +43,64 @@ #include "sa1100_generic.h" +static const char *sa11x0_cf_gpio_names[] = { + [SOC_STAT_CD] = "detect", + [SOC_STAT_BVD1] = "bvd1", + [SOC_STAT_BVD2] = "bvd2", + [SOC_STAT_RDY] = "ready", +}; + +static int sa11x0_cf_hw_init(struct soc_pcmcia_socket *skt) +{ + struct device *dev = skt->socket.dev.parent; + int i; + + skt->gpio_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); + if (IS_ERR(skt->gpio_reset)) + return PTR_ERR(skt->gpio_reset); + + skt->gpio_bus_enable = devm_gpiod_get_optional(dev, "bus-enable", + GPIOD_OUT_HIGH); + if (IS_ERR(skt->gpio_bus_enable)) + return PTR_ERR(skt->gpio_bus_enable); + + skt->vcc.reg = devm_regulator_get_optional(dev, "vcc"); + if (IS_ERR(skt->vcc.reg)) + return PTR_ERR(skt->vcc.reg); + + if (!skt->vcc.reg) + dev_warn(dev, + "no Vcc regulator provided, ignoring Vcc controls\n"); + + for (i = 0; i < ARRAY_SIZE(sa11x0_cf_gpio_names); i++) { + skt->stat[i].name = sa11x0_cf_gpio_names[i]; + skt->stat[i].desc = devm_gpiod_get_optional(dev, + sa11x0_cf_gpio_names[i], GPIOD_IN); + if (IS_ERR(skt->stat[i].desc)) + return PTR_ERR(skt->stat[i].desc); + } + return 0; +} + +static int sa11x0_cf_configure_socket(struct soc_pcmcia_socket *skt, + const socket_state_t *state) +{ + return soc_pcmcia_regulator_set(skt, &skt->vcc, state->Vcc); +} + +static struct pcmcia_low_level sa11x0_cf_ops = { + .owner = THIS_MODULE, + .hw_init = sa11x0_cf_hw_init, + .socket_state = soc_common_cf_socket_state, + .configure_socket = sa11x0_cf_configure_socket, +}; + int __init pcmcia_collie_init(struct device *dev); -static int (*sa11x0_pcmcia_hw_init[])(struct device *dev) = { -#ifdef CONFIG_SA1100_ASSABET - pcmcia_assabet_init, -#endif -#ifdef CONFIG_SA1100_CERF - pcmcia_cerf_init, -#endif +static int (*sa11x0_pcmcia_legacy_hw_init[])(struct device *dev) = { #if defined(CONFIG_SA1100_H3100) || defined(CONFIG_SA1100_H3600) pcmcia_h3600_init, #endif -#ifdef CONFIG_SA1100_NANOENGINE - pcmcia_nanoengine_init, -#endif -#ifdef CONFIG_SA1100_SHANNON - pcmcia_shannon_init, -#endif #ifdef CONFIG_SA1100_SIMPAD pcmcia_simpad_init, #endif @@ -67,15 +109,15 @@ static int (*sa11x0_pcmcia_hw_init[])(struct device *dev) = { #endif }; -static int sa11x0_drv_pcmcia_probe(struct platform_device *dev) +static int sa11x0_drv_pcmcia_legacy_probe(struct platform_device *dev) { int i, ret = -ENODEV; /* * Initialise any "on-board" PCMCIA sockets. */ - for (i = 0; i < ARRAY_SIZE(sa11x0_pcmcia_hw_init); i++) { - ret = sa11x0_pcmcia_hw_init[i](&dev->dev); + for (i = 0; i < ARRAY_SIZE(sa11x0_pcmcia_legacy_hw_init); i++) { + ret = sa11x0_pcmcia_legacy_hw_init[i](&dev->dev); if (ret == 0) break; } @@ -83,7 +125,7 @@ static int sa11x0_drv_pcmcia_probe(struct platform_device *dev) return ret; } -static int sa11x0_drv_pcmcia_remove(struct platform_device *dev) +static int sa11x0_drv_pcmcia_legacy_remove(struct platform_device *dev) { struct skt_dev_info *sinfo = platform_get_drvdata(dev); int i; @@ -96,6 +138,45 @@ static int sa11x0_drv_pcmcia_remove(struct platform_device *dev) return 0; } +static int sa11x0_drv_pcmcia_probe(struct platform_device *pdev) +{ + struct soc_pcmcia_socket *skt; + struct device *dev = &pdev->dev; + + if (pdev->id == -1) + return sa11x0_drv_pcmcia_legacy_probe(pdev); + + skt = devm_kzalloc(dev, sizeof(*skt), GFP_KERNEL); + if (!skt) + return -ENOMEM; + + platform_set_drvdata(pdev, skt); + + skt->nr = pdev->id; + skt->clk = devm_clk_get(dev, NULL); + if (IS_ERR(skt->clk)) + return PTR_ERR(skt->clk); + + sa11xx_drv_pcmcia_ops(&sa11x0_cf_ops); + soc_pcmcia_init_one(skt, &sa11x0_cf_ops, dev); + + return sa11xx_drv_pcmcia_add_one(skt); +} + +static int sa11x0_drv_pcmcia_remove(struct platform_device *dev) +{ + struct soc_pcmcia_socket *skt; + + if (dev->id == -1) + return sa11x0_drv_pcmcia_legacy_remove(dev); + + skt = platform_get_drvdata(dev); + + soc_pcmcia_remove_one(skt); + + return 0; +} + static struct platform_driver sa11x0_pcmcia_driver = { .driver = { .name = "sa11x0-pcmcia", diff --git a/drivers/pcmcia/sa1100_generic.h b/drivers/pcmcia/sa1100_generic.h index a5f1f1dd63cb..7b7cdcd20187 100644 --- a/drivers/pcmcia/sa1100_generic.h +++ b/drivers/pcmcia/sa1100_generic.h @@ -6,18 +6,14 @@ * Declaration for all machine specific init/exit functions. */ extern int pcmcia_adsbitsy_init(struct device *); -extern int pcmcia_assabet_init(struct device *); extern int pcmcia_badge4_init(struct device *); -extern int pcmcia_cerf_init(struct device *); extern int pcmcia_flexanet_init(struct device *); extern int pcmcia_freebird_init(struct device *); extern int pcmcia_gcplus_init(struct device *); extern int pcmcia_graphicsmaster_init(struct device *); extern int pcmcia_h3600_init(struct device *); -extern int pcmcia_nanoengine_init(struct device *); extern int pcmcia_pangolin_init(struct device *); extern int pcmcia_pfs168_init(struct device *); -extern int pcmcia_shannon_init(struct device *); extern int pcmcia_simpad_init(struct device *); extern int pcmcia_stork_init(struct device *); extern int pcmcia_system3_init(struct device *); diff --git a/drivers/pcmcia/sa1100_h3600.c b/drivers/pcmcia/sa1100_h3600.c index aebf9a66fdde..a91222bc3824 100644 --- a/drivers/pcmcia/sa1100_h3600.c +++ b/drivers/pcmcia/sa1100_h3600.c @@ -24,13 +24,15 @@ static int h3600_pcmcia_hw_init(struct soc_pcmcia_socket *skt) { int err; + skt->stat[SOC_STAT_CD].name = skt->nr ? "pcmcia1-detect" : "pcmcia0-detect"; + skt->stat[SOC_STAT_RDY].name = skt->nr ? "pcmcia1-ready" : "pcmcia0-ready"; + + err = soc_pcmcia_request_gpiods(skt); + if (err) + return err; + switch (skt->nr) { case 0: - skt->stat[SOC_STAT_CD].gpio = H3XXX_GPIO_PCMCIA_CD0; - skt->stat[SOC_STAT_CD].name = "PCMCIA CD0"; - skt->stat[SOC_STAT_RDY].gpio = H3XXX_GPIO_PCMCIA_IRQ0; - skt->stat[SOC_STAT_RDY].name = "PCMCIA IRQ0"; - err = gpio_request(H3XXX_EGPIO_OPT_NVRAM_ON, "OPT NVRAM ON"); if (err) goto err01; @@ -57,10 +59,6 @@ static int h3600_pcmcia_hw_init(struct soc_pcmcia_socket *skt) goto err06; break; case 1: - skt->stat[SOC_STAT_CD].gpio = H3XXX_GPIO_PCMCIA_CD1; - skt->stat[SOC_STAT_CD].name = "PCMCIA CD1"; - skt->stat[SOC_STAT_RDY].gpio = H3XXX_GPIO_PCMCIA_IRQ1; - skt->stat[SOC_STAT_RDY].name = "PCMCIA IRQ1"; break; } return 0; diff --git a/drivers/pcmcia/sa1100_nanoengine.c b/drivers/pcmcia/sa1100_nanoengine.c deleted file mode 100644 index 35c30ff41e81..000000000000 --- a/drivers/pcmcia/sa1100_nanoengine.c +++ /dev/null @@ -1,133 +0,0 @@ -/* - * drivers/pcmcia/sa1100_nanoengine.c - * - * PCMCIA implementation routines for BSI nanoEngine. - * - * In order to have a fully functional pcmcia subsystem in a BSE nanoEngine - * board you should carefully read this: - * http://cambuca.ldhs.cetuc.puc-rio.br/nanoengine/ - * - * Copyright (C) 2010 Marcelo Roberto Jimenez <mroberto@cpti.cetuc.puc-rio.br> - * - * Based on original work for kernel 2.4 by - * Miguel Freitas <miguel@cpti.cetuc.puc-rio.br> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - */ -#include <linux/device.h> -#include <linux/errno.h> -#include <linux/gpio.h> -#include <linux/interrupt.h> -#include <linux/irq.h> -#include <linux/init.h> -#include <linux/kernel.h> -#include <linux/module.h> -#include <linux/signal.h> - -#include <asm/mach-types.h> -#include <asm/irq.h> - -#include <mach/hardware.h> -#include <mach/nanoengine.h> - -#include "sa1100_generic.h" - -struct nanoengine_pins { - unsigned output_pins; - unsigned clear_outputs; - int gpio_rst; - int gpio_cd; - int gpio_rdy; -}; - -static struct nanoengine_pins nano_skts[] = { - { - .gpio_rst = GPIO_PC_RESET0, - .gpio_cd = GPIO_PC_CD0, - .gpio_rdy = GPIO_PC_READY0, - }, { - .gpio_rst = GPIO_PC_RESET1, - .gpio_cd = GPIO_PC_CD1, - .gpio_rdy = GPIO_PC_READY1, - } -}; - -unsigned num_nano_pcmcia_sockets = ARRAY_SIZE(nano_skts); - -static int nanoengine_pcmcia_hw_init(struct soc_pcmcia_socket *skt) -{ - unsigned i = skt->nr; - int ret; - - if (i >= num_nano_pcmcia_sockets) - return -ENXIO; - - ret = gpio_request_one(nano_skts[i].gpio_rst, GPIOF_OUT_INIT_LOW, - i ? "PC RST1" : "PC RST0"); - if (ret) - return ret; - - skt->stat[SOC_STAT_CD].gpio = nano_skts[i].gpio_cd; - skt->stat[SOC_STAT_CD].name = i ? "PC CD1" : "PC CD0"; - skt->stat[SOC_STAT_RDY].gpio = nano_skts[i].gpio_rdy; - skt->stat[SOC_STAT_RDY].name = i ? "PC RDY1" : "PC RDY0"; - - return 0; -} - -static void nanoengine_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt) -{ - gpio_free(nano_skts[skt->nr].gpio_rst); -} - -static int nanoengine_pcmcia_configure_socket( - struct soc_pcmcia_socket *skt, const socket_state_t *state) -{ - unsigned i = skt->nr; - - if (i >= num_nano_pcmcia_sockets) - return -ENXIO; - - gpio_set_value(nano_skts[skt->nr].gpio_rst, !!(state->flags & SS_RESET)); - - return 0; -} - -static void nanoengine_pcmcia_socket_state( - struct soc_pcmcia_socket *skt, struct pcmcia_state *state) -{ - unsigned i = skt->nr; - - if (i >= num_nano_pcmcia_sockets) - return; - - state->bvd1 = 1; - state->bvd2 = 1; - state->vs_3v = 1; /* Can only apply 3.3V */ - state->vs_Xv = 0; -} - -static struct pcmcia_low_level nanoengine_pcmcia_ops = { - .owner = THIS_MODULE, - - .hw_init = nanoengine_pcmcia_hw_init, - .hw_shutdown = nanoengine_pcmcia_hw_shutdown, - - .configure_socket = nanoengine_pcmcia_configure_socket, - .socket_state = nanoengine_pcmcia_socket_state, -}; - -int pcmcia_nanoengine_init(struct device *dev) -{ - int ret = -ENODEV; - - if (machine_is_nanoengine()) - ret = sa11xx_drv_pcmcia_probe( - dev, &nanoengine_pcmcia_ops, 0, 2); - - return ret; -} - diff --git a/drivers/pcmcia/sa1100_shannon.c b/drivers/pcmcia/sa1100_shannon.c deleted file mode 100644 index 0e52a575986e..000000000000 --- a/drivers/pcmcia/sa1100_shannon.c +++ /dev/null @@ -1,104 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * drivers/pcmcia/sa1100_shannon.c - * - * PCMCIA implementation routines for Shannon - * - */ -#include <linux/module.h> -#include <linux/kernel.h> -#include <linux/device.h> -#include <linux/init.h> -#include <linux/io.h> - -#include <mach/hardware.h> -#include <asm/mach-types.h> -#include <mach/shannon.h> -#include <asm/irq.h> -#include "sa1100_generic.h" - -static int shannon_pcmcia_hw_init(struct soc_pcmcia_socket *skt) -{ - /* All those are inputs */ - GAFR &= ~(GPIO_GPIO(SHANNON_GPIO_EJECT_0) | - GPIO_GPIO(SHANNON_GPIO_EJECT_1) | - GPIO_GPIO(SHANNON_GPIO_RDY_0) | - GPIO_GPIO(SHANNON_GPIO_RDY_1)); - - if (skt->nr == 0) { - skt->stat[SOC_STAT_CD].gpio = SHANNON_GPIO_EJECT_0; - skt->stat[SOC_STAT_CD].name = "PCMCIA_CD_0"; - skt->stat[SOC_STAT_RDY].gpio = SHANNON_GPIO_RDY_0; - skt->stat[SOC_STAT_RDY].name = "PCMCIA_RDY_0"; - } else { - skt->stat[SOC_STAT_CD].gpio = SHANNON_GPIO_EJECT_1; - skt->stat[SOC_STAT_CD].name = "PCMCIA_CD_1"; - skt->stat[SOC_STAT_RDY].gpio = SHANNON_GPIO_RDY_1; - skt->stat[SOC_STAT_RDY].name = "PCMCIA_RDY_1"; - } - - return 0; -} - -static void -shannon_pcmcia_socket_state(struct soc_pcmcia_socket *skt, - struct pcmcia_state *state) -{ - switch (skt->nr) { - case 0: - state->bvd1 = 1; - state->bvd2 = 1; - state->vs_3v = 1; /* FIXME Can only apply 3.3V on Shannon. */ - state->vs_Xv = 0; - break; - - case 1: - state->bvd1 = 1; - state->bvd2 = 1; - state->vs_3v = 1; /* FIXME Can only apply 3.3V on Shannon. */ - state->vs_Xv = 0; - break; - } -} - -static int -shannon_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, - const socket_state_t *state) -{ - switch (state->Vcc) { - case 0: /* power off */ - printk(KERN_WARNING "%s(): CS asked for 0V, still applying 3.3V..\n", __func__); - break; - case 50: - printk(KERN_WARNING "%s(): CS asked for 5V, applying 3.3V..\n", __func__); - case 33: - break; - default: - printk(KERN_ERR "%s(): unrecognized Vcc %u\n", - __func__, state->Vcc); - return -1; - } - - printk(KERN_WARNING "%s(): Warning, Can't perform reset\n", __func__); - - /* Silently ignore Vpp, output enable, speaker enable. */ - - return 0; -} - -static struct pcmcia_low_level shannon_pcmcia_ops = { - .owner = THIS_MODULE, - .hw_init = shannon_pcmcia_hw_init, - .socket_state = shannon_pcmcia_socket_state, - .configure_socket = shannon_pcmcia_configure_socket, -}; - -int pcmcia_shannon_init(struct device *dev) -{ - int ret = -ENODEV; - - if (machine_is_shannon()) - ret = sa11xx_drv_pcmcia_probe(dev, &shannon_pcmcia_ops, 0, 2); - - return ret; -} diff --git a/drivers/pcmcia/sa1100_simpad.c b/drivers/pcmcia/sa1100_simpad.c index 7ce65bb23a8e..e235ee14eaa6 100644 --- a/drivers/pcmcia/sa1100_simpad.c +++ b/drivers/pcmcia/sa1100_simpad.c @@ -12,7 +12,6 @@ #include <mach/hardware.h> #include <asm/mach-types.h> -#include <asm/irq.h> #include <mach/simpad.h> #include "sa1100_generic.h" @@ -21,12 +20,10 @@ static int simpad_pcmcia_hw_init(struct soc_pcmcia_socket *skt) simpad_clear_cs3_bit(VCC_3V_EN|VCC_5V_EN|EN0|EN1); - skt->stat[SOC_STAT_CD].gpio = GPIO_CF_CD; - skt->stat[SOC_STAT_CD].name = "CF_CD"; - skt->stat[SOC_STAT_RDY].gpio = GPIO_CF_IRQ; - skt->stat[SOC_STAT_RDY].name = "CF_RDY"; + skt->stat[SOC_STAT_CD].name = "cf-detect"; + skt->stat[SOC_STAT_RDY].name = "cf-ready"; - return 0; + return soc_pcmcia_request_gpiods(skt); } static void simpad_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt) @@ -42,9 +39,6 @@ simpad_pcmcia_socket_state(struct soc_pcmcia_socket *skt, { long cs3reg = simpad_get_cs3_ro(); - /* the detect signal is inverted - fix that up here */ - state->detect = !state->detect; - state->bvd1 = 1; /* Might be cs3reg & PCMCIA_BVD1 */ state->bvd2 = 1; /* Might be cs3reg & PCMCIA_BVD2 */ |