1
0

mach-hornet-ub.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /*
  2. * ALFA NETWORK Hornet-UB board support
  3. *
  4. * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  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 <linux/gpio.h>
  11. #include <asm/mach-ath79/ath79.h>
  12. #include <asm/mach-ath79/ar71xx_regs.h>
  13. #include "common.h"
  14. #include "dev-eth.h"
  15. #include "dev-gpio-buttons.h"
  16. #include "dev-leds-gpio.h"
  17. #include "dev-m25p80.h"
  18. #include "dev-usb.h"
  19. #include "dev-wmac.h"
  20. #include "machtypes.h"
  21. #define HORNET_UB_GPIO_LED_WLAN 0
  22. #define HORNET_UB_GPIO_LED_USB 1
  23. #define HORNET_UB_GPIO_LED_LAN 13
  24. #define HORNET_UB_GPIO_LED_WAN 17
  25. #define HORNET_UB_GPIO_LED_WPS 27
  26. #define HORNET_UB_GPIO_EXT_LNA 28
  27. #define HORNET_UB_GPIO_BTN_RESET 12
  28. #define HORNET_UB_GPIO_BTN_WPS 11
  29. #define HORNET_UB_GPIO_USB_POWER 26
  30. #define HORNET_UB_KEYS_POLL_INTERVAL 20 /* msecs */
  31. #define HORNET_UB_KEYS_DEBOUNCE_INTERVAL (3 * HORNET_UB_KEYS_POLL_INTERVAL)
  32. #define HORNET_UB_MAC0_OFFSET 0x0000
  33. #define HORNET_UB_MAC1_OFFSET 0x0006
  34. #define HORNET_UB_CALDATA_OFFSET 0x1000
  35. static struct gpio_led hornet_ub_leds_gpio[] __initdata = {
  36. {
  37. .name = "alfa:blue:lan",
  38. .gpio = HORNET_UB_GPIO_LED_LAN,
  39. .active_low = 0,
  40. },
  41. {
  42. .name = "alfa:blue:usb",
  43. .gpio = HORNET_UB_GPIO_LED_USB,
  44. .active_low = 0,
  45. },
  46. {
  47. .name = "alfa:blue:wan",
  48. .gpio = HORNET_UB_GPIO_LED_WAN,
  49. .active_low = 1,
  50. },
  51. {
  52. .name = "alfa:blue:wlan",
  53. .gpio = HORNET_UB_GPIO_LED_WLAN,
  54. .active_low = 0,
  55. },
  56. {
  57. .name = "alfa:blue:wps",
  58. .gpio = HORNET_UB_GPIO_LED_WPS,
  59. .active_low = 1,
  60. },
  61. };
  62. static struct gpio_keys_button hornet_ub_gpio_keys[] __initdata = {
  63. {
  64. .desc = "WPS button",
  65. .type = EV_KEY,
  66. .code = KEY_WPS_BUTTON,
  67. .debounce_interval = HORNET_UB_KEYS_DEBOUNCE_INTERVAL,
  68. .gpio = HORNET_UB_GPIO_BTN_WPS,
  69. .active_low = 0,
  70. },
  71. {
  72. .desc = "Reset button",
  73. .type = EV_KEY,
  74. .code = KEY_RESTART,
  75. .debounce_interval = HORNET_UB_KEYS_DEBOUNCE_INTERVAL,
  76. .gpio = HORNET_UB_GPIO_BTN_RESET,
  77. .active_low = 1,
  78. }
  79. };
  80. static void __init hornet_ub_gpio_setup(void)
  81. {
  82. u32 t;
  83. ath79_gpio_function_disable(AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  84. AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  85. AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  86. AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  87. AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
  88. t = ath79_reset_rr(AR933X_RESET_REG_BOOTSTRAP);
  89. t |= AR933X_BOOTSTRAP_MDIO_GPIO_EN;
  90. ath79_reset_wr(AR933X_RESET_REG_BOOTSTRAP, t);
  91. gpio_request_one(HORNET_UB_GPIO_USB_POWER,
  92. GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  93. "USB power");
  94. gpio_request_one(HORNET_UB_GPIO_EXT_LNA,
  95. GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  96. "external LNA0");
  97. }
  98. static void __init hornet_ub_setup(void)
  99. {
  100. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  101. hornet_ub_gpio_setup();
  102. ath79_register_m25p80(NULL);
  103. ath79_register_leds_gpio(-1, ARRAY_SIZE(hornet_ub_leds_gpio),
  104. hornet_ub_leds_gpio);
  105. ath79_register_gpio_keys_polled(-1, HORNET_UB_KEYS_POLL_INTERVAL,
  106. ARRAY_SIZE(hornet_ub_gpio_keys),
  107. hornet_ub_gpio_keys);
  108. ath79_init_mac(ath79_eth1_data.mac_addr,
  109. art + HORNET_UB_MAC0_OFFSET, 0);
  110. ath79_init_mac(ath79_eth0_data.mac_addr,
  111. art + HORNET_UB_MAC1_OFFSET, 0);
  112. ath79_register_mdio(0, 0x0);
  113. ath79_register_eth(1);
  114. ath79_register_eth(0);
  115. ath79_register_wmac(art + HORNET_UB_CALDATA_OFFSET, NULL);
  116. ath79_register_usb();
  117. }
  118. MIPS_MACHINE(ATH79_MACH_HORNET_UB, "HORNET-UB", "ALFA NETWORK Hornet-UB",
  119. hornet_ub_setup);