ramips: rt305x: remove CONFIG_MTD_PARTITION ifdefery from machine files
[openwrt/staging/chunkeey.git] / target / linux / ramips / files / arch / mips / ralink / rt305x / mach-wr6202.c
1 /*
2 * AWB WR6202 board support
3 *
4 * Copyright (C) 2012 Johnathan Boyce<jon.boyce@globalreach.eu.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 #include<linux/gpio.h>
17
18 #include<asm/mach-ralink/machine.h>
19 #include<asm/mach-ralink/dev-gpio-buttons.h>
20 #include<asm/mach-ralink/dev-gpio-leds.h>
21 #include<asm/mach-ralink/rt305x.h>
22 #include<asm/mach-ralink/rt305x_regs.h>
23
24 #include "devices.h"
25
26 #define WR6202_GPIO_BUTTON_RESET 10 /* active low */
27 #define WR6202_GPIO_BUTTON_WPS 0 /* active low */
28
29 #define WR6202_BUTTONS_POLL_INTERVAL 20
30
31 #define WR6202_GPIO_USB_POWER 11
32
33 #define WR6202_GPIO_LED_3G 13
34 #define WR6202_GPIO_LED_WPS 14
35
36 static struct mtd_partition wr6202_partitions[] = {
37 {
38 .name = "uboot",
39 .offset = 0,
40 .size = 0x030000,
41 }, {
42 .name = "uboot-config",
43 .offset = 0x030000,
44 .size = 0x040000,
45 .mask_flags = MTD_WRITEABLE,
46 }, {
47 .name = "factory",
48 .offset = 0x040000,
49 .size = 0x050000,
50 .mask_flags = MTD_WRITEABLE,
51 }, {
52 .name = "linux",
53 .offset = 0x050000,
54 .size = 0x100000,
55 }, {
56 .name = "rootfs",
57 .offset = 0x150000,
58 .size = 0x6B0000,
59 }
60 };
61
62 static struct physmap_flash_data wr6202_flash_data = {
63 .nr_parts = ARRAY_SIZE(wr6202_partitions),
64 .parts = wr6202_partitions,
65 };
66
67 static struct gpio_led wr6202_leds_gpio[] __initdata = {
68 {
69 .name = "wr6202:blue:wps",
70 .gpio = WR6202_GPIO_LED_WPS,
71 .active_low = 1,
72 }, {
73 .name = "wr6202:blue:3g",
74 .gpio = WR6202_GPIO_LED_3G,
75 .active_low = 1,
76 }
77 };
78
79 static struct gpio_button wr6202_gpio_buttons[] __initdata = {
80 {
81 .desc = "reset",
82 .type = EV_KEY,
83 .code = KEY_RESTART,
84 .threshold = 3,
85 .gpio = WR6202_GPIO_BUTTON_RESET,
86 .active_low = 1,
87 }, {
88 .desc = "wps",
89 .type = EV_KEY,
90 .code = KEY_WPS_BUTTON,
91 .threshold = 3,
92 .gpio = WR6202_GPIO_BUTTON_WPS,
93 .active_low = 1,
94 }
95 };
96
97 static void __init wr6202_init(void)
98 {
99 rt305x_esw_data.vlan_config = RT305X_ESW_VLAN_CONFIG_WLLLL;
100
101 rt305x_gpio_init(RT305X_GPIO_MODE_GPIO << RT305X_GPIO_MODE_UART0_SHIFT);
102
103 ramips_register_gpio_leds(-1, ARRAY_SIZE(wr6202_leds_gpio),
104 wr6202_leds_gpio);
105 ramips_register_gpio_buttons(-1, WR6202_BUTTONS_POLL_INTERVAL,
106 ARRAY_SIZE(wr6202_gpio_buttons),
107 wr6202_gpio_buttons);
108
109 /* Power to the USB port is controlled by GPIO line */
110 gpio_request(WR6202_GPIO_USB_POWER, "WR6202_GPIO_USB_POWER");
111 gpio_direction_output(WR6202_GPIO_USB_POWER, 0);
112 gpio_free(WR6202_GPIO_USB_POWER);
113
114 rt305x_register_flash(0, &wr6202_flash_data);
115 rt305x_register_ethernet();
116 rt305x_register_wifi();
117 rt305x_register_wdt();
118 rt305x_register_usb();
119 }
120
121 MIPS_MACHINE(RAMIPS_MACH_WR6202, "WR6202", "AWB WR6202",
122 wr6202_init);