OpenWrt – Blame information for rev 4
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
4 | office | 1 | /* |
2 | * Buffalo WZR-HP-AG300H board support |
||
3 | * |
||
4 | * Copyright (C) 2011 Felix Fietkau <nbd@nbd.name> |
||
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/gpio.h> |
||
12 | #include <linux/mtd/mtd.h> |
||
13 | #include <linux/mtd/partitions.h> |
||
14 | |||
15 | #include <asm/mach-ath79/ath79.h> |
||
16 | |||
17 | #include "dev-eth.h" |
||
18 | #include "dev-ap9x-pci.h" |
||
19 | #include "dev-gpio-buttons.h" |
||
20 | #include "dev-leds-gpio.h" |
||
21 | #include "dev-m25p80.h" |
||
22 | #include "dev-usb.h" |
||
23 | #include "machtypes.h" |
||
24 | |||
25 | #define WZRHPAG300H_MAC_OFFSET 0x20c |
||
26 | #define WZRHPAG300H_KEYS_POLL_INTERVAL 20 /* msecs */ |
||
27 | #define WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL (3 * WZRHPAG300H_KEYS_POLL_INTERVAL) |
||
28 | |||
29 | static struct mtd_partition wzrhpag300h_flash_partitions[] = { |
||
30 | { |
||
31 | .name = "u-boot", |
||
32 | .offset = 0, |
||
33 | .size = 0x0040000, |
||
34 | .mask_flags = MTD_WRITEABLE, |
||
35 | }, { |
||
36 | .name = "u-boot-env", |
||
37 | .offset = 0x0040000, |
||
38 | .size = 0x0010000, |
||
39 | .mask_flags = MTD_WRITEABLE, |
||
40 | }, { |
||
41 | .name = "art", |
||
42 | .offset = 0x0050000, |
||
43 | .size = 0x0010000, |
||
44 | .mask_flags = MTD_WRITEABLE, |
||
45 | }, { |
||
46 | .name = "firmware", |
||
47 | .offset = 0x0060000, |
||
48 | .size = 0x1f90000, |
||
49 | }, { |
||
50 | .name = "user_property", |
||
51 | .offset = 0x1ff0000, |
||
52 | .size = 0x0010000, |
||
53 | .mask_flags = MTD_WRITEABLE, |
||
54 | } |
||
55 | }; |
||
56 | |||
57 | static struct flash_platform_data wzrhpag300h_flash_data = { |
||
58 | .parts = wzrhpag300h_flash_partitions, |
||
59 | .nr_parts = ARRAY_SIZE(wzrhpag300h_flash_partitions), |
||
60 | }; |
||
61 | |||
62 | static struct gpio_led wzrhpag300h_leds_gpio[] __initdata = { |
||
63 | { |
||
64 | .name = "buffalo:red:diag", |
||
65 | .gpio = 1, |
||
66 | .active_low = 1, |
||
67 | }, |
||
68 | }; |
||
69 | |||
70 | static struct gpio_led wzrhpag300h_wmac0_leds_gpio[] = { |
||
71 | { |
||
72 | .name = "buffalo:amber:band2g", |
||
73 | .gpio = 1, |
||
74 | .active_low = 1, |
||
75 | }, |
||
76 | { |
||
77 | .name = "buffalo:green:usb", |
||
78 | .gpio = 3, |
||
79 | .active_low = 1, |
||
80 | }, |
||
81 | { |
||
82 | .name = "buffalo:green:band2g", |
||
83 | .gpio = 5, |
||
84 | .active_low = 1, |
||
85 | }, |
||
86 | }; |
||
87 | |||
88 | static struct gpio_led wzrhpag300h_wmac1_leds_gpio[] = { |
||
89 | { |
||
90 | .name = "buffalo:green:band5g", |
||
91 | .gpio = 1, |
||
92 | .active_low = 1, |
||
93 | }, |
||
94 | { |
||
95 | .name = "buffalo:green:router", |
||
96 | .gpio = 3, |
||
97 | .active_low = 1, |
||
98 | }, |
||
99 | { |
||
100 | .name = "buffalo:blue:movie_engine", |
||
101 | .gpio = 4, |
||
102 | .active_low = 1, |
||
103 | }, |
||
104 | { |
||
105 | .name = "buffalo:amber:band5g", |
||
106 | .gpio = 5, |
||
107 | .active_low = 1, |
||
108 | }, |
||
109 | }; |
||
110 | |||
111 | static struct gpio_keys_button wzrhpag300h_gpio_keys[] __initdata = { |
||
112 | { |
||
113 | .desc = "reset", |
||
114 | .type = EV_KEY, |
||
115 | .code = KEY_RESTART, |
||
116 | .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL, |
||
117 | .gpio = 11, |
||
118 | .active_low = 1, |
||
119 | }, { |
||
120 | .desc = "usb", |
||
121 | .type = EV_KEY, |
||
122 | .code = BTN_2, |
||
123 | .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL, |
||
124 | .gpio = 3, |
||
125 | .active_low = 1, |
||
126 | }, { |
||
127 | .desc = "aoss", |
||
128 | .type = EV_KEY, |
||
129 | .code = KEY_WPS_BUTTON, |
||
130 | .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL, |
||
131 | .gpio = 5, |
||
132 | .active_low = 1, |
||
133 | }, { |
||
134 | .desc = "router_auto", |
||
135 | .type = EV_SW, |
||
136 | .code = BTN_6, |
||
137 | .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL, |
||
138 | .gpio = 6, |
||
139 | .active_low = 1, |
||
140 | }, { |
||
141 | .desc = "router_off", |
||
142 | .type = EV_SW, |
||
143 | .code = BTN_5, |
||
144 | .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL, |
||
145 | .gpio = 7, |
||
146 | .active_low = 1, |
||
147 | }, { |
||
148 | .desc = "movie_engine", |
||
149 | .type = EV_SW, |
||
150 | .code = BTN_7, |
||
151 | .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL, |
||
152 | .gpio = 8, |
||
153 | .active_low = 1, |
||
154 | } |
||
155 | }; |
||
156 | |||
157 | static void __init wzrhpag300h_setup(void) |
||
158 | { |
||
159 | u8 *eeprom1 = (u8 *) KSEG1ADDR(0x1f051000); |
||
160 | u8 *eeprom2 = (u8 *) KSEG1ADDR(0x1f055000); |
||
161 | u8 *mac1 = eeprom1 + WZRHPAG300H_MAC_OFFSET; |
||
162 | u8 *mac2 = eeprom2 + WZRHPAG300H_MAC_OFFSET; |
||
163 | |||
164 | ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0); |
||
165 | ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 1); |
||
166 | |||
167 | ath79_register_mdio(0, ~(BIT(0) | BIT(4))); |
||
168 | |||
169 | ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII; |
||
170 | ath79_eth0_data.speed = SPEED_1000; |
||
171 | ath79_eth0_data.duplex = DUPLEX_FULL; |
||
172 | ath79_eth0_data.phy_mask = BIT(0); |
||
173 | |||
174 | ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII; |
||
175 | ath79_eth1_data.phy_mask = BIT(4); |
||
176 | |||
177 | ath79_register_eth(0); |
||
178 | ath79_register_eth(1); |
||
179 | |||
180 | gpio_request_one(2, GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED, |
||
181 | "USB power"); |
||
182 | ath79_register_usb(); |
||
183 | |||
184 | ath79_register_leds_gpio(-1, ARRAY_SIZE(wzrhpag300h_leds_gpio), |
||
185 | wzrhpag300h_leds_gpio); |
||
186 | |||
187 | ath79_register_gpio_keys_polled(-1, WZRHPAG300H_KEYS_POLL_INTERVAL, |
||
188 | ARRAY_SIZE(wzrhpag300h_gpio_keys), |
||
189 | wzrhpag300h_gpio_keys); |
||
190 | |||
191 | ath79_register_m25p80_multi(&wzrhpag300h_flash_data); |
||
192 | |||
193 | ap94_pci_init(eeprom1, mac1, eeprom2, mac2); |
||
194 | |||
195 | ap9x_pci_setup_wmac_leds(0, wzrhpag300h_wmac0_leds_gpio, |
||
196 | ARRAY_SIZE(wzrhpag300h_wmac0_leds_gpio)); |
||
197 | ap9x_pci_setup_wmac_leds(1, wzrhpag300h_wmac1_leds_gpio, |
||
198 | ARRAY_SIZE(wzrhpag300h_wmac1_leds_gpio)); |
||
199 | } |
||
200 | |||
201 | MIPS_MACHINE(ATH79_MACH_WZR_HP_AG300H, "WZR-HP-AG300H", |
||
202 | "Buffalo WZR-HP-AG300H/WZR-600DHP", wzrhpag300h_setup); |