mach-dr531.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /*
  2. * Wallys DR531 board support
  3. *
  4. * Copyright (C) 2016 Piotr Dymacz <pepe2k@gmail.com>
  5. *
  6. * Based on mach-wpj531.c
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License version 2 as published
  10. * by the Free Software Foundation.
  11. */
  12. #include <linux/pci.h>
  13. #include <linux/gpio.h>
  14. #include <linux/platform_device.h>
  15. #include <asm/mach-ath79/ath79.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-usb.h"
  24. #include "dev-wmac.h"
  25. #include "machtypes.h"
  26. #include "pci.h"
  27. #define DR531_GPIO_BUZZER 4
  28. #define DR531_GPIO_LED_WAN 11
  29. #define DR531_GPIO_LED_LAN 14
  30. #define DR531_GPIO_LED_SIG1 12
  31. #define DR531_GPIO_LED_SIG2 16
  32. #define DR531_GPIO_LED_SIG3 15
  33. #define DR531_GPIO_LED_SIG4 13
  34. #define DR531_GPIO_BTN_RESET 17
  35. #define DR531_KEYS_POLL_INTERVAL 20 /* msecs */
  36. #define DR531_KEYS_DEBOUNCE_INTERVAL (3 * DR531_KEYS_POLL_INTERVAL)
  37. #define DR531_MAC0_OFFSET 0x0
  38. #define DR531_MAC1_OFFSET 0x8
  39. #define DR531_WMAC_CALDATA_OFFSET 0x1000
  40. static struct gpio_led dr531_leds_gpio[] __initdata = {
  41. {
  42. .name = "dr531:green:wan",
  43. .gpio = DR531_GPIO_LED_WAN,
  44. .active_low = 1,
  45. },
  46. {
  47. .name = "dr531:green:lan",
  48. .gpio = DR531_GPIO_LED_LAN,
  49. .active_low = 1,
  50. },
  51. {
  52. .name = "dr531:green:sig1",
  53. .gpio = DR531_GPIO_LED_SIG1,
  54. .active_low = 1,
  55. },
  56. {
  57. .name = "dr531:green:sig2",
  58. .gpio = DR531_GPIO_LED_SIG2,
  59. .active_low = 1,
  60. },
  61. {
  62. .name = "dr531:green:sig3",
  63. .gpio = DR531_GPIO_LED_SIG3,
  64. .active_low = 1,
  65. },
  66. {
  67. .name = "dr531:green:sig4",
  68. .gpio = DR531_GPIO_LED_SIG4,
  69. .active_low = 1,
  70. },
  71. {
  72. .name = "dr531:buzzer",
  73. .gpio = DR531_GPIO_BUZZER,
  74. .active_low = 0,
  75. }
  76. };
  77. static struct gpio_keys_button dr531_gpio_keys[] __initdata = {
  78. {
  79. .desc = "reset",
  80. .type = EV_KEY,
  81. .code = KEY_RESTART,
  82. .debounce_interval = DR531_KEYS_DEBOUNCE_INTERVAL,
  83. .gpio = DR531_GPIO_BTN_RESET,
  84. .active_low = 1,
  85. },
  86. };
  87. static void __init dr531_gpio_setup(void)
  88. {
  89. ath79_gpio_direction_select(DR531_GPIO_BUZZER, true);
  90. ath79_gpio_direction_select(DR531_GPIO_LED_WAN, true);
  91. ath79_gpio_direction_select(DR531_GPIO_LED_LAN, true);
  92. ath79_gpio_direction_select(DR531_GPIO_LED_SIG1, true);
  93. ath79_gpio_direction_select(DR531_GPIO_LED_SIG2, true);
  94. ath79_gpio_direction_select(DR531_GPIO_LED_SIG3, true);
  95. ath79_gpio_direction_select(DR531_GPIO_LED_SIG4, true);
  96. ath79_gpio_output_select(DR531_GPIO_BUZZER, 0);
  97. ath79_gpio_output_select(DR531_GPIO_LED_WAN, 0);
  98. ath79_gpio_output_select(DR531_GPIO_LED_LAN, 0);
  99. ath79_register_leds_gpio(-1, ARRAY_SIZE(dr531_leds_gpio),
  100. dr531_leds_gpio);
  101. ath79_register_gpio_keys_polled(-1, DR531_KEYS_POLL_INTERVAL,
  102. ARRAY_SIZE(dr531_gpio_keys),
  103. dr531_gpio_keys);
  104. }
  105. static void __init dr531_setup(void)
  106. {
  107. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  108. u8 *mac = (u8 *) KSEG1ADDR(0x1f03f810);
  109. ath79_register_m25p80(NULL);
  110. dr531_gpio_setup();
  111. ath79_setup_ar933x_phy4_switch(false, false);
  112. ath79_register_mdio(0, 0x0);
  113. /* LAN */
  114. ath79_eth0_data.duplex = DUPLEX_FULL;
  115. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  116. ath79_eth0_data.speed = SPEED_100;
  117. ath79_eth0_data.phy_mask = BIT(4);
  118. ath79_init_mac(ath79_eth0_data.mac_addr, mac + DR531_MAC1_OFFSET, 0);
  119. ath79_register_eth(0);
  120. /* WAN */
  121. ath79_switch_data.phy4_mii_en = 1;
  122. ath79_eth1_data.duplex = DUPLEX_FULL;
  123. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  124. ath79_eth1_data.speed = SPEED_1000;
  125. ath79_switch_data.phy_poll_mask |= BIT(4);
  126. ath79_init_mac(ath79_eth1_data.mac_addr, mac + DR531_MAC0_OFFSET, 0);
  127. ath79_register_eth(1);
  128. ath79_register_wmac(art + DR531_WMAC_CALDATA_OFFSET, NULL);
  129. ath79_register_pci();
  130. ath79_register_usb();
  131. }
  132. MIPS_MACHINE(ATH79_MACH_DR531, "DR531", "Wallys DR531", dr531_setup);