mach-jwap230.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /*
  2. * jjPlus JWAP230 board support
  3. *
  4. * Copyright (C) 2016 Piotr Dymacz <pepe2k@gmail.com>
  5. *
  6. * Based on mach-wpj558.c and mach-tl-wr1043nd-v2.c
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License version 2 as published
  10. * by the Free Software Foundation.
  11. */
  12. #include <linux/pci.h>
  13. #include <linux/phy.h>
  14. #include <linux/gpio.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/ar8216_platform.h>
  17. #include <asm/mach-ath79/ath79.h>
  18. #include <asm/mach-ath79/ar71xx_regs.h>
  19. #include "common.h"
  20. #include "dev-ap9x-pci.h"
  21. #include "dev-eth.h"
  22. #include "dev-leds-gpio.h"
  23. #include "dev-m25p80.h"
  24. #include "dev-usb.h"
  25. #include "dev-wmac.h"
  26. #include "machtypes.h"
  27. #include "pci.h"
  28. #define JWAP230_GPIO_LED_LED1 23
  29. #define JWAP230_GPIO_LED_LED2 22
  30. #define JWAP230_GPIO_LED_LED3 21
  31. #define JWAP230_MAC0_OFFSET 0x0
  32. #define JWAP230_MAC1_OFFSET 0x6
  33. #define JWAP230_WMAC_CALDATA_OFFSET 0x1000
  34. static struct gpio_led jwap230_leds_gpio[] __initdata = {
  35. {
  36. .name = "jwap230:green:led1",
  37. .gpio = JWAP230_GPIO_LED_LED1,
  38. .active_low = 1,
  39. },
  40. {
  41. .name = "jwap230:green:led2",
  42. .gpio = JWAP230_GPIO_LED_LED2,
  43. .active_low = 1,
  44. },
  45. {
  46. .name = "jwap230:green:led3",
  47. .gpio = JWAP230_GPIO_LED_LED3,
  48. .active_low = 1,
  49. }
  50. };
  51. static const struct ar8327_led_info jwap230_leds_qca8337[] = {
  52. AR8327_LED_INFO(PHY0_0, HW, "jwap230:green:lan"),
  53. AR8327_LED_INFO(PHY4_0, HW, "jwap230:green:wan"),
  54. };
  55. /* Blink rate: 1 Gbps -> 8 hz, 100 Mbs -> 4 Hz, 10 Mbps -> 2 Hz */
  56. static struct ar8327_led_cfg jwap230_qca8337_led_cfg = {
  57. .led_ctrl0 = 0xcf37cf37,
  58. .led_ctrl1 = 0xcf37cf37,
  59. .led_ctrl2 = 0xcf37cf37,
  60. .led_ctrl3 = 0x0,
  61. .open_drain = true,
  62. };
  63. /* QCA8337 GMAC0 is connected with QCA9558 over RGMII */
  64. static struct ar8327_pad_cfg jwap230_qca8337_pad0_cfg = {
  65. .mode = AR8327_PAD_MAC_RGMII,
  66. .txclk_delay_en = true,
  67. .rxclk_delay_en = true,
  68. .txclk_delay_sel = AR8327_CLK_DELAY_SEL1,
  69. .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2,
  70. .mac06_exchange_dis = true,
  71. };
  72. /* QCA8337 GMAC6 is connected with QCA9558 over SGMII */
  73. static struct ar8327_pad_cfg jwap230_qca8337_pad6_cfg = {
  74. .mode = AR8327_PAD_MAC_SGMII,
  75. .sgmii_delay_en = true,
  76. .rxclk_delay_sel = AR8327_CLK_DELAY_SEL0,
  77. };
  78. static struct ar8327_platform_data jwap230_qca8337_data = {
  79. .pad0_cfg = &jwap230_qca8337_pad0_cfg,
  80. .pad6_cfg = &jwap230_qca8337_pad6_cfg,
  81. .port0_cfg = {
  82. .force_link = 1,
  83. .speed = AR8327_PORT_SPEED_1000,
  84. .duplex = 1,
  85. .txpause = 1,
  86. .rxpause = 1,
  87. },
  88. .port6_cfg = {
  89. .force_link = 1,
  90. .speed = AR8327_PORT_SPEED_1000,
  91. .duplex = 1,
  92. .txpause = 1,
  93. .rxpause = 1,
  94. },
  95. .led_cfg = &jwap230_qca8337_led_cfg,
  96. .num_leds = ARRAY_SIZE(jwap230_leds_qca8337),
  97. .leds = jwap230_leds_qca8337,
  98. };
  99. static struct mdio_board_info jwap230_mdio0_info[] = {
  100. {
  101. .bus_id = "ag71xx-mdio.0",
  102. .phy_addr = 0,
  103. .platform_data = &jwap230_qca8337_data,
  104. },
  105. };
  106. static void __init jwap230_setup(void)
  107. {
  108. u8 *art = (u8 *) KSEG1ADDR(0x1fff0000);
  109. ath79_register_m25p80(NULL);
  110. ath79_register_leds_gpio(-1, ARRAY_SIZE(jwap230_leds_gpio),
  111. jwap230_leds_gpio);
  112. mdiobus_register_board_info(jwap230_mdio0_info,
  113. ARRAY_SIZE(jwap230_mdio0_info));
  114. ath79_register_mdio(0, 0x0);
  115. ath79_setup_qca955x_eth_cfg(QCA955X_ETH_CFG_RGMII_EN);
  116. /* QCA9558 GMAC0 is connected to RMGII interface */
  117. ath79_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII;
  118. ath79_eth0_data.phy_mask = BIT(0);
  119. ath79_eth0_data.mii_bus_dev = &ath79_mdio0_device.dev;
  120. ath79_eth0_pll_data.pll_1000 = 0xa6000000;
  121. ath79_init_mac(ath79_eth0_data.mac_addr, art + JWAP230_MAC0_OFFSET, 0);
  122. ath79_register_eth(0);
  123. /* QCA9558 GMAC1 is connected to SGMII interface */
  124. ath79_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_SGMII;
  125. ath79_eth1_data.speed = SPEED_1000;
  126. ath79_eth1_data.duplex = DUPLEX_FULL;
  127. ath79_eth1_pll_data.pll_1000 = 0x03000101;
  128. ath79_init_mac(ath79_eth1_data.mac_addr, art + JWAP230_MAC1_OFFSET, 0);
  129. ath79_register_eth(1);
  130. ath79_register_wmac(art + JWAP230_WMAC_CALDATA_OFFSET, NULL);
  131. ath79_register_pci();
  132. ath79_register_usb();
  133. }
  134. MIPS_MACHINE(ATH79_MACH_JWAP230, "JWAP230", "jjPlus JWAP230", jwap230_setup);