mach-gl-ar150.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * GL_ar150 board support
  3. *
  4. * Copyright (C) 2011 dongyuqi <729650915@qq.com>
  5. * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
  6. * Copyright (C) 2013 alzhao <alzhao@gmail.com>
  7. * Copyright (C) 2014 Michel Stempin <michel.stempin@wanadoo.fr>
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License version 2 as published
  11. * by the Free Software Foundation.
  12. */
  13. #include <linux/gpio.h>
  14. #include <asm/mach-ath79/ath79.h>
  15. #include "dev-eth.h"
  16. #include "dev-gpio-buttons.h"
  17. #include "dev-leds-gpio.h"
  18. #include "dev-m25p80.h"
  19. #include "dev-usb.h"
  20. #include "dev-wmac.h"
  21. #include "machtypes.h"
  22. #define GL_AR150_GPIO_LED_WLAN 0
  23. #define GL_AR150_GPIO_LED_LAN 13
  24. #define GL_AR150_GPIO_LED_WAN 15
  25. #define GL_AR150_GPIO_BIN_USB 6
  26. #define GL_AR150_GPIO_BTN_MANUAL 7
  27. #define GL_AR150_GPIO_BTN_AUTO 8
  28. #define GL_AR150_GPIO_BTN_RESET 11
  29. #define GL_AR150_KEYS_POLL_INTERVAL 20 /* msecs */
  30. #define GL_AR150_KEYS_DEBOUNCE_INTERVAL (3 * GL_AR150_KEYS_POLL_INTERVAL)
  31. #define GL_AR150_MAC0_OFFSET 0x0000
  32. #define GL_AR150_MAC1_OFFSET 0x0000
  33. #define GL_AR150_CALDATA_OFFSET 0x1000
  34. #define GL_AR150_WMAC_MAC_OFFSET 0x0000
  35. static struct gpio_led gl_ar150_leds_gpio[] __initdata = {
  36. {
  37. .name = "gl-ar150:wlan",
  38. .gpio = GL_AR150_GPIO_LED_WLAN,
  39. .active_low = 0,
  40. },
  41. {
  42. .name = "gl-ar150:lan",
  43. .gpio = GL_AR150_GPIO_LED_LAN,
  44. .active_low = 0,
  45. },
  46. {
  47. .name = "gl-ar150:wan",
  48. .gpio = GL_AR150_GPIO_LED_WAN,
  49. .active_low = 0,
  50. .default_state = 1,
  51. },
  52. };
  53. static struct gpio_keys_button gl_ar150_gpio_keys[] __initdata = {
  54. {
  55. .desc = "BTN_7",
  56. .type = EV_KEY,
  57. .code = BTN_7,
  58. .debounce_interval = GL_AR150_KEYS_DEBOUNCE_INTERVAL,
  59. .gpio = GL_AR150_GPIO_BTN_MANUAL,
  60. .active_low = 0,
  61. },
  62. {
  63. .desc = "BTN_8",
  64. .type = EV_KEY,
  65. .code = BTN_8,
  66. .debounce_interval = GL_AR150_KEYS_DEBOUNCE_INTERVAL,
  67. .gpio = GL_AR150_GPIO_BTN_AUTO,
  68. .active_low = 0,
  69. },
  70. {
  71. .desc = "reset",
  72. .type = EV_KEY,
  73. .code = KEY_RESTART,
  74. .debounce_interval = GL_AR150_KEYS_DEBOUNCE_INTERVAL,
  75. .gpio = GL_AR150_GPIO_BTN_RESET,
  76. .active_low = 0,
  77. },
  78. };
  79. static void __init gl_ar150_setup(void)
  80. {
  81. /* ART base address */
  82. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  83. /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
  84. ath79_setup_ar933x_phy4_switch(false, false);
  85. /* register flash. */
  86. ath79_register_m25p80(NULL);
  87. /* register gpio LEDs and keys */
  88. ath79_register_leds_gpio(-1, ARRAY_SIZE(gl_ar150_leds_gpio),
  89. gl_ar150_leds_gpio);
  90. ath79_register_gpio_keys_polled(-1, GL_AR150_KEYS_POLL_INTERVAL,
  91. ARRAY_SIZE(gl_ar150_gpio_keys),
  92. gl_ar150_gpio_keys);
  93. /* enable usb */
  94. gpio_request_one(GL_AR150_GPIO_BIN_USB,
  95. GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  96. "USB power");
  97. ath79_register_usb();
  98. /* register eth0 as WAN, eth1 as LAN */
  99. ath79_init_mac(ath79_eth0_data.mac_addr, art+GL_AR150_MAC0_OFFSET, 0);
  100. ath79_init_mac(ath79_eth1_data.mac_addr, art+GL_AR150_MAC1_OFFSET, 0);
  101. ath79_register_mdio(0, 0x0);
  102. ath79_register_eth(0);
  103. ath79_register_eth(1);
  104. /* register wireless mac with cal data */
  105. ath79_register_wmac(art + GL_AR150_CALDATA_OFFSET, art + GL_AR150_WMAC_MAC_OFFSET);
  106. }
  107. MIPS_MACHINE(ATH79_MACH_GL_AR150, "GL-AR150", "GL AR150",gl_ar150_setup);