ar71xx: Add support for D-Link DAP-1330 a1
[openwrt/openwrt.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-wnr2000.c
1 /*
2 * NETGEAR WNR2000 board support
3 *
4 * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
6 * Copyright (C) 2008-2009 Andy Boyett <agb@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/mtd/mtd.h>
14 #include <linux/mtd/partitions.h>
15
16 #include <asm/mach-ath79/ath79.h>
17
18 #include "dev-eth.h"
19 #include "dev-gpio-buttons.h"
20 #include "dev-leds-gpio.h"
21 #include "dev-m25p80.h"
22 #include "dev-wmac.h"
23 #include "machtypes.h"
24
25 #define WNR2000_GPIO_LED_PWR_GREEN 14
26 #define WNR2000_GPIO_LED_PWR_AMBER 7
27 #define WNR2000_GPIO_LED_WPS 4
28 #define WNR2000_GPIO_LED_WLAN 6
29 #define WNR2000_GPIO_BTN_RESET 21
30 #define WNR2000_GPIO_BTN_WPS 8
31
32 #define WNR2000_KEYS_POLL_INTERVAL 20 /* msecs */
33 #define WNR2000_KEYS_DEBOUNCE_INTERVAL (3 * WNR2000_KEYS_POLL_INTERVAL)
34
35 static struct gpio_led wnr2000_leds_gpio[] __initdata = {
36 {
37 .name = "netgear:green:power",
38 .gpio = WNR2000_GPIO_LED_PWR_GREEN,
39 .active_low = 1,
40 }, {
41 .name = "netgear:amber:power",
42 .gpio = WNR2000_GPIO_LED_PWR_AMBER,
43 .active_low = 1,
44 }, {
45 .name = "netgear:green:wps",
46 .gpio = WNR2000_GPIO_LED_WPS,
47 .active_low = 1,
48 }, {
49 .name = "netgear:blue:wlan",
50 .gpio = WNR2000_GPIO_LED_WLAN,
51 .active_low = 1,
52 }
53 };
54
55 static struct gpio_keys_button wnr2000_gpio_keys[] __initdata = {
56 {
57 .desc = "reset",
58 .type = EV_KEY,
59 .code = KEY_RESTART,
60 .debounce_interval = WNR2000_KEYS_DEBOUNCE_INTERVAL,
61 .gpio = WNR2000_GPIO_BTN_RESET,
62 }, {
63 .desc = "wps",
64 .type = EV_KEY,
65 .code = KEY_WPS_BUTTON,
66 .debounce_interval = WNR2000_KEYS_DEBOUNCE_INTERVAL,
67 .gpio = WNR2000_GPIO_BTN_WPS,
68 }
69 };
70
71 static void __init wnr2000_setup(void)
72 {
73 u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
74
75 ath79_register_mdio(0, 0x0);
76
77 ath79_init_mac(ath79_eth0_data.mac_addr, eeprom, 0);
78 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
79 ath79_eth0_data.speed = SPEED_100;
80 ath79_eth0_data.duplex = DUPLEX_FULL;
81 ath79_eth0_data.has_ar8216 = 1;
82
83 ath79_init_mac(ath79_eth1_data.mac_addr, eeprom, 1);
84 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
85 ath79_eth1_data.phy_mask = 0x10;
86
87 ath79_register_eth(0);
88 ath79_register_eth(1);
89
90 ath79_register_m25p80(NULL);
91
92 ath79_register_leds_gpio(-1, ARRAY_SIZE(wnr2000_leds_gpio),
93 wnr2000_leds_gpio);
94
95 ath79_register_gpio_keys_polled(-1, WNR2000_KEYS_POLL_INTERVAL,
96 ARRAY_SIZE(wnr2000_gpio_keys),
97 wnr2000_gpio_keys);
98
99 ath79_register_wmac(eeprom, NULL);
100 }
101
102 MIPS_MACHINE(ATH79_MACH_WNR2000, "WNR2000", "NETGEAR WNR2000", wnr2000_setup);