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_BTN_RESET 4
35 #define CPE510_KEYS_POLL_INTERVAL 20 /* msecs */
36 #define CPE510_KEYS_DEBOUNCE_INTERVAL (3 * CPE510_KEYS_POLL_INTERVAL)
39 static struct gpio_led cpe510_leds_gpio[] __initdata = {
41 .name = "tp-link:green:lan0",
42 .gpio = CPE510_GPIO_LED_LAN0,
45 .name = "tp-link:green:lan1",
46 .gpio = CPE510_GPIO_LED_LAN1,
49 .name = "tp-link:green:link1",
50 .gpio = CPE510_GPIO_LED_L1,
53 .name = "tp-link:green:link2",
54 .gpio = CPE510_GPIO_LED_L2,
57 .name = "tp-link:green:link3",
58 .gpio = CPE510_GPIO_LED_L3,
61 .name = "tp-link:green:link4",
62 .gpio = CPE510_GPIO_LED_L4,
67 static struct gpio_keys_button cpe510_gpio_keys[] __initdata = {
69 .desc = "Reset button",
72 .debounce_interval = CPE510_KEYS_DEBOUNCE_INTERVAL,
73 .gpio = CPE510_GPIO_BTN_RESET,
79 static void __init cpe510_setup(void)
81 u8 *mac = (u8 *) KSEG1ADDR(0x1f830008);
82 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
84 /* Disable JTAG, enabling GPIOs 0-3 */
85 /* Configure OBS4 line, for GPIO 4*/
86 ath79_gpio_function_setup(AR934X_GPIO_FUNC_JTAG_DISABLE,
87 AR934X_GPIO_FUNC_CLK_OBS4_EN);
89 ath79_register_leds_gpio(-1, ARRAY_SIZE(cpe510_leds_gpio),
92 ath79_register_gpio_keys_polled(1, CPE510_KEYS_POLL_INTERVAL,
93 ARRAY_SIZE(cpe510_gpio_keys),
96 ath79_register_m25p80(NULL);
98 ath79_register_mdio(1, 0);
99 ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
100 ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
101 ath79_register_eth(1);
103 ath79_register_wmac(ee, mac);
106 MIPS_MACHINE(ATH79_MACH_CPE510, "CPE510", "TP-LINK CPE210/220/510/520",