2 * Atheros ARCHER_C7 reference board support
4 * Copyright (c) 2018 Arvid E. Picciani <aep@exys.org>
5 * Copyright (c) 2017 Felix Fietkau <nbd@nbd.name>
6 * Copyright (c) 2014 The Linux Foundation. All rights reserved.
7 * Copyright (c) 2012 Gabor Juhos <juhosg@openwrt.org>
9 * Permission to use, copy, modify, and/or distribute this software for any
10 * purpose with or without fee is hereby granted, provided that the above
11 * copyright notice and this permission notice appear in all copies.
13 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 #include <linux/platform_device.h>
24 #include <linux/ath9k_platform.h>
25 #include <linux/ar8216_platform.h>
26 #include <linux/proc_fs.h>
27 #include <linux/gpio.h>
28 #include <linux/spi/spi_gpio.h>
29 #include <linux/spi/74x164.h>
31 #include <asm/mach-ath79/ar71xx_regs.h>
34 #include "dev-m25p80.h"
35 #include "machtypes.h"
38 #include "dev-gpio-buttons.h"
39 #include "dev-leds-gpio.h"
45 #define ARCHER_C7_GPIO_BTN_RESET 5
46 #define ARCHER_C7_GPIO_BTN_WPS_WIFI 2
48 #define ARCHER_C7_GPIO_LED_WLAN5 9
49 #define ARCHER_C7_GPIO_LED_POWER 6
50 #define ARCHER_C7_GPIO_LED_USB 7
51 #define ARCHER_C7_GPIO_LED_WPS 1
52 #define ARCHER_C7_GPIO_LED_LAN1 8
53 #define ARCHER_C7_GPIO_LED_LAN2 17
54 #define ARCHER_C7_GPIO_LED_LAN3 16
55 #define ARCHER_C7_GPIO_LED_LAN4 15
56 #define ARCHER_C7_GPIO_LED_WAN_GREEN 21
57 #define ARCHER_C7_GPIO_LED_WAN_AMBER 20
58 #define ARCHER_C7_GPIO_LED_WLAN2 14
59 #define ARCHER_C7_GPIO_USB_PWR 19
61 #define ARCHER_C7_KEYS_POLL_INTERVAL 20 /* msecs */
62 #define ARCHER_C7_KEYS_DEBOUNCE_INTERVAL (3 * ARCHER_C7_KEYS_POLL_INTERVAL)
64 #define ARCHER_C7_MAC0_OFFSET 0
65 #define ARCHER_C7_MAC1_OFFSET 6
66 #define ARCHER_C7_WMAC_CALDATA_OFFSET 0x1000
68 #define ARCHER_C7_GPIO_MDC 3
69 #define ARCHER_C7_GPIO_MDIO 4
71 static struct gpio_led archer_c7_v5_leds_gpio
[] __initdata
= {
73 .name
= "archer-c7-v5:green:power",
74 .gpio
= ARCHER_C7_GPIO_LED_POWER
,
77 .name
= "archer-c7-v5:green:wps",
78 .gpio
= ARCHER_C7_GPIO_LED_WPS
,
81 .name
= "archer-c7-v5:green:wlan2g",
82 .gpio
= ARCHER_C7_GPIO_LED_WLAN2
,
85 .name
= "archer-c7-v5:green:wlan5g",
86 .gpio
= ARCHER_C7_GPIO_LED_WLAN5
,
89 .name
= "archer-c7-v5:green:lan1",
90 .gpio
= ARCHER_C7_GPIO_LED_LAN1
,
93 .name
= "archer-c7-v5:green:lan2",
94 .gpio
= ARCHER_C7_GPIO_LED_LAN2
,
97 .name
= "archer-c7-v5:green:lan3",
98 .gpio
= ARCHER_C7_GPIO_LED_LAN3
,
101 .name
= "archer-c7-v5:green:lan4",
102 .gpio
= ARCHER_C7_GPIO_LED_LAN4
,
105 .name
= "archer-c7-v5:green:wan",
106 .gpio
= ARCHER_C7_GPIO_LED_WAN_GREEN
,
109 .name
= "archer-c7-v5:amber:wan",
110 .gpio
= ARCHER_C7_GPIO_LED_WAN_AMBER
,
113 .name
= "archer-c7-v5:green:usb",
114 .gpio
= ARCHER_C7_GPIO_LED_USB
,
119 static struct gpio_keys_button archer_c7_v5_gpio_keys
[] __initdata
= {
121 .desc
= "WPS and WIFI button",
123 .code
= KEY_WPS_BUTTON
,
124 .debounce_interval
= ARCHER_C7_KEYS_DEBOUNCE_INTERVAL
,
125 .gpio
= ARCHER_C7_GPIO_BTN_WPS_WIFI
,
129 .desc
= "Reset button",
132 .debounce_interval
= ARCHER_C7_KEYS_DEBOUNCE_INTERVAL
,
133 .gpio
= ARCHER_C7_GPIO_BTN_RESET
,
139 static struct ar8327_pad_cfg archer_c7_v5_ar8337_pad0_cfg
= {
140 .mode
= AR8327_PAD_MAC_SGMII
,
141 .sgmii_delay_en
= true,
144 static struct ar8327_platform_data archer_c7_v5_ar8337_data
= {
145 .pad0_cfg
= &archer_c7_v5_ar8337_pad0_cfg
,
148 .speed
= AR8327_PORT_SPEED_1000
,
155 static struct mdio_board_info archer_c7_v5_mdio0_info
[] = {
157 .bus_id
= "ag71xx-mdio.0",
159 .platform_data
= &archer_c7_v5_ar8337_data
,
164 static void __init
archer_c7_v5_setup(void)
166 u8
*art
= (u8
*) KSEG1ADDR(0x1f050000);
167 u8
*mac
= (u8
*) KSEG1ADDR(0x1f060008);
169 ath79_register_m25p80(NULL
);
172 ath79_register_leds_gpio(-1, ARRAY_SIZE(archer_c7_v5_leds_gpio
),
173 archer_c7_v5_leds_gpio
);
175 ath79_register_gpio_keys_polled(-1, ARCHER_C7_KEYS_POLL_INTERVAL
,
176 ARRAY_SIZE(archer_c7_v5_gpio_keys
),
177 archer_c7_v5_gpio_keys
);
179 ath79_register_usb();
181 ath79_gpio_output_select(ARCHER_C7_GPIO_MDC
, QCA956X_GPIO_OUT_MUX_GE0_MDC
);
182 ath79_gpio_output_select(ARCHER_C7_GPIO_MDIO
, QCA956X_GPIO_OUT_MUX_GE0_MDO
);
184 ath79_register_mdio(0, 0x0);
186 mdiobus_register_board_info(archer_c7_v5_mdio0_info
,
187 ARRAY_SIZE(archer_c7_v5_mdio0_info
));
189 gpio_request_one(ARCHER_C7_GPIO_USB_PWR
,
190 GPIOF_OUT_INIT_HIGH
| GPIOF_EXPORT_DIR_FIXED
,
193 ath79_register_wmac(art
+ ARCHER_C7_WMAC_CALDATA_OFFSET
, mac
);
194 ath79_register_pci();
196 /* GMAC0 is connected to an AR8337 switch */
197 ath79_init_mac(ath79_eth0_data
.mac_addr
, mac
, 0);
198 ath79_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_SGMII
;
199 ath79_eth0_data
.speed
= SPEED_1000
;
200 ath79_eth0_data
.duplex
= DUPLEX_FULL
;
201 ath79_eth0_data
.phy_mask
= BIT(0);
202 ath79_eth0_data
.mii_bus_dev
= &ath79_mdio0_device
.dev
;
203 ath79_register_eth(0);
206 MIPS_MACHINE(ATH79_MACH_ARCHER_C7_V5
, "ARCHER-C7-V5", "TP-LINK Archer C7 v5",