2 * YunCore T830 board support
4 * Copyright (C) 2018 Piotr Dymacz <pepe2k@gmail.com>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation.
11 #include <linux/gpio.h>
12 #include <linux/platform_device.h>
14 #include <asm/mach-ath79/ath79.h>
15 #include <asm/mach-ath79/ar71xx_regs.h>
19 #include "dev-gpio-buttons.h"
20 #include "dev-leds-gpio.h"
21 #include "dev-m25p80.h"
24 #include "machtypes.h"
26 #define T830_GPIO_LED_LAN1 16
27 #define T830_GPIO_LED_LAN2 15
28 #define T830_GPIO_LED_LAN3 14
29 #define T830_GPIO_LED_LAN4 11
30 #define T830_GPIO_LED_USB 13
31 #define T830_GPIO_LED_WAN 4
32 #define T830_GPIO_LED_WLAN 12
34 #define T830_GPIO_BTN_RESET 17
36 #define T830_KEYS_POLL_INTERVAL 20 /* msec */
37 #define T830_KEYS_DEBOUNCE_INTERVAL (3 * T830_KEYS_POLL_INTERVAL)
39 #define T830_WMAC_CALDATA_OFFSET 0x1000
41 static struct gpio_led t830_gpio_leds[] __initdata = {
43 .name = "t830:green:lan1",
44 .gpio = T830_GPIO_LED_LAN1,
47 .name = "t830:green:lan2",
48 .gpio = T830_GPIO_LED_LAN2,
51 .name = "t830:green:lan3",
52 .gpio = T830_GPIO_LED_LAN3,
55 .name = "t830:green:lan4",
56 .gpio = T830_GPIO_LED_LAN4,
59 .name = "t830:green:usb",
60 .gpio = T830_GPIO_LED_USB,
62 .default_state = LEDS_GPIO_DEFSTATE_KEEP,
64 .name = "t830:green:wan",
65 .gpio = T830_GPIO_LED_WAN,
68 .name = "t830:green:wlan",
69 .gpio = T830_GPIO_LED_WLAN,
74 static struct gpio_keys_button t830_gpio_keys[] __initdata = {
79 .debounce_interval = T830_KEYS_DEBOUNCE_INTERVAL,
80 .gpio = T830_GPIO_BTN_RESET,
85 static void __init t830_setup(void)
87 u8 *art = (u8 *) KSEG1ADDR(0x1fff1000);
88 u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000);
90 ath79_register_m25p80(NULL);
92 ath79_setup_ar933x_phy4_switch(false, false);
94 ath79_register_mdio(0, 0x0);
96 ath79_switch_data.phy4_mii_en = 1;
97 ath79_switch_data.phy_poll_mask |= BIT(4);
100 ath79_eth1_data.duplex = DUPLEX_FULL;
101 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
102 ath79_init_mac(ath79_eth1_data.mac_addr, mac + 6, 0);
103 ath79_register_eth(1);
106 ath79_eth0_data.duplex = DUPLEX_FULL;
107 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
108 ath79_eth0_data.phy_mask = BIT(4);
109 ath79_eth0_data.speed = SPEED_100;
110 ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
111 ath79_register_eth(0);
113 ath79_gpio_function_setup(AR934X_GPIO_FUNC_JTAG_DISABLE,
114 AR934X_GPIO_FUNC_CLK_OBS4_EN);
116 ath79_register_leds_gpio(-1, ARRAY_SIZE(t830_gpio_leds),
119 ath79_register_gpio_keys_polled(-1, T830_KEYS_POLL_INTERVAL,
120 ARRAY_SIZE(t830_gpio_keys),
123 ath79_register_usb();
124 ath79_register_wmac(art, NULL);
127 MIPS_MACHINE(ATH79_MACH_T830, "T830", "YunCore T830", t830_setup);