mach-dhp-1565-a1.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*
  2. * D-Link DHP-1565 rev. A1 board support
  3. *
  4. * Copyright (C) 2014 Jacek Kikiewicz
  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/pci.h>
  11. #include <linux/phy.h>
  12. #include <linux/gpio.h>
  13. #include <linux/platform_device.h>
  14. #include <linux/ath9k_platform.h>
  15. #include <linux/ar8216_platform.h>
  16. #include <asm/mach-ath79/ar71xx_regs.h>
  17. #include "common.h"
  18. #include "dev-ap9x-pci.h"
  19. #include "dev-eth.h"
  20. #include "dev-gpio-buttons.h"
  21. #include "dev-leds-gpio.h"
  22. #include "dev-m25p80.h"
  23. #include "dev-spi.h"
  24. #include "dev-usb.h"
  25. #include "dev-wmac.h"
  26. #include "machtypes.h"
  27. #define DHP1565A1_GPIO_LED_BLUE_USB 11
  28. #define DHP1565A1_GPIO_LED_AMBER_POWER 14
  29. #define DHP1565A1_GPIO_LED_BLUE_POWER 22
  30. #define DHP1565A1_GPIO_LED_BLUE_WPS 15
  31. #define DHP1565A1_GPIO_LED_AMBER_PLANET 19
  32. #define DHP1565A1_GPIO_LED_BLUE_PLANET 18
  33. #define DHP1565A1_GPIO_LED_WLAN_2G 13
  34. #define DHP1565A1_GPIO_WAN_LED_ENABLE 20
  35. #define DHP1565A1_GPIO_BTN_RESET 17
  36. #define DHP1565A1_GPIO_BTN_WPS 16
  37. #define DHP1565A1_KEYS_POLL_INTERVAL 20 /* msecs */
  38. #define DHP1565A1_KEYS_DEBOUNCE_INTERVAL (3 * DHP1565A1_KEYS_POLL_INTERVAL)
  39. #define DHP1565A1_MAC0_OFFSET 0xFFA0
  40. #define DHP1565A1_MAC1_OFFSET 0xFFB4
  41. #define DHP1565A1_WMAC0_OFFSET 0x5
  42. #define DHP1565A1_WMAC_CALDATA_OFFSET 0x1000
  43. #define DHP1565A1_PCIE_CALDATA_OFFSET 0x5000
  44. static struct gpio_led dhp1565a1_leds_gpio[] __initdata = {
  45. {
  46. .name = "d-link:amber:power",
  47. .gpio = DHP1565A1_GPIO_LED_AMBER_POWER,
  48. .active_low = 1,
  49. },
  50. {
  51. .name = "d-link:green:power",
  52. .gpio = DHP1565A1_GPIO_LED_BLUE_POWER,
  53. .active_low = 1,
  54. },
  55. {
  56. .name = "d-link:amber:planet",
  57. .gpio = DHP1565A1_GPIO_LED_AMBER_PLANET,
  58. .active_low = 1,
  59. },
  60. {
  61. .name = "d-link:green:planet",
  62. .gpio = DHP1565A1_GPIO_LED_BLUE_PLANET,
  63. .active_low = 1,
  64. },
  65. };
  66. static struct gpio_keys_button dhp1565a1_gpio_keys[] __initdata = {
  67. {
  68. .desc = "Soft reset",
  69. .type = EV_KEY,
  70. .code = KEY_RESTART,
  71. .debounce_interval = DHP1565A1_KEYS_DEBOUNCE_INTERVAL,
  72. .gpio = DHP1565A1_GPIO_BTN_RESET,
  73. .active_low = 1,
  74. },
  75. {
  76. .desc = "WPS button",
  77. .type = EV_KEY,
  78. .code = KEY_WPS_BUTTON,
  79. .debounce_interval = DHP1565A1_KEYS_DEBOUNCE_INTERVAL,
  80. .gpio = DHP1565A1_GPIO_BTN_WPS,
  81. .active_low = 1,
  82. },
  83. };
  84. static struct ar8327_pad_cfg dhp1565a1_ar8327_pad0_cfg = {
  85. .mode = AR8327_PAD_MAC_RGMII,
  86. .txclk_delay_en = true,
  87. .rxclk_delay_en = true,
  88. .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
  89. .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
  90. };
  91. static struct ar8327_platform_data dhp1565a1_ar8327_data = {
  92. .pad0_cfg = &dhp1565a1_ar8327_pad0_cfg,
  93. .port0_cfg = {
  94. .force_link = 1,
  95. .speed = AR8327_PORT_SPEED_1000,
  96. .duplex = 1,
  97. .txpause = 1,
  98. .rxpause = 1,
  99. },
  100. };
  101. static struct mdio_board_info dhp1565a1_mdio0_info[] = {
  102. {
  103. .bus_id = "ag71xx-mdio.0",
  104. .phy_addr = 0,
  105. .platform_data = &dhp1565a1_ar8327_data,
  106. },
  107. };
  108. static void __init dhp1565a1_generic_setup(void)
  109. {
  110. u8 *mac = (u8 *) KSEG1ADDR(0x1ffe0000);
  111. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  112. u8 mac0[ETH_ALEN], mac1[ETH_ALEN];
  113. u8 wmac0[ETH_ALEN];
  114. ath79_parse_ascii_mac(mac + DHP1565A1_MAC0_OFFSET, mac0);
  115. ath79_parse_ascii_mac(mac + DHP1565A1_MAC1_OFFSET, mac1);
  116. ath79_register_m25p80(NULL);
  117. ath79_register_gpio_keys_polled(-1, DHP1565A1_KEYS_POLL_INTERVAL,
  118. ARRAY_SIZE(dhp1565a1_gpio_keys),
  119. dhp1565a1_gpio_keys);
  120. ath79_init_mac(wmac0, mac0, 0);
  121. ath79_register_wmac(art + DHP1565A1_WMAC_CALDATA_OFFSET, wmac0);
  122. ath79_setup_ar934x_eth_cfg(AR934X_ETH_CFG_RGMII_GMAC0);
  123. mdiobus_register_board_info(dhp1565a1_mdio0_info,
  124. ARRAY_SIZE(dhp1565a1_mdio0_info));
  125. ath79_register_mdio(0, 0x0);
  126. ath79_init_mac(ath79_eth0_data.mac_addr, mac0, 1);
  127. /* GMAC0 is connected to an AR8327N switch */
  128. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  129. ath79_eth0_data.phy_mask = BIT(0);
  130. ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  131. ath79_eth0_pll_data.pll_1000 = 0x06000000;
  132. ath79_register_eth(0);
  133. ath79_register_usb();
  134. }
  135. static void __init dhp1565a1_setup(void)
  136. {
  137. ath79_register_leds_gpio(-1, ARRAY_SIZE(dhp1565a1_leds_gpio),
  138. dhp1565a1_leds_gpio);
  139. dhp1565a1_generic_setup();
  140. }
  141. MIPS_MACHINE(ATH79_MACH_DHP_1565_A1, "DHP-1565-A1",
  142. "D-Link DHP-1565 rev. A1",
  143. dhp1565a1_setup);