i.MX7 PCI support
Subsystems (5)
v4 cover i.MX7 PCI support
Hello, everyone:
This is a fourth iteration of the code that adds PCI-subsystem bits necessary for enabling PCI support on i.MX7.
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)
[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 (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 | 13 +- drivers/pci/host/pci-imx6.c | 131 ++++++++++++++++----- include/linux/mfd/syscon/imx7-iomuxc-gpr.h | 4 + 3 files changed, 118 insertions(+), 30 deletions(-)
Signature · 1 line
2.9.3
PATCH v4 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 v4 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
PATCH v4 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 | 13 ++- drivers/pci/host/pci-imx6.c | 121 ++++++++++++++++----- include/linux/mfd/syscon/imx7-iomuxc-gpr.h | 4 + 3 files changed, 112 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/host/pci-imx6.c +96 -25
211 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
Re: [PATCH v4 3/3] PCI: imx6: Add code to support i.MX7D
Am Dienstag, den 07.02.2017, 07:50 -0800 schrieb Andrey Smirnov:
Quoted 13 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 Fabio Estevam <[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]>
Quoted 277 lines
--- .../devicetree/bindings/pci/fsl,imx6q-pcie.txt | 13 ++- drivers/pci/host/pci-imx6.c | 121 ++++++++++++++++----- include/linux/mfd/syscon/imx7-iomuxc-gpr.h | 4 + 3 files changed, 112 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/host/pci-imx6.c +96
-25@@ -17,6 +17,7 @@#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/module.h> #include <linux/of_gpio.h> #include <linux/of_device.h> @@ -27,6 +28,7 @@#include <linux/signal.h> #include <linux/types.h> #include <linux/interrupt.h> +#include <linux/reset.h> #include "pcie-designware.h" @@ -36,6 +38,7 @@ enum imx6_pcie_variants {IMX6Q ,IMX6SX ,IMX6QP , + IMX7D, }; struct imx6_pcie {@@ -47,6 +50,8 @@ struct imx6_pcie {struct clk *pcie_inbound_axi;struct clk *pcie;struct regmap *iomuxc_gpr; +struct reset_control *pciephy_reset; +struct reset_control *apps_reset;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,10 @@ static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie)u32 val, gpr1, gpr12;switch (imx6_pcie->variant) { +case IMX7D : +reset_control_assert (imx6_pcie->pciephy_reset); +reset_control_assert (imx6_pcie->apps_reset); +break ;case IMX6SX : regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, IMX6SX_GPR12_PCIE_TEST_POWERDOWN,@@ -333,11 +347,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; } +static void imx7d_pcie_wait_for_phy_pll_lock (struct imx6_pcie *imx6_pcie) +{ +u32 val; +unsigned int retries; +struct pcie_port *pp = &imx6_pcie->pp; +struct device *dev = pp->dev; + +for (retries =0 ; retries <PHY_PLL_LOCK_WAIT_MAX_RETRIES ; retries++) { +regmap_read (imx6_pcie->iomuxc_gpr,IOMUXC_GPR22 , &val); + +if (val &IMX7D_GPR22_PCIE_PHY_PLL_LOCKED ) +return ; + +usleep_range (PHY_PLL_LOCK_WAIT_USLEEP_MIN , +PHY_PLL_LOCK_WAIT_USLEEP_MAX ); + } + +dev_err (dev,"PCIe PLL lock timeout\n" ); +} +static void imx6_pcie_deassert_core_reset (struct imx6_pcie *imx6_pcie) {struct pcie_port *pp = &imx6_pcie->pp;@@ -381,6 +417,10 @@ static void imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie) }switch (imx6_pcie->variant) { +case IMX7D : +reset_control_deassert (imx6_pcie->pciephy_reset); +imx7d_pcie_wait_for_phy_pll_lock (imx6_pcie); +break ;case IMX6SX :regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR5 ,IMX6SX_GPR5_PCIE_BTNRST_RESET ,0 );@@ -407,35 +447,44 @@ static void imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie)static void imx6_pcie_init_phy (struct imx6_pcie *imx6_pcie) { -if (imx6_pcie->variant ==IMX6SX ) +switch (imx6_pcie->variant) { +case IMX7D : +regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR12 , +IMX7D_GPR12_PCIE_PHY_REFCLK_SEL ,0 ); +break ; +case IMX6SX :regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR12 ,IMX6SX_GPR12_PCIE_RX_EQ_MASK ,IMX6SX_GPR12_PCIE_RX_EQ_2 ); +/* FALLTHROUGH */ +default : +regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR12 , +IMX6Q_GPR12_PCIE_CTL_2 ,0 <<10 ); -regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR12 , -IMX6Q_GPR12_PCIE_CTL_2 ,0 <<10 ); +/* configure constant input signal to the pcie ctrl and phy */ +regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR12 , +IMX6Q_GPR12_LOS_LEVEL ,9 <<4 ); + +regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR8 , +IMX6Q_GPR8_TX_DEEMPH_GEN1 , + imx6_pcie->tx_deemph_gen1 <<0 ); +regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR8 , +IMX6Q_GPR8_TX_DEEMPH_GEN2_3P5DB , + imx6_pcie->tx_deemph_gen2_3p5db <<6 ); +regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR8 , +IMX6Q_GPR8_TX_DEEMPH_GEN2_6DB , + imx6_pcie->tx_deemph_gen2_6db <<12 ); +regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR8 , +IMX6Q_GPR8_TX_SWING_FULL , + imx6_pcie->tx_swing_full <<18 ); +regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR8 , +IMX6Q_GPR8_TX_SWING_LOW , + imx6_pcie->tx_swing_low <<25 ); +break ; + } -/* configure constant input signal to the pcie ctrl and phy */ regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR12 ,IMX6Q_GPR12_DEVICE_TYPE ,PCI_EXP_TYPE_ROOT_PORT <<12 ); -regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR12 , -IMX6Q_GPR12_LOS_LEVEL ,9 <<4 ); - -regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR8 , -IMX6Q_GPR8_TX_DEEMPH_GEN1 , - imx6_pcie->tx_deemph_gen1 <<0 ); -regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR8 , -IMX6Q_GPR8_TX_DEEMPH_GEN2_3P5DB , - imx6_pcie->tx_deemph_gen2_3p5db <<6 ); -regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR8 , -IMX6Q_GPR8_TX_DEEMPH_GEN2_6DB , - imx6_pcie->tx_deemph_gen2_6db <<12 ); -regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR8 , -IMX6Q_GPR8_TX_SWING_FULL , - imx6_pcie->tx_swing_full <<18 ); -regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR8 , -IMX6Q_GPR8_TX_SWING_LOW , - imx6_pcie->tx_swing_low <<25 ); }static int imx6_pcie_wait_for_link (struct imx6_pcie *imx6_pcie)@@ -498,8 +547,11 @@ static int imx6_pcie_establish_link(struct imx6_pcie *imx6_pcie)dw_pcie_writel_rc (pp,PCIE_RC_LCR , tmp);/* Start LTSSM. */ -regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR12 , -IMX6Q_GPR12_PCIE_CTL_2 ,1 <<10 ); +if (imx6_pcie->variant ==IMX7D ) +reset_control_deassert (imx6_pcie->apps_reset); +else +regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR12 , +IMX6Q_GPR12_PCIE_CTL_2 ,1 <<10 ); ret =imx6_pcie_wait_for_link (imx6_pcie);if (ret) {@@ -676,13 +728,31 @@ static int imx6_pcie_probe(struct platform_device *pdev)return PTR_ERR (imx6_pcie->pcie); } -if (imx6_pcie->variant ==IMX6SX ) { +switch (imx6_pcie->variant) { +case IMX6SX : imx6_pcie->pcie_inbound_axi =devm_clk_get (dev,"pcie_inbound_axi" );if (IS_ERR (imx6_pcie->pcie_inbound_axi)) {dev_err (dev,"pcie_inbound_axi clock missing or invalid\n" );return PTR_ERR (imx6_pcie->pcie_inbound_axi); } +break ; +case IMX7D : + imx6_pcie->pciephy_reset =devm_reset_control_get (dev, +"pciephy" ); +if (IS_ERR (imx6_pcie->pciephy_reset)) { +dev_err (dev,"Failed to get PCIEPHY reset contol\n" ); +return PTR_ERR (imx6_pcie->pciephy_reset); + } + + imx6_pcie->apps_reset =devm_reset_control_get (dev,"apps" ); +if (IS_ERR (imx6_pcie->apps_reset)) { +dev_err (dev,"Failed to get PCIE APPS reset contol\n" ); +return PTR_ERR (imx6_pcie->apps_reset); + } +break ; +default : +break ; }/* Grab GPR config register range */ @@ -740,6 +810,7 @@ static const struct of_device_id imx6_pcie_of_match[] = { { .compatible = "fsl,imx6q-pcie", .data = (void *)IMX6Q, }, { .compatible = "fsl,imx6sx-pcie", .data = (void *)IMX6SX, }, { .compatible = "fsl,imx6qp-pcie", .data = (void *)IMX6QP, }, + { .compatible = "fsl,imx7d-pcie", .data = (void *)IMX7D, }, {}, };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 */
kbuild test robot
build botRe: [PATCH v4 2/3] PCI: imx6: Allow probe deferal by reset GPIO
In reply to Andrey Smirnovreproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree…
Hi Andrey,
[auto build test WARNING on robh/for-next]
[also build test WARNING on v4.10-rc7 next-20170207]
[cannot apply to pci/next]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Andrey-Smirnov/PCI-imx6-Fix-a-typo-in-error-message/20170208-014815 base: https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next config: arm-allmodconfig (attached as .config) compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm
All warnings (new ones prefixed by >>):
>> WARNING: vmlinux.o(.text+0x4d99fc): Section mismatch in reference from the function imx6_pcie_probe() to the function .init.text:hook_fault_code()
The function imx6_pcie_probe() references
the function __init hook_fault_code().
This is often because imx6_pcie_probe lacks a __init annotation or the annotation of hook_fault_code is wrong.
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 60380 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170208/4de16b82/attachment-0001.gz>
Re: [PATCH v4 3/3] PCI: imx6: Add code to support i.MX7D
In reply to Andrey SmirnovQuoted 13 lines · Andrey Smirnov
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 Fabio Estevam <[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]>
Quoted 5 lines
--- .../devicetree/bindings/pci/fsl,imx6q-pcie.txt | 13 ++- drivers/pci/host/pci-imx6.c | 121 ++++++++++++++++-----include/linux/mfd/syscon/imx7-iomuxc-gpr.h | 4 +
Quoted 273 lines
3 files changed, 112 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/host/pci-imx6.c +96
-25@@ -17,6 +17,7 @@#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/module.h> #include <linux/of_gpio.h> #include <linux/of_device.h> @@ -27,6 +28,7 @@#include <linux/signal.h> #include <linux/types.h> #include <linux/interrupt.h> +#include <linux/reset.h> #include "pcie-designware.h" @@ -36,6 +38,7 @@ enum imx6_pcie_variants {IMX6Q ,IMX6SX ,IMX6QP , + IMX7D, }; struct imx6_pcie {@@ -47,6 +50,8 @@ struct imx6_pcie {struct clk *pcie_inbound_axi;struct clk *pcie;struct regmap *iomuxc_gpr; +struct reset_control *pciephy_reset; +struct reset_control *apps_reset;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,10 @@ static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie)u32 val, gpr1, gpr12;switch (imx6_pcie->variant) { +case IMX7D : +reset_control_assert (imx6_pcie->pciephy_reset); +reset_control_assert (imx6_pcie->apps_reset); +break ;case IMX6SX : regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, IMX6SX_GPR12_PCIE_TEST_POWERDOWN,@@ -333,11 +347,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; } +static void imx7d_pcie_wait_for_phy_pll_lock (struct imx6_pcie *imx6_pcie) +{ +u32 val; +unsigned int retries; +struct pcie_port *pp = &imx6_pcie->pp; +struct device *dev = pp->dev; + +for (retries =0 ; retries <PHY_PLL_LOCK_WAIT_MAX_RETRIES ; retries++) { +regmap_read (imx6_pcie->iomuxc_gpr,IOMUXC_GPR22 , &val); + +if (val &IMX7D_GPR22_PCIE_PHY_PLL_LOCKED ) +return ; + +usleep_range (PHY_PLL_LOCK_WAIT_USLEEP_MIN , +PHY_PLL_LOCK_WAIT_USLEEP_MAX ); + } + +dev_err (dev,"PCIe PLL lock timeout\n" ); +} +static void imx6_pcie_deassert_core_reset (struct imx6_pcie *imx6_pcie) {struct pcie_port *pp = &imx6_pcie->pp;@@ -381,6 +417,10 @@ static void imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie) }switch (imx6_pcie->variant) { +case IMX7D : +reset_control_deassert (imx6_pcie->pciephy_reset); +imx7d_pcie_wait_for_phy_pll_lock (imx6_pcie); +break ;case IMX6SX :regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR5 ,IMX6SX_GPR5_PCIE_BTNRST_RESET ,0 );@@ -407,35 +447,44 @@ static void imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie)static void imx6_pcie_init_phy (struct imx6_pcie *imx6_pcie) { -if (imx6_pcie->variant ==IMX6SX ) +switch (imx6_pcie->variant) { +case IMX7D : +regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR12 , +IMX7D_GPR12_PCIE_PHY_REFCLK_SEL ,0 ); +break ; +case IMX6SX :regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR12 ,IMX6SX_GPR12_PCIE_RX_EQ_MASK ,IMX6SX_GPR12_PCIE_RX_EQ_2 ); +/* FALLTHROUGH */ +default : +regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR12 , +IMX6Q_GPR12_PCIE_CTL_2 ,0 <<10 ); -regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR12 , -IMX6Q_GPR12_PCIE_CTL_2 ,0 <<10 ); +/* configure constant input signal to the pcie ctrl and phy */ +regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR12 , +IMX6Q_GPR12_LOS_LEVEL ,9 <<4 ); + +regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR8 , +IMX6Q_GPR8_TX_DEEMPH_GEN1 , + imx6_pcie->tx_deemph_gen1 <<0 ); +regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR8 , +IMX6Q_GPR8_TX_DEEMPH_GEN2_3P5DB , + imx6_pcie->tx_deemph_gen2_3p5db <<6 ); +regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR8 , +IMX6Q_GPR8_TX_DEEMPH_GEN2_6DB , + imx6_pcie->tx_deemph_gen2_6db <<12 ); +regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR8 , +IMX6Q_GPR8_TX_SWING_FULL , + imx6_pcie->tx_swing_full <<18 ); +regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR8 , +IMX6Q_GPR8_TX_SWING_LOW , + imx6_pcie->tx_swing_low <<25 ); +break ; + } -/* configure constant input signal to the pcie ctrl and phy */ regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR12 ,IMX6Q_GPR12_DEVICE_TYPE ,PCI_EXP_TYPE_ROOT_PORT <<12 ); -regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR12 , -IMX6Q_GPR12_LOS_LEVEL ,9 <<4 ); - -regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR8 , -IMX6Q_GPR8_TX_DEEMPH_GEN1 , - imx6_pcie->tx_deemph_gen1 <<0 ); -regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR8 , -IMX6Q_GPR8_TX_DEEMPH_GEN2_3P5DB , - imx6_pcie->tx_deemph_gen2_3p5db <<6 ); -regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR8 , -IMX6Q_GPR8_TX_DEEMPH_GEN2_6DB , - imx6_pcie->tx_deemph_gen2_6db <<12 ); -regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR8 , -IMX6Q_GPR8_TX_SWING_FULL , - imx6_pcie->tx_swing_full <<18 ); -regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR8 , -IMX6Q_GPR8_TX_SWING_LOW , - imx6_pcie->tx_swing_low <<25 ); }static int imx6_pcie_wait_for_link (struct imx6_pcie *imx6_pcie)@@ -498,8 +547,11 @@ static int imx6_pcie_establish_link(struct imx6_pcie *imx6_pcie)dw_pcie_writel_rc (pp,PCIE_RC_LCR , tmp);/* Start LTSSM. */ -regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR12 , -IMX6Q_GPR12_PCIE_CTL_2 ,1 <<10 ); +if (imx6_pcie->variant ==IMX7D ) +reset_control_deassert (imx6_pcie->apps_reset); +else +regmap_update_bits (imx6_pcie->iomuxc_gpr,IOMUXC_GPR12 , +IMX6Q_GPR12_PCIE_CTL_2 ,1 <<10 ); ret =imx6_pcie_wait_for_link (imx6_pcie);if (ret) {@@ -676,13 +728,31 @@ static int imx6_pcie_probe(struct platform_device *pdev)return PTR_ERR (imx6_pcie->pcie); } -if (imx6_pcie->variant ==IMX6SX ) { +switch (imx6_pcie->variant) { +case IMX6SX : imx6_pcie->pcie_inbound_axi =devm_clk_get (dev,"pcie_inbound_axi" );if (IS_ERR (imx6_pcie->pcie_inbound_axi)) {dev_err (dev,"pcie_inbound_axi clock missing or invalid\n" );return PTR_ERR (imx6_pcie->pcie_inbound_axi); } +break ; +case IMX7D : + imx6_pcie->pciephy_reset =devm_reset_control_get (dev, +"pciephy" ); +if (IS_ERR (imx6_pcie->pciephy_reset)) { +dev_err (dev,"Failed to get PCIEPHY reset contol\n" ); +return PTR_ERR (imx6_pcie->pciephy_reset); + } + + imx6_pcie->apps_reset =devm_reset_control_get (dev,"apps" ); +if (IS_ERR (imx6_pcie->apps_reset)) { +dev_err (dev,"Failed to get PCIE APPS reset contol\n" ); +return PTR_ERR (imx6_pcie->apps_reset); + } +break ; +default : +break ; }/* Grab GPR config register range */ @@ -740,6 +810,7 @@ static const struct of_device_id imx6_pcie_of_match[] = { { .compatible = "fsl,imx6q-pcie", .data = (void *)IMX6Q, }, { .compatible = "fsl,imx6sx-pcie", .data = (void *)IMX6SX, }, { .compatible = "fsl,imx6qp-pcie", .data = (void *)IMX6QP, }, + { .compatible = "fsl,imx7d-pcie", .data = (void *)IMX7D, }, {}, };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 · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org ? Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Quoted 35 lines · Andrey Smirnov
Hello, everyone:
This is a fourth iteration of the code that adds PCI-subsystem bits necessary for enabling PCI support on i.MX7.
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)[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 (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
Quoted 4 lines
.../devicetree/bindings/pci/fsl,imx6q-pcie.txt | 13 +- drivers/pci/host/pci-imx6.c | 131 ++++++++++++++++----- include/linux/mfd/syscon/imx7-iomuxc-gpr.h | 4 + 3 files changed, 118 insertions(+), 30 deletions(-)
I applied patches 1 & 3 (with reviewed-by and ack from Lucas and Lee) to pci/host-imx6 for v4.11, thanks!
I didn't apply 2 because of the section mismatch found by the autobuilder:
Quoted 1 line
Quoted 1 line
WARNING: drivers/built-in.o(.data+0x6948c): Section mismatch in reference from the variable
imx6_pcie_driverto the function .init.text:imx6_pcie_probe()
The variable imx6_pcie_driver references
the function __init imx6_pcie_probe()
If the reference is valid then annotate the
variable with or __refdata (see linux/init.h) or name the variable:
Please repost it after you figure out how to deal with that.
Bjorn
Rob Herring
maintainerRe: [PATCH v4 3/3] PCI: imx6: Add code to support i.MX7D
In reply to Andrey SmirnovQuoted 37 lines · Andrey Smirnov
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 Fabio Estevam <[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 | 13 ++- drivers/pci/host/pci-imx6.c | 121 ++++++++++++++++----- include/linux/mfd/syscon/imx7-iomuxc-gpr.h | 4 + 3 files changed, 112 insertions(+), 26 deletions(-)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.
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt Additional required properties for imx6sx-pcie: · line 42
Quoted 5 lines
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt +2
-0@@ -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
This domain is just the PHY? Seems like this needs a separate PHY driver.
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt Additional required properties for imx6sx-pcie: · line 45
Quoted 3 lines
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt +3
-0+- resets: Must contain phandles to PCIE related reset lines exposed by SRC IP block +- reset-names: Must contain the following entires: + - "pciephy"
And for this too.
Quoted 5 lines
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt +2
-0+ - "apps" + Example: pcie at 0x01000000 {
[...]
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie) · line 270
Quoted 11 lines
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt +4
-0@@ -251,6 +261,10 @@ static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie) u32 val, gpr1, gpr12; switch (imx6_pcie->variant) { + case IMX7D: + reset_control_assert(imx6_pcie->pciephy_reset); + reset_control_assert(imx6_pcie->apps_reset); + break; case IMX6SX: regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, IMX6SX_GPR12_PCIE_TEST_POWERDOWN,
So the difference with i.MX7D is not really that it has a reset or not, but some platforms use a reset driver and some do not. The latter should be fixed.
Rob
Re: [PATCH v4 3/3] PCI: imx6: Add code to support i.MX7D
Quoted 64 lines · Rob Herring
Quoted 37 lines · Andrey Smirnov
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 Fabio Estevam <[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 | 13 ++- drivers/pci/host/pci-imx6.c | 121 ++++++++++++++++----- include/linux/mfd/syscon/imx7-iomuxc-gpr.h | 4 + 3 files changed, 112 insertions(+), 26 deletions(-)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.Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt Additional required properties for imx6sx-pcie: · line 42
Quoted 5 lines
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt +2
-0@@ -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 domainThis domain is just the PHY? Seems like this needs a separate PHY driver.
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt Additional required properties for imx6sx-pcie: · line 45
Quoted 3 lines
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt +3
-0+- resets: Must contain phandles to PCIE related reset lines exposed by SRC IP block +- reset-names: Must contain the following entires: + - "pciephy"And for this too.
Quoted 5 lines
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt +2
-0+ - "apps" + Example: pcie at 0x01000000 {[...]
Quoted 3 lines
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt +0
-0@@ -251,6 +261,10 @@ static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie) u32 val, gpr1, gpr12;
Quoted 12 lines
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie) · line 270
Quoted 8 lines
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt +4
-0switch (imx6_pcie->variant) { + case IMX7D: + reset_control_assert(imx6_pcie->pciephy_reset); + reset_control_assert(imx6_pcie->apps_reset); + break; case IMX6SX: regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, IMX6SX_GPR12_PCIE_TEST_POWERDOWN,So the difference with i.MX7D is not really that it has a reset or not, but some platforms use a reset driver and some do not. The latter should be fixed.
I have this patch queued for v4.11. Are these things that should be fixed first? If so, I can drop this.
Bjorn
Rob Herring
maintainerRe: [PATCH v4 3/3] PCI: imx6: Add code to support i.MX7D
Quoted 23 lines · Bjorn Helgaas
Quoted 9 lines · Rob Herring
Quoted 1 line · Andrey Smirnov
Add various bits of code needed to support i.MX7D variant of the IP.
[...]
Quoted 3 lines
drivers/pci/host/pci-imx6.c +0
-0@@ -251,6 +261,10 @@ static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie)u32 val, gpr1, gpr12;Quoted 12 lines
drivers/pci/host/pci-imx6.c static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie) · line 270
Quoted 8 lines
drivers/pci/host/pci-imx6.c +4
-0switch (imx6_pcie->variant) { +case IMX7D : +reset_control_assert (imx6_pcie->pciephy_reset); +reset_control_assert (imx6_pcie->apps_reset); +break ;case IMX6SX : regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, IMX6SX_GPR12_PCIE_TEST_POWERDOWN,So the difference with i.MX7D is not really that it has a reset or not, but some platforms use a reset driver and some do not. The latter should be fixed.
Quoted 2 lines
I have this patch queued for v4.11. Are these things that should be fixed first? If so, I can drop this.
Well, depends if you trust things will get fixed later and if the PHY in fact should be separate as that affects the binding. It would affect how the driver changes are done as instead of "if (IMX7D) ...", you'd have "if (imx6_pcie->apps_reset) ..." for example. That part depends on how much churn you want there.
Rob
Re: [PATCH v4 3/3] PCI: imx6: Add code to support i.MX7D
Quoted 24 lines · Rob Herring
Quoted 23 lines · Bjorn Helgaas
Quoted 21 lines · Rob Herring
Quoted 1 line · Andrey Smirnov
Add various bits of code needed to support i.MX7D variant of the IP.
[...]
drivers/pci/host/pci-imx6.c static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie) · line 270
Quoted 11 lines
drivers/pci/host/pci-imx6.c +4
-0@@ -251,6 +261,10 @@ static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie)u32 val, gpr1, gpr12;switch (imx6_pcie->variant) { +case IMX7D : +reset_control_assert (imx6_pcie->pciephy_reset); +reset_control_assert (imx6_pcie->apps_reset); +break ;case IMX6SX : regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, IMX6SX_GPR12_PCIE_TEST_POWERDOWN,So the difference with i.MX7D is not really that it has a reset or not, but some platforms use a reset driver and some do not. The latter should be fixed.
Quoted 8 lines
Quoted 2 lines
I have this patch queued for v4.11. Are these things that should be fixed first? If so, I can drop this.
Well, depends if you trust things will get fixed later and if the PHY in fact should be separate as that affects the binding. It would affect how the driver changes are done as instead of "if (IMX7D) ...", you'd have "if (
imx6_pcie->apps_reset) ..." for example. That part depends on how much churn you want there.
I dropped it for now, not that I don't trust it will get fixed, but it sounds like not completely trivial changes and will affect the binding as well, so the intermediate state sounds a little messy.
Bjorn
Re: [PATCH v4 3/3] PCI: imx6: Add code to support i.MX7D
In reply to Rob HerringQuoted 41 lines · Rob Herring
Quoted 40 lines · Andrey Smirnov
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 Fabio Estevam <[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 | 13 ++- drivers/pci/host/pci-imx6.c | 121 ++++++++++++++++----- include/linux/mfd/syscon/imx7-iomuxc-gpr.h | 4 + 3 files changed, 112 insertions(+), 26 deletions(-)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.@@ -34,6 +38,13 @@ Additional required properties for imx6sx-pcie: - clock names: Must include the following additional entries: - "pcie_inbound_axi"
Quoted 5 lines
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt Additional required properties for imx6sx-pcie: · line 42
Quoted 2 lines
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt +2
-0+Additional required properties for imx7d-pcie: +- power-domains: Must be set to a phandle pointing to PCIE_PHY power domainThis domain is just the PHY? Seems like this needs a separate PHY driver.
PCIE_PHY is the name of the power domain corresponding to PGC_PCIE (which is what that property is expected to point to) as per Frescale/NXP datasheet (p. 822 in v0.1 of i.MX7 Application Processors Manual). I was never able to find any clear language indicating what parts of DesignWare's IP core and Freescale's/NXP's PCIE PHY it powers in the manual. However, experiments with hardware show that when that domain remains non-powered any attempt to access registers of DW's IP block result in system hanging, so it seemed to me that the two are not independent of each other enough to be represented as individual DT nodes.
Quoted 18 lines
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt Additional required properties for imx6sx-pcie: · line 45
Quoted 4 lines
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt +3
-0+- resets: Must contain phandles to PCIE related reset lines exposed by SRC IP block +- reset-names: Must contain the following entires: + - "pciephy"And for this too.
Quoted 5 lines
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt +2
-0+ - "apps" + Example: pcie at 0x01000000 {[...]
Quoted 3 lines
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt +0
-0@@ -251,6 +261,10 @@ static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie) u32 val, gpr1, gpr12;
Quoted 12 lines
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie) · line 270
Quoted 8 lines
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt +4
-0switch (imx6_pcie->variant) { + case IMX7D: + reset_control_assert(imx6_pcie->pciephy_reset); + reset_control_assert(imx6_pcie->apps_reset); + break; case IMX6SX: regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, IMX6SX_GPR12_PCIE_TEST_POWERDOWN,So the difference with i.MX7D is not really that it has a reset or not, but some platforms use a reset driver and some do not. The latter should be fixed.
That depends on what variant of the SoC you are comparing it to. 6QP, 6SX do have reset and helper signals wire to bits in registers in IOMUX, 6Q howerver doesn't have a reset line wire and have to do some trickery as per comment in the driver several lines below:
"... As there is no dedicated reset signal wired up for MX6QDL, we need to manually force LTSSM into "detect" state before completely disabling LTSSM, which is a prerequisite for core configuration..."
If memory serves me well part of that 6Q trickery code is the reason for driver using hook_fault_code().
That is not to say that all of this code could not be encapsulated as a reset controller, and I agree, doing so might make the driver better. At the same time I don't have the hardware to test all of those platforms and I am hoping we can agree this kind of change to be out of scope of this series.
Thanks,
Andrey Smironv
Re: [PATCH v4 3/3] PCI: imx6: Add code to support i.MX7D
In reply to Rob HerringAm Mittwoch, den 15.02.2017, 11:17 -0600 schrieb Rob Herring:
Quoted 41 lines · Andrey Smirnov
Quoted 40 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 Fabio Estevam <[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 | 13 ++- drivers/pci/host/pci-imx6.c | 121 ++++++++++++++++----- include/linux/mfd/syscon/imx7-iomuxc-gpr.h | 4 + 3 files changed, 112 insertions(+), 26 deletions(-)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.@@ -34,6 +38,13 @@ Additional required properties for imx6sx-pcie: - clock names: Must include the following additional entries: - "pcie_inbound_axi"
Quoted 6 lines
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt Additional required properties for imx6sx-pcie: · line 42
Quoted 2 lines
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt +2
-0+Additional required properties for imx7d-pcie: +- power-domains: Must be set to a phandle pointing to PCIE_PHY power domainThis domain is just the PHY? Seems like this needs a separate PHY driver.
No, it's called the PHY power domain, as that is probably the part that draws the most power, but the PCIe core also looses it's state when this domain is powered down. So it's probably the complete core that is inside this domain.
Quoted 17 lines
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt Additional required properties for imx6sx-pcie: · line 45
Quoted 3 lines
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt +3
-0+- resets: Must contain phandles to PCIE related reset lines exposed by SRC IP block +- reset-names: Must contain the following entires: + - "pciephy"And for this too.
Quoted 5 lines
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt +2
-0+ - "apps" + Example: pcie at 0x01000000 {[...]
Quoted 3 lines
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt +0
-0@@ -251,6 +261,10 @@ static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie) u32 val, gpr1, gpr12;
Quoted 12 lines
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie) · line 270
Quoted 8 lines
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt +4
-0switch (imx6_pcie->variant) { + case IMX7D: + reset_control_assert(imx6_pcie->pciephy_reset); + reset_control_assert(imx6_pcie->apps_reset); + break; case IMX6SX: regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, IMX6SX_GPR12_PCIE_TEST_POWERDOWN,So the difference with i.MX7D is not really that it has a reset or not, but some platforms use a reset driver and some do not. The latter should be fixed.
The resets on anything before i.MX7 are not in a separate reset driver, but are just some signals from the PCIe core wired into a syscon (IOMUX GPR) area. While we could invent a reset controller for those, I don't see how this would improve things. Especially as the reset on i.MX6 seems to be some side-effect of the "power-down" signal of the core, so not strictly a reset.
Also I don't see why we should change the binding for the driver with a long history of deployed DTs. That seems like a total waste of manpower.
Regards,
Lucas
Re: [PATCH v4 3/3] PCI: imx6: Add code to support i.MX7D
In reply to Bjorn HelgaasAm Mittwoch, den 15.02.2017, 15:57 -0600 schrieb Bjorn Helgaas:
Quoted 34 lines · Rob Herring
Quoted 24 lines · Bjorn Helgaas
Quoted 23 lines · Rob Herring
Quoted 21 lines · Andrey Smirnov
Quoted 1 line
Add various bits of code needed to support i.MX7D variant of the IP.
[...]
drivers/pci/host/pci-imx6.c static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie) · line 270
Quoted 11 lines
drivers/pci/host/pci-imx6.c +4
-0@@ -251,6 +261,10 @@ static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie)u32 val, gpr1, gpr12;switch (imx6_pcie->variant) { +case IMX7D : +reset_control_assert (imx6_pcie->pciephy_reset); +reset_control_assert (imx6_pcie->apps_reset); +break ;case IMX6SX : regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, IMX6SX_GPR12_PCIE_TEST_POWERDOWN,So the difference with i.MX7D is not really that it has a reset or not, but some platforms use a reset driver and some do not. The latter should be fixed.
Quoted 8 lines
Quoted 2 lines
I have this patch queued for v4.11. Are these things that should be fixed first? If so, I can drop this.
Well, depends if you trust things will get fixed later and if the PHY in fact should be separate as that affects the binding. It would affect how the driver changes are done as instead of "if (IMX7D) ...", you'd have "if (
imx6_pcie->apps_reset) ..." for example. That part depends on how much churn you want there.
Quoted 3 lines
I dropped it for now, not that I don't trust it will get fixed, but it sounds like not completely trivial changes and will affect the binding as well, so the intermediate state sounds a little messy.
As I pointed out in direct reply to Rob, I honestly think the binding is fine as is and properly reflects the hardware. But I guess he'll comment on that, so JFYI.
Regards,
Lucas
Rob Herring
maintainerRe: [PATCH v4 3/3] PCI: imx6: Add code to support i.MX7D
In reply to Lucas StachQuoted 48 lines · Lucas Stach
Am Mittwoch, den 15.02.2017, 11:17 -0600 schrieb Rob Herring:
Quoted 41 lines · Andrey Smirnov
Quoted 40 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 Fabio Estevam <[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 | 13 ++- drivers/pci/host/pci-imx6.c | 121 ++++++++++++++++----- include/linux/mfd/syscon/imx7-iomuxc-gpr.h | 4 + 3 files changed, 112 insertions(+), 26 deletions(-)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.@@ -34,6 +38,13 @@ Additional required properties for imx6sx-pcie: - clock names: Must include the following additional entries: - "pcie_inbound_axi"Quoted 6 lines
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt Additional required properties for imx6sx-pcie: · line 42
Quoted 2 lines
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt +2
-0+Additional required properties for imx7d-pcie: +- power-domains: Must be set to a phandle pointing to PCIE_PHY power domainThis domain is just the PHY? Seems like this needs a separate PHY driver.
Quoted 4 lines
No, it's called the PHY power domain, as that is probably the part that draws the most power, but the PCIe core also looses it's state when this domain is powered down. So it's probably the complete core that is inside this domain.
A shared domain doesn't mean the phy and core should be 1 node. It is the separate reset and clock for the PHY that tell me they should be separate. And I'm pretty sure the DW block and PHY are separate. If the PHY registers were part of the same register range, then I'd say they should be one.
Quoted 37 lines
Quoted 17 lines
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt Additional required properties for imx6sx-pcie: · line 45
Quoted 3 lines
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt +3
-0+- resets: Must contain phandles to PCIE related reset lines exposed by SRC IP block +- reset-names: Must contain the following entires: + - "pciephy"And for this too.
Quoted 5 lines
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt +2
-0+ - "apps" + Example: pcie at 0x01000000 {[...]
Quoted 3 lines
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt +0
-0@@ -251,6 +261,10 @@ static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie) u32 val, gpr1, gpr12;Quoted 12 lines
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie) · line 270
Quoted 8 lines
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt +4
-0switch (imx6_pcie->variant) { + case IMX7D: + reset_control_assert(imx6_pcie->pciephy_reset); + reset_control_assert(imx6_pcie->apps_reset); + break; case IMX6SX: regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, IMX6SX_GPR12_PCIE_TEST_POWERDOWN,So the difference with i.MX7D is not really that it has a reset or not, but some platforms use a reset driver and some do not. The latter should be fixed.
The resets on anything before i.MX7 are not in a separate reset driver, but are just some signals from the PCIe core wired into a syscon (IOMUX GPR) area. While we could invent a reset controller for those, I don't see how this would improve things. Especially as the reset on i.MX6 seems to be some side-effect of the "power-down" signal of the core, so not strictly a reset.
Quoted 2 lines
Also I don't see why we should change the binding for the driver with a long history of deployed DTs. That seems like a total waste of manpower.
We can debate whether or not we change existing platforms. Maybe that doesn't make sense now. But best practices should be considered when adding new bindings rather than just extending existing bindings. We didn't split out PHYs at one time and now we generally do. I'm not so concerned with just adding i.MX7D, but really the next chip (and the next).
Rob
Re: [PATCH v4 3/3] PCI: imx6: Add code to support i.MX7D
Am Dienstag, den 21.02.2017, 10:38 -0600 schrieb Rob Herring:
Quoted 54 lines · Lucas Stach
Quoted 48 lines
Am Mittwoch, den 15.02.2017, 11:17 -0600 schrieb Rob Herring:
Quoted 41 lines · Andrey Smirnov
Quoted 40 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 Fabio Estevam <[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 | 13 ++- drivers/pci/host/pci-imx6.c | 121 ++++++++++++++++----- include/linux/mfd/syscon/imx7-iomuxc-gpr.h | 4 + 3 files changed, 112 insertions(+), 26 deletions(-)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.@@ -34,6 +38,13 @@ Additional required properties for imx6sx-pcie: - clock names: Must include the following additional entries: - "pcie_inbound_axi"Quoted 6 lines
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt Additional required properties for imx6sx-pcie: · line 42
Quoted 2 lines
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt +2
-0+Additional required properties for imx7d-pcie: +- power-domains: Must be set to a phandle pointing to PCIE_PHY power domainThis domain is just the PHY? Seems like this needs a separate PHY driver.
Quoted 4 lines
No, it's called the PHY power domain, as that is probably the part that draws the most power, but the PCIe core also looses it's state when this domain is powered down. So it's probably the complete core that is inside this domain.
Quoted 5 lines
A shared domain doesn't mean the phy and core should be 1 node. It is the separate reset and clock for the PHY that tell me they should be separate. And I'm pretty sure the DW block and PHY are separate. If the PHY registers were part of the same register range, then I'd say they should be one.
Then we are on the same page of _not_ splitting out the PHY. :) The DW PCIe PHY has no separate register range on i.MX. In fact the PHY registers are only accessible through a indirection register in the PCIe host controller register range.
Regards,
Lucas