ramips: add support for unbranded XDX-RN502J board
[openwrt/svn-archive/archive.git] / target / linux / ramips / files / arch / mips / ralink / rt305x / mach-xdx-rn502j.c
1 /*
2 * Unknown router name/model, PCB marked with XDX-RN502J
3 *
4 * Copyright (C) 2011 Bruno Schwander bruno@tinkerbox.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 XDXRN502J_GPIO_BUTTON_RESET 12
23 #define XDXRN502J_GPIO_LED_WIFI 7
24 #define XDXRN502J_GPIO_LED_POWER 9
25
26 #define XDXRN502J_BUTTONS_POLL_INTERVAL 20
27 #define XDXRN502J_BUTTONS_DEBOUNCE_INTERVAL (3 * XDXRN502J_BUTTONS_POLL_INTERVAL)
28
29
30 static struct gpio_led xdxrn502j_leds_gpio[] __initdata = {
31 {
32 .name = "xdxrn502j:green:wifi",
33 .gpio = XDXRN502J_GPIO_LED_WIFI,
34 .active_low = 1,
35 }, {
36 .name = "xdxrn502j:green:power",
37 .gpio = XDXRN502J_GPIO_LED_POWER,
38 .active_low = 1,
39 }
40 };
41
42 static struct gpio_keys_button xdxrn502j_gpio_buttons[] __initdata = {
43 {
44 .desc = "reset",
45 .type = EV_KEY,
46 .code = KEY_RESTART,
47 .debounce_interval = XDXRN502J_BUTTONS_DEBOUNCE_INTERVAL,
48 .gpio = XDXRN502J_GPIO_BUTTON_RESET,
49 .active_low = 1,
50 }
51 };
52
53 #define XDXRN502J_GPIO_MODE \
54 ((RT305X_GPIO_MODE_GPIO << RT305X_GPIO_MODE_UART0_SHIFT) | \
55 RT305X_GPIO_MODE_MDIO)
56
57 static void __init xdxrn502j_init(void)
58 {
59 rt305x_gpio_init(XDXRN502J_GPIO_MODE);
60
61 rt305x_register_flash(0);
62
63 rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_WLLLL;
64 rt305x_register_ethernet();
65
66 ramips_register_gpio_leds(-1, ARRAY_SIZE(xdxrn502j_leds_gpio),
67 xdxrn502j_leds_gpio);
68
69 ramips_register_gpio_buttons(-1, XDXRN502J_BUTTONS_POLL_INTERVAL,
70 ARRAY_SIZE(xdxrn502j_gpio_buttons),
71 xdxrn502j_gpio_buttons);
72
73 rt305x_register_wifi();
74 rt305x_register_wdt();
75 rt305x_register_usb();
76 }
77
78 MIPS_MACHINE(RAMIPS_MACH_XDXRN502J, "XDXRN502J", "XDX RN502J",
79 xdxrn502j_init);