3e68fa52abdb885bceb9ae812b048b57f15d230b
[librecmc/librecmc.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 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 void switch_bank_gpio5(unsigned bank)
26 {
27         switch (bank) {
28         case 0:
29                 gpio_set_value(ADM5120_GPIO_PIN5, 0);
30                 break;
31         case 1:
32                 gpio_set_value(ADM5120_GPIO_PIN5, 1);
33                 break;
34         }
35 }
36
37 static struct adm5120_pci_irq cas771_pci_irqs[] __initdata = {
38         PCIIRQ(2, 0, 1, ADM5120_IRQ_PCI0),
39         PCIIRQ(3, 0, 1, ADM5120_IRQ_PCI1),
40         PCIIRQ(3, 2, 3, ADM5120_IRQ_PCI2)
41 };
42
43 static struct mtd_partition cas6xx_partitions[] = {
44         {
45                 .name   = "admboot",
46                 .offset = 0,
47                 .size   = 32*1024,
48                 .mask_flags = MTD_WRITEABLE,
49         } , {
50                 .name   = "config",
51                 .offset = MTDPART_OFS_APPEND,
52                 .size   = 32*1024,
53         } , {
54                 .name   = "nvfs1",
55                 .offset = MTDPART_OFS_APPEND,
56                 .size   = 64*1024,
57         } , {
58                 .name   = "nvfs2",
59                 .offset = MTDPART_OFS_APPEND,
60                 .size   = 64*1024,
61         } , {
62                 .name   = "firmware",
63                 .offset = MTDPART_OFS_APPEND,
64                 .size   = MTDPART_SIZ_FULL,
65         }
66 };
67
68 static struct mtd_partition cas7xx_partitions[] = {
69         {
70                 .name   = "admboot",
71                 .offset = 0,
72                 .size   = 32*1024,
73                 .mask_flags = MTD_WRITEABLE,
74         } , {
75                 .name   = "config",
76                 .offset = MTDPART_OFS_APPEND,
77                 .size   = 32*1024,
78         } , {
79                 .name   = "nvfs",
80                 .offset = MTDPART_OFS_APPEND,
81                 .size   = 128*1024,
82         } , {
83                 .name   = "firmware",
84                 .offset = MTDPART_OFS_APPEND,
85                 .size   = MTDPART_SIZ_FULL,
86         }
87 };
88
89 static struct platform_device *cas6xx_devices[] __initdata = {
90         &adm5120_flash0_device,
91 };
92
93 static struct platform_device *cas7xx_devices[] __initdata = {
94         &adm5120_flash0_device,
95 };
96
97 static void __init cas6xx_setup(void)
98 {
99         gpio_request(ADM5120_GPIO_PIN5, NULL);  /* for flash A20 line */
100         gpio_direction_output(ADM5120_GPIO_PIN5, 0);
101
102         /* setup data for flash0 device */
103         adm5120_flash0_data.switch_bank = switch_bank_gpio5;
104         adm5120_flash0_data.nr_parts = ARRAY_SIZE(cas6xx_partitions);
105         adm5120_flash0_data.parts = cas6xx_partitions;
106
107         /* TODO: setup mac address */
108 }
109
110 static void __init cas7xx_setup(void)
111 {
112         gpio_request(ADM5120_GPIO_PIN5, NULL);  /* for flash A20 line */
113         gpio_direction_output(ADM5120_GPIO_PIN5, 0);
114
115         /* setup data for flash0 device */
116         adm5120_flash0_data.switch_bank = switch_bank_gpio5;
117         adm5120_flash0_data.nr_parts = ARRAY_SIZE(cas7xx_partitions);
118         adm5120_flash0_data.parts = cas7xx_partitions;
119
120         /* TODO: setup mac address */
121 }
122
123 static void __init nfs_setup(void)
124 {
125         gpio_request(ADM5120_GPIO_PIN5, NULL);  /* for flash A20 line */
126         gpio_direction_output(ADM5120_GPIO_PIN5, 0);
127
128         /* setup data for flash0 device */
129         adm5120_flash0_data.switch_bank = switch_bank_gpio5;
130         adm5120_flash0_data.nr_parts = ARRAY_SIZE(cas6xx_partitions);
131         adm5120_flash0_data.parts = cas6xx_partitions;
132
133         /* TODO: setup mac address */
134 }
135
136 unsigned char nfs_vlans[6] = { /* TODO: not tested */
137         0x41, 0x42, 0x44, 0x48, 0x50, 0x00
138 };
139
140 /*--------------------------------------------------------------------------*/
141
142 ADM5120_BOARD_START(CAS630, "Cellvision CAS-630/630W")
143         .board_setup    = cas6xx_setup,
144         .eth_num_ports  = 1,
145         .num_devices    = ARRAY_SIZE(cas6xx_devices),
146         .devices        = cas6xx_devices,
147         /* TODO: PCI IRQ map */
148 ADM5120_BOARD_END
149
150 ADM5120_BOARD_START(CAS670, "Cellvision CAS-670/670W")
151         .board_setup    = cas6xx_setup,
152         .eth_num_ports  = 1,
153         .num_devices    = ARRAY_SIZE(cas6xx_devices),
154         .devices        = cas6xx_devices,
155         /* TODO: PCI IRQ map */
156 ADM5120_BOARD_END
157
158 ADM5120_BOARD_START(CAS700, "Cellvision CAS-700/700W")
159         .board_setup    = cas7xx_setup,
160         .eth_num_ports  = 1,
161         .num_devices    = ARRAY_SIZE(cas7xx_devices),
162         .devices        = cas7xx_devices,
163         /* TODO: PCI IRQ map */
164 ADM5120_BOARD_END
165
166 ADM5120_BOARD_START(CAS771, "Cellvision CAS-771/771W")
167         .board_setup    = cas7xx_setup,
168         .eth_num_ports  = 1,
169         .num_devices    = ARRAY_SIZE(cas7xx_devices),
170         .devices        = cas7xx_devices,
171         .pci_nr_irqs    = ARRAY_SIZE(cas771_pci_irqs),
172         .pci_irq_map    = cas771_pci_irqs,
173 ADM5120_BOARD_END
174
175 ADM5120_BOARD_START(CAS790, "Cellvision CAS-790")
176         .board_setup    = cas7xx_setup,
177         .eth_num_ports  = 1,
178         .num_devices    = ARRAY_SIZE(cas7xx_devices),
179         .devices        = cas7xx_devices,
180         /* TODO: PCI IRQ map */
181 ADM5120_BOARD_END
182
183 ADM5120_BOARD_START(CAS861, "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         /* TODO: PCI IRQ map */
189 ADM5120_BOARD_END
190
191 ADM5120_BOARD_START(NFS101U, "Cellvision NFS-101U/101WU")
192         .board_setup    = nfs_setup,
193         .eth_num_ports  = 5,
194         .eth_vlans      = nfs_vlans,
195         .num_devices    = ARRAY_SIZE(cas6xx_devices),
196         .devices        = cas6xx_devices,
197         /* TODO: PCI IRQ map */
198 ADM5120_BOARD_END