blob: 152efae3df8f39637f0ea750c90ca7dd99464170 [file] [log] [blame]
Linus Walleijbd41b992009-04-23 21:15:04 +01001/*
Grant Likelyc103de22011-06-04 18:38:28 -06002 * U300 GPIO module.
Linus Walleijbd41b992009-04-23 21:15:04 +01003 *
Linus Walleij04b13de2012-08-13 10:36:55 +02004 * Copyright (C) 2007-2012 ST-Ericsson AB
Linus Walleijbd41b992009-04-23 21:15:04 +01005 * License terms: GNU General Public License (GPL) version 2
Linus Walleijbd41b992009-04-23 21:15:04 +01006 * COH 901 571/3 - Used in DB3210 (U365 2.0) and DB3350 (U335 1.0)
Linus Walleijcc890cd2011-09-08 09:04:51 +01007 * Author: Linus Walleij <linus.walleij@linaro.org>
Linus Walleijbd41b992009-04-23 21:15:04 +01008 * Author: Jonas Aaberg <jonas.aberg@stericsson.com>
Linus Walleijbd41b992009-04-23 21:15:04 +01009 */
10#include <linux/module.h>
Linus Walleijcc890cd2011-09-08 09:04:51 +010011#include <linux/irq.h>
Linus Walleijbd41b992009-04-23 21:15:04 +010012#include <linux/interrupt.h>
13#include <linux/delay.h>
14#include <linux/errno.h>
15#include <linux/io.h>
Linus Walleija6c45b92012-10-17 18:31:20 +020016#include <linux/irqdomain.h>
Linus Walleijbd41b992009-04-23 21:15:04 +010017#include <linux/clk.h>
18#include <linux/err.h>
19#include <linux/platform_device.h>
20#include <linux/gpio.h>
Linus Walleijcc890cd2011-09-08 09:04:51 +010021#include <linux/list.h>
22#include <linux/slab.h>
Linus Walleij28a8d142012-02-09 01:52:22 +010023#include <linux/pinctrl/consumer.h>
Linus Walleijdc0b1aa2011-11-16 21:58:10 +010024#include <linux/pinctrl/pinconf-generic.h>
Linus Walleij65172852012-08-13 10:56:43 +020025#include <linux/platform_data/pinctrl-coh901.h>
Linus Walleijdc0b1aa2011-11-16 21:58:10 +010026#include "pinctrl-coh901.h"
Linus Walleijbd41b992009-04-23 21:15:04 +010027
Linus Walleij04b13de2012-08-13 10:36:55 +020028#define U300_GPIO_PORT_STRIDE (0x30)
Linus Walleijcc890cd2011-09-08 09:04:51 +010029/*
Linus Walleij04b13de2012-08-13 10:36:55 +020030 * Control Register 32bit (R/W)
31 * bit 15-9 (mask 0x0000FE00) contains the number of cores. 8*cores
32 * gives the number of GPIO pins.
33 * bit 8-2 (mask 0x000001FC) contains the core version ID.
Linus Walleijcc890cd2011-09-08 09:04:51 +010034 */
Linus Walleij04b13de2012-08-13 10:36:55 +020035#define U300_GPIO_CR (0x00)
36#define U300_GPIO_CR_SYNC_SEL_ENABLE (0x00000002UL)
37#define U300_GPIO_CR_BLOCK_CLKRQ_ENABLE (0x00000001UL)
38#define U300_GPIO_PXPDIR (0x04)
39#define U300_GPIO_PXPDOR (0x08)
40#define U300_GPIO_PXPCR (0x0C)
Linus Walleijcc890cd2011-09-08 09:04:51 +010041#define U300_GPIO_PXPCR_ALL_PINS_MODE_MASK (0x0000FFFFUL)
42#define U300_GPIO_PXPCR_PIN_MODE_MASK (0x00000003UL)
43#define U300_GPIO_PXPCR_PIN_MODE_SHIFT (0x00000002UL)
44#define U300_GPIO_PXPCR_PIN_MODE_INPUT (0x00000000UL)
45#define U300_GPIO_PXPCR_PIN_MODE_OUTPUT_PUSH_PULL (0x00000001UL)
46#define U300_GPIO_PXPCR_PIN_MODE_OUTPUT_OPEN_DRAIN (0x00000002UL)
47#define U300_GPIO_PXPCR_PIN_MODE_OUTPUT_OPEN_SOURCE (0x00000003UL)
Linus Walleij04b13de2012-08-13 10:36:55 +020048#define U300_GPIO_PXPER (0x10)
49#define U300_GPIO_PXPER_ALL_PULL_UP_DISABLE_MASK (0x000000FFUL)
50#define U300_GPIO_PXPER_PULL_UP_DISABLE (0x00000001UL)
51#define U300_GPIO_PXIEV (0x14)
52#define U300_GPIO_PXIEN (0x18)
53#define U300_GPIO_PXIFR (0x1C)
54#define U300_GPIO_PXICR (0x20)
Linus Walleijcc890cd2011-09-08 09:04:51 +010055#define U300_GPIO_PXICR_ALL_IRQ_CONFIG_MASK (0x000000FFUL)
56#define U300_GPIO_PXICR_IRQ_CONFIG_MASK (0x00000001UL)
57#define U300_GPIO_PXICR_IRQ_CONFIG_FALLING_EDGE (0x00000000UL)
58#define U300_GPIO_PXICR_IRQ_CONFIG_RISING_EDGE (0x00000001UL)
Linus Walleijcc890cd2011-09-08 09:04:51 +010059
60/* 8 bits per port, no version has more than 7 ports */
61#define U300_GPIO_PINS_PER_PORT 8
62#define U300_GPIO_MAX (U300_GPIO_PINS_PER_PORT * 7)
63
64struct u300_gpio {
65 struct gpio_chip chip;
66 struct list_head port_list;
67 struct clk *clk;
68 struct resource *memres;
69 void __iomem *base;
70 struct device *dev;
Linus Walleijcc890cd2011-09-08 09:04:51 +010071 u32 stride;
72 /* Register offsets */
73 u32 pcr;
74 u32 dor;
75 u32 dir;
76 u32 per;
77 u32 icr;
78 u32 ien;
79 u32 iev;
80};
Linus Walleijbd41b992009-04-23 21:15:04 +010081
82struct u300_gpio_port {
Linus Walleijcc890cd2011-09-08 09:04:51 +010083 struct list_head node;
84 struct u300_gpio *gpio;
85 char name[8];
Linus Walleija6c45b92012-10-17 18:31:20 +020086 struct irq_domain *domain;
Linus Walleijbd41b992009-04-23 21:15:04 +010087 int irq;
88 int number;
Linus Walleijcc890cd2011-09-08 09:04:51 +010089 u8 toggle_edge_mode;
Linus Walleijbd41b992009-04-23 21:15:04 +010090};
91
Linus Walleijcc890cd2011-09-08 09:04:51 +010092/*
93 * Macro to expand to read a specific register found in the "gpio"
94 * struct. It requires the struct u300_gpio *gpio variable to exist in
95 * its context. It calculates the port offset from the given pin
96 * offset, muliplies by the port stride and adds the register offset
97 * so it provides a pointer to the desired register.
98 */
99#define U300_PIN_REG(pin, reg) \
100 (gpio->base + (pin >> 3) * gpio->stride + gpio->reg)
Linus Walleijbd41b992009-04-23 21:15:04 +0100101
Linus Walleijcc890cd2011-09-08 09:04:51 +0100102/*
103 * Provides a bitmask for a specific gpio pin inside an 8-bit GPIO
104 * register.
105 */
106#define U300_PIN_BIT(pin) \
107 (1 << (pin & 0x07))
Linus Walleijbd41b992009-04-23 21:15:04 +0100108
Linus Walleijcc890cd2011-09-08 09:04:51 +0100109struct u300_gpio_confdata {
110 u16 bias_mode;
111 bool output;
112 int outval;
Linus Walleijbd41b992009-04-23 21:15:04 +0100113};
114
Linus Walleijcc890cd2011-09-08 09:04:51 +0100115/* BS335 has seven ports of 8 bits each = GPIO pins 0..55 */
116#define BS335_GPIO_NUM_PORTS 7
Linus Walleijbd41b992009-04-23 21:15:04 +0100117
Linus Walleijcc890cd2011-09-08 09:04:51 +0100118#define U300_FLOATING_INPUT { \
Linus Walleija050b3e2011-11-16 20:10:09 +0100119 .bias_mode = PIN_CONFIG_BIAS_HIGH_IMPEDANCE, \
Linus Walleijcc890cd2011-09-08 09:04:51 +0100120 .output = false, \
121}
Linus Walleijbd41b992009-04-23 21:15:04 +0100122
Linus Walleijcc890cd2011-09-08 09:04:51 +0100123#define U300_PULL_UP_INPUT { \
Linus Walleija050b3e2011-11-16 20:10:09 +0100124 .bias_mode = PIN_CONFIG_BIAS_PULL_UP, \
Linus Walleijcc890cd2011-09-08 09:04:51 +0100125 .output = false, \
126}
Linus Walleijbd41b992009-04-23 21:15:04 +0100127
Linus Walleijcc890cd2011-09-08 09:04:51 +0100128#define U300_OUTPUT_LOW { \
129 .output = true, \
130 .outval = 0, \
131}
Linus Walleijbd41b992009-04-23 21:15:04 +0100132
Linus Walleijcc890cd2011-09-08 09:04:51 +0100133#define U300_OUTPUT_HIGH { \
134 .output = true, \
135 .outval = 1, \
136}
Linus Walleijbd41b992009-04-23 21:15:04 +0100137
Linus Walleijbd41b992009-04-23 21:15:04 +0100138/* Initial configuration */
Uwe Kleine-König122dbe72012-03-30 22:04:51 +0200139static const struct __initconst u300_gpio_confdata
Linus Walleijcc890cd2011-09-08 09:04:51 +0100140bs335_gpio_config[BS335_GPIO_NUM_PORTS][U300_GPIO_PINS_PER_PORT] = {
Linus Walleijbd41b992009-04-23 21:15:04 +0100141 /* Port 0, pins 0-7 */
142 {
Linus Walleijcc890cd2011-09-08 09:04:51 +0100143 U300_FLOATING_INPUT,
144 U300_OUTPUT_HIGH,
145 U300_FLOATING_INPUT,
146 U300_OUTPUT_LOW,
147 U300_OUTPUT_LOW,
148 U300_OUTPUT_LOW,
149 U300_OUTPUT_LOW,
150 U300_OUTPUT_LOW,
Linus Walleijbd41b992009-04-23 21:15:04 +0100151 },
152 /* Port 1, pins 0-7 */
153 {
Linus Walleijcc890cd2011-09-08 09:04:51 +0100154 U300_OUTPUT_LOW,
155 U300_OUTPUT_LOW,
156 U300_OUTPUT_LOW,
157 U300_PULL_UP_INPUT,
158 U300_FLOATING_INPUT,
159 U300_OUTPUT_HIGH,
160 U300_OUTPUT_LOW,
161 U300_OUTPUT_LOW,
Linus Walleijbd41b992009-04-23 21:15:04 +0100162 },
163 /* Port 2, pins 0-7 */
164 {
Linus Walleijcc890cd2011-09-08 09:04:51 +0100165 U300_FLOATING_INPUT,
166 U300_FLOATING_INPUT,
167 U300_FLOATING_INPUT,
168 U300_FLOATING_INPUT,
169 U300_OUTPUT_LOW,
170 U300_PULL_UP_INPUT,
171 U300_OUTPUT_LOW,
172 U300_PULL_UP_INPUT,
Linus Walleijbd41b992009-04-23 21:15:04 +0100173 },
174 /* Port 3, pins 0-7 */
175 {
Linus Walleijcc890cd2011-09-08 09:04:51 +0100176 U300_PULL_UP_INPUT,
177 U300_OUTPUT_LOW,
178 U300_FLOATING_INPUT,
179 U300_FLOATING_INPUT,
180 U300_FLOATING_INPUT,
181 U300_FLOATING_INPUT,
182 U300_FLOATING_INPUT,
183 U300_FLOATING_INPUT,
Linus Walleijbd41b992009-04-23 21:15:04 +0100184 },
185 /* Port 4, pins 0-7 */
186 {
Linus Walleijcc890cd2011-09-08 09:04:51 +0100187 U300_FLOATING_INPUT,
188 U300_FLOATING_INPUT,
189 U300_FLOATING_INPUT,
190 U300_FLOATING_INPUT,
191 U300_FLOATING_INPUT,
192 U300_FLOATING_INPUT,
193 U300_FLOATING_INPUT,
194 U300_FLOATING_INPUT,
Linus Walleijbd41b992009-04-23 21:15:04 +0100195 },
196 /* Port 5, pins 0-7 */
197 {
Linus Walleijcc890cd2011-09-08 09:04:51 +0100198 U300_FLOATING_INPUT,
199 U300_FLOATING_INPUT,
200 U300_FLOATING_INPUT,
201 U300_FLOATING_INPUT,
202 U300_FLOATING_INPUT,
203 U300_FLOATING_INPUT,
204 U300_FLOATING_INPUT,
205 U300_FLOATING_INPUT,
Linus Walleijbd41b992009-04-23 21:15:04 +0100206 },
207 /* Port 6, pind 0-7 */
208 {
Linus Walleijcc890cd2011-09-08 09:04:51 +0100209 U300_FLOATING_INPUT,
210 U300_FLOATING_INPUT,
211 U300_FLOATING_INPUT,
212 U300_FLOATING_INPUT,
213 U300_FLOATING_INPUT,
214 U300_FLOATING_INPUT,
215 U300_FLOATING_INPUT,
216 U300_FLOATING_INPUT,
Linus Walleijbd41b992009-04-23 21:15:04 +0100217 }
Linus Walleijcc890cd2011-09-08 09:04:51 +0100218};
Linus Walleijbd41b992009-04-23 21:15:04 +0100219
Linus Walleijcc890cd2011-09-08 09:04:51 +0100220/**
221 * to_u300_gpio() - get the pointer to u300_gpio
222 * @chip: the gpio chip member of the structure u300_gpio
Linus Walleijbd41b992009-04-23 21:15:04 +0100223 */
Linus Walleijcc890cd2011-09-08 09:04:51 +0100224static inline struct u300_gpio *to_u300_gpio(struct gpio_chip *chip)
Linus Walleijbd41b992009-04-23 21:15:04 +0100225{
Linus Walleijcc890cd2011-09-08 09:04:51 +0100226 return container_of(chip, struct u300_gpio, chip);
Linus Walleijbd41b992009-04-23 21:15:04 +0100227}
Linus Walleijbd41b992009-04-23 21:15:04 +0100228
Linus Walleijb4e3ac72011-11-16 10:24:39 +0100229static int u300_gpio_request(struct gpio_chip *chip, unsigned offset)
230{
231 /*
232 * Map back to global GPIO space and request muxing, the direction
233 * parameter does not matter for this controller.
234 */
235 int gpio = chip->base + offset;
236
Linus Walleije93bcee2012-02-09 07:23:28 +0100237 return pinctrl_request_gpio(gpio);
Linus Walleijb4e3ac72011-11-16 10:24:39 +0100238}
239
240static void u300_gpio_free(struct gpio_chip *chip, unsigned offset)
241{
242 int gpio = chip->base + offset;
243
Linus Walleije93bcee2012-02-09 07:23:28 +0100244 pinctrl_free_gpio(gpio);
Linus Walleijb4e3ac72011-11-16 10:24:39 +0100245}
246
Linus Walleijcc890cd2011-09-08 09:04:51 +0100247static int u300_gpio_get(struct gpio_chip *chip, unsigned offset)
Linus Walleijbd41b992009-04-23 21:15:04 +0100248{
Linus Walleijcc890cd2011-09-08 09:04:51 +0100249 struct u300_gpio *gpio = to_u300_gpio(chip);
Linus Walleijbd41b992009-04-23 21:15:04 +0100250
Linus Walleijcc890cd2011-09-08 09:04:51 +0100251 return readl(U300_PIN_REG(offset, dir)) & U300_PIN_BIT(offset);
Linus Walleijbd41b992009-04-23 21:15:04 +0100252}
Linus Walleijbd41b992009-04-23 21:15:04 +0100253
Linus Walleijcc890cd2011-09-08 09:04:51 +0100254static void u300_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
Linus Walleijee179622009-09-28 12:36:18 +0100255{
Linus Walleijcc890cd2011-09-08 09:04:51 +0100256 struct u300_gpio *gpio = to_u300_gpio(chip);
257 unsigned long flags;
258 u32 val;
Linus Walleijee179622009-09-28 12:36:18 +0100259
Linus Walleijcc890cd2011-09-08 09:04:51 +0100260 local_irq_save(flags);
261
262 val = readl(U300_PIN_REG(offset, dor));
263 if (value)
264 writel(val | U300_PIN_BIT(offset), U300_PIN_REG(offset, dor));
Linus Walleijbd41b992009-04-23 21:15:04 +0100265 else
Linus Walleijcc890cd2011-09-08 09:04:51 +0100266 writel(val & ~U300_PIN_BIT(offset), U300_PIN_REG(offset, dor));
Linus Walleijbd41b992009-04-23 21:15:04 +0100267
Linus Walleijbd41b992009-04-23 21:15:04 +0100268 local_irq_restore(flags);
269}
Linus Walleijbd41b992009-04-23 21:15:04 +0100270
Linus Walleijcc890cd2011-09-08 09:04:51 +0100271static int u300_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
Linus Walleijbd41b992009-04-23 21:15:04 +0100272{
Linus Walleijcc890cd2011-09-08 09:04:51 +0100273 struct u300_gpio *gpio = to_u300_gpio(chip);
Linus Walleijbd41b992009-04-23 21:15:04 +0100274 unsigned long flags;
275 u32 val;
276
Linus Walleijbd41b992009-04-23 21:15:04 +0100277 local_irq_save(flags);
Linus Walleijcc890cd2011-09-08 09:04:51 +0100278 val = readl(U300_PIN_REG(offset, pcr));
279 /* Mask out this pin, note 2 bits per setting */
280 val &= ~(U300_GPIO_PXPCR_PIN_MODE_MASK << ((offset & 0x07) << 1));
281 writel(val, U300_PIN_REG(offset, pcr));
Linus Walleijbd41b992009-04-23 21:15:04 +0100282 local_irq_restore(flags);
283 return 0;
284}
Linus Walleijbd41b992009-04-23 21:15:04 +0100285
Linus Walleijcc890cd2011-09-08 09:04:51 +0100286static int u300_gpio_direction_output(struct gpio_chip *chip, unsigned offset,
287 int value)
Linus Walleijbd41b992009-04-23 21:15:04 +0100288{
Linus Walleijcc890cd2011-09-08 09:04:51 +0100289 struct u300_gpio *gpio = to_u300_gpio(chip);
Linus Walleijbd41b992009-04-23 21:15:04 +0100290 unsigned long flags;
Linus Walleijcc890cd2011-09-08 09:04:51 +0100291 u32 oldmode;
Linus Walleijbd41b992009-04-23 21:15:04 +0100292 u32 val;
293
Linus Walleijbd41b992009-04-23 21:15:04 +0100294 local_irq_save(flags);
Linus Walleijcc890cd2011-09-08 09:04:51 +0100295 val = readl(U300_PIN_REG(offset, pcr));
Linus Walleijbd41b992009-04-23 21:15:04 +0100296 /*
Linus Walleijcc890cd2011-09-08 09:04:51 +0100297 * Drive mode must be set by the special mode set function, set
298 * push/pull mode by default if no mode has been selected.
Linus Walleijbd41b992009-04-23 21:15:04 +0100299 */
Linus Walleijcc890cd2011-09-08 09:04:51 +0100300 oldmode = val & (U300_GPIO_PXPCR_PIN_MODE_MASK <<
301 ((offset & 0x07) << 1));
302 /* mode = 0 means input, else some mode is already set */
303 if (oldmode == 0) {
304 val &= ~(U300_GPIO_PXPCR_PIN_MODE_MASK <<
305 ((offset & 0x07) << 1));
306 val |= (U300_GPIO_PXPCR_PIN_MODE_OUTPUT_PUSH_PULL
307 << ((offset & 0x07) << 1));
308 writel(val, U300_PIN_REG(offset, pcr));
309 }
310 u300_gpio_set(chip, offset, value);
Linus Walleijbd41b992009-04-23 21:15:04 +0100311 local_irq_restore(flags);
312 return 0;
313}
Linus Walleijbd41b992009-04-23 21:15:04 +0100314
Linus Walleijcc890cd2011-09-08 09:04:51 +0100315static int u300_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
Linus Walleijbd41b992009-04-23 21:15:04 +0100316{
Linus Walleijcc890cd2011-09-08 09:04:51 +0100317 struct u300_gpio *gpio = to_u300_gpio(chip);
Linus Walleija6c45b92012-10-17 18:31:20 +0200318 int portno = offset >> 3;
319 struct u300_gpio_port *port = NULL;
320 struct list_head *p;
321 int retirq;
Linus Walleijbd41b992009-04-23 21:15:04 +0100322
Linus Walleija6c45b92012-10-17 18:31:20 +0200323 list_for_each(p, &gpio->port_list) {
324 port = list_entry(p, struct u300_gpio_port, node);
325 if (port->number == portno)
326 break;
327 }
328 if (port == NULL) {
329 dev_err(gpio->dev, "could not locate port for GPIO %d IRQ\n",
330 offset);
331 return -EINVAL;
332 }
333
334 /*
335 * The local hwirqs on the port are the lower three bits, there
336 * are exactly 8 IRQs per port since they are 8-bit
337 */
338 retirq = irq_find_mapping(port->domain, (offset & 0x7));
339
340 dev_dbg(gpio->dev, "request IRQ for GPIO %d, return %d from port %d\n",
341 offset, retirq, port->number);
Linus Walleijcc890cd2011-09-08 09:04:51 +0100342 return retirq;
Linus Walleijbd41b992009-04-23 21:15:04 +0100343}
Linus Walleijbd41b992009-04-23 21:15:04 +0100344
Linus Walleijdc0b1aa2011-11-16 21:58:10 +0100345/* Returning -EINVAL means "supported but not available" */
346int u300_gpio_config_get(struct gpio_chip *chip,
347 unsigned offset,
348 unsigned long *config)
349{
350 struct u300_gpio *gpio = to_u300_gpio(chip);
351 enum pin_config_param param = (enum pin_config_param) *config;
352 bool biasmode;
353 u32 drmode;
354
355 /* One bit per pin, clamp to bool range */
356 biasmode = !!(readl(U300_PIN_REG(offset, per)) & U300_PIN_BIT(offset));
357
358 /* Mask out the two bits for this pin and shift to bits 0,1 */
359 drmode = readl(U300_PIN_REG(offset, pcr));
360 drmode &= (U300_GPIO_PXPCR_PIN_MODE_MASK << ((offset & 0x07) << 1));
361 drmode >>= ((offset & 0x07) << 1);
362
363 switch(param) {
364 case PIN_CONFIG_BIAS_HIGH_IMPEDANCE:
365 *config = 0;
366 if (biasmode)
367 return 0;
368 else
369 return -EINVAL;
370 break;
371 case PIN_CONFIG_BIAS_PULL_UP:
372 *config = 0;
373 if (!biasmode)
374 return 0;
375 else
376 return -EINVAL;
377 break;
378 case PIN_CONFIG_DRIVE_PUSH_PULL:
379 *config = 0;
380 if (drmode == U300_GPIO_PXPCR_PIN_MODE_OUTPUT_PUSH_PULL)
381 return 0;
382 else
383 return -EINVAL;
384 break;
385 case PIN_CONFIG_DRIVE_OPEN_DRAIN:
386 *config = 0;
387 if (drmode == U300_GPIO_PXPCR_PIN_MODE_OUTPUT_OPEN_DRAIN)
388 return 0;
389 else
390 return -EINVAL;
391 break;
392 case PIN_CONFIG_DRIVE_OPEN_SOURCE:
393 *config = 0;
394 if (drmode == U300_GPIO_PXPCR_PIN_MODE_OUTPUT_OPEN_SOURCE)
395 return 0;
396 else
397 return -EINVAL;
398 break;
399 default:
400 break;
401 }
402 return -ENOTSUPP;
403}
404
405int u300_gpio_config_set(struct gpio_chip *chip, unsigned offset,
406 enum pin_config_param param)
Linus Walleijbd41b992009-04-23 21:15:04 +0100407{
Linus Walleijcc890cd2011-09-08 09:04:51 +0100408 struct u300_gpio *gpio = to_u300_gpio(chip);
Linus Walleijbd41b992009-04-23 21:15:04 +0100409 unsigned long flags;
Linus Walleijcc890cd2011-09-08 09:04:51 +0100410 u32 val;
Linus Walleijbd41b992009-04-23 21:15:04 +0100411
412 local_irq_save(flags);
Linus Walleijcc890cd2011-09-08 09:04:51 +0100413 switch (param) {
Linus Walleija050b3e2011-11-16 20:10:09 +0100414 case PIN_CONFIG_BIAS_DISABLE:
415 case PIN_CONFIG_BIAS_HIGH_IMPEDANCE:
Linus Walleijcc890cd2011-09-08 09:04:51 +0100416 val = readl(U300_PIN_REG(offset, per));
417 writel(val | U300_PIN_BIT(offset), U300_PIN_REG(offset, per));
418 break;
Linus Walleija050b3e2011-11-16 20:10:09 +0100419 case PIN_CONFIG_BIAS_PULL_UP:
Linus Walleijcc890cd2011-09-08 09:04:51 +0100420 val = readl(U300_PIN_REG(offset, per));
421 writel(val & ~U300_PIN_BIT(offset), U300_PIN_REG(offset, per));
422 break;
Linus Walleija050b3e2011-11-16 20:10:09 +0100423 case PIN_CONFIG_DRIVE_PUSH_PULL:
Linus Walleijcc890cd2011-09-08 09:04:51 +0100424 val = readl(U300_PIN_REG(offset, pcr));
425 val &= ~(U300_GPIO_PXPCR_PIN_MODE_MASK
426 << ((offset & 0x07) << 1));
427 val |= (U300_GPIO_PXPCR_PIN_MODE_OUTPUT_PUSH_PULL
428 << ((offset & 0x07) << 1));
429 writel(val, U300_PIN_REG(offset, pcr));
430 break;
Linus Walleija050b3e2011-11-16 20:10:09 +0100431 case PIN_CONFIG_DRIVE_OPEN_DRAIN:
Linus Walleijcc890cd2011-09-08 09:04:51 +0100432 val = readl(U300_PIN_REG(offset, pcr));
433 val &= ~(U300_GPIO_PXPCR_PIN_MODE_MASK
434 << ((offset & 0x07) << 1));
435 val |= (U300_GPIO_PXPCR_PIN_MODE_OUTPUT_OPEN_DRAIN
436 << ((offset & 0x07) << 1));
437 writel(val, U300_PIN_REG(offset, pcr));
438 break;
Linus Walleija050b3e2011-11-16 20:10:09 +0100439 case PIN_CONFIG_DRIVE_OPEN_SOURCE:
Linus Walleijcc890cd2011-09-08 09:04:51 +0100440 val = readl(U300_PIN_REG(offset, pcr));
441 val &= ~(U300_GPIO_PXPCR_PIN_MODE_MASK
442 << ((offset & 0x07) << 1));
443 val |= (U300_GPIO_PXPCR_PIN_MODE_OUTPUT_OPEN_SOURCE
444 << ((offset & 0x07) << 1));
445 writel(val, U300_PIN_REG(offset, pcr));
446 break;
447 default:
Linus Walleijbd41b992009-04-23 21:15:04 +0100448 local_irq_restore(flags);
Linus Walleijcc890cd2011-09-08 09:04:51 +0100449 dev_err(gpio->dev, "illegal configuration requested\n");
450 return -EINVAL;
451 }
452 local_irq_restore(flags);
453 return 0;
454}
455
456static struct gpio_chip u300_gpio_chip = {
457 .label = "u300-gpio-chip",
458 .owner = THIS_MODULE,
Linus Walleijb4e3ac72011-11-16 10:24:39 +0100459 .request = u300_gpio_request,
460 .free = u300_gpio_free,
Linus Walleijcc890cd2011-09-08 09:04:51 +0100461 .get = u300_gpio_get,
462 .set = u300_gpio_set,
463 .direction_input = u300_gpio_direction_input,
464 .direction_output = u300_gpio_direction_output,
465 .to_irq = u300_gpio_to_irq,
466};
467
468static void u300_toggle_trigger(struct u300_gpio *gpio, unsigned offset)
469{
470 u32 val;
471
472 val = readl(U300_PIN_REG(offset, icr));
473 /* Set mode depending on state */
474 if (u300_gpio_get(&gpio->chip, offset)) {
475 /* High now, let's trigger on falling edge next then */
476 writel(val & ~U300_PIN_BIT(offset), U300_PIN_REG(offset, icr));
477 dev_dbg(gpio->dev, "next IRQ on falling edge on pin %d\n",
478 offset);
479 } else {
480 /* Low now, let's trigger on rising edge next then */
481 writel(val | U300_PIN_BIT(offset), U300_PIN_REG(offset, icr));
482 dev_dbg(gpio->dev, "next IRQ on rising edge on pin %d\n",
483 offset);
484 }
485}
486
487static int u300_gpio_irq_type(struct irq_data *d, unsigned trigger)
488{
489 struct u300_gpio_port *port = irq_data_get_irq_chip_data(d);
490 struct u300_gpio *gpio = port->gpio;
Linus Walleija6c45b92012-10-17 18:31:20 +0200491 int offset = (port->number << 3) + d->hwirq;
Linus Walleijcc890cd2011-09-08 09:04:51 +0100492 u32 val;
493
494 if ((trigger & IRQF_TRIGGER_RISING) &&
495 (trigger & IRQF_TRIGGER_FALLING)) {
496 /*
497 * The GPIO block can only trigger on falling OR rising edges,
498 * not both. So we need to toggle the mode whenever the pin
499 * goes from one state to the other with a special state flag
500 */
501 dev_dbg(gpio->dev,
502 "trigger on both rising and falling edge on pin %d\n",
503 offset);
504 port->toggle_edge_mode |= U300_PIN_BIT(offset);
505 u300_toggle_trigger(gpio, offset);
506 } else if (trigger & IRQF_TRIGGER_RISING) {
507 dev_dbg(gpio->dev, "trigger on rising edge on pin %d\n",
508 offset);
509 val = readl(U300_PIN_REG(offset, icr));
510 writel(val | U300_PIN_BIT(offset), U300_PIN_REG(offset, icr));
511 port->toggle_edge_mode &= ~U300_PIN_BIT(offset);
512 } else if (trigger & IRQF_TRIGGER_FALLING) {
513 dev_dbg(gpio->dev, "trigger on falling edge on pin %d\n",
514 offset);
515 val = readl(U300_PIN_REG(offset, icr));
516 writel(val & ~U300_PIN_BIT(offset), U300_PIN_REG(offset, icr));
517 port->toggle_edge_mode &= ~U300_PIN_BIT(offset);
Linus Walleijbd41b992009-04-23 21:15:04 +0100518 }
519
Linus Walleijcc890cd2011-09-08 09:04:51 +0100520 return 0;
521}
Linus Walleijbd41b992009-04-23 21:15:04 +0100522
Linus Walleijcc890cd2011-09-08 09:04:51 +0100523static void u300_gpio_irq_enable(struct irq_data *d)
524{
525 struct u300_gpio_port *port = irq_data_get_irq_chip_data(d);
526 struct u300_gpio *gpio = port->gpio;
Linus Walleija6c45b92012-10-17 18:31:20 +0200527 int offset = (port->number << 3) + d->hwirq;
Linus Walleijcc890cd2011-09-08 09:04:51 +0100528 u32 val;
529 unsigned long flags;
530
Linus Walleija6c45b92012-10-17 18:31:20 +0200531 dev_dbg(gpio->dev, "enable IRQ for hwirq %lu on port %s, offset %d\n",
532 d->hwirq, port->name, offset);
Linus Walleijcc890cd2011-09-08 09:04:51 +0100533 local_irq_save(flags);
534 val = readl(U300_PIN_REG(offset, ien));
535 writel(val | U300_PIN_BIT(offset), U300_PIN_REG(offset, ien));
536 local_irq_restore(flags);
537}
538
539static void u300_gpio_irq_disable(struct irq_data *d)
540{
541 struct u300_gpio_port *port = irq_data_get_irq_chip_data(d);
542 struct u300_gpio *gpio = port->gpio;
Linus Walleija6c45b92012-10-17 18:31:20 +0200543 int offset = (port->number << 3) + d->hwirq;
Linus Walleijcc890cd2011-09-08 09:04:51 +0100544 u32 val;
545 unsigned long flags;
546
547 local_irq_save(flags);
548 val = readl(U300_PIN_REG(offset, ien));
549 writel(val & ~U300_PIN_BIT(offset), U300_PIN_REG(offset, ien));
550 local_irq_restore(flags);
551}
552
553static struct irq_chip u300_gpio_irqchip = {
554 .name = "u300-gpio-irqchip",
555 .irq_enable = u300_gpio_irq_enable,
556 .irq_disable = u300_gpio_irq_disable,
557 .irq_set_type = u300_gpio_irq_type,
558
559};
560
561static void u300_gpio_irq_handler(unsigned irq, struct irq_desc *desc)
562{
563 struct u300_gpio_port *port = irq_get_handler_data(irq);
564 struct u300_gpio *gpio = port->gpio;
565 int pinoffset = port->number << 3; /* get the right stride */
566 unsigned long val;
567
568 desc->irq_data.chip->irq_ack(&desc->irq_data);
569 /* Read event register */
570 val = readl(U300_PIN_REG(pinoffset, iev));
571 /* Mask relevant bits */
572 val &= 0xFFU; /* 8 bits per port */
573 /* ACK IRQ (clear event) */
574 writel(val, U300_PIN_REG(pinoffset, iev));
575
576 /* Call IRQ handler */
577 if (val != 0) {
578 int irqoffset;
579
580 for_each_set_bit(irqoffset, &val, U300_GPIO_PINS_PER_PORT) {
Linus Walleija6c45b92012-10-17 18:31:20 +0200581 int pin_irq = irq_find_mapping(port->domain, irqoffset);
Linus Walleijcc890cd2011-09-08 09:04:51 +0100582 int offset = pinoffset + irqoffset;
583
584 dev_dbg(gpio->dev, "GPIO IRQ %d on pin %d\n",
585 pin_irq, offset);
586 generic_handle_irq(pin_irq);
587 /*
588 * Triggering IRQ on both rising and falling edge
589 * needs mockery
590 */
591 if (port->toggle_edge_mode & U300_PIN_BIT(offset))
592 u300_toggle_trigger(gpio, offset);
Linus Walleijbd41b992009-04-23 21:15:04 +0100593 }
594 }
595
Linus Walleijcc890cd2011-09-08 09:04:51 +0100596 desc->irq_data.chip->irq_unmask(&desc->irq_data);
Linus Walleijbd41b992009-04-23 21:15:04 +0100597}
598
Linus Walleijcc890cd2011-09-08 09:04:51 +0100599static void __init u300_gpio_init_pin(struct u300_gpio *gpio,
600 int offset,
601 const struct u300_gpio_confdata *conf)
Linus Walleijbd41b992009-04-23 21:15:04 +0100602{
Linus Walleijcc890cd2011-09-08 09:04:51 +0100603 /* Set mode: input or output */
604 if (conf->output) {
605 u300_gpio_direction_output(&gpio->chip, offset, conf->outval);
Linus Walleijbd41b992009-04-23 21:15:04 +0100606
Linus Walleijcc890cd2011-09-08 09:04:51 +0100607 /* Deactivate bias mode for output */
Linus Walleijdc0b1aa2011-11-16 21:58:10 +0100608 u300_gpio_config_set(&gpio->chip, offset,
609 PIN_CONFIG_BIAS_HIGH_IMPEDANCE);
Linus Walleijcc890cd2011-09-08 09:04:51 +0100610
611 /* Set drive mode for output */
Linus Walleijdc0b1aa2011-11-16 21:58:10 +0100612 u300_gpio_config_set(&gpio->chip, offset,
613 PIN_CONFIG_DRIVE_PUSH_PULL);
Linus Walleijcc890cd2011-09-08 09:04:51 +0100614
615 dev_dbg(gpio->dev, "set up pin %d as output, value: %d\n",
616 offset, conf->outval);
617 } else {
618 u300_gpio_direction_input(&gpio->chip, offset);
619
620 /* Always set output low on input pins */
621 u300_gpio_set(&gpio->chip, offset, 0);
622
623 /* Set bias mode for input */
Linus Walleijdc0b1aa2011-11-16 21:58:10 +0100624 u300_gpio_config_set(&gpio->chip, offset, conf->bias_mode);
Linus Walleijcc890cd2011-09-08 09:04:51 +0100625
626 dev_dbg(gpio->dev, "set up pin %d as input, bias: %04x\n",
627 offset, conf->bias_mode);
628 }
629}
630
631static void __init u300_gpio_init_coh901571(struct u300_gpio *gpio,
632 struct u300_gpio_platform *plat)
633{
634 int i, j;
635
636 /* Write default config and values to all pins */
637 for (i = 0; i < plat->ports; i++) {
638 for (j = 0; j < 8; j++) {
639 const struct u300_gpio_confdata *conf;
640 int offset = (i*8) + j;
641
Linus Walleij04b13de2012-08-13 10:36:55 +0200642 conf = &bs335_gpio_config[i][j];
Linus Walleijcc890cd2011-09-08 09:04:51 +0100643 u300_gpio_init_pin(gpio, offset, conf);
644 }
645 }
646}
647
648static inline void u300_gpio_free_ports(struct u300_gpio *gpio)
649{
650 struct u300_gpio_port *port;
651 struct list_head *p, *n;
652
653 list_for_each_safe(p, n, &gpio->port_list) {
654 port = list_entry(p, struct u300_gpio_port, node);
655 list_del(&port->node);
Linus Walleija6c45b92012-10-17 18:31:20 +0200656 if (port->domain)
657 irq_domain_remove(port->domain);
Linus Walleijcc890cd2011-09-08 09:04:51 +0100658 kfree(port);
659 }
660}
661
662static int __init u300_gpio_probe(struct platform_device *pdev)
663{
664 struct u300_gpio_platform *plat = dev_get_platdata(&pdev->dev);
665 struct u300_gpio *gpio;
666 int err = 0;
667 int portno;
668 u32 val;
669 u32 ifr;
670 int i;
671
672 gpio = kzalloc(sizeof(struct u300_gpio), GFP_KERNEL);
673 if (gpio == NULL) {
674 dev_err(&pdev->dev, "failed to allocate memory\n");
675 return -ENOMEM;
676 }
677
678 gpio->chip = u300_gpio_chip;
679 gpio->chip.ngpio = plat->ports * U300_GPIO_PINS_PER_PORT;
Linus Walleijcc890cd2011-09-08 09:04:51 +0100680 gpio->chip.dev = &pdev->dev;
681 gpio->chip.base = plat->gpio_base;
682 gpio->dev = &pdev->dev;
Linus Walleijbd41b992009-04-23 21:15:04 +0100683
684 /* Get GPIO clock */
Linus Walleijcc890cd2011-09-08 09:04:51 +0100685 gpio->clk = clk_get(gpio->dev, NULL);
686 if (IS_ERR(gpio->clk)) {
687 err = PTR_ERR(gpio->clk);
688 dev_err(gpio->dev, "could not get GPIO clock\n");
Linus Walleijbd41b992009-04-23 21:15:04 +0100689 goto err_no_clk;
690 }
Linus Walleij27e84612012-06-19 23:36:15 +0200691 err = clk_prepare_enable(gpio->clk);
Linus Walleijbd41b992009-04-23 21:15:04 +0100692 if (err) {
Linus Walleijcc890cd2011-09-08 09:04:51 +0100693 dev_err(gpio->dev, "could not enable GPIO clock\n");
Linus Walleijbd41b992009-04-23 21:15:04 +0100694 goto err_no_clk_enable;
695 }
696
Linus Walleijcc890cd2011-09-08 09:04:51 +0100697 gpio->memres = platform_get_resource(pdev, IORESOURCE_MEM, 0);
698 if (!gpio->memres) {
699 dev_err(gpio->dev, "could not get GPIO memory resource\n");
700 err = -ENODEV;
Linus Walleijbd41b992009-04-23 21:15:04 +0100701 goto err_no_resource;
Linus Walleijcc890cd2011-09-08 09:04:51 +0100702 }
Linus Walleijbd41b992009-04-23 21:15:04 +0100703
Linus Walleijcc890cd2011-09-08 09:04:51 +0100704 if (!request_mem_region(gpio->memres->start,
705 resource_size(gpio->memres),
Joe Perches28f65c112011-06-09 09:13:32 -0700706 "GPIO Controller")) {
Linus Walleijbd41b992009-04-23 21:15:04 +0100707 err = -ENODEV;
708 goto err_no_ioregion;
709 }
710
Linus Walleijcc890cd2011-09-08 09:04:51 +0100711 gpio->base = ioremap(gpio->memres->start, resource_size(gpio->memres));
712 if (!gpio->base) {
Linus Walleijbd41b992009-04-23 21:15:04 +0100713 err = -ENOMEM;
714 goto err_no_ioremap;
715 }
716
Linus Walleij04b13de2012-08-13 10:36:55 +0200717 dev_info(gpio->dev,
718 "initializing GPIO Controller COH 901 571/3\n");
719 gpio->stride = U300_GPIO_PORT_STRIDE;
720 gpio->pcr = U300_GPIO_PXPCR;
721 gpio->dor = U300_GPIO_PXPDOR;
722 gpio->dir = U300_GPIO_PXPDIR;
723 gpio->per = U300_GPIO_PXPER;
724 gpio->icr = U300_GPIO_PXICR;
725 gpio->ien = U300_GPIO_PXIEN;
726 gpio->iev = U300_GPIO_PXIEV;
727 ifr = U300_GPIO_PXIFR;
Linus Walleijbd41b992009-04-23 21:15:04 +0100728
Linus Walleij04b13de2012-08-13 10:36:55 +0200729 val = readl(gpio->base + U300_GPIO_CR);
730 dev_info(gpio->dev, "COH901571/3 block version: %d, " \
731 "number of cores: %d totalling %d pins\n",
732 ((val & 0x000001FC) >> 2),
733 ((val & 0x0000FE00) >> 9),
734 ((val & 0x0000FE00) >> 9) * 8);
735 writel(U300_GPIO_CR_BLOCK_CLKRQ_ENABLE,
736 gpio->base + U300_GPIO_CR);
737 u300_gpio_init_coh901571(gpio, plat);
Linus Walleijbd41b992009-04-23 21:15:04 +0100738
Linus Walleijcc890cd2011-09-08 09:04:51 +0100739 /* Add each port with its IRQ separately */
740 INIT_LIST_HEAD(&gpio->port_list);
741 for (portno = 0 ; portno < plat->ports; portno++) {
742 struct u300_gpio_port *port =
743 kmalloc(sizeof(struct u300_gpio_port), GFP_KERNEL);
744
745 if (!port) {
746 dev_err(gpio->dev, "out of memory\n");
747 err = -ENOMEM;
748 goto err_no_port;
749 }
750
751 snprintf(port->name, 8, "gpio%d", portno);
752 port->number = portno;
753 port->gpio = gpio;
754
755 port->irq = platform_get_irq_byname(pdev,
756 port->name);
757
Linus Walleija6c45b92012-10-17 18:31:20 +0200758 dev_dbg(gpio->dev, "register IRQ %d for port %s\n", port->irq,
Linus Walleijcc890cd2011-09-08 09:04:51 +0100759 port->name);
760
Linus Walleija6c45b92012-10-17 18:31:20 +0200761 port->domain = irq_domain_add_linear(pdev->dev.of_node,
762 U300_GPIO_PINS_PER_PORT,
763 &irq_domain_simple_ops,
764 port);
765 if (!port->domain)
766 goto err_no_domain;
767
Linus Walleijcc890cd2011-09-08 09:04:51 +0100768 irq_set_chained_handler(port->irq, u300_gpio_irq_handler);
769 irq_set_handler_data(port->irq, port);
770
771 /* For each GPIO pin set the unique IRQ handler */
772 for (i = 0; i < U300_GPIO_PINS_PER_PORT; i++) {
Linus Walleija6c45b92012-10-17 18:31:20 +0200773 int irqno = irq_create_mapping(port->domain, i);
Linus Walleijcc890cd2011-09-08 09:04:51 +0100774
Linus Walleija6c45b92012-10-17 18:31:20 +0200775 dev_dbg(gpio->dev, "GPIO%d on port %s gets IRQ %d\n",
776 gpio->chip.base + (port->number << 3) + i,
777 port->name, irqno);
Linus Walleijcc890cd2011-09-08 09:04:51 +0100778 irq_set_chip_and_handler(irqno, &u300_gpio_irqchip,
779 handle_simple_irq);
780 set_irq_flags(irqno, IRQF_VALID);
781 irq_set_chip_data(irqno, port);
782 }
783
784 /* Turns off irq force (test register) for this port */
785 writel(0x0, gpio->base + portno * gpio->stride + ifr);
786
787 list_add_tail(&port->node, &gpio->port_list);
788 }
789 dev_dbg(gpio->dev, "initialized %d GPIO ports\n", portno);
790
791 err = gpiochip_add(&gpio->chip);
792 if (err) {
793 dev_err(gpio->dev, "unable to add gpiochip: %d\n", err);
794 goto err_no_chip;
795 }
796
Linus Walleij128a06d2012-02-21 14:31:45 +0100797 /* Spawn pin controller device as child of the GPIO, pass gpio chip */
798 plat->pinctrl_device->dev.platform_data = &gpio->chip;
799 err = platform_device_register(plat->pinctrl_device);
800 if (err)
801 goto err_no_pinctrl;
802
Linus Walleijcc890cd2011-09-08 09:04:51 +0100803 platform_set_drvdata(pdev, gpio);
804
Linus Walleijbd41b992009-04-23 21:15:04 +0100805 return 0;
806
Linus Walleij128a06d2012-02-21 14:31:45 +0100807err_no_pinctrl:
808 err = gpiochip_remove(&gpio->chip);
Linus Walleijcc890cd2011-09-08 09:04:51 +0100809err_no_chip:
Linus Walleija6c45b92012-10-17 18:31:20 +0200810err_no_domain:
Linus Walleijcc890cd2011-09-08 09:04:51 +0100811err_no_port:
812 u300_gpio_free_ports(gpio);
Linus Walleijcc890cd2011-09-08 09:04:51 +0100813 iounmap(gpio->base);
814err_no_ioremap:
815 release_mem_region(gpio->memres->start, resource_size(gpio->memres));
816err_no_ioregion:
817err_no_resource:
Linus Walleij27e84612012-06-19 23:36:15 +0200818 clk_disable_unprepare(gpio->clk);
Linus Walleijcc890cd2011-09-08 09:04:51 +0100819err_no_clk_enable:
820 clk_put(gpio->clk);
821err_no_clk:
822 kfree(gpio);
823 dev_info(&pdev->dev, "module ERROR:%d\n", err);
Linus Walleijbd41b992009-04-23 21:15:04 +0100824 return err;
825}
826
Linus Walleijcc890cd2011-09-08 09:04:51 +0100827static int __exit u300_gpio_remove(struct platform_device *pdev)
Linus Walleijbd41b992009-04-23 21:15:04 +0100828{
Linus Walleijcc890cd2011-09-08 09:04:51 +0100829 struct u300_gpio *gpio = platform_get_drvdata(pdev);
830 int err;
Linus Walleijbd41b992009-04-23 21:15:04 +0100831
832 /* Turn off the GPIO block */
Linus Walleij04b13de2012-08-13 10:36:55 +0200833 writel(0x00000000U, gpio->base + U300_GPIO_CR);
Linus Walleijcc890cd2011-09-08 09:04:51 +0100834
835 err = gpiochip_remove(&gpio->chip);
836 if (err < 0) {
837 dev_err(gpio->dev, "unable to remove gpiochip: %d\n", err);
838 return err;
839 }
840 u300_gpio_free_ports(gpio);
841 iounmap(gpio->base);
842 release_mem_region(gpio->memres->start,
843 resource_size(gpio->memres));
Linus Walleij27e84612012-06-19 23:36:15 +0200844 clk_disable_unprepare(gpio->clk);
Linus Walleijcc890cd2011-09-08 09:04:51 +0100845 clk_put(gpio->clk);
846 platform_set_drvdata(pdev, NULL);
847 kfree(gpio);
Linus Walleijbd41b992009-04-23 21:15:04 +0100848 return 0;
849}
850
Linus Walleijcc890cd2011-09-08 09:04:51 +0100851static struct platform_driver u300_gpio_driver = {
Linus Walleijbd41b992009-04-23 21:15:04 +0100852 .driver = {
853 .name = "u300-gpio",
854 },
Linus Walleijcc890cd2011-09-08 09:04:51 +0100855 .remove = __exit_p(u300_gpio_remove),
Linus Walleijbd41b992009-04-23 21:15:04 +0100856};
857
Linus Walleijbd41b992009-04-23 21:15:04 +0100858static int __init u300_gpio_init(void)
859{
Linus Walleijcc890cd2011-09-08 09:04:51 +0100860 return platform_driver_probe(&u300_gpio_driver, u300_gpio_probe);
Linus Walleijbd41b992009-04-23 21:15:04 +0100861}
862
863static void __exit u300_gpio_exit(void)
864{
Linus Walleijcc890cd2011-09-08 09:04:51 +0100865 platform_driver_unregister(&u300_gpio_driver);
Linus Walleijbd41b992009-04-23 21:15:04 +0100866}
867
868arch_initcall(u300_gpio_init);
869module_exit(u300_gpio_exit);
870
871MODULE_AUTHOR("Linus Walleij <linus.walleij@stericsson.com>");
Linus Walleijcc890cd2011-09-08 09:04:51 +0100872MODULE_DESCRIPTION("ST-Ericsson AB COH 901 335/COH 901 571/3 GPIO driver");
Linus Walleijbd41b992009-04-23 21:15:04 +0100873MODULE_LICENSE("GPL");