| 1 | /* |
| 2 | * TP-LINK TL-WR2543N/ND board support |
| 3 | * |
| 4 | * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org> |
| 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/platform_device.h> |
| 12 | #include <linux/rtl8367.h> |
| 13 | |
| 14 | #include <asm/mach-ath79/ath79.h> |
| 15 | |
| 16 | #include "dev-eth.h" |
| 17 | #include "dev-ap9x-pci.h" |
| 18 | #include "dev-gpio-buttons.h" |
| 19 | #include "dev-leds-gpio.h" |
| 20 | #include "dev-m25p80.h" |
| 21 | #include "dev-usb.h" |
| 22 | #include "machtypes.h" |
| 23 | |
| 24 | #define TL_WR2543N_GPIO_LED_WPS 0 |
| 25 | #define TL_WR2543N_GPIO_LED_USB 8 |
| 26 | |
| 27 | #define TL_WR2543N_GPIO_BTN_RESET 11 |
| 28 | #define TL_WR2543N_GPIO_BTN_WPS 12 |
| 29 | |
| 30 | #define TL_WR2543N_GPIO_RTL8367_SDA 1 |
| 31 | #define TL_WR2543N_GPIO_RTL8367_SCK 6 |
| 32 | |
| 33 | #define TL_WR2543N_KEYS_POLL_INTERVAL 20 /* msecs */ |
| 34 | #define TL_WR2543N_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR2543N_KEYS_POLL_INTERVAL) |
| 35 | |
| 36 | static const char *tl_wr2543n_part_probes[] = { |
| 37 | "tp-link", |
| 38 | NULL, |
| 39 | }; |
| 40 | |
| 41 | static struct flash_platform_data tl_wr2543n_flash_data = { |
| 42 | .part_probes = tl_wr2543n_part_probes, |
| 43 | .max_read_len = 64, |
| 44 | }; |
| 45 | |
| 46 | static struct gpio_led tl_wr2543n_leds_gpio[] __initdata = { |
| 47 | { |
| 48 | .name = "tp-link:green:usb", |
| 49 | .gpio = TL_WR2543N_GPIO_LED_USB, |
| 50 | .active_low = 1, |
| 51 | }, { |
| 52 | .name = "tp-link:green:wps", |
| 53 | .gpio = TL_WR2543N_GPIO_LED_WPS, |
| 54 | .active_low = 1, |
| 55 | } |
| 56 | }; |
| 57 | |
| 58 | static struct gpio_keys_button tl_wr2543n_gpio_keys[] __initdata = { |
| 59 | { |
| 60 | .desc = "reset", |
| 61 | .type = EV_KEY, |
| 62 | .code = KEY_RESTART, |
| 63 | .debounce_interval = TL_WR2543N_KEYS_DEBOUNCE_INTERVAL, |
| 64 | .gpio = TL_WR2543N_GPIO_BTN_RESET, |
| 65 | .active_low = 1, |
| 66 | }, { |
| 67 | .desc = "wps", |
| 68 | .type = EV_KEY, |
| 69 | .code = KEY_WPS_BUTTON, |
| 70 | .debounce_interval = TL_WR2543N_KEYS_DEBOUNCE_INTERVAL, |
| 71 | .gpio = TL_WR2543N_GPIO_BTN_WPS, |
| 72 | } |
| 73 | }; |
| 74 | |
| 75 | static struct rtl8367_extif_config tl_wr2543n_rtl8367_extif0_cfg = { |
| 76 | .mode = RTL8367_EXTIF_MODE_RGMII, |
| 77 | .txdelay = 1, |
| 78 | .rxdelay = 0, |
| 79 | .ability = { |
| 80 | .force_mode = 1, |
| 81 | .txpause = 1, |
| 82 | .rxpause = 1, |
| 83 | .link = 1, |
| 84 | .duplex = 1, |
| 85 | .speed = RTL8367_PORT_SPEED_1000, |
| 86 | }, |
| 87 | }; |
| 88 | |
| 89 | static struct rtl8367_platform_data tl_wr2543n_rtl8367_data = { |
| 90 | .gpio_sda = TL_WR2543N_GPIO_RTL8367_SDA, |
| 91 | .gpio_sck = TL_WR2543N_GPIO_RTL8367_SCK, |
| 92 | .extif0_cfg = &tl_wr2543n_rtl8367_extif0_cfg, |
| 93 | }; |
| 94 | |
| 95 | static struct platform_device tl_wr2543n_rtl8367_device = { |
| 96 | .name = RTL8367_DRIVER_NAME, |
| 97 | .id = -1, |
| 98 | .dev = { |
| 99 | .platform_data = &tl_wr2543n_rtl8367_data, |
| 100 | } |
| 101 | }; |
| 102 | |
| 103 | static void __init tl_wr2543n_setup(void) |
| 104 | { |
| 105 | u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00); |
| 106 | u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000); |
| 107 | |
| 108 | ath79_register_m25p80(&tl_wr2543n_flash_data); |
| 109 | ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr2543n_leds_gpio), |
| 110 | tl_wr2543n_leds_gpio); |
| 111 | ath79_register_gpio_keys_polled(-1, TL_WR2543N_KEYS_POLL_INTERVAL, |
| 112 | ARRAY_SIZE(tl_wr2543n_gpio_keys), |
| 113 | tl_wr2543n_gpio_keys); |
| 114 | ath79_register_usb(); |
| 115 | ap91_pci_init(eeprom, mac); |
| 116 | |
| 117 | ath79_init_mac(ath79_eth0_data.mac_addr, mac, -1); |
| 118 | ath79_eth0_data.mii_bus_dev = &tl_wr2543n_rtl8367_device.dev; |
| 119 | ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII; |
| 120 | ath79_eth0_data.speed = SPEED_1000; |
| 121 | ath79_eth0_data.duplex = DUPLEX_FULL; |
| 122 | ath79_eth0_pll_data.pll_1000 = 0x1a000000; |
| 123 | |
| 124 | ath79_register_eth(0); |
| 125 | |
| 126 | platform_device_register(&tl_wr2543n_rtl8367_device); |
| 127 | } |
| 128 | |
| 129 | MIPS_MACHINE(ATH79_MACH_TL_WR2543N, "TL-WR2543N", "TP-LINK TL-WR2543N/ND", |
| 130 | tl_wr2543n_setup); |
| 131 | |