mach-dir-615-i1.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * D-Link DIR-615 rev. I1 board support
  3. * Copyright (C) 2013-2015 Jaehoon You <teslamint@gmail.com>
  4. *
  5. * based on the DIR-600 rev. A1 board support code
  6. * Copyright (C) 2010-2012 Gabor Juhos <juhosg@openwrt.org>
  7. * Copyright (C) 2012 Vadim Girlin <vadimgirlin@gmail.com>
  8. *
  9. * based on the TP-LINK TL-WR841N/ND v8/TL-MR3420 v2 board support code
  10. * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
  11. *
  12. * This program is free software; you can redistribute it and/or modify it
  13. * under the terms of the GNU General Public License version 2 as published
  14. * by the Free Software Foundation.
  15. */
  16. #include <linux/platform_device.h>
  17. #include <asm/mach-ath79/ath79.h>
  18. #include <asm/mach-ath79/ar71xx_regs.h>
  19. #include "common.h"
  20. #include "dev-eth.h"
  21. #include "dev-gpio-buttons.h"
  22. #include "dev-leds-gpio.h"
  23. #include "dev-m25p80.h"
  24. #include "dev-wmac.h"
  25. #include "machtypes.h"
  26. #define DIR_615_I1_GPIO_LED_WPS 15
  27. #define DIR_615_I1_GPIO_LED_POWER_AMBER 14
  28. #define DIR_615_I1_GPIO_LED_POWER_GREEN 4
  29. #define DIR_615_I1_GPIO_LED_WAN_AMBER 22
  30. #define DIR_615_I1_GPIO_LED_WAN_GREEN 12
  31. #define DIR_615_I1_GPIO_LED_WLAN_GREEN 13
  32. #define DIR_615_I1_GPIO_BTN_WPS 16
  33. #define DIR_615_I1_GPIO_BTN_RESET 17
  34. #define DIR_615_I1_KEYS_POLL_INTERVAL 20 /* msecs */
  35. #define DIR_615_I1_KEYS_DEBOUNCE_INTERVAL (3 * DIR_615_I1_KEYS_POLL_INTERVAL)
  36. #define DIR_615_I1_LAN_PHYMASK BIT(0)
  37. #define DIR_615_I1_WAN_PHYMASK BIT(4)
  38. #define DIR_615_I1_WLAN_MAC_ADDR 0x1fffffb4
  39. static struct gpio_led dir_615_i1_leds_gpio[] __initdata = {
  40. {
  41. .name = "d-link:green:power",
  42. .gpio = DIR_615_I1_GPIO_LED_POWER_GREEN,
  43. }, {
  44. .name = "d-link:amber:power",
  45. .gpio = DIR_615_I1_GPIO_LED_POWER_AMBER,
  46. }, {
  47. .name = "d-link:amber:wan",
  48. .gpio = DIR_615_I1_GPIO_LED_WAN_AMBER,
  49. }, {
  50. .name = "d-link:green:wan",
  51. .gpio = DIR_615_I1_GPIO_LED_WAN_GREEN,
  52. .active_low = 1,
  53. }, {
  54. .name = "d-link:green:wlan",
  55. .gpio = DIR_615_I1_GPIO_LED_WLAN_GREEN,
  56. .active_low = 1,
  57. }, {
  58. .name = "d-link:blue:wps",
  59. .gpio = DIR_615_I1_GPIO_LED_WPS,
  60. .active_low = 1,
  61. }
  62. };
  63. static struct gpio_keys_button dir_615_i1_gpio_keys[] __initdata = {
  64. {
  65. .desc = "reset",
  66. .type = EV_KEY,
  67. .code = KEY_RESTART,
  68. .debounce_interval = DIR_615_I1_KEYS_DEBOUNCE_INTERVAL,
  69. .gpio = DIR_615_I1_GPIO_BTN_RESET,
  70. .active_low = 1,
  71. }, {
  72. .desc = "wps",
  73. .type = EV_KEY,
  74. .code = KEY_WPS_BUTTON,
  75. .debounce_interval = DIR_615_I1_KEYS_DEBOUNCE_INTERVAL,
  76. .gpio = DIR_615_I1_GPIO_BTN_WPS,
  77. .active_low = 1,
  78. }
  79. };
  80. static void __init dir_615_i1_setup(void)
  81. {
  82. u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
  83. u8 mac[ETH_ALEN];
  84. ath79_register_mdio(0, 0x0);
  85. ath79_register_mdio(1, ~(DIR_615_I1_WAN_PHYMASK));
  86. ath79_parse_ascii_mac((char *) KSEG1ADDR(DIR_615_I1_WLAN_MAC_ADDR), mac);
  87. ath79_init_mac(ath79_eth1_data.mac_addr, mac, 0);
  88. ath79_init_mac(ath79_eth0_data.mac_addr, mac, 1);
  89. /* GMAC0 is connected to the PHY0 of the internal switch */
  90. ath79_switch_data.phy4_mii_en = 1;
  91. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_MII;
  92. ath79_eth0_data.phy_mask = DIR_615_I1_WAN_PHYMASK;
  93. ath79_eth0_data.mii_bus_dev = &ath79_mdio1_device.dev;
  94. /* GMAC1 is connected to the internal switch */
  95. ath79_eth1_data.phy_mask = DIR_615_I1_LAN_PHYMASK;
  96. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_GMII;
  97. ath79_register_eth(0);
  98. ath79_register_eth(1);
  99. ath79_register_m25p80(NULL);
  100. /* Disable JTAG, enabling GPIOs 0-3 */
  101. /* Configure OBS4 line, for GPIO 4*/
  102. ath79_gpio_function_setup(AR934X_GPIO_FUNC_JTAG_DISABLE,
  103. AR934X_GPIO_FUNC_CLK_OBS4_EN);
  104. ath79_register_leds_gpio(-1, ARRAY_SIZE(dir_615_i1_leds_gpio),
  105. dir_615_i1_leds_gpio);
  106. ath79_register_gpio_keys_polled(-1, DIR_615_I1_KEYS_POLL_INTERVAL,
  107. ARRAY_SIZE(dir_615_i1_gpio_keys),
  108. dir_615_i1_gpio_keys);
  109. ath79_register_wmac(eeprom, mac);
  110. }
  111. MIPS_MACHINE(ATH79_MACH_DIR_615_I1, "DIR-615-I1", "D-Link DIR-615 rev. I1",
  112. dir_615_i1_setup);