Skip to contentSkip to conversation

UFS: Add reference clock support for AMD Versal2

PATCH New Ajay Neeli 2 participants 5 messages Nov 25

Subsystems (4)
lore
Share & tools
lore

Ajay Neeli

author maintainer
#0 lore raw

v2 cover UFS: Add reference clock support for AMD Versal2

This series adds reference clock support for AMD Versal2 UFS.

The first patch updates the common UFS platform code to recognize "ref" as the reference clock name while retaining support for "ref_clk" for existing devicetree users.

The second patch adds the reference clock to the AMD Versal2 UFS devicetree binding.

---
Changes in v2:
- Add descriptions for individual clocks.
- Use "ref" instead of "ref_clk" for the AMD binding.
- Update the common UFS platform code to support "ref" while retaining compatibility with existing "ref_clk" users.
---

Ajay Neeli (2):
scsi: ufs: core: Support "ref" clock name
dt-bindings: ufs: amd,versal2-ufs: Add reference clock

 .../devicetree/bindings/ufs/amd,versal2-ufs.yaml      | 11 +++++++----
 drivers/ufs/host/ufshcd-pltfrm.c                      |  2 +-
 2 files changed, 8 insertions(+), 5 deletions(-)
Signature · 1 line
2.43.7
author maintainer
#1 lore raw

PATCH v2 1/2 scsi: ufs: core: Support "ref" clock name

The UFS platform code identifies the reference clock by the "ref_clk" clock name and marks it to keep the link active.

Allow "ref" to be used as the reference clock name, while retaining support for "ref_clk" for compatibility with existing devicetree bindings.

---
 drivers/ufs/host/ufshcd-pltfrm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ufs/host/ufshcd-pltfrm.c +1 -1
index 169dbc1a75fe..947edcd88668 100644
@@ -96,7 +96,7 @@ static int ufshcd_parse_clock_info(struct ufs_hba *hba)
 			goto out;
 		}
 
-		if (!strcmp(name, "ref_clk"))
+		if (!strcmp(name, "ref") || !strcmp(name, "ref_clk"))
 			clki->keep_link_active = true;
 		dev_dbg(dev, "%s: min %u max %u name %s\n", "freq-table-hz",
 				clki->min_freq, clki->max_freq, clki->name);
Signature · 1 line
2.43.7
#2 lore raw

Re: [PATCH v2 1/2] scsi: ufs: core: Support "ref" clock name

Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [High] scsi: ufs: missing ref clock name check in ufshcd_init_clocks() - [Medium] scsi: ufs: missing ref…

Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [High] scsi: ufs: missing ref clock name check in ufshcd_init_clocks()
- [Medium] scsi: ufs: missing ref clock name check in ufshcd_parse_operating_points()
--

commit 4196a48351e8b590f1bfcc4bbd914e822554236d
Author: Ajay Neeli <[email protected]>

scsi: ufs: core: Support "ref" clock name

This commit updates ufshcd_parse_clock_info() to also match the "ref" clock name when setting keep_link_active on the reference clock.

drivers/ufs/host/ufshcd-pltfrm.c static int ufshcd_parse_clock_info(struct ufs_hba *hba) · line 102

Quoted 13 lines
drivers/ufs/host/ufshcd-pltfrm.c +1 -1
index 169dbc1a75fe5..947edcd886680 100644
@@ -96,7 +96,7 @@ static int ufshcd_parse_clock_info(struct ufs_hba *hba)
 			goto out;
 		}
 
-		if (!strcmp(name, "ref_clk"))
+		if (!strcmp(name, "ref") || !strcmp(name, "ref_clk"))
 			clki->keep_link_active = true;
 		dev_dbg(dev, "%s: min %u max %u name %s\n", "freq-table-hz",
 				clki->min_freq, clki->max_freq, clki->name);

[Severity: High]
Should ufshcd_init_clocks() also check for "ref" when detecting the device reference clock frequency?

drivers/ufs/core/ufshcd.c:ufshcd_init_clocks() {
    ...
		if (!strcmp(clki->name, "ref_clk"))
			ufshcd_parse_dev_ref_clk_freq(hba, clki->clk);
    ...
}

When the clock is named "ref", ufshcd_parse_dev_ref_clk_freq() is skipped and hba->dev_ref_clk_freq remains REF_CLK_FREQ_INVAL unless a separate ref-clk-freq property is present, so ufshcd_set_dev_ref_clk() will not program the UFS device bRefClkFreq attribute before switching to High-Speed mode.

[Severity: Medium]
Does ufshcd_parse_operating_points() in this file need the same "ref" check?

drivers/ufs/host/ufshcd-pltfrm.c:ufshcd_parse_operating_points() {
    ...
		if (!strcmp(clk_names[i], "ref_clk"))
			clki->keep_link_active = true;
    ...
}

On platforms that use operating-points-v2 instead of freq-table-hz, ufshcd_parse_clock_info() exits early and ufshcd_parse_operating_points() populates hba->clk_list_head, leaving keep_link_active false for a "ref" clock and allowing __ufshcd_setup_clocks() to disable the reference clock while the link is active.

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

PATCH v2 2/2 dt-bindings: ufs: amd,versal2-ufs: Add reference clock

In reply to Ajay Neeli

Add the reference clock supplied to the UFS device.

The AMD Versal2 UFS controller operates with a 26 MHz reference clock. UFS 3.x devices default their bRefClkFreq attribute to 26 MHz, matching the controller, so no explicit configuration is needed. However, UFS 4.0 and later devices default bRefClkFreq to 52 MHz, expecting a 52 MHz reference clock. This mismatch causes timing violations and link instability.

Add the reference clock to allow the UFS driver to obtain its frequency from devicetree and program the device bRefClkFreq attribute accordingly during initialization.

---
 .../devicetree/bindings/ufs/amd,versal2-ufs.yaml      | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/ufs/amd,versal2-ufs.yaml +7 -4
index c00ec342d574..11138578975f 100644
@@ -20,11 +20,14 @@ properties:
     maxItems: 1
 
   clocks:
-    maxItems: 1
+    items:
+      - description: UFS core clock
+      - description: UFS reference clock
 
   clock-names:
     items:
       - const: core
+      - const: ref
 
   power-domains:
     maxItems: 1
@@ -52,10 +55,10 @@ examples:
     ufs@f10b0000 {
         compatible = "amd,versal2-ufs";
         reg = <0xf10b0000 0x1000>;
-        clocks = <&ufs_core_clk>;
-        clock-names = "core";
+        clocks = <&ufs_core_clk>, <&ufs_ref_clk>;
+        clock-names = "core", "ref";
         resets = <&scmi_reset 4>, <&scmi_reset 35>;
         reset-names = "host", "phy";
         interrupts = <GIC_SPI 234 IRQ_TYPE_LEVEL_HIGH>;
-        freq-table-hz = <0 0>;
+        freq-table-hz = <0 0>, <26000000 26000000>;
     };
Signature · 1 line
2.43.7
#4 lore raw

Re: [PATCH v2 2/2] dt-bindings: ufs: amd,versal2-ufs: Add reference clock

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] dt-bindings: ufs: amd,versal2-ufs: ref clock name ignored by ufshcd_init_clocks() --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Medium] dt-bindings: ufs: amd,versal2-ufs: ref clock name ignored by ufshcd_init_clocks()
--

commit 533c5c18f1ac18e00d180f090ca93237f628f615
Author: Ajay Neeli <[email protected]>

dt-bindings: ufs: amd,versal2-ufs: Add reference clock

This commit adds the reference clock and its "ref" clock-names entry to the AMD Versal Gen 2 UFS devicetree binding schema so the driver can program the device bRefClkFreq attribute.

Quoted 7 lines
Documentation/devicetree/bindings/ufs/amd,versal2-ufs.yaml +0 -0
index c00ec342d5743..11138578975f5 100644
@@ -20,11 +20,14 @@ properties:
     maxItems: 1
 

Documentation/devicetree/bindings/ufs/amd,versal2-ufs.yaml properties: · line 30

Quoted 10 lines
Documentation/devicetree/bindings/ufs/amd,versal2-ufs.yaml +4 -1
   clocks:
-    maxItems: 1
+    items:
+      - description: UFS core clock
+      - description: UFS reference clock
 
   clock-names:
     items:
       - const: core
+      - const: ref

[Severity: Medium]
Will naming this clock "ref" actually allow the UFS core to parse the reference clock frequency and program bRefClkFreq?

Earlier commit "scsi: ufs: core: Support "ref" clock name" updated ufshcd_parse_clock_info() to set clki->keep_link_active for "ref", but ufshcd_init_clocks() still only checks for "ref_clk":

drivers/ufs/core/ufshcd.c:ufshcd_init_clocks() {
    ...
		if (!strcmp(clki->name, "ref_clk"))
			ufshcd_parse_dev_ref_clk_freq(hba, clki->clk);
    ...
}

With clock-names set to "ref", hba->dev_ref_clk_freq remains REF_CLK_FREQ_INVAL, so ufshcd_post_device_init() skips ufshcd_set_dev_ref_clk() and leaves UFS 4.0+ devices at their 52 MHz default. ufshcd_parse_operating_points() in drivers/ufs/host/ufshcd-pltfrm.c also checks only for "ref_clk" when setting clki->keep_link_active.

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