mach-tl-wr1041n-v2.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. * TP-LINK TL-WR1041 v2 board support
  3. *
  4. * Copyright (C) 2010-2012 Gabor Juhos <juhosg@openwrt.org>
  5. * Copyright (C) 2011-2012 Anan Huang <axishero@foxmail.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License version 2 as published
  9. * by the Free Software Foundation.
  10. */
  11. #include <linux/pci.h>
  12. #include <linux/phy.h>
  13. #include <linux/platform_device.h>
  14. #include <linux/ath9k_platform.h>
  15. #include <linux/ar8216_platform.h>
  16. #include <asm/mach-ath79/ar71xx_regs.h>
  17. #include "common.h"
  18. #include "dev-ap9x-pci.h"
  19. #include "dev-eth.h"
  20. #include "dev-gpio-buttons.h"
  21. #include "dev-leds-gpio.h"
  22. #include "dev-m25p80.h"
  23. #include "dev-spi.h"
  24. #include "dev-wmac.h"
  25. #include "machtypes.h"
  26. #define TL_WR1041NV2_GPIO_BTN_RESET 14
  27. #define TL_WR1041NV2_GPIO_LED_WPS 13
  28. #define TL_WR1041NV2_GPIO_LED_WLAN 11
  29. #define TL_WR1041NV2_GPIO_LED_SYSTEM 12
  30. #define TL_WR1041NV2_KEYS_POLL_INTERVAL 20 /* msecs */
  31. #define TL_WR1041NV2_KEYS_DEBOUNCE_INTERVAL (3 * TL_WR1041NV2_KEYS_POLL_INTERVAL)
  32. #define TL_WR1041NV2_PCIE_CALDATA_OFFSET 0x5000
  33. static const char *tl_wr1041nv2_part_probes[] = {
  34. "tp-link",
  35. NULL,
  36. };
  37. static struct flash_platform_data tl_wr1041nv2_flash_data = {
  38. .part_probes = tl_wr1041nv2_part_probes,
  39. };
  40. static struct gpio_led tl_wr1041nv2_leds_gpio[] __initdata = {
  41. {
  42. .name = "tp-link:green:system",
  43. .gpio = TL_WR1041NV2_GPIO_LED_SYSTEM,
  44. .active_low = 1,
  45. }, {
  46. .name = "tp-link:green:wps",
  47. .gpio = TL_WR1041NV2_GPIO_LED_WPS,
  48. .active_low = 1,
  49. }, {
  50. .name = "tp-link:green:wlan",
  51. .gpio = TL_WR1041NV2_GPIO_LED_WLAN,
  52. .active_low = 1,
  53. }
  54. };
  55. static struct gpio_keys_button tl_wr1041nv2_gpio_keys[] __initdata = {
  56. {
  57. .desc = "reset",
  58. .type = EV_KEY,
  59. .code = KEY_RESTART,
  60. .debounce_interval = TL_WR1041NV2_KEYS_DEBOUNCE_INTERVAL,
  61. .gpio = TL_WR1041NV2_GPIO_BTN_RESET,
  62. .active_low = 1,
  63. }
  64. };
  65. static struct ar8327_pad_cfg db120_ar8327_pad0_cfg = {
  66. .mode = AR8327_PAD_MAC_RGMII,
  67. .txclk_delay_en = true,
  68. .rxclk_delay_en = true,
  69. .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
  70. .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
  71. };
  72. static struct ar8327_platform_data db120_ar8327_data = {
  73. .pad0_cfg = &db120_ar8327_pad0_cfg,
  74. .port0_cfg = {
  75. .force_link = 1,
  76. .speed = AR8327_PORT_SPEED_1000,
  77. .duplex = 1,
  78. .txpause = 1,
  79. .rxpause = 1,
  80. }
  81. };
  82. static struct mdio_board_info db120_mdio0_info[] = {
  83. {
  84. .bus_id = "ag71xx-mdio.0",
  85. .phy_addr = 0,
  86. .platform_data = &db120_ar8327_data,
  87. },
  88. };
  89. static void __init tl_wr1041nv2_setup(void)
  90. {
  91. u8 *mac = (u8 *) KSEG1ADDR(0x1f01fc00);
  92. u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  93. ath79_register_m25p80(&tl_wr1041nv2_flash_data);
  94. ath79_register_leds_gpio(-1, ARRAY_SIZE(tl_wr1041nv2_leds_gpio),
  95. tl_wr1041nv2_leds_gpio);
  96. ath79_register_gpio_keys_polled(-1, TL_WR1041NV2_KEYS_POLL_INTERVAL,
  97. ARRAY_SIZE(tl_wr1041nv2_gpio_keys),
  98. tl_wr1041nv2_gpio_keys);
  99. ath79_register_wmac(ee, mac);
  100. ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0 |
  101. AR934X_ETH_CFG_SW_ONLY_MODE);
  102. ath79_register_mdio(1, 0x0);
  103. ath79_register_mdio(0, 0x0);
  104. ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
  105. mdiobus_register_board_info(db120_mdio0_info,
  106. ARRAY_SIZE(db120_mdio0_info));
  107. /* GMAC0 is connected to an AR8327 switch */
  108. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  109. ath79_eth0_data.phy_mask = BIT(0);
  110. ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  111. ath79_eth0_pll_data.pll_1000 = 0x06000000;
  112. ath79_register_eth(0);
  113. }
  114. MIPS_MACHINE(ATH79_MACH_TL_WR1041N_V2, "TL-WR1041N-v2",
  115. "TP-LINK TL-WR1041N v2", tl_wr1041nv2_setup);