ramips: rt305x: remove CONFIG_MTD_PARTITION ifdefery from machine files
[lede.git] / target / linux / ramips / files / arch / mips / ralink / rt305x / mach-w502u.c
1 /*
2  *  ALFA Networks W502U board support
3  *
4  *  Copyright (C) 2011 Gabor Juhos <juhosg@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
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 W502U_GPIO_LED_USB              13
26 #define W502U_GPIO_LED_WPS              14
27
28 #define W502U_GPIO_BUTTON_WPS           0
29 #define W502U_GPIO_BUTTON_RESET         10
30
31 #define W502U_BUTTONS_POLL_INTERVAL     20
32
33 static struct mtd_partition w502u_partitions[] = {
34         {
35                 .name   = "u-boot",
36                 .offset = 0,
37                 .size   = 0x030000,
38                 .mask_flags = MTD_WRITEABLE,
39         }, {
40                 .name   = "config",
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   = 0x0d0000,
53         }, {
54                 .name   = "rootfs",
55                 .offset = 0x120000,
56                 .size   = 0x6d0000,
57         }, {
58                 .name   = "data3g",
59                 .offset = 0x7f0000,
60                 .size   = 0x010000,
61                 .mask_flags = MTD_WRITEABLE,
62         }, {
63                 .name   = "firmware",
64                 .offset = 0x050000,
65                 .size   = 0x7a0000,
66         }
67 };
68
69 static struct physmap_flash_data w502u_flash_data = {
70         .nr_parts       = ARRAY_SIZE(w502u_partitions),
71         .parts          = w502u_partitions,
72 };
73
74 static struct gpio_led w502u_leds_gpio[] __initdata = {
75         {
76                 .name           = "alfa:blue:usb",
77                 .gpio           = W502U_GPIO_LED_USB,
78                 .active_low     = 1,
79         },
80         {
81                 .name           = "alfa:blue:wps",
82                 .gpio           = W502U_GPIO_LED_WPS,
83                 .active_low     = 1,
84         },
85 };
86
87 static struct gpio_button w502u_gpio_buttons[] __initdata = {
88         {
89                 .desc           = "Reset button",
90                 .type           = EV_KEY,
91                 .code           = KEY_RESTART,
92                 .threshold      = 3,
93                 .gpio           = W502U_GPIO_BUTTON_RESET,
94                 .active_low     = 1,
95         },
96         {
97                 .desc           = "WPS button",
98                 .type           = EV_KEY,
99                 .code           = KEY_WPS_BUTTON,
100                 .threshold      = 3,
101                 .gpio           = W502U_GPIO_BUTTON_WPS,
102                 .active_low     = 1,
103         },
104 };
105
106 static void __init w502u_init(void)
107 {
108         rt305x_gpio_init((RT305X_GPIO_MODE_GPIO <<
109                           RT305X_GPIO_MODE_UART0_SHIFT));
110
111         rt305x_register_flash(0, &w502u_flash_data);
112         rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_WLLLL;
113         rt305x_register_ethernet();
114         ramips_register_gpio_leds(-1, ARRAY_SIZE(w502u_leds_gpio),
115                                   w502u_leds_gpio);
116         ramips_register_gpio_buttons(-1, W502U_BUTTONS_POLL_INTERVAL,
117                                      ARRAY_SIZE(w502u_gpio_buttons),
118                                      w502u_gpio_buttons);
119         rt305x_register_wifi();
120         rt305x_register_wdt();
121         rt305x_register_usb();
122 }
123
124 MIPS_MACHINE(RAMIPS_MACH_W502U, "W502U", "ALFA Networks W502U",
125               w502u_init);