|
14 | 14 | #include <linux/clk.h>
|
15 | 15 | #include <linux/delay.h>
|
16 | 16 | #include <linux/gpio/consumer.h>
|
| 17 | +#include <linux/iopoll.h> |
17 | 18 | #include <linux/of_pci.h>
|
18 | 19 | #include <linux/phy/phy.h>
|
19 | 20 | #include <linux/platform_device.h>
|
@@ -153,6 +154,12 @@ int rockchip_pcie_parse_dt(struct rockchip_pcie *rockchip)
|
153 | 154 | }
|
154 | 155 | EXPORT_SYMBOL_GPL(rockchip_pcie_parse_dt);
|
155 | 156 |
|
| 157 | +#define rockchip_pcie_read_addr(addr) rockchip_pcie_read(rockchip, addr) |
| 158 | +/* 100 ms max wait time for PHY PLLs to lock */ |
| 159 | +#define RK_PHY_PLL_LOCK_TIMEOUT_US 100000 |
| 160 | +/* Sleep should be less than 20ms */ |
| 161 | +#define RK_PHY_PLL_LOCK_SLEEP_US 1000 |
| 162 | + |
156 | 163 | int rockchip_pcie_init_port(struct rockchip_pcie *rockchip)
|
157 | 164 | {
|
158 | 165 | struct device *dev = rockchip->dev;
|
@@ -254,6 +261,16 @@ int rockchip_pcie_init_port(struct rockchip_pcie *rockchip)
|
254 | 261 | }
|
255 | 262 | }
|
256 | 263 |
|
| 264 | + err = readx_poll_timeout(rockchip_pcie_read_addr, |
| 265 | + PCIE_CLIENT_SIDE_BAND_STATUS, |
| 266 | + regs, !(regs & PCIE_CLIENT_PHY_ST), |
| 267 | + RK_PHY_PLL_LOCK_SLEEP_US, |
| 268 | + RK_PHY_PLL_LOCK_TIMEOUT_US); |
| 269 | + if (err) { |
| 270 | + dev_err(dev, "PHY PLLs could not lock, %d\n", err); |
| 271 | + goto err_power_off_phy; |
| 272 | + } |
| 273 | + |
257 | 274 | /*
|
258 | 275 | * Please don't reorder the deassert sequence of the following
|
259 | 276 | * four reset pins.
|
|
0 commit comments