Lines Matching +full:pci +full:- +full:ep

1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright (C) 2013-2020 Samsung Electronics Co., Ltd.
17 #include <linux/pci.h>
24 #include "pcie-designware.h"
26 #define to_exynos_pcie(x) dev_get_drvdata((x)->dev)
55 struct dw_pcie pci; member
72 static void exynos_pcie_sideband_dbi_w_mode(struct exynos_pcie *ep, bool on) in exynos_pcie_sideband_dbi_w_mode() argument
76 val = exynos_pcie_readl(ep->elbi_base, PCIE_ELBI_SLV_AWMISC); in exynos_pcie_sideband_dbi_w_mode()
81 exynos_pcie_writel(ep->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
88 val = exynos_pcie_readl(ep->elbi_base, PCIE_ELBI_SLV_ARMISC); in exynos_pcie_sideband_dbi_r_mode()
93 exynos_pcie_writel(ep->elbi_base, val, PCIE_ELBI_SLV_ARMISC); in exynos_pcie_sideband_dbi_r_mode()
96 static void exynos_pcie_assert_core_reset(struct exynos_pcie *ep) in exynos_pcie_assert_core_reset() argument
100 val = exynos_pcie_readl(ep->elbi_base, PCIE_CORE_RESET); in exynos_pcie_assert_core_reset()
102 exynos_pcie_writel(ep->elbi_base, val, PCIE_CORE_RESET); in exynos_pcie_assert_core_reset()
103 exynos_pcie_writel(ep->elbi_base, 0, PCIE_STICKY_RESET); in exynos_pcie_assert_core_reset()
104 exynos_pcie_writel(ep->elbi_base, 0, PCIE_NONSTICKY_RESET); in exynos_pcie_assert_core_reset()
107 static void exynos_pcie_deassert_core_reset(struct exynos_pcie *ep) in exynos_pcie_deassert_core_reset() argument
111 val = exynos_pcie_readl(ep->elbi_base, PCIE_CORE_RESET); in exynos_pcie_deassert_core_reset()
114 exynos_pcie_writel(ep->elbi_base, val, PCIE_CORE_RESET); in exynos_pcie_deassert_core_reset()
115 exynos_pcie_writel(ep->elbi_base, 1, PCIE_STICKY_RESET); in exynos_pcie_deassert_core_reset()
116 exynos_pcie_writel(ep->elbi_base, 1, PCIE_NONSTICKY_RESET); in exynos_pcie_deassert_core_reset()
117 exynos_pcie_writel(ep->elbi_base, 1, PCIE_APP_INIT_RESET); in exynos_pcie_deassert_core_reset()
118 exynos_pcie_writel(ep->elbi_base, 0, PCIE_APP_INIT_RESET); in exynos_pcie_deassert_core_reset()
121 static int exynos_pcie_start_link(struct dw_pcie *pci) in exynos_pcie_start_link() argument
123 struct exynos_pcie *ep = to_exynos_pcie(pci); in exynos_pcie_start_link() local
126 val = exynos_pcie_readl(ep->elbi_base, PCIE_SW_WAKE); in exynos_pcie_start_link()
128 exynos_pcie_writel(ep->elbi_base, val, PCIE_SW_WAKE); in exynos_pcie_start_link()
131 exynos_pcie_writel(ep->elbi_base, PCIE_ELBI_LTSSM_ENABLE, in exynos_pcie_start_link()
136 static void exynos_pcie_clear_irq_pulse(struct exynos_pcie *ep) in exynos_pcie_clear_irq_pulse() argument
138 u32 val = exynos_pcie_readl(ep->elbi_base, PCIE_IRQ_PULSE); in exynos_pcie_clear_irq_pulse()
140 exynos_pcie_writel(ep->elbi_base, val, PCIE_IRQ_PULSE); in exynos_pcie_clear_irq_pulse()
145 struct exynos_pcie *ep = arg; in exynos_pcie_irq_handler() local
147 exynos_pcie_clear_irq_pulse(ep); in exynos_pcie_irq_handler()
151 static void exynos_pcie_enable_irq_pulse(struct exynos_pcie *ep) in exynos_pcie_enable_irq_pulse() argument
156 exynos_pcie_writel(ep->elbi_base, val, PCIE_IRQ_EN_PULSE); in exynos_pcie_enable_irq_pulse()
157 exynos_pcie_writel(ep->elbi_base, 0, PCIE_IRQ_EN_LEVEL); in exynos_pcie_enable_irq_pulse()
158 exynos_pcie_writel(ep->elbi_base, 0, PCIE_IRQ_EN_SPECIAL); in exynos_pcie_enable_irq_pulse()
161 static u32 exynos_pcie_read_dbi(struct dw_pcie *pci, void __iomem *base, in exynos_pcie_read_dbi() argument
164 struct exynos_pcie *ep = to_exynos_pcie(pci); in exynos_pcie_read_dbi() local
167 exynos_pcie_sideband_dbi_r_mode(ep, true); in exynos_pcie_read_dbi()
169 exynos_pcie_sideband_dbi_r_mode(ep, false); in exynos_pcie_read_dbi()
173 static void exynos_pcie_write_dbi(struct dw_pcie *pci, void __iomem *base, in exynos_pcie_write_dbi() argument
176 struct exynos_pcie *ep = to_exynos_pcie(pci); in exynos_pcie_write_dbi() local
178 exynos_pcie_sideband_dbi_w_mode(ep, true); in exynos_pcie_write_dbi()
180 exynos_pcie_sideband_dbi_w_mode(ep, false); in exynos_pcie_write_dbi()
186 struct dw_pcie *pci = to_dw_pcie_from_pp(bus->sysdata); in exynos_pcie_rd_own_conf() local
191 *val = dw_pcie_read_dbi(pci, where, size); in exynos_pcie_rd_own_conf()
198 struct dw_pcie *pci = to_dw_pcie_from_pp(bus->sysdata); in exynos_pcie_wr_own_conf() local
203 dw_pcie_write_dbi(pci, where, size, val); in exynos_pcie_wr_own_conf()
212 static int exynos_pcie_link_up(struct dw_pcie *pci) in exynos_pcie_link_up() argument
214 struct exynos_pcie *ep = to_exynos_pcie(pci); in exynos_pcie_link_up() local
215 u32 val = exynos_pcie_readl(ep->elbi_base, PCIE_ELBI_RDLH_LINKUP); in exynos_pcie_link_up()
222 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); in exynos_pcie_host_init() local
223 struct exynos_pcie *ep = to_exynos_pcie(pci); in exynos_pcie_host_init() local
225 pp->bridge->ops = &exynos_pci_ops; in exynos_pcie_host_init()
227 exynos_pcie_assert_core_reset(ep); in exynos_pcie_host_init()
229 phy_init(ep->phy); in exynos_pcie_host_init()
230 phy_power_on(ep->phy); in exynos_pcie_host_init()
232 exynos_pcie_deassert_core_reset(ep); in exynos_pcie_host_init()
233 exynos_pcie_enable_irq_pulse(ep); in exynos_pcie_host_init()
242 static int exynos_add_pcie_port(struct exynos_pcie *ep, in exynos_add_pcie_port() argument
245 struct dw_pcie *pci = &ep->pci; in exynos_add_pcie_port() local
246 struct dw_pcie_rp *pp = &pci->pp; in exynos_add_pcie_port()
247 struct device *dev = &pdev->dev; in exynos_add_pcie_port()
250 pp->irq = platform_get_irq(pdev, 0); in exynos_add_pcie_port()
251 if (pp->irq < 0) in exynos_add_pcie_port()
252 return pp->irq; in exynos_add_pcie_port()
254 ret = devm_request_irq(dev, pp->irq, exynos_pcie_irq_handler, in exynos_add_pcie_port()
255 IRQF_SHARED, "exynos-pcie", ep); in exynos_add_pcie_port()
261 pp->ops = &exynos_pcie_host_ops; in exynos_add_pcie_port()
262 pp->msi_irq[0] = -ENODEV; in exynos_add_pcie_port()
282 struct device *dev = &pdev->dev; in exynos_pcie_probe()
283 struct exynos_pcie *ep; in exynos_pcie_probe() local
284 struct device_node *np = dev->of_node; in exynos_pcie_probe()
287 ep = devm_kzalloc(dev, sizeof(*ep), GFP_KERNEL); in exynos_pcie_probe()
288 if (!ep) in exynos_pcie_probe()
289 return -ENOMEM; in exynos_pcie_probe()
291 ep->pci.dev = dev; in exynos_pcie_probe()
292 ep->pci.ops = &dw_pcie_ops; in exynos_pcie_probe()
294 ep->phy = devm_of_phy_get(dev, np, NULL); in exynos_pcie_probe()
295 if (IS_ERR(ep->phy)) in exynos_pcie_probe()
296 return PTR_ERR(ep->phy); in exynos_pcie_probe()
299 ep->elbi_base = devm_platform_ioremap_resource_byname(pdev, "elbi"); in exynos_pcie_probe()
300 if (IS_ERR(ep->elbi_base)) in exynos_pcie_probe()
301 return PTR_ERR(ep->elbi_base); 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() local
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()
370 exynos_pcie_start_link(pci); in exynos_pcie_resume_noirq()
371 return dw_pcie_wait_for_link(pci); in exynos_pcie_resume_noirq()
380 { .compatible = "samsung,exynos5433-pcie", },
388 .name = "exynos-pcie",