i.MX7 PCI support
Subsystems (5)
v8 cover i.MX7 PCI support
Hello, everyone:
This is a eightth iteration of the code that adds PCI-subsystem bits necessary for enabling PCI support on i.MX7.
NOTE: To test this patchset with real i.MX7 hardware, additional patches, that are being upstreamed via different trees, are needed. Full working tree is availible at:
https://github.com/ndreys/linux/tree/imx7d/pcie-support-v8
Changes since v7 (can be found at [version7]):
- Collected Reviewed-by for the whole series from Lucas
Changes since v6 (can be found at [version6]):
- Rebased against latest changes in 'next' of PCI subsystem git tree
Chagnes since v5 (can be found at [version5]):
- Collected ACKs from Lee and Rob
Changes since v4 (can be found at [version4]):
- Dropped typo-fix patch (originally patch #1 of the series).
- Added patch with workaround to address speed change false failures (I kept it as a separate patch to better document exchange with NXP/Freescale that lead to that patch)
- Added patch to avoid speed change on links configured Gen1 only (Let me know if that is a terrible idea)
- Addressed section mismatch problem by moving call to hook_fault_code to happend before driver registration.
Changes since v3 (can be found at [version3]):
- Move all of the reset_control_assert's into imx6_pcie_assert_core_reset
- Documented required reset and power domain DT bindings
Changes since v2 (can be found at [version2]):
- Collected Reviewed-by for patch #2 from Lucas
- Reset logic implementation moved out into a reset controller driver (see [reset1])
- Removed unused leftover code
Changes since v1 (can be found at [version1]):
- All GPC related code moved into a separate driver (see [gpc1])
- Removed GPIO probe deferral logging
- Fixed section mismatch warning
- Minor reformatting of fsl,imx6q-pcie.txt(as per Rob Herring's request)
[version7] https://lkml.org/lkml/2017/3/21/331
[version6] https://lkml.org/lkml/2017/3/14/584
[version5] https://lkml.org/lkml/2017/2/20/376
[version4] https://lkml.org/lkml/2017/2/7/478
[version3] https://lkml.org/lkml/2017/2/6/565
[version2] https://lkml.org/lkml/2017/2/1/510
[version1] https://lkml.org/lkml/2017/1/19/488
[gpc1] https://lkml.org/lkml/2017/2/6/551
[reset1] https://lkml.org/lkml/2017/2/6/554
Andrey Smirnov (4):
PCI: imx6: Add code to support i.MX7D
PCI: imx6: Allow probe deferal by reset GPIO
PCI: imx6: Do not wait for speed change on i.MX7
PCI: imx6: Do not switch speed if Gen2 is disabled
.../devicetree/bindings/pci/fsl,imx6q-pcie.txt | 13 +- drivers/pci/dwc/pci-imx6.c | 198 +++++++++++++++------ include/linux/mfd/syscon/imx7-iomuxc-gpr.h | 4 + 3 files changed, 160 insertions(+), 55 deletions(-)
Signature · 1 line
2.9.3
PATCH v8 1/4 PCI: imx6: Add code to support i.MX7D
Add various bits of code needed to support i.MX7D variant of the IP.
--- .../devicetree/bindings/pci/fsl,imx6q-pcie.txt | 13 ++- drivers/pci/dwc/pci-imx6.c | 120 ++++++++++++++++----- include/linux/mfd/syscon/imx7-iomuxc-gpr.h | 4 + 3 files changed, 111 insertions(+), 26 deletions(-)
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt +12 -1
@@ -4,7 +4,11 @@ This PCIe host controller is based on the Synopsis Designware PCIe IP and thus inherits all the common properties defined in designware-pcie.txt. Required properties: -- compatible: "fsl,imx6q-pcie", "fsl,imx6sx-pcie", "fsl,imx6qp-pcie" +- compatible: + - "fsl,imx6q-pcie" + - "fsl,imx6sx-pcie", + - "fsl,imx6qp-pcie" + - "fsl,imx7d-pcie" - reg: base address and length of the PCIe controller - interrupts: A list of interrupt outputs of the controller. Must contain an entry for each entry in the interrupt-names property.
@@ -34,6 +38,13 @@ Additional required properties for imx6sx-pcie: - clock names: Must include the following additional entries: - "pcie_inbound_axi" +Additional required properties for imx7d-pcie: +- power-domains: Must be set to a phandle pointing to PCIE_PHY power domain +- resets: Must contain phandles to PCIE related reset lines exposed by SRC IP block +- reset-names: Must contain the following entires: + - "pciephy" + - "apps" + Example: pcie at 0x01000000 {
drivers/pci/dwc/pci-imx6.c +95 -25
210 lines not on this page · raw message
include/linux/mfd/syscon/imx7-iomuxc-gpr.h +4 -0
@@ -44,4 +44,8 @@#define IMX7D_GPR5_CSI_MUX_CONTROL_MIPI (0x1 << 4) +#define IMX7D_GPR12_PCIE_PHY_REFCLK_SEL BIT(5) + +#define IMX7D_GPR22_PCIE_PHY_PLL_LOCKED BIT(31) +#endif /* __LINUX_IMX7_IOMUXC_GPR_H */
Signature · 1 line
2.9.3
PATCH v8 2/4 PCI: imx6: Allow probe deferal by reset GPIO
In reply to Andrey SmirnovSome designs implement reset GPIO via a GPIO expander connected to a peripheral bus. One such example would be i.MX7 Sabre board where said GPIO is provided by SPI shift register connected to a bitbanged SPI bus. In order to support such designs allow reset GPIO request to defer probing of the driver.
--- drivers/pci/dwc/pci-imx6.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-)
drivers/pci/dwc/pci-imx6.c +17 -8
@@ -595,8 +595,8 @@ static struct dw_pcie_host_ops imx6_pcie_host_ops = { .host_init = imx6_pcie_host_init, }; -static int __init imx6_add_pcie_port (struct imx6_pcie *imx6_pcie, -struct platform_device *pdev) +static int imx6_add_pcie_port (struct imx6_pcie *imx6_pcie, +struct platform_device *pdev) {struct dw_pcie *pci = imx6_pcie->pci;struct pcie_port *pp = &pci->pp;
@@ -636,7 +636,7 @@ static const struct dw_pcie_ops dw_pcie_ops = { .link_up = imx6_pcie_link_up, }; -static int __init imx6_pcie_probe (struct platform_device *pdev) +static int imx6_pcie_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;struct dw_pcie *pci;
@@ -660,10 +660,6 @@ static int __init imx6_pcie_probe(struct platform_device *pdev) imx6_pcie->variant = (enum imx6_pcie_variants )of_device_get_match_data (dev); -/* Added for PCI abort handling */ -hook_fault_code (16 +6 , imx6q_pcie_abort_handler,SIGBUS ,0 , -"imprecise external abort" ); - dbi_base =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); pci->dbi_base =devm_ioremap_resource (dev, dbi_base);if (IS_ERR (pci->dbi_base))
@@ -683,6 +679,8 @@ static int __init imx6_pcie_probe(struct platform_device *pdev)dev_err (dev,"unable to get reset gpio\n" );return ret; } + }else if (imx6_pcie->reset_gpio == -EPROBE_DEFER ) { +return imx6_pcie->reset_gpio; }/* Fetch clocks */
@@ -796,11 +794,22 @@ static struct platform_driver imx6_pcie_driver = { .name = "imx6q-pcie", .of_match_table = imx6_pcie_of_match, }, + .probe = imx6_pcie_probe, .shutdown = imx6_pcie_shutdown, };static int __init imx6_pcie_init (void ) { -return platform_driver_probe (&imx6_pcie_driver, imx6_pcie_probe); +/* +* Since probe() can be deferred we need to make sure that +* hook_fault_code is not called after __init memory is freed +* by kernel and since imx6q_pcie_abort_handler() is a no-op +* we can install the handler here without risking it +* accessing some unitialized driver state +*/ +hook_fault_code (16 +6 , imx6q_pcie_abort_handler,SIGBUS ,0 , +"imprecise external abort" ); + +return platform_driver_register (&imx6_pcie_driver); }device_initcall (imx6_pcie_init);
Signature · 1 line
2.9.3
PATCH v8 3/4 PCI: imx6: Do not wait for speed change on i.MX7
In reply to Andrey SmirnovAs can be seen from [1]:
"...the different behavior between iMX6Q PCIe and iMX7D PCIe maybe caused by the different controller version.
Regarding to the DOC description, the DIRECT_SPEED_CHANGE should be cleared after the speed change from GEN1 to GEN2. Unfortunately, when GEN1 device is used, the behavior is not documented.
So, IC design guys run the simulation and
find out the following behaviors:
1. DIRECT_SPEED_CHANGE will be cleared in 7D after speed change from GEN1 to GEN2. This matches doc?s description
2. set MAX link speed(PCIE_CAP_TARGET_LINK_SPEED=0x01) as GEN1 and re-run the simulation, DIRECT_SPEED_CHANGE will not be cleared; remain as 1, this matches your result, but function test is passed, so this bit should not affect the normal PCIe function.
..."
imx6_pcie_wait_for_speed_change will report false failures for Gen1 -> Gen1 speed transition, so avoid doing that check and just rely on imx6_pcie_wait_for_link only.
[1] https://community.nxp.com/message/867943
--- drivers/pci/dwc/pci-imx6.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)
drivers/pci/dwc/pci-imx6.c +15 -4
@@ -545,10 +545,21 @@ static int imx6_pcie_establish_link(struct imx6_pcie *imx6_pcie) tmp |=PORT_LOGIC_SPEED_CHANGE ;dw_pcie_writel_dbi (pci,PCIE_LINK_WIDTH_SPEED_CONTROL , tmp); - ret =imx6_pcie_wait_for_speed_change (imx6_pcie); -if (ret) { -dev_err (dev,"Failed to bring link up!\n" ); - goto err_reset_phy; +if (imx6_pcie->variant !=IMX7D ) { +/* +* On i.MX7, DIRECT_SPEED_CHANGE behaves differently +* from i.MX6 family when no link speed transition +* occurs and we go Gen1 -> yep, Gen1. The difference +* is that, in such case, it will not be cleared by HW +* which will cause the following code to report false +* failure. +*/ + + ret =imx6_pcie_wait_for_speed_change (imx6_pcie); +if (ret) { +dev_err (dev,"Failed to bring link up!\n" ); + goto err_reset_phy; + } }/* Make sure link training is finished as well! */
Signature · 1 line
2.9.3
PATCH v8 4/4 PCI: imx6: Do not switch speed if Gen2 is disabled
In reply to Andrey SmirnovSave a bit of time and avoid going through link speed change procedure in configuration where link max speed is limited to Gen1 in DT.
--- drivers/pci/dwc/pci-imx6.c | 52 +++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 26 deletions(-)
drivers/pci/dwc/pci-imx6.c +26 -26
@@ -533,40 +533,40 @@ static int imx6_pcie_establish_link(struct imx6_pcie *imx6_pcie) tmp &= ~PCIE_RC_LCR_MAX_LINK_SPEEDS_MASK ; tmp |=PCIE_RC_LCR_MAX_LINK_SPEEDS_GEN2 ;dw_pcie_writel_dbi (pci,PCIE_RC_LCR , tmp); - }else { -dev_info (dev,"Link: Gen2 disabled\n" ); - } - -/* -* Start Directed Speed Change so the best possible speed both link -* partners support can be negotiated. -*/ - tmp =dw_pcie_readl_dbi (pci,PCIE_LINK_WIDTH_SPEED_CONTROL ); - tmp |=PORT_LOGIC_SPEED_CHANGE ; -dw_pcie_writel_dbi (pci,PCIE_LINK_WIDTH_SPEED_CONTROL , tmp); -if (imx6_pcie->variant !=IMX7D ) {/* -* On i.MX7, DIRECT_SPEED_CHANGE behaves differently -* from i.MX6 family when no link speed transition -* occurs and we go Gen1 -> yep, Gen1. The difference -* is that, in such case, it will not be cleared by HW -* which will cause the following code to report false -* failure. +* Start Directed Speed Change so the best possible +* speed both link partners support can be negotiated. */ + tmp =dw_pcie_readl_dbi (pci,PCIE_LINK_WIDTH_SPEED_CONTROL ); + tmp |=PORT_LOGIC_SPEED_CHANGE ; +dw_pcie_writel_dbi (pci,PCIE_LINK_WIDTH_SPEED_CONTROL , tmp); + +if (imx6_pcie->variant !=IMX7D ) { +/* +* On i.MX7, DIRECT_SPEED_CHANGE behaves differently +* from i.MX6 family when no link speed transition +* occurs and we go Gen1 -> yep, Gen1. The difference +* is that, in such case, it will not be cleared by HW +* which will cause the following code to report false +* failure. +*/ + + ret =imx6_pcie_wait_for_speed_change (imx6_pcie); +if (ret) { +dev_err (dev,"Failed to bring link up!\n" ); + goto err_reset_phy; + } + } - ret =imx6_pcie_wait_for_speed_change (imx6_pcie); +/* Make sure link training is finished as well! */ + ret =imx6_pcie_wait_for_link (imx6_pcie);if (ret) {dev_err (dev,"Failed to bring link up!\n" ); goto err_reset_phy; } - } - -/* Make sure link training is finished as well! */ - ret =imx6_pcie_wait_for_link (imx6_pcie); -if (ret) { -dev_err (dev,"Failed to bring link up!\n" ); - goto err_reset_phy; + }else { +dev_info (dev,"Link: Gen2 disabled\n" ); } tmp =dw_pcie_readl_dbi (pci,PCIE_RC_LCSR );
Signature · 1 line
2.9.3
Bjorn Helgaas
AppliedQuoted 74 lines · Andrey Smirnov
Hello, everyone:
This is a eightth iteration of the code that adds PCI-subsystem bits necessary for enabling PCI support on i.MX7.
NOTE: To test this patchset with real i.MX7 hardware, additional patches, that are being upstreamed via different trees, are needed. Full working tree is availible at:
https://github.com/ndreys/linux/tree/imx7d/pcie-support-v8
Changes since v7 (can be found at [version7]):
- Collected Reviewed-by for the whole series from Lucas
Changes since v6 (can be found at [version6]):
- Rebased against latest changes in 'next' of PCI subsystem git tree
Chagnes since v5 (can be found at [version5]):
- Collected ACKs from Lee and Rob
Changes since v4 (can be found at [version4]):
- Dropped typo-fix patch (originally patch #1 of the series).
- Added patch with workaround to address speed change false failures (I kept it as a separate patch to better document exchange with NXP/Freescale that lead to that patch)
- Added patch to avoid speed change on links configured Gen1 only (Let me know if that is a terrible idea)
- Addressed section mismatch problem by moving call to
hook_fault_codeto happend before driver registration.Changes since v3 (can be found at [version3]):
- Move all of the reset_control_assert's intoimx6_pcie_assert_core_reset
- Documented required reset and power domain DT bindingsChanges since v2 (can be found at [version2]):
- Collected Reviewed-by for patch #2 from Lucas
- Reset logic implementation moved out into a reset controller driver (see [reset1])
- Removed unused leftover codeChanges since v1 (can be found at [version1]):
- All GPC related code moved into a separate driver (see [gpc1])
- Removed GPIO probe deferral logging
- Fixed section mismatch warning
- Minor reformatting of fsl,imx6q-pcie.txt(as per Rob Herring's request)[version7] https://lkml.org/lkml/2017/3/21/331
[version6] https://lkml.org/lkml/2017/3/14/584
[version5] https://lkml.org/lkml/2017/2/20/376
[version4] https://lkml.org/lkml/2017/2/7/478
[version3] https://lkml.org/lkml/2017/2/6/565
[version2] https://lkml.org/lkml/2017/2/1/510
[version1] https://lkml.org/lkml/2017/1/19/488
[gpc1] https://lkml.org/lkml/2017/2/6/551
[reset1] https://lkml.org/lkml/2017/2/6/554Andrey Smirnov (4):
PCI: imx6: Add code to support i.MX7D
PCI: imx6: Allow probe deferal by reset GPIO
PCI: imx6: Do not wait for speed change on i.MX7
PCI: imx6: Do not switch speed if Gen2 is disabled
Quoted 4 lines
.../devicetree/bindings/pci/fsl,imx6q-pcie.txt | 13 +- drivers/pci/dwc/pci-imx6.c | 198 +++++++++++++++------ include/linux/mfd/syscon/imx7-iomuxc-gpr.h | 4 + 3 files changed, 160 insertions(+), 55 deletions(-)
Applied to pci/host-imx6 for v4.12, thanks!