2b90ce16d0cd51b4172a2c80fb4de416a6a2c7e0
[librecmc/librecmc.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 "cellvision.h"
13
14 #define CELLVISION_GPIO_FLASH_A20       ADM5120_GPIO_PIN5
15 #define CELLVISION_GPIO_DEV_MASK        (1 << CELLVISION_GPIO_FLASH_A20)
16
17 #ifdef CONFIG_MTD_PARTITIONS
18 static struct mtd_partition cas6xx_partitions[] = {
19         {
20                 .name   = "admboot",
21                 .offset = 0,
22                 .size   = 32*1024,
23                 .mask_flags = MTD_WRITEABLE,
24         } , {
25                 .name   = "config",
26                 .offset = MTDPART_OFS_APPEND,
27                 .size   = 32*1024,
28         } , {
29                 .name   = "nvfs1",
30                 .offset = MTDPART_OFS_APPEND,
31                 .size   = 64*1024,
32         } , {
33                 .name   = "nvfs2",
34                 .offset = MTDPART_OFS_APPEND,
35                 .size   = 64*1024,
36         } , {
37                 .name   = "firmware",
38                 .offset = MTDPART_OFS_APPEND,
39                 .size   = MTDPART_SIZ_FULL,
40         }
41 };
42
43 static struct mtd_partition cas7xx_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   = "nvfs",
55                 .offset = MTDPART_OFS_APPEND,
56                 .size   = 128*1024,
57         } , {
58                 .name   = "firmware",
59                 .offset = MTDPART_OFS_APPEND,
60                 .size   = MTDPART_SIZ_FULL,
61         }
62 };
63 #endif /* CONFIG_MTD_PARTITIONS */
64
65 static void switch_bank_gpio5(unsigned bank)
66 {
67         switch (bank) {
68         case 0:
69                 gpio_set_value(CELLVISION_GPIO_FLASH_A20, 0);
70                 break;
71         case 1:
72                 gpio_set_value(CELLVISION_GPIO_FLASH_A20, 1);
73                 break;
74         }
75 }
76
77 static void __init cellvision_flash_setup(void)
78 {
79         /* setup flash A20 line */
80         gpio_request(CELLVISION_GPIO_FLASH_A20, NULL);
81         gpio_direction_output(CELLVISION_GPIO_FLASH_A20, 0);
82
83         adm5120_flash0_data.switch_bank = switch_bank_gpio5;
84         adm5120_add_device_flash(0);
85 }
86
87 void __init cas6xx_flash_setup(void)
88 {
89 #ifdef CONFIG_MTD_PARTITIONS
90         adm5120_flash0_data.nr_parts = ARRAY_SIZE(cas6xx_partitions);
91         adm5120_flash0_data.parts = cas6xx_partitions;
92 #endif /* CONFIG_MTD_PARTITIONS */
93
94         cellvision_flash_setup();
95 }
96
97 void __init cas7xx_flash_setup(void)
98 {
99 #ifdef CONFIG_MTD_PARTITIONS
100         adm5120_flash0_data.nr_parts = ARRAY_SIZE(cas7xx_partitions);
101         adm5120_flash0_data.parts = cas7xx_partitions;
102 #endif /* CONFIG_MTD_PARTITIONS */
103
104         cellvision_flash_setup();
105 }
106
107 #if 0
108 void __init cas6xx_setup(void)
109 {
110         cas6xx_flash_setup();
111         adm5120_add_device_switch(1, NULL);
112 }
113
114 ADM5120_BOARD(MACH_ADM5120_CAS630, "Cellvision CAS-630/630W", cas6xx_setup);
115 ADM5120_BOARD(MACH_ADM5120_CAS670, "Cellvision CAS-670/670W", cas6xx_setup);
116 #endif
117
118 void __init cas7xx_setup(void)
119 {
120         cas7xx_flash_setup();
121         adm5120_add_device_switch(1, NULL);
122 }
123
124 #if 0
125 ADM5120_BOARD(MACH_ADM5120_CAS700, "Cellvision CAS-700/700W", cas7xx_setup);
126 ADM5120_BOARD(MACH_ADM5120_CAS790, "Cellvision CAS-790", cas7xx_setup);
127 ADM5120_BOARD(MACH_ADM5120_CAS861, "Cellvision CAS-861/861W", cas7xx_setup);
128 #endif