ad1a0338b9739cae617dcd106a1abaf5afea6b2f
[openwrt.git] / target / linux / ar71xx / files / arch / mips / ar71xx / mach-wzr-hp-g300nh2.c
1 /*
2 * Buffalo WZR-HP-G300NH2 board support
3 *
4 * Copyright (C) 2011 Felix Fietkau <nbd@openwrt.org>
5 * Copyright (C) 2011 Mark Deneen <mdeneen@gmail.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published
9 * by the Free Software Foundation.
10 */
11
12 #include <linux/platform_device.h>
13 #include <linux/mtd/mtd.h>
14 #include <linux/mtd/partitions.h>
15
16 #include <asm/mips_machine.h>
17 #include <asm/mach-ar71xx/ar71xx.h>
18 #include <asm/mach-ar71xx/gpio.h>
19
20 #include "machtype.h"
21 #include "devices.h"
22 #include "dev-ap91-pci.h"
23 #include "dev-gpio-buttons.h"
24 #include "dev-leds-gpio.h"
25 #include "dev-m25p80.h"
26 #include "dev-usb.h"
27
28
29 #define WZRHPG300NH2_MAC_OFFSET 0x20c
30 #define WZRHPG300NH2_KEYS_POLL_INTERVAL 20 /* msecs */
31 #define WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL (3 * WZRHPG300NH2_KEYS_POLL_INTERVAL)
32
33 #ifdef CONFIG_MTD_PARTITIONS
34 static struct mtd_partition wzrhpg300nh2_flash_partitions[] = {
35 {
36 .name = "u-boot",
37 .offset = 0,
38 .size = 0x0040000,
39 .mask_flags = MTD_WRITEABLE,
40 }, {
41 .name = "u-boot-env",
42 .offset = 0x0040000,
43 .size = 0x0010000,
44 .mask_flags = MTD_WRITEABLE,
45 }, {
46 .name = "art",
47 .offset = 0x0050000,
48 .size = 0x0010000,
49 .mask_flags = MTD_WRITEABLE,
50 }, {
51 .name = "kernel",
52 .offset = 0x0060000,
53 .size = 0x0100000,
54 }, {
55 .name = "rootfs",
56 .offset = 0x0160000,
57 .size = 0x1e90000,
58 }, {
59 .name = "user_property",
60 .offset = 0x1ff0000,
61 .size = 0x0010000,
62 .mask_flags = MTD_WRITEABLE,
63 }, {
64 .name = "firmware",
65 .offset = 0x0060000,
66 .size = 0x1f90000,
67 }
68 };
69
70 #endif /* CONFIG_MTD_PARTITIONS */
71
72
73
74 static struct flash_platform_data wzrhpg300nh2_flash_data = {
75 #ifdef CONFIG_MTD_PARTITIONS
76 .parts = wzrhpg300nh2_flash_partitions,
77 .nr_parts = ARRAY_SIZE(wzrhpg300nh2_flash_partitions),
78 #endif
79 };
80
81
82 static struct gpio_led wzrhpg300nh2_leds_gpio[] __initdata = {
83 {
84 .name = "buffalo:red:diag",
85 .gpio = 16,
86 .active_low = 1,
87 },
88 };
89
90 static struct gpio_led wzrhpg300nh2_wmac_leds_gpio[] = {
91 {
92 .name = "buffalo:blue:usb",
93 .gpio = 4,
94 .active_low = 1,
95 },
96 {
97 .name = "buffalo:orange:security",
98 .gpio = 6,
99 .active_low = 1,
100 },
101 {
102 .name = "buffalo:green:router",
103 .gpio = 7,
104 .active_low = 1,
105 },
106 {
107 .name = "buffalo:blue:movie_engine_on",
108 .gpio = 8,
109 .active_low = 1,
110 },
111 {
112 .name = "buffalo:blue:movie_engine_off",
113 .gpio = 9,
114 .active_low = 1,
115 },
116 };
117
118 /* The AOSS button is wmac gpio 12 */
119 static struct gpio_keys_button wzrhpg300nh2_gpio_keys[] __initdata = {
120 {
121 .desc = "reset",
122 .type = EV_KEY,
123 .code = KEY_RESTART,
124 .debounce_interval = WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL,
125 .gpio = 1,
126 .active_low = 1,
127 }, {
128 .desc = "usb",
129 .type = EV_KEY,
130 .code = BTN_2,
131 .debounce_interval = WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL,
132 .gpio = 7,
133 .active_low = 1,
134 }, {
135 .desc = "qos",
136 .type = EV_KEY,
137 .code = BTN_3,
138 .debounce_interval = WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL,
139 .gpio = 11,
140 .active_low = 0,
141 }, {
142 .desc = "router_on",
143 .type = EV_KEY,
144 .code = BTN_5,
145 .debounce_interval = WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL,
146 .gpio = 8,
147 .active_low = 0,
148 },
149 };
150
151
152 static void __init wzrhpg300nh2_setup(void)
153 {
154
155 u8 *eeprom = (u8 *) KSEG1ADDR(0x1f051000);
156 u8 *mac0 = eeprom + WZRHPG300NH2_MAC_OFFSET;
157 /* There is an eth1 but it is not connected to the switch */
158
159 ar71xx_add_device_m25p80_multi(&wzrhpg300nh2_flash_data);
160
161 ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac0, 0);
162 ar71xx_add_device_mdio(0, ~(BIT(0)));
163
164 ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac0, 0);
165 ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
166 ar71xx_eth0_data.speed = SPEED_1000;
167 ar71xx_eth0_data.duplex = DUPLEX_FULL;
168 ar71xx_eth0_data.phy_mask = BIT(0);
169
170 ar71xx_add_device_eth(0);
171 ar71xx_add_device_usb();
172 /* gpio13 is usb power. Turn it on. */
173 gpio_request(13, "usb");
174 gpio_direction_output(13, 1);
175
176 ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(wzrhpg300nh2_leds_gpio),
177 wzrhpg300nh2_leds_gpio);
178 ar71xx_register_gpio_keys_polled(-1, WZRHPG300NH2_KEYS_POLL_INTERVAL,
179 ARRAY_SIZE(wzrhpg300nh2_gpio_keys),
180 wzrhpg300nh2_gpio_keys);
181 ap91_pci_setup_wmac_led_pin(5);
182 ap91_pci_setup_wmac_leds(wzrhpg300nh2_wmac_leds_gpio,
183 ARRAY_SIZE(wzrhpg300nh2_wmac_leds_gpio));
184
185 ap91_pci_init(eeprom, mac0);
186 }
187
188 MIPS_MACHINE(AR71XX_MACH_WZR_HP_G300NH2, "WZR-HP-G300NH2",
189 "Buffalo WZR-HP-G300NH2", wzrhpg300nh2_setup);
190
This page took 0.051531 seconds and 3 git commands to generate.