| 1 | --- a/arch/arm/Kconfig |
| 2 | +++ b/arch/arm/Kconfig |
| 3 | @@ -296,6 +296,8 @@ config ARCH_CNS21XX |
| 4 | select CPU_FA526 |
| 5 | select PLAT_FA |
| 6 | select PLAT_FA_TIME |
| 7 | + select PLAT_FA_GPIO |
| 8 | + select ARCH_REQUIRE_GPIOLIB |
| 9 | select ARM_L1_CACHE_SHIFT_4 |
| 10 | help |
| 11 | Support for Cavium Networks CNS21xx family. |
| 12 | --- a/arch/arm/mach-cns21xx/common.h |
| 13 | +++ b/arch/arm/mach-cns21xx/common.h |
| 14 | @@ -12,6 +12,7 @@ |
| 15 | |
| 16 | void __init cns21xx_map_io(void); |
| 17 | void __init cns21xx_init_irq(void); |
| 18 | +void __init cns21xx_gpio_init(void); |
| 19 | |
| 20 | extern struct sys_timer cns21xx_timer; |
| 21 | |
| 22 | --- /dev/null |
| 23 | +++ b/arch/arm/mach-cns21xx/gpio.c |
| 24 | @@ -0,0 +1,45 @@ |
| 25 | +/* |
| 26 | + * Copyright (c) 2010 Gabor Juhos <juhosg@openwrt.org> |
| 27 | + * |
| 28 | + * This file is free software; you can redistribute it and/or modify |
| 29 | + * it under the terms of the GNU General Public License, Version 2, as |
| 30 | + * published by the Free Software Foundation. |
| 31 | + */ |
| 32 | + |
| 33 | +#include <plat/gpio.h> |
| 34 | + |
| 35 | +#include <mach/cns21xx.h> |
| 36 | +#include <mach/irqs.h> |
| 37 | + |
| 38 | +static struct fa_gpio_chip cns21xx_gpio_chips[] = { |
| 39 | + { |
| 40 | + .gpio_chip = { |
| 41 | + .label = "GPIOA", |
| 42 | + .base = 0, |
| 43 | + .ngpio = 32, |
| 44 | + }, |
| 45 | + |
| 46 | + .map_base = CNS21XX_GPIOA_BASE, |
| 47 | + .irq_base = CNS21XX_GPIO_IRQ_BASE, |
| 48 | + }, { |
| 49 | + .gpio_chip = { |
| 50 | + .label = "GPIOB", |
| 51 | + .base = 32, |
| 52 | + .ngpio = 32, |
| 53 | + }, |
| 54 | + |
| 55 | + .map_base = CNS21XX_GPIOB_BASE, |
| 56 | + .irq_base = CNS21XX_GPIO_IRQ_BASE + 32, |
| 57 | + } |
| 58 | +}; |
| 59 | + |
| 60 | +static struct fa_gpio_data cns21xx_gpio_data = { |
| 61 | + .chips = cns21xx_gpio_chips, |
| 62 | + .nchips = ARRAY_SIZE(cns21xx_gpio_chips), |
| 63 | + .irq = CNS21XX_IRQ_GPIO, |
| 64 | +}; |
| 65 | + |
| 66 | +void __init cns21xx_gpio_init(void) |
| 67 | +{ |
| 68 | + fa_gpio_init(&cns21xx_gpio_data); |
| 69 | +} |
| 70 | --- /dev/null |
| 71 | +++ b/arch/arm/mach-cns21xx/include/mach/gpio.h |
| 72 | @@ -0,0 +1,30 @@ |
| 73 | +/* |
| 74 | + * Copyright (c) 2008 Cavium Networks |
| 75 | + * Copyright (c) 2010 Gabor Juhos <juhosg@openwrt.org> |
| 76 | + * |
| 77 | + * This file is free software; you can redistribute it and/or modify |
| 78 | + * it under the terms of the GNU General Public License, Version 2, as |
| 79 | + * published by the Free Software Foundation. |
| 80 | + */ |
| 81 | + |
| 82 | +#ifndef _CNS21XX_GPIO_H |
| 83 | +#define _CNS21XX_GPIO_H |
| 84 | + |
| 85 | +#include <asm-generic/gpio.h> |
| 86 | +#include <mach/irqs.h> |
| 87 | + |
| 88 | +#define gpio_get_value __gpio_get_value |
| 89 | +#define gpio_set_value __gpio_set_value |
| 90 | +#define gpio_cansleep __gpio_cansleep |
| 91 | + |
| 92 | +static inline int gpio_to_irq(unsigned gpio) |
| 93 | +{ |
| 94 | + return (CNS21XX_GPIO_IRQ_BASE + gpio); |
| 95 | +} |
| 96 | + |
| 97 | +static inline int irq_to_gpio(int irq) |
| 98 | +{ |
| 99 | + return (irq - CNS21XX_GPIO_IRQ_BASE); |
| 100 | +} |
| 101 | + |
| 102 | +#endif /* _CNS21XX_GPIO_H */ |
| 103 | --- a/arch/arm/mach-cns21xx/Makefile |
| 104 | +++ b/arch/arm/mach-cns21xx/Makefile |
| 105 | @@ -4,7 +4,7 @@ |
| 106 | |
| 107 | # Object file lists. |
| 108 | |
| 109 | -obj-y := core.o devices.o irq.o mm.o time.o |
| 110 | +obj-y := core.o devices.o gpio.o irq.o mm.o time.o |
| 111 | |
| 112 | # machine specific files |
| 113 | |
| 114 | |