.. | .. |
---|
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/module.h> |
---|
18 | 19 | #include <linux/of_pci.h> |
---|
19 | 20 | #include <linux/phy/phy.h> |
---|
.. | .. |
---|
154 | 155 | } |
---|
155 | 156 | EXPORT_SYMBOL_GPL(rockchip_pcie_parse_dt); |
---|
156 | 157 | |
---|
| 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 | + |
---|
157 | 164 | int rockchip_pcie_init_port(struct rockchip_pcie *rockchip) |
---|
158 | 165 | { |
---|
159 | 166 | struct device *dev = rockchip->dev; |
---|
.. | .. |
---|
255 | 262 | } |
---|
256 | 263 | } |
---|
257 | 264 | |
---|
| 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 | + |
---|
258 | 275 | /* |
---|
259 | 276 | * Please don't reorder the deassert sequence of the following |
---|
260 | 277 | * four reset pins. |
---|