ramips: rt305x: remove per-board physmap_flash_data instances
[lede.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_KEYS_POLL_INTERVAL      20
37 #define WL341V3_KEYS_DEBOUNCE_INTERVAL  (3 * WL341V3_KEYS_POLL_INTERVAL)
38
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
78 static struct gpio_led wl341v3_leds_gpio[] __initdata = {
79         {
80                 .name           = "wl341v3:amber:first",
81                 .gpio           = WL341V3_GPIO_LED_FIRST_AMBER,
82                 .active_low     = 1,
83         }, {
84                 .name           = "wl341v3:blue:first",
85                 .gpio           = WL341V3_GPIO_LED_FIRST_BLUE,
86                 .active_low     = 1,
87         }, {
88                 .name           = "wl341v3:amber:third",
89                 .gpio           = WL341V3_GPIO_LED_THIRD_AMBER,
90                 .active_low     = 1,
91         }, {
92                 .name           = "wl341v3:blue:third",
93                 .gpio           = WL341V3_GPIO_LED_THIRD_BLUE,
94                 .active_low     = 1,
95         }, {
96                 .name           = "wl341v3:blue:fourth",
97                 .gpio           = WL341V3_GPIO_LED_FOURTH_BLUE,
98                 .active_low     = 1,
99         }, {
100                 .name           = "wl341v3:amber:fifth",
101                 .gpio           = WL341V3_GPIO_LED_FIFTH_AMBER,
102                 .active_low     = 1,
103         }, {
104                 .name           = "wl341v3:blue:fifth",
105                 .gpio           = WL341V3_GPIO_LED_FIFTH_BLUE,
106                 .active_low     = 1,
107         }
108 };
109
110 static struct gpio_keys_button wl341v3_gpio_buttons[] __initdata = {
111         {
112                 .desc           = "reset",
113                 .type           = EV_KEY,
114                 .code           = KEY_RESTART,
115                 .debounce_interval = WL341V3_KEYS_DEBOUNCE_INTERVAL,
116                 .gpio           = WL341V3_GPIO_BUTTON_RESET,
117                 .active_low     = 1,
118         }, {
119                 .desc           = "wps",
120                 .type           = EV_KEY,
121                 .code           = KEY_WPS_BUTTON,
122                 .debounce_interval = WL341V3_KEYS_DEBOUNCE_INTERVAL,
123                 .gpio           = WL341V3_GPIO_BUTTON_WPS,
124                 .active_low     = 1,
125         }
126 };
127
128 static void __init wl341v3_init(void)
129 {
130         rt305x_gpio_init(RT305X_GPIO_MODE_GPIO << RT305X_GPIO_MODE_UART0_SHIFT);
131
132         rt305x_flash0_data.nr_parts = ARRAY_SIZE(wl341v3_partitions);
133         rt305x_flash0_data.parts = wl341v3_partitions;
134         rt305x_register_flash(0);
135
136         rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_WLLLL;
137         rt305x_register_ethernet();
138         ramips_register_gpio_leds(-1, ARRAY_SIZE(wl341v3_leds_gpio),
139                                   wl341v3_leds_gpio);
140         ramips_register_gpio_buttons(-1, WL341V3_KEYS_POLL_INTERVAL,
141                                      ARRAY_SIZE(wl341v3_gpio_buttons),
142                                      wl341v3_gpio_buttons);
143         rt305x_register_wifi();
144         rt305x_register_wdt();
145         rt305x_register_usb();
146 }
147
148 MIPS_MACHINE(RAMIPS_MACH_WL341V3, "WL341V3", "Sitecom WL-341 v3",
149              wl341v3_init);