ar71xx: make rb750_latch_change 'static void'
[openwrt.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-whr-hp-g300n.c
1 /*
2 * Buffalo WHR-HP-G300N board support
3 *
4 * based on ...
5 *
6 * TP-LINK TL-WR741ND board support
7 *
8 * Copyright (C) 2009-2010 Gabor Juhos <juhosg@openwrt.org>
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License version 2 as published
12 * by the Free Software Foundation.
13 */
14
15 #include <linux/mtd/mtd.h>
16 #include <linux/mtd/partitions.h>
17
18 #include <asm/mach-ath79/ath79.h>
19 #include <asm/mach-ath79/ar71xx_regs.h>
20
21 #include "common.h"
22 #include "dev-ap9x-pci.h"
23 #include "dev-eth.h"
24 #include "dev-gpio-buttons.h"
25 #include "dev-leds-gpio.h"
26 #include "dev-m25p80.h"
27 #include "machtypes.h"
28
29 #define WHRHPG300N_GPIO_LED_SECURITY 0
30 #define WHRHPG300N_GPIO_LED_DIAG 1
31 #define WHRHPG300N_GPIO_LED_ROUTER 6
32
33 #define WHRHPG300N_GPIO_BTN_ROUTER_ON 7
34 #define WHRHPG300N_GPIO_BTN_ROUTER_AUTO 8
35 #define WHRHPG300N_GPIO_BTN_RESET 11
36 #define WHRHPG300N_GPIO_BTN_AOSS 12
37 #define WHRHPG300N_GPIO_LED_LAN1 13
38 #define WHRHPG300N_GPIO_LED_LAN2 14
39 #define WHRHPG300N_GPIO_LED_LAN3 15
40 #define WHRHPG300N_GPIO_LED_LAN4 16
41 #define WHRHPG300N_GPIO_LED_WAN 17
42
43 #define WHRHPG300N_KEYS_POLL_INTERVAL 20 /* msecs */
44 #define WHRHPG300N_KEYS_DEBOUNCE_INTERVAL (3 * WHRHPG300N_KEYS_POLL_INTERVAL)
45
46 #define WHRHPG300N_MAC_OFFSET 0x20c
47
48 static struct mtd_partition whrhpg300n_partitions[] = {
49 {
50 .name = "u-boot",
51 .offset = 0,
52 .size = 0x03e000,
53 .mask_flags = MTD_WRITEABLE,
54 }, {
55 .name = "u-boot-env",
56 .offset = 0x03e000,
57 .size = 0x002000,
58 .mask_flags = MTD_WRITEABLE,
59 }, {
60 .name = "kernel",
61 .offset = 0x040000,
62 .size = 0x0e0000,
63 }, {
64 .name = "rootfs",
65 .offset = 0x120000,
66 .size = 0x2c0000,
67 }, {
68 .name = "user_property",
69 .offset = 0x3e0000,
70 .size = 0x010000,
71 }, {
72 .name = "ART",
73 .offset = 0x3f0000,
74 .size = 0x010000,
75 .mask_flags = MTD_WRITEABLE,
76 }, {
77 .name = "firmware",
78 .offset = 0x040000,
79 .size = 0x3a0000,
80 }
81 };
82
83 static struct flash_platform_data whrhpg300n_flash_data = {
84 .parts = whrhpg300n_partitions,
85 .nr_parts = ARRAY_SIZE(whrhpg300n_partitions),
86 };
87
88 static struct gpio_led whrhpg300n_leds_gpio[] __initdata = {
89 {
90 .name = "buffalo:orange:security",
91 .gpio = WHRHPG300N_GPIO_LED_SECURITY,
92 .active_low = 1,
93 }, {
94 .name = "buffalo:red:diag",
95 .gpio = WHRHPG300N_GPIO_LED_DIAG,
96 .active_low = 1,
97 }, {
98 .name = "buffalo:green:router",
99 .gpio = WHRHPG300N_GPIO_LED_ROUTER,
100 .active_low = 1,
101 }, {
102 .name = "buffalo:green:wan",
103 .gpio = WHRHPG300N_GPIO_LED_WAN,
104 .active_low = 1,
105 }, {
106 .name = "buffalo:green:lan1",
107 .gpio = WHRHPG300N_GPIO_LED_LAN1,
108 .active_low = 1,
109 }, {
110 .name = "buffalo:green:lan2",
111 .gpio = WHRHPG300N_GPIO_LED_LAN2,
112 .active_low = 1,
113 }, {
114 .name = "buffalo:green:lan3",
115 .gpio = WHRHPG300N_GPIO_LED_LAN3,
116 .active_low = 1,
117 }, {
118 .name = "buffalo:green:lan4",
119 .gpio = WHRHPG300N_GPIO_LED_LAN4,
120 .active_low = 1,
121 }
122 };
123
124 static struct gpio_keys_button whrhpg300n_gpio_keys[] __initdata = {
125 {
126 .desc = "reset",
127 .type = EV_KEY,
128 .code = KEY_RESTART,
129 .debounce_interval = WHRHPG300N_KEYS_DEBOUNCE_INTERVAL,
130 .gpio = WHRHPG300N_GPIO_BTN_RESET,
131 .active_low = 1,
132 }, {
133 .desc = "aoss/wps",
134 .type = EV_KEY,
135 .code = KEY_WPS_BUTTON,
136 .gpio = WHRHPG300N_GPIO_BTN_AOSS,
137 .debounce_interval = WHRHPG300N_KEYS_DEBOUNCE_INTERVAL,
138 .active_low = 1,
139 }, {
140 .desc = "router_on",
141 .type = EV_KEY,
142 .code = BTN_2,
143 .gpio = WHRHPG300N_GPIO_BTN_ROUTER_ON,
144 .debounce_interval = WHRHPG300N_KEYS_DEBOUNCE_INTERVAL,
145 .active_low = 1,
146 }, {
147 .desc = "router_auto",
148 .type = EV_KEY,
149 .code = BTN_3,
150 .gpio = WHRHPG300N_GPIO_BTN_ROUTER_AUTO,
151 .debounce_interval = WHRHPG300N_KEYS_DEBOUNCE_INTERVAL,
152 .active_low = 1,
153 }
154 };
155
156 static void __init whrhpg300n_setup(void)
157 {
158 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
159 u8 *mac = (u8 *) KSEG1ADDR(ee + WHRHPG300N_MAC_OFFSET);
160
161 ath79_register_m25p80(&whrhpg300n_flash_data);
162
163 ath79_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
164 AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
165 AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
166 AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
167 AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
168
169 ath79_register_leds_gpio(-1, ARRAY_SIZE(whrhpg300n_leds_gpio),
170 whrhpg300n_leds_gpio);
171
172 ath79_register_gpio_keys_polled(-1, WHRHPG300N_KEYS_POLL_INTERVAL,
173 ARRAY_SIZE(whrhpg300n_gpio_keys),
174 whrhpg300n_gpio_keys);
175
176 ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
177 ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
178
179 ath79_register_mdio(0, 0x0);
180
181 /* LAN ports */
182 ath79_register_eth(1);
183 /* WAN port */
184 ath79_register_eth(0);
185
186 ap9x_pci_setup_wmac_led_pin(0, 1);
187
188 ap91_pci_init(ee, mac);
189 }
190
191 MIPS_MACHINE(ATH79_MACH_WHR_HP_G300N, "WHR-HP-G300N", "Buffalo WHR-HP-G300N",
192 whrhpg300n_setup);
193
194 MIPS_MACHINE(ATH79_MACH_WHR_G301N, "WHR-G301N", "Buffalo WHR-G301N",
195 whrhpg300n_setup);
196
197 MIPS_MACHINE(ATH79_MACH_WHR_HP_GN, "WHR-HP-GN", "Buffalo WHR-HP-GN",
198 whrhpg300n_setup);
This page took 0.046432 seconds and 5 git commands to generate.