lots of ifxmips cleanups
[openwrt/staging/yousong.git] / target / linux / ifxmips / files / arch / mips / ifxmips / board.c
1 /*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
15 *
16 * Copyright (C) 2007 John Crispin <blogic@openwrt.org>
17 */
18
19 #include <linux/autoconf.h>
20 #include <linux/init.h>
21 #include <linux/module.h>
22 #include <linux/types.h>
23 #include <linux/string.h>
24 #include <linux/mtd/physmap.h>
25 #include <linux/kernel.h>
26 #include <linux/reboot.h>
27 #include <linux/platform_device.h>
28 #include <asm/bootinfo.h>
29 #include <asm/reboot.h>
30 #include <asm/time.h>
31 #include <asm/irq.h>
32 #include <asm/io.h>
33 #include <asm/ifxmips/ifxmips.h>
34
35 #define MAX_IFXMIPS_DEVS 9
36
37 #define BOARD_DANUBE "Danube"
38 #define BOARD_DANUBE_CHIPID 0x10129083
39
40 #define BOARD_TWINPASS "Twinpass"
41 #define BOARD_TWINPASS_CHIPID 0x3012D083
42
43 static unsigned int chiprev;
44 static struct platform_device *ifxmips_devs[MAX_IFXMIPS_DEVS];
45
46 static struct platform_device
47 ifxmips_led[] =
48 {
49 {
50 .id = 0,
51 .name = "ifxmips_led",
52 },
53 };
54
55 static struct platform_device
56 ifxmips_gpio[] =
57 {
58 {
59 .id = 0,
60 .name = "ifxmips_gpio",
61 },
62 };
63
64 static struct platform_device
65 ifxmips_mii[] =
66 {
67 {
68 .id = 0,
69 .name = "ifxmips_mii0",
70 },
71 };
72
73 static struct platform_device
74 ifxmips_wdt[] =
75 {
76 {
77 .id = 0,
78 .name = "ifxmips_wdt",
79 },
80 };
81
82 static struct platform_device
83 ifxmips_asc0[] =
84 {
85 {
86 .id = 0,
87 .name = "ifxmips_asc",
88 },
89 };
90
91 static struct platform_device
92 ifxmips_asc1[] =
93 {
94 {
95 .id = 1,
96 .name = "ifxmips_asc",
97 },
98 };
99
100 static struct physmap_flash_data
101 ifxmips_mtd_data = {
102 .width = 2,
103 };
104
105 static struct resource
106 ifxmips_mtd_resource = {
107 .start = IFXMIPS_FLASH_START,
108 .end = IFXMIPS_FLASH_START + IFXMIPS_FLASH_MAX - 1,
109 .flags = IORESOURCE_MEM,
110 };
111
112 static struct platform_device
113 ifxmips_mtd[] =
114 {
115 {
116 .id = 0,
117 .name = "ifxmips_mtd",
118 .dev = {
119 .platform_data = &ifxmips_mtd_data,
120 },
121 .num_resources = 1,
122 .resource = &ifxmips_mtd_resource,
123 },
124 };
125
126 #ifdef CONFIG_GPIO_DEVICE
127 static struct resource
128 ifxmips_gpio_dev_resources[] = {
129 {
130 .name = "gpio",
131 .flags = 0,
132 .start = (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) |
133 (1 << 4) | (1 << 5) | (1 << 8) | (1 << 9) | (1 << 12),
134 .end = (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) |
135 (1 << 4) | (1 << 5) | (1 << 8) | (1 << 9) | (1 << 12),
136 },
137 };
138
139 static struct platform_device
140 ifxmips_gpio_dev[] = {
141 {
142 .name = "GPIODEV",
143 .id = -1,
144 .num_resources = ARRAY_SIZE(ifxmips_gpio_dev_resources),
145 .resource = ifxmips_gpio_dev_resources,
146 }
147 };
148 #endif
149
150 const char*
151 get_system_type(void)
152 {
153 chiprev = ifxmips_r32(IFXMIPS_MPS_CHIPID);
154 switch(chiprev)
155 {
156 case BOARD_DANUBE_CHIPID:
157 return BOARD_DANUBE;
158
159 case BOARD_TWINPASS_CHIPID:
160 return BOARD_TWINPASS;
161 }
162
163 return BOARD_SYSTEM_TYPE;
164 }
165
166 int __init
167 ifxmips_init_devices(void)
168 {
169 int dev = 0;
170
171 ifxmips_devs[dev++] = ifxmips_led;
172 ifxmips_devs[dev++] = ifxmips_gpio;
173 ifxmips_devs[dev++] = ifxmips_mii;
174 ifxmips_devs[dev++] = ifxmips_mtd;
175 ifxmips_devs[dev++] = ifxmips_wdt;
176 //ifxmips_devs[dev++] = ifxmips_asc0;
177 ifxmips_devs[dev++] = ifxmips_asc1;
178 #ifdef CONFIG_GPIO_DEVICE
179 ifxmips_devs[dev++] = ifxmips_gpio_dev;
180 #endif
181 return platform_add_devices(ifxmips_devs, dev);
182 }
183
184 arch_initcall(ifxmips_init_devices);