Skip to contentSkip to conversation

mmc: mmci: sdmmc: add sdr104 support

PATCH In review Ludovic Barre 3 participants 17 messages Jan 28, 2020 – Feb 24, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover mmc: mmci: sdmmc: add sdr104 support

To support the sdr104 mode, sdmmc variant needs:
-Hardware delay block support for sdmmc variant
with tuning procedure
-Voltage switch callbacks
-sdmmc revision 2.0

V2:
-regroup host->mmc_ops & mmc->ops assignment
-add timeout define
-rename prep_volt_switch to pre_sig_volt_switch -rename volt_switch to post_sig_volt_switch
-add 'why' comment for "mmc: mmci: add volt_switch callbacks"

Ludovic Barre (9):
mmc: mmci: sdmmc: replace sg_dma_xxx macros
mmc: mmci: sdmmc: rename sdmmc_priv struct to sdmmc_idma
mmc: mmci: add a reference at mmc_host_ops in mmci struct
mmc: mmci: add private pointer for variant
dt-bindings: mmc: mmci: add delay block base register for sdmmc
mmc: mmci: sdmmc: add execute tuning with delay block
mmc: mmci: add volt_switch callbacks
mmc: mmci: sdmmc: add voltage switch functions
mmc: mmci: add sdmmc variant revision 2.0

 .../devicetree/bindings/mmc/mmci.txt          |   2 +
 drivers/mmc/host/mmci.c                       |  42 +++-
 drivers/mmc/host/mmci.h                       |   8 +
 drivers/mmc/host/mmci_stm32_sdmmc.c           | 204 +++++++++++++++++-
 4 files changed, 248 insertions(+), 8 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 1/9 mmc: mmci: sdmmc: replace sg_dma_xxx macros

sg_dma_xxx should be used after a dma_map_sg call has been done to get bus addresses of each of the SG entries and their lengths. But mmci_host_ops validate_data can be called before dma_map_sg. This patch replaces theses macros by sg->offset and sg->length which are always defined.

---
 drivers/mmc/host/mmci_stm32_sdmmc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mmc/host/mmci_stm32_sdmmc.c +3 -3
index a4f7e8e689d3..6ccfbbc82c77 100644
@@ -36,8 +36,8 @@ static int sdmmc_idma_validate_data(struct mmci_host *host,
 	 * excepted the last element which has no constraint on idmasize
 	 */
 	for_each_sg(data->sg, sg, data->sg_len - 1, i) {
-		if (!IS_ALIGNED(sg_dma_address(data->sg), sizeof(u32)) ||
-		    !IS_ALIGNED(sg_dma_len(data->sg), SDMMC_IDMA_BURST)) {
+		if (!IS_ALIGNED(data->sg->offset, sizeof(u32)) ||
+		    !IS_ALIGNED(data->sg->length, SDMMC_IDMA_BURST)) {
 			dev_err(mmc_dev(host->mmc),
 				"unaligned scatterlist: ofst:%x length:%d\n",
 				data->sg->offset, data->sg->length);
@@ -45,7 +45,7 @@ static int sdmmc_idma_validate_data(struct mmci_host *host,
 		}
 	}
 
-	if (!IS_ALIGNED(sg_dma_address(data->sg), sizeof(u32))) {
+	if (!IS_ALIGNED(data->sg->offset, sizeof(u32))) {
 		dev_err(mmc_dev(host->mmc),
 			"unaligned last scatterlist: ofst:%x length:%d\n",
 			data->sg->offset, data->sg->length);
Signature · 7 lines
2.17.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#2 lore raw

PATCH v2 2/9 mmc: mmci: sdmmc: rename sdmmc_priv struct to sdmmc_idma

In reply to Ludovic Barre

This patch renames sdmmc_priv struct to sdmmc_idma which is assigned to host->dma_priv.

---
 drivers/mmc/host/mmci_stm32_sdmmc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mmc/host/mmci_stm32_sdmmc.c +3 -3
index 6ccfbbc82c77..df08f6662431 100644
@@ -20,7 +20,7 @@ struct sdmmc_lli_desc {
 	u32 idmasize;
 };
 
-struct sdmmc_priv {
+struct sdmmc_idma {
 	dma_addr_t sg_dma;
 	void *sg_cpu;
 };
@@ -92,7 +92,7 @@ static void sdmmc_idma_unprep_data(struct mmci_host *host,
 
 static int sdmmc_idma_setup(struct mmci_host *host)
 {
-	struct sdmmc_priv *idma;
+	struct sdmmc_idma *idma;
 
 	idma = devm_kzalloc(mmc_dev(host->mmc), sizeof(*idma), GFP_KERNEL);
 	if (!idma)
@@ -123,7 +123,7 @@ static int sdmmc_idma_setup(struct mmci_host *host)
 static int sdmmc_idma_start(struct mmci_host *host, unsigned int *datactrl)
 
 {
-	struct sdmmc_priv *idma = host->dma_priv;
+	struct sdmmc_idma *idma = host->dma_priv;
 	struct sdmmc_lli_desc *desc = (struct sdmmc_lli_desc *)idma->sg_cpu;
 	struct mmc_data *data = host->data;
 	struct scatterlist *sg;
Signature · 1 line
2.17.1
#3 lore raw

PATCH v2 3/9 mmc: mmci: add a reference at mmc_host_ops in mmci struct

In reply to Ludovic Barre

The variant init function may need to add a mmc_host_ops, for example to add the execute_tuning support if this feature is available.
This patch adds mmc_host_ops pointer in mmci struct.

---
 drivers/mmc/host/mmci.c | 4 ++--
 drivers/mmc/host/mmci.h | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/mmc/host/mmci.c +2 -2
index e9ffce8d41ea..d0a041c9e6cd 100644
@@ -1933,6 +1933,8 @@ static int mmci_probe(struct amba_device *dev,
 
 	host = mmc_priv(mmc);
 	host->mmc = mmc;
+	host->mmc_ops = &mmci_ops;
+	mmc->ops = &mmci_ops;
 
 	/*
 	 * Some variant (STM32) doesn't have opendrain bit, nevertheless
@@ -2072,8 +2074,6 @@ static int mmci_probe(struct amba_device *dev,
 	host->stop_abort.arg = 0;
 	host->stop_abort.flags = MMC_RSP_R1B | MMC_CMD_AC;
 
-	mmc->ops = &mmci_ops;
-
 	/* We support these PM capabilities. */
 	mmc->pm_caps |= MMC_PM_KEEP_POWER;
 
drivers/mmc/host/mmci.h +1 -0
index ea6a0b5779d4..55acc0971a44 100644
@@ -407,6 +407,7 @@ struct mmci_host {
 	u32			mask1_reg;
 	u8			vqmmc_enabled:1;
 	struct mmci_platform_data *plat;
+	struct mmc_host_ops	*mmc_ops;
 	struct mmci_host_ops	*ops;
 	struct variant_data	*variant;
 	struct pinctrl		*pinctrl;
Signature · 1 line
2.17.1
#4 lore raw

PATCH v2 4/9 mmc: mmci: add private pointer for variant

In reply to Ludovic Barre

In variant init function, some references may be allocated for variant specific usage. Add a private void* to mmci_host struct allows at variant functions to access on this references by mmci_host structure.

---
 drivers/mmc/host/mmci.h | 1 +
 1 file changed, 1 insertion(+)
drivers/mmc/host/mmci.h +1 -0
index 55acc0971a44..ddcdfb827996 100644
@@ -410,6 +410,7 @@ struct mmci_host {
 	struct mmc_host_ops	*mmc_ops;
 	struct mmci_host_ops	*ops;
 	struct variant_data	*variant;
+	void			*variant_priv;
 	struct pinctrl		*pinctrl;
 	struct pinctrl_state	*pins_opendrain;
 
Signature · 1 line
2.17.1
#5 lore raw

PATCH v2 5/9 dt-bindings: mmc: mmci: add delay block base register for sdmmc

In reply to Ludovic Barre

To support the sdr104 mode, the sdmmc variant has a hardware delay block to manage the clock phase when sampling data received by the card.

This patch adds a second base register (optional) for sdmmc delay block.

---
 Documentation/devicetree/bindings/mmc/mmci.txt | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/mmc/mmci.txt +2 -0
index 6d3c626e017d..4ec921e4bf34 100644
@@ -28,6 +28,8 @@ specific for ux500 variant:
 - st,sig-pin-fbclk       : feedback clock signal pin used.
 
 specific for sdmmc variant:
+- reg			 : a second base register may be defined if a delay
+                           block is present and used for tuning.
 - st,sig-dir             : signal direction polarity used for cmd, dat0 dat123.
 - st,neg-edge            : data & command phase relation, generated on
                            sd clock falling edge.
Signature · 1 line
2.17.1
maintainer Acked-by on v2 5/9
#6 lore raw

Re: [PATCH V2 5/9] dt-bindings: mmc: mmci: add delay block base register for sdmmc

Quoted 4 lines · Ludovic Barre

To support the sdr104 mode, the sdmmc variant has a hardware delay block to manage the clock phase when sampling data received by the card.

Quoted 8 lines

This patch adds a second base register (optional) for sdmmc delay block.

---
 Documentation/devicetree/bindings/mmc/mmci.txt | 2 ++
 1 file changed, 2 insertions(+)
#7 lore raw

PATCH v2 6/9 mmc: mmci: sdmmc: add execute tuning with delay block

In reply to Ludovic Barre

The hardware delay block is used to align the sampling clock on the data received by SDMMC. It is mandatory for SDMMC to support the SDR104 mode. The delay block is used to generate an output clock which is dephased from the input clock. The phase of the output clock must be programmed by the execute tuning interface.

---
 drivers/mmc/host/mmci_stm32_sdmmc.c | 149 ++++++++++++++++++++++++++++
 1 file changed, 149 insertions(+)
drivers/mmc/host/mmci_stm32_sdmmc.c +149 -0
index df08f6662431..fa875febcc85 100644
@@ -3,10 +3,13 @@
  * Copyright (C) STMicroelectronics 2018 - All Rights Reserved
  * Author: [email protected] for STMicroelectronics.
  */
+#include <linux/bitfield.h>
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
+#include <linux/iopoll.h>
 #include <linux/mmc/host.h>
 #include <linux/mmc/card.h>
+#include <linux/of_address.h>
 #include <linux/reset.h>
 #include <linux/scatterlist.h>
 #include "mmci.h"
@@ -14,6 +17,22 @@
 #define SDMMC_LLI_BUF_LEN	PAGE_SIZE
 #define SDMMC_IDMA_BURST	BIT(MMCI_STM32_IDMABNDT_SHIFT)
 
+#define DLYB_CR			0x0
+#define DLYB_CR_DEN		BIT(0)
+#define DLYB_CR_SEN		BIT(1)
+
+#define DLYB_CFGR		0x4
+#define DLYB_CFGR_SEL_MASK	GENMASK(3, 0)
+#define DLYB_CFGR_UNIT_MASK	GENMASK(14, 8)
+#define DLYB_CFGR_LNG_MASK	GENMASK(27, 16)
+#define DLYB_CFGR_LNGF		BIT(31)
+
+#define DLYB_NB_DELAY		11
+#define DLYB_CFGR_SEL_MAX	(DLYB_NB_DELAY + 1)
+#define DLYB_CFGR_UNIT_MAX	127
+
+#define DLYB_LNG_TIMEOUT_US	1000
+
 struct sdmmc_lli_desc {
 	u32 idmalar;
 	u32 idmabase;
@@ -25,6 +44,12 @@ struct sdmmc_idma {
 	void *sg_cpu;
 };
 
+struct sdmmc_dlyb {
+	void __iomem *base;
+	u32 unit;
+	u32 max;
+};
+
 static int sdmmc_idma_validate_data(struct mmci_host *host,
 				    struct mmc_data *data)
 {
@@ -226,12 +251,24 @@ static void mmci_sdmmc_set_clkreg(struct mmci_host *host, unsigned int desired)
 	mmci_write_clkreg(host, clk);
 }
 
+static void sdmmc_dlyb_input_ck(struct sdmmc_dlyb *dlyb)
+{
+	if (!dlyb || !dlyb->base)
+		return;
+
+	/* Output clock = Input clock */
+	writel_relaxed(0, dlyb->base + DLYB_CR);
+}
+
 static void mmci_sdmmc_set_pwrreg(struct mmci_host *host, unsigned int pwr)
 {
 	struct mmc_ios ios = host->mmc->ios;
+	struct sdmmc_dlyb *dlyb = host->variant_priv;
 
 	pwr = host->pwr_reg_add;
 
+	sdmmc_dlyb_input_ck(dlyb);
+
 	if (ios.power_mode == MMC_POWER_OFF) {
 		/* Only a reset could power-off sdmmc */
 		reset_control_assert(host->rst);
@@ -323,6 +360,102 @@ static bool sdmmc_busy_complete(struct mmci_host *host, u32 status, u32 err_msk)
 	return true;
 }
 
+static void sdmmc_dlyb_set_cfgr(struct sdmmc_dlyb *dlyb,
+				int unit, int phase, bool sampler)
+{
+	u32 cfgr;
+
+	writel_relaxed(DLYB_CR_SEN | DLYB_CR_DEN, dlyb->base + DLYB_CR);
+
+	cfgr = FIELD_PREP(DLYB_CFGR_UNIT_MASK, unit) |
+	       FIELD_PREP(DLYB_CFGR_SEL_MASK, phase);
+	writel_relaxed(cfgr, dlyb->base + DLYB_CFGR);
+
+	if (!sampler)
+		writel_relaxed(DLYB_CR_DEN, dlyb->base + DLYB_CR);
+}
+
+static int sdmmc_dlyb_lng_tuning(struct mmci_host *host)
+{
+	struct sdmmc_dlyb *dlyb = host->variant_priv;
+	u32 cfgr;
+	int i, lng, ret;
+
+	for (i = 0; i <= DLYB_CFGR_UNIT_MAX; i++) {
+		sdmmc_dlyb_set_cfgr(dlyb, i, DLYB_CFGR_SEL_MAX, true);
+
+		ret = readl_relaxed_poll_timeout(dlyb->base + DLYB_CFGR, cfgr,
+						 (cfgr & DLYB_CFGR_LNGF),
+						 1, DLYB_LNG_TIMEOUT_US);
+		if (ret) {
+			dev_warn(mmc_dev(host->mmc),
+				 "delay line cfg timeout unit:%d cfgr:%d\n",
+				 i, cfgr);
+			continue;
+		}
+
+		lng = FIELD_GET(DLYB_CFGR_LNG_MASK, cfgr);
+		if (lng < BIT(DLYB_NB_DELAY) && lng > 0)
+			break;
+	}
+
+	if (i > DLYB_CFGR_UNIT_MAX)
+		return -EINVAL;
+
+	dlyb->unit = i;
+	dlyb->max = __fls(lng);
+
+	return 0;
+}
+
+static int sdmmc_dlyb_phase_tuning(struct mmci_host *host, u32 opcode)
+{
+	struct sdmmc_dlyb *dlyb = host->variant_priv;
+	int cur_len = 0, max_len = 0, end_of_len = 0;
+	int phase;
+
+	for (phase = 0; phase <= dlyb->max; phase++) {
+		sdmmc_dlyb_set_cfgr(dlyb, dlyb->unit, phase, false);
+
+		if (mmc_send_tuning(host->mmc, opcode, NULL)) {
+			cur_len = 0;
+		} else {
+			cur_len++;
+			if (cur_len > max_len) {
+				max_len = cur_len;
+				end_of_len = phase;
+			}
+		}
+	}
+
+	if (!max_len) {
+		dev_err(mmc_dev(host->mmc), "no tuning point found\n");
+		return -EINVAL;
+	}
+
+	phase = end_of_len - max_len / 2;
+	sdmmc_dlyb_set_cfgr(dlyb, dlyb->unit, phase, false);
+
+	dev_dbg(mmc_dev(host->mmc), "unit:%d max_dly:%d phase:%d\n",
+		dlyb->unit, dlyb->max, phase);
+
+	return 0;
+}
+
+static int sdmmc_execute_tuning(struct mmc_host *mmc, u32 opcode)
+{
+	struct mmci_host *host = mmc_priv(mmc);
+	struct sdmmc_dlyb *dlyb = host->variant_priv;
+
+	if (!dlyb || !dlyb->base)
+		return -EINVAL;
+
+	if (sdmmc_dlyb_lng_tuning(host))
+		return -EINVAL;
+
+	return sdmmc_dlyb_phase_tuning(host, opcode);
+}
+
 static struct mmci_host_ops sdmmc_variant_ops = {
 	.validate_data = sdmmc_idma_validate_data,
 	.prep_data = sdmmc_idma_prep_data,
@@ -338,5 +471,21 @@ static struct mmci_host_ops sdmmc_variant_ops = {
 
 void sdmmc_variant_init(struct mmci_host *host)
 {
+	struct device_node *np = host->mmc->parent->of_node;
+	void __iomem *base_dlyb;
+	struct sdmmc_dlyb *dlyb;
+
 	host->ops = &sdmmc_variant_ops;
+
+	base_dlyb = devm_of_iomap(mmc_dev(host->mmc), np, 1, NULL);
+	if (IS_ERR(base_dlyb))
+		return;
+
+	dlyb = devm_kzalloc(mmc_dev(host->mmc), sizeof(*dlyb), GFP_KERNEL);
+	if (!dlyb)
+		return;
+
+	dlyb->base = base_dlyb;
+	host->variant_priv = dlyb;
+	host->mmc_ops->execute_tuning = sdmmc_execute_tuning;
 }
Signature · 1 line
2.17.1
#8 lore raw

PATCH v2 7/9 mmc: mmci: add volt_switch callbacks

In reply to Ludovic Barre

A variant may need to define some actions before and after a voltage switch.

This patch adds 2 voltage switch callbacks in mmci_host_ops:
-pre_sig_volt_switch allows to prepare voltage switch before to
sent the SD_SWITCH_VOLTAGE command (cmd11).
-post_sig_volt_switch callback allows to define specific action after
regulator set voltage.

---
 drivers/mmc/host/mmci.c | 8 ++++++++
 drivers/mmc/host/mmci.h | 2 ++
 2 files changed, 10 insertions(+)
drivers/mmc/host/mmci.c +8 -0
index d0a041c9e6cd..24e630183ed4 100644
@@ -22,6 +22,7 @@
 #include <linux/mmc/pm.h>
 #include <linux/mmc/host.h>
 #include <linux/mmc/card.h>
+#include <linux/mmc/sd.h>
 #include <linux/mmc/slot-gpio.h>
 #include <linux/amba/bus.h>
 #include <linux/clk.h>
@@ -1217,6 +1218,9 @@ mmci_start_command(struct mmci_host *host, struct mmc_command *cmd, u32 c)
 		writel_relaxed(clks, host->base + MMCIDATATIMER);
 	}
 
+	if (host->ops->pre_sig_volt_switch && cmd->opcode == SD_SWITCH_VOLTAGE)
+		host->ops->pre_sig_volt_switch(host);
+
 	if (/*interrupt*/0)
 		c |= MCI_CPSM_INTERRUPT;
 
@@ -1830,6 +1834,7 @@ static int mmci_get_cd(struct mmc_host *mmc)
 
 static int mmci_sig_volt_switch(struct mmc_host *mmc, struct mmc_ios *ios)
 {
+	struct mmci_host *host = mmc_priv(mmc);
 	int ret = 0;
 
 	if (!IS_ERR(mmc->supply.vqmmc)) {
@@ -1849,6 +1854,9 @@ static int mmci_sig_volt_switch(struct mmc_host *mmc, struct mmc_ios *ios)
 			break;
 		}
 
+		if (!ret && host->ops && host->ops->post_sig_volt_switch)
+			ret = host->ops->post_sig_volt_switch(host, ios);
+
 		if (ret)
 			dev_warn(mmc_dev(mmc), "Voltage switch failed\n");
 	}
drivers/mmc/host/mmci.h +2 -0
index ddcdfb827996..c3bc0a38d4cb 100644
@@ -377,6 +377,8 @@ struct mmci_host_ops {
 	void (*set_clkreg)(struct mmci_host *host, unsigned int desired);
 	void (*set_pwrreg)(struct mmci_host *host, unsigned int pwr);
 	bool (*busy_complete)(struct mmci_host *host, u32 status, u32 err_msk);
+	void (*pre_sig_volt_switch)(struct mmci_host *host);
+	int (*post_sig_volt_switch)(struct mmci_host *host, struct mmc_ios *ios);
 };
 
 struct mmci_host {
Signature · 1 line
2.17.1
#9 lore raw

PATCH v2 8/9 mmc: mmci: sdmmc: add voltage switch functions

In reply to Ludovic Barre

To prepare the voltage switch procedure, the VSWITCHEN bit must be set before sending the cmd11.
To confirm completion of voltage switch, the VSWEND flag must be checked.

---
 drivers/mmc/host/mmci.h             |  4 +++
 drivers/mmc/host/mmci_stm32_sdmmc.c | 43 +++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+)
drivers/mmc/host/mmci.h +4 -0
index c3bc0a38d4cb..e1a9b96a3396 100644
@@ -165,6 +165,7 @@
 /* Extended status bits for the STM32 variants */
 #define MCI_STM32_BUSYD0	BIT(20)
 #define MCI_STM32_BUSYD0END	BIT(21)
+#define MCI_STM32_VSWEND	BIT(25)
 
 #define MMCICLEAR		0x038
 #define MCI_CMDCRCFAILCLR	(1 << 0)
@@ -182,6 +183,9 @@
 #define MCI_ST_SDIOITC		(1 << 22)
 #define MCI_ST_CEATAENDC	(1 << 23)
 #define MCI_ST_BUSYENDC		(1 << 24)
+/* Extended clear bits for the STM32 variants */
+#define MCI_STM32_VSWENDC	BIT(25)
+#define MCI_STM32_CKSTOPC	BIT(26)
 
 #define MMCIMASK0		0x03c
 #define MCI_CMDCRCFAILMASK	(1 << 0)
drivers/mmc/host/mmci_stm32_sdmmc.c +43 -0

73 lines not on this page · raw message

Signature · 1 line
2.17.1
#10 lore raw

PATCH v2 9/9 mmc: mmci: add sdmmc variant revision 2.0

In reply to Ludovic Barre

This patch adds a sdmmc variant revision 2.0.
This revision is backward compatible with 1.1, and adds dma link list support.

---
 drivers/mmc/host/mmci.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
drivers/mmc/host/mmci.c +30 -0
index 24e630183ed4..a774c329c212 100644
@@ -275,6 +275,31 @@ static struct variant_data variant_stm32_sdmmc = {
 	.init			= sdmmc_variant_init,
 };
 
+static struct variant_data variant_stm32_sdmmcv2 = {
+	.fifosize		= 16 * 4,
+	.fifohalfsize		= 8 * 4,
+	.f_max			= 208000000,
+	.stm32_clkdiv		= true,
+	.cmdreg_cpsm_enable	= MCI_CPSM_STM32_ENABLE,
+	.cmdreg_lrsp_crc	= MCI_CPSM_STM32_LRSP_CRC,
+	.cmdreg_srsp_crc	= MCI_CPSM_STM32_SRSP_CRC,
+	.cmdreg_srsp		= MCI_CPSM_STM32_SRSP,
+	.cmdreg_stop		= MCI_CPSM_STM32_CMDSTOP,
+	.data_cmd_enable	= MCI_CPSM_STM32_CMDTRANS,
+	.irq_pio_mask		= MCI_IRQ_PIO_STM32_MASK,
+	.datactrl_first		= true,
+	.datacnt_useless	= true,
+	.datalength_bits	= 25,
+	.datactrl_blocksz	= 14,
+	.datactrl_any_blocksz	= true,
+	.stm32_idmabsize_mask	= GENMASK(16, 5),
+	.dma_lli		= true,
+	.busy_timeout		= true,
+	.busy_detect_flag	= MCI_STM32_BUSYD0,
+	.busy_detect_mask	= MCI_STM32_BUSYD0ENDMASK,
+	.init			= sdmmc_variant_init,
+};
+
 static struct variant_data variant_qcom = {
 	.fifosize		= 16 * 4,
 	.fifohalfsize		= 8 * 4,
@@ -2343,6 +2368,11 @@ static const struct amba_id mmci_ids[] = {
 		.mask	= 0xf0ffffff,
 		.data	= &variant_stm32_sdmmc,
 	},
+	{
+		.id     = 0x00253180,
+		.mask	= 0xf0ffffff,
+		.data	= &variant_stm32_sdmmcv2,
+	},
 	/* Qualcomm variants */
 	{
 		.id     = 0x00051180,
Signature · 1 line
2.17.1
#11 lore raw

Re: [PATCH V2 9/9] mmc: mmci: add sdmmc variant revision 2.0

hi Ulf

Le 1/28/20 à 10:06 AM, Ludovic Barre a écrit :

Quoted 27 lines

This patch adds a sdmmc variant revision 2.0.
This revision is backward compatible with 1.1, and adds dma link list support.

---
  drivers/mmc/host/mmci.c | 30 ++++++++++++++++++++++++++++++
  1 file changed, 30 insertions(+)
drivers/mmc/host/mmci.c +10 -0
index 24e630183ed4..a774c329c212 100644
@@ -275,6 +275,31 @@ static struct variant_data variant_stm32_sdmmc = {
  	.init			= sdmmc_variant_init,
  };
 
+static struct variant_data variant_stm32_sdmmcv2 = {
+	.fifosize		= 16 * 4,
+	.fifohalfsize		= 8 * 4,
+	.f_max			= 208000000,
+	.stm32_clkdiv		= true,
+	.cmdreg_cpsm_enable	= MCI_CPSM_STM32_ENABLE,
+	.cmdreg_lrsp_crc	= MCI_CPSM_STM32_LRSP_CRC,
+	.cmdreg_srsp_crc	= MCI_CPSM_STM32_SRSP_CRC,
+	.cmdreg_srsp		= MCI_CPSM_STM32_SRSP,
+	.cmdreg_stop		= MCI_CPSM_STM32_CMDSTOP,

drivers/mmc/host/mmci.c static struct variant_data variant_stm32_sdmmc = { · line 297

Quoted 10 lines
drivers/mmc/host/mmci.c +10 -0
+	.data_cmd_enable	= MCI_CPSM_STM32_CMDTRANS,
+	.irq_pio_mask		= MCI_IRQ_PIO_STM32_MASK,
+	.datactrl_first		= true,
+	.datacnt_useless	= true,
+	.datalength_bits	= 25,
+	.datactrl_blocksz	= 14,
+	.datactrl_any_blocksz	= true,
+	.stm32_idmabsize_mask	= GENMASK(16, 5),
+	.dma_lli		= true,
+	.busy_timeout		= true,

I forget "busy_detect = true," property
I add this in next patch set

Quoted 21 lines
drivers/mmc/host/mmci.c +10 -0
+	.busy_detect_flag	= MCI_STM32_BUSYD0,
+	.busy_detect_mask	= MCI_STM32_BUSYD0ENDMASK,
+	.init			= sdmmc_variant_init,
+};
+
  static struct variant_data variant_qcom = {
  	.fifosize		= 16 * 4,
  	.fifohalfsize		= 8 * 4,
@@ -2343,6 +2368,11 @@ static const struct amba_id mmci_ids[] = {
  		.mask	= 0xf0ffffff,
  		.data	= &variant_stm32_sdmmc,
  	},
+	{
+		.id     = 0x00253180,
+		.mask	= 0xf0ffffff,
+		.data	= &variant_stm32_sdmmcv2,
+	},
  	/* Qualcomm variants */
  	{
  		.id     = 0x00051180,
#12 lore raw

Re: [PATCH V2 9/9] mmc: mmci: add sdmmc variant revision 2.0

Quoted 36 lines · Ludovic BARRE

hi Ulf

Quoted 32 lines · Ludovic Barre

This patch adds a sdmmc variant revision 2.0.
This revision is backward compatible with 1.1, and adds dma link list support.

---
  drivers/mmc/host/mmci.c | 30 ++++++++++++++++++++++++++++++
  1 file changed, 30 insertions(+)
drivers/mmc/host/mmci.c +15 -0
index 24e630183ed4..a774c329c212 100644
@@ -275,6 +275,31 @@ static struct variant_data variant_stm32_sdmmc = {
      .init                   = sdmmc_variant_init,
  };
 
+static struct variant_data variant_stm32_sdmmcv2 = {
+     .fifosize               = 16 * 4,
+     .fifohalfsize           = 8 * 4,
+     .f_max                  = 208000000,
+     .stm32_clkdiv           = true,
+     .cmdreg_cpsm_enable     = MCI_CPSM_STM32_ENABLE,
+     .cmdreg_lrsp_crc        = MCI_CPSM_STM32_LRSP_CRC,
+     .cmdreg_srsp_crc        = MCI_CPSM_STM32_SRSP_CRC,
+     .cmdreg_srsp            = MCI_CPSM_STM32_SRSP,
+     .cmdreg_stop            = MCI_CPSM_STM32_CMDSTOP,
+     .data_cmd_enable        = MCI_CPSM_STM32_CMDTRANS,
+     .irq_pio_mask           = MCI_IRQ_PIO_STM32_MASK,
+     .datactrl_first         = true,
+     .datacnt_useless        = true,
+     .datalength_bits        = 25,
Quoted 8 lines

drivers/mmc/host/mmci.c static struct variant_data variant_stm32_sdmmc = { · line 297

Quoted 5 lines
drivers/mmc/host/mmci.c +5 -0
+     .datactrl_blocksz       = 14,
+     .datactrl_any_blocksz   = true,
+     .stm32_idmabsize_mask   = GENMASK(16, 5),
+     .dma_lli                = true,
+     .busy_timeout           = true,

I forget "busy_detect = true," property
I add this in next patch set

No need for a re-send, I amended this when I applied it.

Quoted 14 lines
Quoted 14 lines
drivers/mmc/host/mmci.c +6 -0
+     .busy_detect_flag       = MCI_STM32_BUSYD0,
+     .busy_detect_mask       = MCI_STM32_BUSYD0ENDMASK,
+     .init                   = sdmmc_variant_init,
+};
+
  static struct variant_data variant_qcom = {
      .fifosize               = 16 * 4,
      .fifohalfsize           = 8 * 4,
@@ -2343,6 +2368,11 @@ static const struct amba_id mmci_ids[] = {
              .mask   = 0xf0ffffff,
              .data   = &variant_stm32_sdmmc,
      },
+     {
Quoted 8 lines

drivers/mmc/host/mmci.c static const struct amba_id mmci_ids[] = { · line 2378

Quoted 8 lines
drivers/mmc/host/mmci.c +4 -0
+             .id     = 0x00253180,
+             .mask   = 0xf0ffffff,
+             .data   = &variant_stm32_sdmmcv2,
+     },
      /* Qualcomm variants */
      {
              .id     = 0x00051180,

Kind regards
Uffe

#13 lore raw
In reply to Ludovic Barre

hi Ulf

Just a "gentleman ping" on this series
https://patchwork.kernel.org/project/linux-mmc/list/?series=234011

Regards
Ludo

Le 1/28/20 à 10:06 AM, Ludovic Barre a écrit :

Quoted 30 lines

To support the sdr104 mode, sdmmc variant needs:

(quoted diff) +0 -3
-Hardware delay block support for sdmmc variant
  with tuning procedure
-Voltage switch callbacks
-sdmmc revision 2.0

V2:

(quoted diff) +0 -5
-regroup host->mmc_ops & mmc->ops assignment
-add timeout define
-rename prep_volt_switch to pre_sig_volt_switch
-rename volt_switch to post_sig_volt_switch
-add 'why' comment for "mmc: mmci: add volt_switch callbacks"

Ludovic Barre (9):
mmc: mmci: sdmmc: replace sg_dma_xxx macros
mmc: mmci: sdmmc: rename sdmmc_priv struct to sdmmc_idma
mmc: mmci: add a reference at mmc_host_ops in mmci struct
mmc: mmci: add private pointer for variant
dt-bindings: mmc: mmci: add delay block base register for sdmmc
mmc: mmci: sdmmc: add execute tuning with delay block
mmc: mmci: add volt_switch callbacks
mmc: mmci: sdmmc: add voltage switch functions
mmc: mmci: add sdmmc variant revision 2.0

  .../devicetree/bindings/mmc/mmci.txt          |   2 +
  drivers/mmc/host/mmci.c                       |  42 +++-
  drivers/mmc/host/mmci.h                       |   8 +
  drivers/mmc/host/mmci_stm32_sdmmc.c           | 204 +++++++++++++++++-
  4 files changed, 248 insertions(+), 8 deletions(-)
#14 lore raw
Quoted 5 lines · Ludovic BARRE

hi Ulf

Just a "gentleman ping" on this series
https://patchwork.kernel.org/project/linux-mmc/list/?series=234011

I will have a look later this week. The merge window closed yesterday and normally I don't queue anything but fixes during the merge window.

Anyway, apologize for the delays.

Kind regards
Uffe

Quoted 35 lines

Regards
Ludo

Quoted 30 lines · Ludovic Barre

To support the sdr104 mode, sdmmc variant needs:

(quoted diff) +0 -3
-Hardware delay block support for sdmmc variant
  with tuning procedure
-Voltage switch callbacks
-sdmmc revision 2.0

V2:

(quoted diff) +0 -5
-regroup host->mmc_ops & mmc->ops assignment
-add timeout define
-rename prep_volt_switch to pre_sig_volt_switch
-rename volt_switch to post_sig_volt_switch
-add 'why' comment for "mmc: mmci: add volt_switch callbacks"

Ludovic Barre (9):
mmc: mmci: sdmmc: replace sg_dma_xxx macros
mmc: mmci: sdmmc: rename sdmmc_priv struct to sdmmc_idma
mmc: mmci: add a reference at mmc_host_ops in mmci struct
mmc: mmci: add private pointer for variant
dt-bindings: mmc: mmci: add delay block base register for sdmmc
mmc: mmci: sdmmc: add execute tuning with delay block
mmc: mmci: add volt_switch callbacks
mmc: mmci: sdmmc: add voltage switch functions
mmc: mmci: add sdmmc variant revision 2.0

  .../devicetree/bindings/mmc/mmci.txt          |   2 +
  drivers/mmc/host/mmci.c                       |  42 +++-
  drivers/mmc/host/mmci.h                       |   8 +
  drivers/mmc/host/mmci_stm32_sdmmc.c           | 204 +++++++++++++++++-
  4 files changed, 248 insertions(+), 8 deletions(-)
#15 lore raw
In reply to Ludovic Barre
Quoted 25 lines · Ludovic Barre

To support the sdr104 mode, sdmmc variant needs:

(quoted diff) +0 -3
-Hardware delay block support for sdmmc variant
 with tuning procedure
-Voltage switch callbacks
-sdmmc revision 2.0

V2:

(quoted diff) +0 -5
-regroup host->mmc_ops & mmc->ops assignment
-add timeout define
-rename prep_volt_switch to pre_sig_volt_switch
-rename volt_switch to post_sig_volt_switch
-add 'why' comment for "mmc: mmci: add volt_switch callbacks"

Ludovic Barre (9):
mmc: mmci: sdmmc: replace sg_dma_xxx macros
mmc: mmci: sdmmc: rename sdmmc_priv struct to sdmmc_idma
mmc: mmci: add a reference at mmc_host_ops in mmci struct
mmc: mmci: add private pointer for variant
dt-bindings: mmc: mmci: add delay block base register for sdmmc
mmc: mmci: sdmmc: add execute tuning with delay block
mmc: mmci: add volt_switch callbacks
mmc: mmci: sdmmc: add voltage switch functions
mmc: mmci: add sdmmc variant revision 2.0

Quoted 9 lines
 .../devicetree/bindings/mmc/mmci.txt          |   2 +
 drivers/mmc/host/mmci.c                       |  42 +++-
 drivers/mmc/host/mmci.h                       |   8 +
 drivers/mmc/host/mmci_stm32_sdmmc.c           | 204 +++++++++++++++++-
 4 files changed, 248 insertions(+), 8 deletions(-)

--
2.17.1

Applied for next, thanks!

I took the liberty to do minor amendments to some of the changelogs, but in particular I have change some of prefixes for the commit message headers into "mmc: mmci_sdmmc:".

Please tell, if there is anything that you want me to update.

Kind regards
Uffe

#16 lore raw

hi Ulf

Le 2/19/20 à 11:28 AM, Ulf Hansson a écrit :

Quoted 32 lines · Ludovic Barre
Quoted 31 lines

To support the sdr104 mode, sdmmc variant needs:

(quoted diff) +0 -3
-Hardware delay block support for sdmmc variant
  with tuning procedure
-Voltage switch callbacks
-sdmmc revision 2.0

V2:

(quoted diff) +0 -5
-regroup host->mmc_ops & mmc->ops assignment
-add timeout define
-rename prep_volt_switch to pre_sig_volt_switch
-rename volt_switch to post_sig_volt_switch
-add 'why' comment for "mmc: mmci: add volt_switch callbacks"

Ludovic Barre (9):
mmc: mmci: sdmmc: replace sg_dma_xxx macros
mmc: mmci: sdmmc: rename sdmmc_priv struct to sdmmc_idma
mmc: mmci: add a reference at mmc_host_ops in mmci struct
mmc: mmci: add private pointer for variant
dt-bindings: mmc: mmci: add delay block base register for sdmmc
mmc: mmci: sdmmc: add execute tuning with delay block
mmc: mmci: add volt_switch callbacks
mmc: mmci: sdmmc: add voltage switch functions
mmc: mmci: add sdmmc variant revision 2.0

  .../devicetree/bindings/mmc/mmci.txt          |   2 +
  drivers/mmc/host/mmci.c                       |  42 +++-
  drivers/mmc/host/mmci.h                       |   8 +
  drivers/mmc/host/mmci_stm32_sdmmc.c           | 204 +++++++++++++++++-
  4 files changed, 248 insertions(+), 8 deletions(-)
Quoted 5 lines
Quoted 3 lines

--
2.17.1

Applied for next, thanks!

thanks Ulf.

Quoted 4 lines

I took the liberty to do minor amendments to some of the changelogs, but in particular I have change some of prefixes for the commit message headers into "mmc: mmci_sdmmc:".

Ok, I use this prefixe for next commit.

Quoted 2 lines

Please tell, if there is anything that you want me to update.

I tested your next branch, and it's ok for me.
sdmmc upstream is almost finished, I just some recent fixes to send.

Quoted 4 lines

Kind regards
Uffe