Lines Matching +full:pcie +full:- +full:phy

1 // SPDX-License-Identifier: GPL-2.0
3 * PCIe host controller driver for Marvell Armada-8K SoCs
5 * Armada-8K PCIe Glue Layer Source Code
20 #include <linux/phy/phy.h>
25 #include "pcie-designware.h"
33 struct phy *phy[ARMADA8K_PCIE_MAX_LANES]; member
61 * AR/AW Cache defaults: Normal memory, Write-Back, Read / Write
71 #define to_armada8k_pcie(x) dev_get_drvdata((x)->dev)
73 static void armada8k_pcie_disable_phys(struct armada8k_pcie *pcie) in armada8k_pcie_disable_phys() argument
78 phy_power_off(pcie->phy[i]); in armada8k_pcie_disable_phys()
79 phy_exit(pcie->phy[i]); in armada8k_pcie_disable_phys()
83 static int armada8k_pcie_enable_phys(struct armada8k_pcie *pcie) in armada8k_pcie_enable_phys() argument
89 ret = phy_init(pcie->phy[i]); in armada8k_pcie_enable_phys()
93 ret = phy_set_mode_ext(pcie->phy[i], PHY_MODE_PCIE, in armada8k_pcie_enable_phys()
94 pcie->phy_count); in armada8k_pcie_enable_phys()
96 phy_exit(pcie->phy[i]); in armada8k_pcie_enable_phys()
100 ret = phy_power_on(pcie->phy[i]); in armada8k_pcie_enable_phys()
102 phy_exit(pcie->phy[i]); in armada8k_pcie_enable_phys()
110 static int armada8k_pcie_setup_phys(struct armada8k_pcie *pcie) in armada8k_pcie_setup_phys() argument
112 struct dw_pcie *pci = pcie->pci; in armada8k_pcie_setup_phys()
113 struct device *dev = pci->dev; in armada8k_pcie_setup_phys()
114 struct device_node *node = dev->of_node; in armada8k_pcie_setup_phys()
119 pcie->phy[i] = devm_of_phy_get_by_index(dev, node, i); in armada8k_pcie_setup_phys()
120 if (IS_ERR(pcie->phy[i])) { in armada8k_pcie_setup_phys()
121 if (PTR_ERR(pcie->phy[i]) != -ENODEV) in armada8k_pcie_setup_phys()
122 return PTR_ERR(pcie->phy[i]); in armada8k_pcie_setup_phys()
124 pcie->phy[i] = NULL; in armada8k_pcie_setup_phys()
128 pcie->phy_count++; in armada8k_pcie_setup_phys()
131 /* Old bindings miss the PHY handle, so just warn if there is no PHY */ in armada8k_pcie_setup_phys()
132 if (!pcie->phy_count) in armada8k_pcie_setup_phys()
133 dev_warn(dev, "No available PHY\n"); in armada8k_pcie_setup_phys()
135 ret = armada8k_pcie_enable_phys(pcie); in armada8k_pcie_setup_phys()
137 dev_err(dev, "Failed to initialize PHY(s) (%d)\n", ret); in armada8k_pcie_setup_phys()
152 dev_dbg(pci->dev, "No link detected (Global-Status: 0x%08x).\n", reg); in armada8k_pcie_link_up()
186 /* Set the PCIe master AxCache attributes */ in armada8k_pcie_host_init()
190 /* Set the PCIe master AxDomain attributes */ in armada8k_pcie_host_init()
201 /* Enable INT A-D interrupts */ in armada8k_pcie_host_init()
212 struct armada8k_pcie *pcie = arg; in armada8k_pcie_irq_handler() local
213 struct dw_pcie *pci = pcie->pci; in armada8k_pcie_irq_handler()
218 * PCI device. However, they are also latched into the PCIe in armada8k_pcie_irq_handler()
231 static int armada8k_add_pcie_port(struct armada8k_pcie *pcie, in armada8k_add_pcie_port() argument
234 struct dw_pcie *pci = pcie->pci; in armada8k_add_pcie_port()
235 struct dw_pcie_rp *pp = &pci->pp; in armada8k_add_pcie_port()
236 struct device *dev = &pdev->dev; in armada8k_add_pcie_port()
239 pp->ops = &armada8k_pcie_host_ops; in armada8k_add_pcie_port()
241 pp->irq = platform_get_irq(pdev, 0); in armada8k_add_pcie_port()
242 if (pp->irq < 0) in armada8k_add_pcie_port()
243 return pp->irq; in armada8k_add_pcie_port()
245 ret = devm_request_irq(dev, pp->irq, armada8k_pcie_irq_handler, in armada8k_add_pcie_port()
246 IRQF_SHARED, "armada8k-pcie", pcie); in armada8k_add_pcie_port()
248 dev_err(dev, "failed to request irq %d\n", pp->irq); in armada8k_add_pcie_port()
269 struct armada8k_pcie *pcie; in armada8k_pcie_probe() local
270 struct device *dev = &pdev->dev; in armada8k_pcie_probe()
274 pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL); in armada8k_pcie_probe()
275 if (!pcie) in armada8k_pcie_probe()
276 return -ENOMEM; in armada8k_pcie_probe()
280 return -ENOMEM; in armada8k_pcie_probe()
282 pci->dev = dev; in armada8k_pcie_probe()
283 pci->ops = &dw_pcie_ops; in armada8k_pcie_probe()
285 pcie->pci = pci; in armada8k_pcie_probe()
287 pcie->clk = devm_clk_get(dev, NULL); in armada8k_pcie_probe()
288 if (IS_ERR(pcie->clk)) in armada8k_pcie_probe()
289 return PTR_ERR(pcie->clk); in armada8k_pcie_probe()
291 ret = clk_prepare_enable(pcie->clk); in armada8k_pcie_probe()
295 pcie->clk_reg = devm_clk_get(dev, "reg"); in armada8k_pcie_probe()
296 if (pcie->clk_reg == ERR_PTR(-EPROBE_DEFER)) { in armada8k_pcie_probe()
297 ret = -EPROBE_DEFER; in armada8k_pcie_probe()
300 if (!IS_ERR(pcie->clk_reg)) { in armada8k_pcie_probe()
301 ret = clk_prepare_enable(pcie->clk_reg); in armada8k_pcie_probe()
306 /* Get the dw-pcie unit configuration/control registers base. */ in armada8k_pcie_probe()
308 pci->dbi_base = devm_pci_remap_cfg_resource(dev, base); in armada8k_pcie_probe()
309 if (IS_ERR(pci->dbi_base)) { in armada8k_pcie_probe()
310 ret = PTR_ERR(pci->dbi_base); in armada8k_pcie_probe()
314 ret = armada8k_pcie_setup_phys(pcie); in armada8k_pcie_probe()
318 platform_set_drvdata(pdev, pcie); in armada8k_pcie_probe()
320 ret = armada8k_add_pcie_port(pcie, pdev); in armada8k_pcie_probe()
327 armada8k_pcie_disable_phys(pcie); in armada8k_pcie_probe()
329 clk_disable_unprepare(pcie->clk_reg); in armada8k_pcie_probe()
331 clk_disable_unprepare(pcie->clk); in armada8k_pcie_probe()
337 { .compatible = "marvell,armada8k-pcie", },
344 .name = "armada8k-pcie",