mach-tube2h.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. * ALFA NETWORK Tube2H board support
  3. *
  4. * Copyright (C) 2014 Gabor Juhos <juhosg@openwrt.org>
  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-wmac.h"
  19. #include "machtypes.h"
  20. #define TUBE2H_GPIO_LED_SIGNAL4 0
  21. #define TUBE2H_GPIO_LED_SIGNAL3 1
  22. #define TUBE2H_GPIO_LED_SIGNAL2 13
  23. #define TUBE2H_GPIO_LED_LAN 17
  24. #define TUBE2H_GPIO_LED_SIGNAL1 27
  25. #define TUBE2H_GPIO_EXT_LNA 28
  26. #define TUBE2H_GPIO_WDT_EN 22
  27. #define TUBE2H_GPIO_WDT_IN 18
  28. #define TUBE2H_GPIO_BTN_RESET 12
  29. #define TUBE2H_KEYS_POLL_INTERVAL 20 /* msecs */
  30. #define TUBE2H_KEYS_DEBOUNCE_INTERVAL (3 * TUBE2H_KEYS_POLL_INTERVAL)
  31. #define TUBE2H_ART_ADDRESS 0x1fff0000
  32. #define TUBE2H_LAN_MAC_OFFSET 0x06
  33. #define TUBE2H_CALDATA_OFFSET 0x1000
  34. static struct gpio_led tube2h_leds_gpio[] __initdata = {
  35. {
  36. .name = "alfa:blue:lan",
  37. .gpio = TUBE2H_GPIO_LED_LAN,
  38. .active_low = 1,
  39. },
  40. {
  41. .name = "alfa:red:signal1",
  42. .gpio = TUBE2H_GPIO_LED_SIGNAL1,
  43. .active_low = 1,
  44. },
  45. {
  46. .name = "alfa:orange:signal2",
  47. .gpio = TUBE2H_GPIO_LED_SIGNAL2,
  48. .active_low = 0,
  49. },
  50. {
  51. .name = "alfa:green:signal3",
  52. .gpio = TUBE2H_GPIO_LED_SIGNAL3,
  53. .active_low = 0,
  54. },
  55. {
  56. .name = "alfa:green:signal4",
  57. .gpio = TUBE2H_GPIO_LED_SIGNAL4,
  58. .active_low = 0,
  59. },
  60. };
  61. static struct gpio_keys_button tube2h_gpio_keys[] __initdata = {
  62. {
  63. .desc = "Reset button",
  64. .type = EV_KEY,
  65. .code = KEY_RESTART,
  66. .debounce_interval = TUBE2H_KEYS_DEBOUNCE_INTERVAL,
  67. .gpio = TUBE2H_GPIO_BTN_RESET,
  68. .active_low = 1,
  69. },
  70. };
  71. static void __init tube2h_setup(void)
  72. {
  73. u8 *art = (u8 *) KSEG1ADDR(TUBE2H_ART_ADDRESS);
  74. u32 t;
  75. ath79_gpio_function_disable(AR933X_GPIO_FUNC_JTAG_DISABLE |
  76. AR933X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  77. AR933X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  78. AR933X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  79. AR933X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  80. AR933X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
  81. /* Ensure that GPIO26 and GPIO27 are controllable by software */
  82. t = ath79_reset_rr(AR933X_RESET_REG_BOOTSTRAP);
  83. t |= AR933X_BOOTSTRAP_MDIO_GPIO_EN;
  84. ath79_reset_wr(AR933X_RESET_REG_BOOTSTRAP, t);
  85. gpio_request_one(TUBE2H_GPIO_EXT_LNA,
  86. GPIOF_OUT_INIT_HIGH | GPIOF_EXPORT_DIR_FIXED,
  87. "external LNA0");
  88. gpio_request_one(TUBE2H_GPIO_WDT_IN,
  89. GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
  90. "WDT input");
  91. gpio_request_one(TUBE2H_GPIO_WDT_EN,
  92. GPIOF_OUT_INIT_LOW | GPIOF_EXPORT_DIR_FIXED,
  93. "WDT enable");
  94. ath79_register_wmac(art + TUBE2H_CALDATA_OFFSET, NULL);
  95. ath79_register_m25p80(NULL);
  96. ath79_register_leds_gpio(-1, ARRAY_SIZE(tube2h_leds_gpio),
  97. tube2h_leds_gpio);
  98. ath79_register_gpio_keys_polled(-1, TUBE2H_KEYS_POLL_INTERVAL,
  99. ARRAY_SIZE(tube2h_gpio_keys),
  100. tube2h_gpio_keys);
  101. ath79_init_mac(ath79_eth0_data.mac_addr,
  102. art + TUBE2H_LAN_MAC_OFFSET, 0);
  103. ath79_register_mdio(0, 0x0);
  104. ath79_register_eth(0);
  105. }
  106. MIPS_MACHINE(ATH79_MACH_TUBE2H, "TUBE2H", "ALFA NETWORK Tube2H",
  107. tube2h_setup);