iproute2: add ip-tiny, ip-full as alternatives of /sbin/ip
[openwrt/staging/yousong.git] / target / linux / ar71xx / files / arch / mips / ath79 / mach-wrtnode2q.c
1 /*
2 * WRTnode2Q board support
3 *
4 * Copyright (c) 2013 The Linux Foundation. All rights reserved.
5 * Copyright (c) 2012 Gabor Juhos <juhosg@openwrt.org>
6 * Copyright (c) 2015 Kelei <xzmu@wrtnode.com>
7 *
8 * Permission to use, copy, modify, and/or distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 *
20 */
21
22 #include <linux/platform_device.h>
23 #include <linux/ath9k_platform.h>
24 #include <linux/ar8216_platform.h>
25
26 #include <asm/mach-ath79/ar71xx_regs.h>
27
28 #include "common.h"
29 #include "dev-eth.h"
30 #include "dev-gpio-buttons.h"
31 #include "dev-leds-gpio.h"
32 #include "dev-m25p80.h"
33 #include "dev-spi.h"
34 #include "dev-usb.h"
35 #include "dev-wmac.h"
36 #include "machtypes.h"
37 #include "pci.h"
38
39 #define WRTNODE2Q_GPIO_LED_WLAN 12
40 #define WRTNODE2Q_GPIO_LED_WPS 13
41 #define WRTNODE2Q_GPIO_LED_STATUS 13
42
43 #define WRTNODE2Q_GPIO_LED_WAN 4
44 #define WRTNODE2Q_GPIO_LED_LAN1 16
45 #define WRTNODE2Q_GPIO_LED_LAN2 15
46 #define WRTNODE2Q_GPIO_LED_LAN3 14
47 #define WRTNODE2Q_GPIO_LED_LAN4 11
48
49 #define WRTNODE2Q_GPIO_BTN_WPS 17
50
51 #define WRTNODE2Q_KEYS_POLL_INTERVAL 20 /* msecs */
52 #define WRTNODE2Q_KEYS_DEBOUNCE_INTERVAL (3 * WRTNODE2Q_KEYS_POLL_INTERVAL)
53
54 #define WRTNODE2Q_MAC0_OFFSET 0
55 #define WRTNODE2Q_WMAC_CALDATA_OFFSET 0x1000
56
57 static struct gpio_led wrtnode2q_leds_gpio[] __initdata = {
58 {
59 .name = "wrtnode2q:green:status",
60 .gpio = WRTNODE2Q_GPIO_LED_STATUS,
61 .active_low = 1,
62 },
63 {
64 .name = "wrtnode2q:green:wlan",
65 .gpio = WRTNODE2Q_GPIO_LED_WLAN,
66 .active_low = 1,
67 }
68 };
69
70 static struct gpio_keys_button wrtnode2q_gpio_keys[] __initdata = {
71 {
72 .desc = "WPS button",
73 .type = EV_KEY,
74 .code = KEY_WPS_BUTTON,
75 .debounce_interval = WRTNODE2Q_KEYS_DEBOUNCE_INTERVAL,
76 .gpio = WRTNODE2Q_GPIO_BTN_WPS,
77 .active_low = 1,
78 },
79 };
80
81 static void __init wrtnode2q_gpio_led_setup(void)
82 {
83 ath79_register_leds_gpio(-1, ARRAY_SIZE(wrtnode2q_leds_gpio),
84 wrtnode2q_leds_gpio);
85 ath79_register_gpio_keys_polled(-1, WRTNODE2Q_KEYS_POLL_INTERVAL,
86 ARRAY_SIZE(wrtnode2q_gpio_keys),
87 wrtnode2q_gpio_keys);
88 }
89
90 static void __init wrtnode2q_setup(void)
91 {
92 u8 *art = (u8 *) KSEG1ADDR(0x1f040000);
93
94 ath79_register_m25p80(NULL);
95
96 wrtnode2q_gpio_led_setup();
97
98 ath79_register_pci();
99 ath79_register_usb();
100
101 ath79_register_wmac(art + WRTNODE2Q_WMAC_CALDATA_OFFSET, NULL);
102
103 ath79_register_mdio(0, 0x0);
104 ath79_register_mdio(1, 0x0);
105
106 ath79_init_mac(ath79_eth0_data.mac_addr, art + WRTNODE2Q_MAC0_OFFSET, 0);
107 ath79_init_mac(ath79_eth1_data.mac_addr, art + WRTNODE2Q_MAC0_OFFSET, 1);
108
109 /* LAN ports */
110 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
111 ath79_eth1_data.speed = SPEED_1000;
112 ath79_eth1_data.duplex = DUPLEX_FULL;
113 ath79_switch_data.phy_poll_mask |= BIT(4);
114 ath79_switch_data.phy4_mii_en = 1;
115 ath79_register_eth(1);
116
117 /* WAN port */
118 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
119 ath79_eth0_data.speed = SPEED_100;
120 ath79_eth0_data.duplex = DUPLEX_FULL;
121 ath79_eth0_data.phy_mask = BIT(4);
122 ath79_register_eth(0);
123 }
124
125 MIPS_MACHINE(ATH79_MACH_WRTNODE2Q, "WRTNODE2Q", "WRTnode2Q board",
126 wrtnode2q_setup);