[adm5120] add missing PCI irq map for the RouterBOARD 133 (closes #2431)
[openwrt/svn-archive/archive.git] / target / linux / adm5120 / 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 at openwrt.org>
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 <adm5120_board.h>
33 #include <adm5120_platform.h>
34 #include <adm5120_irq.h>
35
36 static void switch_bank_gpio5(unsigned bank)
37 {
38 switch (bank) {
39 case 0:
40 gpio_set_value(ADM5120_GPIO_PIN5, 0);
41 break;
42 case 1:
43 gpio_set_value(ADM5120_GPIO_PIN5, 1);
44 break;
45 }
46 }
47
48 static void wp54_reset(void)
49 {
50 gpio_set_value(ADM5120_GPIO_PIN3, 0);
51 }
52
53 static struct adm5120_pci_irq wp54_pci_irqs[] __initdata = {
54 PCIIRQ(2, 0, 1, ADM5120_IRQ_PCI0),
55 };
56
57 static struct adm5120_pci_irq np28g_pci_irqs[] __initdata = {
58 PCIIRQ(2, 0, 1, ADM5120_IRQ_PCI0),
59 PCIIRQ(3, 0, 1, ADM5120_IRQ_PCI0),
60 PCIIRQ(3, 1, 2, ADM5120_IRQ_PCI1),
61 PCIIRQ(3, 2, 3, ADM5120_IRQ_PCI2)
62 };
63
64 static struct mtd_partition wp54g_wrt_partitions[] = {
65 {
66 .name = "cfe",
67 .offset = 0,
68 .size = 0x050000,
69 .mask_flags = MTD_WRITEABLE,
70 } , {
71 .name = "trx",
72 .offset = MTDPART_OFS_APPEND,
73 .size = 0x3A0000,
74 } , {
75 .name = "nvram",
76 .offset = MTDPART_OFS_APPEND,
77 .size = 0x010000,
78 }
79 };
80
81 static struct platform_device *np2xg_devices[] __initdata = {
82 &adm5120_flash0_device,
83 &adm5120_hcd_device,
84 };
85
86 static struct platform_device *wp54_devices[] __initdata = {
87 &adm5120_flash0_device,
88 };
89
90 static void __init np2xg_setup(void)
91 {
92 gpio_request(ADM5120_GPIO_PIN5, NULL); /* for flash A20 line */
93 gpio_direction_output(ADM5120_GPIO_PIN5, 0);
94
95 /* setup data for flash0 device */
96 adm5120_flash0_data.switch_bank = switch_bank_gpio5;
97
98 /* TODO: setup mac address */
99 }
100
101 static void __init wp54_setup(void)
102 {
103 gpio_request(ADM5120_GPIO_PIN5, NULL); /* for flash A20 line */
104 gpio_direction_output(ADM5120_GPIO_PIN5, 0);
105
106 gpio_request(ADM5120_GPIO_PIN3, NULL); /* for system reset */
107 gpio_direction_output(ADM5120_GPIO_PIN3, 1);
108
109
110 /* setup data for flash0 device */
111 adm5120_flash0_data.switch_bank = switch_bank_gpio5;
112
113 /* TODO: setup mac address */
114 }
115
116 static void __init wp54_wrt_setup(void)
117 {
118 gpio_request(ADM5120_GPIO_PIN5, NULL); /* for flash A20 line */
119 gpio_direction_output(ADM5120_GPIO_PIN5, 0);
120
121 gpio_request(ADM5120_GPIO_PIN3, NULL); /* for system reset */
122 gpio_direction_output(ADM5120_GPIO_PIN3, 1);
123
124 /* setup data for flash0 device */
125 adm5120_flash0_data.switch_bank = switch_bank_gpio5;
126 adm5120_flash0_data.nr_parts = ARRAY_SIZE(wp54g_wrt_partitions);
127 adm5120_flash0_data.parts = wp54g_wrt_partitions;
128
129 /* TODO: setup mac address */
130 }
131
132 unsigned char np27g_vlans[6] __initdata = {
133 /* FIXME: untested */
134 0x41, 0x42, 0x44, 0x48, 0x50, 0x00
135 };
136
137 unsigned char np28g_vlans[6] __initdata = {
138 0x50, 0x42, 0x44, 0x48, 0x00, 0x00
139 };
140
141 unsigned char wp54_vlans[6] __initdata = {
142 0x41, 0x42, 0x00, 0x00, 0x00, 0x00
143 };
144
145 static struct adm5120_board np27g_board __initdata = {
146 .mach_type = MACH_ADM5120_NP27G,
147 .name = "Compex NetPassage 27G",
148 .board_setup = np2xg_setup,
149 .eth_num_ports = 5,
150 .eth_vlans = np27g_vlans,
151 .num_devices = ARRAY_SIZE(np2xg_devices),
152 .devices = np2xg_devices,
153 };
154
155 static struct adm5120_board np28g_board __initdata = {
156 .mach_type = MACH_ADM5120_NP28G,
157 .name = "Compex NetPassage 28G",
158 .board_setup = np2xg_setup,
159 .eth_num_ports = 4,
160 .eth_vlans = np28g_vlans,
161 .num_devices = ARRAY_SIZE(np2xg_devices),
162 .devices = np2xg_devices,
163 .pci_nr_irqs = ARRAY_SIZE(np28g_pci_irqs),
164 .pci_irq_map = np28g_pci_irqs,
165 };
166
167 static struct adm5120_board wp54ag_board __initdata = {
168 .mach_type = MACH_ADM5120_WP54AG,
169 .name = "Compex WP54AG",
170 .board_setup = wp54_setup,
171 .board_reset = wp54_reset,
172 .eth_num_ports = 2,
173 .eth_vlans = wp54_vlans,
174 .num_devices = ARRAY_SIZE(wp54_devices),
175 .devices = wp54_devices,
176 .pci_nr_irqs = ARRAY_SIZE(wp54_pci_irqs),
177 .pci_irq_map = wp54_pci_irqs,
178 };
179
180 static struct adm5120_board wp54g_board __initdata = {
181 .mach_type = MACH_ADM5120_WP54G,
182 .name = "Compex WP54G",
183 .board_setup = wp54_setup,
184 .board_reset = wp54_reset,
185 .eth_num_ports = 2,
186 .eth_vlans = wp54_vlans,
187 .num_devices = ARRAY_SIZE(wp54_devices),
188 .devices = wp54_devices,
189 .pci_nr_irqs = ARRAY_SIZE(wp54_pci_irqs),
190 .pci_irq_map = wp54_pci_irqs,
191 };
192
193 static struct adm5120_board wp54g_wrt_board __initdata = {
194 .mach_type = MACH_ADM5120_WP54G,
195 .name = "Compex WP54G-WRT",
196 .board_setup = wp54_wrt_setup,
197 .board_reset = wp54_reset,
198 .eth_num_ports = 2,
199 .eth_vlans = wp54_vlans,
200 .num_devices = ARRAY_SIZE(wp54_devices),
201 .devices = wp54_devices,
202 .pci_nr_irqs = ARRAY_SIZE(wp54_pci_irqs),
203 .pci_irq_map = wp54_pci_irqs,
204 };
205
206 static struct adm5120_board wpp54ag_board __initdata = {
207 .mach_type = MACH_ADM5120_WPP54AG,
208 .name = "Compex WPP54AG",
209 .board_setup = wp54_setup,
210 .board_reset = wp54_reset,
211 .eth_num_ports = 2,
212 .eth_vlans = wp54_vlans,
213 .num_devices = ARRAY_SIZE(wp54_devices),
214 .devices = wp54_devices,
215 .pci_nr_irqs = ARRAY_SIZE(wp54_pci_irqs),
216 .pci_irq_map = wp54_pci_irqs,
217 };
218
219 static struct adm5120_board wpp54g_board __initdata = {
220 .mach_type = MACH_ADM5120_WPP54G,
221 .name = "Compex WPP54G",
222 .board_setup = wp54_setup,
223 .board_reset = wp54_reset,
224 .eth_num_ports = 2,
225 .eth_vlans = wp54_vlans,
226 .num_devices = ARRAY_SIZE(wp54_devices),
227 .devices = wp54_devices,
228 .pci_nr_irqs = ARRAY_SIZE(wp54_pci_irqs),
229 .pci_irq_map = wp54_pci_irqs,
230 };
231
232 static int __init register_boards(void)
233 {
234 adm5120_board_register(&np27g_board);
235 adm5120_board_register(&np28g_board);
236 adm5120_board_register(&wp54ag_board);
237 adm5120_board_register(&wp54g_board);
238 adm5120_board_register(&wp54g_wrt_board);
239 adm5120_board_register(&wpp54ag_board);
240 adm5120_board_register(&wpp54g_board);
241 return 0;
242 }
243
244 pure_initcall(register_boards);