From: Richard Zhu <hongxing.zhu@nxp.com> Date: 2021-09-26 08:03:41
Refer to the discussion [1] when try to enable i.MX8MM PCIe support,
one standalone PCIe PHY driver should be seperated from i.MX PCIe
driver when enable i.MX8MM PCIe support.
This patch-set adds the standalone PCIe PHY driver suport, and as a
preparatory to add the i.MX8MM PCIe support later.
The PCIe works on i.MX8MM EVK board based the the blkctrl power driver
[2] and this PHY driver patch-set.
[1] https://patchwork.ozlabs.org/project/linux-pci/patch/20210510141509.929120-3-l.stach@pengutronix.de/
[2] https://patchwork.kernel.org/project/linux-arm-kernel/cover/20210910202640.980366-1-l.stach@pengutronix.de/
Changes v1 --> v2:
- Update the license of the dt-binding header file to make the license
compatible with dts files.
- Fix the dt_binding_check errors.
[PATCH v2 1/4] dt-bindings: phy: phy-imx8-pcie: Add binding for the
[PATCH v2 2/4] dt-bindings: phy: add imx8 pcie phy driver support
[PATCH v2 3/4] arm64: dts: imx8mm: add the pcie phy support
[PATCH v2 4/4] phy: freescale: pcie: initialize the imx8 pcie
Documentation/devicetree/bindings/phy/fsl,imx8-pcie-phy.yaml | 67 ++++++++++++++++++++++++++++++++
arch/arm64/boot/dts/freescale/imx8mm-evk.dtsi | 4 ++
arch/arm64/boot/dts/freescale/imx8mm.dtsi | 12 ++++++
drivers/phy/freescale/Kconfig | 9 +++++
drivers/phy/freescale/Makefile | 1 +
drivers/phy/freescale/phy-fsl-imx8-pcie.c | 167 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
include/dt-bindings/phy/phy-imx8-pcie.h | 14 +++++++
7 files changed, 274 insertions(+)
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
@@ -0,0 +1,67 @@+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)+%YAML1.2+---+$id:http://devicetree.org/schemas/phy/fsl,imx8-pcie-phy.yaml#+$schema:http://devicetree.org/meta-schemas/core.yaml#++title:Freescale i.MX8 SoC series PCIe PHY Device Tree Bindings++maintainers:+-Richard Zhu <hongxing.zhu@nxp.com>++properties:+"#phy-cells":+const:0++compatible:+enum:+-fsl,imx8mm-pcie-phy++reg:+maxItems:1++clocks:+items:+-description:PHY module clock++clock-names:+items:+-const:phy++fsl,refclk-pad-mode:+description:|+Specifies the mode of the refclk pad used. It can be NO_USED(PHY+refclock is derived from SoC internal source), INPUT(PHY refclock+is provided externally via the refclk pad) or OUTPUT(PHY refclock+is derived from SoC internal source and provided on the refclk pad).+Refer include/dt-bindings/phy/phy-imx8-pcie.h for the constants+to be used.+$ref:/schemas/types.yaml#/definitions/uint32+enum:[0,1,2]++required:+-"#phy-cells"+-compatible+-reg+-clocks+-clock-names+-fsl,refclk-pad-mode++additionalProperties:false++examples:+-|+#include <dt-bindings/clock/imx8mm-clock.h>++pcie_phy:pcie-phy@32f00000 {+compatible = "fsl,imx8mm-pcie-phy";+reg = <0x32f00000 0x10000>;+clocks = <&clk IMX8MM_CLK_PCIE1_PHY>;+clock-names = "phy";+assigned-clocks = <&clk IMX8MM_CLK_PCIE1_PHY>;+assigned-clock-rates = <100000000>;+assigned-clock-parents = <&clk IMX8MM_SYS_PLL2_100M>;+fsl,refclk-pad-mode = <1>;+#phy-cells = <0>;+};+...
--
2.25.1
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
From: Richard Zhu <hongxing.zhu@nxp.com> Date: 2021-09-26 08:03:51
Add the standalone i.MX8 PCIe PHY driver.
Some reset bits should be manipulated between PHY configurations and
status check(internal PLL is locked or not).
So, do the PHY configuration in the phy_calibrate().
And check the PHY is ready or not in the phy_init().
Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
---
drivers/phy/freescale/Kconfig | 9 ++
drivers/phy/freescale/Makefile | 1 +
drivers/phy/freescale/phy-fsl-imx8-pcie.c | 167 ++++++++++++++++++++++
3 files changed, 177 insertions(+)
create mode 100644 drivers/phy/freescale/phy-fsl-imx8-pcie.c
@@ -0,0 +1,67 @@+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)+%YAML1.2+---+$id:http://devicetree.org/schemas/phy/fsl,imx8-pcie-phy.yaml#+$schema:http://devicetree.org/meta-schemas/core.yaml#++title:Freescale i.MX8 SoC series PCIe PHY Device Tree Bindings++maintainers:+-Richard Zhu <hongxing.zhu@nxp.com>++properties:+"#phy-cells":+const:0++compatible:+enum:+-fsl,imx8mm-pcie-phy++reg:+maxItems:1++clocks:+items:+-description:PHY module clock++clock-names:+items:+-const:phy
The clock name should describe what it is used for in the hardware
block described by the DT node. So I would think this should be called
"ref" or something like this, as I believe this clock is really only
used as the reference clock and can be disabled when the refclock is
supplied via the pad, right?
+
+ fsl,refclk-pad-mode:
+ description: |
+ Specifies the mode of the refclk pad used. It can be NO_USED(PHY
+ refclock is derived from SoC internal source), INPUT(PHY refclock
+ is provided externally via the refclk pad) or OUTPUT(PHY refclock
+ is derived from SoC internal source and provided on the refclk pad).
+ Refer include/dt-bindings/phy/phy-imx8-pcie.h for the constants
+ to be used.
+ $ref: /schemas/types.yaml#/definitions/uint32
+ enum: [ 0, 1, 2 ]
+
+required:
+ - "#phy-cells"
+ - compatible
+ - reg
+ - clocks
+ - clock-names
+ - fsl,refclk-pad-mode
+
+additionalProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/clock/imx8mm-clock.h>
+
+ pcie_phy: pcie-phy@32f00000 {
+ compatible = "fsl,imx8mm-pcie-phy";
+ reg = <0x32f00000 0x10000>;
+ clocks = <&clk IMX8MM_CLK_PCIE1_PHY>;
+ clock-names = "phy";
+ assigned-clocks = <&clk IMX8MM_CLK_PCIE1_PHY>;
+ assigned-clock-rates = <100000000>;
+ assigned-clock-parents = <&clk IMX8MM_SYS_PLL2_100M>;
+ fsl,refclk-pad-mode = <1>;
Include the new header added in patch 1 and use the enum.
From: Lucas Stach <l.stach@pengutronix.de> Date: 2021-09-27 08:43:44
Am Sonntag, dem 26.09.2021 um 15:39 +0800 schrieb Richard Zhu:
Add the standalone i.MX8 PCIe PHY driver.
Some reset bits should be manipulated between PHY configurations and
status check(internal PLL is locked or not).
So, do the PHY configuration in the phy_calibrate().
And check the PHY is ready or not in the phy_init().
I would really like to see the PCIe controller driver side of this
also, as it's hard to review standalone. For example I'm not sure if
some of those reset bits should also be driven from the PHY driver,
even if they are currently hooked up to the controller driver.
Also I think the IOMUX GPR register handling belongs in the PHY driver,
as it's configuring the reference clock routing.
From what I know, there are several quite different PCIe PHYs used in
the different i.MX8 variants. I'm not sure if we want to stuff them all
into one file. I guess we should be more specific here and call this
imx8m-phy, or even imx8mm-phy.
From: Richard Zhu <hongxing.zhu@nxp.com> Date: 2021-09-28 02:28:45
-----Original Message-----
From: Lucas Stach <l.stach@pengutronix.de>
Sent: Monday, September 27, 2021 4:27 PM
To: Richard Zhu <hongxing.zhu@nxp.com>; kishon@ti.com; vkoul@kernel.org;
robh@kernel.org; galak@kernel.crashing.org; shawnguo@kernel.org
Cc: linux-phy@lists.infradead.org; devicetree@vger.kernel.org;
linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org;
kernel@pengutronix.de; dl-linux-imx [off-list ref]
Subject: Re: [PATCH v2 1/4] dt-bindings: phy: phy-imx8-pcie: Add binding for
the pad modes of imx8 pcie phy
Am Sonntag, dem 26.09.2021 um 15:39 +0800 schrieb Richard Zhu:
quoted
Add binding for reference clock PAD modes of the i.MX8 PCIe PHY.
Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
---
include/dt-bindings/phy/phy-imx8-pcie.h | 14 ++++++++++++++
1 file changed, 14 insertions(+)
create mode 100644 include/dt-bindings/phy/phy-imx8-pcie.h
The clock name should describe what it is used for in the hardware block
described by the DT node. So I would think this should be called "ref" or
something like this, as I believe this clock is really only used as the reference
clock and can be disabled when the refclock is supplied via the pad, right?
[Richard Zhu] That's right. "ref" is better. Thanks.
quoted
+
+ fsl,refclk-pad-mode:
+ description: |
+ Specifies the mode of the refclk pad used. It can be NO_USED(PHY
+ refclock is derived from SoC internal source), INPUT(PHY refclock
+ is provided externally via the refclk pad) or OUTPUT(PHY refclock
+ is derived from SoC internal source and provided on the refclk pad).
+ Refer include/dt-bindings/phy/phy-imx8-pcie.h for the constants
+ to be used.
+ $ref: /schemas/types.yaml#/definitions/uint32
+ enum: [ 0, 1, 2 ]
+
+required:
+ - "#phy-cells"
+ - compatible
+ - reg
+ - clocks
+ - clock-names
+ - fsl,refclk-pad-mode
+
+additionalProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/clock/imx8mm-clock.h>
+
+ pcie_phy: pcie-phy@32f00000 {
+ compatible = "fsl,imx8mm-pcie-phy";
+ reg = <0x32f00000 0x10000>;
+ clocks = <&clk IMX8MM_CLK_PCIE1_PHY>;
+ clock-names = "phy";
+ assigned-clocks = <&clk IMX8MM_CLK_PCIE1_PHY>;
+ assigned-clock-rates = <100000000>;
+ assigned-clock-parents = <&clk
IMX8MM_SYS_PLL2_100M>;
quoted
+ fsl,refclk-pad-mode = <1>;
Include the new header added in patch 1 and use the enum.
[Richard Zhu] Got that, would changed in next version. Thanks.
From: Richard Zhu <hongxing.zhu@nxp.com> Date: 2021-09-28 02:38:36
-----Original Message-----
From: Lucas Stach <l.stach@pengutronix.de>
Sent: Monday, September 27, 2021 4:35 PM
To: Richard Zhu <hongxing.zhu@nxp.com>; kishon@ti.com; vkoul@kernel.org;
robh@kernel.org; galak@kernel.crashing.org; shawnguo@kernel.org
Cc: linux-phy@lists.infradead.org; devicetree@vger.kernel.org;
linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org;
kernel@pengutronix.de; dl-linux-imx [off-list ref]
Subject: Re: [PATCH v2 3/4] arm64: dts: imx8mm: add the pcie phy support
Am Sonntag, dem 26.09.2021 um 15:39 +0800 schrieb Richard Zhu:
quoted
Add the PCIe PHY support on iMX8MM platforms.
Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
---
arch/arm64/boot/dts/freescale/imx8mm-evk.dtsi | 4 ++++
arch/arm64/boot/dts/freescale/imx8mm.dtsi | 12 ++++++++++++
This should be split into 2 patches: one for the SoC and one for the EVK board.
[Richard Zhu] Okay, would split this patch into 2 patches later. Thanks.
From: Richard Zhu <hongxing.zhu@nxp.com> Date: 2021-09-28 07:09:16
-----Original Message-----
From: Lucas Stach <l.stach@pengutronix.de>
Sent: Monday, September 27, 2021 4:43 PM
To: Richard Zhu <hongxing.zhu@nxp.com>; kishon@ti.com; vkoul@kernel.org;
robh@kernel.org; galak@kernel.crashing.org; shawnguo@kernel.org
Cc: linux-phy@lists.infradead.org; devicetree@vger.kernel.org;
linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org;
kernel@pengutronix.de; dl-linux-imx [off-list ref]
Subject: Re: [PATCH v2 4/4] phy: freescale: pcie: initialize the imx8 pcie
standalone phy driver
Am Sonntag, dem 26.09.2021 um 15:39 +0800 schrieb Richard Zhu:
quoted
Add the standalone i.MX8 PCIe PHY driver.
Some reset bits should be manipulated between PHY configurations and
status check(internal PLL is locked or not).
So, do the PHY configuration in the phy_calibrate().
And check the PHY is ready or not in the phy_init().
I would really like to see the PCIe controller driver side of this also, as it's hard
to review standalone. For example I'm not sure if some of those reset bits
should also be driven from the PHY driver, even if they are currently hooked
up to the controller driver.
Also I think the IOMUX GPR register handling belongs in the PHY driver, as it's
configuring the reference clock routing.
[Richard Zhu] Sorry to bring inconvenience to you. I would send out the v3
patch-set and the i.MX8MM PCIe controller driver patches after I'm back from the
national holiday tomorrow(about one week).
Although most of the IOMUX GPR bits are related to PHY, but there are some bits are
defined only for controller. For example, the device_type of the controller, the clkreq#
signal control in L1SS, and so on. We can't encapsulate all the GPR bits setting into PHY driver.
So, it's better to let controller driver to handle the general register bits manipulations.
How do you think about that?
From what I know, there are several quite different PCIe PHYs used in the
different i.MX8 variants. I'm not sure if we want to stuff them all into one file.
I guess we should be more specific here and call this imx8m-phy, or even
imx8mm-phy.
[Richard Zhu] Good suggestions, I think imx8m-phy is better, since the i.MX8MQ/MM/MP
have the similar architecture of the PCIe PHY implementation.
quoted
diff --git a/drivers/phy/freescale/Kconfig
b/drivers/phy/freescale/Kconfig index 320630ffe3cd..da078a676fbc
100644
Do we need to enable this clock when the refclock is supplied externally via
the pad?
[Richard Zhu] Good question. I think this clock is not needed anymore if the refclock is sourced from external OSC.
I just enable the PLL2_100Mhz here, since when internal PLL is used as refclock, the pll2_100Mhz should be turned on.
Shall I remove the setting and just keep the callback for further extend usage(internal PLL used as refclk)?
From: Lucas Stach <l.stach@pengutronix.de> Date: 2021-09-28 08:44:14
Hi Richard,
Am Dienstag, dem 28.09.2021 um 07:09 +0000 schrieb Richard Zhu:
quoted
-----Original Message-----
From: Lucas Stach <l.stach@pengutronix.de>
Sent: Monday, September 27, 2021 4:43 PM
To: Richard Zhu <hongxing.zhu@nxp.com>; kishon@ti.com; vkoul@kernel.org;
robh@kernel.org; galak@kernel.crashing.org; shawnguo@kernel.org
Cc: linux-phy@lists.infradead.org; devicetree@vger.kernel.org;
linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org;
kernel@pengutronix.de; dl-linux-imx [off-list ref]
Subject: Re: [PATCH v2 4/4] phy: freescale: pcie: initialize the imx8 pcie
standalone phy driver
Am Sonntag, dem 26.09.2021 um 15:39 +0800 schrieb Richard Zhu:
quoted
Add the standalone i.MX8 PCIe PHY driver.
Some reset bits should be manipulated between PHY configurations and
status check(internal PLL is locked or not).
So, do the PHY configuration in the phy_calibrate().
And check the PHY is ready or not in the phy_init().
I would really like to see the PCIe controller driver side of this also, as it's hard
to review standalone. For example I'm not sure if some of those reset bits
should also be driven from the PHY driver, even if they are currently hooked
up to the controller driver.
Also I think the IOMUX GPR register handling belongs in the PHY driver, as it's
configuring the reference clock routing.
[Richard Zhu] Sorry to bring inconvenience to you. I would send out the v3
patch-set and the i.MX8MM PCIe controller driver patches after I'm back from the
national holiday tomorrow(about one week).
No problem. :) I'm just pointing out that I probably won't be able to
invest more time reviewing this before I can get the full picture.
Although most of the IOMUX GPR bits are related to PHY, but there are some bits are
defined only for controller. For example, the device_type of the controller, the clkreq#
signal control in L1SS, and so on. We can't encapsulate all the GPR bits setting into PHY driver.
So, it's better to let controller driver to handle the general register bits manipulations.
How do you think about that?
I still think we should split the drivers along the functional
boundaries. It's quite confusing and probably going to be a maintenance
issues when some of the PHY handling bits are still located in the
controller driver, while we have a separate PHY driver.
As the GPR region is handled by a regmap we should have no issues
accessing even the same register from different drivers. So my vote is
on moving the GPR bits related to PHY clocking to this driver.
From what I know, there are several quite different PCIe PHYs used in the
different i.MX8 variants. I'm not sure if we want to stuff them all into one file.
I guess we should be more specific here and call this imx8m-phy, or even
imx8mm-phy.
[Richard Zhu] Good suggestions, I think imx8m-phy is better, since the i.MX8MQ/MM/MP
have the similar architecture of the PCIe PHY implementation.
quoted
quoted
diff --git a/drivers/phy/freescale/Kconfig
b/drivers/phy/freescale/Kconfig index 320630ffe3cd..da078a676fbc
100644
help
Enable this to add support for the Mixel DSI PHY as found
on NXP's i.MX8 family of SOCs.
+
+config PHY_FSL_IMX8_PCIE
+ tristate "Freescale i.MX8 PCIE PHY"
+ depends on OF && HAS_IOMEM
+ select GENERIC_PHY
+ default ARCH_MXC
+ help
+ Enable this to add support for the PCIE PHY as found on i.MX8
+ family of SOCs.
diff --git a/drivers/phy/freescale/Makefile
b/drivers/phy/freescale/Makefile index 1d02e3869b45..9fd467b58621
100644
Do we need to enable this clock when the refclock is supplied externally via
the pad?
[Richard Zhu] Good question. I think this clock is not needed anymore if the refclock is sourced from external OSC.
I just enable the PLL2_100Mhz here, since when internal PLL is used as refclock, the pll2_100Mhz should be turned on.
Shall I remove the setting and just keep the callback for further extend usage(internal PLL used as refclk)?
Yes, we should avoid turning on clocks that aren't needed. So the clock
enable here should be dependent on the pad-mode. When the clock is
supplied externally we don't want to enable the internal clock.
Regards,
Lucas
From: Richard Zhu <hongxing.zhu@nxp.com> Date: 2021-10-11 07:47:53
-----Original Message-----
From: Lucas Stach <l.stach@pengutronix.de>
Sent: Tuesday, September 28, 2021 4:44 PM
To: Richard Zhu <hongxing.zhu@nxp.com>; kishon@ti.com; vkoul@kernel.org;
robh@kernel.org; galak@kernel.crashing.org; shawnguo@kernel.org
Cc: linux-phy@lists.infradead.org; devicetree@vger.kernel.org;
linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org;
kernel@pengutronix.de; dl-linux-imx [off-list ref]
Subject: Re: [PATCH v2 4/4] phy: freescale: pcie: initialize the imx8 pcie
standalone phy driver
Hi Richard,
Am Dienstag, dem 28.09.2021 um 07:09 +0000 schrieb Richard Zhu:
quoted
quoted
-----Original Message-----
From: Lucas Stach <l.stach@pengutronix.de>
Sent: Monday, September 27, 2021 4:43 PM
To: Richard Zhu <hongxing.zhu@nxp.com>; kishon@ti.com;
vkoul@kernel.org; robh@kernel.org; galak@kernel.crashing.org;
shawnguo@kernel.org
Cc: linux-phy@lists.infradead.org; devicetree@vger.kernel.org;
linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org;
kernel@pengutronix.de; dl-linux-imx [off-list ref]
Subject: Re: [PATCH v2 4/4] phy: freescale: pcie: initialize the
imx8 pcie standalone phy driver
Am Sonntag, dem 26.09.2021 um 15:39 +0800 schrieb Richard Zhu:
quoted
Add the standalone i.MX8 PCIe PHY driver.
Some reset bits should be manipulated between PHY configurations
and status check(internal PLL is locked or not).
So, do the PHY configuration in the phy_calibrate().
And check the PHY is ready or not in the phy_init().
I would really like to see the PCIe controller driver side of this
also, as it's hard to review standalone. For example I'm not sure if
some of those reset bits should also be driven from the PHY driver,
even if they are currently hooked up to the controller driver.
Also I think the IOMUX GPR register handling belongs in the PHY
driver, as it's configuring the reference clock routing.
[Richard Zhu] Sorry to bring inconvenience to you. I would send out
the v3
patch-set and the i.MX8MM PCIe controller driver patches after I'm
back from the
national holiday tomorrow(about one week).
No problem. :) I'm just pointing out that I probably won't be able to invest
more time reviewing this before I can get the full picture.
quoted
Although most of the IOMUX GPR bits are related to PHY, but there are
some bits are
defined only for controller. For example, the device_type of the
controller, the clkreq#
signal control in L1SS, and so on. We can't encapsulate all the GPR bits
setting into PHY driver.
quoted
So, it's better to let controller driver to handle the general register bits
manipulations.
quoted
How do you think about that?
I still think we should split the drivers along the functional boundaries. It's
quite confusing and probably going to be a maintenance issues when some of
the PHY handling bits are still located in the controller driver, while we have a
separate PHY driver.
As the GPR region is handled by a regmap we should have no issues accessing
even the same register from different drivers. So my vote is on moving the
GPR bits related to PHY clocking to this driver.
[Richard Zhu] Yes, it is. I will consider to let PHY driver manipulate PHY related GPR bits.
help
Enable this to add support for the Mixel DSI PHY as found
on NXP's i.MX8 family of SOCs.
+
+config PHY_FSL_IMX8_PCIE
+ tristate "Freescale i.MX8 PCIE PHY"
+ depends on OF && HAS_IOMEM
+ select GENERIC_PHY
+ default ARCH_MXC
+ help
+ Enable this to add support for the PCIE PHY as found on i.MX8
+ family of SOCs.
diff --git a/drivers/phy/freescale/Makefile
b/drivers/phy/freescale/Makefile index 1d02e3869b45..9fd467b58621
100644
+ } else if (pad_mode == IMX8_PCIE_REFCLK_PAD_OUTPUT) {
+ /* Configure the PHY to output the refclock via pad */
+ writel(ANA_PLL_CLK_OUT_TO_EXT_IO_EN,
+ imx8_phy->base +
Do we need to enable this clock when the refclock is supplied
externally via the pad?
[Richard Zhu] Good question. I think this clock is not needed anymore if the
refclock is sourced from external OSC.
quoted
I just enable the PLL2_100Mhz here, since when internal PLL is used as
refclock, the pll2_100Mhz should be turned on.
quoted
Shall I remove the setting and just keep the callback for further extend
usage(internal PLL used as refclk)?
quoted
Yes, we should avoid turning on clocks that aren't needed. So the clock enable
here should be dependent on the pad-mode. When the clock is supplied
externally we don't want to enable the internal clock.
[Richard Zhu] How about that the dummy clock is used in the dts when "IMX8_PCIE_REFCLK_PAD_INPUT" mode is used?
Thus, we can keep driver simple and aligned, and use different dts definitions to specify different REFCLK modes.