ramips: add support for Sitecom WL-341v3 and other Sercomm IP1006RRv2 boards
[openwrt.git] / target / linux / ramips / files / arch / mips / ralink / rt305x / mach-wl341v3.c
1 /*
2  *  Sitecom WL341v3 board support
3  *
4  *  Copyright (C) 2012 Marco Antonio Mauro <marcus90@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 #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 WL341V3_GPIO_LED_FIRST_AMBER    9
26 #define WL341V3_GPIO_LED_FIRST_BLUE     13
27 #define WL341V3_GPIO_LED_THIRD_AMBER    11
28 #define WL341V3_GPIO_LED_THIRD_BLUE     14
29 #define WL341V3_GPIO_LED_FOURTH_BLUE    10
30 #define WL341V3_GPIO_LED_FIFTH_AMBER    12
31 #define WL341V3_GPIO_LED_FIFTH_BLUE     8
32
33 #define WL341V3_GPIO_BUTTON_WPS         5       /* active low */
34 #define WL341V3_GPIO_BUTTON_RESET       7       /* active low */
35
36 #define WL341V3_BUTTONS_POLL_INTERVAL   20
37
38 #ifdef CONFIG_MTD_PARTITIONS
39 static struct mtd_partition wl341v3_partitions[] = {
40         {
41                 .name   = "u-boot",
42                 .offset = 0,
43                 .size   = 0x020000,
44                 .mask_flags = MTD_WRITEABLE,
45         }, {
46                 .name   = "board-nvram",
47                 .offset = 0x020000,
48                 .size   = 0x010000,
49                 .mask_flags = MTD_WRITEABLE,
50         }, {
51                 .name   = "u-boot-env",
52                 .offset = 0x030000,
53                 .size   = 0x010000,
54                 .mask_flags = MTD_WRITEABLE,
55         }, {
56                 .name   = "kernel",
57                 .offset = 0x040000,
58                 .size   = 0x0d0000,
59         }, {
60                 .name   = "rootfs",
61                 .offset = 0x110000,
62                 .size   = 0x2e0000,
63         }, {
64                 .name   = "signature-eRcOmM",
65                 .offset = 0x3f0000,
66                 .size   = 0x010000,
67         }, {
68                 .name   = "firmware",
69                 .offset = 0x040000,
70                 .size   = 0x3b0000,
71         }, {
72                 .name   = "fullflash",
73                 .offset = 0x000000,
74                 .size   = 0x400000,
75         }
76 };
77 #endif /* CONFIG_MTD_PARTITIONS */
78
79 static struct physmap_flash_data wl341v3_flash_data = {
80 #ifdef CONFIG_MTD_PARTITIONS
81         .nr_parts       = ARRAY_SIZE(wl341v3_partitions),
82         .parts          = wl341v3_partitions,
83 #endif
84 };
85
86 static struct gpio_led wl341v3_leds_gpio[] __initdata = {
87         {
88                 .name           = "wl341v3:amber:first",
89                 .gpio           = WL341V3_GPIO_LED_FIRST_AMBER,
90                 .active_low     = 1,
91         }, {
92                 .name           = "wl341v3:blue:first",
93                 .gpio           = WL341V3_GPIO_LED_FIRST_BLUE,
94                 .active_low     = 1,
95         }, {
96                 .name           = "wl341v3:amber:third",
97                 .gpio           = WL341V3_GPIO_LED_THIRD_AMBER,
98                 .active_low     = 1,
99         }, {
100                 .name           = "wl341v3:blue:third",
101                 .gpio           = WL341V3_GPIO_LED_THIRD_BLUE,
102                 .active_low     = 1,
103         }, {
104                 .name           = "wl341v3:blue:fourth",
105                 .gpio           = WL341V3_GPIO_LED_FOURTH_BLUE,
106                 .active_low     = 1,
107         }, {
108                 .name           = "wl341v3:amber:fifth",
109                 .gpio           = WL341V3_GPIO_LED_FIFTH_AMBER,
110                 .active_low     = 1,
111         }, {
112                 .name           = "wl341v3:blue:fifth",
113                 .gpio           = WL341V3_GPIO_LED_FIFTH_BLUE,
114                 .active_low     = 1,
115         }
116 };
117
118 static struct gpio_button wl341v3_gpio_buttons[] __initdata = {
119         {
120                 .desc           = "reset",
121                 .type           = EV_KEY,
122                 .code           = KEY_RESTART,
123                 .threshold      = 3,
124                 .gpio           = WL341V3_GPIO_BUTTON_RESET,
125                 .active_low     = 1,
126         }, {
127                 .desc           = "wps",
128                 .type           = EV_KEY,
129                 .code           = KEY_WPS_BUTTON,
130                 .threshold      = 3,
131                 .gpio           = WL341V3_GPIO_BUTTON_WPS,
132                 .active_low     = 1,
133         }
134 };
135
136 static void __init wl341v3_init(void)
137 {
138         rt305x_gpio_init(RT305X_GPIO_MODE_GPIO << RT305X_GPIO_MODE_UART0_SHIFT);
139
140         rt305x_register_flash(0, &wl341v3_flash_data);
141         rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_WLLLL;
142         rt305x_register_ethernet();
143         ramips_register_gpio_leds(-1, ARRAY_SIZE(wl341v3_leds_gpio),
144                                   wl341v3_leds_gpio);
145         ramips_register_gpio_buttons(-1, WL341V3_BUTTONS_POLL_INTERVAL,
146                                      ARRAY_SIZE(wl341v3_gpio_buttons),
147                                      wl341v3_gpio_buttons);
148         rt305x_register_wifi();
149         rt305x_register_wdt();
150         rt305x_register_usb();
151 }
152
153 MIPS_MACHINE(RAMIPS_MACH_WL341V3, "WL341V3", "Sitecom WL-341 v3",
154              wl341v3_init);