4410b032c4260936425cdad8721c7bb0b0986f0a
[openwrt/openwrt.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 #include <linux/mtd/mtd.h>
14 #include <linux/mtd/partitions.h>
15 #include <linux/mtd/physmap.h>
16
17 #include <asm/mach-ralink/machine.h>
18 #include <asm/mach-ralink/dev-gpio-buttons.h>
19 #include <asm/mach-ralink/dev-gpio-leds.h>
20 #include <asm/mach-ralink/rt305x.h>
21 #include <asm/mach-ralink/rt305x_regs.h>
22
23 #include "devices.h"
24
25 #define NBG_419N_GPIO_LED_POWER 9
26 #define NBG_419N_GPIO_LED_WPS 14
27
28 #define NBG_419N_GPIO_BUTTON_WPS 0 /* active low */
29 #define NBG_419N_GPIO_BUTTON_RESET 10 /* active low */
30
31 #define NBG_419N_KEYS_POLL_INTERVAL 20
32 #define NBG_419N_KEYS_DEBOUNCE_INTERVAL (3 * NBG_419N_KEYS_POLL_INTERVAL)
33
34 static struct mtd_partition nbg_419n_partitions[] = {
35 {
36 .name = "u-boot",
37 .offset = 0,
38 .size = 0x030000,
39 .mask_flags = MTD_WRITEABLE,
40 }, {
41 .name = "config",
42 .offset = 0x030000,
43 .size = 0x010000,
44 .mask_flags = MTD_WRITEABLE,
45 }, {
46 .name = "factory",
47 .offset = 0x040000,
48 .size = 0x010000,
49 .mask_flags = MTD_WRITEABLE,
50 }, {
51 .name = "kernel",
52 .offset = 0x050000,
53 .size = 0x3b0000,
54 }
55 };
56
57 static struct gpio_led nbg_419n_leds_gpio[] __initdata = {
58 {
59 .name = "nbg-419n:green:power",
60 .gpio = NBG_419N_GPIO_LED_POWER,
61 .active_low = 1,
62 }, {
63 .name = "nbg-419n:green:wps",
64 .gpio = NBG_419N_GPIO_LED_WPS,
65 .active_low = 1,
66 }
67 };
68
69 static struct gpio_keys_button nbg_419n_gpio_buttons[] __initdata = {
70 {
71 .desc = "reset",
72 .type = EV_KEY,
73 .code = KEY_RESTART,
74 .debounce_interval = NBG_419N_KEYS_DEBOUNCE_INTERVAL,
75 .gpio = NBG_419N_GPIO_BUTTON_RESET,
76 .active_low = 1,
77 }, {
78 .desc = "wps",
79 .type = EV_KEY,
80 .code = KEY_WPS_BUTTON,
81 .debounce_interval = NBG_419N_KEYS_DEBOUNCE_INTERVAL,
82 .gpio = NBG_419N_GPIO_BUTTON_WPS,
83 .active_low = 1,
84 }
85 };
86
87 static void __init nbg_419n_init(void)
88 {
89 rt305x_gpio_init(RT305X_GPIO_MODE_GPIO << RT305X_GPIO_MODE_UART0_SHIFT);
90
91 rt305x_flash0_data.nr_parts = ARRAY_SIZE(nbg_419n_partitions);
92 rt305x_flash0_data.parts = nbg_419n_partitions;
93 rt305x_register_flash(0);
94
95 rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_LLLLW;
96 rt305x_register_ethernet();
97 ramips_register_gpio_leds(-1, ARRAY_SIZE(nbg_419n_leds_gpio),
98 nbg_419n_leds_gpio);
99 ramips_register_gpio_buttons(-1, NBG_419N_KEYS_POLL_INTERVAL,
100 ARRAY_SIZE(nbg_419n_gpio_buttons),
101 nbg_419n_gpio_buttons);
102 rt305x_register_wifi();
103 rt305x_register_wdt();
104 }
105
106 MIPS_MACHINE(RAMIPS_MACH_NBG_419N, "NBG-419N", "ZyXEL NBG-419N", nbg_419n_init);