Commit 70f82f2c authored by Manuel Lauss's avatar Manuel Lauss Committed by Ralf Baechle

MIPS: Alchemy: use runtime cpu detection in GPIO code.

Remove the cpu subtype cpp macros in favor of runtime detection,
to improve compile coverage of the alchemy common code.
(Increases kernel size by 700 bytes).
Signed-off-by: default avatarManuel Lauss <manuel.lauss@gmail.com>
Cc: linux-mips@linux-mips.org
Patchwork: http://patchwork.linux-mips.org/patch/699/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent bd2302c2
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
#include <asm/mach-au1x00/au1000.h> #include <asm/mach-au1x00/au1000.h>
#include <asm/mach-au1x00/gpio.h> #include <asm/mach-au1x00/gpio.h>
#if !defined(CONFIG_SOC_AU1000)
static int gpio2_get(struct gpio_chip *chip, unsigned offset) static int gpio2_get(struct gpio_chip *chip, unsigned offset)
{ {
return alchemy_gpio2_get_value(offset + ALCHEMY_GPIO2_BASE); return alchemy_gpio2_get_value(offset + ALCHEMY_GPIO2_BASE);
...@@ -63,7 +62,7 @@ static int gpio2_to_irq(struct gpio_chip *chip, unsigned offset) ...@@ -63,7 +62,7 @@ static int gpio2_to_irq(struct gpio_chip *chip, unsigned offset)
{ {
return alchemy_gpio2_to_irq(offset + ALCHEMY_GPIO2_BASE); return alchemy_gpio2_to_irq(offset + ALCHEMY_GPIO2_BASE);
} }
#endif /* !defined(CONFIG_SOC_AU1000) */
static int gpio1_get(struct gpio_chip *chip, unsigned offset) static int gpio1_get(struct gpio_chip *chip, unsigned offset)
{ {
...@@ -104,7 +103,6 @@ struct gpio_chip alchemy_gpio_chip[] = { ...@@ -104,7 +103,6 @@ struct gpio_chip alchemy_gpio_chip[] = {
.base = ALCHEMY_GPIO1_BASE, .base = ALCHEMY_GPIO1_BASE,
.ngpio = ALCHEMY_GPIO1_NUM, .ngpio = ALCHEMY_GPIO1_NUM,
}, },
#if !defined(CONFIG_SOC_AU1000)
[1] = { [1] = {
.label = "alchemy-gpio2", .label = "alchemy-gpio2",
.direction_input = gpio2_direction_input, .direction_input = gpio2_direction_input,
...@@ -115,15 +113,13 @@ struct gpio_chip alchemy_gpio_chip[] = { ...@@ -115,15 +113,13 @@ struct gpio_chip alchemy_gpio_chip[] = {
.base = ALCHEMY_GPIO2_BASE, .base = ALCHEMY_GPIO2_BASE,
.ngpio = ALCHEMY_GPIO2_NUM, .ngpio = ALCHEMY_GPIO2_NUM,
}, },
#endif
}; };
static int __init alchemy_gpiolib_init(void) static int __init alchemy_gpiolib_init(void)
{ {
gpiochip_add(&alchemy_gpio_chip[0]); gpiochip_add(&alchemy_gpio_chip[0]);
#if !defined(CONFIG_SOC_AU1000) if (alchemy_get_cputype() != ALCHEMY_CPU_AU1000)
gpiochip_add(&alchemy_gpio_chip[1]); gpiochip_add(&alchemy_gpio_chip[1]);
#endif
return 0; return 0;
} }
......
...@@ -236,19 +236,19 @@ static inline int alchemy_gpio1_is_valid(int gpio) ...@@ -236,19 +236,19 @@ static inline int alchemy_gpio1_is_valid(int gpio)
static inline int alchemy_gpio1_to_irq(int gpio) static inline int alchemy_gpio1_to_irq(int gpio)
{ {
#if defined(CONFIG_SOC_AU1000) switch (alchemy_get_cputype()) {
return au1000_gpio1_to_irq(gpio); case ALCHEMY_CPU_AU1000:
#elif defined(CONFIG_SOC_AU1100) return au1000_gpio1_to_irq(gpio);
return au1100_gpio1_to_irq(gpio); case ALCHEMY_CPU_AU1100:
#elif defined(CONFIG_SOC_AU1500) return au1100_gpio1_to_irq(gpio);
return au1500_gpio1_to_irq(gpio); case ALCHEMY_CPU_AU1500:
#elif defined(CONFIG_SOC_AU1550) return au1500_gpio1_to_irq(gpio);
return au1550_gpio1_to_irq(gpio); case ALCHEMY_CPU_AU1550:
#elif defined(CONFIG_SOC_AU1200) return au1550_gpio1_to_irq(gpio);
return au1200_gpio1_to_irq(gpio); case ALCHEMY_CPU_AU1200:
#else return au1200_gpio1_to_irq(gpio);
}
return -ENXIO; return -ENXIO;
#endif
} }
/* /*
...@@ -306,19 +306,19 @@ static inline int alchemy_gpio2_is_valid(int gpio) ...@@ -306,19 +306,19 @@ static inline int alchemy_gpio2_is_valid(int gpio)
static inline int alchemy_gpio2_to_irq(int gpio) static inline int alchemy_gpio2_to_irq(int gpio)
{ {
#if defined(CONFIG_SOC_AU1000) switch (alchemy_get_cputype()) {
return au1000_gpio2_to_irq(gpio); case ALCHEMY_CPU_AU1000:
#elif defined(CONFIG_SOC_AU1100) return au1000_gpio2_to_irq(gpio);
return au1100_gpio2_to_irq(gpio); case ALCHEMY_CPU_AU1100:
#elif defined(CONFIG_SOC_AU1500) return au1100_gpio2_to_irq(gpio);
return au1500_gpio2_to_irq(gpio); case ALCHEMY_CPU_AU1500:
#elif defined(CONFIG_SOC_AU1550) return au1500_gpio2_to_irq(gpio);
return au1550_gpio2_to_irq(gpio); case ALCHEMY_CPU_AU1550:
#elif defined(CONFIG_SOC_AU1200) return au1550_gpio2_to_irq(gpio);
return au1200_gpio2_to_irq(gpio); case ALCHEMY_CPU_AU1200:
#else return au1200_gpio2_to_irq(gpio);
}
return -ENXIO; return -ENXIO;
#endif
} }
/**********************************************************************/ /**********************************************************************/
...@@ -374,10 +374,13 @@ static inline void alchemy_gpio2_enable_int(int gpio2) ...@@ -374,10 +374,13 @@ static inline void alchemy_gpio2_enable_int(int gpio2)
gpio2 -= ALCHEMY_GPIO2_BASE; gpio2 -= ALCHEMY_GPIO2_BASE;
#if defined(CONFIG_SOC_AU1100) || defined(CONFIG_SOC_AU1500)
/* Au1100/Au1500 have GPIO208-215 enable bits at 0..7 */ /* Au1100/Au1500 have GPIO208-215 enable bits at 0..7 */
gpio2 -= 8; switch (alchemy_get_cputype()) {
#endif case ALCHEMY_CPU_AU1100:
case ALCHEMY_CPU_AU1500:
gpio2 -= 8;
}
local_irq_save(flags); local_irq_save(flags);
__alchemy_gpio2_mod_int(gpio2, 1); __alchemy_gpio2_mod_int(gpio2, 1);
local_irq_restore(flags); local_irq_restore(flags);
...@@ -395,10 +398,13 @@ static inline void alchemy_gpio2_disable_int(int gpio2) ...@@ -395,10 +398,13 @@ static inline void alchemy_gpio2_disable_int(int gpio2)
gpio2 -= ALCHEMY_GPIO2_BASE; gpio2 -= ALCHEMY_GPIO2_BASE;
#if defined(CONFIG_SOC_AU1100) || defined(CONFIG_SOC_AU1500)
/* Au1100/Au1500 have GPIO208-215 enable bits at 0..7 */ /* Au1100/Au1500 have GPIO208-215 enable bits at 0..7 */
gpio2 -= 8; switch (alchemy_get_cputype()) {
#endif case ALCHEMY_CPU_AU1100:
case ALCHEMY_CPU_AU1500:
gpio2 -= 8;
}
local_irq_save(flags); local_irq_save(flags);
__alchemy_gpio2_mod_int(gpio2, 0); __alchemy_gpio2_mod_int(gpio2, 0);
local_irq_restore(flags); local_irq_restore(flags);
...@@ -484,19 +490,19 @@ static inline int alchemy_gpio_to_irq(int gpio) ...@@ -484,19 +490,19 @@ static inline int alchemy_gpio_to_irq(int gpio)
static inline int alchemy_irq_to_gpio(int irq) static inline int alchemy_irq_to_gpio(int irq)
{ {
#if defined(CONFIG_SOC_AU1000) switch (alchemy_get_cputype()) {
return au1000_irq_to_gpio(irq); case ALCHEMY_CPU_AU1000:
#elif defined(CONFIG_SOC_AU1100) return au1000_irq_to_gpio(irq);
return au1100_irq_to_gpio(irq); case ALCHEMY_CPU_AU1100:
#elif defined(CONFIG_SOC_AU1500) return au1100_irq_to_gpio(irq);
return au1500_irq_to_gpio(irq); case ALCHEMY_CPU_AU1500:
#elif defined(CONFIG_SOC_AU1550) return au1500_irq_to_gpio(irq);
return au1550_irq_to_gpio(irq); case ALCHEMY_CPU_AU1550:
#elif defined(CONFIG_SOC_AU1200) return au1550_irq_to_gpio(irq);
return au1200_irq_to_gpio(irq); case ALCHEMY_CPU_AU1200:
#else return au1200_irq_to_gpio(irq);
}
return -ENXIO; return -ENXIO;
#endif
} }
/**********************************************************************/ /**********************************************************************/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment