Skip to contentSkip to conversation

Add UFS Host driver support for SpacemiT K3 SoC

PATCH Superseded Yixun Lan 5 participants 11 messages Sep 8 – Sep 14

Subsystems (5)

v4 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

Yixun Lan

author maintainer
#0 lore raw

v4 cover Add UFS Host driver support for SpacemiT K3 SoC

This series try to add UFS support for SpacemiT K3 SoC, the controller components consists of System Bus Interface Unit, UFS Host Controller Interface, UFS Transport Protocol Layer, UFS Host Registers, Device Management Entity (DME), Transport Layer, Network Layer, Data Link Layer, PHY Adapter Layer, and M-PHY Interface. A more detail functional block diagram can be found in SpacemiT website, chapter 9.7.3 [1]

One known issue is that the device will occasionally raise BKOPS interrupt when doing some high load test, log from dmesg shows

[  806.710763] ufshcd-spacemit c0e00000.ufshc: ufshcd_bkops_exception_event_handler: device raised urgent BKOPS exception for bkops status 1

---
Changes in v4:
- fix clock and reset settings
- drop function which retrieve value of tx_lanes
- propagate return error of ufs_spacemit_dme_set()
- check return value ufs_spacemit_check_hibern8()
- drop call to ufshcd_vops_phy_initialization()
- handle compiling warning if CONFIG_OF not enabled
add __maybe_unused to ufs_spacemit_of_match
- Link to v3: https://patch.msgid.link/[email protected]

Changes in v3:
- collect tags
- fix dt-binding warning reported-by sashiko
- fix low freq in opp-2 table
- fix err checking in check_hibern8()
- propagate err code in link_startup_notify()
- update documents for event_notify()
- ufs clock driver is merged into v7.3-rc1, update cover letter
- Link to v2: https://patch.msgid.link/[email protected]

Changes in v2:
- fix missing interrupts property
- move ufs node to k3-com260.dtsi
- convert freq-table-hz to operating-points-v2
- rework reset_control, fix header and drop global variable
- drop dump_host_regs() debug interface
- converge and refactor dme_set() operations
- massive reduce of busy delay() loops
- drop vendor specific hce_enable_notify(), fallback to default
- drop unused member from struct ufs_spacemit_host
- add COMPILE_TEST support to Kconfig
- comment style fix
- Link to v1: https://patch.msgid.link/[email protected]

---
Yixun Lan (3):
scsi: ufs: spacemit: dt-bindings: Add UFS controller for K3 SoC
scsi: ufs: spacemit: k3: Add UFS Host Controller driver
riscv: dts: spacemit: k3: Add UFS support

 .../devicetree/bindings/ufs/spacemit,k3-ufshc.yaml |  56 ++
 arch/riscv/boot/dts/spacemit/k3-com260.dtsi        |   4 +
 arch/riscv/boot/dts/spacemit/k3-pico-itx.dts       |   4 +
 arch/riscv/boot/dts/spacemit/k3.dtsi               |  22 +
 drivers/ufs/host/Kconfig                           |  12 +
 drivers/ufs/host/Makefile                          |   1 +
 drivers/ufs/host/ufs-spacemit.c                    | 678 +++++++++++++++++++++
 drivers/ufs/host/ufs-spacemit.h                    |  79 +++
 8 files changed, 856 insertions(+)

---
base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
change-id: 20260605-08-k3-ufs-support-c8b308e415e2

Best regards,

Signature · 1 line
Yixun Lan <[email protected]>
author maintainer
#1 lore raw

PATCH v4 1/3 scsi: ufs: spacemit: dt-bindings: Add UFS controller for K3 SoC

Document the compatible for UFS (Universal Flash Storage) Host Controller which found in SpacemiT K3 SoC chip. Its features are listed below:

- Compliant with MIPI UniPro v1.61 specification.
- Compliant with M-PHY v3.0 specification.
- Compliant with UFS HCI v2.1 specification.
- Supports up to 2 Tx and 2 Rx lanes, up to HS-GEAR3 5.8 Gbps per lane.
- Supports standard low-power hibernate to reduce power consumption.

---
 .../devicetree/bindings/ufs/spacemit,k3-ufshc.yaml | 56 ++++++++++++++++++++++
 1 file changed, 56 insertions(+)
Documentation/devicetree/bindings/ufs/spacemit,k3-ufshc.yaml new file +56 -0
new file mode 100644
index 000000000000..dda533c852e8
@@ -0,0 +1,56 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/ufs/spacemit,k3-ufshc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: SpacemiT K3 SoC UFS Host Controller
+
+maintainers:
+  - Yixun Lan <[email protected]>
+
+properties:
+  compatible:
+    const: spacemit,k3-ufshc
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 2
+
+  clock-names:
+    items:
+      - const: aclk
+      - const: ref_clk
+
+  resets:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - resets
+
+allOf:
+  - $ref: ufs-common.yaml
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/spacemit,k3-clocks.h>
+    #include <dt-bindings/reset/spacemit,k3-resets.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+    ufs@c0e00000 {
+        compatible = "spacemit,k3-ufshc";
+        reg = <0xc0e00000 0x40000>;
+        clocks = <&syscon_apmu CLK_APMU_UFS_ACLK>,
+                 <&syscon_apmu CLK_APMU_UFS_REFCLK>;
+        clock-names = "aclk", "ref_clk";
+        resets = <&syscon_apmu RESET_APMU_UFS_ACLK>;
+        interrupts = <135 IRQ_TYPE_LEVEL_HIGH>;
+        lanes-per-direction = <2>;
+    };
Signature · 1 line
2.55.0
#2 lore raw

Re: [PATCH v4 1/3] scsi: ufs: spacemit: dt-bindings: Add UFS controller for K3 SoC

Quoted 35 lines · Yixun Lan

Document the compatible for UFS (Universal Flash Storage) Host Controller which found in SpacemiT K3 SoC chip. Its features are listed below:

- Compliant with MIPI UniPro v1.61 specification.
- Compliant with M-PHY v3.0 specification.
- Compliant with UFS HCI v2.1 specification.
- Supports up to 2 Tx and 2 Rx lanes, up to HS-GEAR3 5.8 Gbps per lane.
- Supports standard low-power hibernate to reduce power consumption.

---
 .../devicetree/bindings/ufs/spacemit,k3-ufshc.yaml | 56 ++++++++++++++++++++++
 1 file changed, 56 insertions(+)
Documentation/devicetree/bindings/ufs/spacemit,k3-ufshc.yaml new file +15 -0
new file mode 100644
index 000000000000..dda533c852e8
@@ -0,0 +1,56 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/ufs/spacemit,k3-ufshc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: SpacemiT K3 SoC UFS Host Controller
+
+maintainers:
+  - Yixun Lan <[email protected]>
+
+properties:
+  compatible:
+    const: spacemit,k3-ufshc
+

Documentation/devicetree/bindings/ufs/spacemit,k3-ufshc.yaml line 25

Quoted 10 lines
Documentation/devicetree/bindings/ufs/spacemit,k3-ufshc.yaml new file +10 -0
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 2
+
+  clock-names:
+    items:
+      - const: aclk
+      - const: ref_clk

It's the usual refrain here, about having "clk" in clock names. "axi" and "ref" perhaps?
Otherwise, looks fine to me.

pw-bot: changes-requested

Thanks,
Conor.

Quoted 35 lines
Documentation/devicetree/bindings/ufs/spacemit,k3-ufshc.yaml new file +31 -0
+
+  resets:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - resets
+
+allOf:
+  - $ref: ufs-common.yaml
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/spacemit,k3-clocks.h>
+    #include <dt-bindings/reset/spacemit,k3-resets.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+    ufs@c0e00000 {
+        compatible = "spacemit,k3-ufshc";
+        reg = <0xc0e00000 0x40000>;
+        clocks = <&syscon_apmu CLK_APMU_UFS_ACLK>,
+                 <&syscon_apmu CLK_APMU_UFS_REFCLK>;
+        clock-names = "aclk", "ref_clk";
+        resets = <&syscon_apmu RESET_APMU_UFS_ACLK>;
+        interrupts = <135 IRQ_TYPE_LEVEL_HIGH>;
+        lanes-per-direction = <2>;
+    };
Signature · 2 lines
-- 
2.55.0
author maintainer
#3 lore raw

Re: [PATCH v4 1/3] scsi: ufs: spacemit: dt-bindings: Add UFS controller for K3 SoC

Hi Conor,

Quoted 41 lines · Conor Dooley
Quoted 40 lines · Yixun Lan

Document the compatible for UFS (Universal Flash Storage) Host Controller which found in SpacemiT K3 SoC chip. Its features are listed below:

- Compliant with MIPI UniPro v1.61 specification.
- Compliant with M-PHY v3.0 specification.
- Compliant with UFS HCI v2.1 specification.
- Supports up to 2 Tx and 2 Rx lanes, up to HS-GEAR3 5.8 Gbps per lane.
- Supports standard low-power hibernate to reduce power consumption.

---
 .../devicetree/bindings/ufs/spacemit,k3-ufshc.yaml | 56 ++++++++++++++++++++++
 1 file changed, 56 insertions(+)
Documentation/devicetree/bindings/ufs/spacemit,k3-ufshc.yaml new file +20 -0
new file mode 100644
index 000000000000..dda533c852e8
@@ -0,0 +1,56 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/ufs/spacemit,k3-ufshc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: SpacemiT K3 SoC UFS Host Controller
+
+maintainers:
+  - Yixun Lan <[email protected]>
+
+properties:
+  compatible:
+    const: spacemit,k3-ufshc
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 2
Quoted 8 lines

Documentation/devicetree/bindings/ufs/spacemit,k3-ufshc.yaml line 25

Quoted 5 lines
Documentation/devicetree/bindings/ufs/spacemit,k3-ufshc.yaml new file +5 -0
+
+  clock-names:
+    items:
+      - const: aclk
+      - const: ref_clk

It's the usual refrain here, about having "clk" in clock names. "axi" and "ref" perhaps?

Yes, it's axi clock, I agree and will adjust in next version

Quoted 2 lines

Otherwise, looks fine to me.

Ok, thanks

Signature · 1 line
Yixun Lan (dlan)
author maintainer
#4 lore raw

PATCH v4 2/3 scsi: ufs: spacemit: k3: Add UFS Host Controller driver

In reply to Yixun Lan

SpacemiT K3 SoC consist of UFS (Universal Flash Storage) Host Controller which has features compatible with JEDEC UFS 2.2, MIPI UniPro v1.61 and M-PHY v3.0 standard.

---
 drivers/ufs/host/Kconfig        |  12 +
 drivers/ufs/host/Makefile       |   1 +
 drivers/ufs/host/ufs-spacemit.c | 678 ++++++++++++++++++++++++++++++++++++++++
 drivers/ufs/host/ufs-spacemit.h |  79 +++++
 4 files changed, 770 insertions(+)
drivers/ufs/host/Kconfig +12 -0
index ff170c0b6da0..6146872fcecc 100644
@@ -132,6 +132,18 @@ config SCSI_UFS_VARIABLE_SG_ENTRY_SIZE
 	bool
 	default y if SCSI_UFS_EXYNOS && SCSI_UFS_CRYPTO
 
+config SCSI_UFS_SPACEMIT
+	tristate "SpacemiT UFS controller driver"
+	depends on SCSI_UFSHCD_PLATFORM && (ARCH_SPACEMIT || COMPILE_TEST)
+	help
+	  This selects the SpacemiT specific additions to UFSHCD platform driver.
+	  UFS host on SpacemiT needs some vendor specific configuration before
+	  accessing the hardware which includes PHY configuration and vendor
+	  specific registers.
+
+	  Select this if you have UFS controller on SpacemiT chipset.
+	  If unsure, say N.
+
 config SCSI_UFS_SPRD
 	tristate "Unisoc specific hooks to UFS controller platform driver"
 	depends on SCSI_UFSHCD_PLATFORM && (ARCH_SPRD || COMPILE_TEST)
drivers/ufs/host/Makefile +1 -0
index 7d8db67eb23c..a3c447b8fc21 100644
@@ -13,6 +13,7 @@ obj-$(CONFIG_SCSI_UFS_HISI) += ufs-hisi.o
 obj-$(CONFIG_SCSI_UFS_MEDIATEK) += ufs-mediatek.o
 obj-$(CONFIG_SCSI_UFS_RENESAS) += ufs-renesas.o
 obj-$(CONFIG_SCSI_UFS_ROCKCHIP) += ufs-rockchip.o
+obj-$(CONFIG_SCSI_UFS_SPACEMIT) += ufs-spacemit.o
 obj-$(CONFIG_SCSI_UFS_SPRD) += ufs-sprd.o
 obj-$(CONFIG_SCSI_UFS_TI_J721E) += ti-j721e-ufs.o
 obj-$(CONFIG_SCSI_UFS_AMD_VERSAL2) += ufs-amd-versal2.o ufshcd-dwc.o
drivers/ufs/host/ufs-spacemit.c new file +678 -0

678 lines not on this page · raw message

drivers/ufs/host/ufs-spacemit.h new file +79 -0

79 lines not on this page · raw message

Signature · 1 line
2.55.0
#5 lore raw

Re: [PATCH v4 2/3] scsi: ufs: spacemit: k3: Add UFS Host Controller driver

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] Missing lane 1 configuration for M-PHY tuning attribute 0xe8. - [High] The SpacemiT UFS platform…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Missing lane 1 configuration for M-PHY tuning attribute 0xe8.
- [High] The SpacemiT UFS platform driver fails to configure PM (Power Management) operations, breaking system suspend/resume. --

commit e432cf6faf83c7fe0612ce4cb8a3f5d0731598d9
Author: Yixun Lan <[email protected]>

scsi: ufs: spacemit: k3: Add UFS Host Controller driver

SpacemiT K3 SoC consist of UFS (Universal Flash Storage) Host Controller which has features compatible with JEDEC UFS 2.2, MIPI UniPro v1.61 and M-PHY v3.0 standard.

Quoted 5 lines
drivers/ufs/host/ufs-spacemit.c new file +0 -0
new file mode 100644
index 0000000000000..9d037d90ac5e3

[ ... ]

drivers/ufs/host/ufs-spacemit.c line 334

Quoted 9 lines
drivers/ufs/host/ufs-spacemit.c new file +9 -0
+static int ufs_spacemit_link_startup_post_change(struct ufs_hba *hba)
+{
+	/* Add 0xe8 make UFS2.1 run GEAR3 + 2Lane@409M */
+	static const struct ufshcd_dme_attr_val setup_attrs[] = {
+		{ UIC_ARG_MIB_SEL(0xe8, UIC_ARG_MPHY_TX_GEN_SEL_INDEX(0)), 0x97 },
+		{ UIC_ARG_MIB_SEL(0xe8, UIC_ARG_MPHY_TX_GEN_SEL_INDEX(0)), 0xd7 },
+		{ UIC_ARG_MIB_SEL(0xe8, UIC_ARG_MPHY_TX_GEN_SEL_INDEX(0)), 0x17 },
+		{ UIC_ARG_MIB(DL_AFC0REQTIMEOUTVAL), UFS_DL_AFC0REQTIMEOUTVAL_MAX },
+	};

[Severity: High]
Is Lane 1 tuning intentionally omitted here?

The driver declares support for 2 TX lanes, and the comment mentions configuring "2Lane@409M". However, the M-PHY tuning attribute 0xe8 is only configured for Lane 0 via UIC_ARG_MPHY_TX_GEN_SEL_INDEX(0).

Operating in 2-lane mode without applying the same PHY tuning to the second lane can cause link instability or negotiation failures. Should this also configure Lane 1?

[ ... ]

drivers/ufs/host/ufs-spacemit.c line 675

Quoted 9 lines
drivers/ufs/host/ufs-spacemit.c new file +9 -0
+static struct platform_driver ufs_spacemit_pltform = {
+	.probe	= ufs_spacemit_probe,
+	.remove	= ufs_spacemit_remove,
+	.driver	= {
+		.name	= "ufshcd-spacemit",
+		.of_match_table = of_match_ptr(ufs_spacemit_of_match),
+	},
+};
+module_platform_driver(ufs_spacemit_pltform);

[Severity: High]
Does this driver correctly configure power management?

The platform driver structure does not initialize the pm field in its driver sub-structure. Without a valid dev_pm_ops structure, the platform bus will not invoke any PM callbacks for this device.

This means the UFS host controller will not participate in system suspend/resume or runtime power management, which can lead to power drain or system crashes on resume if the power domain was gated by firmware. Should this assign standard UFS PM callbacks to the pm field?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
author maintainer
#6 lore raw

Re: [PATCH v4 2/3] scsi: ufs: spacemit: k3: Add UFS Host Controller driver

Hi All,

Quoted 33 lines · On 07:55 Tue 08 Sep , [email protected] wrote:

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Missing lane 1 configuration for M-PHY tuning attribute 0xe8.
- [High] The SpacemiT UFS platform driver fails to configure PM (Power Management) operations, breaking system suspend/resume. --

commit e432cf6faf83c7fe0612ce4cb8a3f5d0731598d9
Author: Yixun Lan <[email protected]>

scsi: ufs: spacemit: k3: Add UFS Host Controller driver

SpacemiT K3 SoC consist of UFS (Universal Flash Storage) Host Controller which has features compatible with JEDEC UFS 2.2, MIPI UniPro v1.61 and M-PHY v3.0 standard.

Quoted 5 lines
drivers/ufs/host/ufs-spacemit.c new file +0 -0
new file mode 100644
index 0000000000000..9d037d90ac5e3

[ ... ]

drivers/ufs/host/ufs-spacemit.c line 334

Quoted 9 lines
drivers/ufs/host/ufs-spacemit.c new file +9 -0
+static int ufs_spacemit_link_startup_post_change(struct ufs_hba *hba)
+{
+	/* Add 0xe8 make UFS2.1 run GEAR3 + 2Lane@409M */
+	static const struct ufshcd_dme_attr_val setup_attrs[] = {
+		{ UIC_ARG_MIB_SEL(0xe8, UIC_ARG_MPHY_TX_GEN_SEL_INDEX(0)), 0x97 },
+		{ UIC_ARG_MIB_SEL(0xe8, UIC_ARG_MPHY_TX_GEN_SEL_INDEX(0)), 0xd7 },
+		{ UIC_ARG_MIB_SEL(0xe8, UIC_ARG_MPHY_TX_GEN_SEL_INDEX(0)), 0x17 },
+		{ UIC_ARG_MIB(DL_AFC0REQTIMEOUTVAL), UFS_DL_AFC0REQTIMEOUTVAL_MAX },
+	};

[Severity: High]
Is Lane 1 tuning intentionally omitted here?

Quoted 8 lines

The driver declares support for 2 TX lanes, and the comment mentions configuring "2Lane@409M". However, the M-PHY tuning attribute 0xe8 is only configured for Lane 0 via UIC_ARG_MPHY_TX_GEN_SEL_INDEX(0).

Operating in 2-lane mode without applying the same PHY tuning to the second lane can cause link instability or negotiation failures. Should this also configure Lane 1?

No need, this is false report, the configuration will apply to Lane 1

or anyone has idea to silence this when sending next version?

Quoted 14 lines

[ ... ]

drivers/ufs/host/ufs-spacemit.c line 675

Quoted 9 lines
drivers/ufs/host/ufs-spacemit.c new file +9 -0
+static struct platform_driver ufs_spacemit_pltform = {
+	.probe	= ufs_spacemit_probe,
+	.remove	= ufs_spacemit_remove,
+	.driver	= {
+		.name	= "ufshcd-spacemit",
+		.of_match_table = of_match_ptr(ufs_spacemit_of_match),
+	},
+};
+module_platform_driver(ufs_spacemit_pltform);

[Severity: High]
Does this driver correctly configure power management?

Quoted 6 lines

The platform driver structure does not initialize the pm field in its driver sub-structure. Without a valid dev_pm_ops structure, the platform bus will not invoke any PM callbacks for this device.

This means the UFS host controller will not participate in system suspend/resume or runtime power management, which can lead to power

The K3 mainline platform lacks low level support for system suspend/resume, while for runtime power management, I think it's a valid point, and should be feasible to implement, so will take a look in next version.

Quoted 3 lines

drain or system crashes on resume if the power domain was gated by firmware. Should this assign standard UFS PM callbacks to the pm field?

Thanks

Signature · 1 line
Yixun Lan (dlan)
author maintainer
#7 lore raw

PATCH v4 3/3 riscv: dts: spacemit: k3: Add UFS support

In reply to Yixun Lan

Add UFS Host Controller support for SpacemiT K3 SoC, and enable it both on Pico-ITX and CoM260-IFX boards.

---
 arch/riscv/boot/dts/spacemit/k3-com260.dtsi  |  4 ++++
 arch/riscv/boot/dts/spacemit/k3-pico-itx.dts |  4 ++++
 arch/riscv/boot/dts/spacemit/k3.dtsi         | 22 ++++++++++++++++++++++
 3 files changed, 30 insertions(+)
arch/riscv/boot/dts/spacemit/k3-com260.dtsi +4 -0
index 37627963a649..3251ee8405de 100644
@@ -220,3 +220,7 @@ &uart0 {
 	pinctrl-0 = <&uart0_0_cfg>;
 	status = "okay";
 };
+
+&ufshc {
+	status = "okay";
+};
arch/riscv/boot/dts/spacemit/k3-pico-itx.dts +4 -0
index b084a35aa00e..6369602e81da 100644
@@ -307,6 +307,10 @@ &uart0 {
 	status = "okay";
 };
 
+&ufshc {
+	status = "okay";
+};
+
 &usb2_host {
 	#address-cells = <1>;
 	#size-cells = <0>;
arch/riscv/boot/dts/spacemit/k3.dtsi +22 -0
index c3f2dce0969c..436c0e7e2838 100644
@@ -513,6 +513,28 @@ usb2_phy: phy@c0a20000 {
 			status = "disabled";
 		};
 
+		ufshc: ufshc@c0e00000 {
+			compatible = "spacemit,k3-ufshc";
+			reg = <0x0 0xc0e00000 0x0 0x40000>;
+			clocks = <&syscon_apmu CLK_APMU_UFS_ACLK>,
+				 <&syscon_apmu CLK_APMU_UFS_REFCLK>;
+			clock-names = "aclk", "ref_clk";
+			resets = <&syscon_apmu RESET_APMU_UFS_ACLK>;
+			interrupts = <135 IRQ_TYPE_LEVEL_HIGH>;
+			lanes-per-direction = <2>;
+			operating-points-v2 = <&ufs_opp_table>;
+			status = "disabled";
+
+			ufs_opp_table: opp-table {
+				compatible = "operating-points-v2";
+
+				opp-1 {
+					opp-hz = /bits/ 64 <491520000>,
+						 /bits/ 64 <19200000>;
+				};
+			};
+		};
+
 		eth0: ethernet@cac80000 {
 			compatible = "spacemit,k3-dwmac", "snps,dwmac-5.40a";
 			reg = <0x0 0xcac80000 0x0 0x2000>;
Signature · 1 line
2.55.0
#8 lore raw

Re: [PATCH v4 3/3] riscv: dts: spacemit: k3: Add UFS support

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] The platform driver is missing power management operations (.pm), which breaks system…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The platform driver is missing power management operations (.pm), which breaks system suspend/resume and runtime PM. --

commit e432cf6faf83c7fe0612ce4cb8a3f5d0731598d9
Author: Yixun Lan <[email protected]>

scsi: ufs: spacemit: k3: Add UFS Host Controller driver

SpacemiT K3 SoC consist of UFS (Universal Flash Storage) Host Controller which has features compatible with JEDEC UFS 2.2, MIPI UniPro v1.61 and M-PHY v3.0 standard.

Quoted 5 lines
drivers/ufs/host/ufs-spacemit.c new file +0 -0
new file mode 100644
index 0000000000000..9d037d90ac5e3

[ ... ]

drivers/ufs/host/ufs-spacemit.c

Quoted 8 lines
drivers/ufs/host/ufs-spacemit.c new file +8 -0
+static struct platform_driver ufs_spacemit_pltform = {
+	.probe	= ufs_spacemit_probe,
+	.remove	= ufs_spacemit_remove,
+	.driver	= {
+		.name	= "ufshcd-spacemit",
+		.of_match_table = of_match_ptr(ufs_spacemit_of_match),
+	},
+};

[Severity: High]
Does this platform driver need power management operations assigned to .pm?

Since .pm is missing in ufs_spacemit_pltform, the platform bus PM core won't invoke any callbacks during system suspend/resume or runtime PM transitions. This means the host controller and attached UFS device might not be placed into a low-power state or have their hardware queues properly flushed during suspend, and could resume in an inconsistent state causing hardware hangs or data corruption if parent buses were powered down.

Could .pm be set here (for example, to a dev_pm_ops struct utilizing ufshcd_system_suspend and ufshcd_runtime_suspend) to ensure the PM core manages the UFS controller's power state?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Tested-by on the v4 series
#9 lore raw
In reply to Yixun Lan

Hi Yixun,

Quoted 64 lines · Yixun Lan

This series try to add UFS support for SpacemiT K3 SoC, the controller components consists of System Bus Interface Unit, UFS Host Controller Interface, UFS Transport Protocol Layer, UFS Host Registers, Device Management Entity (DME), Transport Layer, Network Layer, Data Link Layer, PHY Adapter Layer, and M-PHY Interface. A more detail functional block diagram can be found in SpacemiT website, chapter 9.7.3 [1]

One known issue is that the device will occasionally raise BKOPS interrupt when doing some high load test, log from dmesg shows

[  806.710763] ufshcd-spacemit c0e00000.ufshc: ufshcd_bkops_exception_event_handler: device raised urgent BKOPS exception for bkops status 1

---
Changes in v4:
- fix clock and reset settings
- drop function which retrieve value of tx_lanes
- propagate return error of ufs_spacemit_dme_set()
- check return value ufs_spacemit_check_hibern8()
- drop call to ufshcd_vops_phy_initialization()
- handle compiling warning if CONFIG_OF not enabled
add __maybe_unused to ufs_spacemit_of_match
- Link to v3: https://patch.msgid.link/[email protected]

Changes in v3:
- collect tags
- fix dt-binding warning reported-by sashiko
- fix low freq in opp-2 table
- fix err checking in check_hibern8()
- propagate err code in link_startup_notify()
- update documents for event_notify()
- ufs clock driver is merged into v7.3-rc1, update cover letter
- Link to v2: https://patch.msgid.link/[email protected]

Changes in v2:
- fix missing interrupts property
- move ufs node to k3-com260.dtsi
- convert freq-table-hz to operating-points-v2
- rework reset_control, fix header and drop global variable
- drop dump_host_regs() debug interface
- converge and refactor dme_set() operations
- massive reduce of busy delay() loops
- drop vendor specific hce_enable_notify(), fallback to default
- drop unused member from struct ufs_spacemit_host
- add COMPILE_TEST support to Kconfig
- comment style fix
- Link to v1: https://patch.msgid.link/[email protected]

---
Yixun Lan (3):
scsi: ufs: spacemit: dt-bindings: Add UFS controller for K3 SoC
scsi: ufs: spacemit: k3: Add UFS Host Controller driver
riscv: dts: spacemit: k3: Add UFS support

 .../devicetree/bindings/ufs/spacemit,k3-ufshc.yaml |  56 ++
 arch/riscv/boot/dts/spacemit/k3-com260.dtsi        |   4 +
 arch/riscv/boot/dts/spacemit/k3-pico-itx.dts       |   4 +
 arch/riscv/boot/dts/spacemit/k3.dtsi               |  22 +
 drivers/ufs/host/Kconfig                           |  12 +
 drivers/ufs/host/Makefile                          |   1 +
 drivers/ufs/host/ufs-spacemit.c                    | 678 +++++++++++++++++++++
 drivers/ufs/host/ufs-spacemit.h                    |  79 +++
 8 files changed, 856 insertions(+)
Quoted 3 lines

---
base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
change-id: 20260605-08-k3-ufs-support-c8b308e415e2

Thanks for this new version. Patches 2-3 are:

Regards
Aurelien

Signature · 2 lines
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
[email protected]                     http://aurel32.net
Tested-by on the v4 series
#10 lore raw
In reply to Yixun Lan

Hi Yixun,

Quoted 56 lines · Yixun Lan

This series try to add UFS support for SpacemiT K3 SoC, the controller components consists of System Bus Interface Unit, UFS Host Controller Interface, UFS Transport Protocol Layer, UFS Host Registers, Device Management Entity (DME), Transport Layer, Network Layer, Data Link Layer, PHY Adapter Layer, and M-PHY Interface. A more detail functional block diagram can be found in SpacemiT website, chapter 9.7.3 [1]

One known issue is that the device will occasionally raise BKOPS interrupt when doing some high load test, log from dmesg shows

[  806.710763] ufshcd-spacemit c0e00000.ufshc: ufshcd_bkops_exception_event_handler: device raised urgent BKOPS exception for bkops status 1

---
Changes in v4:
- fix clock and reset settings
- drop function which retrieve value of tx_lanes
- propagate return error of ufs_spacemit_dme_set()
- check return value ufs_spacemit_check_hibern8()
- drop call to ufshcd_vops_phy_initialization()
- handle compiling warning if CONFIG_OF not enabled
add __maybe_unused to ufs_spacemit_of_match
- Link to v3: https://patch.msgid.link/[email protected]

Changes in v3:
- collect tags
- fix dt-binding warning reported-by sashiko
- fix low freq in opp-2 table
- fix err checking in check_hibern8()
- propagate err code in link_startup_notify()
- update documents for event_notify()
- ufs clock driver is merged into v7.3-rc1, update cover letter
- Link to v2: https://patch.msgid.link/[email protected]

Changes in v2:
- fix missing interrupts property
- move ufs node to k3-com260.dtsi
- convert freq-table-hz to operating-points-v2
- rework reset_control, fix header and drop global variable
- drop dump_host_regs() debug interface
- converge and refactor dme_set() operations
- massive reduce of busy delay() loops
- drop vendor specific hce_enable_notify(), fallback to default
- drop unused member from struct ufs_spacemit_host
- add COMPILE_TEST support to Kconfig
- comment style fix
- Link to v1: https://patch.msgid.link/[email protected]

---
Yixun Lan (3):
scsi: ufs: spacemit: dt-bindings: Add UFS controller for K3 SoC
scsi: ufs: spacemit: k3: Add UFS Host Controller driver
riscv: dts: spacemit: k3: Add UFS support

Quoted 9 lines
 .../devicetree/bindings/ufs/spacemit,k3-ufshc.yaml |  56 ++
 arch/riscv/boot/dts/spacemit/k3-com260.dtsi        |   4 +
 arch/riscv/boot/dts/spacemit/k3-pico-itx.dts       |   4 +
 arch/riscv/boot/dts/spacemit/k3.dtsi               |  22 +
 drivers/ufs/host/Kconfig                           |  12 +
 drivers/ufs/host/Makefile                          |   1 +
 drivers/ufs/host/ufs-spacemit.c                    | 678 +++++++++++++++++++++
 drivers/ufs/host/ufs-spacemit.h                    |  79 +++
 8 files changed, 856 insertions(+)