Lines Matching refs:ep

76 			struct exynos_pcie *ep);
77 int (*get_clk_resources)(struct exynos_pcie *ep);
78 int (*init_clk_resources)(struct exynos_pcie *ep);
79 void (*deinit_clk_resources)(struct exynos_pcie *ep);
83 struct exynos_pcie *ep)
85 struct dw_pcie *pci = ep->pci;
88 ep->mem_res = devm_kzalloc(dev, sizeof(*ep->mem_res), GFP_KERNEL);
89 if (!ep->mem_res)
92 ep->mem_res->elbi_base = devm_platform_ioremap_resource(pdev, 0);
93 if (IS_ERR(ep->mem_res->elbi_base))
94 return PTR_ERR(ep->mem_res->elbi_base);
99 static int exynos5440_pcie_get_clk_resources(struct exynos_pcie *ep)
101 struct dw_pcie *pci = ep->pci;
104 ep->clk_res = devm_kzalloc(dev, sizeof(*ep->clk_res), GFP_KERNEL);
105 if (!ep->clk_res)
108 ep->clk_res->clk = devm_clk_get(dev, "pcie");
109 if (IS_ERR(ep->clk_res->clk)) {
111 return PTR_ERR(ep->clk_res->clk);
114 ep->clk_res->bus_clk = devm_clk_get(dev, "pcie_bus");
115 if (IS_ERR(ep->clk_res->bus_clk)) {
117 return PTR_ERR(ep->clk_res->bus_clk);
123 static int exynos5440_pcie_init_clk_resources(struct exynos_pcie *ep)
125 struct dw_pcie *pci = ep->pci;
129 ret = clk_prepare_enable(ep->clk_res->clk);
135 ret = clk_prepare_enable(ep->clk_res->bus_clk);
144 clk_disable_unprepare(ep->clk_res->clk);
149 static void exynos5440_pcie_deinit_clk_resources(struct exynos_pcie *ep)
151 clk_disable_unprepare(ep->clk_res->bus_clk);
152 clk_disable_unprepare(ep->clk_res->clk);
172 static void exynos_pcie_sideband_dbi_w_mode(struct exynos_pcie *ep, bool on)
176 val = exynos_pcie_readl(ep->mem_res->elbi_base, PCIE_ELBI_SLV_AWMISC);
181 exynos_pcie_writel(ep->mem_res->elbi_base, val, PCIE_ELBI_SLV_AWMISC);
184 static void exynos_pcie_sideband_dbi_r_mode(struct exynos_pcie *ep, bool on)
188 val = exynos_pcie_readl(ep->mem_res->elbi_base, PCIE_ELBI_SLV_ARMISC);
193 exynos_pcie_writel(ep->mem_res->elbi_base, val, PCIE_ELBI_SLV_ARMISC);
196 static void exynos_pcie_assert_core_reset(struct exynos_pcie *ep)
200 val = exynos_pcie_readl(ep->mem_res->elbi_base, PCIE_CORE_RESET);
202 exynos_pcie_writel(ep->mem_res->elbi_base, val, PCIE_CORE_RESET);
203 exynos_pcie_writel(ep->mem_res->elbi_base, 0, PCIE_PWR_RESET);
204 exynos_pcie_writel(ep->mem_res->elbi_base, 0, PCIE_STICKY_RESET);
205 exynos_pcie_writel(ep->mem_res->elbi_base, 0, PCIE_NONSTICKY_RESET);
208 static void exynos_pcie_deassert_core_reset(struct exynos_pcie *ep)
212 val = exynos_pcie_readl(ep->mem_res->elbi_base, PCIE_CORE_RESET);
215 exynos_pcie_writel(ep->mem_res->elbi_base, val, PCIE_CORE_RESET);
216 exynos_pcie_writel(ep->mem_res->elbi_base, 1, PCIE_STICKY_RESET);
217 exynos_pcie_writel(ep->mem_res->elbi_base, 1, PCIE_NONSTICKY_RESET);
218 exynos_pcie_writel(ep->mem_res->elbi_base, 1, PCIE_APP_INIT_RESET);
219 exynos_pcie_writel(ep->mem_res->elbi_base, 0, PCIE_APP_INIT_RESET);
222 static void exynos_pcie_assert_reset(struct exynos_pcie *ep)
224 struct dw_pcie *pci = ep->pci;
227 if (ep->reset_gpio >= 0)
228 devm_gpio_request_one(dev, ep->reset_gpio,
232 static int exynos_pcie_establish_link(struct exynos_pcie *ep)
234 struct dw_pcie *pci = ep->pci;
243 exynos_pcie_assert_core_reset(ep);
245 phy_reset(ep->phy);
247 exynos_pcie_writel(ep->mem_res->elbi_base, 1,
250 phy_power_on(ep->phy);
251 phy_init(ep->phy);
253 exynos_pcie_deassert_core_reset(ep);
255 exynos_pcie_assert_reset(ep);
258 exynos_pcie_writel(ep->mem_res->elbi_base, PCIE_ELBI_LTSSM_ENABLE,
265 phy_power_off(ep->phy);
269 static void exynos_pcie_clear_irq_pulse(struct exynos_pcie *ep)
273 val = exynos_pcie_readl(ep->mem_res->elbi_base, PCIE_IRQ_PULSE);
274 exynos_pcie_writel(ep->mem_res->elbi_base, val, PCIE_IRQ_PULSE);
277 static void exynos_pcie_enable_irq_pulse(struct exynos_pcie *ep)
284 exynos_pcie_writel(ep->mem_res->elbi_base, val, PCIE_IRQ_EN_PULSE);
289 struct exynos_pcie *ep = arg;
291 exynos_pcie_clear_irq_pulse(ep);
295 static void exynos_pcie_msi_init(struct exynos_pcie *ep)
297 struct dw_pcie *pci = ep->pci;
304 val = exynos_pcie_readl(ep->mem_res->elbi_base, PCIE_IRQ_EN_LEVEL);
306 exynos_pcie_writel(ep->mem_res->elbi_base, val, PCIE_IRQ_EN_LEVEL);
309 static void exynos_pcie_enable_interrupts(struct exynos_pcie *ep)
311 exynos_pcie_enable_irq_pulse(ep);
314 exynos_pcie_msi_init(ep);
320 struct exynos_pcie *ep = to_exynos_pcie(pci);
323 exynos_pcie_sideband_dbi_r_mode(ep, true);
325 exynos_pcie_sideband_dbi_r_mode(ep, false);
332 struct exynos_pcie *ep = to_exynos_pcie(pci);
334 exynos_pcie_sideband_dbi_w_mode(ep, true);
336 exynos_pcie_sideband_dbi_w_mode(ep, false);
372 struct exynos_pcie *ep = to_exynos_pcie(pci);
375 val = exynos_pcie_readl(ep->mem_res->elbi_base, PCIE_ELBI_RDLH_LINKUP);
385 struct exynos_pcie *ep = to_exynos_pcie(pci);
389 exynos_pcie_establish_link(ep);
390 exynos_pcie_enable_interrupts(ep);
399 static int __init exynos_add_pcie_port(struct exynos_pcie *ep,
402 struct dw_pcie *pci = ep->pci;
412 IRQF_SHARED, "exynos-pcie", ep);
445 struct exynos_pcie *ep;
449 ep = devm_kzalloc(dev, sizeof(*ep), GFP_KERNEL);
450 if (!ep)
460 ep->pci = pci;
461 ep->ops = (const struct exynos_pcie_ops *)
464 ep->reset_gpio = of_get_named_gpio(np, "reset-gpio", 0);
466 ep->phy = devm_of_phy_get(dev, np, NULL);
467 if (IS_ERR(ep->phy)) {
468 if (PTR_ERR(ep->phy) != -ENODEV)
469 return PTR_ERR(ep->phy);
471 ep->phy = NULL;
474 if (ep->ops && ep->ops->get_mem_resources) {
475 ret = ep->ops->get_mem_resources(pdev, ep);
480 if (ep->ops && ep->ops->get_clk_resources &&
481 ep->ops->init_clk_resources) {
482 ret = ep->ops->get_clk_resources(ep);
485 ret = ep->ops->init_clk_resources(ep);
490 platform_set_drvdata(pdev, ep);
492 ret = exynos_add_pcie_port(ep, pdev);
499 phy_exit(ep->phy);
501 if (ep->ops && ep->ops->deinit_clk_resources)
502 ep->ops->deinit_clk_resources(ep);
508 struct exynos_pcie *ep = platform_get_drvdata(pdev);
510 if (ep->ops && ep->ops->deinit_clk_resources)
511 ep->ops->deinit_clk_resources(ep);