Lines Matching +full:pci +full:- +full:phy

1 // SPDX-License-Identifier: GPL-2.0
7 * Copyright (C) 2010-2014 ST Microelectronics
17 #include <linux/pci.h>
18 #include <linux/phy/phy.h>
22 #include "pcie-designware.h"
25 struct dw_pcie *pci; member
27 struct phy *phy; member
67 #define to_spear13xx_pcie(x) dev_get_drvdata((x)->dev)
69 static int spear13xx_pcie_start_link(struct dw_pcie *pci) in spear13xx_pcie_start_link() argument
71 struct spear13xx_pcie *spear13xx_pcie = to_spear13xx_pcie(pci); in spear13xx_pcie_start_link()
72 struct pcie_app_reg __iomem *app_reg = spear13xx_pcie->app_base; in spear13xx_pcie_start_link()
78 &app_reg->app_ctrl_0); in spear13xx_pcie_start_link()
86 struct pcie_app_reg __iomem *app_reg = spear13xx_pcie->app_base; in spear13xx_pcie_irq_handler()
87 struct dw_pcie *pci = spear13xx_pcie->pci; in spear13xx_pcie_irq_handler() local
88 struct dw_pcie_rp *pp = &pci->pp; in spear13xx_pcie_irq_handler()
91 status = readl(&app_reg->int_sts); in spear13xx_pcie_irq_handler()
98 writel(status, &app_reg->int_clr); in spear13xx_pcie_irq_handler()
105 struct pcie_app_reg __iomem *app_reg = spear13xx_pcie->app_base; in spear13xx_pcie_enable_interrupts()
109 writel(readl(&app_reg->int_mask) | in spear13xx_pcie_enable_interrupts()
110 MSI_CTRL_INT, &app_reg->int_mask); in spear13xx_pcie_enable_interrupts()
113 static int spear13xx_pcie_link_up(struct dw_pcie *pci) in spear13xx_pcie_link_up() argument
115 struct spear13xx_pcie *spear13xx_pcie = to_spear13xx_pcie(pci); in spear13xx_pcie_link_up()
116 struct pcie_app_reg __iomem *app_reg = spear13xx_pcie->app_base; in spear13xx_pcie_link_up()
118 if (readl(&app_reg->app_status_1) & XMLH_LINK_UP) in spear13xx_pcie_link_up()
126 struct dw_pcie *pci = to_dw_pcie_from_pp(pp); in spear13xx_pcie_host_init() local
127 struct spear13xx_pcie *spear13xx_pcie = to_spear13xx_pcie(pci); in spear13xx_pcie_host_init()
128 u32 exp_cap_off = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP); in spear13xx_pcie_host_init()
131 spear13xx_pcie->app_base = pci->dbi_base + 0x2000; in spear13xx_pcie_host_init()
138 val = dw_pcie_readw_dbi(pci, exp_cap_off + PCI_EXP_DEVCTL); in spear13xx_pcie_host_init()
140 dw_pcie_writew_dbi(pci, exp_cap_off + PCI_EXP_DEVCTL, val); in spear13xx_pcie_host_init()
142 dw_pcie_writew_dbi(pci, PCI_VENDOR_ID, 0x104A); in spear13xx_pcie_host_init()
143 dw_pcie_writew_dbi(pci, PCI_DEVICE_ID, 0xCD80); in spear13xx_pcie_host_init()
157 struct dw_pcie *pci = spear13xx_pcie->pci; in spear13xx_add_pcie_port() local
158 struct dw_pcie_rp *pp = &pci->pp; in spear13xx_add_pcie_port()
159 struct device *dev = &pdev->dev; in spear13xx_add_pcie_port()
162 pp->irq = platform_get_irq(pdev, 0); in spear13xx_add_pcie_port()
163 if (pp->irq < 0) in spear13xx_add_pcie_port()
164 return pp->irq; in spear13xx_add_pcie_port()
166 ret = devm_request_irq(dev, pp->irq, spear13xx_pcie_irq_handler, in spear13xx_add_pcie_port()
168 "spear1340-pcie", spear13xx_pcie); in spear13xx_add_pcie_port()
170 dev_err(dev, "failed to request irq %d\n", pp->irq); in spear13xx_add_pcie_port()
174 pp->ops = &spear13xx_pcie_host_ops; in spear13xx_add_pcie_port()
175 pp->msi_irq[0] = -ENODEV; in spear13xx_add_pcie_port()
193 struct device *dev = &pdev->dev; in spear13xx_pcie_probe()
194 struct dw_pcie *pci; in spear13xx_pcie_probe() local
196 struct device_node *np = dev->of_node; in spear13xx_pcie_probe()
201 return -ENOMEM; in spear13xx_pcie_probe()
203 pci = devm_kzalloc(dev, sizeof(*pci), GFP_KERNEL); in spear13xx_pcie_probe()
204 if (!pci) in spear13xx_pcie_probe()
205 return -ENOMEM; in spear13xx_pcie_probe()
207 pci->dev = dev; in spear13xx_pcie_probe()
208 pci->ops = &dw_pcie_ops; in spear13xx_pcie_probe()
210 spear13xx_pcie->pci = pci; in spear13xx_pcie_probe()
212 spear13xx_pcie->phy = devm_phy_get(dev, "pcie-phy"); in spear13xx_pcie_probe()
213 if (IS_ERR(spear13xx_pcie->phy)) { in spear13xx_pcie_probe()
214 ret = PTR_ERR(spear13xx_pcie->phy); in spear13xx_pcie_probe()
215 if (ret == -EPROBE_DEFER) in spear13xx_pcie_probe()
218 dev_err(dev, "couldn't get pcie-phy\n"); in spear13xx_pcie_probe()
222 phy_init(spear13xx_pcie->phy); in spear13xx_pcie_probe()
224 spear13xx_pcie->clk = devm_clk_get(dev, NULL); in spear13xx_pcie_probe()
225 if (IS_ERR(spear13xx_pcie->clk)) { in spear13xx_pcie_probe()
227 return PTR_ERR(spear13xx_pcie->clk); in spear13xx_pcie_probe()
229 ret = clk_prepare_enable(spear13xx_pcie->clk); in spear13xx_pcie_probe()
235 if (of_property_read_bool(np, "st,pcie-is-gen1")) in spear13xx_pcie_probe()
236 pci->link_gen = 1; in spear13xx_pcie_probe()
247 clk_disable_unprepare(spear13xx_pcie->clk); in spear13xx_pcie_probe()
253 { .compatible = "st,spear1340-pcie", },
260 .name = "spear-pcie",