[adm5120] add support for board specific vlan matrix, should fix #2132
[openwrt.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_set_value(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 gpio_direction_output(ADM5120_GPIO_PIN5, 0);
82
83 /* setup data for flash0 device */
84 adm5120_flash0_data.switch_bank = switch_bank_gpio5;
85
86 /* TODO: setup mac address */
87 }
88
89 static void __init wp54_setup(void)
90 {
91 gpio_request(ADM5120_GPIO_PIN5, NULL); /* for flash A20 line */
92 gpio_direction_output(ADM5120_GPIO_PIN5, 0);
93
94 gpio_request(ADM5120_GPIO_PIN3, NULL); /* for system reset */
95 gpio_direction_output(ADM5120_GPIO_PIN3, 1);
96
97
98 /* setup data for flash0 device */
99 adm5120_flash0_data.switch_bank = switch_bank_gpio5;
100
101 /* TODO: setup mac address */
102 }
103
104 static void __init wp54_wrt_setup(void)
105 {
106 gpio_request(ADM5120_GPIO_PIN5, NULL); /* for flash A20 line */
107 gpio_direction_output(ADM5120_GPIO_PIN5, 0);
108
109 gpio_request(ADM5120_GPIO_PIN3, NULL); /* for system reset */
110 gpio_direction_output(ADM5120_GPIO_PIN3, 1);
111
112 /* setup data for flash0 device */
113 adm5120_flash0_data.switch_bank = switch_bank_gpio5;
114 adm5120_flash0_data.nr_parts = ARRAY_SIZE(wp54g_wrt_partitions);
115 adm5120_flash0_data.parts = wp54g_wrt_partitions;
116
117 /* TODO: setup mac address */
118 }
119
120 unsigned char np27g_vlans[6] __initdata = {
121 /* FIXME: untested */
122 0x41, 0x42, 0x44, 0x48, 0x50, 0x00
123 };
124
125 unsigned char np28g_vlans[6] __initdata = {
126 /* FIXME: untested */
127 0x41, 0x42, 0x44, 0x48, 0x00, 0x00
128 };
129
130 unsigned char wp54_vlans[6] __initdata = {
131 /* FIXME: untested */
132 0x41, 0x42, 0x00, 0x00, 0x00, 0x00
133 };
134
135 static struct adm5120_board np27g_board __initdata = {
136 .mach_type = MACH_ADM5120_NP27G,
137 .name = "Compex NetPassage 27G",
138 .board_setup = np2xg_setup,
139 .eth_num_ports = 5,
140 .eth_vlans = np27g_vlans,
141 .num_devices = ARRAY_SIZE(np2xg_devices),
142 .devices = np2xg_devices,
143 };
144
145 static struct adm5120_board np28g_board __initdata = {
146 .mach_type = MACH_ADM5120_NP28G,
147 .name = "Compex NetPassage 28G",
148 .board_setup = np2xg_setup,
149 .eth_num_ports = 4,
150 .eth_vlans = np28g_vlans,
151 .num_devices = ARRAY_SIZE(np2xg_devices),
152 .devices = np2xg_devices,
153 };
154
155 static struct adm5120_board wp54ag_board __initdata = {
156 .mach_type = MACH_ADM5120_WP54AG,
157 .name = "Compex WP54AG",
158 .board_setup = wp54_setup,
159 .board_reset = wp54_reset,
160 .eth_num_ports = 2,
161 .eth_vlans = wp54_vlans,
162 .num_devices = ARRAY_SIZE(wp54_devices),
163 .devices = wp54_devices,
164 };
165
166 static struct adm5120_board wp54g_board __initdata = {
167 .mach_type = MACH_ADM5120_WP54G,
168 .name = "Compex WP54G",
169 .board_setup = wp54_setup,
170 .board_reset = wp54_reset,
171 .eth_num_ports = 2,
172 .eth_vlans = wp54_vlans,
173 .num_devices = ARRAY_SIZE(wp54_devices),
174 .devices = wp54_devices,
175 };
176
177 static struct adm5120_board wp54g_wrt_board __initdata = {
178 .mach_type = MACH_ADM5120_WP54G,
179 .name = "Compex WP54G-WRT",
180 .board_setup = wp54_wrt_setup,
181 .board_reset = wp54_reset,
182 .eth_num_ports = 2,
183 .eth_vlans = wp54_vlans,
184 .num_devices = ARRAY_SIZE(wp54_devices),
185 .devices = wp54_devices,
186 };
187
188 static struct adm5120_board wpp54ag_board __initdata = {
189 .mach_type = MACH_ADM5120_WPP54AG,
190 .name = "Compex WPP54AG",
191 .board_setup = wp54_setup,
192 .board_reset = wp54_reset,
193 .eth_num_ports = 2,
194 .eth_vlans = wp54_vlans,
195 .num_devices = ARRAY_SIZE(wp54_devices),
196 .devices = wp54_devices,
197 };
198
199 static struct adm5120_board wpp54g_board __initdata = {
200 .mach_type = MACH_ADM5120_WPP54G,
201 .name = "Compex WPP54G",
202 .board_setup = wp54_setup,
203 .board_reset = wp54_reset,
204 .eth_num_ports = 2,
205 .eth_vlans = wp54_vlans,
206 .num_devices = ARRAY_SIZE(wp54_devices),
207 .devices = wp54_devices,
208 };
209
210 static int __init register_boards(void)
211 {
212 adm5120_board_register(&np27g_board);
213 adm5120_board_register(&np28g_board);
214 adm5120_board_register(&wp54ag_board);
215 adm5120_board_register(&wp54g_board);
216 adm5120_board_register(&wp54g_wrt_board);
217 adm5120_board_register(&wpp54ag_board);
218 adm5120_board_register(&wpp54g_board);
219 return 0;
220 }
221
222 pure_initcall(register_boards);
This page took 0.053991 seconds and 5 git commands to generate.