ramips: rt288x: remove CONFIG_MTD_PARTITION ifdefery from machine files
[openwrt/svn-archive/archive.git] / target / linux / ramips / files / arch / mips / ralink / rt288x / mach-wli-tx4-ag300n.c
1 /*
2 * Buffalo WLI-TX4-AG300N 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/ethtool.h>
13 #include <linux/platform_device.h>
14 #include <linux/mtd/mtd.h>
15 #include <linux/mtd/partitions.h>
16 #include <linux/mtd/physmap.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/rt288x.h>
22 #include <asm/mach-ralink/rt288x_regs.h>
23 #include <asm/mach-ralink/ramips_eth_platform.h>
24
25 #include "devices.h"
26
27 #define WLI_TX4_AG300N_GPIO_LED_DIAG 10
28 #define WLI_TX4_AG300N_GPIO_LED_POWER 12
29 #define WLI_TX4_AG300N_GPIO_LED_SECURITY 13
30
31 #define WLI_TX4_AG300N_GPIO_BUTTON_AOSS 0
32 #define WLI_TX4_AG300N_GPIO_BUTTON_BW_SWITCH 8
33 #define WLI_TX4_AG300N_GPIO_BUTTON_RESET 9
34
35 #define WLI_TX4_AG300N_BUTTONS_POLL_INTERVAL 20
36
37 static struct mtd_partition wli_tx4_ag300n_partitions[] = {
38 {
39 .name = "u-boot",
40 .offset = 0,
41 .size = 0x030000,
42 .mask_flags = MTD_WRITEABLE,
43 },
44 {
45 .name = "u-boot-env",
46 .offset = 0x030000,
47 .size = 0x010000,
48 .mask_flags = MTD_WRITEABLE,
49 },
50 {
51 .name = "factory",
52 .offset = 0x040000,
53 .size = 0x010000,
54 .mask_flags = MTD_WRITEABLE,
55 },
56 {
57 .name = "kernel",
58 .offset = 0x050000,
59 .size = 0x0d0000,
60 },
61 {
62 .name = "rootfs",
63 .offset = 0x120000,
64 .size = 0x2d0000,
65 },
66 {
67 .name = "user",
68 .offset = 0x3f0000,
69 .size = 0x010000,
70 },
71 {
72 .name = "firmware",
73 .offset = 0x050000,
74 .size = 0x3a0000,
75 },
76 };
77
78 static struct physmap_flash_data wli_tx4_ag300n_flash_data = {
79 .nr_parts = ARRAY_SIZE(wli_tx4_ag300n_partitions),
80 .parts = wli_tx4_ag300n_partitions,
81 };
82
83 static struct gpio_led wli_tx4_ag300n_leds_gpio[] __initdata = {
84 {
85 .name = "buffalo:blue:power",
86 .gpio = WLI_TX4_AG300N_GPIO_LED_POWER,
87 .active_low = 1,
88 },
89 {
90 .name = "buffalo:red:diag",
91 .gpio = WLI_TX4_AG300N_GPIO_LED_DIAG,
92 .active_low = 1,
93 },
94 {
95 .name = "buffalo:blue:security",
96 .gpio = WLI_TX4_AG300N_GPIO_LED_SECURITY,
97 .active_low = 0,
98 },
99 };
100
101 static struct gpio_button wli_tx4_ag300n_gpio_buttons[] __initdata = {
102 {
103 .desc = "Reset button",
104 .type = EV_KEY,
105 .code = KEY_RESTART,
106 .threshold = 3,
107 .gpio = WLI_TX4_AG300N_GPIO_BUTTON_RESET,
108 .active_low = 1,
109 },
110 {
111 .desc = "AOSS button",
112 .type = EV_KEY,
113 .code = KEY_WPS_BUTTON,
114 .threshold = 3,
115 .gpio = WLI_TX4_AG300N_GPIO_BUTTON_AOSS,
116 .active_low = 1,
117 },
118 {
119 .desc = "Bandwidth switch",
120 .type = EV_KEY,
121 .code = BTN_0,
122 .threshold = 3,
123 .gpio = WLI_TX4_AG300N_GPIO_BUTTON_BW_SWITCH,
124 .active_low = 0,
125 },
126 };
127
128 static void __init wli_tx4_ag300n_init(void)
129 {
130 rt288x_gpio_init(RT2880_GPIO_MODE_UART0);
131
132 ramips_register_gpio_leds(-1, ARRAY_SIZE(wli_tx4_ag300n_leds_gpio),
133 wli_tx4_ag300n_leds_gpio);
134 ramips_register_gpio_buttons(-1, WLI_TX4_AG300N_BUTTONS_POLL_INTERVAL,
135 ARRAY_SIZE(wli_tx4_ag300n_gpio_buttons),
136 wli_tx4_ag300n_gpio_buttons);
137
138 rt288x_register_flash(0, &wli_tx4_ag300n_flash_data);
139 rt288x_register_wifi();
140 rt288x_register_wdt();
141
142 rt288x_eth_data.speed = SPEED_100;
143 rt288x_eth_data.duplex = DUPLEX_FULL;
144 rt288x_eth_data.tx_fc = 1;
145 rt288x_eth_data.rx_fc = 1;
146 rt288x_register_ethernet();
147 }
148
149 MIPS_MACHINE(RAMIPS_MACH_WLI_TX4_AG300N, "WLI-TX4-AG300N",
150 "Buffalo WLI-TX4-AG300N", wli_tx4_ag300n_init);