mach-rme-eg200.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * eTactica EG-200 board, based on 8devices Carambola2 module
  3. *
  4. * Copyright (C) 2015 Karl Palsson <karlp@etactica.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License version 2 as published
  8. * by the Free Software Foundation.
  9. */
  10. #include <asm/mach-ath79/ath79.h>
  11. #include <asm/mach-ath79/ar71xx_regs.h>
  12. #include "common.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-usb.h"
  18. #include "dev-wmac.h"
  19. #include "machtypes.h"
  20. #define RME_EG200_GPIO_LED_WLAN 0
  21. #define RME_EG200_GPIO_LED_ETH0 13
  22. #define RME_EG200_GPIO_LED_ETACTICA 15
  23. #define RME_EG200_GPIO_LED_MODBUS 16
  24. #define RME_EG200_GPIO_BTN_RESTORE 11
  25. #define RME_EG200_KEYS_POLL_INTERVAL 20 /* msecs */
  26. #define RME_EG200_KEYS_DEBOUNCE_INTERVAL (3 * RME_EG200_KEYS_POLL_INTERVAL)
  27. #define RME_EG200_MAC0_OFFSET 0x0000
  28. #define RME_EG200_CALDATA_OFFSET 0x1000
  29. #define RME_EG200_WMAC_MAC_OFFSET 0x1002
  30. static struct gpio_led rme_eg200_leds_gpio[] __initdata = {
  31. {
  32. .name = "eg200:red:wlan",
  33. .gpio = RME_EG200_GPIO_LED_WLAN,
  34. .active_low = 1,
  35. }, {
  36. .name = "eg200:red:eth0",
  37. .gpio = RME_EG200_GPIO_LED_ETH0,
  38. .active_low = 1,
  39. }, {
  40. .name = "eg200:red:etactica",
  41. .gpio = RME_EG200_GPIO_LED_ETACTICA,
  42. .active_low = 0,
  43. }, {
  44. .name = "eg200:red:modbus",
  45. .gpio = RME_EG200_GPIO_LED_MODBUS,
  46. .active_low = 0,
  47. }
  48. };
  49. static struct gpio_keys_button rme_eg200_keys[] __initdata = {
  50. {
  51. .desc = "restore button",
  52. .type = EV_KEY,
  53. .code = KEY_WPS_BUTTON,
  54. .debounce_interval = RME_EG200_KEYS_DEBOUNCE_INTERVAL,
  55. .gpio = RME_EG200_GPIO_BTN_RESTORE,
  56. .active_low = 1,
  57. },
  58. };
  59. static void __init rme_eg200_setup(void)
  60. {
  61. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  62. ath79_register_m25p80(NULL);
  63. ath79_register_wmac(art + RME_EG200_CALDATA_OFFSET,
  64. art + RME_EG200_WMAC_MAC_OFFSET);
  65. ath79_setup_ar933x_phy4_switch(true, true);
  66. ath79_init_mac(ath79_eth0_data.mac_addr, art + RME_EG200_MAC0_OFFSET, 0);
  67. ath79_register_mdio(0, 0x0);
  68. /* WAN port */
  69. ath79_register_eth(0);
  70. ath79_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  71. AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  72. AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  73. AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  74. AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
  75. ath79_register_leds_gpio(-1, ARRAY_SIZE(rme_eg200_leds_gpio),
  76. rme_eg200_leds_gpio);
  77. ath79_register_gpio_keys_polled(-1, RME_EG200_KEYS_POLL_INTERVAL,
  78. ARRAY_SIZE(rme_eg200_keys),
  79. rme_eg200_keys);
  80. ath79_register_usb();
  81. }
  82. MIPS_MACHINE(ATH79_MACH_RME_EG200, "RME-EG200", "eTactica EG-200",
  83. rme_eg200_setup);