mach-dir-615-c1.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * D-Link DIR-615 rev C1 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 DIR_615C1_GPIO_LED_ORANGE_STATUS 1 /* ORANGE:STATUS:TRICOLOR */
  20. #define DIR_615C1_GPIO_LED_BLUE_WPS 3 /* BLUE:WPS */
  21. #define DIR_615C1_GPIO_LED_GREEN_WAN 4 /* GREEN:WAN:TRICOLOR */
  22. #define DIR_615C1_GPIO_LED_GREEN_WANCPU 5 /* GREEN:WAN:CPU:TRICOLOR */
  23. #define DIR_615C1_GPIO_LED_GREEN_WLAN 6 /* GREEN:WLAN */
  24. #define DIR_615C1_GPIO_LED_GREEN_STATUS 14 /* GREEN:STATUS:TRICOLOR */
  25. #define DIR_615C1_GPIO_LED_ORANGE_WAN 15 /* ORANGE:WAN:TRICOLOR */
  26. /* buttons may need refinement */
  27. #define DIR_615C1_GPIO_BTN_WPS 12
  28. #define DIR_615C1_GPIO_BTN_RESET 21
  29. #define DIR_615C1_KEYS_POLL_INTERVAL 20 /* msecs */
  30. #define DIR_615C1_KEYS_DEBOUNCE_INTERVAL (3 * DIR_615C1_KEYS_POLL_INTERVAL)
  31. #define DIR_615C1_CONFIG_ADDR 0x1f020000
  32. #define DIR_615C1_CONFIG_SIZE 0x10000
  33. #define DIR_615C1_WLAN_MAC_ADDR 0x1f3fffb4
  34. static struct gpio_led dir_615c1_leds_gpio[] __initdata = {
  35. {
  36. .name = "d-link:orange:status",
  37. .gpio = DIR_615C1_GPIO_LED_ORANGE_STATUS,
  38. .active_low = 1,
  39. }, {
  40. .name = "d-link:blue:wps",
  41. .gpio = DIR_615C1_GPIO_LED_BLUE_WPS,
  42. .active_low = 1,
  43. }, {
  44. .name = "d-link:green:wan",
  45. .gpio = DIR_615C1_GPIO_LED_GREEN_WAN,
  46. .active_low = 1,
  47. }, {
  48. .name = "d-link:green:wancpu",
  49. .gpio = DIR_615C1_GPIO_LED_GREEN_WANCPU,
  50. .active_low = 1,
  51. }, {
  52. .name = "d-link:green:wlan",
  53. .gpio = DIR_615C1_GPIO_LED_GREEN_WLAN,
  54. .active_low = 1,
  55. }, {
  56. .name = "d-link:green:status",
  57. .gpio = DIR_615C1_GPIO_LED_GREEN_STATUS,
  58. .active_low = 1,
  59. }, {
  60. .name = "d-link:orange:wan",
  61. .gpio = DIR_615C1_GPIO_LED_ORANGE_WAN,
  62. .active_low = 1,
  63. }
  64. };
  65. static struct gpio_keys_button dir_615c1_gpio_keys[] __initdata = {
  66. {
  67. .desc = "reset",
  68. .type = EV_KEY,
  69. .code = KEY_RESTART,
  70. .debounce_interval = DIR_615C1_KEYS_DEBOUNCE_INTERVAL,
  71. .gpio = DIR_615C1_GPIO_BTN_RESET,
  72. }, {
  73. .desc = "wps",
  74. .type = EV_KEY,
  75. .code = KEY_WPS_BUTTON,
  76. .debounce_interval = DIR_615C1_KEYS_DEBOUNCE_INTERVAL,
  77. .gpio = DIR_615C1_GPIO_BTN_WPS,
  78. }
  79. };
  80. #define DIR_615C1_LAN_PHYMASK BIT(0)
  81. #define DIR_615C1_WAN_PHYMASK BIT(4)
  82. #define DIR_615C1_MDIO_MASK (~(DIR_615C1_LAN_PHYMASK | \
  83. DIR_615C1_WAN_PHYMASK))
  84. static void __init dir_615c1_setup(void)
  85. {
  86. const char *config = (char *) KSEG1ADDR(DIR_615C1_CONFIG_ADDR);
  87. u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
  88. u8 mac[ETH_ALEN], wlan_mac[ETH_ALEN];
  89. if (ath79_nvram_parse_mac_addr(config, DIR_615C1_CONFIG_SIZE,
  90. "lan_mac=", mac) == 0) {
  91. ath79_init_mac(ath79_eth0_data.mac_addr, mac, 0);
  92. ath79_init_mac(ath79_eth1_data.mac_addr, mac, 1);
  93. }
  94. ath79_parse_ascii_mac((char *) KSEG1ADDR(DIR_615C1_WLAN_MAC_ADDR), wlan_mac);
  95. ath79_register_mdio(0, DIR_615C1_MDIO_MASK);
  96. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  97. ath79_eth0_data.phy_mask = DIR_615C1_LAN_PHYMASK;
  98. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII;
  99. ath79_eth1_data.phy_mask = DIR_615C1_WAN_PHYMASK;
  100. ath79_register_eth(0);
  101. ath79_register_eth(1);
  102. ath79_register_m25p80(NULL);
  103. ath79_register_leds_gpio(-1, ARRAY_SIZE(dir_615c1_leds_gpio),
  104. dir_615c1_leds_gpio);
  105. ath79_register_gpio_keys_polled(-1, DIR_615C1_KEYS_POLL_INTERVAL,
  106. ARRAY_SIZE(dir_615c1_gpio_keys),
  107. dir_615c1_gpio_keys);
  108. ath79_register_wmac(eeprom, wlan_mac);
  109. }
  110. MIPS_MACHINE(ATH79_MACH_DIR_615_C1, "DIR-615-C1", "D-Link DIR-615 rev. C1",
  111. dir_615c1_setup);