2 * Atheros AP143 reference board support
4 * Copyright (c) 2013-2015 The Linux Foundation. All rights reserved.
5 * Copyright (c) 2012 Gabor Juhos <juhosg@openwrt.org>
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 #include <linux/platform_device.h>
22 #include <linux/ath9k_platform.h>
23 #include <linux/ar8216_platform.h>
25 #include <asm/mach-ath79/ar71xx_regs.h>
29 #include "dev-gpio-buttons.h"
30 #include "dev-leds-gpio.h"
31 #include "dev-m25p80.h"
35 #include "machtypes.h"
37 #define AP143_GPIO_LED_WLAN 12
38 #define AP143_GPIO_LED_WPS 13
39 #define AP143_GPIO_LED_STATUS 13
41 #define AP143_GPIO_LED_WAN 4
42 #define AP143_GPIO_LED_LAN1 16
43 #define AP143_GPIO_LED_LAN2 15
44 #define AP143_GPIO_LED_LAN3 14
45 #define AP143_GPIO_LED_LAN4 11
47 #define AP143_GPIO_BTN_WPS 17
49 #define AP143_KEYS_POLL_INTERVAL 20 /* msecs */
50 #define AP143_KEYS_DEBOUNCE_INTERVAL (3 * AP143_KEYS_POLL_INTERVAL)
52 #define AP143_MAC0_OFFSET 0
53 #define AP143_MAC1_OFFSET 6
54 #define AP143_WMAC_CALDATA_OFFSET 0x1000
56 static struct gpio_led ap143_leds_gpio[] __initdata = {
58 .name = "ap143:green:status",
59 .gpio = AP143_GPIO_LED_STATUS,
63 .name = "ap143:green:wlan",
64 .gpio = AP143_GPIO_LED_WLAN,
69 static struct gpio_keys_button ap143_gpio_keys[] __initdata = {
73 .code = KEY_WPS_BUTTON,
74 .debounce_interval = AP143_KEYS_DEBOUNCE_INTERVAL,
75 .gpio = AP143_GPIO_BTN_WPS,
80 static void __init ap143_gpio_led_setup(void)
82 ath79_gpio_direction_select(AP143_GPIO_LED_WAN, true);
83 ath79_gpio_direction_select(AP143_GPIO_LED_LAN1, true);
84 ath79_gpio_direction_select(AP143_GPIO_LED_LAN2, true);
85 ath79_gpio_direction_select(AP143_GPIO_LED_LAN3, true);
86 ath79_gpio_direction_select(AP143_GPIO_LED_LAN4, true);
88 ath79_gpio_output_select(AP143_GPIO_LED_WAN,
89 QCA953X_GPIO_OUT_MUX_LED_LINK5);
90 ath79_gpio_output_select(AP143_GPIO_LED_LAN1,
91 QCA953X_GPIO_OUT_MUX_LED_LINK1);
92 ath79_gpio_output_select(AP143_GPIO_LED_LAN2,
93 QCA953X_GPIO_OUT_MUX_LED_LINK2);
94 ath79_gpio_output_select(AP143_GPIO_LED_LAN3,
95 QCA953X_GPIO_OUT_MUX_LED_LINK3);
96 ath79_gpio_output_select(AP143_GPIO_LED_LAN4,
97 QCA953X_GPIO_OUT_MUX_LED_LINK4);
99 ath79_register_leds_gpio(-1, ARRAY_SIZE(ap143_leds_gpio),
101 ath79_register_gpio_keys_polled(-1, AP143_KEYS_POLL_INTERVAL,
102 ARRAY_SIZE(ap143_gpio_keys),
106 static void __init ap143_setup(void)
108 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
110 ath79_register_m25p80(NULL);
112 ap143_gpio_led_setup();
114 ath79_register_usb();
116 ath79_wmac_set_led_pin(AP143_GPIO_LED_WLAN);
117 ath79_register_wmac(art + AP143_WMAC_CALDATA_OFFSET, NULL);
119 ath79_register_mdio(0, 0x0);
120 ath79_register_mdio(1, 0x0);
122 ath79_init_mac(ath79_eth0_data.mac_addr, art + AP143_MAC0_OFFSET, 0);
123 ath79_init_mac(ath79_eth1_data.mac_addr, art + AP143_MAC1_OFFSET, 0);
126 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
127 ath79_eth0_data.speed = SPEED_100;
128 ath79_eth0_data.duplex = DUPLEX_FULL;
129 ath79_eth0_data.phy_mask = BIT(4);
130 ath79_register_eth(0);
133 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
134 ath79_eth1_data.speed = SPEED_1000;
135 ath79_eth1_data.duplex = DUPLEX_FULL;
136 ath79_switch_data.phy_poll_mask |= BIT(4);
137 ath79_switch_data.phy4_mii_en = 1;
138 ath79_register_eth(1);
141 MIPS_MACHINE(ATH79_MACH_AP143, "AP143", "Qualcomm Atheros AP143 reference board",