Skip to content

Commit c269977

Browse files
Richard Zhubjorn-helgaas
authored andcommitted
PCI: imx6: Add i.MX8Q PCIe Root Complex (RC) support
Implement i.MX8Q (i.MX8QM, i.MX8QXP, and i.MX8DXL) PCIe Root Complex (RC) support. While the controller resembles that of i.MX8MP, the PHY differs significantly. Also, there's a distinction between PCI bus addresses and CPU addresses. Introduce IMX_PCIE_FLAG_CPU_ADDR_FIXUP in drvdata::flags to indicate driver need the cpu_addr_fixup() callback to facilitate CPU address to PCI bus address conversion according to "ranges" property. Link: https://lore.kernel.org/linux-pci/[email protected] Signed-off-by: Richard Zhu <[email protected]> Signed-off-by: Frank Li <[email protected]> Signed-off-by: Krzysztof Wilczyński <[email protected]> [bhelgaas: check resource_list_first_type() for NULL] Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Manivannan Sadhasivam <[email protected]>
1 parent 8026f2d commit c269977

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

drivers/pci/controller/dwc/pci-imx6.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ enum imx_pcie_variants {
6565
IMX8MQ,
6666
IMX8MM,
6767
IMX8MP,
68+
IMX8Q,
6869
IMX95,
6970
IMX8MQ_EP,
7071
IMX8MM_EP,
@@ -80,6 +81,7 @@ enum imx_pcie_variants {
8081
#define IMX_PCIE_FLAG_HAS_PHY_RESET BIT(5)
8182
#define IMX_PCIE_FLAG_HAS_SERDES BIT(6)
8283
#define IMX_PCIE_FLAG_SUPPORT_64BIT BIT(7)
84+
#define IMX_PCIE_FLAG_CPU_ADDR_FIXUP BIT(8)
8385

8486
#define imx_check_flag(pci, val) (pci->drvdata->flags & val)
8587

@@ -1010,6 +1012,22 @@ static void imx_pcie_host_exit(struct dw_pcie_rp *pp)
10101012
regulator_disable(imx_pcie->vpcie);
10111013
}
10121014

1015+
static u64 imx_pcie_cpu_addr_fixup(struct dw_pcie *pcie, u64 cpu_addr)
1016+
{
1017+
struct imx_pcie *imx_pcie = to_imx_pcie(pcie);
1018+
struct dw_pcie_rp *pp = &pcie->pp;
1019+
struct resource_entry *entry;
1020+
1021+
if (!(imx_pcie->drvdata->flags & IMX_PCIE_FLAG_CPU_ADDR_FIXUP))
1022+
return cpu_addr;
1023+
1024+
entry = resource_list_first_type(&pp->bridge->windows, IORESOURCE_MEM);
1025+
if (!entry)
1026+
return cpu_addr;
1027+
1028+
return cpu_addr - entry->offset;
1029+
}
1030+
10131031
static const struct dw_pcie_host_ops imx_pcie_host_ops = {
10141032
.init = imx_pcie_host_init,
10151033
.deinit = imx_pcie_host_exit,
@@ -1018,6 +1036,7 @@ static const struct dw_pcie_host_ops imx_pcie_host_ops = {
10181036
static const struct dw_pcie_ops dw_pcie_ops = {
10191037
.start_link = imx_pcie_start_link,
10201038
.stop_link = imx_pcie_stop_link,
1039+
.cpu_addr_fixup = imx_pcie_cpu_addr_fixup,
10211040
};
10221041

10231042
static void imx_pcie_ep_init(struct dw_pcie_ep *ep)
@@ -1460,6 +1479,7 @@ static const char * const imx6q_clks[] = {"pcie_bus", "pcie", "pcie_phy"};
14601479
static const char * const imx8mm_clks[] = {"pcie_bus", "pcie", "pcie_aux"};
14611480
static const char * const imx8mq_clks[] = {"pcie_bus", "pcie", "pcie_phy", "pcie_aux"};
14621481
static const char * const imx6sx_clks[] = {"pcie_bus", "pcie", "pcie_phy", "pcie_inbound_axi"};
1482+
static const char * const imx8q_clks[] = {"mstr", "slv", "dbi"};
14631483

14641484
static const struct imx_pcie_drvdata drvdata[] = {
14651485
[IMX6Q] = {
@@ -1563,6 +1583,13 @@ static const struct imx_pcie_drvdata drvdata[] = {
15631583
.mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE,
15641584
.enable_ref_clk = imx8mm_pcie_enable_ref_clk,
15651585
},
1586+
[IMX8Q] = {
1587+
.variant = IMX8Q,
1588+
.flags = IMX_PCIE_FLAG_HAS_PHYDRV |
1589+
IMX_PCIE_FLAG_CPU_ADDR_FIXUP,
1590+
.clk_names = imx8q_clks,
1591+
.clks_cnt = ARRAY_SIZE(imx8q_clks),
1592+
},
15661593
[IMX95] = {
15671594
.variant = IMX95,
15681595
.flags = IMX_PCIE_FLAG_HAS_SERDES,
@@ -1640,6 +1667,7 @@ static const struct of_device_id imx_pcie_of_match[] = {
16401667
{ .compatible = "fsl,imx8mq-pcie", .data = &drvdata[IMX8MQ], },
16411668
{ .compatible = "fsl,imx8mm-pcie", .data = &drvdata[IMX8MM], },
16421669
{ .compatible = "fsl,imx8mp-pcie", .data = &drvdata[IMX8MP], },
1670+
{ .compatible = "fsl,imx8q-pcie", .data = &drvdata[IMX8Q], },
16431671
{ .compatible = "fsl,imx95-pcie", .data = &drvdata[IMX95], },
16441672
{ .compatible = "fsl,imx8mq-pcie-ep", .data = &drvdata[IMX8MQ_EP], },
16451673
{ .compatible = "fsl,imx8mm-pcie-ep", .data = &drvdata[IMX8MM_EP], },

0 commit comments

Comments
 (0)