Root/target/linux/ar71xx/files/arch/mips/ath79/mach-wzr-hp-ag300h.c

1/*
2 * Buffalo WZR-HP-AG300H board support
3 *
4 * Copyright (C) 2011 Felix Fietkau <nbd@openwrt.org>
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
29static 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 = "kernel",
47        .offset = 0x0060000,
48        .size = 0x0100000,
49    }, {
50        .name = "rootfs",
51        .offset = 0x0160000,
52        .size = 0x1e90000,
53    }, {
54        .name = "user_property",
55        .offset = 0x1ff0000,
56        .size = 0x0010000,
57        .mask_flags = MTD_WRITEABLE,
58    }, {
59        .name = "firmware",
60        .offset = 0x0060000,
61        .size = 0x1f90000,
62    }
63};
64
65static struct flash_platform_data wzrhpag300h_flash_data = {
66    .parts = wzrhpag300h_flash_partitions,
67    .nr_parts = ARRAY_SIZE(wzrhpag300h_flash_partitions),
68};
69
70static struct gpio_led wzrhpag300h_leds_gpio[] __initdata = {
71    {
72        .name = "buffalo:red:diag",
73        .gpio = 1,
74        .active_low = 1,
75    },
76};
77
78static struct gpio_led wzrhpag300h_wmac0_leds_gpio[] = {
79        {
80                .name = "buffalo:amber:band2g",
81                .gpio = 1,
82                .active_low = 1,
83    },
84        {
85                .name = "buffalo:green:usb",
86                .gpio = 3,
87                .active_low = 1,
88    },
89        {
90                .name = "buffalo:green:band2g",
91                .gpio = 5,
92                .active_low = 1,
93    },
94};
95
96static struct gpio_led wzrhpag300h_wmac1_leds_gpio[] = {
97        {
98                .name = "buffalo:green:band5g",
99                .gpio = 1,
100                .active_low = 1,
101    },
102        {
103                .name = "buffalo:green:router",
104                .gpio = 3,
105                .active_low = 1,
106    },
107        {
108                .name = "buffalo:blue:movie_engine",
109                .gpio = 4,
110                .active_low = 1,
111    },
112        {
113                .name = "buffalo:amber:band5g",
114                .gpio = 5,
115                .active_low = 1,
116    },
117};
118
119static struct gpio_keys_button wzrhpag300h_gpio_keys[] __initdata = {
120    {
121        .desc = "reset",
122        .type = EV_KEY,
123        .code = KEY_RESTART,
124        .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL,
125        .gpio = 11,
126        .active_low = 1,
127    }, {
128        .desc = "usb",
129        .type = EV_KEY,
130        .code = BTN_2,
131        .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL,
132        .gpio = 3,
133        .active_low = 1,
134    }, {
135        .desc = "aoss",
136        .type = EV_KEY,
137        .code = KEY_WPS_BUTTON,
138        .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL,
139        .gpio = 5,
140        .active_low = 1,
141    }, {
142        .desc = "router_auto",
143        .type = EV_KEY,
144        .code = BTN_6,
145        .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL,
146        .gpio = 6,
147        .active_low = 1,
148    }, {
149        .desc = "router_off",
150        .type = EV_KEY,
151        .code = BTN_5,
152        .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL,
153        .gpio = 7,
154        .active_low = 1,
155    }, {
156        .desc = "movie_engine",
157        .type = EV_KEY,
158        .code = BTN_7,
159        .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL,
160        .gpio = 8,
161        .active_low = 1,
162    }
163};
164
165static void __init wzrhpag300h_setup(void)
166{
167    u8 *eeprom1 = (u8 *) KSEG1ADDR(0x1f051000);
168    u8 *eeprom2 = (u8 *) KSEG1ADDR(0x1f055000);
169    u8 *mac1 = eeprom1 + WZRHPAG300H_MAC_OFFSET;
170    u8 *mac2 = eeprom2 + WZRHPAG300H_MAC_OFFSET;
171
172    ath79_init_mac(ath79_eth0_data.mac_addr, mac1, 0);
173    ath79_init_mac(ath79_eth1_data.mac_addr, mac2, 1);
174
175    ath79_register_mdio(0, ~(BIT(0) | BIT(4)));
176
177    ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
178    ath79_eth0_data.speed = SPEED_1000;
179    ath79_eth0_data.duplex = DUPLEX_FULL;
180    ath79_eth0_data.phy_mask = BIT(0);
181
182    ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
183    ath79_eth1_data.phy_mask = BIT(4);
184
185    ath79_register_eth(0);
186    ath79_register_eth(1);
187
188    gpio_request_one(2, GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
189             "USB power");
190    ath79_register_usb();
191
192    ath79_register_leds_gpio(-1, ARRAY_SIZE(wzrhpag300h_leds_gpio),
193                    wzrhpag300h_leds_gpio);
194
195    ath79_register_gpio_keys_polled(-1, WZRHPAG300H_KEYS_POLL_INTERVAL,
196                     ARRAY_SIZE(wzrhpag300h_gpio_keys),
197                     wzrhpag300h_gpio_keys);
198
199    ath79_register_m25p80_multi(&wzrhpag300h_flash_data);
200
201    ap94_pci_init(eeprom1, mac1, eeprom2, mac2);
202
203    ap9x_pci_setup_wmac_led_pin(0, 1);
204    ap9x_pci_setup_wmac_led_pin(1, 5);
205
206    ap9x_pci_setup_wmac_leds(0, wzrhpag300h_wmac0_leds_gpio,
207                ARRAY_SIZE(wzrhpag300h_wmac0_leds_gpio));
208    ap9x_pci_setup_wmac_leds(1, wzrhpag300h_wmac1_leds_gpio,
209                ARRAY_SIZE(wzrhpag300h_wmac1_leds_gpio));
210}
211
212MIPS_MACHINE(ATH79_MACH_WZR_HP_AG300H, "WZR-HP-AG300H",
213         "Buffalo WZR-HP-AG300H", wzrhpag300h_setup);
214
215

Archive Download this file



interactive