1
0

mach-tl-wr802n.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * TP-LINK TL-WR802N v1
  3. *
  4. * Copyright (C) 2015 Rick Pannen <pannen@gmail.com <mailto:pannen@gmail.com>>
  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. #include <linux/gpio.h>
  11. #include <linux/platform_device.h>
  12. #include <asm/mach-ath79/ath79.h>
  13. #include <asm/mach-ath79/ar71xx_regs.h>
  14. #include "common.h"
  15. #include "dev-eth.h"
  16. #include "dev-gpio-buttons.h"
  17. #include "dev-leds-gpio.h"
  18. #include "dev-m25p80.h"
  19. #include "dev-wmac.h"
  20. #include "machtypes.h"
  21. #define TL_WR802N_V1_GPIO_LED_SYSTEM 13
  22. #define TL_WR802N_V1_GPIO_BTN_RESET 11
  23. #define TL_WR802N_V1_KEYS_POLL_INTERVAL 20 /* msecs */
  24. #define TL_WR802N_V1_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR802N_V1_KEYS_POLL_INTERVAL)
  25. static const char *tl_wr802n_v1_part_probes[] = {
  26. "tp-link",
  27. NULL,
  28. };
  29. static struct flash_platform_data tl_wr802n_v1_flash_data = {
  30. .part_probes = tl_wr802n_v1_part_probes,
  31. };
  32. static struct gpio_led tl_wr802n_v1_leds_gpio[] __initdata = {
  33. {
  34. .name = "tp-link:blue:system",
  35. .gpio = TL_WR802N_V1_GPIO_LED_SYSTEM,
  36. .active_low = 1,
  37. },
  38. };
  39. static struct gpio_keys_button tl_wr802n_v1_gpio_keys[] __initdata = {
  40. {
  41. .desc = "reset",
  42. .type = EV_KEY,
  43. .code = KEY_RESTART,
  44. .debounce_interval = TL_WR802N_V1_KEYS_DEBOUNCE_INTERVAL,
  45. .gpio = TL_WR802N_V1_GPIO_BTN_RESET,
  46. .active_low = 0,
  47. }
  48. };
  49. static void __init tl_ap143_setup(void)
  50. {
  51. u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  52. u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  53. u8 tmpmac[ETH_ALEN];
  54. ath79_register_m25p80(&tl_wr802n_v1_flash_data);
  55. ath79_setup_ar933x_phy4_switch(false, false);
  56. ath79_register_mdio(0, 0x0);
  57. /* LAN */
  58. ath79_switch_data.phy4_mii_en = 1;
  59. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  60. ath79_eth0_data.duplex = DUPLEX_FULL;
  61. ath79_eth0_data.speed = SPEED_100;
  62. ath79_eth0_data.phy_mask = BIT(4);
  63. ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
  64. ath79_register_eth(0);
  65. ath79_init_mac(tmpmac, mac, 0);
  66. ath79_register_wmac(ee, tmpmac);
  67. };
  68. static void __init tl_wr802n_v1_setup(void)
  69. {
  70. tl_ap143_setup();
  71. ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr802n_v1_leds_gpio),
  72. tl_wr802n_v1_leds_gpio);
  73. ath79_register_gpio_keys_polled(1, TL_WR802N_V1_KEYS_POLL_INTERVAL,
  74. ARRAY_SIZE(tl_wr802n_v1_gpio_keys),
  75. tl_wr802n_v1_gpio_keys);
  76. }
  77. MIPS_MACHINE(ATH79_MACH_TL_WR802N_V1, "TL-WR802N-v1", "TP-LINK TL-WR802N v1",
  78. tl_wr802n_v1_setup);