mach-tl-wr841n.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. * TP-LINK TL-WR841N/ND v1 board support
  3. *
  4. * Copyright (C) 2009-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. #include <linux/mtd/mtd.h>
  11. #include <linux/mtd/partitions.h>
  12. #include <linux/platform_device.h>
  13. #include <asm/mach-ath79/ath79.h>
  14. #include "dev-dsa.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 "machtypes.h"
  20. #include "pci.h"
  21. #define TL_WR841ND_V1_GPIO_LED_SYSTEM 2
  22. #define TL_WR841ND_V1_GPIO_LED_QSS_GREEN 4
  23. #define TL_WR841ND_V1_GPIO_LED_QSS_RED 5
  24. #define TL_WR841ND_V1_GPIO_BTN_RESET 3
  25. #define TL_WR841ND_V1_GPIO_BTN_QSS 7
  26. #define TL_WR841ND_V1_KEYS_POLL_INTERVAL 20 /* msecs */
  27. #define TL_WR841ND_V1_KEYS_DEBOUNCE_INTERVAL \
  28. (3 * TL_WR841ND_V1_KEYS_POLL_INTERVAL)
  29. static struct mtd_partition tl_wr841n_v1_partitions[] = {
  30. {
  31. .name = "redboot",
  32. .offset = 0,
  33. .size = 0x020000,
  34. .mask_flags = MTD_WRITEABLE,
  35. }, {
  36. .name = "kernel",
  37. .offset = 0x020000,
  38. .size = 0x140000,
  39. }, {
  40. .name = "rootfs",
  41. .offset = 0x160000,
  42. .size = 0x280000,
  43. }, {
  44. .name = "config",
  45. .offset = 0x3e0000,
  46. .size = 0x020000,
  47. .mask_flags = MTD_WRITEABLE,
  48. }, {
  49. .name = "firmware",
  50. .offset = 0x020000,
  51. .size = 0x3c0000,
  52. }
  53. };
  54. static struct flash_platform_data tl_wr841n_v1_flash_data = {
  55. .parts = tl_wr841n_v1_partitions,
  56. .nr_parts = ARRAY_SIZE(tl_wr841n_v1_partitions),
  57. };
  58. static struct gpio_led tl_wr841n_v1_leds_gpio[] __initdata = {
  59. {
  60. .name = "tp-link:green:system",
  61. .gpio = TL_WR841ND_V1_GPIO_LED_SYSTEM,
  62. .active_low = 1,
  63. }, {
  64. .name = "tp-link:red:qss",
  65. .gpio = TL_WR841ND_V1_GPIO_LED_QSS_RED,
  66. }, {
  67. .name = "tp-link:green:qss",
  68. .gpio = TL_WR841ND_V1_GPIO_LED_QSS_GREEN,
  69. }
  70. };
  71. static struct gpio_keys_button tl_wr841n_v1_gpio_keys[] __initdata = {
  72. {
  73. .desc = "reset",
  74. .type = EV_KEY,
  75. .code = KEY_RESTART,
  76. .debounce_interval = TL_WR841ND_V1_KEYS_DEBOUNCE_INTERVAL,
  77. .gpio = TL_WR841ND_V1_GPIO_BTN_RESET,
  78. .active_low = 1,
  79. }, {
  80. .desc = "qss",
  81. .type = EV_KEY,
  82. .code = KEY_WPS_BUTTON,
  83. .debounce_interval = TL_WR841ND_V1_KEYS_DEBOUNCE_INTERVAL,
  84. .gpio = TL_WR841ND_V1_GPIO_BTN_QSS,
  85. .active_low = 1,
  86. }
  87. };
  88. static struct dsa_chip_data tl_wr841n_v1_dsa_chip = {
  89. .port_names[0] = "wan",
  90. .port_names[1] = "lan1",
  91. .port_names[2] = "lan2",
  92. .port_names[3] = "lan3",
  93. .port_names[4] = "lan4",
  94. .port_names[5] = "cpu",
  95. };
  96. static struct dsa_platform_data tl_wr841n_v1_dsa_data = {
  97. .nr_chips = 1,
  98. .chip = &tl_wr841n_v1_dsa_chip,
  99. };
  100. static void __init tl_wr841n_v1_setup(void)
  101. {
  102. u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  103. ath79_register_mdio(0, 0x0);
  104. ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  105. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  106. ath79_eth0_data.speed = SPEED_100;
  107. ath79_eth0_data.duplex = DUPLEX_FULL;
  108. ath79_register_eth(0);
  109. ath79_register_dsa(&ath79_eth0_device.dev, &ath79_mdio0_device.dev,
  110. &tl_wr841n_v1_dsa_data);
  111. ath79_register_m25p80(&tl_wr841n_v1_flash_data);
  112. ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr841n_v1_leds_gpio),
  113. tl_wr841n_v1_leds_gpio);
  114. ath79_register_gpio_keys_polled(-1, TL_WR841ND_V1_KEYS_POLL_INTERVAL,
  115. ARRAY_SIZE(tl_wr841n_v1_gpio_keys),
  116. tl_wr841n_v1_gpio_keys);
  117. ath79_register_pci();
  118. }
  119. MIPS_MACHINE(ATH79_MACH_TL_WR841N_V1, "TL-WR841N-v1.5", "TP-LINK TL-WR841N v1",
  120. tl_wr841n_v1_setup);