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