Skip to contentSkip to conversation

Add DesignWare Mobile mmc driver

PATCH Superseded Jyan Chou 2 participants 12 messages Nov 2, 2023 – Nov 9, 2023

Subsystems (4)

v5 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Jyan Chou

author
#0 lore raw

v5 cover Add DesignWare Mobile mmc driver

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

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

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

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

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

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

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

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

---
 drivers/mmc/host/cqhci-core.c | 8 +++++++-
 drivers/mmc/host/cqhci.h      | 8 ++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)
drivers/mmc/host/cqhci-core.c +7 -1
index b3d7d6d8d654..a0ec1559c42b 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_GPL(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 +8 -0
index 1a12e40a02e6..c3b9dbe60cc3 100644
@@ -216,6 +216,7 @@ union cqhci_crypto_cfg_entry {
 struct cqhci_host_ops;
 struct mmc_host;
 struct mmc_request;
+struct mmc_data;
 struct cqhci_slot;
 
 struct cqhci_host {
@@ -293,6 +294,11 @@ struct cqhci_host_ops {
 	int (*program_key)(struct cqhci_host *cq_host,
 			   const union cqhci_crypto_cfg_entry *cfg, int slot);
 #endif
+
+#ifdef CONFIG_MMC_DW_CQE
+	void (*setup_tran_desc)(struct mmc_data *data,
+				struct cqhci_host *cq_host, u8 *desc, int sg_count);
+#endif
 };
 
 static inline void cqhci_writel(struct cqhci_host *host, u32 val, int reg)
@@ -322,6 +328,8 @@ static inline int cqhci_suspend(struct mmc_host *mmc)
 {
 	return cqhci_deactivate(mmc);
 }
+
+void cqhci_set_tran_desc(u8 *desc, dma_addr_t addr, int len, bool end, bool dma64);
 int cqhci_resume(struct mmc_host *mmc);
 
 #endif
Signature · 1 line
2.42.0
author
#2 lore raw

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

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

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

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

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

---
 drivers/mmc/host/Kconfig      |   13 +
 drivers/mmc/host/Makefile     |    1 +
 drivers/mmc/host/dw_mmc_cqe.c | 1536 +++++++++++++++++++++++++++++++++
 drivers/mmc/host/dw_mmc_cqe.h |  456 ++++++++++
 4 files changed, 2006 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 554e67103c1a..173541da7de8 100644
@@ -828,6 +828,19 @@ config MMC_DW_STARFIVE
 	  This selects support for StarFive JH7110 SoC specific extensions to the
 	  Synopsys DesignWare Memory Card Interface driver. Select this option
 	  for platforms based on StarFive JH7110 SoC.
+
+config MMC_DW_CQE
+	tristate "Synopsys DesignWare Memory Card with CQE Interface"
+	depends on ARC || ARM || ARM64 || MIPS || COMPILE_TEST
+	select MMC_CQHCI
+	help
+	 This selects support for the Synopsys DesignWare Mobile Storage IP
+	 block after JEDEC Standard version 5.1. Select this option for SD and
+	 MMC interfaces that use command queue.
+
+	 If you have a controller with this interface, say Y or M here.
+
+	 If unsure, say Y.
 
 config MMC_SH_MMCIF
 	tristate "SuperH Internal MMCIF support"
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 +1536 -0

1,536 lines not on this page · raw message

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

456 lines not on this page · raw message

Signature · 1 line
2.42.0
#3 lore raw

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

Quoted 10 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 12 lines
drivers/mmc/host/dw_mmc_cqe.c new file +12 -0
+	for (i = 0; i < host->dma_nents; i++, sg++) {
+		dma_len = sg_dma_len(sg);
+
+		/* blk_cnt must be the multiple of 512(0x200) */
+		if (dma_len < SZ_512)
+			blk_cnt = 1;
+		else
+			blk_cnt  = dma_len >> 9;
+
+		remain_blk_cnt  = blk_cnt;
+		dma_addr = sg_dma_address(sg);
+

drivers/mmc/host/dw_mmc_cqe.c line 506

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe.c new file +10 -0
+		while (remain_blk_cnt) {
+			/* DW_MCI_MAX_SCRIPT_BLK is the max
+			 * for each descriptor record
+			 */
+			if (remain_blk_cnt > DW_MCI_MAX_SCRIPT_BLK)
+				cur_blk_cnt = DW_MCI_MAX_SCRIPT_BLK;
+			else
+				cur_blk_cnt = remain_blk_cnt;
+
+			/* In Synopsys DesignWare Databook Page 84,

/*
*

I mentioned it last time. Use Linux coding style. For entire patchset.

Quoted 28 lines
drivers/mmc/host/dw_mmc_cqe.c new file +28 -0
+			 * They mentioned the DMA 128MB restriction
+			 */
+			begin = dma_addr / SZ_128M;
+			end = (dma_addr + cur_blk_cnt * SZ_512) / SZ_128M;
+
+			/* If begin and end in the different 128MB memory zone */
+			if (begin != end)
+				cur_blk_cnt = (end * SZ_128M - dma_addr) / SZ_512;
+
+			if (dma_len < SZ_512)
+				tmp_val = ((dma_len) << 16) | VALID(0x1) | ACT(0x4);
+			else
+				tmp_val = ((cur_blk_cnt & 0x7f) << 25) | VALID(0x1) | ACT(0x4);
+
+			/* Last descriptor */
+			if (i == host->dma_nents - 1 && remain_blk_cnt == cur_blk_cnt)
+				tmp_val |= END(0x1);
+
+			desc_base[0] =  tmp_val;
+			desc_base[1] =  dma_addr;
+
+			dma_addr = dma_addr + (cur_blk_cnt << 9);
+			remain_blk_cnt -= cur_blk_cnt;
+			desc_base += 2;
+		}
+	}
+}
+

...

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

drivers/mmc/host/dw_mmc_cqe.c line 1295

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe.c new file +10 -0
+	const struct dw_mci_drv_data *drv_data = host->drv_data;
+	int ret;
+	u32 clock_frequency;
+
+	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
+	if (!pdata)
+		return ERR_PTR(-ENOMEM);
+
+	/* find reset controller when exist */
+	pdata->rstc = devm_reset_control_get_optional(dev, "reset");

Where is it described in the bindings?

drivers/mmc/host/dw_mmc_cqe.c line 1301

Quoted 6 lines
drivers/mmc/host/dw_mmc_cqe.c new file +6 -0
+	if (IS_ERR(pdata->rstc)) {
+		if (PTR_ERR(pdata->rstc) == -EPROBE_DEFER)
+			return ERR_PTR(-EPROBE_DEFER);
+	}
+
+	device_property_read_u32(dev, "card-detect-delay",

Where is it described in the bindings? It's not. This is v5 but, sorry, but I do not see much improvements. You still send code which clearly is wrong.

drivers/mmc/host/dw_mmc_cqe.c line 1305

Quoted 4 lines
drivers/mmc/host/dw_mmc_cqe.c new file +4 -0
+				 &pdata->detect_delay_ms);
+
+	if (!device_property_read_u32(dev, "clock-frequency", &clock_frequency))
+		pdata->bus_hz = clock_frequency;

Drop property. I don't think it is needed. MMC and CCF has other ways to do it.

Quoted 67 lines
drivers/mmc/host/dw_mmc_cqe.c new file +67 -0
+
+	if (drv_data && drv_data->parse_dt) {
+		ret = drv_data->parse_dt(host);
+		if (ret)
+			return ERR_PTR(ret);
+	}
+
+	return pdata;
+}
+
+#else /* CONFIG_OF */
+static struct dw_mci_board *dw_mci_cqe_parse_dt(struct dw_mci *host)
+{
+	return ERR_PTR(-EINVAL);
+}
+#endif /* CONFIG_OF */
+
+static void dw_mci_cqe_cto_timer(struct timer_list *t)
+{
+	struct dw_mci *host = from_timer(host, t, timer);
+
+	if (host->int_waiting) {
+		dev_err(host->dev, "fired, opcode=%d, arg=0x%x, irq status=0x%x, err irq=0x%x, auto err irq=0x%x\n",
+			host->opcode, host->arg,
+			host->normal_interrupt, host->error_interrupt,
+			host->auto_error_interrupt);
+
+		dw_mci_clr_signal_int(host);
+		dw_mci_get_int(host);
+
+		complete(host->int_waiting);
+	}
+}
+
+static void dw_mci_cqhci_init(struct dw_mci *host)
+{
+	if (host->pdata && (host->pdata->caps2 & MMC_CAP2_CQE)) {
+		host->cqe = cqhci_pltfm_init(host->pdev);
+		if (PTR_ERR(host->cqe) == -EINVAL ||
+		    PTR_ERR(host->cqe) == -ENOMEM ||
+		    PTR_ERR(host->cqe) == -EBUSY) {
+			dev_err(host->dev, "Unable to get the cmdq related attribute,err = %ld\n",
+				PTR_ERR(host->cqe));
+			host->cqe = 0;
+			host->pdata->caps2 &= ~(MMC_CAP2_CQE | MMC_CAP2_CQE_DCMD);
+		} else {
+			host->cqe->ops = &dw_mci_cqhci_host_ops;
+			cqhci_init(host->cqe, host->slot->mmc, 0);
+		}
+	}
+}
+
+int dw_mci_cqe_probe(struct dw_mci *host)
+{
+	const struct dw_mci_drv_data *drv_data = host->drv_data;
+	int ret = 0;
+
+	if (!host->pdata) {
+		host->pdata = dw_mci_cqe_parse_dt(host);
+		if (PTR_ERR(host->pdata) == -EPROBE_DEFER) {
+			return -EPROBE_DEFER;
+		} else if (IS_ERR(host->pdata)) {
+			dev_err(host->dev, "platform data not available\n");
+			return -EINVAL;
+		}
+	}
+

drivers/mmc/host/dw_mmc_cqe.c line 1382

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe.c new file +10 -0
+	host->biu_clk = devm_clk_get(host->dev, "biu");
+	if (IS_ERR(host->biu_clk)) {
+		dev_dbg(host->dev, "biu clock not available\n");
+	} else {
+		ret = clk_prepare_enable(host->biu_clk);
+		if (ret) {
+			dev_err(host->dev, "failed to enable biu clock\n");
+			return ret;
+		}
+	}

All this should be probably devm_clk_get_enabled().

Quoted 9 lines
drivers/mmc/host/dw_mmc_cqe.c new file +9 -0
+
+	host->ciu_clk = devm_clk_get(host->dev, "ciu");
+	if (IS_ERR(host->ciu_clk)) {
+		dev_dbg(host->dev, "ciu clock not available\n");
+		host->bus_hz = host->pdata->bus_hz;
+	} else {
+		ret = clk_prepare_enable(host->ciu_clk);
+		if (ret) {
+			dev_err(host->dev, "failed to enable ciu clock\n");

drivers/mmc/host/dw_mmc_cqe.c line 1401

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe.c new file +10 -0
+			goto err_clk_biu;
+		}
+
+		if (host->pdata->bus_hz) {
+			ret = clk_set_rate(host->ciu_clk, host->pdata->bus_hz);
+			if (ret)
+				dev_warn(host->dev,
+					 "Unable to set bus rate to %uHz\n",
+					 host->pdata->bus_hz);
+		}

All this should be probably devm_clk_get_enabled().

drivers/mmc/host/dw_mmc_cqe.c line 1402

Quoted 1 line
drivers/mmc/host/dw_mmc_cqe.c new file +1 -0
+		host->bus_hz = clk_get_rate(host->ciu_clk);

So this proves that your property clock-frequency is useless.

Quoted 55 lines
drivers/mmc/host/dw_mmc_cqe.c new file +55 -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);
+	spin_lock_init(&host->irq_lock);
+	init_rwsem(&host->cr_rw_sem);
+	tasklet_init(&host->tasklet, dw_mci_cqe_tasklet_func, (unsigned long)host);
+
+	dw_mci_cqe_setup(host);
+
+	dw_mci_cqe_init_dma(host);
+
+	host->tuning = 0;
+	host->current_speed = 0;
+
+	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;
+	}
+
+	ret = devm_request_irq(host->dev, host->irq, dw_mci_cqe_interrupt,
+			       host->irq_flags, "dw-mci-cqe", host);
+	if (ret)
+		goto err_dmaunmap;
+
+	dw_mci_cqhci_init(host);
+
+	return 0;
+
+err_dmaunmap:
+	if (!IS_ERR(host->pdata->rstc))

drivers/mmc/host/dw_mmc_cqe.c line 1467

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe.c new file +10 -0
+		reset_control_assert(host->pdata->rstc);
+err_clk_ciu:
+	clk_disable_unprepare(host->ciu_clk);
+
+err_clk_biu:
+	clk_disable_unprepare(host->biu_clk);
+
+	return ret;
+}
+EXPORT_SYMBOL(dw_mci_cqe_probe);

EXPORT_SYMBOL_GPL

I should have been more explicit:
EXPORT_SYMBOL_GPL everywhere. In this patchset and all your future patchsets. For all your current and future code.

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

drivers/mmc/host/dw_mmc_cqe.c line 1481

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe.c new file +10 -0
+		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);
+

Best regards,
Krzysztof

#4 lore raw

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

Hi Krzysztof,

Quoted 39 lines
Quoted 10 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 12 lines
drivers/mmc/host/dw_mmc_cqe.c new file +12 -0
+     for (i = 0; i < host->dma_nents; i++, sg++) {
+             dma_len = sg_dma_len(sg);
+
+             /* blk_cnt must be the multiple of 512(0x200) */
+             if (dma_len < SZ_512)
+                     blk_cnt = 1;
+             else
+                     blk_cnt  = dma_len >> 9;
+
+             remain_blk_cnt  = blk_cnt;
+             dma_addr = sg_dma_address(sg);
+

drivers/mmc/host/dw_mmc_cqe.c line 506

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe.c new file +10 -0
+             while (remain_blk_cnt) {
+                     /* DW_MCI_MAX_SCRIPT_BLK is the max
+                      * for each descriptor record
+                      */
+                     if (remain_blk_cnt > DW_MCI_MAX_SCRIPT_BLK)
+                             cur_blk_cnt = DW_MCI_MAX_SCRIPT_BLK;
+                     else
+                             cur_blk_cnt = remain_blk_cnt;
+
+                     /* In Synopsys DesignWare Databook Page 84,

/*
*

Quoted 1 line

I mentioned it last time. Use Linux coding style. For entire patchset.

Thanks for your remind. Sorry for didn't correct some of Linux coding style error.

Quoted 44 lines
Quoted 31 lines
drivers/mmc/host/dw_mmc_cqe.c new file +31 -0
+                      * They mentioned the DMA 128MB restriction
+                      */
+                     begin = dma_addr / SZ_128M;
+                     end = (dma_addr + cur_blk_cnt * SZ_512) / 
+ SZ_128M;
+
+                     /* If begin and end in the different 128MB memory zone */
+                     if (begin != end)
+                             cur_blk_cnt = (end * SZ_128M - dma_addr) 
+ / SZ_512;
+
+                     if (dma_len < SZ_512)
+                             tmp_val = ((dma_len) << 16) | VALID(0x1) | ACT(0x4);
+                     else
+                             tmp_val = ((cur_blk_cnt & 0x7f) << 25) | 
+ VALID(0x1) | ACT(0x4);
+
+                     /* Last descriptor */
+                     if (i == host->dma_nents - 1 && remain_blk_cnt == cur_blk_cnt)
+                             tmp_val |= END(0x1);
+
+                     desc_base[0] =  tmp_val;
+                     desc_base[1] =  dma_addr;
+
+                     dma_addr = dma_addr + (cur_blk_cnt << 9);
+                     remain_blk_cnt -= cur_blk_cnt;
+                     desc_base += 2;
+             }
+     }
+}
+

...

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

drivers/mmc/host/dw_mmc_cqe.c line 1295

Quoted 6 lines
drivers/mmc/host/dw_mmc_cqe.c new file +6 -0
+     pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
+     if (!pdata)
+             return ERR_PTR(-ENOMEM);
+
+     /* find reset controller when exist */
+     pdata->rstc = devm_reset_control_get_optional(dev, "reset");

Where is it described in the bindings?

I will add it in new version and test it.

Quoted 8 lines

drivers/mmc/host/dw_mmc_cqe.c line 1301

Quoted 6 lines
drivers/mmc/host/dw_mmc_cqe.c new file +6 -0
+     if (IS_ERR(pdata->rstc)) {
+             if (PTR_ERR(pdata->rstc) == -EPROBE_DEFER)
+                     return ERR_PTR(-EPROBE_DEFER);
+     }
+
+     device_property_read_u32(dev, "card-detect-delay",

Where is it described in the bindings? It's not. This is v5 but, sorry, but I do not see much improvements. You still send code which clearly is wrong.

It doesn't need to be in the bindings, I will remove this useless code.

Quoted 6 lines

drivers/mmc/host/dw_mmc_cqe.c line 1305

Quoted 4 lines
drivers/mmc/host/dw_mmc_cqe.c new file +4 -0
+                              &pdata->detect_delay_ms);
+
+     if (!device_property_read_u32(dev, "clock-frequency", &clock_frequency))
+             pdata->bus_hz = clock_frequency;

Drop property. I don't think it is needed. MMC and CCF has other ways to do it.

Alright, I will drop it.

Quoted 68 lines
Quoted 68 lines
drivers/mmc/host/dw_mmc_cqe.c new file +68 -0
+
+     if (drv_data && drv_data->parse_dt) {
+             ret = drv_data->parse_dt(host);
+             if (ret)
+                     return ERR_PTR(ret);
+     }
+
+     return pdata;
+}
+
+#else /* CONFIG_OF */
+static struct dw_mci_board *dw_mci_cqe_parse_dt(struct dw_mci *host) 
+{
+     return ERR_PTR(-EINVAL);
+}
+#endif /* CONFIG_OF */
+
+static void dw_mci_cqe_cto_timer(struct timer_list *t) {
+     struct dw_mci *host = from_timer(host, t, timer);
+
+     if (host->int_waiting) {
+             dev_err(host->dev, "fired, opcode=%d, arg=0x%x, irq status=0x%x, err irq=0x%x, auto err irq=0x%x\n",
+                     host->opcode, host->arg,
+                     host->normal_interrupt, host->error_interrupt,
+                     host->auto_error_interrupt);
+
+             dw_mci_clr_signal_int(host);
+             dw_mci_get_int(host);
+
+             complete(host->int_waiting);
+     }
+}
+
+static void dw_mci_cqhci_init(struct dw_mci *host) {
+     if (host->pdata && (host->pdata->caps2 & MMC_CAP2_CQE)) {
+             host->cqe = cqhci_pltfm_init(host->pdev);
+             if (PTR_ERR(host->cqe) == -EINVAL ||
+                 PTR_ERR(host->cqe) == -ENOMEM ||
+                 PTR_ERR(host->cqe) == -EBUSY) {
+                     dev_err(host->dev, "Unable to get the cmdq related attribute,err = %ld\n",
+                             PTR_ERR(host->cqe));
+                     host->cqe = 0;
+                     host->pdata->caps2 &= ~(MMC_CAP2_CQE | MMC_CAP2_CQE_DCMD);
+             } else {
+                     host->cqe->ops = &dw_mci_cqhci_host_ops;
+                     cqhci_init(host->cqe, host->slot->mmc, 0);
+             }
+     }
+}
+
+int dw_mci_cqe_probe(struct dw_mci *host) {
+     const struct dw_mci_drv_data *drv_data = host->drv_data;
+     int ret = 0;
+
+     if (!host->pdata) {
+             host->pdata = dw_mci_cqe_parse_dt(host);
+             if (PTR_ERR(host->pdata) == -EPROBE_DEFER) {
+                     return -EPROBE_DEFER;
+             } else if (IS_ERR(host->pdata)) {
+                     dev_err(host->dev, "platform data not available\n");
+                     return -EINVAL;
+             }
+     }
+
+     host->biu_clk = devm_clk_get(host->dev, "biu");
+     if (IS_ERR(host->biu_clk)) {
+             dev_dbg(host->dev, "biu clock not available\n");
+     } else {
Quoted 8 lines

drivers/mmc/host/dw_mmc_cqe.c line 1382

Quoted 6 lines
drivers/mmc/host/dw_mmc_cqe.c new file +6 -0
+             ret = clk_prepare_enable(host->biu_clk);
+             if (ret) {
+                     dev_err(host->dev, "failed to enable biu clock\n");
+                     return ret;
+             }
+     }

All this should be probably devm_clk_get_enabled().

Thanks. We will correct it.

Quoted 13 lines
Quoted 13 lines
drivers/mmc/host/dw_mmc_cqe.c new file +13 -0
+
+     host->ciu_clk = devm_clk_get(host->dev, "ciu");
+     if (IS_ERR(host->ciu_clk)) {
+             dev_dbg(host->dev, "ciu clock not available\n");
+             host->bus_hz = host->pdata->bus_hz;
+     } else {
+             ret = clk_prepare_enable(host->ciu_clk);
+             if (ret) {
+                     dev_err(host->dev, "failed to enable ciu clock\n");
+                     goto err_clk_biu;
+             }
+
+             if (host->pdata->bus_hz) {
Quoted 8 lines

drivers/mmc/host/dw_mmc_cqe.c line 1401

Quoted 6 lines
drivers/mmc/host/dw_mmc_cqe.c new file +6 -0
+                     ret = clk_set_rate(host->ciu_clk, host->pdata->bus_hz);
+                     if (ret)
+                             dev_warn(host->dev,
+                                      "Unable to set bus rate to %uHz\n",
+                                      host->pdata->bus_hz);
+             }

All this should be probably devm_clk_get_enabled().

Thanks. We will correct it.

Quoted 3 lines
Quoted 1 line

+ host->bus_hz = clk_get_rate(host->ciu_clk);

 So this proves that your property clock-frequency is useless.

Yes... we will remove it in bindings.

Quoted 69 lines
Quoted 56 lines
drivers/mmc/host/dw_mmc_cqe.c new file +56 -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);
+     spin_lock_init(&host->irq_lock);
+     init_rwsem(&host->cr_rw_sem);
+     tasklet_init(&host->tasklet, dw_mci_cqe_tasklet_func, (unsigned 
+ long)host);
+
+     dw_mci_cqe_setup(host);
+
+     dw_mci_cqe_init_dma(host);
+
+     host->tuning = 0;
+     host->current_speed = 0;
+
+     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;
+     }
+
+     ret = devm_request_irq(host->dev, host->irq, dw_mci_cqe_interrupt,
+                            host->irq_flags, "dw-mci-cqe", host);
+     if (ret)
+             goto err_dmaunmap;
+
+     dw_mci_cqhci_init(host);
+
+     return 0;
+
+err_dmaunmap:
+     if (!IS_ERR(host->pdata->rstc))

drivers/mmc/host/dw_mmc_cqe.c line 1467

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe.c new file +10 -0
+             reset_control_assert(host->pdata->rstc);
+err_clk_ciu:
+     clk_disable_unprepare(host->ciu_clk);
+
+err_clk_biu:
+     clk_disable_unprepare(host->biu_clk);
+
+     return ret;
+}
+EXPORT_SYMBOL(dw_mci_cqe_probe);

EXPORT_SYMBOL_GPL

Quoted 2 lines

I should have been more explicit:
EXPORT_SYMBOL_GPL everywhere. In this patchset and all your future patchsets. For all your current and future code.

Thanks. We will use EXPORT_SYMBOL_GPL in all our patchset.

Quoted 5 lines
Quoted 5 lines
drivers/mmc/host/dw_mmc_cqe.c new file +5 -0
+
+void dw_mci_cqe_remove(struct dw_mci *host) {
+     if (host->slot)
+             dw_mci_cqe_cleanup_slot(host->slot); 
+
Quoted 8 lines

drivers/mmc/host/dw_mmc_cqe.c line 1481

Quoted 8 lines
drivers/mmc/host/dw_mmc_cqe.c new file +8 -0
+     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);
+

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

External mail.

Quoted 10 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 12 lines
drivers/mmc/host/dw_mmc_cqe.c new file +12 -0
+     for (i = 0; i < host->dma_nents; i++, sg++) {
+             dma_len = sg_dma_len(sg);
+
+             /* blk_cnt must be the multiple of 512(0x200) */
+             if (dma_len < SZ_512)
+                     blk_cnt = 1;
+             else
+                     blk_cnt  = dma_len >> 9;
+
+             remain_blk_cnt  = blk_cnt;
+             dma_addr = sg_dma_address(sg);
+

drivers/mmc/host/dw_mmc_cqe.c line 506

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe.c new file +10 -0
+             while (remain_blk_cnt) {
+                     /* DW_MCI_MAX_SCRIPT_BLK is the max
+                      * for each descriptor record
+                      */
+                     if (remain_blk_cnt > DW_MCI_MAX_SCRIPT_BLK)
+                             cur_blk_cnt = DW_MCI_MAX_SCRIPT_BLK;
+                     else
+                             cur_blk_cnt = remain_blk_cnt;
+
+                     /* In Synopsys DesignWare Databook Page 84,

/*
*

I mentioned it last time. Use Linux coding style. For entire patchset.

Quoted 31 lines
drivers/mmc/host/dw_mmc_cqe.c new file +31 -0
+                      * They mentioned the DMA 128MB restriction
+                      */
+                     begin = dma_addr / SZ_128M;
+                     end = (dma_addr + cur_blk_cnt * SZ_512) / 
+ SZ_128M;
+
+                     /* If begin and end in the different 128MB memory zone */
+                     if (begin != end)
+                             cur_blk_cnt = (end * SZ_128M - dma_addr) 
+ / SZ_512;
+
+                     if (dma_len < SZ_512)
+                             tmp_val = ((dma_len) << 16) | VALID(0x1) | ACT(0x4);
+                     else
+                             tmp_val = ((cur_blk_cnt & 0x7f) << 25) | 
+ VALID(0x1) | ACT(0x4);
+
+                     /* Last descriptor */
+                     if (i == host->dma_nents - 1 && remain_blk_cnt == cur_blk_cnt)
+                             tmp_val |= END(0x1);
+
+                     desc_base[0] =  tmp_val;
+                     desc_base[1] =  dma_addr;
+
+                     dma_addr = dma_addr + (cur_blk_cnt << 9);
+                     remain_blk_cnt -= cur_blk_cnt;
+                     desc_base += 2;
+             }
+     }
+}
+

...

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

drivers/mmc/host/dw_mmc_cqe.c line 1295

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe.c new file +10 -0
+     const struct dw_mci_drv_data *drv_data = host->drv_data;
+     int ret;
+     u32 clock_frequency;
+
+     pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
+     if (!pdata)
+             return ERR_PTR(-ENOMEM);
+
+     /* find reset controller when exist */
+     pdata->rstc = devm_reset_control_get_optional(dev, "reset");

Where is it described in the bindings?

drivers/mmc/host/dw_mmc_cqe.c line 1301

Quoted 6 lines
drivers/mmc/host/dw_mmc_cqe.c new file +6 -0
+     if (IS_ERR(pdata->rstc)) {
+             if (PTR_ERR(pdata->rstc) == -EPROBE_DEFER)
+                     return ERR_PTR(-EPROBE_DEFER);
+     }
+
+     device_property_read_u32(dev, "card-detect-delay",

Where is it described in the bindings? It's not. This is v5 but, sorry, but I do not see much improvements. You still send code which clearly is wrong.

drivers/mmc/host/dw_mmc_cqe.c line 1305

Quoted 4 lines
drivers/mmc/host/dw_mmc_cqe.c new file +4 -0
+                              &pdata->detect_delay_ms);
+
+     if (!device_property_read_u32(dev, "clock-frequency", &clock_frequency))
+             pdata->bus_hz = clock_frequency;

Drop property. I don't think it is needed. MMC and CCF has other ways to do it.

Quoted 64 lines
drivers/mmc/host/dw_mmc_cqe.c new file +64 -0
+
+     if (drv_data && drv_data->parse_dt) {
+             ret = drv_data->parse_dt(host);
+             if (ret)
+                     return ERR_PTR(ret);
+     }
+
+     return pdata;
+}
+
+#else /* CONFIG_OF */
+static struct dw_mci_board *dw_mci_cqe_parse_dt(struct dw_mci *host) 
+{
+     return ERR_PTR(-EINVAL);
+}
+#endif /* CONFIG_OF */
+
+static void dw_mci_cqe_cto_timer(struct timer_list *t) {
+     struct dw_mci *host = from_timer(host, t, timer);
+
+     if (host->int_waiting) {
+             dev_err(host->dev, "fired, opcode=%d, arg=0x%x, irq status=0x%x, err irq=0x%x, auto err irq=0x%x\n",
+                     host->opcode, host->arg,
+                     host->normal_interrupt, host->error_interrupt,
+                     host->auto_error_interrupt);
+
+             dw_mci_clr_signal_int(host);
+             dw_mci_get_int(host);
+
+             complete(host->int_waiting);
+     }
+}
+
+static void dw_mci_cqhci_init(struct dw_mci *host) {
+     if (host->pdata && (host->pdata->caps2 & MMC_CAP2_CQE)) {
+             host->cqe = cqhci_pltfm_init(host->pdev);
+             if (PTR_ERR(host->cqe) == -EINVAL ||
+                 PTR_ERR(host->cqe) == -ENOMEM ||
+                 PTR_ERR(host->cqe) == -EBUSY) {
+                     dev_err(host->dev, "Unable to get the cmdq related attribute,err = %ld\n",
+                             PTR_ERR(host->cqe));
+                     host->cqe = 0;
+                     host->pdata->caps2 &= ~(MMC_CAP2_CQE | MMC_CAP2_CQE_DCMD);
+             } else {
+                     host->cqe->ops = &dw_mci_cqhci_host_ops;
+                     cqhci_init(host->cqe, host->slot->mmc, 0);
+             }
+     }
+}
+
+int dw_mci_cqe_probe(struct dw_mci *host) {
+     const struct dw_mci_drv_data *drv_data = host->drv_data;
+     int ret = 0;
+
+     if (!host->pdata) {
+             host->pdata = dw_mci_cqe_parse_dt(host);
+             if (PTR_ERR(host->pdata) == -EPROBE_DEFER) {
+                     return -EPROBE_DEFER;
+             } else if (IS_ERR(host->pdata)) {
+                     dev_err(host->dev, "platform data not available\n");
+                     return -EINVAL;
+             }
+     }
+

drivers/mmc/host/dw_mmc_cqe.c line 1382

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe.c new file +10 -0
+     host->biu_clk = devm_clk_get(host->dev, "biu");
+     if (IS_ERR(host->biu_clk)) {
+             dev_dbg(host->dev, "biu clock not available\n");
+     } else {
+             ret = clk_prepare_enable(host->biu_clk);
+             if (ret) {
+                     dev_err(host->dev, "failed to enable biu clock\n");
+                     return ret;
+             }
+     }

All this should be probably devm_clk_get_enabled().

Quoted 9 lines
drivers/mmc/host/dw_mmc_cqe.c new file +9 -0
+
+     host->ciu_clk = devm_clk_get(host->dev, "ciu");
+     if (IS_ERR(host->ciu_clk)) {
+             dev_dbg(host->dev, "ciu clock not available\n");
+             host->bus_hz = host->pdata->bus_hz;
+     } else {
+             ret = clk_prepare_enable(host->ciu_clk);
+             if (ret) {
+                     dev_err(host->dev, "failed to enable ciu clock\n");

drivers/mmc/host/dw_mmc_cqe.c line 1401

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe.c new file +10 -0
+                     goto err_clk_biu;
+             }
+
+             if (host->pdata->bus_hz) {
+                     ret = clk_set_rate(host->ciu_clk, host->pdata->bus_hz);
+                     if (ret)
+                             dev_warn(host->dev,
+                                      "Unable to set bus rate to %uHz\n",
+                                      host->pdata->bus_hz);
+             }

All this should be probably devm_clk_get_enabled().

Quoted 1 line

+ host->bus_hz = clk_get_rate(host->ciu_clk);

So this proves that your property clock-frequency is useless.

Quoted 56 lines
drivers/mmc/host/dw_mmc_cqe.c new file +56 -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);
+     spin_lock_init(&host->irq_lock);
+     init_rwsem(&host->cr_rw_sem);
+     tasklet_init(&host->tasklet, dw_mci_cqe_tasklet_func, (unsigned 
+ long)host);
+
+     dw_mci_cqe_setup(host);
+
+     dw_mci_cqe_init_dma(host);
+
+     host->tuning = 0;
+     host->current_speed = 0;
+
+     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;
+     }
+
+     ret = devm_request_irq(host->dev, host->irq, dw_mci_cqe_interrupt,
+                            host->irq_flags, "dw-mci-cqe", host);
+     if (ret)
+             goto err_dmaunmap;
+
+     dw_mci_cqhci_init(host);
+
+     return 0;
+
+err_dmaunmap:
+     if (!IS_ERR(host->pdata->rstc))

drivers/mmc/host/dw_mmc_cqe.c line 1467

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe.c new file +10 -0
+             reset_control_assert(host->pdata->rstc);
+err_clk_ciu:
+     clk_disable_unprepare(host->ciu_clk);
+
+err_clk_biu:
+     clk_disable_unprepare(host->biu_clk);
+
+     return ret;
+}
+EXPORT_SYMBOL(dw_mci_cqe_probe);

EXPORT_SYMBOL_GPL

I should have been more explicit:
EXPORT_SYMBOL_GPL everywhere. In this patchset and all your future patchsets. For all your current and future code.

drivers/mmc/host/dw_mmc_cqe.c line 1481

Quoted 13 lines
drivers/mmc/host/dw_mmc_cqe.c new file +13 -0
+
+void dw_mci_cqe_remove(struct dw_mci *host) {
+     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);
+

Best regards,
Krzysztof

author
#5 lore raw

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

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

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

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

---
 drivers/mmc/host/Kconfig          |   9 +
 drivers/mmc/host/Makefile         |   1 +
 drivers/mmc/host/dw_mmc_cqe-rtk.c | 802 ++++++++++++++++++++++++++++++
 drivers/mmc/host/dw_mmc_cqe-rtk.h | 160 ++++++
 4 files changed, 972 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 173541da7de8..72d5bb6d018f 100644
@@ -842,6 +842,15 @@ config MMC_DW_CQE
 
 	 If unsure, say Y.
 
+config MMC_DW_CQE_RTK
+	tristate "Realtek Soc's specific extensions for Synopsys DW Memory Card Interface"
+	depends on MMC_DW_CQE
+	select REGULATOR_FIXED_VOLTAGE
+	help
+	 This selects support for Realtek SoC specific extensions to the
+	 Synopsys DesignWare Memory Card Interface driver. Select this option
+	 for platforms after RTD16xxb SoC's.
+
 config MMC_SH_MMCIF
 	tristate "SuperH Internal MMCIF support"
 	depends on SUPERH || ARCH_RENESAS || COMPILE_TEST
drivers/mmc/host/Makefile +1 -0
index 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 +802 -0

802 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
#6 lore raw

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

Quoted 11 lines · Jyan Chou

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

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

It's merge window. Sending big patchset every day won't get you far.

Quoted 77 lines

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/dw_mmc_cqe-rtk.c new file +65 -0
+
+static int dw_mci_rtk_parse_dt(struct dw_mci *host)
+{
+	struct dw_mci_rtkemmc_host *priv;
+	const u32 *prop;
+	int size, ret;
+
+	priv = devm_kzalloc(host->dev, sizeof(*priv), GFP_KERNEL);
+	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");
+
+	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");
+	if (IS_ERR(priv->vp0))
+		dev_err_probe(host->dev, ret, "could not get vp0 clk\n");
+

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

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +10 -0
+	priv->vp1 = devm_clk_get(host->dev, "vp1");
+	if (IS_ERR(priv->vp1))
+		dev_err_probe(host->dev, ret, "could not get vp1 clk\n");
+
+	if (of_property_read_bool(host->dev->of_node, "supports-cqe"))
+		priv->is_cqe = 1;
+	else
+		priv->is_cqe = 0;
+
+	prop = of_get_property(host->dev->of_node, "rdq-ctrl", &size);

NAK

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

Quoted 8 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +8 -0
+	if (prop)
+		priv->rdq_ctrl = of_read_number(prop, 1);
+	else
+		priv->rdq_ctrl = 0;
+
+	priv->emmc_mode = 3;
+
+	priv->m2tmx = syscon_regmap_lookup_by_phandle(host->dev->of_node, "realtek,m2tmx");

NAK, for the same reasons I mentioned for other patch.

I will keep NAK-ing till you start testing your DTS.

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

Quoted 7 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +7 -0
+	if (IS_ERR_OR_NULL(priv->m2tmx))
+		dev_err_probe(host->dev, ret, "can not get m2mtx node.\n");
+
+	host->priv = priv;
+
+	return 0;
+}

Best regards,
Krzysztof

#7 lore raw

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

Hi Krzysztof,

Quoted 5 lines
Quoted 5 lines

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

Quoted 8 lines
Quoted 6 lines

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

It's merge window. Sending big patchset every day won't get you far.

Thanks for your remind.

Quoted 81 lines
Quoted 81 lines

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

v0 -> v1:
- Fix the compiler complains.
---

drivers/mmc/host/dw_mmc_cqe-rtk.c new file +70 -0
+
+static int dw_mci_rtk_parse_dt(struct dw_mci *host) {
+     struct dw_mci_rtkemmc_host *priv;
+     const u32 *prop;
+     int size, ret;
+
+     priv = devm_kzalloc(host->dev, sizeof(*priv), GFP_KERNEL);
+     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");
+
+     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");
+     if (IS_ERR(priv->vp0))
+             dev_err_probe(host->dev, ret, "could not get vp0 
+ clk\n");
+
+     priv->vp1 = devm_clk_get(host->dev, "vp1");
+     if (IS_ERR(priv->vp1))
+             dev_err_probe(host->dev, ret, "could not get vp1 
+ clk\n");
+
Quoted 8 lines

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

Quoted 6 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +6 -0
+     if (of_property_read_bool(host->dev->of_node, "supports-cqe"))
+             priv->is_cqe = 1;
+     else
+             priv->is_cqe = 0;
+
+     prop = of_get_property(host->dev->of_node, "rdq-ctrl", &size);

NAK

I will remove useless bindings.

Quoted 13 lines

drivers/mmc/host/dw_mmc_cqe-rtk.c

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +10 -0
+     if (prop)
+             priv->rdq_ctrl = of_read_number(prop, 1);
+     else
+             priv->rdq_ctrl = 0;
+
+     priv->emmc_mode = 3;
+
+     priv->m2tmx = 
+ syscon_regmap_lookup_by_phandle(host->dev->of_node, 
+ "realtek,m2tmx");

NAK, for the same reasons I mentioned for other patch.

Quoted 1 line

I will keep NAK-ing till you start testing your DTS.

Sorry, I am not sure whether I modify the correct thing you said. I will add

realtek,m2tmx in bindings.

Quoted 8 lines

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

Quoted 8 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +8 -0
+     if (IS_ERR_OR_NULL(priv->m2tmx))
+             dev_err_probe(host->dev, ret, "can not get m2mtx 
+ node.\n");
+
+     host->priv = priv;
+
+     return 0;
+}

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

External mail.

Quoted 11 lines · Jyan Chou

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

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

It's merge window. Sending big patchset every day won't get you far.

Quoted 78 lines

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/dw_mmc_cqe-rtk.c new file +66 -0
+
+static int dw_mci_rtk_parse_dt(struct dw_mci *host) {
+     struct dw_mci_rtkemmc_host *priv;
+     const u32 *prop;
+     int size, ret;
+
+     priv = devm_kzalloc(host->dev, sizeof(*priv), GFP_KERNEL);
+     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");
+
+     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");
+     if (IS_ERR(priv->vp0))
+             dev_err_probe(host->dev, ret, "could not get vp0 
+ clk\n");
+
+     priv->vp1 = devm_clk_get(host->dev, "vp1");

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

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +10 -0
+     if (IS_ERR(priv->vp1))
+             dev_err_probe(host->dev, ret, "could not get vp1 
+ clk\n");
+
+     if (of_property_read_bool(host->dev->of_node, "supports-cqe"))
+             priv->is_cqe = 1;
+     else
+             priv->is_cqe = 0;
+
+     prop = of_get_property(host->dev->of_node, "rdq-ctrl", &size);

NAK

drivers/mmc/host/dw_mmc_cqe-rtk.c

Quoted 10 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +10 -0
+     if (prop)
+             priv->rdq_ctrl = of_read_number(prop, 1);
+     else
+             priv->rdq_ctrl = 0;
+
+     priv->emmc_mode = 3;
+
+     priv->m2tmx = 
+ syscon_regmap_lookup_by_phandle(host->dev->of_node, 
+ "realtek,m2tmx");

NAK, for the same reasons I mentioned for other patch.

I will keep NAK-ing till you start testing your DTS.

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

Quoted 8 lines
drivers/mmc/host/dw_mmc_cqe-rtk.c new file +8 -0
+     if (IS_ERR_OR_NULL(priv->m2tmx))
+             dev_err_probe(host->dev, ret, "can not get m2mtx 
+ node.\n");
+
+     host->priv = priv;
+
+     return 0;
+}

Best regards,
Krzysztof

#8 lore raw

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

Quoted 11 lines · Jyan Chou [周芷安]
Quoted 7 lines
Quoted 3 lines

+ priv->m2tmx =
+ syscon_regmap_lookup_by_phandle(host->dev->of_node,
+ "realtek,m2tmx");

NAK, for the same reasons I mentioned for other patch.

I will keep NAK-ing till you start testing your DTS.

Sorry, I am not sure whether I modify the correct thing you said. I will add

realtek,m2tmx in bindings.

Upstream a tested DTS. I don't trust that you test it, so I need to see it.

Best regards,
Krzysztof

author
#9 lore raw

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

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

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

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

v1 -> v2:
- Add dt-bindings.

---
 .../bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml | 157 ++++++++++++++++++
 1 file changed, 157 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml new file +157 -0
new file mode 100644
index 000000000000..f422a216ff93
@@ -0,0 +1,157 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mmc/realtek,rtd-dw-cqe-emmc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Realtek DesignWare mobile storage host controller
+
+description:
+  Realtek uses the Synopsys DesignWare mobile storage host controller
+  to interface a SoC with storage medium. This file documents the Realtek
+  specific extensions.
+
+maintainers:
+  - Jyan Chou <[email protected]>
+
+allOf:
+  - $ref: mmc-controller.yaml#
+
+properties:
+  compatible:
+    enum:
+      - realtek,rtd-dw-cqe-emmc
+
+  reg:
+    items:
+      - description: emmc base address
+      - description: cqhci base address
+
+  reg-names:
+    items:
+      - const: emmc
+      - const: cqhci
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    description: Handles to input clocks
+
+  clock-names:
+    items:
+      - const: biu
+      - const: ciu
+      - const: vp0
+      - const: vp1
+
+  clock-frequency:
+    description:
+      Operating frequency of realtek emmc controller clock
+    minimum: 300000
+    maximum: 400000000
+
+  vmmc-supply:
+    description:
+      Handle to fixed-voltage supply for the card power.
+
+  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
+  - clock-frequency
+  - vmmc-supply
+  - pinctrl-names
+  - pinctrl-0
+  - pinctrl-1
+  - pinctrl-3
+  - pinctrl-4
+  - pinctrl-5
+  - pinctrl-6
+  - pinctrl-7
+  - pinctrl-8
+  - pinctrl-9
+
+additionalProperties: false
+
+examples:
+  - |
+    emmc: mmc@12000 {
+      compatible = "realtek,rtd-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-frequency = <400000>;
+      vmmc-supply = <&reg_vcc1v8>;
+      pinctrl-names = "default", "sdr50", "ddr50", "hs200", "hs400",
+                      "tune0","tune1", "tune2","tune3", "tune4";
+      pinctrl-0 = <&emmc_pins_sdr50>;
+      pinctrl-1 = <&emmc_pins_sdr50>;
+      pinctrl-2 = <&emmc_pins_ddr50>;
+      pinctrl-3 = <&emmc_pins_hs200>;
+      pinctrl-4 = <&emmc_pins_hs400>;
+      pinctrl-5 = <&emmc_pins_tune0>;
+      pinctrl-6 = <&emmc_pins_tune1>;
+      pinctrl-7 = <&emmc_pins_tune2>;
+      pinctrl-8 = <&emmc_pins_tune3>;
+      pinctrl-9 = <&emmc_pins_tune4>;
+    };
Signature · 1 line
2.42.0
#10 lore raw

Re: [PATCH V5][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.

---
v4 -> v5:
- Fix compatible to match filename.

That's not what I said. Filename must match compatible, not the other way around.

Quoted 39 lines

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

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

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

v1 -> v2:
- Add dt-bindings.

---
 .../bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml | 157 ++++++++++++++++++
 1 file changed, 157 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml new file +13 -0
new file mode 100644
index 000000000000..f422a216ff93
@@ -0,0 +1,157 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mmc/realtek,rtd-dw-cqe-emmc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Realtek DesignWare mobile storage host controller
+
+description:
+  Realtek uses the Synopsys DesignWare mobile storage host controller
+  to interface a SoC with storage medium. This file documents the Realtek
+  specific extensions.
+

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

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

I don't understand what happened here. I asked you to drop the incorrect, generic compatible. Instead you dropped specific compatibles and left generic. Nope, this does not work like it.

You *must* use specific compatibles.

Quoted 6 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml new file +6 -0
+
+  reg:
+    items:
+      - description: emmc base address
+      - description: cqhci base address
+

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

Quoted 10 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml new file +10 -0
+  reg-names:
+    items:
+      - const: emmc
+      - const: cqhci
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    description: Handles to input clocks

Instead: maxItems: 4

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

Quoted 11 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml new file +11 -0
+
+  clock-names:
+    items:
+      - const: biu
+      - const: ciu
+      - const: vp0
+      - const: vp1
+
+  clock-frequency:
+    description:
+      Operating frequency of realtek emmc controller clock

Drop entire property. There is already max-frequency.

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

Quoted 6 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml new file +6 -0
+    minimum: 300000
+    maximum: 400000000
+
+  vmmc-supply:
+    description:
+      Handle to fixed-voltage supply for the card power.

Drop entire property. Not needed.

Quoted 65 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml new file +65 -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
+
+  pinctrl-9:
+    description:
+      should contain tune4 pin ctrl.
+    maxItems: 1
+
+  pinctrl-names:
+    maxItems: 10
+
+required:
+  - compatible
+  - reg
+  - reg-names
+  - interrupts
+  - clocks
+  - clock-names
+  - clock-frequency
+  - vmmc-supply
+  - pinctrl-names
+  - pinctrl-0

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

Quoted 10 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml new file +10 -0
+  - pinctrl-1
+  - pinctrl-3
+  - pinctrl-4
+  - pinctrl-5
+  - pinctrl-6
+  - pinctrl-7
+  - pinctrl-8
+  - pinctrl-9
+
+additionalProperties: false

unevaluatedProperties: false

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

Quoted 11 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml new file +11 -0
+
+examples:
+  - |
+    emmc: mmc@12000 {
+      compatible = "realtek,rtd-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";

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

NAK, till you upstream your DTS.

Best regards,
Krzysztof

#11 lore raw

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

Quoted 4 lines
Quoted 2 lines

v4 -> v5:
- Fix compatible to match filename.

That's not what I said. Filename must match compatible, not the other way around.

Sorry for misunderstand your advice. We name our filename realtek,rtd-dw-cqe-emmc.yaml and correct our compatible to
compatible:
enum:
- realtek,rtd1325-dw-cqe-emmc
- realtek,rtd1319-dw-cqe-emmc
- realtek,rtd1315e-dw-cqe-emmc
- realtek,rtd1619b-dw-cqe-emmc
in new version.

Quoted 57 lines
Quoted 44 lines

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

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

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

v1 -> v2:
- Add dt-bindings.

---
 .../bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml | 157 
++++++++++++++++++
 1 file changed, 157 insertions(+)
 create mode 100644 

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

(quoted diff) +0 -0

a/Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml b/Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml new file mode 100644
index 000000000000..f422a216ff93

Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.ya new file +14 -0
+++ ml
@@ -0,0 +1,157 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) %YAML 1.2
+---
+$id: http://devicetree.org/schemas/mmc/realtek,rtd-dw-cqe-emmc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Realtek DesignWare mobile storage host controller
+
+description:
+  Realtek uses the Synopsys DesignWare mobile storage host controller
+  to interface a SoC with storage medium. This file documents the 
+Realtek
+  specific extensions.
+

Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.ya line 23

Quoted 10 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.ya new file +10 -0
+maintainers:
+  - Jyan Chou <[email protected]>
+
+allOf:
+  - $ref: mmc-controller.yaml#
+
+properties:
+  compatible:
+    enum:
+      - realtek,rtd-dw-cqe-emmc

I don't understand what happened here. I asked you to drop the incorrect, generic compatible. Instead you dropped specific compatibles and left generic. Nope, this does not work like it.

Quoted 1 line

You *must* use specific compatibles.

We change our compatible to be like realtek,rtd1325-dw-cqe-emmc.

Quoted 10 lines
Quoted 10 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.ya new file +10 -0
+
+  reg:
+    items:
+      - description: emmc base address
+      - description: cqhci base address
+
+  reg-names:
+    items:
+      - const: emmc
+      - const: cqhci
Quoted 8 lines

Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.ya line 39

Quoted 6 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.ya new file +6 -0
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    description: Handles to input clocks

Instead: maxItems: 4

Okay. I will add maxItems: 4.

Quoted 5 lines
Quoted 5 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.ya new file +5 -0
+
+  clock-names:
+    items:
+      - const: biu
+      - const: ciu
Quoted 8 lines

Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.ya line 50

Quoted 6 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.ya new file +6 -0
+      - const: vp0
+      - const: vp1
+
+  clock-frequency:
+    description:
+      Operating frequency of realtek emmc controller clock

Drop entire property. There is already max-frequency.

We will drop it in our new version.

Quoted 8 lines

Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.ya line 56

Quoted 6 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.ya new file +6 -0
+    minimum: 300000
+    maximum: 400000000
+
+  vmmc-supply:
+    description:
+      Handle to fixed-voltage supply for the card power.

Drop entire property. Not needed.

We will drop it.

Quoted 69 lines
Quoted 69 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.ya new file +69 -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
+
+  pinctrl-9:
+    description:
+      should contain tune4 pin ctrl.
+    maxItems: 1
+
+  pinctrl-names:
+    maxItems: 10
+
+required:
+  - compatible
+  - reg
+  - reg-names
+  - interrupts
+  - clocks
+  - clock-names
+  - clock-frequency
+  - vmmc-supply
+  - pinctrl-names
+  - pinctrl-0
+  - pinctrl-1
+  - pinctrl-3
+  - pinctrl-4
+  - pinctrl-5
Quoted 8 lines

Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.ya line 131

Quoted 6 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.ya new file +6 -0
+  - pinctrl-6
+  - pinctrl-7
+  - pinctrl-8
+  - pinctrl-9
+
+additionalProperties: false

unevaluatedProperties: false

I will replace additionalProperties: false with unevaluatedProperties: false.

Quoted 14 lines

Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.ya line 142

Quoted 11 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.ya new file +11 -0
+
+examples:
+  - |
+    emmc: mmc@12000 {
+      compatible = "realtek,rtd-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";

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

Quoted 1 line

NAK, till you upstream your DTS.

Okay, I will test it and push a correct one again. Thanks.

-----Original Message-----
From: Krzysztof Kozlowski <[email protected]>
Sent: Thursday, November 2, 2023 4:54 PM
To: Jyan Chou [周芷安] <[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]; [email protected]
Subject: Re: [PATCH V5][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.

---
v4 -> v5:
- Fix compatible to match filename.

That's not what I said. Filename must match compatible, not the other way around.

Quoted 44 lines

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

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

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

v1 -> v2:
- Add dt-bindings.

---
 .../bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml | 157 
++++++++++++++++++
 1 file changed, 157 insertions(+)
 create mode 100644 

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

(quoted diff) +0 -0

a/Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml b/Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.yaml new file mode 100644
index 000000000000..f422a216ff93

Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.ya new file +14 -0
+++ ml
@@ -0,0 +1,157 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) %YAML 1.2
+---
+$id: http://devicetree.org/schemas/mmc/realtek,rtd-dw-cqe-emmc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Realtek DesignWare mobile storage host controller
+
+description:
+  Realtek uses the Synopsys DesignWare mobile storage host controller
+  to interface a SoC with storage medium. This file documents the 
+Realtek
+  specific extensions.
+

Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.ya line 23

Quoted 10 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.ya new file +10 -0
+maintainers:
+  - Jyan Chou <[email protected]>
+
+allOf:
+  - $ref: mmc-controller.yaml#
+
+properties:
+  compatible:
+    enum:
+      - realtek,rtd-dw-cqe-emmc

I don't understand what happened here. I asked you to drop the incorrect, generic compatible. Instead you dropped specific compatibles and left generic. Nope, this does not work like it.

You *must* use specific compatibles.

Quoted 6 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.ya new file +6 -0
+
+  reg:
+    items:
+      - description: emmc base address
+      - description: cqhci base address
+

Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.ya line 39

Quoted 10 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.ya new file +10 -0
+  reg-names:
+    items:
+      - const: emmc
+      - const: cqhci
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    description: Handles to input clocks

Instead: maxItems: 4

Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.ya line 50

Quoted 11 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.ya new file +11 -0
+
+  clock-names:
+    items:
+      - const: biu
+      - const: ciu
+      - const: vp0
+      - const: vp1
+
+  clock-frequency:
+    description:
+      Operating frequency of realtek emmc controller clock

Drop entire property. There is already max-frequency.

Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.ya line 56

Quoted 6 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.ya new file +6 -0
+    minimum: 300000
+    maximum: 400000000
+
+  vmmc-supply:
+    description:
+      Handle to fixed-voltage supply for the card power.

Drop entire property. Not needed.

Quoted 65 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.ya new file +65 -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
+
+  pinctrl-9:
+    description:
+      should contain tune4 pin ctrl.
+    maxItems: 1
+
+  pinctrl-names:
+    maxItems: 10
+
+required:
+  - compatible
+  - reg
+  - reg-names
+  - interrupts
+  - clocks
+  - clock-names
+  - clock-frequency
+  - vmmc-supply
+  - pinctrl-names
+  - pinctrl-0

Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.ya line 131

Quoted 10 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.ya new file +10 -0
+  - pinctrl-1
+  - pinctrl-3
+  - pinctrl-4
+  - pinctrl-5
+  - pinctrl-6
+  - pinctrl-7
+  - pinctrl-8
+  - pinctrl-9
+
+additionalProperties: false

unevaluatedProperties: false

Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.ya line 142

Quoted 11 lines
Documentation/devicetree/bindings/mmc/realtek,rtd-dw-cqe-emmc.ya new file +11 -0
+
+examples:
+  - |
+    emmc: mmc@12000 {
+      compatible = "realtek,rtd-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";

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

NAK, till you upstream your DTS.

Best regards,
Krzysztof