From bcbbf908e3c6d60f8efb7e2e8f09285bbda9e11e Mon Sep 17 00:00:00 2001 From: Russell King Date: Fri, 10 Jun 2011 11:13:05 +0100 Subject: ARM: ebsa110: move platform definitions out of mach/hardware.h Stop exposing platform definitions to the entire kernel tree, move them into a private header file instead. Signed-off-by: Russell King --- arch/arm/mach-ebsa110/core.c | 5 +--- arch/arm/mach-ebsa110/core.h | 37 +++++++++++++++++++++++++ arch/arm/mach-ebsa110/include/mach/hardware.h | 39 --------------------------- arch/arm/mach-ebsa110/io.c | 20 ++++++++++++++ arch/arm/mach-ebsa110/leds.c | 2 ++ 5 files changed, 60 insertions(+), 43 deletions(-) create mode 100644 arch/arm/mach-ebsa110/core.h (limited to 'arch/arm') diff --git a/arch/arm/mach-ebsa110/core.c b/arch/arm/mach-ebsa110/core.c index 294aad07f7a0..d7f83e912bd7 100644 --- a/arch/arm/mach-ebsa110/core.c +++ b/arch/arm/mach-ebsa110/core.c @@ -30,10 +30,7 @@ #include -#define IRQ_MASK 0xfe000000 /* read */ -#define IRQ_MSET 0xfe000000 /* write */ -#define IRQ_STAT 0xff000000 /* read */ -#define IRQ_MCLR 0xff000000 /* write */ +#include "core.h" static void ebsa110_mask_irq(struct irq_data *d) { diff --git a/arch/arm/mach-ebsa110/core.h b/arch/arm/mach-ebsa110/core.h new file mode 100644 index 000000000000..61f675426eb8 --- /dev/null +++ b/arch/arm/mach-ebsa110/core.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) 1996-2000 Russell King. + * + * 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. + * + * This file contains the core hardware definitions of the EBSA-110. + */ +#ifndef CORE_H +#define CORE_H + +/* Physical addresses/sizes */ +#define ISAMEM_PHYS 0xe0000000 +#define ISAMEM_SIZE 0x10000000 + +#define ISAIO_PHYS 0xf0000000 +#define ISAIO_SIZE PGDIR_SIZE + +#define TRICK0_PHYS 0xf2000000 +#define TRICK1_PHYS 0xf2400000 +#define TRICK2_PHYS 0xf2800000 +#define TRICK3_PHYS 0xf2c00000 +#define TRICK4_PHYS 0xf3000000 +#define TRICK5_PHYS 0xf3400000 +#define TRICK6_PHYS 0xf3800000 +#define TRICK7_PHYS 0xf3c00000 + +/* Virtual addresses */ +#define PIT_BASE 0xfc000000 /* trick 0 */ +#define SOFT_BASE 0xfd000000 /* trick 1 */ +#define IRQ_MASK 0xfe000000 /* trick 3 - read */ +#define IRQ_MSET 0xfe000000 /* trick 3 - write */ +#define IRQ_STAT 0xff000000 /* trick 4 - read */ +#define IRQ_MCLR 0xff000000 /* trick 4 - write */ + +#endif diff --git a/arch/arm/mach-ebsa110/include/mach/hardware.h b/arch/arm/mach-ebsa110/include/mach/hardware.h index 4b2fb7743909..f4e5407bd004 100644 --- a/arch/arm/mach-ebsa110/include/mach/hardware.h +++ b/arch/arm/mach-ebsa110/include/mach/hardware.h @@ -12,48 +12,9 @@ #ifndef __ASM_ARCH_HARDWARE_H #define __ASM_ARCH_HARDWARE_H -/* - * The EBSA110 has a weird "ISA IO" region: - * - * Region 0 (addr = 0xf0000000 + io << 2) - * -------------------------------------------------------- - * Physical region IO region - * f0000fe0 - f0000ffc 3f8 - 3ff ttyS0 - * f0000e60 - f0000e64 398 - 399 - * f0000de0 - f0000dfc 378 - 37f lp0 - * f0000be0 - f0000bfc 2f8 - 2ff ttyS1 - * - * Region 1 (addr = 0xf0000000 + (io & ~1) << 1 + (io & 1)) - * -------------------------------------------------------- - * Physical region IO region - * f00014f1 a79 pnp write data - * f00007c0 - f00007c1 3e0 - 3e1 pcmcia - * f00004f1 279 pnp address - * f0000440 - f000046c 220 - 236 eth0 - * f0000405 203 pnp read data - */ - -#define ISAMEM_PHYS 0xe0000000 -#define ISAMEM_SIZE 0x10000000 - -#define ISAIO_PHYS 0xf0000000 -#define ISAIO_SIZE PGDIR_SIZE - -#define TRICK0_PHYS 0xf2000000 -#define TRICK1_PHYS 0xf2400000 -#define TRICK2_PHYS 0xf2800000 -#define TRICK3_PHYS 0xf2c00000 -#define TRICK4_PHYS 0xf3000000 -#define TRICK5_PHYS 0xf3400000 -#define TRICK6_PHYS 0xf3800000 -#define TRICK7_PHYS 0xf3c00000 - #define ISAMEM_BASE 0xe0000000 #define ISAIO_BASE 0xf0000000 -#define PIT_BASE 0xfc000000 -#define SOFT_BASE 0xfd000000 - /* * RAM definitions */ diff --git a/arch/arm/mach-ebsa110/io.c b/arch/arm/mach-ebsa110/io.c index c52e3047a7eb..756cc377a73d 100644 --- a/arch/arm/mach-ebsa110/io.c +++ b/arch/arm/mach-ebsa110/io.c @@ -177,6 +177,26 @@ void writesl(void __iomem *addr, const void *data, int len) } EXPORT_SYMBOL(writesl); +/* + * The EBSA110 has a weird "ISA IO" region: + * + * Region 0 (addr = 0xf0000000 + io << 2) + * -------------------------------------------------------- + * Physical region IO region + * f0000fe0 - f0000ffc 3f8 - 3ff ttyS0 + * f0000e60 - f0000e64 398 - 399 + * f0000de0 - f0000dfc 378 - 37f lp0 + * f0000be0 - f0000bfc 2f8 - 2ff ttyS1 + * + * Region 1 (addr = 0xf0000000 + (io & ~1) << 1 + (io & 1)) + * -------------------------------------------------------- + * Physical region IO region + * f00014f1 a79 pnp write data + * f00007c0 - f00007c1 3e0 - 3e1 pcmcia + * f00004f1 279 pnp address + * f0000440 - f000046c 220 - 236 eth0 + * f0000405 203 pnp read data + */ #define SUPERIO_PORT(p) \ (((p) >> 3) == (0x3f8 >> 3) || \ ((p) >> 3) == (0x2f8 >> 3) || \ diff --git a/arch/arm/mach-ebsa110/leds.c b/arch/arm/mach-ebsa110/leds.c index 6a6ea57c2a4e..d43121a30aa7 100644 --- a/arch/arm/mach-ebsa110/leds.c +++ b/arch/arm/mach-ebsa110/leds.c @@ -20,6 +20,8 @@ #include #include +#include "core.h" + static spinlock_t leds_lock; static void ebsa110_leds_event(led_event_t ledevt) -- cgit v1.2.3 From 5eca8f3a8048235d7fa3faa9ee4fc292d25a7425 Mon Sep 17 00:00:00 2001 From: Russell King Date: Fri, 10 Jun 2011 12:35:45 +0100 Subject: ARM: ebsa110: provide TRICK?_SIZE macros Signed-off-by: Russell King --- arch/arm/mach-ebsa110/core.c | 8 ++++---- arch/arm/mach-ebsa110/core.h | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/mach-ebsa110/core.c b/arch/arm/mach-ebsa110/core.c index d7f83e912bd7..6235efb0ccd4 100644 --- a/arch/arm/mach-ebsa110/core.c +++ b/arch/arm/mach-ebsa110/core.c @@ -76,22 +76,22 @@ static struct map_desc ebsa110_io_desc[] __initdata = { { /* IRQ_STAT/IRQ_MCLR */ .virtual = IRQ_STAT, .pfn = __phys_to_pfn(TRICK4_PHYS), - .length = PGDIR_SIZE, + .length = TRICK4_SIZE, .type = MT_DEVICE }, { /* IRQ_MASK/IRQ_MSET */ .virtual = IRQ_MASK, .pfn = __phys_to_pfn(TRICK3_PHYS), - .length = PGDIR_SIZE, + .length = TRICK3_SIZE, .type = MT_DEVICE }, { /* SOFT_BASE */ .virtual = SOFT_BASE, .pfn = __phys_to_pfn(TRICK1_PHYS), - .length = PGDIR_SIZE, + .length = TRICK1_SIZE, .type = MT_DEVICE }, { /* PIT_BASE */ .virtual = PIT_BASE, .pfn = __phys_to_pfn(TRICK0_PHYS), - .length = PGDIR_SIZE, + .length = TRICK0_SIZE, .type = MT_DEVICE }, diff --git a/arch/arm/mach-ebsa110/core.h b/arch/arm/mach-ebsa110/core.h index 61f675426eb8..c93c9e43012d 100644 --- a/arch/arm/mach-ebsa110/core.h +++ b/arch/arm/mach-ebsa110/core.h @@ -18,10 +18,14 @@ #define ISAIO_SIZE PGDIR_SIZE #define TRICK0_PHYS 0xf2000000 +#define TRICK0_SIZE PGDIR_SIZE #define TRICK1_PHYS 0xf2400000 +#define TRICK1_SIZE PGDIR_SIZE #define TRICK2_PHYS 0xf2800000 #define TRICK3_PHYS 0xf2c00000 +#define TRICK3_SIZE PGDIR_SIZE #define TRICK4_PHYS 0xf3000000 +#define TRICK4_SIZE PGDIR_SIZE #define TRICK5_PHYS 0xf3400000 #define TRICK6_PHYS 0xf3800000 #define TRICK7_PHYS 0xf3c00000 -- cgit v1.2.3 From e36e26a8b761d1a601e284e2b5d8aff84de3b756 Mon Sep 17 00:00:00 2001 From: Russell King Date: Fri, 20 Jan 2012 22:24:07 +0000 Subject: MFD: mcp-sa11x0: move setup of PPC unit out of mcp-sa11x0.c Patch taken from af9081ae64 (ARM: sa1100: Refactor mcp-sa11x0 to use platform resources.) by Jochen Friedrich , and consolidated to use a common function. Move the setup of the PPC unit out of mcp-sa11x0 into the core SA11x0 code, and call it from each platforms initialization file. This centralizes the setup of the PPC unit while not polluting the mcp-sa11x0 driver with these details. Acked-by: Jochen Friedrich Signed-off-by: Russell King --- arch/arm/mach-sa1100/assabet.c | 2 ++ arch/arm/mach-sa1100/cerf.c | 1 + arch/arm/mach-sa1100/collie.c | 2 ++ arch/arm/mach-sa1100/generic.c | 10 ++++++++++ arch/arm/mach-sa1100/generic.h | 1 + arch/arm/mach-sa1100/lart.c | 1 + arch/arm/mach-sa1100/shannon.c | 1 + arch/arm/mach-sa1100/simpad.c | 1 + drivers/mfd/mcp-sa11x0.c | 9 --------- 9 files changed, 19 insertions(+), 9 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/mach-sa1100/assabet.c b/arch/arm/mach-sa1100/assabet.c index 0c4b76ab4d8e..3a1914568374 100644 --- a/arch/arm/mach-sa1100/assabet.c +++ b/arch/arm/mach-sa1100/assabet.c @@ -231,6 +231,8 @@ static void __init assabet_init(void) PPDR |= PPC_TXD3 | PPC_TXD1; PPSR |= PPC_TXD3 | PPC_TXD1; + sa11x0_ppc_configure_mcp(); + sa1100fb_lcd_power = assabet_lcd_power; sa1100fb_backlight_power = assabet_backlight_power; diff --git a/arch/arm/mach-sa1100/cerf.c b/arch/arm/mach-sa1100/cerf.c index 11bb6d0b9be3..bc11879f80c8 100644 --- a/arch/arm/mach-sa1100/cerf.c +++ b/arch/arm/mach-sa1100/cerf.c @@ -128,6 +128,7 @@ static struct mcp_plat_data cerf_mcp_data = { static void __init cerf_init(void) { + sa11x0_ppc_configure_mcp(); 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); diff --git a/arch/arm/mach-sa1100/collie.c b/arch/arm/mach-sa1100/collie.c index b9060e236def..efa2bc132cbf 100644 --- a/arch/arm/mach-sa1100/collie.c +++ b/arch/arm/mach-sa1100/collie.c @@ -341,6 +341,8 @@ static void __init collie_init(void) GPSR |= _COLLIE_GPIO_UCB1x00_RESET; + sa11x0_ppc_configure_mcp(); + platform_scoop_config = &collie_pcmcia_config; diff --git a/arch/arm/mach-sa1100/generic.c b/arch/arm/mach-sa1100/generic.c index 480d2ea46b00..1416094cc013 100644 --- a/arch/arm/mach-sa1100/generic.c +++ b/arch/arm/mach-sa1100/generic.c @@ -240,6 +240,16 @@ static struct platform_device sa11x0mcp_device = { .resource = sa11x0mcp_resources, }; +void __init sa11x0_ppc_configure_mcp(void) +{ + /* Setup the PPC unit for the MCP */ + PPDR &= ~PPC_RXD4; + PPDR |= PPC_TXD4 | PPC_SCLK | PPC_SFRM; + PSDR |= PPC_RXD4; + PSDR &= ~(PPC_TXD4 | PPC_SCLK | PPC_SFRM); + PPSR &= ~(PPC_TXD4 | PPC_SCLK | PPC_SFRM); +} + void sa11x0_register_mcp(struct mcp_plat_data *data) { sa11x0_register_device(&sa11x0mcp_device, data); diff --git a/arch/arm/mach-sa1100/generic.h b/arch/arm/mach-sa1100/generic.h index 33268cf6be36..9236ff42bd1f 100644 --- a/arch/arm/mach-sa1100/generic.h +++ b/arch/arm/mach-sa1100/generic.h @@ -39,4 +39,5 @@ struct irda_platform_data; void sa11x0_register_irda(struct irda_platform_data *irda); struct mcp_plat_data; +void sa11x0_ppc_configure_mcp(void); void sa11x0_register_mcp(struct mcp_plat_data *data); diff --git a/arch/arm/mach-sa1100/lart.c b/arch/arm/mach-sa1100/lart.c index af4e2761f3db..eba64b781500 100644 --- a/arch/arm/mach-sa1100/lart.c +++ b/arch/arm/mach-sa1100/lart.c @@ -28,6 +28,7 @@ static struct mcp_plat_data lart_mcp_data = { static void __init lart_init(void) { + sa11x0_ppc_configure_mcp(); sa11x0_register_mcp(&lart_mcp_data); } diff --git a/arch/arm/mach-sa1100/shannon.c b/arch/arm/mach-sa1100/shannon.c index 318b2b766a0b..3efb4ac62240 100644 --- a/arch/arm/mach-sa1100/shannon.c +++ b/arch/arm/mach-sa1100/shannon.c @@ -59,6 +59,7 @@ static struct mcp_plat_data shannon_mcp_data = { static void __init shannon_init(void) { + sa11x0_ppc_configure_mcp(); sa11x0_register_mtd(&shannon_flash_data, &shannon_flash_resource, 1); sa11x0_register_mcp(&shannon_mcp_data); } diff --git a/arch/arm/mach-sa1100/simpad.c b/arch/arm/mach-sa1100/simpad.c index e17c04d6e324..3aa36ec21039 100644 --- a/arch/arm/mach-sa1100/simpad.c +++ b/arch/arm/mach-sa1100/simpad.c @@ -376,6 +376,7 @@ static int __init simpad_init(void) pm_power_off = simpad_power_off; + sa11x0_ppc_configure_mcp(); sa11x0_register_mtd(&simpad_flash_data, simpad_flash_resources, ARRAY_SIZE(simpad_flash_resources)); sa11x0_register_mcp(&simpad_mcp_data); diff --git a/drivers/mfd/mcp-sa11x0.c b/drivers/mfd/mcp-sa11x0.c index d2ebc641b014..5373a7a835c6 100644 --- a/drivers/mfd/mcp-sa11x0.c +++ b/drivers/mfd/mcp-sa11x0.c @@ -165,15 +165,6 @@ static int mcp_sa11x0_probe(struct platform_device *pdev) ASSABET_BCR_set(ASSABET_BCR_CODEC_RST); } - /* - * Setup the PPC unit correctly. - */ - PPDR &= ~PPC_RXD4; - PPDR |= PPC_TXD4 | PPC_SCLK | PPC_SFRM; - PSDR |= PPC_RXD4; - PSDR &= ~(PPC_TXD4 | PPC_SCLK | PPC_SFRM); - PPSR &= ~(PPC_TXD4 | PPC_SCLK | PPC_SFRM); - /* * Initialise device. Note that we initially * set the sampling rate to minimum. -- cgit v1.2.3 From 45c7f75fd4b57035cd35954986a2faefb07dac9d Mon Sep 17 00:00:00 2001 From: Russell King Date: Fri, 20 Jan 2012 23:09:42 +0000 Subject: MFD: mcp-sa11x0: convert mcp-sa11x0 to use platform resources Patch taken from af9081ae64 (ARM: sa1100: Refactor mcp-sa11x0 to use platform resources.) by Jochen Friedrich , and fixes applied. We can safely do this now that we have sanitized host removal; the original patch had use-after-free bugs in the removal code. Not only that, but there was no checking of the ioremap() return. The final change over Jochen's patch is that we wrap the base pointer selection inside the various register indexes, which reduces the possibility of the wrong register index being used. Acked-by: Jochen Friedrich Signed-off-by: Russell King --- arch/arm/mach-sa1100/generic.c | 5 ++ drivers/mfd/mcp-sa11x0.c | 141 +++++++++++++++++++++++++++++------------ 2 files changed, 104 insertions(+), 42 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/mach-sa1100/generic.c b/arch/arm/mach-sa1100/generic.c index 1416094cc013..9379c53d3018 100644 --- a/arch/arm/mach-sa1100/generic.c +++ b/arch/arm/mach-sa1100/generic.c @@ -221,6 +221,11 @@ static struct resource sa11x0mcp_resources[] = { .flags = IORESOURCE_MEM, }, [1] = { + .start = __PREG(Ser4MCCR1), + .end = __PREG(Ser4MCCR1) + 4 - 1, + .flags = IORESOURCE_MEM, + }, + [2] = { .start = IRQ_Ser4MCP, .end = IRQ_Ser4MCP, .flags = IORESOURCE_IRQ, diff --git a/drivers/mfd/mcp-sa11x0.c b/drivers/mfd/mcp-sa11x0.c index 703e76a77005..4d06db72bb9c 100644 --- a/drivers/mfd/mcp-sa11x0.c +++ b/drivers/mfd/mcp-sa11x0.c @@ -13,6 +13,7 @@ */ #include #include +#include #include #include #include @@ -30,34 +31,44 @@ #define DRIVER_NAME "sa11x0-mcp" struct mcp_sa11x0 { - u32 mccr0; - u32 mccr1; + void __iomem *base0; + void __iomem *base1; + u32 mccr0; + u32 mccr1; }; +/* Register offsets */ +#define MCCR0(m) ((m)->base0 + 0x00) +#define MCDR0(m) ((m)->base0 + 0x08) +#define MCDR1(m) ((m)->base0 + 0x0c) +#define MCDR2(m) ((m)->base0 + 0x10) +#define MCSR(m) ((m)->base0 + 0x18) +#define MCCR1(m) ((m)->base1 + 0x00) + #define priv(mcp) ((struct mcp_sa11x0 *)mcp_priv(mcp)) static void mcp_sa11x0_set_telecom_divisor(struct mcp *mcp, unsigned int divisor) { - unsigned int mccr0; + struct mcp_sa11x0 *m = priv(mcp); divisor /= 32; - mccr0 = Ser4MCCR0 & ~0x00007f00; - mccr0 |= divisor << 8; - Ser4MCCR0 = mccr0; + m->mccr0 &= ~0x00007f00; + m->mccr0 |= divisor << 8; + writel_relaxed(m->mccr0, MCCR0(m)); } static void mcp_sa11x0_set_audio_divisor(struct mcp *mcp, unsigned int divisor) { - unsigned int mccr0; + struct mcp_sa11x0 *m = priv(mcp); divisor /= 32; - mccr0 = Ser4MCCR0 & ~0x0000007f; - mccr0 |= divisor; - Ser4MCCR0 = mccr0; + m->mccr0 &= ~0x0000007f; + m->mccr0 |= divisor; + writel_relaxed(m->mccr0, MCCR0(m)); } /* @@ -69,14 +80,15 @@ mcp_sa11x0_set_audio_divisor(struct mcp *mcp, unsigned int divisor) static void mcp_sa11x0_write(struct mcp *mcp, unsigned int reg, unsigned int val) { + struct mcp_sa11x0 *m = priv(mcp); int ret = -ETIME; int i; - Ser4MCDR2 = reg << 17 | MCDR2_Wr | (val & 0xffff); + writel_relaxed(reg << 17 | MCDR2_Wr | (val & 0xffff), MCDR2(m)); for (i = 0; i < 2; i++) { udelay(mcp->rw_timeout); - if (Ser4MCSR & MCSR_CWC) { + if (readl_relaxed(MCSR(m)) & MCSR_CWC) { ret = 0; break; } @@ -95,15 +107,16 @@ mcp_sa11x0_write(struct mcp *mcp, unsigned int reg, unsigned int val) static unsigned int mcp_sa11x0_read(struct mcp *mcp, unsigned int reg) { + struct mcp_sa11x0 *m = priv(mcp); int ret = -ETIME; int i; - Ser4MCDR2 = reg << 17 | MCDR2_Rd; + writel_relaxed(reg << 17 | MCDR2_Rd, MCDR2(m)); for (i = 0; i < 2; i++) { udelay(mcp->rw_timeout); - if (Ser4MCSR & MCSR_CRC) { - ret = Ser4MCDR2 & 0xffff; + if (readl_relaxed(MCSR(m)) & MCSR_CRC) { + ret = readl_relaxed(MCDR2(m)) & 0xffff; break; } } @@ -116,13 +129,19 @@ mcp_sa11x0_read(struct mcp *mcp, unsigned int reg) static void mcp_sa11x0_enable(struct mcp *mcp) { - Ser4MCSR = -1; - Ser4MCCR0 |= MCCR0_MCE; + struct mcp_sa11x0 *m = priv(mcp); + + writel(-1, MCSR(m)); + m->mccr0 |= MCCR0_MCE; + writel_relaxed(m->mccr0, MCCR0(m)); } static void mcp_sa11x0_disable(struct mcp *mcp) { - Ser4MCCR0 &= ~MCCR0_MCE; + struct mcp_sa11x0 *m = priv(mcp); + + m->mccr0 &= ~MCCR0_MCE; + writel_relaxed(m->mccr0, MCCR0(m)); } /* @@ -137,22 +156,38 @@ static struct mcp_ops mcp_sa11x0 = { .disable = mcp_sa11x0_disable, }; -static int mcp_sa11x0_probe(struct platform_device *pdev) +static int mcp_sa11x0_probe(struct platform_device *dev) { - struct mcp_plat_data *data = pdev->dev.platform_data; + struct mcp_plat_data *data = dev->dev.platform_data; + struct resource *mem0, *mem1; + struct mcp_sa11x0 *m; struct mcp *mcp; int ret; if (!data) return -ENODEV; - if (!request_mem_region(0x80060000, 0x60, "sa11x0-mcp")) - return -EBUSY; + mem0 = platform_get_resource(dev, IORESOURCE_MEM, 0); + mem1 = platform_get_resource(dev, IORESOURCE_MEM, 1); + if (!mem0 || !mem1) + return -ENXIO; + + if (!request_mem_region(mem0->start, resource_size(mem0), + DRIVER_NAME)) { + ret = -EBUSY; + goto err_mem0; + } - mcp = mcp_host_alloc(&pdev->dev, sizeof(struct mcp_sa11x0)); + if (!request_mem_region(mem1->start, resource_size(mem1), + DRIVER_NAME)) { + ret = -EBUSY; + goto err_mem1; + } + + mcp = mcp_host_alloc(&dev->dev, sizeof(struct mcp_sa11x0)); if (!mcp) { ret = -ENOMEM; - goto release; + goto err_alloc; } mcp->owner = THIS_MODULE; @@ -160,7 +195,18 @@ static int mcp_sa11x0_probe(struct platform_device *pdev) mcp->sclk_rate = data->sclk_rate; mcp->gpio_base = data->gpio_base; - platform_set_drvdata(pdev, mcp); + m = priv(mcp); + m->mccr0 = data->mccr0 | 0x7f7f; + m->mccr1 = data->mccr1; + + m->base0 = ioremap(mem0->start, resource_size(mem0)); + m->base1 = ioremap(mem1->start, resource_size(mem1)); + if (!m->base0 || !m->base1) { + ret = -ENOMEM; + goto err_ioremap; + } + + platform_set_drvdata(dev, mcp); if (machine_is_assabet()) { ASSABET_BCR_set(ASSABET_BCR_CODEC_RST); @@ -170,9 +216,9 @@ static int mcp_sa11x0_probe(struct platform_device *pdev) * Initialise device. Note that we initially * set the sampling rate to minimum. */ - Ser4MCSR = -1; - Ser4MCCR1 = data->mccr1; - Ser4MCCR0 = data->mccr0 | 0x7f7f; + writel_relaxed(-1, MCSR(m)); + writel_relaxed(m->mccr1, MCCR1(m)); + writel_relaxed(m->mccr0, MCCR0(m)); /* * Calculate the read/write timeout (us) from the bit clock @@ -184,46 +230,57 @@ static int mcp_sa11x0_probe(struct platform_device *pdev) ret = mcp_host_add(mcp); if (ret == 0) - goto out; + return 0; - mcp_host_free(mcp); - release: - release_mem_region(0x80060000, 0x60); - platform_set_drvdata(pdev, NULL); + platform_set_drvdata(dev, NULL); - out: + err_ioremap: + iounmap(m->base1); + iounmap(m->base0); + mcp_host_free(mcp); + err_alloc: + release_mem_region(mem1->start, resource_size(mem1)); + err_mem1: + release_mem_region(mem0->start, resource_size(mem0)); + err_mem0: return ret; } static int mcp_sa11x0_remove(struct platform_device *dev) { struct mcp *mcp = platform_get_drvdata(dev); + struct mcp_sa11x0 *m = priv(mcp); + struct resource *mem0, *mem1; + + mem0 = platform_get_resource(dev, IORESOURCE_MEM, 0); + mem1 = platform_get_resource(dev, IORESOURCE_MEM, 1); platform_set_drvdata(dev, NULL); mcp_host_del(mcp); + iounmap(m->base1); + iounmap(m->base0); mcp_host_free(mcp); - release_mem_region(0x80060000, 0x60); + release_mem_region(mem1->start, resource_size(mem1)); + release_mem_region(mem0->start, resource_size(mem0)); return 0; } static int mcp_sa11x0_suspend(struct platform_device *dev, pm_message_t state) { - struct mcp *mcp = platform_get_drvdata(dev); + struct mcp_sa11x0 *m = priv(platform_get_drvdata(dev)); - priv(mcp)->mccr0 = Ser4MCCR0; - priv(mcp)->mccr1 = Ser4MCCR1; - Ser4MCCR0 &= ~MCCR0_MCE; + writel(m->mccr0 & ~MCCR0_MCE, MCCR0(m)); return 0; } static int mcp_sa11x0_resume(struct platform_device *dev) { - struct mcp *mcp = platform_get_drvdata(dev); + struct mcp_sa11x0 *m = priv(platform_get_drvdata(dev)); - Ser4MCCR1 = priv(mcp)->mccr1; - Ser4MCCR0 = priv(mcp)->mccr0; + writel_relaxed(m->mccr1, MCCR1(m)); + writel_relaxed(m->mccr0, MCCR0(m)); return 0; } -- cgit v1.2.3 From cb5e2399f9e504dc78525988c85882643e915da4 Mon Sep 17 00:00:00 2001 From: Russell King Date: Thu, 12 Jan 2012 10:59:21 +0000 Subject: ARM: sa11x0: fix off-by-one resource sizes Hackkit defined its flash memory resource to be 32M + 1 byte. Jornada defined the Epson video controller resources to be one byte larger than they should be, and mis-mapped the SA-1111 companion chip one byte smaller than it should be. Fix these. Signed-off-by: Russell King --- arch/arm/mach-sa1100/hackkit.c | 2 +- arch/arm/mach-sa1100/jornada720.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/mach-sa1100/hackkit.c b/arch/arm/mach-sa1100/hackkit.c index c01bb36db940..9092b3aff534 100644 --- a/arch/arm/mach-sa1100/hackkit.c +++ b/arch/arm/mach-sa1100/hackkit.c @@ -181,7 +181,7 @@ static struct flash_platform_data hackkit_flash_data = { static struct resource hackkit_flash_resource = { .start = SA1100_CS0_PHYS, - .end = SA1100_CS0_PHYS + SZ_32M, + .end = SA1100_CS0_PHYS + SZ_32M - 1, .flags = IORESOURCE_MEM, }; diff --git a/arch/arm/mach-sa1100/jornada720.c b/arch/arm/mach-sa1100/jornada720.c index ee121d6f0480..5393b06ee2d2 100644 --- a/arch/arm/mach-sa1100/jornada720.c +++ b/arch/arm/mach-sa1100/jornada720.c @@ -46,7 +46,7 @@ /* memory space (line 52 of HP's doc) */ #define SA1111REGSTART 0x40000000 -#define SA1111REGLEN 0x00001fff +#define SA1111REGLEN 0x00002000 #define EPSONREGSTART 0x48000000 #define EPSONREGLEN 0x00100000 #define EPSONFBSTART 0x48200000 @@ -176,12 +176,12 @@ static struct s1d13xxxfb_pdata s1d13xxxfb_data = { static struct resource s1d13xxxfb_resources[] = { [0] = { .start = EPSONFBSTART, - .end = EPSONFBSTART + EPSONFBLEN, + .end = EPSONFBSTART + EPSONFBLEN - 1, .flags = IORESOURCE_MEM, }, [1] = { .start = EPSONREGSTART, - .end = EPSONREGSTART + EPSONREGLEN, + .end = EPSONREGSTART + EPSONREGLEN - 1, .flags = IORESOURCE_MEM, } }; @@ -199,7 +199,7 @@ static struct platform_device s1d13xxxfb_device = { static struct resource sa1111_resources[] = { [0] = { .start = SA1111REGSTART, - .end = SA1111REGSTART + SA1111REGLEN, + .end = SA1111REGSTART + SA1111REGLEN - 1, .flags = IORESOURCE_MEM, }, [1] = { -- cgit v1.2.3 From f3bb3d7422b4161df31e2fd2e503897926d8ffe7 Mon Sep 17 00:00:00 2001 From: Russell King Date: Mon, 23 Jan 2012 18:39:21 +0000 Subject: ARM: sa11x0: fix sleep entry Sometimes, we get stuck while trying to enter sleep. This seems to occur if we do not have udelay() in the instruction cache. Avoid this by requesting a short delay prior to modifying the SDRAM timings. Signed-off-by: Russell King --- arch/arm/mach-sa1100/sleep.S | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/mach-sa1100/sleep.S b/arch/arm/mach-sa1100/sleep.S index e8223315b442..30cc6721665b 100644 --- a/arch/arm/mach-sa1100/sleep.S +++ b/arch/arm/mach-sa1100/sleep.S @@ -26,27 +26,36 @@ * * Causes sa11x0 to enter sleep state * + * Must be aligned to a cacheline. */ - + .balign 32 ENTRY(sa1100_finish_suspend) @ disable clock switching mcr p15, 0, r1, c15, c2, 2 - @ Adjust memory timing before lowering CPU clock - @ Clock speed adjustment without changing memory timing makes - @ CPU hang in some cases - ldr r0, =MDREFR - ldr r1, [r0] - orr r1, r1, #MDREFR_K1DB2 - str r1, [r0] + ldr r6, =MDREFR + ldr r4, [r6] + orr r4, r4, #MDREFR_K1DB2 + ldr r5, =PPCR + + @ Pre-load __udelay into the I-cache + mov r0, #1 + bl __udelay + mov r0, r0 + + @ The following must all exist in a single cache line to + @ avoid accessing memory until this sequence is complete, + @ otherwise we occasionally hang. + + @ Adjust memory timing before lowering CPU clock + str r4, [r6] @ delay 90us and set CPU PLL to lowest speed @ fixes resume problem on high speed SA1110 mov r0, #90 bl __udelay - ldr r0, =PPCR mov r1, #0 - str r1, [r0] + str r1, [r5] mov r0, #90 bl __udelay @@ -85,12 +94,10 @@ ENTRY(sa1100_finish_suspend) bic r5, r5, #FMsk(MSC_RT) bic r5, r5, #FMsk(MSC_RT)<<16 - ldr r6, =MDREFR - ldr r7, [r6] -bic r7, r7, #0x0000FF00 -bic r7, r7, #0x000000F0 -orr r8, r7, #MDREFR_SLFRSH + bic r7, r7, #0x0000FF00 + bic r7, r7, #0x000000F0 + orr r8, r7, #MDREFR_SLFRSH ldr r9, =MDCNFG ldr r10, [r9] -- cgit v1.2.3 From 80ea2065e186d8d69b617770ae7fe51dfea6ba90 Mon Sep 17 00:00:00 2001 From: Russell King Date: Fri, 3 Feb 2012 18:16:45 +0000 Subject: ARM: sa11x0: fix section mismatch warnings Neponset calls sa1110_mb_disable() from __devinit code, but sa1110_mb_disable() is marked __init, and so causes a section mismatch warning. As sa1110_mb_enable() and sa1110_mb_disable() need to be callable from suspend/resume paths as well, they must not be marked __init or __devinit. Signed-off-by: Russell King --- arch/arm/common/sa1111.c | 2 +- arch/arm/mach-sa1100/generic.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/common/sa1111.c b/arch/arm/common/sa1111.c index 61691cdbdcf2..bf508a78aa33 100644 --- a/arch/arm/common/sa1111.c +++ b/arch/arm/common/sa1111.c @@ -87,7 +87,7 @@ #define IRQ_S0_BVD1_STSCHG (53) #define IRQ_S1_BVD1_STSCHG (54) -extern void __init sa1110_mb_enable(void); +extern void sa1110_mb_enable(void); /* * We keep the following data for the overall SA1111. Note that the diff --git a/arch/arm/mach-sa1100/generic.c b/arch/arm/mach-sa1100/generic.c index bb10ee2cb89f..0e356bb89fb7 100644 --- a/arch/arm/mach-sa1100/generic.c +++ b/arch/arm/mach-sa1100/generic.c @@ -428,7 +428,7 @@ void __init sa1100_map_io(void) * the MBGNT signal false to ensure the SA1111 doesn't own the * SDRAM bus. */ -void __init sa1110_mb_disable(void) +void sa1110_mb_disable(void) { unsigned long flags; @@ -447,7 +447,7 @@ void __init sa1110_mb_disable(void) * If the system is going to use the SA-1111 DMA engines, set up * the memory bus request/grant pins. */ -void __devinit sa1110_mb_enable(void) +void sa1110_mb_enable(void) { unsigned long flags; -- cgit v1.2.3 From a181099e2f74dffe45487704cf0e97fd007b2628 Mon Sep 17 00:00:00 2001 From: Russell King Date: Thu, 12 Jan 2012 10:25:29 +0000 Subject: ARM: sa11x0: convert to use DEFINE_RES_xxx macros Convert StrongARM-11x0 platforms and core SoC code to use the DEFINE_RES_xxx macros. Signed-off-by: Russell King --- arch/arm/mach-sa1100/assabet.c | 11 +---- arch/arm/mach-sa1100/badge4.c | 19 ++----- arch/arm/mach-sa1100/cerf.c | 13 ++--- arch/arm/mach-sa1100/collie.c | 24 ++------- arch/arm/mach-sa1100/generic.c | 93 ++++++----------------------------- arch/arm/mach-sa1100/h3xxx.c | 13 ++--- arch/arm/mach-sa1100/hackkit.c | 7 +-- arch/arm/mach-sa1100/irq.c | 7 +-- arch/arm/mach-sa1100/jornada720.c | 31 +++--------- arch/arm/mach-sa1100/nanoengine.c | 11 +---- arch/arm/mach-sa1100/neponset.c | 39 +++------------ arch/arm/mach-sa1100/pci-nanoengine.c | 8 +-- arch/arm/mach-sa1100/pleb.c | 24 ++------- arch/arm/mach-sa1100/shannon.c | 7 +-- arch/arm/mach-sa1100/simpad.c | 11 +---- 15 files changed, 61 insertions(+), 257 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/mach-sa1100/assabet.c b/arch/arm/mach-sa1100/assabet.c index 0c4b76ab4d8e..642f3b3df215 100644 --- a/arch/arm/mach-sa1100/assabet.c +++ b/arch/arm/mach-sa1100/assabet.c @@ -152,15 +152,8 @@ static struct flash_platform_data assabet_flash_data = { }; static struct resource assabet_flash_resources[] = { - { - .start = SA1100_CS0_PHYS, - .end = SA1100_CS0_PHYS + SZ_32M - 1, - .flags = IORESOURCE_MEM, - }, { - .start = SA1100_CS1_PHYS, - .end = SA1100_CS1_PHYS + SZ_32M - 1, - .flags = IORESOURCE_MEM, - } + DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_32M), + DEFINE_RES_MEM(SA1100_CS1_PHYS, SZ_32M), }; diff --git a/arch/arm/mach-sa1100/badge4.c b/arch/arm/mach-sa1100/badge4.c index b07a2c024cb7..ce2dbdf4ba1a 100644 --- a/arch/arm/mach-sa1100/badge4.c +++ b/arch/arm/mach-sa1100/badge4.c @@ -39,16 +39,8 @@ #include "generic.h" static struct resource sa1111_resources[] = { - [0] = { - .start = BADGE4_SA1111_BASE, - .end = BADGE4_SA1111_BASE + 0x00001fff, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = BADGE4_IRQ_GPIO_SA1111, - .end = BADGE4_IRQ_GPIO_SA1111, - .flags = IORESOURCE_IRQ, - }, + [0] = DEFINE_RES_MEM(BADGE4_SA1111_BASE, 0x2000), + [1] = DEFINE_RES_IRQ(BADGE4_IRQ_GPIO_SA1111), }; static struct sa1111_platform_data sa1111_info = { @@ -121,11 +113,8 @@ static struct flash_platform_data badge4_flash_data = { .nr_parts = ARRAY_SIZE(badge4_partitions), }; -static struct resource badge4_flash_resource = { - .start = SA1100_CS0_PHYS, - .end = SA1100_CS0_PHYS + SZ_64M - 1, - .flags = IORESOURCE_MEM, -}; +static struct resource badge4_flash_resource = + DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_64M); static int five_v_on __initdata = 0; diff --git a/arch/arm/mach-sa1100/cerf.c b/arch/arm/mach-sa1100/cerf.c index 11bb6d0b9be3..c2f9ba3a9578 100644 --- a/arch/arm/mach-sa1100/cerf.c +++ b/arch/arm/mach-sa1100/cerf.c @@ -33,11 +33,7 @@ #include "generic.h" static struct resource cerfuart2_resources[] = { - [0] = { - .start = 0x80030000, - .end = 0x8003ffff, - .flags = IORESOURCE_MEM, - }, + [0] = DEFINE_RES_MEM(0x80030000, SZ_64K), }; static struct platform_device cerfuart2_device = { @@ -87,11 +83,8 @@ static struct flash_platform_data cerf_flash_data = { .nr_parts = ARRAY_SIZE(cerf_partitions), }; -static struct resource cerf_flash_resource = { - .start = SA1100_CS0_PHYS, - .end = SA1100_CS0_PHYS + SZ_32M - 1, - .flags = IORESOURCE_MEM, -}; +static struct resource cerf_flash_resource = + DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_32M); static void __init cerf_init_irq(void) { diff --git a/arch/arm/mach-sa1100/collie.c b/arch/arm/mach-sa1100/collie.c index fd5652118ed1..dbe5cf719f7e 100644 --- a/arch/arm/mach-sa1100/collie.c +++ b/arch/arm/mach-sa1100/collie.c @@ -48,11 +48,7 @@ #include "generic.h" static struct resource collie_scoop_resources[] = { - [0] = { - .start = 0x40800000, - .end = 0x40800fff, - .flags = IORESOURCE_MEM, - }, + [0] = DEFINE_RES_MEM(0x40800000, SZ_4K), }; static struct scoop_config collie_scoop_setup = { @@ -221,16 +217,8 @@ device_initcall(collie_uart_init); static struct resource locomo_resources[] = { - [0] = { - .start = 0x40000000, - .end = 0x40001fff, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = IRQ_GPIO25, - .end = IRQ_GPIO25, - .flags = IORESOURCE_IRQ, - }, + [0] = DEFINE_RES_MEM(0x40000000, SZ_8K), + [1] = DEFINE_RES_IRQ(IRQ_GPIO25), }; static struct locomo_platform_data locomo_info = { @@ -303,11 +291,7 @@ static struct flash_platform_data collie_flash_data = { }; static struct resource collie_flash_resources[] = { - { - .start = SA1100_CS0_PHYS, - .end = SA1100_CS0_PHYS + SZ_32M - 1, - .flags = IORESOURCE_MEM, - } + DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_32M), }; static void __init collie_init(void) diff --git a/arch/arm/mach-sa1100/generic.c b/arch/arm/mach-sa1100/generic.c index 0e356bb89fb7..2b33b4597468 100644 --- a/arch/arm/mach-sa1100/generic.c +++ b/arch/arm/mach-sa1100/generic.c @@ -149,16 +149,8 @@ static void sa11x0_register_device(struct platform_device *dev, void *data) static struct resource sa11x0udc_resources[] = { - [0] = { - .start = __PREG(Ser0UDCCR), - .end = __PREG(Ser0UDCCR) + 0xffff, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = IRQ_Ser0UDC, - .end = IRQ_Ser0UDC, - .flags = IORESOURCE_IRQ, - }, + [0] = DEFINE_RES_MEM(__PREG(Ser0UDCCR), SZ_64K), + [1] = DEFINE_RES_IRQ(IRQ_Ser0UDC), }; static u64 sa11x0udc_dma_mask = 0xffffffffUL; @@ -175,16 +167,8 @@ static struct platform_device sa11x0udc_device = { }; static struct resource sa11x0uart1_resources[] = { - [0] = { - .start = __PREG(Ser1UTCR0), - .end = __PREG(Ser1UTCR0) + 0xffff, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = IRQ_Ser1UART, - .end = IRQ_Ser1UART, - .flags = IORESOURCE_IRQ, - }, + [0] = DEFINE_RES_MEM(__PREG(Ser1UTCR0), SZ_64K), + [1] = DEFINE_RES_IRQ(IRQ_Ser1UART), }; static struct platform_device sa11x0uart1_device = { @@ -195,16 +179,8 @@ static struct platform_device sa11x0uart1_device = { }; static struct resource sa11x0uart3_resources[] = { - [0] = { - .start = __PREG(Ser3UTCR0), - .end = __PREG(Ser3UTCR0) + 0xffff, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = IRQ_Ser3UART, - .end = IRQ_Ser3UART, - .flags = IORESOURCE_IRQ, - }, + [0] = DEFINE_RES_MEM(__PREG(Ser3UTCR0), SZ_64K), + [1] = DEFINE_RES_IRQ(IRQ_Ser3UART), }; static struct platform_device sa11x0uart3_device = { @@ -215,16 +191,8 @@ static struct platform_device sa11x0uart3_device = { }; static struct resource sa11x0mcp_resources[] = { - [0] = { - .start = __PREG(Ser4MCCR0), - .end = __PREG(Ser4MCCR0) + 0xffff, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = IRQ_Ser4MCP, - .end = IRQ_Ser4MCP, - .flags = IORESOURCE_IRQ, - }, + [0] = DEFINE_RES_MEM(__PREG(Ser4MCCR0), SZ_64K), + [1] = DEFINE_RES_IRQ(IRQ_Ser4MCP), }; static u64 sa11x0mcp_dma_mask = 0xffffffffUL; @@ -246,16 +214,8 @@ void sa11x0_register_mcp(struct mcp_plat_data *data) } static struct resource sa11x0ssp_resources[] = { - [0] = { - .start = 0x80070000, - .end = 0x8007ffff, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = IRQ_Ser4SSP, - .end = IRQ_Ser4SSP, - .flags = IORESOURCE_IRQ, - }, + [0] = DEFINE_RES_MEM(0x80070000, SZ_64K), + [1] = DEFINE_RES_IRQ(IRQ_Ser4SSP), }; static u64 sa11x0ssp_dma_mask = 0xffffffffUL; @@ -272,16 +232,8 @@ static struct platform_device sa11x0ssp_device = { }; static struct resource sa11x0fb_resources[] = { - [0] = { - .start = 0xb0100000, - .end = 0xb010ffff, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = IRQ_LCD, - .end = IRQ_LCD, - .flags = IORESOURCE_IRQ, - }, + [0] = DEFINE_RES_MEM(0xb0100000, SZ_64K), + [1] = DEFINE_RES_IRQ(IRQ_LCD), }; static struct platform_device sa11x0fb_device = { @@ -314,23 +266,10 @@ void sa11x0_register_mtd(struct flash_platform_data *flash, } static struct resource sa11x0ir_resources[] = { - { - .start = __PREG(Ser2UTCR0), - .end = __PREG(Ser2UTCR0) + 0x24 - 1, - .flags = IORESOURCE_MEM, - }, { - .start = __PREG(Ser2HSCR0), - .end = __PREG(Ser2HSCR0) + 0x1c - 1, - .flags = IORESOURCE_MEM, - }, { - .start = __PREG(Ser2HSCR2), - .end = __PREG(Ser2HSCR2) + 0x04 - 1, - .flags = IORESOURCE_MEM, - }, { - .start = IRQ_Ser2ICP, - .end = IRQ_Ser2ICP, - .flags = IORESOURCE_IRQ, - } + DEFINE_RES_MEM(__PREG(Ser2UTCR0), 0x24), + DEFINE_RES_MEM(__PREG(Ser2HSCR0), 0x1c), + DEFINE_RES_MEM(__PREG(Ser2HSCR2), 0x04), + DEFINE_RES_IRQ(IRQ_Ser2ICP), }; static struct platform_device sa11x0ir_device = { diff --git a/arch/arm/mach-sa1100/h3xxx.c b/arch/arm/mach-sa1100/h3xxx.c index b0784c974c2d..63150e1ffe9e 100644 --- a/arch/arm/mach-sa1100/h3xxx.c +++ b/arch/arm/mach-sa1100/h3xxx.c @@ -109,11 +109,8 @@ static struct flash_platform_data h3xxx_flash_data = { .nr_parts = ARRAY_SIZE(h3xxx_partitions), }; -static struct resource h3xxx_flash_resource = { - .start = SA1100_CS0_PHYS, - .end = SA1100_CS0_PHYS + SZ_32M - 1, - .flags = IORESOURCE_MEM, -}; +static struct resource h3xxx_flash_resource = + DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_32M); /* @@ -186,11 +183,7 @@ static struct sa1100_port_fns h3xxx_port_fns __initdata = { */ static struct resource egpio_resources[] = { - [0] = { - .start = H3600_EGPIO_PHYS, - .end = H3600_EGPIO_PHYS + 0x4 - 1, - .flags = IORESOURCE_MEM, - }, + [0] = DEFINE_RES_MEM(H3600_EGPIO_PHYS, 0x4), }; static struct htc_egpio_chip egpio_chips[] = { diff --git a/arch/arm/mach-sa1100/hackkit.c b/arch/arm/mach-sa1100/hackkit.c index 9092b3aff534..37d381ad5464 100644 --- a/arch/arm/mach-sa1100/hackkit.c +++ b/arch/arm/mach-sa1100/hackkit.c @@ -179,11 +179,8 @@ static struct flash_platform_data hackkit_flash_data = { .nr_parts = ARRAY_SIZE(hackkit_partitions), }; -static struct resource hackkit_flash_resource = { - .start = SA1100_CS0_PHYS, - .end = SA1100_CS0_PHYS + SZ_32M - 1, - .flags = IORESOURCE_MEM, -}; +static struct resource hackkit_flash_resource = + DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_32M); static void __init hackkit_init(void) { diff --git a/arch/arm/mach-sa1100/irq.c b/arch/arm/mach-sa1100/irq.c index dfbf824a69fa..5d12a305f53e 100644 --- a/arch/arm/mach-sa1100/irq.c +++ b/arch/arm/mach-sa1100/irq.c @@ -221,11 +221,8 @@ static struct irq_chip sa1100_normal_chip = { .irq_set_wake = sa1100_set_wake, }; -static struct resource irq_resource = { - .name = "irqs", - .start = 0x90050000, - .end = 0x9005ffff, -}; +static struct resource irq_resource = + DEFINE_RES_MEM_NAMED(0x90050000, SZ_64K, "irqs"); static struct sa1100irq_state { unsigned int saved; diff --git a/arch/arm/mach-sa1100/jornada720.c b/arch/arm/mach-sa1100/jornada720.c index 5393b06ee2d2..8512cfcc0d9b 100644 --- a/arch/arm/mach-sa1100/jornada720.c +++ b/arch/arm/mach-sa1100/jornada720.c @@ -174,16 +174,8 @@ static struct s1d13xxxfb_pdata s1d13xxxfb_data = { }; static struct resource s1d13xxxfb_resources[] = { - [0] = { - .start = EPSONFBSTART, - .end = EPSONFBSTART + EPSONFBLEN - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = EPSONREGSTART, - .end = EPSONREGSTART + EPSONREGLEN - 1, - .flags = IORESOURCE_MEM, - } + [0] = DEFINE_RES_MEM(EPSONFBSTART, EPSONFBLEN), + [1] = DEFINE_RES_MEM(EPSONREGSTART, EPSONREGLEN), }; static struct platform_device s1d13xxxfb_device = { @@ -197,16 +189,8 @@ static struct platform_device s1d13xxxfb_device = { }; static struct resource sa1111_resources[] = { - [0] = { - .start = SA1111REGSTART, - .end = SA1111REGSTART + SA1111REGLEN - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = IRQ_GPIO1, - .end = IRQ_GPIO1, - .flags = IORESOURCE_IRQ, - }, + [0] = DEFINE_RES_MEM(SA1111REGSTART, SA1111REGLEN), + [1] = DEFINE_RES_IRQ(IRQ_GPIO1), }; static struct sa1111_platform_data sa1111_info = { @@ -352,11 +336,8 @@ static struct flash_platform_data jornada720_flash_data = { .nr_parts = ARRAY_SIZE(jornada720_partitions), }; -static struct resource jornada720_flash_resource = { - .start = SA1100_CS0_PHYS, - .end = SA1100_CS0_PHYS + SZ_32M - 1, - .flags = IORESOURCE_MEM, -}; +static struct resource jornada720_flash_resource = + DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_32M); static void __init jornada720_mach_init(void) { diff --git a/arch/arm/mach-sa1100/nanoengine.c b/arch/arm/mach-sa1100/nanoengine.c index 85f6ee672225..3923911000de 100644 --- a/arch/arm/mach-sa1100/nanoengine.c +++ b/arch/arm/mach-sa1100/nanoengine.c @@ -58,15 +58,8 @@ static struct flash_platform_data nanoengine_flash_data = { }; static struct resource nanoengine_flash_resources[] = { - { - .start = SA1100_CS0_PHYS, - .end = SA1100_CS0_PHYS + SZ_32M - 1, - .flags = IORESOURCE_MEM, - }, { - .start = SA1100_CS1_PHYS, - .end = SA1100_CS1_PHYS + SZ_32M - 1, - .flags = IORESOURCE_MEM, - } + DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_32M), + DEFINE_RES_MEM(SA1100_CS1_PHYS, SZ_32M), }; static struct map_desc nanoengine_io_desc[] __initdata = { diff --git a/arch/arm/mach-sa1100/neponset.c b/arch/arm/mach-sa1100/neponset.c index b4fa53a1427e..abbe859b265d 100644 --- a/arch/arm/mach-sa1100/neponset.c +++ b/arch/arm/mach-sa1100/neponset.c @@ -213,11 +213,7 @@ static struct platform_driver neponset_device_driver = { }; static struct resource neponset_resources[] = { - [0] = { - .start = 0x10000000, - .end = 0x17ffffff, - .flags = IORESOURCE_MEM, - }, + [0] = DEFINE_RES_MEM(0x10000000, 0x08000000), }; static struct platform_device neponset_device = { @@ -228,16 +224,8 @@ static struct platform_device neponset_device = { }; static struct resource sa1111_resources[] = { - [0] = { - .start = 0x40000000, - .end = 0x40001fff, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = IRQ_NEPONSET_SA1111, - .end = IRQ_NEPONSET_SA1111, - .flags = IORESOURCE_IRQ, - }, + [0] = DEFINE_RES_MEM(0x40000000, SZ_8K), + [1] = DEFINE_RES_IRQ(IRQ_NEPONSET_SA1111), }; static struct sa1111_platform_data sa1111_info = { @@ -259,23 +247,10 @@ static struct platform_device sa1111_device = { }; static struct resource smc91x_resources[] = { - [0] = { - .name = "smc91x-regs", - .start = SA1100_CS3_PHYS, - .end = SA1100_CS3_PHYS + 0x01ffffff, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = IRQ_NEPONSET_SMC9196, - .end = IRQ_NEPONSET_SMC9196, - .flags = IORESOURCE_IRQ, - }, - [2] = { - .name = "smc91x-attrib", - .start = SA1100_CS3_PHYS + 0x02000000, - .end = SA1100_CS3_PHYS + 0x03ffffff, - .flags = IORESOURCE_MEM, - }, + [0] = DEFINE_RES_MEM_NAMED(SA1100_CS3_PHYS, 0x02000000, "smc91x-regs"), + [1] = DEFINE_RES_IRQ(IRQ_NEPONSET_SMC9196), + [2] = DEFINE_RES_MEM_NAMED(SA1100_CS3_PHYS + 0x02000000, + 0x02000000, "smc91x-attrib"), }; static struct platform_device smc91x_device = { diff --git a/arch/arm/mach-sa1100/pci-nanoengine.c b/arch/arm/mach-sa1100/pci-nanoengine.c index 0d01ca788922..41bb018b3103 100644 --- a/arch/arm/mach-sa1100/pci-nanoengine.c +++ b/arch/arm/mach-sa1100/pci-nanoengine.c @@ -135,12 +135,8 @@ struct pci_bus * __init pci_nanoengine_scan_bus(int nr, struct pci_sys_data *sys &sys->resources); } -static struct resource pci_io_ports = { - .name = "PCI IO", - .start = 0x400, - .end = 0x7FF, - .flags = IORESOURCE_IO, -}; +static struct resource pci_io_ports = + DEFINE_RES_IO_NAMED(0x400, 0x400, "PCI IO"); static struct resource pci_non_prefetchable_memory = { .name = "PCI non-prefetchable", diff --git a/arch/arm/mach-sa1100/pleb.c b/arch/arm/mach-sa1100/pleb.c index 9307df053533..ca5d33b6041a 100644 --- a/arch/arm/mach-sa1100/pleb.c +++ b/arch/arm/mach-sa1100/pleb.c @@ -37,17 +37,9 @@ #define IRQ_GPIO_ETH0_IRQ IRQ_GPIO21 static struct resource smc91x_resources[] = { - [0] = { - .start = PLEB_ETH0_P, - .end = PLEB_ETH0_P | 0x03ffffff, - .flags = IORESOURCE_MEM, - }, + [0] = DEFINE_RES_MEM(PLEB_ETH0_P, 0x04000000), #if 0 /* Autoprobe instead, to get rising/falling edge characteristic right */ - [1] = { - .start = IRQ_GPIO_ETH0_IRQ, - .end = IRQ_GPIO_ETH0_IRQ, - .flags = IORESOURCE_IRQ, - }, + [1] = DEFINE_RES_IRQ(IRQ_GPIO_ETH0_IRQ), #endif }; @@ -70,16 +62,8 @@ static struct platform_device *devices[] __initdata = { * the two SA1100 lowest chip select outputs. */ static struct resource pleb_flash_resources[] = { - [0] = { - .start = SA1100_CS0_PHYS, - .end = SA1100_CS0_PHYS + SZ_8M - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = SA1100_CS1_PHYS, - .end = SA1100_CS1_PHYS + SZ_8M - 1, - .flags = IORESOURCE_MEM, - } + [0] = DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_8M), + [1] = DEFINE_RES_MEM(SA1100_CS1_PHYS, SZ_8M), }; diff --git a/arch/arm/mach-sa1100/shannon.c b/arch/arm/mach-sa1100/shannon.c index 318b2b766a0b..5fd615649847 100644 --- a/arch/arm/mach-sa1100/shannon.c +++ b/arch/arm/mach-sa1100/shannon.c @@ -46,11 +46,8 @@ static struct flash_platform_data shannon_flash_data = { .nr_parts = ARRAY_SIZE(shannon_partitions), }; -static struct resource shannon_flash_resource = { - .start = SA1100_CS0_PHYS, - .end = SA1100_CS0_PHYS + SZ_4M - 1, - .flags = IORESOURCE_MEM, -}; +static struct resource shannon_flash_resource = + DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_4M); static struct mcp_plat_data shannon_mcp_data = { .mccr0 = MCCR0_ADM, diff --git a/arch/arm/mach-sa1100/simpad.c b/arch/arm/mach-sa1100/simpad.c index e17c04d6e324..cdb9d197c092 100644 --- a/arch/arm/mach-sa1100/simpad.c +++ b/arch/arm/mach-sa1100/simpad.c @@ -176,15 +176,8 @@ static struct flash_platform_data simpad_flash_data = { static struct resource simpad_flash_resources [] = { - { - .start = SA1100_CS0_PHYS, - .end = SA1100_CS0_PHYS + SZ_16M -1, - .flags = IORESOURCE_MEM, - }, { - .start = SA1100_CS1_PHYS, - .end = SA1100_CS1_PHYS + SZ_16M -1, - .flags = IORESOURCE_MEM, - } + DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_16M), + DEFINE_RES_MEM(SA1100_CS1_PHYS, SZ_16M), }; static struct mcp_plat_data simpad_mcp_data = { -- cgit v1.2.3 From 7186fb9fd79d6209fe7aea9dbe06b629c61b389e Mon Sep 17 00:00:00 2001 From: Russell King Date: Sat, 21 Jan 2012 21:17:06 +0000 Subject: ARM: sa11x0: assabet: deassert QMUTE to codec while codec is unpowered Signed-off-by: Russell King --- arch/arm/mach-sa1100/assabet.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/mach-sa1100/assabet.c b/arch/arm/mach-sa1100/assabet.c index 642f3b3df215..3a3282e08a70 100644 --- a/arch/arm/mach-sa1100/assabet.c +++ b/arch/arm/mach-sa1100/assabet.c @@ -40,13 +40,13 @@ #include "generic.h" #define ASSABET_BCR_DB1110 \ - (ASSABET_BCR_SPK_OFF | ASSABET_BCR_QMUTE | \ + (ASSABET_BCR_SPK_OFF | \ ASSABET_BCR_LED_GREEN | ASSABET_BCR_LED_RED | \ ASSABET_BCR_RS232EN | ASSABET_BCR_LCD_12RGB | \ ASSABET_BCR_IRDA_MD0) #define ASSABET_BCR_DB1111 \ - (ASSABET_BCR_SPK_OFF | ASSABET_BCR_QMUTE | \ + (ASSABET_BCR_SPK_OFF | \ ASSABET_BCR_LED_GREEN | ASSABET_BCR_LED_RED | \ ASSABET_BCR_RS232EN | ASSABET_BCR_LCD_12RGB | \ ASSABET_BCR_CF_BUS_OFF | ASSABET_BCR_STEREO_LB | \ -- cgit v1.2.3 From 4f592e6d1a6711b2ef140b5c76342dbe2506c8cb Mon Sep 17 00:00:00 2001 From: Russell King Date: Tue, 24 Jan 2012 09:23:19 +0000 Subject: ARM: sa11x0: assabet: avoid glitching GPIOs when setting outputs Avoid glitching the GPIO signals during initialization, which can have undesirable effects. Ensure that the desired pin state is set before we change the GPIO pin direction to be an output. Signed-off-by: Russell King --- arch/arm/mach-sa1100/assabet.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/mach-sa1100/assabet.c b/arch/arm/mach-sa1100/assabet.c index 3a3282e08a70..6356896587bf 100644 --- a/arch/arm/mach-sa1100/assabet.c +++ b/arch/arm/mach-sa1100/assabet.c @@ -202,8 +202,8 @@ static void __init assabet_init(void) /* * Ensure that the power supply is in "high power" mode. */ - GPDR |= GPIO_GPIO16; GPSR = GPIO_GPIO16; + GPDR |= GPIO_GPIO16; /* * Ensure that these pins are set as outputs and are driving @@ -211,8 +211,8 @@ static void __init assabet_init(void) * the WS latch in the CPLD, and we don't float causing * excessive power drain. --rmk */ - GPDR |= GPIO_SSP_TXD | GPIO_SSP_SCLK | GPIO_SSP_SFRM; GPCR = GPIO_SSP_TXD | GPIO_SSP_SCLK | GPIO_SSP_SFRM; + GPDR |= GPIO_SSP_TXD | GPIO_SSP_SCLK | GPIO_SSP_SFRM; /* * Set up registers for sleep mode. -- cgit v1.2.3 From 49e01e3fb6efe1b0abfa2d5675f88f07989d621f Mon Sep 17 00:00:00 2001 From: Russell King Date: Tue, 24 Jan 2012 09:25:57 +0000 Subject: ARM: sa11x0: assabet: ensure that GPIO27 is driven GPIO27 is just connected to a CPLD input without any pull-ups or pull- downs. If GPIO27 is left as an input, it will float around mid-supply, which for CMOS inputs is the worst place for a pin to be. Ensure that this pin is driven. Signed-off-by: Russell King --- arch/arm/mach-sa1100/assabet.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'arch/arm') diff --git a/arch/arm/mach-sa1100/assabet.c b/arch/arm/mach-sa1100/assabet.c index 6356896587bf..e3805d4c052a 100644 --- a/arch/arm/mach-sa1100/assabet.c +++ b/arch/arm/mach-sa1100/assabet.c @@ -214,6 +214,14 @@ static void __init assabet_init(void) GPCR = GPIO_SSP_TXD | GPIO_SSP_SCLK | GPIO_SSP_SFRM; GPDR |= GPIO_SSP_TXD | GPIO_SSP_SCLK | GPIO_SSP_SFRM; + /* + * Also set GPIO27 as an output; this is used to clock UART3 + * via the FPGA and as otherwise has no pullups or pulldowns, + * so stop it floating. + */ + GPCR = GPIO_GPIO27; + GPDR |= GPIO_GPIO27; + /* * Set up registers for sleep mode. */ -- cgit v1.2.3 From 710455201f6690841e9a40bedba09ddd0a7e0620 Mon Sep 17 00:00:00 2001 From: Russell King Date: Mon, 16 Jan 2012 00:17:41 +0000 Subject: ARM: sa11x0: neponset: fix interrupt setup Since ARM was converted to genirq, the neponset IRQ implementation has gradually broken as a result of various subtle changes being introduced into genirq. It used to be that simple IRQs did not need an IRQ chip. This is no longer the case, and genirq barfs in irq_set_handler(). Fix this by introducing a dummy no-op chip, and registering it along with the flow handler. Neponset IRQs really don't have any masking ability - all we have is a status register to allow us to decode the source, and a three input OR gate inside a CPLD. Signed-off-by: Russell King --- arch/arm/mach-sa1100/neponset.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/mach-sa1100/neponset.c b/arch/arm/mach-sa1100/neponset.c index abbe859b265d..6a14d3760ccd 100644 --- a/arch/arm/mach-sa1100/neponset.c +++ b/arch/arm/mach-sa1100/neponset.c @@ -138,6 +138,20 @@ static struct sa1100_port_fns neponset_port_fns __devinitdata = { .get_mctrl = neponset_get_mctrl, }; +/* + * Yes, we really do not have any kind of masking or unmasking + */ +static void nochip_noop(struct irq_data *irq) +{ +} + +static struct irq_chip nochip = { + .name = "neponset", + .irq_ack = nochip_noop, + .irq_mask = nochip_noop, + .irq_unmask = nochip_noop, +}; + static int __devinit neponset_probe(struct platform_device *dev) { sa1100_register_uart_fns(&neponset_port_fns); @@ -161,10 +175,13 @@ static int __devinit neponset_probe(struct platform_device *dev) * Setup other Neponset IRQs. SA1111 will be done by the * generic SA1111 code. */ - irq_set_handler(IRQ_NEPONSET_SMC9196, handle_simple_irq); + irq_set_chip_and_handler(IRQ_NEPONSET_SMC9196, &nochip, + handle_simple_irq); set_irq_flags(IRQ_NEPONSET_SMC9196, IRQF_VALID | IRQF_PROBE); - irq_set_handler(IRQ_NEPONSET_USAR, handle_simple_irq); + irq_set_chip_and_handler(IRQ_NEPONSET_USAR, &nochip, + handle_simple_irq); set_irq_flags(IRQ_NEPONSET_USAR, IRQF_VALID | IRQF_PROBE); + irq_set_chip(IRQ_NEPONSET_SA1111, &nochip); /* * Disable GPIO 0/1 drivers so the buttons work on the module. -- cgit v1.2.3 From 6ad1b614007c556129989b9f6b020d0d2e058121 Mon Sep 17 00:00:00 2001 From: Russell King Date: Mon, 16 Jan 2012 09:31:47 +0000 Subject: ARM: sa11x0: neponset: provide function to manipulate NCR_0 Rather than having direct register accesses to NCR_0 scattered amongst the code, provide a function instead. This contains the necessary race protection for this platform, ensuring that updates to this register are safe. Signed-off-by: Russell King --- arch/arm/mach-sa1100/include/mach/neponset.h | 4 ++++ arch/arm/mach-sa1100/neponset.c | 9 +++++++++ drivers/net/ethernet/smsc/smc91x.c | 2 +- drivers/pcmcia/sa1100_neponset.c | 7 +------ 4 files changed, 15 insertions(+), 7 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/mach-sa1100/include/mach/neponset.h b/arch/arm/mach-sa1100/include/mach/neponset.h index ffe2bc45eed0..6032216e1830 100644 --- a/arch/arm/mach-sa1100/include/mach/neponset.h +++ b/arch/arm/mach-sa1100/include/mach/neponset.h @@ -71,4 +71,8 @@ #define NCR_A0VPP (1<<5) #define NCR_A1VPP (1<<6) +void neponset_ncr_frob(unsigned int, unsigned int); +#define neponset_ncr_set(v) neponset_ncr_frob(0, v) +#define neponset_ncr_clear(v) neponset_ncr_frob(v, 0) + #endif diff --git a/arch/arm/mach-sa1100/neponset.c b/arch/arm/mach-sa1100/neponset.c index 6a14d3760ccd..10be07e2bd56 100644 --- a/arch/arm/mach-sa1100/neponset.c +++ b/arch/arm/mach-sa1100/neponset.c @@ -20,6 +20,15 @@ #include #include +void neponset_ncr_frob(unsigned int mask, unsigned int val) +{ + unsigned long flags; + + local_irq_save(flags); + NCR_0 = (NCR_0 & ~mask) | val; + local_irq_restore(flags); +} + /* * Install handler for Neponset IRQ. Note that we have to loop here * since the ETHERNET and USAR IRQs are level based, and we need to diff --git a/drivers/net/ethernet/smsc/smc91x.c b/drivers/net/ethernet/smsc/smc91x.c index 64ad3ed74495..0dba0501b712 100644 --- a/drivers/net/ethernet/smsc/smc91x.c +++ b/drivers/net/ethernet/smsc/smc91x.c @@ -2281,7 +2281,7 @@ static int __devinit smc_drv_probe(struct platform_device *pdev) if (ret) goto out_release_io; #if defined(CONFIG_SA1100_ASSABET) - NCR_0 |= NCR_ENET_OSC_EN; + neponset_ncr_set(NCR_ENET_OSC_EN); #endif platform_set_drvdata(pdev, ndev); ret = smc_enable_device(pdev); diff --git a/drivers/pcmcia/sa1100_neponset.c b/drivers/pcmcia/sa1100_neponset.c index c95639b5f2a0..4300a7fb3edb 100644 --- a/drivers/pcmcia/sa1100_neponset.c +++ b/drivers/pcmcia/sa1100_neponset.c @@ -94,12 +94,7 @@ neponset_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_sta ret = sa1111_pcmcia_configure_socket(skt, state); if (ret == 0) { - unsigned long flags; - - local_irq_save(flags); - NCR_0 = (NCR_0 & ~ncr_mask) | ncr_set; - - local_irq_restore(flags); + neponset_ncr_frob(ncr_mask, ncr_set); sa1111_set_io(s->dev, pa_dwr_mask, pa_dwr_set); } -- cgit v1.2.3 From 92e617d9e6f148b8301968c8b78e3cbc7bd5172e Mon Sep 17 00:00:00 2001 From: Russell King Date: Tue, 24 Jan 2012 22:13:00 +0000 Subject: ARM: sa11x0: neponset: shuffle some code around Move the IRQ handler along side the rest of the IRQ code, and rearrange the include files. Signed-off-by: Russell King --- arch/arm/mach-sa1100/neponset.c | 202 ++++++++++++++++++++-------------------- 1 file changed, 101 insertions(+), 101 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/mach-sa1100/neponset.c b/arch/arm/mach-sa1100/neponset.c index 10be07e2bd56..8fcd542d46f7 100644 --- a/arch/arm/mach-sa1100/neponset.c +++ b/arch/arm/mach-sa1100/neponset.c @@ -2,24 +2,24 @@ * linux/arch/arm/mach-sa1100/neponset.c * */ -#include #include -#include #include -#include +#include #include +#include -#include #include #include #include #include #include -#include -#include #include #include +#include +#include +#include + void neponset_ncr_frob(unsigned int mask, unsigned int val) { unsigned long flags; @@ -29,6 +29,64 @@ void neponset_ncr_frob(unsigned int mask, unsigned int val) local_irq_restore(flags); } +static void neponset_set_mctrl(struct uart_port *port, u_int mctrl) +{ + u_int mdm_ctl0 = MDM_CTL_0; + + if (port->mapbase == _Ser1UTCR0) { + if (mctrl & TIOCM_RTS) + mdm_ctl0 &= ~MDM_CTL0_RTS2; + else + mdm_ctl0 |= MDM_CTL0_RTS2; + + if (mctrl & TIOCM_DTR) + mdm_ctl0 &= ~MDM_CTL0_DTR2; + else + mdm_ctl0 |= MDM_CTL0_DTR2; + } else if (port->mapbase == _Ser3UTCR0) { + if (mctrl & TIOCM_RTS) + mdm_ctl0 &= ~MDM_CTL0_RTS1; + else + mdm_ctl0 |= MDM_CTL0_RTS1; + + if (mctrl & TIOCM_DTR) + mdm_ctl0 &= ~MDM_CTL0_DTR1; + else + mdm_ctl0 |= MDM_CTL0_DTR1; + } + + MDM_CTL_0 = mdm_ctl0; +} + +static u_int neponset_get_mctrl(struct uart_port *port) +{ + u_int ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR; + u_int mdm_ctl1 = MDM_CTL_1; + + if (port->mapbase == _Ser1UTCR0) { + if (mdm_ctl1 & MDM_CTL1_DCD2) + ret &= ~TIOCM_CD; + if (mdm_ctl1 & MDM_CTL1_CTS2) + ret &= ~TIOCM_CTS; + if (mdm_ctl1 & MDM_CTL1_DSR2) + ret &= ~TIOCM_DSR; + } else if (port->mapbase == _Ser3UTCR0) { + if (mdm_ctl1 & MDM_CTL1_DCD1) + ret &= ~TIOCM_CD; + if (mdm_ctl1 & MDM_CTL1_CTS1) + ret &= ~TIOCM_CTS; + if (mdm_ctl1 & MDM_CTL1_DSR1) + ret &= ~TIOCM_DSR; + } + + return ret; +} + +static struct sa1100_port_fns neponset_port_fns __devinitdata = { + .set_mctrl = neponset_set_mctrl, + .get_mctrl = neponset_get_mctrl, +}; + /* * Install handler for Neponset IRQ. Note that we have to loop here * since the ETHERNET and USAR IRQs are level based, and we need to @@ -89,64 +147,6 @@ neponset_irq_handler(unsigned int irq, struct irq_desc *desc) } } -static void neponset_set_mctrl(struct uart_port *port, u_int mctrl) -{ - u_int mdm_ctl0 = MDM_CTL_0; - - if (port->mapbase == _Ser1UTCR0) { - if (mctrl & TIOCM_RTS) - mdm_ctl0 &= ~MDM_CTL0_RTS2; - else - mdm_ctl0 |= MDM_CTL0_RTS2; - - if (mctrl & TIOCM_DTR) - mdm_ctl0 &= ~MDM_CTL0_DTR2; - else - mdm_ctl0 |= MDM_CTL0_DTR2; - } else if (port->mapbase == _Ser3UTCR0) { - if (mctrl & TIOCM_RTS) - mdm_ctl0 &= ~MDM_CTL0_RTS1; - else - mdm_ctl0 |= MDM_CTL0_RTS1; - - if (mctrl & TIOCM_DTR) - mdm_ctl0 &= ~MDM_CTL0_DTR1; - else - mdm_ctl0 |= MDM_CTL0_DTR1; - } - - MDM_CTL_0 = mdm_ctl0; -} - -static u_int neponset_get_mctrl(struct uart_port *port) -{ - u_int ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR; - u_int mdm_ctl1 = MDM_CTL_1; - - if (port->mapbase == _Ser1UTCR0) { - if (mdm_ctl1 & MDM_CTL1_DCD2) - ret &= ~TIOCM_CD; - if (mdm_ctl1 & MDM_CTL1_CTS2) - ret &= ~TIOCM_CTS; - if (mdm_ctl1 & MDM_CTL1_DSR2) - ret &= ~TIOCM_DSR; - } else if (port->mapbase == _Ser3UTCR0) { - if (mdm_ctl1 & MDM_CTL1_DCD1) - ret &= ~TIOCM_CD; - if (mdm_ctl1 & MDM_CTL1_CTS1) - ret &= ~TIOCM_CTS; - if (mdm_ctl1 & MDM_CTL1_DSR1) - ret &= ~TIOCM_DSR; - } - - return ret; -} - -static struct sa1100_port_fns neponset_port_fns __devinitdata = { - .set_mctrl = neponset_set_mctrl, - .get_mctrl = neponset_get_mctrl, -}; - /* * Yes, we really do not have any kind of masking or unmasking */ @@ -161,6 +161,43 @@ static struct irq_chip nochip = { .irq_unmask = nochip_noop, }; +static struct resource sa1111_resources[] = { + [0] = DEFINE_RES_MEM(0x40000000, SZ_8K), + [1] = DEFINE_RES_IRQ(IRQ_NEPONSET_SA1111), +}; + +static struct sa1111_platform_data sa1111_info = { + .irq_base = IRQ_BOARD_END, +}; + +static u64 sa1111_dmamask = 0xffffffffUL; + +static struct platform_device sa1111_device = { + .name = "sa1111", + .id = 0, + .dev = { + .dma_mask = &sa1111_dmamask, + .coherent_dma_mask = 0xffffffff, + .platform_data = &sa1111_info, + }, + .num_resources = ARRAY_SIZE(sa1111_resources), + .resource = sa1111_resources, +}; + +static struct resource smc91x_resources[] = { + [0] = DEFINE_RES_MEM_NAMED(SA1100_CS3_PHYS, 0x02000000, "smc91x-regs"), + [1] = DEFINE_RES_IRQ(IRQ_NEPONSET_SMC9196), + [2] = DEFINE_RES_MEM_NAMED(SA1100_CS3_PHYS + 0x02000000, + 0x02000000, "smc91x-attrib"), +}; + +static struct platform_device smc91x_device = { + .name = "smc91x", + .id = 0, + .num_resources = ARRAY_SIZE(smc91x_resources), + .resource = smc91x_resources, +}; + static int __devinit neponset_probe(struct platform_device *dev) { sa1100_register_uart_fns(&neponset_port_fns); @@ -249,43 +286,6 @@ static struct platform_device neponset_device = { .resource = neponset_resources, }; -static struct resource sa1111_resources[] = { - [0] = DEFINE_RES_MEM(0x40000000, SZ_8K), - [1] = DEFINE_RES_IRQ(IRQ_NEPONSET_SA1111), -}; - -static struct sa1111_platform_data sa1111_info = { - .irq_base = IRQ_BOARD_END, -}; - -static u64 sa1111_dmamask = 0xffffffffUL; - -static struct platform_device sa1111_device = { - .name = "sa1111", - .id = 0, - .dev = { - .dma_mask = &sa1111_dmamask, - .coherent_dma_mask = 0xffffffff, - .platform_data = &sa1111_info, - }, - .num_resources = ARRAY_SIZE(sa1111_resources), - .resource = sa1111_resources, -}; - -static struct resource smc91x_resources[] = { - [0] = DEFINE_RES_MEM_NAMED(SA1100_CS3_PHYS, 0x02000000, "smc91x-regs"), - [1] = DEFINE_RES_IRQ(IRQ_NEPONSET_SMC9196), - [2] = DEFINE_RES_MEM_NAMED(SA1100_CS3_PHYS + 0x02000000, - 0x02000000, "smc91x-attrib"), -}; - -static struct platform_device smc91x_device = { - .name = "smc91x", - .id = 0, - .num_resources = ARRAY_SIZE(smc91x_resources), - .resource = smc91x_resources, -}; - static struct platform_device *devices[] __initdata = { &neponset_device, &sa1111_device, -- cgit v1.2.3 From 398e58d09d9ca024ecbf9b67dac57a995865bfcd Mon Sep 17 00:00:00 2001 From: Russell King Date: Tue, 24 Jan 2012 23:33:28 +0000 Subject: ARM: sa11x0: neponset: add driver .owner initializer Ensure that the driver .owner field is properly initialized. Signed-off-by: Russell King --- arch/arm/mach-sa1100/neponset.c | 1 + 1 file changed, 1 insertion(+) (limited to 'arch/arm') diff --git a/arch/arm/mach-sa1100/neponset.c b/arch/arm/mach-sa1100/neponset.c index 8fcd542d46f7..1beaa0e5bf3f 100644 --- a/arch/arm/mach-sa1100/neponset.c +++ b/arch/arm/mach-sa1100/neponset.c @@ -272,6 +272,7 @@ static struct platform_driver neponset_device_driver = { .resume = neponset_resume, .driver = { .name = "neponset", + .owner = THIS_MODULE, }, }; -- cgit v1.2.3 From ae14c2e28cd6d78a975dda853d2fdb00a3219c16 Mon Sep 17 00:00:00 2001 From: Russell King Date: Tue, 24 Jan 2012 22:10:02 +0000 Subject: ARM: sa11x0: neponset: save and restore MDM_CTL_0 Save and restore the modem output control register across a suspend/ resume, as well as the NCR register. Place these in a locally allocated data structure rather than needing a new static variable. Signed-off-by: Russell King --- arch/arm/mach-sa1100/neponset.c | 53 ++++++++++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 11 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/mach-sa1100/neponset.c b/arch/arm/mach-sa1100/neponset.c index 1beaa0e5bf3f..6f0aa91d5d34 100644 --- a/arch/arm/mach-sa1100/neponset.c +++ b/arch/arm/mach-sa1100/neponset.c @@ -1,12 +1,13 @@ /* * linux/arch/arm/mach-sa1100/neponset.c - * */ #include #include #include +#include #include #include +#include #include #include @@ -20,6 +21,13 @@ #include #include +struct neponset_drvdata { +#ifdef CONFIG_PM_SLEEP + u32 ncr0; + u32 mdm_ctl_0; +#endif +}; + void neponset_ncr_frob(unsigned int mask, unsigned int val) { unsigned long flags; @@ -200,6 +208,15 @@ static struct platform_device smc91x_device = { static int __devinit neponset_probe(struct platform_device *dev) { + struct neponset_drvdata *d; + int ret; + + d = kzalloc(sizeof(*d), GFP_KERNEL); + if (!d) { + ret = -ENOMEM; + goto err_alloc; + } + sa1100_register_uart_fns(&neponset_port_fns); /* @@ -234,29 +251,42 @@ static int __devinit neponset_probe(struct platform_device *dev) */ NCR_0 = NCR_GP01_OFF; + platform_set_drvdata(dev, d); + return 0; + + err_alloc: + return ret; } -#ifdef CONFIG_PM +static int __devexit neponset_remove(struct platform_device *dev) +{ + struct neponset_drvdata *d = platform_get_drvdata(dev); -/* - * LDM power management. - */ -static unsigned int neponset_saved_state; + irq_set_chained_handler(IRQ_GPIO25, NULL); + + kfree(d); + + return 0; +} +#ifdef CONFIG_PM static int neponset_suspend(struct platform_device *dev, pm_message_t state) { - /* - * Save state. - */ - neponset_saved_state = NCR_0; + struct neponset_drvdata *d = platform_get_drvdata(dev); + + d->ncr0 = NCR_0; + d->mdm_ctl_0 = MDM_CTL_0; return 0; } static int neponset_resume(struct platform_device *dev) { - NCR_0 = neponset_saved_state; + struct neponset_drvdata *d = platform_get_drvdata(dev); + + NCR_0 = d->ncr0; + MDM_CTL_0 = d->mdm_ctl_0; return 0; } @@ -268,6 +298,7 @@ static int neponset_resume(struct platform_device *dev) static struct platform_driver neponset_device_driver = { .probe = neponset_probe, + .remove = __devexit_p(neponset_remove), .suspend = neponset_suspend, .resume = neponset_resume, .driver = { -- cgit v1.2.3 From 9590e898742cd6cd50aab1109a115faf42befaf7 Mon Sep 17 00:00:00 2001 From: Russell King Date: Tue, 24 Jan 2012 22:36:47 +0000 Subject: ARM: sa11x0: neponset: dynamically create neponset child devices Use platform_device_register_full() to dynamically create the various neponset child platform devices, and place them below the neponset device itself to ensure proper PM ordering and device structure. Signed-off-by: Russell King --- arch/arm/mach-sa1100/neponset.c | 56 ++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/mach-sa1100/neponset.c b/arch/arm/mach-sa1100/neponset.c index 6f0aa91d5d34..164bc9801ed7 100644 --- a/arch/arm/mach-sa1100/neponset.c +++ b/arch/arm/mach-sa1100/neponset.c @@ -1,6 +1,7 @@ /* * linux/arch/arm/mach-sa1100/neponset.c */ +#include #include #include #include @@ -22,6 +23,8 @@ #include struct neponset_drvdata { + struct platform_device *sa1111; + struct platform_device *smc91x; #ifdef CONFIG_PM_SLEEP u32 ncr0; u32 mdm_ctl_0; @@ -178,20 +181,6 @@ static struct sa1111_platform_data sa1111_info = { .irq_base = IRQ_BOARD_END, }; -static u64 sa1111_dmamask = 0xffffffffUL; - -static struct platform_device sa1111_device = { - .name = "sa1111", - .id = 0, - .dev = { - .dma_mask = &sa1111_dmamask, - .coherent_dma_mask = 0xffffffff, - .platform_data = &sa1111_info, - }, - .num_resources = ARRAY_SIZE(sa1111_resources), - .resource = sa1111_resources, -}; - static struct resource smc91x_resources[] = { [0] = DEFINE_RES_MEM_NAMED(SA1100_CS3_PHYS, 0x02000000, "smc91x-regs"), [1] = DEFINE_RES_IRQ(IRQ_NEPONSET_SMC9196), @@ -199,16 +188,26 @@ static struct resource smc91x_resources[] = { 0x02000000, "smc91x-attrib"), }; -static struct platform_device smc91x_device = { - .name = "smc91x", - .id = 0, - .num_resources = ARRAY_SIZE(smc91x_resources), - .resource = smc91x_resources, -}; - static int __devinit neponset_probe(struct platform_device *dev) { struct neponset_drvdata *d; + struct platform_device_info sa1111_devinfo = { + .parent = &dev->dev, + .name = "sa1111", + .id = 0, + .res = sa1111_resources, + .num_res = ARRAY_SIZE(sa1111_resources), + .data = &sa1111_info, + .size_data = sizeof(sa1111_info), + .dma_mask = 0xffffffffUL, + }; + struct platform_device_info smc91x_devinfo = { + .parent = &dev->dev, + .name = "smc91x", + .id = 0, + .res = smc91x_resources, + .num_res = ARRAY_SIZE(smc91x_resources), + }; int ret; d = kzalloc(sizeof(*d), GFP_KERNEL); @@ -251,6 +250,9 @@ static int __devinit neponset_probe(struct platform_device *dev) */ NCR_0 = NCR_GP01_OFF; + d->sa1111 = platform_device_register_full(&sa1111_devinfo); + d->smc91x = platform_device_register_full(&smc91x_devinfo); + platform_set_drvdata(dev, d); return 0; @@ -263,6 +265,10 @@ static int __devexit neponset_remove(struct platform_device *dev) { struct neponset_drvdata *d = platform_get_drvdata(dev); + if (!IS_ERR(d->sa1111)) + platform_device_unregister(d->sa1111); + if (!IS_ERR(d->smc91x)) + platform_device_unregister(d->smc91x); irq_set_chained_handler(IRQ_GPIO25, NULL); kfree(d); @@ -318,12 +324,6 @@ static struct platform_device neponset_device = { .resource = neponset_resources, }; -static struct platform_device *devices[] __initdata = { - &neponset_device, - &sa1111_device, - &smc91x_device, -}; - extern void sa1110_mb_disable(void); static int __init neponset_init(void) @@ -354,7 +354,7 @@ static int __init neponset_init(void) return -ENODEV; } - return platform_add_devices(devices, ARRAY_SIZE(devices)); + return platform_device_register(&neponset_device); } subsys_initcall(neponset_init); -- cgit v1.2.3 From ced8d21cf104c9924e98f78954e873577366d156 Mon Sep 17 00:00:00 2001 From: Russell King Date: Tue, 24 Jan 2012 22:22:18 +0000 Subject: ARM: sa11x0: neponset: implement support for sparse IRQs Implement the necessary allocation/freeing functionality to support sparse IRQs with the Neponset device. On non-sparse IRQ platforms, this allows us to dynamically allocate from within the available IRQ number space. Signed-off-by: Russell King --- arch/arm/mach-sa1100/include/mach/irqs.h | 8 --- arch/arm/mach-sa1100/neponset.c | 111 +++++++++++++++++-------------- 2 files changed, 61 insertions(+), 58 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/mach-sa1100/include/mach/irqs.h b/arch/arm/mach-sa1100/include/mach/irqs.h index d18f21abef80..9e07634a4670 100644 --- a/arch/arm/mach-sa1100/include/mach/irqs.h +++ b/arch/arm/mach-sa1100/include/mach/irqs.h @@ -82,11 +82,3 @@ #else #define NR_IRQS (IRQ_BOARD_START) #endif - -/* - * Board specific IRQs. Define them here. - * Do not surround them with ifdefs. - */ -#define IRQ_NEPONSET_SMC9196 (IRQ_BOARD_START + 0) -#define IRQ_NEPONSET_USAR (IRQ_BOARD_START + 1) -#define IRQ_NEPONSET_SA1111 (IRQ_BOARD_START + 2) diff --git a/arch/arm/mach-sa1100/neponset.c b/arch/arm/mach-sa1100/neponset.c index 164bc9801ed7..47681960783b 100644 --- a/arch/arm/mach-sa1100/neponset.c +++ b/arch/arm/mach-sa1100/neponset.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -11,9 +12,7 @@ #include #include -#include #include -#include #include #include #include @@ -22,9 +21,15 @@ #include #include +#define NEP_IRQ_SMC91X 0 +#define NEP_IRQ_USAR 1 +#define NEP_IRQ_SA1111 2 +#define NEP_IRQ_NR 3 + struct neponset_drvdata { struct platform_device *sa1111; struct platform_device *smc91x; + unsigned irq_base; #ifdef CONFIG_PM_SLEEP u32 ncr0; u32 mdm_ctl_0; @@ -104,9 +109,9 @@ static struct sa1100_port_fns neponset_port_fns __devinitdata = { * ensure that the IRQ signal is deasserted before returning. This * is rather unfortunate. */ -static void -neponset_irq_handler(unsigned int irq, struct irq_desc *desc) +static void neponset_irq_handler(unsigned int irq, struct irq_desc *desc) { + struct neponset_drvdata *d = irq_desc_get_handler_data(desc); unsigned int irr; while (1) { @@ -141,26 +146,21 @@ neponset_irq_handler(unsigned int irq, struct irq_desc *desc) */ desc->irq_data.chip->irq_ack(&desc->irq_data); - if (irr & IRR_ETHERNET) { - generic_handle_irq(IRQ_NEPONSET_SMC9196); - } + if (irr & IRR_ETHERNET) + generic_handle_irq(d->irq_base + NEP_IRQ_SMC91X); - if (irr & IRR_USAR) { - generic_handle_irq(IRQ_NEPONSET_USAR); - } + if (irr & IRR_USAR) + generic_handle_irq(d->irq_base + NEP_IRQ_USAR); desc->irq_data.chip->irq_unmask(&desc->irq_data); } - if (irr & IRR_SA1111) { - generic_handle_irq(IRQ_NEPONSET_SA1111); - } + if (irr & IRR_SA1111) + generic_handle_irq(d->irq_base + NEP_IRQ_SA1111); } } -/* - * Yes, we really do not have any kind of masking or unmasking - */ +/* Yes, we really do not have any kind of masking or unmasking */ static void nochip_noop(struct irq_data *irq) { } @@ -172,25 +172,17 @@ static struct irq_chip nochip = { .irq_unmask = nochip_noop, }; -static struct resource sa1111_resources[] = { - [0] = DEFINE_RES_MEM(0x40000000, SZ_8K), - [1] = DEFINE_RES_IRQ(IRQ_NEPONSET_SA1111), -}; - static struct sa1111_platform_data sa1111_info = { .irq_base = IRQ_BOARD_END, }; -static struct resource smc91x_resources[] = { - [0] = DEFINE_RES_MEM_NAMED(SA1100_CS3_PHYS, 0x02000000, "smc91x-regs"), - [1] = DEFINE_RES_IRQ(IRQ_NEPONSET_SMC9196), - [2] = DEFINE_RES_MEM_NAMED(SA1100_CS3_PHYS + 0x02000000, - 0x02000000, "smc91x-attrib"), -}; - static int __devinit neponset_probe(struct platform_device *dev) { struct neponset_drvdata *d; + struct resource sa1111_resources[] = { + DEFINE_RES_MEM(0x40000000, SZ_8K), + { .flags = IORESOURCE_IRQ }, + }; struct platform_device_info sa1111_devinfo = { .parent = &dev->dev, .name = "sa1111", @@ -201,6 +193,13 @@ static int __devinit neponset_probe(struct platform_device *dev) .size_data = sizeof(sa1111_info), .dma_mask = 0xffffffffUL, }; + struct resource smc91x_resources[] = { + DEFINE_RES_MEM_NAMED(SA1100_CS3_PHYS, + 0x02000000, "smc91x-regs"), + DEFINE_RES_MEM_NAMED(SA1100_CS3_PHYS + 0x02000000, + 0x02000000, "smc91x-attrib"), + { .flags = IORESOURCE_IRQ }, + }; struct platform_device_info smc91x_devinfo = { .parent = &dev->dev, .name = "smc91x", @@ -216,47 +215,59 @@ static int __devinit neponset_probe(struct platform_device *dev) goto err_alloc; } - sa1100_register_uart_fns(&neponset_port_fns); + ret = irq_alloc_descs(-1, IRQ_BOARD_START, NEP_IRQ_NR, -1); + if (ret <= 0) { + dev_err(&dev->dev, "unable to allocate %u irqs: %d\n", + NEP_IRQ_NR, ret); + if (ret == 0) + ret = -ENOMEM; + goto err_irq_alloc; + } + + d->irq_base = ret; + + irq_set_chip_and_handler(d->irq_base + NEP_IRQ_SMC91X, &nochip, + handle_simple_irq); + set_irq_flags(d->irq_base + NEP_IRQ_SMC91X, IRQF_VALID | IRQF_PROBE); + irq_set_chip_and_handler(d->irq_base + NEP_IRQ_USAR, &nochip, + handle_simple_irq); + set_irq_flags(d->irq_base + NEP_IRQ_USAR, IRQF_VALID | IRQF_PROBE); + irq_set_chip(d->irq_base + NEP_IRQ_SA1111, &nochip); - /* - * Install handler for GPIO25. - */ irq_set_irq_type(IRQ_GPIO25, IRQ_TYPE_EDGE_RISING); + irq_set_handler_data(IRQ_GPIO25, d); irq_set_chained_handler(IRQ_GPIO25, neponset_irq_handler); /* - * We would set IRQ_GPIO25 to be a wake-up IRQ, but - * unfortunately something on the Neponset activates - * this IRQ on sleep (ethernet?) + * We would set IRQ_GPIO25 to be a wake-up IRQ, but unfortunately + * something on the Neponset activates this IRQ on sleep (eth?) */ #if 0 enable_irq_wake(IRQ_GPIO25); #endif - /* - * Setup other Neponset IRQs. SA1111 will be done by the - * generic SA1111 code. - */ - irq_set_chip_and_handler(IRQ_NEPONSET_SMC9196, &nochip, - handle_simple_irq); - set_irq_flags(IRQ_NEPONSET_SMC9196, IRQF_VALID | IRQF_PROBE); - irq_set_chip_and_handler(IRQ_NEPONSET_USAR, &nochip, - handle_simple_irq); - set_irq_flags(IRQ_NEPONSET_USAR, IRQF_VALID | IRQF_PROBE); - irq_set_chip(IRQ_NEPONSET_SA1111, &nochip); + dev_info(&dev->dev, "Neponset daughter board, providing IRQ%u-%u\n", + d->irq_base, d->irq_base + NEP_IRQ_NR - 1); - /* - * Disable GPIO 0/1 drivers so the buttons work on the module. - */ + sa1100_register_uart_fns(&neponset_port_fns); + + /* Disable GPIO 0/1 drivers so the buttons work on the Assabet */ NCR_0 = NCR_GP01_OFF; + sa1111_resources[1].start = d->irq_base + NEP_IRQ_SA1111; + sa1111_resources[1].end = d->irq_base + NEP_IRQ_SA1111; d->sa1111 = platform_device_register_full(&sa1111_devinfo); + + smc91x_resources[2].start = d->irq_base + NEP_IRQ_SMC91X; + smc91x_resources[2].end = d->irq_base + NEP_IRQ_SMC91X; d->smc91x = platform_device_register_full(&smc91x_devinfo); platform_set_drvdata(dev, d); return 0; + err_irq_alloc: + kfree(d); err_alloc: return ret; } @@ -270,7 +281,7 @@ static int __devexit neponset_remove(struct platform_device *dev) if (!IS_ERR(d->smc91x)) platform_device_unregister(d->smc91x); irq_set_chained_handler(IRQ_GPIO25, NULL); - + irq_free_descs(d->irq_base, NEP_IRQ_NR); kfree(d); return 0; -- cgit v1.2.3 From b6bdfcf5ae634fcb9dce0c16972cf39d90be6f74 Mon Sep 17 00:00:00 2001 From: Russell King Date: Tue, 24 Jan 2012 23:05:08 +0000 Subject: ARM: sa11x0: neponset: get parent IRQ from neponset device resource Obtain the parent IRQ from the neponset device resource rather than hard-coding it into the code. Signed-off-by: Russell King --- arch/arm/mach-sa1100/neponset.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/mach-sa1100/neponset.c b/arch/arm/mach-sa1100/neponset.c index 47681960783b..f4d587151770 100644 --- a/arch/arm/mach-sa1100/neponset.c +++ b/arch/arm/mach-sa1100/neponset.c @@ -207,7 +207,11 @@ static int __devinit neponset_probe(struct platform_device *dev) .res = smc91x_resources, .num_res = ARRAY_SIZE(smc91x_resources), }; - int ret; + int ret, irq; + + irq = ret = platform_get_irq(dev, 0); + if (ret < 0) + goto err_alloc; d = kzalloc(sizeof(*d), GFP_KERNEL); if (!d) { @@ -234,16 +238,16 @@ static int __devinit neponset_probe(struct platform_device *dev) set_irq_flags(d->irq_base + NEP_IRQ_USAR, IRQF_VALID | IRQF_PROBE); irq_set_chip(d->irq_base + NEP_IRQ_SA1111, &nochip); - irq_set_irq_type(IRQ_GPIO25, IRQ_TYPE_EDGE_RISING); - irq_set_handler_data(IRQ_GPIO25, d); - irq_set_chained_handler(IRQ_GPIO25, neponset_irq_handler); + irq_set_irq_type(irq, IRQ_TYPE_EDGE_RISING); + irq_set_handler_data(irq, d); + irq_set_chained_handler(irq, neponset_irq_handler); /* * We would set IRQ_GPIO25 to be a wake-up IRQ, but unfortunately * something on the Neponset activates this IRQ on sleep (eth?) */ #if 0 - enable_irq_wake(IRQ_GPIO25); + enable_irq_wake(irq); #endif dev_info(&dev->dev, "Neponset daughter board, providing IRQ%u-%u\n", @@ -275,12 +279,13 @@ static int __devinit neponset_probe(struct platform_device *dev) static int __devexit neponset_remove(struct platform_device *dev) { struct neponset_drvdata *d = platform_get_drvdata(dev); + int irq = platform_get_irq(dev, 0); if (!IS_ERR(d->sa1111)) platform_device_unregister(d->sa1111); if (!IS_ERR(d->smc91x)) platform_device_unregister(d->smc91x); - irq_set_chained_handler(IRQ_GPIO25, NULL); + irq_set_chained_handler(irq, NULL); irq_free_descs(d->irq_base, NEP_IRQ_NR); kfree(d); @@ -325,7 +330,8 @@ static struct platform_driver neponset_device_driver = { }; static struct resource neponset_resources[] = { - [0] = DEFINE_RES_MEM(0x10000000, 0x08000000), + DEFINE_RES_MEM(0x10000000, 0x08000000), + DEFINE_RES_IRQ(IRQ_GPIO25), }; static struct platform_device neponset_device = { -- cgit v1.2.3 From d2e539a5ebd6b204037deb44c416a9e20b5d2354 Mon Sep 17 00:00:00 2001 From: Russell King Date: Tue, 24 Jan 2012 23:17:37 +0000 Subject: ARM: sa11x0: neponset: place smc91x and sa1111 resources in neponset device Complete the neponset device resources by covering the children's memory resources in the parent neponset device. Signed-off-by: Russell King --- arch/arm/mach-sa1100/neponset.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'arch/arm') diff --git a/arch/arm/mach-sa1100/neponset.c b/arch/arm/mach-sa1100/neponset.c index f4d587151770..2451a38aa2f0 100644 --- a/arch/arm/mach-sa1100/neponset.c +++ b/arch/arm/mach-sa1100/neponset.c @@ -179,6 +179,7 @@ static struct sa1111_platform_data sa1111_info = { static int __devinit neponset_probe(struct platform_device *dev) { struct neponset_drvdata *d; + struct resource *sa1111_res, *smc91x_res; struct resource sa1111_resources[] = { DEFINE_RES_MEM(0x40000000, SZ_8K), { .flags = IORESOURCE_IRQ }, @@ -213,6 +214,13 @@ static int __devinit neponset_probe(struct platform_device *dev) if (ret < 0) goto err_alloc; + smc91x_res = platform_get_resource(dev, IORESOURCE_MEM, 1); + sa1111_res = platform_get_resource(dev, IORESOURCE_MEM, 2); + if (!smc91x_res || !sa1111_res) { + ret = -ENXIO; + goto err_alloc; + } + d = kzalloc(sizeof(*d), GFP_KERNEL); if (!d) { ret = -ENOMEM; @@ -258,10 +266,13 @@ static int __devinit neponset_probe(struct platform_device *dev) /* Disable GPIO 0/1 drivers so the buttons work on the Assabet */ NCR_0 = NCR_GP01_OFF; + sa1111_resources[0].parent = sa1111_res; sa1111_resources[1].start = d->irq_base + NEP_IRQ_SA1111; sa1111_resources[1].end = d->irq_base + NEP_IRQ_SA1111; d->sa1111 = platform_device_register_full(&sa1111_devinfo); + smc91x_resources[0].parent = smc91x_res; + smc91x_resources[1].parent = smc91x_res; smc91x_resources[2].start = d->irq_base + NEP_IRQ_SMC91X; smc91x_resources[2].end = d->irq_base + NEP_IRQ_SMC91X; d->smc91x = platform_device_register_full(&smc91x_devinfo); @@ -331,6 +342,8 @@ static struct platform_driver neponset_device_driver = { static struct resource neponset_resources[] = { DEFINE_RES_MEM(0x10000000, 0x08000000), + DEFINE_RES_MEM(0x18000000, 0x04000000), + DEFINE_RES_MEM(0x40000000, SZ_8K), DEFINE_RES_IRQ(IRQ_GPIO25), }; -- cgit v1.2.3 From 51f93390c21a4154b0520c3a8a34733e4072a7db Mon Sep 17 00:00:00 2001 From: Russell King Date: Tue, 24 Jan 2012 23:29:47 +0000 Subject: ARM: sa11x0: neponset: suspend/resume in _noirq state Suspend and resume in the _noirq state, so that we're saving the state of the modem control signals as late as possible, and restoring them as early as possible. There's nothing to do in thaw/poweroff methods as we've already saved the necessary state. Signed-off-by: Russell King --- arch/arm/mach-sa1100/neponset.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/mach-sa1100/neponset.c b/arch/arm/mach-sa1100/neponset.c index 2451a38aa2f0..59223baa7c1d 100644 --- a/arch/arm/mach-sa1100/neponset.c +++ b/arch/arm/mach-sa1100/neponset.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -303,10 +304,10 @@ static int __devexit neponset_remove(struct platform_device *dev) return 0; } -#ifdef CONFIG_PM -static int neponset_suspend(struct platform_device *dev, pm_message_t state) +#ifdef CONFIG_PM_SLEEP +static int neponset_suspend(struct device *dev) { - struct neponset_drvdata *d = platform_get_drvdata(dev); + struct neponset_drvdata *d = dev_get_drvdata(dev); d->ncr0 = NCR_0; d->mdm_ctl_0 = MDM_CTL_0; @@ -314,9 +315,9 @@ static int neponset_suspend(struct platform_device *dev, pm_message_t state) return 0; } -static int neponset_resume(struct platform_device *dev) +static int neponset_resume(struct device *dev) { - struct neponset_drvdata *d = platform_get_drvdata(dev); + struct neponset_drvdata *d = dev_get_drvdata(dev); NCR_0 = d->ncr0; MDM_CTL_0 = d->mdm_ctl_0; @@ -324,19 +325,24 @@ static int neponset_resume(struct platform_device *dev) return 0; } +static const struct dev_pm_ops neponset_pm_ops = { + .suspend_noirq = neponset_suspend, + .resume_noirq = neponset_resume, + .freeze_noirq = neponset_suspend, + .restore_noirq = neponset_resume, +}; +#define PM_OPS &neponset_pm_ops #else -#define neponset_suspend NULL -#define neponset_resume NULL +#define PM_OPS NULL #endif static struct platform_driver neponset_device_driver = { .probe = neponset_probe, .remove = __devexit_p(neponset_remove), - .suspend = neponset_suspend, - .resume = neponset_resume, .driver = { .name = "neponset", .owner = THIS_MODULE, + .pm = PM_OPS, }, }; -- cgit v1.2.3 From bab50a35ee703955bd708a4a44cd56ed30e601c8 Mon Sep 17 00:00:00 2001 From: Russell King Date: Thu, 26 Jan 2012 11:50:23 +0000 Subject: ARM: sa11x0: assabet/neponest: create neponset device in assabet.c The neponset board is a daughter board for the Assabet. Create the neponset platform device in assabet.c, where we don't have to wrap it with machine_is_assabet() stuff. We also create this device dynamically rather than keeping it as a static device. Signed-off-by: Russell King --- arch/arm/mach-sa1100/assabet.c | 12 +++++++++ arch/arm/mach-sa1100/neponset.c | 56 ++++++++++------------------------------- 2 files changed, 25 insertions(+), 43 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/mach-sa1100/assabet.c b/arch/arm/mach-sa1100/assabet.c index e3805d4c052a..f2030bc22cde 100644 --- a/arch/arm/mach-sa1100/assabet.c +++ b/arch/arm/mach-sa1100/assabet.c @@ -197,6 +197,15 @@ static struct mcp_plat_data assabet_mcp_data = { .sclk_rate = 11981000, }; +#ifdef CONFIG_ASSABET_NEPONSET +static struct resource neponset_resources[] = { + DEFINE_RES_MEM(0x10000000, 0x08000000), + DEFINE_RES_MEM(0x18000000, 0x04000000), + DEFINE_RES_MEM(0x40000000, SZ_8K), + DEFINE_RES_IRQ(IRQ_GPIO25), +}; +#endif + static void __init assabet_init(void) { /* @@ -247,6 +256,9 @@ static void __init assabet_init(void) #ifndef CONFIG_ASSABET_NEPONSET printk( "Warning: Neponset detected but full support " "hasn't been configured in the kernel\n" ); +#else + platform_device_register_simple("neponset", 0, + neponset_resources, ARRAY_SIZE(neponset_resources)); #endif } diff --git a/arch/arm/mach-sa1100/neponset.c b/arch/arm/mach-sa1100/neponset.c index 59223baa7c1d..2a9e1e2223f0 100644 --- a/arch/arm/mach-sa1100/neponset.c +++ b/arch/arm/mach-sa1100/neponset.c @@ -27,6 +27,8 @@ #define NEP_IRQ_SA1111 2 #define NEP_IRQ_NR 3 +extern void sa1110_mb_disable(void); + struct neponset_drvdata { struct platform_device *sa1111; struct platform_device *smc91x; @@ -222,6 +224,13 @@ static int __devinit neponset_probe(struct platform_device *dev) goto err_alloc; } + if (WHOAMI != 0x11) { + dev_warn(&dev->dev, "Neponset board detected, but wrong ID: %02x\n", + WHOAMI); + ret = -ENODEV; + goto err_alloc; + } + d = kzalloc(sizeof(*d), GFP_KERNEL); if (!d) { ret = -ENOMEM; @@ -264,6 +273,9 @@ static int __devinit neponset_probe(struct platform_device *dev) sa1100_register_uart_fns(&neponset_port_fns); + /* Ensure that the memory bus request/grant signals are setup */ + sa1110_mb_disable(); + /* Disable GPIO 0/1 drivers so the buttons work on the Assabet */ NCR_0 = NCR_GP01_OFF; @@ -346,51 +358,9 @@ static struct platform_driver neponset_device_driver = { }, }; -static struct resource neponset_resources[] = { - DEFINE_RES_MEM(0x10000000, 0x08000000), - DEFINE_RES_MEM(0x18000000, 0x04000000), - DEFINE_RES_MEM(0x40000000, SZ_8K), - DEFINE_RES_IRQ(IRQ_GPIO25), -}; - -static struct platform_device neponset_device = { - .name = "neponset", - .id = 0, - .num_resources = ARRAY_SIZE(neponset_resources), - .resource = neponset_resources, -}; - -extern void sa1110_mb_disable(void); - static int __init neponset_init(void) { - platform_driver_register(&neponset_device_driver); - - /* - * The Neponset is only present on the Assabet machine type. - */ - if (!machine_is_assabet()) - return -ENODEV; - - /* - * Ensure that the memory bus request/grant signals are setup, - * and the grant is held in its inactive state, whether or not - * we actually have a Neponset attached. - */ - sa1110_mb_disable(); - - if (!machine_has_neponset()) { - printk(KERN_DEBUG "Neponset expansion board not present\n"); - return -ENODEV; - } - - if (WHOAMI != 0x11) { - printk(KERN_WARNING "Neponset board detected, but " - "wrong ID: %02x\n", WHOAMI); - return -ENODEV; - } - - return platform_device_register(&neponset_device); + return platform_driver_register(&neponset_device_driver); } subsys_initcall(neponset_init); -- cgit v1.2.3 From f942b0fd6c81416bb8d52bc26a76a58c02d87bc2 Mon Sep 17 00:00:00 2001 From: Russell King Date: Sun, 29 Jan 2012 11:19:06 +0000 Subject: ARM: sa11x0: neponset: move register definitions to neponset.c Move the board specific neponset register definitions to the board file, rather than mach/neponset.h. However, as the NCR_0 register definitions are used by some drivers, leave these behind. Signed-off-by: Russell King --- arch/arm/mach-sa1100/include/mach/neponset.h | 48 ----------- arch/arm/mach-sa1100/neponset.c | 114 +++++++++++++++++++++------ 2 files changed, 91 insertions(+), 71 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/mach-sa1100/include/mach/neponset.h b/arch/arm/mach-sa1100/include/mach/neponset.h index 6032216e1830..5516a52a329d 100644 --- a/arch/arm/mach-sa1100/include/mach/neponset.h +++ b/arch/arm/mach-sa1100/include/mach/neponset.h @@ -15,54 +15,6 @@ /* * Neponset definitions: */ - -#define NEPONSET_CPLD_BASE (0x10000000) -#define Nep_p2v( x ) ((x) - NEPONSET_CPLD_BASE + 0xf3000000) -#define Nep_v2p( x ) ((x) - 0xf3000000 + NEPONSET_CPLD_BASE) - -#define _IRR 0x10000024 /* Interrupt Reason Register */ -#define _AUD_CTL 0x100000c0 /* Audio controls (RW) */ -#define _MDM_CTL_0 0x100000b0 /* Modem control 0 (RW) */ -#define _MDM_CTL_1 0x100000b4 /* Modem control 1 (RW) */ -#define _NCR_0 0x100000a0 /* Control Register (RW) */ -#define _KP_X_OUT 0x10000090 /* Keypad row write (RW) */ -#define _KP_Y_IN 0x10000080 /* Keypad column read (RO) */ -#define _SWPK 0x10000020 /* Switch pack (RO) */ -#define _WHOAMI 0x10000000 /* System ID Register (RO) */ - -#define _LEDS 0x10000010 /* LEDs [31:0] (WO) */ - -#define IRR (*((volatile u_char *) Nep_p2v(_IRR))) -#define AUD_CTL (*((volatile u_char *) Nep_p2v(_AUD_CTL))) -#define MDM_CTL_0 (*((volatile u_char *) Nep_p2v(_MDM_CTL_0))) -#define MDM_CTL_1 (*((volatile u_char *) Nep_p2v(_MDM_CTL_1))) -#define NCR_0 (*((volatile u_char *) Nep_p2v(_NCR_0))) -#define KP_X_OUT (*((volatile u_char *) Nep_p2v(_KP_X_OUT))) -#define KP_Y_IN (*((volatile u_char *) Nep_p2v(_KP_Y_IN))) -#define SWPK (*((volatile u_char *) Nep_p2v(_SWPK))) -#define WHOAMI (*((volatile u_char *) Nep_p2v(_WHOAMI))) - -#define LEDS (*((volatile Word *) Nep_p2v(_LEDS))) - -#define IRR_ETHERNET (1<<0) -#define IRR_USAR (1<<1) -#define IRR_SA1111 (1<<2) - -#define AUD_SEL_1341 (1<<0) -#define AUD_MUTE_1341 (1<<1) - -#define MDM_CTL0_RTS1 (1 << 0) -#define MDM_CTL0_DTR1 (1 << 1) -#define MDM_CTL0_RTS2 (1 << 2) -#define MDM_CTL0_DTR2 (1 << 3) - -#define MDM_CTL1_CTS1 (1 << 0) -#define MDM_CTL1_DSR1 (1 << 1) -#define MDM_CTL1_DCD1 (1 << 2) -#define MDM_CTL1_CTS2 (1 << 3) -#define MDM_CTL1_DSR2 (1 << 4) -#define MDM_CTL1_DCD2 (1 << 5) - #define NCR_GP01_OFF (1<<0) #define NCR_TP_PWR_EN (1<<1) #define NCR_MS_PWR_EN (1<<2) diff --git a/arch/arm/mach-sa1100/neponset.c b/arch/arm/mach-sa1100/neponset.c index 2a9e1e2223f0..3c0d4b837adb 100644 --- a/arch/arm/mach-sa1100/neponset.c +++ b/arch/arm/mach-sa1100/neponset.c @@ -27,9 +27,40 @@ #define NEP_IRQ_SA1111 2 #define NEP_IRQ_NR 3 +#define WHOAMI 0x00 +#define LEDS 0x10 +#define SWPK 0x20 +#define IRR 0x24 +#define KP_Y_IN 0x80 +#define KP_X_OUT 0x90 +#define NCR_0 0xa0 +#define MDM_CTL_0 0xb0 +#define MDM_CTL_1 0xb4 +#define AUD_CTL 0xc0 + +#define IRR_ETHERNET (1 << 0) +#define IRR_USAR (1 << 1) +#define IRR_SA1111 (1 << 2) + +#define MDM_CTL0_RTS1 (1 << 0) +#define MDM_CTL0_DTR1 (1 << 1) +#define MDM_CTL0_RTS2 (1 << 2) +#define MDM_CTL0_DTR2 (1 << 3) + +#define MDM_CTL1_CTS1 (1 << 0) +#define MDM_CTL1_DSR1 (1 << 1) +#define MDM_CTL1_DCD1 (1 << 2) +#define MDM_CTL1_CTS2 (1 << 3) +#define MDM_CTL1_DSR2 (1 << 4) +#define MDM_CTL1_DCD2 (1 << 5) + +#define AUD_SEL_1341 (1 << 0) +#define AUD_MUTE_1341 (1 << 1) + extern void sa1110_mb_disable(void); struct neponset_drvdata { + void __iomem *base; struct platform_device *sa1111; struct platform_device *smc91x; unsigned irq_base; @@ -39,19 +70,34 @@ struct neponset_drvdata { #endif }; +static void __iomem *nep_base; + void neponset_ncr_frob(unsigned int mask, unsigned int val) { - unsigned long flags; - - local_irq_save(flags); - NCR_0 = (NCR_0 & ~mask) | val; - local_irq_restore(flags); + void __iomem *base = nep_base; + + if (base) { + unsigned long flags; + unsigned v; + + local_irq_save(flags); + v = readb_relaxed(base + NCR_0); + writeb_relaxed((v & ~mask) | val, base + NCR_0); + local_irq_restore(flags); + } else { + WARN(1, "nep_base unset\n"); + } } static void neponset_set_mctrl(struct uart_port *port, u_int mctrl) { - u_int mdm_ctl0 = MDM_CTL_0; + void __iomem *base = nep_base; + u_int mdm_ctl0; + + if (!base) + return; + mdm_ctl0 = readb_relaxed(base + MDM_CTL_0); if (port->mapbase == _Ser1UTCR0) { if (mctrl & TIOCM_RTS) mdm_ctl0 &= ~MDM_CTL0_RTS2; @@ -74,14 +120,19 @@ static void neponset_set_mctrl(struct uart_port *port, u_int mctrl) mdm_ctl0 |= MDM_CTL0_DTR1; } - MDM_CTL_0 = mdm_ctl0; + writeb_relaxed(mdm_ctl0, base + MDM_CTL_0); } static u_int neponset_get_mctrl(struct uart_port *port) { + void __iomem *base = nep_base; u_int ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR; - u_int mdm_ctl1 = MDM_CTL_1; + u_int mdm_ctl1; + if (!base) + return ret; + + mdm_ctl1 = readb_relaxed(base + MDM_CTL_1); if (port->mapbase == _Ser1UTCR0) { if (mdm_ctl1 & MDM_CTL1_DCD2) ret &= ~TIOCM_CD; @@ -128,7 +179,8 @@ static void neponset_irq_handler(unsigned int irq, struct irq_desc *desc) * active IRQ bits high. Note: there is a typo in the * Neponset user's guide for the SA1111 IRR level. */ - irr = IRR ^ (IRR_ETHERNET | IRR_USAR); + irr = readb_relaxed(d->base + IRR); + irr ^= IRR_ETHERNET | IRR_USAR; if ((irr & (IRR_ETHERNET | IRR_USAR | IRR_SA1111)) == 0) break; @@ -182,7 +234,7 @@ static struct sa1111_platform_data sa1111_info = { static int __devinit neponset_probe(struct platform_device *dev) { struct neponset_drvdata *d; - struct resource *sa1111_res, *smc91x_res; + struct resource *nep_res, *sa1111_res, *smc91x_res; struct resource sa1111_resources[] = { DEFINE_RES_MEM(0x40000000, SZ_8K), { .flags = IORESOURCE_IRQ }, @@ -213,30 +265,40 @@ static int __devinit neponset_probe(struct platform_device *dev) }; int ret, irq; + if (nep_base) + return -EBUSY; + irq = ret = platform_get_irq(dev, 0); if (ret < 0) goto err_alloc; + nep_res = platform_get_resource(dev, IORESOURCE_MEM, 0); smc91x_res = platform_get_resource(dev, IORESOURCE_MEM, 1); sa1111_res = platform_get_resource(dev, IORESOURCE_MEM, 2); - if (!smc91x_res || !sa1111_res) { + if (!nep_res || !smc91x_res || !sa1111_res) { ret = -ENXIO; goto err_alloc; } - if (WHOAMI != 0x11) { - dev_warn(&dev->dev, "Neponset board detected, but wrong ID: %02x\n", - WHOAMI); - ret = -ENODEV; - goto err_alloc; - } - d = kzalloc(sizeof(*d), GFP_KERNEL); if (!d) { ret = -ENOMEM; goto err_alloc; } + d->base = ioremap(nep_res->start, SZ_4K); + if (!d->base) { + ret = -ENOMEM; + goto err_ioremap; + } + + if (readb_relaxed(d->base + WHOAMI) != 0x11) { + dev_warn(&dev->dev, "Neponset board detected, but wrong ID: %02x\n", + readb_relaxed(d->base + WHOAMI)); + ret = -ENODEV; + goto err_id; + } + ret = irq_alloc_descs(-1, IRQ_BOARD_START, NEP_IRQ_NR, -1); if (ret <= 0) { dev_err(&dev->dev, "unable to allocate %u irqs: %d\n", @@ -270,6 +332,7 @@ static int __devinit neponset_probe(struct platform_device *dev) dev_info(&dev->dev, "Neponset daughter board, providing IRQ%u-%u\n", d->irq_base, d->irq_base + NEP_IRQ_NR - 1); + nep_base = d->base; sa1100_register_uart_fns(&neponset_port_fns); @@ -277,7 +340,7 @@ static int __devinit neponset_probe(struct platform_device *dev) sa1110_mb_disable(); /* Disable GPIO 0/1 drivers so the buttons work on the Assabet */ - NCR_0 = NCR_GP01_OFF; + writeb_relaxed(NCR_GP01_OFF, d->base + NCR_0); sa1111_resources[0].parent = sa1111_res; sa1111_resources[1].start = d->irq_base + NEP_IRQ_SA1111; @@ -295,6 +358,9 @@ static int __devinit neponset_probe(struct platform_device *dev) return 0; err_irq_alloc: + err_id: + iounmap(d->base); + err_ioremap: kfree(d); err_alloc: return ret; @@ -311,6 +377,8 @@ static int __devexit neponset_remove(struct platform_device *dev) platform_device_unregister(d->smc91x); irq_set_chained_handler(irq, NULL); irq_free_descs(d->irq_base, NEP_IRQ_NR); + nep_base = NULL; + iounmap(d->base); kfree(d); return 0; @@ -321,8 +389,8 @@ static int neponset_suspend(struct device *dev) { struct neponset_drvdata *d = dev_get_drvdata(dev); - d->ncr0 = NCR_0; - d->mdm_ctl_0 = MDM_CTL_0; + d->ncr0 = readb_relaxed(d->base + NCR_0); + d->mdm_ctl_0 = readb_relaxed(d->base + MDM_CTL_0); return 0; } @@ -331,8 +399,8 @@ static int neponset_resume(struct device *dev) { struct neponset_drvdata *d = dev_get_drvdata(dev); - NCR_0 = d->ncr0; - MDM_CTL_0 = d->mdm_ctl_0; + writeb_relaxed(d->ncr0, d->base + NCR_0); + writeb_relaxed(d->mdm_ctl_0, d->base + MDM_CTL_0); return 0; } -- cgit v1.2.3 From fbae0f8912dc12b284433c05417ea76311205bbf Mon Sep 17 00:00:00 2001 From: Russell King Date: Sun, 29 Jan 2012 11:23:33 +0000 Subject: ARM: sa11x0: neponset: don't static map neponset registers Now that we ioremap() the neponset register space, there's no need to static map the neponset registers. Get rid of this static mapping. Signed-off-by: Russell King --- arch/arm/mach-sa1100/neponset.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/mach-sa1100/neponset.c b/arch/arm/mach-sa1100/neponset.c index 3c0d4b837adb..7ffa631eede4 100644 --- a/arch/arm/mach-sa1100/neponset.c +++ b/arch/arm/mach-sa1100/neponset.c @@ -434,12 +434,7 @@ static int __init neponset_init(void) subsys_initcall(neponset_init); static struct map_desc neponset_io_desc[] __initdata = { - { /* System Registers */ - .virtual = 0xf3000000, - .pfn = __phys_to_pfn(0x10000000), - .length = SZ_1M, - .type = MT_DEVICE - }, { /* SA-1111 */ + { /* SA-1111 */ .virtual = 0xf4000000, .pfn = __phys_to_pfn(0x40000000), .length = SZ_1M, -- cgit v1.2.3 From 29c140b623ce2c55131c6d1c26a2f3e455723b81 Mon Sep 17 00:00:00 2001 From: Russell King Date: Fri, 3 Feb 2012 19:03:31 +0000 Subject: ARM: sa1111: fix memory request/grant setup on PM events We weren't re-enabling the memory request/grant signals on resume, causing DMA devices on the sa1111 to fail. Acked-by: Nicolas Pitre Signed-off-by: Russell King --- arch/arm/common/sa1111.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'arch/arm') diff --git a/arch/arm/common/sa1111.c b/arch/arm/common/sa1111.c index 61691cdbdcf2..c7bed309b3aa 100644 --- a/arch/arm/common/sa1111.c +++ b/arch/arm/common/sa1111.c @@ -87,7 +87,8 @@ #define IRQ_S0_BVD1_STSCHG (53) #define IRQ_S1_BVD1_STSCHG (54) -extern void __init sa1110_mb_enable(void); +extern void sa1110_mb_enable(void); +extern void sa1110_mb_disable(void); /* * We keep the following data for the overall SA1111. Note that the @@ -926,6 +927,10 @@ static int sa1111_suspend(struct platform_device *dev, pm_message_t state) spin_unlock_irqrestore(&sachip->lock, flags); +#ifdef CONFIG_ARCH_SA1100 + sa1110_mb_disable(); +#endif + return 0; } @@ -966,6 +971,11 @@ static int sa1111_resume(struct platform_device *dev) */ sa1111_wake(sachip); +#ifdef CONFIG_ARCH_SA1100 + /* Enable the memory bus request/grant signals */ + sa1110_mb_enable(); +#endif + /* * Only lock for write ops. Also, sa1111_wake must be called with * released spinlock! -- cgit v1.2.3 From a22db0f38243f68957c89b1b9689a2064507bed6 Mon Sep 17 00:00:00 2001 From: Russell King Date: Fri, 3 Feb 2012 19:05:13 +0000 Subject: ARM: sa1111: fix PWM state on suspend We should not write to the SA1111 registers after setting the SLEEP bit. Moreover, the manual says that the PWM registers should be disabled before we enter sleep. So, move the clearing of these registers earlier in the suspend sequence. Acked-by: Nicolas Pitre Signed-off-by: Russell King --- arch/arm/common/sa1111.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/common/sa1111.c b/arch/arm/common/sa1111.c index c7bed309b3aa..f0d9faadcc3f 100644 --- a/arch/arm/common/sa1111.c +++ b/arch/arm/common/sa1111.c @@ -905,6 +905,9 @@ static int sa1111_suspend(struct platform_device *dev, pm_message_t state) save->skpwm0 = sa1111_readl(base + SA1111_SKPWM0); save->skpwm1 = sa1111_readl(base + SA1111_SKPWM1); + sa1111_writel(0, sachip->base + SA1111_SKPWM0); + sa1111_writel(0, sachip->base + SA1111_SKPWM1); + base = sachip->base + SA1111_INTC; save->intpol0 = sa1111_readl(base + SA1111_INTPOL0); save->intpol1 = sa1111_readl(base + SA1111_INTPOL1); @@ -920,8 +923,6 @@ static int sa1111_suspend(struct platform_device *dev, pm_message_t state) */ val = sa1111_readl(sachip->base + SA1111_SKCR); sa1111_writel(val | SKCR_SLEEP, sachip->base + SA1111_SKCR); - sa1111_writel(0, sachip->base + SA1111_SKPWM0); - sa1111_writel(0, sachip->base + SA1111_SKPWM1); clk_disable(sachip->clk); -- cgit v1.2.3 From 4d5d11285c78691efb17148dfc3d56642bee6204 Mon Sep 17 00:00:00 2001 From: Russell King Date: Sat, 14 Jan 2012 16:09:22 +0000 Subject: ARM: sa1111: add sa1111 core driver .owner initializer Add an initializer for the struct device_driver .owner member. Acked-by: Nicolas Pitre Signed-off-by: Russell King --- arch/arm/common/sa1111.c | 1 + 1 file changed, 1 insertion(+) (limited to 'arch/arm') diff --git a/arch/arm/common/sa1111.c b/arch/arm/common/sa1111.c index f0d9faadcc3f..957f6e3c4280 100644 --- a/arch/arm/common/sa1111.c +++ b/arch/arm/common/sa1111.c @@ -1064,6 +1064,7 @@ static struct platform_driver sa1111_device_driver = { .resume = sa1111_resume, .driver = { .name = "sa1111", + .owner = THIS_MODULE, }, }; -- cgit v1.2.3 From f03ecaa0aa3a3b74b9b9e8341cf7919516c902d5 Mon Sep 17 00:00:00 2001 From: Russell King Date: Mon, 16 Jan 2012 00:09:22 +0000 Subject: ARM: sa1111: finish "allow cascaded IRQs to be used by platforms" Commit 19851c58e680 (sa1111: allow cascaded IRQs to be used by platforms) moved the IRQ definitions to the .c file, and added an irq_base member to the private data structure. The inerrupt demultiplexer uses irq_base, but the interrupt setup code does not. Also, although the commit adds a private data structure to pass this data, it isn't even referenced, resulting in irq_base being zero. We also copied the IRQ numbers from the device info array into the actual devices, resulting in wrong interrupt numbers passed to the sub-devices. The net effect of this is that we always overwrite IRQs 0-54, even if they are allocated elsewhere in the system. Add the code necessary to setup the private irq_base, and use it in the IRQ setup code. Make the SA-1111 probe fail with -EINVAL if there is no platform data provided. Acked-by: Nicolas Pitre Signed-off-by: Russell King --- arch/arm/common/sa1111.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/common/sa1111.c b/arch/arm/common/sa1111.c index 957f6e3c4280..d3a8f5e26487 100644 --- a/arch/arm/common/sa1111.c +++ b/arch/arm/common/sa1111.c @@ -438,7 +438,7 @@ static struct irq_chip sa1111_high_chip = { static void sa1111_setup_irq(struct sa1111 *sachip) { void __iomem *irqbase = sachip->base + SA1111_INTC; - unsigned int irq; + unsigned i, irq; /* * We're guaranteed that this region hasn't been taken. @@ -464,14 +464,16 @@ static void sa1111_setup_irq(struct sa1111 *sachip) sa1111_writel(~0, irqbase + SA1111_INTSTATCLR0); sa1111_writel(~0, irqbase + SA1111_INTSTATCLR1); - for (irq = IRQ_GPAIN0; irq <= SSPROR; irq++) { + for (i = IRQ_GPAIN0; i <= SSPROR; i++) { + irq = sachip->irq_base + i; irq_set_chip_and_handler(irq, &sa1111_low_chip, handle_edge_irq); irq_set_chip_data(irq, sachip); set_irq_flags(irq, IRQF_VALID | IRQF_PROBE); } - for (irq = AUDXMTDMADONEA; irq <= IRQ_S1_BVD1_STSCHG; irq++) { + for (i = AUDXMTDMADONEA; i <= IRQ_S1_BVD1_STSCHG; i++) { + irq = sachip->irq_base + i; irq_set_chip_and_handler(irq, &sa1111_high_chip, handle_edge_irq); irq_set_chip_data(irq, sachip); @@ -625,6 +627,7 @@ sa1111_init_one_child(struct sa1111 *sachip, struct resource *parent, struct sa1111_dev_info *info) { struct sa1111_dev *dev; + unsigned i; int ret; dev = kzalloc(sizeof(struct sa1111_dev), GFP_KERNEL); @@ -645,7 +648,9 @@ sa1111_init_one_child(struct sa1111 *sachip, struct resource *parent, dev->res.flags = IORESOURCE_MEM; dev->mapbase = sachip->base + info->offset; dev->skpcr_mask = info->skpcr_mask; - memmove(dev->irq, info->irq, sizeof(dev->irq)); + + for (i = 0; i < ARRAY_SIZE(info->irq); i++) + dev->irq[i] = sachip->irq_base + info->irq[i]; ret = request_resource(parent, &dev->res); if (ret) { @@ -699,16 +704,21 @@ out: * Returns: * %-ENODEV device not found. * %-EBUSY physical address already marked in-use. + * %-EINVAL no platform data passed * %0 successful. */ static int __devinit __sa1111_probe(struct device *me, struct resource *mem, int irq) { + struct sa1111_platform_data *pd = me->platform_data; struct sa1111 *sachip; unsigned long id; unsigned int has_devs; int i, ret = -ENODEV; + if (!pd) + return -EINVAL; + sachip = kzalloc(sizeof(struct sa1111), GFP_KERNEL); if (!sachip) return -ENOMEM; @@ -730,6 +740,7 @@ __sa1111_probe(struct device *me, struct resource *mem, int irq) sachip->phys = mem->start; sachip->irq = irq; + sachip->irq_base = pd->irq_base; /* * Map the whole region. This also maps the -- cgit v1.2.3 From 36d312130228504a223de44739c807b0353248c1 Mon Sep 17 00:00:00 2001 From: Russell King Date: Tue, 24 Jan 2012 21:25:20 +0000 Subject: ARM: sa1111: implement support for sparse IRQs Implement the necessary allocation/freeing functionality to support sparse IRQs with the SA-1111 device. On non-sparse IRQ platforms, this allows us to dynamically allocate from within the available IRQ number space. Acked-by: Nicolas Pitre Signed-off-by: Russell King --- arch/arm/common/sa1111.c | 43 ++++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/common/sa1111.c b/arch/arm/common/sa1111.c index d3a8f5e26487..b64a3360c8c2 100644 --- a/arch/arm/common/sa1111.c +++ b/arch/arm/common/sa1111.c @@ -16,6 +16,7 @@ */ #include #include +#include #include #include #include @@ -28,9 +29,8 @@ #include #include -#include -#include #include +#include #include #include @@ -86,6 +86,7 @@ #define IRQ_S1_CD_VALID (52) #define IRQ_S0_BVD1_STSCHG (53) #define IRQ_S1_BVD1_STSCHG (54) +#define SA1111_IRQ_NR (55) extern void sa1110_mb_enable(void); extern void sa1110_mb_disable(void); @@ -435,16 +436,28 @@ static struct irq_chip sa1111_high_chip = { .irq_set_wake = sa1111_wake_highirq, }; -static void sa1111_setup_irq(struct sa1111 *sachip) +static int sa1111_setup_irq(struct sa1111 *sachip, unsigned irq_base) { void __iomem *irqbase = sachip->base + SA1111_INTC; unsigned i, irq; + int ret; /* * We're guaranteed that this region hasn't been taken. */ request_mem_region(sachip->phys + SA1111_INTC, 512, "irq"); + ret = irq_alloc_descs(-1, irq_base, SA1111_IRQ_NR, -1); + if (ret <= 0) { + dev_err(sachip->dev, "unable to allocate %u irqs: %d\n", + SA1111_IRQ_NR, ret); + if (ret == 0) + ret = -EINVAL; + return ret; + } + + sachip->irq_base = ret; + /* disable all IRQs */ sa1111_writel(0, irqbase + SA1111_INTEN0); sa1111_writel(0, irqbase + SA1111_INTEN1); @@ -486,6 +499,11 @@ static void sa1111_setup_irq(struct sa1111 *sachip) irq_set_irq_type(sachip->irq, IRQ_TYPE_EDGE_RISING); irq_set_handler_data(sachip->irq, sachip); irq_set_chained_handler(sachip->irq, sa1111_irq_handler); + + dev_info(sachip->dev, "Providing IRQ%u-%u\n", + sachip->irq_base, sachip->irq_base + SA1111_IRQ_NR - 1); + + return 0; } /* @@ -740,7 +758,6 @@ __sa1111_probe(struct device *me, struct resource *mem, int irq) sachip->phys = mem->start; sachip->irq = irq; - sachip->irq_base = pd->irq_base; /* * Map the whole region. This also maps the @@ -771,6 +788,16 @@ __sa1111_probe(struct device *me, struct resource *mem, int irq) */ sa1111_wake(sachip); + /* + * The interrupt controller must be initialised before any + * other device to ensure that the interrupts are available. + */ + if (sachip->irq != NO_IRQ) { + ret = sa1111_setup_irq(sachip, pd->irq_base); + if (ret) + goto err_unmap; + } + #ifdef CONFIG_ARCH_SA1100 { unsigned int val; @@ -801,13 +828,6 @@ __sa1111_probe(struct device *me, struct resource *mem, int irq) } #endif - /* - * The interrupt controller must be initialised before any - * other device to ensure that the interrupts are available. - */ - if (sachip->irq != NO_IRQ) - sa1111_setup_irq(sachip); - g_sa1111 = sachip; has_devs = ~0; @@ -858,6 +878,7 @@ static void __sa1111_remove(struct sa1111 *sachip) if (sachip->irq != NO_IRQ) { irq_set_chained_handler(sachip->irq, NULL); irq_set_handler_data(sachip->irq, NULL); + irq_free_descs(sachip->irq_base, SA1111_IRQ_NR); release_mem_region(sachip->phys + SA1111_INTC, 512); } -- cgit v1.2.3 From 6bd72f0562142ddae26a052cfc4e578ad6953d06 Mon Sep 17 00:00:00 2001 From: Russell King Date: Thu, 26 Jan 2012 11:01:18 +0000 Subject: ARM: sa1111: add shutdown hook to sa1111_driver structure Add a shutdown hook to the sa1111_driver structure to allow drivers to be notified of system reboots and shutdowns. Acked-by: Nicolas Pitre Signed-off-by: Russell King --- arch/arm/common/sa1111.c | 9 +++++++++ arch/arm/include/asm/hardware/sa1111.h | 1 + 2 files changed, 10 insertions(+) (limited to 'arch/arm') diff --git a/arch/arm/common/sa1111.c b/arch/arm/common/sa1111.c index b64a3360c8c2..b0f93628dcd7 100644 --- a/arch/arm/common/sa1111.c +++ b/arch/arm/common/sa1111.c @@ -1348,6 +1348,14 @@ static int sa1111_bus_resume(struct device *dev) return ret; } +static void sa1111_bus_shutdown(struct device *dev) +{ + struct sa1111_driver *drv = SA1111_DRV(dev->driver); + + if (drv && drv->shutdown) + drv->shutdown(SA1111_DEV(dev)); +} + static int sa1111_bus_probe(struct device *dev) { struct sa1111_dev *sadev = SA1111_DEV(dev); @@ -1377,6 +1385,7 @@ struct bus_type sa1111_bus_type = { .remove = sa1111_bus_remove, .suspend = sa1111_bus_suspend, .resume = sa1111_bus_resume, + .shutdown = sa1111_bus_shutdown, }; EXPORT_SYMBOL(sa1111_bus_type); diff --git a/arch/arm/include/asm/hardware/sa1111.h b/arch/arm/include/asm/hardware/sa1111.h index 92ed254c175b..29e320f6f85f 100644 --- a/arch/arm/include/asm/hardware/sa1111.h +++ b/arch/arm/include/asm/hardware/sa1111.h @@ -548,6 +548,7 @@ struct sa1111_driver { int (*remove)(struct sa1111_dev *); int (*suspend)(struct sa1111_dev *, pm_message_t); int (*resume)(struct sa1111_dev *); + void (*shutdown)(struct sa1111_dev *); }; #define SA1111_DRV(_d) container_of((_d), struct sa1111_driver, drv) -- cgit v1.2.3 From ae99ddbc976572194e8a68cb9ca1e27805ce30c7 Mon Sep 17 00:00:00 2001 From: Russell King Date: Thu, 26 Jan 2012 13:25:47 +0000 Subject: ARM: sa1111: add platform enable/disable functions Add platform hooks to be called when individual sa1111 devices are enabled and disabled. This will allow us to move some platform specifics out of the individual drivers. Acked-by: Nicolas Pitre Signed-off-by: Russell King --- arch/arm/common/sa1111.c | 22 +++++++++++++++++----- arch/arm/include/asm/hardware/sa1111.h | 8 ++++++-- drivers/input/serio/sa1111ps2.c | 6 +++++- drivers/pcmcia/sa1111_generic.c | 11 +++++++++-- drivers/usb/host/ohci-sa1111.c | 19 ++++++++++++++----- 5 files changed, 51 insertions(+), 15 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/common/sa1111.c b/arch/arm/common/sa1111.c index b0f93628dcd7..1366e82e6707 100644 --- a/arch/arm/common/sa1111.c +++ b/arch/arm/common/sa1111.c @@ -106,6 +106,7 @@ struct sa1111 { int irq_base; /* base for cascaded on-chip IRQs */ spinlock_t lock; void __iomem *base; + struct sa1111_platform_data *pdata; #ifdef CONFIG_PM void *saved_state; #endif @@ -756,6 +757,7 @@ __sa1111_probe(struct device *me, struct resource *mem, int irq) sachip->dev = me; dev_set_drvdata(sachip->dev, sachip); + sachip->pdata = pd; sachip->phys = mem->start; sachip->irq = irq; @@ -1282,16 +1284,23 @@ EXPORT_SYMBOL(sa1111_set_sleep_io); * sa1111_enable_device - enable an on-chip SA1111 function block * @sadev: SA1111 function block device to enable */ -void sa1111_enable_device(struct sa1111_dev *sadev) +int sa1111_enable_device(struct sa1111_dev *sadev) { struct sa1111 *sachip = sa1111_chip_driver(sadev); unsigned long flags; unsigned int val; + int ret = 0; - spin_lock_irqsave(&sachip->lock, flags); - val = sa1111_readl(sachip->base + SA1111_SKPCR); - sa1111_writel(val | sadev->skpcr_mask, sachip->base + SA1111_SKPCR); - spin_unlock_irqrestore(&sachip->lock, flags); + if (sachip->pdata && sachip->pdata->enable) + ret = sachip->pdata->enable(sachip->pdata->data, sadev->devid); + + if (ret == 0) { + spin_lock_irqsave(&sachip->lock, flags); + val = sa1111_readl(sachip->base + SA1111_SKPCR); + sa1111_writel(val | sadev->skpcr_mask, sachip->base + SA1111_SKPCR); + spin_unlock_irqrestore(&sachip->lock, flags); + } + return ret; } EXPORT_SYMBOL(sa1111_enable_device); @@ -1309,6 +1318,9 @@ void sa1111_disable_device(struct sa1111_dev *sadev) val = sa1111_readl(sachip->base + SA1111_SKPCR); sa1111_writel(val & ~sadev->skpcr_mask, sachip->base + SA1111_SKPCR); spin_unlock_irqrestore(&sachip->lock, flags); + + if (sachip->pdata && sachip->pdata->disable) + sachip->pdata->disable(sachip->pdata->data, sadev->devid); } EXPORT_SYMBOL(sa1111_disable_device); diff --git a/arch/arm/include/asm/hardware/sa1111.h b/arch/arm/include/asm/hardware/sa1111.h index 29e320f6f85f..d54d781021c8 100644 --- a/arch/arm/include/asm/hardware/sa1111.h +++ b/arch/arm/include/asm/hardware/sa1111.h @@ -556,9 +556,10 @@ struct sa1111_driver { #define SA1111_DRIVER_NAME(_sadev) ((_sadev)->dev.driver->name) /* - * These frob the SKPCR register. + * These frob the SKPCR register, and call platform specific + * enable/disable functions. */ -void sa1111_enable_device(struct sa1111_dev *); +int sa1111_enable_device(struct sa1111_dev *); void sa1111_disable_device(struct sa1111_dev *); unsigned int sa1111_pll_clock(struct sa1111_dev *); @@ -581,6 +582,9 @@ void sa1111_set_sleep_io(struct sa1111_dev *sadev, unsigned int bits, unsigned i struct sa1111_platform_data { int irq_base; /* base for cascaded on-chip IRQs */ + void *data; + int (*enable)(void *, unsigned); + void (*disable)(void *, unsigned); }; #endif /* _ASM_ARCH_SA1111 */ diff --git a/drivers/input/serio/sa1111ps2.c b/drivers/input/serio/sa1111ps2.c index 40ec545fbd40..ad7d23b5c6fe 100644 --- a/drivers/input/serio/sa1111ps2.c +++ b/drivers/input/serio/sa1111ps2.c @@ -124,13 +124,16 @@ static int ps2_open(struct serio *io) struct ps2if *ps2if = io->port_data; int ret; - sa1111_enable_device(ps2if->dev); + ret = sa1111_enable_device(ps2if->dev); + if (ret) + return ret; ret = request_irq(ps2if->dev->irq[0], ps2_rxint, 0, SA1111_DRIVER_NAME(ps2if->dev), ps2if); if (ret) { printk(KERN_ERR "sa1111ps2: could not allocate IRQ%d: %d\n", ps2if->dev->irq[0], ret); + sa1111_disable_device(ps2if->dev); return ret; } @@ -140,6 +143,7 @@ static int ps2_open(struct serio *io) printk(KERN_ERR "sa1111ps2: could not allocate IRQ%d: %d\n", ps2if->dev->irq[1], ret); free_irq(ps2if->dev->irq[0], ps2if); + sa1111_disable_device(ps2if->dev); return ret; } diff --git a/drivers/pcmcia/sa1111_generic.c b/drivers/pcmcia/sa1111_generic.c index 27f2fe3b7fb4..0735c3e6a8b0 100644 --- a/drivers/pcmcia/sa1111_generic.c +++ b/drivers/pcmcia/sa1111_generic.c @@ -163,12 +163,18 @@ int sa1111_pcmcia_add(struct sa1111_dev *dev, struct pcmcia_low_level *ops, static int pcmcia_probe(struct sa1111_dev *dev) { void __iomem *base; + int ret; + + ret = sa1111_enable_device(dev); + if (ret) + return ret; dev_set_drvdata(&dev->dev, NULL); - if (!request_mem_region(dev->res.start, 512, - SA1111_DRIVER_NAME(dev))) + if (!request_mem_region(dev->res.start, 512, SA1111_DRIVER_NAME(dev))) { + sa1111_disable_device(dev); return -EBUSY; + } base = dev->mapbase; @@ -212,6 +218,7 @@ static int __devexit pcmcia_remove(struct sa1111_dev *dev) } release_mem_region(dev->res.start, 512); + sa1111_disable_device(dev); return 0; } diff --git a/drivers/usb/host/ohci-sa1111.c b/drivers/usb/host/ohci-sa1111.c index 7d2aa62ea613..f61f4f90529e 100644 --- a/drivers/usb/host/ohci-sa1111.c +++ b/drivers/usb/host/ohci-sa1111.c @@ -27,9 +27,10 @@ extern int usb_disabled(void); /*-------------------------------------------------------------------------*/ -static void sa1111_start_hc(struct sa1111_dev *dev) +static int sa1111_start_hc(struct sa1111_dev *dev) { unsigned int usb_rst = 0; + int ret; printk(KERN_DEBUG "%s: starting SA-1111 OHCI USB Controller\n", __FILE__); @@ -57,9 +58,13 @@ static void sa1111_start_hc(struct sa1111_dev *dev) * Now, carefully enable the USB clock, and take * the USB host controller out of reset. */ - sa1111_enable_device(dev); - udelay(11); - sa1111_writel(usb_rst, dev->mapbase + SA1111_USB_RESET); + ret = sa1111_enable_device(dev); + if (ret == 0) { + udelay(11); + sa1111_writel(usb_rst, dev->mapbase + SA1111_USB_RESET); + } + + return ret; } static void sa1111_stop_hc(struct sa1111_dev *dev) @@ -140,7 +145,10 @@ int usb_hcd_sa1111_probe (const struct hc_driver *driver, } hcd->regs = dev->mapbase; - sa1111_start_hc(dev); + ret = sa1111_start_hc(dev); + if (ret) + goto err2; + ohci_hcd_init(hcd_to_ohci(hcd)); retval = usb_add_hcd(hcd, dev->irq[1], 0); @@ -148,6 +156,7 @@ int usb_hcd_sa1111_probe (const struct hc_driver *driver, return retval; sa1111_stop_hc(dev); + err2: release_mem_region(hcd->rsrc_start, hcd->rsrc_len); err1: usb_put_hcd(hcd); -- cgit v1.2.3 From 3259701cc2969ae16a0018d7e3a89f327fa23a6e Mon Sep 17 00:00:00 2001 From: Russell King Date: Thu, 26 Jan 2012 13:28:35 +0000 Subject: ARM: sa11x0: badge4: move board specific ohci initialization to badge4.c Move the handling of the 5v supply into badge4.c, removing this board specific detail from the sa1111 ohci driver. Acked-by: Nicolas Pitre Signed-off-by: Russell King --- arch/arm/mach-sa1100/badge4.c | 15 +++++++++++++++ drivers/usb/host/ohci-sa1111.c | 14 -------------- 2 files changed, 15 insertions(+), 14 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/mach-sa1100/badge4.c b/arch/arm/mach-sa1100/badge4.c index b07a2c024cb7..d84924993bad 100644 --- a/arch/arm/mach-sa1100/badge4.c +++ b/arch/arm/mach-sa1100/badge4.c @@ -51,8 +51,23 @@ static struct resource sa1111_resources[] = { }, }; +static int badge4_sa1111_enable(void *data, unsigned devid) +{ + if (devid == SA1111_DEVID_USB) + badge4_set_5V(BADGE4_5V_USB, 1); + return 0; +} + +static void badge4_sa1111_disable(void *data, unsigned devid) +{ + if (devid == SA1111_DEVID_USB) + badge4_set_5V(BADGE4_5V_USB, 0); +} + static struct sa1111_platform_data sa1111_info = { .irq_base = IRQ_BOARD_END, + .enable = badge4_sa1111_enable, + .disable = badge4_sa1111_disable, }; static u64 sa1111_dmamask = 0xffffffffUL; diff --git a/drivers/usb/host/ohci-sa1111.c b/drivers/usb/host/ohci-sa1111.c index f61f4f90529e..48300080433c 100644 --- a/drivers/usb/host/ohci-sa1111.c +++ b/drivers/usb/host/ohci-sa1111.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #ifndef CONFIG_SA1111 @@ -35,12 +34,6 @@ static int sa1111_start_hc(struct sa1111_dev *dev) printk(KERN_DEBUG "%s: starting SA-1111 OHCI USB Controller\n", __FILE__); -#ifdef CONFIG_SA1100_BADGE4 - if (machine_is_badge4()) { - badge4_set_5V(BADGE4_5V_USB, 1); - } -#endif - if (machine_is_xp860() || machine_has_neponset() || machine_is_pfs168() || @@ -84,13 +77,6 @@ static void sa1111_stop_hc(struct sa1111_dev *dev) * Stop the USB clock. */ sa1111_disable_device(dev); - -#ifdef CONFIG_SA1100_BADGE4 - if (machine_is_badge4()) { - /* Disable power to the USB bus */ - badge4_set_5V(BADGE4_5V_USB, 0); - } -#endif } -- cgit v1.2.3 From e5c0fc4185c551c270868dcb6573604db2bc3171 Mon Sep 17 00:00:00 2001 From: Russell King Date: Wed, 25 Jan 2012 10:42:52 +0000 Subject: ARM: sa1111: change devid to be a bitmask Change the sa1111 device id to be a bitmask. This allows us to specify the actual device, while allowing a single driver to bind to both PS2 devices. Acked-by: Nicolas Pitre Signed-off-by: Russell King --- arch/arm/common/sa1111.c | 12 ++++++------ arch/arm/include/asm/hardware/sa1111.h | 20 +++++++++++--------- 2 files changed, 17 insertions(+), 15 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/common/sa1111.c b/arch/arm/common/sa1111.c index 1366e82e6707..4bdf1bb283dc 100644 --- a/arch/arm/common/sa1111.c +++ b/arch/arm/common/sa1111.c @@ -158,7 +158,7 @@ static struct sa1111_dev_info sa1111_devices[] = { { .offset = SA1111_KBD, .skpcr_mask = SKPCR_PTCLKEN, - .devid = SA1111_DEVID_PS2, + .devid = SA1111_DEVID_PS2_KBD, .irq = { IRQ_TPRXINT, IRQ_TPTXINT @@ -167,7 +167,7 @@ static struct sa1111_dev_info sa1111_devices[] = { { .offset = SA1111_MSE, .skpcr_mask = SKPCR_PMCLKEN, - .devid = SA1111_DEVID_PS2, + .devid = SA1111_DEVID_PS2_MSE, .irq = { IRQ_MSRXINT, IRQ_MSTXINT @@ -835,12 +835,12 @@ __sa1111_probe(struct device *me, struct resource *mem, int irq) has_devs = ~0; if (machine_is_assabet() || machine_is_jornada720() || machine_is_badge4()) - has_devs &= ~(1 << 4); + has_devs &= ~SA1111_DEVID_PS2_MSE; else - has_devs &= ~(1 << 1); + has_devs &= ~SA1111_DEVID_SAC; for (i = 0; i < ARRAY_SIZE(sa1111_devices); i++) - if (has_devs & (1 << i)) + if (sa1111_devices[i].devid & has_devs) sa1111_init_one_child(sachip, mem, &sa1111_devices[i]); return 0; @@ -1335,7 +1335,7 @@ static int sa1111_match(struct device *_dev, struct device_driver *_drv) struct sa1111_dev *dev = SA1111_DEV(_dev); struct sa1111_driver *drv = SA1111_DRV(_drv); - return dev->devid == drv->devid; + return dev->devid & drv->devid; } static int sa1111_bus_suspend(struct device *dev, pm_message_t state) diff --git a/arch/arm/include/asm/hardware/sa1111.h b/arch/arm/include/asm/hardware/sa1111.h index d54d781021c8..37ad29d482f4 100644 --- a/arch/arm/include/asm/hardware/sa1111.h +++ b/arch/arm/include/asm/hardware/sa1111.h @@ -516,15 +516,17 @@ extern struct bus_type sa1111_bus_type; -#define SA1111_DEVID_SBI 0 -#define SA1111_DEVID_SK 1 -#define SA1111_DEVID_USB 2 -#define SA1111_DEVID_SAC 3 -#define SA1111_DEVID_SSP 4 -#define SA1111_DEVID_PS2 5 -#define SA1111_DEVID_GPIO 6 -#define SA1111_DEVID_INT 7 -#define SA1111_DEVID_PCMCIA 8 +#define SA1111_DEVID_SBI (1 << 0) +#define SA1111_DEVID_SK (1 << 1) +#define SA1111_DEVID_USB (1 << 2) +#define SA1111_DEVID_SAC (1 << 3) +#define SA1111_DEVID_SSP (1 << 4) +#define SA1111_DEVID_PS2 (3 << 5) +#define SA1111_DEVID_PS2_KBD (1 << 5) +#define SA1111_DEVID_PS2_MSE (1 << 6) +#define SA1111_DEVID_GPIO (1 << 7) +#define SA1111_DEVID_INT (1 << 8) +#define SA1111_DEVID_PCMCIA (1 << 9) struct sa1111_dev { struct device dev; -- cgit v1.2.3 From abe06082d07fcb0673cb93338c1d6f037fdc375b Mon Sep 17 00:00:00 2001 From: Russell King Date: Fri, 20 Jan 2012 22:13:52 +0000 Subject: MFD: mcp/ucb1x00: separate ucb1x00 driver data from the MCP data Patch taken from 5dd7bf59e0 (ARM: sa11x0: Implement autoloading of codec and codec pdata for mcp bus.) by Jochen Friedrich . This adds just the codec data part of the patch. Acked-by: Jochen Friedrich Signed-off-by: Russell King --- arch/arm/mach-sa1100/collie.c | 7 ++++++- arch/arm/mach-sa1100/include/mach/mcp.h | 2 +- arch/arm/mach-sa1100/simpad.c | 7 ++++++- drivers/mfd/mcp-core.c | 3 ++- drivers/mfd/mcp-sa11x0.c | 3 +-- drivers/mfd/ucb1x00-core.c | 7 ++++--- include/linux/mfd/mcp.h | 3 +-- include/linux/mfd/ucb1x00.h | 3 +++ 8 files changed, 24 insertions(+), 11 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/mach-sa1100/collie.c b/arch/arm/mach-sa1100/collie.c index efa2bc132cbf..0e7359785159 100644 --- a/arch/arm/mach-sa1100/collie.c +++ b/arch/arm/mach-sa1100/collie.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -85,10 +86,14 @@ static struct scoop_pcmcia_config collie_pcmcia_config = { .num_devs = 1, }; +static struct ucb1x00_plat_data collie_ucb1x00_data = { + .gpio_base = COLLIE_TC35143_GPIO_BASE, +}; + static struct mcp_plat_data collie_mcp_data = { .mccr0 = MCCR0_ADM | MCCR0_ExtClk, .sclk_rate = 9216000, - .gpio_base = COLLIE_TC35143_GPIO_BASE, + .codec_pdata = &collie_ucb1x00_data, }; /* diff --git a/arch/arm/mach-sa1100/include/mach/mcp.h b/arch/arm/mach-sa1100/include/mach/mcp.h index ed1a331508a7..4b2860ae3828 100644 --- a/arch/arm/mach-sa1100/include/mach/mcp.h +++ b/arch/arm/mach-sa1100/include/mach/mcp.h @@ -16,7 +16,7 @@ struct mcp_plat_data { u32 mccr0; u32 mccr1; unsigned int sclk_rate; - int gpio_base; + void *codec_pdata; }; #endif diff --git a/arch/arm/mach-sa1100/simpad.c b/arch/arm/mach-sa1100/simpad.c index 3aa36ec21039..81506562ee26 100644 --- a/arch/arm/mach-sa1100/simpad.c +++ b/arch/arm/mach-sa1100/simpad.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -187,10 +188,14 @@ static struct resource simpad_flash_resources [] = { } }; +static struct ucb1x00_plat_data simpad_ucb1x00_data = { + .gpio_base = SIMPAD_UCB1X00_GPIO_BASE, +}; + static struct mcp_plat_data simpad_mcp_data = { .mccr0 = MCCR0_ADM, .sclk_rate = 11981000, - .gpio_base = SIMPAD_UCB1X00_GPIO_BASE, + .codec_pdata = &simpad_ucb1x00_data, }; diff --git a/drivers/mfd/mcp-core.c b/drivers/mfd/mcp-core.c index 280a4f8a7876..c409d6327140 100644 --- a/drivers/mfd/mcp-core.c +++ b/drivers/mfd/mcp-core.c @@ -217,8 +217,9 @@ struct mcp *mcp_host_alloc(struct device *parent, size_t size) } EXPORT_SYMBOL(mcp_host_alloc); -int mcp_host_add(struct mcp *mcp) +int mcp_host_add(struct mcp *mcp, void *pdata) { + mcp->attached_device.platform_data = pdata; dev_set_name(&mcp->attached_device, "mcp0"); return device_add(&mcp->attached_device); } diff --git a/drivers/mfd/mcp-sa11x0.c b/drivers/mfd/mcp-sa11x0.c index 420710b19f2d..960ebc790389 100644 --- a/drivers/mfd/mcp-sa11x0.c +++ b/drivers/mfd/mcp-sa11x0.c @@ -194,7 +194,6 @@ static int mcp_sa11x0_probe(struct platform_device *dev) mcp->owner = THIS_MODULE; mcp->ops = &mcp_sa11x0; mcp->sclk_rate = data->sclk_rate; - mcp->gpio_base = data->gpio_base; m = priv(mcp); m->mccr0 = data->mccr0 | 0x7f7f; @@ -229,7 +228,7 @@ static int mcp_sa11x0_probe(struct platform_device *dev) mcp->rw_timeout = (64 * 3 * 1000000 + mcp->sclk_rate - 1) / mcp->sclk_rate; - ret = mcp_host_add(mcp); + ret = mcp_host_add(mcp, data->codec_pdata); if (ret == 0) return 0; diff --git a/drivers/mfd/ucb1x00-core.c b/drivers/mfd/ucb1x00-core.c index f2fb4205467c..6825169b06fc 100644 --- a/drivers/mfd/ucb1x00-core.c +++ b/drivers/mfd/ucb1x00-core.c @@ -534,6 +534,7 @@ static int ucb1x00_probe(struct mcp *mcp) { struct ucb1x00 *ucb; struct ucb1x00_driver *drv; + struct ucb1x00_plat_data *pdata; unsigned int id; int ret = -ENODEV; int temp; @@ -551,7 +552,7 @@ static int ucb1x00_probe(struct mcp *mcp) if (!ucb) goto err_disable; - + pdata = mcp->attached_device.platform_data; ucb->dev.class = &ucb1x00_class; ucb->dev.parent = &mcp->attached_device; dev_set_name(&ucb->dev, "ucb1x00"); @@ -570,9 +571,9 @@ static int ucb1x00_probe(struct mcp *mcp) } ucb->gpio.base = -1; - if (mcp->gpio_base != 0) { + if (pdata && pdata->gpio_base) { ucb->gpio.label = dev_name(&ucb->dev); - ucb->gpio.base = mcp->gpio_base; + ucb->gpio.base = pdata->gpio_base; ucb->gpio.ngpio = 10; ucb->gpio.set = ucb1x00_gpio_set; ucb->gpio.get = ucb1x00_gpio_get; diff --git a/include/linux/mfd/mcp.h b/include/linux/mfd/mcp.h index dfe7e517ad9b..bfcdf6d3f1bf 100644 --- a/include/linux/mfd/mcp.h +++ b/include/linux/mfd/mcp.h @@ -20,7 +20,6 @@ struct mcp { unsigned int sclk_rate; unsigned int rw_timeout; struct device attached_device; - int gpio_base; }; struct mcp_ops { @@ -41,7 +40,7 @@ void mcp_disable(struct mcp *); #define mcp_get_sclk_rate(mcp) ((mcp)->sclk_rate) struct mcp *mcp_host_alloc(struct device *, size_t); -int mcp_host_add(struct mcp *); +int mcp_host_add(struct mcp *, void *); void mcp_host_del(struct mcp *); void mcp_host_free(struct mcp *); diff --git a/include/linux/mfd/ucb1x00.h b/include/linux/mfd/ucb1x00.h index 4321f044d1e4..731b23a656c0 100644 --- a/include/linux/mfd/ucb1x00.h +++ b/include/linux/mfd/ucb1x00.h @@ -104,6 +104,9 @@ #define UCB_MODE_DYN_VFLAG_ENA (1 << 12) #define UCB_MODE_AUD_OFF_CAN (1 << 13) +struct ucb1x00_plat_data { + int gpio_base; +}; struct ucb1x00_irq { void *devid; -- cgit v1.2.3 From 69dde86aa616b09bb3ef39a5ab783f82254d241c Mon Sep 17 00:00:00 2001 From: Russell King Date: Fri, 20 Jan 2012 22:18:06 +0000 Subject: ARM: sa11x0: add assabet ucb1x00 platform data Add ucb1x00 platform data to enable GPIO support on the UCB1300 device. Acked-by: Jochen Friedrich Signed-off-by: Russell King --- arch/arm/mach-sa1100/assabet.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'arch/arm') diff --git a/arch/arm/mach-sa1100/assabet.c b/arch/arm/mach-sa1100/assabet.c index 3a1914568374..c45402f866cc 100644 --- a/arch/arm/mach-sa1100/assabet.c +++ b/arch/arm/mach-sa1100/assabet.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -199,9 +200,14 @@ static struct irda_platform_data assabet_irda_data = { .set_speed = assabet_irda_set_speed, }; +static struct ucb1x00_plat_data assabet_ucb1x00_data = { + .gpio_base = -1, +}; + static struct mcp_plat_data assabet_mcp_data = { .mccr0 = MCCR0_ADM, .sclk_rate = 11981000, + .codec_pdata = &assabet_ucb1x00_data, }; static void __init assabet_init(void) -- cgit v1.2.3 From 6ed3e2acc7995625625592abe8cd3383c34a471b Mon Sep 17 00:00:00 2001 From: Russell King Date: Sun, 22 Jan 2012 19:23:33 +0000 Subject: MFD: mcp-sa11x0/assabet: move assabet reset handling out of mcp-sa11x0.c Move the assabet specific reset handling out of mcp-sa11x0.c, into its board file. This leaves the mcp code free from all board specific details. Acked-by: Jochen Friedrich Signed-off-by: Russell King --- arch/arm/mach-sa1100/assabet.c | 8 ++++++++ drivers/mfd/mcp-sa11x0.c | 6 ------ 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/mach-sa1100/assabet.c b/arch/arm/mach-sa1100/assabet.c index c45402f866cc..b5955ad35945 100644 --- a/arch/arm/mach-sa1100/assabet.c +++ b/arch/arm/mach-sa1100/assabet.c @@ -70,6 +70,13 @@ void ASSABET_BCR_frob(unsigned int mask, unsigned int val) EXPORT_SYMBOL(ASSABET_BCR_frob); +static void assabet_ucb1x00_reset(enum ucb1x00_reset state) +{ + if (state == UCB_RST_PROBE) + ASSABET_BCR_set(ASSABET_BCR_CODEC_RST); +} + + static void assabet_backlight_power(int on) { #ifndef ASSABET_PAL_VIDEO @@ -201,6 +208,7 @@ static struct irda_platform_data assabet_irda_data = { }; static struct ucb1x00_plat_data assabet_ucb1x00_data = { + .reset = assabet_ucb1x00_reset, .gpio_base = -1, }; diff --git a/drivers/mfd/mcp-sa11x0.c b/drivers/mfd/mcp-sa11x0.c index c381436ed3de..1c0ceacaa1f6 100644 --- a/drivers/mfd/mcp-sa11x0.c +++ b/drivers/mfd/mcp-sa11x0.c @@ -27,8 +27,6 @@ #include #include -#include - #define DRIVER_NAME "sa11x0-mcp" struct mcp_sa11x0 { @@ -208,10 +206,6 @@ static int mcp_sa11x0_probe(struct platform_device *dev) platform_set_drvdata(dev, mcp); - if (machine_is_assabet()) { - ASSABET_BCR_set(ASSABET_BCR_CODEC_RST); - } - /* * Initialise device. Note that we initially * set the sampling rate to minimum. -- cgit v1.2.3 From e1b7a72aeb8292502c97b43eceb01aea47ded40f Mon Sep 17 00:00:00 2001 From: Russell King Date: Sat, 14 Jan 2012 11:50:04 +0000 Subject: FB: sa1100: move platform data to platform files Move platform data out of the sa1100fb driver into the various platform files themselves. Acked-by: Florian Tobias Schandinat Signed-off-by: Russell King --- arch/arm/mach-sa1100/assabet.c | 40 +++++++ arch/arm/mach-sa1100/collie.c | 17 +++ arch/arm/mach-sa1100/generic.c | 8 +- arch/arm/mach-sa1100/generic.h | 3 + arch/arm/mach-sa1100/h3100.c | 22 +++- arch/arm/mach-sa1100/h3600.c | 31 +++++- arch/arm/mach-sa1100/lart.c | 79 ++++++++++++++ arch/arm/mach-sa1100/shannon.c | 17 +++ drivers/video/sa1100fb.c | 239 ++--------------------------------------- 9 files changed, 218 insertions(+), 238 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/mach-sa1100/assabet.c b/arch/arm/mach-sa1100/assabet.c index 0c4b76ab4d8e..37fb0cd1a296 100644 --- a/arch/arm/mach-sa1100/assabet.c +++ b/arch/arm/mach-sa1100/assabet.c @@ -20,6 +20,8 @@ #include #include +#include