From b9e25aced33eeb7279ccbaef198f28370cfb4e93 Mon Sep 17 00:00:00 2001 From: eric miao Date: Tue, 4 Mar 2008 14:19:58 +0800 Subject: [PATCH] [ARM] pxa: merge assignment of set_wake into pxa_init_{irq,gpio}() To further clean up the GPIO and IRQ structure: 1. pxa_init_irq_gpio() and pxa_init_gpio() combines into a single function pxa_init_gpio() 2. assignment of set_wake merged into pxa_init_{irq,gpio}() as an argument Signed-off-by: eric miao Signed-off-by: Russell King --- arch/arm/mach-pxa/generic.h | 9 ++++----- arch/arm/mach-pxa/gpio.c | 34 ++++++++++++---------------------- arch/arm/mach-pxa/irq.c | 8 ++------ arch/arm/mach-pxa/pxa25x.c | 5 ++--- arch/arm/mach-pxa/pxa27x.c | 5 ++--- arch/arm/mach-pxa/pxa3xx.c | 13 +++---------- 6 files changed, 25 insertions(+), 49 deletions(-) diff --git a/arch/arm/mach-pxa/generic.h b/arch/arm/mach-pxa/generic.h index 0e3e058296..bd2a2356d9 100644 --- a/arch/arm/mach-pxa/generic.h +++ b/arch/arm/mach-pxa/generic.h @@ -9,14 +9,13 @@ * published by the Free Software Foundation. */ +typedef int (*set_wake_t)(unsigned int, unsigned int); + struct sys_timer; extern struct sys_timer pxa_timer; -extern void __init pxa_init_irq(int irq_nr); -extern void __init pxa_init_irq_gpio(int gpio_nr); -extern void __init pxa_init_irq_set_wake(int (*set_wake)(unsigned int, unsigned int)); -extern void __init pxa_init_gpio_set_wake(int (*set_wake)(unsigned int, unsigned int)); -extern void __init pxa_init_gpio(int gpio_nr); +extern void __init pxa_init_irq(int irq_nr, set_wake_t fn); +extern void __init pxa_init_gpio(int gpio_nr, set_wake_t fn); extern void __init pxa25x_init_irq(void); extern void __init pxa27x_init_irq(void); extern void __init pxa3xx_init_irq(void); diff --git a/arch/arm/mach-pxa/gpio.c b/arch/arm/mach-pxa/gpio.c index a642272541..bf4c08408f 100644 --- a/arch/arm/mach-pxa/gpio.c +++ b/arch/arm/mach-pxa/gpio.c @@ -153,20 +153,6 @@ static struct pxa_gpio_chip pxa_gpio_chip[] = { #endif }; -void __init pxa_init_gpio(int gpio_nr) -{ - int i; - - /* add a GPIO chip for each register bank. - * the last PXA25x register only contains 21 GPIOs - */ - for (i = 0; i < gpio_nr; i += 32) { - if (i+32 > gpio_nr) - pxa_gpio_chip[i/32].chip.ngpio = gpio_nr - i; - gpiochip_add(&pxa_gpio_chip[i/32].chip); - } -} - /* * PXA GPIO edge detection for IRQs: * IRQs are generated on Falling-Edge, Rising-Edge, or both. @@ -309,9 +295,9 @@ static struct irq_chip pxa_muxed_gpio_chip = { .set_type = pxa_gpio_irq_type, }; -void __init pxa_init_irq_gpio(int gpio_nr) +void __init pxa_init_gpio(int gpio_nr, set_wake_t fn) { - int irq, i; + int irq, i, gpio; pxa_last_gpio = gpio_nr - 1; @@ -340,11 +326,15 @@ void __init pxa_init_irq_gpio(int gpio_nr) /* Install handler for GPIO>=2 edge detect interrupts */ set_irq_chained_handler(IRQ_GPIO_2_x, pxa_gpio_demux_handler); - pxa_init_gpio(gpio_nr); -} + pxa_low_gpio_chip.set_wake = fn; + pxa_muxed_gpio_chip.set_wake = fn; -void __init pxa_init_gpio_set_wake(int (*set_wake)(unsigned int, unsigned int)) -{ - pxa_low_gpio_chip.set_wake = set_wake; - pxa_muxed_gpio_chip.set_wake = set_wake; + /* add a GPIO chip for each register bank. + * the last PXA25x register only contains 21 GPIOs + */ + for (gpio = 0, i = 0; gpio < gpio_nr; gpio += 32, i++) { + if (gpio + 32 > gpio_nr) + pxa_gpio_chip[i].chip.ngpio = gpio_nr - gpio; + gpiochip_add(&pxa_gpio_chip[i].chip); + } } diff --git a/arch/arm/mach-pxa/irq.c b/arch/arm/mach-pxa/irq.c index cccc3ed3c6..fbff557bb2 100644 --- a/arch/arm/mach-pxa/irq.c +++ b/arch/arm/mach-pxa/irq.c @@ -51,7 +51,7 @@ static struct irq_chip pxa_internal_irq_chip = { .unmask = pxa_unmask_irq, }; -void __init pxa_init_irq(int irq_nr) +void __init pxa_init_irq(int irq_nr, set_wake_t fn) { int irq; @@ -70,12 +70,8 @@ void __init pxa_init_irq(int irq_nr) set_irq_handler(irq, handle_level_irq); set_irq_flags(irq, IRQF_VALID); } -} -void __init pxa_init_irq_set_wake(int (*set_wake)(unsigned int, unsigned int)) -{ - pxa_internal_irq_chip.set_wake = set_wake; - pxa_init_gpio_set_wake(set_wake); + pxa_internal_irq_chip.set_wake = fn; } #ifdef CONFIG_PM diff --git a/arch/arm/mach-pxa/pxa25x.c b/arch/arm/mach-pxa/pxa25x.c index bb0bf51f50..653a3b63d0 100644 --- a/arch/arm/mach-pxa/pxa25x.c +++ b/arch/arm/mach-pxa/pxa25x.c @@ -267,9 +267,8 @@ set_pwer: void __init pxa25x_init_irq(void) { - pxa_init_irq(32); - pxa_init_irq_gpio(85); - pxa_init_irq_set_wake(pxa25x_set_wake); + pxa_init_irq(32, pxa25x_set_wake); + pxa_init_gpio(85, pxa25x_set_wake); } static struct platform_device *pxa25x_devices[] __initdata = { diff --git a/arch/arm/mach-pxa/pxa27x.c b/arch/arm/mach-pxa/pxa27x.c index 54d8448cad..87ade40865 100644 --- a/arch/arm/mach-pxa/pxa27x.c +++ b/arch/arm/mach-pxa/pxa27x.c @@ -340,9 +340,8 @@ set_pwer: void __init pxa27x_init_irq(void) { - pxa_init_irq(34); - pxa_init_irq_gpio(128); - pxa_init_irq_set_wake(pxa27x_set_wake); + pxa_init_irq(34, pxa27x_set_wake); + pxa_init_gpio(128, pxa27x_set_wake); } /* diff --git a/arch/arm/mach-pxa/pxa3xx.c b/arch/arm/mach-pxa/pxa3xx.c index 8f8179b2fc..eedcec0bf3 100644 --- a/arch/arm/mach-pxa/pxa3xx.c +++ b/arch/arm/mach-pxa/pxa3xx.c @@ -494,15 +494,9 @@ static int pxa3xx_set_wake(unsigned int irq, unsigned int on) return 0; } - -static void pxa3xx_init_irq_pm(void) -{ - pxa_init_irq_set_wake(pxa3xx_set_wake); -} - #else static inline void pxa3xx_init_pm(void) {} -static inline void pxa3xx_init_irq_pm(void) {} +#define pxa3xx_set_wake NULL #endif void __init pxa3xx_init_irq(void) @@ -513,9 +507,8 @@ void __init pxa3xx_init_irq(void) value |= (1 << 6); __asm__ __volatile__("mcr p15, 0, %0, c15, c1, 0\n": :"r"(value)); - pxa_init_irq(56); - pxa_init_irq_gpio(128); - pxa3xx_init_irq_pm(); + pxa_init_irq(56, pxa3xx_set_wake); + pxa_init_gpio(128, NULL); } /* -- 2.39.5