Skip to contentSkip to conversation

ufs: Add a PCI UFS controller support

PATCH In review Bin Meng 6 participants 31 messages Oct 11, 2023 – Nov 27, 2023

Subsystems (2)
lore
Share & tools
lore

Bin Meng

author
#0 lore raw

v2 cover ufs: Add a PCI UFS controller support

This adds a PCI UFS controller support and enables the support on QEMU RISC-V for testing.

Requiring QEMU v8.2+.

This series is avaiable at u-boot-x86/ufs for testing.

Changes in v2:
- fix a build warning

Bin Meng (9):
ufs: Correct the UFS terminlogy
ufs: Add a line feed to the end of some dev_xxx() messages
cmd: kconfig: Make ufs prompt look similar to other commands
cmd: ufs: Correct the help text
pci_ids: Add Red Hat vendor and device IDs
ufs: Allow mmio registers on the PCI bus
ufs: Add a PCI based UFS controller driver
ufs: Handle UFS 3.1 controllers
qemu: riscv: Enable UFS support

 board/emulation/qemu-riscv/Kconfig |  2 ++
 cmd/Kconfig                        |  2 +-
 cmd/ufs.c                          |  2 +-
 doc/board/emulation/qemu-riscv.rst |  8 +++++-
 drivers/ufs/Kconfig                | 11 ++++++++
 drivers/ufs/Makefile               |  1 +
 drivers/ufs/ufs-pci.c              | 45 ++++++++++++++++++++++++++++++
 drivers/ufs/ufs-uclass.c           |  2 +-
 drivers/ufs/ufs.c                  | 31 ++++++++++++--------
 drivers/ufs/ufs.h                  |  1 +
 include/pci_ids.h                  |  7 +++++
 11 files changed, 97 insertions(+), 15 deletions(-)
 create mode 100644 drivers/ufs/ufs-pci.c
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH v2 1/9 ufs: Correct the UFS terminlogy

UFS stands for Universal Flash Storage, not Subsytem.

---

(no changes since v1)

 cmd/Kconfig              | 2 +-
 drivers/ufs/ufs-uclass.c | 2 +-
 drivers/ufs/ufs.c        | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
cmd/Kconfig +1 -1
index 6470b138d2..a59c67e333 100644
@@ -1536,7 +1536,7 @@ config CMD_TSI148
 	  Turndra tsi148 device. See the command help for full details.
 
 config CMD_UFS
-	bool "Enable UFS - Universal Flash Subsystem commands"
+	bool "Enable UFS - Universal Flash Storage commands"
 	depends on UFS
 	help
 	  "This provides commands to initialise and configure universal flash
drivers/ufs/ufs-uclass.c +1 -1
index ceea30c4a9..ffae811d46 100644
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 /**
- * ufs-uclass.c - Universal Flash Subsystem (UFS) Uclass driver
+ * ufs-uclass.c - Universal Flash Storage (UFS) Uclass driver
  *
  * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com
  */
drivers/ufs/ufs.c +1 -1
index 7c48d57f99..f534d6e29f 100644
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 /**
- * ufs.c - Universal Flash Subsystem (UFS) driver
+ * ufs.c - Universal Flash Storage (UFS) driver
  *
  * Taken from Linux Kernel v5.2 (drivers/scsi/ufs/ufshcd.c) and ported
  * to u-boot.
Signature · 1 line
2.34.1
Reviewed-by on v2 1/9
#2 lore raw

Re: [PATCH v2 1/9] ufs: Correct the UFS terminlogy

Quoted 4 lines · Bin Meng

UFS stands for Universal Flash Storage, not Subsytem.

Quoted 8 lines

---

(no changes since v1)

 cmd/Kconfig              | 2 +-
 drivers/ufs/ufs-uclass.c | 2 +-
 drivers/ufs/ufs.c        | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
Reviewed-by on v2 1/9
#3 lore raw

Re: [PATCH v2 1/9] ufs: Correct the UFS terminlogy

In reply to Bin Meng

Hi Bin,

Quoted 42 lines · Bin Meng

UFS stands for Universal Flash Storage, not Subsytem.

---

(no changes since v1)

  cmd/Kconfig              | 2 +-
  drivers/ufs/ufs-uclass.c | 2 +-
  drivers/ufs/ufs.c        | 2 +-
  3 files changed, 3 insertions(+), 3 deletions(-)
cmd/Kconfig +1 -1
index 6470b138d2..a59c67e333 100644
@@ -1536,7 +1536,7 @@ config CMD_TSI148
  	  Turndra tsi148 device. See the command help for full details.
 
  config CMD_UFS
-	bool "Enable UFS - Universal Flash Subsystem commands"
+	bool "Enable UFS - Universal Flash Storage commands"
  	depends on UFS
  	help
  	  "This provides commands to initialise and configure universal flash
drivers/ufs/ufs-uclass.c +1 -1
index ceea30c4a9..ffae811d46 100644
@@ -1,6 +1,6 @@
  // SPDX-License-Identifier: GPL-2.0
  /**
- * ufs-uclass.c - Universal Flash Subsystem (UFS) Uclass driver
+ * ufs-uclass.c - Universal Flash Storage (UFS) Uclass driver
   *
   * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com
   */
drivers/ufs/ufs.c +0 -0
index 7c48d57f99..f534d6e29f 100644

drivers/ufs/ufs.c line 6

Quoted 7 lines
drivers/ufs/ufs.c +1 -1
@@ -1,6 +1,6 @@
  // SPDX-License-Identifier: GPL-2.0+
  /**
- * ufs.c - Universal Flash Subsystem (UFS) driver
+ * ufs.c - Universal Flash Storage (UFS) driver
   *
   * Taken from Linux Kernel v5.2 (drivers/scsi/ufs/ufshcd.c) and ported
   * to u-boot.
Signature · 2 lines
Thanking You
Neha Malcom Francis
author
#4 lore raw

PATCH v2 2/9 ufs: Add a line feed to the end of some dev_xxx() messages

In reply to Bin Meng

Add a line feed to improve readability of some dev_xxx() messages.

---

(no changes since v1)

 drivers/ufs/ufs.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/ufs/ufs.c +8 -8
index f534d6e29f..96801866d3 100644
@@ -320,7 +320,7 @@ static int ufshcd_disable_tx_lcc(struct ufs_hba *hba, bool peer)
 					UIC_ARG_MPHY_TX_GEN_SEL_INDEX(i)),
 					0);
 		if (err) {
-			dev_err(hba->dev, "%s: TX LCC Disable failed, peer = %d, lane = %d, err = %d",
+			dev_err(hba->dev, "%s: TX LCC Disable failed, peer = %d, lane = %d, err = %d\n",
 				__func__, peer, i, err);
 			break;
 		}
@@ -441,7 +441,7 @@ static int ufshcd_make_hba_operational(struct ufs_hba *hba)
 		ufshcd_enable_run_stop_reg(hba);
 	} else {
 		dev_err(hba->dev,
-			"Host controller not ready to process requests");
+			"Host controller not ready to process requests\n");
 		err = -EIO;
 		goto out;
 	}
@@ -930,7 +930,7 @@ static int ufshcd_copy_query_response(struct ufs_hba *hba)
 			memcpy(hba->dev_cmd.query.descriptor, descp, resp_len);
 		} else {
 			dev_warn(hba->dev,
-				 "%s: Response size is bigger than buffer",
+				 "%s: Response size is bigger than buffer\n",
 				 __func__);
 			return -EINVAL;
 		}
@@ -1179,11 +1179,11 @@ static int ufshcd_read_desc_length(struct ufs_hba *hba, enum desc_idn desc_id,
 					    &header_len);
 
 	if (ret) {
-		dev_err(hba->dev, "%s: Failed to get descriptor header id %d",
+		dev_err(hba->dev, "%s: Failed to get descriptor header id %d\n",
 			__func__, desc_id);
 		return ret;
 	} else if (desc_id != header[QUERY_DESC_DESC_TYPE_OFFSET]) {
-		dev_warn(hba->dev, "%s: descriptor header id %d and desc_id %d mismatch",
+		dev_warn(hba->dev, "%s: descriptor header id %d and desc_id %d mismatch\n",
 			 __func__, header[QUERY_DESC_DESC_TYPE_OFFSET],
 			 desc_id);
 		ret = -EINVAL;
@@ -1302,7 +1302,7 @@ int ufshcd_read_desc_param(struct ufs_hba *hba, enum desc_idn desc_id,
 
 	/* Sanity checks */
 	if (ret || !buff_len) {
-		dev_err(hba->dev, "%s: Failed to get full descriptor length",
+		dev_err(hba->dev, "%s: Failed to get full descriptor length\n",
 			__func__);
 		return ret;
 	}
@@ -1323,14 +1323,14 @@ int ufshcd_read_desc_param(struct ufs_hba *hba, enum desc_idn desc_id,
 					    &buff_len);
 
 	if (ret) {
-		dev_err(hba->dev, "%s: Failed reading descriptor. desc_id %d, desc_index %d, param_offset %d, ret %d",
+		dev_err(hba->dev, "%s: Failed reading descriptor. desc_id %d, desc_index %d, param_offset %d, ret %d\n",
 			__func__, desc_id, desc_index, param_offset, ret);
 		goto out;
 	}
 
 	/* Sanity check */
 	if (desc_buf[QUERY_DESC_DESC_TYPE_OFFSET] != desc_id) {
-		dev_err(hba->dev, "%s: invalid desc_id %d in descriptor header",
+		dev_err(hba->dev, "%s: invalid desc_id %d in descriptor header\n",
 			__func__, desc_buf[QUERY_DESC_DESC_TYPE_OFFSET]);
 		ret = -EINVAL;
 		goto out;
Signature · 1 line
2.34.1
Reviewed-by on v2 2/9
#5 lore raw

Re: [PATCH v2 2/9] ufs: Add a line feed to the end of some dev_xxx() messages

Quoted 10 lines · Bin Meng

Add a line feed to improve readability of some dev_xxx() messages.

---

(no changes since v1)

 drivers/ufs/ufs.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
Reviewed-by on v2 2/9
#6 lore raw

Re: [PATCH v2 2/9] ufs: Add a line feed to the end of some dev_xxx() messages

In reply to Bin Meng

Hi Bin,

Quoted 71 lines · Bin Meng

Add a line feed to improve readability of some dev_xxx() messages.

---

(no changes since v1)

  drivers/ufs/ufs.c | 16 ++++++++--------
  1 file changed, 8 insertions(+), 8 deletions(-)
drivers/ufs/ufs.c +7 -7
index f534d6e29f..96801866d3 100644
@@ -320,7 +320,7 @@ static int ufshcd_disable_tx_lcc(struct ufs_hba *hba, bool peer)
  					UIC_ARG_MPHY_TX_GEN_SEL_INDEX(i)),
  					0);
  		if (err) {
-			dev_err(hba->dev, "%s: TX LCC Disable failed, peer = %d, lane = %d, err = %d",
+			dev_err(hba->dev, "%s: TX LCC Disable failed, peer = %d, lane = %d, err = %d\n",
  				__func__, peer, i, err);
  			break;
  		}
@@ -441,7 +441,7 @@ static int ufshcd_make_hba_operational(struct ufs_hba *hba)
  		ufshcd_enable_run_stop_reg(hba);
  	} else {
  		dev_err(hba->dev,
-			"Host controller not ready to process requests");
+			"Host controller not ready to process requests\n");
  		err = -EIO;
  		goto out;
  	}
@@ -930,7 +930,7 @@ static int ufshcd_copy_query_response(struct ufs_hba *hba)
  			memcpy(hba->dev_cmd.query.descriptor, descp, resp_len);
  		} else {
  			dev_warn(hba->dev,
-				 "%s: Response size is bigger than buffer",
+				 "%s: Response size is bigger than buffer\n",
  				 __func__);
  			return -EINVAL;
  		}
@@ -1179,11 +1179,11 @@ static int ufshcd_read_desc_length(struct ufs_hba *hba, enum desc_idn desc_id,
  					    &header_len);
 
  	if (ret) {
-		dev_err(hba->dev, "%s: Failed to get descriptor header id %d",
+		dev_err(hba->dev, "%s: Failed to get descriptor header id %d\n",
  			__func__, desc_id);
  		return ret;
  	} else if (desc_id != header[QUERY_DESC_DESC_TYPE_OFFSET]) {
-		dev_warn(hba->dev, "%s: descriptor header id %d and desc_id %d mismatch",
+		dev_warn(hba->dev, "%s: descriptor header id %d and desc_id %d mismatch\n",
  			 __func__, header[QUERY_DESC_DESC_TYPE_OFFSET],
  			 desc_id);
  		ret = -EINVAL;
@@ -1302,7 +1302,7 @@ int ufshcd_read_desc_param(struct ufs_hba *hba, enum desc_idn desc_id,
 
  	/* Sanity checks */
  	if (ret || !buff_len) {
-		dev_err(hba->dev, "%s: Failed to get full descriptor length",
+		dev_err(hba->dev, "%s: Failed to get full descriptor length\n",
  			__func__);
  		return ret;
  	}
@@ -1323,14 +1323,14 @@ int ufshcd_read_desc_param(struct ufs_hba *hba, enum desc_idn desc_id,
  					    &buff_len);
 
  	if (ret) {
-		dev_err(hba->dev, "%s: Failed reading descriptor. desc_id %d, desc_index %d, param_offset %d, ret %d",
+		dev_err(hba->dev, "%s: Failed reading descriptor. desc_id %d, desc_index %d, param_offset %d, ret %d\n",
  			__func__, desc_id, desc_index, param_offset, ret);

drivers/ufs/ufs.c int ufshcd_read_desc_param(struct ufs_hba *hba, enum desc_idn desc_id, · line 1336

Quoted 10 lines
drivers/ufs/ufs.c +1 -1
  		goto out;
  	}
 
  	/* Sanity check */
  	if (desc_buf[QUERY_DESC_DESC_TYPE_OFFSET] != desc_id) {
-		dev_err(hba->dev, "%s: invalid desc_id %d in descriptor header",
+		dev_err(hba->dev, "%s: invalid desc_id %d in descriptor header\n",
  			__func__, desc_buf[QUERY_DESC_DESC_TYPE_OFFSET]);
  		ret = -EINVAL;
  		goto out;
Signature · 2 lines
Thanking You
Neha Malcom Francis
author
#7 lore raw

PATCH v2 3/9 cmd: kconfig: Make ufs prompt look similar to other commands

In reply to Bin Meng

At present the 'ufs' command prompt does not look similar like other commands. Update it.

---

(no changes since v1)

 cmd/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
cmd/Kconfig +1 -1
index a59c67e333..0b4e76c262 100644
@@ -1536,7 +1536,7 @@ config CMD_TSI148
 	  Turndra tsi148 device. See the command help for full details.
 
 config CMD_UFS
-	bool "Enable UFS - Universal Flash Storage commands"
+	bool "ufs - Universal Flash Storage commands"
 	depends on UFS
 	help
 	  "This provides commands to initialise and configure universal flash
Signature · 1 line
2.34.1
Reviewed-by on v2 3/9
#8 lore raw

Re: [PATCH v2 3/9] cmd: kconfig: Make ufs prompt look similar to other commands

Quoted 4 lines · Bin Meng

At present the 'ufs' command prompt does not look similar like other commands. Update it.

Quoted 8 lines

---

(no changes since v1)

 cmd/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by on v2 3/9
#9 lore raw

Re: [PATCH v2 3/9] cmd: kconfig: Make ufs prompt look similar to other commands

In reply to Bin Meng

Hi Bin,

Quoted 16 lines · Bin Meng

At present the 'ufs' command prompt does not look similar like other commands. Update it.

---

(no changes since v1)

  cmd/Kconfig | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
cmd/Kconfig +0 -0
index a59c67e333..0b4e76c262 100644

cmd/Kconfig config CMD_TSI148 · line 1542

Quoted 8 lines
cmd/Kconfig +1 -1
@@ -1536,7 +1536,7 @@ config CMD_TSI148
  	  Turndra tsi148 device. See the command help for full details.
 
  config CMD_UFS
-	bool "Enable UFS - Universal Flash Storage commands"
+	bool "ufs - Universal Flash Storage commands"
  	depends on UFS
  	help
  	  "This provides commands to initialise and configure universal flash
Signature · 2 lines
Thanking You
Neha Malcom Francis
author
#10 lore raw

PATCH v2 4/9 cmd: ufs: Correct the help text

In reply to Bin Meng

Remove the additional space and use "sub-system" for consistency with other commands like "scsi" and "usb".

---

(no changes since v1)

 cmd/ufs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
cmd/ufs.c +1 -1
index 143e946370..2c8d88df18 100644
@@ -32,6 +32,6 @@ static int do_ufs(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 }
 
 U_BOOT_CMD(ufs, 3, 1, do_ufs,
-	   "UFS  sub system",
+	   "UFS sub-system",
 	   "init [dev] - init UFS subsystem\n"
 );
Signature · 1 line
2.34.1
Reviewed-by on v2 4/9
#11 lore raw

Re: [PATCH v2 4/9] cmd: ufs: Correct the help text

Quoted 11 lines · Bin Meng

Remove the additional space and use "sub-system" for consistency with other commands like "scsi" and "usb".

---

(no changes since v1)

 cmd/ufs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by on v2 4/9
#12 lore raw

Re: [PATCH v2 4/9] cmd: ufs: Correct the help text

In reply to Bin Meng

Hi Bin,

Quoted 16 lines · Bin Meng

Remove the additional space and use "sub-system" for consistency with other commands like "scsi" and "usb".

---

(no changes since v1)

  cmd/ufs.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
cmd/ufs.c +0 -0
index 143e946370..2c8d88df18 100644

cmd/ufs.c static int do_ufs(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) · line 37

Quoted 7 lines
cmd/ufs.c +1 -1
@@ -32,6 +32,6 @@ static int do_ufs(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
  }
 
  U_BOOT_CMD(ufs, 3, 1, do_ufs,
-	   "UFS  sub system",
+	   "UFS sub-system",
  	   "init [dev] - init UFS subsystem\n"
  );
Signature · 2 lines
Thanking You
Neha Malcom Francis
author
#13 lore raw

PATCH v2 5/9 pci_ids: Add Red Hat vendor and device IDs

In reply to Bin Meng

Red Hat, Inc. donates a part of its device ID range [1] to QEMU, to be used for virtual devices. This commit adds several typical devices that are useful in U-Boot.

[1] https://www.qemu.org/docs/master/specs/pci-ids.html

---

(no changes since v1)

 include/pci_ids.h | 7 +++++++
 1 file changed, 7 insertions(+)
include/pci_ids.h +7 -0
index 88b0a64045..b63bf45168 100644
@@ -1363,6 +1363,13 @@
 #define PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP 0x3fc5
 #define PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP_MADI 0x3fc6
 
+/* Per https://www.qemu.org/docs/master/specs/pci-ids.html */
+#define PCI_VENDOR_ID_REDHAT            0x1b36
+#define PCI_DEVICE_ID_REDHAT_SDHCI      0x0007
+#define PCI_DEVICE_ID_REDHAT_XHCI       0x000d
+#define PCI_DEVICE_ID_REDHAT_NVME       0x0010
+#define PCI_DEVICE_ID_REDHAT_UFS        0x0013
+
 #define PCI_VENDOR_ID_INIT		0x1101
 
 #define PCI_VENDOR_ID_CREATIVE		0x1102 /* duplicate: ECTIVA */
Signature · 1 line
2.34.1
Reviewed-by on v2 5/9
#14 lore raw

Re: [PATCH v2 5/9] pci_ids: Add Red Hat vendor and device IDs

Quoted 7 lines · Bin Meng

Red Hat, Inc. donates a part of its device ID range [1] to QEMU, to be used for virtual devices. This commit adds several typical devices that are useful in U-Boot.

[1] https://www.qemu.org/docs/master/specs/pci-ids.html

Quoted 7 lines

---

(no changes since v1)

 include/pci_ids.h | 7 +++++++
 1 file changed, 7 insertions(+)
Reviewed-by on v2 5/9
#15 lore raw

Re: [PATCH v2 5/9] pci_ids: Add Red Hat vendor and device IDs

In reply to Bin Meng

Hi Bin

Quoted 22 lines · Bin Meng

Red Hat, Inc. donates a part of its device ID range [1] to QEMU, to be used for virtual devices. This commit adds several typical devices that are useful in U-Boot.

[1] https://www.qemu.org/docs/master/specs/pci-ids.html

---

(no changes since v1)

  include/pci_ids.h | 7 +++++++
  1 file changed, 7 insertions(+)
include/pci_ids.h +0 -0
index 88b0a64045..b63bf45168 100644
@@ -1363,6 +1363,13 @@
  #define PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP 0x3fc5
  #define PCI_DEVICE_ID_XILINX_HAMMERFALL_DSP_MADI 0x3fc6
 

include/pci_ids.h line 1375

Quoted 10 lines
include/pci_ids.h +7 -0
+/* Per https://www.qemu.org/docs/master/specs/pci-ids.html */
+#define PCI_VENDOR_ID_REDHAT            0x1b36
+#define PCI_DEVICE_ID_REDHAT_SDHCI      0x0007
+#define PCI_DEVICE_ID_REDHAT_XHCI       0x000d
+#define PCI_DEVICE_ID_REDHAT_NVME       0x0010
+#define PCI_DEVICE_ID_REDHAT_UFS        0x0013
+
  #define PCI_VENDOR_ID_INIT		0x1101
 
  #define PCI_VENDOR_ID_CREATIVE		0x1102 /* duplicate: ECTIVA */
Signature · 2 lines
Thanking You
Neha Malcom Francis
author
#16 lore raw

PATCH v2 6/9 ufs: Allow mmio registers on the PCI bus

In reply to Bin Meng

Check if the UFS controller is on the PCI bus, and get its register base address accordingly.

---

(no changes since v1)

 drivers/ufs/ufs.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/ufs/ufs.c +9 -1
index 96801866d3..fb2a607ef1 100644
@@ -1914,6 +1914,7 @@ int ufshcd_probe(struct udevice *ufs_dev, struct ufs_hba_ops *hba_ops)
 	struct ufs_hba *hba = dev_get_uclass_priv(ufs_dev);
 	struct scsi_plat *scsi_plat;
 	struct udevice *scsi_dev;
+	void __iomem *mmio_base;
 	int err;
 
 	device_find_first_child(ufs_dev, &scsi_dev);
@@ -1927,7 +1928,14 @@ int ufshcd_probe(struct udevice *ufs_dev, struct ufs_hba_ops *hba_ops)
 
 	hba->dev = ufs_dev;
 	hba->ops = hba_ops;
-	hba->mmio_base = dev_read_addr_ptr(ufs_dev);
+
+	if (device_is_on_pci_bus(ufs_dev)) {
+		mmio_base = dm_pci_map_bar(ufs_dev, PCI_BASE_ADDRESS_0, 0, 0,
+					   PCI_REGION_TYPE, PCI_REGION_MEM);
+	} else {
+		mmio_base = dev_read_addr_ptr(ufs_dev);
+	}
+	hba->mmio_base = mmio_base;
 
 	/* Set descriptor lengths to specification defaults */
 	ufshcd_def_desc_sizes(hba);
Signature · 1 line
2.34.1
Reviewed-by on v2 6/9
#17 lore raw

Re: [PATCH v2 6/9] ufs: Allow mmio registers on the PCI bus

Quoted 4 lines · Bin Meng

Check if the UFS controller is on the PCI bus, and get its register base address accordingly.

Quoted 8 lines

---

(no changes since v1)

 drivers/ufs/ufs.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
Reviewed-by on v2 6/9
#18 lore raw

Re: [PATCH v2 6/9] ufs: Allow mmio registers on the PCI bus

In reply to Bin Meng

Hi Bin,

Quoted 29 lines · Bin Meng

Check if the UFS controller is on the PCI bus, and get its register base address accordingly.

---

(no changes since v1)

  drivers/ufs/ufs.c | 10 +++++++++-
  1 file changed, 9 insertions(+), 1 deletion(-)
drivers/ufs/ufs.c +2 -1
index 96801866d3..fb2a607ef1 100644
@@ -1914,6 +1914,7 @@ int ufshcd_probe(struct udevice *ufs_dev, struct ufs_hba_ops *hba_ops)
  	struct ufs_hba *hba = dev_get_uclass_priv(ufs_dev);
  	struct scsi_plat *scsi_plat;
  	struct udevice *scsi_dev;
+	void __iomem *mmio_base;
  	int err;
 
  	device_find_first_child(ufs_dev, &scsi_dev);
@@ -1927,7 +1928,14 @@ int ufshcd_probe(struct udevice *ufs_dev, struct ufs_hba_ops *hba_ops)
 
  	hba->dev = ufs_dev;
  	hba->ops = hba_ops;
-	hba->mmio_base = dev_read_addr_ptr(ufs_dev);
+

drivers/ufs/ufs.c int ufshcd_probe(struct udevice *ufs_dev, struct ufs_hba_ops *hba_ops) · line 1941

Quoted 10 lines
drivers/ufs/ufs.c +7 -0
+	if (device_is_on_pci_bus(ufs_dev)) {
+		mmio_base = dm_pci_map_bar(ufs_dev, PCI_BASE_ADDRESS_0, 0, 0,
+					   PCI_REGION_TYPE, PCI_REGION_MEM);
+	} else {
+		mmio_base = dev_read_addr_ptr(ufs_dev);
+	}
+	hba->mmio_base = mmio_base;
 
  	/* Set descriptor lengths to specification defaults */
  	ufshcd_def_desc_sizes(hba);
Signature · 2 lines
Thanking You
Neha Malcom Francis
author
#19 lore raw

PATCH v2 7/9 ufs: Add a PCI based UFS controller driver

In reply to Bin Meng

This adds a simple PCI based UFS controller driver with a QEMU emulated UFS controller on the PCI bus.

Requiring QEMU v8.2+.

---

Changes in v2:
- fix a build warning

 drivers/ufs/Kconfig   | 11 +++++++++++
 drivers/ufs/Makefile  |  1 +
 drivers/ufs/ufs-pci.c | 45 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 57 insertions(+)
 create mode 100644 drivers/ufs/ufs-pci.c
drivers/ufs/Kconfig +11 -0
index 0e0cc58e3d..42797ce052 100644
@@ -15,6 +15,17 @@ config CADENCE_UFS
 	  This selects the platform driver for the Cadence UFS host
 	  controller present on present TI's J721e devices.
 
+config UFS_PCI
+	bool "PCI bus based UFS Controller support"
+	depends on PCI && UFS
+	help
+	  This selects the PCI UFS Host Controller Interface. Select this if
+	  you have UFS Host Controller with PCI Interface.
+
+	  If you have a controller with this interface, say Y here.
+
+	  If unsure, say N.
+
 config TI_J721E_UFS
 	bool "Glue Layer driver for UFS on TI J721E devices"
 	help
drivers/ufs/Makefile +1 -0
index 4f3344fd4e..13f1e689ef 100644
@@ -6,4 +6,5 @@
 obj-$(CONFIG_UFS) += ufs.o ufs-uclass.o
 obj-$(CONFIG_CADENCE_UFS) += cdns-platform.o
 obj-$(CONFIG_TI_J721E_UFS) += ti-j721e-ufs.o
+obj-$(CONFIG_UFS_PCI) += ufs-pci.o
 obj-$(CONFIG_UFS_RENESAS) += ufs-renesas.o
drivers/ufs/ufs-pci.c new file +45 -0

45 lines not on this page · raw message

Signature · 1 line
2.34.1
Reviewed-by on v2 7/9
#20 lore raw

Re: [PATCH v2 7/9] ufs: Add a PCI based UFS controller driver

Quoted 10 lines · Bin Meng

This adds a simple PCI based UFS controller driver with a QEMU emulated UFS controller on the PCI bus.

Requiring QEMU v8.2+.

---

Quoted 8 lines

Changes in v2:
- fix a build warning

 drivers/ufs/Kconfig   | 11 +++++++++++
 drivers/ufs/Makefile  |  1 +
 drivers/ufs/ufs-pci.c | 45 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 57 insertions(+)
 create mode 100644 drivers/ufs/ufs-pci.c
Reviewed-by on v2 7/9
#21 lore raw

Re: [PATCH v2 7/9] ufs: Add a PCI based UFS controller driver

In reply to Bin Meng

Hi Bin,

Quoted 9 lines · Bin Meng

This adds a simple PCI based UFS controller driver with a QEMU emulated UFS controller on the PCI bus.

Requiring QEMU v8.2+.

---

Quoted 9 lines

Changes in v2:
- fix a build warning

  drivers/ufs/Kconfig   | 11 +++++++++++
  drivers/ufs/Makefile  |  1 +
  drivers/ufs/ufs-pci.c | 45 +++++++++++++++++++++++++++++++++++++++++++
  3 files changed, 57 insertions(+)

create mode 100644 drivers/ufs/ufs-pci.c

Signature · 2 lines
Thanking You
Neha Malcom Francis
author
#22 lore raw

PATCH v2 8/9 ufs: Handle UFS 3.1 controllers

In reply to Bin Meng

Extend the version check to handle UFS 3.1 controllers as well. Tested on QEMU emulated UFS 3.1 controller.

---

(no changes since v1)

 drivers/ufs/ufs.c | 3 ++-
 drivers/ufs/ufs.h | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/ufs/ufs.c +2 -1
index fb2a607ef1..6287ce91a3 100644
@@ -1953,7 +1953,8 @@ int ufshcd_probe(struct udevice *ufs_dev, struct ufs_hba_ops *hba_ops)
 	    hba->version != UFSHCI_VERSION_11 &&
 	    hba->version != UFSHCI_VERSION_20 &&
 	    hba->version != UFSHCI_VERSION_21 &&
-	    hba->version != UFSHCI_VERSION_30)
+	    hba->version != UFSHCI_VERSION_30 &&
+	    hba->version != UFSHCI_VERSION_31)
 		dev_err(hba->dev, "invalid UFS version 0x%x\n",
 			hba->version);
 
drivers/ufs/ufs.h +1 -0
index 9daaf03d22..816a5ce0ca 100644
@@ -782,6 +782,7 @@ enum {
 	UFSHCI_VERSION_20 = 0x00000200, /* 2.0 */
 	UFSHCI_VERSION_21 = 0x00000210, /* 2.1 */
 	UFSHCI_VERSION_30 = 0x00000300, /* 3.0 */
+	UFSHCI_VERSION_31 = 0x00000310, /* 3.1 */
 };
 
 /* Interrupt disable masks */
Signature · 1 line
2.34.1
Reviewed-by on v2 8/9
#23 lore raw

Re: [PATCH v2 8/9] ufs: Handle UFS 3.1 controllers

Quoted 4 lines · Bin Meng

Extend the version check to handle UFS 3.1 controllers as well. Tested on QEMU emulated UFS 3.1 controller.

Quoted 9 lines

---

(no changes since v1)

 drivers/ufs/ufs.c | 3 ++-
 drivers/ufs/ufs.h | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)
Reviewed-by on v2 8/9
#24 lore raw

Re: [PATCH v2 8/9] ufs: Handle UFS 3.1 controllers

In reply to Bin Meng

Hi Bin

Quoted 31 lines · Bin Meng

Extend the version check to handle UFS 3.1 controllers as well. Tested on QEMU emulated UFS 3.1 controller.

---

(no changes since v1)

  drivers/ufs/ufs.c | 3 ++-
  drivers/ufs/ufs.h | 1 +
  2 files changed, 3 insertions(+), 1 deletion(-)
drivers/ufs/ufs.c +2 -1
index fb2a607ef1..6287ce91a3 100644
@@ -1953,7 +1953,8 @@ int ufshcd_probe(struct udevice *ufs_dev, struct ufs_hba_ops *hba_ops)
  	    hba->version != UFSHCI_VERSION_11 &&
  	    hba->version != UFSHCI_VERSION_20 &&
  	    hba->version != UFSHCI_VERSION_21 &&
-	    hba->version != UFSHCI_VERSION_30)
+	    hba->version != UFSHCI_VERSION_30 &&
+	    hba->version != UFSHCI_VERSION_31)
  		dev_err(hba->dev, "invalid UFS version 0x%x\n",
  			hba->version);
 
drivers/ufs/ufs.h +0 -0
index 9daaf03d22..816a5ce0ca 100644

drivers/ufs/ufs.h enum { · line 788

Quoted 7 lines
drivers/ufs/ufs.h +1 -0
@@ -782,6 +782,7 @@ enum {
  	UFSHCI_VERSION_20 = 0x00000200, /* 2.0 */
  	UFSHCI_VERSION_21 = 0x00000210, /* 2.1 */
  	UFSHCI_VERSION_30 = 0x00000300, /* 3.0 */
+	UFSHCI_VERSION_31 = 0x00000310, /* 3.1 */
  };
 
  /* Interrupt disable masks */
Signature · 2 lines
Thanking You
Neha Malcom Francis
author
#25 lore raw

PATCH v2 9/9 qemu: riscv: Enable UFS support

In reply to Bin Meng

This enables UFS support for QEMU RISC-V 'virt' machine.

---

(no changes since v1)

 board/emulation/qemu-riscv/Kconfig | 2 ++
 doc/board/emulation/qemu-riscv.rst | 8 +++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)
board/emulation/qemu-riscv/Kconfig +2 -0
index d56b4b5bc1..f3ee1f6e90 100644
@@ -82,5 +82,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
 	imply USB_XHCI_PCI
 	imply USB_KEYBOARD
 	imply CMD_USB
+	imply UFS
+	imply UFS_PCI
 
 endif
doc/board/emulation/qemu-riscv.rst +7 -1
index 61137bcbf1..8a5eb1eda5 100644
@@ -131,7 +131,13 @@ An attached disk can be emulated in RISC-V virt machine by adding::
     -drive if=none,file=riscv64.img,format=raw,id=mydisk \
     -device ide-hd,drive=mydisk,bus=ahci.0
 
-You will have to run 'scsi scan' to use it.
+or alternatively attach an emulated UFS::
+
+    -device ufs,id=ufs0 \
+    -drive if=none,file=test.img,format=raw,id=lun0 \
+    -device ufs-lu,drive=lun0,bus=ufs0
+
+You will have to run 'scsi scan' to use them.
 
 A video console can be emulated in RISC-V virt machine by removing "-nographic"
 and adding::
Signature · 1 line
2.34.1
Reviewed-by on v2 9/9
#26 lore raw

Re: [PATCH v2 9/9] qemu: riscv: Enable UFS support

Quoted 5 lines · Bin Meng

This enables UFS support for QEMU RISC-V 'virt' machine.

Quoted 7 lines

---

(no changes since v1)

 board/emulation/qemu-riscv/Kconfig | 2 ++
 doc/board/emulation/qemu-riscv.rst | 8 +++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)
Reviewed-by on v2 9/9
#27 lore raw

Re: [PATCH v2 9/9] qemu: riscv: Enable UFS support

In reply to Bin Meng

Hi Bin

Quoted 33 lines · Bin Meng

This enables UFS support for QEMU RISC-V 'virt' machine.

---

(no changes since v1)

  board/emulation/qemu-riscv/Kconfig | 2 ++
  doc/board/emulation/qemu-riscv.rst | 8 +++++++-
  2 files changed, 9 insertions(+), 1 deletion(-)
board/emulation/qemu-riscv/Kconfig +2 -0
index d56b4b5bc1..f3ee1f6e90 100644
@@ -82,5 +82,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
  	imply USB_XHCI_PCI
  	imply USB_KEYBOARD
  	imply CMD_USB
+	imply UFS
+	imply UFS_PCI
 
  endif
doc/board/emulation/qemu-riscv.rst +0 -1
index 61137bcbf1..8a5eb1eda5 100644
@@ -131,7 +131,13 @@ An attached disk can be emulated in RISC-V virt machine by adding::
      -drive if=none,file=riscv64.img,format=raw,id=mydisk \
      -device ide-hd,drive=mydisk,bus=ahci.0
 
-You will have to run 'scsi scan' to use it.

doc/board/emulation/qemu-riscv.rst An attached disk can be emulated in RISC-V virt machine by adding:: · line 143

Quoted 10 lines
doc/board/emulation/qemu-riscv.rst +7 -0
+or alternatively attach an emulated UFS::
+
+    -device ufs,id=ufs0 \
+    -drive if=none,file=test.img,format=raw,id=lun0 \
+    -device ufs-lu,drive=lun0,bus=ufs0
+
+You will have to run 'scsi scan' to use them.
 
  A video console can be emulated in RISC-V virt machine by removing "-nographic"
  and adding::
Signature · 2 lines
Thanking You
Neha Malcom Francis
#28 lore raw
In reply to Bin Meng

+ Marek,

Quoted 22 lines · Bin Meng

This adds a PCI UFS controller support and enables the support on QEMU RISC-V for testing.

Requiring QEMU v8.2+.

This series is avaiable at u-boot-x86/ufs for testing.

Changes in v2:
- fix a build warning

Bin Meng (9):
ufs: Correct the UFS terminlogy
ufs: Add a line feed to the end of some dev_xxx() messages
cmd: kconfig: Make ufs prompt look similar to other commands
cmd: ufs: Correct the help text
pci_ids: Add Red Hat vendor and device IDs
ufs: Allow mmio registers on the PCI bus
ufs: Add a PCI based UFS controller driver
ufs: Handle UFS 3.1 controllers
qemu: riscv: Enable UFS support

Quoted 14 lines
 board/emulation/qemu-riscv/Kconfig |  2 ++
 cmd/Kconfig                        |  2 +-
 cmd/ufs.c                          |  2 +-
 doc/board/emulation/qemu-riscv.rst |  8 +++++-
 drivers/ufs/Kconfig                | 11 ++++++++
 drivers/ufs/Makefile               |  1 +
 drivers/ufs/ufs-pci.c              | 45 ++++++++++++++++++++++++++++++
 drivers/ufs/ufs-uclass.c           |  2 +-
 drivers/ufs/ufs.c                  | 31 ++++++++++++--------
 drivers/ufs/ufs.h                  |  1 +
 include/pci_ids.h                  |  7 +++++
 11 files changed, 97 insertions(+), 15 deletions(-)
 create mode 100644 drivers/ufs/ufs-pci.c

Ping?

#29 lore raw
Quoted 38 lines · Bin Meng

+ Marek,

Quoted 35 lines · Bin Meng

This adds a PCI UFS controller support and enables the support on QEMU RISC-V for testing.

Requiring QEMU v8.2+.

This series is avaiable at u-boot-x86/ufs for testing.

Changes in v2:
- fix a build warning

Bin Meng (9):
ufs: Correct the UFS terminlogy
ufs: Add a line feed to the end of some dev_xxx() messages
cmd: kconfig: Make ufs prompt look similar to other commands
cmd: ufs: Correct the help text
pci_ids: Add Red Hat vendor and device IDs
ufs: Allow mmio registers on the PCI bus
ufs: Add a PCI based UFS controller driver
ufs: Handle UFS 3.1 controllers
qemu: riscv: Enable UFS support

  board/emulation/qemu-riscv/Kconfig |  2 ++
  cmd/Kconfig                        |  2 +-
  cmd/ufs.c                          |  2 +-
  doc/board/emulation/qemu-riscv.rst |  8 +++++-
  drivers/ufs/Kconfig                | 11 ++++++++
  drivers/ufs/Makefile               |  1 +
  drivers/ufs/ufs-pci.c              | 45 ++++++++++++++++++++++++++++++
  drivers/ufs/ufs-uclass.c           |  2 +-
  drivers/ufs/ufs.c                  | 31 ++++++++++++--------
  drivers/ufs/ufs.h                  |  1 +
  include/pci_ids.h                  |  7 +++++
  11 files changed, 97 insertions(+), 15 deletions(-)

create mode 100644 drivers/ufs/ufs-pci.c

Thanks, uh ... could you please just CC me on V3 (if there is one) ?

#30 lore raw
In reply to Bin Meng
Quoted 8 lines · Bin Meng

This adds a PCI UFS controller support and enables the support on QEMU RISC-V for testing.

Requiring QEMU v8.2+.

This series is avaiable at u-boot-x86/ufs for testing.

[...]

Applied to u-boot/next, thanks!

Signature · 1 line
Tom