Skip to contentSkip to conversation

Add DesignWare Mobile mmc driver

PATCH Superseded Jyan Chou 4 participants 19 messages Oct 30, 2023 – Nov 2, 2023

Subsystems (4)

v4 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Jyan Chou

author
#0 lore raw

v4 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-dw-mshc.yaml         |  161 ++
 drivers/mmc/host/Kconfig                      |   22 +
 drivers/mmc/host/Makefile                     |    2 +
 drivers/mmc/host/cqhci-core.c                 |    8 +-
 drivers/mmc/host/cqhci.h                      |    5 +
 drivers/mmc/host/dw_mmc_cqe-rtk.c             |  979 ++++++++++
 drivers/mmc/host/dw_mmc_cqe-rtk.h             |  160 ++
 drivers/mmc/host/dw_mmc_cqe.c                 | 1620 +++++++++++++++++
 drivers/mmc/host/dw_mmc_cqe.h                 |  449 +++++
 9 files changed, 3405 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/mmc/realtek-dw-mshc.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 v4 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.

---
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 | 8 +++++++-
 drivers/mmc/host/cqhci.h      | 5 +++++
 2 files changed, 12 insertions(+), 1 deletion(-)
drivers/mmc/host/cqhci-core.c +7 -1
index b3d7d6d8d654..5560329d2a7d 100644
@@ -474,7 +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,
+void cqhci_set_tran_desc(u8 *desc, dma_addr_t addr, int len, bool end,
 				bool dma64)
 {
 	__le32 *attr = (__le32 __force *)desc;
@@ -495,6 +495,7 @@ static void cqhci_set_tran_desc(u8 *desc, dma_addr_t addr, int len, bool end,
 		dataddr[0] = cpu_to_le32(addr);
 	}
 }
+EXPORT_SYMBOL(cqhci_set_tran_desc);
 
 static int cqhci_prep_tran_desc(struct mmc_request *mrq,
 			       struct cqhci_host *cq_host, int tag)
@@ -516,6 +517,11 @@ static int cqhci_prep_tran_desc(struct mmc_request *mrq,
 
 	desc = get_trans_desc(cq_host, tag);
 
+	if (cq_host->ops->setup_tran_desc) {
+		cq_host->ops->setup_tran_desc(data, cq_host, desc, sg_count);
+		return 0;
+	}
+
 	for_each_sg(data->sg, sg, sg_count, i) {
 		addr = sg_dma_address(sg);
 		len = sg_dma_len(sg);
drivers/mmc/host/cqhci.h +5 -0
index 1a12e40a02e6..fded53fc2a0b 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 {
@@ -289,6 +290,8 @@ struct cqhci_host_ops {
 				 u64 *data);
 	void (*pre_enable)(struct mmc_host *mmc);
 	void (*post_disable)(struct mmc_host *mmc);
+	void (*setup_tran_desc)(struct mmc_data *data,
+				struct cqhci_host *cq_host, u8 *desc, int sg_count);
 #ifdef CONFIG_MMC_CRYPTO
 	int (*program_key)(struct cqhci_host *cq_host,
 			   const union cqhci_crypto_cfg_entry *cfg, int slot);
@@ -322,6 +325,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
#2 lore raw

Re: [PATCH V4][1/4] mmc: solve DMA boundary limitation of CQHCI driver

Quoted 37 lines · Jyan Chou

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.

---
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 | 8 +++++++-
 drivers/mmc/host/cqhci.h      | 5 +++++
 2 files changed, 12 insertions(+), 1 deletion(-)
drivers/mmc/host/cqhci-core.c +1 -1
index b3d7d6d8d654..5560329d2a7d 100644
@@ -474,7 +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,
+void cqhci_set_tran_desc(u8 *desc, dma_addr_t addr, int len, bool end,
 				bool dma64)
 {
 	__le32 *attr = (__le32 __force *)desc;

drivers/mmc/host/cqhci-core.c static void cqhci_set_tran_desc(u8 *desc, dma_addr_t addr, int len, bool end, · line 498

Quoted 4 lines
drivers/mmc/host/cqhci-core.c +1 -0
@@ -495,6 +495,7 @@ static void cqhci_set_tran_desc(u8 *desc, dma_addr_t addr, int len, bool end,
 		dataddr[0] = cpu_to_le32(addr);
 	}
 }
+EXPORT_SYMBOL(cqhci_set_tran_desc);

EXPORT_SYMBOL_GPL

Best regards,
Krzysztof

#3 lore raw

RE: [PATCH V4][1/4] mmc: solve DMA boundary limitation of CQHCI driver

Quoted 30 lines
Quoted 30 lines

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.

---
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 | 8 +++++++-
 drivers/mmc/host/cqhci.h      | 5 +++++
 2 files changed, 12 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/mmc/host/cqhci-core.c index b3d7d6d8d654..5560329d2a7d 100644

drivers/mmc/host/cqhci-core.c +0 -0
@@ -474,7 +474,7 @@ static int cqhci_dma_map(struct mmc_host *host, struct mmc_request *mrq)
      return sg_count;
 }
 
Quoted 13 lines
Quoted 11 lines
drivers/mmc/host/cqhci-core.c +2 -1
-static void cqhci_set_tran_desc(u8 *desc, dma_addr_t addr, int len, 
 bool end,
+void cqhci_set_tran_desc(u8 *desc, dma_addr_t addr, int len, bool 
+end,
                              bool dma64)  {
      __le32 *attr = (__le32 __force *)desc; @@ -495,6 +495,7 @@ 

static void cqhci_set_tran_desc(u8 *desc, dma_addr_t addr, int len, bool end,

              dataddr[0] = cpu_to_le32(addr);
      }

}
+EXPORT_SYMBOL(cqhci_set_tran_desc);

EXPORT_SYMBOL_GPL

We had corrected it.

Best regards,
Jyan

-----Original Message-----
From: Krzysztof Kozlowski <[email protected]>
Sent: Monday, October 30, 2023 3:35 PM
To: Jyan Chou [周芷安] <[email protected]>; [email protected]; [email protected]; [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]
Subject: Re: [PATCH V4][1/4] mmc: solve DMA boundary limitation of CQHCI driver

External mail.

Quoted 38 lines · Jyan Chou

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.

---
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 | 8 +++++++-
 drivers/mmc/host/cqhci.h      | 5 +++++
 2 files changed, 12 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/mmc/host/cqhci-core.c index b3d7d6d8d654..5560329d2a7d 100644

drivers/mmc/host/cqhci-core.c +2 -1
@@ -474,7 +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,
+void cqhci_set_tran_desc(u8 *desc, dma_addr_t addr, int len, bool 
+end,
                              bool dma64)  {
      __le32 *attr = (__le32 __force *)desc; @@ -495,6 +495,7 @@ 

static void cqhci_set_tran_desc(u8 *desc, dma_addr_t addr, int len, bool end,

Quoted 4 lines
              dataddr[0] = cpu_to_le32(addr);
      }

}
+EXPORT_SYMBOL(cqhci_set_tran_desc);

EXPORT_SYMBOL_GPL

Best regards,
Krzysztof

author
#4 lore raw

PATCH v4 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.

—--
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 | 1620 +++++++++++++++++++++++++++++++++
 drivers/mmc/host/dw_mmc_cqe.h |  449 +++++++++
 4 files changed, 2083 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 159a3e9490ae..894b89a396bb 100644
@@ -762,6 +762,19 @@ config MMC_DW_PLTFM
 
 	  If unsure, say Y.
 
+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_DW_BLUEFIELD
 	tristate "BlueField specific extensions for Synopsys DW Memory Card Interface"
 	depends on MMC_DW
drivers/mmc/host/Makefile +1 -0
index a693fa3d3f1c..23546b7b692e 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 +1620 -0

1,620 lines not on this page · raw message

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

449 lines not on this page · raw message

Signature · 1 line
2.42.0
#5 lore raw

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

Quoted 11 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 7 lines

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

I asked to fix several coding style issues so it will look a bit as matching Linux coding style. I don't see improvements.

Please read carefully, more than once, the Linux coding style. Then document in changelog what you fixed. If you document nothing, means you ignored the feedback.

Fix every warning from checkpatch --strict. Then document in changelog what you fixed. If you document nothing, means you ignored the feedback.

Quoted 12 lines
drivers/mmc/host/dw_mmc_cqe.c new file +12 -0
+
+	if (!host->bus_hz) {
+		dev_err(host->dev,
+			"Platform data must supply bus speed\n");
+		ret = -ENODEV;
+		goto err_clk_ciu;
+	}
+
+	if (!IS_ERR(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 1474

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe.c new file +10 -0
+	}
+
+	timer_setup(&host->timer, dw_mci_cqe_cto_timer, 0);
+
+	spin_lock_init(&host->lock);
+	spin_lock_init(&host->irq_lock);
+	init_rwsem(&host->cr_rw_sem);
+	tasklet_init(&host->tasklet, dw_mci_cqe_tasklet_func, (unsigned long)host);
+
+	/*pio mode's parameters should be initialized here*/

Nothing improved.

drivers/mmc/host/dw_mmc_cqe.c line 1481

Quoted 7 lines
drivers/mmc/host/dw_mmc_cqe.c new file +7 -0
+
+	/*Initialize the eMMC IP related attribute*/
+	dw_mci_cqe_setup(host);
+
+	dw_mci_cqe_init_dma(host);
+
+	/* This flag will be set 1 when doing tuning,

Nothing improved.

drivers/mmc/host/dw_mmc_cqe.c line 1489

Quoted 8 lines
drivers/mmc/host/dw_mmc_cqe.c new file +8 -0
+	 * we add this flag because
+	 * some vendors might use other cmd instead of 21
+	 * to tune phase under high speed interface.
+	 * we use this flag to recognize if the system is under tuning stage.
+	 */
+	host->tuning = 0;
+
+	/*Timing_setting is to avoid sending command

Nothing improved.

Quoted 16 lines
drivers/mmc/host/dw_mmc_cqe.c new file +16 -0
+	 *before setting phase in hs200, hs400
+	 */
+	host->current_speed = 0;
+
+	/*Do the rest of init for specific*/
+	if (drv_data && drv_data->init) {
+		ret = drv_data->init(host);
+		if (ret) {
+			dev_err(host->dev,
+				"implementation specific init failed\n");
+			goto err_dmaunmap;
+		}
+	}
+
+	ret = dw_mci_cqe_init_slot(host);
+	if (ret) {

drivers/mmc/host/dw_mmc_cqe.c line 1515

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe.c new file +10 -0
+		dev_err(host->dev, "slot 0 init failed\n");
+		goto err_dmaunmap;
+	}
+
+	ret = devm_request_irq(host->dev, host->irq, dw_mci_cqe_interrupt,
+			       host->irq_flags, "dw-mci-cqe", host);
+	if (ret)
+		goto err_dmaunmap;
+
+	/*After the slot initialization,

Nothing improved.

Quoted 12 lines
drivers/mmc/host/dw_mmc_cqe.c new file +12 -0
+	 *now we have mmc data and can initialize cmdq if user enabled
+	 */
+	dw_mci_cqhci_init(host);
+
+	return 0;
+
+err_dmaunmap:
+	if (!IS_ERR(host->pdata->rstc))
+		reset_control_assert(host->pdata->rstc);
+err_clk_ciu:
+	clk_disable_unprepare(host->ciu_clk);
+

drivers/mmc/host/dw_mmc_cqe.c line 1537

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe.c new file +10 -0
+err_clk_biu:
+	clk_disable_unprepare(host->biu_clk);
+
+	return ret;
+}
+EXPORT_SYMBOL(dw_mci_cqe_probe);
+
+void dw_mci_cqe_remove(struct dw_mci *host)
+{
+	dev_dbg(host->dev, "remove slot\n");

Nothing improved.

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe.c new file +10 -0
+	if (host->slot)
+		dw_mci_cqe_cleanup_slot(host->slot);
+
+	if (!IS_ERR(host->pdata->rstc))
+		reset_control_assert(host->pdata->rstc);
+
+	clk_disable_unprepare(host->ciu_clk);
+	clk_disable_unprepare(host->biu_clk);
+}
+EXPORT_SYMBOL(dw_mci_cqe_remove);

drivers/mmc/host/dw_mmc_cqe.c line 1557

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe.c new file +10 -0
+
+#ifdef CONFIG_PM
+int dw_mci_cqe_runtime_suspend(struct device *dev)
+{
+	struct dw_mci *host = dev_get_drvdata(dev);
+	int ret = 0;
+
+	if (host->pdata && (host->pdata->caps2 & MMC_CAP2_CQE)) {
+		if (host->slot) {
+			dev_info(host->dev, "cqe suspend\n");

Nothing improved.

drivers/mmc/host/dw_mmc_cqe.c line 1560

Quoted 3 lines
drivers/mmc/host/dw_mmc_cqe.c new file +3 -0
+			ret = cqhci_suspend(host->slot->mmc);
+			if (ret) {
+				dev_err(host->dev, "cqe suspend failed\n");

Nothing improved.

Quoted 24 lines
drivers/mmc/host/dw_mmc_cqe.c new file +24 -0
+				return ret;
+			}
+		}
+	}
+
+	clk_disable_unprepare(host->ciu_clk);
+
+	return ret;
+}
+EXPORT_SYMBOL(dw_mci_cqe_runtime_suspend);
+
+int dw_mci_cqe_runtime_resume(struct device *dev)
+{
+	struct dw_mci *host = dev_get_drvdata(dev);
+	const struct dw_mci_drv_data *drv_data = host->drv_data;
+	int ret = 0;
+
+	clk_prepare_enable(host->ciu_clk);
+
+	dw_mci_cqe_setup(host);
+	if (drv_data && drv_data->init) {
+		ret = drv_data->init(host);
+		if (ret)
+			dev_err(host->dev, "implementation specific init failed\n");

drivers/mmc/host/dw_mmc_cqe.c line 1594

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe.c new file +10 -0
+	}
+
+	init_completion(host->int_waiting);
+
+	if (host->pdata && (host->pdata->caps2 & MMC_CAP2_CQE)) {
+		if (host->slot) {
+			dev_info(host->dev, "cqe resume\n");
+			ret = cqhci_resume(host->slot->mmc);
+			if (ret)
+				dev_err(host->dev, "cqe resume failed\n");

Nothing improved.

drivers/mmc/host/dw_mmc_cqe.c line 1607

Quoted 13 lines
drivers/mmc/host/dw_mmc_cqe.c new file +13 -0
+		}
+	}
+
+	dw_mci_cqe_setup_bus(host->slot, true);
+
+	return ret;
+}
+EXPORT_SYMBOL(dw_mci_cqe_runtime_resume);
+#endif /* CONFIG_PM */
+
+static int __init dw_mci_cqe_init(void)
+{
+	pr_info("Synopsys Designware Multimedia Card Interface Driver\n");

Nothing improved.

drivers/mmc/host/dw_mmc_cqe.c line 1616

Quoted 9 lines
drivers/mmc/host/dw_mmc_cqe.c new file +9 -0
+	return 0;
+}
+
+static void __exit dw_mci_cqe_exit(void)
+{
+}
+
+module_init(dw_mci_cqe_init);
+module_exit(dw_mci_cqe_exit);

This part of code is just useless.

Best regards,
Krzysztof

#6 lore raw

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

Quoted 19 lines
Quoted 11 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 7 lines

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

Quoted 5 lines

I asked to fix several coding style issues so it will look a bit as matching Linux coding style. I don't see improvements.

Please read carefully, more than once, the Linux coding style. Then document in changelog what you fixed. If you document nothing, means you ignored the feedback.

Fix every warning from checkpatch --strict. Then document in changelog what you fixed. If you document nothing, means you ignored the feedback.

Thanks for your remind, we had fixed more coding style issues and checked with checkpatch --strict.

Quoted 17 lines
Quoted 17 lines
drivers/mmc/host/dw_mmc_cqe.c new file +17 -0
+
+     if (!host->bus_hz) {
+             dev_err(host->dev,
+                     "Platform data must supply bus speed\n");
+             ret = -ENODEV;
+             goto err_clk_ciu;
+     }
+
+     if (!IS_ERR(host->pdata->rstc)) {
+             reset_control_assert(host->pdata->rstc);
+             usleep_range(10, 50);
+             reset_control_deassert(host->pdata->rstc);
+     }
+
+     timer_setup(&host->timer, dw_mci_cqe_cto_timer, 0);
+
+     spin_lock_init(&host->lock);
Quoted 8 lines

drivers/mmc/host/dw_mmc_cqe.c line 1474

Quoted 6 lines
drivers/mmc/host/dw_mmc_cqe.c new file +6 -0
+     spin_lock_init(&host->irq_lock);
+     init_rwsem(&host->cr_rw_sem);
+     tasklet_init(&host->tasklet, dw_mci_cqe_tasklet_func, (unsigned 
+ long)host);
+
+     /*pio mode's parameters should be initialized here*/

Nothing improved.

We had fixed it.

Quoted 9 lines

drivers/mmc/host/dw_mmc_cqe.c line 1481

Quoted 7 lines
drivers/mmc/host/dw_mmc_cqe.c new file +7 -0
+
+     /*Initialize the eMMC IP related attribute*/
+     dw_mci_cqe_setup(host);
+
+     dw_mci_cqe_init_dma(host);
+
+     /* This flag will be set 1 when doing tuning,

Nothing improved.

We had fixed it.

Quoted 10 lines

drivers/mmc/host/dw_mmc_cqe.c line 1489

Quoted 8 lines
drivers/mmc/host/dw_mmc_cqe.c new file +8 -0
+      * we add this flag because
+      * some vendors might use other cmd instead of 21
+      * to tune phase under high speed interface.
+      * we use this flag to recognize if the system is under tuning stage.
+      */
+     host->tuning = 0;
+
+     /*Timing_setting is to avoid sending command

Nothing improved.

We had fixed it.

Quoted 20 lines
Quoted 20 lines
drivers/mmc/host/dw_mmc_cqe.c new file +20 -0
+      *before setting phase in hs200, hs400
+      */
+     host->current_speed = 0;
+
+     /*Do the rest of init for specific*/
+     if (drv_data && drv_data->init) {
+             ret = drv_data->init(host);
+             if (ret) {
+                     dev_err(host->dev,
+                             "implementation specific init failed\n");
+                     goto err_dmaunmap;
+             }
+     }
+
+     ret = dw_mci_cqe_init_slot(host);
+     if (ret) {
+             dev_err(host->dev, "slot 0 init failed\n");
+             goto err_dmaunmap;
+     }
+
Quoted 8 lines

drivers/mmc/host/dw_mmc_cqe.c line 1515

Quoted 6 lines
drivers/mmc/host/dw_mmc_cqe.c new file +6 -0
+     ret = devm_request_irq(host->dev, host->irq, dw_mci_cqe_interrupt,
+                            host->irq_flags, "dw-mci-cqe", host);
+     if (ret)
+             goto err_dmaunmap;
+
+     /*After the slot initialization,

Nothing improved.

We had fixed it.

Quoted 15 lines
Quoted 15 lines
drivers/mmc/host/dw_mmc_cqe.c new file +15 -0
+      *now we have mmc data and can initialize cmdq if user enabled
+      */
+     dw_mci_cqhci_init(host);
+
+     return 0;
+
+err_dmaunmap:
+     if (!IS_ERR(host->pdata->rstc))
+             reset_control_assert(host->pdata->rstc);
+err_clk_ciu:
+     clk_disable_unprepare(host->ciu_clk);
+
+err_clk_biu:
+     clk_disable_unprepare(host->biu_clk);
+
Quoted 8 lines

drivers/mmc/host/dw_mmc_cqe.c line 1537

Quoted 6 lines
drivers/mmc/host/dw_mmc_cqe.c new file +6 -0
+     return ret;
+}
+EXPORT_SYMBOL(dw_mci_cqe_probe);
+
+void dw_mci_cqe_remove(struct dw_mci *host) {
+     dev_dbg(host->dev, "remove slot\n");

Nothing improved.

We had fixed it.

Quoted 13 lines
Quoted 13 lines
drivers/mmc/host/dw_mmc_cqe.c new file +13 -0
+     if (host->slot)
+             dw_mci_cqe_cleanup_slot(host->slot);
+
+     if (!IS_ERR(host->pdata->rstc))
+             reset_control_assert(host->pdata->rstc);
+
+     clk_disable_unprepare(host->ciu_clk);
+     clk_disable_unprepare(host->biu_clk);
+}
+EXPORT_SYMBOL(dw_mci_cqe_remove);
+
+#ifdef CONFIG_PM
+int dw_mci_cqe_runtime_suspend(struct device *dev) {
Quoted 8 lines

drivers/mmc/host/dw_mmc_cqe.c line 1557

Quoted 6 lines
drivers/mmc/host/dw_mmc_cqe.c new file +6 -0
+     struct dw_mci *host = dev_get_drvdata(dev);
+     int ret = 0;
+
+     if (host->pdata && (host->pdata->caps2 & MMC_CAP2_CQE)) {
+             if (host->slot) {
+                     dev_info(host->dev, "cqe suspend\n");

Nothing improved.

We had dropped it.

Quoted 6 lines

drivers/mmc/host/dw_mmc_cqe.c

Quoted 4 lines
drivers/mmc/host/dw_mmc_cqe.c new file +4 -0
+                     ret = cqhci_suspend(host->slot->mmc);
+                     if (ret) {
+                             dev_err(host->dev, "cqe suspend 
+ failed\n");

Nothing improved.

We had dropped it.

Quoted 29 lines
Quoted 29 lines
drivers/mmc/host/dw_mmc_cqe.c new file +29 -0
+                             return ret;
+                     }
+             }
+     }
+
+     clk_disable_unprepare(host->ciu_clk);
+
+     return ret;
+}
+EXPORT_SYMBOL(dw_mci_cqe_runtime_suspend);
+
+int dw_mci_cqe_runtime_resume(struct device *dev) {
+     struct dw_mci *host = dev_get_drvdata(dev);
+     const struct dw_mci_drv_data *drv_data = host->drv_data;
+     int ret = 0;
+
+     clk_prepare_enable(host->ciu_clk);
+
+     dw_mci_cqe_setup(host);
+     if (drv_data && drv_data->init) {
+             ret = drv_data->init(host);
+             if (ret)
+                     dev_err(host->dev, "implementation specific init failed\n");
+     }
+
+     init_completion(host->int_waiting);
+
+     if (host->pdata && (host->pdata->caps2 & MMC_CAP2_CQE)) {
+             if (host->slot) {
Quoted 8 lines

drivers/mmc/host/dw_mmc_cqe.c

Quoted 5 lines
drivers/mmc/host/dw_mmc_cqe.c new file +5 -0
+                     dev_info(host->dev, "cqe resume\n");
+                     ret = cqhci_resume(host->slot->mmc);
+                     if (ret)
+                             dev_err(host->dev, "cqe resume 
+ failed\n");

Nothing improved.

We had fixed it.

Quoted 8 lines
Quoted 8 lines
drivers/mmc/host/dw_mmc_cqe.c new file +8 -0
+             }
+     }
+
+     dw_mci_cqe_setup_bus(host->slot, true);
+
+     return ret;
+}
+EXPORT_SYMBOL(dw_mci_cqe_runtime_resume);
Quoted 8 lines

Review

Quoted 5 lines
(quoted diff) +5 -0
+#endif /* CONFIG_PM */
+
+static int __init dw_mci_cqe_init(void) {
+     pr_info("Synopsys Designware Multimedia Card Interface 
+Driver\n");

Nothing improved.

We had dropped it.

Quoted 9 lines

drivers/mmc/host/dw_mmc_cqe.c line 1616

Quoted 7 lines
drivers/mmc/host/dw_mmc_cqe.c new file +7 -0
+     return 0;
+}
+
+static void __exit dw_mci_cqe_exit(void) { }
+
+module_init(dw_mci_cqe_init);
+module_exit(dw_mci_cqe_exit);

This part of code is just useless.

We had removed useless code.

Best regards,
Jyan

-----Original Message-----
From: Krzysztof Kozlowski <[email protected]>
Sent: Monday, October 30, 2023 3:39 PM
To: Jyan Chou [周芷安] <[email protected]>; [email protected]; [email protected]; [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]
Subject: Re: [PATCH V4][2/4] mmc: Add Synopsys DesignWare mmc cmdq host driver

External mail.

Quoted 11 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 7 lines

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

I asked to fix several coding style issues so it will look a bit as matching Linux coding style. I don't see improvements.

Please read carefully, more than once, the Linux coding style. Then document in changelog what you fixed. If you document nothing, means you ignored the feedback.

Fix every warning from checkpatch --strict. Then document in changelog what you fixed. If you document nothing, means you ignored the feedback.

Quoted 13 lines
drivers/mmc/host/dw_mmc_cqe.c new file +13 -0
+
+     if (!host->bus_hz) {
+             dev_err(host->dev,
+                     "Platform data must supply bus speed\n");
+             ret = -ENODEV;
+             goto err_clk_ciu;
+     }
+
+     if (!IS_ERR(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 1474

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe.c new file +10 -0
+
+     timer_setup(&host->timer, dw_mci_cqe_cto_timer, 0);
+
+     spin_lock_init(&host->lock);
+     spin_lock_init(&host->irq_lock);
+     init_rwsem(&host->cr_rw_sem);
+     tasklet_init(&host->tasklet, dw_mci_cqe_tasklet_func, (unsigned 
+ long)host);
+
+     /*pio mode's parameters should be initialized here*/

Nothing improved.

drivers/mmc/host/dw_mmc_cqe.c line 1481

Quoted 7 lines
drivers/mmc/host/dw_mmc_cqe.c new file +7 -0
+
+     /*Initialize the eMMC IP related attribute*/
+     dw_mci_cqe_setup(host);
+
+     dw_mci_cqe_init_dma(host);
+
+     /* This flag will be set 1 when doing tuning,

Nothing improved.

drivers/mmc/host/dw_mmc_cqe.c line 1489

Quoted 8 lines
drivers/mmc/host/dw_mmc_cqe.c new file +8 -0
+      * we add this flag because
+      * some vendors might use other cmd instead of 21
+      * to tune phase under high speed interface.
+      * we use this flag to recognize if the system is under tuning stage.
+      */
+     host->tuning = 0;
+
+     /*Timing_setting is to avoid sending command

Nothing improved.

Quoted 16 lines
drivers/mmc/host/dw_mmc_cqe.c new file +16 -0
+      *before setting phase in hs200, hs400
+      */
+     host->current_speed = 0;
+
+     /*Do the rest of init for specific*/
+     if (drv_data && drv_data->init) {
+             ret = drv_data->init(host);
+             if (ret) {
+                     dev_err(host->dev,
+                             "implementation specific init failed\n");
+                     goto err_dmaunmap;
+             }
+     }
+
+     ret = dw_mci_cqe_init_slot(host);
+     if (ret) {

drivers/mmc/host/dw_mmc_cqe.c line 1515

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe.c new file +10 -0
+             dev_err(host->dev, "slot 0 init failed\n");
+             goto err_dmaunmap;
+     }
+
+     ret = devm_request_irq(host->dev, host->irq, dw_mci_cqe_interrupt,
+                            host->irq_flags, "dw-mci-cqe", host);
+     if (ret)
+             goto err_dmaunmap;
+
+     /*After the slot initialization,

Nothing improved.

Quoted 11 lines
drivers/mmc/host/dw_mmc_cqe.c new file +11 -0
+      *now we have mmc data and can initialize cmdq if user enabled
+      */
+     dw_mci_cqhci_init(host);
+
+     return 0;
+
+err_dmaunmap:
+     if (!IS_ERR(host->pdata->rstc))
+             reset_control_assert(host->pdata->rstc);
+err_clk_ciu:
+     clk_disable_unprepare(host->ciu_clk);

drivers/mmc/host/dw_mmc_cqe.c line 1537

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe.c new file +10 -0
+
+err_clk_biu:
+     clk_disable_unprepare(host->biu_clk);
+
+     return ret;
+}
+EXPORT_SYMBOL(dw_mci_cqe_probe);
+
+void dw_mci_cqe_remove(struct dw_mci *host) {
+     dev_dbg(host->dev, "remove slot\n");

Nothing improved.

Quoted 9 lines
drivers/mmc/host/dw_mmc_cqe.c new file +9 -0
+     if (host->slot)
+             dw_mci_cqe_cleanup_slot(host->slot);
+
+     if (!IS_ERR(host->pdata->rstc))
+             reset_control_assert(host->pdata->rstc);
+
+     clk_disable_unprepare(host->ciu_clk);
+     clk_disable_unprepare(host->biu_clk);
+}

drivers/mmc/host/dw_mmc_cqe.c line 1557

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe.c new file +10 -0
+EXPORT_SYMBOL(dw_mci_cqe_remove);
+
+#ifdef CONFIG_PM
+int dw_mci_cqe_runtime_suspend(struct device *dev) {
+     struct dw_mci *host = dev_get_drvdata(dev);
+     int ret = 0;
+
+     if (host->pdata && (host->pdata->caps2 & MMC_CAP2_CQE)) {
+             if (host->slot) {
+                     dev_info(host->dev, "cqe suspend\n");

Nothing improved.

drivers/mmc/host/dw_mmc_cqe.c

Quoted 4 lines
drivers/mmc/host/dw_mmc_cqe.c new file +4 -0
+                     ret = cqhci_suspend(host->slot->mmc);
+                     if (ret) {
+                             dev_err(host->dev, "cqe suspend 
+ failed\n");

Nothing improved.

Quoted 24 lines
drivers/mmc/host/dw_mmc_cqe.c new file +24 -0
+                             return ret;
+                     }
+             }
+     }
+
+     clk_disable_unprepare(host->ciu_clk);
+
+     return ret;
+}
+EXPORT_SYMBOL(dw_mci_cqe_runtime_suspend);
+
+int dw_mci_cqe_runtime_resume(struct device *dev) {
+     struct dw_mci *host = dev_get_drvdata(dev);
+     const struct dw_mci_drv_data *drv_data = host->drv_data;
+     int ret = 0;
+
+     clk_prepare_enable(host->ciu_clk);
+
+     dw_mci_cqe_setup(host);
+     if (drv_data && drv_data->init) {
+             ret = drv_data->init(host);
+             if (ret)
+                     dev_err(host->dev, "implementation specific init failed\n");
+     }

drivers/mmc/host/dw_mmc_cqe.c

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe.c new file +10 -0
+
+     init_completion(host->int_waiting);
+
+     if (host->pdata && (host->pdata->caps2 & MMC_CAP2_CQE)) {
+             if (host->slot) {
+                     dev_info(host->dev, "cqe resume\n");
+                     ret = cqhci_resume(host->slot->mmc);
+                     if (ret)
+                             dev_err(host->dev, "cqe resume 
+ failed\n");

Nothing improved.

drivers/mmc/host/dw_mmc_cqe.c

Quoted 13 lines
drivers/mmc/host/dw_mmc_cqe.c new file +13 -0
+             }
+     }
+
+     dw_mci_cqe_setup_bus(host->slot, true);
+
+     return ret;
+}
+EXPORT_SYMBOL(dw_mci_cqe_runtime_resume);
+#endif /* CONFIG_PM */
+
+static int __init dw_mci_cqe_init(void) {
+     pr_info("Synopsys Designware Multimedia Card Interface 
+Driver\n");

Nothing improved.

drivers/mmc/host/dw_mmc_cqe.c line 1616

Quoted 7 lines
drivers/mmc/host/dw_mmc_cqe.c new file +7 -0
+     return 0;
+}
+
+static void __exit dw_mci_cqe_exit(void) { }
+
+module_init(dw_mci_cqe_init);
+module_exit(dw_mci_cqe_exit);

This part of code is just useless.

Best regards,
Krzysztof

#7 lore raw

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

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

Hi Jyan,

kernel test robot noticed the following build errors:

[auto build test ERROR on linus/master]
[also build test ERROR on ulf-hansson-mmc-mirror/next v6.6 next-20231031] [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/20231030-144300
base:   linus/master
patch link:    https://lore.kernel.org/r/20231030062749.2840-3-jyanchou%40realtek.com
patch subject: [PATCH V4][2/4] mmc: Add Synopsys DesignWare mmc cmdq host driver
config: sparc64-allyesconfig (https://download.01.org/0day-ci/archive/20231101/[email protected]/config)
compiler: sparc64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231101/[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 errors (new ones prefixed by >>):

>> drivers/mmc/host/dw_mmc_cqe.c:227:10: error: 'const struct cqhci_host_ops' has no member named 'setup_tran_desc'
     227 |         .setup_tran_desc = dw_mci_cqe_setup_tran_desc,
         |          ^~~~~~~~~~~~~~~
>> drivers/mmc/host/dw_mmc_cqe.c:227:28: error: initialization of 'int (*)(struct cqhci_host *, const union cqhci_crypto_cfg_entry *, int)' from incompatible pointer type 'void (*)(struct mmc_data *, struct cqhci_host *, u8 *, int)' {aka 'void (*)(struct mmc_data *, struct cqhci_host *, unsigned char *, int)'} [-Werror=incompatible-pointer-types]
     227 |         .setup_tran_desc = dw_mci_cqe_setup_tran_desc,
         |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/mmc/host/dw_mmc_cqe.c:227:28: note: (near initialization for 'dw_mci_cqhci_host_ops.program_key')
   In file included from include/linux/debugfs.h:16,
                    from drivers/mmc/host/dw_mmc_cqe.c:12:
   drivers/mmc/host/dw_mmc_cqe.c:96:23: warning: 'dw_mci_cqe_req_fops' defined but not used [-Wunused-const-variable=]
      96 | DEFINE_SHOW_ATTRIBUTE(dw_mci_cqe_req);
         |                       ^~~~~~~~~~~~~~
   include/linux/seq_file.h:202:37: note: in definition of macro 'DEFINE_SHOW_ATTRIBUTE'
     202 | static const struct file_operations __name ## _fops = {                 \
         |                                     ^~~~~~

cc1: some warnings being treated as errors

vim +227 drivers/mmc/host/dw_mmc_cqe.c

221
222 static const struct cqhci_host_ops dw_mci_cqhci_host_ops = {
223 .enable = dw_mci_cqe_enable,
224 .dumpregs = dw_mci_cqe_dumpregs,
225 .pre_enable = dw_mci_cqe_pre_enable,
226 .post_disable = dw_mci_cqe_post_disable,

 > 227		.setup_tran_desc = dw_mci_cqe_setup_tran_desc,

228 };
229

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

PATCH v4 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.

---
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 | 979 ++++++++++++++++++++++++++++++
 drivers/mmc/host/dw_mmc_cqe-rtk.h | 160 +++++
 4 files changed, 1149 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 894b89a396bb..23544b226b8e 100644
@@ -775,6 +775,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_DW_BLUEFIELD
 	tristate "BlueField specific extensions for Synopsys DW Memory Card Interface"
 	depends on MMC_DW
drivers/mmc/host/Makefile +1 -0
index 23546b7b692e..fe4676202b95 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 +979 -0

979 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
#9 lore raw

Re: [PATCH V4][3/4] mmc: Add dw mobile mmc cmdq rtk driver

Quoted 8 lines · Jyan Chou

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

---
v3 -> v4:
- Modify dma setting's code to fix linux coding style.

And coding style of all other parts were ignored. You must fix it everywhere in your code.

...

Quoted 9 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +9 -0
+
+static void dw_mci_rtk_init_card(struct mmc_host *host, struct mmc_card *card)
+{
+	/* In Realtek Platform, we need to attach eMMC card onto mmc host
+	 * during eMMC initialization because of the following reason:
+	 * When system cannot run the hs400, we need to down speed to hs200
+	 * and call mmc_hw_reset and modify the mmc card attribute through mmc host.
+	 * At this moment, system will show errors if host->card = NULL.
+	 */

drivers/mmc/host/dw_mmc_cqe-rtk.c line 692

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +10 -0
+	host->card = card;
+}
+
+static int dw_mci_rtk_parse_dt(struct dw_mci *host)
+{
+	struct dw_mci_rtkemmc_host *priv;
+	const u32 *prop;
+	int size;
+
+	priv = devm_kzalloc(host->dev, sizeof(struct dw_mci_rtkemmc_host), GFP_KERNEL);

sizeof(*)

drivers/mmc/host/dw_mmc_cqe-rtk.c line 704

Quoted 12 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +12 -0
+	if (!priv)
+		return -ENOMEM;
+
+	priv->pinctrl = devm_pinctrl_get(host->dev);
+	if (IS_ERR(priv->pinctrl))
+		dev_dbg(host->dev, "no pinctrl\n");
+
+	priv->pins_default = pinctrl_lookup_state(priv->pinctrl,
+						  PINCTRL_STATE_DEFAULT);
+	if (IS_ERR(priv->pins_default))
+		dev_warn(host->dev, "could not get default state\n");
+

So this is required by the driver but not by the bindings.

Quoted 38 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +38 -0
+	priv->pins_sdr50 = pinctrl_lookup_state(priv->pinctrl,
+						"sdr50");
+	if (IS_ERR(priv->pins_sdr50))
+		dev_warn(host->dev, "could not get sdr50 state\n");
+
+	priv->pins_hs200 = pinctrl_lookup_state(priv->pinctrl,
+						"hs200");
+	if (IS_ERR(priv->pins_hs200))
+		dev_warn(host->dev, "could not get hs200 state\n");
+
+	priv->pins_hs400 = pinctrl_lookup_state(priv->pinctrl,
+						"hs400");
+	if (IS_ERR(priv->pins_hs400))
+		dev_warn(host->dev, "could not get hs400 state\n");
+
+	priv->pins_tune0 = pinctrl_lookup_state(priv->pinctrl,
+						"tune0");
+	if (IS_ERR(priv->pins_tune0))
+		dev_warn(host->dev, "could not get tune0 state\n");
+
+	priv->pins_tune1 = pinctrl_lookup_state(priv->pinctrl,
+						"tune1");
+	if (IS_ERR(priv->pins_tune1))
+		dev_warn(host->dev, "could not get tune1 state\n");
+
+	priv->pins_tune2 = pinctrl_lookup_state(priv->pinctrl,
+						"tune2");
+	if (IS_ERR(priv->pins_tune2))
+		dev_warn(host->dev, "could not get tune2 state\n");
+
+	priv->pins_tune3 = pinctrl_lookup_state(priv->pinctrl,
+						"tune3");
+	if (IS_ERR(priv->pins_tune3))
+		dev_warn(host->dev, "could not get tune3 state\n");
+
+	priv->pins_tune4 = pinctrl_lookup_state(priv->pinctrl,
+						"tune4");
+

drivers/mmc/host/dw_mmc_cqe-rtk.c line 752

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +10 -0
+	if (IS_ERR(priv->pins_tune4))
+		dev_warn(host->dev, "could not get tune4 state\n");
+
+	priv->vp0 = devm_clk_get(host->dev, "vp0");
+	if (IS_ERR(priv->vp0))
+		dev_err(host->dev, "could not get vp0 clk\n");
+
+	priv->vp1 = devm_clk_get(host->dev, "vp1");
+	if (IS_ERR(priv->vp1))
+		dev_err(host->dev, "could not get vp1 clk\n");

dev_err_probe. Everywhere where applicable.

drivers/mmc/host/dw_mmc_cqe-rtk.c line 758

Quoted 6 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +6 -0
+
+	priv->emmc_mode = 0;
+	prop = of_get_property(host->dev->of_node, "speed-step", &size);
+	if (prop) {
+		priv->emmc_mode = of_read_number(prop, 1);
+		dev_info(host->dev, "emmc mode : %d\n", priv->emmc_mode);

Drop

drivers/mmc/host/dw_mmc_cqe-rtk.c line 760

Quoted 2 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +2 -0
+	} else {
+		dev_info(host->dev, "use default emmc sdr50 mode !\n");

Drop, why is this a problem?

drivers/mmc/host/dw_mmc_cqe-rtk.c line 767

Quoted 7 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +7 -0
+	}
+
+	priv->is_cqe = 0;
+	prop = of_get_property(host->dev->of_node, "cqe", &size);
+	if (prop) {
+		priv->is_cqe = of_read_number(prop, 1);
+		dev_info(host->dev, "cmdq mode : %d\n", priv->is_cqe);

Drop

Review

Quoted 2 lines
(quoted diff) +2 -0
+	} else {
+		dev_info(host->dev, "use default eMMC legacy mode !\n");

Drop

drivers/mmc/host/dw_mmc_cqe-rtk.c line 775

Quoted 6 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +6 -0
+	}
+
+	prop = of_get_property(host->dev->of_node, "rdq-ctrl", &size);
+	if (prop) {
+		priv->rdq_ctrl = of_read_number(prop, 1);
+		dev_info(host->dev, "get rdq-ctrl : %u\n", priv->rdq_ctrl);

Drop

drivers/mmc/host/dw_mmc_cqe-rtk.c line 778

Quoted 3 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +3 -0
+	} else {
+		priv->rdq_ctrl = 0;
+		dev_info(host->dev, "no dqs_dly_tape switch node, use default 0x0 !!\n");

Drop

Quoted 22 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +22 -0
+	}
+
+	priv->m2tmx = syscon_regmap_lookup_by_phandle(host->dev->of_node, "realtek,m2tmx");
+	if (IS_ERR_OR_NULL(priv->m2tmx))
+		dev_err(host->dev, "can not get m2mtx node.\n");
+
+	host->priv = priv;
+
+	return 0;
+}
+
+static int dw_mci_rtk_init(struct dw_mci *host)
+{
+	struct dw_mci_rtkemmc_host *priv = host->priv;
+
+	host->pdata->caps2 = MMC_CAP2_NO_SDIO | MMC_CAP2_NO_SD;
+
+	if (priv->emmc_mode >= 2)
+		host->pdata->caps2 |= MMC_CAP2_HS200_1_8V_SDR;
+	if (priv->emmc_mode >= 3) {
+		host->pdata->caps |= MMC_CAP_1_8V_DDR;
+		host->pdata->caps2 |= MMC_CAP2_HS400_1_8V;

drivers/mmc/host/dw_mmc_cqe-rtk.c line 810

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +10 -0
+	}
+
+	if (priv->is_cqe > 0)
+		host->pdata->caps2 |= (MMC_CAP2_CQE | MMC_CAP2_CQE_DCMD);
+
+	host->irq_flags = IRQF_SHARED;
+
+	mcq_writel(host, CP, 0x0);
+
+	/*Enable L4 gated*/

Read Linux coding style. Multiple times if needed.

Quoted 38 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +38 -0
+	mcq_writel(host, OTHER1, mcq_readl(host, OTHER1) &
+		~(SDMMC_L4_GATED_DIS | SDMMC_L4_GATED_DIS1));
+
+	mcq_writel(host, OTHER1, mcq_readl(host, OTHER1) &
+		   (~(SDMMC_DQS_CTRL_GATE_DIS | SDMMC_DBUS_MAS_GATING_DIS)));
+
+	/*Set the eMMC wrapper little Endian*/
+	mcq_writel(host, AHB, mcq_readl(host, AHB) | SDMMC_AHB_BIG);
+
+	mcq_writel(host, OTHER1,
+		   mcq_readl(host, OTHER1) | SDMMC_STARK_CARD_STOP_ENABLE);
+
+	/*set eMMC instead of nand*/
+	regmap_update_bits_base(priv->m2tmx, SDMMC_NAND_DMA_SEL,
+				SDMMC_SRAM_DMA_SEL, SDMMC_SRAM_DMA_SEL, NULL, false, true);
+
+	/*Set the clk initial phase*/
+	dw_mci_rtk_phase_tuning(host, 0, 0);
+
+	return 0;
+}
+
+#ifdef CONFIG_PM
+static int dw_mci_rtk_suspend(struct device *dev)
+{
+	struct dw_mci *host = dev_get_drvdata(dev);
+	int ret = 0;
+
+	ret = dw_mci_cqe_runtime_suspend(dev);
+	mcq_writel(host, AHB, 0);
+
+	return ret;
+}
+
+static int dw_mci_rtk_resume(struct device *dev)
+{
+	struct dw_mci *host = dev_get_drvdata(dev);
+	int ret = 0;

drivers/mmc/host/dw_mmc_cqe-rtk.c line 858

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +10 -0
+
+	mcq_writel(host, AHB, mcq_readl(host, AHB) | SDMMC_AHB_BIG);
+	ret = dw_mci_cqe_runtime_resume(dev);
+
+	return ret;
+}
+#else
+static int dw_mci_rtk_suspend(struct device *dev)
+{
+	dev_info(dev, "User should enable CONFIG_PM kernel config\n");

NAK, come on. I asked to drop it. Did you just ignore the feedback? Yep...

drivers/mmc/host/dw_mmc_cqe-rtk.c line 858

Quoted 7 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +7 -0
+
+	return 0;
+}
+
+static int dw_mci_rtk_resume(struct device *dev)
+{
+	dev_info(dev, "User should enable CONFIG_PM kernel config\n");

NAK

Quoted 5 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +5 -0
+
+	return 0;
+}
+#endif /*CONFIG_PM*/
+static const struct dev_pm_ops rtk_dev_pm_ops = {

drivers/mmc/host/dw_mmc_cqe-rtk.c line 880

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +10 -0
+	SET_SYSTEM_SLEEP_PM_OPS(dw_mci_rtk_suspend,
+				dw_mci_rtk_resume)
+	SET_RUNTIME_PM_OPS(dw_mci_cqe_runtime_suspend,
+			   dw_mci_cqe_runtime_resume,
+			   NULL)
+};
+
+static void dw_mci_rtk_shutdown(struct platform_device *pdev)
+{
+	dev_info(&pdev->dev, "[eMMC] Shutdown\n");

NAK

Quoted 25 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +25 -0
+	dw_mci_cqe_runtime_resume(&pdev->dev);
+}
+
+static unsigned long dw_mci_rtk_dwmmc_caps[1] = {
+	MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA |
+	MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED |
+	MMC_CAP_NONREMOVABLE | MMC_CAP_CMD23,
+};
+
+static const struct dw_mci_drv_data rtk_drv_data = {
+	.caps                   = dw_mci_rtk_dwmmc_caps,
+	.num_caps               = ARRAY_SIZE(dw_mci_rtk_dwmmc_caps),
+	.set_ios                = dw_mci_rtk_set_ios,
+	.execute_tuning         = dw_mci_rtk_execute_tuning,
+	.parse_dt               = dw_mci_rtk_parse_dt,
+	.init                   = dw_mci_rtk_init,
+	.prepare_hs400_tuning	= dw_mci_rtk_prepare_hs400_tuning,
+	.hs400_complete         = dw_mci_rtk_hs400_complete,
+	.init_card		= dw_mci_rtk_init_card,
+};
+
+static const struct of_device_id dw_mci_rtk_match[] = {
+	{ .compatible = "realtek,rtd1325-dw-cqe-emmc",
+		.data = &rtk_drv_data },
+	{},

drivers/mmc/host/dw_mmc_cqe-rtk.c line 915

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +10 -0
+};
+MODULE_DEVICE_TABLE(of, dw_mci_rtk_match);
+
+int dw_mci_cqe_pltfm_register(struct platform_device *pdev,
+			      const struct dw_mci_drv_data *drv_data)
+{
+	struct dw_mci *host;
+	struct resource	*regs;
+
+	host = devm_kzalloc(&pdev->dev, sizeof(struct dw_mci), GFP_KERNEL);

sizeof(*)

Quoted 5 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +5 -0
+	if (!host)
+		return -ENOMEM;
+
+	host->irq = platform_get_irq(pdev, 0);
+	if (host->irq < 0)

drivers/mmc/host/dw_mmc_cqe-rtk.c line 930

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +10 -0
+		return host->irq;
+
+	host->drv_data = drv_data;
+	host->pdev = pdev;
+	host->dev = &pdev->dev;
+	host->irq_flags = 0;
+	host->pdata = pdev->dev.platform_data;
+
+	regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	host->regs = devm_ioremap_resource(&pdev->dev, regs);

Use helper for this.

Open existing, recent drivers and use the them as template or some set of patterns. Sorry, but upstreaming your vendor code will be painful, because you started from some old, buggier version.

Quoted 21 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +21 -0
+	if (IS_ERR(host->regs))
+		return PTR_ERR(host->regs);
+
+	/* Get registers' physical base address */
+	host->phy_regs = regs->start;
+
+	platform_set_drvdata(pdev, host);
+
+	return dw_mci_cqe_probe(host);
+}
+
+static int dw_mci_rtk_probe(struct platform_device *pdev)
+{
+	const struct dw_mci_drv_data *drv_data;
+	const struct of_device_id *match;
+
+	if (!pdev->dev.of_node)
+		return -ENODEV;
+
+	match = of_match_node(dw_mci_rtk_match, pdev->dev.of_node);
+	drv_data = match->data;

drivers/mmc/host/dw_mmc_cqe-rtk.c line 961

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +10 -0
+
+	return dw_mci_cqe_pltfm_register(pdev, drv_data);
+}
+
+int dw_mci_rtk_remove(struct platform_device *pdev)
+{
+	struct dw_mci *host = platform_get_drvdata(pdev);
+
+	dw_mci_cqe_remove(host);
+	return 0;

Best regards,
Krzysztof

#10 lore raw

RE: [PATCH V4][3/4] mmc: Add dw mobile mmc cmdq rtk driver

Hi Krzysztof,

Thanks for you to review our code and give some advices. We will check carefully and fix coding style of all, also, we will drop useless function and message in our next push.
Since some advice we were not sure, we would like to discuss first and modified correctly in our next version.

Quoted 4 lines
Quoted 2 lines

+ priv = devm_kzalloc(host->dev, sizeof(struct
+ dw_mci_rtkemmc_host), GFP_KERNEL);

sizeof(*)

Thanks. I will correct it in our next version.

Quoted 7 lines

drivers/mmc/host/dw_mmc_cqe-rtk.c line 704

Quoted 5 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +5 -0
+     priv->pins_default = pinctrl_lookup_state(priv->pinctrl,
+                                               PINCTRL_STATE_DEFAULT);
+     if (IS_ERR(priv->pins_default))
+             dev_warn(host->dev, "could not get default state\n");
+

So this is required by the driver but not by the bindings.

Since our pinctrl driver supports different driver's usage, we may use bindings to get the correct pinctrl setting, so we add different pinctrl-names in our bindings. It is correct, or am I misunderstand what you say?

Quoted 1 line

dev_err_probe. Everywhere where applicable.

Thanks. I will correct it in our next version.

Quoted 1 line

Read Linux coding style. Multiple times if needed.

Thanks. I will correct it in our next version.

Quoted 10 lines

drivers/mmc/host/dw_mmc_cqe-rtk.c line 930

Quoted 6 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +6 -0
+     host->dev = &pdev->dev;
+     host->irq_flags = 0;
+     host->pdata = pdev->dev.platform_data;
+
+     regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+     host->regs = devm_ioremap_resource(&pdev->dev, regs);

Use helper for this.

Open existing, recent drivers and use the them as template or some set of patterns. Sorry, but upstreaming your vendor code will be painful, because you started from some old, buggier version.

Sorry for asking, but I would like to know what is the meaning of "Use helper for this." ? Does it mean we need to get rid of our code above or something else? Thanks a lot.

Best regards,
Jyan

-----Original Message-----
From: Krzysztof Kozlowski <[email protected]>
Sent: Monday, October 30, 2023 3:44 PM
To: Jyan Chou [周芷安] <[email protected]>; [email protected]; [email protected]; [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]
Subject: Re: [PATCH V4][3/4] mmc: Add dw mobile mmc cmdq rtk driver

External mail.

Quoted 8 lines · Jyan Chou

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

---
v3 -> v4:
- Modify dma setting's code to fix linux coding style.

And coding style of all other parts were ignored. You must fix it everywhere in your code.

...

Quoted 9 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +9 -0
+
+static void dw_mci_rtk_init_card(struct mmc_host *host, struct 
+mmc_card *card) {
+     /* In Realtek Platform, we need to attach eMMC card onto mmc host
+      * during eMMC initialization because of the following reason:
+      * When system cannot run the hs400, we need to down speed to hs200
+      * and call mmc_hw_reset and modify the mmc card attribute through mmc host.
+      * At this moment, system will show errors if host->card = NULL.
+      */

drivers/mmc/host/dw_mmc_cqe-rtk.c

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +10 -0
+     host->card = card;
+}
+
+static int dw_mci_rtk_parse_dt(struct dw_mci *host) {
+     struct dw_mci_rtkemmc_host *priv;
+     const u32 *prop;
+     int size;
+
+     priv = devm_kzalloc(host->dev, sizeof(struct 
+ dw_mci_rtkemmc_host), GFP_KERNEL);

sizeof(*)

drivers/mmc/host/dw_mmc_cqe-rtk.c line 704

Quoted 12 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +12 -0
+     if (!priv)
+             return -ENOMEM;
+
+     priv->pinctrl = devm_pinctrl_get(host->dev);
+     if (IS_ERR(priv->pinctrl))
+             dev_dbg(host->dev, "no pinctrl\n");
+
+     priv->pins_default = pinctrl_lookup_state(priv->pinctrl,
+                                               PINCTRL_STATE_DEFAULT);
+     if (IS_ERR(priv->pins_default))
+             dev_warn(host->dev, "could not get default state\n");
+

So this is required by the driver but not by the bindings.

Quoted 38 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +38 -0
+     priv->pins_sdr50 = pinctrl_lookup_state(priv->pinctrl,
+                                             "sdr50");
+     if (IS_ERR(priv->pins_sdr50))
+             dev_warn(host->dev, "could not get sdr50 state\n");
+
+     priv->pins_hs200 = pinctrl_lookup_state(priv->pinctrl,
+                                             "hs200");
+     if (IS_ERR(priv->pins_hs200))
+             dev_warn(host->dev, "could not get hs200 state\n");
+
+     priv->pins_hs400 = pinctrl_lookup_state(priv->pinctrl,
+                                             "hs400");
+     if (IS_ERR(priv->pins_hs400))
+             dev_warn(host->dev, "could not get hs400 state\n");
+
+     priv->pins_tune0 = pinctrl_lookup_state(priv->pinctrl,
+                                             "tune0");
+     if (IS_ERR(priv->pins_tune0))
+             dev_warn(host->dev, "could not get tune0 state\n");
+
+     priv->pins_tune1 = pinctrl_lookup_state(priv->pinctrl,
+                                             "tune1");
+     if (IS_ERR(priv->pins_tune1))
+             dev_warn(host->dev, "could not get tune1 state\n");
+
+     priv->pins_tune2 = pinctrl_lookup_state(priv->pinctrl,
+                                             "tune2");
+     if (IS_ERR(priv->pins_tune2))
+             dev_warn(host->dev, "could not get tune2 state\n");
+
+     priv->pins_tune3 = pinctrl_lookup_state(priv->pinctrl,
+                                             "tune3");
+     if (IS_ERR(priv->pins_tune3))
+             dev_warn(host->dev, "could not get tune3 state\n");
+
+     priv->pins_tune4 = pinctrl_lookup_state(priv->pinctrl,
+                                             "tune4");
+

drivers/mmc/host/dw_mmc_cqe-rtk.c line 752

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +10 -0
+     if (IS_ERR(priv->pins_tune4))
+             dev_warn(host->dev, "could not get tune4 state\n");
+
+     priv->vp0 = devm_clk_get(host->dev, "vp0");
+     if (IS_ERR(priv->vp0))
+             dev_err(host->dev, "could not get vp0 clk\n");
+
+     priv->vp1 = devm_clk_get(host->dev, "vp1");
+     if (IS_ERR(priv->vp1))
+             dev_err(host->dev, "could not get vp1 clk\n");

dev_err_probe. Everywhere where applicable.

drivers/mmc/host/dw_mmc_cqe-rtk.c

Quoted 7 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +7 -0
+
+     priv->emmc_mode = 0;
+     prop = of_get_property(host->dev->of_node, "speed-step", &size);
+     if (prop) {
+             priv->emmc_mode = of_read_number(prop, 1);
+             dev_info(host->dev, "emmc mode : %d\n", 
+ priv->emmc_mode);

Drop

drivers/mmc/host/dw_mmc_cqe-rtk.c line 760

Quoted 2 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +2 -0
+     } else {
+             dev_info(host->dev, "use default emmc sdr50 mode !\n");

Drop, why is this a problem?

drivers/mmc/host/dw_mmc_cqe-rtk.c line 767

Quoted 7 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +7 -0
+     }
+
+     priv->is_cqe = 0;
+     prop = of_get_property(host->dev->of_node, "cqe", &size);
+     if (prop) {
+             priv->is_cqe = of_read_number(prop, 1);
+             dev_info(host->dev, "cmdq mode : %d\n", priv->is_cqe);

Drop

Review

Quoted 2 lines
(quoted diff) +2 -0
+     } else {
+             dev_info(host->dev, "use default eMMC legacy mode !\n");

Drop

drivers/mmc/host/dw_mmc_cqe-rtk.c

Quoted 7 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +7 -0
+     }
+
+     prop = of_get_property(host->dev->of_node, "rdq-ctrl", &size);
+     if (prop) {
+             priv->rdq_ctrl = of_read_number(prop, 1);
+             dev_info(host->dev, "get rdq-ctrl : %u\n", 
+ priv->rdq_ctrl);

Drop

drivers/mmc/host/dw_mmc_cqe-rtk.c

Quoted 4 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +4 -0
+     } else {
+             priv->rdq_ctrl = 0;
+             dev_info(host->dev, "no dqs_dly_tape switch node, use 
+ default 0x0 !!\n");

Drop

Quoted 22 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +22 -0
+     }
+
+     priv->m2tmx = syscon_regmap_lookup_by_phandle(host->dev->of_node, "realtek,m2tmx");
+     if (IS_ERR_OR_NULL(priv->m2tmx))
+             dev_err(host->dev, "can not get m2mtx node.\n");
+
+     host->priv = priv;
+
+     return 0;
+}
+
+static int dw_mci_rtk_init(struct dw_mci *host) {
+     struct dw_mci_rtkemmc_host *priv = host->priv;
+
+     host->pdata->caps2 = MMC_CAP2_NO_SDIO | MMC_CAP2_NO_SD;
+
+     if (priv->emmc_mode >= 2)
+             host->pdata->caps2 |= MMC_CAP2_HS200_1_8V_SDR;
+     if (priv->emmc_mode >= 3) {
+             host->pdata->caps |= MMC_CAP_1_8V_DDR;
+             host->pdata->caps2 |= MMC_CAP2_HS400_1_8V;
+     }

drivers/mmc/host/dw_mmc_cqe-rtk.c line 810

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +10 -0
+
+     if (priv->is_cqe > 0)
+             host->pdata->caps2 |= (MMC_CAP2_CQE | 
+ MMC_CAP2_CQE_DCMD);
+
+     host->irq_flags = IRQF_SHARED;
+
+     mcq_writel(host, CP, 0x0);
+
+     /*Enable L4 gated*/

Read Linux coding style. Multiple times if needed.

Quoted 38 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +38 -0
+     mcq_writel(host, OTHER1, mcq_readl(host, OTHER1) &
+             ~(SDMMC_L4_GATED_DIS | SDMMC_L4_GATED_DIS1));
+
+     mcq_writel(host, OTHER1, mcq_readl(host, OTHER1) &
+                (~(SDMMC_DQS_CTRL_GATE_DIS | 
+ SDMMC_DBUS_MAS_GATING_DIS)));
+
+     /*Set the eMMC wrapper little Endian*/
+     mcq_writel(host, AHB, mcq_readl(host, AHB) | SDMMC_AHB_BIG);
+
+     mcq_writel(host, OTHER1,
+                mcq_readl(host, OTHER1) | 
+ SDMMC_STARK_CARD_STOP_ENABLE);
+
+     /*set eMMC instead of nand*/
+     regmap_update_bits_base(priv->m2tmx, SDMMC_NAND_DMA_SEL,
+                             SDMMC_SRAM_DMA_SEL, SDMMC_SRAM_DMA_SEL, 
+ NULL, false, true);
+
+     /*Set the clk initial phase*/
+     dw_mci_rtk_phase_tuning(host, 0, 0);
+
+     return 0;
+}
+
+#ifdef CONFIG_PM
+static int dw_mci_rtk_suspend(struct device *dev) {
+     struct dw_mci *host = dev_get_drvdata(dev);
+     int ret = 0;
+
+     ret = dw_mci_cqe_runtime_suspend(dev);
+     mcq_writel(host, AHB, 0);
+
+     return ret;
+}
+
+static int dw_mci_rtk_resume(struct device *dev) {
+     struct dw_mci *host = dev_get_drvdata(dev);

drivers/mmc/host/dw_mmc_cqe-rtk.c line 858

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +10 -0
+     int ret = 0;
+
+     mcq_writel(host, AHB, mcq_readl(host, AHB) | SDMMC_AHB_BIG);
+     ret = dw_mci_cqe_runtime_resume(dev);
+
+     return ret;
+}
+#else
+static int dw_mci_rtk_suspend(struct device *dev) {
+     dev_info(dev, "User should enable CONFIG_PM kernel config\n");

NAK, come on. I asked to drop it. Did you just ignore the feedback? Yep...

drivers/mmc/host/dw_mmc_cqe-rtk.c line 858

Quoted 6 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +6 -0
+
+     return 0;
+}
+
+static int dw_mci_rtk_resume(struct device *dev) {
+     dev_info(dev, "User should enable CONFIG_PM kernel config\n");

NAK

Quoted 4 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +4 -0
+
+     return 0;
+}
+#endif /*CONFIG_PM*/

drivers/mmc/host/dw_mmc_cqe-rtk.c line 880

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +10 -0
+static const struct dev_pm_ops rtk_dev_pm_ops = {
+     SET_SYSTEM_SLEEP_PM_OPS(dw_mci_rtk_suspend,
+                             dw_mci_rtk_resume)
+     SET_RUNTIME_PM_OPS(dw_mci_cqe_runtime_suspend,
+                        dw_mci_cqe_runtime_resume,
+                        NULL)
+};
+
+static void dw_mci_rtk_shutdown(struct platform_device *pdev) {
+     dev_info(&pdev->dev, "[eMMC] Shutdown\n");

NAK

Quoted 24 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +24 -0
+     dw_mci_cqe_runtime_resume(&pdev->dev);
+}
+
+static unsigned long dw_mci_rtk_dwmmc_caps[1] = {
+     MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA |
+     MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED |
+     MMC_CAP_NONREMOVABLE | MMC_CAP_CMD23, };
+
+static const struct dw_mci_drv_data rtk_drv_data = {
+     .caps                   = dw_mci_rtk_dwmmc_caps,
+     .num_caps               = ARRAY_SIZE(dw_mci_rtk_dwmmc_caps),
+     .set_ios                = dw_mci_rtk_set_ios,
+     .execute_tuning         = dw_mci_rtk_execute_tuning,
+     .parse_dt               = dw_mci_rtk_parse_dt,
+     .init                   = dw_mci_rtk_init,
+     .prepare_hs400_tuning   = dw_mci_rtk_prepare_hs400_tuning,
+     .hs400_complete         = dw_mci_rtk_hs400_complete,
+     .init_card              = dw_mci_rtk_init_card,
+};
+
+static const struct of_device_id dw_mci_rtk_match[] = {
+     { .compatible = "realtek,rtd1325-dw-cqe-emmc",
+             .data = &rtk_drv_data },
+     {},

drivers/mmc/host/dw_mmc_cqe-rtk.c

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +10 -0
+};
+MODULE_DEVICE_TABLE(of, dw_mci_rtk_match);
+
+int dw_mci_cqe_pltfm_register(struct platform_device *pdev,
+                           const struct dw_mci_drv_data *drv_data) {
+     struct dw_mci *host;
+     struct resource *regs;
+
+     host = devm_kzalloc(&pdev->dev, sizeof(struct dw_mci), 
+ GFP_KERNEL);

sizeof(*)

Quoted 5 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +5 -0
+     if (!host)
+             return -ENOMEM;
+
+     host->irq = platform_get_irq(pdev, 0);
+     if (host->irq < 0)

drivers/mmc/host/dw_mmc_cqe-rtk.c line 930

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +10 -0
+             return host->irq;
+
+     host->drv_data = drv_data;
+     host->pdev = pdev;
+     host->dev = &pdev->dev;
+     host->irq_flags = 0;
+     host->pdata = pdev->dev.platform_data;
+
+     regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+     host->regs = devm_ioremap_resource(&pdev->dev, regs);

Use helper for this.

Open existing, recent drivers and use the them as template or some set of patterns. Sorry, but upstreaming your vendor code will be painful, because you started from some old, buggier version.

Quoted 18 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +18 -0
+     if (IS_ERR(host->regs))
+             return PTR_ERR(host->regs);
+
+     /* Get registers' physical base address */
+     host->phy_regs = regs->start;
+
+     platform_set_drvdata(pdev, host);
+
+     return dw_mci_cqe_probe(host);
+}
+
+static int dw_mci_rtk_probe(struct platform_device *pdev) {
+     const struct dw_mci_drv_data *drv_data;
+     const struct of_device_id *match;
+
+     if (!pdev->dev.of_node)
+             return -ENODEV;
+

drivers/mmc/host/dw_mmc_cqe-rtk.c line 961

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +10 -0
+     match = of_match_node(dw_mci_rtk_match, pdev->dev.of_node);
+     drv_data = match->data;
+
+     return dw_mci_cqe_pltfm_register(pdev, drv_data); }
+
+int dw_mci_rtk_remove(struct platform_device *pdev) {
+     struct dw_mci *host = platform_get_drvdata(pdev);
+
+     dw_mci_cqe_remove(host);
+     return 0;

Best regards,
Krzysztof

#11 lore raw

Re: [PATCH V4][3/4] mmc: Add dw mobile mmc cmdq rtk driver

Quoted 19 lines · Jyan Chou [周芷安]

Hi Krzysztof,

Thanks for you to review our code and give some advices. We will check carefully and fix coding style of all, also, we will drop useless function and message in our next push.
Since some advice we were not sure, we would like to discuss first and modified correctly in our next version.

Quoted 4 lines
Quoted 2 lines

+ priv = devm_kzalloc(host->dev, sizeof(struct
+ dw_mci_rtkemmc_host), GFP_KERNEL);

sizeof(*)

Thanks. I will correct it in our next version.

Quoted 5 lines
Quoted 5 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +5 -0
+     priv->pins_default = pinctrl_lookup_state(priv->pinctrl,
+                                               PINCTRL_STATE_DEFAULT);
+     if (IS_ERR(priv->pins_default))
+             dev_warn(host->dev, "could not get default state\n");
+
Quoted 4 lines
Quoted 1 line

So this is required by the driver but not by the bindings.

Since our pinctrl driver supports different driver's usage, we may use bindings to get the correct pinctrl setting, so we add different pinctrl-names in our bindings. It is correct, or am I misunderstand what you say?

Printing warning means this is required. If driver requires it, so should bindings.

Quoted 16 lines
Quoted 2 lines

dev_err_probe. Everywhere where applicable.

Thanks. I will correct it in our next version.

Quoted 1 line

Read Linux coding style. Multiple times if needed.

Thanks. I will correct it in our next version.

Quoted 6 lines
Quoted 6 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +6 -0
+     host->dev = &pdev->dev;
+     host->irq_flags = 0;
+     host->pdata = pdev->dev.platform_data;
+
+     regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+     host->regs = devm_ioremap_resource(&pdev->dev, regs);
Quoted 5 lines
Quoted 3 lines

Use helper for this.

Open existing, recent drivers and use the them as template or some set of patterns. Sorry, but upstreaming your vendor code will be painful, because you started from some old, buggier version.

Sorry for asking, but I would like to know what is the meaning of "Use helper for this." ? Does it mean we need to get rid of our code above or something else? Thanks a lot.

There is a helper combining two calls above.

Best regards,
Krzysztof

#12 lore raw

RE: [PATCH V4][3/4] mmc: Add dw mobile mmc cmdq rtk driver

In reply to Krzysztof Kozlowski
Quoted 10 lines
Quoted 8 lines

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

---
v3 -> v4:
- Modify dma setting's code to fix linux coding style.

And coding style of all other parts were ignored. You must fix it everywhere in your code.

Thanks for your remind, we checked other linux coding style issues.
...

Quoted 13 lines
Quoted 13 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +13 -0
+
+static void dw_mci_rtk_init_card(struct mmc_host *host, struct 
+mmc_card *card) {
+     /* In Realtek Platform, we need to attach eMMC card onto mmc host
+      * during eMMC initialization because of the following reason:
+      * When system cannot run the hs400, we need to down speed to hs200
+      * and call mmc_hw_reset and modify the mmc card attribute through mmc host.
+      * At this moment, system will show errors if host->card = NULL.
+      */
+     host->card = card;
+}
+
+static int dw_mci_rtk_parse_dt(struct dw_mci *host) {
Quoted 8 lines

drivers/mmc/host/dw_mmc_cqe-rtk.c

Quoted 6 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +6 -0
+     struct dw_mci_rtkemmc_host *priv;
+     const u32 *prop;
+     int size;
+
+     priv = devm_kzalloc(host->dev, sizeof(struct 
+ dw_mci_rtkemmc_host), GFP_KERNEL);

sizeof(*)

We had corrected it.

Quoted 6 lines
Quoted 6 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +6 -0
+     if (!priv)
+             return -ENOMEM;
+
+     priv->pinctrl = devm_pinctrl_get(host->dev);
+     if (IS_ERR(priv->pinctrl))
+             dev_dbg(host->dev, "no pinctrl\n");
Quoted 8 lines

drivers/mmc/host/dw_mmc_cqe-rtk.c line 704

Quoted 6 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +6 -0
+
+     priv->pins_default = pinctrl_lookup_state(priv->pinctrl,
+                                               PINCTRL_STATE_DEFAULT);
+     if (IS_ERR(priv->pins_default))
+             dev_warn(host->dev, "could not get default state\n");
+

So this is required by the driver but not by the bindings.

These pinctrl setting are required by the driver passing from the bindings.

Quoted 42 lines
Quoted 42 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +42 -0
+     priv->pins_sdr50 = pinctrl_lookup_state(priv->pinctrl,
+                                             "sdr50");
+     if (IS_ERR(priv->pins_sdr50))
+             dev_warn(host->dev, "could not get sdr50 state\n");
+
+     priv->pins_hs200 = pinctrl_lookup_state(priv->pinctrl,
+                                             "hs200");
+     if (IS_ERR(priv->pins_hs200))
+             dev_warn(host->dev, "could not get hs200 state\n");
+
+     priv->pins_hs400 = pinctrl_lookup_state(priv->pinctrl,
+                                             "hs400");
+     if (IS_ERR(priv->pins_hs400))
+             dev_warn(host->dev, "could not get hs400 state\n");
+
+     priv->pins_tune0 = pinctrl_lookup_state(priv->pinctrl,
+                                             "tune0");
+     if (IS_ERR(priv->pins_tune0))
+             dev_warn(host->dev, "could not get tune0 state\n");
+
+     priv->pins_tune1 = pinctrl_lookup_state(priv->pinctrl,
+                                             "tune1");
+     if (IS_ERR(priv->pins_tune1))
+             dev_warn(host->dev, "could not get tune1 state\n");
+
+     priv->pins_tune2 = pinctrl_lookup_state(priv->pinctrl,
+                                             "tune2");
+     if (IS_ERR(priv->pins_tune2))
+             dev_warn(host->dev, "could not get tune2 state\n");
+
+     priv->pins_tune3 = pinctrl_lookup_state(priv->pinctrl,
+                                             "tune3");
+     if (IS_ERR(priv->pins_tune3))
+             dev_warn(host->dev, "could not get tune3 state\n");
+
+     priv->pins_tune4 = pinctrl_lookup_state(priv->pinctrl,
+                                             "tune4");
+
+     if (IS_ERR(priv->pins_tune4))
+             dev_warn(host->dev, "could not get tune4 state\n");
+
+     priv->vp0 = devm_clk_get(host->dev, "vp0");
Quoted 8 lines

drivers/mmc/host/dw_mmc_cqe-rtk.c line 752

Quoted 6 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +6 -0
+     if (IS_ERR(priv->vp0))
+             dev_err(host->dev, "could not get vp0 clk\n");
+
+     priv->vp1 = devm_clk_get(host->dev, "vp1");
+     if (IS_ERR(priv->vp1))
+             dev_err(host->dev, "could not get vp1 clk\n");

dev_err_probe. Everywhere where applicable.

We had replace dev_err to dev_err_probe for error prints during probe.

Quoted 9 lines

drivers/mmc/host/dw_mmc_cqe-rtk.c

Quoted 7 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +7 -0
+
+     priv->emmc_mode = 0;
+     prop = of_get_property(host->dev->of_node, "speed-step", &size);
+     if (prop) {
+             priv->emmc_mode = of_read_number(prop, 1);
+             dev_info(host->dev, "emmc mode : %d\n", 
+ priv->emmc_mode);

Drop

Okay.

Quoted 4 lines

drivers/mmc/host/dw_mmc_cqe-rtk.c line 760

Quoted 2 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +2 -0
+     } else {
+             dev_info(host->dev, "use default emmc sdr50 mode !\n");

Drop, why is this a problem?

Okay.

Quoted 9 lines

drivers/mmc/host/dw_mmc_cqe-rtk.c line 767

Quoted 7 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +7 -0
+     }
+
+     priv->is_cqe = 0;
+     prop = of_get_property(host->dev->of_node, "cqe", &size);
+     if (prop) {
+             priv->is_cqe = of_read_number(prop, 1);
+             dev_info(host->dev, "cmdq mode : %d\n", priv->is_cqe);

Drop

Okay.

Quoted 4 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+     } else {
+             dev_info(host->dev, "use default eMMC legacy mode !\n");

Drop

Okay.

Quoted 9 lines

drivers/mmc/host/dw_mmc_cqe-rtk.c

Quoted 7 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +7 -0
+     }
+
+     prop = of_get_property(host->dev->of_node, "rdq-ctrl", &size);
+     if (prop) {
+             priv->rdq_ctrl = of_read_number(prop, 1);
+             dev_info(host->dev, "get rdq-ctrl : %u\n", 
+ priv->rdq_ctrl);

Drop

Okay.

Quoted 6 lines

drivers/mmc/host/dw_mmc_cqe-rtk.c

Quoted 4 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +4 -0
+     } else {
+             priv->rdq_ctrl = 0;
+             dev_info(host->dev, "no dqs_dly_tape switch node, use 
+ default 0x0 !!\n");

Drop

Okay.

Quoted 26 lines
Quoted 26 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +26 -0
+     }
+
+     priv->m2tmx = syscon_regmap_lookup_by_phandle(host->dev->of_node, "realtek,m2tmx");
+     if (IS_ERR_OR_NULL(priv->m2tmx))
+             dev_err(host->dev, "can not get m2mtx node.\n");
+
+     host->priv = priv;
+
+     return 0;
+}
+
+static int dw_mci_rtk_init(struct dw_mci *host) {
+     struct dw_mci_rtkemmc_host *priv = host->priv;
+
+     host->pdata->caps2 = MMC_CAP2_NO_SDIO | MMC_CAP2_NO_SD;
+
+     if (priv->emmc_mode >= 2)
+             host->pdata->caps2 |= MMC_CAP2_HS200_1_8V_SDR;
+     if (priv->emmc_mode >= 3) {
+             host->pdata->caps |= MMC_CAP_1_8V_DDR;
+             host->pdata->caps2 |= MMC_CAP2_HS400_1_8V;
+     }
+
+     if (priv->is_cqe > 0)
+             host->pdata->caps2 |= (MMC_CAP2_CQE | 
+ MMC_CAP2_CQE_DCMD);
Quoted 8 lines

drivers/mmc/host/dw_mmc_cqe-rtk.c line 810

Quoted 6 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +6 -0
+
+     host->irq_flags = IRQF_SHARED;
+
+     mcq_writel(host, CP, 0x0);
+
+     /*Enable L4 gated*/

Read Linux coding style. Multiple times if needed.

Thanks for your remind.

Quoted 42 lines
Quoted 42 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +42 -0
+     mcq_writel(host, OTHER1, mcq_readl(host, OTHER1) &
+             ~(SDMMC_L4_GATED_DIS | SDMMC_L4_GATED_DIS1));
+
+     mcq_writel(host, OTHER1, mcq_readl(host, OTHER1) &
+                (~(SDMMC_DQS_CTRL_GATE_DIS | 
+ SDMMC_DBUS_MAS_GATING_DIS)));
+
+     /*Set the eMMC wrapper little Endian*/
+     mcq_writel(host, AHB, mcq_readl(host, AHB) | SDMMC_AHB_BIG);
+
+     mcq_writel(host, OTHER1,
+                mcq_readl(host, OTHER1) | 
+ SDMMC_STARK_CARD_STOP_ENABLE);
+
+     /*set eMMC instead of nand*/
+     regmap_update_bits_base(priv->m2tmx, SDMMC_NAND_DMA_SEL,
+                             SDMMC_SRAM_DMA_SEL, SDMMC_SRAM_DMA_SEL, 
+ NULL, false, true);
+
+     /*Set the clk initial phase*/
+     dw_mci_rtk_phase_tuning(host, 0, 0);
+
+     return 0;
+}
+
+#ifdef CONFIG_PM
+static int dw_mci_rtk_suspend(struct device *dev) {
+     struct dw_mci *host = dev_get_drvdata(dev);
+     int ret = 0;
+
+     ret = dw_mci_cqe_runtime_suspend(dev);
+     mcq_writel(host, AHB, 0);
+
+     return ret;
+}
+
+static int dw_mci_rtk_resume(struct device *dev) {
+     struct dw_mci *host = dev_get_drvdata(dev);
+     int ret = 0;
+
+     mcq_writel(host, AHB, mcq_readl(host, AHB) | SDMMC_AHB_BIG);
+     ret = dw_mci_cqe_runtime_resume(dev);
Quoted 8 lines

drivers/mmc/host/dw_mmc_cqe-rtk.c line 858

Quoted 6 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +6 -0
+
+     return ret;
+}
+#else
+static int dw_mci_rtk_suspend(struct device *dev) {
+     dev_info(dev, "User should enable CONFIG_PM kernel config\n");

NAK, come on. I asked to drop it. Did you just ignore the feedback? Yep...

Okay.

Quoted 8 lines

drivers/mmc/host/dw_mmc_cqe-rtk.c line 858

Quoted 6 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +6 -0
+
+     return 0;
+}
+
+static int dw_mci_rtk_resume(struct device *dev) {
+     dev_info(dev, "User should enable CONFIG_PM kernel config\n");

NAK

We had removed it.

Quoted 8 lines
Quoted 8 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +8 -0
+
+     return 0;
+}
+#endif /*CONFIG_PM*/
+static const struct dev_pm_ops rtk_dev_pm_ops = {
+     SET_SYSTEM_SLEEP_PM_OPS(dw_mci_rtk_suspend,
+                             dw_mci_rtk_resume)
+     SET_RUNTIME_PM_OPS(dw_mci_cqe_runtime_suspend,
Quoted 8 lines

drivers/mmc/host/dw_mmc_cqe-rtk.c line 880

Quoted 6 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +6 -0
+                        dw_mci_cqe_runtime_resume,
+                        NULL)
+};
+
+static void dw_mci_rtk_shutdown(struct platform_device *pdev) {
+     dev_info(&pdev->dev, "[eMMC] Shutdown\n");

NAK

We had removed it.

Quoted 28 lines
Quoted 28 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +28 -0
+     dw_mci_cqe_runtime_resume(&pdev->dev);
+}
+
+static unsigned long dw_mci_rtk_dwmmc_caps[1] = {
+     MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA |
+     MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED |
+     MMC_CAP_NONREMOVABLE | MMC_CAP_CMD23, };
+
+static const struct dw_mci_drv_data rtk_drv_data = {
+     .caps                   = dw_mci_rtk_dwmmc_caps,
+     .num_caps               = ARRAY_SIZE(dw_mci_rtk_dwmmc_caps),
+     .set_ios                = dw_mci_rtk_set_ios,
+     .execute_tuning         = dw_mci_rtk_execute_tuning,
+     .parse_dt               = dw_mci_rtk_parse_dt,
+     .init                   = dw_mci_rtk_init,
+     .prepare_hs400_tuning   = dw_mci_rtk_prepare_hs400_tuning,
+     .hs400_complete         = dw_mci_rtk_hs400_complete,
+     .init_card              = dw_mci_rtk_init_card,
+};
+
+static const struct of_device_id dw_mci_rtk_match[] = {
+     { .compatible = "realtek,rtd1325-dw-cqe-emmc",
+             .data = &rtk_drv_data },
+     {},
+};
+MODULE_DEVICE_TABLE(of, dw_mci_rtk_match);
+
+int dw_mci_cqe_pltfm_register(struct platform_device *pdev,
Quoted 8 lines

drivers/mmc/host/dw_mmc_cqe-rtk.c

Quoted 6 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +6 -0
+                           const struct dw_mci_drv_data *drv_data) {
+     struct dw_mci *host;
+     struct resource *regs;
+
+     host = devm_kzalloc(&pdev->dev, sizeof(struct dw_mci), 
+ GFP_KERNEL);

sizeof(*)

We had corrected it.

Quoted 18 lines
Quoted 5 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +5 -0
+     if (!host)
+             return -ENOMEM;
+
+     host->irq = platform_get_irq(pdev, 0);
+     if (host->irq < 0)

drivers/mmc/host/dw_mmc_cqe-rtk.c line 930

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +10 -0
+             return host->irq;
+
+     host->drv_data = drv_data;
+     host->pdev = pdev;
+     host->dev = &pdev->dev;
+     host->irq_flags = 0;
+     host->pdata = pdev->dev.platform_data;
+
+     regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+     host->regs = devm_ioremap_resource(&pdev->dev, regs);

Use helper for this.

Quoted 1 line

Open existing, recent drivers and use the them as template or some set of patterns. Sorry, but upstreaming your vendor code will be painful, because you started from some old, buggier version.

We had replaced platform_get_resource , devm_ioremap_resource by devm_platform_ioremap_resource.

Quoted 20 lines
Quoted 20 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +20 -0
+     if (IS_ERR(host->regs))
+             return PTR_ERR(host->regs);
+
+     /* Get registers' physical base address */
+     host->phy_regs = regs->start;
+
+     platform_set_drvdata(pdev, host);
+
+     return dw_mci_cqe_probe(host);
+}
+
+static int dw_mci_rtk_probe(struct platform_device *pdev) {
+     const struct dw_mci_drv_data *drv_data;
+     const struct of_device_id *match;
+
+     if (!pdev->dev.of_node)
+             return -ENODEV;
+
+     match = of_match_node(dw_mci_rtk_match, pdev->dev.of_node);
+     drv_data = match->data;
Quoted 8 lines

drivers/mmc/host/dw_mmc_cqe-rtk.c line 961

Quoted 8 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +8 -0
+
+     return dw_mci_cqe_pltfm_register(pdev, drv_data); }
+
+int dw_mci_rtk_remove(struct platform_device *pdev) {
+     struct dw_mci *host = platform_get_drvdata(pdev);
+
+     dw_mci_cqe_remove(host);
+     return 0;

Best regards,
Jyan

-----Original Message-----
From: Krzysztof Kozlowski <[email protected]>
Sent: Monday, October 30, 2023 3:44 PM
To: Jyan Chou [周芷安] <[email protected]>; [email protected]; [email protected]; [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]
Subject: Re: [PATCH V4][3/4] mmc: Add dw mobile mmc cmdq rtk driver

External mail.

Quoted 8 lines · Jyan Chou

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

---
v3 -> v4:
- Modify dma setting's code to fix linux coding style.

And coding style of all other parts were ignored. You must fix it everywhere in your code.

...

Quoted 9 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +9 -0
+
+static void dw_mci_rtk_init_card(struct mmc_host *host, struct 
+mmc_card *card) {
+     /* In Realtek Platform, we need to attach eMMC card onto mmc host
+      * during eMMC initialization because of the following reason:
+      * When system cannot run the hs400, we need to down speed to hs200
+      * and call mmc_hw_reset and modify the mmc card attribute through mmc host.
+      * At this moment, system will show errors if host->card = NULL.
+      */

drivers/mmc/host/dw_mmc_cqe-rtk.c

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +10 -0
+     host->card = card;
+}
+
+static int dw_mci_rtk_parse_dt(struct dw_mci *host) {
+     struct dw_mci_rtkemmc_host *priv;
+     const u32 *prop;
+     int size;
+
+     priv = devm_kzalloc(host->dev, sizeof(struct 
+ dw_mci_rtkemmc_host), GFP_KERNEL);

sizeof(*)

drivers/mmc/host/dw_mmc_cqe-rtk.c line 704

Quoted 12 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +12 -0
+     if (!priv)
+             return -ENOMEM;
+
+     priv->pinctrl = devm_pinctrl_get(host->dev);
+     if (IS_ERR(priv->pinctrl))
+             dev_dbg(host->dev, "no pinctrl\n");
+
+     priv->pins_default = pinctrl_lookup_state(priv->pinctrl,
+                                               PINCTRL_STATE_DEFAULT);
+     if (IS_ERR(priv->pins_default))
+             dev_warn(host->dev, "could not get default state\n");
+

So this is required by the driver but not by the bindings.

Quoted 38 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +38 -0
+     priv->pins_sdr50 = pinctrl_lookup_state(priv->pinctrl,
+                                             "sdr50");
+     if (IS_ERR(priv->pins_sdr50))
+             dev_warn(host->dev, "could not get sdr50 state\n");
+
+     priv->pins_hs200 = pinctrl_lookup_state(priv->pinctrl,
+                                             "hs200");
+     if (IS_ERR(priv->pins_hs200))
+             dev_warn(host->dev, "could not get hs200 state\n");
+
+     priv->pins_hs400 = pinctrl_lookup_state(priv->pinctrl,
+                                             "hs400");
+     if (IS_ERR(priv->pins_hs400))
+             dev_warn(host->dev, "could not get hs400 state\n");
+
+     priv->pins_tune0 = pinctrl_lookup_state(priv->pinctrl,
+                                             "tune0");
+     if (IS_ERR(priv->pins_tune0))
+             dev_warn(host->dev, "could not get tune0 state\n");
+
+     priv->pins_tune1 = pinctrl_lookup_state(priv->pinctrl,
+                                             "tune1");
+     if (IS_ERR(priv->pins_tune1))
+             dev_warn(host->dev, "could not get tune1 state\n");
+
+     priv->pins_tune2 = pinctrl_lookup_state(priv->pinctrl,
+                                             "tune2");
+     if (IS_ERR(priv->pins_tune2))
+             dev_warn(host->dev, "could not get tune2 state\n");
+
+     priv->pins_tune3 = pinctrl_lookup_state(priv->pinctrl,
+                                             "tune3");
+     if (IS_ERR(priv->pins_tune3))
+             dev_warn(host->dev, "could not get tune3 state\n");
+
+     priv->pins_tune4 = pinctrl_lookup_state(priv->pinctrl,
+                                             "tune4");
+

drivers/mmc/host/dw_mmc_cqe-rtk.c line 752

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +10 -0
+     if (IS_ERR(priv->pins_tune4))
+             dev_warn(host->dev, "could not get tune4 state\n");
+
+     priv->vp0 = devm_clk_get(host->dev, "vp0");
+     if (IS_ERR(priv->vp0))
+             dev_err(host->dev, "could not get vp0 clk\n");
+
+     priv->vp1 = devm_clk_get(host->dev, "vp1");
+     if (IS_ERR(priv->vp1))
+             dev_err(host->dev, "could not get vp1 clk\n");

dev_err_probe. Everywhere where applicable.

drivers/mmc/host/dw_mmc_cqe-rtk.c

Quoted 7 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +7 -0
+
+     priv->emmc_mode = 0;
+     prop = of_get_property(host->dev->of_node, "speed-step", &size);
+     if (prop) {
+             priv->emmc_mode = of_read_number(prop, 1);
+             dev_info(host->dev, "emmc mode : %d\n", 
+ priv->emmc_mode);

Drop

drivers/mmc/host/dw_mmc_cqe-rtk.c line 760

Quoted 2 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +2 -0
+     } else {
+             dev_info(host->dev, "use default emmc sdr50 mode !\n");

Drop, why is this a problem?

drivers/mmc/host/dw_mmc_cqe-rtk.c line 767

Quoted 7 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +7 -0
+     }
+
+     priv->is_cqe = 0;
+     prop = of_get_property(host->dev->of_node, "cqe", &size);
+     if (prop) {
+             priv->is_cqe = of_read_number(prop, 1);
+             dev_info(host->dev, "cmdq mode : %d\n", priv->is_cqe);

Drop

Review

Quoted 2 lines
(quoted diff) +2 -0
+     } else {
+             dev_info(host->dev, "use default eMMC legacy mode !\n");

Drop

drivers/mmc/host/dw_mmc_cqe-rtk.c

Quoted 7 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +7 -0
+     }
+
+     prop = of_get_property(host->dev->of_node, "rdq-ctrl", &size);
+     if (prop) {
+             priv->rdq_ctrl = of_read_number(prop, 1);
+             dev_info(host->dev, "get rdq-ctrl : %u\n", 
+ priv->rdq_ctrl);

Drop

drivers/mmc/host/dw_mmc_cqe-rtk.c

Quoted 4 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +4 -0
+     } else {
+             priv->rdq_ctrl = 0;
+             dev_info(host->dev, "no dqs_dly_tape switch node, use 
+ default 0x0 !!\n");

Drop

Quoted 22 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +22 -0
+     }
+
+     priv->m2tmx = syscon_regmap_lookup_by_phandle(host->dev->of_node, "realtek,m2tmx");
+     if (IS_ERR_OR_NULL(priv->m2tmx))
+             dev_err(host->dev, "can not get m2mtx node.\n");
+
+     host->priv = priv;
+
+     return 0;
+}
+
+static int dw_mci_rtk_init(struct dw_mci *host) {
+     struct dw_mci_rtkemmc_host *priv = host->priv;
+
+     host->pdata->caps2 = MMC_CAP2_NO_SDIO | MMC_CAP2_NO_SD;
+
+     if (priv->emmc_mode >= 2)
+             host->pdata->caps2 |= MMC_CAP2_HS200_1_8V_SDR;
+     if (priv->emmc_mode >= 3) {
+             host->pdata->caps |= MMC_CAP_1_8V_DDR;
+             host->pdata->caps2 |= MMC_CAP2_HS400_1_8V;
+     }

drivers/mmc/host/dw_mmc_cqe-rtk.c line 810

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +10 -0
+
+     if (priv->is_cqe > 0)
+             host->pdata->caps2 |= (MMC_CAP2_CQE | 
+ MMC_CAP2_CQE_DCMD);
+
+     host->irq_flags = IRQF_SHARED;
+
+     mcq_writel(host, CP, 0x0);
+
+     /*Enable L4 gated*/

Read Linux coding style. Multiple times if needed.

Quoted 38 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +38 -0
+     mcq_writel(host, OTHER1, mcq_readl(host, OTHER1) &
+             ~(SDMMC_L4_GATED_DIS | SDMMC_L4_GATED_DIS1));
+
+     mcq_writel(host, OTHER1, mcq_readl(host, OTHER1) &
+                (~(SDMMC_DQS_CTRL_GATE_DIS | 
+ SDMMC_DBUS_MAS_GATING_DIS)));
+
+     /*Set the eMMC wrapper little Endian*/
+     mcq_writel(host, AHB, mcq_readl(host, AHB) | SDMMC_AHB_BIG);
+
+     mcq_writel(host, OTHER1,
+                mcq_readl(host, OTHER1) | 
+ SDMMC_STARK_CARD_STOP_ENABLE);
+
+     /*set eMMC instead of nand*/
+     regmap_update_bits_base(priv->m2tmx, SDMMC_NAND_DMA_SEL,
+                             SDMMC_SRAM_DMA_SEL, SDMMC_SRAM_DMA_SEL, 
+ NULL, false, true);
+
+     /*Set the clk initial phase*/
+     dw_mci_rtk_phase_tuning(host, 0, 0);
+
+     return 0;
+}
+
+#ifdef CONFIG_PM
+static int dw_mci_rtk_suspend(struct device *dev) {
+     struct dw_mci *host = dev_get_drvdata(dev);
+     int ret = 0;
+
+     ret = dw_mci_cqe_runtime_suspend(dev);
+     mcq_writel(host, AHB, 0);
+
+     return ret;
+}
+
+static int dw_mci_rtk_resume(struct device *dev) {
+     struct dw_mci *host = dev_get_drvdata(dev);

drivers/mmc/host/dw_mmc_cqe-rtk.c line 858

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +10 -0
+     int ret = 0;
+
+     mcq_writel(host, AHB, mcq_readl(host, AHB) | SDMMC_AHB_BIG);
+     ret = dw_mci_cqe_runtime_resume(dev);
+
+     return ret;
+}
+#else
+static int dw_mci_rtk_suspend(struct device *dev) {
+     dev_info(dev, "User should enable CONFIG_PM kernel config\n");

NAK, come on. I asked to drop it. Did you just ignore the feedback? Yep...

drivers/mmc/host/dw_mmc_cqe-rtk.c line 858

Quoted 6 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +6 -0
+
+     return 0;
+}
+
+static int dw_mci_rtk_resume(struct device *dev) {
+     dev_info(dev, "User should enable CONFIG_PM kernel config\n");

NAK

Quoted 4 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +4 -0
+
+     return 0;
+}
+#endif /*CONFIG_PM*/

drivers/mmc/host/dw_mmc_cqe-rtk.c line 880

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +10 -0
+static const struct dev_pm_ops rtk_dev_pm_ops = {
+     SET_SYSTEM_SLEEP_PM_OPS(dw_mci_rtk_suspend,
+                             dw_mci_rtk_resume)
+     SET_RUNTIME_PM_OPS(dw_mci_cqe_runtime_suspend,
+                        dw_mci_cqe_runtime_resume,
+                        NULL)
+};
+
+static void dw_mci_rtk_shutdown(struct platform_device *pdev) {
+     dev_info(&pdev->dev, "[eMMC] Shutdown\n");

NAK

Quoted 24 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +24 -0
+     dw_mci_cqe_runtime_resume(&pdev->dev);
+}
+
+static unsigned long dw_mci_rtk_dwmmc_caps[1] = {
+     MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA |
+     MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED |
+     MMC_CAP_NONREMOVABLE | MMC_CAP_CMD23, };
+
+static const struct dw_mci_drv_data rtk_drv_data = {
+     .caps                   = dw_mci_rtk_dwmmc_caps,
+     .num_caps               = ARRAY_SIZE(dw_mci_rtk_dwmmc_caps),
+     .set_ios                = dw_mci_rtk_set_ios,
+     .execute_tuning         = dw_mci_rtk_execute_tuning,
+     .parse_dt               = dw_mci_rtk_parse_dt,
+     .init                   = dw_mci_rtk_init,
+     .prepare_hs400_tuning   = dw_mci_rtk_prepare_hs400_tuning,
+     .hs400_complete         = dw_mci_rtk_hs400_complete,
+     .init_card              = dw_mci_rtk_init_card,
+};
+
+static const struct of_device_id dw_mci_rtk_match[] = {
+     { .compatible = "realtek,rtd1325-dw-cqe-emmc",
+             .data = &rtk_drv_data },
+     {},

drivers/mmc/host/dw_mmc_cqe-rtk.c

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +10 -0
+};
+MODULE_DEVICE_TABLE(of, dw_mci_rtk_match);
+
+int dw_mci_cqe_pltfm_register(struct platform_device *pdev,
+                           const struct dw_mci_drv_data *drv_data) {
+     struct dw_mci *host;
+     struct resource *regs;
+
+     host = devm_kzalloc(&pdev->dev, sizeof(struct dw_mci), 
+ GFP_KERNEL);

sizeof(*)

Quoted 5 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +5 -0
+     if (!host)
+             return -ENOMEM;
+
+     host->irq = platform_get_irq(pdev, 0);
+     if (host->irq < 0)

drivers/mmc/host/dw_mmc_cqe-rtk.c line 930

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +10 -0
+             return host->irq;
+
+     host->drv_data = drv_data;
+     host->pdev = pdev;
+     host->dev = &pdev->dev;
+     host->irq_flags = 0;
+     host->pdata = pdev->dev.platform_data;
+
+     regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+     host->regs = devm_ioremap_resource(&pdev->dev, regs);

Use helper for this.

Open existing, recent drivers and use the them as template or some set of patterns. Sorry, but upstreaming your vendor code will be painful, because you started from some old, buggier version.

Quoted 18 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +18 -0
+     if (IS_ERR(host->regs))
+             return PTR_ERR(host->regs);
+
+     /* Get registers' physical base address */
+     host->phy_regs = regs->start;
+
+     platform_set_drvdata(pdev, host);
+
+     return dw_mci_cqe_probe(host);
+}
+
+static int dw_mci_rtk_probe(struct platform_device *pdev) {
+     const struct dw_mci_drv_data *drv_data;
+     const struct of_device_id *match;
+
+     if (!pdev->dev.of_node)
+             return -ENODEV;
+

drivers/mmc/host/dw_mmc_cqe-rtk.c line 961

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +10 -0
+     match = of_match_node(dw_mci_rtk_match, pdev->dev.of_node);
+     drv_data = match->data;
+
+     return dw_mci_cqe_pltfm_register(pdev, drv_data); }
+
+int dw_mci_rtk_remove(struct platform_device *pdev) {
+     struct dw_mci *host = platform_get_drvdata(pdev);
+
+     dw_mci_cqe_remove(host);
+     return 0;

Best regards,
Krzysztof

author
#13 lore raw

PATCH v4 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.

---
v3 -> v4:
- Rename compatible(add SoC-specific part) to be different from filename.
- 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.

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

---
 .../bindings/mmc/realtek-dw-mshc.yaml         | 161 ++++++++++++++++++
 1 file changed, 161 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml
Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml new file +161 -0
new file mode 100644
index 000000000000..d238cf3b8b47
@@ -0,0 +1,161 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mmc/realtek-dw-mshc.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.
+
+allOf:
+  - $ref: synopsys-dw-mshc-common.yaml#
+
+maintainers:
+  - Jyan Chou <[email protected]>
+
+properties:
+  compatible:
+    enum:
+      - realtek,rtd1325-dw-cqe-emmc
+
+  reg:
+    maxItems: 2
+    description:
+      Two regs are required, first reg specifies emmc base address, second reg
+      specifies cqhci base register address.
+
+  reg-names:
+    maxItems: 2
+    items:
+      - const: emmc
+      - const: cqhci
+
+  interrupts:
+    maxItems: 1
+
+  cqe:
+    maxItems: 1
+    description:
+      Cqe should set to 1 while using command queue feature, and set to 0 while
+      in legacy mode.
+
+  clocks:
+    minItems: 2
+    items:
+      - description: bus interface unit clock
+      - description: card interface unit clock
+      - description: select the phase for vpclk0 in realtek chip specified
+      - description: select the phase for vpclk1 in realtek chip specified
+
+  clock-names:
+    minItems: 2
+    items:
+      - const: biu
+      - const: ciu
+      - const: vp0
+      - const: vp1
+
+  resets:
+    maxItems: 1
+
+  reset-names:
+    const: reset
+
+  pinctrl-0:
+    description:
+      should contain default/high speed pin ctrl.
+    maxItems: 1
+
+  pinctrl-1:
+    description:
+      should contain sdr50 mode 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
+    - pinctrl-names
+
+  unevaluatedProperties: false
+
+  examples:
+    - |
+      emmc: mmc@12000 {
+        compatible = "realtek,rtd1325-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";
+        clock-freq-min-max = <300000 400000000>;
+        clock-frequency = <400000>;
+        vmmc-supply = <&reg_vcc1v8>;
+        resets = <&rst 20>;
+        reset-names = "reset";
+        speed-step = <3>;
+        cqe = <1>;
+        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>;
+        };
Signature · 1 line
2.42.0
#14 lore raw

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

Quoted 7 lines · Jyan Chou

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

---
v3 -> v4:
- Rename compatible(add SoC-specific part) to be different from filename.

What? I asked to be the same.

Quoted 9 lines

- 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.

Quoted 7 lines

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

---
 .../bindings/mmc/realtek-dw-mshc.yaml         | 161 ++++++++++++++++++
 1 file changed, 161 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml

Compatible should match filename.

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.

Quoted 41 lines
Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml new file +34 -0
new file mode 100644
index 000000000000..d238cf3b8b47
@@ -0,0 +1,161 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mmc/realtek-dw-mshc.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.
+
+allOf:
+  - $ref: synopsys-dw-mshc-common.yaml#
+
+maintainers:
+  - Jyan Chou <[email protected]>
+
+properties:
+  compatible:
+    enum:
+      - realtek,rtd1325-dw-cqe-emmc
+
+  reg:
+    maxItems: 2
+    description:
+      Two regs are required, first reg specifies emmc base address, second reg
+      specifies cqhci base register address.
+
+  reg-names:
+    maxItems: 2
+    items:
+      - const: emmc

Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml line 44

Quoted 10 lines
Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml new file +10 -0
+      - const: cqhci
+
+  interrupts:
+    maxItems: 1
+
+  cqe:
+    maxItems: 1
+    description:
+      Cqe should set to 1 while using command queue feature, and set to 0 while
+      in legacy mode.

Did you just ignore Rob's comment?

Please point me where and how did you address it?

Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml line 47

Quoted 3 lines
Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml new file +3 -0
+
+  clocks:
+    minItems: 2

No, why?

Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml line 55

Quoted 8 lines
Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml new file +8 -0
+    items:
+      - description: bus interface unit clock
+      - description: card interface unit clock
+      - description: select the phase for vpclk0 in realtek chip specified
+      - description: select the phase for vpclk1 in realtek chip specified
+
+  clock-names:
+    minItems: 2

No, why?

Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml line 66

Quoted 11 lines
Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml new file +11 -0
+    items:
+      - const: biu
+      - const: ciu
+      - const: vp0
+      - const: vp1
+
+  resets:
+    maxItems: 1
+
+  reset-names:
+    const: reset

You ignored my feedback. NAK.

Quoted 45 lines
Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml new file +45 -0
+
+  pinctrl-0:
+    description:
+      should contain default/high speed pin ctrl.
+    maxItems: 1
+
+  pinctrl-1:
+    description:
+      should contain sdr50 mode 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

Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml line 121

Quoted 10 lines
Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml new file +10 -0
+
+  pinctrl-9:
+    description:
+      should contain tune4 pin ctrl.
+    maxItems: 1
+
+  pinctrl-names:
+    maxItems: 10
+
+  required:

This wasn't even tested.

Do not send untested, broken code. Please run make dt_binding_check (see Documentation/devicetree/bindings/writing-schema.rst for instructions). Maybe you need to update your dtschema and yamllint.

Quoted 32 lines
Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml new file +30 -0
+    - compatible
+    - reg
+    - reg-names
+    - interrupts
+    - clocks
+    - clock-names
+    - pinctrl-names
+
+  unevaluatedProperties: false
+
+  examples:
 
 
+    - |
+      emmc: mmc@12000 {
+        compatible = "realtek,rtd1325-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";
+        clock-freq-min-max = <300000 400000000>;
+        clock-frequency = <400000>;
+        vmmc-supply = <&reg_vcc1v8>;
+        resets = <&rst 20>;
+        reset-names = "reset";
+        speed-step = <3>;
+        cqe = <1>;
+        pinctrl-names = "default", "sdr50", "ddr50", "hs200", "hs400",
+                        "tune0","tune1", "tune2","tune3", "tune4";
+        pinctrl-0 = <&emmc_pins_sdr50>;

Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml line 161

Quoted 10 lines
Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml new file +10 -0
+        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>;
+        };

Broken indentation.

Best regards,
Krzysztof

#15 lore raw

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

Hi Krzysztof, Rob,

Thanks for your code review and advice.

Quoted 1 line

What? I asked to be the same.

We had modified it to be the same.

Quoted 1 line

Compatible should match filename.

compatible = "realtek,rtd-dw-cqe-emmc"; be the same as realtek,rtd-dw-cqe-emmc.yaml

Quoted 9 lines

Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml line 44

Quoted 5 lines
Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml new file +5 -0
+  cqe:
+    maxItems: 1
+    description:
+      Cqe should set to 1 while using command queue feature, and set to 0 while
+      in legacy mode.

Did you just ignore Rob's comment?

Please point me where and how did you address it?

Sorry for not fixing this error. We had removed cqe and used common properties related to CQE.

Quoted 17 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+  clocks:
+    minItems: 2

No, why?

Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml line 55

Quoted 9 lines
Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml new file +9 -0
+    items:
+      - description: bus interface unit clock
+      - description: card interface unit clock
+      - description: select the phase for vpclk0 in realtek chip specified
+      - description: select the phase for vpclk1 in realtek chip 
+ specified
+
+  clock-names:
+    minItems: 2

No, why?

Quoted 11 lines

Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml line 66

Quoted 11 lines
Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml new file +11 -0
+    items:
+      - const: biu
+      - const: ciu
+      - const: vp0
+      - const: vp1
+
+  resets:
+    maxItems: 1
+
+  reset-names:
+    const: reset

We had modified our wrong format of clocks and clock-names, also we removed useless resets properties.

Quoted 30 lines
Quoted 19 lines
Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml new file +19 -0
+    - |
+      emmc: mmc@12000 {
+        compatible = "realtek,rtd1325-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";
+        clock-freq-min-max = <300000 400000000>;
+        clock-frequency = <400000>;
+        vmmc-supply = <&reg_vcc1v8>;
+        resets = <&rst 20>;
+        reset-names = "reset";
+        speed-step = <3>;
+        cqe = <1>;
+        pinctrl-names = "default", "sdr50", "ddr50", "hs200", "hs400",
+                        "tune0","tune1", "tune2","tune3", "tune4";
+        pinctrl-0 = <&emmc_pins_sdr50>;

Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml line 161

Quoted 10 lines
Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml new file +10 -0
+        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>;
+        };
Quoted 1 line

Broken indentation.

We had corrected the wrong indentation and tested it with make dt_binding_check.

Best Regards,

Jyan

-----Original Message-----
From: Krzysztof Kozlowski <[email protected]>
Sent: Monday, October 30, 2023 3:47 PM
To: Jyan Chou [周芷安] <[email protected]>; [email protected]; [email protected]; [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]
Subject: Re: [PATCH V4][4/4] dt-bindings: mmc: Add dt-bindings for realtek mmc driver

External mail.

Quoted 7 lines · Jyan Chou

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

---
v3 -> v4:
- Rename compatible(add SoC-specific part) to be different from filename.

What? I asked to be the same.

Quoted 9 lines

- 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.

Quoted 8 lines

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

---
 .../bindings/mmc/realtek-dw-mshc.yaml         | 161 ++++++++++++++++++
 1 file changed, 161 insertions(+)
 create mode 100644 

Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml

Compatible should match filename.

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.

Quoted 43 lines
(quoted diff) +0 -0

a/Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml b/Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml new file mode 100644
index 000000000000..d238cf3b8b47

Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml new file +34 -0
@@ -0,0 +1,161 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) %YAML 1.2
+---
+$id: http://devicetree.org/schemas/mmc/realtek-dw-mshc.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.
+
+allOf:
+  - $ref: synopsys-dw-mshc-common.yaml#
+
+maintainers:
+  - Jyan Chou <[email protected]>
+
+properties:
+  compatible:
+    enum:
+      - realtek,rtd1325-dw-cqe-emmc
+
+  reg:
+    maxItems: 2
+    description:
+      Two regs are required, first reg specifies emmc base address, second reg
+      specifies cqhci base register address.
+
+  reg-names:
+    maxItems: 2
+    items:
+      - const: emmc

Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml line 44

Quoted 10 lines
Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml new file +10 -0
+      - const: cqhci
+
+  interrupts:
+    maxItems: 1
+
+  cqe:
+    maxItems: 1
+    description:
+      Cqe should set to 1 while using command queue feature, and set to 0 while
+      in legacy mode.

Did you just ignore Rob's comment?

Please point me where and how did you address it?

Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml line 47

Quoted 3 lines
Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml new file +3 -0
+
+  clocks:
+    minItems: 2

No, why?

Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml line 55

Quoted 9 lines
Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml new file +9 -0
+    items:
+      - description: bus interface unit clock
+      - description: card interface unit clock
+      - description: select the phase for vpclk0 in realtek chip specified
+      - description: select the phase for vpclk1 in realtek chip 
+ specified
+
+  clock-names:
+    minItems: 2

No, why?

Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml line 66

Quoted 11 lines
Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml new file +11 -0
+    items:
+      - const: biu
+      - const: ciu
+      - const: vp0
+      - const: vp1
+
+  resets:
+    maxItems: 1
+
+  reset-names:
+    const: reset

You ignored my feedback. NAK.

Quoted 45 lines
Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml new file +45 -0
+
+  pinctrl-0:
+    description:
+      should contain default/high speed pin ctrl.
+    maxItems: 1
+
+  pinctrl-1:
+    description:
+      should contain sdr50 mode 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

Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml line 121

Quoted 10 lines
Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml new file +10 -0
+
+  pinctrl-9:
+    description:
+      should contain tune4 pin ctrl.
+    maxItems: 1
+
+  pinctrl-names:
+    maxItems: 10
+
+  required:

This wasn't even tested.

Do not send untested, broken code. Please run make dt_binding_check (see Documentation/devicetree/bindings/writing-schema.rst for instructions). Maybe you need to update your dtschema and yamllint.

Quoted 32 lines
Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml new file +30 -0
+    - compatible
+    - reg
+    - reg-names
+    - interrupts
+    - clocks
+    - clock-names
+    - pinctrl-names
+
+  unevaluatedProperties: false
+
+  examples:
 
 
+    - |
+      emmc: mmc@12000 {
+        compatible = "realtek,rtd1325-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";
+        clock-freq-min-max = <300000 400000000>;
+        clock-frequency = <400000>;
+        vmmc-supply = <&reg_vcc1v8>;
+        resets = <&rst 20>;
+        reset-names = "reset";
+        speed-step = <3>;
+        cqe = <1>;
+        pinctrl-names = "default", "sdr50", "ddr50", "hs200", "hs400",
+                        "tune0","tune1", "tune2","tune3", "tune4";
+        pinctrl-0 = <&emmc_pins_sdr50>;

Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml line 161

Quoted 10 lines
Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml new file +10 -0
+        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>;
+        };

Broken indentation.

Best regards,
Krzysztof

#16 lore raw

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

Quoted 6 lines · Jyan Chou [周芷安]

Hi Krzysztof, Rob,

Thanks for your code review and advice.

Quoted 1 line

What? I asked to be the same.

Respond inline, not by copying some pieces out of context to another part of email. That's not mailing list style response.

Best regards,
Krzysztof

#17 lore raw

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

Quoted 7 lines
Quoted 5 lines

Hi Krzysztof, Rob,

Thanks for your code review and advice.

Quoted 1 line

What? I asked to be the same.

Respond inline, not by copying some pieces out of context to another part of email. That's not mailing list style response.

Thanks for your remind. I will resend changelog.

Quoted 9 lines
Quoted 7 lines
Quoted 4 lines

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

---
v3 -> v4:
- Rename compatible(add SoC-specific part) to be different from filename.

What? I asked to be the same.

We had modified it to be the same.

Quoted 18 lines
Quoted 9 lines

- 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.

Quoted 8 lines

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

---
 .../bindings/mmc/realtek-dw-mshc.yaml         | 161 ++++++++++++++++++
 1 file changed, 161 insertions(+)
 create mode 100644 

Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml

Quoted 1 line

Compatible should match filename.

compatible = "realtek,rtd-dw-cqe-emmc"; had changes to be the same as realtek,rtd-dw-cqe-emmc.yaml

Quoted 5 lines

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.

Sorry for not to fully addressed previous comments, I will corrected in this version.

Quoted 56 lines
Quoted 43 lines
(quoted diff) +0 -0

a/Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml b/Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml new file mode 100644
index 000000000000..d238cf3b8b47

Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml new file +34 -0
@@ -0,0 +1,161 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) %YAML 1.2
+---
+$id: http://devicetree.org/schemas/mmc/realtek-dw-mshc.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.
+
+allOf:
+  - $ref: synopsys-dw-mshc-common.yaml#
+
+maintainers:
+  - Jyan Chou <[email protected]>
+
+properties:
+  compatible:
+    enum:
+      - realtek,rtd1325-dw-cqe-emmc
+
+  reg:
+    maxItems: 2
+    description:
+      Two regs are required, first reg specifies emmc base address, second reg
+      specifies cqhci base register address.
+
+  reg-names:
+    maxItems: 2
+    items:
+      - const: emmc

Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml line 44

Quoted 10 lines
Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml new file +10 -0
+     - const: cqhci
+ 
+  interrupts:
+    maxItems: 1
+
+  cqe:
+    maxItems: 1
+    description:
+      Cqe should set to 1 while using command queue feature, and set to 0 while
+      in legacy mode.

Did you just ignore Rob's comment?

Quoted 1 line

Please point me where and how did you address it?

Sorry for not fixing this error. We had removed cqe and used common properties related to CQE.

Quoted 5 lines

Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml line 47

Quoted 3 lines
Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml new file +3 -0
+
+  clocks:
+    minItems: 2

No, why?

We had the wrong use of this and had corrected it.

Quoted 11 lines

Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml line 55

Quoted 9 lines
Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml new file +9 -0
+    items:
+      - description: bus interface unit clock
+      - description: card interface unit clock
+      - description: select the phase for vpclk0 in realtek chip specified
+      - description: select the phase for vpclk1 in realtek chip 
+ specified
+
+  clock-names:
+    minItems: 2

No, why?

We had the wrong use of this and had corrected it.

Quoted 5 lines
Quoted 5 lines
Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml new file +5 -0
+    items:
+      - const: biu
+      - const: ciu
+      - const: vp0
+      - const: vp1
Quoted 8 lines

Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml line 66

Quoted 6 lines
Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml new file +6 -0
+
+  resets:
+    maxItems: 1
+
+  reset-names:
+    const: reset

You ignored my feedback. NAK.

Sorry. We had dropped it.

Quoted 58 lines
Quoted 45 lines
Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml new file +45 -0
+
+  pinctrl-0:
+    description:
+      should contain default/high speed pin ctrl.
+    maxItems: 1
+
+  pinctrl-1:
+    description:
+      should contain sdr50 mode 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

Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml line 121

Quoted 10 lines
Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml new file +10 -0
+
+  pinctrl-9:
+    description:
+      should contain tune4 pin ctrl.
+    maxItems: 1
+
+  pinctrl-names:
+    maxItems: 10
+
+  required:

This wasn't even tested.

Quoted 1 line

Do not send untested, broken code. Please run make dt_binding_check (see Documentation/devicetree/bindings/writing-schema.rst for instructions). Maybe you need to update your dtschema and yamllint.

We had tested it with make dt_binding_check to ensure it is not a broken code.

Quoted 43 lines
Quoted 32 lines
Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml new file +30 -0
+    - compatible
+    - reg
+    - reg-names
+    - interrupts
+    - clocks
+    - clock-names
+    - pinctrl-names
+
+  unevaluatedProperties: false
+
+  examples:
 
 
+    - |
+      emmc: mmc@12000 {
+        compatible = "realtek,rtd1325-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";
+        clock-freq-min-max = <300000 400000000>;
+        clock-frequency = <400000>;
+        vmmc-supply = <&reg_vcc1v8>;
+        resets = <&rst 20>;
+        reset-names = "reset";
+        speed-step = <3>;
+        cqe = <1>;
+        pinctrl-names = "default", "sdr50", "ddr50", "hs200", "hs400",
+                        "tune0","tune1", "tune2","tune3", "tune4";
+        pinctrl-0 = <&emmc_pins_sdr50>;

Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml line 161

Quoted 10 lines
Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml new file +10 -0
+        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>;
+        };
Quoted 1 line

Broken indentation.

We had corrected the wrong indentation in our new version.

Best regards,
Jyan

-----Original Message-----
From: Krzysztof Kozlowski <[email protected]>
Sent: Thursday, November 2, 2023 3:14 PM
To: Jyan Chou [周芷安] <[email protected]>; [email protected]; [email protected]; [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]
Subject: Re: [PATCH V4][4/4] dt-bindings: mmc: Add dt-bindings for realtek mmc driver

External mail.

Quoted 6 lines · Jyan Chou [周芷安]

Hi Krzysztof, Rob,

Thanks for your code review and advice.

Quoted 1 line

What? I asked to be the same.

Respond inline, not by copying some pieces out of context to another part of email. That's not mailing list style response.

Best regards,
Krzysztof

maintainer
#18 lore raw

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

In reply to Jyan Chou
Quoted 16 lines · Jyan Chou

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

---
v3 -> v4:
- Rename compatible(add SoC-specific part) to be different from filename.
- 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.

Quoted 8 lines

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

---
 .../bindings/mmc/realtek-dw-mshc.yaml         | 161 ++++++++++++++++++
 1 file changed, 161 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml: properties:required: ['compatible', 'reg', 'reg-names', 'interrupts', 'clocks', 'clock-names', 'pinctrl-names'] is not of type 'object', 'boolean'
from schema $id: http://json-schema.org/draft-07/schema#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml: properties:examples: ['emmc: mmc@12000 {\n compatible = "realtek,rtd1325-dw-cqe-emmc";\n reg = <0x00012000 0x00600>,\n <0x00012180 0x00060>;\n reg-names = "emmc", "cqhci";\n interrupts = <0 42 4>;\n clocks = <&cc 22>, <&cc 26>, <&cc 121>, <&cc 122>;\n clock-names = "biu", "ciu", "vp0", "vp1";\n clock-freq-min-max = <300000 400000000>;\n clock-frequency = <400000>;\n vmmc-supply = <&reg_vcc1v8>;\n resets = <&rst 20>;\n reset-names = "reset";\n speed-step = <3>;\n cqe = <1>;\n pinctrl-names = "default", "sdr50", "ddr50", "hs200", "hs400",\n "tune0","tune1", "tune2","tune3", "tune4";\n pinctrl-0 = <&emmc_pins_sdr50>;\n pinctrl-1 = <&emmc_pins_sdr50>;\n pinctrl-2 = <&emmc_pins_ddr50>;\n pinctrl-3 = <&emmc_pins_hs200>;\n pinctrl-4 = <&emmc_pins_hs400>;\n pinctrl-5 = <&emmc_pins_tune0>;\n pinctrl-6 = <&emmc_pins_tune1>;\n pinctrl-7 = <&emmc_pins_tu
ne2>;\n pinctrl-8 = <&emmc_pins_tune3>;\n pinctrl-9 = <&emmc_pins_tune4>;\n };\n'] is not of type 'object', 'boolean'
from schema $id: http://json-schema.org/draft-07/schema#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml: properties: 'required' should not be valid under {'$ref': '#/definitions/json-schema-prop-names'}
hint: A json-schema keyword was found instead of a DT property name.
from schema $id: http://devicetree.org/meta-schemas/keywords.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml: properties: 'unevaluatedProperties' should not be valid under {'$ref': '#/definitions/json-schema-prop-names'}
hint: A json-schema keyword was found instead of a DT property name.
from schema $id: http://devicetree.org/meta-schemas/keywords.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml: properties:required: ['compatible', 'reg', 'reg-names', 'interrupts', 'clocks', 'clock-names', 'pinctrl-names'] is not of type 'object', 'boolean'
from schema $id: http://devicetree.org/meta-schemas/keywords.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml: properties:reg-names: {'maxItems': 2, 'items': [{'const': 'emmc'}, {'const': 'cqhci'}]} should not be valid under {'required': ['maxItems']}
hint: "maxItems" is not needed with an "items" list
from schema $id: http://devicetree.org/meta-schemas/items.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml: properties:examples: ['emmc: mmc@12000 {\n compatible = "realtek,rtd1325-dw-cqe-emmc";\n reg = <0x00012000 0x00600>,\n <0x00012180 0x00060>;\n reg-names = "emmc", "cqhci";\n interrupts = <0 42 4>;\n clocks = <&cc 22>, <&cc 26>, <&cc 121>, <&cc 122>;\n clock-names = "biu", "ciu", "vp0", "vp1";\n clock-freq-min-max = <300000 400000000>;\n clock-frequency = <400000>;\n vmmc-supply = <&reg_vcc1v8>;\n resets = <&rst 20>;\n reset-names = "reset";\n speed-step = <3>;\n cqe = <1>;\n pinctrl-names = "default", "sdr50", "ddr50", "hs200", "hs400",\n "tune0","tune1", "tune2","tune3", "tune4";\n pinctrl-0 = <&emmc_pins_sdr50>;\n pinctrl-1 = <&emmc_pins_sdr50>;\n pinctrl-2 = <&emmc_pins_ddr50>;\n pinctrl-3 = <&emmc_pins_hs200>;\n pinctrl-4 = <&emmc_pins_hs400>;\n pinctrl-5 = <&emmc_pins_tune0>;\n pinctrl-6 = <&emmc_pins_tune1>;\n pinctrl-7 = <&emmc_pins_tu
ne2>;\n pinctrl-8 = <&emmc_pins_tune3>;\n pinctrl-9 = <&emmc_pins_tune4>;\n };\n'] is not of type 'object', 'boolean'
from schema $id: http://devicetree.org/meta-schemas/keywords.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml: 'oneOf' conditional failed, one must be fixed:
'unevaluatedProperties' is a required property
'additionalProperties' is a required property
hint: Either unevaluatedProperties or additionalProperties must be present
from schema $id: http://devicetree.org/meta-schemas/core.yaml#
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/mmc/realtek-dw-mshc.yaml: cqe: missing type definition

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]

The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.