1
0

mach-mzk-w300nh.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * Planex MZK-W300NH board support
  3. *
  4. * Copyright (C) 2008-2012 Gabor Juhos <juhosg@openwrt.org>
  5. * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License version 2 as published
  9. * by the Free Software Foundation.
  10. */
  11. #include <asm/mach-ath79/ath79.h>
  12. #include "dev-eth.h"
  13. #include "dev-gpio-buttons.h"
  14. #include "dev-leds-gpio.h"
  15. #include "dev-m25p80.h"
  16. #include "dev-wmac.h"
  17. #include "machtypes.h"
  18. #define MZK_W300NH_GPIO_LED_STATUS 1
  19. #define MZK_W300NH_GPIO_LED_WPS 3
  20. #define MZK_W300NH_GPIO_LED_WLAN 6
  21. #define MZK_W300NH_GPIO_LED_AP_GREEN 15
  22. #define MZK_W300NH_GPIO_LED_AP_AMBER 16
  23. #define MZK_W300NH_GPIO_BTN_APROUTER 5
  24. #define MZK_W300NH_GPIO_BTN_WPS 12
  25. #define MZK_W300NH_GPIO_BTN_RESET 21
  26. #define MZK_W300NH_KEYS_POLL_INTERVAL 20 /* msecs */
  27. #define MZK_W300NH_KEYS_DEBOUNCE_INTERVAL (3 * MZK_W300NH_KEYS_POLL_INTERVAL)
  28. static struct gpio_led mzk_w300nh_leds_gpio[] __initdata = {
  29. {
  30. .name = "planex:green:status",
  31. .gpio = MZK_W300NH_GPIO_LED_STATUS,
  32. .active_low = 1,
  33. }, {
  34. .name = "planex:blue:wps",
  35. .gpio = MZK_W300NH_GPIO_LED_WPS,
  36. .active_low = 1,
  37. }, {
  38. .name = "planex:green:wlan",
  39. .gpio = MZK_W300NH_GPIO_LED_WLAN,
  40. .active_low = 1,
  41. }, {
  42. .name = "planex:green:aprouter",
  43. .gpio = MZK_W300NH_GPIO_LED_AP_GREEN,
  44. }, {
  45. .name = "planex:amber:aprouter",
  46. .gpio = MZK_W300NH_GPIO_LED_AP_AMBER,
  47. }
  48. };
  49. static struct gpio_keys_button mzk_w300nh_gpio_keys[] __initdata = {
  50. {
  51. .desc = "reset",
  52. .type = EV_KEY,
  53. .code = KEY_RESTART,
  54. .debounce_interval = MZK_W300NH_KEYS_DEBOUNCE_INTERVAL,
  55. .gpio = MZK_W300NH_GPIO_BTN_RESET,
  56. .active_low = 1,
  57. }, {
  58. .desc = "wps",
  59. .type = EV_KEY,
  60. .code = KEY_WPS_BUTTON,
  61. .debounce_interval = MZK_W300NH_KEYS_DEBOUNCE_INTERVAL,
  62. .gpio = MZK_W300NH_GPIO_BTN_WPS,
  63. .active_low = 1,
  64. }, {
  65. .desc = "aprouter",
  66. .type = EV_KEY,
  67. .code = BTN_2,
  68. .debounce_interval = MZK_W300NH_KEYS_DEBOUNCE_INTERVAL,
  69. .gpio = MZK_W300NH_GPIO_BTN_APROUTER,
  70. .active_low = 0,
  71. }
  72. };
  73. #define MZK_W300NH_WAN_PHYMASK BIT(4)
  74. #define MZK_W300NH_MDIO_MASK (~MZK_W300NH_WAN_PHYMASK)
  75. static void __init mzk_w300nh_setup(void)
  76. {
  77. u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
  78. ath79_register_mdio(0, MZK_W300NH_MDIO_MASK);
  79. ath79_init_mac(ath79_eth0_data.mac_addr, eeprom, 0);
  80. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  81. ath79_eth0_data.speed = SPEED_100;
  82. ath79_eth0_data.duplex = DUPLEX_FULL;
  83. ath79_eth0_data.has_ar8216 = 1;
  84. ath79_init_mac(ath79_eth1_data.mac_addr, eeprom, 1);
  85. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  86. ath79_eth1_data.phy_mask = MZK_W300NH_WAN_PHYMASK;
  87. ath79_register_eth(0);
  88. ath79_register_eth(1);
  89. ath79_register_m25p80(NULL);
  90. ath79_register_leds_gpio(-1, ARRAY_SIZE(mzk_w300nh_leds_gpio),
  91. mzk_w300nh_leds_gpio);
  92. ath79_register_gpio_keys_polled(-1, MZK_W300NH_KEYS_POLL_INTERVAL,
  93. ARRAY_SIZE(mzk_w300nh_gpio_keys),
  94. mzk_w300nh_gpio_keys);
  95. ath79_register_wmac(eeprom, NULL);
  96. }
  97. MIPS_MACHINE(ATH79_MACH_MZK_W300NH, "MZK-W300NH", "Planex MZK-W300NH",
  98. mzk_w300nh_setup);