Lines Matching +full:rk3568 +full:- +full:pcie

1 // SPDX-License-Identifier: GPL-2.0
3 * PCIe host controller driver for Rockchip SoCs.
6 * http://www.rock-chips.com
8 * Author: Simon Xue <xxm@rock-chips.com>
24 #include "pcie-designware.h"
34 #define to_rockchip_pcie(x) dev_get_drvdata((x)->dev)
66 return readl_relaxed(rockchip->apb_base + reg); in rockchip_pcie_readl_apb()
72 writel_relaxed(val, rockchip->apb_base + reg); in rockchip_pcie_writel_apb()
86 generic_handle_domain_irq(rockchip->irq_domain, hwirq); in rockchip_pcie_legacy_int_handler()
94 HIWORD_UPDATE_BIT(BIT(data->hwirq)), in rockchip_intx_mask()
101 HIWORD_DISABLE_BIT(BIT(data->hwirq)), in rockchip_intx_unmask()
116 irq_set_chip_data(irq, domain->host_data); in rockchip_pcie_intx_map()
127 struct device *dev = rockchip->pci.dev; in rockchip_pcie_init_irq_domain()
130 intc = of_get_child_by_name(dev->of_node, "legacy-interrupt-controller"); in rockchip_pcie_init_irq_domain()
132 dev_err(dev, "missing child interrupt-controller node\n"); in rockchip_pcie_init_irq_domain()
133 return -EINVAL; in rockchip_pcie_init_irq_domain()
136 rockchip->irq_domain = irq_domain_add_linear(intc, PCI_NUM_INTX, in rockchip_pcie_init_irq_domain()
139 if (!rockchip->irq_domain) { in rockchip_pcie_init_irq_domain()
141 return -EINVAL; in rockchip_pcie_init_irq_domain()
170 gpiod_set_value_cansleep(rockchip->rst_gpio, 0); in rockchip_pcie_start_link()
175 * PCIe requires the refclk to be stable for 100µs prior to releasing in rockchip_pcie_start_link()
176 * PERST. See table 2-4 in section 2.6.2 AC Specifications of the PCI in rockchip_pcie_start_link()
184 gpiod_set_value_cansleep(rockchip->rst_gpio, 1); in rockchip_pcie_start_link()
193 struct device *dev = rockchip->pci.dev; in rockchip_pcie_host_init()
197 irq = of_irq_get_byname(dev->of_node, "legacy"); in rockchip_pcie_host_init()
223 struct device *dev = rockchip->pci.dev; in rockchip_pcie_clk_init()
226 ret = devm_clk_bulk_get_all(dev, &rockchip->clks); in rockchip_pcie_clk_init()
230 rockchip->clk_cnt = ret; in rockchip_pcie_clk_init()
232 return clk_bulk_prepare_enable(rockchip->clk_cnt, rockchip->clks); in rockchip_pcie_clk_init()
238 rockchip->apb_base = devm_platform_ioremap_resource_byname(pdev, "apb"); in rockchip_pcie_resource_get()
239 if (IS_ERR(rockchip->apb_base)) in rockchip_pcie_resource_get()
240 return PTR_ERR(rockchip->apb_base); in rockchip_pcie_resource_get()
242 rockchip->rst_gpio = devm_gpiod_get_optional(&pdev->dev, "reset", in rockchip_pcie_resource_get()
244 if (IS_ERR(rockchip->rst_gpio)) in rockchip_pcie_resource_get()
245 return PTR_ERR(rockchip->rst_gpio); in rockchip_pcie_resource_get()
247 rockchip->rst = devm_reset_control_array_get_exclusive(&pdev->dev); in rockchip_pcie_resource_get()
248 if (IS_ERR(rockchip->rst)) in rockchip_pcie_resource_get()
249 return dev_err_probe(&pdev->dev, PTR_ERR(rockchip->rst), in rockchip_pcie_resource_get()
257 struct device *dev = rockchip->pci.dev; in rockchip_pcie_phy_init()
260 rockchip->phy = devm_phy_get(dev, "pcie-phy"); in rockchip_pcie_phy_init()
261 if (IS_ERR(rockchip->phy)) in rockchip_pcie_phy_init()
262 return dev_err_probe(dev, PTR_ERR(rockchip->phy), in rockchip_pcie_phy_init()
265 ret = phy_init(rockchip->phy); in rockchip_pcie_phy_init()
269 ret = phy_power_on(rockchip->phy); in rockchip_pcie_phy_init()
271 phy_exit(rockchip->phy); in rockchip_pcie_phy_init()
278 phy_exit(rockchip->phy); in rockchip_pcie_phy_deinit()
279 phy_power_off(rockchip->phy); in rockchip_pcie_phy_deinit()
289 struct device *dev = &pdev->dev; in rockchip_pcie_probe()
296 return -ENOMEM; in rockchip_pcie_probe()
300 rockchip->pci.dev = dev; in rockchip_pcie_probe()
301 rockchip->pci.ops = &dw_pcie_ops; in rockchip_pcie_probe()
303 pp = &rockchip->pci.pp; in rockchip_pcie_probe()
304 pp->ops = &rockchip_pcie_host_ops; in rockchip_pcie_probe()
310 ret = reset_control_assert(rockchip->rst); in rockchip_pcie_probe()
315 rockchip->vpcie3v3 = devm_regulator_get_optional(dev, "vpcie3v3"); in rockchip_pcie_probe()
316 if (IS_ERR(rockchip->vpcie3v3)) { in rockchip_pcie_probe()
317 if (PTR_ERR(rockchip->vpcie3v3) != -ENODEV) in rockchip_pcie_probe()
318 return dev_err_probe(dev, PTR_ERR(rockchip->vpcie3v3), in rockchip_pcie_probe()
320 rockchip->vpcie3v3 = NULL; in rockchip_pcie_probe()
322 ret = regulator_enable(rockchip->vpcie3v3); in rockchip_pcie_probe()
333 ret = reset_control_deassert(rockchip->rst); in rockchip_pcie_probe()
345 clk_bulk_disable_unprepare(rockchip->clk_cnt, rockchip->clks); in rockchip_pcie_probe()
349 if (rockchip->vpcie3v3) in rockchip_pcie_probe()
350 regulator_disable(rockchip->vpcie3v3); in rockchip_pcie_probe()
356 { .compatible = "rockchip,rk3568-pcie", },
362 .name = "rockchip-dw-pcie",