Skip to contentSkip to conversation

Add support for Unisoc UFS host controller

PATCH Superseded Zhe Wang 4 participants 8 messages Nov 16, 2022 – Nov 21, 2022

Subsystems (4)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Zhe Wang

author
#0 lore raw

v2 cover Add support for Unisoc UFS host controller

Add this patchset to support the Unisoc UFS host controller.

V1 -> V2:
- Fix dt-binding doc in v2 patch
- Do some minor format changes
- Remove of_match_ptr
- Remove functions from headers

Zhe Wang (2):
dt-bindings: ufs: Add document for Unisoc UFS host controller
scsi: ufs-unisoc: Add support for Unisoc UFS host controller

 .../bindings/ufs/sprd,ums9620-ufs.yaml        |  78 +++
 drivers/ufs/host/Kconfig                      |  12 +
 drivers/ufs/host/Makefile                     |   1 +
 drivers/ufs/host/ufs-sprd.c                   | 484 ++++++++++++++++++
 drivers/ufs/host/ufs-sprd.h                   |  86 ++++
 5 files changed, 661 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/ufs/sprd,ums9620-ufs.yaml
 create mode 100644 drivers/ufs/host/ufs-sprd.c
 create mode 100644 drivers/ufs/host/ufs-sprd.h
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH v2 1/2 dt-bindings: ufs: Add document for Unisoc UFS host controller

Add Unisoc ums9620 ufs host controller devicetree document.

---
 .../bindings/ufs/sprd,ums9620-ufs.yaml        | 78 +++++++++++++++++++
 1 file changed, 78 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/ufs/sprd,ums9620-ufs.yaml
Documentation/devicetree/bindings/ufs/sprd,ums9620-ufs.yaml new file +78 -0
new file mode 100644
index 000000000000..ce9d05be1a6b
@@ -0,0 +1,78 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/ufs/sprd,ums9620-ufs.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Unisoc Universal Flash Storage (UFS) Controller
+
+maintainers:
+  - Zhe Wang <[email protected]>
+
+allOf:
+  - $ref: ufs-common.yaml
+
+properties:
+  compatible:
+    const: sprd,ums9620-ufs
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 4
+
+  clock-names:
+    items:
+      - const: ufs_eb
+      - const: ufs_cfg_eb
+      - const: ufsh
+      - const: ufsh_source
+
+  resets:
+    maxItems: 2
+
+  reset-names:
+    items:
+      - const: ufs
+      - const: ufsdev
+
+  vdd-mphy-supply:
+    description:
+      Phandle to vdd-mphy supply regulator node.
+
+  sprd,ufs-anlg-syscon:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description: phandle of syscon used to control ufs analog regs.
+
+  sprd,aon-apb-syscon:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description: phandle of syscon used to control always-on regs.
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - resets
+  - reset-names
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+
+    ufs: ufs@22000000 {
+        compatible = "sprd,ums9620-ufs";
+        reg = <0x22000000 0x3000>;
+        interrupts = <GIC_SPI 159 IRQ_TYPE_LEVEL_HIGH>;
+        vcc-supply = <&vddemmccore>;
+        vdd-mphy-supply = <&vddufs1v2>;
+        clock-names = "ufs_eb", "ufs_cfg_eb", "ufsh", "ufsh_source";
+        clocks = <&apahb_gate 5>, <&apahb_gate 22>, <&aonapb_clk 52>, <&g5l_pll 12>;
+        reset-names = "ufs", "ufsdev";
+        resets = <&apahb_gate 4>, <&aonapb_gate 69>;
+        sprd,ufs-anlg-syscon = <&anlg_phy_g12_regs>;
+        sprd,aon-apb-syscon = <&aon_apb_regs>;
+    };
Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH v2 1/2] dt-bindings: ufs: Add document for Unisoc UFS host controller

Quoted 3 lines · Zhe Wang

Add Unisoc ums9620 ufs host controller devicetree document.

Thank you for your patch. There is something to discuss/improve.

Quoted 5 lines
Documentation/devicetree/bindings/ufs/sprd,ums9620-ufs.yaml new file +5 -0
+
+  clock-names:
+    items:
+      - const: ufs_eb
+      - const: ufs_cfg_eb

Documentation/devicetree/bindings/ufs/sprd,ums9620-ufs.yaml line 38

Quoted 10 lines
Documentation/devicetree/bindings/ufs/sprd,ums9620-ufs.yaml new file +10 -0
+      - const: ufsh
+      - const: ufsh_source
+
+  resets:
+    maxItems: 2
+
+  reset-names:
+    items:
+      - const: ufs
+      - const: ufsdev

Both clock names and resets are still not useful. "ufs" is the name of the block, so reset name of "ufs" and "ufsdev" says nothing. This is the dev right?

Quoted 25 lines
Documentation/devicetree/bindings/ufs/sprd,ums9620-ufs.yaml new file +25 -0
+
+  vdd-mphy-supply:
+    description:
+      Phandle to vdd-mphy supply regulator node.
+
+  sprd,ufs-anlg-syscon:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description: phandle of syscon used to control ufs analog regs.
+
+  sprd,aon-apb-syscon:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description: phandle of syscon used to control always-on regs.
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - resets
+  - reset-names
+
+unevaluatedProperties: false
+
+examples:
+  - |

Documentation/devicetree/bindings/ufs/sprd,ums9620-ufs.yaml line 73

Quoted 10 lines
Documentation/devicetree/bindings/ufs/sprd,ums9620-ufs.yaml new file +10 -0
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+
+    ufs: ufs@22000000 {
+        compatible = "sprd,ums9620-ufs";
+        reg = <0x22000000 0x3000>;
+        interrupts = <GIC_SPI 159 IRQ_TYPE_LEVEL_HIGH>;
+        vcc-supply = <&vddemmccore>;
+        vdd-mphy-supply = <&vddufs1v2>;
+        clock-names = "ufs_eb", "ufs_cfg_eb", "ufsh", "ufsh_source";
+        clocks = <&apahb_gate 5>, <&apahb_gate 22>, <&aonapb_clk 52>, <&g5l_pll 12>;

First clocks, then names.

Documentation/devicetree/bindings/ufs/sprd,ums9620-ufs.yaml line 75

Quoted 2 lines
Documentation/devicetree/bindings/ufs/sprd,ums9620-ufs.yaml new file +2 -0
+        reset-names = "ufs", "ufsdev";
+        resets = <&apahb_gate 4>, <&aonapb_gate 69>;

First resets, then names.

Documentation/devicetree/bindings/ufs/sprd,ums9620-ufs.yaml line 78

Quoted 3 lines
Documentation/devicetree/bindings/ufs/sprd,ums9620-ufs.yaml new file +3 -0
+        sprd,ufs-anlg-syscon = <&anlg_phy_g12_regs>;
+        sprd,aon-apb-syscon = <&aon_apb_regs>;
+    };

Best regards,
Krzysztof

#3 lore raw

Re: [PATCH v2 1/2] dt-bindings: ufs: Add document for Unisoc UFS host controller

hi Krzysztof

Quoted 19 lines · Krzysztof Kozlowski
Quoted 3 lines · Zhe Wang

Add Unisoc ums9620 ufs host controller devicetree document.

Thank you for your patch. There is something to discuss/improve.

Quoted 11 lines
Documentation/devicetree/bindings/ufs/sprd,ums9620-ufs.yaml new file +11 -0
+
+  clock-names:
+    items:
+      - const: ufs_eb
+      - const: ufs_cfg_eb
+      - const: ufsh
+      - const: ufsh_source
+
+  resets:
+    maxItems: 2
+
Quoted 9 lines

Documentation/devicetree/bindings/ufs/sprd,ums9620-ufs.yaml line 38

Quoted 4 lines
Documentation/devicetree/bindings/ufs/sprd,ums9620-ufs.yaml new file +4 -0
+  reset-names:
+    items:
+      - const: ufs
+      - const: ufsdev

Both clock names and resets are still not useful. "ufs" is the name of the block, so reset name of "ufs" and "ufsdev" says nothing. This is the dev right?

Yes, this means reset on the device side. How about the modification below?

+ clock-names:
+ items:

+      - const: controller_eb
+      - const: cfg_eb
+      - const: core
+      - const: core_source

+
+ resets:
+ maxItems: 2
+
+ reset-names:
+ items:
+ - const: controller
+ - const: device

Quoted 29 lines
Quoted 29 lines
Documentation/devicetree/bindings/ufs/sprd,ums9620-ufs.yaml new file +29 -0
+
+  vdd-mphy-supply:
+    description:
+      Phandle to vdd-mphy supply regulator node.
+
+  sprd,ufs-anlg-syscon:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description: phandle of syscon used to control ufs analog regs.
+
+  sprd,aon-apb-syscon:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description: phandle of syscon used to control always-on regs.
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - resets
+  - reset-names
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+
+    ufs: ufs@22000000 {
+        compatible = "sprd,ums9620-ufs";
Quoted 9 lines

Documentation/devicetree/bindings/ufs/sprd,ums9620-ufs.yaml line 73

Quoted 6 lines
Documentation/devicetree/bindings/ufs/sprd,ums9620-ufs.yaml new file +6 -0
+        reg = <0x22000000 0x3000>;
+        interrupts = <GIC_SPI 159 IRQ_TYPE_LEVEL_HIGH>;
+        vcc-supply = <&vddemmccore>;
+        vdd-mphy-supply = <&vddufs1v2>;
+        clock-names = "ufs_eb", "ufs_cfg_eb", "ufsh", "ufsh_source";
+        clocks = <&apahb_gate 5>, <&apahb_gate 22>, <&aonapb_clk 52>, <&g5l_pll 12>;

First clocks, then names.

I'll fix it.

Quoted 5 lines

Documentation/devicetree/bindings/ufs/sprd,ums9620-ufs.yaml line 75

Quoted 2 lines
Documentation/devicetree/bindings/ufs/sprd,ums9620-ufs.yaml new file +2 -0
+        reset-names = "ufs", "ufsdev";
+        resets = <&apahb_gate 4>, <&aonapb_gate 69>;

First resets, then names.

I'll fix it.

Best regards,
Zhe

Quoted 7 lines

Documentation/devicetree/bindings/ufs/sprd,ums9620-ufs.yaml line 78

Quoted 3 lines
Documentation/devicetree/bindings/ufs/sprd,ums9620-ufs.yaml new file +3 -0
+        sprd,ufs-anlg-syscon = <&anlg_phy_g12_regs>;
+        sprd,aon-apb-syscon = <&aon_apb_regs>;
+    };

Best regards,
Krzysztof

#4 lore raw

Re: [PATCH v2 1/2] dt-bindings: ufs: Add document for Unisoc UFS host controller

Quoted 39 lines · Zhe Wang

hi Krzysztof

Quoted 19 lines · Krzysztof Kozlowski
Quoted 3 lines · Zhe Wang

Add Unisoc ums9620 ufs host controller devicetree document.

Thank you for your patch. There is something to discuss/improve.

Quoted 11 lines
Documentation/devicetree/bindings/ufs/sprd,ums9620-ufs.yaml new file +11 -0
+
+  clock-names:
+    items:
+      - const: ufs_eb
+      - const: ufs_cfg_eb
+      - const: ufsh
+      - const: ufsh_source
+
+  resets:
+    maxItems: 2
+
Quoted 9 lines

Documentation/devicetree/bindings/ufs/sprd,ums9620-ufs.yaml line 38

Quoted 4 lines
Documentation/devicetree/bindings/ufs/sprd,ums9620-ufs.yaml new file +4 -0
+  reset-names:
+    items:
+      - const: ufs
+      - const: ufsdev

Both clock names and resets are still not useful. "ufs" is the name of the block, so reset name of "ufs" and "ufsdev" says nothing. This is the dev right?

Yes, this means reset on the device side. How about the modification below?

Documentation/devicetree/bindings/ufs/sprd,ums9620-ufs.yaml new file +4 -0
+  clock-names:
+    items:
+      - const: controller_eb
+      - const: cfg_eb

Documentation/devicetree/bindings/ufs/sprd,ums9620-ufs.yaml

Quoted 10 lines
Documentation/devicetree/bindings/ufs/sprd,ums9620-ufs.yaml new file +10 -0
+      - const: core
+      - const: core_source
+
+  resets:
+    maxItems: 2
+
+  reset-names:
+    items:
+      - const: controller
+      - const: device

That's very good, thanks.

Quoted 1 line

Best regards,
Krzysztof

maintainer
#5 lore raw

Re: [PATCH v2 1/2] dt-bindings: ufs: Add document for Unisoc UFS host controller

In reply to Zhe Wang
Quoted 34 lines · Zhe Wang

Add Unisoc ums9620 ufs host controller devicetree document.

---
 .../bindings/ufs/sprd,ums9620-ufs.yaml        | 78 +++++++++++++++++++
 1 file changed, 78 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/ufs/sprd,ums9620-ufs.yaml
Documentation/devicetree/bindings/ufs/sprd,ums9620-ufs.yaml new file +20 -0
new file mode 100644
index 000000000000..ce9d05be1a6b
@@ -0,0 +1,78 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/ufs/sprd,ums9620-ufs.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Unisoc Universal Flash Storage (UFS) Controller
+
+maintainers:
+  - Zhe Wang <[email protected]>
+
+allOf:
+  - $ref: ufs-common.yaml
+
+properties:
+  compatible:
+    const: sprd,ums9620-ufs
+
+  reg:
+    maxItems: 1

Documentation/devicetree/bindings/ufs/sprd,ums9620-ufs.yaml line 30

Quoted 10 lines
Documentation/devicetree/bindings/ufs/sprd,ums9620-ufs.yaml new file +10 -0
+
+  clocks:
+    maxItems: 4
+
+  clock-names:
+    items:
+      - const: ufs_eb
+      - const: ufs_cfg_eb
+      - const: ufsh
+      - const: ufsh_source

Sounds like a parent clock to 'ufsh'? If so, it doesn't belong in 'clocks'. Use the clock API to get the parent or use 'assigned-clock-parents'.

Rob

#6 lore raw

Re: [PATCH v2 1/2] dt-bindings: ufs: Add document for Unisoc UFS host controller

hi Rob,

Quoted 51 lines · Rob Herring
Quoted 34 lines · Zhe Wang

Add Unisoc ums9620 ufs host controller devicetree document.

---
 .../bindings/ufs/sprd,ums9620-ufs.yaml        | 78 +++++++++++++++++++
 1 file changed, 78 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/ufs/sprd,ums9620-ufs.yaml
Documentation/devicetree/bindings/ufs/sprd,ums9620-ufs.yaml new file +20 -0
new file mode 100644
index 000000000000..ce9d05be1a6b
@@ -0,0 +1,78 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/ufs/sprd,ums9620-ufs.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Unisoc Universal Flash Storage (UFS) Controller
+
+maintainers:
+  - Zhe Wang <[email protected]>
+
+allOf:
+  - $ref: ufs-common.yaml
+
+properties:
+  compatible:
+    const: sprd,ums9620-ufs
+
+  reg:
+    maxItems: 1

Documentation/devicetree/bindings/ufs/sprd,ums9620-ufs.yaml line 30

Quoted 10 lines
Documentation/devicetree/bindings/ufs/sprd,ums9620-ufs.yaml new file +10 -0
+
+  clocks:
+    maxItems: 4
+
+  clock-names:
+    items:
+      - const: ufs_eb
+      - const: ufs_cfg_eb
+      - const: ufsh
+      - const: ufsh_source

Sounds like a parent clock to 'ufsh'? If so, it doesn't belong in 'clocks'. Use the clock API to get the parent or use 'assigned-clock-parents'.

Quoted 1 line

Rob

It would be more appropriate to use 'assigned-clock-parents', I'll fix this, thanks.

Best regards,
zhe

author
#7 lore raw

PATCH v2 2/2 scsi: ufs-unisoc: Add support for Unisoc UFS host controller

In reply to Zhe Wang

Add driver code for Unisoc ufs host controller, along with ufs initialization.

---
 drivers/ufs/host/Kconfig    |  12 +
 drivers/ufs/host/Makefile   |   1 +
 drivers/ufs/host/ufs-sprd.c | 484 ++++++++++++++++++++++++++++++++++++
 drivers/ufs/host/ufs-sprd.h |  86 +++++++
 4 files changed, 583 insertions(+)
 create mode 100644 drivers/ufs/host/ufs-sprd.c
 create mode 100644 drivers/ufs/host/ufs-sprd.h
drivers/ufs/host/Kconfig +12 -0
index 4cc2dbd79ed0..90a7142ec846 100644
@@ -124,3 +124,15 @@ config SCSI_UFS_EXYNOS
 
 	  Select this if you have UFS host controller on Samsung Exynos SoC.
 	  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)
+	help
+	  This selects the Unisoc specific additions to UFSHCD platform driver.
+	  UFS host on Unisoc 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 Unisoc chipset.
+	  If unsure, say N.
drivers/ufs/host/Makefile +1 -0
index 7717ca93e7d5..a946c3b35c9d 100644
@@ -13,3 +13,4 @@ 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_TI_J721E) += ti-j721e-ufs.o
+obj-$(CONFIG_SCSI_UFS_SPRD) += ufs-sprd.o
drivers/ufs/host/ufs-sprd.c new file +484 -0

484 lines not on this page · raw message

drivers/ufs/host/ufs-sprd.h new file +86 -0

86 lines not on this page · raw message

Signature · 1 line
2.17.1