mach-tew-632brp.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * TrendNET TEW-632BRP 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. #include "nvram.h"
  19. #define TEW_632BRP_GPIO_LED_STATUS 1
  20. #define TEW_632BRP_GPIO_LED_WPS 3
  21. #define TEW_632BRP_GPIO_LED_WLAN 6
  22. #define TEW_632BRP_GPIO_BTN_WPS 12
  23. #define TEW_632BRP_GPIO_BTN_RESET 21
  24. #define TEW_632BRP_KEYS_POLL_INTERVAL 20 /* msecs */
  25. #define TEW_632BRP_KEYS_DEBOUNCE_INTERVAL (3 * TEW_632BRP_KEYS_POLL_INTERVAL)
  26. #define TEW_632BRP_CONFIG_ADDR 0x1f020000
  27. #define TEW_632BRP_CONFIG_SIZE 0x10000
  28. static struct gpio_led tew_632brp_leds_gpio[] __initdata = {
  29. {
  30. .name = "tew-632brp:green:status",
  31. .gpio = TEW_632BRP_GPIO_LED_STATUS,
  32. .active_low = 1,
  33. }, {
  34. .name = "tew-632brp:blue:wps",
  35. .gpio = TEW_632BRP_GPIO_LED_WPS,
  36. .active_low = 1,
  37. }, {
  38. .name = "tew-632brp:green:wlan",
  39. .gpio = TEW_632BRP_GPIO_LED_WLAN,
  40. .active_low = 1,
  41. }
  42. };
  43. static struct gpio_keys_button tew_632brp_gpio_keys[] __initdata = {
  44. {
  45. .desc = "reset",
  46. .type = EV_KEY,
  47. .code = KEY_RESTART,
  48. .debounce_interval = TEW_632BRP_KEYS_DEBOUNCE_INTERVAL,
  49. .gpio = TEW_632BRP_GPIO_BTN_RESET,
  50. .active_low = 1,
  51. }, {
  52. .desc = "wps",
  53. .type = EV_KEY,
  54. .code = KEY_WPS_BUTTON,
  55. .debounce_interval = TEW_632BRP_KEYS_DEBOUNCE_INTERVAL,
  56. .gpio = TEW_632BRP_GPIO_BTN_WPS,
  57. .active_low = 1,
  58. }
  59. };
  60. #define TEW_632BRP_LAN_PHYMASK BIT(0)
  61. #define TEW_632BRP_WAN_PHYMASK BIT(4)
  62. #define TEW_632BRP_MDIO_MASK (~(TEW_632BRP_LAN_PHYMASK | \
  63. TEW_632BRP_WAN_PHYMASK))
  64. static void __init tew_632brp_setup(void)
  65. {
  66. const char *config = (char *) KSEG1ADDR(TEW_632BRP_CONFIG_ADDR);
  67. u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
  68. u8 mac[6];
  69. u8 *wlan_mac = NULL;
  70. if (ath79_nvram_parse_mac_addr(config, TEW_632BRP_CONFIG_SIZE,
  71. "lan_mac=", mac) == 0) {
  72. ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  73. ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
  74. wlan_mac = mac;
  75. }
  76. ath79_register_mdio(0, TEW_632BRP_MDIO_MASK);
  77. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  78. ath79_eth0_data.phy_mask = TEW_632BRP_LAN_PHYMASK;
  79. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  80. ath79_eth1_data.phy_mask = TEW_632BRP_WAN_PHYMASK;
  81. ath79_register_eth(0);
  82. ath79_register_eth(1);
  83. ath79_register_m25p80(NULL);
  84. ath79_register_leds_gpio(-1, ARRAY_SIZE(tew_632brp_leds_gpio),
  85. tew_632brp_leds_gpio);
  86. ath79_register_gpio_keys_polled(-1, TEW_632BRP_KEYS_POLL_INTERVAL,
  87. ARRAY_SIZE(tew_632brp_gpio_keys),
  88. tew_632brp_gpio_keys);
  89. ath79_register_wmac(eeprom, wlan_mac);
  90. }
  91. MIPS_MACHINE(ATH79_MACH_TEW_632BRP, "TEW-632BRP", "TRENDnet TEW-632BRP",
  92. tew_632brp_setup);