f58a8fef46abd78f01825d56665f9b5a419fc401
[openwrt/svn-archive/archive.git] / target / linux / adm5120 / files-2.6.26 / arch / mips / adm5120 / cellvision / cellvision.c
1 /*
2 * Cellvision/SparkLAN boards
3 *
4 * Copyright (C) 2007-2008 Gabor Juhos <juhosg@openwrt.org>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation.
9 *
10 */
11
12 #include <linux/kernel.h>
13 #include <linux/init.h>
14 #include <linux/gpio.h>
15
16 #include <asm/bootinfo.h>
17
18 #include <asm/mach-adm5120/adm5120_info.h>
19 #include <asm/mach-adm5120/adm5120_board.h>
20 #include <asm/mach-adm5120/adm5120_platform.h>
21 #include <asm/mach-adm5120/adm5120_irq.h>
22
23 #define CELLVISION_GPIO_FLASH_A20 ADM5120_GPIO_PIN5
24 #define CELLVISION_GPIO_DEV_MASK (1 << CELLVISION_GPIO_FLASH_A20)
25
26 #ifdef CONFIG_MTD_PARTITIONS
27 static struct mtd_partition cas6xx_partitions[] = {
28 {
29 .name = "admboot",
30 .offset = 0,
31 .size = 32*1024,
32 .mask_flags = MTD_WRITEABLE,
33 } , {
34 .name = "config",
35 .offset = MTDPART_OFS_APPEND,
36 .size = 32*1024,
37 } , {
38 .name = "nvfs1",
39 .offset = MTDPART_OFS_APPEND,
40 .size = 64*1024,
41 } , {
42 .name = "nvfs2",
43 .offset = MTDPART_OFS_APPEND,
44 .size = 64*1024,
45 } , {
46 .name = "firmware",
47 .offset = MTDPART_OFS_APPEND,
48 .size = MTDPART_SIZ_FULL,
49 }
50 };
51
52 static struct mtd_partition cas7xx_partitions[] = {
53 {
54 .name = "admboot",
55 .offset = 0,
56 .size = 32*1024,
57 .mask_flags = MTD_WRITEABLE,
58 } , {
59 .name = "config",
60 .offset = MTDPART_OFS_APPEND,
61 .size = 32*1024,
62 } , {
63 .name = "nvfs",
64 .offset = MTDPART_OFS_APPEND,
65 .size = 128*1024,
66 } , {
67 .name = "firmware",
68 .offset = MTDPART_OFS_APPEND,
69 .size = MTDPART_SIZ_FULL,
70 }
71 };
72 #endif /* CONFIG_MTD_PARTITIONS */
73
74 static struct adm5120_pci_irq cas771_pci_irqs[] __initdata = {
75 PCIIRQ(2, 0, 1, ADM5120_IRQ_PCI0),
76 PCIIRQ(3, 0, 1, ADM5120_IRQ_PCI1),
77 PCIIRQ(3, 2, 3, ADM5120_IRQ_PCI2)
78 };
79
80 static struct gpio_led cas771_gpio_leds[] __initdata = {
81 GPIO_LED_STD(ADM5120_GPIO_PIN0, "cam_flash", NULL),
82 /* GPIO PIN3 is the reset */
83 GPIO_LED_STD(ADM5120_GPIO_PIN6, "access", NULL),
84 GPIO_LED_STD(ADM5120_GPIO_P0L1, "status", NULL),
85 GPIO_LED_STD(ADM5120_GPIO_P0L2, "diag", NULL),
86 };
87
88 static void switch_bank_gpio5(unsigned bank)
89 {
90 switch (bank) {
91 case 0:
92 gpio_set_value(CELLVISION_GPIO_FLASH_A20, 0);
93 break;
94 case 1:
95 gpio_set_value(CELLVISION_GPIO_FLASH_A20, 1);
96 break;
97 }
98 }
99
100 static void __init cellvision_generic_setup(void)
101 {
102 /* setup flash A20 line */
103 gpio_request(CELLVISION_GPIO_FLASH_A20, NULL);
104 gpio_direction_output(CELLVISION_GPIO_FLASH_A20, 0);
105
106 adm5120_flash0_data.switch_bank = switch_bank_gpio5;
107 adm5120_add_device_flash(0);
108 }
109
110 static void __init cas6xx_setup(void)
111 {
112 #ifdef CONFIG_MTD_PARTITIONS
113 adm5120_flash0_data.nr_parts = ARRAY_SIZE(cas6xx_partitions);
114 adm5120_flash0_data.parts = cas6xx_partitions;
115 #endif /* CONFIG_MTD_PARTITIONS */
116 cellvision_generic_setup();
117
118 adm5120_add_device_switch(1, NULL);
119 }
120
121 ADM5120_BOARD(MACH_ADM5120_CAS630, "Cellvision CAS-630/630W", cas6xx_setup);
122 ADM5120_BOARD(MACH_ADM5120_CAS670, "Cellvision CAS-670/670W", cas6xx_setup);
123
124 static void __init cas7xx_setup(void)
125 {
126 #ifdef CONFIG_MTD_PARTITIONS
127 adm5120_flash0_data.nr_parts = ARRAY_SIZE(cas7xx_partitions);
128 adm5120_flash0_data.parts = cas7xx_partitions;
129 #endif /* CONFIG_MTD_PARTITIONS */
130
131 adm5120_add_device_switch(1, NULL);
132 }
133
134 ADM5120_BOARD(MACH_ADM5120_CAS700, "Cellvision CAS-700/700W", cas7xx_setup);
135 ADM5120_BOARD(MACH_ADM5120_CAS790, "Cellvision CAS-790", cas7xx_setup);
136 ADM5120_BOARD(MACH_ADM5120_CAS861, "Cellvision CAS-861/861W", cas7xx_setup);
137
138 static void __init cas771_setup(void)
139 {
140 cas7xx_setup();
141 adm5120_add_device_gpio_leds(ARRAY_SIZE(cas771_gpio_leds),
142 cas771_gpio_leds);
143 adm5120_pci_set_irq_map(ARRAY_SIZE(cas771_pci_irqs), cas771_pci_irqs);
144 }
145
146 ADM5120_BOARD(MACH_ADM5120_CAS771, "Cellvision CAS-771/771W", cas771_setup);
147
148 static u8 nfs_vlans[6] __initdata = { /* TODO: not tested */
149 0x41, 0x42, 0x44, 0x48, 0x50, 0x00
150 };
151
152 static void __init nfs_setup(void)
153 {
154 #ifdef CONFIG_MTD_PARTITIONS
155 adm5120_flash0_data.nr_parts = ARRAY_SIZE(cas6xx_partitions);
156 adm5120_flash0_data.parts = cas6xx_partitions;
157 #endif /* CONFIG_MTD_PARTITIONS */
158
159 cellvision_generic_setup();
160 adm5120_add_device_switch(5, nfs_vlans);
161
162 /* TODO: add PCI IRQ map */
163 }
164
165 ADM5120_BOARD(MACH_ADM5120_NFS101U, "Cellvision NFS-101U/101WU", nfs_setup);