ar71xx: nuke 2.6.39 support
[openwrt/openwrt.git] / target / linux / ar71xx / files-3.2 / arch / mips / ath79 / mach-wzr-hp-g450h.c
1 /*
2 * Buffalo WZR-HP-G450G board support
3 *
4 * Copyright (C) 2011 Felix Fietkau <nbd@openwrt.org>
5 * Copyright (C) 2008-2012 Gabor Juhos <juhosg@openwrt.org>
6 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 2 as published
10 * by the Free Software Foundation.
11 */
12
13 #include <asm/mach-ath79/gpio.h>
14 #include <linux/mtd/mtd.h>
15 #include <linux/mtd/partitions.h>
16
17 #include <asm/mach-ath79/ath79.h>
18
19 #include "dev-eth.h"
20 #include "dev-m25p80.h"
21 #include "dev-ap9x-pci.h"
22 #include "dev-gpio-buttons.h"
23 #include "dev-leds-gpio.h"
24 #include "dev-usb.h"
25 #include "machtypes.h"
26
27 #define WZRHPG450H_KEYS_POLL_INTERVAL 20 /* msecs */
28 #define WZRHPG450H_KEYS_DEBOUNCE_INTERVAL (3 * WZRHPG450H_KEYS_POLL_INTERVAL)
29
30 static struct mtd_partition wzrhpg450h_partitions[] = {
31 {
32 .name = "u-boot",
33 .offset = 0,
34 .size = 0x0040000,
35 .mask_flags = MTD_WRITEABLE,
36 }, {
37 .name = "u-boot-env",
38 .offset = 0x0040000,
39 .size = 0x0010000,
40 }, {
41 .name = "ART",
42 .offset = 0x0050000,
43 .size = 0x0010000,
44 .mask_flags = MTD_WRITEABLE,
45 }, {
46 .name = "uImage",
47 .offset = 0x0060000,
48 .size = 0x0100000,
49 }, {
50 .name = "rootfs",
51 .offset = 0x0160000,
52 .size = 0x1e80000,
53 }, {
54 .name = "user_property",
55 .offset = 0x1fe0000,
56 .size = 0x0020000,
57 }, {
58 .name = "firmware",
59 .offset = 0x0060000,
60 .size = 0x1f80000,
61 }
62 };
63
64 static struct flash_platform_data wzrhpg450h_flash_data = {
65 .parts = wzrhpg450h_partitions,
66 .nr_parts = ARRAY_SIZE(wzrhpg450h_partitions),
67 };
68
69 static struct gpio_led wzrhpg450h_leds_gpio[] __initdata = {
70 {
71 .name = "buffalo:red:diag",
72 .gpio = 14,
73 .active_low = 1,
74 },
75 {
76 .name = "buffalo:orange:security",
77 .gpio = 13,
78 .active_low = 1,
79 },
80 };
81
82
83 static struct gpio_led wzrhpg450h_wmac_leds_gpio[] = {
84 {
85 .name = "buffalo:blue:movie_engine",
86 .gpio = 13,
87 .active_low = 1,
88 },
89 {
90 .name = "buffalo:green:router",
91 .gpio = 14,
92 .active_low = 1,
93 },
94 };
95
96 static struct gpio_keys_button wzrhpg450h_gpio_keys[] __initdata = {
97 {
98 .desc = "reset",
99 .type = EV_KEY,
100 .code = KEY_RESTART,
101 .debounce_interval = WZRHPG450H_KEYS_DEBOUNCE_INTERVAL,
102 .gpio = 6,
103 .active_low = 1,
104 }, {
105 .desc = "usb",
106 .type = EV_KEY,
107 .code = BTN_2,
108 .debounce_interval = WZRHPG450H_KEYS_DEBOUNCE_INTERVAL,
109 .gpio = 1,
110 .active_low = 1,
111 }, {
112 .desc = "aoss",
113 .type = EV_KEY,
114 .code = KEY_WPS_BUTTON,
115 .debounce_interval = WZRHPG450H_KEYS_DEBOUNCE_INTERVAL,
116 .gpio = 8,
117 .active_low = 1,
118 }, {
119 .desc = "movie_engine",
120 .type = EV_KEY,
121 .code = BTN_6,
122 .debounce_interval = WZRHPG450H_KEYS_DEBOUNCE_INTERVAL,
123 .gpio = 7,
124 .active_low = 0,
125 }, {
126 .desc = "router_off",
127 .type = EV_KEY,
128 .code = BTN_5,
129 .debounce_interval = WZRHPG450H_KEYS_DEBOUNCE_INTERVAL,
130 .gpio = 12,
131 .active_low = 0,
132 }
133 };
134
135
136 static void __init wzrhpg450h_init(void)
137 {
138 u8 *ee = (u8 *) KSEG1ADDR(0x1f051000);
139 u8 *mac = (u8 *) ee + 2;
140
141 ath79_register_m25p80_multi(&wzrhpg450h_flash_data);
142
143 ath79_register_mdio(0, ~BIT(0));
144 ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
145 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
146 ath79_eth0_data.speed = SPEED_1000;
147 ath79_eth0_data.duplex = DUPLEX_FULL;
148 ath79_eth0_data.phy_mask = BIT(0);
149
150 ath79_register_leds_gpio(-1, ARRAY_SIZE(wzrhpg450h_leds_gpio),
151 wzrhpg450h_leds_gpio);
152
153 ath79_register_gpio_keys_polled(-1, WZRHPG450H_KEYS_POLL_INTERVAL,
154 ARRAY_SIZE(wzrhpg450h_gpio_keys),
155 wzrhpg450h_gpio_keys);
156
157 ath79_register_eth(0);
158
159 ath79_register_usb();
160 gpio_request(16, "usb");
161 gpio_direction_output(16, 1);
162
163 ap91_pci_init(ee, NULL);
164 ap9x_pci_setup_wmac_led_pin(0, 15);
165 ap9x_pci_setup_wmac_leds(0, wzrhpg450h_wmac_leds_gpio,
166 ARRAY_SIZE(wzrhpg450h_wmac_leds_gpio));
167 }
168
169 MIPS_MACHINE(ATH79_MACH_WZR_HP_G450H, "WZR-HP-G450H", "Buffalo WZR-HP-G450H",
170 wzrhpg450h_init);