b7fcb04a9bd4ae9463df7a3fb0048ee8a47c8cb7
[openwrt/openwrt.git] / target / linux / kirkwood / patches-3.3 / 201-raidsonic-IB-NAS62x0-support.patch
1 --- /dev/null
2 +++ b/arch/arm/mach-kirkwood/nas6210-setup.c
3 @@ -0,0 +1,189 @@
4 +/*
5 + * arch/arm/mach-kirkwood/nas6210-setup.c
6 + *
7 + * Raidsonic ICYBOX NAS6210 Board Setup
8 + *
9 + * This file is licensed under the terms of the GNU General Public
10 + * License version 2. This program is licensed "as is" without any
11 + * warranty of any kind, whether express or implied.
12 + */
13 +
14 +#include <linux/kernel.h>
15 +#include <linux/init.h>
16 +#include <linux/platform_device.h>
17 +#include <linux/ata_platform.h>
18 +#include <linux/mtd/partitions.h>
19 +#include <linux/mv643xx_eth.h>
20 +#include <linux/gpio.h>
21 +#include <linux/gpio_keys.h>
22 +#include <linux/input.h>
23 +#include <linux/leds.h>
24 +#include <asm/mach-types.h>
25 +#include <asm/mach/arch.h>
26 +#include <mach/kirkwood.h>
27 +#include "common.h"
28 +#include "mpp.h"
29 +
30 +#define NAS6210_GPIO_POWER_OFF 24
31 +
32 +static struct mtd_partition nas6210_nand_parts[] = {
33 + {
34 + .name = "uboot",
35 + .offset = 0,
36 + .size = SZ_512K
37 + }, {
38 + .name = "uboot_env",
39 + .offset = MTDPART_OFS_NXTBLK,
40 + .size = SZ_128K
41 + }, {
42 + .name = "kernel",
43 + .offset = MTDPART_OFS_NXTBLK,
44 + .size = 3 * SZ_1M
45 + }, {
46 + .name = "rootfs",
47 + .offset = MTDPART_OFS_NXTBLK,
48 + .size = MTDPART_SIZ_FULL
49 + },
50 +};
51 +
52 +static struct mv643xx_eth_platform_data nas6210_ge00_data = {
53 + .phy_addr = MV643XX_ETH_PHY_ADDR(8),
54 +};
55 +
56 +static struct mv_sata_platform_data nas6210_sata_data = {
57 + .n_ports = 2,
58 +};
59 +
60 +static struct gpio_led nas6210_led_pins[] = {
61 + {
62 + .name = "status:green:power",
63 + .default_trigger = "default-on",
64 + .gpio = 25,
65 + .active_low = 0,
66 + },
67 + {
68 + .name = "status:red:power",
69 + .default_trigger = "none",
70 + .gpio = 22,
71 + .active_low = 0,
72 + },
73 + {
74 + .name = "status:red:usb_copy",
75 + .default_trigger = "none",
76 + .gpio = 27,
77 + .active_low = 0,
78 + },
79 +};
80 +
81 +static struct gpio_led_platform_data nas6210_led_data = {
82 + .leds = nas6210_led_pins,
83 + .num_leds = ARRAY_SIZE(nas6210_led_pins),
84 +};
85 +
86 +static struct platform_device nas6210_leds = {
87 + .name = "leds-gpio",
88 + .id = -1,
89 + .dev = {
90 + .platform_data = &nas6210_led_data,
91 + }
92 +};
93 +
94 +static struct gpio_keys_button nas6210_buttons[] = {
95 + {
96 + .code = KEY_COPY,
97 + .gpio = 29,
98 + .desc = "USB Copy",
99 + .active_low = 1,
100 + },
101 + {
102 + .code = KEY_RESTART,
103 + .gpio = 28,
104 + .desc = "Reset",
105 + .active_low = 1,
106 + },
107 +};
108 +
109 +static struct gpio_keys_platform_data nas6210_button_data = {
110 + .buttons = nas6210_buttons,
111 + .nbuttons = ARRAY_SIZE(nas6210_buttons),
112 +};
113 +
114 +static struct platform_device nas6210_button_device = {
115 + .name = "gpio-keys",
116 + .id = -1,
117 + .num_resources = 0,
118 + .dev = {
119 + .platform_data = &nas6210_button_data,
120 + }
121 +};
122 +
123 +static unsigned int nas6210_mpp_config[] __initdata = {
124 + MPP0_NF_IO2,
125 + MPP1_NF_IO3,
126 + MPP2_NF_IO4,
127 + MPP3_NF_IO5,
128 + MPP4_NF_IO6,
129 + MPP5_NF_IO7,
130 + MPP18_NF_IO0,
131 + MPP19_NF_IO1,
132 + MPP22_GPIO, /* Power LED red */
133 + MPP24_GPIO, /* Power off device */
134 + MPP25_GPIO, /* Power LED green */
135 + MPP27_GPIO, /* USB transfer LED */
136 + MPP28_GPIO, /* Reset button */
137 + MPP29_GPIO, /* USB Copy button */
138 + 0
139 +};
140 +
141 +static void nas6210_power_off(void)
142 +{
143 + gpio_set_value(NAS6210_GPIO_POWER_OFF, 1);
144 +}
145 +
146 +static void __init nas6210_init(void)
147 +{
148 + /*
149 + * Basic setup. Needs to be called early.
150 + */
151 + kirkwood_init();
152 + kirkwood_mpp_conf(nas6210_mpp_config);
153 +
154 + kirkwood_nand_init(ARRAY_AND_SIZE(nas6210_nand_parts), 25);
155 + kirkwood_ehci_init();
156 + kirkwood_ge00_init(&nas6210_ge00_data);
157 + kirkwood_sata_init(&nas6210_sata_data);
158 + kirkwood_uart0_init();
159 + platform_device_register(&nas6210_leds);
160 + platform_device_register(&nas6210_button_device);
161 + if (gpio_request(NAS6210_GPIO_POWER_OFF, "power-off") == 0 &&
162 + gpio_direction_output(NAS6210_GPIO_POWER_OFF, 0) == 0)
163 + pm_power_off = nas6210_power_off;
164 + else
165 + pr_err("nas6210: failed to configure power-off GPIO\n");
166 +}
167 +
168 +static int __init nas6210_pci_init(void)
169 +{
170 + if (machine_is_nas6210()) {
171 + u32 dev, rev;
172 +
173 + kirkwood_pcie_id(&dev, &rev);
174 + if (dev == MV88F6282_DEV_ID)
175 + kirkwood_pcie_init(KW_PCIE1 | KW_PCIE0);
176 + else
177 + kirkwood_pcie_init(KW_PCIE0);
178 + }
179 +
180 + return 0;
181 +}
182 +subsys_initcall(nas6210_pci_init);
183 +
184 +MACHINE_START(NAS6210, "RaidSonic ICY BOX IB-NAS6210")
185 + /* Maintainer: <gmbnomis at gmail dot com> */
186 + .atag_offset = 0x100,
187 + .init_machine = nas6210_init,
188 + .map_io = kirkwood_map_io,
189 + .init_early = kirkwood_init_early,
190 + .init_irq = kirkwood_init_irq,
191 + .timer = &kirkwood_timer,
192 +MACHINE_END
193 --- a/arch/arm/mach-kirkwood/Kconfig
194 +++ b/arch/arm/mach-kirkwood/Kconfig
195 @@ -136,6 +136,12 @@ config MACH_ICONNECT
196 Say 'Y' here if you want your kernel to support the
197 Iomega iConnect Wireless.
198
199 +config MACH_NAS6210
200 + bool "RaidSonic ICY BOX IB-NAS6210"
201 + help
202 + Say 'Y' here if you want your kernel to support the
203 + RaidSonic ICY BOX IB-NAS6210 device.
204 +
205 endmenu
206
207 endif
208 --- a/arch/arm/mach-kirkwood/Makefile
209 +++ b/arch/arm/mach-kirkwood/Makefile
210 @@ -19,5 +19,6 @@ obj-$(CONFIG_MACH_D2NET_V2) += d2net_v2
211 obj-$(CONFIG_MACH_NET2BIG_V2) += netxbig_v2-setup.o lacie_v2-common.o
212 obj-$(CONFIG_MACH_NET5BIG_V2) += netxbig_v2-setup.o lacie_v2-common.o
213 obj-$(CONFIG_MACH_T5325) += t5325-setup.o
214 +obj-$(CONFIG_MACH_NAS6210) += nas6210-setup.o
215
216 obj-$(CONFIG_CPU_IDLE) += cpuidle.o