mach-alfa-nx.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * ALFA Network N2/N5 board support
  3. *
  4. * Copyright (C) 2011-2012 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 <asm/mach-ath79/ar71xx_regs.h>
  11. #include <asm/mach-ath79/ath79.h>
  12. #include "common.h"
  13. #include "dev-eth.h"
  14. #include "dev-ap9x-pci.h"
  15. #include "dev-gpio-buttons.h"
  16. #include "dev-leds-gpio.h"
  17. #include "dev-m25p80.h"
  18. #include "machtypes.h"
  19. #define ALFA_NX_GPIO_LED_2 17
  20. #define ALFA_NX_GPIO_LED_3 16
  21. #define ALFA_NX_GPIO_LED_5 12
  22. #define ALFA_NX_GPIO_LED_6 8
  23. #define ALFA_NX_GPIO_LED_7 6
  24. #define ALFA_NX_GPIO_LED_8 7
  25. #define ALFA_NX_GPIO_BTN_RESET 11
  26. #define ALFA_NX_KEYS_POLL_INTERVAL 20 /* msecs */
  27. #define ALFA_NX_KEYS_DEBOUNCE_INTERVAL (3 * ALFA_NX_KEYS_POLL_INTERVAL)
  28. #define ALFA_NX_MAC0_OFFSET 0
  29. #define ALFA_NX_MAC1_OFFSET 6
  30. #define ALFA_NX_CALDATA_OFFSET 0x1000
  31. static struct gpio_keys_button alfa_nx_gpio_keys[] __initdata = {
  32. {
  33. .desc = "Reset button",
  34. .type = EV_KEY,
  35. .code = KEY_RESTART,
  36. .debounce_interval = ALFA_NX_KEYS_DEBOUNCE_INTERVAL,
  37. .gpio = ALFA_NX_GPIO_BTN_RESET,
  38. .active_low = 1,
  39. }
  40. };
  41. static struct gpio_led alfa_nx_leds_gpio[] __initdata = {
  42. {
  43. .name = "alfa:green:led_2",
  44. .gpio = ALFA_NX_GPIO_LED_2,
  45. .active_low = 1,
  46. }, {
  47. .name = "alfa:green:led_3",
  48. .gpio = ALFA_NX_GPIO_LED_3,
  49. .active_low = 1,
  50. }, {
  51. .name = "alfa:red:led_5",
  52. .gpio = ALFA_NX_GPIO_LED_5,
  53. .active_low = 1,
  54. }, {
  55. .name = "alfa:amber:led_6",
  56. .gpio = ALFA_NX_GPIO_LED_6,
  57. .active_low = 1,
  58. }, {
  59. .name = "alfa:green:led_7",
  60. .gpio = ALFA_NX_GPIO_LED_7,
  61. .active_low = 1,
  62. }, {
  63. .name = "alfa:green:led_8",
  64. .gpio = ALFA_NX_GPIO_LED_8,
  65. .active_low = 1,
  66. }
  67. };
  68. static void __init alfa_nx_setup(void)
  69. {
  70. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  71. ath79_gpio_function_setup(AR724X_GPIO_FUNC_JTAG_DISABLE,
  72. AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  73. AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  74. AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  75. AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  76. AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
  77. ath79_register_m25p80(NULL);
  78. ath79_register_leds_gpio(0, ARRAY_SIZE(alfa_nx_leds_gpio),
  79. alfa_nx_leds_gpio);
  80. ath79_register_gpio_keys_polled(-1, ALFA_NX_KEYS_POLL_INTERVAL,
  81. ARRAY_SIZE(alfa_nx_gpio_keys),
  82. alfa_nx_gpio_keys);
  83. ath79_register_mdio(0, 0x0);
  84. ath79_init_mac(ath79_eth0_data.mac_addr,
  85. art + ALFA_NX_MAC0_OFFSET, 0);
  86. ath79_init_mac(ath79_eth1_data.mac_addr,
  87. art + ALFA_NX_MAC1_OFFSET, 0);
  88. /* WAN port */
  89. ath79_register_eth(0);
  90. /* LAN port */
  91. ath79_register_eth(1);
  92. ap91_pci_init(art + ALFA_NX_CALDATA_OFFSET, NULL);
  93. }
  94. MIPS_MACHINE(ATH79_MACH_ALFA_NX, "ALFA-NX", "ALFA Network N2/N5",
  95. alfa_nx_setup);