ar71xx: configure OBS4 line on TL-WR841N-v8/MR3420v2
[openwrt/staging/chunkeey.git] / target / linux / ar71xx / files / 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 <linux/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 = "firmware",
47 .offset = 0x0060000,
48 .size = 0x1f80000,
49 }, {
50 .name = "user_property",
51 .offset = 0x1fe0000,
52 .size = 0x0020000,
53 }
54 };
55
56 static struct flash_platform_data wzrhpg450h_flash_data = {
57 .parts = wzrhpg450h_partitions,
58 .nr_parts = ARRAY_SIZE(wzrhpg450h_partitions),
59 };
60
61 static struct gpio_led wzrhpg450h_leds_gpio[] __initdata = {
62 {
63 .name = "buffalo:red:diag",
64 .gpio = 14,
65 .active_low = 1,
66 },
67 {
68 .name = "buffalo:orange:security",
69 .gpio = 13,
70 .active_low = 1,
71 },
72 };
73
74
75 static struct gpio_led wzrhpg450h_wmac_leds_gpio[] = {
76 {
77 .name = "buffalo:blue:movie_engine",
78 .gpio = 13,
79 .active_low = 1,
80 },
81 {
82 .name = "buffalo:green:router",
83 .gpio = 14,
84 .active_low = 1,
85 },
86 };
87
88 static struct gpio_keys_button wzrhpg450h_gpio_keys[] __initdata = {
89 {
90 .desc = "reset",
91 .type = EV_KEY,
92 .code = KEY_RESTART,
93 .debounce_interval = WZRHPG450H_KEYS_DEBOUNCE_INTERVAL,
94 .gpio = 6,
95 .active_low = 1,
96 }, {
97 .desc = "usb",
98 .type = EV_KEY,
99 .code = BTN_2,
100 .debounce_interval = WZRHPG450H_KEYS_DEBOUNCE_INTERVAL,
101 .gpio = 1,
102 .active_low = 1,
103 }, {
104 .desc = "aoss",
105 .type = EV_KEY,
106 .code = KEY_WPS_BUTTON,
107 .debounce_interval = WZRHPG450H_KEYS_DEBOUNCE_INTERVAL,
108 .gpio = 8,
109 .active_low = 1,
110 }, {
111 .desc = "movie_engine",
112 .type = EV_KEY,
113 .code = BTN_6,
114 .debounce_interval = WZRHPG450H_KEYS_DEBOUNCE_INTERVAL,
115 .gpio = 7,
116 .active_low = 0,
117 }, {
118 .desc = "router_off",
119 .type = EV_KEY,
120 .code = BTN_5,
121 .debounce_interval = WZRHPG450H_KEYS_DEBOUNCE_INTERVAL,
122 .gpio = 12,
123 .active_low = 0,
124 }
125 };
126
127
128 static void __init wzrhpg450h_init(void)
129 {
130 u8 *ee = (u8 *) KSEG1ADDR(0x1f051000);
131 u8 *mac = (u8 *) ee + 2;
132
133 ath79_register_m25p80_multi(&wzrhpg450h_flash_data);
134
135 ath79_register_mdio(0, ~BIT(0));
136 ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
137 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
138 ath79_eth0_data.speed = SPEED_1000;
139 ath79_eth0_data.duplex = DUPLEX_FULL;
140 ath79_eth0_data.phy_mask = BIT(0);
141
142 ath79_register_leds_gpio(-1, ARRAY_SIZE(wzrhpg450h_leds_gpio),
143 wzrhpg450h_leds_gpio);
144
145 ath79_register_gpio_keys_polled(-1, WZRHPG450H_KEYS_POLL_INTERVAL,
146 ARRAY_SIZE(wzrhpg450h_gpio_keys),
147 wzrhpg450h_gpio_keys);
148
149 ath79_register_eth(0);
150
151 gpio_request_one(16, GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
152 "USB power");
153 ath79_register_usb();
154
155 ap91_pci_init(ee, NULL);
156 ap9x_pci_setup_wmac_led_pin(0, 15);
157 ap9x_pci_setup_wmac_leds(0, wzrhpg450h_wmac_leds_gpio,
158 ARRAY_SIZE(wzrhpg450h_wmac_leds_gpio));
159 }
160
161 MIPS_MACHINE(ATH79_MACH_WZR_HP_G450H, "WZR-HP-G450H", "Buffalo WZR-HP-G450H",
162 wzrhpg450h_init);