[ramips] add feature gpio
[openwrt/svn-archive/archive.git] / target / linux / ramips / files / arch / mips / ralink / rt305x / mach-nbg-419n.c
1 /*
2 * ZyXEL NBG-419N board support
3 *
4 * Copyright (C) 2011 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 #include <linux/init.h>
12 #include <linux/platform_device.h>
13
14 #include <asm/mach-ralink/machine.h>
15 #include <asm/mach-ralink/dev-gpio-buttons.h>
16 #include <asm/mach-ralink/dev-gpio-leds.h>
17 #include <asm/mach-ralink/rt305x.h>
18 #include <asm/mach-ralink/rt305x_regs.h>
19
20 #include "devices.h"
21
22 #define NBG_419N_GPIO_LED_POWER 9
23 #define NBG_419N_GPIO_LED_WPS 14
24
25 #define NBG_419N_GPIO_BUTTON_WPS 0 /* active low */
26 #define NBG_419N_GPIO_BUTTON_RESET 10 /* active low */
27
28 #define NBG_419N_KEYS_POLL_INTERVAL 20
29 #define NBG_419N_KEYS_DEBOUNCE_INTERVAL (3 * NBG_419N_KEYS_POLL_INTERVAL)
30
31 static struct gpio_led nbg_419n_leds_gpio[] __initdata = {
32 {
33 .name = "nbg-419n:green:power",
34 .gpio = NBG_419N_GPIO_LED_POWER,
35 .active_low = 1,
36 }, {
37 .name = "nbg-419n:green:wps",
38 .gpio = NBG_419N_GPIO_LED_WPS,
39 .active_low = 1,
40 }
41 };
42
43 static struct gpio_keys_button nbg_419n_gpio_buttons[] __initdata = {
44 {
45 .desc = "reset",
46 .type = EV_KEY,
47 .code = KEY_RESTART,
48 .debounce_interval = NBG_419N_KEYS_DEBOUNCE_INTERVAL,
49 .gpio = NBG_419N_GPIO_BUTTON_RESET,
50 .active_low = 1,
51 }, {
52 .desc = "wps",
53 .type = EV_KEY,
54 .code = KEY_WPS_BUTTON,
55 .debounce_interval = NBG_419N_KEYS_DEBOUNCE_INTERVAL,
56 .gpio = NBG_419N_GPIO_BUTTON_WPS,
57 .active_low = 1,
58 }
59 };
60
61 static void __init nbg_419n_init(void)
62 {
63 rt305x_gpio_init(RT305X_GPIO_MODE_GPIO << RT305X_GPIO_MODE_UART0_SHIFT);
64
65 rt305x_register_flash(0);
66
67 rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_LLLLW;
68 rt305x_register_ethernet();
69 ramips_register_gpio_leds(-1, ARRAY_SIZE(nbg_419n_leds_gpio),
70 nbg_419n_leds_gpio);
71 ramips_register_gpio_buttons(-1, NBG_419N_KEYS_POLL_INTERVAL,
72 ARRAY_SIZE(nbg_419n_gpio_buttons),
73 nbg_419n_gpio_buttons);
74 rt305x_register_wifi();
75 rt305x_register_wdt();
76 }
77
78 MIPS_MACHINE(RAMIPS_MACH_NBG_419N, "NBG-419N", "ZyXEL NBG-419N", nbg_419n_init);