diff options
Diffstat (limited to 'arch/mips/alchemy/common/gpiolib.c')
-rw-r--r-- | arch/mips/alchemy/common/gpiolib.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/arch/mips/alchemy/common/gpiolib.c b/arch/mips/alchemy/common/gpiolib.c index 91fb4d9e30fd..f1b50f0c01db 100644 --- a/arch/mips/alchemy/common/gpiolib.c +++ b/arch/mips/alchemy/common/gpiolib.c | |||
@@ -27,6 +27,7 @@ | |||
27 | * CONFIG_ALCHEMY_GPIO_INDIRECT=n, otherwise compilation will fail! | 27 | * CONFIG_ALCHEMY_GPIO_INDIRECT=n, otherwise compilation will fail! |
28 | * au1000 SoC have only one GPIO block : GPIO1 | 28 | * au1000 SoC have only one GPIO block : GPIO1 |
29 | * Au1100, Au15x0, Au12x0 have a second one : GPIO2 | 29 | * Au1100, Au15x0, Au12x0 have a second one : GPIO2 |
30 | * Au1300 is totally different: 1 block with up to 128 GPIOs | ||
30 | */ | 31 | */ |
31 | 32 | ||
32 | #include <linux/init.h> | 33 | #include <linux/init.h> |
@@ -35,6 +36,7 @@ | |||
35 | #include <linux/types.h> | 36 | #include <linux/types.h> |
36 | #include <linux/gpio.h> | 37 | #include <linux/gpio.h> |
37 | #include <asm/mach-au1x00/gpio-au1000.h> | 38 | #include <asm/mach-au1x00/gpio-au1000.h> |
39 | #include <asm/mach-au1x00/gpio-au1300.h> | ||
38 | 40 | ||
39 | static int gpio2_get(struct gpio_chip *chip, unsigned offset) | 41 | static int gpio2_get(struct gpio_chip *chip, unsigned offset) |
40 | { | 42 | { |
@@ -115,6 +117,43 @@ struct gpio_chip alchemy_gpio_chip[] = { | |||
115 | }, | 117 | }, |
116 | }; | 118 | }; |
117 | 119 | ||
120 | static int alchemy_gpic_get(struct gpio_chip *chip, unsigned int off) | ||
121 | { | ||
122 | return au1300_gpio_get_value(off + AU1300_GPIO_BASE); | ||
123 | } | ||
124 | |||
125 | static void alchemy_gpic_set(struct gpio_chip *chip, unsigned int off, int v) | ||
126 | { | ||
127 | au1300_gpio_set_value(off + AU1300_GPIO_BASE, v); | ||
128 | } | ||
129 | |||
130 | static int alchemy_gpic_dir_input(struct gpio_chip *chip, unsigned int off) | ||
131 | { | ||
132 | return au1300_gpio_direction_input(off + AU1300_GPIO_BASE); | ||
133 | } | ||
134 | |||
135 | static int alchemy_gpic_dir_output(struct gpio_chip *chip, unsigned int off, | ||
136 | int v) | ||
137 | { | ||
138 | return au1300_gpio_direction_output(off + AU1300_GPIO_BASE, v); | ||
139 | } | ||
140 | |||
141 | static int alchemy_gpic_gpio_to_irq(struct gpio_chip *chip, unsigned int off) | ||
142 | { | ||
143 | return au1300_gpio_to_irq(off + AU1300_GPIO_BASE); | ||
144 | } | ||
145 | |||
146 | static struct gpio_chip au1300_gpiochip = { | ||
147 | .label = "alchemy-gpic", | ||
148 | .direction_input = alchemy_gpic_dir_input, | ||
149 | .direction_output = alchemy_gpic_dir_output, | ||
150 | .get = alchemy_gpic_get, | ||
151 | .set = alchemy_gpic_set, | ||
152 | .to_irq = alchemy_gpic_gpio_to_irq, | ||
153 | .base = AU1300_GPIO_BASE, | ||
154 | .ngpio = AU1300_GPIO_NUM, | ||
155 | }; | ||
156 | |||
118 | static int __init alchemy_gpiochip_init(void) | 157 | static int __init alchemy_gpiochip_init(void) |
119 | { | 158 | { |
120 | int ret = 0; | 159 | int ret = 0; |
@@ -127,6 +166,9 @@ static int __init alchemy_gpiochip_init(void) | |||
127 | ret = gpiochip_add(&alchemy_gpio_chip[0]); | 166 | ret = gpiochip_add(&alchemy_gpio_chip[0]); |
128 | ret |= gpiochip_add(&alchemy_gpio_chip[1]); | 167 | ret |= gpiochip_add(&alchemy_gpio_chip[1]); |
129 | break; | 168 | break; |
169 | case ALCHEMY_CPU_AU1300: | ||
170 | ret = gpiochip_add(&au1300_gpiochip); | ||
171 | break; | ||
130 | } | 172 | } |
131 | return ret; | 173 | return ret; |
132 | } | 174 | } |