2 * arch/arm/mach-kirkwood/nsa-310-setup.c
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.
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/i2c.h>
16 #include <linux/mtd/mtd.h>
17 #include <linux/mtd/partitions.h>
18 #include <linux/gpio.h>
19 #include <linux/gpio_keys.h>
20 #include <linux/input.h>
21 #include <linux/leds.h>
22 #include <linux/delay.h>
24 #include <asm/mach-types.h>
25 #include <asm/mach/arch.h>
26 #include <mach/kirkwood.h>
30 #define NSA310_GPIO_LED_ESATA_GREEN 12
31 #define NSA310_GPIO_LED_ESATA_RED 13
32 #define NSA310_GPIO_LED_USB_GREEN 15
33 #define NSA310_GPIO_LED_USB_RED 16
34 #define NSA310_GPIO_USB_POWER_OFF 21
35 #define NSA310_GPIO_LED_SYS_GREEN 28
36 #define NSA310_GPIO_LED_SYS_RED 29
37 #define NSA310_GPIO_KEY_RESTART 36
38 #define NSA310_GPIO_KEY_COPY 37
39 #define NSA310_GPIO_LED_COPY_GREEN 39
40 #define NSA310_GPIO_LED_COPY_RED 40
41 #define NSA310_GPIO_LED_HDD_GREEN 41
42 #define NSA310_GPIO_LED_HDD_RED 42
43 #define NSA310_GPIO_BUZZER 44
44 #define NSA310_GPIO_KEY_POWER 46
45 #define NSA310_GPIO_POWER_OFF 48
48 static unsigned int nsa310_mpp_config
[] __initdata
= {
68 static struct mtd_partition nsa310_mtd_parts
[] = {
73 .mask_flags
= MTD_WRITEABLE
,
76 .offset
= MTDPART_OFS_NXTBLK
,
80 .offset
= MTDPART_OFS_NXTBLK
,
84 .offset
= MTDPART_OFS_NXTBLK
,
88 .offset
= MTDPART_OFS_NXTBLK
,
92 .offset
= MTDPART_OFS_NXTBLK
,
96 .offset
= MTDPART_OFS_NXTBLK
,
100 .offset
= MTDPART_OFS_NXTBLK
,
104 .offset
= MTDPART_OFS_NXTBLK
,
109 static struct gpio_led nsa310_leds
[] = {
111 .name
= "nsa310:green:sys",
112 .gpio
= NSA310_GPIO_LED_SYS_GREEN
,
114 .name
= "nsa310:red:sys",
115 .gpio
= NSA310_GPIO_LED_SYS_RED
,
117 .name
= "nsa310:green:hdd",
118 .gpio
= NSA310_GPIO_LED_HDD_GREEN
,
120 .name
= "nsa310:red:hdd",
121 .gpio
= NSA310_GPIO_LED_HDD_RED
,
123 .name
= "nsa310:green:esata",
124 .gpio
= NSA310_GPIO_LED_ESATA_GREEN
,
126 .name
= "nsa310:red:esata",
127 .gpio
= NSA310_GPIO_LED_ESATA_RED
,
129 .name
= "nsa310:green:usb",
130 .gpio
= NSA310_GPIO_LED_USB_GREEN
,
132 .name
= "nsa310:red:usb",
133 .gpio
= NSA310_GPIO_LED_USB_RED
,
135 .name
= "nsa310:green:copy",
136 .gpio
= NSA310_GPIO_LED_COPY_GREEN
,
138 .name
= "nsa310:red:copy",
139 .gpio
= NSA310_GPIO_LED_COPY_RED
,
143 static struct gpio_led_platform_data nsa310_leds_data
= {
145 .num_leds
= ARRAY_SIZE(nsa310_leds
),
148 static struct platform_device nsa310_leds_device
= {
152 .platform_data
= &nsa310_leds_data
,
156 static struct gpio_keys_button nsa310_buttons
[] = {
158 .desc
= "Power Button",
161 .gpio
= NSA310_GPIO_KEY_POWER
,
162 .debounce_interval
= 1000,
164 .desc
= "Copy Button",
167 .gpio
= NSA310_GPIO_KEY_COPY
,
169 .debounce_interval
= 1000,
171 .desc
= "Reset Button",
174 .gpio
= NSA310_GPIO_KEY_RESTART
,
176 .debounce_interval
= 1000,
180 static struct gpio_keys_platform_data nsa310_keys_data
= {
181 .buttons
= nsa310_buttons
,
182 .nbuttons
= ARRAY_SIZE(nsa310_buttons
),
185 static struct platform_device nsa310_keys_device
= {
189 .platform_data
= &nsa310_keys_data
,
193 static struct i2c_board_info __initdata nsa310_i2c_info
[] = {
194 { I2C_BOARD_INFO("adt7476", 0x2e) },
197 static struct mv_sata_platform_data nsa310_sata_data
= {
201 static void nsa310_power_off(void)
203 gpio_set_value(NSA310_GPIO_POWER_OFF
, 1);
206 static int __init
nsa310_gpio_request(unsigned int gpio
, unsigned long flags
,
211 err
= gpio_request_one(gpio
, flags
, label
);
213 pr_err("NSA-310: can't setup GPIO%u (%s), err=%d\n",
219 static void __init
nsa310_gpio_init(void)
223 err
= nsa310_gpio_request(NSA310_GPIO_POWER_OFF
, GPIOF_OUT_INIT_LOW
,
226 pm_power_off
= nsa310_power_off
;
228 nsa310_gpio_request(NSA310_GPIO_USB_POWER_OFF
, GPIOF_OUT_INIT_LOW
,
232 static void __init
nsa310_init(void)
237 kirkwood_mpp_conf(nsa310_mpp_config
);
241 kirkwood_nand_init(ARRAY_AND_SIZE(nsa310_mtd_parts
), 35);
242 kirkwood_ehci_init();
244 kirkwood_pcie_id(&dev
, &rev
);
246 kirkwood_sata_init(&nsa310_sata_data
);
247 kirkwood_uart0_init();
249 i2c_register_board_info(0, ARRAY_AND_SIZE(nsa310_i2c_info
));
252 platform_device_register(&nsa310_leds_device
);
253 platform_device_register(&nsa310_keys_device
);
256 static int __init
nsa310_pci_init(void)
258 if (machine_is_nsa310())
259 kirkwood_pcie_init(KW_PCIE0
);
263 subsys_initcall(nsa310_pci_init
);
265 MACHINE_START(NSA310
, "ZyXEL NSA-310")
266 .atag_offset
= 0x100,
267 .init_machine
= nsa310_init
,
268 .map_io
= kirkwood_map_io
,
269 .init_early
= kirkwood_init_early
,
270 .init_irq
= kirkwood_init_irq
,
271 .timer
= &kirkwood_timer
,
272 .restart
= kirkwood_restart
,