summaryrefslogtreecommitdiff
path: root/target/linux/ath79/patches-5.10/0062-MIPS-pci-ar724x-add-QCA9550-reset-sequence.patch
blob: f596ddb7336f642924d5e9efa1963e688d3be4a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
From: David Bauer <mail@david-bauer.net>
Date: Sat, 11 Apr 2020 14:03:12 +0200
Subject: MIPS: pci-ar724x: add QCA9550 reset sequence

The QCA9550 family of SoCs have a slightly different reset
sequence compared to older chips.

Normally the bootloader performs this sequence, however
some bootloader implementation expect the operating system
to clear the reset.

Also get the resets from OF to support handling of the second
PCIe root-complex on the QCA9558.

Signed-off-by: David Bauer <mail@david-bauer.net>

--- a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
+++ b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
@@ -391,6 +391,7 @@
 #define QCA955X_PLL_CPU_CONFIG_REG		0x00
 #define QCA955X_PLL_DDR_CONFIG_REG		0x04
 #define QCA955X_PLL_CLK_CTRL_REG		0x08
+#define QCA955X_PLL_PCIE_CONFIG_REG		0x0c
 #define QCA955X_PLL_ETH_XMII_CONTROL_REG	0x28
 #define QCA955X_PLL_ETH_SGMII_CONTROL_REG	0x48
 #define QCA955X_PLL_ETH_SGMII_SERDES_REG	0x4c
@@ -476,6 +477,9 @@
 #define QCA956X_PLL_CLK_CTRL_CPU_DDRCLK_FROM_CPUPLL	BIT(21)
 #define QCA956X_PLL_CLK_CTRL_AHBCLK_FROM_DDRPLL		BIT(24)
 
+#define QCA955X_PLL_PCIE_CONFIG_PLL_PWD			BIT(30)
+#define QCA955X_PLL_PCIE_CONFIG_PLL_BYPASS		BIT(16)
+
 #define QCA956X_PLL_SWITCH_CLOCK_SPARE_I2C_CLK_SELB		BIT(5)
 #define QCA956X_PLL_SWITCH_CLOCK_SPARE_MDIO_CLK_SEL0_1		BIT(6)
 #define QCA956X_PLL_SWITCH_CLOCK_SPARE_UART1_CLK_SEL		BIT(7)
--- a/arch/mips/pci/pci-ar724x.c
+++ b/arch/mips/pci/pci-ar724x.c
@@ -8,6 +8,7 @@
 
 #include <linux/irq.h>
 #include <linux/pci.h>
+#include <linux/reset.h>
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/platform_device.h>
@@ -55,6 +56,9 @@ struct ar724x_pci_controller {
 	struct irq_domain *domain;
 	struct resource io_res;
 	struct resource mem_res;
+
+	struct reset_control *hc_reset;
+	struct reset_control *phy_reset;
 };
 
 static struct irq_chip ar724x_pci_irq_chip;
@@ -340,18 +344,30 @@ static void ar724x_pci_hw_init(struct ar
 	int wait = 0;
 
 	/* deassert PCIe host controller and PCIe PHY reset */
-	ath79_device_reset_clear(AR724X_RESET_PCIE);
-	ath79_device_reset_clear(AR724X_RESET_PCIE_PHY);
+	reset_control_deassert(apc->hc_reset);
+	reset_control_deassert(apc->phy_reset);
 
-	/* remove the reset of the PCIE PLL */
-	ppl = ath79_pll_rr(AR724X_PLL_REG_PCIE_CONFIG);
-	ppl &= ~AR724X_PLL_REG_PCIE_CONFIG_PPL_RESET;
-	ath79_pll_wr(AR724X_PLL_REG_PCIE_CONFIG, ppl);
-
-	/* deassert bypass for the PCIE PLL */
-	ppl = ath79_pll_rr(AR724X_PLL_REG_PCIE_CONFIG);
-	ppl &= ~AR724X_PLL_REG_PCIE_CONFIG_PPL_BYPASS;
-	ath79_pll_wr(AR724X_PLL_REG_PCIE_CONFIG, ppl);
+	if (of_device_is_compatible(apc->np, "qcom,qca9550-pci")) {
+		/* remove the reset of the PCIE PLL */
+		ppl = ath79_pll_rr(QCA955X_PLL_PCIE_CONFIG_REG);
+		ppl &= ~QCA955X_PLL_PCIE_CONFIG_PLL_PWD;
+		ath79_pll_wr(QCA955X_PLL_PCIE_CONFIG_REG, ppl);
+
+		/* deassert bypass for the PCIE PLL */
+		ppl = ath79_pll_rr(QCA955X_PLL_PCIE_CONFIG_REG);
+		ppl &= ~QCA955X_PLL_PCIE_CONFIG_PLL_BYPASS;
+		ath79_pll_wr(QCA955X_PLL_PCIE_CONFIG_REG, ppl);
+	} else {
+		/* remove the reset of the PCIE PLL */
+		ppl = ath79_pll_rr(AR724X_PLL_REG_PCIE_CONFIG);
+		ppl &= ~AR724X_PLL_REG_PCIE_CONFIG_PPL_RESET;
+		ath79_pll_wr(AR724X_PLL_REG_PCIE_CONFIG, ppl);
+
+		/* deassert bypass for the PCIE PLL */
+		ppl = ath79_pll_rr(AR724X_PLL_REG_PCIE_CONFIG);
+		ppl &= ~AR724X_PLL_REG_PCIE_CONFIG_PPL_BYPASS;
+		ath79_pll_wr(AR724X_PLL_REG_PCIE_CONFIG, ppl);
+	}
 
 	/* set PCIE Application Control to ready */
 	app = __raw_readl(apc->ctrl_base + AR724X_PCI_REG_APP);
@@ -396,6 +412,14 @@ static int ar724x_pci_probe(struct platf
 	if (apc->irq < 0)
 		return -EINVAL;
 
+	apc->hc_reset = devm_reset_control_get_exclusive(&pdev->dev, "hc");
+	if (IS_ERR(apc->hc_reset))
+		return PTR_ERR(apc->hc_reset);
+
+	apc->phy_reset = devm_reset_control_get_exclusive(&pdev->dev, "phy");
+	if (IS_ERR(apc->phy_reset))
+		return PTR_ERR(apc->phy_reset);
+
 	apc->np = pdev->dev.of_node;
 	apc->pci_controller.pci_ops = &ar724x_pci_ops;
 	apc->pci_controller.io_resource = &apc->io_res;
@@ -406,7 +430,7 @@ static int ar724x_pci_probe(struct platf
 	 * Do the full PCIE Root Complex Initialization Sequence if the PCIe
 	 * host controller is in reset.
 	 */
-	if (ath79_reset_rr(AR724X_RESET_REG_RESET_MODULE) & AR724X_RESET_PCIE)
+	if (reset_control_status(apc->hc_reset))
 		ar724x_pci_hw_init(apc);
 
 	apc->link_up = ar724x_pci_check_link(apc);
@@ -424,6 +448,7 @@ static int ar724x_pci_probe(struct platf
 
 static const struct of_device_id ar724x_pci_ids[] = {
 	{ .compatible = "qcom,ar7240-pci" },
+	{ .compatible = "qcom,qca9550-pci" },
 	{},
 };