1/* 2 * TP-LINK CPE210/220/510/520 board support 3 * 4 * Copyright (C) 2014 Matthias Schiffer <mschiffer@universe-factory.net> 5 * 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. 9 */ 10 11#include <linux/gpio.h> 12#include <linux/platform_device.h> 13 14#include <asm/mach-ath79/ath79.h> 15#include <asm/mach-ath79/ar71xx_regs.h> 16 17#include "common.h" 18#include "dev-eth.h" 19#include "dev-gpio-buttons.h" 20#include "dev-leds-gpio.h" 21#include "dev-m25p80.h" 22#include "dev-wmac.h" 23#include "machtypes.h" 24 25 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 32 33#define CPE510_GPIO_EXTERNAL_LNA0 18 34#define CPE510_GPIO_EXTERNAL_LNA1 19 35 36#define CPE510_GPIO_BTN_RESET 4 37 38#define CPE510_KEYS_POLL_INTERVAL 20 /* msecs */ 39#define CPE510_KEYS_DEBOUNCE_INTERVAL (3 * CPE510_KEYS_POLL_INTERVAL) 40 41 42static struct gpio_led cpe510_leds_gpio[] __initdata = { 43 { 44 .name = "tp-link:green:lan0", 45 .gpio = CPE510_GPIO_LED_LAN0, 46 .active_low = 1, 47 }, { 48 .name = "tp-link:green:lan1", 49 .gpio = CPE510_GPIO_LED_LAN1, 50 .active_low = 1, 51 }, { 52 .name = "tp-link:green:link1", 53 .gpio = CPE510_GPIO_LED_L1, 54 .active_low = 1, 55 }, { 56 .name = "tp-link:green:link2", 57 .gpio = CPE510_GPIO_LED_L2, 58 .active_low = 1, 59 }, { 60 .name = "tp-link:green:link3", 61 .gpio = CPE510_GPIO_LED_L3, 62 .active_low = 1, 63 }, { 64 .name = "tp-link:green:link4", 65 .gpio = CPE510_GPIO_LED_L4, 66 .active_low = 1, 67 }, 68}; 69 70static struct gpio_keys_button cpe510_gpio_keys[] __initdata = { 71 { 72 .desc = "Reset button", 73 .type = EV_KEY, 74 .code = KEY_RESTART, 75 .debounce_interval = CPE510_KEYS_DEBOUNCE_INTERVAL, 76 .gpio = CPE510_GPIO_BTN_RESET, 77 .active_low = 1, 78 } 79}; 80 81static void __init cpe_setup(u8 *mac) 82{ 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); 87 88 ath79_register_leds_gpio(-1, ARRAY_SIZE(cpe510_leds_gpio), 89 cpe510_leds_gpio); 90 91 ath79_register_gpio_keys_polled(1, CPE510_KEYS_POLL_INTERVAL, 92 ARRAY_SIZE(cpe510_gpio_keys), 93 cpe510_gpio_keys); 94 95 ath79_wmac_set_ext_lna_gpio(0, CPE510_GPIO_EXTERNAL_LNA0); 96 ath79_wmac_set_ext_lna_gpio(1, CPE510_GPIO_EXTERNAL_LNA1); 97 98 ath79_register_m25p80(NULL); 99 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); 104} 105 106 107static void __init cpe210_setup(void) 108{ 109 u8 *mac = (u8 *) KSEG1ADDR(0x1f830008); 110 u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000); 111 112 cpe_setup(mac); 113 114 ath79_register_wmac(ee, mac); 115} 116 117static void __init cpe510_setup(void) 118{ 119 u8 *mac = (u8 *) KSEG1ADDR(0x1f830008); 120 u8 *ee = (u8 *) KSEG1ADDR(0x1fff5000); 121 122 cpe_setup(mac); 123 124 ath79_register_wmac(ee, mac); 125} 126 127MIPS_MACHINE(ATH79_MACH_CPE210, "CPE210", "TP-LINK CPE210/220", 128 cpe210_setup); 129 130MIPS_MACHINE(ATH79_MACH_CPE510, "CPE510", "TP-LINK CPE510/520", 131 cpe510_setup); 132