2 * TP-LINK CPE210/220/510/520 board support
4 * Copyright (C) 2014 Matthias Schiffer <mschiffer@universe-factory.net>
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"
23 #include "machtypes.h"
26 #define CPE510_GPIO_LED_LAN0 11
27 #define CPE510_GPIO_LED_LAN1 12
28 #define CPE510_GPIO_LED_L1 13
29 #define CPE510_GPIO_LED_L2 14
30 #define CPE510_GPIO_LED_L3 15
31 #define CPE510_GPIO_LED_L4 16
33 #define CPE510_GPIO_EXTERNAL_LNA0 18
34 #define CPE510_GPIO_EXTERNAL_LNA1 19
36 #define CPE510_GPIO_BTN_RESET 4
38 #define CPE510_KEYS_POLL_INTERVAL 20 /* msecs */
39 #define CPE510_KEYS_DEBOUNCE_INTERVAL (3 * CPE510_KEYS_POLL_INTERVAL)
42 static struct gpio_led cpe510_leds_gpio[] __initdata = {
44 .name = "tp-link:green:lan0",
45 .gpio = CPE510_GPIO_LED_LAN0,
48 .name = "tp-link:green:lan1",
49 .gpio = CPE510_GPIO_LED_LAN1,
52 .name = "tp-link:green:link1",
53 .gpio = CPE510_GPIO_LED_L1,
56 .name = "tp-link:green:link2",
57 .gpio = CPE510_GPIO_LED_L2,
60 .name = "tp-link:green:link3",
61 .gpio = CPE510_GPIO_LED_L3,
64 .name = "tp-link:green:link4",
65 .gpio = CPE510_GPIO_LED_L4,
70 static struct gpio_keys_button cpe510_gpio_keys[] __initdata = {
72 .desc = "Reset button",
75 .debounce_interval = CPE510_KEYS_DEBOUNCE_INTERVAL,
76 .gpio = CPE510_GPIO_BTN_RESET,
81 static void __init cpe_setup(u8 *mac)
83 /* Disable JTAG, enabling GPIOs 0-3 */
84 /* Configure OBS4 line, for GPIO 4*/
85 ath79_gpio_function_setup(AR934X_GPIO_FUNC_JTAG_DISABLE,
86 AR934X_GPIO_FUNC_CLK_OBS4_EN);
88 ath79_register_leds_gpio(-1, ARRAY_SIZE(cpe510_leds_gpio),
91 ath79_register_gpio_keys_polled(1, CPE510_KEYS_POLL_INTERVAL,
92 ARRAY_SIZE(cpe510_gpio_keys),
95 ath79_wmac_set_ext_lna_gpio(0, CPE510_GPIO_EXTERNAL_LNA0);
96 ath79_wmac_set_ext_lna_gpio(1, CPE510_GPIO_EXTERNAL_LNA1);
98 ath79_register_m25p80(NULL);
100 ath79_register_mdio(1, 0);
101 ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
102 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
103 ath79_register_eth(1);
107 static void __init cpe210_setup(void)
109 u8 *mac = (u8 *) KSEG1ADDR(0x1f830008);
110 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
114 ath79_register_wmac(ee, mac);
117 static void __init cpe510_setup(void)
119 u8 *mac = (u8 *) KSEG1ADDR(0x1f830008);
120 u8 *ee = (u8 *) KSEG1ADDR(0x1fff5000);
124 ath79_register_wmac(ee, mac);
127 MIPS_MACHINE(ATH79_MACH_CPE210, "CPE210", "TP-LINK CPE210/220",
130 MIPS_MACHINE(ATH79_MACH_CPE510, "CPE510", "TP-LINK CPE510/520",