mach-wpj531.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * Compex WPJ531 board support
  3. *
  4. * Copyright (c) 2012 Qualcomm Atheros
  5. * Copyright (c) 2012 Gabor Juhos <juhosg@openwrt.org>
  6. *
  7. * Permission to use, copy, modify, and/or distribute this software for any
  8. * purpose with or without fee is hereby granted, provided that the above
  9. * copyright notice and this permission notice appear in all copies.
  10. *
  11. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  12. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  13. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  14. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  15. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  16. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  17. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  18. *
  19. */
  20. #include <linux/irq.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/ar8216_platform.h>
  23. #include <asm/mach-ath79/ar71xx_regs.h>
  24. #include "pci.h"
  25. #include "common.h"
  26. #include "dev-ap9x-pci.h"
  27. #include "dev-gpio-buttons.h"
  28. #include "dev-eth.h"
  29. #include "dev-leds-gpio.h"
  30. #include "dev-m25p80.h"
  31. #include "dev-usb.h"
  32. #include "dev-wmac.h"
  33. #include "machtypes.h"
  34. #define WPJ531_GPIO_LED_SIG1 14
  35. #define WPJ531_GPIO_LED_SIG2 15
  36. #define WPJ531_GPIO_LED_SIG3 22
  37. #define WPJ531_GPIO_LED_SIG4 23
  38. #define WPJ531_GPIO_BUZZER 4
  39. #define WPJ531_GPIO_BTN_RESET 17
  40. #define WPJ531_KEYS_POLL_INTERVAL 20 /* msecs */
  41. #define WPJ531_KEYS_DEBOUNCE_INTERVAL (3 * WPJ531_KEYS_POLL_INTERVAL)
  42. #define WPJ531_MAC0_OFFSET 0x10
  43. #define WPJ531_MAC1_OFFSET 0x18
  44. #define WPJ531_WMAC_CALDATA_OFFSET 0x1000
  45. #define WPJ531_PCIE_CALDATA_OFFSET 0x5000
  46. #define WPJ531_ART_SIZE 0x8000
  47. static struct gpio_led wpj531_leds_gpio[] __initdata = {
  48. {
  49. .name = "wpj531:red:sig1",
  50. .gpio = WPJ531_GPIO_LED_SIG1,
  51. .active_low = 1,
  52. },
  53. {
  54. .name = "wpj531:yellow:sig2",
  55. .gpio = WPJ531_GPIO_LED_SIG2,
  56. .active_low = 1,
  57. },
  58. {
  59. .name = "wpj531:green:sig3",
  60. .gpio = WPJ531_GPIO_LED_SIG3,
  61. .active_low = 1,
  62. },
  63. {
  64. .name = "wpj531:green:sig4",
  65. .gpio = WPJ531_GPIO_LED_SIG4,
  66. .active_low = 1,
  67. },
  68. {
  69. .name = "wpj531:buzzer",
  70. .gpio = WPJ531_GPIO_BUZZER,
  71. .active_low = 0,
  72. }
  73. };
  74. static struct gpio_keys_button wpj531_gpio_keys[] __initdata = {
  75. {
  76. .desc = "reset",
  77. .type = EV_KEY,
  78. .code = KEY_RESTART,
  79. .debounce_interval = WPJ531_KEYS_DEBOUNCE_INTERVAL,
  80. .gpio = WPJ531_GPIO_BTN_RESET,
  81. .active_low = 1,
  82. },
  83. };
  84. static void __init common_setup(void)
  85. {
  86. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  87. u8 *mac = (u8 *) KSEG1ADDR(0x1f02e000);
  88. ath79_register_m25p80(NULL);
  89. ath79_setup_ar933x_phy4_switch(false, false);
  90. ath79_register_mdio(0, 0x0);
  91. /* LAN */
  92. ath79_eth0_data.duplex = DUPLEX_FULL;
  93. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  94. ath79_eth0_data.speed = SPEED_100;
  95. ath79_eth0_data.phy_mask = BIT(4);
  96. ath79_init_mac(ath79_eth0_data.mac_addr, mac + WPJ531_MAC0_OFFSET, 0);
  97. ath79_register_eth(0);
  98. /* WAN */
  99. ath79_switch_data.phy4_mii_en = 1;
  100. ath79_eth1_data.duplex = DUPLEX_FULL;
  101. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  102. ath79_eth1_data.speed = SPEED_1000;
  103. ath79_switch_data.phy_poll_mask |= BIT(4);
  104. ath79_init_mac(ath79_eth1_data.mac_addr, mac + WPJ531_MAC1_OFFSET, 0);
  105. ath79_register_eth(1);
  106. ath79_register_wmac(art + WPJ531_WMAC_CALDATA_OFFSET, NULL);
  107. ath79_register_pci();
  108. ath79_register_usb();
  109. }
  110. static void __init wpj531_setup(void)
  111. {
  112. common_setup();
  113. ath79_register_leds_gpio(-1,
  114. ARRAY_SIZE(wpj531_leds_gpio),
  115. wpj531_leds_gpio);
  116. ath79_register_gpio_keys_polled(-1,
  117. WPJ531_KEYS_POLL_INTERVAL,
  118. ARRAY_SIZE(wpj531_gpio_keys),
  119. wpj531_gpio_keys);
  120. }
  121. MIPS_MACHINE(ATH79_MACH_WPJ531, "WPJ531", "Compex WPJ531", wpj531_setup);