hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/pci/controller/pcie-rockchip.c
....@@ -14,6 +14,7 @@
1414 #include <linux/clk.h>
1515 #include <linux/delay.h>
1616 #include <linux/gpio/consumer.h>
17
+#include <linux/iopoll.h>
1718 #include <linux/module.h>
1819 #include <linux/of_pci.h>
1920 #include <linux/phy/phy.h>
....@@ -154,6 +155,12 @@
154155 }
155156 EXPORT_SYMBOL_GPL(rockchip_pcie_parse_dt);
156157
158
+#define rockchip_pcie_read_addr(addr) rockchip_pcie_read(rockchip, addr)
159
+/* 100 ms max wait time for PHY PLLs to lock */
160
+#define RK_PHY_PLL_LOCK_TIMEOUT_US 100000
161
+/* Sleep should be less than 20ms */
162
+#define RK_PHY_PLL_LOCK_SLEEP_US 1000
163
+
157164 int rockchip_pcie_init_port(struct rockchip_pcie *rockchip)
158165 {
159166 struct device *dev = rockchip->dev;
....@@ -255,6 +262,16 @@
255262 }
256263 }
257264
265
+ err = readx_poll_timeout(rockchip_pcie_read_addr,
266
+ PCIE_CLIENT_SIDE_BAND_STATUS,
267
+ regs, !(regs & PCIE_CLIENT_PHY_ST),
268
+ RK_PHY_PLL_LOCK_SLEEP_US,
269
+ RK_PHY_PLL_LOCK_TIMEOUT_US);
270
+ if (err) {
271
+ dev_err(dev, "PHY PLLs could not lock, %d\n", err);
272
+ goto err_power_off_phy;
273
+ }
274
+
258275 /*
259276 * Please don't reorder the deassert sequence of the following
260277 * four reset pins.