2 * Support for YunCore boards:
6 * Copyright (C) 2016 Piotr Dymacz <pepe2k@gmail.com>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 2 as published
10 * by the Free Software Foundation.
13 #include <linux/gpio.h>
14 #include <linux/platform_device.h>
16 #include <asm/mach-ath79/ath79.h>
17 #include <asm/mach-ath79/ar71xx_regs.h>
21 #include "dev-gpio-buttons.h"
22 #include "dev-leds-gpio.h"
23 #include "dev-m25p80.h"
26 #include "machtypes.h"
29 #define AP90Q_GPIO_LED_WAN 4
30 #define AP90Q_GPIO_LED_WLAN 12
31 #define AP90Q_GPIO_LED_LAN 16
33 #define AP90Q_GPIO_BTN_RESET 17
35 #define AP90Q_KEYS_POLL_INTERVAL 20
36 #define AP90Q_KEYS_DEBOUNCE_INTERVAL (3 * AP90Q_KEYS_POLL_INTERVAL)
38 static struct gpio_led ap90q_leds_gpio[] __initdata = {
40 .name = "ap90q:green:lan",
41 .gpio = AP90Q_GPIO_LED_LAN,
45 .name = "ap90q:green:wan",
46 .gpio = AP90Q_GPIO_LED_WAN,
50 .name = "ap90q:green:wlan",
51 .gpio = AP90Q_GPIO_LED_WLAN,
56 static struct gpio_keys_button ap90q_gpio_keys[] __initdata = {
61 .debounce_interval = AP90Q_KEYS_DEBOUNCE_INTERVAL,
62 .gpio = AP90Q_GPIO_BTN_RESET,
68 #define CPE830_GPIO_LED_LINK4 0
69 #define CPE830_GPIO_LED_LINK1 1
70 #define CPE830_GPIO_LED_LINK2 2
71 #define CPE830_GPIO_LED_LINK3 3
72 #define CPE830_GPIO_LED_WAN 4
73 #define CPE830_GPIO_LED_WLAN 12
74 #define CPE830_GPIO_LED_LAN 16
76 #define CPE830_GPIO_BTN_RESET 17
78 static struct gpio_led cpe830_leds_gpio[] __initdata = {
80 .name = "cpe830:green:lan",
81 .gpio = CPE830_GPIO_LED_LAN,
85 .name = "cpe830:green:wan",
86 .gpio = CPE830_GPIO_LED_WAN,
90 .name = "cpe830:green:wlan",
91 .gpio = CPE830_GPIO_LED_WLAN,
95 .name = "cpe830:green:link1",
96 .gpio = CPE830_GPIO_LED_LINK1,
100 .name = "cpe830:green:link2",
101 .gpio = CPE830_GPIO_LED_LINK2,
105 .name = "cpe830:green:link3",
106 .gpio = CPE830_GPIO_LED_LINK3,
110 .name = "cpe830:green:link4",
111 .gpio = CPE830_GPIO_LED_LINK4,
116 static void __init ap90q_cpe830_common_setup(void)
118 u8 *art = (u8 *) KSEG1ADDR(0x1fff1000);
119 u8 *mac = (u8 *) KSEG1ADDR(0x1fff0000);
121 ath79_register_m25p80(NULL);
123 ath79_setup_ar933x_phy4_switch(false, false);
125 ath79_register_mdio(0, 0x0);
127 ath79_switch_data.phy4_mii_en = 1;
128 ath79_switch_data.phy_poll_mask |= BIT(4);
131 ath79_eth1_data.duplex = DUPLEX_FULL;
132 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
133 ath79_eth1_data.speed = SPEED_1000;
134 ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
135 ath79_register_eth(1);
138 ath79_eth0_data.duplex = DUPLEX_FULL;
139 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
140 ath79_eth0_data.speed = SPEED_100;
141 ath79_eth0_data.phy_mask = BIT(4);
142 ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
143 ath79_register_eth(0);
145 ath79_register_wmac(art, NULL);
147 /* For LED on GPIO4 */
148 ath79_gpio_function_disable(AR934X_GPIO_FUNC_CLK_OBS4_EN);
150 ath79_gpio_direction_select(AP90Q_GPIO_LED_LAN, true);
151 ath79_gpio_direction_select(AP90Q_GPIO_LED_WAN, true);
152 ath79_gpio_direction_select(AP90Q_GPIO_LED_WLAN, true);
154 /* Mute LEDs on boot */
155 gpio_set_value(AP90Q_GPIO_LED_LAN, 1);
156 gpio_set_value(AP90Q_GPIO_LED_WAN, 1);
158 ath79_gpio_output_select(AP90Q_GPIO_LED_LAN, 0);
159 ath79_gpio_output_select(AP90Q_GPIO_LED_WAN, 0);
160 ath79_gpio_output_select(AP90Q_GPIO_LED_WLAN, 0);
162 ath79_register_gpio_keys_polled(-1, AP90Q_KEYS_POLL_INTERVAL,
163 ARRAY_SIZE(ap90q_gpio_keys),
167 static void __init ap90q_setup(void)
169 ap90q_cpe830_common_setup();
171 ath79_register_leds_gpio(-1, ARRAY_SIZE(ap90q_leds_gpio),
175 MIPS_MACHINE(ATH79_MACH_AP90Q, "AP90Q", "YunCore AP90Q", ap90q_setup);
177 static void __init cpe830_setup(void)
179 ap90q_cpe830_common_setup();
181 ath79_gpio_direction_select(CPE830_GPIO_LED_LINK1, true);
182 ath79_gpio_direction_select(CPE830_GPIO_LED_LINK2, true);
183 ath79_gpio_direction_select(CPE830_GPIO_LED_LINK3, true);
184 ath79_gpio_direction_select(CPE830_GPIO_LED_LINK4, true);
186 /* Mute LEDs on boot */
187 gpio_set_value(CPE830_GPIO_LED_LINK1, 1);
188 gpio_set_value(CPE830_GPIO_LED_LINK2, 1);
189 gpio_set_value(CPE830_GPIO_LED_LINK3, 1);
190 gpio_set_value(CPE830_GPIO_LED_LINK4, 1);
192 ath79_gpio_output_select(CPE830_GPIO_LED_LINK1, 0);
193 ath79_gpio_output_select(CPE830_GPIO_LED_LINK2, 0);
194 ath79_gpio_output_select(CPE830_GPIO_LED_LINK3, 0);
195 ath79_gpio_output_select(CPE830_GPIO_LED_LINK4, 0);
197 ath79_register_leds_gpio(-1, ARRAY_SIZE(cpe830_leds_gpio),
201 MIPS_MACHINE(ATH79_MACH_CPE830, "CPE830", "YunCore CPE830", cpe830_setup);