1/*
2 *  Belkin F5D825 V1 board support
3 *
4 *  Copyright (C) 2011 Cezary Jackiewicz <cezary.jackiewicz@gmail.com>
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/rt288x.h>
18#include <asm/mach-ralink/rt288x_regs.h>
19
20#include "devices.h"
21
22#include <linux/rtl8366.h>
23#include <linux/ethtool.h>
24
25#include <asm/mach-ralink/ramips_eth_platform.h>
26
27#define F5D8235_GPIO_RTL8366_SCK	2
28#define F5D8235_GPIO_RTL8366_SDA	1
29
30#define F5D8235_GPIO_LED_USB_BLUE	7
31#define F5D8235_GPIO_LED_USB_ORANGE	8
32#define F5D8235_GPIO_BUTTON_WPS		0
33#define F5D8235_GPIO_BUTTON_RESET	9
34
35#define F5D8235_KEYS_POLL_INTERVAL	20
36#define F5D8235_KEYS_DEBOUNCE_INTERVAL	(3 * F5D8235_KEYS_POLL_INTERVAL)
37
38static struct rtl8366_platform_data f5d8235_rtl8366s_data = {
39	.gpio_sda	= F5D8235_GPIO_RTL8366_SDA,
40	.gpio_sck	= F5D8235_GPIO_RTL8366_SCK,
41};
42
43static struct platform_device f5d8235_rtl8366s_device = {
44	.name		= RTL8366S_DRIVER_NAME,
45	.id		= -1,
46	.dev = {
47		.platform_data	= &f5d8235_rtl8366s_data,
48	}
49};
50
51static struct gpio_led f5d8235_leds_gpio[] __initdata = {
52	{
53		.name		= "f5d8235-v1:blue:storage",
54		.gpio		= F5D8235_GPIO_LED_USB_BLUE,
55		.active_low	= 1,
56	},{
57		.name		= "f5d8235-v1:orange:storage",
58		.gpio		= F5D8235_GPIO_LED_USB_ORANGE,
59		.active_low	= 1,
60	}
61};
62
63static struct gpio_keys_button f5d8235_gpio_buttons[] __initdata = {
64	{
65		.desc		= "reset",
66		.type		= EV_KEY,
67		.code		= KEY_RESTART,
68		.debounce_interval = F5D8235_KEYS_DEBOUNCE_INTERVAL,
69		.gpio		= F5D8235_GPIO_BUTTON_RESET,
70		.active_low	= 1,
71	}, {
72		.desc		= "wps",
73		.type		= EV_KEY,
74		.code		= KEY_WPS_BUTTON,
75		.debounce_interval = F5D8235_KEYS_DEBOUNCE_INTERVAL,
76		.gpio		= F5D8235_GPIO_BUTTON_WPS,
77		.active_low	= 1,
78	}
79};
80
81static void __init f5d8235_init(void)
82{
83	rt288x_gpio_init(RT2880_GPIO_MODE_UART0 | RT2880_GPIO_MODE_I2C);
84
85	rt288x_register_flash(0);
86	rt288x_register_wifi();
87	rt288x_register_wdt();
88
89	ramips_register_gpio_leds(-1, ARRAY_SIZE(f5d8235_leds_gpio),
90				  f5d8235_leds_gpio);
91
92	ramips_register_gpio_buttons(-1, F5D8235_KEYS_POLL_INTERVAL,
93				     ARRAY_SIZE(f5d8235_gpio_buttons),
94				     f5d8235_gpio_buttons);
95
96	platform_device_register(&f5d8235_rtl8366s_device);
97
98	rt288x_eth_data.speed = SPEED_1000;
99	rt288x_eth_data.duplex = DUPLEX_FULL;
100	rt288x_eth_data.tx_fc = 1;
101	rt288x_eth_data.rx_fc = 1;
102	rt288x_register_ethernet();
103}
104
105MIPS_MACHINE(RAMIPS_MACH_F5D8235_V1, "F5D8235_V1",
106	     "Belkin F5D8235 v1", f5d8235_init);
107