blob: 63a2a6632106c3ad50a6ecbbb58e6ba80b11ba35 [file] [log] [blame]
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -08001/*
2 * driver/mfd/asic3.c
3 *
4 * Compaq ASIC3 support.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * Copyright 2001 Compaq Computer Corporation.
11 * Copyright 2004-2005 Phil Blundell
Samuel Ortiz6f2384c2008-06-20 11:02:19 +020012 * Copyright 2007-2008 OpenedHand Ltd.
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -080013 *
14 * Authors: Phil Blundell <pb@handhelds.org>,
15 * Samuel Ortiz <sameo@openedhand.com>
16 *
17 */
18
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -080019#include <linux/kernel.h>
Philipp Zabel9461f652009-06-15 12:10:24 +020020#include <linux/delay.h>
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -080021#include <linux/irq.h>
Samuel Ortiz6f2384c2008-06-20 11:02:19 +020022#include <linux/gpio.h>
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -080023#include <linux/io.h>
24#include <linux/spinlock.h>
25#include <linux/platform_device.h>
26
27#include <linux/mfd/asic3.h>
Philipp Zabel9461f652009-06-15 12:10:24 +020028#include <linux/mfd/core.h>
29#include <linux/mfd/ds1wm.h>
Philipp Zabel09f05ce2009-06-15 12:10:25 +020030#include <linux/mfd/tmio.h>
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -080031
Philipp Zabele956a2a2009-06-05 18:31:02 +020032enum {
33 ASIC3_CLOCK_SPI,
34 ASIC3_CLOCK_OWM,
35 ASIC3_CLOCK_PWM0,
36 ASIC3_CLOCK_PWM1,
37 ASIC3_CLOCK_LED0,
38 ASIC3_CLOCK_LED1,
39 ASIC3_CLOCK_LED2,
40 ASIC3_CLOCK_SD_HOST,
41 ASIC3_CLOCK_SD_BUS,
42 ASIC3_CLOCK_SMBUS,
43 ASIC3_CLOCK_EX0,
44 ASIC3_CLOCK_EX1,
45};
46
47struct asic3_clk {
48 int enabled;
49 unsigned int cdex;
50 unsigned long rate;
51};
52
53#define INIT_CDEX(_name, _rate) \
54 [ASIC3_CLOCK_##_name] = { \
55 .cdex = CLOCK_CDEX_##_name, \
56 .rate = _rate, \
57 }
58
59struct asic3_clk asic3_clk_init[] __initdata = {
60 INIT_CDEX(SPI, 0),
61 INIT_CDEX(OWM, 5000000),
62 INIT_CDEX(PWM0, 0),
63 INIT_CDEX(PWM1, 0),
64 INIT_CDEX(LED0, 0),
65 INIT_CDEX(LED1, 0),
66 INIT_CDEX(LED2, 0),
67 INIT_CDEX(SD_HOST, 24576000),
68 INIT_CDEX(SD_BUS, 12288000),
69 INIT_CDEX(SMBUS, 0),
70 INIT_CDEX(EX0, 32768),
71 INIT_CDEX(EX1, 24576000),
72};
73
Samuel Ortiz6f2384c2008-06-20 11:02:19 +020074struct asic3 {
75 void __iomem *mapping;
76 unsigned int bus_shift;
77 unsigned int irq_nr;
78 unsigned int irq_base;
79 spinlock_t lock;
80 u16 irq_bothedge[4];
81 struct gpio_chip gpio;
82 struct device *dev;
Philipp Zabele956a2a2009-06-05 18:31:02 +020083
84 struct asic3_clk clocks[ARRAY_SIZE(asic3_clk_init)];
Samuel Ortiz6f2384c2008-06-20 11:02:19 +020085};
86
87static int asic3_gpio_get(struct gpio_chip *chip, unsigned offset);
88
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -080089static inline void asic3_write_register(struct asic3 *asic,
90 unsigned int reg, u32 value)
91{
Al Virob32661e2008-03-29 03:10:58 +000092 iowrite16(value, asic->mapping +
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -080093 (reg >> asic->bus_shift));
94}
95
96static inline u32 asic3_read_register(struct asic3 *asic,
97 unsigned int reg)
98{
Al Virob32661e2008-03-29 03:10:58 +000099 return ioread16(asic->mapping +
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800100 (reg >> asic->bus_shift));
101}
102
Philipp Zabel6483c1b2009-06-05 18:31:01 +0200103void asic3_set_register(struct asic3 *asic, u32 reg, u32 bits, bool set)
104{
105 unsigned long flags;
106 u32 val;
107
108 spin_lock_irqsave(&asic->lock, flags);
109 val = asic3_read_register(asic, reg);
110 if (set)
111 val |= bits;
112 else
113 val &= ~bits;
114 asic3_write_register(asic, reg, val);
115 spin_unlock_irqrestore(&asic->lock, flags);
116}
117
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800118/* IRQs */
119#define MAX_ASIC_ISR_LOOPS 20
Samuel Ortiz3b8139f2008-06-20 11:12:21 +0200120#define ASIC3_GPIO_BASE_INCR \
121 (ASIC3_GPIO_B_BASE - ASIC3_GPIO_A_BASE)
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800122
123static void asic3_irq_flip_edge(struct asic3 *asic,
124 u32 base, int bit)
125{
126 u16 edge;
127 unsigned long flags;
128
129 spin_lock_irqsave(&asic->lock, flags);
130 edge = asic3_read_register(asic,
Samuel Ortiz3b8139f2008-06-20 11:12:21 +0200131 base + ASIC3_GPIO_EDGE_TRIGGER);
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800132 edge ^= bit;
133 asic3_write_register(asic,
Samuel Ortiz3b8139f2008-06-20 11:12:21 +0200134 base + ASIC3_GPIO_EDGE_TRIGGER, edge);
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800135 spin_unlock_irqrestore(&asic->lock, flags);
136}
137
138static void asic3_irq_demux(unsigned int irq, struct irq_desc *desc)
139{
140 int iter, i;
141 unsigned long flags;
142 struct asic3 *asic;
143
144 desc->chip->ack(irq);
145
146 asic = desc->handler_data;
147
148 for (iter = 0 ; iter < MAX_ASIC_ISR_LOOPS; iter++) {
149 u32 status;
150 int bank;
151
152 spin_lock_irqsave(&asic->lock, flags);
153 status = asic3_read_register(asic,
Samuel Ortiz3b8139f2008-06-20 11:12:21 +0200154 ASIC3_OFFSET(INTR, P_INT_STAT));
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800155 spin_unlock_irqrestore(&asic->lock, flags);
156
157 /* Check all ten register bits */
158 if ((status & 0x3ff) == 0)
159 break;
160
161 /* Handle GPIO IRQs */
162 for (bank = 0; bank < ASIC3_NUM_GPIO_BANKS; bank++) {
163 if (status & (1 << bank)) {
164 unsigned long base, istat;
165
Samuel Ortiz3b8139f2008-06-20 11:12:21 +0200166 base = ASIC3_GPIO_A_BASE
167 + bank * ASIC3_GPIO_BASE_INCR;
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800168
169 spin_lock_irqsave(&asic->lock, flags);
170 istat = asic3_read_register(asic,
171 base +
Samuel Ortiz3b8139f2008-06-20 11:12:21 +0200172 ASIC3_GPIO_INT_STATUS);
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800173 /* Clearing IntStatus */
174 asic3_write_register(asic,
175 base +
Samuel Ortiz3b8139f2008-06-20 11:12:21 +0200176 ASIC3_GPIO_INT_STATUS, 0);
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800177 spin_unlock_irqrestore(&asic->lock, flags);
178
179 for (i = 0; i < ASIC3_GPIOS_PER_BANK; i++) {
180 int bit = (1 << i);
181 unsigned int irqnr;
182
183 if (!(istat & bit))
184 continue;
185
186 irqnr = asic->irq_base +
187 (ASIC3_GPIOS_PER_BANK * bank)
188 + i;
Yinghai Lu08678b02008-08-19 20:50:05 -0700189 desc = irq_to_desc(irqnr);
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800190 desc->handle_irq(irqnr, desc);
191 if (asic->irq_bothedge[bank] & bit)
192 asic3_irq_flip_edge(asic, base,
193 bit);
194 }
195 }
196 }
197
198 /* Handle remaining IRQs in the status register */
199 for (i = ASIC3_NUM_GPIOS; i < ASIC3_NR_IRQS; i++) {
200 /* They start at bit 4 and go up */
201 if (status & (1 << (i - ASIC3_NUM_GPIOS + 4))) {
Yinghai Lu08678b02008-08-19 20:50:05 -0700202 desc = irq_to_desc(asic->irq_base + i);
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800203 desc->handle_irq(asic->irq_base + i,
204 desc);
205 }
206 }
207 }
208
209 if (iter >= MAX_ASIC_ISR_LOOPS)
Samuel Ortiz24f4f2e2008-06-20 11:11:19 +0200210 dev_err(asic->dev, "interrupt processing overrun\n");
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800211}
212
213static inline int asic3_irq_to_bank(struct asic3 *asic, int irq)
214{
215 int n;
216
217 n = (irq - asic->irq_base) >> 4;
218
Samuel Ortiz3b8139f2008-06-20 11:12:21 +0200219 return (n * (ASIC3_GPIO_B_BASE - ASIC3_GPIO_A_BASE));
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800220}
221
222static inline int asic3_irq_to_index(struct asic3 *asic, int irq)
223{
224 return (irq - asic->irq_base) & 0xf;
225}
226
227static void asic3_mask_gpio_irq(unsigned int irq)
228{
229 struct asic3 *asic = get_irq_chip_data(irq);
230 u32 val, bank, index;
231 unsigned long flags;
232
233 bank = asic3_irq_to_bank(asic, irq);
234 index = asic3_irq_to_index(asic, irq);
235
236 spin_lock_irqsave(&asic->lock, flags);
Samuel Ortiz3b8139f2008-06-20 11:12:21 +0200237 val = asic3_read_register(asic, bank + ASIC3_GPIO_MASK);
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800238 val |= 1 << index;
Samuel Ortiz3b8139f2008-06-20 11:12:21 +0200239 asic3_write_register(asic, bank + ASIC3_GPIO_MASK, val);
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800240 spin_unlock_irqrestore(&asic->lock, flags);
241}
242
243static void asic3_mask_irq(unsigned int irq)
244{
245 struct asic3 *asic = get_irq_chip_data(irq);
246 int regval;
247 unsigned long flags;
248
249 spin_lock_irqsave(&asic->lock, flags);
250 regval = asic3_read_register(asic,
Samuel Ortiz3b8139f2008-06-20 11:12:21 +0200251 ASIC3_INTR_BASE +
252 ASIC3_INTR_INT_MASK);
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800253
254 regval &= ~(ASIC3_INTMASK_MASK0 <<
255 (irq - (asic->irq_base + ASIC3_NUM_GPIOS)));
256
257 asic3_write_register(asic,
Samuel Ortiz3b8139f2008-06-20 11:12:21 +0200258 ASIC3_INTR_BASE +
259 ASIC3_INTR_INT_MASK,
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800260 regval);
261 spin_unlock_irqrestore(&asic->lock, flags);
262}
263
264static void asic3_unmask_gpio_irq(unsigned int irq)
265{
266 struct asic3 *asic = get_irq_chip_data(irq);
267 u32 val, bank, index;
268 unsigned long flags;
269
270 bank = asic3_irq_to_bank(asic, irq);
271 index = asic3_irq_to_index(asic, irq);
272
273 spin_lock_irqsave(&asic->lock, flags);
Samuel Ortiz3b8139f2008-06-20 11:12:21 +0200274 val = asic3_read_register(asic, bank + ASIC3_GPIO_MASK);
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800275 val &= ~(1 << index);
Samuel Ortiz3b8139f2008-06-20 11:12:21 +0200276 asic3_write_register(asic, bank + ASIC3_GPIO_MASK, val);
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800277 spin_unlock_irqrestore(&asic->lock, flags);
278}
279
280static void asic3_unmask_irq(unsigned int irq)
281{
282 struct asic3 *asic = get_irq_chip_data(irq);
283 int regval;
284 unsigned long flags;
285
286 spin_lock_irqsave(&asic->lock, flags);
287 regval = asic3_read_register(asic,
Samuel Ortiz3b8139f2008-06-20 11:12:21 +0200288 ASIC3_INTR_BASE +
289 ASIC3_INTR_INT_MASK);
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800290
291 regval |= (ASIC3_INTMASK_MASK0 <<
292 (irq - (asic->irq_base + ASIC3_NUM_GPIOS)));
293
294 asic3_write_register(asic,
Samuel Ortiz3b8139f2008-06-20 11:12:21 +0200295 ASIC3_INTR_BASE +
296 ASIC3_INTR_INT_MASK,
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800297 regval);
298 spin_unlock_irqrestore(&asic->lock, flags);
299}
300
301static int asic3_gpio_irq_type(unsigned int irq, unsigned int type)
302{
303 struct asic3 *asic = get_irq_chip_data(irq);
304 u32 bank, index;
305 u16 trigger, level, edge, bit;
306 unsigned long flags;
307
308 bank = asic3_irq_to_bank(asic, irq);
309 index = asic3_irq_to_index(asic, irq);
310 bit = 1<<index;
311
312 spin_lock_irqsave(&asic->lock, flags);
313 level = asic3_read_register(asic,
Samuel Ortiz3b8139f2008-06-20 11:12:21 +0200314 bank + ASIC3_GPIO_LEVEL_TRIGGER);
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800315 edge = asic3_read_register(asic,
Samuel Ortiz3b8139f2008-06-20 11:12:21 +0200316 bank + ASIC3_GPIO_EDGE_TRIGGER);
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800317 trigger = asic3_read_register(asic,
Samuel Ortiz3b8139f2008-06-20 11:12:21 +0200318 bank + ASIC3_GPIO_TRIGGER_TYPE);
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800319 asic->irq_bothedge[(irq - asic->irq_base) >> 4] &= ~bit;
320
Dmitry Baryshkov6cab4862008-07-27 04:23:31 +0100321 if (type == IRQ_TYPE_EDGE_RISING) {
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800322 trigger |= bit;
323 edge |= bit;
Dmitry Baryshkov6cab4862008-07-27 04:23:31 +0100324 } else if (type == IRQ_TYPE_EDGE_FALLING) {
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800325 trigger |= bit;
326 edge &= ~bit;
Dmitry Baryshkov6cab4862008-07-27 04:23:31 +0100327 } else if (type == IRQ_TYPE_EDGE_BOTH) {
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800328 trigger |= bit;
Samuel Ortiz6f2384c2008-06-20 11:02:19 +0200329 if (asic3_gpio_get(&asic->gpio, irq - asic->irq_base))
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800330 edge &= ~bit;
331 else
332 edge |= bit;
333 asic->irq_bothedge[(irq - asic->irq_base) >> 4] |= bit;
Dmitry Baryshkov6cab4862008-07-27 04:23:31 +0100334 } else if (type == IRQ_TYPE_LEVEL_LOW) {
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800335 trigger &= ~bit;
336 level &= ~bit;
Dmitry Baryshkov6cab4862008-07-27 04:23:31 +0100337 } else if (type == IRQ_TYPE_LEVEL_HIGH) {
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800338 trigger &= ~bit;
339 level |= bit;
340 } else {
341 /*
Dmitry Baryshkov6cab4862008-07-27 04:23:31 +0100342 * if type == IRQ_TYPE_NONE, we should mask interrupts, but
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800343 * be careful to not unmask them if mask was also called.
344 * Probably need internal state for mask.
345 */
Samuel Ortiz24f4f2e2008-06-20 11:11:19 +0200346 dev_notice(asic->dev, "irq type not changed\n");
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800347 }
Samuel Ortiz3b8139f2008-06-20 11:12:21 +0200348 asic3_write_register(asic, bank + ASIC3_GPIO_LEVEL_TRIGGER,
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800349 level);
Samuel Ortiz3b8139f2008-06-20 11:12:21 +0200350 asic3_write_register(asic, bank + ASIC3_GPIO_EDGE_TRIGGER,
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800351 edge);
Samuel Ortiz3b8139f2008-06-20 11:12:21 +0200352 asic3_write_register(asic, bank + ASIC3_GPIO_TRIGGER_TYPE,
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800353 trigger);
354 spin_unlock_irqrestore(&asic->lock, flags);
355 return 0;
356}
357
358static struct irq_chip asic3_gpio_irq_chip = {
359 .name = "ASIC3-GPIO",
360 .ack = asic3_mask_gpio_irq,
361 .mask = asic3_mask_gpio_irq,
362 .unmask = asic3_unmask_gpio_irq,
363 .set_type = asic3_gpio_irq_type,
364};
365
366static struct irq_chip asic3_irq_chip = {
367 .name = "ASIC3",
368 .ack = asic3_mask_irq,
369 .mask = asic3_mask_irq,
370 .unmask = asic3_unmask_irq,
371};
372
Philipp Zabel065032f2008-06-21 00:51:38 +0200373static int __init asic3_irq_probe(struct platform_device *pdev)
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800374{
375 struct asic3 *asic = platform_get_drvdata(pdev);
376 unsigned long clksel = 0;
377 unsigned int irq, irq_base;
Roel Kluinc491b2f2008-07-25 19:44:41 -0700378 int ret;
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800379
Roel Kluinc491b2f2008-07-25 19:44:41 -0700380 ret = platform_get_irq(pdev, 0);
381 if (ret < 0)
382 return ret;
383 asic->irq_nr = ret;
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800384
385 /* turn on clock to IRQ controller */
386 clksel |= CLOCK_SEL_CX;
387 asic3_write_register(asic, ASIC3_OFFSET(CLOCK, SEL),
388 clksel);
389
390 irq_base = asic->irq_base;
391
392 for (irq = irq_base; irq < irq_base + ASIC3_NR_IRQS; irq++) {
393 if (irq < asic->irq_base + ASIC3_NUM_GPIOS)
394 set_irq_chip(irq, &asic3_gpio_irq_chip);
395 else
396 set_irq_chip(irq, &asic3_irq_chip);
397
398 set_irq_chip_data(irq, asic);
399 set_irq_handler(irq, handle_level_irq);
400 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
401 }
402
Samuel Ortiz3b8139f2008-06-20 11:12:21 +0200403 asic3_write_register(asic, ASIC3_OFFSET(INTR, INT_MASK),
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800404 ASIC3_INTMASK_GINTMASK);
405
406 set_irq_chained_handler(asic->irq_nr, asic3_irq_demux);
Dmitry Baryshkov6cab4862008-07-27 04:23:31 +0100407 set_irq_type(asic->irq_nr, IRQ_TYPE_EDGE_RISING);
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800408 set_irq_data(asic->irq_nr, asic);
409
410 return 0;
411}
412
413static void asic3_irq_remove(struct platform_device *pdev)
414{
415 struct asic3 *asic = platform_get_drvdata(pdev);
416 unsigned int irq, irq_base;
417
418 irq_base = asic->irq_base;
419
420 for (irq = irq_base; irq < irq_base + ASIC3_NR_IRQS; irq++) {
421 set_irq_flags(irq, 0);
422 set_irq_handler(irq, NULL);
423 set_irq_chip(irq, NULL);
424 set_irq_chip_data(irq, NULL);
425 }
426 set_irq_chained_handler(asic->irq_nr, NULL);
427}
428
429/* GPIOs */
Samuel Ortiz6f2384c2008-06-20 11:02:19 +0200430static int asic3_gpio_direction(struct gpio_chip *chip,
431 unsigned offset, int out)
432{
433 u32 mask = ASIC3_GPIO_TO_MASK(offset), out_reg;
434 unsigned int gpio_base;
435 unsigned long flags;
436 struct asic3 *asic;
437
438 asic = container_of(chip, struct asic3, gpio);
439 gpio_base = ASIC3_GPIO_TO_BASE(offset);
440
Samuel Ortiz3b8139f2008-06-20 11:12:21 +0200441 if (gpio_base > ASIC3_GPIO_D_BASE) {
Samuel Ortiz24f4f2e2008-06-20 11:11:19 +0200442 dev_err(asic->dev, "Invalid base (0x%x) for gpio %d\n",
443 gpio_base, offset);
Samuel Ortiz6f2384c2008-06-20 11:02:19 +0200444 return -EINVAL;
445 }
446
447 spin_lock_irqsave(&asic->lock, flags);
448
Samuel Ortiz3b8139f2008-06-20 11:12:21 +0200449 out_reg = asic3_read_register(asic, gpio_base + ASIC3_GPIO_DIRECTION);
Samuel Ortiz6f2384c2008-06-20 11:02:19 +0200450
451 /* Input is 0, Output is 1 */
452 if (out)
453 out_reg |= mask;
454 else
455 out_reg &= ~mask;
456
Samuel Ortiz3b8139f2008-06-20 11:12:21 +0200457 asic3_write_register(asic, gpio_base + ASIC3_GPIO_DIRECTION, out_reg);
Samuel Ortiz6f2384c2008-06-20 11:02:19 +0200458
459 spin_unlock_irqrestore(&asic->lock, flags);
460
461 return 0;
462
463}
464
465static int asic3_gpio_direction_input(struct gpio_chip *chip,
466 unsigned offset)
467{
468 return asic3_gpio_direction(chip, offset, 0);
469}
470
471static int asic3_gpio_direction_output(struct gpio_chip *chip,
472 unsigned offset, int value)
473{
474 return asic3_gpio_direction(chip, offset, 1);
475}
476
477static int asic3_gpio_get(struct gpio_chip *chip,
478 unsigned offset)
479{
480 unsigned int gpio_base;
481 u32 mask = ASIC3_GPIO_TO_MASK(offset);
482 struct asic3 *asic;
483
484 asic = container_of(chip, struct asic3, gpio);
485 gpio_base = ASIC3_GPIO_TO_BASE(offset);
486
Samuel Ortiz3b8139f2008-06-20 11:12:21 +0200487 if (gpio_base > ASIC3_GPIO_D_BASE) {
Samuel Ortiz24f4f2e2008-06-20 11:11:19 +0200488 dev_err(asic->dev, "Invalid base (0x%x) for gpio %d\n",
489 gpio_base, offset);
Samuel Ortiz6f2384c2008-06-20 11:02:19 +0200490 return -EINVAL;
491 }
492
Samuel Ortiz3b8139f2008-06-20 11:12:21 +0200493 return asic3_read_register(asic, gpio_base + ASIC3_GPIO_STATUS) & mask;
Samuel Ortiz6f2384c2008-06-20 11:02:19 +0200494}
495
496static void asic3_gpio_set(struct gpio_chip *chip,
497 unsigned offset, int value)
498{
499 u32 mask, out_reg;
500 unsigned int gpio_base;
501 unsigned long flags;
502 struct asic3 *asic;
503
504 asic = container_of(chip, struct asic3, gpio);
505 gpio_base = ASIC3_GPIO_TO_BASE(offset);
506
Samuel Ortiz3b8139f2008-06-20 11:12:21 +0200507 if (gpio_base > ASIC3_GPIO_D_BASE) {
Samuel Ortiz24f4f2e2008-06-20 11:11:19 +0200508 dev_err(asic->dev, "Invalid base (0x%x) for gpio %d\n",
509 gpio_base, offset);
Samuel Ortiz6f2384c2008-06-20 11:02:19 +0200510 return;
511 }
512
513 mask = ASIC3_GPIO_TO_MASK(offset);
514
515 spin_lock_irqsave(&asic->lock, flags);
516
Samuel Ortiz3b8139f2008-06-20 11:12:21 +0200517 out_reg = asic3_read_register(asic, gpio_base + ASIC3_GPIO_OUT);
Samuel Ortiz6f2384c2008-06-20 11:02:19 +0200518
519 if (value)
520 out_reg |= mask;
521 else
522 out_reg &= ~mask;
523
Samuel Ortiz3b8139f2008-06-20 11:12:21 +0200524 asic3_write_register(asic, gpio_base + ASIC3_GPIO_OUT, out_reg);
Samuel Ortiz6f2384c2008-06-20 11:02:19 +0200525
526 spin_unlock_irqrestore(&asic->lock, flags);
527
528 return;
529}
530
Philipp Zabel065032f2008-06-21 00:51:38 +0200531static __init int asic3_gpio_probe(struct platform_device *pdev,
532 u16 *gpio_config, int num)
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800533{
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800534 struct asic3 *asic = platform_get_drvdata(pdev);
Samuel Ortiz3b26bf12008-06-20 11:09:51 +0200535 u16 alt_reg[ASIC3_NUM_GPIO_BANKS];
536 u16 out_reg[ASIC3_NUM_GPIO_BANKS];
537 u16 dir_reg[ASIC3_NUM_GPIO_BANKS];
538 int i;
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800539
Russell King59f0cb02008-10-27 11:24:09 +0000540 memset(alt_reg, 0, ASIC3_NUM_GPIO_BANKS * sizeof(u16));
541 memset(out_reg, 0, ASIC3_NUM_GPIO_BANKS * sizeof(u16));
542 memset(dir_reg, 0, ASIC3_NUM_GPIO_BANKS * sizeof(u16));
Samuel Ortiz3b26bf12008-06-20 11:09:51 +0200543
544 /* Enable all GPIOs */
Samuel Ortiz3b8139f2008-06-20 11:12:21 +0200545 asic3_write_register(asic, ASIC3_GPIO_OFFSET(A, MASK), 0xffff);
546 asic3_write_register(asic, ASIC3_GPIO_OFFSET(B, MASK), 0xffff);
547 asic3_write_register(asic, ASIC3_GPIO_OFFSET(C, MASK), 0xffff);
548 asic3_write_register(asic, ASIC3_GPIO_OFFSET(D, MASK), 0xffff);
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800549
Samuel Ortiz3b26bf12008-06-20 11:09:51 +0200550 for (i = 0; i < num; i++) {
551 u8 alt, pin, dir, init, bank_num, bit_num;
552 u16 config = gpio_config[i];
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800553
Samuel Ortiz3b26bf12008-06-20 11:09:51 +0200554 pin = ASIC3_CONFIG_GPIO_PIN(config);
555 alt = ASIC3_CONFIG_GPIO_ALT(config);
556 dir = ASIC3_CONFIG_GPIO_DIR(config);
557 init = ASIC3_CONFIG_GPIO_INIT(config);
558
559 bank_num = ASIC3_GPIO_TO_BANK(pin);
560 bit_num = ASIC3_GPIO_TO_BIT(pin);
561
562 alt_reg[bank_num] |= (alt << bit_num);
563 out_reg[bank_num] |= (init << bit_num);
564 dir_reg[bank_num] |= (dir << bit_num);
565 }
566
567 for (i = 0; i < ASIC3_NUM_GPIO_BANKS; i++) {
568 asic3_write_register(asic,
569 ASIC3_BANK_TO_BASE(i) +
Samuel Ortiz3b8139f2008-06-20 11:12:21 +0200570 ASIC3_GPIO_DIRECTION,
Samuel Ortiz3b26bf12008-06-20 11:09:51 +0200571 dir_reg[i]);
572 asic3_write_register(asic,
Samuel Ortiz3b8139f2008-06-20 11:12:21 +0200573 ASIC3_BANK_TO_BASE(i) + ASIC3_GPIO_OUT,
Samuel Ortiz3b26bf12008-06-20 11:09:51 +0200574 out_reg[i]);
575 asic3_write_register(asic,
576 ASIC3_BANK_TO_BASE(i) +
Samuel Ortiz3b8139f2008-06-20 11:12:21 +0200577 ASIC3_GPIO_ALT_FUNCTION,
Samuel Ortiz3b26bf12008-06-20 11:09:51 +0200578 alt_reg[i]);
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800579 }
580
Samuel Ortiz6f2384c2008-06-20 11:02:19 +0200581 return gpiochip_add(&asic->gpio);
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800582}
583
Samuel Ortiz6f2384c2008-06-20 11:02:19 +0200584static int asic3_gpio_remove(struct platform_device *pdev)
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800585{
Samuel Ortiz6f2384c2008-06-20 11:02:19 +0200586 struct asic3 *asic = platform_get_drvdata(pdev);
587
588 return gpiochip_remove(&asic->gpio);
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800589}
590
Philipp Zabele956a2a2009-06-05 18:31:02 +0200591static int asic3_clk_enable(struct asic3 *asic, struct asic3_clk *clk)
592{
593 unsigned long flags;
594 u32 cdex;
595
596 spin_lock_irqsave(&asic->lock, flags);
597 if (clk->enabled++ == 0) {
598 cdex = asic3_read_register(asic, ASIC3_OFFSET(CLOCK, CDEX));
599 cdex |= clk->cdex;
600 asic3_write_register(asic, ASIC3_OFFSET(CLOCK, CDEX), cdex);
601 }
602 spin_unlock_irqrestore(&asic->lock, flags);
603
604 return 0;
605}
606
607static void asic3_clk_disable(struct asic3 *asic, struct asic3_clk *clk)
608{
609 unsigned long flags;
610 u32 cdex;
611
612 WARN_ON(clk->enabled == 0);
613
614 spin_lock_irqsave(&asic->lock, flags);
615 if (--clk->enabled == 0) {
616 cdex = asic3_read_register(asic, ASIC3_OFFSET(CLOCK, CDEX));
617 cdex &= ~clk->cdex;
618 asic3_write_register(asic, ASIC3_OFFSET(CLOCK, CDEX), cdex);
619 }
620 spin_unlock_irqrestore(&asic->lock, flags);
621}
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800622
Philipp Zabel9461f652009-06-15 12:10:24 +0200623/* MFD cells (SPI, PWM, LED, DS1WM, MMC) */
624static struct ds1wm_driver_data ds1wm_pdata = {
625 .active_high = 1,
626};
627
628static struct resource ds1wm_resources[] = {
629 {
630 .start = ASIC3_OWM_BASE,
631 .end = ASIC3_OWM_BASE + 0x13,
632 .flags = IORESOURCE_MEM,
633 },
634 {
635 .start = ASIC3_IRQ_OWM,
636 .start = ASIC3_IRQ_OWM,
637 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
638 },
639};
640
641static int ds1wm_enable(struct platform_device *pdev)
642{
643 struct asic3 *asic = dev_get_drvdata(pdev->dev.parent);
644
645 /* Turn on external clocks and the OWM clock */
646 asic3_clk_enable(asic, &asic->clocks[ASIC3_CLOCK_EX0]);
647 asic3_clk_enable(asic, &asic->clocks[ASIC3_CLOCK_EX1]);
648 asic3_clk_enable(asic, &asic->clocks[ASIC3_CLOCK_OWM]);
649 msleep(1);
650
651 /* Reset and enable DS1WM */
652 asic3_set_register(asic, ASIC3_OFFSET(EXTCF, RESET),
653 ASIC3_EXTCF_OWM_RESET, 1);
654 msleep(1);
655 asic3_set_register(asic, ASIC3_OFFSET(EXTCF, RESET),
656 ASIC3_EXTCF_OWM_RESET, 0);
657 msleep(1);
658 asic3_set_register(asic, ASIC3_OFFSET(EXTCF, SELECT),
659 ASIC3_EXTCF_OWM_EN, 1);
660 msleep(1);
661
662 return 0;
663}
664
665static int ds1wm_disable(struct platform_device *pdev)
666{
667 struct asic3 *asic = dev_get_drvdata(pdev->dev.parent);
668
669 asic3_set_register(asic, ASIC3_OFFSET(EXTCF, SELECT),
670 ASIC3_EXTCF_OWM_EN, 0);
671
672 asic3_clk_disable(asic, &asic->clocks[ASIC3_CLOCK_OWM]);
673 asic3_clk_disable(asic, &asic->clocks[ASIC3_CLOCK_EX0]);
674 asic3_clk_disable(asic, &asic->clocks[ASIC3_CLOCK_EX1]);
675
676 return 0;
677}
678
679static struct mfd_cell asic3_cell_ds1wm = {
680 .name = "ds1wm",
681 .enable = ds1wm_enable,
682 .disable = ds1wm_disable,
683 .driver_data = &ds1wm_pdata,
684 .num_resources = ARRAY_SIZE(ds1wm_resources),
685 .resources = ds1wm_resources,
686};
687
Philipp Zabel09f05ce2009-06-15 12:10:25 +0200688static struct tmio_mmc_data asic3_mmc_data = {
689 .hclk = 24576000,
690};
691
692static struct resource asic3_mmc_resources[] = {
693 {
694 .start = ASIC3_SD_CTRL_BASE,
695 .end = ASIC3_SD_CTRL_BASE + 0x3ff,
696 .flags = IORESOURCE_MEM,
697 },
698 {
699 .start = ASIC3_SD_CONFIG_BASE,
700 .end = ASIC3_SD_CONFIG_BASE + 0x1ff,
701 .flags = IORESOURCE_MEM,
702 },
703 {
704 .start = 0,
705 .end = 0,
706 .flags = IORESOURCE_IRQ,
707 },
708};
709
710static int asic3_mmc_enable(struct platform_device *pdev)
711{
712 struct asic3 *asic = dev_get_drvdata(pdev->dev.parent);
713
714 /* Not sure if it must be done bit by bit, but leaving as-is */
715 asic3_set_register(asic, ASIC3_OFFSET(SDHWCTRL, SDCONF),
716 ASIC3_SDHWCTRL_LEVCD, 1);
717 asic3_set_register(asic, ASIC3_OFFSET(SDHWCTRL, SDCONF),
718 ASIC3_SDHWCTRL_LEVWP, 1);
719 asic3_set_register(asic, ASIC3_OFFSET(SDHWCTRL, SDCONF),
720 ASIC3_SDHWCTRL_SUSPEND, 0);
721 asic3_set_register(asic, ASIC3_OFFSET(SDHWCTRL, SDCONF),
722 ASIC3_SDHWCTRL_PCLR, 0);
723
724 asic3_clk_enable(asic, &asic->clocks[ASIC3_CLOCK_EX0]);
725 /* CLK32 used for card detection and for interruption detection
726 * when HCLK is stopped.
727 */
728 asic3_clk_enable(asic, &asic->clocks[ASIC3_CLOCK_EX1]);
729 msleep(1);
730
731 /* HCLK 24.576 MHz, BCLK 12.288 MHz: */
732 asic3_write_register(asic, ASIC3_OFFSET(CLOCK, SEL),
733 CLOCK_SEL_CX | CLOCK_SEL_SD_HCLK_SEL);
734
735 asic3_clk_enable(asic, &asic->clocks[ASIC3_CLOCK_SD_HOST]);
736 asic3_clk_enable(asic, &asic->clocks[ASIC3_CLOCK_SD_BUS]);
737 msleep(1);
738
739 asic3_set_register(asic, ASIC3_OFFSET(EXTCF, SELECT),
740 ASIC3_EXTCF_SD_MEM_ENABLE, 1);
741
742 /* Enable SD card slot 3.3V power supply */
743 asic3_set_register(asic, ASIC3_OFFSET(SDHWCTRL, SDCONF),
744 ASIC3_SDHWCTRL_SDPWR, 1);
745
746 return 0;
747}
748
749static int asic3_mmc_disable(struct platform_device *pdev)
750{
751 struct asic3 *asic = dev_get_drvdata(pdev->dev.parent);
752
753 /* Put in suspend mode */
754 asic3_set_register(asic, ASIC3_OFFSET(SDHWCTRL, SDCONF),
755 ASIC3_SDHWCTRL_SUSPEND, 1);
756
757 /* Disable clocks */
758 asic3_clk_disable(asic, &asic->clocks[ASIC3_CLOCK_SD_HOST]);
759 asic3_clk_disable(asic, &asic->clocks[ASIC3_CLOCK_SD_BUS]);
760 asic3_clk_disable(asic, &asic->clocks[ASIC3_CLOCK_EX0]);
761 asic3_clk_disable(asic, &asic->clocks[ASIC3_CLOCK_EX1]);
762 return 0;
763}
764
765static struct mfd_cell asic3_cell_mmc = {
766 .name = "tmio-mmc",
767 .enable = asic3_mmc_enable,
768 .disable = asic3_mmc_disable,
769 .driver_data = &asic3_mmc_data,
770 .num_resources = ARRAY_SIZE(asic3_mmc_resources),
771 .resources = asic3_mmc_resources,
772};
773
Philipp Zabel9461f652009-06-15 12:10:24 +0200774static int __init asic3_mfd_probe(struct platform_device *pdev,
775 struct resource *mem)
776{
777 struct asic3 *asic = platform_get_drvdata(pdev);
Philipp Zabel09f05ce2009-06-15 12:10:25 +0200778 struct resource *mem_sdio;
779 int irq, ret;
780
781 mem_sdio = platform_get_resource(pdev, IORESOURCE_MEM, 1);
782 if (!mem_sdio)
783 dev_dbg(asic->dev, "no SDIO MEM resource\n");
784
785 irq = platform_get_irq(pdev, 1);
786 if (irq < 0)
787 dev_dbg(asic->dev, "no SDIO IRQ resource\n");
Philipp Zabel9461f652009-06-15 12:10:24 +0200788
789 /* DS1WM */
790 asic3_set_register(asic, ASIC3_OFFSET(EXTCF, SELECT),
791 ASIC3_EXTCF_OWM_SMB, 0);
792
793 ds1wm_resources[0].start >>= asic->bus_shift;
794 ds1wm_resources[0].end >>= asic->bus_shift;
795
796 asic3_cell_ds1wm.platform_data = &asic3_cell_ds1wm;
797 asic3_cell_ds1wm.data_size = sizeof(asic3_cell_ds1wm);
798
Philipp Zabel09f05ce2009-06-15 12:10:25 +0200799 /* MMC */
800 asic3_mmc_resources[0].start >>= asic->bus_shift;
801 asic3_mmc_resources[0].end >>= asic->bus_shift;
802 asic3_mmc_resources[1].start >>= asic->bus_shift;
803 asic3_mmc_resources[1].end >>= asic->bus_shift;
804
805 asic3_cell_mmc.platform_data = &asic3_cell_mmc;
806 asic3_cell_mmc.data_size = sizeof(asic3_cell_mmc);
807
Philipp Zabel9461f652009-06-15 12:10:24 +0200808 ret = mfd_add_devices(&pdev->dev, pdev->id,
809 &asic3_cell_ds1wm, 1, mem, asic->irq_base);
Philipp Zabel09f05ce2009-06-15 12:10:25 +0200810 if (ret < 0)
811 goto out;
Philipp Zabel9461f652009-06-15 12:10:24 +0200812
Philipp Zabel09f05ce2009-06-15 12:10:25 +0200813 if (mem_sdio && (irq >= 0))
814 ret = mfd_add_devices(&pdev->dev, pdev->id,
815 &asic3_cell_mmc, 1, mem_sdio, irq);
816
817 out:
Philipp Zabel9461f652009-06-15 12:10:24 +0200818 return ret;
819}
820
821static void asic3_mfd_remove(struct platform_device *pdev)
822{
823 mfd_remove_devices(&pdev->dev);
824}
825
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800826/* Core */
Philipp Zabel065032f2008-06-21 00:51:38 +0200827static int __init asic3_probe(struct platform_device *pdev)
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800828{
829 struct asic3_platform_data *pdata = pdev->dev.platform_data;
830 struct asic3 *asic;
831 struct resource *mem;
832 unsigned long clksel;
Samuel Ortiz6f2384c2008-06-20 11:02:19 +0200833 int ret = 0;
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800834
835 asic = kzalloc(sizeof(struct asic3), GFP_KERNEL);
Samuel Ortiz6f2384c2008-06-20 11:02:19 +0200836 if (asic == NULL) {
837 printk(KERN_ERR "kzalloc failed\n");
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800838 return -ENOMEM;
Samuel Ortiz6f2384c2008-06-20 11:02:19 +0200839 }
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800840
841 spin_lock_init(&asic->lock);
842 platform_set_drvdata(pdev, asic);
843 asic->dev = &pdev->dev;
844
845 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
846 if (!mem) {
847 ret = -ENOMEM;
Samuel Ortiz24f4f2e2008-06-20 11:11:19 +0200848 dev_err(asic->dev, "no MEM resource\n");
Samuel Ortiz6f2384c2008-06-20 11:02:19 +0200849 goto out_free;
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800850 }
851
Philipp Zabelbe584bd2009-06-05 18:31:04 +0200852 asic->mapping = ioremap(mem->start, resource_size(mem));
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800853 if (!asic->mapping) {
854 ret = -ENOMEM;
Samuel Ortiz24f4f2e2008-06-20 11:11:19 +0200855 dev_err(asic->dev, "Couldn't ioremap\n");
Samuel Ortiz6f2384c2008-06-20 11:02:19 +0200856 goto out_free;
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800857 }
858
859 asic->irq_base = pdata->irq_base;
860
Philipp Zabel99cdb0c2008-07-10 02:17:02 +0200861 /* calculate bus shift from mem resource */
Philipp Zabelbe584bd2009-06-05 18:31:04 +0200862 asic->bus_shift = 2 - (resource_size(mem) >> 12);
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800863
864 clksel = 0;
865 asic3_write_register(asic, ASIC3_OFFSET(CLOCK, SEL), clksel);
866
867 ret = asic3_irq_probe(pdev);
868 if (ret < 0) {
Samuel Ortiz24f4f2e2008-06-20 11:11:19 +0200869 dev_err(asic->dev, "Couldn't probe IRQs\n");
Samuel Ortiz6f2384c2008-06-20 11:02:19 +0200870 goto out_unmap;
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800871 }
Samuel Ortiz6f2384c2008-06-20 11:02:19 +0200872
873 asic->gpio.base = pdata->gpio_base;
874 asic->gpio.ngpio = ASIC3_NUM_GPIOS;
875 asic->gpio.get = asic3_gpio_get;
876 asic->gpio.set = asic3_gpio_set;
877 asic->gpio.direction_input = asic3_gpio_direction_input;
878 asic->gpio.direction_output = asic3_gpio_direction_output;
879
Samuel Ortiz3b26bf12008-06-20 11:09:51 +0200880 ret = asic3_gpio_probe(pdev,
881 pdata->gpio_config,
882 pdata->gpio_config_num);
Samuel Ortiz6f2384c2008-06-20 11:02:19 +0200883 if (ret < 0) {
Samuel Ortiz24f4f2e2008-06-20 11:11:19 +0200884 dev_err(asic->dev, "GPIO probe failed\n");
Samuel Ortiz6f2384c2008-06-20 11:02:19 +0200885 goto out_irq;
886 }
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800887
Philipp Zabele956a2a2009-06-05 18:31:02 +0200888 /* Making a per-device copy is only needed for the
889 * theoretical case of multiple ASIC3s on one board:
890 */
891 memcpy(asic->clocks, asic3_clk_init, sizeof(asic3_clk_init));
892
Philipp Zabel9461f652009-06-15 12:10:24 +0200893 asic3_mfd_probe(pdev, mem);
894
Samuel Ortiz24f4f2e2008-06-20 11:11:19 +0200895 dev_info(asic->dev, "ASIC3 Core driver\n");
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800896
897 return 0;
898
Samuel Ortiz6f2384c2008-06-20 11:02:19 +0200899 out_irq:
900 asic3_irq_remove(pdev);
901
902 out_unmap:
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800903 iounmap(asic->mapping);
Samuel Ortiz6f2384c2008-06-20 11:02:19 +0200904
905 out_free:
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800906 kfree(asic);
907
908 return ret;
909}
910
911static int asic3_remove(struct platform_device *pdev)
912{
Samuel Ortiz6f2384c2008-06-20 11:02:19 +0200913 int ret;
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800914 struct asic3 *asic = platform_get_drvdata(pdev);
915
Philipp Zabel9461f652009-06-15 12:10:24 +0200916 asic3_mfd_remove(pdev);
917
Samuel Ortiz6f2384c2008-06-20 11:02:19 +0200918 ret = asic3_gpio_remove(pdev);
919 if (ret < 0)
920 return ret;
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800921 asic3_irq_remove(pdev);
922
923 asic3_write_register(asic, ASIC3_OFFSET(CLOCK, SEL), 0);
924
925 iounmap(asic->mapping);
926
927 kfree(asic);
928
929 return 0;
930}
931
932static void asic3_shutdown(struct platform_device *pdev)
933{
934}
935
936static struct platform_driver asic3_device_driver = {
937 .driver = {
938 .name = "asic3",
939 },
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800940 .remove = __devexit_p(asic3_remove),
941 .shutdown = asic3_shutdown,
942};
943
944static int __init asic3_init(void)
945{
946 int retval = 0;
Philipp Zabel065032f2008-06-21 00:51:38 +0200947 retval = platform_driver_probe(&asic3_device_driver, asic3_probe);
Samuel Ortizfa9ff4b2008-02-07 00:14:49 -0800948 return retval;
949}
950
951subsys_initcall(asic3_init);