315-MIPS-pci-ar724x-add-QCA9550-reset-sequence.patch 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. From: David Bauer <[email protected]>
  2. Date: Sat, 11 Apr 2020 14:03:12 +0200
  3. Subject: MIPS: pci-ar724x: add QCA9550 reset sequence
  4. The QCA9550 family of SoCs have a slightly different reset
  5. sequence compared to older chips.
  6. Normally the bootloader performs this sequence, however
  7. some bootloader implementation expect the operating system
  8. to clear the reset.
  9. Also get the resets from OF to support handling of the second
  10. PCIe root-complex on the QCA9558.
  11. Signed-off-by: David Bauer <[email protected]>
  12. --- a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
  13. +++ b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
  14. @@ -390,6 +390,7 @@
  15. #define QCA955X_PLL_CPU_CONFIG_REG 0x00
  16. #define QCA955X_PLL_DDR_CONFIG_REG 0x04
  17. #define QCA955X_PLL_CLK_CTRL_REG 0x08
  18. +#define QCA955X_PLL_PCIE_CONFIG_REG 0x0c
  19. #define QCA955X_PLL_ETH_XMII_CONTROL_REG 0x28
  20. #define QCA955X_PLL_ETH_SGMII_CONTROL_REG 0x48
  21. #define QCA955X_PLL_ETH_SGMII_SERDES_REG 0x4c
  22. @@ -475,6 +476,9 @@
  23. #define QCA956X_PLL_CLK_CTRL_CPU_DDRCLK_FROM_CPUPLL BIT(21)
  24. #define QCA956X_PLL_CLK_CTRL_AHBCLK_FROM_DDRPLL BIT(24)
  25. +#define QCA955X_PLL_PCIE_CONFIG_PLL_PWD BIT(30)
  26. +#define QCA955X_PLL_PCIE_CONFIG_PLL_BYPASS BIT(16)
  27. +
  28. #define QCA956X_PLL_SWITCH_CLOCK_SPARE_I2C_CLK_SELB BIT(5)
  29. #define QCA956X_PLL_SWITCH_CLOCK_SPARE_MDIO_CLK_SEL0_1 BIT(6)
  30. #define QCA956X_PLL_SWITCH_CLOCK_SPARE_UART1_CLK_SEL BIT(7)
  31. --- a/arch/mips/pci/pci-ar724x.c
  32. +++ b/arch/mips/pci/pci-ar724x.c
  33. @@ -8,6 +8,7 @@
  34. #include <linux/irq.h>
  35. #include <linux/pci.h>
  36. +#include <linux/reset.h>
  37. #include <linux/init.h>
  38. #include <linux/delay.h>
  39. #include <linux/platform_device.h>
  40. @@ -55,6 +56,9 @@ struct ar724x_pci_controller {
  41. struct irq_domain *domain;
  42. struct resource io_res;
  43. struct resource mem_res;
  44. +
  45. + struct reset_control *hc_reset;
  46. + struct reset_control *phy_reset;
  47. };
  48. static struct irq_chip ar724x_pci_irq_chip;
  49. @@ -340,18 +344,30 @@ static void ar724x_pci_hw_init(struct ar
  50. int wait = 0;
  51. /* deassert PCIe host controller and PCIe PHY reset */
  52. - ath79_device_reset_clear(AR724X_RESET_PCIE);
  53. - ath79_device_reset_clear(AR724X_RESET_PCIE_PHY);
  54. + reset_control_deassert(apc->hc_reset);
  55. + reset_control_deassert(apc->phy_reset);
  56. - /* remove the reset of the PCIE PLL */
  57. - ppl = ath79_pll_rr(AR724X_PLL_REG_PCIE_CONFIG);
  58. - ppl &= ~AR724X_PLL_REG_PCIE_CONFIG_PPL_RESET;
  59. - ath79_pll_wr(AR724X_PLL_REG_PCIE_CONFIG, ppl);
  60. -
  61. - /* deassert bypass for the PCIE PLL */
  62. - ppl = ath79_pll_rr(AR724X_PLL_REG_PCIE_CONFIG);
  63. - ppl &= ~AR724X_PLL_REG_PCIE_CONFIG_PPL_BYPASS;
  64. - ath79_pll_wr(AR724X_PLL_REG_PCIE_CONFIG, ppl);
  65. + if (of_device_is_compatible(apc->np, "qcom,qca9550-pci")) {
  66. + /* remove the reset of the PCIE PLL */
  67. + ppl = ath79_pll_rr(QCA955X_PLL_PCIE_CONFIG_REG);
  68. + ppl &= ~QCA955X_PLL_PCIE_CONFIG_PLL_PWD;
  69. + ath79_pll_wr(QCA955X_PLL_PCIE_CONFIG_REG, ppl);
  70. +
  71. + /* deassert bypass for the PCIE PLL */
  72. + ppl = ath79_pll_rr(QCA955X_PLL_PCIE_CONFIG_REG);
  73. + ppl &= ~QCA955X_PLL_PCIE_CONFIG_PLL_BYPASS;
  74. + ath79_pll_wr(QCA955X_PLL_PCIE_CONFIG_REG, ppl);
  75. + } else {
  76. + /* remove the reset of the PCIE PLL */
  77. + ppl = ath79_pll_rr(AR724X_PLL_REG_PCIE_CONFIG);
  78. + ppl &= ~AR724X_PLL_REG_PCIE_CONFIG_PPL_RESET;
  79. + ath79_pll_wr(AR724X_PLL_REG_PCIE_CONFIG, ppl);
  80. +
  81. + /* deassert bypass for the PCIE PLL */
  82. + ppl = ath79_pll_rr(AR724X_PLL_REG_PCIE_CONFIG);
  83. + ppl &= ~AR724X_PLL_REG_PCIE_CONFIG_PPL_BYPASS;
  84. + ath79_pll_wr(AR724X_PLL_REG_PCIE_CONFIG, ppl);
  85. + }
  86. /* set PCIE Application Control to ready */
  87. app = __raw_readl(apc->ctrl_base + AR724X_PCI_REG_APP);
  88. @@ -395,6 +411,14 @@ static int ar724x_pci_probe(struct platf
  89. if (apc->irq < 0)
  90. return -EINVAL;
  91. + apc->hc_reset = devm_reset_control_get_exclusive(&pdev->dev, "hc");
  92. + if (IS_ERR(apc->hc_reset))
  93. + return PTR_ERR(apc->hc_reset);
  94. +
  95. + apc->phy_reset = devm_reset_control_get_exclusive(&pdev->dev, "phy");
  96. + if (IS_ERR(apc->phy_reset))
  97. + return PTR_ERR(apc->phy_reset);
  98. +
  99. apc->np = pdev->dev.of_node;
  100. apc->pci_controller.pci_ops = &ar724x_pci_ops;
  101. apc->pci_controller.io_resource = &apc->io_res;
  102. @@ -405,7 +429,7 @@ static int ar724x_pci_probe(struct platf
  103. * Do the full PCIE Root Complex Initialization Sequence if the PCIe
  104. * host controller is in reset.
  105. */
  106. - if (ath79_reset_rr(AR724X_RESET_REG_RESET_MODULE) & AR724X_RESET_PCIE)
  107. + if (reset_control_status(apc->hc_reset))
  108. ar724x_pci_hw_init(apc);
  109. apc->link_up = ar724x_pci_check_link(apc);
  110. @@ -423,6 +447,7 @@ static int ar724x_pci_probe(struct platf
  111. static const struct of_device_id ar724x_pci_ids[] = {
  112. { .compatible = "qcom,ar7240-pci" },
  113. + { .compatible = "qcom,qca9550-pci" },
  114. {},
  115. };