ramips: rt305x: remove per-board physmap_flash_data instances
[openwrt.git] / target / linux / ramips / files / arch / mips / ralink / rt305x / mach-wr512-3gn.c
1 /*
2 * Unbranded router from DX board support
3 * Also known as *WR512*-3GN by local vendors
4 * e.g. WS-WR512N1, Sin Hon SH-WR512NU, and etc
5 * (http://www.dealextreme.com/p/portable-wireless-n-3g-router-cdma2000-evdo-td-scdma-hspa-wcdma-45639)
6 * This router is also known to be rebranded and sold by a number of local
7 * vendors in several countries.
8 *
9 * Copyright (C) 2011 Andrew Andrianov <necromant@necromant.ath.cx>
10 * Based on MOFI3500-3N code by
11 * Copyright (C) 2011 Layne Edwards <ledwards76@gmail.com>
12 *
13 *
14 * This program is free software; you can redistribute it and/or modify it
15 * under the terms of the GNU General Public License version 2 as published
16 * by the Free Software Foundation.
17 */
18
19 #include <linux/init.h>
20 #include <linux/platform_device.h>
21 #include <linux/mtd/mtd.h>
22 #include <linux/mtd/partitions.h>
23 #include <linux/mtd/physmap.h>
24
25 #include <asm/mach-ralink/machine.h>
26 #include <asm/mach-ralink/dev-gpio-buttons.h>
27 #include <asm/mach-ralink/dev-gpio-leds.h>
28 #include <asm/mach-ralink/rt305x.h>
29 #include <asm/mach-ralink/rt305x_regs.h>
30
31 #include "devices.h"
32
33
34 #define WR512_3GN_GPIO_LED_3G 9
35 #define WR512_3GN_GPIO_LED_GATEWAY 11
36 #define WR512_3GN_GPIO_LED_AP 12
37 #define WR512_3GN_GPIO_LED_STATION 13
38 #define WR512_3GN_GPIO_LED_WPS 14
39
40 #define WR512_3GN_GPIO_BUTTON_RESET 10
41 #define WR512_3GN_GPIO_BUTTON_CONNECT 7
42 #define WR512_3GN_GPIO_BUTTON_WPS 0
43 #define WR512_3GN_GPIO_BUTTON_WPS2 8
44
45 #define WR512_3GN_KEYS_POLL_INTERVAL 20
46 #define WR512_3GN_KEYS_DEBOUNCE_INTERVAL (3 * WR512_3GN_KEYS_POLL_INTERVAL)
47
48 static struct mtd_partition wr512_3gn_partitions[] = {
49 {
50 .name = "u-boot",
51 .offset = 0,
52 .size = 0x030000,
53 .mask_flags = MTD_WRITEABLE,
54 }, {
55 .name = "devdata",
56 .offset = 0x030000,
57 .size = 0x010000,
58 .mask_flags = MTD_WRITEABLE,
59 }, {
60 .name = "devconf",
61 .offset = 0x040000,
62 .size = 0x010000,
63 .mask_flags = MTD_WRITEABLE,
64 }, {
65 .name = "kernel",
66 .offset = 0x050000,
67 .size = 0x0d0000,
68 }, {
69 .name = "rootfs",
70 .offset = 0x120000,
71 .size = 0x2e0000,
72 }, {
73 .name = "firmware",
74 .offset = 0x050000,
75 .size = 0x3b0000,
76 }
77 };
78
79 static struct gpio_led wr512_3gn_leds_gpio[] __initdata = {
80 {
81 .name = "wr512:green:3g",
82 .gpio = WR512_3GN_GPIO_LED_3G,
83 .active_low = 1,
84 }, {
85 .name = "wr512:green:gateway",
86 .gpio = WR512_3GN_GPIO_LED_GATEWAY,
87 .active_low = 1,
88 }, {
89 .name = "wr512:green:ap",
90 .gpio = WR512_3GN_GPIO_LED_AP,
91 .active_low = 1,
92 }, {
93 .name = "wr512:green:wps",
94 .gpio = WR512_3GN_GPIO_LED_WPS,
95 .active_low = 1,
96 }, {
97 .name = "wr512:green:station",
98 .gpio = WR512_3GN_GPIO_LED_STATION,
99 .active_low = 1,
100 }
101 };
102
103 static struct gpio_keys_button wr512_3gn_gpio_buttons[] __initdata = {
104 {
105 .desc = "reset_wps",
106 .type = EV_KEY,
107 .code = KEY_RESTART,
108 .debounce_interval = WR512_3GN_KEYS_DEBOUNCE_INTERVAL,
109 .gpio = WR512_3GN_GPIO_BUTTON_RESET,
110 .active_low = 1,
111 }, {
112 .desc = "mode",
113 .type = EV_KEY,
114 .code = KEY_M,
115 .debounce_interval = WR512_3GN_KEYS_DEBOUNCE_INTERVAL,
116 .gpio = WR512_3GN_GPIO_BUTTON_CONNECT,
117 .active_low = 1,
118 }
119 };
120
121 #define WR512_3GN_GPIO_MODE \
122 ((RT305X_GPIO_MODE_GPIO << RT305X_GPIO_MODE_UART0_SHIFT) | \
123 RT305X_GPIO_MODE_MDIO)
124
125 static void __init wr512_3gn_init(void)
126 {
127 rt305x_gpio_init(WR512_3GN_GPIO_MODE);
128
129 rt305x_flash0_data.nr_parts = ARRAY_SIZE(wr512_3gn_partitions);
130 rt305x_flash0_data.parts = wr512_3gn_partitions;
131 rt305x_register_flash(0);
132
133 rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_LLLLW;
134 rt305x_register_ethernet();
135 ramips_register_gpio_leds(-1, ARRAY_SIZE(wr512_3gn_leds_gpio),
136 wr512_3gn_leds_gpio);
137 ramips_register_gpio_buttons(-1, WR512_3GN_KEYS_POLL_INTERVAL,
138 ARRAY_SIZE(wr512_3gn_gpio_buttons),
139 wr512_3gn_gpio_buttons);
140 rt305x_register_wifi();
141 rt305x_register_wdt();
142 rt305x_register_usb();
143 }
144
145 MIPS_MACHINE(RAMIPS_MACH_WR512_3GN, "WR512-3GN", "WR512-3GN-like router",
146 wr512_3gn_init);
This page took 0.053408 seconds and 5 git commands to generate.