ramips: rt305x: add support for the Skyline SL-R7205 Wireless 3G router
[openwrt.git] / target / linux / ramips / files / arch / mips / ralink / rt305x / mach-sl-r7205.c
1 /*
2  *  Skyline SL-R7205 Wireless 3G Router support
3  *
4  *  Copyright (C) 2012 Haipoh Teoh <hpteoh@ceedtec.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 #include <linux/mtd/mtd.h>
14 #include <linux/mtd/partitions.h>
15 #include <linux/mtd/physmap.h>
16
17 #include <asm/mach-ralink/machine.h>
18 #include <asm/mach-ralink/dev-gpio-buttons.h>
19 #include <asm/mach-ralink/dev-gpio-leds.h>
20 #include <asm/mach-ralink/rt305x.h>
21 #include <asm/mach-ralink/rt305x_regs.h>
22
23 #include "devices.h"
24
25 #define SL_R7205_GPIO_BUTTON_WPS        0
26 #define SL_R7205_GPIO_BUTTON_RESET      10      /* active low */
27
28 #define SL_R7205_GPIO_LED_WIFI          7
29
30 #define SL_R7205_KEYS_POLL_INTERVAL     20
31 #define SL_R7205_KEYS_DEBOUNCE_INTERVAL (3 * SL_R7205_KEYS_POLL_INTERVAL)
32
33 static struct mtd_partition sl_r7205_partitions[] = {
34         {
35                 .name   = "u-boot",
36                 .offset = 0,
37                 .size   = 0x030000,
38                 .mask_flags = MTD_WRITEABLE,
39         }, {
40                 .name   = "u-boot-env",
41                 .offset = 0x030000,
42                 .size   = 0x010000,
43                 .mask_flags = MTD_WRITEABLE,
44         }, {
45                 .name   = "factory",
46                 .offset = 0x040000,
47                 .size   = 0x010000,
48                 .mask_flags = MTD_WRITEABLE,
49         }, {
50                 .name   = "kernel",
51                 .offset = 0x050000,
52                 .size   = 0x0a0000,
53         }, {
54                 .name   = "rootfs",
55                 .offset = 0x150000,
56                 .size   = 0x2b0000,
57         }, {
58                 .name   = "firmware",
59                 .offset = 0x050000,
60                 .size   = 0x3b0000,
61         }
62 };
63
64 static struct gpio_led sl_r7205_leds_gpio[] __initdata = {
65         {
66                 .name           = "sl-r7205:green:wifi",
67                 .gpio           = SL_R7205_GPIO_LED_WIFI,
68                 .active_low     = 1,
69         }
70 };
71
72 static struct gpio_keys_button sl_r7205_gpio_buttons[] __initdata = {
73         {
74                 .desc           = "reset",
75                 .type           = EV_KEY,
76                 .code           = KEY_RESTART,
77                 .debounce_interval = SL_R7205_KEYS_DEBOUNCE_INTERVAL,
78                 .gpio           = SL_R7205_GPIO_BUTTON_RESET,
79                 .active_low     = 1,
80         }, {
81                 .desc           = "wps",
82                 .type           = EV_KEY,
83                 .code           = KEY_WPS_BUTTON,
84                 .debounce_interval = SL_R7205_KEYS_DEBOUNCE_INTERVAL,
85                 .gpio           = SL_R7205_GPIO_BUTTON_WPS,
86                 .active_low     = 1,
87         }
88 };
89
90 static void __init sl_r7205_init(void)
91 {
92         rt305x_gpio_init(RT305X_GPIO_MODE_GPIO << RT305X_GPIO_MODE_UART0_SHIFT);
93
94         rt305x_flash0_data.nr_parts = ARRAY_SIZE(sl_r7205_partitions);
95         rt305x_flash0_data.parts = sl_r7205_partitions;
96         rt305x_register_flash(0);
97
98         rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_WLLLL;
99         rt305x_register_ethernet();
100         ramips_register_gpio_leds(-1, ARRAY_SIZE(sl_r7205_leds_gpio),
101                                   sl_r7205_leds_gpio);
102         ramips_register_gpio_buttons(-1, SL_R7205_KEYS_POLL_INTERVAL,
103                                      ARRAY_SIZE(sl_r7205_gpio_buttons),
104                                      sl_r7205_gpio_buttons);
105         rt305x_register_wifi();
106         rt305x_register_wdt();
107         rt305x_register_usb();
108 }
109
110 MIPS_MACHINE(RAMIPS_MACH_SL_R7205, "SL-R7205",
111              "Skyline SL-R7205 Wireless 3G Router",
112              sl_r7205_init);