mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 11:26:02 +09:00
PCI: rockchip: dw: Add present IO detect
prsnt-gpios can be defined in DTS for showing if PCIe device is present or not. By default, low voltage means device is present defined by PCIe ECM spec. However, some buggy board may invert this voltage level. So if you need high voltage to show the device is present, please add rockchip,prsnt-active-high as well. Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com> Change-Id: Ib0a5b509afc202a9ec63a4bbdd1e54a3916dcfc9
This commit is contained in:
@@ -147,6 +147,8 @@ struct rk_pcie {
|
||||
unsigned int clk_cnt;
|
||||
struct reset_bulk_data *rsts;
|
||||
struct gpio_desc *rst_gpio;
|
||||
struct gpio_desc *prsnt_gpio;
|
||||
int prsnt_active_stat;
|
||||
phys_addr_t mem_start;
|
||||
size_t mem_size;
|
||||
struct pcie_port pp;
|
||||
@@ -1179,6 +1181,13 @@ static int rk_pcie_resource_get(struct platform_device *pdev,
|
||||
return PTR_ERR(rk_pcie->rst_gpio);
|
||||
}
|
||||
|
||||
rk_pcie->prsnt_gpio = devm_gpiod_get_optional(&pdev->dev, "prsnt", GPIOD_IN);
|
||||
if (IS_ERR_OR_NULL(rk_pcie->prsnt_gpio))
|
||||
dev_info(&pdev->dev, "invalid prsnt-gpios property in node\n");
|
||||
|
||||
if (device_property_read_bool(&pdev->dev, "rockchip,prsnt-active-high"))
|
||||
rk_pcie->prsnt_active_stat = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1752,6 +1761,13 @@ static int rk_pcie_really_probe(void *p)
|
||||
goto release_driver;
|
||||
}
|
||||
|
||||
if (!IS_ERR_OR_NULL(rk_pcie->prsnt_gpio)) {
|
||||
if (gpiod_get_value(rk_pcie->prsnt_gpio) != rk_pcie->prsnt_active_stat) {
|
||||
ret = -ENODEV;
|
||||
goto release_driver;
|
||||
}
|
||||
}
|
||||
|
||||
retry_regulator:
|
||||
/* DON'T MOVE ME: must be enable before phy init */
|
||||
rk_pcie->vpcie3v3 = devm_regulator_get_optional(dev, "vpcie3v3");
|
||||
|
||||
Reference in New Issue
Block a user