1
0

mach-gl-domino.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * Domino 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 DOMINO_GPIO_LED_WLAN 0
  23. #define DOMINO_GPIO_LED_WAN 17
  24. #define DOMINO_GPIO_LED_USB 1
  25. #define DOMINO_GPIO_LED_LAN1 13
  26. #define DOMINO_GPIO_LED_LAN2 14
  27. #define DOMINO_GPIO_LED_LAN3 15
  28. #define DOMINO_GPIO_LED_LAN4 16
  29. #define DOMINO_GPIO_LED_SYS 27
  30. #define DOMINO_GPIO_LED_WPS 26
  31. #define DOMINO_GPIO_USB_POWER 6
  32. #define DOMINO_GPIO_BTN_RESET 11
  33. #define DOMINO_GPIO_BTN_WPS 20
  34. #define DOMINO_KEYS_POLL_INTERVAL 20 /* msecs */
  35. #define DOMINO_KEYS_DEBOUNCE_INTERVAL (3 * DOMINO_KEYS_POLL_INTERVAL)
  36. #define DOMINO_MAC0_OFFSET 0x0000
  37. #define DOMINO_MAC1_OFFSET 0x0000
  38. #define DOMINO_CALDATA_OFFSET 0x1000
  39. #define DOMINO_WMAC_MAC_OFFSET 0x0000
  40. static struct gpio_led domino_leds_gpio[] __initdata = {
  41. {
  42. .name = "gl-domino:blue:wlan",
  43. .gpio = DOMINO_GPIO_LED_WLAN,
  44. .active_low = 0,
  45. },
  46. {
  47. .name = "gl-domino:red:wan",
  48. .gpio = DOMINO_GPIO_LED_WAN,
  49. .active_low = 1,
  50. },
  51. {
  52. .name = "gl-domino:white:usb",
  53. .gpio = DOMINO_GPIO_LED_USB,
  54. .active_low = 0,
  55. },
  56. {
  57. .name = "gl-domino:green:lan1",
  58. .gpio = DOMINO_GPIO_LED_LAN1,
  59. .active_low = 0,
  60. },
  61. {
  62. .name = "gl-domino:yellow:wps",
  63. .gpio = DOMINO_GPIO_LED_WPS,
  64. .active_low = 1,
  65. },
  66. {
  67. .name = "gl-domino:orange:sys",
  68. .gpio = DOMINO_GPIO_LED_SYS,
  69. .active_low = 1,
  70. },
  71. };
  72. static struct gpio_keys_button domino_gpio_keys[] __initdata = {
  73. {
  74. .desc = "reset",
  75. .type = EV_KEY,
  76. .code = KEY_RESTART,
  77. .debounce_interval = DOMINO_KEYS_DEBOUNCE_INTERVAL,
  78. .gpio = DOMINO_GPIO_BTN_RESET,
  79. .active_low = 0,
  80. },
  81. {
  82. .desc = "wps",
  83. .type = EV_KEY,
  84. .code = KEY_WPS_BUTTON,
  85. .debounce_interval = DOMINO_KEYS_DEBOUNCE_INTERVAL,
  86. .gpio = DOMINO_GPIO_BTN_WPS,
  87. .active_low = 0,
  88. }
  89. };
  90. static void __init domino_setup(void)
  91. {
  92. /* ART base address */
  93. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  94. /* disable PHY_SWAP and PHY_ADDR_SWAP bits */
  95. ath79_setup_ar933x_phy4_switch(false, false);
  96. /* register flash. */
  97. ath79_register_m25p80(NULL);
  98. /* register gpio LEDs and keys */
  99. ath79_register_leds_gpio(-1, ARRAY_SIZE(domino_leds_gpio),
  100. domino_leds_gpio);
  101. ath79_register_gpio_keys_polled(-1, DOMINO_KEYS_POLL_INTERVAL,
  102. ARRAY_SIZE(domino_gpio_keys),
  103. domino_gpio_keys);
  104. gpio_request_one(DOMINO_GPIO_USB_POWER,
  105. GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  106. "USB power");
  107. /* enable usb */
  108. ath79_register_usb();
  109. /* register eth0 as WAN, eth1 as LAN */
  110. ath79_init_mac(ath79_eth0_data.mac_addr, art+DOMINO_MAC0_OFFSET, 0);
  111. ath79_init_mac(ath79_eth1_data.mac_addr, art+DOMINO_MAC1_OFFSET, 0);
  112. ath79_register_mdio(0, 0x0);
  113. ath79_register_eth(0);
  114. ath79_register_eth(1);
  115. /* register wireless mac with cal data */
  116. ath79_register_wmac(art + DOMINO_CALDATA_OFFSET, art + DOMINO_WMAC_MAC_OFFSET);
  117. }
  118. MIPS_MACHINE(ATH79_MACH_GL_DOMINO, "DOMINO", "Domino Pi", domino_setup);