mach-gl-mifi.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * Mifi 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_MIFI_GPIO_LED_WAN 27
  23. #define GL_MIFI_GPIO_LED_LAN 16
  24. #define GL_MIFI_GPIO_LED_WLAN 1
  25. #define GL_MIFI_GPIO_LED_NET 0
  26. #define GL_MIFI_GPIO_LED_3GCONTROL 7
  27. #define GL_MIFI_GPIO_BTN_RESET 11
  28. #define GL_MIFI_KEYS_POLL_INTERVAL 20 /* msecs */
  29. #define GL_MIFI_KEYS_DEBOUNCE_INTERVAL (3 * GL_MIFI_KEYS_POLL_INTERVAL)
  30. #define GL_MIFI_MAC0_OFFSET 0x0000
  31. #define GL_MIFI_MAC1_OFFSET 0x0000
  32. #define GL_MIFI_CALDATA_OFFSET 0x1000
  33. #define GL_MIFI_WMAC_MAC_OFFSET 0x0000
  34. static struct gpio_led gl_mifi_leds_gpio[] __initdata = {
  35. {
  36. .name = "gl-mifi:wan",
  37. .gpio = GL_MIFI_GPIO_LED_WAN,
  38. .active_low = 0,
  39. },
  40. {
  41. .name = "gl-mifi:lan",
  42. .gpio = GL_MIFI_GPIO_LED_LAN,
  43. .active_low = 0,
  44. },
  45. {
  46. .name = "gl-mifi:wlan",
  47. .gpio = GL_MIFI_GPIO_LED_WLAN,
  48. .active_low = 0,
  49. },
  50. {
  51. .name = "gl-mifi:net",
  52. .gpio = GL_MIFI_GPIO_LED_NET,
  53. .active_low = 0,
  54. },
  55. {
  56. .name = "gl-mifi:3gcontrol",
  57. .gpio = GL_MIFI_GPIO_LED_3GCONTROL,
  58. .active_low = 0,
  59. }
  60. };
  61. static struct gpio_keys_button gl_mifi_gpio_keys[] __initdata = {
  62. {
  63. .desc = "reset",
  64. .type = EV_KEY,
  65. .code = KEY_RESTART,
  66. .debounce_interval = GL_MIFI_KEYS_DEBOUNCE_INTERVAL,
  67. .gpio = GL_MIFI_GPIO_BTN_RESET,
  68. .active_low = 0,
  69. },
  70. };
  71. static void __init gl_mifi_setup(void)
  72. {
  73. /* ART base address */
  74. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  75. /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
  76. ath79_setup_ar933x_phy4_switch(false, false);
  77. /* register flash. */
  78. ath79_register_m25p80(NULL);
  79. /* register gpio LEDs and keys */
  80. ath79_register_leds_gpio(-1, ARRAY_SIZE(gl_mifi_leds_gpio),
  81. gl_mifi_leds_gpio);
  82. ath79_register_gpio_keys_polled(-1, GL_MIFI_KEYS_POLL_INTERVAL,
  83. ARRAY_SIZE(gl_mifi_gpio_keys),
  84. gl_mifi_gpio_keys);
  85. /* enable usb */
  86. ath79_register_usb();
  87. /* register eth0 as WAN, eth1 as LAN */
  88. ath79_init_mac(ath79_eth0_data.mac_addr, art+GL_MIFI_MAC0_OFFSET, 0);
  89. ath79_init_mac(ath79_eth1_data.mac_addr, art+GL_MIFI_MAC1_OFFSET, 0);
  90. ath79_register_mdio(0, 0x0);
  91. ath79_register_eth(0);
  92. ath79_register_eth(1);
  93. /* register wireless mac with cal data */
  94. ath79_register_wmac(art + GL_MIFI_CALDATA_OFFSET, art + GL_MIFI_WMAC_MAC_OFFSET);
  95. }
  96. MIPS_MACHINE(ATH79_MACH_GL_MIFI, "GL-MIFI", "GL-MIFI",gl_mifi_setup);