Lines Matching +full:pcie +full:- +full:ep
1 // SPDX-License-Identifier: GPL-2.0
3 * PCIe host controller driver for Samsung Exynos SoCs
5 * Copyright (C) 2013-2020 Samsung Electronics Co., Ltd.
24 #include "pcie-designware.h"
26 #define to_exynos_pcie(x) dev_get_drvdata((x)->dev)
28 /* PCIe ELBI registers */
71 static void exynos_pcie_sideband_dbi_w_mode(struct exynos_pcie *ep, bool on) in exynos_pcie_sideband_dbi_w_mode() argument
73 struct dw_pcie *pci = &ep->pci; in exynos_pcie_sideband_dbi_w_mode()
76 val = exynos_pcie_readl(pci->elbi_base, PCIE_ELBI_SLV_AWMISC); in exynos_pcie_sideband_dbi_w_mode()
81 exynos_pcie_writel(pci->elbi_base, val, PCIE_ELBI_SLV_AWMISC); in exynos_pcie_sideband_dbi_w_mode()
84 static void exynos_pcie_sideband_dbi_r_mode(struct exynos_pcie *ep, bool on) in exynos_pcie_sideband_dbi_r_mode() argument
86 struct dw_pcie *pci = &ep->pci; in exynos_pcie_sideband_dbi_r_mode()
89 val = exynos_pcie_readl(pci->elbi_base, PCIE_ELBI_SLV_ARMISC); in exynos_pcie_sideband_dbi_r_mode()
94 exynos_pcie_writel(pci->elbi_base, val, PCIE_ELBI_SLV_ARMISC); in exynos_pcie_sideband_dbi_r_mode()
97 static void exynos_pcie_assert_core_reset(struct exynos_pcie *ep) in exynos_pcie_assert_core_reset() argument
99 struct dw_pcie *pci = &ep->pci; in exynos_pcie_assert_core_reset()
102 val = exynos_pcie_readl(pci->elbi_base, PCIE_CORE_RESET); in exynos_pcie_assert_core_reset()
104 exynos_pcie_writel(pci->elbi_base, val, PCIE_CORE_RESET); in exynos_pcie_assert_core_reset()
105 exynos_pcie_writel(pci->elbi_base, 0, PCIE_STICKY_RESET); in exynos_pcie_assert_core_reset()
106 exynos_pcie_writel(pci->elbi_base, 0, PCIE_NONSTICKY_RESET); in exynos_pcie_assert_core_reset()
109 static void exynos_pcie_deassert_core_reset(struct exynos_pcie *ep) in exynos_pcie_deassert_core_reset() argument
111 struct dw_pcie *pci = &ep->pci; in exynos_pcie_deassert_core_reset()
114 val = exynos_pcie_readl(pci->elbi_base, PCIE_CORE_RESET); in exynos_pcie_deassert_core_reset()
117 exynos_pcie_writel(pci->elbi_base, val, PCIE_CORE_RESET); in exynos_pcie_deassert_core_reset()
118 exynos_pcie_writel(pci->elbi_base, 1, PCIE_STICKY_RESET); in exynos_pcie_deassert_core_reset()
119 exynos_pcie_writel(pci->elbi_base, 1, PCIE_NONSTICKY_RESET); in exynos_pcie_deassert_core_reset()
120 exynos_pcie_writel(pci->elbi_base, 1, PCIE_APP_INIT_RESET); in exynos_pcie_deassert_core_reset()
121 exynos_pcie_writel(pci->elbi_base, 0, PCIE_APP_INIT_RESET); in exynos_pcie_deassert_core_reset()
128 val = exynos_pcie_readl(pci->elbi_base, PCIE_SW_WAKE); in exynos_pcie_start_link()
130 exynos_pcie_writel(pci->elbi_base, val, PCIE_SW_WAKE); in exynos_pcie_start_link()
133 exynos_pcie_writel(pci->elbi_base, PCIE_ELBI_LTSSM_ENABLE, in exynos_pcie_start_link()
138 static void exynos_pcie_clear_irq_pulse(struct exynos_pcie *ep) in exynos_pcie_clear_irq_pulse() argument
140 struct dw_pcie *pci = &ep->pci; in exynos_pcie_clear_irq_pulse()
142 u32 val = exynos_pcie_readl(pci->elbi_base, PCIE_IRQ_PULSE); in exynos_pcie_clear_irq_pulse()
144 exynos_pcie_writel(pci->elbi_base, val, PCIE_IRQ_PULSE); in exynos_pcie_clear_irq_pulse()
149 struct exynos_pcie *ep = arg; in exynos_pcie_irq_handler() local
151 exynos_pcie_clear_irq_pulse(ep); in exynos_pcie_irq_handler()
155 static void exynos_pcie_enable_irq_pulse(struct exynos_pcie *ep) in exynos_pcie_enable_irq_pulse() argument
157 struct dw_pcie *pci = &ep->pci; in exynos_pcie_enable_irq_pulse()
162 exynos_pcie_writel(pci->elbi_base, val, PCIE_IRQ_EN_PULSE); in exynos_pcie_enable_irq_pulse()
163 exynos_pcie_writel(pci->elbi_base, 0, PCIE_IRQ_EN_LEVEL); in exynos_pcie_enable_irq_pulse()
164 exynos_pcie_writel(pci->elbi_base, 0, PCIE_IRQ_EN_SPECIAL); in exynos_pcie_enable_irq_pulse()
170 struct exynos_pcie *ep = to_exynos_pcie(pci); in exynos_pcie_read_dbi() local
173 exynos_pcie_sideband_dbi_r_mode(ep, true); in exynos_pcie_read_dbi()
175 exynos_pcie_sideband_dbi_r_mode(ep, false); in exynos_pcie_read_dbi()
182 struct exynos_pcie *ep = to_exynos_pcie(pci); in exynos_pcie_write_dbi() local
184 exynos_pcie_sideband_dbi_w_mode(ep, true); in exynos_pcie_write_dbi()
186 exynos_pcie_sideband_dbi_w_mode(ep, false); in exynos_pcie_write_dbi()
192 struct dw_pcie *pci = to_dw_pcie_from_pp(bus->sysdata); in exynos_pcie_rd_own_conf()
204 struct dw_pcie *pci = to_dw_pcie_from_pp(bus->sysdata); in exynos_pcie_wr_own_conf()
220 u32 val = exynos_pcie_readl(pci->elbi_base, PCIE_ELBI_RDLH_LINKUP); in exynos_pcie_link_up()
228 struct exynos_pcie *ep = to_exynos_pcie(pci); in exynos_pcie_host_init() local
230 pp->bridge->ops = &exynos_pci_ops; in exynos_pcie_host_init()
232 exynos_pcie_assert_core_reset(ep); in exynos_pcie_host_init()
234 phy_init(ep->phy); in exynos_pcie_host_init()
235 phy_power_on(ep->phy); in exynos_pcie_host_init()
237 exynos_pcie_deassert_core_reset(ep); in exynos_pcie_host_init()
238 exynos_pcie_enable_irq_pulse(ep); in exynos_pcie_host_init()
247 static int exynos_add_pcie_port(struct exynos_pcie *ep, in exynos_add_pcie_port() argument
250 struct dw_pcie *pci = &ep->pci; in exynos_add_pcie_port()
251 struct dw_pcie_rp *pp = &pci->pp; in exynos_add_pcie_port()
252 struct device *dev = &pdev->dev; in exynos_add_pcie_port()
255 pp->irq = platform_get_irq(pdev, 0); in exynos_add_pcie_port()
256 if (pp->irq < 0) in exynos_add_pcie_port()
257 return pp->irq; in exynos_add_pcie_port()
259 ret = devm_request_irq(dev, pp->irq, exynos_pcie_irq_handler, in exynos_add_pcie_port()
260 IRQF_SHARED, "exynos-pcie", ep); in exynos_add_pcie_port()
266 pp->ops = &exynos_pcie_host_ops; in exynos_add_pcie_port()
267 pp->msi_irq[0] = -ENODEV; in exynos_add_pcie_port()
287 struct device *dev = &pdev->dev; in exynos_pcie_probe()
288 struct exynos_pcie *ep; in exynos_pcie_probe() local
289 struct device_node *np = dev->of_node; in exynos_pcie_probe()
292 ep = devm_kzalloc(dev, sizeof(*ep), GFP_KERNEL); in exynos_pcie_probe()
293 if (!ep) in exynos_pcie_probe()
294 return -ENOMEM; in exynos_pcie_probe()
296 ep->pci.dev = dev; in exynos_pcie_probe()
297 ep->pci.ops = &dw_pcie_ops; in exynos_pcie_probe()
299 ep->phy = devm_of_phy_get(dev, np, NULL); in exynos_pcie_probe()
300 if (IS_ERR(ep->phy)) in exynos_pcie_probe()
301 return PTR_ERR(ep->phy); in exynos_pcie_probe()
303 ret = devm_clk_bulk_get_all_enabled(dev, &ep->clks); in exynos_pcie_probe()
307 ep->supplies[0].supply = "vdd18"; in exynos_pcie_probe()
308 ep->supplies[1].supply = "vdd10"; in exynos_pcie_probe()
309 ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(ep->supplies), in exynos_pcie_probe()
310 ep->supplies); in exynos_pcie_probe()
314 ret = regulator_bulk_enable(ARRAY_SIZE(ep->supplies), ep->supplies); in exynos_pcie_probe()
318 platform_set_drvdata(pdev, ep); in exynos_pcie_probe()
320 ret = exynos_add_pcie_port(ep, pdev); in exynos_pcie_probe()
327 phy_exit(ep->phy); in exynos_pcie_probe()
328 regulator_bulk_disable(ARRAY_SIZE(ep->supplies), ep->supplies); in exynos_pcie_probe()
335 struct exynos_pcie *ep = platform_get_drvdata(pdev); in exynos_pcie_remove() local
337 dw_pcie_host_deinit(&ep->pci.pp); in exynos_pcie_remove()
338 exynos_pcie_assert_core_reset(ep); in exynos_pcie_remove()
339 phy_power_off(ep->phy); in exynos_pcie_remove()
340 phy_exit(ep->phy); in exynos_pcie_remove()
341 regulator_bulk_disable(ARRAY_SIZE(ep->supplies), ep->supplies); in exynos_pcie_remove()
346 struct exynos_pcie *ep = dev_get_drvdata(dev); in exynos_pcie_suspend_noirq() local
348 exynos_pcie_assert_core_reset(ep); in exynos_pcie_suspend_noirq()
349 phy_power_off(ep->phy); in exynos_pcie_suspend_noirq()
350 phy_exit(ep->phy); in exynos_pcie_suspend_noirq()
351 regulator_bulk_disable(ARRAY_SIZE(ep->supplies), ep->supplies); in exynos_pcie_suspend_noirq()
358 struct exynos_pcie *ep = dev_get_drvdata(dev); in exynos_pcie_resume_noirq() local
359 struct dw_pcie *pci = &ep->pci; in exynos_pcie_resume_noirq()
360 struct dw_pcie_rp *pp = &pci->pp; in exynos_pcie_resume_noirq()
363 ret = regulator_bulk_enable(ARRAY_SIZE(ep->supplies), ep->supplies); in exynos_pcie_resume_noirq()
367 /* exynos_pcie_host_init controls ep->phy */ in exynos_pcie_resume_noirq()
380 { .compatible = "samsung,exynos5433-pcie", },
388 .name = "exynos-pcie",
394 MODULE_DESCRIPTION("Samsung Exynos PCIe host controller driver");