mach-tew-732br.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * TRENDnet TEW-732BR board support
  3. *
  4. * Copyright (C) 2013 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 <linux/platform_device.h>
  12. #include <asm/mach-ath79/ath79.h>
  13. #include <asm/mach-ath79/ar71xx_regs.h>
  14. #include "common.h"
  15. #include "dev-eth.h"
  16. #include "dev-gpio-buttons.h"
  17. #include "dev-leds-gpio.h"
  18. #include "dev-m25p80.h"
  19. #include "dev-wmac.h"
  20. #include "machtypes.h"
  21. #define TEW_732BR_GPIO_BTN_WPS 16
  22. #define TEW_732BR_GPIO_BTN_RESET 17
  23. #define TEW_732BR_GPIO_LED_POWER_GREEN 4
  24. #define TEW_732BR_GPIO_LED_POWER_AMBER 14
  25. #define TEW_732BR_GPIO_LED_PLANET_GREEN 12
  26. #define TEW_732BR_GPIO_LED_PLANET_AMBER 22
  27. #define TEW_732BR_KEYS_POLL_INTERVAL 20 /* msecs */
  28. #define TEW_732BR_KEYS_DEBOUNCE_INTERVAL (3 * TEW_732BR_KEYS_POLL_INTERVAL)
  29. #define TEW_732BR_ART_ADDRESS 0x1fff0000
  30. #define TEW_732BR_CALDATA_OFFSET 0x1000
  31. #define TEW_732BR_LAN_MAC_OFFSET 0xffa0
  32. #define TEW_732BR_WAN_MAC_OFFSET 0xffb4
  33. static struct gpio_led tew_732br_leds_gpio[] __initdata = {
  34. {
  35. .name = "trendnet:green:power",
  36. .gpio = TEW_732BR_GPIO_LED_POWER_GREEN,
  37. .active_low = 0,
  38. },
  39. {
  40. .name = "trendnet:amber:power",
  41. .gpio = TEW_732BR_GPIO_LED_POWER_AMBER,
  42. .active_low = 0,
  43. },
  44. {
  45. .name = "trendnet:green:wan",
  46. .gpio = TEW_732BR_GPIO_LED_PLANET_GREEN,
  47. .active_low = 1,
  48. },
  49. {
  50. .name = "trendnet:amber:wan",
  51. .gpio = TEW_732BR_GPIO_LED_PLANET_AMBER,
  52. .active_low = 0,
  53. },
  54. };
  55. static struct gpio_keys_button tew_732br_gpio_keys[] __initdata = {
  56. {
  57. .desc = "Reset button",
  58. .type = EV_KEY,
  59. .code = KEY_RESTART,
  60. .debounce_interval = TEW_732BR_KEYS_DEBOUNCE_INTERVAL,
  61. .gpio = TEW_732BR_GPIO_BTN_RESET,
  62. .active_low = 1,
  63. },
  64. {
  65. .desc = "WPS button",
  66. .type = EV_KEY,
  67. .code = KEY_WPS_BUTTON,
  68. .debounce_interval = TEW_732BR_KEYS_DEBOUNCE_INTERVAL,
  69. .gpio = TEW_732BR_GPIO_BTN_WPS,
  70. .active_low = 1,
  71. },
  72. };
  73. static void __init tew_732br_setup(void)
  74. {
  75. u8 *art = (u8 *) KSEG1ADDR(TEW_732BR_ART_ADDRESS);
  76. u8 lan_mac[ETH_ALEN];
  77. u8 wan_mac[ETH_ALEN];
  78. ath79_register_leds_gpio(-1, ARRAY_SIZE(tew_732br_leds_gpio),
  79. tew_732br_leds_gpio);
  80. ath79_register_gpio_keys_polled(1, TEW_732BR_KEYS_POLL_INTERVAL,
  81. ARRAY_SIZE(tew_732br_gpio_keys),
  82. tew_732br_gpio_keys);
  83. ath79_register_m25p80(NULL);
  84. ath79_parse_ascii_mac(art + TEW_732BR_LAN_MAC_OFFSET, lan_mac);
  85. ath79_parse_ascii_mac(art + TEW_732BR_WAN_MAC_OFFSET, wan_mac);
  86. ath79_register_wmac(art + TEW_732BR_CALDATA_OFFSET, lan_mac);
  87. ath79_register_mdio(1, 0x0);
  88. ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_SW_ONLY_MODE);
  89. /* LAN: GMAC1 is connected to the internal switch */
  90. ath79_init_mac(ath79_eth1_data.mac_addr, lan_mac, 0);
  91. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  92. ath79_register_eth(1);
  93. /* WAN: GMAC0 is connected to the PHY4 of the internal switch */
  94. ath79_init_mac(ath79_eth0_data.mac_addr, wan_mac, 0);
  95. ath79_switch_data.phy4_mii_en = 1;
  96. ath79_switch_data.phy_poll_mask = BIT(4);
  97. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  98. ath79_eth0_data.phy_mask = BIT(4);
  99. ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
  100. ath79_register_eth(0);
  101. }
  102. MIPS_MACHINE(ATH79_MACH_TEW_732BR, "TEW-732BR", "TRENDnet TEW-732BR",
  103. tew_732br_setup);