2 * Zbtlink ZBT-WE1526 board support
4 * Copyright (C) 2016 Piotr Dymacz <pepe2k@gmail.com>
6 * Based on mach-dr531.c and mach-tl-wr841n-v9.c
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"
28 #define ZBT_WE1526_GPIO_LED_STATUS 13
29 #define ZBT_WE1526_GPIO_LED_LAN1 16
30 #define ZBT_WE1526_GPIO_LED_LAN2 15
31 #define ZBT_WE1526_GPIO_LED_LAN3 14
32 #define ZBT_WE1526_GPIO_LED_LAN4 11
33 #define ZBT_WE1526_GPIO_LED_WAN 4
34 #define ZBT_WE1526_GPIO_LED_WLAN 12
36 #define ZBT_WE1526_GPIO_BTN_RESET 17
38 #define ZBT_WE1526_KEYS_POLL_INTERVAL 20 /* msecs */
39 #define ZBT_WE1526_KEYS_DEBOUNCE_INTERVAL \
40 (3 * ZBT_WE1526_KEYS_POLL_INTERVAL)
42 #define ZBT_WE1526_MAC0_OFFSET 0x0
43 #define ZBT_WE1526_MAC1_OFFSET 0x6
44 #define ZBT_WE1526_WMAC_CALDATA_OFFSET 0x1000
46 static struct gpio_led zbt_we1526_leds_gpio[] __initdata = {
48 .name = "zbt-we1526:green:status",
49 .gpio = ZBT_WE1526_GPIO_LED_STATUS,
53 .name = "zbt-we1526:green:lan1",
54 .gpio = ZBT_WE1526_GPIO_LED_LAN1,
58 .name = "zbt-we1526:green:lan2",
59 .gpio = ZBT_WE1526_GPIO_LED_LAN2,
63 .name = "zbt-we1526:green:lan3",
64 .gpio = ZBT_WE1526_GPIO_LED_LAN3,
68 .name = "zbt-we1526:green:lan4",
69 .gpio = ZBT_WE1526_GPIO_LED_LAN4,
73 .name = "zbt-we1526:green:wan",
74 .gpio = ZBT_WE1526_GPIO_LED_WAN,
78 .name = "zbt-we1526:green:wlan",
79 .gpio = ZBT_WE1526_GPIO_LED_WLAN,
84 static struct gpio_keys_button zbt_we1526_gpio_keys[] __initdata = {
89 .debounce_interval = ZBT_WE1526_KEYS_DEBOUNCE_INTERVAL,
90 .gpio = ZBT_WE1526_GPIO_BTN_RESET,
95 static void __init zbt_we1526_gpio_setup(void)
97 /* For LED on GPIO4 */
98 ath79_gpio_function_disable(AR934X_GPIO_FUNC_CLK_OBS4_EN);
99 ath79_gpio_output_select(ZBT_WE1526_GPIO_LED_WAN, 0);
101 ath79_gpio_direction_select(ZBT_WE1526_GPIO_LED_STATUS, true);
102 ath79_gpio_direction_select(ZBT_WE1526_GPIO_LED_LAN1, true);
103 ath79_gpio_direction_select(ZBT_WE1526_GPIO_LED_LAN2, true);
104 ath79_gpio_direction_select(ZBT_WE1526_GPIO_LED_LAN3, true);
105 ath79_gpio_direction_select(ZBT_WE1526_GPIO_LED_LAN4, true);
106 ath79_gpio_direction_select(ZBT_WE1526_GPIO_LED_WAN, true);
107 ath79_gpio_direction_select(ZBT_WE1526_GPIO_LED_WLAN, true);
109 ath79_register_leds_gpio(-1, ARRAY_SIZE(zbt_we1526_leds_gpio),
110 zbt_we1526_leds_gpio);
112 ath79_register_gpio_keys_polled(-1, ZBT_WE1526_KEYS_POLL_INTERVAL,
113 ARRAY_SIZE(zbt_we1526_gpio_keys),
114 zbt_we1526_gpio_keys);
117 static void __init zbt_we1526_setup(void)
119 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
121 ath79_register_m25p80(NULL);
123 zbt_we1526_gpio_setup();
125 ath79_setup_ar933x_phy4_switch(false, false);
127 ath79_register_mdio(0, 0x0);
130 ath79_eth1_data.duplex = DUPLEX_FULL;
131 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
132 ath79_switch_data.phy_poll_mask |= BIT(4);
133 ath79_init_mac(ath79_eth1_data.mac_addr,
134 art + ZBT_WE1526_MAC0_OFFSET, 0);
135 ath79_register_eth(1);
138 ath79_switch_data.phy4_mii_en = 1;
139 ath79_eth0_data.duplex = DUPLEX_FULL;
140 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
141 ath79_eth0_data.phy_mask = BIT(4);
142 ath79_eth0_data.speed = SPEED_100;
143 ath79_init_mac(ath79_eth0_data.mac_addr,
144 art + ZBT_WE1526_MAC1_OFFSET, 0);
145 ath79_register_eth(0);
147 ath79_register_wmac(art + ZBT_WE1526_WMAC_CALDATA_OFFSET, NULL);
149 ath79_register_usb();
152 MIPS_MACHINE(ATH79_MACH_ZBT_WE1526, "ZBT-WE1526", "Zbtlink ZBT-WE1526",