3 * Qualcomm Atheros AP152 reference board support
5 * Copyright (c) 2015 Qualcomm Atheros
6 * Copyright (c) 2012 Gabor Juhos <juhosg@openwrt.org>
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.
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.
22 #include <linux/platform_device.h>
23 #include <linux/ath9k_platform.h>
24 #include <linux/ar8216_platform.h>
25 #include <asm/mach-ath79/ar71xx_regs.h>
28 #include "dev-m25p80.h"
29 #include "machtypes.h"
32 #include "dev-gpio-buttons.h"
33 #include "dev-leds-gpio.h"
38 #define AP152_GPIO_LED_USB0 7
39 #define AP152_GPIO_LED_USB1 8
41 #define AP152_GPIO_BTN_RESET 2
42 #define AP152_GPIO_BTN_WPS 1
43 #define AP152_KEYS_POLL_INTERVAL 20 /* msecs */
44 #define AP152_KEYS_DEBOUNCE_INTERVAL (3 * AP152_KEYS_POLL_INTERVAL)
46 #define AP152_MAC0_OFFSET 0
47 #define AP152_WMAC_CALDATA_OFFSET 0x1000
49 static struct gpio_led ap152_leds_gpio[] __initdata = {
51 .name = "ap152:green:usb0",
52 .gpio = AP152_GPIO_LED_USB0,
56 .name = "ap152:green:usb1",
57 .gpio = AP152_GPIO_LED_USB1,
62 static struct gpio_keys_button ap152_gpio_keys[] __initdata = {
66 .code = KEY_WPS_BUTTON,
67 .debounce_interval = AP152_KEYS_DEBOUNCE_INTERVAL,
68 .gpio = AP152_GPIO_BTN_WPS,
72 .desc = "Reset button",
75 .debounce_interval = AP152_KEYS_DEBOUNCE_INTERVAL,
76 .gpio = AP152_GPIO_BTN_RESET,
81 static struct ar8327_pad_cfg ap152_ar8337_pad0_cfg = {
82 .mode = AR8327_PAD_MAC_SGMII,
83 .sgmii_delay_en = true,
86 static struct ar8327_platform_data ap152_ar8337_data = {
87 .pad0_cfg = &ap152_ar8337_pad0_cfg,
90 .speed = AR8327_PORT_SPEED_1000,
97 static struct mdio_board_info ap152_mdio0_info[] = {
99 .bus_id = "ag71xx-mdio.0",
101 .platform_data = &ap152_ar8337_data,
105 static void __init ap152_setup(void)
107 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
109 ath79_register_m25p80(NULL);
111 ath79_register_leds_gpio(-1, ARRAY_SIZE(ap152_leds_gpio),
113 ath79_register_gpio_keys_polled(-1, AP152_KEYS_POLL_INTERVAL,
114 ARRAY_SIZE(ap152_gpio_keys),
117 ath79_register_usb();
119 platform_device_register(&ath79_mdio0_device);
121 mdiobus_register_board_info(ap152_mdio0_info,
122 ARRAY_SIZE(ap152_mdio0_info));
124 ath79_register_wmac(art + AP152_WMAC_CALDATA_OFFSET, NULL);
125 ath79_register_pci();
127 ath79_init_mac(ath79_eth0_data.mac_addr, art + AP152_MAC0_OFFSET, 0);
129 /* GMAC0 is connected to an AR8337 switch */
130 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
131 ath79_eth0_data.speed = SPEED_1000;
132 ath79_eth0_data.duplex = DUPLEX_FULL;
133 ath79_eth0_data.phy_mask = BIT(0);
134 ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
136 ath79_register_eth(0);
139 MIPS_MACHINE(ATH79_MACH_AP152, "AP152", "Qualcomm Atheros AP152 reference board",