Skip to contentSkip to conversation

Add DesignWare Mobile mmc driver

PATCH In review Jyan Chou 7 participants 22 messages Nov 21, 2023 – Dec 11, 2023

Subsystems (4)
lore
Share & tools
lore

Jyan Chou

author
#0 lore raw

v7 cover Add DesignWare Mobile mmc driver

We added Synopsys DesignWare mmc cmdq driver and also added Realtek mmc driver to make good use of it.

Jyan Chou (4):
mmc: solve DMA boundary limitation of CQHCI driver
mmc: Add Synopsys DesignWare mmc cmdq host driver
mmc: Add dw mobile mmc cmdq rtk driver
dt-bindings: mmc: Add dt-bindings for realtek mmc driver

 .../bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml |  153 ++
 drivers/mmc/host/Kconfig                      |   22 +
 drivers/mmc/host/Makefile                     |    2 +
 drivers/mmc/host/cqhci-core.c                 |   13 +-
 drivers/mmc/host/cqhci.h                      |    8 +
 drivers/mmc/host/dw_mmc_cqe-rtk.c             |  768 +++++++++
 drivers/mmc/host/dw_mmc_cqe-rtk.h             |  160 ++
 drivers/mmc/host/dw_mmc_cqe.c                 | 1467 +++++++++++++++++
 drivers/mmc/host/dw_mmc_cqe.h                 |  456 +++++
 9 files changed, 3046 insertions(+), 3 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml
 create mode 100644 drivers/mmc/host/dw_mmc_cqe-rtk.c
 create mode 100644 drivers/mmc/host/dw_mmc_cqe-rtk.h
 create mode 100644 drivers/mmc/host/dw_mmc_cqe.c
 create mode 100644 drivers/mmc/host/dw_mmc_cqe.h
Signature · 1 line
2.42.0
author
#1 lore raw

PATCH v7 1/4 mmc: solve DMA boundary limitation of CQHCI driver

Due to synopsys data book's description, it had a limitation while using DMA that buffer size and start address must not exceed 128 MB.

We add an option setup_tran_desc to make tran_desc setting flexible.

---
v6 -> v7:
- fix kernel test robot build errors, error: no member named 'setup_tran_desc' in 'struct cqhci_host_ops'

v4 -> v5:
- use EXPORT_SYMBOL_GPL to replace EXPORT_SYMBOL
- Fix kernel test robot build errors, let 'setup_tran_desc' to be a member in 'const struct cqhci_host_ops'.

v2 -> v3:
- Fix auto test compile warning.

v1 -> v2:
- Export cqhci_set_tran_desc for setting the descriptor's callback function.

v0 -> v1:
- Separate different patch supports into single patch.

---
 drivers/mmc/host/cqhci-core.c | 13 ++++++++++---
 drivers/mmc/host/cqhci.h      |  8 ++++++++
 2 files changed, 18 insertions(+), 3 deletions(-)
drivers/mmc/host/cqhci-core.c +10 -3
index b3d7d6d8d654..b40bd368a955 100644
@@ -474,8 +474,7 @@ static int cqhci_dma_map(struct mmc_host *host, struct mmc_request *mrq)
 	return sg_count;
 }
 
-static void cqhci_set_tran_desc(u8 *desc, dma_addr_t addr, int len, bool end,
-				bool dma64)
+void cqhci_set_tran_desc(u8 *desc, dma_addr_t addr, int len, bool end, bool dma64)
 {
 	__le32 *attr = (__le32 __force *)desc;
 
@@ -495,9 +494,10 @@ static void cqhci_set_tran_desc(u8 *desc, dma_addr_t addr, int len, bool end,
 		dataddr[0] = cpu_to_le32(addr);
 	}
 }
+EXPORT_SYMBOL_GPL(cqhci_set_tran_desc);
 
 static int cqhci_prep_tran_desc(struct mmc_request *mrq,
-			       struct cqhci_host *cq_host, int tag)
+				struct cqhci_host *cq_host, int tag)
 {
 	struct mmc_data *data = mrq->data;
 	int i, sg_count, len;
@@ -516,6 +516,13 @@ static int cqhci_prep_tran_desc(struct mmc_request *mrq,
 
 	desc = get_trans_desc(cq_host, tag);
 
+#ifdef CONFIG_MMC_DW_CQE
+	if (cq_host->ops->setup_tran_desc) {
+		cq_host->ops->setup_tran_desc(data, cq_host, desc, sg_count);
+		return 0;
+	}
+#endif
+
 	for_each_sg(data->sg, sg, sg_count, i) {
 		addr = sg_dma_address(sg);
 		len = sg_dma_len(sg);
drivers/mmc/host/cqhci.h +8 -0
index 1a12e40a02e6..713fc56127df 100644
@@ -216,6 +216,7 @@ union cqhci_crypto_cfg_entry {
 struct cqhci_host_ops;
 struct mmc_host;
 struct mmc_request;
+struct mmc_data;
 struct cqhci_slot;
 
 struct cqhci_host {
@@ -293,6 +294,11 @@ struct cqhci_host_ops {
 	int (*program_key)(struct cqhci_host *cq_host,
 			   const union cqhci_crypto_cfg_entry *cfg, int slot);
 #endif
+
+#ifdef CONFIG_MMC_DW_CQE
+	void (*setup_tran_desc)(struct mmc_data *data,
+				struct cqhci_host *cq_host, u8 *desc, int sg_count);
+#endif
 };
 
 static inline void cqhci_writel(struct cqhci_host *host, u32 val, int reg)
@@ -322,6 +328,8 @@ static inline int cqhci_suspend(struct mmc_host *mmc)
 {
 	return cqhci_deactivate(mmc);
 }
+
+void cqhci_set_tran_desc(u8 *desc, dma_addr_t addr, int len, bool end, bool dma64);
 int cqhci_resume(struct mmc_host *mmc);
 
 #endif
Signature · 1 line
2.42.0
author
#2 lore raw

PATCH v7 2/4 mmc: Add Synopsys DesignWare mmc cmdq host driver

In reply to Jyan Chou

We implemented cmdq feature on Synopsys DesignWare mmc driver. The difference between dw_mmc.c and dw_mmc_cqe.c were distinct register definitions, mmc user flow and the addition of cmdq.

New version of User Guide had modify mmc driver's usage flow, we may need to renew code to precisely follow user guide.

More over, We added a wait status function to satisfy synopsys user guide's description, since this flow might be specific in synopsys host driver only.

—--
v6 -> v7:
- Remove reset-names in driver and adjust reset control's code.

v5 -> v6:
- Fix linux coding style issues.
- Drop useless code that is not described in the bindings.
- Replace devm_clk_get and clk_prepare_enable with devm_clk_get_enabled.
- Replace EXPORT_SYMBOL with EXPORT_SYMBOL_GPL.

v4 -> v5:
- Fix linux coding style issues.
- Fix test robot build errors to make good use of setup_tran_desc call back function.
- Remove useless function.

v3 -> v4:
- Modify dma mode selection and dma addressing bit to statisfy linux coding style.

v1 -> v2:
- Remove dw_mci_cqe_set_tran_desc due to the duplicated function.
- Add ->pre_enable() / ->post_disable()

v0 -> v1:
- Seperate different support into single patch.
- Fix the compiler complains.
---

---
 drivers/mmc/host/Kconfig      |   13 +
 drivers/mmc/host/Makefile     |    1 +
 drivers/mmc/host/dw_mmc_cqe.c | 1467 +++++++++++++++++++++++++++++++++
 drivers/mmc/host/dw_mmc_cqe.h |  456 ++++++++++
 4 files changed, 1937 insertions(+)
 create mode 100644 drivers/mmc/host/dw_mmc_cqe.c
 create mode 100644 drivers/mmc/host/dw_mmc_cqe.h
drivers/mmc/host/Kconfig +13 -0
index 58bd5fe4cd25..06bb4de28cc4 100644
@@ -837,6 +837,19 @@ config MMC_DW_STARFIVE
 	  Synopsys DesignWare Memory Card Interface driver. Select this option
 	  for platforms based on StarFive JH7110 SoC.
 
+config MMC_DW_CQE
+	tristate "Synopsys DesignWare Memory Card with CQE Interface"
+	depends on ARC || ARM || ARM64 || MIPS || COMPILE_TEST
+	select MMC_CQHCI
+	help
+	 This selects support for the Synopsys DesignWare Mobile Storage IP
+	 block after JEDEC Standard version 5.1. Select this option for SD and
+	 MMC interfaces that use command queue.
+
+	 If you have a controller with this interface, say Y or M here.
+
+	 If unsure, say Y.
+
 config MMC_SH_MMCIF
 	tristate "SuperH Internal MMCIF support"
 	depends on SUPERH || ARCH_RENESAS || COMPILE_TEST
drivers/mmc/host/Makefile +1 -0
index d0be4465f3ec..464fe58f8541 100644
@@ -55,6 +55,7 @@ obj-$(CONFIG_MMC_DW_K3)		+= dw_mmc-k3.o
 obj-$(CONFIG_MMC_DW_PCI)	+= dw_mmc-pci.o
 obj-$(CONFIG_MMC_DW_ROCKCHIP)	+= dw_mmc-rockchip.o
 obj-$(CONFIG_MMC_DW_STARFIVE)	+= dw_mmc-starfive.o
+obj-$(CONFIG_MMC_DW_CQE)	+= dw_mmc_cqe.o
 obj-$(CONFIG_MMC_SH_MMCIF)	+= sh_mmcif.o
 obj-$(CONFIG_MMC_JZ4740)	+= jz4740_mmc.o
 obj-$(CONFIG_MMC_VUB300)	+= vub300.o
drivers/mmc/host/dw_mmc_cqe.c new file +1467 -0

1,467 lines not on this page · raw message

drivers/mmc/host/dw_mmc_cqe.h new file +456 -0

456 lines not on this page · raw message

Signature · 1 line
2.42.0
#3 lore raw

Re: [PATCH v7][2/4] mmc: Add Synopsys DesignWare mmc cmdq host driver

kernel test robot noticed the following build warnings:

Hi Jyan,

kernel test robot noticed the following build warnings:

[auto build test WARNING on linus/master]
[also build test WARNING on ulf-hansson-mmc-mirror/next v6.7-rc2 next-20231121] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Jyan-Chou/mmc-Add-Synopsys-DesignWare-mmc-cmdq-host-driver/20231121-171551
base:   linus/master
patch link:    https://lore.kernel.org/r/20231121091101.5540-3-jyanchou%40realtek.com
patch subject: [PATCH v7][2/4] mmc: Add Synopsys DesignWare mmc cmdq host driver
config: mips-randconfig-r133-20231122 (https://download.01.org/0day-ci/archive/20231122/[email protected]/config)
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a)
reproduce: (https://download.01.org/0day-ci/archive/20231122/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

In file included from drivers/mmc/host/dw_mmc_cqe.c:39:

>> drivers/mmc/host/dw_mmc_cqe.h:324:9: warning: 'END' macro redefined [-Wmacro-redefined]
     324 | #define END(x)                          (((x) & 1) << 1)
         |         ^
   arch/mips/include/asm/asm.h:69:9: note: previous definition is here
      69 | #define END(function)                                   \
         |         ^
   drivers/mmc/host/dw_mmc_cqe.c:174:3: error: field designator 'setup_tran_desc' does not refer to any field in type 'const struct cqhci_host_ops'
     174 |         .setup_tran_desc = dw_mci_cqe_setup_tran_desc,
         |         ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

1 warning and 1 error generated.

vim +/END +324 drivers/mmc/host/dw_mmc_cqe.h

322
323 #define VALID(x) (((x) & 1) << 0)

 > 324	#define END(x)				(((x) & 1) << 1)

325 #define INT(x) (((x) & 1) << 2)
326 #define ACT(x) (((x) & 0x7) << 3)
327 #define DAT_LENGTH(x) (((x) & 0xFFFF) << 16)
328

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#4 lore raw

Re: [PATCH v7][2/4] mmc: Add Synopsys DesignWare mmc cmdq host driver

In reply to Jyan Chou
kernel test robot noticed the following build warnings:

Hi Jyan,

kernel test robot noticed the following build warnings:

[auto build test WARNING on linus/master]
[also build test WARNING on ulf-hansson-mmc-mirror/next v6.7-rc2 next-20231122] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Jyan-Chou/mmc-Add-Synopsys-DesignWare-mmc-cmdq-host-driver/20231121-171551
base:   linus/master
patch link:    https://lore.kernel.org/r/20231121091101.5540-3-jyanchou%40realtek.com
patch subject: [PATCH v7][2/4] mmc: Add Synopsys DesignWare mmc cmdq host driver
config: m68k-kismet-CONFIG_MMC_CQHCI-CONFIG_MMC_DW_CQE-0-0 (https://download.01.org/0day-ci/archive/20231122/[email protected]/config)
reproduce: (https://download.01.org/0day-ci/archive/20231122/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

kismet warnings: (new ones prefixed by >>)

>> kismet: WARNING: unmet direct dependencies detected for MMC_CQHCI when selected by MMC_DW_CQE

/usr/bin/grep: /db/releases/20231122101355/kernel-tests/etc/kcflags: No such file or directory
{"timestamp":"2023-11-22 18:07:24 +0800", "level":"WARN", "event":"kbuild.sh:3942:in `add_etc_kcflags': grep exit 2 (ShellError)", "detail":"cmd: '/usr/bin/grep' '-v' '-e' '^#' '-e' '^$' '/db/releases/20231122101355/kernel-tests/etc/kcflags' \nstderr: /usr/bin/grep: /db/releases/20231122101355/kernel-tests/etc/kcflags: No such file or directory\n\n", "hostname":"community-kbuild-consumer-181", "host_hostname":"lkp-worker74", "call_stack":"/zday/kernel-tests/lib/kbuild.sh:3942:in `add_etc_kcflags': /usr/bin/grep: /db/releases/20231122101355/kernel-tests/etc/kcflags: No such file or directory (ShellError 2)\n from /zday/kernel-tests/lib/kbuild.sh:3971: setup_kcflags\n from /zday/kernel-tests/lib/kbuild.sh:4016: invoke_make\n from /zday/kernel-tests/lib/kbuild.sh:4122: make\n from /zday/kernel-tests/lib/kbuild.sh:5623: make_config_allyes\n from /zday/kernel-tests/common.sh:209: redirect_error_to_screen\n from /zday/kernel-tests/common.sh:217: redirect_command_errors\n from /zday/kernel-tests/lib/kbuild.sh:5630: make_config\n from /zday/kernel-tests/lib/builder/kismet.sh:156: generate_make_olddefconfig_warnings\n from /zday/kernel-tests/lib/builder/kismet.sh:297: builder_compile\n from /zday/kernel-tests/bisect-test-build-error.sh:94: main\n"}

WARNING: unmet direct dependencies detected for MMC_CQHCI
Depends on [n]: MMC [=y] && HAS_DMA [=n]
Selected by [y]:
- MMC_DW_CQE [=y] && MMC [=y] && (ARC || ARM || ARM64 || MIPS || COMPILE_TEST [=y])

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#5 lore raw

Re: [PATCH v7][2/4] mmc: Add Synopsys DesignWare mmc cmdq host driver

In reply to Jyan Chou

Hi,

Quoted 14 lines · Jyan Chou

We implemented cmdq feature on Synopsys DesignWare mmc driver. The difference between dw_mmc.c and dw_mmc_cqe.c were distinct register definitions, mmc user flow and the addition of cmdq.

New version of User Guide had modify mmc driver's usage flow, we may need to renew code to precisely follow user guide.

More over, We added a wait status function to satisfy synopsys user guide's description, since this flow might be specific in synopsys host driver only.

—--

[...]

Quoted 6 lines
drivers/mmc/host/dw_mmc_cqe.c new file +0 -0
new file mode 100644
index 000000000000..eb00d6a474b2
@@ -0,0 +1,1467 @@

[...]

Quoted 6 lines
drivers/mmc/host/dw_mmc_cqe.c new file +6 -0
+#ifdef CONFIG_OF
+static struct dw_mci_board *dw_mci_cqe_parse_dt(struct dw_mci *host)
+{
+	struct dw_mci_board *pdata;
+	struct device *dev = host->dev;
+	const struct dw_mci_drv_data *drv_data = host->drv_data;

drivers/mmc/host/dw_mmc_cqe.c line 1246

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe.c new file +10 -0
+	int ret;
+
+	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
+	if (!pdata)
+		return ERR_PTR(-ENOMEM);
+
+	pdata->rstc = devm_reset_control_get_optional_exclusive(dev, NULL);
+	if (IS_ERR(pdata->rstc)) {
+		if (PTR_ERR(pdata->rstc) == -EPROBE_DEFER)
+			return ERR_PTR(-EPROBE_DEFER);

This should

		return ERR_CAST(pdata->rstc);

instead.

There is no reason to hide device tree parsing errors here, and I'd argue pdata should not be returned with rstc set to an error value. devm_reset_control_get_optional_exclusive() returns NULL if there are no errors and no reset is specified in the device tree.

Then you can just use dev_err_probe() at the call site in dw_mci_cqe_probe().

[...]

Quoted 2 lines
drivers/mmc/host/dw_mmc_cqe.c new file +2 -0
+int dw_mci_cqe_probe(struct dw_mci *host)
+{

[...]

drivers/mmc/host/dw_mmc_cqe.c line 1347

Quoted 5 lines
drivers/mmc/host/dw_mmc_cqe.c new file +5 -0
+	if (!IS_ERR(host->pdata->rstc)) {
+		reset_control_assert(host->pdata->rstc);
+		usleep_range(10, 50);
+		reset_control_deassert(host->pdata->rstc);
+	}

This should be changed to

	if (host->pdata->rstc) {
		reset_control_assert(host->pdata->rstc);
		usleep_range(10, 50);
		reset_control_deassert(host->pdata->rstc);
	}

[...]

drivers/mmc/host/dw_mmc_cqe.c line 1389

Quoted 5 lines
drivers/mmc/host/dw_mmc_cqe.c new file +5 -0
+	return 0;
+
+err_dmaunmap:
+	if (!IS_ERR(host->pdata->rstc))
+		reset_control_assert(host->pdata->rstc);

This should be just

	reset_control_assert(host->pdata->rstc);

as reset_control_assert() is a no-op if host->pdata->rstc == NULL.

[...]

Quoted 2 lines
drivers/mmc/host/dw_mmc_cqe.c new file +2 -0
+void dw_mci_cqe_remove(struct dw_mci *host)
+{

[...]

drivers/mmc/host/dw_mmc_cqe.c

Quoted 2 lines
drivers/mmc/host/dw_mmc_cqe.c new file +2 -0
+	if (!IS_ERR(host->pdata->rstc))
+		reset_control_assert(host->pdata->rstc);
	reset_control_assert(host->pdata->rstc);

regards
Philipp

#6 lore raw

RE: [PATCH v7][2/4] mmc: Add Synopsys DesignWare mmc cmdq host driver

Hi Philipp,

Quoted 41 lines
Quoted 14 lines

We implemented cmdq feature on Synopsys DesignWare mmc driver. The difference between dw_mmc.c and dw_mmc_cqe.c were distinct register definitions, mmc user flow and the addition of cmdq.

New version of User Guide had modify mmc driver's usage flow, we may need to renew code to precisely follow user guide.

More over, We added a wait status function to satisfy synopsys user guide's description, since this flow might be specific in synopsys host driver only.

—--

[...]

Quoted 6 lines
(quoted diff) +0 -0

b/drivers/mmc/host/dw_mmc_cqe.c new file mode 100644 index 000000000000..eb00d6a474b2

drivers/mmc/host/dw_mmc_cqe.c new file +0 -0
@@ -0,0 +1,1467 @@

[...]

Quoted 6 lines
drivers/mmc/host/dw_mmc_cqe.c new file +6 -0
+#ifdef CONFIG_OF
+static struct dw_mci_board *dw_mci_cqe_parse_dt(struct dw_mci *host) 
+{
+     struct dw_mci_board *pdata;
+     struct device *dev = host->dev;
+     const struct dw_mci_drv_data *drv_data = host->drv_data;

drivers/mmc/host/dw_mmc_cqe.c line 1246

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe.c new file +10 -0
+     int ret;
+
+     pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
+     if (!pdata)
+             return ERR_PTR(-ENOMEM);
+
+     pdata->rstc = devm_reset_control_get_optional_exclusive(dev, NULL);
+     if (IS_ERR(pdata->rstc)) {
+             if (PTR_ERR(pdata->rstc) == -EPROBE_DEFER)
+                     return ERR_PTR(-EPROBE_DEFER);

This should

Quoted 8 lines
               return ERR_CAST(pdata->rstc);

instead.

There is no reason to hide device tree parsing errors here, and I'd argue pdata should not be returned with rstc set to an error value. devm_reset_control_get_optional_exclusive() returns NULL if there are no errors and no reset is specified in the device tree.

Then you can just use dev_err_probe() at the call site in dw_mci_cqe_probe().

Thanks for your advice, we will correct it in our next version.

Quoted 16 lines

[...]

Quoted 1 line

+int dw_mci_cqe_probe(struct dw_mci *host) {

[...]

drivers/mmc/host/dw_mmc_cqe.c line 1347

Quoted 5 lines
drivers/mmc/host/dw_mmc_cqe.c new file +5 -0
+     if (!IS_ERR(host->pdata->rstc)) {
+             reset_control_assert(host->pdata->rstc);
+             usleep_range(10, 50);
+             reset_control_deassert(host->pdata->rstc);
+     }

This should be changed to

       if (host->pdata->rstc) {
               reset_control_assert(host->pdata->rstc);
               usleep_range(10, 50);
               reset_control_deassert(host->pdata->rstc);
       }

[...]

Quoted 12 lines
drivers/mmc/host/dw_mmc_cqe.c new file +5 -0
+     return 0;
+
+err_dmaunmap:
+     if (!IS_ERR(host->pdata->rstc))
+             reset_control_assert(host->pdata->rstc);

This should be just

       reset_control_assert(host->pdata->rstc);

as reset_control_assert() is a no-op if host->pdata->rstc == NULL.

Quoted 7 lines

[...]

Quoted 1 line

+void dw_mci_cqe_remove(struct dw_mci *host) {

[...]

drivers/mmc/host/dw_mmc_cqe.c

Quoted 2 lines
drivers/mmc/host/dw_mmc_cqe.c new file +2 -0
+     if (!IS_ERR(host->pdata->rstc))
+             reset_control_assert(host->pdata->rstc);
       reset_control_assert(host->pdata->rstc);

Also, we will correct this in our new version, thanks.

Best Regards,
Jyan

-----Original Message-----
From: Philipp Zabel <[email protected]>
Sent: Monday, November 27, 2023 8:51 PM
To: Jyan Chou [周芷安] <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v7][2/4] mmc: Add Synopsys DesignWare mmc cmdq host driver

External mail.

Hi,

Quoted 14 lines · Jyan Chou

We implemented cmdq feature on Synopsys DesignWare mmc driver. The difference between dw_mmc.c and dw_mmc_cqe.c were distinct register definitions, mmc user flow and the addition of cmdq.

New version of User Guide had modify mmc driver's usage flow, we may need to renew code to precisely follow user guide.

More over, We added a wait status function to satisfy synopsys user guide's description, since this flow might be specific in synopsys host driver only.

—--

[...]

Quoted 6 lines
(quoted diff) +0 -0

b/drivers/mmc/host/dw_mmc_cqe.c new file mode 100644 index 000000000000..eb00d6a474b2

drivers/mmc/host/dw_mmc_cqe.c new file +0 -0
@@ -0,0 +1,1467 @@

[...]

Quoted 6 lines
drivers/mmc/host/dw_mmc_cqe.c new file +6 -0
+#ifdef CONFIG_OF
+static struct dw_mci_board *dw_mci_cqe_parse_dt(struct dw_mci *host) 
+{
+     struct dw_mci_board *pdata;
+     struct device *dev = host->dev;
+     const struct dw_mci_drv_data *drv_data = host->drv_data;

drivers/mmc/host/dw_mmc_cqe.c line 1246

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe.c new file +10 -0
+     int ret;
+
+     pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
+     if (!pdata)
+             return ERR_PTR(-ENOMEM);
+
+     pdata->rstc = devm_reset_control_get_optional_exclusive(dev, NULL);
+     if (IS_ERR(pdata->rstc)) {
+             if (PTR_ERR(pdata->rstc) == -EPROBE_DEFER)
+                     return ERR_PTR(-EPROBE_DEFER);

This should

                return ERR_CAST(pdata->rstc);

instead.

There is no reason to hide device tree parsing errors here, and I'd argue pdata should not be returned with rstc set to an error value. devm_reset_control_get_optional_exclusive() returns NULL if there are no errors and no reset is specified in the device tree.

Then you can just use dev_err_probe() at the call site in dw_mci_cqe_probe().

[...]

Quoted 1 line

+int dw_mci_cqe_probe(struct dw_mci *host) {

[...]

drivers/mmc/host/dw_mmc_cqe.c line 1347

Quoted 5 lines
drivers/mmc/host/dw_mmc_cqe.c new file +5 -0
+     if (!IS_ERR(host->pdata->rstc)) {
+             reset_control_assert(host->pdata->rstc);
+             usleep_range(10, 50);
+             reset_control_deassert(host->pdata->rstc);
+     }

This should be changed to

        if (host->pdata->rstc) {
                reset_control_assert(host->pdata->rstc);
                usleep_range(10, 50);
                reset_control_deassert(host->pdata->rstc);
        }

[...]

drivers/mmc/host/dw_mmc_cqe.c line 1389

Quoted 5 lines
drivers/mmc/host/dw_mmc_cqe.c new file +5 -0
+     return 0;
+
+err_dmaunmap:
+     if (!IS_ERR(host->pdata->rstc))
+             reset_control_assert(host->pdata->rstc);

This should be just

        reset_control_assert(host->pdata->rstc);

as reset_control_assert() is a no-op if host->pdata->rstc == NULL.

[...]

Quoted 1 line

+void dw_mci_cqe_remove(struct dw_mci *host) {

[...]

drivers/mmc/host/dw_mmc_cqe.c

Quoted 2 lines
drivers/mmc/host/dw_mmc_cqe.c new file +2 -0
+     if (!IS_ERR(host->pdata->rstc))
+             reset_control_assert(host->pdata->rstc);
        reset_control_assert(host->pdata->rstc);

regards
Philipp

#7 lore raw

Re: [PATCH v7][2/4] mmc: Add Synopsys DesignWare mmc cmdq host driver

In reply to Philipp Zabel
Quoted 26 lines · Philipp Zabel
Quoted 6 lines · Jyan Chou
drivers/mmc/host/dw_mmc_cqe.c new file +0 -0
new file mode 100644
index 000000000000..eb00d6a474b2
@@ -0,0 +1,1467 @@

[...]

drivers/mmc/host/dw_mmc_cqe.c line 1242

Quoted 12 lines
drivers/mmc/host/dw_mmc_cqe.c new file +12 -0
+#ifdef CONFIG_OF
+static struct dw_mci_board *dw_mci_cqe_parse_dt(struct dw_mci *host)
+{
+	struct dw_mci_board *pdata;
+	struct device *dev = host->dev;
+	const struct dw_mci_drv_data *drv_data = host->drv_data;
+	int ret;
+
+	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
+	if (!pdata)
+		return ERR_PTR(-ENOMEM);
+

There is no reason to hide device tree parsing errors here, and I'd argue pdata should not be returned with rstc set to an error value. devm_reset_control_get_optional_exclusive() returns NULL if there are no errors and no reset is specified in the device tree.

Quoted 2 lines

Then you can just use dev_err_probe() at the call site in dw_mci_cqe_probe().

I think ideally the dw_mci_board should be merged into the dw_mci structure, avoiding the extra kzalloc() step. Having separate structures here is likely an artifact from an old version of the driver that predates the use of devicetree, but since everything now uses DT, there is no point in the extra abstraction.

Arnd

#8 lore raw

Re: [PATCH v7][2/4] mmc: Add Synopsys DesignWare mmc cmdq host driver

In reply to Jyan Chou
Quoted 56 lines · Jyan Chou

We implemented cmdq feature on Synopsys DesignWare mmc driver. The difference between dw_mmc.c and dw_mmc_cqe.c were distinct register definitions, mmc user flow and the addition of cmdq.

New version of User Guide had modify mmc driver's usage flow, we may need to renew code to precisely follow user guide.

More over, We added a wait status function to satisfy synopsys user guide's description, since this flow might be specific in synopsys host driver only.

—--
v6 -> v7:
- Remove reset-names in driver and adjust reset control's code.

v5 -> v6:
- Fix linux coding style issues.
- Drop useless code that is not described in the bindings.
- Replace devm_clk_get and clk_prepare_enable with devm_clk_get_enabled.
- Replace EXPORT_SYMBOL with EXPORT_SYMBOL_GPL.

v4 -> v5:
- Fix linux coding style issues.
- Fix test robot build errors to make good use of setup_tran_desc call back function.
- Remove useless function.

v3 -> v4:
- Modify dma mode selection and dma addressing bit to statisfy linux coding style.

v1 -> v2:
- Remove dw_mci_cqe_set_tran_desc due to the duplicated function.
- Add ->pre_enable() / ->post_disable()

v0 -> v1:
- Seperate different support into single patch.
- Fix the compiler complains.
---

---
 drivers/mmc/host/Kconfig      |   13 +
 drivers/mmc/host/Makefile     |    1 +
 drivers/mmc/host/dw_mmc_cqe.c | 1467 +++++++++++++++++++++++++++++++++
 drivers/mmc/host/dw_mmc_cqe.h |  456 ++++++++++
 4 files changed, 1937 insertions(+)
 create mode 100644 drivers/mmc/host/dw_mmc_cqe.c
 create mode 100644 drivers/mmc/host/dw_mmc_cqe.h
drivers/mmc/host/Kconfig +0 -0
index 58bd5fe4cd25..06bb4de28cc4 100644
@@ -837,6 +837,19 @@ config MMC_DW_STARFIVE
 	  Synopsys DesignWare Memory Card Interface driver. Select this option

drivers/mmc/host/Kconfig config MMC_DW_STARFIVE · line 847

Quoted 10 lines
drivers/mmc/host/Kconfig +8 -0
 	  for platforms based on StarFive JH7110 SoC.
 
+config MMC_DW_CQE
+	tristate "Synopsys DesignWare Memory Card with CQE Interface"
+	depends on ARC || ARM || ARM64 || MIPS || COMPILE_TEST
+	select MMC_CQHCI
+	help
+	 This selects support for the Synopsys DesignWare Mobile Storage IP
+	 block after JEDEC Standard version 5.1. Select this option for SD and
+	 MMC interfaces that use command queue.

/after/according to/ ?
Does the hardware actually implement both: SD and MMC CQ?
If so that would be very interesting, but also not currently supported by mmc layer.

#9 lore raw

RE: [PATCH v7][2/4] mmc: Add Synopsys DesignWare mmc cmdq host driver

Hi,

Quoted 59 lines
Quoted 59 lines

We implemented cmdq feature on Synopsys DesignWare mmc driver. The difference between dw_mmc.c and dw_mmc_cqe.c were distinct register definitions, mmc user flow and the addition of cmdq.

New version of User Guide had modify mmc driver's usage flow, we may need to renew code to precisely follow user guide.

More over, We added a wait status function to satisfy synopsys user guide's description, since this flow might be specific in synopsys host driver only.

—--
v6 -> v7:
- Remove reset-names in driver and adjust reset control's code.

v5 -> v6:
- Fix linux coding style issues.
- Drop useless code that is not described in the bindings.
- Replace devm_clk_get and clk_prepare_enable with devm_clk_get_enabled.
- Replace EXPORT_SYMBOL with EXPORT_SYMBOL_GPL.

v4 -> v5:
- Fix linux coding style issues.
- Fix test robot build errors to make good use of setup_tran_desc call back function.
- Remove useless function.

v3 -> v4:
- Modify dma mode selection and dma addressing bit to statisfy linux coding style.

v1 -> v2:
- Remove dw_mci_cqe_set_tran_desc due to the duplicated function.
- Add ->pre_enable() / ->post_disable()

v0 -> v1:
- Seperate different support into single patch.
- Fix the compiler complains.
---

---
 drivers/mmc/host/Kconfig      |   13 +
 drivers/mmc/host/Makefile     |    1 +
 drivers/mmc/host/dw_mmc_cqe.c | 1467 
+++++++++++++++++++++++++++++++++  drivers/mmc/host/dw_mmc_cqe.h |  
456 ++++++++++
 4 files changed, 1937 insertions(+)
 create mode 100644 drivers/mmc/host/dw_mmc_cqe.c  create mode 100644 

drivers/mmc/host/dw_mmc_cqe.h

drivers/mmc/host/Kconfig index renamed from drivers/mmc/host/Kconfig +0 -0

58bd5fe4cd25..06bb4de28cc4 100644

drivers/mmc/host/Kconfig +0 -0
@@ -837,6 +837,19 @@ config MMC_DW_STARFIVE
        Synopsys DesignWare Memory Card Interface driver. Select this option
        for platforms based on StarFive JH7110 SoC.
 
Quoted 9 lines

drivers/mmc/host/Kconfig config MMC_DW_STARFIVE · line 847

Quoted 8 lines
drivers/mmc/host/Kconfig +8 -0
+config MMC_DW_CQE
+     tristate "Synopsys DesignWare Memory Card with CQE Interface"
+     depends on ARC || ARM || ARM64 || MIPS || COMPILE_TEST
+     select MMC_CQHCI
+     help
+      This selects support for the Synopsys DesignWare Mobile Storage IP
+      block after JEDEC Standard version 5.1. Select this option for SD and
+      MMC interfaces that use command queue.

/after/according to/ ?

Sorry for asking, what does " /after/according to/ ? " mean ?

Quoted 2 lines

Does the hardware actually implement both: SD and MMC CQ?
If so that would be very interesting, but also not currently supported by mmc layer.

Since we only had Synopsys eMMC's IP, our hardware only implement MMC CQ, but because we followed Synopsys' data book and user guide, it might probably expand to SD card usage, thanks.

Best Regards,
Jyan
-----Original Message-----
From: Christian Loehle <[email protected]>
Sent: Monday, November 27, 2023 9:02 PM
To: Jyan Chou [周芷安] <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v7][2/4] mmc: Add Synopsys DesignWare mmc cmdq host driver

External mail.

Quoted 57 lines · Jyan Chou

We implemented cmdq feature on Synopsys DesignWare mmc driver. The difference between dw_mmc.c and dw_mmc_cqe.c were distinct register definitions, mmc user flow and the addition of cmdq.

New version of User Guide had modify mmc driver's usage flow, we may need to renew code to precisely follow user guide.

More over, We added a wait status function to satisfy synopsys user guide's description, since this flow might be specific in synopsys host driver only.

—--
v6 -> v7:
- Remove reset-names in driver and adjust reset control's code.

v5 -> v6:
- Fix linux coding style issues.
- Drop useless code that is not described in the bindings.
- Replace devm_clk_get and clk_prepare_enable with devm_clk_get_enabled.
- Replace EXPORT_SYMBOL with EXPORT_SYMBOL_GPL.

v4 -> v5:
- Fix linux coding style issues.
- Fix test robot build errors to make good use of setup_tran_desc call back function.
- Remove useless function.

v3 -> v4:
- Modify dma mode selection and dma addressing bit to statisfy linux coding style.

v1 -> v2:
- Remove dw_mci_cqe_set_tran_desc due to the duplicated function.
- Add ->pre_enable() / ->post_disable()

v0 -> v1:
- Seperate different support into single patch.
- Fix the compiler complains.
---

---
 drivers/mmc/host/Kconfig      |   13 +
 drivers/mmc/host/Makefile     |    1 +
 drivers/mmc/host/dw_mmc_cqe.c | 1467 
+++++++++++++++++++++++++++++++++  drivers/mmc/host/dw_mmc_cqe.h |  
456 ++++++++++
 4 files changed, 1937 insertions(+)
 create mode 100644 drivers/mmc/host/dw_mmc_cqe.c  create mode 100644 

drivers/mmc/host/dw_mmc_cqe.h

drivers/mmc/host/Kconfig index renamed from drivers/mmc/host/Kconfig +0 -0

58bd5fe4cd25..06bb4de28cc4 100644

drivers/mmc/host/Kconfig +0 -0
@@ -837,6 +837,19 @@ config MMC_DW_STARFIVE
        Synopsys DesignWare Memory Card Interface driver. Select this option

drivers/mmc/host/Kconfig config MMC_DW_STARFIVE · line 847

Quoted 10 lines
drivers/mmc/host/Kconfig +8 -0
        for platforms based on StarFive JH7110 SoC.
 
+config MMC_DW_CQE
+     tristate "Synopsys DesignWare Memory Card with CQE Interface"
+     depends on ARC || ARM || ARM64 || MIPS || COMPILE_TEST
+     select MMC_CQHCI
+     help
+      This selects support for the Synopsys DesignWare Mobile Storage IP
+      block after JEDEC Standard version 5.1. Select this option for SD and
+      MMC interfaces that use command queue.

/after/according to/ ?
Does the hardware actually implement both: SD and MMC CQ?
If so that would be very interesting, but also not currently supported by mmc layer.

maintainer
#10 lore raw

Re: [PATCH v7][2/4] mmc: Add Synopsys DesignWare mmc cmdq host driver

In reply to Jyan Chou
Quoted 4 lines · Jyan Chou

We implemented cmdq feature on Synopsys DesignWare mmc driver. The difference between dw_mmc.c and dw_mmc_cqe.c were distinct register definitions, mmc user flow and the addition of cmdq.

Quoted 9 lines

New version of User Guide had modify mmc driver's usage flow, we may need to renew code to precisely follow user guide.

More over, We added a wait status function to satisfy synopsys user guide's description, since this flow might be specific in synopsys host driver only.

Some comments below wrt cqhci

Quoted 120 lines

—--
v6 -> v7:
- Remove reset-names in driver and adjust reset control's code.

v5 -> v6:
- Fix linux coding style issues.
- Drop useless code that is not described in the bindings.
- Replace devm_clk_get and clk_prepare_enable with devm_clk_get_enabled.
- Replace EXPORT_SYMBOL with EXPORT_SYMBOL_GPL.

v4 -> v5:
- Fix linux coding style issues.
- Fix test robot build errors to make good use of setup_tran_desc call back function.
- Remove useless function.

v3 -> v4:
- Modify dma mode selection and dma addressing bit to statisfy linux coding style.

v1 -> v2:
- Remove dw_mci_cqe_set_tran_desc due to the duplicated function.
- Add ->pre_enable() / ->post_disable()

v0 -> v1:
- Seperate different support into single patch.
- Fix the compiler complains.
---

---
 drivers/mmc/host/Kconfig      |   13 +
 drivers/mmc/host/Makefile     |    1 +
 drivers/mmc/host/dw_mmc_cqe.c | 1467 +++++++++++++++++++++++++++++++++
 drivers/mmc/host/dw_mmc_cqe.h |  456 ++++++++++
 4 files changed, 1937 insertions(+)
 create mode 100644 drivers/mmc/host/dw_mmc_cqe.c
 create mode 100644 drivers/mmc/host/dw_mmc_cqe.h
drivers/mmc/host/Kconfig +13 -0
index 58bd5fe4cd25..06bb4de28cc4 100644
@@ -837,6 +837,19 @@ config MMC_DW_STARFIVE
 	  Synopsys DesignWare Memory Card Interface driver. Select this option
 	  for platforms based on StarFive JH7110 SoC.
 
+config MMC_DW_CQE
+	tristate "Synopsys DesignWare Memory Card with CQE Interface"
+	depends on ARC || ARM || ARM64 || MIPS || COMPILE_TEST
+	select MMC_CQHCI
+	help
+	 This selects support for the Synopsys DesignWare Mobile Storage IP
+	 block after JEDEC Standard version 5.1. Select this option for SD and
+	 MMC interfaces that use command queue.
+
+	 If you have a controller with this interface, say Y or M here.
+
+	 If unsure, say Y.
+
 config MMC_SH_MMCIF
 	tristate "SuperH Internal MMCIF support"
 	depends on SUPERH || ARCH_RENESAS || COMPILE_TEST
drivers/mmc/host/Makefile +1 -0
index d0be4465f3ec..464fe58f8541 100644
@@ -55,6 +55,7 @@ obj-$(CONFIG_MMC_DW_K3)		+= dw_mmc-k3.o
 obj-$(CONFIG_MMC_DW_PCI)	+= dw_mmc-pci.o
 obj-$(CONFIG_MMC_DW_ROCKCHIP)	+= dw_mmc-rockchip.o
 obj-$(CONFIG_MMC_DW_STARFIVE)	+= dw_mmc-starfive.o
+obj-$(CONFIG_MMC_DW_CQE)	+= dw_mmc_cqe.o
 obj-$(CONFIG_MMC_SH_MMCIF)	+= sh_mmcif.o
 obj-$(CONFIG_MMC_JZ4740)	+= jz4740_mmc.o
 obj-$(CONFIG_MMC_VUB300)	+= vub300.o
drivers/mmc/host/dw_mmc_cqe.c new file +41 -0
new file mode 100644
index 000000000000..eb00d6a474b2
@@ -0,0 +1,1467 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Synopsys DesignWare Multimedia Card Interface driver with CMDQ support
+ *  (Based on Synopsys DesignWare Multimedia Card Interface driver)
+ *
+ * Copyright (c) 2023 Realtek Semiconductor Corp
+ */
+
+#include <linux/bitops.h>
+#include <linux/blkdev.h>
+#include <linux/clk.h>
+#include <linux/debugfs.h>
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/dma-mapping.h>
+#include <linux/err.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/iopoll.h>
+#include <linux/ioport.h>
+#include <linux/irq.h>
+#include <linux/mmc/card.h>
+#include <linux/mmc/host.h>
+#include <linux/mmc/mmc.h>
+#include <linux/mmc/sd.h>
+#include <linux/mmc/sdio.h>
+#include <linux/mmc/slot-gpio.h>
+#include <linux/module.h>
+#include <linux/of_gpio.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
+#include <linux/regulator/consumer.h>
+#include <linux/seq_file.h>
+#include <linux/sizes.h>
+#include <linux/slab.h>
+#include <linux/stat.h>
+
+#include "dw_mmc_cqe.h"
+#include "cqhci.h"
+

drivers/mmc/host/dw_mmc_cqe.c line 51

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe.c new file +10 -0
+#define DW_MCI_FREQ_MAX	200000000	/* unit: HZ */
+#define DW_MCI_FREQ_MIN	100000		/* unit: HZ */
+#define DW_MCI_CMDQ_DISABLED	0x30f0001
+#define DW_MCI_CMDQ_ENABLED	0x30f0101
+#define DW_MCI_POWEROFF		0x3220301
+#define DW_MCI_DESC_LEN		0x100000
+#define DW_MCI_MAX_SCRIPT_BLK	128
+#define DW_MCI_TIMEOUT_Ms	200
+#define DW_MCI_TIMEOUT		200000
+#define TUNING_ERR		531

Could just use EIO

Quoted 34 lines
drivers/mmc/host/dw_mmc_cqe.c new file +34 -0
+#define DW_MCI_NOT_READY	9999
+
+DECLARE_COMPLETION(dw_mci_wait);
+
+static int dw_mci_cqe_regs_show(struct dw_mci *host,
+				struct mmc_command *cmd, u32 cmd_flags)
+{
+	dev_info(host->dev, "opcode = %d, arg = 0x%x, cmdflags = 0x%x\n",
+		 cmd->opcode, cmd->arg, cmd_flags);
+	dev_info(host->dev, "status_int = 0x%x\n", host->normal_interrupt);
+	dev_info(host->dev, "error_int = 0x%x\n", host->error_interrupt);
+	dev_info(host->dev, "auto_error_int = 0x%x\n", host->auto_error_interrupt);
+
+	return 0;
+}
+
+static void dw_mci_cqe_dumpregs(struct mmc_host *mmc)
+{
+	struct dw_mci_slot *slot = mmc_priv(mmc);
+	struct dw_mci *host = slot->host;
+
+	dev_info(host->dev, "%s: cmd idx 0x%08x\n", __func__, mcq_readw(host, CMD_R));
+}
+
+static void dw_mci_cqe_setup_tran_desc(struct mmc_data *data,
+				       struct cqhci_host *cq_host,
+					u8 *desc,
+					int sg_count)
+{
+	struct scatterlist *sg;
+	u32 cur_blk_cnt, remain_blk_cnt;
+	unsigned int begin, end;
+	int i, len;
+	bool last = false;

drivers/mmc/host/dw_mmc_cqe.c line 95

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe.c new file +10 -0
+	bool dma64 = cq_host->dma64;
+	dma_addr_t addr;
+
+	for_each_sg(data->sg, sg, sg_count, i) {
+		addr = sg_dma_address(sg);
+		len = sg_dma_len(sg);
+		remain_blk_cnt  = len >> 9;
+
+		while (remain_blk_cnt) {
+			if (remain_blk_cnt > DW_MCI_MAX_SCRIPT_BLK)

Use max_seg_size then that won't happen

Quoted 12 lines
drivers/mmc/host/dw_mmc_cqe.c new file +12 -0
+				cur_blk_cnt = DW_MCI_MAX_SCRIPT_BLK;
+			else
+				cur_blk_cnt = remain_blk_cnt;
+
+			begin = addr / SZ_128M;
+			end = (addr + cur_blk_cnt * SZ_512) / SZ_128M;
+
+			if (begin != end)
+				cur_blk_cnt = (end * SZ_128M - addr) / SZ_512;
+
+			if ((i + 1) == sg_count && remain_blk_cnt == cur_blk_cnt)
+				last = true;

drivers/mmc/host/dw_mmc_cqe.c line 117

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe.c new file +10 -0
+
+			cqhci_set_tran_desc(desc, addr,
+					    (cur_blk_cnt << 9), last, dma64);
+
+			addr = addr + (cur_blk_cnt << 9);
+			remain_blk_cnt -= cur_blk_cnt;
+			desc += cq_host->trans_desc_len;
+		}
+	}
+}

Provide a hook for cqhci_set_tran_desc() instead of cqhci_prep_tran_desc() You'll need to check the details, but something like:

drivers/mmc/host/cqhci-core.c +4 -1
index b3d7d6d8d654..98e7e9d3030d 100644
@@ -522,7 +522,10 @@ static int cqhci_prep_tran_desc(struct mmc_request *mrq,
 
 		if ((i+1) == sg_count)
 			end = true;
-		cqhci_set_tran_desc(desc, addr, len, end, dma64);
+		if (cq_host->ops->set_tran_desc)
+			cq_host->ops->set_tran_desc(&desc, addr, len, end, dma64);
+		else
+			cqhci_set_tran_desc(desc, addr, len, end, dma64);
 		desc += cq_host->trans_desc_len;
 	}
 

And:

#define BOUNDARY_OK(addr, len) \
	((addr | (SZ_128M - 1)) == ((addr + len - 1) | (SZ_128M - 1)))

static void dw_mci_cqe_set_tran_desc(u8 **desc, dma_addr_t addr, int len, bool end, bool dma64)

{
	int tmplen, offset;

	if (likely(!len || BOUNDARY_OK(addr, len))) {
		cqhci_set_tran_desc(*desc, addr, len, end, dma64);
		return;
	}

	offset = addr & (SZ_128M - 1);
	tmplen = SZ_128M - offset;
	cqhci_set_tran_desc(*desc, addr, tmplen, false, dma64);

	addr += tmplen;
	len -= tmplen;
	*desc += cq_host->trans_desc_len;
	cqhci_set_tran_desc(*desc, addr, len, end, dma64);
}
Quoted 59 lines
drivers/mmc/host/dw_mmc_cqe.c new file +59 -0
+
+static void dw_mci_cqe_enable(struct mmc_host *mmc)
+{
+	struct dw_mci_slot *slot = mmc_priv(mmc);
+	struct dw_mci *host = slot->host;
+
+	mcq_writeb(host, SW_RST_R, SDMMC_RST_DAT);
+	mcq_writew(host, XFER_MODE_R,
+		   ((1 << SDMMC_MULTI_BLK_SEL) | SDMMC_BLOCK_COUNT_ENABLE
+			| SDMMC_DMA_ENABLE));
+
+	mcq_writeb(host, HOST_CTRL1_R,
+		   (mcq_readb(host, HOST_CTRL1_R) & 0xe7) |
+			(SDMMC_ADMA2_32 << SDMMC_DMA_SEL));
+	mcq_writew(host, BLOCKSIZE_R, 0x200);
+	mcq_writew(host, BLOCKCOUNT_R, 0);
+
+	mcq_writel(host, SDMASA_R, 0);
+
+	cqhci_writel(host->cqe, 0x10, CQHCI_SSC1);
+	cqhci_writel(host->cqe, 0, CQHCI_CTL);
+
+	if (cqhci_readl(host->cqe, CQHCI_CTL) && CQHCI_HALT) {
+		dev_err(host->dev, "%s: cqhci: CQE failed to exit halt state\n",
+			mmc_hostname(mmc));
+	}
+
+	dw_mci_clr_signal_int(host);
+	dw_mci_en_cqe_int(host);
+}
+
+static void dw_mci_cqe_pre_enable(struct mmc_host *mmc)
+{
+	struct cqhci_host *cq_host = mmc->cqe_private;
+	u32 reg;
+
+	reg = cqhci_readl(cq_host, CQHCI_CFG);
+	reg |= CQHCI_ENABLE;
+	cqhci_writel(cq_host, reg, CQHCI_CFG);
+}
+
+static void dw_mci_cqe_post_disable(struct mmc_host *mmc)
+{
+	struct cqhci_host *cq_host = mmc->cqe_private;
+	u32 reg;
+
+	reg = cqhci_readl(cq_host, CQHCI_CFG);
+	reg &= ~CQHCI_ENABLE;
+	cqhci_writel(cq_host, reg, CQHCI_CFG);
+}
+
+static const struct cqhci_host_ops dw_mci_cqhci_host_ops = {
+	.enable = dw_mci_cqe_enable,
+	.dumpregs = dw_mci_cqe_dumpregs,
+	.pre_enable = dw_mci_cqe_pre_enable,
+	.post_disable = dw_mci_cqe_post_disable,
+	.setup_tran_desc = dw_mci_cqe_setup_tran_desc,
+};
+

[SNIP]

Quoted 5 lines
drivers/mmc/host/dw_mmc_cqe.c new file +5 -0
+
+static irqreturn_t dw_mci_cqe_interrupt(int irq, void *dev_id)
+{
+	struct dw_mci *host = dev_id;
+	struct mmc_host *mmc = host->slot->mmc;

drivers/mmc/host/dw_mmc_cqe.c

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe.c new file +10 -0
+	struct cqhci_host *cq_host = NULL;
+	int cmd_error = 0, data_error = 0;
+
+	if (host->pdata && (host->pdata->caps2 & MMC_CAP2_CQE))
+		cq_host = mmc->cqe_private;
+
+	dw_mci_get_int(host);
+
+	if (host->pdata && (host->pdata->caps2 & MMC_CAP2_CQE)) {
+		if (!mmc->cqe_on && !cq_host->activated)

Shouldn't really look at internals like mmc->cqe_on or cq_host->activated. There are the cqhci_host_ops ->enable() and ->disable() callbacks to keep track of whether cqhci is expecting interrupts.

drivers/mmc/host/dw_mmc_cqe.c

Quoted 7 lines
drivers/mmc/host/dw_mmc_cqe.c new file +7 -0
+			dw_mci_clr_signal_int(host);
+	} else {
+		dw_mci_clr_signal_int(host);
+	}
+
+	if (host->pdata && (host->pdata->caps2 & MMC_CAP2_CQE) &&
+	    mmc->cqe_on && cq_host->activated) {

As above

Quoted 23 lines
drivers/mmc/host/dw_mmc_cqe.c new file +23 -0
+		if (host->normal_interrupt & SDMMC_ERR_INTERRUPT) {
+			dev_err(host->dev, "cmdq error: interrupt status=%08x, error interrupt=0x%08x, CQIS=0x%x, CQTCN=0x%x\n",
+				host->normal_interrupt, host->error_interrupt,
+				readl(host->cqe->mmio + CQHCI_IS),
+				readl(host->cqe->mmio + CQHCI_TCN));
+
+			dw_mci_cqe_command_complete(host, host->error_interrupt, &cmd_error);
+			dw_mci_cqe_data_complete(host, host->error_interrupt, &data_error);
+		}
+		cqhci_irq(mmc, (u32)(host->normal_interrupt), cmd_error, data_error);
+		dw_mci_clr_int(host);
+
+		return IRQ_HANDLED;
+	}
+
+	if (host->int_waiting) {
+		del_timer(&host->timer);
+		complete(host->int_waiting);
+	}
+
+	return IRQ_HANDLED;
+}
+
#11 lore raw

RE: [PATCH v7][2/4] mmc: Add Synopsys DesignWare mmc cmdq host driver

Quoted 130 lines

Some comments below wrt cqhci

Quoted 8 lines

—--
v6 -> v7:
- Remove reset-names in driver and adjust reset control's code.

v5 -> v6:
- Fix linux coding style issues.
- Drop useless code that is not described in the bindings.
- Replace devm_clk_get and clk_prepare_enable with

devm_clk_get_enabled.

Quoted 20 lines

- Replace EXPORT_SYMBOL with EXPORT_SYMBOL_GPL.

v4 -> v5:
- Fix linux coding style issues.
- Fix test robot build errors to make good use of setup_tran_desc call back function.
- Remove useless function.

v3 -> v4:
- Modify dma mode selection and dma addressing bit to statisfy linux coding style.

v1 -> v2:
- Remove dw_mci_cqe_set_tran_desc due to the duplicated function.
- Add ->pre_enable() / ->post_disable()

v0 -> v1:
- Seperate different support into single patch.
- Fix the compiler complains.
---

Quoted 5 lines
---
 drivers/mmc/host/Kconfig      |   13 +
 drivers/mmc/host/Makefile     |    1 +
 drivers/mmc/host/dw_mmc_cqe.c | 1467

+++++++++++++++++++++++++++++++++

drivers/mmc/host/dw_mmc_cqe.h |

Quoted 3 lines

456 ++++++++++

 4 files changed, 1937 insertions(+)
 create mode 100644 drivers/mmc/host/dw_mmc_cqe.c  create mode

100644

drivers/mmc/host/Kconfig config MMC_DW_STARFIVE · line 837

Quoted 8 lines

drivers/mmc/host/dw_mmc_cqe.h

drivers/mmc/host/Kconfig index renamed from drivers/mmc/host/Kconfig +0 -0

58bd5fe4cd25..06bb4de28cc4 100644

drivers/mmc/host/Kconfig +0 -0
@@ -837,6 +837,19 @@ config MMC_DW_STARFIVE
        Synopsys DesignWare Memory Card Interface driver. Select this

option

drivers/mmc/host/Makefile obj-$(CONFIG_MMC_DW_K3) +=

Quoted 23 lines
drivers/mmc/host/Kconfig +13 -0
        for platforms based on StarFive JH7110 SoC.
 
+config MMC_DW_CQE
+     tristate "Synopsys DesignWare Memory Card with CQE Interface"
+     depends on ARC || ARM || ARM64 || MIPS || COMPILE_TEST
+     select MMC_CQHCI
+     help
+      This selects support for the Synopsys DesignWare Mobile Storage IP
+      block after JEDEC Standard version 5.1. Select this option for SD and
+      MMC interfaces that use command queue.
+
+      If you have a controller with this interface, say Y or M here.
+
+      If unsure, say Y.
+
 config MMC_SH_MMCIF
      tristate "SuperH Internal MMCIF support"
      depends on SUPERH || ARCH_RENESAS || COMPILE_TEST diff --git

a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile index d0be4465f3ec..464fe58f8541 100644

drivers/mmc/host/Makefile +0 -0
@@ -55,6 +55,7 @@ obj-$(CONFIG_MMC_DW_K3)             +=

dw_mmc-k3.o

Quoted 45 lines
drivers/mmc/host/Makefile +1 -0
 obj-$(CONFIG_MMC_DW_PCI)     += dw_mmc-pci.o
 obj-$(CONFIG_MMC_DW_ROCKCHIP)        += dw_mmc-rockchip.o
 obj-$(CONFIG_MMC_DW_STARFIVE)        += dw_mmc-starfive.o
+obj-$(CONFIG_MMC_DW_CQE)     += dw_mmc_cqe.o
 obj-$(CONFIG_MMC_SH_MMCIF)   += sh_mmcif.o
 obj-$(CONFIG_MMC_JZ4740)     += jz4740_mmc.o
 obj-$(CONFIG_MMC_VUB300)     += vub300.o
(quoted diff) +0 -0

b/drivers/mmc/host/dw_mmc_cqe.c new file mode 100644 index 000000000000..eb00d6a474b2

drivers/mmc/host/dw_mmc_cqe.c new file +32 -0
@@ -0,0 +1,1467 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Synopsys DesignWare Multimedia Card Interface driver with CMDQ
+support
+ *  (Based on Synopsys DesignWare Multimedia Card Interface driver)
+ *
+ * Copyright (c) 2023 Realtek Semiconductor Corp  */
+
+#include <linux/bitops.h>
+#include <linux/blkdev.h>
+#include <linux/clk.h>
+#include <linux/debugfs.h>
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/dma-mapping.h>
+#include <linux/err.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/iopoll.h>
+#include <linux/ioport.h>
+#include <linux/irq.h>
+#include <linux/mmc/card.h>
+#include <linux/mmc/host.h>
+#include <linux/mmc/mmc.h>
+#include <linux/mmc/sd.h>
+#include <linux/mmc/sdio.h>
+#include <linux/mmc/slot-gpio.h>
+#include <linux/module.h>
+#include <linux/of_gpio.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/pm_runtime.h>

drivers/mmc/host/dw_mmc_cqe.c line 42

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe.c new file +10 -0
+#include <linux/regulator/consumer.h> #include <linux/seq_file.h>
+#include <linux/sizes.h> #include <linux/slab.h> #include
+<linux/stat.h>
+
+#include "dw_mmc_cqe.h"
+#include "cqhci.h"
+
+#define DW_MCI_FREQ_MAX      200000000       /* unit: HZ */
+#define DW_MCI_FREQ_MIN      100000          /* unit: HZ */
+#define DW_MCI_CMDQ_DISABLED 0x30f0001 #define

DW_MCI_CMDQ_ENABLED

Quoted 10 lines

drivers/mmc/host/dw_mmc_cqe.c line 49

Quoted 7 lines
drivers/mmc/host/dw_mmc_cqe.c new file +7 -0
+0x30f0101
+#define DW_MCI_POWEROFF              0x3220301
+#define DW_MCI_DESC_LEN              0x100000
+#define DW_MCI_MAX_SCRIPT_BLK        128
+#define DW_MCI_TIMEOUT_Ms    200
+#define DW_MCI_TIMEOUT               200000
+#define TUNING_ERR           531

Could just use EIO

Okay, we will correct it in our new version.

Quoted 38 lines

drivers/mmc/host/dw_mmc_cqe.c line 55

Quoted 6 lines
drivers/mmc/host/dw_mmc_cqe.c new file +6 -0
+#define DW_MCI_NOT_READY     9999
+
+DECLARE_COMPLETION(dw_mci_wait);
+
+static int dw_mci_cqe_regs_show(struct dw_mci *host,
+                             struct mmc_command *cmd, u32

cmd_flags)

Quoted 31 lines
drivers/mmc/host/dw_mmc_cqe.c new file +31 -0
+{
+     dev_info(host->dev, "opcode = %d, arg = 0x%x, cmdflags = 0x%x\n",
+              cmd->opcode, cmd->arg, cmd_flags);
+     dev_info(host->dev, "status_int = 0x%x\n", host->normal_interrupt);
+     dev_info(host->dev, "error_int = 0x%x\n", host->error_interrupt);
+     dev_info(host->dev, "auto_error_int = 0x%x\n",
+host->auto_error_interrupt);
+
+     return 0;
+}
+
+static void dw_mci_cqe_dumpregs(struct mmc_host *mmc) {
+     struct dw_mci_slot *slot = mmc_priv(mmc);
+     struct dw_mci *host = slot->host;
+
+     dev_info(host->dev, "%s: cmd idx 0x%08x\n", __func__,
+mcq_readw(host, CMD_R)); }
+
+static void dw_mci_cqe_setup_tran_desc(struct mmc_data *data,
+                                    struct cqhci_host *cq_host,
+                                     u8 *desc,
+                                     int sg_count) {
+     struct scatterlist *sg;
+     u32 cur_blk_cnt, remain_blk_cnt;
+     unsigned int begin, end;
+     int i, len;
+     bool last = false;
+     bool dma64 = cq_host->dma64;
+     dma_addr_t addr;
+
+     for_each_sg(data->sg, sg, sg_count, i) {
Quoted 9 lines

drivers/mmc/host/dw_mmc_cqe.c line 92

Quoted 6 lines
drivers/mmc/host/dw_mmc_cqe.c new file +6 -0
+             addr = sg_dma_address(sg);
+             len = sg_dma_len(sg);
+             remain_blk_cnt  = len >> 9;
+
+             while (remain_blk_cnt) {
+                     if (remain_blk_cnt > DW_MCI_MAX_SCRIPT_BLK)

Use max_seg_size then that won't happen

We will remove this useless check, thanks.

Quoted 57 lines

drivers/mmc/host/dw_mmc_cqe.c line 93

Quoted 1 line
drivers/mmc/host/dw_mmc_cqe.c new file +1 -0
+                             cur_blk_cnt =

DW_MCI_MAX_SCRIPT_BLK;

drivers/mmc/host/dw_mmc_cqe.c line 104

Quoted 11 lines
drivers/mmc/host/dw_mmc_cqe.c new file +11 -0
+                     else
+                             cur_blk_cnt = remain_blk_cnt;
+
+                     begin = addr / SZ_128M;
+                     end = (addr + cur_blk_cnt * SZ_512) / SZ_128M;
+
+                     if (begin != end)
+                             cur_blk_cnt = (end * SZ_128M - addr) /
+ SZ_512;
+
+                     if ((i + 1) == sg_count && remain_blk_cnt ==

cur_blk_cnt)

drivers/mmc/host/dw_mmc_cqe.c line 116

Quoted 12 lines
drivers/mmc/host/dw_mmc_cqe.c new file +12 -0
+                             last = true;
+
+                     cqhci_set_tran_desc(desc, addr,
+                                         (cur_blk_cnt << 9), last,
+ dma64);
+
+                     addr = addr + (cur_blk_cnt << 9);
+                     remain_blk_cnt -= cur_blk_cnt;
+                     desc += cq_host->trans_desc_len;
+             }
+     }
+}

Provide a hook for cqhci_set_tran_desc() instead of cqhci_prep_tran_desc() You'll need to check the details, but something like:

drivers/mmc/host/cqhci-core.c +5 -1
index b3d7d6d8d654..98e7e9d3030d 100644
@@ -522,7 +522,10 @@ static int cqhci_prep_tran_desc(struct mmc_request
 *mrq,
 
                if ((i+1) == sg_count)
                        end = true;
-               cqhci_set_tran_desc(desc, addr, len, end, dma64);
+               if (cq_host->ops->set_tran_desc)
+                       cq_host->ops->set_tran_desc(&desc, addr, len,
 end, dma64);
+               else
+                       cqhci_set_tran_desc(desc, addr, len, end,
+ dma64);
                desc += cq_host->trans_desc_len;
        }

And:

#define BOUNDARY_OK(addr, len) \
        ((addr | (SZ_128M - 1)) == ((addr + len - 1) | (SZ_128M - 1)))

static void dw_mci_cqe_set_tran_desc(u8 **desc, dma_addr_t addr, int len,

Quoted 17 lines
bool end, bool dma64) {
        int tmplen, offset;

        if (likely(!len || BOUNDARY_OK(addr, len))) {
                cqhci_set_tran_desc(*desc, addr, len, end, dma64);
                return;
        }

        offset = addr & (SZ_128M - 1);
        tmplen = SZ_128M - offset;
        cqhci_set_tran_desc(*desc, addr, tmplen, false, dma64);

        addr += tmplen;
        len -= tmplen;
        *desc += cq_host->trans_desc_len;
        cqhci_set_tran_desc(*desc, addr, len, end, dma64); }

Thanks, we will refactor this part to a more accurately way.

Quoted 68 lines

drivers/mmc/host/dw_mmc_cqe.c line 124

Quoted 8 lines
drivers/mmc/host/dw_mmc_cqe.c new file +8 -0
+
+static void dw_mci_cqe_enable(struct mmc_host *mmc) {
+     struct dw_mci_slot *slot = mmc_priv(mmc);
+     struct dw_mci *host = slot->host;
+
+     mcq_writeb(host, SW_RST_R, SDMMC_RST_DAT);
+     mcq_writew(host, XFER_MODE_R,
+                ((1 << SDMMC_MULTI_BLK_SEL) |

SDMMC_BLOCK_COUNT_ENABLE

Quoted 5 lines
drivers/mmc/host/dw_mmc_cqe.c new file +5 -0
+                     | SDMMC_DMA_ENABLE));
+
+     mcq_writeb(host, HOST_CTRL1_R,
+                (mcq_readb(host, HOST_CTRL1_R) & 0xe7) |
+                     (SDMMC_ADMA2_32 << SDMMC_DMA_SEL));

drivers/mmc/host/dw_mmc_cqe.c line 139

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe.c new file +10 -0
+     mcq_writew(host, BLOCKSIZE_R, 0x200);
+     mcq_writew(host, BLOCKCOUNT_R, 0);
+
+     mcq_writel(host, SDMASA_R, 0);
+
+     cqhci_writel(host->cqe, 0x10, CQHCI_SSC1);
+     cqhci_writel(host->cqe, 0, CQHCI_CTL);
+
+     if (cqhci_readl(host->cqe, CQHCI_CTL) && CQHCI_HALT) {
+             dev_err(host->dev, "%s: cqhci: CQE failed to exit halt

state\n",

Quoted 30 lines
drivers/mmc/host/dw_mmc_cqe.c new file +30 -0
+                     mmc_hostname(mmc));
+     }
+
+     dw_mci_clr_signal_int(host);
+     dw_mci_en_cqe_int(host);
+}
+
+static void dw_mci_cqe_pre_enable(struct mmc_host *mmc) {
+     struct cqhci_host *cq_host = mmc->cqe_private;
+     u32 reg;
+
+     reg = cqhci_readl(cq_host, CQHCI_CFG);
+     reg |= CQHCI_ENABLE;
+     cqhci_writel(cq_host, reg, CQHCI_CFG); }
+
+static void dw_mci_cqe_post_disable(struct mmc_host *mmc) {
+     struct cqhci_host *cq_host = mmc->cqe_private;
+     u32 reg;
+
+     reg = cqhci_readl(cq_host, CQHCI_CFG);
+     reg &= ~CQHCI_ENABLE;
+     cqhci_writel(cq_host, reg, CQHCI_CFG); }
+
+static const struct cqhci_host_ops dw_mci_cqhci_host_ops = {
+     .enable = dw_mci_cqe_enable,
+     .dumpregs = dw_mci_cqe_dumpregs,
+     .pre_enable = dw_mci_cqe_pre_enable,
+     .post_disable = dw_mci_cqe_post_disable,
+     .setup_tran_desc = dw_mci_cqe_setup_tran_desc, };
+

[SNIP]

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe.c new file +10 -0
+
+static irqreturn_t dw_mci_cqe_interrupt(int irq, void *dev_id) {
+     struct dw_mci *host = dev_id;
+     struct mmc_host *mmc = host->slot->mmc;
+     struct cqhci_host *cq_host = NULL;
+     int cmd_error = 0, data_error = 0;
+
+     if (host->pdata && (host->pdata->caps2 & MMC_CAP2_CQE))
+             cq_host = mmc->cqe_private;
+
Quoted 8 lines

drivers/mmc/host/dw_mmc_cqe.c

Quoted 4 lines
drivers/mmc/host/dw_mmc_cqe.c new file +4 -0
+     dw_mci_get_int(host);
+
+     if (host->pdata && (host->pdata->caps2 & MMC_CAP2_CQE)) {
+             if (!mmc->cqe_on && !cq_host->activated)

Shouldn't really look at internals like mmc->cqe_on or cq_host->activated. There are the cqhci_host_ops ->enable() and ->disable() callbacks to keep track of whether cqhci is expecting interrupts.

Does this means we need to use cqhci_host_ops ->enable() and ->disable() callbacks instead of mmc->cqe_on && !cq_host->activated? Thanks.

Quoted 40 lines

drivers/mmc/host/dw_mmc_cqe.c

Quoted 8 lines
drivers/mmc/host/dw_mmc_cqe.c new file +7 -0
+                     dw_mci_clr_signal_int(host);
+     } else {
+             dw_mci_clr_signal_int(host);
+     }
+
+     if (host->pdata && (host->pdata->caps2 & MMC_CAP2_CQE) &&
+         mmc->cqe_on && cq_host->activated) {

As above

drivers/mmc/host/dw_mmc_cqe.c

Quoted 2 lines
drivers/mmc/host/dw_mmc_cqe.c new file +2 -0
+             if (host->normal_interrupt & SDMMC_ERR_INTERRUPT) {
+                     dev_err(host->dev, "cmdq error: interrupt

status=%08x, error interrupt=0x%08x, CQIS=0x%x, CQTCN=0x%x\n",

Quoted 1 line

+ host->normal_interrupt,

host->error_interrupt,

drivers/mmc/host/dw_mmc_cqe.c

Quoted 4 lines
drivers/mmc/host/dw_mmc_cqe.c new file +4 -0
+                             readl(host->cqe->mmio + CQHCI_IS),
+                             readl(host->cqe->mmio + CQHCI_TCN));
+
+                     dw_mci_cqe_command_complete(host,

host->error_interrupt, &cmd_error);

Quoted 1 line

+ dw_mci_cqe_data_complete(host,

host->error_interrupt, &data_error);

drivers/mmc/host/dw_mmc_cqe.c

Quoted 2 lines
drivers/mmc/host/dw_mmc_cqe.c new file +2 -0
+             }
+             cqhci_irq(mmc, (u32)(host->normal_interrupt), cmd_error,

data_error);

Quoted 13 lines
drivers/mmc/host/dw_mmc_cqe.c new file +13 -0
+             dw_mci_clr_int(host);
+
+             return IRQ_HANDLED;
+     }
+
+     if (host->int_waiting) {
+             del_timer(&host->timer);
+             complete(host->int_waiting);
+     }
+
+     return IRQ_HANDLED;
+}
+
maintainer
#12 lore raw

Re: [PATCH v7][2/4] mmc: Add Synopsys DesignWare mmc cmdq host driver

Quoted 19 lines · Jyan Chou [周芷安]
Quoted 10 lines
Quoted 10 lines
(quoted diff) +10 -0
+
+static irqreturn_t dw_mci_cqe_interrupt(int irq, void *dev_id) {
+     struct dw_mci *host = dev_id;
+     struct mmc_host *mmc = host->slot->mmc;
+     struct cqhci_host *cq_host = NULL;
+     int cmd_error = 0, data_error = 0;
+
+     if (host->pdata && (host->pdata->caps2 & MMC_CAP2_CQE))
+             cq_host = mmc->cqe_private;
+
Quoted 8 lines

Review

Quoted 4 lines
(quoted diff) +4 -0
+     dw_mci_get_int(host);
+
+     if (host->pdata && (host->pdata->caps2 & MMC_CAP2_CQE)) {
+             if (!mmc->cqe_on && !cq_host->activated)

Shouldn't really look at internals like mmc->cqe_on or cq_host->activated. There are the cqhci_host_ops ->enable() and ->disable() callbacks to keep track of whether cqhci is expecting interrupts.

Quoted 2 lines

Does this means we need to use cqhci_host_ops ->enable() and ->disable() callbacks instead of mmc->cqe_on && !cq_host->activated? Thanks.

Yes. ->enable() is always called before cqhci operation and ->disable() before non-cqhci operation, so they can be used to determine if an interrupt is for cqhci.

#13 lore raw

RE: [PATCH v7][2/4] mmc: Add Synopsys DesignWare mmc cmdq host driver

Hi Adrian,

Quoted 19 lines
Quoted 19 lines
Quoted 18 lines
Quoted 4 lines
(quoted diff) +4 -0
+
+static irqreturn_t dw_mci_cqe_interrupt(int irq, void *dev_id) {
+     struct dw_mci *host = dev_id;
+     struct mmc_host *mmc = host->slot->mmc;

Review

Quoted 10 lines
(quoted diff) +10 -0
+     struct cqhci_host *cq_host = NULL;
+     int cmd_error = 0, data_error = 0;
+
+     if (host->pdata && (host->pdata->caps2 & MMC_CAP2_CQE))
+             cq_host = mmc->cqe_private;
+
+     dw_mci_get_int(host);
+
+     if (host->pdata && (host->pdata->caps2 & MMC_CAP2_CQE)) {
+             if (!mmc->cqe_on && !cq_host->activated)

Shouldn't really look at internals like mmc->cqe_on or cq_host->activated. There are the cqhci_host_ops ->enable() and ->disable() callbacks to keep track of whether cqhci is expecting interrupts.

Quoted 7 lines
Quoted 2 lines

Does this means we need to use cqhci_host_ops ->enable() and ->disable() callbacks instead of mmc->cqe_on && !cq_host->activated?

Thanks.

Yes. ->enable() is always called before cqhci operation and ->disable() before non-cqhci operation, so they can be used to determine if an interrupt is for cqhci.

Thanks for your advice, and I got your point for calling cqhci_host_ops ->enable()

and ->disable() callbacks, but the reason we used " if (!mmc->cqe_on && !cq_host->activated) "

is that when sending command like cmd0, 1, 7, 8... in mmc_init_card before mmc_cmdq_enable,

we need to use interrupt in legacy mode, it is much better to write in this way?

+ events = mci_readw(host, NORMAL_INT_STAT_R);
- if (host->pdata && (host->pdata->caps2 & MMC_CAP2_CQE)) {
- if (!mmc->cqe_on && !cq_host->activated)
+ if (mmc->caps2 & MMC_CAP2_CQE) {
+ if (!(events & CQE_EVENT))

			dw_mci_clr_signal_int(host);

Using CQE_EVENT to determine whether Command Queue enable or not.

Many thanks.

Best Regards,
Jyan

maintainer
#14 lore raw

Re: [PATCH v7][2/4] mmc: Add Synopsys DesignWare mmc cmdq host driver

Quoted 44 lines · Jyan Chou [周芷安]

Hi Adrian,

Quoted 19 lines
Quoted 19 lines
Quoted 18 lines
Quoted 4 lines
(quoted diff) +4 -0
+
+static irqreturn_t dw_mci_cqe_interrupt(int irq, void *dev_id) {
+     struct dw_mci *host = dev_id;
+     struct mmc_host *mmc = host->slot->mmc;

Review

Quoted 10 lines
(quoted diff) +10 -0
+     struct cqhci_host *cq_host = NULL;
+     int cmd_error = 0, data_error = 0;
+
+     if (host->pdata && (host->pdata->caps2 & MMC_CAP2_CQE))
+             cq_host = mmc->cqe_private;
+
+     dw_mci_get_int(host);
+
+     if (host->pdata && (host->pdata->caps2 & MMC_CAP2_CQE)) {
+             if (!mmc->cqe_on && !cq_host->activated)

Shouldn't really look at internals like mmc->cqe_on or cq_host->activated. There are the cqhci_host_ops ->enable() and ->disable() callbacks to keep track of whether cqhci is expecting interrupts.

Quoted 7 lines
Quoted 2 lines

Does this means we need to use cqhci_host_ops ->enable() and ->disable() callbacks instead of mmc->cqe_on && !cq_host->activated?

Thanks.

Yes. ->enable() is always called before cqhci operation and ->disable() before non-cqhci operation, so they can be used to determine if an interrupt is for cqhci.

Thanks for your advice, and I got your point for calling cqhci_host_ops ->enable()

and ->disable() callbacks, but the reason we used " if (!mmc->cqe_on && !cq_host->activated) "

is that when sending command like cmd0, 1, 7, 8... in mmc_init_card before mmc_cmdq_enable,

we need to use interrupt in legacy mode, it is much better to write in this way?

(quoted diff) +3 -2
+	events = mci_readw(host, NORMAL_INT_STAT_R);
- 	if (host->pdata && (host->pdata->caps2 & MMC_CAP2_CQE)) {
- 		if (!mmc->cqe_on && !cq_host->activated)
+	if (mmc->caps2 & MMC_CAP2_CQE) {
+		if (!(events & CQE_EVENT))
			dw_mci_clr_signal_int(host);
Quoted 1 line

Using CQE_EVENT to determine whether Command Queue enable or not.

Unless you expect CQ interrupts before cqhci_host_ops ->enable() is called, then you know it is legacy mode.

author
#15 lore raw

PATCH v7 3/4 mmc: Add dw mobile mmc cmdq rtk driver

In reply to Jyan Chou

Add Realtek mmc driver to make good use Synopsys
DesignWare mmc cmdq host driver.

---
v6 -> v7:
- remove useless setting realtek,m2tmx since we set it by hardware default.

v5 -> v6:
- Fix linux coding style issues.
- Drop useless code that is not descibed in bindings.

v4 -> v5:
- Fix linux coding style issues.
- Modify the use of sizeof(*).
- Remove useless function and parameter passing.
- Replace platform_get_resource by devm_platform_ioremap_resource().

v3 -> v4:
- Modify dma setting's code to fix linux coding style.
- Drop useless function messages.
- Remove MODULE_ALIAS().

v0 -> v1:
- Seperate different support into single patch.
- Fix the compiler complains.
---

---
 drivers/mmc/host/Kconfig          |   9 +
 drivers/mmc/host/Makefile         |   1 +
 drivers/mmc/host/dw_mmc_cqe-rtk.c | 768 ++++++++++++++++++++++++++++++
 drivers/mmc/host/dw_mmc_cqe-rtk.h | 160 +++++++
 4 files changed, 938 insertions(+)
 create mode 100644 drivers/mmc/host/dw_mmc_cqe-rtk.c
 create mode 100644 drivers/mmc/host/dw_mmc_cqe-rtk.h
drivers/mmc/host/Kconfig +9 -0
index 06bb4de28cc4..2bc361dc8359 100644
@@ -850,6 +850,15 @@ config MMC_DW_CQE
 
 	 If unsure, say Y.
 
+config MMC_DW_CQE_RTK
+	tristate "Realtek Soc's specific extensions for Synopsys DW Memory Card Interface"
+	depends on MMC_DW_CQE
+	select REGULATOR_FIXED_VOLTAGE
+	help
+	 This selects support for Realtek SoC specific extensions to the
+	 Synopsys DesignWare Memory Card Interface driver. Select this option
+	 for platforms after RTD16xxb SoC's.
+
 config MMC_SH_MMCIF
 	tristate "SuperH Internal MMCIF support"
 	depends on SUPERH || ARCH_RENESAS || COMPILE_TEST
drivers/mmc/host/Makefile +1 -0
index 464fe58f8541..4762d1e68cba 100644
@@ -56,6 +56,7 @@ obj-$(CONFIG_MMC_DW_PCI)	+= dw_mmc-pci.o
 obj-$(CONFIG_MMC_DW_ROCKCHIP)	+= dw_mmc-rockchip.o
 obj-$(CONFIG_MMC_DW_STARFIVE)	+= dw_mmc-starfive.o
 obj-$(CONFIG_MMC_DW_CQE)	+= dw_mmc_cqe.o
+obj-$(CONFIG_MMC_DW_CQE_RTK)    += dw_mmc_cqe-rtk.o
 obj-$(CONFIG_MMC_SH_MMCIF)	+= sh_mmcif.o
 obj-$(CONFIG_MMC_JZ4740)	+= jz4740_mmc.o
 obj-$(CONFIG_MMC_VUB300)	+= vub300.o
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +768 -0

768 lines not on this page · raw message

drivers/mmc/host/dw_mmc_cqe-rtk.h new file +160 -0

160 lines not on this page · raw message

Signature · 1 line
2.42.0
author
#16 lore raw

PATCH v7 4/4 dt-bindings: mmc: Add dt-bindings for realtek mmc driver

In reply to Jyan Chou

Document the device-tree bindings for Realtek SoCs mmc driver.

---
v6 -> v7:
- Drop reset-names and realtek,m2tmx since it is not needed in our driver.

v5 -> v6:
- Drop the incorrect, generic compatible and modify it to specific.
- Drop useless properties.
- Modify bindings to make DTS and driver match.

v4 -> v5:
- Remove unused property, e.g.,cqe, resets, clock-freq-min-max.
- Fix indentation.

v3 -> v4:
- Describe the items to make properties and item easy to understand.
- Fix examples' indentation and compiling error.
- Drop useless properties.

v2 -> v3:
- Modify dt-bindings' content and description.
- Fix coding style.
- Update the list of maintainers.

v1 -> v2:
- Add dt-bindings.
---

---
 .../bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml | 153 ++++++++++++++++++
 1 file changed, 153 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml new file +153 -0
new file mode 100644
index 000000000000..ae063fcae365
@@ -0,0 +1,153 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mmc/realtek,rtd-dw-cqe-emmc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Realtek DesignWare mobile storage host controller
+
+description:
+  Realtek uses the Synopsys DesignWare mobile storage host controller
+  to interface a SoC with storage medium. This file documents the Realtek
+  specific extensions.
+
+maintainers:
+  - Jyan Chou <[email protected]>
+
+allOf:
+  - $ref: synopsys-dw-mshc-common.yaml#
+
+properties:
+  compatible:
+    enum:
+      - realtek,rtd1325-dw-cqe-emmc
+      - realtek,rtd1319-dw-cqe-emmc
+      - realtek,rtd1315e-dw-cqe-emmc
+      - realtek,rtd1619b-dw-cqe-emmc
+
+  reg:
+    items:
+      - description: emmc base address
+      - description: cqhci base address
+
+  reg-names:
+    items:
+      - const: emmc
+      - const: cqhci
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    maxItems: 4
+
+  clock-names:
+    items:
+      - const: biu
+      - const: ciu
+      - const: vp0
+      - const: vp1
+
+  resets:
+    maxItems: 1
+
+  pinctrl-0:
+    description:
+      should contain default/high speed pin ctrl.
+    maxItems: 1
+
+  pinctrl-1:
+    description:
+      should contain sdr50 pin ctrl.
+    maxItems: 1
+
+  pinctrl-2:
+    description:
+      should contain ddr50 mode pin ctrl.
+    maxItems: 1
+
+  pinctrl-3:
+    description:
+      should contain hs200 speed pin ctrl.
+    maxItems: 1
+
+  pinctrl-4:
+    description:
+      should contain hs400 speed pin ctrl.
+    maxItems: 1
+
+  pinctrl-5:
+    description:
+      should contain tune0 pin ctrl.
+    maxItems: 1
+
+  pinctrl-6:
+    description:
+      should contain tune1 pin ctrl.
+    maxItems: 1
+
+  pinctrl-7:
+    description:
+      should contain tune2 pin ctrl.
+    maxItems: 1
+
+  pinctrl-8:
+    description:
+      should contain tune3 pin ctrl.
+    maxItems: 1
+
+  pinctrl-9:
+    description:
+      should contain tune4 pin ctrl.
+    maxItems: 1
+
+  pinctrl-names:
+    maxItems: 10
+
+required:
+  - compatible
+  - reg
+  - reg-names
+  - interrupts
+  - clocks
+  - clock-names
+  - vmmc-supply
+  - pinctrl-names
+  - pinctrl-0
+  - pinctrl-1
+  - pinctrl-3
+  - pinctrl-4
+  - pinctrl-5
+  - pinctrl-6
+  - pinctrl-7
+  - pinctrl-8
+  - pinctrl-9
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    emmc: mmc@12000 {
+      compatible = "realtek,rtd1315e-dw-cqe-emmc";
+      reg = <0x00012000 0x00600>,
+            <0x00012180 0x00060>;
+      reg-names = "emmc", "cqhci";
+      interrupts = <0 42 4>;
+      clocks = <&cc 22>, <&cc 26>, <&cc 121>, <&cc 122>;
+      clock-names = "biu", "ciu", "vp0", "vp1";
+      resets = <&rst 20>;
+      vmmc-supply = <&reg_vcc1v8>;
+      pinctrl-names = "default", "sdr50", "ddr50", "hs200", "hs400",
+                      "tune0","tune1", "tune2","tune3", "tune4";
+      pinctrl-0 = <&emmc_pins_sdr50>;
+      pinctrl-1 = <&emmc_pins_sdr50>;
+      pinctrl-2 = <&emmc_pins_ddr50>;
+      pinctrl-3 = <&emmc_pins_hs200>;
+      pinctrl-4 = <&emmc_pins_hs400>;
+      pinctrl-5 = <&emmc_pins_tune0>;
+      pinctrl-6 = <&emmc_pins_tune1>;
+      pinctrl-7 = <&emmc_pins_tune2>;
+      pinctrl-8 = <&emmc_pins_tune3>;
+      pinctrl-9 = <&emmc_pins_tune4>;
+      supports-cqe;
+    };
Signature · 1 line
2.42.0
#17 lore raw

Re: [PATCH v7][4/4] dt-bindings: mmc: Add dt-bindings for realtek mmc driver

Quoted 1 line · Jyan Chou

Document the device-tree bindings for Realtek SoCs mmc driver.

This is a friendly reminder during the review process.

It seems my or other reviewer's previous comments were not fully addressed. Maybe the feedback got lost between the quotes, maybe you just forgot to apply it. Please go back to the previous discussion and either implement all requested changes or keep discussing them.

Thank you.

Additionally:

A nit, subject: drop second/last, redundant "bindings for". The "dt-bindings" prefix is already stating that these are bindings.

Quoted 10 lines

---
v6 -> v7:
- Drop reset-names and realtek,m2tmx since it is not needed in our driver.

v5 -> v6:
- Drop the incorrect, generic compatible and modify it to specific.
- Drop useless properties.

I asked which ones. I still do not see that information here.

Quoted 6 lines

- Modify bindings to make DTS and driver match.

v4 -> v5:
- Remove unused property, e.g.,cqe, resets, clock-freq-min-max.
- Fix indentation.

...

Quoted 4 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml new file +4 -0
+
+maintainers:
+  - Jyan Chou <[email protected]>
+

Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml line 26

Quoted 10 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml new file +10 -0
+allOf:
+  - $ref: synopsys-dw-mshc-common.yaml#
+
+properties:
+  compatible:
+    enum:
+      - realtek,rtd1325-dw-cqe-emmc
+      - realtek,rtd1319-dw-cqe-emmc
+      - realtek,rtd1315e-dw-cqe-emmc
+      - realtek,rtd1619b-dw-cqe-emmc

That's not what is present in your driver. Why other compatibles are not there? What do you want to express here?

Quoted 99 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml new file +99 -0
+
+  reg:
+    items:
+      - description: emmc base address
+      - description: cqhci base address
+
+  reg-names:
+    items:
+      - const: emmc
+      - const: cqhci
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    maxItems: 4
+
+  clock-names:
+    items:
+      - const: biu
+      - const: ciu
+      - const: vp0
+      - const: vp1
+
+  resets:
+    maxItems: 1
+
+  pinctrl-0:
+    description:
+      should contain default/high speed pin ctrl.
+    maxItems: 1
+
+  pinctrl-1:
+    description:
+      should contain sdr50 pin ctrl.
+    maxItems: 1
+
+  pinctrl-2:
+    description:
+      should contain ddr50 mode pin ctrl.
+    maxItems: 1
+
+  pinctrl-3:
+    description:
+      should contain hs200 speed pin ctrl.
+    maxItems: 1
+
+  pinctrl-4:
+    description:
+      should contain hs400 speed pin ctrl.
+    maxItems: 1
+
+  pinctrl-5:
+    description:
+      should contain tune0 pin ctrl.
+    maxItems: 1
+
+  pinctrl-6:
+    description:
+      should contain tune1 pin ctrl.
+    maxItems: 1
+
+  pinctrl-7:
+    description:
+      should contain tune2 pin ctrl.
+    maxItems: 1
+
+  pinctrl-8:
+    description:
+      should contain tune3 pin ctrl.
+    maxItems: 1
+
+  pinctrl-9:
+    description:
+      should contain tune4 pin ctrl.
+    maxItems: 1
+
+  pinctrl-names:
+    maxItems: 10
+
+required:
+  - compatible
+  - reg
+  - reg-names
+  - interrupts
+  - clocks
+  - clock-names
+  - vmmc-supply
+  - pinctrl-names
+  - pinctrl-0
+  - pinctrl-1
+  - pinctrl-3
+  - pinctrl-4
+  - pinctrl-5
+  - pinctrl-6
+  - pinctrl-7
+  - pinctrl-8
+  - pinctrl-9
+

Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml line 135

Quoted 10 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml new file +10 -0
+unevaluatedProperties: false
+
+examples:
+  - |
+    emmc: mmc@12000 {
+      compatible = "realtek,rtd1315e-dw-cqe-emmc";
+      reg = <0x00012000 0x00600>,
+            <0x00012180 0x00060>;
+      reg-names = "emmc", "cqhci";
+      interrupts = <0 42 4>;

Use proper interrupt defines instead of raw values.

Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml line 137

Quoted 2 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml new file +2 -0
+      clocks = <&cc 22>, <&cc 26>, <&cc 121>, <&cc 122>;
+      clock-names = "biu", "ciu", "vp0", "vp1";

Where is the DTS implementing this binding?

I said it once:

Quoted 5 lines

I asked you to test the bindings. This also means that you must test your DTS against bindings. Your bindings, DTS and driver do not match, therefore let's be a bit more clear:

NAK, till you upstream your DTS.

I still do not see DTS anywhere. Please link it.

Best regards,
Krzysztof

#18 lore raw

RE: [PATCH v7][4/4] dt-bindings: mmc: Add dt-bindings for realtek mmc driver

Quoted 11 lines
Quoted 1 line

Document the device-tree bindings for Realtek SoCs mmc driver.

This is a friendly reminder during the review process.

It seems my or other reviewer's previous comments were not fully addressed. Maybe the feedback got lost between the quotes, maybe you just forgot to apply it. Please go back to the previous discussion and either implement all requested changes or keep discussing them.

Thank you.

Additionally:

A nit, subject: drop second/last, redundant "bindings for". The "dt-bindings" prefix is already stating that these are bindings.

Okay, I will check if I miss to correct some previous comments.

Quoted 7 lines
Quoted 7 lines

---
v6 -> v7:
- Drop reset-names and realtek,m2tmx since it is not needed in our driver.

Quoted 5 lines
Quoted 3 lines

v5 -> v6:
- Drop the incorrect, generic compatible and modify it to specific.
- Drop useless properties.

I asked which ones. I still do not see that information here.

Okay, I will list it in.

Quoted 6 lines
Quoted 6 lines

- Modify bindings to make DTS and driver match.

v4 -> v5:
- Remove unused property, e.g.,cqe, resets, clock-freq-min-max.
- Fix indentation.

...

Quoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml new file +8 -0
+
+maintainers:
+  - Jyan Chou <[email protected]>
+
+allOf:
+  - $ref: synopsys-dw-mshc-common.yaml#
+
+properties:
Quoted 8 lines

Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml line 26

Quoted 6 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml new file +6 -0
+  compatible:
+    enum:
+      - realtek,rtd1325-dw-cqe-emmc
+      - realtek,rtd1319-dw-cqe-emmc
+      - realtek,rtd1315e-dw-cqe-emmc
+      - realtek,rtd1619b-dw-cqe-emmc

That's not what is present in your driver. Why other compatibles are not there? What do you want to express here?

Other compatibles are surely needed to be in our driver, I will correct it in our new version, thanks.

Quoted 103 lines
Quoted 103 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml new file +103 -0
+
+  reg:
+    items:
+      - description: emmc base address
+      - description: cqhci base address
+
+  reg-names:
+    items:
+      - const: emmc
+      - const: cqhci
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    maxItems: 4
+
+  clock-names:
+    items:
+      - const: biu
+      - const: ciu
+      - const: vp0
+      - const: vp1
+
+  resets:
+    maxItems: 1
+
+  pinctrl-0:
+    description:
+      should contain default/high speed pin ctrl.
+    maxItems: 1
+
+  pinctrl-1:
+    description:
+      should contain sdr50 pin ctrl.
+    maxItems: 1
+
+  pinctrl-2:
+    description:
+      should contain ddr50 mode pin ctrl.
+    maxItems: 1
+
+  pinctrl-3:
+    description:
+      should contain hs200 speed pin ctrl.
+    maxItems: 1
+
+  pinctrl-4:
+    description:
+      should contain hs400 speed pin ctrl.
+    maxItems: 1
+
+  pinctrl-5:
+    description:
+      should contain tune0 pin ctrl.
+    maxItems: 1
+
+  pinctrl-6:
+    description:
+      should contain tune1 pin ctrl.
+    maxItems: 1
+
+  pinctrl-7:
+    description:
+      should contain tune2 pin ctrl.
+    maxItems: 1
+
+  pinctrl-8:
+    description:
+      should contain tune3 pin ctrl.
+    maxItems: 1
+
+  pinctrl-9:
+    description:
+      should contain tune4 pin ctrl.
+    maxItems: 1
+
+  pinctrl-names:
+    maxItems: 10
+
+required:
+  - compatible
+  - reg
+  - reg-names
+  - interrupts
+  - clocks
+  - clock-names
+  - vmmc-supply
+  - pinctrl-names
+  - pinctrl-0
+  - pinctrl-1
+  - pinctrl-3
+  - pinctrl-4
+  - pinctrl-5
+  - pinctrl-6
+  - pinctrl-7
+  - pinctrl-8
+  - pinctrl-9
+
+unevaluatedProperties: false
+
+examples:
+  - |
Quoted 8 lines

Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml line 135

Quoted 6 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml new file +6 -0
+    emmc: mmc@12000 {
+      compatible = "realtek,rtd1315e-dw-cqe-emmc";
+      reg = <0x00012000 0x00600>,
+            <0x00012180 0x00060>;
+      reg-names = "emmc", "cqhci";
+      interrupts = <0 42 4>;

Use proper interrupt defines instead of raw values.

Okay, I will correct it.

Quoted 7 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml new file +2 -0
+      clocks = <&cc 22>, <&cc 26>, <&cc 121>, <&cc 122>;
+      clock-names = "biu", "ciu", "vp0", "vp1";

Where is the DTS implementing this binding?

I said it once:

Quoted 7 lines
Quoted 5 lines

I asked you to test the bindings. This also means that you must test your DTS against bindings. Your bindings, DTS and driver do not match, therefore let's be a bit more clear:

NAK, till you upstream your DTS.

I still do not see DTS anywhere. Please link it.

Sorry for asking. Which dts do we need to link it? The device tree we use for our SOC?

or realtek,rtd-dw-cqe-emmc.example.dts? Thanks.

Best Regards,

Jyan
-----Original Message-----
From: Krzysztof Kozlowski <[email protected]>
Sent: Tuesday, November 21, 2023 5:35 PM
To: Jyan Chou [周芷安] <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v7][4/4] dt-bindings: mmc: Add dt-bindings for realtek mmc driver

External mail.

Quoted 1 line · Jyan Chou

Document the device-tree bindings for Realtek SoCs mmc driver.

This is a friendly reminder during the review process.

It seems my or other reviewer's previous comments were not fully addressed. Maybe the feedback got lost between the quotes, maybe you just forgot to apply it. Please go back to the previous discussion and either implement all requested changes or keep discussing them.

Thank you.

Additionally:

A nit, subject: drop second/last, redundant "bindings for". The "dt-bindings" prefix is already stating that these are bindings.

Quoted 10 lines

---
v6 -> v7:
- Drop reset-names and realtek,m2tmx since it is not needed in our driver.

v5 -> v6:
- Drop the incorrect, generic compatible and modify it to specific.
- Drop useless properties.

I asked which ones. I still do not see that information here.

Quoted 6 lines

- Modify bindings to make DTS and driver match.

v4 -> v5:
- Remove unused property, e.g.,cqe, resets, clock-freq-min-max.
- Fix indentation.

...

Quoted 4 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml new file +4 -0
+
+maintainers:
+  - Jyan Chou <[email protected]>
+

Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml line 26

Quoted 10 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml new file +10 -0
+allOf:
+  - $ref: synopsys-dw-mshc-common.yaml#
+
+properties:
+  compatible:
+    enum:
+      - realtek,rtd1325-dw-cqe-emmc
+      - realtek,rtd1319-dw-cqe-emmc
+      - realtek,rtd1315e-dw-cqe-emmc
+      - realtek,rtd1619b-dw-cqe-emmc

That's not what is present in your driver. Why other compatibles are not there? What do you want to express here?

Quoted 99 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml new file +99 -0
+
+  reg:
+    items:
+      - description: emmc base address
+      - description: cqhci base address
+
+  reg-names:
+    items:
+      - const: emmc
+      - const: cqhci
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    maxItems: 4
+
+  clock-names:
+    items:
+      - const: biu
+      - const: ciu
+      - const: vp0
+      - const: vp1
+
+  resets:
+    maxItems: 1
+
+  pinctrl-0:
+    description:
+      should contain default/high speed pin ctrl.
+    maxItems: 1
+
+  pinctrl-1:
+    description:
+      should contain sdr50 pin ctrl.
+    maxItems: 1
+
+  pinctrl-2:
+    description:
+      should contain ddr50 mode pin ctrl.
+    maxItems: 1
+
+  pinctrl-3:
+    description:
+      should contain hs200 speed pin ctrl.
+    maxItems: 1
+
+  pinctrl-4:
+    description:
+      should contain hs400 speed pin ctrl.
+    maxItems: 1
+
+  pinctrl-5:
+    description:
+      should contain tune0 pin ctrl.
+    maxItems: 1
+
+  pinctrl-6:
+    description:
+      should contain tune1 pin ctrl.
+    maxItems: 1
+
+  pinctrl-7:
+    description:
+      should contain tune2 pin ctrl.
+    maxItems: 1
+
+  pinctrl-8:
+    description:
+      should contain tune3 pin ctrl.
+    maxItems: 1
+
+  pinctrl-9:
+    description:
+      should contain tune4 pin ctrl.
+    maxItems: 1
+
+  pinctrl-names:
+    maxItems: 10
+
+required:
+  - compatible
+  - reg
+  - reg-names
+  - interrupts
+  - clocks
+  - clock-names
+  - vmmc-supply
+  - pinctrl-names
+  - pinctrl-0
+  - pinctrl-1
+  - pinctrl-3
+  - pinctrl-4
+  - pinctrl-5
+  - pinctrl-6
+  - pinctrl-7
+  - pinctrl-8
+  - pinctrl-9
+

Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml line 135

Quoted 10 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml new file +10 -0
+unevaluatedProperties: false
+
+examples:
+  - |
+    emmc: mmc@12000 {
+      compatible = "realtek,rtd1315e-dw-cqe-emmc";
+      reg = <0x00012000 0x00600>,
+            <0x00012180 0x00060>;
+      reg-names = "emmc", "cqhci";
+      interrupts = <0 42 4>;

Use proper interrupt defines instead of raw values.

Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml line 137

Quoted 2 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml new file +2 -0
+      clocks = <&cc 22>, <&cc 26>, <&cc 121>, <&cc 122>;
+      clock-names = "biu", "ciu", "vp0", "vp1";

Where is the DTS implementing this binding?

I said it once:

Quoted 5 lines

I asked you to test the bindings. This also means that you must test your DTS against bindings. Your bindings, DTS and driver do not match, therefore let's be a bit more clear:

NAK, till you upstream your DTS.

I still do not see DTS anywhere. Please link it.

Best regards,
Krzysztof

#19 lore raw

Re: [PATCH v7][4/4] dt-bindings: mmc: Add dt-bindings for realtek mmc driver

Quoted 11 lines · Jyan Chou [周芷安]
Quoted 11 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml new file +2 -0
+      clocks = <&cc 22>, <&cc 26>, <&cc 121>, <&cc 122>;
+      clock-names = "biu", "ciu", "vp0", "vp1";

Where is the DTS implementing this binding?

I said it once:

Quoted 4 lines

I asked you to test the bindings. This also means that you must test your DTS against bindings. Your bindings, DTS and driver do not match, therefore let's be a bit more clear:

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

NAK, till you upstream your DTS.

I still do not see DTS anywhere. Please link it.

Sorry for asking. Which dts do we need to link it? The device tree we use for our SOC?

or realtek,rtd-dw-cqe-emmc.example.dts? Thanks.

The patch adding this device node to any upstream DTS. I am not speaking about example, but about upstream DTS using this MMC.

As I wrote last time, I don't believe you test bindings and DTS and I had proofs of that. Therefore I expect you to upstream DTS of your product.

Best regards,
Krzysztof

#20 lore raw

RE: [PATCH v7][4/4] dt-bindings: mmc: Add dt-bindings for realtek mmc driver

Quoted 15 lines
Quoted 15 lines

Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml line 137

Quoted 2 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml new file +2 -0
+      clocks = <&cc 22>, <&cc 26>, <&cc 121>, <&cc 122>;
+      clock-names = "biu", "ciu", "vp0", "vp1";

Where is the DTS implementing this binding?

Quoted 9 lines

I said it once:

Quoted 5 lines

I asked you to test the bindings. This also means that you must test your DTS against bindings. Your bindings, DTS and driver do not match, therefore let's be a bit more clear:

NAK, till you upstream your DTS.

I still do not see DTS anywhere. Please link it.

Quoted 7 lines
Quoted 3 lines

Sorry for asking. Which dts do we need to link it? The device tree we use for our SOC?

or realtek,rtd-dw-cqe-emmc.example.dts? Thanks.

The patch adding this device node to any upstream DTS. I am not speaking about example, but about upstream DTS using this MMC.

As I wrote last time, I don't believe you test bindings and DTS and I had proofs of that. Therefore I expect you to upstream DTS of your product.

Sorry for explaining, since our DTS is still trying to upstream, but not accepted by upstream yet,

https://lore.kernel.org/linux-arm-kernel/[email protected]/T/

could I provide the dts we local used now for you first to compare with bindings? I am sorry for making this request.

Best regards,
Jyan

-----Original Message-----
From: Krzysztof Kozlowski <[email protected]>
Sent: Wednesday, November 22, 2023 3:37 PM
To: Jyan Chou [周芷安] <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v7][4/4] dt-bindings: mmc: Add dt-bindings for realtek mmc driver

External mail.

Quoted 11 lines · Jyan Chou [周芷安]
Quoted 11 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml new file +2 -0
+      clocks = <&cc 22>, <&cc 26>, <&cc 121>, <&cc 122>;
+      clock-names = "biu", "ciu", "vp0", "vp1";

Where is the DTS implementing this binding?

I said it once:

Quoted 4 lines

I asked you to test the bindings. This also means that you must test your DTS against bindings. Your bindings, DTS and driver do not match, therefore let's be a bit more clear:

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

NAK, till you upstream your DTS.

I still do not see DTS anywhere. Please link it.

Sorry for asking. Which dts do we need to link it? The device tree we use for our SOC?

or realtek,rtd-dw-cqe-emmc.example.dts? Thanks.

The patch adding this device node to any upstream DTS. I am not speaking about example, but about upstream DTS using this MMC.

As I wrote last time, I don't believe you test bindings and DTS and I had proofs of that. Therefore I expect you to upstream DTS of your product.

Best regards,
Krzysztof

#21 lore raw

Re: [PATCH v7][4/4] dt-bindings: mmc: Add dt-bindings for realtek mmc driver

Quoted 17 lines · Jyan Chou [周芷安]
Quoted 17 lines
Quoted 17 lines

Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml line 137

Quoted 2 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml new file +2 -0
+      clocks = <&cc 22>, <&cc 26>, <&cc 121>, <&cc 122>;
+      clock-names = "biu", "ciu", "vp0", "vp1";

Where is the DTS implementing this binding?

Quoted 9 lines

I said it once:

Quoted 5 lines

I asked you to test the bindings. This also means that you must test your DTS against bindings. Your bindings, DTS and driver do not match, therefore let's be a bit more clear:

NAK, till you upstream your DTS.

I still do not see DTS anywhere. Please link it.

Sorry for asking. Which dts do we need to link it? The device tree we use for our SOC?

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

or realtek,rtd-dw-cqe-emmc.example.dts? Thanks.

The patch adding this device node to any upstream DTS. I am not speaking about example, but about upstream DTS using this MMC.

As I wrote last time, I don't believe you test bindings and DTS and I had proofs of that. Therefore I expect you to upstream DTS of your product.

Sorry for explaining, since our DTS is still trying to upstream, but not accepted by upstream yet,

Please wrap your replies to match mailing list etiquette.

Quoted 2 lines

https://lore.kernel.org/linux-arm-kernel/[email protected]/T/

Last submission was half a year ago. That submission was not tested either, so neither are your bindings nor DTS tested.

Quoted 2 lines

could I provide the dts we local used now for you first to compare with bindings? I am sorry for making this request.

I don't believe you are testing these, so the answer is not. Please send your SoC for upstreaming with MMC nodes included or as follow up.

Best regards,
Krzysztof