1/*
2 *  Prolink PWH2004 support (or Abocom WR5205)
3 *
4 *  Copyright (C) 2010 Esa Hyytia <esa@netlab.tkk.fi>
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 PWH2004_GPIO_BUTTON_WPS		12
23#define PWH2004_GPIO_LED_POWER		9
24#define PWH2004_GPIO_LED_WIFI		14
25#define PWH2004_KEYS_POLL_INTERVAL	20
26#define PWH2004_KEYS_DEBOUNCE_INTERVAL	(3 * PWH2004_KEYS_POLL_INTERVAL)
27
28static struct gpio_led pwh2004_leds_gpio[] __initdata = {
29	{
30		.name		= "pwh2004:red:wifi",
31		.gpio		= PWH2004_GPIO_LED_WIFI,
32		.active_low	= 1,
33	}, {
34		.name		= "pwh2004:green:power",
35		.gpio		= PWH2004_GPIO_LED_POWER,
36		.active_low	= 1,
37	}
38};
39
40static struct gpio_keys_button pwh2004_gpio_buttons[] __initdata = {
41	{
42		.desc		= "wps",
43		.type		= EV_KEY,
44		.code		= KEY_RESTART,
45		.debounce_interval = PWH2004_KEYS_DEBOUNCE_INTERVAL,
46		.gpio		= PWH2004_GPIO_BUTTON_WPS,
47		.active_low	= 1,
48	}
49};
50
51static void __init pwh2004_init(void)
52{
53	rt305x_gpio_init(RT305X_GPIO_MODE_GPIO << RT305X_GPIO_MODE_UART0_SHIFT);
54
55	rt305x_register_flash(0);
56
57	ramips_register_gpio_leds(-1, ARRAY_SIZE(pwh2004_leds_gpio),
58				  pwh2004_leds_gpio);
59	ramips_register_gpio_buttons(-1, PWH2004_KEYS_POLL_INTERVAL,
60				     ARRAY_SIZE(pwh2004_gpio_buttons),
61				     pwh2004_gpio_buttons);
62	rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_LLLLW;
63	rt305x_register_ethernet();
64	rt305x_register_wifi();
65	rt305x_register_wdt();
66}
67
68MIPS_MACHINE(RAMIPS_MACH_PWH2004, "PWH2004", "Prolink PWH2004",
69	     pwh2004_init);
70