mach-ew-dorin.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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-2017 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_STATUS 21
  26. #define DORIN_GPIO_BTN_JUMPSTART 11
  27. #define DORIN_GPIO_BTN_RESET 6
  28. static struct gpio_led dorin_leds_gpio[] __initdata = {
  29. {
  30. .name = "dorin:green:status",
  31. .gpio = DORIN_GPIO_LED_STATUS,
  32. .active_low = 1,
  33. },
  34. };
  35. static struct gpio_keys_button dorin_gpio_keys[] __initdata = {
  36. {
  37. .desc = "jumpstart button",
  38. .type = EV_KEY,
  39. .code = KEY_WPS_BUTTON,
  40. .debounce_interval = DORIN_KEYS_DEBOUNCE_INTERVAL,
  41. .gpio = DORIN_GPIO_BTN_JUMPSTART,
  42. .active_low = 1,
  43. },
  44. {
  45. .desc = "reset button",
  46. .type = EV_KEY,
  47. .code = KEY_RESTART,
  48. .debounce_interval = DORIN_KEYS_DEBOUNCE_INTERVAL,
  49. .gpio = DORIN_GPIO_BTN_RESET,
  50. .active_low = 0,
  51. }
  52. };
  53. static void __init ew_dorin_setup(void)
  54. {
  55. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  56. static u8 mac[6];
  57. ath79_register_m25p80(NULL);
  58. ath79_register_usb();
  59. if (ar93xx_wmac_read_mac_address(mac)) {
  60. ath79_register_wmac(NULL, NULL);
  61. } else {
  62. ath79_register_wmac(art + DORIN_CALDATA_OFFSET,
  63. art + DORIN_WMAC_MAC_OFFSET);
  64. memcpy(mac, art + DORIN_WMAC_MAC_OFFSET, sizeof(mac));
  65. }
  66. mac[3] |= 0x40;
  67. ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
  68. ath79_register_mdio(0, 0x0);
  69. /* LAN ports */
  70. ath79_register_eth(1);
  71. ath79_register_leds_gpio(-1, ARRAY_SIZE(dorin_leds_gpio),
  72. dorin_leds_gpio);
  73. ath79_register_gpio_keys_polled(-1, DORIN_KEYS_POLL_INTERVAL,
  74. ARRAY_SIZE(dorin_gpio_keys),
  75. dorin_gpio_keys);
  76. }
  77. MIPS_MACHINE(ATH79_MACH_EW_DORIN, "EW-DORIN", "EmbWir-Dorin",
  78. ew_dorin_setup);
  79. static void __init ew_dorin_router_setup(void)
  80. {
  81. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  82. static u8 mac[6];
  83. ath79_register_m25p80(NULL);
  84. ath79_register_usb();
  85. if (ar93xx_wmac_read_mac_address(mac)) {
  86. ath79_register_wmac(NULL, NULL);
  87. } else {
  88. ath79_register_wmac(art + DORIN_CALDATA_OFFSET,
  89. art + DORIN_WMAC_MAC_OFFSET);
  90. memcpy(mac, art + DORIN_WMAC_MAC_OFFSET, sizeof(mac));
  91. }
  92. mac[3] |= 0x40;
  93. ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
  94. mac[3] &= 0x3F;
  95. ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  96. ath79_setup_ar933x_phy4_switch(true, true);
  97. ath79_register_mdio(0, 0x0);
  98. /* LAN ports */
  99. ath79_register_eth(1);
  100. /* WAN port */
  101. ath79_register_eth(0);
  102. ath79_register_leds_gpio(-1, ARRAY_SIZE(dorin_leds_gpio),
  103. dorin_leds_gpio);
  104. ath79_register_gpio_keys_polled(-1, DORIN_KEYS_POLL_INTERVAL,
  105. ARRAY_SIZE(dorin_gpio_keys),
  106. dorin_gpio_keys);
  107. }
  108. MIPS_MACHINE(ATH79_MACH_EW_DORIN_ROUTER, "EW-DORIN-ROUTER",
  109. "EmbWir-Dorin-Router", ew_dorin_router_setup);