[PATCH v4 0/7] Introduce SpacemiT K1 PCIe phy and host controller

Alex Elder
2025-10-30T22:03:05Z

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/20251017190740.306780-1-elder@riscstar.com/

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/20251013153526.2276556-1-elder@riscstar.com/

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
--
2.48.1