[adm5120] license cleanup
[openwrt.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 modify it
10  *  under the terms of the GNU General Public License version 2 as published
11  *  by the Free Software Foundation.
12  *
13  */
14
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17
18 #include <asm/bootinfo.h>
19 #include <asm/gpio.h>
20
21 #include <adm5120_board.h>
22 #include <adm5120_platform.h>
23 #include <adm5120_irq.h>
24
25 static struct adm5120_pci_irq wp54_pci_irqs[] __initdata = {
26         PCIIRQ(2, 0, 1, ADM5120_IRQ_PCI0),
27 };
28
29 static struct adm5120_pci_irq np28g_pci_irqs[] __initdata = {
30         PCIIRQ(2, 0, 1, ADM5120_IRQ_PCI0),
31         PCIIRQ(3, 0, 1, ADM5120_IRQ_PCI0),
32         PCIIRQ(3, 1, 2, ADM5120_IRQ_PCI1),
33         PCIIRQ(3, 2, 3, ADM5120_IRQ_PCI2)
34 };
35
36 static struct mtd_partition wp54g_wrt_partitions[] = {
37         {
38                 .name   = "cfe",
39                 .offset = 0,
40                 .size   = 0x050000,
41                 .mask_flags = MTD_WRITEABLE,
42         } , {
43                 .name   = "trx",
44                 .offset = MTDPART_OFS_APPEND,
45                 .size   = 0x3A0000,
46         } , {
47                 .name   = "nvram",
48                 .offset = MTDPART_OFS_APPEND,
49                 .size   = 0x010000,
50         }
51 };
52
53 static struct platform_device *np2xg_devices[] __initdata = {
54         &adm5120_flash0_device,
55         &adm5120_hcd_device,
56 };
57
58 static struct platform_device *wp54_devices[] __initdata = {
59         &adm5120_flash0_device,
60 };
61
62 unsigned char np27g_vlans[6] __initdata = {
63         /* FIXME: untested */
64         0x41, 0x42, 0x44, 0x48, 0x50, 0x00
65 };
66
67 unsigned char np28g_vlans[6] __initdata = {
68         0x50, 0x42, 0x44, 0x48, 0x00, 0x00
69 };
70
71 unsigned char wp54_vlans[6] __initdata = {
72         0x41, 0x42, 0x00, 0x00, 0x00, 0x00
73 };
74
75 /*--------------------------------------------------------------------------*/
76
77 static void switch_bank_gpio5(unsigned bank)
78 {
79         switch (bank) {
80         case 0:
81                 gpio_set_value(ADM5120_GPIO_PIN5, 0);
82                 break;
83         case 1:
84                 gpio_set_value(ADM5120_GPIO_PIN5, 1);
85                 break;
86         }
87 }
88
89 static void wp54_reset(void)
90 {
91         gpio_set_value(ADM5120_GPIO_PIN3, 0);
92 }
93
94 static void np28g_reset(void)
95 {
96         gpio_set_value(ADM5120_GPIO_PIN4, 0);
97 }
98
99 static void __init np27g_setup(void)
100 {
101         gpio_request(ADM5120_GPIO_PIN5, NULL); /* for flash A20 line */
102         gpio_direction_output(ADM5120_GPIO_PIN5, 0);
103
104         /* setup data for flash0 device */
105         adm5120_flash0_data.switch_bank = switch_bank_gpio5;
106
107         /* TODO: setup mac address */
108 }
109
110 static void __init np28g_setup(void)
111 {
112         gpio_request(ADM5120_GPIO_PIN5, NULL); /* for flash A20 line */
113         gpio_direction_output(ADM5120_GPIO_PIN5, 0);
114
115         gpio_request(ADM5120_GPIO_PIN4, NULL); /* for system reset */
116         gpio_direction_output(ADM5120_GPIO_PIN4, 1);
117
118         /* setup data for flash0 device */
119         adm5120_flash0_data.switch_bank = switch_bank_gpio5;
120
121         /* TODO: setup mac address */
122 }
123
124 static void __init wp54_setup(void)
125 {
126         gpio_request(ADM5120_GPIO_PIN5, NULL); /* for flash A20 line */
127         gpio_direction_output(ADM5120_GPIO_PIN5, 0);
128
129         gpio_request(ADM5120_GPIO_PIN3, NULL); /* for system reset */
130         gpio_direction_output(ADM5120_GPIO_PIN3, 1);
131
132         /* setup data for flash0 device */
133         adm5120_flash0_data.switch_bank = switch_bank_gpio5;
134
135         /* TODO: setup mac address */
136 }
137
138 static void __init wp54_wrt_setup(void)
139 {
140         gpio_request(ADM5120_GPIO_PIN5, NULL); /* for flash A20 line */
141         gpio_direction_output(ADM5120_GPIO_PIN5, 0);
142
143         gpio_request(ADM5120_GPIO_PIN3, NULL); /* for system reset */
144         gpio_direction_output(ADM5120_GPIO_PIN3, 1);
145
146         /* setup data for flash0 device */
147         adm5120_flash0_data.switch_bank = switch_bank_gpio5;
148         adm5120_flash0_data.nr_parts = ARRAY_SIZE(wp54g_wrt_partitions);
149         adm5120_flash0_data.parts = wp54g_wrt_partitions;
150
151         /* TODO: setup mac address */
152 }
153
154 /*--------------------------------------------------------------------------*/
155
156 ADM5120_BOARD_START(NP27G, "Compex NetPassage 27G")
157         .board_setup    = np27g_setup,
158         .eth_num_ports  = 5,
159         .eth_vlans      = np27g_vlans,
160         .num_devices    = ARRAY_SIZE(np2xg_devices),
161         .devices        = np2xg_devices,
162         /* TODO: add PCI IRQ map */
163 ADM5120_BOARD_END
164
165 ADM5120_BOARD_START(NP28G, "Compex NetPassage 28G")
166         .board_setup    = np28g_setup,
167         .board_reset    = np28g_reset,
168         .eth_num_ports  = 4,
169         .eth_vlans      = np28g_vlans,
170         .num_devices    = ARRAY_SIZE(np2xg_devices),
171         .devices        = np2xg_devices,
172         .pci_nr_irqs    = ARRAY_SIZE(np28g_pci_irqs),
173         .pci_irq_map    = np28g_pci_irqs,
174 ADM5120_BOARD_END
175
176 ADM5120_BOARD_START(WP54AG, "Compex WP54AG")
177         .board_setup    = wp54_setup,
178         .board_reset    = wp54_reset,
179         .eth_num_ports  = 2,
180         .eth_vlans      = wp54_vlans,
181         .num_devices    = ARRAY_SIZE(wp54_devices),
182         .devices        = wp54_devices,
183         .pci_nr_irqs    = ARRAY_SIZE(wp54_pci_irqs),
184         .pci_irq_map    = wp54_pci_irqs,
185 ADM5120_BOARD_END
186
187 ADM5120_BOARD_START(WP54G, "Compex WP54G")
188         .board_setup    = wp54_setup,
189         .board_reset    = wp54_reset,
190         .eth_num_ports  = 2,
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,
196 ADM5120_BOARD_END
197
198 ADM5120_BOARD_START(WP54G_WRT, "Compex WP54G-WRT")
199         .board_setup    = wp54_wrt_setup,
200         .board_reset    = wp54_reset,
201         .eth_num_ports  = 2,
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,
207 ADM5120_BOARD_END
208
209 ADM5120_BOARD_START(WPP54AG, "Compex WPP54AG")
210         .board_setup    = wp54_setup,
211         .board_reset    = wp54_reset,
212         .eth_num_ports  = 2,
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,
218 ADM5120_BOARD_END
219
220 ADM5120_BOARD_START(WPP54G, "Compex WPP54G")
221         .board_setup    = wp54_setup,
222         .board_reset    = wp54_reset,
223         .eth_num_ports  = 2,
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,
229 ADM5120_BOARD_END