Lines Matching +full:syscon +full:- +full:pcie +full:- +full:mode
1 // SPDX-License-Identifier: GPL-2.0
3 * PCIe host controller driver for Axis ARTPEC-6 SoC
20 #include <linux/mfd/syscon.h>
23 #include "pcie-designware.h"
25 #define to_artpec6_pcie(x) dev_get_drvdata((x)->dev)
34 struct regmap *regmap; /* DT axis,syscon-pcie */
37 enum dw_pcie_device_mode mode; member
42 enum dw_pcie_device_mode mode; member
47 /* ARTPEC-6 specific registers */
61 /* ARTPEC-7 specific fields */
66 /* ARTPEC-7 specific fields */
88 regmap_read(artpec6_pcie->regmap, offset, &val); in artpec6_pcie_readl()
94 regmap_write(artpec6_pcie->regmap, offset, val); in artpec6_pcie_writel()
100 struct dw_pcie_rp *pp = &pci->pp; in artpec6_pcie_cpu_addr_fixup()
101 struct dw_pcie_ep *ep = &pci->ep; in artpec6_pcie_cpu_addr_fixup()
103 switch (artpec6_pcie->mode) { in artpec6_pcie_cpu_addr_fixup()
105 return cpu_addr - pp->cfg0_base; in artpec6_pcie_cpu_addr_fixup()
107 return cpu_addr - ep->phys_base; in artpec6_pcie_cpu_addr_fixup()
109 dev_err(pci->dev, "UNKNOWN device type\n"); in artpec6_pcie_cpu_addr_fixup()
144 struct dw_pcie *pci = artpec6_pcie->pci; in artpec6_pcie_wait_for_phy_a6()
145 struct device *dev = pci->dev; in artpec6_pcie_wait_for_phy_a6()
153 retries--; in artpec6_pcie_wait_for_phy_a6()
157 dev_err(dev, "PCIe clock manager did not leave idle state\n"); in artpec6_pcie_wait_for_phy_a6()
162 val = readl(artpec6_pcie->phy_base + PHY_STATUS); in artpec6_pcie_wait_for_phy_a6()
163 retries--; in artpec6_pcie_wait_for_phy_a6()
171 struct dw_pcie *pci = artpec6_pcie->pci; in artpec6_pcie_wait_for_phy_a7()
172 struct device *dev = pci->dev; in artpec6_pcie_wait_for_phy_a7()
181 retries--; in artpec6_pcie_wait_for_phy_a7()
185 dev_err(dev, "PCIe clock manager did not leave idle state\n"); in artpec6_pcie_wait_for_phy_a7()
190 phy_status_tx = readw(artpec6_pcie->phy_base + PHY_TX_ASIC_OUT); in artpec6_pcie_wait_for_phy_a7()
191 phy_status_rx = readw(artpec6_pcie->phy_base + PHY_RX_ASIC_OUT); in artpec6_pcie_wait_for_phy_a7()
192 retries--; in artpec6_pcie_wait_for_phy_a7()
201 switch (artpec6_pcie->variant) { in artpec6_pcie_wait_for_phy()
243 struct dw_pcie *pci = artpec6_pcie->pci; in artpec6_pcie_init_phy_a7()
250 dev_dbg(pci->dev, "Using reference clock: %s\n", in artpec6_pcie_init_phy_a7()
275 switch (artpec6_pcie->variant) { in artpec6_pcie_init_phy()
290 switch (artpec6_pcie->variant) { in artpec6_pcie_assert_core_reset()
306 switch (artpec6_pcie->variant) { in artpec6_pcie_deassert_core_reset()
323 if (artpec6_pcie->variant == ARTPEC7) { in artpec6_pcie_host_init()
324 pci->n_fts[0] = 180; in artpec6_pcie_host_init()
325 pci->n_fts[1] = 180; in artpec6_pcie_host_init()
361 dev_err(pci->dev, "EP cannot trigger INTx IRQs\n"); in artpec6_pcie_raise_irq()
362 return -EINVAL; in artpec6_pcie_raise_irq()
366 dev_err(pci->dev, "UNKNOWN IRQ type\n"); in artpec6_pcie_raise_irq()
379 struct device *dev = &pdev->dev; in artpec6_pcie_probe()
385 enum dw_pcie_device_mode mode; in artpec6_pcie_probe() local
390 return -EINVAL; in artpec6_pcie_probe()
392 variant = (enum artpec_pcie_variants)data->variant; in artpec6_pcie_probe()
393 mode = (enum dw_pcie_device_mode)data->mode; in artpec6_pcie_probe()
397 return -ENOMEM; in artpec6_pcie_probe()
401 return -ENOMEM; in artpec6_pcie_probe()
403 pci->dev = dev; in artpec6_pcie_probe()
404 pci->ops = &dw_pcie_ops; in artpec6_pcie_probe()
406 artpec6_pcie->pci = pci; in artpec6_pcie_probe()
407 artpec6_pcie->variant = variant; in artpec6_pcie_probe()
408 artpec6_pcie->mode = mode; in artpec6_pcie_probe()
410 artpec6_pcie->phy_base = in artpec6_pcie_probe()
412 if (IS_ERR(artpec6_pcie->phy_base)) in artpec6_pcie_probe()
413 return PTR_ERR(artpec6_pcie->phy_base); in artpec6_pcie_probe()
415 artpec6_pcie->regmap = in artpec6_pcie_probe()
416 syscon_regmap_lookup_by_phandle(dev->of_node, in artpec6_pcie_probe()
417 "axis,syscon-pcie"); in artpec6_pcie_probe()
418 if (IS_ERR(artpec6_pcie->regmap)) in artpec6_pcie_probe()
419 return PTR_ERR(artpec6_pcie->regmap); in artpec6_pcie_probe()
423 switch (artpec6_pcie->mode) { in artpec6_pcie_probe()
426 return -ENODEV; in artpec6_pcie_probe()
428 pci->pp.ops = &artpec6_pcie_host_ops; in artpec6_pcie_probe()
430 ret = dw_pcie_host_init(&pci->pp); in artpec6_pcie_probe()
436 return -ENODEV; in artpec6_pcie_probe()
442 pci->ep.ops = &pcie_ep_ops; in artpec6_pcie_probe()
444 ret = dw_pcie_ep_init(&pci->ep); in artpec6_pcie_probe()
448 ret = dw_pcie_ep_init_registers(&pci->ep); in artpec6_pcie_probe()
451 dw_pcie_ep_deinit(&pci->ep); in artpec6_pcie_probe()
455 pci_epc_init_notify(pci->ep.epc); in artpec6_pcie_probe()
459 dev_err(dev, "INVALID device type %d\n", artpec6_pcie->mode); in artpec6_pcie_probe()
467 .mode = DW_PCIE_RC_TYPE,
472 .mode = DW_PCIE_EP_TYPE,
477 .mode = DW_PCIE_RC_TYPE,
482 .mode = DW_PCIE_EP_TYPE,
487 .compatible = "axis,artpec6-pcie",
491 .compatible = "axis,artpec6-pcie-ep",
495 .compatible = "axis,artpec7-pcie",
499 .compatible = "axis,artpec7-pcie-ep",
508 .name = "artpec6-pcie",