6 * Copyright (C) 2007-2008 OpenWrt.org
7 * Copyright (C) 2007-2008 Gabor Juhos <juhosg at openwrt.org>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License version 2 as published
11 * by the Free Software Foundation.
15 #include <linux/kernel.h>
16 #include <linux/init.h>
18 #include <asm/bootinfo.h>
21 #include <adm5120_board.h>
22 #include <adm5120_platform.h>
23 #include <adm5120_irq.h>
25 #define NP27G_GPIO_DEV_MASK (1 << ADM5120_GPIO_PIN5)
26 #define NP28G_GPIO_DEV_MASK ( 1 << ADM5120_GPIO_PIN5 \
27 | 1 << ADM5120_GPIO_PIN4)
29 #define WP54_GPIO_DEV_MASK ( 1 << ADM5120_GPIO_PIN5 \
30 | 1 << ADM5120_GPIO_PIN3)
32 static struct adm5120_pci_irq wp54_pci_irqs[] __initdata = {
33 PCIIRQ(2, 0, 1, ADM5120_IRQ_PCI0),
36 static struct adm5120_pci_irq np28g_pci_irqs[] __initdata = {
37 PCIIRQ(2, 0, 1, ADM5120_IRQ_PCI0),
38 PCIIRQ(3, 0, 1, ADM5120_IRQ_PCI0),
39 PCIIRQ(3, 1, 2, ADM5120_IRQ_PCI1),
40 PCIIRQ(3, 2, 3, ADM5120_IRQ_PCI2)
43 static struct mtd_partition wp54g_wrt_partitions[] = {
48 .mask_flags = MTD_WRITEABLE,
51 .offset = MTDPART_OFS_APPEND,
55 .offset = MTDPART_OFS_APPEND,
60 static struct platform_device *np2xg_devices[] __initdata = {
61 &adm5120_flash0_device,
65 static struct platform_device *wp54_devices[] __initdata = {
66 &adm5120_flash0_device,
67 &adm5120_buttons_device,
70 unsigned char np27g_vlans[6] __initdata = {
72 0x41, 0x42, 0x44, 0x48, 0x50, 0x00
75 unsigned char np28g_vlans[6] __initdata = {
76 0x50, 0x42, 0x44, 0x48, 0x00, 0x00
79 unsigned char wp54_vlans[6] __initdata = {
80 0x41, 0x42, 0x00, 0x00, 0x00, 0x00
83 /*--------------------------------------------------------------------------*/
85 static void switch_bank_gpio5(unsigned bank)
89 gpio_set_value(ADM5120_GPIO_PIN5, 0);
92 gpio_set_value(ADM5120_GPIO_PIN5, 1);
97 static void wp54_reset(void)
99 gpio_set_value(ADM5120_GPIO_PIN3, 0);
102 static void np28g_reset(void)
104 gpio_set_value(ADM5120_GPIO_PIN4, 0);
107 static void __init np27g_setup(void)
109 gpio_request(ADM5120_GPIO_PIN5, NULL); /* for flash A20 line */
110 gpio_direction_output(ADM5120_GPIO_PIN5, 0);
112 /* setup data for flash0 device */
113 adm5120_flash0_data.switch_bank = switch_bank_gpio5;
114 adm5120_gpiodev_resource.start &= ~NP27G_GPIO_DEV_MASK;
116 /* TODO: setup mac address */
119 static void __init np28g_setup(void)
121 gpio_request(ADM5120_GPIO_PIN5, NULL); /* for flash A20 line */
122 gpio_direction_output(ADM5120_GPIO_PIN5, 0);
124 gpio_request(ADM5120_GPIO_PIN4, NULL); /* for system reset */
125 gpio_direction_output(ADM5120_GPIO_PIN4, 1);
127 /* setup data for flash0 device */
128 adm5120_flash0_data.switch_bank = switch_bank_gpio5;
130 adm5120_gpiodev_resource.start &= ~NP28G_GPIO_DEV_MASK;
132 /* TODO: setup mac address */
135 static void __init wp54_setup(void)
137 gpio_request(ADM5120_GPIO_PIN5, NULL); /* for flash A20 line */
138 gpio_direction_output(ADM5120_GPIO_PIN5, 0);
140 gpio_request(ADM5120_GPIO_PIN3, NULL); /* for system reset */
141 gpio_direction_output(ADM5120_GPIO_PIN3, 1);
143 /* setup data for flash0 device */
144 adm5120_flash0_data.switch_bank = switch_bank_gpio5;
146 adm5120_buttons_data.nbuttons = 1;
147 adm5120_buttons[0].desc = "reset button";
148 adm5120_buttons[0].gpio = ADM5120_GPIO_PIN2;
150 adm5120_gpiodev_resource.start &= ~WP54_GPIO_DEV_MASK;
152 /* TODO: setup mac address */
155 static void __init wp54_wrt_setup(void)
159 adm5120_flash0_data.nr_parts = ARRAY_SIZE(wp54g_wrt_partitions);
160 adm5120_flash0_data.parts = wp54g_wrt_partitions;
162 /* TODO: setup mac address */
165 /*--------------------------------------------------------------------------*/
167 ADM5120_BOARD_START(NP27G, "Compex NetPassage 27G")
168 .board_setup = np27g_setup,
170 .eth_vlans = np27g_vlans,
171 .num_devices = ARRAY_SIZE(np2xg_devices),
172 .devices = np2xg_devices,
173 /* TODO: add PCI IRQ map */
176 ADM5120_BOARD_START(NP28G, "Compex NetPassage 28G")
177 .board_setup = np28g_setup,
178 .board_reset = np28g_reset,
180 .eth_vlans = np28g_vlans,
181 .num_devices = ARRAY_SIZE(np2xg_devices),
182 .devices = np2xg_devices,
183 .pci_nr_irqs = ARRAY_SIZE(np28g_pci_irqs),
184 .pci_irq_map = np28g_pci_irqs,
187 ADM5120_BOARD_START(WP54AG, "Compex WP54AG")
188 .board_setup = wp54_setup,
189 .board_reset = wp54_reset,
191 .eth_vlans = wp54_vlans,
192 .num_devices = ARRAY_SIZE(wp54_devices),
193 .devices = wp54_devices,
194 .pci_nr_irqs = ARRAY_SIZE(wp54_pci_irqs),
195 .pci_irq_map = wp54_pci_irqs,
198 ADM5120_BOARD_START(WP54G, "Compex WP54G")
199 .board_setup = wp54_setup,
200 .board_reset = wp54_reset,
202 .eth_vlans = wp54_vlans,
203 .num_devices = ARRAY_SIZE(wp54_devices),
204 .devices = wp54_devices,
205 .pci_nr_irqs = ARRAY_SIZE(wp54_pci_irqs),
206 .pci_irq_map = wp54_pci_irqs,
209 ADM5120_BOARD_START(WP54G_WRT, "Compex WP54G-WRT")
210 .board_setup = wp54_wrt_setup,
211 .board_reset = wp54_reset,
213 .eth_vlans = wp54_vlans,
214 .num_devices = ARRAY_SIZE(wp54_devices),
215 .devices = wp54_devices,
216 .pci_nr_irqs = ARRAY_SIZE(wp54_pci_irqs),
217 .pci_irq_map = wp54_pci_irqs,
220 ADM5120_BOARD_START(WPP54AG, "Compex WPP54AG")
221 .board_setup = wp54_setup,
222 .board_reset = wp54_reset,
224 .eth_vlans = wp54_vlans,
225 .num_devices = ARRAY_SIZE(wp54_devices),
226 .devices = wp54_devices,
227 .pci_nr_irqs = ARRAY_SIZE(wp54_pci_irqs),
228 .pci_irq_map = wp54_pci_irqs,
231 ADM5120_BOARD_START(WPP54G, "Compex WPP54G")
232 .board_setup = wp54_setup,
233 .board_reset = wp54_reset,
235 .eth_vlans = wp54_vlans,
236 .num_devices = ARRAY_SIZE(wp54_devices),
237 .devices = wp54_devices,
238 .pci_nr_irqs = ARRAY_SIZE(wp54_pci_irqs),
239 .pci_irq_map = wp54_pci_irqs,