mach-zcn-1523h.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. * Zcomax ZCN-1523H-2-8/5-16 board support
  3. *
  4. * Copyright (C) 2010-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/ath79.h>
  11. #include <asm/mach-ath79/ar71xx_regs.h>
  12. #include "common.h"
  13. #include "dev-eth.h"
  14. #include "dev-m25p80.h"
  15. #include "dev-ap9x-pci.h"
  16. #include "dev-gpio-buttons.h"
  17. #include "dev-leds-gpio.h"
  18. #include "machtypes.h"
  19. #define ZCN_1523H_GPIO_BTN_RESET 0
  20. #define ZCN_1523H_GPIO_LED_INIT 11
  21. #define ZCN_1523H_GPIO_LED_LAN1 17
  22. #define ZCN_1523H_2_GPIO_LED_WEAK 13
  23. #define ZCN_1523H_2_GPIO_LED_MEDIUM 14
  24. #define ZCN_1523H_2_GPIO_LED_STRONG 15
  25. #define ZCN_1523H_5_GPIO_LAN2_POWER 1
  26. #define ZCN_1523H_5_GPIO_LED_LAN2 13
  27. #define ZCN_1523H_5_GPIO_LED_WEAK 14
  28. #define ZCN_1523H_5_GPIO_LED_MEDIUM 15
  29. #define ZCN_1523H_5_GPIO_LED_STRONG 16
  30. #define ZCN_1523H_KEYS_POLL_INTERVAL 20 /* msecs */
  31. #define ZCN_1523H_KEYS_DEBOUNCE_INTERVAL (3 * ZCN_1523H_KEYS_POLL_INTERVAL)
  32. static struct gpio_keys_button zcn_1523h_gpio_keys[] __initdata = {
  33. {
  34. .desc = "reset",
  35. .type = EV_KEY,
  36. .code = KEY_RESTART,
  37. .debounce_interval = ZCN_1523H_KEYS_DEBOUNCE_INTERVAL,
  38. .gpio = ZCN_1523H_GPIO_BTN_RESET,
  39. .active_low = 1,
  40. }
  41. };
  42. static struct gpio_led zcn_1523h_leds_gpio[] __initdata = {
  43. {
  44. .name = "zcn-1523h:amber:init",
  45. .gpio = ZCN_1523H_GPIO_LED_INIT,
  46. .active_low = 1,
  47. }, {
  48. .name = "zcn-1523h:green:lan1",
  49. .gpio = ZCN_1523H_GPIO_LED_LAN1,
  50. .active_low = 1,
  51. }
  52. };
  53. static struct gpio_led zcn_1523h_2_leds_gpio[] __initdata = {
  54. {
  55. .name = "zcn-1523h:red:weak",
  56. .gpio = ZCN_1523H_2_GPIO_LED_WEAK,
  57. .active_low = 1,
  58. }, {
  59. .name = "zcn-1523h:amber:medium",
  60. .gpio = ZCN_1523H_2_GPIO_LED_MEDIUM,
  61. .active_low = 1,
  62. }, {
  63. .name = "zcn-1523h:green:strong",
  64. .gpio = ZCN_1523H_2_GPIO_LED_STRONG,
  65. .active_low = 1,
  66. }
  67. };
  68. static struct gpio_led zcn_1523h_5_leds_gpio[] __initdata = {
  69. {
  70. .name = "zcn-1523h:red:weak",
  71. .gpio = ZCN_1523H_5_GPIO_LED_WEAK,
  72. .active_low = 1,
  73. }, {
  74. .name = "zcn-1523h:amber:medium",
  75. .gpio = ZCN_1523H_5_GPIO_LED_MEDIUM,
  76. .active_low = 1,
  77. }, {
  78. .name = "zcn-1523h:green:strong",
  79. .gpio = ZCN_1523H_5_GPIO_LED_STRONG,
  80. .active_low = 1,
  81. }, {
  82. .name = "zcn-1523h:green:lan2",
  83. .gpio = ZCN_1523H_5_GPIO_LED_LAN2,
  84. .active_low = 1,
  85. }
  86. };
  87. static void __init zcn_1523h_generic_setup(void)
  88. {
  89. u8 *mac = (u8 *) KSEG1ADDR(0x1f7e0004);
  90. u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000);
  91. ath79_gpio_function_disable(AR724X_GPIO_FUNC_ETH_SWITCH_LED0_EN |
  92. AR724X_GPIO_FUNC_ETH_SWITCH_LED1_EN |
  93. AR724X_GPIO_FUNC_ETH_SWITCH_LED2_EN |
  94. AR724X_GPIO_FUNC_ETH_SWITCH_LED3_EN |
  95. AR724X_GPIO_FUNC_ETH_SWITCH_LED4_EN);
  96. ath79_register_m25p80(NULL);
  97. ath79_register_leds_gpio(0, ARRAY_SIZE(zcn_1523h_leds_gpio),
  98. zcn_1523h_leds_gpio);
  99. ath79_register_gpio_keys_polled(-1, ZCN_1523H_KEYS_POLL_INTERVAL,
  100. ARRAY_SIZE(zcn_1523h_gpio_keys),
  101. zcn_1523h_gpio_keys);
  102. ap91_pci_init(ee, mac);
  103. ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  104. ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
  105. ath79_register_mdio(0, 0x0);
  106. /* LAN1 port */
  107. ath79_register_eth(0);
  108. }
  109. static void __init zcn_1523h_2_setup(void)
  110. {
  111. zcn_1523h_generic_setup();
  112. ap9x_pci_setup_wmac_gpio(0, BIT(9), 0);
  113. ath79_register_leds_gpio(1, ARRAY_SIZE(zcn_1523h_2_leds_gpio),
  114. zcn_1523h_2_leds_gpio);
  115. }
  116. MIPS_MACHINE(ATH79_MACH_ZCN_1523H_2, "ZCN-1523H-2", "Zcomax ZCN-1523H-2",
  117. zcn_1523h_2_setup);
  118. static void __init zcn_1523h_5_setup(void)
  119. {
  120. zcn_1523h_generic_setup();
  121. ap9x_pci_setup_wmac_gpio(0, BIT(8), 0);
  122. ath79_register_leds_gpio(1, ARRAY_SIZE(zcn_1523h_5_leds_gpio),
  123. zcn_1523h_5_leds_gpio);
  124. /* LAN2 port */
  125. ath79_register_eth(1);
  126. }
  127. MIPS_MACHINE(ATH79_MACH_ZCN_1523H_5, "ZCN-1523H-5", "Zcomax ZCN-1523H-5",
  128. zcn_1523h_5_setup);