4ff19e884191af6c1a663bd7cf493f36d2d21936
[openwrt/openwrt.git] / target / linux / ar71xx / files-3.2 / arch / mips / ath79 / mach-mzk-w300nh.c
1 /*
2 * Planex MZK-W300NH board support
3 *
4 * Copyright (C) 2008-2012 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
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 <asm/mach-ath79/ath79.h>
13
14 #include "dev-eth.h"
15 #include "dev-gpio-buttons.h"
16 #include "dev-leds-gpio.h"
17 #include "dev-m25p80.h"
18 #include "dev-wmac.h"
19 #include "machtypes.h"
20
21 #define MZK_W300NH_GPIO_LED_STATUS 1
22 #define MZK_W300NH_GPIO_LED_WPS 3
23 #define MZK_W300NH_GPIO_LED_WLAN 6
24 #define MZK_W300NH_GPIO_LED_AP 15
25 #define MZK_W300NH_GPIO_LED_ROUTER 16
26
27 #define MZK_W300NH_GPIO_BTN_APROUTER 5
28 #define MZK_W300NH_GPIO_BTN_WPS 12
29 #define MZK_W300NH_GPIO_BTN_RESET 21
30
31 #define MZK_W300NH_KEYS_POLL_INTERVAL 20 /* msecs */
32 #define MZK_W300NH_KEYS_DEBOUNCE_INTERVAL (3 * MZK_W300NH_KEYS_POLL_INTERVAL)
33
34 static struct gpio_led mzk_w300nh_leds_gpio[] __initdata = {
35 {
36 .name = "planex:green:status",
37 .gpio = MZK_W300NH_GPIO_LED_STATUS,
38 .active_low = 1,
39 }, {
40 .name = "planex:blue:wps",
41 .gpio = MZK_W300NH_GPIO_LED_WPS,
42 .active_low = 1,
43 }, {
44 .name = "planex:green:wlan",
45 .gpio = MZK_W300NH_GPIO_LED_WLAN,
46 .active_low = 1,
47 }, {
48 .name = "planex:green:ap",
49 .gpio = MZK_W300NH_GPIO_LED_AP,
50 .active_low = 1,
51 }, {
52 .name = "planex:green:router",
53 .gpio = MZK_W300NH_GPIO_LED_ROUTER,
54 .active_low = 1,
55 }
56 };
57
58 static struct gpio_keys_button mzk_w300nh_gpio_keys[] __initdata = {
59 {
60 .desc = "reset",
61 .type = EV_KEY,
62 .code = KEY_RESTART,
63 .debounce_interval = MZK_W300NH_KEYS_DEBOUNCE_INTERVAL,
64 .gpio = MZK_W300NH_GPIO_BTN_RESET,
65 .active_low = 1,
66 }, {
67 .desc = "wps",
68 .type = EV_KEY,
69 .code = KEY_WPS_BUTTON,
70 .debounce_interval = MZK_W300NH_KEYS_DEBOUNCE_INTERVAL,
71 .gpio = MZK_W300NH_GPIO_BTN_WPS,
72 .active_low = 1,
73 }, {
74 .desc = "aprouter",
75 .type = EV_KEY,
76 .code = BTN_2,
77 .debounce_interval = MZK_W300NH_KEYS_DEBOUNCE_INTERVAL,
78 .gpio = MZK_W300NH_GPIO_BTN_APROUTER,
79 .active_low = 0,
80 }
81 };
82
83 #define MZK_W300NH_WAN_PHYMASK BIT(4)
84 #define MZK_W300NH_MDIO_MASK (~MZK_W300NH_WAN_PHYMASK)
85
86 static void __init mzk_w300nh_setup(void)
87 {
88 u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
89
90 ath79_register_mdio(0, MZK_W300NH_MDIO_MASK);
91
92 ath79_init_mac(ath79_eth0_data.mac_addr, eeprom, 0);
93 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
94 ath79_eth0_data.speed = SPEED_100;
95 ath79_eth0_data.duplex = DUPLEX_FULL;
96 ath79_eth0_data.has_ar8216 = 1;
97
98 ath79_init_mac(ath79_eth1_data.mac_addr, eeprom, 1);
99 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
100 ath79_eth1_data.phy_mask = MZK_W300NH_WAN_PHYMASK;
101
102 ath79_register_eth(0);
103 ath79_register_eth(1);
104
105 ath79_register_m25p80(NULL);
106
107 ath79_register_leds_gpio(-1, ARRAY_SIZE(mzk_w300nh_leds_gpio),
108 mzk_w300nh_leds_gpio);
109
110 ath79_register_gpio_keys_polled(-1, MZK_W300NH_KEYS_POLL_INTERVAL,
111 ARRAY_SIZE(mzk_w300nh_gpio_keys),
112 mzk_w300nh_gpio_keys);
113 ath79_register_wmac(eeprom, NULL);
114 }
115
116 MIPS_MACHINE(ATH79_MACH_MZK_W300NH, "MZK-W300NH", "Planex MZK-W300NH",
117 mzk_w300nh_setup);