1
0

mach-ew-dorin.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*
  2. * EW Dorin board support
  3. * (based on Atheros Ref. Design AP121)
  4. * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  5. * Copyright (C) 2012-2015 Embedded Wireless GmbH www.80211.de
  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 <asm/mach-ath79/ath79.h>
  12. #include <asm/mach-ath79/ar71xx_regs.h>
  13. #include "dev-eth.h"
  14. #include "dev-gpio-buttons.h"
  15. #include "dev-leds-gpio.h"
  16. #include "dev-m25p80.h"
  17. #include "dev-spi.h"
  18. #include "dev-usb.h"
  19. #include "dev-wmac.h"
  20. #include "machtypes.h"
  21. #define DORIN_KEYS_POLL_INTERVAL 20 /* msecs */
  22. #define DORIN_KEYS_DEBOUNCE_INTERVAL (3 * DORIN_KEYS_POLL_INTERVAL)
  23. #define DORIN_CALDATA_OFFSET 0x1000
  24. #define DORIN_WMAC_MAC_OFFSET 0x1002
  25. #define DORIN_GPIO_LED_21 21
  26. #define DORIN_GPIO_LED_22 22
  27. #define DORIN_GPIO_LED_STATUS 23
  28. #define DORIN_GPIO_BTN_JUMPSTART 11
  29. #define DORIN_GPIO_BTN_RESET 6
  30. static struct gpio_led dorin_leds_gpio[] __initdata = {
  31. {
  32. .name = "dorin:green:led21",
  33. .gpio = DORIN_GPIO_LED_21,
  34. .active_low = 1,
  35. },
  36. {
  37. .name = "dorin:green:led22",
  38. .gpio = DORIN_GPIO_LED_22,
  39. .active_low = 1,
  40. },
  41. {
  42. .name = "dorin:green:status",
  43. .gpio = DORIN_GPIO_LED_STATUS,
  44. .active_low = 1,
  45. },
  46. };
  47. static struct gpio_keys_button dorin_gpio_keys[] __initdata = {
  48. {
  49. .desc = "jumpstart button",
  50. .type = EV_KEY,
  51. .code = KEY_WPS_BUTTON,
  52. .debounce_interval = DORIN_KEYS_DEBOUNCE_INTERVAL,
  53. .gpio = DORIN_GPIO_BTN_JUMPSTART,
  54. .active_low = 1,
  55. },
  56. {
  57. .desc = "reset button",
  58. .type = EV_KEY,
  59. .code = KEY_RESTART,
  60. .debounce_interval = DORIN_KEYS_DEBOUNCE_INTERVAL,
  61. .gpio = DORIN_GPIO_BTN_RESET,
  62. .active_low = 0,
  63. }
  64. };
  65. static void __init ew_dorin_setup(void)
  66. {
  67. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  68. static u8 mac[6];
  69. ath79_register_m25p80(NULL);
  70. ath79_register_usb();
  71. if (ar93xx_wmac_read_mac_address(mac)) {
  72. ath79_register_wmac(NULL, NULL);
  73. } else {
  74. ath79_register_wmac(art + DORIN_CALDATA_OFFSET,
  75. art + DORIN_WMAC_MAC_OFFSET);
  76. memcpy(mac, art + DORIN_WMAC_MAC_OFFSET, sizeof(mac));
  77. }
  78. mac[3] |= 0x40;
  79. ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
  80. ath79_register_mdio(0, 0x0);
  81. /* LAN ports */
  82. ath79_register_eth(1);
  83. ath79_register_leds_gpio(-1, ARRAY_SIZE(dorin_leds_gpio),
  84. dorin_leds_gpio);
  85. ath79_register_gpio_keys_polled(-1, DORIN_KEYS_POLL_INTERVAL,
  86. ARRAY_SIZE(dorin_gpio_keys),
  87. dorin_gpio_keys);
  88. }
  89. MIPS_MACHINE(ATH79_MACH_EW_DORIN, "EW-DORIN", "EmbWir-Dorin",
  90. ew_dorin_setup);
  91. static void __init ew_dorin_router_setup(void)
  92. {
  93. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  94. static u8 mac[6];
  95. ath79_register_m25p80(NULL);
  96. ath79_register_usb();
  97. if (ar93xx_wmac_read_mac_address(mac)) {
  98. ath79_register_wmac(NULL, NULL);
  99. } else {
  100. ath79_register_wmac(art + DORIN_CALDATA_OFFSET,
  101. art + DORIN_WMAC_MAC_OFFSET);
  102. memcpy(mac, art + DORIN_WMAC_MAC_OFFSET, sizeof(mac));
  103. }
  104. mac[3] |= 0x40;
  105. ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
  106. mac[3] &= 0x3F;
  107. ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  108. ath79_setup_ar933x_phy4_switch(true, true);
  109. ath79_register_mdio(0, 0x0);
  110. /* LAN ports */
  111. ath79_register_eth(1);
  112. /* WAN port */
  113. ath79_register_eth(0);
  114. ath79_register_leds_gpio(-1, ARRAY_SIZE(dorin_leds_gpio),
  115. dorin_leds_gpio);
  116. ath79_register_gpio_keys_polled(-1, DORIN_KEYS_POLL_INTERVAL,
  117. ARRAY_SIZE(dorin_gpio_keys),
  118. dorin_gpio_keys);
  119. }
  120. MIPS_MACHINE(ATH79_MACH_EW_DORIN_ROUTER, "EW-DORIN-ROUTER",
  121. "EmbWir-Dorin-Router", ew_dorin_router_setup);