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>
26 #include "pcie-designware.h"
34 struct phy *phy[ARMADA8K_PCIE_MAX_LANES]; member
62 * AR/AW Cache defaults: Normal memory, Write-Back, Read / Write
72 #define to_armada8k_pcie(x) dev_get_drvdata((x)->dev)
74 static void armada8k_pcie_disable_phys(struct armada8k_pcie *pcie) in armada8k_pcie_disable_phys() argument
79 phy_power_off(pcie->phy[i]); in armada8k_pcie_disable_phys()
80 phy_exit(pcie->phy[i]); in armada8k_pcie_disable_phys()
84 static int armada8k_pcie_enable_phys(struct armada8k_pcie *pcie) in armada8k_pcie_enable_phys() argument
90 ret = phy_init(pcie->phy[i]); in armada8k_pcie_enable_phys()
94 ret = phy_set_mode_ext(pcie->phy[i], PHY_MODE_PCIE, in armada8k_pcie_enable_phys()
95 pcie->phy_count); in armada8k_pcie_enable_phys()
97 phy_exit(pcie->phy[i]); in armada8k_pcie_enable_phys()
101 ret = phy_power_on(pcie->phy[i]); in armada8k_pcie_enable_phys()
103 phy_exit(pcie->phy[i]); in armada8k_pcie_enable_phys()
111 static int armada8k_pcie_setup_phys(struct armada8k_pcie *pcie) in armada8k_pcie_setup_phys() argument
113 struct dw_pcie *pci = pcie->pci; in armada8k_pcie_setup_phys()
114 struct device *dev = pci->dev; in armada8k_pcie_setup_phys()
115 struct device_node *node = dev->of_node; in armada8k_pcie_setup_phys()
120 pcie->phy[i] = devm_of_phy_get_by_index(dev, node, i); in armada8k_pcie_setup_phys()
121 if (IS_ERR(pcie->phy[i])) { in armada8k_pcie_setup_phys()
122 if (PTR_ERR(pcie->phy[i]) != -ENODEV) in armada8k_pcie_setup_phys()
123 return PTR_ERR(pcie->phy[i]); in armada8k_pcie_setup_phys()
125 pcie->phy[i] = NULL; in armada8k_pcie_setup_phys()
129 pcie->phy_count++; in armada8k_pcie_setup_phys()
132 /* Old bindings miss the PHY handle, so just warn if there is no PHY */ in armada8k_pcie_setup_phys()
133 if (!pcie->phy_count) in armada8k_pcie_setup_phys()
134 dev_warn(dev, "No available PHY\n"); in armada8k_pcie_setup_phys()
136 ret = armada8k_pcie_enable_phys(pcie); in armada8k_pcie_setup_phys()
138 dev_err(dev, "Failed to initialize PHY(s) (%d)\n", ret); in armada8k_pcie_setup_phys()
153 dev_dbg(pci->dev, "No link detected (Global-Status: 0x%08x).\n", reg); in armada8k_pcie_link_up()
157 static void armada8k_pcie_establish_link(struct armada8k_pcie *pcie) in armada8k_pcie_establish_link() argument
159 struct dw_pcie *pci = pcie->pci; in armada8k_pcie_establish_link()
175 /* Set the PCIe master AxCache attributes */ in armada8k_pcie_establish_link()
179 /* Set the PCIe master AxDomain attributes */ in armada8k_pcie_establish_link()
190 /* Enable INT A-D interrupts */ in armada8k_pcie_establish_link()
205 dev_err(pci->dev, "Link not up after reconfiguration\n"); in armada8k_pcie_establish_link()
211 struct armada8k_pcie *pcie = to_armada8k_pcie(pci); in armada8k_pcie_host_init() local
214 armada8k_pcie_establish_link(pcie); in armada8k_pcie_host_init()
221 struct armada8k_pcie *pcie = arg; in armada8k_pcie_irq_handler() local
222 struct dw_pcie *pci = pcie->pci; in armada8k_pcie_irq_handler()
227 * PCI device. However, they are also latched into the PCIe in armada8k_pcie_irq_handler()
240 static int armada8k_add_pcie_port(struct armada8k_pcie *pcie, in armada8k_add_pcie_port() argument
243 struct dw_pcie *pci = pcie->pci; in armada8k_add_pcie_port()
244 struct pcie_port *pp = &pci->pp; in armada8k_add_pcie_port()
245 struct device *dev = &pdev->dev; in armada8k_add_pcie_port()
248 pp->ops = &armada8k_pcie_host_ops; in armada8k_add_pcie_port()
250 pp->irq = platform_get_irq(pdev, 0); in armada8k_add_pcie_port()
251 if (pp->irq < 0) in armada8k_add_pcie_port()
252 return pp->irq; in armada8k_add_pcie_port()
254 ret = devm_request_irq(dev, pp->irq, armada8k_pcie_irq_handler, in armada8k_add_pcie_port()
255 IRQF_SHARED, "armada8k-pcie", pcie); in armada8k_add_pcie_port()
257 dev_err(dev, "failed to request irq %d\n", pp->irq); in armada8k_add_pcie_port()
277 struct armada8k_pcie *pcie; in armada8k_pcie_probe() local
278 struct device *dev = &pdev->dev; in armada8k_pcie_probe()
282 pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL); in armada8k_pcie_probe()
283 if (!pcie) in armada8k_pcie_probe()
284 return -ENOMEM; in armada8k_pcie_probe()
288 return -ENOMEM; in armada8k_pcie_probe()
290 pci->dev = dev; in armada8k_pcie_probe()
291 pci->ops = &dw_pcie_ops; in armada8k_pcie_probe()
293 pcie->pci = pci; in armada8k_pcie_probe()
295 pcie->clk = devm_clk_get(dev, NULL); in armada8k_pcie_probe()
296 if (IS_ERR(pcie->clk)) in armada8k_pcie_probe()
297 return PTR_ERR(pcie->clk); in armada8k_pcie_probe()
299 ret = clk_prepare_enable(pcie->clk); in armada8k_pcie_probe()
303 pcie->clk_reg = devm_clk_get(dev, "reg"); in armada8k_pcie_probe()
304 if (pcie->clk_reg == ERR_PTR(-EPROBE_DEFER)) { in armada8k_pcie_probe()
305 ret = -EPROBE_DEFER; in armada8k_pcie_probe()
308 if (!IS_ERR(pcie->clk_reg)) { in armada8k_pcie_probe()
309 ret = clk_prepare_enable(pcie->clk_reg); in armada8k_pcie_probe()
314 /* Get the dw-pcie unit configuration/control registers base. */ in armada8k_pcie_probe()
316 pci->dbi_base = devm_pci_remap_cfg_resource(dev, base); in armada8k_pcie_probe()
317 if (IS_ERR(pci->dbi_base)) { in armada8k_pcie_probe()
318 ret = PTR_ERR(pci->dbi_base); in armada8k_pcie_probe()
322 ret = armada8k_pcie_setup_phys(pcie); in armada8k_pcie_probe()
326 platform_set_drvdata(pdev, pcie); in armada8k_pcie_probe()
328 ret = armada8k_add_pcie_port(pcie, pdev); in armada8k_pcie_probe()
335 armada8k_pcie_disable_phys(pcie); in armada8k_pcie_probe()
337 clk_disable_unprepare(pcie->clk_reg); in armada8k_pcie_probe()
339 clk_disable_unprepare(pcie->clk); in armada8k_pcie_probe()
345 { .compatible = "marvell,armada8k-pcie", },
352 .name = "armada8k-pcie",