refactor kernel code (part 1), mark it as broken now
[openwrt/openwrt.git] / target / linux / adm5120-2.6 / files / arch / mips / adm5120 / boards / cellvision.c
1 /*
2 * $Id$
3 *
4 * Cellvision/SparkLAN 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 struct mtd_partition cas6xx_partitions[] = {
48 {
49 .name = "admboot",
50 .offset = 0,
51 .size = 32*1024,
52 .mask_flags = MTD_WRITEABLE,
53 } , {
54 .name = "config",
55 .offset = MTDPART_OFS_APPEND,
56 .size = 32*1024,
57 } , {
58 .name = "nvfs1",
59 .offset = MTDPART_OFS_APPEND,
60 .size = 64*1024,
61 } , {
62 .name = "nvfs2",
63 .offset = MTDPART_OFS_APPEND,
64 .size = 64*1024,
65 } , {
66 .name = "firmware",
67 .offset = MTDPART_OFS_APPEND,
68 .size = MTDPART_SIZ_FULL,
69 }
70 };
71
72 static struct mtd_partition cas7xx_partitions[] = {
73 {
74 .name = "admboot",
75 .offset = 0,
76 .size = 32*1024,
77 .mask_flags = MTD_WRITEABLE,
78 } , {
79 .name = "config",
80 .offset = MTDPART_OFS_APPEND,
81 .size = 32*1024,
82 } , {
83 .name = "nvfs",
84 .offset = MTDPART_OFS_APPEND,
85 .size = 128*1024,
86 } , {
87 .name = "firmware",
88 .offset = MTDPART_OFS_APPEND,
89 .size = MTDPART_SIZ_FULL,
90 }
91 };
92
93 static struct platform_device *cas6xx_devices[] __initdata = {
94 &adm5120_flash0_device,
95 };
96
97 static struct platform_device *cas7xx_devices[] __initdata = {
98 &adm5120_flash0_device,
99 };
100
101 static void __init cas6xx_setup(void)
102 {
103 gpio_request(ADM5120_GPIO_PIN5, NULL); /* for flash A20 line */
104
105 /* setup data for flash0 device */
106 adm5120_flash0_data.switch_bank = switch_bank_gpio5;
107 adm5120_flash0_data.nr_parts = ARRAY_SIZE(cas6xx_partitions);
108 adm5120_flash0_data.parts = cas6xx_partitions;
109
110 /* TODO: setup mac address */
111 }
112
113 static void __init cas7xx_setup(void)
114 {
115 gpio_request(ADM5120_GPIO_PIN5, NULL); /* for flash A20 line */
116
117 /* setup data for flash0 device */
118 adm5120_flash0_data.switch_bank = switch_bank_gpio5;
119 adm5120_flash0_data.nr_parts = ARRAY_SIZE(cas7xx_partitions);
120 adm5120_flash0_data.parts = cas7xx_partitions;
121
122 /* TODO: setup mac address */
123 }
124
125 static struct adm5120_board cas630_board __initdata = {
126 .mach_type = MACH_ADM5120_CAS630,
127 .name = "Cellvision CAS-630/630W",
128 .board_setup = cas6xx_setup,
129 .num_eth_ports = 1,
130 .num_devices = ARRAY_SIZE(cas6xx_devices),
131 .devices = cas6xx_devices,
132 };
133
134 static struct adm5120_board cas670_board __initdata = {
135 .mach_type = MACH_ADM5120_CAS670,
136 .name = "Cellvision CAS-670/670W",
137 .board_setup = cas6xx_setup,
138 .num_eth_ports = 1,
139 .num_devices = ARRAY_SIZE(cas6xx_devices),
140 .devices = cas6xx_devices,
141 };
142
143 static struct adm5120_board cas700_board __initdata = {
144 .mach_type = MACH_ADM5120_CAS700,
145 .name = "Cellvision CAS-700/700W",
146 .board_setup = cas7xx_setup,
147 .num_eth_ports = 1,
148 .num_devices = ARRAY_SIZE(cas7xx_devices),
149 .devices = cas7xx_devices,
150 };
151
152 static struct adm5120_board cas771_board __initdata = {
153 .mach_type = MACH_ADM5120_CAS771,
154 .name = "Cellvision CAS-771/771W",
155 .board_setup = cas7xx_setup,
156 .num_eth_ports = 1,
157 .num_devices = ARRAY_SIZE(cas7xx_devices),
158 .devices = cas7xx_devices,
159 };
160
161 static struct adm5120_board cas790_board __initdata = {
162 .mach_type = MACH_ADM5120_CAS790,
163 .name = "Cellvision CAS-790",
164 .board_setup = cas7xx_setup,
165 .num_eth_ports = 1,
166 .num_devices = ARRAY_SIZE(cas7xx_devices),
167 .devices = cas7xx_devices,
168 };
169
170 static struct adm5120_board cas861_board __initdata = {
171 .mach_type = MACH_ADM5120_CAS861,
172 .name = "Cellvision CAS-861/861W",
173 .board_setup = cas7xx_setup,
174 .num_eth_ports = 1,
175 .num_devices = ARRAY_SIZE(cas7xx_devices),
176 .devices = cas7xx_devices,
177 };
178
179 static int __init register_boards(void)
180 {
181 adm5120_board_register(&cas630_board);
182 adm5120_board_register(&cas670_board);
183 adm5120_board_register(&cas700_board);
184 adm5120_board_register(&cas771_board);
185 adm5120_board_register(&cas790_board);
186 adm5120_board_register(&cas861_board);
187 return 0;
188 }
189
190 pure_initcall(register_boards);