Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab...
[pandora-kernel.git] / arch / mips / lantiq / devices.c
1 /*
2  *  This program is free software; you can redistribute it and/or modify it
3  *  under the terms of the GNU General Public License version 2 as published
4  *  by the Free Software Foundation.
5  *
6  *  Copyright (C) 2010 John Crispin <blogic@openwrt.org>
7  */
8
9 #include <linux/init.h>
10 #include <linux/module.h>
11 #include <linux/types.h>
12 #include <linux/string.h>
13 #include <linux/kernel.h>
14 #include <linux/reboot.h>
15 #include <linux/platform_device.h>
16 #include <linux/leds.h>
17 #include <linux/etherdevice.h>
18 #include <linux/reboot.h>
19 #include <linux/time.h>
20 #include <linux/io.h>
21 #include <linux/gpio.h>
22 #include <linux/leds.h>
23
24 #include <asm/bootinfo.h>
25 #include <asm/irq.h>
26
27 #include <lantiq_soc.h>
28
29 #include "devices.h"
30
31 /* nor flash */
32 static struct resource ltq_nor_resource = {
33         .name   = "nor",
34         .start  = LTQ_FLASH_START,
35         .end    = LTQ_FLASH_START + LTQ_FLASH_MAX - 1,
36         .flags  = IORESOURCE_MEM,
37 };
38
39 static struct platform_device ltq_nor = {
40         .name           = "ltq_nor",
41         .resource       = &ltq_nor_resource,
42         .num_resources  = 1,
43 };
44
45 void __init ltq_register_nor(struct physmap_flash_data *data)
46 {
47         ltq_nor.dev.platform_data = data;
48         platform_device_register(&ltq_nor);
49 }
50
51 /* watchdog */
52 static struct resource ltq_wdt_resource = {
53         .name   = "watchdog",
54         .start  = LTQ_WDT_BASE_ADDR,
55         .end    = LTQ_WDT_BASE_ADDR + LTQ_WDT_SIZE - 1,
56         .flags  = IORESOURCE_MEM,
57 };
58
59 void __init ltq_register_wdt(void)
60 {
61         platform_device_register_simple("ltq_wdt", 0, &ltq_wdt_resource, 1);
62 }
63
64 /* asc ports */
65 static struct resource ltq_asc0_resources[] = {
66         {
67                 .name   = "asc0",
68                 .start  = LTQ_ASC0_BASE_ADDR,
69                 .end    = LTQ_ASC0_BASE_ADDR + LTQ_ASC_SIZE - 1,
70                 .flags  = IORESOURCE_MEM,
71         },
72         IRQ_RES(tx, LTQ_ASC_TIR(0)),
73         IRQ_RES(rx, LTQ_ASC_RIR(0)),
74         IRQ_RES(err, LTQ_ASC_EIR(0)),
75 };
76
77 static struct resource ltq_asc1_resources[] = {
78         {
79                 .name   = "asc1",
80                 .start  = LTQ_ASC1_BASE_ADDR,
81                 .end    = LTQ_ASC1_BASE_ADDR + LTQ_ASC_SIZE - 1,
82                 .flags  = IORESOURCE_MEM,
83         },
84         IRQ_RES(tx, LTQ_ASC_TIR(1)),
85         IRQ_RES(rx, LTQ_ASC_RIR(1)),
86         IRQ_RES(err, LTQ_ASC_EIR(1)),
87 };
88
89 void __init ltq_register_asc(int port)
90 {
91         switch (port) {
92         case 0:
93                 platform_device_register_simple("ltq_asc", 0,
94                         ltq_asc0_resources, ARRAY_SIZE(ltq_asc0_resources));
95                 break;
96         case 1:
97                 platform_device_register_simple("ltq_asc", 1,
98                         ltq_asc1_resources, ARRAY_SIZE(ltq_asc1_resources));
99                 break;
100         default:
101                 break;
102         }
103 }
104
105 #ifdef CONFIG_PCI
106 /* pci */
107 static struct platform_device ltq_pci = {
108         .name           = "ltq_pci",
109         .num_resources  = 0,
110 };
111
112 void __init ltq_register_pci(struct ltq_pci_data *data)
113 {
114         ltq_pci.dev.platform_data = data;
115         platform_device_register(&ltq_pci);
116 }
117 #else
118 void __init ltq_register_pci(struct ltq_pci_data *data)
119 {
120         pr_err("kernel is compiled without PCI support\n");
121 }
122 #endif