2 * YunCore AP90Q board support
4 * Copyright (C) 2016 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 AP90Q_GPIO_LED_WAN 4
27 #define AP90Q_GPIO_LED_WLAN 12
28 #define AP90Q_GPIO_LED_LAN 16
30 #define AP90Q_GPIO_BTN_RESET 17
32 #define AP90Q_KEYS_POLL_INTERVAL 20
33 #define AP90Q_KEYS_DEBOUNCE_INTERVAL (3 * AP90Q_KEYS_POLL_INTERVAL)
35 static struct gpio_led ap90q_leds_gpio
[] __initdata
= {
37 .name
= "ap90q:green:lan",
38 .gpio
= AP90Q_GPIO_LED_LAN
,
42 .name
= "ap90q:green:wan",
43 .gpio
= AP90Q_GPIO_LED_WAN
,
47 .name
= "ap90q:green:wlan",
48 .gpio
= AP90Q_GPIO_LED_WLAN
,
53 static struct gpio_keys_button ap90q_gpio_keys
[] __initdata
= {
58 .debounce_interval
= AP90Q_KEYS_DEBOUNCE_INTERVAL
,
59 .gpio
= AP90Q_GPIO_BTN_RESET
,
64 static void __init
ap90q_gpio_setup(void)
66 /* For LED on GPIO4 */
67 ath79_gpio_function_disable(AR934X_GPIO_FUNC_CLK_OBS4_EN
);
69 ath79_gpio_direction_select(AP90Q_GPIO_LED_LAN
, true);
70 ath79_gpio_direction_select(AP90Q_GPIO_LED_WAN
, true);
71 ath79_gpio_direction_select(AP90Q_GPIO_LED_WLAN
, true);
73 /* Mute LEDs on boot */
74 gpio_set_value(AP90Q_GPIO_LED_LAN
, 1);
75 gpio_set_value(AP90Q_GPIO_LED_WAN
, 1);
77 ath79_gpio_output_select(AP90Q_GPIO_LED_LAN
, 0);
78 ath79_gpio_output_select(AP90Q_GPIO_LED_WAN
, 0);
79 ath79_gpio_output_select(AP90Q_GPIO_LED_WLAN
, 0);
81 ath79_register_leds_gpio(-1, ARRAY_SIZE(ap90q_leds_gpio
),
84 ath79_register_gpio_keys_polled(-1, AP90Q_KEYS_POLL_INTERVAL
,
85 ARRAY_SIZE(ap90q_gpio_keys
),
89 static void __init
ap90q_setup(void)
91 u8
*art
= (u8
*) KSEG1ADDR(0x1fff1000);
92 u8
*mac
= (u8
*) KSEG1ADDR(0x1fff0000);
94 ath79_register_m25p80(NULL
);
98 ath79_setup_ar933x_phy4_switch(false, false);
100 ath79_register_mdio(0, 0x0);
102 ath79_switch_data
.phy4_mii_en
= 1;
103 ath79_switch_data
.phy_poll_mask
|= BIT(4);
106 ath79_eth1_data
.duplex
= DUPLEX_FULL
;
107 ath79_eth1_data
.phy_if_mode
= PHY_INTERFACE_MODE_GMII
;
108 ath79_eth1_data
.speed
= SPEED_1000
;
109 ath79_init_mac(ath79_eth1_data
.mac_addr
, mac
, 1);
110 ath79_register_eth(1);
113 ath79_eth0_data
.duplex
= DUPLEX_FULL
;
114 ath79_eth0_data
.phy_if_mode
= PHY_INTERFACE_MODE_MII
;
115 ath79_eth0_data
.speed
= SPEED_100
;
116 ath79_eth0_data
.phy_mask
= BIT(4);
117 ath79_init_mac(ath79_eth0_data
.mac_addr
, mac
, 0);
118 ath79_register_eth(0);
120 ath79_register_wmac(art
, NULL
);
123 MIPS_MACHINE(ATH79_MACH_AP90Q
, "AP90Q", "YunCore AP90Q", ap90q_setup
);