1
0

mach-whr-hp-g300n.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /*
  2. * Buffalo WHR-HP-G300N board support
  3. *
  4. * based on ...
  5. *
  6. * TP-LINK TL-WR741ND board support
  7. *
  8. * Copyright (C) 2009-2010 Gabor Juhos <juhosg@openwrt.org>
  9. *
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License version 2 as published
  12. * by the Free Software Foundation.
  13. */
  14. #include <asm/mach-ath79/ath79.h>
  15. #include <asm/mach-ath79/ar71xx_regs.h>
  16. #include "common.h"
  17. #include "dev-ap9x-pci.h"
  18. #include "dev-eth.h"
  19. #include "dev-gpio-buttons.h"
  20. #include "dev-leds-gpio.h"
  21. #include "dev-m25p80.h"
  22. #include "machtypes.h"
  23. #define WHRHPG300N_GPIO_LED_SECURITY 0
  24. #define WHRHPG300N_GPIO_LED_DIAG 1
  25. #define WHRHPG300N_GPIO_LED_ROUTER 6
  26. #define WHRHPG300N_GPIO_BTN_ROUTER_ON 7
  27. #define WHRHPG300N_GPIO_BTN_ROUTER_AUTO 8
  28. #define WHRHPG300N_GPIO_BTN_RESET 11
  29. #define WHRHPG300N_GPIO_BTN_AOSS 12
  30. #define WHRHPG300N_GPIO_LED_LAN1 13
  31. #define WHRHPG300N_GPIO_LED_LAN2 14
  32. #define WHRHPG300N_GPIO_LED_LAN3 15
  33. #define WHRHPG300N_GPIO_LED_LAN4 16
  34. #define WHRHPG300N_GPIO_LED_WAN 17
  35. #define WHRHPG300N_KEYS_POLL_INTERVAL 20 /* msecs */
  36. #define WHRHPG300N_KEYS_DEBOUNCE_INTERVAL (3 * WHRHPG300N_KEYS_POLL_INTERVAL)
  37. #define WHRHPG300N_MAC_OFFSET 0x20c
  38. static struct gpio_led whrhpg300n_leds_gpio[] __initdata = {
  39. {
  40. .name = "buffalo:orange:security",
  41. .gpio = WHRHPG300N_GPIO_LED_SECURITY,
  42. .active_low = 1,
  43. }, {
  44. .name = "buffalo:red:diag",
  45. .gpio = WHRHPG300N_GPIO_LED_DIAG,
  46. .active_low = 1,
  47. }, {
  48. .name = "buffalo:green:router",
  49. .gpio = WHRHPG300N_GPIO_LED_ROUTER,
  50. .active_low = 1,
  51. }, {
  52. .name = "buffalo:green:wan",
  53. .gpio = WHRHPG300N_GPIO_LED_WAN,
  54. .active_low = 1,
  55. }, {
  56. .name = "buffalo:green:lan1",
  57. .gpio = WHRHPG300N_GPIO_LED_LAN1,
  58. .active_low = 1,
  59. }, {
  60. .name = "buffalo:green:lan2",
  61. .gpio = WHRHPG300N_GPIO_LED_LAN2,
  62. .active_low = 1,
  63. }, {
  64. .name = "buffalo:green:lan3",
  65. .gpio = WHRHPG300N_GPIO_LED_LAN3,
  66. .active_low = 1,
  67. }, {
  68. .name = "buffalo:green:lan4",
  69. .gpio = WHRHPG300N_GPIO_LED_LAN4,
  70. .active_low = 1,
  71. }
  72. };
  73. static struct gpio_keys_button whrhpg300n_gpio_keys[] __initdata = {
  74. {
  75. .desc = "reset",
  76. .type = EV_KEY,
  77. .code = KEY_RESTART,
  78. .debounce_interval = WHRHPG300N_KEYS_DEBOUNCE_INTERVAL,
  79. .gpio = WHRHPG300N_GPIO_BTN_RESET,
  80. .active_low = 1,
  81. }, {
  82. .desc = "aoss/wps",
  83. .type = EV_KEY,
  84. .code = KEY_WPS_BUTTON,
  85. .gpio = WHRHPG300N_GPIO_BTN_AOSS,
  86. .debounce_interval = WHRHPG300N_KEYS_DEBOUNCE_INTERVAL,
  87. .active_low = 1,
  88. }, {
  89. .desc = "router_on",
  90. .type = EV_KEY,
  91. .code = BTN_2,
  92. .gpio = WHRHPG300N_GPIO_BTN_ROUTER_ON,
  93. .debounce_interval = WHRHPG300N_KEYS_DEBOUNCE_INTERVAL,
  94. .active_low = 1,
  95. }, {
  96. .desc = "router_auto",
  97. .type = EV_KEY,
  98. .code = BTN_3,
  99. .gpio = WHRHPG300N_GPIO_BTN_ROUTER_AUTO,
  100. .debounce_interval = WHRHPG300N_KEYS_DEBOUNCE_INTERVAL,
  101. .active_low = 1,
  102. }
  103. };
  104. static void __init whrhpg300n_setup(void)
  105. {
  106. u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  107. u8 *mac = (u8 *) KSEG1ADDR(ee + WHRHPG300N_MAC_OFFSET);
  108. ath79_register_m25p80(NULL);
  109. ath79_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  110. AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  111. AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  112. AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  113. AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
  114. ath79_register_leds_gpio(-1, ARRAY_SIZE(whrhpg300n_leds_gpio),
  115. whrhpg300n_leds_gpio);
  116. ath79_register_gpio_keys_polled(-1, WHRHPG300N_KEYS_POLL_INTERVAL,
  117. ARRAY_SIZE(whrhpg300n_gpio_keys),
  118. whrhpg300n_gpio_keys);
  119. ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  120. ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
  121. ath79_register_mdio(0, 0x0);
  122. /* LAN ports */
  123. ath79_register_eth(1);
  124. /* WAN port */
  125. ath79_register_eth(0);
  126. ap9x_pci_setup_wmac_led_pin(0, 1);
  127. ap91_pci_init(ee, mac);
  128. }
  129. MIPS_MACHINE(ATH79_MACH_WHR_HP_G300N, "WHR-HP-G300N", "Buffalo WHR-HP-G300N",
  130. whrhpg300n_setup);
  131. MIPS_MACHINE(ATH79_MACH_WHR_G301N, "WHR-G301N", "Buffalo WHR-G301N",
  132. whrhpg300n_setup);
  133. MIPS_MACHINE(ATH79_MACH_WHR_HP_GN, "WHR-HP-GN", "Buffalo WHR-HP-GN",
  134. whrhpg300n_setup);