[ramips] add Ralink V11ST-FE board support
[openwrt/svn-archive/archive.git] / target / linux / ramips / files / arch / mips / ralink / rt288x / mach-v11st-fe.c
1 /*
2 * Ralink V11ST-FE board support
3 *
4 * Copyright (C) 2012 Florian Fainelli <florian@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 #include <linux/ethtool.h>
17
18 #include <asm/mach-ralink/machine.h>
19 #include <asm/mach-ralink/dev-gpio-buttons.h>
20 #include <asm/mach-ralink/dev-gpio-leds.h>
21 #include <asm/mach-ralink/rt288x.h>
22 #include <asm/mach-ralink/rt288x_regs.h>
23 #include <asm/mach-ralink/ramips_eth_platform.h>
24
25 #include "devices.h"
26
27 #define V11ST_FE_GPIO_STATUS_LED 12
28 #define V11ST_FE_GPIO_BUTTON_WPS 0
29
30 #define V11ST_FE_KEYS_POLL_INTERVAL 20
31 #define V11ST_FE_KEYS_DEBOUNCE_INTERVAL (3 * V11ST_FE_KEYS_POLL_INTERVAL)
32
33 static struct gpio_led v11st_fe_leds_gpio[] __initdata = {
34 {
35 .name = "v11st-fe:green:status",
36 .gpio = V11ST_FE_GPIO_STATUS_LED,
37 .active_low = 1,
38 }
39 };
40
41 static struct gpio_keys_button v11st_fe_gpio_buttons[] __initdata = {
42 {
43 .desc = "wps",
44 .type = EV_KEY,
45 .code = KEY_WPS_BUTTON,
46 .debounce_interval = V11ST_FE_KEYS_DEBOUNCE_INTERVAL,
47 .gpio = V11ST_FE_GPIO_BUTTON_WPS,
48 }
49 };
50
51 static struct mtd_partition v11st_fe_partitions[] = {
52 {
53 .name = "u-boot",
54 .offset = 0,
55 .size = 0x030000,
56 .mask_flags = MTD_WRITEABLE,
57 }, {
58 .name = "u-boot-env",
59 .offset = 0x030000,
60 .size = 0x010000,
61 .mask_flags = MTD_WRITEABLE,
62 }, {
63 .name = "factory",
64 .offset = 0x040000,
65 .size = 0x010000,
66 .mask_flags = MTD_WRITEABLE,
67 }, {
68 .name = "kernel",
69 .offset = 0x050000,
70 .size = 0x140000,
71 }, {
72 .name = "rootfs",
73 .offset = 0x190000,
74 .size = 0x210000,
75 }
76 };
77
78 static void __init rt_v11st_fe_init(void)
79 {
80 rt288x_gpio_init(RT2880_GPIO_MODE_UART0);
81
82 rt288x_flash0_data.nr_parts = ARRAY_SIZE(v11st_fe_partitions);
83 rt288x_flash0_data.parts = v11st_fe_partitions;
84 rt288x_register_flash(0);
85
86 ramips_register_gpio_leds(-1, ARRAY_SIZE(v11st_fe_leds_gpio),
87 v11st_fe_leds_gpio);
88
89 ramips_register_gpio_buttons(-1, V11ST_FE_KEYS_POLL_INTERVAL,
90 ARRAY_SIZE(v11st_fe_gpio_buttons),
91 v11st_fe_gpio_buttons);
92
93 rt288x_register_wifi();
94
95 /* Board is connected to an IC+ IP175C Fast Ethernet switch */
96 rt288x_eth_data.speed = SPEED_100;
97 rt288x_eth_data.duplex = DUPLEX_FULL;
98 rt288x_eth_data.tx_fc = 1;
99 rt288x_eth_data.rx_fc = 1;
100 rt288x_eth_data.phy_mask = BIT(0);
101 rt288x_register_ethernet();
102
103 rt288x_register_wdt();
104 }
105
106 MIPS_MACHINE(RAMIPS_MACH_V11ST_FE, "V11ST-FE", "Ralink V11ST-FE", rt_v11st_fe_init);