i.MX7 PCI support
Subsystems (5)
v2 cover i.MX7 PCI support
Hello, everyone:
This is a second iteration of the code that adds PCI-subsystem bits necessary for enabling PCI support on i.MX7.
Changes since v1 (can be found at [version1]):
- All GPC related code moved into a separate driver (subject of a different patch)
- Removed GPIO probe deferral logging
- Fixed section mismatch warning
- Minor reformatting of fsl,imx6q-pcie.txt(as per Rob Herring's request)
[version1] https://lkml.org/lkml/2017/1/19/488
Thanks,
Andrey Smirnov
Andrey Smirnov (3):
PCI: imx6: Fix a typo in error message
PCI: imx6: Allow probe deferal by reset GPIO
PCI: imx6: Add code to support i.MX7D
.../devicetree/bindings/pci/fsl,imx6q-pcie.txt | 6 +- drivers/pci/host/pci-imx6.c | 145 ++++++++++++++++----- include/linux/mfd/syscon/imx7-gpc.h | 18 +++ include/linux/mfd/syscon/imx7-iomuxc-gpr.h | 4 + include/linux/mfd/syscon/imx7-src.h | 18 +++ 5 files changed, 161 insertions(+), 30 deletions(-) create mode 100644 include/linux/mfd/syscon/imx7-gpc.h create mode 100644 include/linux/mfd/syscon/imx7-src.h
Signature · 1 line
2.9.3
PATCH v2 1/3 PCI: imx6: Fix a typo in error message
--- drivers/pci/host/pci-imx6.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/pci/host/pci-imx6.c +1 -2
@@ -678,8 +678,7 @@ static int __init imx6_pcie_probe(struct platform_device *pdev) imx6_pcie->pcie_inbound_axi =devm_clk_get (dev,"pcie_inbound_axi" );if (IS_ERR (imx6_pcie->pcie_inbound_axi)) { -dev_err (dev, -"pcie_incbound_axi clock missing or invalid\n" ); +dev_err (dev,"pcie_inbound_axi clock missing or invalid\n" );return PTR_ERR (imx6_pcie->pcie_inbound_axi); } }
Signature · 1 line
2.9.3
PATCH v2 2/3 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/host/pci-imx6.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/pci/host/pci-imx6.c +5 -2
@@ -611,7 +611,7 @@ static int __init imx6_add_pcie_port(struct imx6_pcie *imx6_pcie,return 0 ; } -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 imx6_pcie *imx6_pcie;
@@ -653,6 +653,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 */
@@ -746,11 +748,12 @@ 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); +return platform_driver_register (&imx6_pcie_driver); }device_initcall (imx6_pcie_init);
Signature · 1 line
2.9.3
Re: [PATCH v2 2/3] PCI: imx6: Allow probe deferal by reset GPIO
Am Mittwoch, den 01.02.2017, 08:55 -0800 schrieb Andrey Smirnov:
Quoted 6 lines
Some 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.
Quoted 6 lines
Cc yurovsky at gmail.comCc Lucas Stach <[email protected]>Cc Bjorn Helgaas <[email protected]>Cc linux-arm-kernel at lists.infradead.orgCc linux-kernel at vger.kernel.orgSigned-off-by Andrey Smirnov <[email protected]>
Quoted 40 lines
--- drivers/pci/host/pci-imx6.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)drivers/pci/host/pci-imx6.c +5
-2@@ -611,7 +611,7 @@ static int __init imx6_add_pcie_port(struct imx6_pcie *imx6_pcie,return 0 ; } -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 imx6_pcie *imx6_pcie;@@ -653,6 +653,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 */ @@ -746,11 +748,12 @@ 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); +return platform_driver_register (&imx6_pcie_driver); }device_initcall (imx6_pcie_init);
PATCH v2 3/3 PCI: imx6: Add code to support i.MX7D
In reply to Andrey SmirnovAdd various bits of code needed to support i.MX7D variant of the IP.
--- .../devicetree/bindings/pci/fsl,imx6q-pcie.txt | 6 +- drivers/pci/host/pci-imx6.c | 136 +++++++++++++++++---- include/linux/mfd/syscon/imx7-gpc.h | 18 +++ include/linux/mfd/syscon/imx7-iomuxc-gpr.h | 4 + include/linux/mfd/syscon/imx7-src.h | 18 +++ 5 files changed, 156 insertions(+), 26 deletions(-) create mode 100644 include/linux/mfd/syscon/imx7-gpc.h create mode 100644 include/linux/mfd/syscon/imx7-src.h
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt +5 -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.
drivers/pci/host/pci-imx6.c +111 -25
226 lines not on this page · raw message
include/linux/mfd/syscon/imx7-gpc.h new file +18 -0
@@ -0,0 +1,18 @@ +/* +* Copyright (C) 2017 Impinj +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#ifndef __LINUX_IMX7_GPC_H +#define __LINUX_IMX7_GPC_H + +#define GPC_PGC_CPU_MAPPING 0xec +#define GPC_PU_PGC_SW_PUP_REQ 0xf8 + +#define IMX7D_PCIE_PHY_A7_DOMAIN BIT(3) +#define IMX7D_PCIE_PHY_SW_PUP_REQ BIT(1) + +#endif
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 */
include/linux/mfd/syscon/imx7-src.h new file +18 -0
@@ -0,0 +1,18 @@ +/* +* Copyright (C) 2017 Impinj +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#ifndef __LINUX_IMX7_SRC_H +#define __LINUX_IMX7_SRC_H + +#define SRC_PCIEPHY_RCR 0x2c + +#define IMX7D_SRC_PCIEPHY_RCR_PCIEPHY_G_RST BIT(1) +#define IMX7D_SRC_PCIEPHY_RCR_PCIEPHY_BTN BIT(2) +#define IMX7D_SRC_PCIEPHY_RCR_PCIE_CTRL_APPS_EN BIT(6) + +#endif /* __LINUX_IMX7_IOMUXC_GPR_H */
Signature · 1 line
2.9.3
Re: [PATCH v2 3/3] PCI: imx6: Add code to support i.MX7D
Am Mittwoch, den 01.02.2017, 08:55 -0800 schrieb Andrey Smirnov:
Quoted 53 lines
Add various bits of code needed to support i.MX7D variant of the IP.
Cc yurovsky at gmail.comCc Lucas Stach <[email protected]>Cc Bjorn Helgaas <[email protected]>Cc Rob Herring <[email protected]>Cc Mark Rutland <[email protected]>Cc Lee Jones <[email protected]>Cc linux-arm-kernel at lists.infradead.orgCc devicetree at vger.kernel.orgCc linux-kernel at vger.kernel.orgSigned-off-by Andrey Smirnov <[email protected]>--- .../devicetree/bindings/pci/fsl,imx6q-pcie.txt | 6 +- drivers/pci/host/pci-imx6.c | 136 +++++++++++++++++---- include/linux/mfd/syscon/imx7-gpc.h | 18 +++ include/linux/mfd/syscon/imx7-iomuxc-gpr.h | 4 + include/linux/mfd/syscon/imx7-src.h | 18 +++ 5 files changed, 156 insertions(+), 26 deletions(-) create mode 100644 include/linux/mfd/syscon/imx7-gpc.h create mode 100644 include/linux/mfd/syscon/imx7-src.hDocumentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt +5
-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.drivers/pci/host/pci-imx6.c +2
-0@@ -17,6 +17,8 @@#include <linux/kernel.h> #include <linux/mfd/syscon.h> #include <linux/mfd/syscon/imx6q-iomuxc-gpr.h> +#include <linux/mfd/syscon/imx7-iomuxc-gpr.h> +#include <linux/mfd/syscon/imx7-src.h> #include <linux/module.h> #include <linux/of_gpio.h> #include <linux/of_device.h>
drivers/pci/host/pci-imx6.c line 32
Quoted 4 lines
drivers/pci/host/pci-imx6.c +1
-0@@ -27,6 +29,7 @@#include <linux/signal.h> #include <linux/types.h> #include <linux/interrupt.h> +#include <linux/pm_domain.h>
I don't think you need this include. PM domain handling should be done by the linux driver core if the pcie node is placed in the proper power-domain.
The pcie driver should only indirectly handle pm domains via the runtime pm kernel facilities.
Quoted 35 lines
drivers/pci/host/pci-imx6.c +7
-0#include "pcie-designware.h" @@ -36,6 +39,7 @@ enum imx6_pcie_variants {IMX6Q ,IMX6SX ,IMX6QP , + IMX7D, }; struct imx6_pcie {@@ -47,6 +51,7 @@ struct imx6_pcie {struct clk *pcie_inbound_axi;struct clk *pcie;struct regmap *iomuxc_gpr; +struct regmap *src;enum imx6_pcie_variants variant;u32 tx_deemph_gen1;u32 tx_deemph_gen2_3p5db;@@ -56,6 +61,11 @@ struct imx6_pcie {int link_gen; }; +/* Parameters for the waiting for PCIe PHY PLL to lock on i.MX7 */ +#define PHY_PLL_LOCK_WAIT_MAX_RETRIES 2000 +#define PHY_PLL_LOCK_WAIT_USLEEP_MIN 50 +#define PHY_PLL_LOCK_WAIT_USLEEP_MAX 200 +/* PCIe Root Complex registers (memory-mapped) */ #define PCIE_RC_LCR 0x7c#define PCIE_RC_LCR_MAX_LINK_SPEEDS_GEN1 0x1@@ -251,6 +261,16 @@ static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie)u32 val, gpr1, gpr12;switch (imx6_pcie->variant) {
drivers/pci/host/pci-imx6.c static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie) · line 273
Quoted 10 lines
drivers/pci/host/pci-imx6.c +10
-0+case IMX7D : +regmap_update_bits (imx6_pcie->src, +SRC_PCIEPHY_RCR , +IMX7D_SRC_PCIEPHY_RCR_PCIEPHY_G_RST , +IMX7D_SRC_PCIEPHY_RCR_PCIEPHY_G_RST ); +regmap_update_bits (imx6_pcie->src, +SRC_PCIEPHY_RCR , +IMX7D_SRC_PCIEPHY_RCR_PCIEPHY_BTN , +IMX7D_SRC_PCIEPHY_RCR_PCIEPHY_BTN ); +break ;
I suppose those are just some random bits tossed together, that can't reasonably be abstracted by a reset controller, right? In that case I'm fine with the code as is.
Quoted 14 lines
drivers/pci/host/pci-imx6.c +2
-0case IMX6SX : regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, IMX6SX_GPR12_PCIE_TEST_POWERDOWN,@@ -333,11 +353,33 @@ static int imx6_pcie_enable_ref_clk(struct imx6_pcie *imx6_pcie)regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR1 ,IMX6Q_GPR1_PCIE_REF_CLK_EN ,1 <<16 );break ; +case IMX7D : +break ; }return ret; }
[...]
Quoted 14 lines
include/linux/mfd/syscon/imx7-gpc.h new file +8
-0@@ -0,0 +1,18 @@ +/* +* Copyright (C) 2017 Impinj +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ +
include/linux/mfd/syscon/imx7-gpc.h line 18
Quoted 10 lines
include/linux/mfd/syscon/imx7-gpc.h new file +10
-0+#ifndef __LINUX_IMX7_GPC_H +#define __LINUX_IMX7_GPC_H + +#define GPC_PGC_CPU_MAPPING 0xec +#define GPC_PU_PGC_SW_PUP_REQ 0xf8 + +#define IMX7D_PCIE_PHY_A7_DOMAIN BIT(3) +#define IMX7D_PCIE_PHY_SW_PUP_REQ BIT(1) + +#endif
This file isn't referenced in the patch anymore. Please remove.
Regards,
Lucas
Re: [PATCH v2 3/3] PCI: imx6: Add code to support i.MX7D
Quoted 63 lines · Lucas Stach
Am Mittwoch, den 01.02.2017, 08:55 -0800 schrieb Andrey Smirnov:
Quoted 53 lines
Add various bits of code needed to support i.MX7D variant of the IP.
Cc yurovsky at gmail.comCc Lucas Stach <[email protected]>Cc Bjorn Helgaas <[email protected]>Cc Rob Herring <[email protected]>Cc Mark Rutland <[email protected]>Cc Lee Jones <[email protected]>Cc linux-arm-kernel at lists.infradead.orgCc devicetree at vger.kernel.orgCc linux-kernel at vger.kernel.orgSigned-off-by Andrey Smirnov <[email protected]>--- .../devicetree/bindings/pci/fsl,imx6q-pcie.txt | 6 +- drivers/pci/host/pci-imx6.c | 136 +++++++++++++++++---- include/linux/mfd/syscon/imx7-gpc.h | 18 +++ include/linux/mfd/syscon/imx7-iomuxc-gpr.h | 4 + include/linux/mfd/syscon/imx7-src.h | 18 +++ 5 files changed, 156 insertions(+), 26 deletions(-) create mode 100644 include/linux/mfd/syscon/imx7-gpc.h create mode 100644 include/linux/mfd/syscon/imx7-src.hDocumentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt +5
-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.drivers/pci/host/pci-imx6.c +2
-0@@ -17,6 +17,8 @@#include <linux/kernel.h> #include <linux/mfd/syscon.h> #include <linux/mfd/syscon/imx6q-iomuxc-gpr.h> +#include <linux/mfd/syscon/imx7-iomuxc-gpr.h> +#include <linux/mfd/syscon/imx7-src.h> #include <linux/module.h> #include <linux/of_gpio.h> #include <linux/of_device.h> drivers/pci/host/pci-imx6.c line 32
Quoted 4 lines
drivers/pci/host/pci-imx6.c +1
-0@@ -27,6 +29,7 @@#include <linux/signal.h> #include <linux/types.h> #include <linux/interrupt.h> +#include <linux/pm_domain.h> I don't think you need this include. PM domain handling should be done by the linux driver core if the pcie node is placed in the proper power-domain.
Quoted 3 lines
The pcie driver should only indirectly handle pm domains via the runtime pm kernel facilities.
You are right, I have no reason to have this include. It's just a experimentation leftover I forgot to remove. Will get rid of it in v3.
Quoted 34 lines
Quoted 34 lines
drivers/pci/host/pci-imx6.c +7
-0#include "pcie-designware.h" @@ -36,6 +39,7 @@ enum imx6_pcie_variants {IMX6Q ,IMX6SX ,IMX6QP , + IMX7D, }; struct imx6_pcie {@@ -47,6 +51,7 @@ struct imx6_pcie {struct clk *pcie_inbound_axi;struct clk *pcie;struct regmap *iomuxc_gpr; +struct regmap *src;enum imx6_pcie_variants variant;u32 tx_deemph_gen1;u32 tx_deemph_gen2_3p5db;@@ -56,6 +61,11 @@ struct imx6_pcie {int link_gen; }; +/* Parameters for the waiting for PCIe PHY PLL to lock on i.MX7 */ +#define PHY_PLL_LOCK_WAIT_MAX_RETRIES 2000 +#define PHY_PLL_LOCK_WAIT_USLEEP_MIN 50 +#define PHY_PLL_LOCK_WAIT_USLEEP_MAX 200 +/* PCIe Root Complex registers (memory-mapped) */ #define PCIE_RC_LCR 0x7c#define PCIE_RC_LCR_MAX_LINK_SPEEDS_GEN1 0x1@@ -251,6 +261,16 @@ static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie)u32 val, gpr1, gpr12;
Quoted 15 lines
drivers/pci/host/pci-imx6.c static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie) · line 273
Quoted 11 lines
drivers/pci/host/pci-imx6.c +10
-0switch (imx6_pcie->variant) { +case IMX7D : +regmap_update_bits (imx6_pcie->src, +SRC_PCIEPHY_RCR , +IMX7D_SRC_PCIEPHY_RCR_PCIEPHY_G_RST , +IMX7D_SRC_PCIEPHY_RCR_PCIEPHY_G_RST ); +regmap_update_bits (imx6_pcie->src, +SRC_PCIEPHY_RCR , +IMX7D_SRC_PCIEPHY_RCR_PCIEPHY_BTN , +IMX7D_SRC_PCIEPHY_RCR_PCIEPHY_BTN ); +break ;I suppose those are just some random bits tossed together, that can't reasonably be abstracted by a reset controller, right? In that case I'm fine with the code as is.
Hmm, good point, I didn't think of that. SRC is a system reset controller, after all, so I think it actually might be possible to do what you describe. I'll investigate the possibility and convert this if I can in v3.
Quoted 35 lines
Quoted 15 lines
drivers/pci/host/pci-imx6.c +2
-0case IMX6SX : regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, IMX6SX_GPR12_PCIE_TEST_POWERDOWN,@@ -333,11 +353,33 @@ static int imx6_pcie_enable_ref_clk(struct imx6_pcie *imx6_pcie)regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR1 ,IMX6Q_GPR1_PCIE_REF_CLK_EN ,1 <<16 );break ; +case IMX7D : +break ; }return ret; }[...]
Quoted 18 lines
include/linux/mfd/syscon/imx7-gpc.h new file +12
-0@@ -0,0 +1,18 @@ +/* +* Copyright (C) 2017 Impinj +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ + +#ifndef __LINUX_IMX7_GPC_H +#define __LINUX_IMX7_GPC_H + +#define GPC_PGC_CPU_MAPPING 0xec
Quoted 8 lines
include/linux/mfd/syscon/imx7-gpc.h line 18
Quoted 6 lines
include/linux/mfd/syscon/imx7-gpc.h new file +6
-0+#define GPC_PU_PGC_SW_PUP_REQ 0xf8 + +#define IMX7D_PCIE_PHY_A7_DOMAIN BIT(3) +#define IMX7D_PCIE_PHY_SW_PUP_REQ BIT(1) + +#endif This file isn't referenced in the patch anymore. Please remove.
More leftover code that I missed. Will remove in v3 and sorry for this noise.
Thanks,
Andrey