kirkwood: fix Kconfig symbol for NSA-310
[openwrt.git] / target / linux / kirkwood / patches-3.3 / 202-zyxel-nsa-310.patch
1 --- a/arch/arm/mach-kirkwood/Kconfig
2 +++ b/arch/arm/mach-kirkwood/Kconfig
3 @@ -142,6 +142,12 @@ config MACH_NAS6210
4           Say 'Y' here if you want your kernel to support the
5           RaidSonic ICY BOX IB-NAS6210 device.
6  
7 +config MACH_NSA310
8 +       bool "ZyXEL NSA-310"
9 +       help
10 +         Say 'Y' here if you want your kernel to support the
11 +         ZyXEL NSA-310 board.
12 +
13  endmenu
14  
15  endif
16 --- a/arch/arm/mach-kirkwood/Makefile
17 +++ b/arch/arm/mach-kirkwood/Makefile
18 @@ -20,5 +20,6 @@ obj-$(CONFIG_MACH_NET2BIG_V2)         += netxbi
19  obj-$(CONFIG_MACH_NET5BIG_V2)          += netxbig_v2-setup.o lacie_v2-common.o
20  obj-$(CONFIG_MACH_T5325)               += t5325-setup.o
21  obj-$(CONFIG_MACH_NAS6210)             += nas6210-setup.o
22 +obj-$(CONFIG_MACH_NSA310)              += nsa-310-setup.o
23  
24  obj-$(CONFIG_CPU_IDLE)                 += cpuidle.o
25 --- /dev/null
26 +++ b/arch/arm/mach-kirkwood/nsa-310-setup.c
27 @@ -0,0 +1,273 @@
28 +/*
29 + * arch/arm/mach-kirkwood/nsa-310-setup.c
30 + *
31 + * ZyXEL NSA-310 Setup
32 + *
33 + * This file is licensed under the terms of the GNU General Public
34 + * License version 2.  This program is licensed "as is" without any
35 + * warranty of any kind, whether express or implied.
36 + */
37 +
38 +#include <linux/kernel.h>
39 +#include <linux/init.h>
40 +#include <linux/platform_device.h>
41 +#include <linux/ata_platform.h>
42 +#include <linux/i2c.h>
43 +#include <linux/mtd/mtd.h>
44 +#include <linux/mtd/partitions.h>
45 +#include <linux/gpio.h>
46 +#include <linux/gpio_keys.h>
47 +#include <linux/input.h>
48 +#include <linux/leds.h>
49 +#include <linux/delay.h>
50 +
51 +#include <asm/mach-types.h>
52 +#include <asm/mach/arch.h>
53 +#include <mach/kirkwood.h>
54 +#include "common.h"
55 +#include "mpp.h"
56 +
57 +#define NSA310_GPIO_LED_ESATA_GREEN    12
58 +#define NSA310_GPIO_LED_ESATA_RED      13
59 +#define NSA310_GPIO_LED_USB_GREEN      15
60 +#define NSA310_GPIO_LED_USB_RED                16
61 +#define NSA310_GPIO_USB_POWER_OFF      21
62 +#define NSA310_GPIO_LED_SYS_GREEN      28
63 +#define NSA310_GPIO_LED_SYS_RED                29
64 +#define NSA310_GPIO_KEY_RESTART                36
65 +#define NSA310_GPIO_KEY_COPY           37
66 +#define NSA310_GPIO_LED_COPY_GREEN     39
67 +#define NSA310_GPIO_LED_COPY_RED       40
68 +#define NSA310_GPIO_LED_HDD_GREEN      41
69 +#define NSA310_GPIO_LED_HDD_RED                42
70 +#define NSA310_GPIO_BUZZER             44
71 +#define NSA310_GPIO_KEY_POWER          46
72 +#define NSA310_GPIO_POWER_OFF          48
73 +
74 +
75 +static unsigned int nsa310_mpp_config[] __initdata = {
76 +       MPP12_GPIO,
77 +       MPP13_GPIO,
78 +       MPP15_GPIO,
79 +       MPP16_GPIO,
80 +       MPP21_GPIO,
81 +       MPP28_GPIO,
82 +       MPP29_GPIO,
83 +       MPP36_GPIO,
84 +       MPP37_GPIO,
85 +       MPP39_GPIO,
86 +       MPP40_GPIO,
87 +       MPP41_GPIO,
88 +       MPP42_GPIO,
89 +       MPP44_GPIO,
90 +       MPP46_GPIO,
91 +       MPP48_GPIO,
92 +       0
93 +};
94 +
95 +static struct mtd_partition nsa310_mtd_parts[] = {
96 +       {
97 +               .name   = "uboot",
98 +               .offset = 0,
99 +               .size   = 0x100000,
100 +               .mask_flags = MTD_WRITEABLE,
101 +       }, {
102 +               .name   = "uboot_env",
103 +               .offset = MTDPART_OFS_NXTBLK,
104 +               .size   = 0x80000,
105 +       }, {
106 +               .name   = "key_store",
107 +               .offset = MTDPART_OFS_NXTBLK,
108 +               .size   = 0x80000,
109 +       }, {
110 +               .name   = "info",
111 +               .offset = MTDPART_OFS_NXTBLK,
112 +               .size   = 0x80000,
113 +       }, {
114 +               .name   = "etc",
115 +               .offset = MTDPART_OFS_NXTBLK,
116 +               .size   = 0xa00000,
117 +       }, {
118 +               .name   = "kernel_1",
119 +               .offset = MTDPART_OFS_NXTBLK,
120 +               .size   = 0xa00000,
121 +       }, {
122 +               .name   = "rootfs1",
123 +               .offset = MTDPART_OFS_NXTBLK,
124 +               .size   = 0x2fc0000,
125 +       }, {
126 +               .name   = "kernel_2",
127 +               .offset = MTDPART_OFS_NXTBLK,
128 +               .size   = 0xa00000,
129 +       }, {
130 +               .name   = "rootfs2",
131 +               .offset = MTDPART_OFS_NXTBLK,
132 +               .size   = 0x2fc0000,
133 +       },
134 +};
135 +
136 +static struct gpio_led nsa310_leds[] = {
137 +       {
138 +               .name   = "nsa310:green:sys",
139 +               .gpio   = NSA310_GPIO_LED_SYS_GREEN,
140 +       }, {
141 +               .name   = "nsa310:red:sys",
142 +               .gpio   = NSA310_GPIO_LED_SYS_RED,
143 +       }, {
144 +               .name   = "nsa310:green:hdd",
145 +               .gpio   = NSA310_GPIO_LED_HDD_GREEN,
146 +       }, {
147 +               .name   = "nsa310:red:hdd",
148 +               .gpio   = NSA310_GPIO_LED_HDD_RED,
149 +       }, {
150 +               .name   = "nsa310:green:esata",
151 +               .gpio   = NSA310_GPIO_LED_ESATA_GREEN,
152 +       }, {
153 +               .name   = "nsa310:red:esata",
154 +               .gpio   = NSA310_GPIO_LED_ESATA_RED,
155 +       }, {
156 +               .name   = "nsa310:green:usb",
157 +               .gpio   = NSA310_GPIO_LED_USB_GREEN,
158 +       }, {
159 +               .name   = "nsa310:red:usb",
160 +               .gpio   = NSA310_GPIO_LED_USB_RED,
161 +       }, {
162 +               .name   = "nsa310:green:copy",
163 +               .gpio   = NSA310_GPIO_LED_COPY_GREEN,
164 +       }, {
165 +               .name   = "nsa310:red:copy",
166 +               .gpio   = NSA310_GPIO_LED_COPY_RED,
167 +       },
168 +};
169 +
170 +static struct gpio_led_platform_data nsa310_leds_data = {
171 +       .leds           = nsa310_leds,
172 +       .num_leds       = ARRAY_SIZE(nsa310_leds),
173 +};
174 +
175 +static struct platform_device nsa310_leds_device = {
176 +       .name   = "leds-gpio",
177 +       .id     = -1,
178 +       .dev    = {
179 +               .platform_data  = &nsa310_leds_data,
180 +       }
181 +};
182 +
183 +static struct gpio_keys_button nsa310_buttons[] = {
184 +       {
185 +               .desc           = "Power Button",
186 +               .code           = KEY_POWER,
187 +               .type           = EV_KEY,
188 +               .gpio           = NSA310_GPIO_KEY_POWER,
189 +               .debounce_interval = 1000,
190 +       }, {
191 +               .desc           = "Copy Button",
192 +               .code           = KEY_COPY,
193 +               .type           = EV_KEY,
194 +               .gpio           = NSA310_GPIO_KEY_COPY,
195 +               .active_low     = 1,
196 +               .debounce_interval = 1000,
197 +       }, {
198 +               .desc           = "Reset Button",
199 +               .code           = KEY_RESTART,
200 +               .type           = EV_KEY,
201 +               .gpio           = NSA310_GPIO_KEY_RESTART,
202 +               .active_low     = 1,
203 +               .debounce_interval = 1000,
204 +       },
205 +};
206 +
207 +static struct gpio_keys_platform_data nsa310_keys_data = {
208 +       .buttons        = nsa310_buttons,
209 +       .nbuttons       = ARRAY_SIZE(nsa310_buttons),
210 +};
211 +
212 +static struct platform_device nsa310_keys_device = {
213 +       .name   = "gpio-keys",
214 +       .id     = -1,
215 +       .dev = {
216 +               .platform_data  = &nsa310_keys_data,
217 +       }
218 +};
219 +
220 +static struct i2c_board_info __initdata nsa310_i2c_info[] = {
221 +        { I2C_BOARD_INFO("adt7476", 0x2e) },
222 +};
223 +
224 +static struct mv_sata_platform_data nsa310_sata_data = {
225 +       .n_ports        = 2,
226 +};
227 +
228 +static void nsa310_power_off(void)
229 +{
230 +       gpio_set_value(NSA310_GPIO_POWER_OFF, 1);
231 +}
232 +
233 +static int __init nsa310_gpio_request(unsigned int gpio, unsigned long flags,
234 +                                      const char *label)
235 +{
236 +       int err;
237 +
238 +       err = gpio_request_one(gpio, flags, label);
239 +       if (err)
240 +               pr_err("NSA-310: can't setup GPIO%u (%s), err=%d\n",
241 +                       gpio, label, err);
242 +
243 +       return err;
244 +}
245 +
246 +static void __init nsa310_gpio_init(void)
247 +{
248 +       int err;
249 +
250 +       err = nsa310_gpio_request(NSA310_GPIO_POWER_OFF, GPIOF_OUT_INIT_LOW,
251 +                                 "Power Off");
252 +       if (!err)
253 +               pm_power_off = nsa310_power_off;
254 +
255 +       nsa310_gpio_request(NSA310_GPIO_USB_POWER_OFF, GPIOF_OUT_INIT_LOW,
256 +                           "USB Power Off");
257 +}
258 +
259 +static void __init nsa310_init(void)
260 +{
261 +       u32 dev, rev;
262 +
263 +       kirkwood_init();
264 +       kirkwood_mpp_conf(nsa310_mpp_config);
265 +
266 +       nsa310_gpio_init();
267 +
268 +       kirkwood_nand_init(ARRAY_AND_SIZE(nsa310_mtd_parts), 35);
269 +       kirkwood_ehci_init();
270 +
271 +       kirkwood_pcie_id(&dev, &rev);
272 +
273 +       kirkwood_sata_init(&nsa310_sata_data);
274 +       kirkwood_uart0_init();
275 +
276 +       i2c_register_board_info(0, ARRAY_AND_SIZE(nsa310_i2c_info));
277 +       kirkwood_i2c_init();
278 +
279 +       platform_device_register(&nsa310_leds_device);
280 +       platform_device_register(&nsa310_keys_device);
281 +}
282 +
283 +static int __init nsa310_pci_init(void)
284 +{
285 +       if (machine_is_nsa310())
286 +               kirkwood_pcie_init(KW_PCIE0);
287 +
288 +       return 0;
289 +}
290 +subsys_initcall(nsa310_pci_init);
291 +
292 +MACHINE_START(NSA310, "ZyXEL NSA-310")
293 +       .atag_offset    = 0x100,
294 +       .init_machine   = nsa310_init,
295 +       .map_io         = kirkwood_map_io,
296 +       .init_early     = kirkwood_init_early,
297 +       .init_irq       = kirkwood_init_irq,
298 +       .timer          = &kirkwood_timer,
299 +       .restart        = kirkwood_restart,
300 +MACHINE_END