2 * TP-LINK TL-MR6400 board support
4 * Copyright (C) 2017 Filip Moc <lede@moc6.cz>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 * * The name of the author may not be used to endorse or promote products
9 * derived from this software without specific prior written permission.
11 * THIS SOFTWARE IS PROVIDED BY AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
12 * WARRANTIES, ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
13 * DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE.
16 #include <linux/gpio.h>
17 #include <linux/platform_device.h>
19 #include <asm/mach-ath79/ar71xx_regs.h>
22 #include "dev-gpio-buttons.h"
24 #include "dev-leds-gpio.h"
25 #include "dev-m25p80.h"
28 #include "machtypes.h"
30 #define TL_MR6400_GPIO_LTE_POWER 4
31 #define TL_MR6400_GPIO_BTN_RESET 12 /* SW2 */
32 #define TL_MR6400_GPIO_BTN_RFKILL 14 /* SW3 */
33 #define TL_MR6400_GPIO_LED_WAN 0 /* D12 */
34 #define TL_MR6400_GPIO_LED_4G 1 /* D11 */
35 #define TL_MR6400_GPIO_LED_WPS 3 /* D5 */
36 #define TL_MR6400_GPIO_LED_WLAN 11 /* D3 */
37 #define TL_MR6400_GPIO_LED_POWER 13 /* D2 */
38 #define TL_MR6400_GPIO_LED_LAN 16 /* D4 */
40 #define TL_MR6400_KEYS_POLL_INTERVAL 20 /* msecs */
41 #define TL_MR6400_KEYS_DEBOUNCE_INTERVAL (3 * TL_MR6400_KEYS_POLL_INTERVAL)
43 #define TL_MR6400_WMAC_CALDATA_OFFSET 0x1000
45 static const char *tl_mr6400_part_probes[] = {
50 static struct flash_platform_data tl_mr6400_flash_data = {
51 .part_probes = tl_mr6400_part_probes,
55 static struct gpio_led tl_mr6400_leds_gpio[] __initdata = {
57 .name = "tp-link:white:wan",
58 .gpio = TL_MR6400_GPIO_LED_WAN,
62 .name = "tp-link:white:4g",
63 .gpio = TL_MR6400_GPIO_LED_4G,
67 .name = "tp-link:white:wps",
68 .gpio = TL_MR6400_GPIO_LED_WPS,
72 .name = "tp-link:white:wlan",
73 .gpio = TL_MR6400_GPIO_LED_WLAN,
77 .name = "tp-link:white:power",
78 .gpio = TL_MR6400_GPIO_LED_POWER,
82 .name = "tp-link:white:lan",
83 .gpio = TL_MR6400_GPIO_LED_LAN,
88 static struct gpio_keys_button tl_mr6400_gpio_keys[] __initdata = {
93 .debounce_interval = TL_MR6400_KEYS_DEBOUNCE_INTERVAL,
94 .gpio = TL_MR6400_GPIO_BTN_RESET,
101 .debounce_interval = TL_MR6400_KEYS_DEBOUNCE_INTERVAL,
102 .gpio = TL_MR6400_GPIO_BTN_RFKILL,
107 static void __init tl_mr6400_setup(void)
109 u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
110 u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
112 ath79_register_m25p80(&tl_mr6400_flash_data);
114 ath79_register_mdio(0, 0x0);
116 /* LAN1, LAN2, LAN3 */
117 ath79_switch_data.phy4_mii_en = 1;
118 ath79_switch_data.phy_poll_mask |= BIT(0);
119 ath79_eth1_data.duplex = DUPLEX_FULL;
120 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
121 ath79_eth1_data.speed = SPEED_1000;
122 ath79_init_mac(ath79_eth1_data.mac_addr, mac, -1);
123 ath79_register_eth(1);
126 ath79_eth0_data.phy_mask = BIT(0);
127 ath79_eth0_data.duplex = DUPLEX_FULL;
128 ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
129 ath79_eth0_data.speed = SPEED_100;
130 ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
131 ath79_register_eth(0);
133 ath79_register_wmac(art + TL_MR6400_WMAC_CALDATA_OFFSET, mac);
135 ath79_register_leds_gpio(-1,
136 ARRAY_SIZE(tl_mr6400_leds_gpio),
137 tl_mr6400_leds_gpio);
139 ath79_register_gpio_keys_polled(-1,
140 TL_MR6400_KEYS_POLL_INTERVAL,
141 ARRAY_SIZE(tl_mr6400_gpio_keys),
142 tl_mr6400_gpio_keys);
144 gpio_request_one(TL_MR6400_GPIO_LTE_POWER,
145 GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED | GPIOF_ACTIVE_LOW,
147 ath79_register_usb();
150 MIPS_MACHINE(ATH79_MACH_TL_MR6400, "TL-MR6400", "TP-LINK TL-MR6400",