Introduce SpacemiT K1 PCIe phy and host controller
Subsystems (6)
v4 cover Introduce SpacemiT K1 PCIe phy and host controller
This series introduces a PHY driver and a PCIe driver to support PCIe on the SpacemiT K1 SoC. The PCIe implementation is derived from a Synopsys DesignWare PCIe IP. The PHY driver supports one combination PCIe/USB PHY as well as two PCIe-only PHYs. The combo PHY port uses one PCIe lane, and the other two ports each have two lanes. All PCIe ports operate at 5 GT/second.
The PCIe PHYs must be configured using a value that can only be determined using the combo PHY, operating in PCIe mode. To allow that PHY to be used for USB, the calibration step is performed by the PHY driver automatically at probe time. Once this step is done, the PHY can be used for either PCIe or USB.
Version 3 of this series incorporates suggestions made during the review of version 2, and based on some error reports from Aurelien Jarno and Johannes Erdfelt, disabled ASPM L1. Specific highlights are detailed below.
-Alex
This series is available here:
https://github.com/riscstar/linux/tree/outgoing/pcie-v4
Between version 3 and version 4:
- In the DT binding for the PCIe host controlloller, add a new sub-node representing the root port
- Move the phys and supply properties out of the PCIe host controller and into the root port node
- Define the spacemit,apmu property later in the binding and DTS files
- Define the device_type property first in the binding examples and DTS files
- Add root port sub-nodes in the examples and the DTS files
- Select the PCI_PWRCTRL_SLOT config option when PCIE_SPACEMIT_K1 is enabled
- Parse the root port node in the driver, and get the PHY
- Leverage the PCI pwrctrl slot driver to get and enable the regulator
- Don't set num_vectors to 256; just use the default (32)
- Cleaned up some comments, white space, and symbol names based on feedback from Mani
- Add some runtime PM calls to ensure it works propertly
- Add a new post_init callback, which disables ASPM L1 for the link
Here is version 3 of this series:
https://lore.kernel.org/lkml/[email protected]/
Between version 2 and version 3:
- Reviewed-by from Rob added to the first two patches
- The "num-viewport" property has been removed
- The "phy" reset is listed first in the combo PHY binding
- The PHY now requires a resets property to specify the "phy" reset
- The PCIe driver no longer requires a "phy" reset
- The PHY driver now gets and deasserts the reset for all PHYs
- Error handling and "put" of clocks in the PHY driver has been corrected (for clk_bulk_get() rather than clk_bulk_get_all())
Here is version 2 of this series:
https://lore.kernel.org/lkml/[email protected]/
Full details of changes made for version 2 are available there.
Alex Elder (7):
dt-bindings: phy: spacemit: add SpacemiT PCIe/combo PHY
dt-bindings: phy: spacemit: introduce PCIe PHY
dt-bindings: pci: spacemit: introduce PCIe host controller
phy: spacemit: introduce PCIe/combo PHY
PCI: spacemit: introduce SpacemiT PCIe host driver
riscv: dts: spacemit: add a PCIe regulator
riscv: dts: spacemit: PCIe and PHY-related updates
.../bindings/pci/spacemit,k1-pcie-host.yaml | 157 ++++ .../bindings/phy/spacemit,k1-combo-phy.yaml | 114 +++ .../bindings/phy/spacemit,k1-pcie-phy.yaml | 71 ++ .../boot/dts/spacemit/k1-bananapi-f3.dts | 44 ++ arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi | 33 + arch/riscv/boot/dts/spacemit/k1.dtsi | 176 +++++ drivers/pci/controller/dwc/Kconfig | 11 + drivers/pci/controller/dwc/Makefile | 1 + drivers/pci/controller/dwc/pcie-spacemit-k1.c | 349 +++++++++ drivers/phy/Kconfig | 11 + drivers/phy/Makefile | 1 + drivers/phy/phy-spacemit-k1-pcie.c | 670 ++++++++++++++++++ 12 files changed, 1638 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/spacemit,k1-pcie-host.yaml create mode 100644 Documentation/devicetree/bindings/phy/spacemit,k1-combo-phy.yaml create mode 100644 Documentation/devicetree/bindings/phy/spacemit,k1-pcie-phy.yaml create mode 100644 drivers/pci/controller/dwc/pcie-spacemit-k1.c create mode 100644 drivers/phy/phy-spacemit-k1-pcie.c
base-commit: 131f3d9446a6075192cdd91f197989d98302faa6
Signature · 1 line
2.48.1
PATCH v4 1/7 dt-bindings: phy: spacemit: add SpacemiT PCIe/combo PHY
Add the Device Tree binding for the PCIe/USB 3.0 combo PHY found in the SpacemiT K1 SoC. This is one of three PCIe PHYs, and is unusual in that only the combo PHY can perform a calibration step needed to determine settings used by the other two PCIe PHYs.
Calibration must be done with the combo PHY in PCIe mode, and to allow this to occur independent of the eventual use for the PHY (PCIe or USB) some PCIe-related properties must be supplied: clocks; resets; and a syscon phandle.
--- .../bindings/phy/spacemit,k1-combo-phy.yaml | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/spacemit,k1-combo-phy.yaml
Documentation/devicetree/bindings/phy/spacemit,k1-combo-phy.yaml new file +114 -0
@@ -0,0 +1,114 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/spacemit,k1-combo-phy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: SpacemiT K1 PCIe/USB3 Combo PHY + +maintainers: + - Alex Elder <[email protected]> + +description: > + Of the three PHYs on the SpacemiT K1 SoC capable of being used for + PCIe, one is a combo PHY that can also be configured for use by a + USB 3 controller. Using PCIe or USB 3 is a board design decision. + + The combo PHY is also the only PCIe PHY that is able to determine + PCIe calibration values to use, and this must be determined before + the other two PCIe PHYs can be used. This calibration must be + performed with the combo PHY in PCIe mode, and is this is done + when the combo PHY is probed. + + The combo PHY uses an external oscillator as a reference clock. + During normal operation, the PCIe or USB port driver is responsible + for ensuring all other clocks needed by a PHY are enabled, and all + resets affecting the PHY are deasserted. However, for the combo + PHY to perform calibration independent of whether it's later used + for PCIe or USB, all PCIe mode clocks and resets must be defined. + +properties: + compatible: + const: spacemit,k1-combo-phy + + reg: + items: + - description: PHY control registers + + clocks: + items: + - description: External oscillator used by the PHY PLL + - description: DWC PCIe Data Bus Interface (DBI) clock + - description: DWC PCIe application AXI-bus Master interface clock + - description: DWC PCIe application AXI-bus slave interface clock + + clock-names: + items: + - const: refclk + - const: dbi + - const: mstr + - const: slv + + resets: + items: + - description: PHY reset; remains deasserted after initialization + - description: DWC PCIe Data Bus Interface (DBI) reset + - description: DWC PCIe application AXI-bus Master interface reset + - description: DWC PCIe application AXI-bus slave interface reset + + reset-names: + items: + - const: phy + - const: dbi + - const: mstr + - const: slv + + spacemit,apmu: + description: + A phandle that refers to the APMU system controller, whose + regmap is used in setting the mode + $ref: /schemas/types.yaml#/definitions/phandle + + "#phy-cells": + const: 1 + description: + The argument value (PHY_TYPE_PCIE or PHY_TYPE_USB3) determines + whether the PHY operates in PCIe or USB3 mode. + +required: + - compatible + - reg + - clocks + - clock-names + - resets + - reset-names + - spacemit,apmu + - "#phy-cells" + +additionalProperties: false + +examples: + - | + #include <dt-bindings/clock/spacemit,k1-syscon.h> + phy@c0b10000 { + compatible = "spacemit,k1-combo-phy"; + reg = <0xc0b10000 0x1000>; + clocks = <&vctcxo_24m>, + <&syscon_apmu CLK_PCIE0_DBI>, + <&syscon_apmu CLK_PCIE0_MASTER>, + <&syscon_apmu CLK_PCIE0_SLAVE>; + clock-names = "refclk", + "dbi", + "mstr", + "slv"; + resets = <&syscon_apmu RESET_PCIE0_GLOBAL>, + <&syscon_apmu RESET_PCIE0_DBI>, + <&syscon_apmu RESET_PCIE0_MASTER>, + <&syscon_apmu RESET_PCIE0_SLAVE>; + reset-names = "phy", + "dbi", + "mstr", + "slv"; + spacemit,apmu = <&syscon_apmu>; + #phy-cells = <1>; + };
Signature · 1 line
2.48.1
PATCH v4 2/7 dt-bindings: phy: spacemit: introduce PCIe PHY
In reply to Alex ElderAdd the Device Tree binding for two PCIe PHYs present on the SpacemiT K1 SoC. These PHYs are dependent on a separate combo PHY, which determines at probe time the calibration values used by the PCIe-only PHYs.
--- .../bindings/phy/spacemit,k1-pcie-phy.yaml | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 Documentation/devicetree/bindings/phy/spacemit,k1-pcie-phy.yaml
Documentation/devicetree/bindings/phy/spacemit,k1-pcie-phy.yaml new file +71 -0
@@ -0,0 +1,71 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/phy/spacemit,k1-pcie-phy.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: SpacemiT K1 PCIe PHY + +maintainers: + - Alex Elder <[email protected]> + +description: > + Two PHYs on the SpacemiT K1 SoC used for only for PCIe. These + PHYs must be configured using calibration values that are + determined by a third "combo PHY". The combo PHY determines + these calibration values during probe so they can be used for + the two PCIe-only PHYs. + + The PHY uses an external oscillator as a reference clock. During + normal operation, the PCIe host driver is responsible for ensuring + all other clocks needed by a PHY are enabled, and all resets + affecting the PHY are deasserted. + +properties: + compatible: + const: spacemit,k1-pcie-phy + + reg: + items: + - description: PHY control registers + + clocks: + items: + - description: External oscillator used by the PHY PLL + + clock-names: + const: refclk + + resets: + items: + - description: PHY reset; remains deasserted after initialization + + reset-names: + const: phy + + "#phy-cells": + const: 0 + +required: + - compatible + - reg + - clocks + - clock-names + - resets + - reset-names + - "#phy-cells" + +additionalProperties: false + +examples: + - | + #include <dt-bindings/clock/spacemit,k1-syscon.h> + phy@c0c10000 { + compatible = "spacemit,k1-pcie-phy"; + reg = <0xc0c10000 0x1000>; + clocks = <&vctcxo_24m>; + clock-names = "refclk"; + resets = <&syscon_apmu RESET_PCIE1_GLOBAL>; + reset-names = "phy"; + #phy-cells = <0>; + };
Signature · 1 line
2.48.1
PATCH v4 3/7 dt-bindings: pci: spacemit: introduce PCIe host controller
In reply to Alex ElderAdd the Device Tree binding for the PCIe root complex found on the SpacemiT K1 SoC. This device is derived from the Synopsys Designware PCIe IP. It supports up to three PCIe ports operating at PCIe gen 2 link speeds (5 GT/sec). One of the ports uses a combo PHY, which is typically used to support a USB 3 port.
--- .../bindings/pci/spacemit,k1-pcie-host.yaml | 157 ++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/spacemit,k1-pcie-host.yaml
Documentation/devicetree/bindings/pci/spacemit,k1-pcie-host.yaml new file +157 -0
@@ -0,0 +1,157 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pci/spacemit,k1-pcie-host.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: SpacemiT K1 PCI Express Host Controller + +maintainers: + - Alex Elder <[email protected]> + +description: > + The SpacemiT K1 SoC PCIe host controller is based on the Synopsys + DesignWare PCIe IP. The controller uses the DesignWare built-in + MSI interrupt controller, and supports 256 MSIs. + +allOf: + - $ref: /schemas/pci/snps,dw-pcie.yaml# + +properties: + compatible: + const: spacemit,k1-pcie + + reg: + items: + - description: DesignWare PCIe registers + - description: ATU address space + - description: PCIe configuration space + - description: Link control registers + + reg-names: + items: + - const: dbi + - const: atu + - const: config + - const: link + + clocks: + items: + - description: DWC PCIe Data Bus Interface (DBI) clock + - description: DWC PCIe application AXI-bus master interface clock + - description: DWC PCIe application AXI-bus slave interface clock + + clock-names: + items: + - const: dbi + - const: mstr + - const: slv + + resets: + items: + - description: DWC PCIe Data Bus Interface (DBI) reset + - description: DWC PCIe application AXI-bus master interface reset + - description: DWC PCIe application AXI-bus slave interface reset + + reset-names: + items: + - const: dbi + - const: mstr + - const: slv + + interrupts: + items: + - description: Interrupt used for MSIs + + interrupt-names: + const: msi + + spacemit,apmu: + $ref: /schemas/types.yaml#/definitions/phandle-array + description: + A phandle that refers to the APMU system controller, whose + regmap is used in managing resets and link state, along with + and offset of its reset control register. + items: + - items: + - description: phandle to APMU system controller + - description: register offset + +patternProperties: + '^pcie?@': + type: object + $ref: /schemas/pci/pci-pci-bridge.yaml# + + properties: + phys: + maxItems: 1 + + vpcie3v3-supply: + description: + A phandle for 3.3v regulator to use for PCIe + + required: + - phys + - vpcie3v3-supply + + unevaluatedProperties: false + +required: + - clocks + - clock-names + - resets + - reset-names + - interrupts + - interrupt-names + - spacemit,apmu + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/clock/spacemit,k1-syscon.h> + pcie@ca400000 { + device_type = "pci"; + compatible = "spacemit,k1-pcie"; + reg = <0xca400000 0x00001000>, + <0xca700000 0x0001ff24>, + <0x9f000000 0x00002000>, + <0xc0c20000 0x00001000>; + reg-names = "dbi", + "atu", + "config", + "link"; + #address-cells = <3>; + #size-cells = <2>; + ranges = <0x01000000 0x0 0x00000000 0x9f002000 0x0 0x00100000>, + <0x02000000 0x0 0x90000000 0x90000000 0x0 0x0f000000>; + interrupts = <142>; + interrupt-names = "msi"; + clocks = <&syscon_apmu CLK_PCIE1_DBI>, + <&syscon_apmu CLK_PCIE1_MASTER>, + <&syscon_apmu CLK_PCIE1_SLAVE>; + clock-names = "dbi", + "mstr", + "slv"; + resets = <&syscon_apmu RESET_PCIE1_DBI>, + <&syscon_apmu RESET_PCIE1_MASTER>, + <&syscon_apmu RESET_PCIE1_SLAVE>; + reset-names = "dbi", + "mstr", + "slv"; + pinctrl-names = "default"; + pinctrl-0 = <&pcie1_3_cfg>; + spacemit,apmu = <&syscon_apmu 0x3d4>; + + pcie@0 { + device_type = "pci"; + compatible = "pciclass,0604"; + reg = <0x0 0x0 0x0 0x0 0x0>; + bus-range = <0x01 0xff>; + #address-cells = <3>; + #size-cells = <2>; + ranges; + phys = <&pcie1_phy>; + vpcie3v3-supply = <&pcie_vcc_3v3>; + }; + };
Signature · 1 line
2.48.1
Re: [PATCH v4 3/7] dt-bindings: pci: spacemit: introduce PCIe host controller
Quoted 23 lines · Alex Elder
Add the Device Tree binding for the PCIe root complex found on the SpacemiT K1 SoC. This device is derived from the Synopsys Designware PCIe IP. It supports up to three PCIe ports operating at PCIe gen 2 link speeds (5 GT/sec). One of the ports uses a combo PHY, which is typically used to support a USB 3 port.
Signed-off-by Alex Elder <[email protected]>--- .../bindings/pci/spacemit,k1-pcie-host.yaml | 157 ++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/spacemit,k1-pcie-host.yamlDocumentation/devicetree/bindings/pci/spacemit,k1-pcie-host.yaml new file +5
-0@@ -0,0 +1,157 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pci/spacemit,k1-pcie-host.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml#
Documentation/devicetree/bindings/pci/spacemit,k1-pcie-host.yaml line 15
Quoted 10 lines
Documentation/devicetree/bindings/pci/spacemit,k1-pcie-host.yaml new file +10
-0+ +title: SpacemiT K1 PCI Express Host Controller + +maintainers: + - Alex Elder <[email protected]> + +description: > + The SpacemiT K1 SoC PCIe host controller is based on the Synopsys + DesignWare PCIe IP. The controller uses the DesignWare built-in + MSI interrupt controller, and supports 256 MSIs.
Wrap lines at 80.
Quoted 56 lines
Documentation/devicetree/bindings/pci/spacemit,k1-pcie-host.yaml new file +56
-0+ +allOf: + - $ref: /schemas/pci/snps,dw-pcie.yaml# + +properties: + compatible: + const: spacemit,k1-pcie + + reg: + items: + - description: DesignWare PCIe registers + - description: ATU address space + - description: PCIe configuration space + - description: Link control registers + + reg-names: + items: + - const: dbi + - const: atu + - const: config + - const: link + + clocks: + items: + - description: DWC PCIe Data Bus Interface (DBI) clock + - description: DWC PCIe application AXI-bus master interface clock + - description: DWC PCIe application AXI-bus slave interface clock + + clock-names: + items: + - const: dbi + - const: mstr + - const: slv + + resets: + items: + - description: DWC PCIe Data Bus Interface (DBI) reset + - description: DWC PCIe application AXI-bus master interface reset + - description: DWC PCIe application AXI-bus slave interface reset + + reset-names: + items: + - const: dbi + - const: mstr + - const: slv + + interrupts: + items: + - description: Interrupt used for MSIs + + interrupt-names: + const: msi + + spacemit,apmu: + $ref: /schemas/types.yaml#/definitions/phandle-array + description:
Documentation/devicetree/bindings/pci/spacemit,k1-pcie-host.yaml line 81
Quoted 10 lines
Documentation/devicetree/bindings/pci/spacemit,k1-pcie-host.yaml new file +10
-0+ A phandle that refers to the APMU system controller, whose + regmap is used in managing resets and link state, along with + and offset of its reset control register. + items: + - items: + - description: phandle to APMU system controller + - description: register offset + +patternProperties: + '^pcie?@':
It's always PCIe, so drop the '?'.
With that,
Re: [PATCH v4 3/7] dt-bindings: pci: spacemit: introduce PCIe host controller
Quoted 28 lines · Rob Herring
Quoted 27 lines · Alex Elder
Add the Device Tree binding for the PCIe root complex found on the SpacemiT K1 SoC. This device is derived from the Synopsys Designware PCIe IP. It supports up to three PCIe ports operating at PCIe gen 2 link speeds (5 GT/sec). One of the ports uses a combo PHY, which is typically used to support a USB 3 port.
Signed-off-by Alex Elder <[email protected]>--- .../bindings/pci/spacemit,k1-pcie-host.yaml | 157 ++++++++++++++++++ 1 file changed, 157 insertions(+)create mode 100644
Documentation/devicetree/bindings/pci/spacemit,k1-pcie-host.yamlDocumentation/devicetree/bindings/pci/spacemit,k1-pcie-host.yaml new file +9
-0@@ -0,0 +1,157 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pci/spacemit,k1-pcie-host.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: SpacemiT K1 PCI Express Host Controller + +maintainers:
Quoted 8 lines
Documentation/devicetree/bindings/pci/spacemit,k1-pcie-host.yaml line 15
Quoted 6 lines
Documentation/devicetree/bindings/pci/spacemit,k1-pcie-host.yaml new file +6
-0+ - Alex Elder <[email protected]> + +description: > + The SpacemiT K1 SoC PCIe host controller is based on the Synopsys + DesignWare PCIe IP. The controller uses the DesignWare built-in + MSI interrupt controller, and supports 256 MSIs.Wrap lines at 80.
OK.
Quoted 60 lines
Quoted 60 lines
Documentation/devicetree/bindings/pci/spacemit,k1-pcie-host.yaml new file +60
-0+ +allOf: + - $ref: /schemas/pci/snps,dw-pcie.yaml# + +properties: + compatible: + const: spacemit,k1-pcie + + reg: + items: + - description: DesignWare PCIe registers + - description: ATU address space + - description: PCIe configuration space + - description: Link control registers + + reg-names: + items: + - const: dbi + - const: atu + - const: config + - const: link + + clocks: + items: + - description: DWC PCIe Data Bus Interface (DBI) clock + - description: DWC PCIe application AXI-bus master interface clock + - description: DWC PCIe application AXI-bus slave interface clock + + clock-names: + items: + - const: dbi + - const: mstr + - const: slv + + resets: + items: + - description: DWC PCIe Data Bus Interface (DBI) reset + - description: DWC PCIe application AXI-bus master interface reset + - description: DWC PCIe application AXI-bus slave interface reset + + reset-names: + items: + - const: dbi + - const: mstr + - const: slv + + interrupts: + items: + - description: Interrupt used for MSIs + + interrupt-names: + const: msi + + spacemit,apmu: + $ref: /schemas/types.yaml#/definitions/phandle-array + description: + A phandle that refers to the APMU system controller, whose + regmap is used in managing resets and link state, along with + and offset of its reset control register. + items:
Quoted 8 lines
Documentation/devicetree/bindings/pci/spacemit,k1-pcie-host.yaml line 81
Quoted 6 lines
Documentation/devicetree/bindings/pci/spacemit,k1-pcie-host.yaml new file +6
-0+ - items: + - description: phandle to APMU system controller + - description: register offset + +patternProperties: + '^pcie?@':It's always PCIe, so drop the '?'.
I'll fix that.
Quoted 3 lines
With that,
Reviewed-by Rob Herring (Arm) <[email protected]>
Thanks for the review.
-Alex
PATCH v4 4/7 phy: spacemit: introduce PCIe/combo PHY
In reply to Alex ElderIntroduce a driver that supports three PHYs found on the SpacemiT K1 SoC. The first PHY is a combo PHY that can be configured for use for either USB 3 or PCIe. The other two PHYs support PCIe only.
All three PHYs must be programmed with an 8 bit receiver termination value, which must be determined dynamically. Only the combo PHY is able to determine this value. The combo PHY performs a special calibration step at probe time to discover this, and that value is used to program each PHY that operates in PCIe mode. The combo PHY must therefore be probed before either of the PCIe-only PHYs will be used.
Each PHY has an internal PLL driven from an external oscillator. This PLL started when the PHY is first initialized, and stays on thereafter.
During normal operation, the USB or PCIe driver using the PHY must ensure (other) clocks and resets are set up properly.
However PCIe mode clocks are enabled and resets are de-asserted temporarily by this driver to perform the calibration step on the combo PHY.
--- drivers/phy/Kconfig | 11 + drivers/phy/Makefile | 1 + drivers/phy/phy-spacemit-k1-pcie.c | 670 +++++++++++++++++++++++++++++ 3 files changed, 682 insertions(+) create mode 100644 drivers/phy/phy-spacemit-k1-pcie.c
drivers/phy/Kconfig +11 -0
@@ -101,6 +101,17 @@ config PHY_NXP_PTN3222 schemes. It supports all three USB 2.0 data rates: Low Speed, Full Speed and High Speed. +config PHY_SPACEMIT_K1_PCIE + tristate "PCIe and combo PHY driver for the SpacemiT K1 SoC" + depends on ARCH_SPACEMIT || COMPILE_TEST + depends on HAS_IOMEM + depends on OF + select GENERIC_PHY + default ARCH_SPACEMIT + help + Enable support for the PCIe and USB 3 combo PHY and two + PCIe-only PHYs used in the SpacemiT K1 SoC. + source "drivers/phy/allwinner/Kconfig" source "drivers/phy/amlogic/Kconfig" source "drivers/phy/broadcom/Kconfig"
drivers/phy/Makefile +1 -0
@@ -13,6 +13,7 @@ obj-$(CONFIG_PHY_SNPS_EUSB2) += phy-snps-eusb2.o obj-$(CONFIG_USB_LGM_PHY) += phy-lgm-usb.o obj-$(CONFIG_PHY_AIROHA_PCIE) += phy-airoha-pcie.o obj-$(CONFIG_PHY_NXP_PTN3222) += phy-nxp-ptn3222.o +obj-$(CONFIG_PHY_SPACEMIT_K1_PCIE) += phy-spacemit-k1-pcie.o obj-y += allwinner/ \ amlogic/ \ broadcom/ \
drivers/phy/phy-spacemit-k1-pcie.c new file +670 -0
670 lines not on this page · raw message
Signature · 1 line
2.48.1
kernel test robot
build botRe: [PATCH v4 4/7] phy: spacemit: introduce PCIe/combo PHY
kernel test robot noticed the following build errors:
Hi Alex,
kernel test robot noticed the following build errors:
[auto build test ERROR on 131f3d9446a6075192cdd91f197989d98302faa6]
url: https://github.com/intel-lab-lkp/linux/commits/Alex-Elder/dt-bindings-phy-spacemit-add-SpacemiT-PCIe-combo-PHY/20251031-060541 base: 131f3d9446a6075192cdd91f197989d98302faa6 patch link: https://lore.kernel.org/r/20251030220259.1063792-5-elder%40riscstar.com patch subject: [PATCH v4 4/7] phy: spacemit: introduce PCIe/combo PHY config: sh-allyesconfig (https://download.01.org/0day-ci/archive/20251103/[email protected]/config) compiler: sh4-linux-gcc (GCC) 15.1.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251103/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
sh4-linux-ld: drivers/phy/phy-spacemit-k1-pcie.o: in function `k1_pcie_phy_probe':
>> phy-spacemit-k1-pcie.c:(.text+0x7e4): undefined reference to `devm_clk_hw_register' >> sh4-linux-ld: phy-spacemit-k1-pcie.c:(.text+0x7ec): undefined reference to `devm_clk_hw_get_clk'
sh4-linux-ld: drivers/net/phy/air_en8811h.o: in function `en8811h_resume':
air_en8811h.c:(.text+0x948): undefined reference to `clk_restore_context'
sh4-linux-ld: drivers/net/phy/air_en8811h.o: in function `en8811h_suspend':
air_en8811h.c:(.text+0x984): undefined reference to `clk_save_context'
sh4-linux-ld: drivers/media/i2c/tc358746.o: in function `tc358746_probe':
tc358746.c:(.text+0x1a68): undefined reference to `devm_clk_hw_register'
sh4-linux-ld: tc358746.c:(.text+0x1a74): undefined reference to `devm_of_clk_add_hw_provider'
sh4-linux-ld: tc358746.c:(.text+0x1a78): undefined reference to `of_clk_hw_simple_get'
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH v4 4/7] phy: spacemit: introduce PCIe/combo PHY
In reply to Alex Elderkernel test robot noticed the following build errors:
Hi Alex,
kernel test robot noticed the following build errors:
[auto build test ERROR on 131f3d9446a6075192cdd91f197989d98302faa6]
url: https://github.com/intel-lab-lkp/linux/commits/Alex-Elder/dt-bindings-phy-spacemit-add-SpacemiT-PCIe-combo-PHY/20251031-060541 base: 131f3d9446a6075192cdd91f197989d98302faa6 patch link: https://lore.kernel.org/r/20251030220259.1063792-5-elder%40riscstar.com patch subject: [PATCH v4 4/7] phy: spacemit: introduce PCIe/combo PHY config: sh-allmodconfig (https://download.01.org/0day-ci/archive/20251103/[email protected]/config) compiler: sh4-linux-gcc (GCC) 15.1.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251103/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>, old ones prefixed by <<):
>> ERROR: modpost: "devm_clk_hw_register" [drivers/phy/phy-spacemit-k1-pcie.ko] undefined! >> ERROR: modpost: "devm_clk_hw_get_clk" [drivers/phy/phy-spacemit-k1-pcie.ko] undefined!
ERROR: modpost: "clk_save_context" [drivers/net/phy/air_en8811h.ko] undefined!
ERROR: modpost: "clk_restore_context" [drivers/net/phy/air_en8811h.ko] undefined!
ERROR: modpost: "__delay" [drivers/net/mdio/mdio-cavium.ko] undefined!
ERROR: modpost: "devm_of_clk_add_hw_provider" [drivers/media/i2c/tc358746.ko] undefined!
ERROR: modpost: "devm_clk_hw_register" [drivers/media/i2c/tc358746.ko] undefined!
ERROR: modpost: "of_clk_hw_simple_get" [drivers/media/i2c/tc358746.ko] undefined!
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
PATCH v4 5/7 PCI: spacemit: introduce SpacemiT PCIe host driver
In reply to Alex ElderIntroduce a driver for the PCIe host controller found in the SpacemiT K1 SoC. The hardware is derived from the Synopsys DesignWare PCIe IP. The driver supports three PCIe ports that operate at PCIe gen2 transfer rates (5 GT/sec). The first port uses a combo PHY, which may be configured for use for USB 3 instead.
--- drivers/pci/controller/dwc/Kconfig | 11 + drivers/pci/controller/dwc/Makefile | 1 + drivers/pci/controller/dwc/pcie-spacemit-k1.c | 349 ++++++++++++++++++ 3 files changed, 361 insertions(+) create mode 100644 drivers/pci/controller/dwc/pcie-spacemit-k1.c
drivers/pci/controller/dwc/Kconfig +11 -0
@@ -509,6 +509,17 @@ config PCI_KEYSTONE_EP on DesignWare hardware and therefore the driver re-uses the DesignWare core functions to implement the driver. +config PCIE_SPACEMIT_K1 + tristate "SpacemiT K1 PCIe controller (host mode)" + depends on ARCH_SPACEMIT || COMPILE_TEST + depends on PCI && OF && HAS_IOMEM + select PCIE_DW_HOST + select PCI_PWRCTRL_SLOT + default ARCH_SPACEMIT + help + Enables support for the PCIe controller in the K1 SoC operating + in host mode. + config PCIE_VISCONTI_HOST bool "Toshiba Visconti PCIe controller" depends on ARCH_VISCONTI || COMPILE_TEST
drivers/pci/controller/dwc/Makefile +1 -0
@@ -31,6 +31,7 @@ obj-$(CONFIG_PCIE_UNIPHIER) += pcie-uniphier.o obj-$(CONFIG_PCIE_UNIPHIER_EP) += pcie-uniphier-ep.o obj-$(CONFIG_PCIE_VISCONTI_HOST) += pcie-visconti.o obj-$(CONFIG_PCIE_RCAR_GEN4) += pcie-rcar-gen4.o +obj-$(CONFIG_PCIE_SPACEMIT_K1) += pcie-spacemit-k1.o obj-$(CONFIG_PCIE_STM32_HOST) += pcie-stm32.o obj-$(CONFIG_PCIE_STM32_EP) += pcie-stm32-ep.o
drivers/pci/controller/dwc/pcie-spacemit-k1.c new file +349 -0
349 lines not on this page · raw message
Signature · 1 line
2.48.1
Re: [PATCH v4 5/7] PCI: spacemit: introduce SpacemiT PCIe host driver
In subject, capitalize "introduce" to match history. Or you could just use "Add ...", which has the advantage of being shorter.
Quoted 6 lines · Alex Elder
Introduce a driver for the PCIe host controller found in the SpacemiT K1 SoC. The hardware is derived from the Synopsys DesignWare PCIe IP. The driver supports three PCIe ports that operate at PCIe gen2 transfer rates (5 GT/sec). The first port uses a combo PHY, which may be configured for use for USB 3 instead.
...
I guess this doesn't support INTx interrupts at all?
drivers/pci/controller/dwc/Kconfig config PCI_KEYSTONE_EP · line 513
Quoted 7 lines
+++ b/drivers/pci/controller/dwc/Kconfig
drivers/pci/controller/dwc/Kconfig +2
-0@@ -509,6 +509,17 @@ config PCI_KEYSTONE_EP on DesignWare hardware and therefore the driver re-uses the DesignWare core functions to implement the driver. +config PCIE_SPACEMIT_K1 + tristate "SpacemiT K1 PCIe controller (host mode)"
Move this to keep the menu items alphabetized by vendor.
drivers/pci/controller/dwc/Kconfig config PCI_KEYSTONE_EP · line 515
Quoted 2 lines
drivers/pci/controller/dwc/Kconfig +2
-0+ depends on ARCH_SPACEMIT || COMPILE_TEST + depends on PCI && OF && HAS_IOMEM
I don't think you need PCI or OF.
drivers/pci/controller/dwc/Kconfig config PCI_KEYSTONE_EP · line 521
Quoted 6 lines
drivers/pci/controller/dwc/Kconfig +6
-0+ select PCIE_DW_HOST + select PCI_PWRCTRL_SLOT + default ARCH_SPACEMIT + help + Enables support for the PCIe controller in the K1 SoC operating + in host mode.
Most help text includes both the vendor and the product line names.
Re: [PATCH v4 5/7] PCI: spacemit: introduce SpacemiT PCIe host driver
Quoted 2 lines · Bjorn Helgaas
In subject, capitalize "introduce" to match history. Or you could just use "Add ...", which has the advantage of being shorter.
OK. I'll capitalize all of them in this series.
Quoted 9 lines · Alex Elder
Quoted 6 lines
Introduce a driver for the PCIe host controller found in the SpacemiT K1 SoC. The hardware is derived from the Synopsys DesignWare PCIe IP. The driver supports three PCIe ports that operate at PCIe gen2 transfer rates (5 GT/sec). The first port uses a combo PHY, which may be configured for use for USB 3 instead.
...I guess this doesn't support INTx interrupts at all?
It can, but I removed that support first to simplify the task of converting the original code, and second because I had no way to test it. I planned for it to be added at a future date.
Quoted 9 lines
drivers/pci/controller/dwc/Kconfig config PCI_KEYSTONE_EP · line 513
Quoted 7 lines
+++ b/drivers/pci/controller/dwc/Kconfig
drivers/pci/controller/dwc/Kconfig +2
-0@@ -509,6 +509,17 @@ config PCI_KEYSTONE_EP on DesignWare hardware and therefore the driver re-uses the DesignWare core functions to implement the driver. +config PCIE_SPACEMIT_K1 + tristate "SpacemiT K1 PCIe controller (host mode)"Move this to keep the menu items alphabetized by vendor.
OK. I was going by Kconfig option name, but now I see what you mean.
I'll put it between PCIE_SOPHGO_DW and PCIE_SPEAR13XX.
Quoted 4 lines
drivers/pci/controller/dwc/Kconfig config PCI_KEYSTONE_EP · line 515
Quoted 2 lines
drivers/pci/controller/dwc/Kconfig +2
-0+ depends on ARCH_SPACEMIT || COMPILE_TEST + depends on PCI && OF && HAS_IOMEMI don't think you need PCI or OF.
You're right. PCI for sure, but it doesn't look like I make an direct OF calls either. I'll drop them both.
Quoted 8 lines
drivers/pci/controller/dwc/Kconfig config PCI_KEYSTONE_EP · line 521
Quoted 6 lines
drivers/pci/controller/dwc/Kconfig +6
-0+ select PCIE_DW_HOST + select PCI_PWRCTRL_SLOT + default ARCH_SPACEMIT + help + Enables support for the PCIe controller in the K1 SoC operating + in host mode.Most help text includes both the vendor and the product line names.
I guess I didn't include "SpacemiT". I'll add that, and will try to come up with a few more words in the description.
Thanks for your quick response.
-Alex
Re: [PATCH v4 5/7] PCI: spacemit: introduce SpacemiT PCIe host driver
In reply to Alex ElderHi Alex,
Quoted 1 line · Alex Elder
+/* Disable ASPM L1 for now, until reported errors can be reproduced */
Thanks for adding this function.
drivers/pci/controller/dwc/pcie-spacemit-k1.c line 176
Quoted 12 lines
drivers/pci/controller/dwc/pcie-spacemit-k1.c new file +12
-0+static void k1_pcie_post_init (struct dw_pcie_rp *pp) +{ +struct dw_pcie *pci =to_dw_pcie_from_pp (pp); +u8 offset; +u32 val; + + offset =dw_pcie_find_capability (pci,PCI_CAP_ID_EXP ); + +dw_pcie_dbi_ro_wr_en (pci); + +/* Turn off ASPM L1 for the link */ + val =readl (pci->dbi_base + offset +PCI_EXP_LNKCAP );
Why not using dw_pcie_readl_dbi() instead?
drivers/pci/controller/dwc/pcie-spacemit-k1.c line 178
Quoted 2 lines
drivers/pci/controller/dwc/pcie-spacemit-k1.c new file +2
-0+ val &= ~PCI_EXP_LNKCAP_ASPM_L1 ; +writel (val, pci->dbi_base + offset +PCI_EXP_LNKCAP );
And here dw_pcie_writel_dbi()?
Quoted 11 lines
drivers/pci/controller/dwc/pcie-spacemit-k1.c new file +11
-0+ +dw_pcie_dbi_ro_wr_dis (pci); +} + +static void k1_pcie_deinit (struct dw_pcie_rp *pp) +{ +struct dw_pcie *pci =to_dw_pcie_from_pp (pp); +struct k1_pcie *k1 =to_k1_pcie (pci); + +/* Assert fundamental reset (drive PERST# low) */ + regmap_set_bits(k1->pmu, k1->pmu_off + PCIE_CLK_RESET_CONTROL,
drivers/pci/controller/dwc/pcie-spacemit-k1.c line 199
Quoted 10 lines
drivers/pci/controller/dwc/pcie-spacemit-k1.c new file +10
-0+ PCIE_RC_PERST); + +phy_exit (k1->phy); + +k1_pcie_disable_resources (k1); +} + +static const struct dw_pcie_host_ops k1_pcie_host_ops = { + .init = k1_pcie_init, + .post_init = k1_pcie_post_init,
Unfortunately, while I can see the effect of the change with for instance lspci -vvv, this happens way too late in the device scan process, i.e. after pcie_aspm_override_default_link_state() and causes L1 to still be enabled.
I have tried to move it earlier, in k1_pcie_init() after writing the vendor and device IDs. This works as long as "nvme scan" is run in U-Boot. But if I don't run this command, it seems that the change is ignored or lost (i.e. I can still see L1 enabled with lspci -vvv).
Moving it at the end of k1_pcie_init() works fine, like moving it at the beginning of k1_pcie_start_link(). But my knowledge is too limited to know where is the correct place.
Regards
Aurelien
Signature · 2 lines
Aurelien Jarno GPG: 4096R/1DDD8C9B [email protected] http://aurel32.net
Re: [PATCH v4 5/7] PCI: spacemit: introduce SpacemiT PCIe host driver
Quoted 45 lines · Aurelien Jarno
Hi Alex,
Quoted 1 line · Alex Elder
+/* Disable ASPM L1 for now, until reported errors can be reproduced */
Thanks for adding this function.
drivers/pci/controller/dwc/pcie-spacemit-k1.c line 176
Quoted 12 lines
drivers/pci/controller/dwc/pcie-spacemit-k1.c new file +12
-0+static void k1_pcie_post_init (struct dw_pcie_rp *pp) +{ +struct dw_pcie *pci =to_dw_pcie_from_pp (pp); +u8 offset; +u32 val; + + offset =dw_pcie_find_capability (pci,PCI_CAP_ID_EXP ); + +dw_pcie_dbi_ro_wr_en (pci); + +/* Turn off ASPM L1 for the link */ + val =readl (pci->dbi_base + offset +PCI_EXP_LNKCAP );Why not using
dw_pcie_readl_dbi()instead?drivers/pci/controller/dwc/pcie-spacemit-k1.c line 178
Quoted 2 lines
drivers/pci/controller/dwc/pcie-spacemit-k1.c new file +2
-0+ val &= ~PCI_EXP_LNKCAP_ASPM_L1 ; +writel (val, pci->dbi_base + offset +PCI_EXP_LNKCAP );And here
dw_pcie_writel_dbi()?Quoted 18 lines
drivers/pci/controller/dwc/pcie-spacemit-k1.c new file +18
-0+ +dw_pcie_dbi_ro_wr_dis (pci); +} + +static void k1_pcie_deinit (struct dw_pcie_rp *pp) +{ +struct dw_pcie *pci =to_dw_pcie_from_pp (pp); +struct k1_pcie *k1 =to_k1_pcie (pci); + +/* Assert fundamental reset (drive PERST# low) */ +regmap_set_bits (k1->pmu, k1->pmu_off +PCIE_CLK_RESET_CONTROL , +PCIE_RC_PERST ); + +phy_exit (k1->phy); + +k1_pcie_disable_resources (k1); +} +
Quoted 8 lines
drivers/pci/controller/dwc/pcie-spacemit-k1.c line 199
Quoted 3 lines
drivers/pci/controller/dwc/pcie-spacemit-k1.c new file +3
-0+static const struct dw_pcie_host_ops k1_pcie_host_ops = { + .init = k1_pcie_init, + .post_init = k1_pcie_post_init,Unfortunately, while I can see the effect of the change with for instance lspci -vvv, this happens way too late in the device scan process, i.e. after
pcie_aspm_override_default_link_state()and causes L1 to still be enabled.
OK thanks for this information. I am going to contact you privately to get more information on your errors (and those Johannes is reporting) so that I can try to resolve them before I post the next version of this patch series.
-Alex
Quoted 13 lines
I have tried to move it earlier, in
k1_pcie_init()after writing the vendor and device IDs. This works as long as "nvme scan" is run in U-Boot. But if I don't run this command, it seems that the change is ignored or lost (i.e. I can still see L1 enabled with lspci -vvv).Moving it at the end of
k1_pcie_init()works fine, like moving it at the beginning ofk1_pcie_start_link(). But my knowledge is too limited to know where is the correct place.Regards
Aurelien
PATCH v4 6/7 riscv: dts: spacemit: add a PCIe regulator
In reply to Alex ElderDefine a 3.3v fixed voltage regulator to be used by PCIe on the Banana Pi BPI-F3. On this platform, this regulator is always on.
--- arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +8 -0
@@ -33,6 +33,14 @@ led1 { }; }; + pcie_vcc_3v3: pcie-vcc3v3 { + compatible = "regulator-fixed"; + regulator-name = "PCIE_VCC3V3"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + }; + reg_dc_in: dc-in-12v { compatible = "regulator-fixed"; regulator-name = "dc_in_12v";
Signature · 1 line
2.48.1
PATCH v4 7/7 riscv: dts: spacemit: PCIe and PHY-related updates
In reply to Alex ElderDefine PCIe and PHY-related Device Tree nodes for the SpacemiT K1 SoC.
Enable the combo PHY and the two PCIe-only PHYs on the Banana Pi BPI-F3 board. The combo PHY is used for USB on this board, and that will be enabled when USB 3 support is accepted.
The combo PHY must perform a calibration step to determine configuration values used by the PCIe-only PHYs. As a result, it must be enabled if either of the other two PHYs is enabled.
--- .../boot/dts/spacemit/k1-bananapi-f3.dts | 36 ++++ arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi | 33 ++++ arch/riscv/boot/dts/spacemit/k1.dtsi | 176 ++++++++++++++++++ 3 files changed, 245 insertions(+)
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +36 -0
@@ -61,6 +61,12 @@ reg_vcc_4v: vcc-4v { }; }; +&combo_phy { + pinctrl-names = "default"; + pinctrl-0 = <&pcie0_3_cfg>; + status = "okay"; +}; + &emmc { bus-width = <8>; mmc-hs400-1_8v;
@@ -266,6 +272,36 @@ dldo7 { }; }; +&pcie1_phy { + pinctrl-names = "default"; + pinctrl-0 = <&pcie1_3_cfg>; + status = "okay"; +}; + +&pcie1_port { + phys = <&pcie1_phy>; + vpcie3v3-supply = <&pcie_vcc_3v3>; +}; + +&pcie1 { + status = "okay"; +}; + +&pcie2_phy { + pinctrl-names = "default"; + pinctrl-0 = <&pcie2_4_cfg>; + status = "okay"; +}; + +&pcie2_port { + phys = <&pcie2_phy>; + vpcie3v3-supply = <&pcie_vcc_3v3>; +}; + +&pcie2 { + status = "okay"; +}; + &uart0 { pinctrl-names = "default"; pinctrl-0 = <&uart0_2_cfg>;
arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi +33 -0
@@ -509,6 +509,39 @@ uart9-2-pins { }; }; + pcie0_3_cfg: pcie0-3-cfg { + pcie0-3-pins { + pinmux = <K1_PADCONF(54, 3)>, /* PERST# */ + <K1_PADCONF(55, 3)>, /* WAKE# */ + <K1_PADCONF(53, 3)>; /* CLKREQ# */ + + bias-pull-up = <0>; + drive-strength = <21>; + }; + }; + + pcie1_3_cfg: pcie1-3-cfg { + pcie1-3-pins { + pinmux = <K1_PADCONF(59, 4)>, /* PERST# */ + <K1_PADCONF(60, 4)>, /* WAKE# */ + <K1_PADCONF(61, 4)>; /* CLKREQ# */ + + bias-pull-up = <0>; + drive-strength = <21>; + }; + }; + + pcie2_4_cfg: pcie2-4-cfg { + pcie2-4-pins { + pinmux = <K1_PADCONF(62, 4)>, /* PERST# */ + <K1_PADCONF(112, 3)>, /* WAKE# */ + <K1_PADCONF(117, 4)>; /* CLKREQ# */ + + bias-pull-up = <0>; + drive-strength = <21>; + }; + }; + pwm14_1_cfg: pwm14-1-cfg { pwm14-1-pins { pinmux = <K1_PADCONF(44, 4)>;
arch/riscv/boot/dts/spacemit/k1.dtsi +176 -0
194 lines not on this page · raw message
Signature · 1 line
2.48.1