cec57f7e9499ff1c152a615846318683b28d36f1
[openwrt.git] / target / linux / adm5120 / files / arch / mips / adm5120 / boards / mikrotik.c
1 /*
2  *  $Id$
3  *
4  *  Mikrotik RouterBOARDs 1xx series
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 struct adm5120_pci_irq rb1xx_pci_irqs[] __initdata = {
37         PCIIRQ(1, 0, 1, ADM5120_IRQ_PCI0),
38         PCIIRQ(2, 0, 1, ADM5120_IRQ_PCI1),
39         PCIIRQ(3, 0, 1, ADM5120_IRQ_PCI2)
40 };
41
42 static struct mtd_partition rb1xx_partitions[] = {
43         {
44                 .name   = "booter",
45                 .offset = 0,
46                 .size   = 64*1024,
47                 .mask_flags = MTD_WRITEABLE,
48         } , {
49                 .name   = "firmware",
50                 .offset = MTDPART_OFS_APPEND,
51                 .size   = MTDPART_SIZ_FULL,
52         }
53 };
54
55 static struct platform_device *rb1xx_devices[] __initdata = {
56         &adm5120_flash0_device,
57         &adm5120_nand_device,
58 };
59
60 static struct platform_device *rb150_devices[] __initdata = {
61         &adm5120_flash0_device,
62         /* TODO: nand device is not yet supported */
63 };
64
65 static void __init rb1xx_setup(void)
66 {
67         /* setup data for flash0 device */
68         adm5120_flash0_data.nr_parts = ARRAY_SIZE(rb1xx_partitions);
69         adm5120_flash0_data.parts = rb1xx_partitions;
70
71         /* TODO: setup mac address */
72 }
73
74 #if 0
75 /*
76  * RB1xx boards have bad network performance with the default VLAN matrixes.
77  * Disable it while the ethernet driver gets fixed.
78  */
79 static unsigned char rb11x_vlans[6] __initdata = {
80         /* FIXME: untested */
81         0x41, 0x00, 0x00, 0x00, 0x00, 0x00
82 };
83
84 static unsigned char rb133_vlans[6] __initdata = {
85         /* FIXME: untested */
86         0x44, 0x42, 0x41, 0x00, 0x00, 0x00
87 };
88
89 static unsigned char rb133c_vlans[6] __initdata = {
90         /* FIXME: untested */
91         0x44, 0x00, 0x00, 0x00, 0x00, 0x00
92 };
93
94 static unsigned char rb15x_vlans[6] __initdata = {
95         /* FIXME: untested */
96         0x41, 0x42, 0x44, 0x48, 0x50, 0x00
97
98 static unsigned char rb192_vlans[6] __initdata = {
99         /* FIXME: untested */
100         0x41, 0x50, 0x48, 0x44, 0x42, 0x00
101 };
102 #else
103 static unsigned char rb_vlans[6] __initdata = {
104         0x7F, 0x00, 0x00, 0x00, 0x00, 0x00
105 };
106 #define rb11x_vlans     rb_vlans
107 #define rb133_vlans     rb_vlans
108 #define rb133c_vlans    rb_vlans
109 #define rb15x_vlans     rb_vlans
110 #define rb192_vlans     rb_vlans
111 #endif
112
113 static struct adm5120_board rb111_board __initdata = {
114         .mach_type      = MACH_ADM5120_RB_111,
115         .name           = "Mikrotik RouterBOARD 111",
116         .board_setup    = rb1xx_setup,
117         .eth_num_ports  = 1,
118         .eth_vlans      = rb11x_vlans,
119         .num_devices    = ARRAY_SIZE(rb1xx_devices),
120         .devices        = rb1xx_devices,
121         .pci_nr_irqs    = ARRAY_SIZE(rb1xx_pci_irqs),
122         .pci_irq_map    = rb1xx_pci_irqs,
123 };
124
125 static struct adm5120_board rb112_board __initdata = {
126         .mach_type      = MACH_ADM5120_RB_112,
127         .name           = "Mikrotik RouterBOARD 112",
128         .board_setup    = rb1xx_setup,
129         .eth_num_ports  = 1,
130         .eth_vlans      = rb11x_vlans,
131         .num_devices    = ARRAY_SIZE(rb1xx_devices),
132         .devices        = rb1xx_devices,
133         .pci_nr_irqs    = ARRAY_SIZE(rb1xx_pci_irqs),
134         .pci_irq_map    = rb1xx_pci_irqs,
135 };
136
137 static struct adm5120_board rb133_board __initdata = {
138         .mach_type      = MACH_ADM5120_RB_133,
139         .name           = "Mikrotik RouterBOARD 133",
140         .board_setup    = rb1xx_setup,
141         .eth_num_ports  = 3,
142         .eth_vlans      = rb133_vlans,
143         .num_devices    = ARRAY_SIZE(rb1xx_devices),
144         .devices        = rb1xx_devices,
145         .pci_nr_irqs    = ARRAY_SIZE(rb1xx_pci_irqs),
146         .pci_irq_map    = rb1xx_pci_irqs,
147 };
148
149 static struct adm5120_board rb133c_board __initdata = {
150         .mach_type      = MACH_ADM5120_RB_133C,
151         .name           = "Mikrotik RouterBOARD 133C",
152         .board_setup    = rb1xx_setup,
153         .eth_num_ports  = 1,
154         .eth_vlans      = rb133c_vlans,
155         .num_devices    = ARRAY_SIZE(rb1xx_devices),
156         .devices        = rb1xx_devices,
157         .pci_nr_irqs    = ARRAY_SIZE(rb1xx_pci_irqs),
158         .pci_irq_map    = rb1xx_pci_irqs,
159 };
160
161 static struct adm5120_board rb150_board __initdata = {
162         .mach_type      = MACH_ADM5120_RB_150,
163         .name           = "Mikrotik RouterBOARD 150",
164         .board_setup    = rb1xx_setup,
165         .eth_num_ports  = 5,
166         .eth_vlans      = rb15x_vlans,
167         .num_devices    = ARRAY_SIZE(rb150_devices),
168         .devices        = rb150_devices,
169 };
170
171 static struct adm5120_board rb153_board __initdata = {
172         .mach_type      = MACH_ADM5120_RB_153,
173         .name           = "Mikrotik RouterBOARD 153",
174         .board_setup    = rb1xx_setup,
175         .eth_num_ports  = 5,
176         .eth_vlans      = rb15x_vlans,
177         .num_devices    = ARRAY_SIZE(rb1xx_devices),
178         .devices        = rb1xx_devices,
179         .pci_nr_irqs    = ARRAY_SIZE(rb1xx_pci_irqs),
180         .pci_irq_map    = rb1xx_pci_irqs,
181 };
182
183 static struct adm5120_board rb192_board __initdata = {
184         .mach_type      = MACH_ADM5120_RB_192,
185         .name           = "Mikrotik RouterBOARD 192",
186         .board_setup    = rb1xx_setup,
187         .eth_num_ports  = 5,
188         .eth_vlans      = rb192_vlans,
189         .num_devices    = ARRAY_SIZE(rb1xx_devices),
190         .devices        = rb1xx_devices,
191         .pci_nr_irqs    = ARRAY_SIZE(rb1xx_pci_irqs),
192         .pci_irq_map    = rb1xx_pci_irqs,
193 };
194
195 static int __init register_boards(void)
196 {
197         adm5120_board_register(&rb111_board);
198         adm5120_board_register(&rb112_board);
199         adm5120_board_register(&rb133_board);
200         adm5120_board_register(&rb133c_board);
201         adm5120_board_register(&rb150_board);
202         adm5120_board_register(&rb153_board);
203         adm5120_board_register(&rb192_board);
204         return 0;
205 }
206
207 pure_initcall(register_boards);