bbc5106e20ee0f70aa55d10ffc6296fccc0110a1
[openwrt/staging/florian.git] / target / linux / adm5120-2.6 / files / arch / mips / adm5120 / boards / compex.c
1 /*
2 * $Id$
3 *
4 * Compex boards
5 *
6 * Copyright (C) 2007 OpenWrt.org
7 * Copyright (C) 2007 Gabor Juhos <juhosg@freemail.hu>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the
21 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301, USA.
23 *
24 */
25
26 #include <linux/kernel.h>
27 #include <linux/init.h>
28
29 #include <asm/bootinfo.h>
30 #include <asm/gpio.h>
31
32 #include <asm/mach-adm5120/adm5120_board.h>
33 #include <asm/mach-adm5120/adm5120_platform.h>
34
35 static void switch_bank_gpio5(unsigned bank)
36 {
37 switch (bank) {
38 case 0:
39 gpio_set_value(ADM5120_GPIO_PIN5, 0);
40 break;
41 case 1:
42 gpio_set_value(ADM5120_GPIO_PIN5, 1);
43 break;
44 }
45 }
46
47 static void wp54_reset(void)
48 {
49 gpio_direction_output(ADM5120_GPIO_PIN3, 0);
50 }
51
52 static struct mtd_partition wp54g_wrt_partitions[] = {
53 {
54 .name = "cfe",
55 .offset = 0,
56 .size = 0x050000,
57 .mask_flags = MTD_WRITEABLE,
58 } , {
59 .name = "trx",
60 .offset = MTDPART_OFS_APPEND,
61 .size = 0x3A0000,
62 } , {
63 .name = "nvram",
64 .offset = MTDPART_OFS_APPEND,
65 .size = 0x010000,
66 }
67 };
68
69 static struct platform_device *np2xg_devices[] __initdata = {
70 &adm5120_flash0_device,
71 &adm5120_usbc_device,
72 };
73
74 static struct platform_device *wp54_devices[] __initdata = {
75 &adm5120_flash0_device,
76 };
77
78 static void __init np2xg_setup(void)
79 {
80 gpio_request(ADM5120_GPIO_PIN5, NULL); /* for flash A20 line */
81
82 /* setup data for flash0 device */
83 adm5120_flash0_data.switch_bank = switch_bank_gpio5;
84
85 /* TODO: setup mac address */
86 }
87
88 static void __init wp54_setup(void)
89 {
90 gpio_request(ADM5120_GPIO_PIN5, NULL); /* for flash A20 line */
91 gpio_request(ADM5120_GPIO_PIN3, NULL); /* for system reset */
92
93 /* setup data for flash0 device */
94 adm5120_flash0_data.switch_bank = switch_bank_gpio5;
95
96 /* TODO: setup mac address */
97 }
98
99 static void __init wp54_wrt_setup(void)
100 {
101 gpio_request(ADM5120_GPIO_PIN5, NULL); /* for flash A20 line */
102 gpio_request(ADM5120_GPIO_PIN3, NULL); /* for system reset */
103
104 /* setup data for flash0 device */
105 adm5120_flash0_data.switch_bank = switch_bank_gpio5;
106 adm5120_flash0_data.nr_parts = ARRAY_SIZE(wp54g_wrt_partitions);
107 adm5120_flash0_data.parts = wp54g_wrt_partitions;
108
109 /* TODO: setup mac address */
110 }
111
112 static struct adm5120_board np27g_board __initdata = {
113 .mach_type = MACH_ADM5120_NP27G,
114 .name = "Compex NetPassage 27G",
115 .board_setup = np2xg_setup,
116 .num_eth_ports = 4,
117 .num_devices = ARRAY_SIZE(np2xg_devices),
118 .devices = np2xg_devices,
119 };
120
121 static struct adm5120_board np28g_board __initdata = {
122 .mach_type = MACH_ADM5120_NP28G,
123 .name = "Compex NetPassage 28G",
124 .board_setup = np2xg_setup,
125 .num_eth_ports = 3,
126 .num_devices = ARRAY_SIZE(np2xg_devices),
127 .devices = np2xg_devices,
128 };
129
130 static struct adm5120_board wp54ag_board __initdata = {
131 .mach_type = MACH_ADM5120_WP54AG,
132 .name = "Compex WP54AG",
133 .board_setup = wp54_setup,
134 .board_reset = wp54_reset,
135 .num_eth_ports = 2,
136 .num_devices = ARRAY_SIZE(wp54_devices),
137 .devices = wp54_devices,
138 };
139
140 static struct adm5120_board wp54g_board __initdata = {
141 .mach_type = MACH_ADM5120_WP54G,
142 .name = "Compex WP54G",
143 .board_setup = wp54_setup,
144 .board_reset = wp54_reset,
145 .num_eth_ports = 2,
146 .num_devices = ARRAY_SIZE(wp54_devices),
147 .devices = wp54_devices,
148 };
149
150 static struct adm5120_board wp54g_wrt_board __initdata = {
151 .mach_type = MACH_ADM5120_WP54G,
152 .name = "Compex WP54G-WRT",
153 .board_setup = wp54_wrt_setup,
154 .board_reset = wp54_reset,
155 .num_eth_ports = 2,
156 .num_devices = ARRAY_SIZE(wp54_devices),
157 .devices = wp54_devices,
158 };
159
160 static struct adm5120_board wpp54ag_board __initdata = {
161 .mach_type = MACH_ADM5120_WPP54AG,
162 .name = "Compex WPP54AG",
163 .board_setup = wp54_setup,
164 .board_reset = wp54_reset,
165 .num_eth_ports = 2,
166 .num_devices = ARRAY_SIZE(wp54_devices),
167 .devices = wp54_devices,
168 };
169
170 static struct adm5120_board wpp54g_board __initdata = {
171 .mach_type = MACH_ADM5120_WPP54G,
172 .name = "Compex WPP54G",
173 .board_setup = wp54_setup,
174 .board_reset = wp54_reset,
175 .num_eth_ports = 2,
176 .num_devices = ARRAY_SIZE(wp54_devices),
177 .devices = wp54_devices,
178 };
179
180 static int __init register_boards(void)
181 {
182 adm5120_board_register(&np27g_board);
183 adm5120_board_register(&np28g_board);
184 adm5120_board_register(&wp54ag_board);
185 adm5120_board_register(&wp54g_board);
186 adm5120_board_register(&wp54g_wrt_board);
187 adm5120_board_register(&wpp54ag_board);
188 adm5120_board_register(&wpp54g_board);
189 return 0;
190 }
191
192 pure_initcall(register_boards);