mach-hornet-ub.c 3.4 KB

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