mach-tube2h.c 3.0 KB

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