1
0

mach-mzk-w04nu.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * Planex MZK-W04NU board support
  3. *
  4. * Copyright (C) 2009-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 "dev-eth.h"
  12. #include "dev-gpio-buttons.h"
  13. #include "dev-leds-gpio.h"
  14. #include "dev-m25p80.h"
  15. #include "dev-usb.h"
  16. #include "dev-wmac.h"
  17. #include "machtypes.h"
  18. #define MZK_W04NU_GPIO_LED_USB 0
  19. #define MZK_W04NU_GPIO_LED_STATUS 1
  20. #define MZK_W04NU_GPIO_LED_WPS 3
  21. #define MZK_W04NU_GPIO_LED_WLAN 6
  22. #define MZK_W04NU_GPIO_LED_AP 15
  23. #define MZK_W04NU_GPIO_LED_ROUTER 16
  24. #define MZK_W04NU_GPIO_BTN_APROUTER 5
  25. #define MZK_W04NU_GPIO_BTN_WPS 12
  26. #define MZK_W04NU_GPIO_BTN_RESET 21
  27. #define MZK_W04NU_KEYS_POLL_INTERVAL 20 /* msecs */
  28. #define MZK_W04NU_KEYS_DEBOUNCE_INTERVAL (3 * MZK_W04NU_KEYS_POLL_INTERVAL)
  29. static struct gpio_led mzk_w04nu_leds_gpio[] __initdata = {
  30. {
  31. .name = "planex:green:status",
  32. .gpio = MZK_W04NU_GPIO_LED_STATUS,
  33. .active_low = 1,
  34. }, {
  35. .name = "planex:blue:wps",
  36. .gpio = MZK_W04NU_GPIO_LED_WPS,
  37. .active_low = 1,
  38. }, {
  39. .name = "planex:green:wlan",
  40. .gpio = MZK_W04NU_GPIO_LED_WLAN,
  41. .active_low = 1,
  42. }, {
  43. .name = "planex:green:usb",
  44. .gpio = MZK_W04NU_GPIO_LED_USB,
  45. .active_low = 1,
  46. }, {
  47. .name = "planex:green:ap",
  48. .gpio = MZK_W04NU_GPIO_LED_AP,
  49. .active_low = 1,
  50. }, {
  51. .name = "planex:green:router",
  52. .gpio = MZK_W04NU_GPIO_LED_ROUTER,
  53. .active_low = 1,
  54. }
  55. };
  56. static struct gpio_keys_button mzk_w04nu_gpio_keys[] __initdata = {
  57. {
  58. .desc = "reset",
  59. .type = EV_KEY,
  60. .code = KEY_RESTART,
  61. .debounce_interval = MZK_W04NU_KEYS_DEBOUNCE_INTERVAL,
  62. .gpio = MZK_W04NU_GPIO_BTN_RESET,
  63. .active_low = 1,
  64. }, {
  65. .desc = "wps",
  66. .type = EV_KEY,
  67. .code = KEY_WPS_BUTTON,
  68. .debounce_interval = MZK_W04NU_KEYS_DEBOUNCE_INTERVAL,
  69. .gpio = MZK_W04NU_GPIO_BTN_WPS,
  70. .active_low = 1,
  71. }, {
  72. .desc = "aprouter",
  73. .type = EV_KEY,
  74. .code = BTN_2,
  75. .debounce_interval = MZK_W04NU_KEYS_DEBOUNCE_INTERVAL,
  76. .gpio = MZK_W04NU_GPIO_BTN_APROUTER,
  77. .active_low = 0,
  78. }
  79. };
  80. #define MZK_W04NU_WAN_PHYMASK BIT(4)
  81. #define MZK_W04NU_MDIO_MASK (~MZK_W04NU_WAN_PHYMASK)
  82. static void __init mzk_w04nu_setup(void)
  83. {
  84. u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
  85. ath79_register_mdio(0, MZK_W04NU_MDIO_MASK);
  86. ath79_init_mac(ath79_eth0_data.mac_addr, eeprom, 0);
  87. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  88. ath79_eth0_data.speed = SPEED_100;
  89. ath79_eth0_data.duplex = DUPLEX_FULL;
  90. ath79_eth0_data.has_ar8216 = 1;
  91. ath79_init_mac(ath79_eth1_data.mac_addr, eeprom, 1);
  92. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  93. ath79_eth1_data.phy_mask = MZK_W04NU_WAN_PHYMASK;
  94. ath79_register_eth(0);
  95. ath79_register_eth(1);
  96. ath79_register_m25p80(NULL);
  97. ath79_register_leds_gpio(-1, ARRAY_SIZE(mzk_w04nu_leds_gpio),
  98. mzk_w04nu_leds_gpio);
  99. ath79_register_gpio_keys_polled(-1, MZK_W04NU_KEYS_POLL_INTERVAL,
  100. ARRAY_SIZE(mzk_w04nu_gpio_keys),
  101. mzk_w04nu_gpio_keys);
  102. ath79_register_usb();
  103. ath79_register_wmac(eeprom, NULL);
  104. }
  105. MIPS_MACHINE(ATH79_MACH_MZK_W04NU, "MZK-W04NU", "Planex MZK-W04NU",
  106. mzk_w04nu_setup);