mach-wrtnode2q.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. * WRTnode2Q board support
  3. *
  4. * Copyright (c) 2013 The Linux Foundation. All rights reserved.
  5. * Copyright (c) 2012 Gabor Juhos <juhosg@openwrt.org>
  6. * Copyright (c) 2015 Kelei <xzmu@wrtnode.com>
  7. *
  8. * Permission to use, copy, modify, and/or distribute this software for any
  9. * purpose with or without fee is hereby granted, provided that the above
  10. * copyright notice and this permission notice appear in all copies.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  13. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  14. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  15. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  16. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  17. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  18. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  19. *
  20. */
  21. #include <linux/platform_device.h>
  22. #include <linux/ath9k_platform.h>
  23. #include <linux/ar8216_platform.h>
  24. #include <asm/mach-ath79/ar71xx_regs.h>
  25. #include "common.h"
  26. #include "dev-eth.h"
  27. #include "dev-gpio-buttons.h"
  28. #include "dev-leds-gpio.h"
  29. #include "dev-m25p80.h"
  30. #include "dev-spi.h"
  31. #include "dev-usb.h"
  32. #include "dev-wmac.h"
  33. #include "machtypes.h"
  34. #include "pci.h"
  35. #define WRTNODE2Q_GPIO_LED_WLAN 12
  36. #define WRTNODE2Q_GPIO_LED_WPS 13
  37. #define WRTNODE2Q_GPIO_LED_STATUS 13
  38. #define WRTNODE2Q_GPIO_LED_WAN 4
  39. #define WRTNODE2Q_GPIO_LED_LAN1 16
  40. #define WRTNODE2Q_GPIO_LED_LAN2 15
  41. #define WRTNODE2Q_GPIO_LED_LAN3 14
  42. #define WRTNODE2Q_GPIO_LED_LAN4 11
  43. #define WRTNODE2Q_GPIO_BTN_WPS 17
  44. #define WRTNODE2Q_KEYS_POLL_INTERVAL 20 /* msecs */
  45. #define WRTNODE2Q_KEYS_DEBOUNCE_INTERVAL (3 * WRTNODE2Q_KEYS_POLL_INTERVAL)
  46. #define WRTNODE2Q_MAC0_OFFSET 0
  47. #define WRTNODE2Q_WMAC_CALDATA_OFFSET 0x1000
  48. static struct gpio_led wrtnode2q_leds_gpio[] __initdata = {
  49. {
  50. .name = "wrtnode2q:green:status",
  51. .gpio = WRTNODE2Q_GPIO_LED_STATUS,
  52. .active_low = 1,
  53. },
  54. {
  55. .name = "wrtnode2q:green:wlan",
  56. .gpio = WRTNODE2Q_GPIO_LED_WLAN,
  57. .active_low = 1,
  58. }
  59. };
  60. static struct gpio_keys_button wrtnode2q_gpio_keys[] __initdata = {
  61. {
  62. .desc = "WPS button",
  63. .type = EV_KEY,
  64. .code = KEY_WPS_BUTTON,
  65. .debounce_interval = WRTNODE2Q_KEYS_DEBOUNCE_INTERVAL,
  66. .gpio = WRTNODE2Q_GPIO_BTN_WPS,
  67. .active_low = 1,
  68. },
  69. };
  70. static void __init wrtnode2q_gpio_led_setup(void)
  71. {
  72. ath79_register_leds_gpio(-1, ARRAY_SIZE(wrtnode2q_leds_gpio),
  73. wrtnode2q_leds_gpio);
  74. ath79_register_gpio_keys_polled(-1, WRTNODE2Q_KEYS_POLL_INTERVAL,
  75. ARRAY_SIZE(wrtnode2q_gpio_keys),
  76. wrtnode2q_gpio_keys);
  77. }
  78. static void __init wrtnode2q_setup(void)
  79. {
  80. u8 *art = (u8 *) KSEG1ADDR(0x1f040000);
  81. ath79_register_m25p80(NULL);
  82. wrtnode2q_gpio_led_setup();
  83. ath79_register_pci();
  84. ath79_register_usb();
  85. ath79_register_wmac(art + WRTNODE2Q_WMAC_CALDATA_OFFSET, NULL);
  86. ath79_register_mdio(0, 0x0);
  87. ath79_register_mdio(1, 0x0);
  88. ath79_init_mac(ath79_eth0_data.mac_addr, art + WRTNODE2Q_MAC0_OFFSET, 0);
  89. ath79_init_mac(ath79_eth1_data.mac_addr, art + WRTNODE2Q_MAC0_OFFSET, 1);
  90. /* LAN ports */
  91. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  92. ath79_eth1_data.speed = SPEED_1000;
  93. ath79_eth1_data.duplex = DUPLEX_FULL;
  94. ath79_switch_data.phy_poll_mask |= BIT(4);
  95. ath79_switch_data.phy4_mii_en = 1;
  96. ath79_register_eth(1);
  97. /* WAN port */
  98. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  99. ath79_eth0_data.speed = SPEED_100;
  100. ath79_eth0_data.duplex = DUPLEX_FULL;
  101. ath79_eth0_data.phy_mask = BIT(4);
  102. ath79_register_eth(0);
  103. }
  104. MIPS_MACHINE(ATH79_MACH_WRTNODE2Q, "WRTNODE2Q", "WRTnode2Q board",
  105. wrtnode2q_setup);