Fix divisor calculation and configuration from previous commit, thanks sn9
[openwrt/svn-archive/archive.git] / target / linux / ar7 / files / drivers / vlynq / vlynq.c
1 /*
2 * Copyright (C) 2006, 2007 Eugene Konev <ejka@openwrt.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #include <linux/init.h>
20 #include <linux/types.h>
21 #include <linux/kernel.h>
22 #include <linux/string.h>
23 #include <linux/device.h>
24 #include <linux/module.h>
25 #include <linux/errno.h>
26 #include <linux/platform_device.h>
27 #include <linux/interrupt.h>
28 #include <linux/device.h>
29 #include <linux/delay.h>
30 #include <linux/io.h>
31
32 #include <linux/vlynq.h>
33
34 #define VLYNQ_CTRL_PM_ENABLE 0x80000000
35 #define VLYNQ_CTRL_CLOCK_INT 0x00008000
36 #define VLYNQ_CTRL_CLOCK_DIV(x) (((x) & 7) << 16)
37 #define VLYNQ_CTRL_INT_LOCAL 0x00004000
38 #define VLYNQ_CTRL_INT_ENABLE 0x00002000
39 #define VLYNQ_CTRL_INT_VECTOR(x) (((x) & 0x1f) << 8)
40 #define VLYNQ_CTRL_INT2CFG 0x00000080
41 #define VLYNQ_CTRL_RESET 0x00000001
42
43 #define VLYNQ_INT_OFFSET 0x00000014
44 #define VLYNQ_REMOTE_OFFSET 0x00000080
45
46 #define VLYNQ_STATUS_LINK 0x00000001
47 #define VLYNQ_STATUS_LERROR 0x00000080
48 #define VLYNQ_STATUS_RERROR 0x00000100
49
50 #define VINT_ENABLE 0x00000100
51 #define VINT_TYPE_EDGE 0x00000080
52 #define VINT_LEVEL_LOW 0x00000040
53 #define VINT_VECTOR(x) ((x) & 0x1f)
54 #define VINT_OFFSET(irq) (8 * ((irq) % 4))
55
56 #define VLYNQ_AUTONEGO_V2 0x00010000
57
58 struct vlynq_regs {
59 u32 revision;
60 u32 control;
61 u32 status;
62 u32 int_prio;
63 u32 int_status;
64 u32 int_pending;
65 u32 int_ptr;
66 u32 tx_offset;
67 struct vlynq_mapping rx_mapping[4];
68 u32 chip;
69 u32 autonego;
70 u32 unused[6];
71 u32 int_device[8];
72 };
73
74 #define vlynq_reg_read(reg) readl(&(reg))
75 #define vlynq_reg_write(reg, val) writel(val, &(reg))
76
77 static int __vlynq_enable_device(struct vlynq_device *dev);
78
79 #ifdef VLYNQ_DEBUG
80 static void vlynq_dump_regs(struct vlynq_device *dev)
81 {
82 int i;
83 printk(KERN_DEBUG "VLYNQ local=%p remote=%p\n",
84 dev->local, dev->remote);
85 for (i = 0; i < 32; i++) {
86 printk(KERN_DEBUG "VLYNQ: local %d: %08x\n",
87 i + 1, ((u32 *)dev->local)[i]);
88 printk(KERN_DEBUG "VLYNQ: remote %d: %08x\n",
89 i + 1, ((u32 *)dev->remote)[i]);
90 }
91 }
92
93 static void vlynq_dump_mem(u32 *base, int count)
94 {
95 int i;
96 for (i = 0; i < (count + 3) / 4; i++) {
97 if (i % 4 == 0) printk(KERN_DEBUG "\nMEM[0x%04x]:", i * 4);
98 printk(KERN_DEBUG " 0x%08x", *(base + i));
99 }
100 printk(KERN_DEBUG "\n");
101 }
102 #endif
103
104 int vlynq_linked(struct vlynq_device *dev)
105 {
106 int i;
107
108 for (i = 0; i < 100; i++)
109 if (vlynq_reg_read(dev->local->status) & VLYNQ_STATUS_LINK)
110 return 1;
111 else
112 cpu_relax();
113
114 return 0;
115 }
116
117 static void vlynq_irq_unmask(unsigned int irq)
118 {
119 u32 val;
120 struct vlynq_device *dev = get_irq_chip_data(irq);
121 int virq;
122
123 BUG_ON(!dev);
124 virq = irq - dev->irq_start;
125 val = vlynq_reg_read(dev->remote->int_device[virq >> 2]);
126 val |= (VINT_ENABLE | virq) << VINT_OFFSET(virq);
127 vlynq_reg_write(dev->remote->int_device[virq >> 2], val);
128 }
129
130 static void vlynq_irq_mask(unsigned int irq)
131 {
132 u32 val;
133 struct vlynq_device *dev = get_irq_chip_data(irq);
134 int virq;
135
136 BUG_ON(!dev);
137 virq = irq - dev->irq_start;
138 val = vlynq_reg_read(dev->remote->int_device[virq >> 2]);
139 val &= ~(VINT_ENABLE << VINT_OFFSET(virq));
140 vlynq_reg_write(dev->remote->int_device[virq >> 2], val);
141 }
142
143 static int vlynq_irq_type(unsigned int irq, unsigned int flow_type)
144 {
145 u32 val;
146 struct vlynq_device *dev = get_irq_chip_data(irq);
147 int virq;
148
149 BUG_ON(!dev);
150 virq = irq - dev->irq_start;
151 val = vlynq_reg_read(dev->remote->int_device[virq >> 2]);
152 switch (flow_type & IRQ_TYPE_SENSE_MASK) {
153 case IRQ_TYPE_EDGE_RISING:
154 case IRQ_TYPE_EDGE_FALLING:
155 case IRQ_TYPE_EDGE_BOTH:
156 val |= VINT_TYPE_EDGE << VINT_OFFSET(virq);
157 val &= ~(VINT_LEVEL_LOW << VINT_OFFSET(virq));
158 break;
159 case IRQ_TYPE_LEVEL_HIGH:
160 val &= ~(VINT_TYPE_EDGE << VINT_OFFSET(virq));
161 val &= ~(VINT_LEVEL_LOW << VINT_OFFSET(virq));
162 break;
163 case IRQ_TYPE_LEVEL_LOW:
164 val &= ~(VINT_TYPE_EDGE << VINT_OFFSET(virq));
165 val |= VINT_LEVEL_LOW << VINT_OFFSET(virq);
166 break;
167 default:
168 return -EINVAL;
169 }
170 vlynq_reg_write(dev->remote->int_device[virq >> 2], val);
171 return 0;
172 }
173
174 static void vlynq_local_ack(unsigned int irq)
175 {
176 struct vlynq_device *dev = get_irq_chip_data(irq);
177 u32 status = vlynq_reg_read(dev->local->status);
178 if (printk_ratelimit())
179 printk(KERN_DEBUG "%s: local status: 0x%08x\n",
180 dev->dev.bus_id, status);
181 vlynq_reg_write(dev->local->status, status);
182 }
183
184 static void vlynq_remote_ack(unsigned int irq)
185 {
186 struct vlynq_device *dev = get_irq_chip_data(irq);
187 u32 status = vlynq_reg_read(dev->remote->status);
188 if (printk_ratelimit())
189 printk(KERN_DEBUG "%s: remote status: 0x%08x\n",
190 dev->dev.bus_id, status);
191 vlynq_reg_write(dev->remote->status, status);
192 }
193
194 static irqreturn_t vlynq_irq(int irq, void *dev_id)
195 {
196 struct vlynq_device *dev = dev_id;
197 u32 status;
198 int virq = 0;
199
200 status = vlynq_reg_read(dev->local->int_status);
201 vlynq_reg_write(dev->local->int_status, status);
202
203 if (unlikely(!status))
204 spurious_interrupt();
205
206 while (status) {
207 if (status & 1)
208 do_IRQ(dev->irq_start + virq);
209 status >>= 1;
210 virq++;
211 }
212
213 return IRQ_HANDLED;
214 }
215
216 static struct irq_chip vlynq_irq_chip = {
217 .name = "vlynq",
218 .unmask = vlynq_irq_unmask,
219 .mask = vlynq_irq_mask,
220 .set_type = vlynq_irq_type,
221 };
222
223 static struct irq_chip vlynq_local_chip = {
224 .name = "vlynq local error",
225 .unmask = vlynq_irq_unmask,
226 .mask = vlynq_irq_mask,
227 .ack = vlynq_local_ack,
228 };
229
230 static struct irq_chip vlynq_remote_chip = {
231 .name = "vlynq local error",
232 .unmask = vlynq_irq_unmask,
233 .mask = vlynq_irq_mask,
234 .ack = vlynq_remote_ack,
235 };
236
237 static int vlynq_setup_irq(struct vlynq_device *dev)
238 {
239 u32 val;
240 int i, virq;
241
242 if (dev->local_irq == dev->remote_irq) {
243 printk(KERN_ERR
244 "%s: local vlynq irq should be different from remote\n",
245 dev->dev.bus_id);
246 return -EINVAL;
247 }
248
249 /* Clear local and remote error bits */
250 vlynq_reg_write(dev->local->status, vlynq_reg_read(dev->local->status));
251 vlynq_reg_write(dev->remote->status,
252 vlynq_reg_read(dev->remote->status));
253
254 /* Now setup interrupts */
255 val = VLYNQ_CTRL_INT_VECTOR(dev->local_irq);
256 val |= VLYNQ_CTRL_INT_ENABLE | VLYNQ_CTRL_INT_LOCAL |
257 VLYNQ_CTRL_INT2CFG;
258 val |= vlynq_reg_read(dev->local->control);
259 vlynq_reg_write(dev->local->int_ptr, VLYNQ_INT_OFFSET);
260 vlynq_reg_write(dev->local->control, val);
261
262 val = VLYNQ_CTRL_INT_VECTOR(dev->remote_irq);
263 val |= VLYNQ_CTRL_INT_ENABLE;
264 val |= vlynq_reg_read(dev->remote->control);
265 vlynq_reg_write(dev->remote->int_ptr, VLYNQ_INT_OFFSET);
266 vlynq_reg_write(dev->remote->control, val);
267
268 for (i = dev->irq_start; i <= dev->irq_end; i++) {
269 virq = i - dev->irq_start;
270 if (virq == dev->local_irq) {
271 set_irq_chip_and_handler(i, &vlynq_local_chip,
272 handle_level_irq);
273 set_irq_chip_data(i, dev);
274 } else if (virq == dev->remote_irq) {
275 set_irq_chip_and_handler(i, &vlynq_remote_chip,
276 handle_level_irq);
277 set_irq_chip_data(i, dev);
278 } else {
279 set_irq_chip_and_handler(i, &vlynq_irq_chip,
280 handle_simple_irq);
281 set_irq_chip_data(i, dev);
282 vlynq_reg_write(dev->remote->int_device[virq >> 2], 0);
283 }
284 }
285
286 if (request_irq(dev->irq, vlynq_irq, IRQF_SHARED, "vlynq", dev)) {
287 printk(KERN_ERR "%s: request_irq failed\n", dev->dev.bus_id);
288 return -EAGAIN;
289 }
290
291 return 0;
292 }
293
294 static void vlynq_device_release(struct device *dev)
295 {
296 struct vlynq_device *vdev = to_vlynq_device(dev);
297 kfree(vdev);
298 }
299
300 static int vlynq_device_match(struct device *dev,
301 struct device_driver *drv)
302 {
303 struct vlynq_device *vdev = to_vlynq_device(dev);
304 struct vlynq_driver *vdrv = to_vlynq_driver(drv);
305 struct vlynq_device_id *ids = vdrv->id_table;
306
307 while (ids->id) {
308 if (ids->id == vdev->dev_id) {
309 vdev->divisor = ids->divisor;
310 vlynq_set_drvdata(vdev, ids);
311 printk(KERN_INFO "Driver found for VLYNQ " \
312 "device: %08x\n", vdev->dev_id);
313 return 1;
314 }
315 printk(KERN_DEBUG "Not using the %08x VLYNQ device's driver" \
316 " for VLYNQ device: %08x\n", ids->id, vdev->dev_id);
317 ids++;
318 }
319 return 0;
320 }
321
322 static int vlynq_device_probe(struct device *dev)
323 {
324 struct vlynq_device *vdev = to_vlynq_device(dev);
325 struct vlynq_driver *drv = to_vlynq_driver(dev->driver);
326 struct vlynq_device_id *id = vlynq_get_drvdata(vdev);
327 int result = -ENODEV;
328
329 get_device(dev);
330 if (drv && drv->probe)
331 result = drv->probe(vdev, id);
332 if (result)
333 put_device(dev);
334 return result;
335 }
336
337 static int vlynq_device_remove(struct device *dev)
338 {
339 struct vlynq_driver *drv = to_vlynq_driver(dev->driver);
340 if (drv && drv->remove)
341 drv->remove(to_vlynq_device(dev));
342 put_device(dev);
343 return 0;
344 }
345
346 int __vlynq_register_driver(struct vlynq_driver *driver, struct module *owner)
347 {
348 driver->driver.name = driver->name;
349 driver->driver.bus = &vlynq_bus_type;
350 return driver_register(&driver->driver);
351 }
352 EXPORT_SYMBOL(__vlynq_register_driver);
353
354 void vlynq_unregister_driver(struct vlynq_driver *driver)
355 {
356 driver_unregister(&driver->driver);
357 }
358 EXPORT_SYMBOL(vlynq_unregister_driver);
359
360 static int __vlynq_enable_device(struct vlynq_device *dev)
361 {
362 int i, result;
363 struct plat_vlynq_ops *ops = dev->dev.platform_data;
364
365 result = ops->on(dev);
366 if (result)
367 return result;
368
369 switch (dev->divisor) {
370 case vlynq_div_auto:
371 /* Only try locally supplied clock, others cause problems */
372 vlynq_reg_write(dev->local->control, 0);
373 vlynq_reg_write(dev->remote->control, 0);
374 if (vlynq_linked(dev)) {
375 dev->divisor = vlynq_div_external;
376 printk(KERN_DEBUG "%s: using external clock\n",
377 dev->dev.bus_id);
378 return 0;
379 }
380 for (i = dev->dev_id ? vlynq_ldiv2 : vlynq_ldiv8; dev->dev_id ?
381 i <= vlynq_ldiv8 : i >= vlynq_ldiv2;
382 dev->dev_id ? i++ : i--) {
383 vlynq_reg_write(dev->local->control,
384 VLYNQ_CTRL_CLOCK_INT |
385 VLYNQ_CTRL_CLOCK_DIV(i - vlynq_ldiv1));
386 if (vlynq_linked(dev)) {
387 printk(KERN_DEBUG
388 "%s: using local clock divisor %d\n",
389 dev->dev.bus_id, i - vlynq_ldiv1 + 1);
390 dev->divisor = i;
391 return 0;
392 }
393 }
394 case vlynq_ldiv1: case vlynq_ldiv2: case vlynq_ldiv3: case vlynq_ldiv4:
395 case vlynq_ldiv5: case vlynq_ldiv6: case vlynq_ldiv7: case vlynq_ldiv8:
396 vlynq_reg_write(dev->local->control,
397 VLYNQ_CTRL_CLOCK_INT |
398 VLYNQ_CTRL_CLOCK_DIV(dev->divisor -
399 vlynq_ldiv1));
400 vlynq_reg_write(dev->remote->control, 0);
401 if (vlynq_linked(dev)) {
402 printk(KERN_DEBUG
403 "%s: using local clock divisor %d\n",
404 dev->dev.bus_id, dev->divisor - vlynq_ldiv1 + 1);
405 return 0;
406 }
407 break;
408 case vlynq_rdiv1: case vlynq_rdiv2: case vlynq_rdiv3: case vlynq_rdiv4:
409 case vlynq_rdiv5: case vlynq_rdiv6: case vlynq_rdiv7: case vlynq_rdiv8:
410 vlynq_reg_write(dev->local->control, 0);
411 vlynq_reg_write(dev->remote->control,
412 VLYNQ_CTRL_CLOCK_INT |
413 VLYNQ_CTRL_CLOCK_DIV(dev->divisor -
414 vlynq_rdiv1));
415 if (vlynq_linked(dev)) {
416 printk(KERN_DEBUG
417 "%s: using remote clock divisor %d\n",
418 dev->dev.bus_id, dev->divisor - vlynq_rdiv1 + 1);
419 return 0;
420 }
421 break;
422 }
423
424 ops->off(dev);
425 return -ENODEV;
426 }
427
428 int vlynq_enable_device(struct vlynq_device *dev)
429 {
430 struct plat_vlynq_ops *ops = dev->dev.platform_data;
431 int result = -ENODEV;
432
433 result = __vlynq_enable_device(dev);
434 if (result)
435 return result;
436
437 result = vlynq_setup_irq(dev);
438 if (result)
439 ops->off(dev);
440
441 dev->enabled = !result;
442 return result;
443 }
444 EXPORT_SYMBOL(vlynq_enable_device);
445
446
447 void vlynq_disable_device(struct vlynq_device *dev)
448 {
449 struct plat_vlynq_ops *ops = dev->dev.platform_data;
450
451 dev->enabled = 0;
452 free_irq(dev->irq, dev);
453 ops->off(dev);
454 }
455 EXPORT_SYMBOL(vlynq_disable_device);
456
457 int vlynq_set_local_mapping(struct vlynq_device *dev, u32 tx_offset,
458 struct vlynq_mapping *mapping)
459 {
460 int i;
461
462 if (!dev->enabled)
463 return -ENXIO;
464
465 vlynq_reg_write(dev->local->tx_offset, tx_offset);
466 for (i = 0; i < 4; i++) {
467 vlynq_reg_write(dev->local->rx_mapping[i].offset,
468 mapping[i].offset);
469 vlynq_reg_write(dev->local->rx_mapping[i].size,
470 mapping[i].size);
471 }
472 return 0;
473 }
474 EXPORT_SYMBOL(vlynq_set_local_mapping);
475
476 int vlynq_set_remote_mapping(struct vlynq_device *dev, u32 tx_offset,
477 struct vlynq_mapping *mapping)
478 {
479 int i;
480
481 if (!dev->enabled)
482 return -ENXIO;
483
484 vlynq_reg_write(dev->remote->tx_offset, tx_offset);
485 for (i = 0; i < 4; i++) {
486 vlynq_reg_write(dev->remote->rx_mapping[i].offset,
487 mapping[i].offset);
488 vlynq_reg_write(dev->remote->rx_mapping[i].size,
489 mapping[i].size);
490 }
491 return 0;
492 }
493 EXPORT_SYMBOL(vlynq_set_remote_mapping);
494
495 int vlynq_set_local_irq(struct vlynq_device *dev, int virq)
496 {
497 int irq = dev->irq_start + virq;
498 if (dev->enabled)
499 return -EBUSY;
500
501 if ((irq < dev->irq_start) || (irq > dev->irq_end))
502 return -EINVAL;
503
504 if (virq == dev->remote_irq)
505 return -EINVAL;
506
507 dev->local_irq = virq;
508
509 return 0;
510 }
511 EXPORT_SYMBOL(vlynq_set_local_irq);
512
513 int vlynq_set_remote_irq(struct vlynq_device *dev, int virq)
514 {
515 int irq = dev->irq_start + virq;
516 if (dev->enabled)
517 return -EBUSY;
518
519 if ((irq < dev->irq_start) || (irq > dev->irq_end))
520 return -EINVAL;
521
522 if (virq == dev->local_irq)
523 return -EINVAL;
524
525 dev->remote_irq = virq;
526
527 return 0;
528 }
529 EXPORT_SYMBOL(vlynq_set_remote_irq);
530
531 static int vlynq_probe(struct platform_device *pdev)
532 {
533 struct vlynq_device *dev;
534 struct resource *regs_res, *mem_res, *irq_res;
535 int len, result;
536
537 regs_res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs");
538 if (!regs_res)
539 return -ENODEV;
540
541 mem_res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mem");
542 if (!mem_res)
543 return -ENODEV;
544
545 irq_res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "devirq");
546 if (!irq_res)
547 return -ENODEV;
548
549 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
550 if (!dev) {
551 printk(KERN_ERR
552 "vlynq: failed to allocate device structure\n");
553 return -ENOMEM;
554 }
555
556 dev->id = pdev->id;
557 dev->dev.bus = &vlynq_bus_type;
558 dev->dev.parent = &pdev->dev;
559 snprintf(dev->dev.bus_id, BUS_ID_SIZE, "vlynq%d", dev->id);
560 dev->dev.bus_id[BUS_ID_SIZE - 1] = 0;
561 dev->dev.platform_data = pdev->dev.platform_data;
562 dev->dev.release = vlynq_device_release;
563
564 dev->regs_start = regs_res->start;
565 dev->regs_end = regs_res->end;
566 dev->mem_start = mem_res->start;
567 dev->mem_end = mem_res->end;
568
569 len = regs_res->end - regs_res->start;
570 if (!request_mem_region(regs_res->start, len, dev->dev.bus_id)) {
571 printk(KERN_ERR "%s: Can't request vlynq registers\n",
572 dev->dev.bus_id);
573 result = -ENXIO;
574 goto fail_request;
575 }
576
577 dev->local = ioremap(regs_res->start, len);
578 if (!dev->local) {
579 printk(KERN_ERR "%s: Can't remap vlynq registers\n",
580 dev->dev.bus_id);
581 result = -ENXIO;
582 goto fail_remap;
583 }
584
585 dev->remote = (struct vlynq_regs *)((void *)dev->local +
586 VLYNQ_REMOTE_OFFSET);
587
588 dev->irq = platform_get_irq_byname(pdev, "irq");
589 dev->irq_start = irq_res->start;
590 dev->irq_end = irq_res->end;
591 dev->local_irq = dev->irq_end - dev->irq_start;
592 dev->remote_irq = dev->local_irq - 1;
593
594 if (device_register(&dev->dev))
595 goto fail_register;
596 platform_set_drvdata(pdev, dev);
597
598 printk(KERN_INFO "%s: regs 0x%p, irq %d, mem 0x%p\n",
599 dev->dev.bus_id, (void *)dev->regs_start, dev->irq,
600 (void *)dev->mem_start);
601
602 dev->dev_id = 0;
603 dev->divisor = vlynq_div_auto;
604 result = __vlynq_enable_device(dev);
605 if (result == 0) {
606 dev->dev_id = vlynq_reg_read(dev->remote->chip);
607 ((struct plat_vlynq_ops *)(dev->dev.platform_data))->off(dev);
608 }
609 if (dev->dev_id)
610 printk(KERN_INFO "Found a VLYNQ device: %08x\n", dev->dev_id);
611
612 return 0;
613
614 fail_register:
615 iounmap(dev->local);
616 fail_remap:
617 fail_request:
618 release_mem_region(regs_res->start, len);
619 kfree(dev);
620 return result;
621 }
622
623 static int vlynq_remove(struct platform_device *pdev)
624 {
625 struct vlynq_device *dev = platform_get_drvdata(pdev);
626
627 device_unregister(&dev->dev);
628 iounmap(dev->local);
629 release_mem_region(dev->regs_start, dev->regs_end - dev->regs_start);
630
631 kfree(dev);
632
633 return 0;
634 }
635
636 static struct platform_driver vlynq_platform_driver = {
637 .driver.name = "vlynq",
638 .probe = vlynq_probe,
639 .remove = __devexit_p(vlynq_remove),
640 };
641
642 struct bus_type vlynq_bus_type = {
643 .name = "vlynq",
644 .match = vlynq_device_match,
645 .probe = vlynq_device_probe,
646 .remove = vlynq_device_remove,
647 };
648 EXPORT_SYMBOL(vlynq_bus_type);
649
650 static int __devinit vlynq_init(void)
651 {
652 int res = 0;
653
654 res = bus_register(&vlynq_bus_type);
655 if (res)
656 goto fail_bus;
657
658 res = platform_driver_register(&vlynq_platform_driver);
659 if (res)
660 goto fail_platform;
661
662 return 0;
663
664 fail_platform:
665 bus_unregister(&vlynq_bus_type);
666 fail_bus:
667 return res;
668 }
669
670 static void __devexit vlynq_exit(void)
671 {
672 platform_driver_unregister(&vlynq_platform_driver);
673 bus_unregister(&vlynq_bus_type);
674 }
675
676 module_init(vlynq_init);
677 module_exit(vlynq_exit);