1/*
2 *  Sparklan WCR-150GN board support
3 *
4 *  Copyright (C) 2010 Roman Yeryomin <roman@advem.lv>
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 WCR150GN_GPIO_LED_USER                 12
23#define WCR150GN_GPIO_LED_POWER                        8
24#define WCR150GN_GPIO_BUTTON_WPS               10
25#define WCR150GN_GPIO_BUTTON_RESET             0
26#define WCR150GN_KEYS_POLL_INTERVAL	20
27#define WCR150GN_KEYS_DEBOUNCE_INTERVAL	(3 * WCR150GN_KEYS_POLL_INTERVAL)
28
29static struct gpio_led wcr150gn_leds_gpio[] __initdata = {
30	{
31		.name       = "wcr150gn:amber:user",
32		.gpio       = WCR150GN_GPIO_LED_USER,
33		.active_low = 1,
34	},
35	{
36		.name       = "wcr150gn:amber:power",
37		.gpio       = WCR150GN_GPIO_LED_POWER,
38		.active_low = 1,
39	}
40};
41
42static struct gpio_keys_button wcr150gn_gpio_buttons[] __initdata = {
43	{
44		.desc       = "wps",
45		.type       = EV_KEY,
46		.code       = KEY_WPS_BUTTON,
47		.debounce_interval = WCR150GN_KEYS_DEBOUNCE_INTERVAL,
48		.gpio       = WCR150GN_GPIO_BUTTON_WPS,
49		.active_low = 1,
50	},
51	{
52		.desc       = "reset",
53		.type       = EV_KEY,
54		.code       = KEY_RESTART,
55		.debounce_interval = WCR150GN_KEYS_DEBOUNCE_INTERVAL,
56		.gpio       = WCR150GN_GPIO_BUTTON_RESET,
57		.active_low = 1,
58	}
59};
60
61static void __init wcr150gn_init(void)
62{
63	rt305x_gpio_init(RT305X_GPIO_MODE_GPIO << RT305X_GPIO_MODE_UART0_SHIFT);
64
65	rt305x_register_flash(0);
66
67	ramips_register_gpio_leds(-1, ARRAY_SIZE(wcr150gn_leds_gpio),
68				  wcr150gn_leds_gpio);
69	ramips_register_gpio_buttons(-1, WCR150GN_KEYS_POLL_INTERVAL,
70				     ARRAY_SIZE(wcr150gn_gpio_buttons),
71				     wcr150gn_gpio_buttons);
72	rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_LLLLW;
73	rt305x_register_ethernet();
74	rt305x_register_wifi();
75	rt305x_register_wdt();
76	rt305x_register_usb();
77}
78
79MIPS_MACHINE(RAMIPS_MACH_WCR150GN, "WCR150GN", "Sparklan WCR-150GN",
80	     wcr150gn_init);
81