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