Skip to contentSkip to conversation

mmc: sdhci-esdhc-imx: eliminate enum imx_esdhc_type

PATCH New Shawn Guo 4 participants 16 messages Oct 14, 2013 – Oct 16, 2013

Subsystems (4)
lore
Share & tools
lore

Shawn Guo

author
#0 lore raw

cover mmc: sdhci-esdhc-imx: eliminate enum imx_esdhc_type

When I was reviewing Dong's imx6sl standard tuning patches, I found that it's a little clumsy to use enum imx_esdhc_type for handling features and quirks on different esdhc variants. Instead, the approach used in fec driver (drivers/net/ethernet/freescale/fec_main.c) should be more scalable in the long run. It defines flags for all those features and quirks and creates a mapping between esdhc variant and the flags.

Actually, sdhci-esdhc-imx driver already has one such flag, i.e. ESDHC_FLAG_MULTIBLK_NO_INT, but there is currently an unnecessary translation between the flag and imx_esdhc_type. The series creates another 3 flags and identify features/quirks using these flags and then eliminate enum imx_esdhc_type completely.

Shawn Guo (5):
mmc: sdhci-esdhc-imx: add flag ESDHC_FLAG_NO_DMAS_BITS
mmc: sdhci-esdhc-imx: add flag ESDHC_FLAG_ENGCM07207
mmc: sdhci-esdhc-imx: add flag ESDHC_FLAG_USDHC
mmc: sdhci-esdhc-imx: pdev->id_entry should be immutable
mmc: sdhci-esdhc-imx: eliminate enum imx_esdhc_type

 drivers/mmc/host/sdhci-esdhc-imx.c |  108 +++++++++++++++---------------------
 1 file changed, 45 insertions(+), 63 deletions(-)
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH 1/5 mmc: sdhci-esdhc-imx: add flag ESDHC_FLAG_NO_DMAS_BITS

Just like the use of the flag ESDHC_FLAG_MULTIBLK_NO_INT, let's add another flag ESDHC_FLAG_NO_DMAS_BITS to tell the quirk that PROCTL register has no DMAS bits, and set it for i.MX25 ESDHC.

While at it, let's use BIT() macro for ESDHC_FLAG_MULTIBLK_NO_INT as well.

---
 drivers/mmc/host/sdhci-esdhc-imx.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci-esdhc-imx.c +10 -2
index b9899e9..e046917 100644
@@ -73,6 +73,11 @@
 #define ESDHC_INT_VENDOR_SPEC_DMA_ERR	(1 << 28)
 
 /*
+ * There is no DMAS bits in PROCTL register, e.g. the ESDHC on i.MX25 gets
+ * DMAS bits PROCTL[9:8] as reserved.
+ */
+#define ESDHC_FLAG_NO_DMAS_BITS		BIT(0)
+/*
  * The CMDTYPE of the CMD register (offset 0xE) should be set to
  * "11" when the STOP CMD12 is issued on imx53 to abort one
  * open ended multi-blk IO. Otherwise the TC INT wouldn't
@@ -83,7 +88,7 @@
  * As a result, the TC flag is not asserted and SW  received timeout
  * exeception. Bit1 of Vendor Spec registor is used to fix it.
  */
-#define ESDHC_FLAG_MULTIBLK_NO_INT	(1 << 1)
+#define ESDHC_FLAG_MULTIBLK_NO_INT	BIT(1)
 
 enum imx_esdhc_type {
 	IMX25_ESDHC,
@@ -433,7 +438,7 @@ static void esdhc_writeb_le(struct sdhci_host *host, u8 val, int reg)
 		/* ensure the endianness */
 		new_val |= ESDHC_HOST_CONTROL_LE;
 		/* bits 8&9 are reserved on mx25 */
-		if (!is_imx25_esdhc(imx_data)) {
+		if (!(imx_data->flags & ESDHC_FLAG_NO_DMAS_BITS)) {
 			/* DMA mode bits are shifted */
 			new_val |= (val & SDHCI_CTRL_DMA_MASK) << 5;
 		}
@@ -857,6 +862,9 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
 	imx_data->devtype = pdev->id_entry->driver_data;
 	pltfm_host->priv = imx_data;
 
+	if (is_imx25_esdhc(imx_data))
+		imx_data->flags |= ESDHC_FLAG_NO_DMAS_BITS;
+
 	imx_data->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
 	if (IS_ERR(imx_data->clk_ipg)) {
 		err = PTR_ERR(imx_data->clk_ipg);
Signature · 1 line
1.7.9.5
author
#2 lore raw

PATCH 2/5 mmc: sdhci-esdhc-imx: add flag ESDHC_FLAG_ENGCM07207

In reply to Shawn Guo

Add flag ESDHC_FLAG_ENGCM07207 for enabling the workaround for errata ENGcm07207 and set the flag for i.MX25 and i.MX35 ESDHC.

---
 drivers/mmc/host/sdhci-esdhc-imx.c |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci-esdhc-imx.c +9 -1
index e046917..a5d7d15 100644
@@ -89,6 +89,11 @@
  * exeception. Bit1 of Vendor Spec registor is used to fix it.
  */
 #define ESDHC_FLAG_MULTIBLK_NO_INT	BIT(1)
+/*
+ * The flag enables the workaround for ESDHC errata ENGcm07207 which
+ * presents on i.MX25 and i.MX35.
+ */
+#define ESDHC_FLAG_ENGCM07207		BIT(2)
 
 enum imx_esdhc_type {
 	IMX25_ESDHC,
@@ -865,6 +870,9 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
 	if (is_imx25_esdhc(imx_data))
 		imx_data->flags |= ESDHC_FLAG_NO_DMAS_BITS;
 
+	if (is_imx25_esdhc(imx_data) || is_imx35_esdhc(imx_data))
+		imx_data->flags |= ESDHC_FLAG_ENGCM07207;
+
 	imx_data->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
 	if (IS_ERR(imx_data->clk_ipg)) {
 		err = PTR_ERR(imx_data->clk_ipg);
@@ -905,7 +913,7 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
 
 	host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;
 
-	if (is_imx25_esdhc(imx_data) || is_imx35_esdhc(imx_data))
+	if (imx_data->flags & ESDHC_FLAG_ENGCM07207)
 		/* Fix errata ENGcm07207 present on i.MX25 and i.MX35 */
 		host->quirks |= SDHCI_QUIRK_NO_MULTIBLOCK
 			| SDHCI_QUIRK_BROKEN_ADMA;
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH 2/5 mmc: sdhci-esdhc-imx: add flag ESDHC_FLAG_ENGCM07207

Am Montag, den 14.10.2013, 16:23 +0800 schrieb Shawn Guo:

Quoted 13 lines

Add flag ESDHC_FLAG_ENGCM07207 for enabling the workaround for errata ENGcm07207 and set the flag for i.MX25 and i.MX35 ESDHC.

---
 drivers/mmc/host/sdhci-esdhc-imx.c |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci-esdhc-imx.c +0 -0
index e046917..a5d7d15 100644

drivers/mmc/host/sdhci-esdhc-imx.c line 94

Quoted 6 lines
drivers/mmc/host/sdhci-esdhc-imx.c +3 -0
@@ -89,6 +89,11 @@
  * exeception. Bit1 of Vendor Spec registor is used to fix it.
  */
 #define ESDHC_FLAG_MULTIBLK_NO_INT	BIT(1)
+/*
+ * The flag enables the workaround for ESDHC errata ENGcm07207 which
+ * presents on i.MX25 and i.MX35.

s/presents/is present/

Quoted 24 lines
drivers/mmc/host/sdhci-esdhc-imx.c +6 -1
+ */
+#define ESDHC_FLAG_ENGCM07207		BIT(2)
 
 enum imx_esdhc_type {
 	IMX25_ESDHC,
@@ -865,6 +870,9 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
 	if (is_imx25_esdhc(imx_data))
 		imx_data->flags |= ESDHC_FLAG_NO_DMAS_BITS;
 
+	if (is_imx25_esdhc(imx_data) || is_imx35_esdhc(imx_data))
+		imx_data->flags |= ESDHC_FLAG_ENGCM07207;
+
 	imx_data->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
 	if (IS_ERR(imx_data->clk_ipg)) {
 		err = PTR_ERR(imx_data->clk_ipg);
@@ -905,7 +913,7 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
 
 	host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;
 
-	if (is_imx25_esdhc(imx_data) || is_imx35_esdhc(imx_data))
+	if (imx_data->flags & ESDHC_FLAG_ENGCM07207)
 		/* Fix errata ENGcm07207 present on i.MX25 and i.MX35 */
 		host->quirks |= SDHCI_QUIRK_NO_MULTIBLOCK
 			| SDHCI_QUIRK_BROKEN_ADMA;
Signature · 4 lines
Pengutronix e.K.                           | Lucas Stach                 |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-5076 |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
author
#4 lore raw

PATCH 3/5 mmc: sdhci-esdhc-imx: add flag ESDHC_FLAG_USDHC

In reply to Shawn Guo

Add flag ESDHC_FLAG_USDHC to tell that the ESDHC is actually an USDHC block, and replace the is_imx6q_usdhc() occurrences with inline function esdhc_is_usdhc() which checks the flag.

---
 drivers/mmc/host/sdhci-esdhc-imx.c |   37 ++++++++++++++++++++++++------------
 1 file changed, 25 insertions(+), 12 deletions(-)
drivers/mmc/host/sdhci-esdhc-imx.c +25 -12
index a5d7d15..63a6024 100644
@@ -94,6 +94,11 @@
  * presents on i.MX25 and i.MX35.
  */
 #define ESDHC_FLAG_ENGCM07207		BIT(2)
+/*
+ * The flag tells that the ESDHC controller is an USDHC block that is
+ * integrated on the i.MX6 series.
+ */
+#define ESDHC_FLAG_USDHC		BIT(3)
 
 enum imx_esdhc_type {
 	IMX25_ESDHC,
@@ -180,6 +185,11 @@ static inline int is_imx6q_usdhc(struct pltfm_imx_data *data)
 	return data->devtype == IMX6Q_USDHC;
 }
 
+static inline int esdhc_is_usdhc(struct pltfm_imx_data *data)
+{
+	return !!(data->flags & ESDHC_FLAG_USDHC);
+}
+
 static inline void esdhc_clrset_le(struct sdhci_host *host, u32 mask, u32 val, int reg)
 {
 	void __iomem *base = host->ioaddr + (reg & ~0x3);
@@ -218,11 +228,11 @@ static u32 esdhc_readl_le(struct sdhci_host *host, int reg)
 		}
 	}
 
-	if (unlikely(reg == SDHCI_CAPABILITIES_1) && is_imx6q_usdhc(imx_data))
+	if (unlikely(reg == SDHCI_CAPABILITIES_1) && esdhc_is_usdhc(imx_data))
 		val = SDHCI_SUPPORT_DDR50 | SDHCI_SUPPORT_SDR104
 				| SDHCI_SUPPORT_SDR50;
 
-	if (unlikely(reg == SDHCI_MAX_CURRENT) && is_imx6q_usdhc(imx_data)) {
+	if (unlikely(reg == SDHCI_MAX_CURRENT) && esdhc_is_usdhc(imx_data)) {
 		val = 0;
 		val |= 0xFF << SDHCI_MAX_CURRENT_330_SHIFT;
 		val |= 0xFF << SDHCI_MAX_CURRENT_300_SHIFT;
@@ -312,7 +322,7 @@ static u16 esdhc_readw_le(struct sdhci_host *host, int reg)
 
 	if (unlikely(reg == SDHCI_HOST_VERSION)) {
 		reg ^= 2;
-		if (is_imx6q_usdhc(imx_data)) {
+		if (esdhc_is_usdhc(imx_data)) {
 			/*
 			 * The usdhc register returns a wrong host version.
 			 * Correct it here.
@@ -326,7 +336,7 @@ static u16 esdhc_readw_le(struct sdhci_host *host, int reg)
 		if (val & ESDHC_VENDOR_SPEC_VSELECT)
 			ret |= SDHCI_CTRL_VDD_180;
 
-		if (is_imx6q_usdhc(imx_data)) {
+		if (esdhc_is_usdhc(imx_data)) {
 			val = readl(host->ioaddr + ESDHC_MIX_CTRL);
 			if (val & ESDHC_MIX_CTRL_EXE_TUNE)
 				ret |= SDHCI_CTRL_EXEC_TUNING;
@@ -384,7 +394,7 @@ static void esdhc_writew_le(struct sdhci_host *host, u16 val, int reg)
 			writel(v, host->ioaddr + ESDHC_VENDOR_SPEC);
 		}
 
-		if (is_imx6q_usdhc(imx_data)) {
+		if (esdhc_is_usdhc(imx_data)) {
 			u32 m = readl(host->ioaddr + ESDHC_MIX_CTRL);
 			/* Swap AC23 bit */
 			if (val & SDHCI_TRNS_AUTO_CMD23) {
@@ -409,7 +419,7 @@ static void esdhc_writew_le(struct sdhci_host *host, u16 val, int reg)
 		    (imx_data->flags & ESDHC_FLAG_MULTIBLK_NO_INT))
 			imx_data->multiblock_status = MULTIBLK_IN_PROCESS;
 
-		if (is_imx6q_usdhc(imx_data))
+		if (esdhc_is_usdhc(imx_data))
 			writel(val << 16,
 			       host->ioaddr + SDHCI_TRANSFER_MODE);
 		else
@@ -475,7 +485,7 @@ static void esdhc_writeb_le(struct sdhci_host *host, u8 val, int reg)
 		 * The reset on usdhc fails to clear MIX_CTRL register.
 		 * Do it manually here.
 		 */
-		if (is_imx6q_usdhc(imx_data))
+		if (esdhc_is_usdhc(imx_data))
 			writel(0, host->ioaddr + ESDHC_MIX_CTRL);
 	}
 }
@@ -512,7 +522,7 @@ static inline void esdhc_pltfm_set_clock(struct sdhci_host *host,
 	u32 temp, val;
 
 	if (clock == 0) {
-		if (is_imx6q_usdhc(imx_data)) {
+		if (esdhc_is_usdhc(imx_data)) {
 			val = readl(host->ioaddr + ESDHC_VENDOR_SPEC);
 			writel(val & ~ESDHC_VENDOR_SPEC_FRC_SDCLK_ON,
 					host->ioaddr + ESDHC_VENDOR_SPEC);
@@ -520,7 +530,7 @@ static inline void esdhc_pltfm_set_clock(struct sdhci_host *host,
 		goto out;
 	}
 
-	if (is_imx6q_usdhc(imx_data))
+	if (esdhc_is_usdhc(imx_data))
 		pre_div = 1;
 
 	temp = sdhci_readl(host, ESDHC_SYSTEM_CONTROL);
@@ -547,7 +557,7 @@ static inline void esdhc_pltfm_set_clock(struct sdhci_host *host,
 		| (pre_div << ESDHC_PREDIV_SHIFT));
 	sdhci_writel(host, temp, ESDHC_SYSTEM_CONTROL);
 
-	if (is_imx6q_usdhc(imx_data)) {
+	if (esdhc_is_usdhc(imx_data)) {
 		val = readl(host->ioaddr + ESDHC_VENDOR_SPEC);
 		writel(val | ESDHC_VENDOR_SPEC_FRC_SDCLK_ON,
 		host->ioaddr + ESDHC_VENDOR_SPEC);
@@ -873,6 +883,9 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
 	if (is_imx25_esdhc(imx_data) || is_imx35_esdhc(imx_data))
 		imx_data->flags |= ESDHC_FLAG_ENGCM07207;
 
+	if (is_imx6q_usdhc(imx_data))
+		imx_data->flags |= ESDHC_FLAG_USDHC;
+
 	imx_data->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
 	if (IS_ERR(imx_data->clk_ipg)) {
 		err = PTR_ERR(imx_data->clk_ipg);
@@ -925,7 +938,7 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
 	 * The imx6q ROM code will change the default watermark level setting
 	 * to something insane.  Change it back here.
 	 */
-	if (is_imx6q_usdhc(imx_data))
+	if (esdhc_is_usdhc(imx_data))
 		writel(0x08100810, host->ioaddr + ESDHC_WTMK_LVL);
 
 	boarddata = &imx_data->boarddata;
@@ -988,7 +1001,7 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
 	}
 
 	/* sdr50 and sdr104 needs work on 1.8v signal voltage */
-	if ((boarddata->support_vsel) && is_imx6q_usdhc(imx_data)) {
+	if ((boarddata->support_vsel) && esdhc_is_usdhc(imx_data)) {
 		imx_data->pins_100mhz = pinctrl_lookup_state(imx_data->pinctrl,
 						ESDHC_PINCTRL_STATE_100MHZ);
 		imx_data->pins_200mhz = pinctrl_lookup_state(imx_data->pinctrl,
Signature · 1 line
1.7.9.5
author
#5 lore raw

PATCH 4/5 mmc: sdhci-esdhc-imx: pdev->id_entry should be immutable

In reply to Shawn Guo

As a good practice, device driver should not modify pdev->id_entry but keep it immutable. Let's assign of_device_id.data with imx_esdhc_type constants directly, so that we do not have to manipulate pdev->id_entry in .probe().

As the result, sdhci-esdhc-imx53 and sdhci-usdhc-imx6q can be removed from platform_device_id table now, since they will only probe from device tree.

---
 drivers/mmc/host/sdhci-esdhc-imx.c |   21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)
drivers/mmc/host/sdhci-esdhc-imx.c +7 -14
index 63a6024..f1e1385 100644
@@ -139,23 +139,17 @@ static struct platform_device_id imx_esdhc_devtype[] = {
 		.name = "sdhci-esdhc-imx51",
 		.driver_data = IMX51_ESDHC,
 	}, {
-		.name = "sdhci-esdhc-imx53",
-		.driver_data = IMX53_ESDHC,
-	}, {
-		.name = "sdhci-usdhc-imx6q",
-		.driver_data = IMX6Q_USDHC,
-	}, {
 		/* sentinel */
 	}
 };
 MODULE_DEVICE_TABLE(platform, imx_esdhc_devtype);
 
 static const struct of_device_id imx_esdhc_dt_ids[] = {
-	{ .compatible = "fsl,imx25-esdhc", .data = &imx_esdhc_devtype[IMX25_ESDHC], },
-	{ .compatible = "fsl,imx35-esdhc", .data = &imx_esdhc_devtype[IMX35_ESDHC], },
-	{ .compatible = "fsl,imx51-esdhc", .data = &imx_esdhc_devtype[IMX51_ESDHC], },
-	{ .compatible = "fsl,imx53-esdhc", .data = &imx_esdhc_devtype[IMX53_ESDHC], },
-	{ .compatible = "fsl,imx6q-usdhc", .data = &imx_esdhc_devtype[IMX6Q_USDHC], },
+	{ .compatible = "fsl,imx25-esdhc", .data = (void *) IMX25_ESDHC, },
+	{ .compatible = "fsl,imx35-esdhc", .data = (void *) IMX35_ESDHC, },
+	{ .compatible = "fsl,imx51-esdhc", .data = (void *) IMX51_ESDHC, },
+	{ .compatible = "fsl,imx53-esdhc", .data = (void *) IMX53_ESDHC, },
+	{ .compatible = "fsl,imx6q-usdhc", .data = (void *) IMX6Q_USDHC, },
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, imx_esdhc_dt_ids);
@@ -872,9 +866,8 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
 		goto free_sdhci;
 	}
 
-	if (of_id)
-		pdev->id_entry = of_id->data;
-	imx_data->devtype = pdev->id_entry->driver_data;
+	imx_data->devtype = of_id ? (enum imx_esdhc_type) of_id->data :
+				    pdev->id_entry->driver_data;
 	pltfm_host->priv = imx_data;
 
 	if (is_imx25_esdhc(imx_data))
Signature · 1 line
1.7.9.5
author
#6 lore raw

PATCH 5/5 mmc: sdhci-esdhc-imx: eliminate enum imx_esdhc_type

In reply to Shawn Guo

We now have 'flags' in struct pltfm_imx_data to identify the features and quirks for ESDHC variants running on different i.MX SoCs. The enum imx_esdhc_type can be eliminated by interpreting the ESDHC variants with the ESDHC_FLAG_* flags.

---
 drivers/mmc/host/sdhci-esdhc-imx.c |   52 +++++-------------------------------
 1 file changed, 6 insertions(+), 46 deletions(-)
drivers/mmc/host/sdhci-esdhc-imx.c +6 -46
index f1e1385..f2cd5b0 100644
@@ -100,18 +100,15 @@
  */
 #define ESDHC_FLAG_USDHC		BIT(3)
 
-enum imx_esdhc_type {
-	IMX25_ESDHC,
-	IMX35_ESDHC,
-	IMX51_ESDHC,
-	IMX53_ESDHC,
-	IMX6Q_USDHC,
-};
+#define IMX25_ESDHC	(ESDHC_FLAG_NO_DMAS_BITS | ESDHC_FLAG_ENGCM07207)
+#define IMX35_ESDHC	(ESDHC_FLAG_ENGCM07207)
+#define IMX51_ESDHC	(0)
+#define IMX53_ESDHC	(ESDHC_FLAG_MULTIBLK_NO_INT)
+#define IMX6Q_USDHC	(ESDHC_FLAG_USDHC)
 
 struct pltfm_imx_data {
 	int flags;
 	u32 scratchpad;
-	enum imx_esdhc_type devtype;
 	struct pinctrl *pinctrl;
 	struct pinctrl_state *pins_default;
 	struct pinctrl_state *pins_100mhz;
@@ -154,31 +151,6 @@ static const struct of_device_id imx_esdhc_dt_ids[] = {
 };
 MODULE_DEVICE_TABLE(of, imx_esdhc_dt_ids);
 
-static inline int is_imx25_esdhc(struct pltfm_imx_data *data)
-{
-	return data->devtype == IMX25_ESDHC;
-}
-
-static inline int is_imx35_esdhc(struct pltfm_imx_data *data)
-{
-	return data->devtype == IMX35_ESDHC;
-}
-
-static inline int is_imx51_esdhc(struct pltfm_imx_data *data)
-{
-	return data->devtype == IMX51_ESDHC;
-}
-
-static inline int is_imx53_esdhc(struct pltfm_imx_data *data)
-{
-	return data->devtype == IMX53_ESDHC;
-}
-
-static inline int is_imx6q_usdhc(struct pltfm_imx_data *data)
-{
-	return data->devtype == IMX6Q_USDHC;
-}
-
 static inline int esdhc_is_usdhc(struct pltfm_imx_data *data)
 {
 	return !!(data->flags & ESDHC_FLAG_USDHC);
@@ -866,19 +838,10 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
 		goto free_sdhci;
 	}
 
-	imx_data->devtype = of_id ? (enum imx_esdhc_type) of_id->data :
+	imx_data->flags = of_id ? (int) of_id->data :
 				    pdev->id_entry->driver_data;
 	pltfm_host->priv = imx_data;
 
-	if (is_imx25_esdhc(imx_data))
-		imx_data->flags |= ESDHC_FLAG_NO_DMAS_BITS;
-
-	if (is_imx25_esdhc(imx_data) || is_imx35_esdhc(imx_data))
-		imx_data->flags |= ESDHC_FLAG_ENGCM07207;
-
-	if (is_imx6q_usdhc(imx_data))
-		imx_data->flags |= ESDHC_FLAG_USDHC;
-
 	imx_data->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
 	if (IS_ERR(imx_data->clk_ipg)) {
 		err = PTR_ERR(imx_data->clk_ipg);
@@ -924,9 +887,6 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
 		host->quirks |= SDHCI_QUIRK_NO_MULTIBLOCK
 			| SDHCI_QUIRK_BROKEN_ADMA;
 
-	if (is_imx53_esdhc(imx_data))
-		imx_data->flags |= ESDHC_FLAG_MULTIBLK_NO_INT;
-
 	/*
 	 * The imx6q ROM code will change the default watermark level setting
 	 * to something insane.  Change it back here.
Signature · 1 line
1.7.9.5
#7 lore raw

PATCH 5/5 mmc: sdhci-esdhc-imx: eliminate enum imx_esdhc_type

Hi Shawn,

Am Montag, den 14.10.2013, 16:23 +0800 schrieb Shawn Guo:

Quoted 21 lines

We now have 'flags' in struct pltfm_imx_data to identify the features and quirks for ESDHC variants running on different i.MX SoCs. The enum imx_esdhc_type can be eliminated by interpreting the ESDHC variants with the ESDHC_FLAG_* flags.

---
 drivers/mmc/host/sdhci-esdhc-imx.c |   52 +++++-------------------------------
 1 file changed, 6 insertions(+), 46 deletions(-)
drivers/mmc/host/sdhci-esdhc-imx.c +0 -3
index f1e1385..f2cd5b0 100644
@@ -100,18 +100,15 @@
  */
 #define ESDHC_FLAG_USDHC		BIT(3)
 
-enum imx_esdhc_type {
-	IMX25_ESDHC,
-	IMX35_ESDHC,

drivers/mmc/host/sdhci-esdhc-imx.c line 108

Quoted 10 lines
drivers/mmc/host/sdhci-esdhc-imx.c +5 -4
-	IMX51_ESDHC,
-	IMX53_ESDHC,
-	IMX6Q_USDHC,
-};
+#define IMX25_ESDHC	(ESDHC_FLAG_NO_DMAS_BITS | ESDHC_FLAG_ENGCM07207)
+#define IMX35_ESDHC	(ESDHC_FLAG_ENGCM07207)
+#define IMX51_ESDHC	(0)
+#define IMX53_ESDHC	(ESDHC_FLAG_MULTIBLK_NO_INT)
+#define IMX6Q_USDHC	(ESDHC_FLAG_USDHC)
 

This looks really nasty to me, especially with the needed void pointer cast you added in the previous patch.

Can you please introduce a proper driver data struct, with the flags field in it? This will make this thing a lot cleaner, more future proof and shouldn't add any overhead in the generated code.

Regards,
Lucas

Quoted 70 lines
drivers/mmc/host/sdhci-esdhc-imx.c +1 -39
 struct pltfm_imx_data {
 	int flags;
 	u32 scratchpad;
-	enum imx_esdhc_type devtype;
 	struct pinctrl *pinctrl;
 	struct pinctrl_state *pins_default;
 	struct pinctrl_state *pins_100mhz;
@@ -154,31 +151,6 @@ static const struct of_device_id imx_esdhc_dt_ids[] = {
 };
 MODULE_DEVICE_TABLE(of, imx_esdhc_dt_ids);
 
-static inline int is_imx25_esdhc(struct pltfm_imx_data *data)
-{
-	return data->devtype == IMX25_ESDHC;
-}
-
-static inline int is_imx35_esdhc(struct pltfm_imx_data *data)
-{
-	return data->devtype == IMX35_ESDHC;
-}
-
-static inline int is_imx51_esdhc(struct pltfm_imx_data *data)
-{
-	return data->devtype == IMX51_ESDHC;
-}
-
-static inline int is_imx53_esdhc(struct pltfm_imx_data *data)
-{
-	return data->devtype == IMX53_ESDHC;
-}
-
-static inline int is_imx6q_usdhc(struct pltfm_imx_data *data)
-{
-	return data->devtype == IMX6Q_USDHC;
-}
-
 static inline int esdhc_is_usdhc(struct pltfm_imx_data *data)
 {
 	return !!(data->flags & ESDHC_FLAG_USDHC);
@@ -866,19 +838,10 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
 		goto free_sdhci;
 	}
 
-	imx_data->devtype = of_id ? (enum imx_esdhc_type) of_id->data :
+	imx_data->flags = of_id ? (int) of_id->data :
 				    pdev->id_entry->driver_data;
 	pltfm_host->priv = imx_data;
 
-	if (is_imx25_esdhc(imx_data))
-		imx_data->flags |= ESDHC_FLAG_NO_DMAS_BITS;
-
-	if (is_imx25_esdhc(imx_data) || is_imx35_esdhc(imx_data))
-		imx_data->flags |= ESDHC_FLAG_ENGCM07207;
-
-	if (is_imx6q_usdhc(imx_data))
-		imx_data->flags |= ESDHC_FLAG_USDHC;
-
 	imx_data->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
 	if (IS_ERR(imx_data->clk_ipg)) {
 		err = PTR_ERR(imx_data->clk_ipg);
@@ -924,9 +887,6 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
 		host->quirks |= SDHCI_QUIRK_NO_MULTIBLOCK
 			| SDHCI_QUIRK_BROKEN_ADMA;
 
-	if (is_imx53_esdhc(imx_data))
-		imx_data->flags |= ESDHC_FLAG_MULTIBLK_NO_INT;
-
 	/*
 	 * The imx6q ROM code will change the default watermark level setting
 	 * to something insane.  Change it back here.
Signature · 4 lines
Pengutronix e.K.                           | Lucas Stach                 |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-5076 |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
author
#8 lore raw

PATCH 5/5 mmc: sdhci-esdhc-imx: eliminate enum imx_esdhc_type

Quoted 8 lines · Lucas Stach

drivers/mmc/host/sdhci-esdhc-imx.c line 107

Quoted 6 lines
drivers/mmc/host/sdhci-esdhc-imx.c +5 -0
+#define IMX25_ESDHC	(ESDHC_FLAG_NO_DMAS_BITS | ESDHC_FLAG_ENGCM07207)
+#define IMX35_ESDHC	(ESDHC_FLAG_ENGCM07207)
+#define IMX51_ESDHC	(0)
+#define IMX53_ESDHC	(ESDHC_FLAG_MULTIBLK_NO_INT)
+#define IMX6Q_USDHC	(ESDHC_FLAG_USDHC)

This looks really nasty to me, especially with the needed void pointer cast you added in the previous patch.

Yes, it does, when you look at from of_device_id.data. But keep it in mind, that platform_device_id.driver data is type kernel_ulong_t not void *. So while we add a structure with the flags field in it to save the cast on of_device_id.data, we will have to add a cast for platform_device_id.driver.

Quoted 3 lines

Can you please introduce a proper driver data struct, with the flags field in it? This will make this thing a lot cleaner, more future proof and shouldn't add any overhead in the generated code.

But I agree with you that using a data structure is more future proof, so will do in v2.

Shawn

author
#9 lore raw

PATCH 5/5 mmc: sdhci-esdhc-imx: eliminate enum imx_esdhc_type

Quoted 16 lines · Shawn Guo
Quoted 8 lines · Lucas Stach

drivers/mmc/host/sdhci-esdhc-imx.c line 107

Quoted 6 lines
drivers/mmc/host/sdhci-esdhc-imx.c +5 -0
+#define IMX25_ESDHC	(ESDHC_FLAG_NO_DMAS_BITS | ESDHC_FLAG_ENGCM07207)
+#define IMX35_ESDHC	(ESDHC_FLAG_ENGCM07207)
+#define IMX51_ESDHC	(0)
+#define IMX53_ESDHC	(ESDHC_FLAG_MULTIBLK_NO_INT)
+#define IMX6Q_USDHC	(ESDHC_FLAG_USDHC)

This looks really nasty to me, especially with the needed void pointer cast you added in the previous patch.

Yes, it does, when you look at from of_device_id.data. But keep it in mind, that platform_device_id.driver data is type kernel_ulong_t not void *. So while we add a structure with the flags field in it to save the cast on of_device_id.data, we will have to add a cast for platform_device_id.driver.

Quoted 6 lines
Quoted 3 lines

Can you please introduce a proper driver data struct, with the flags field in it? This will make this thing a lot cleaner, more future proof and shouldn't add any overhead in the generated code.

But I agree with you that using a data structure is more future proof, so will do in v2.

I will send an additional patch to make the change for keeping the history more clear.

Shawn

#10 lore raw

PATCH 5/5 mmc: sdhci-esdhc-imx: eliminate enum imx_esdhc_type

In reply to Shawn Guo
Quoted 15 lines · Shawn Guo

We now have 'flags' in struct pltfm_imx_data to identify the features and quirks for ESDHC variants running on different i.MX SoCs. The enum imx_esdhc_type can be eliminated by interpreting the ESDHC variants with the ESDHC_FLAG_* flags.

---
 drivers/mmc/host/sdhci-esdhc-imx.c |   52 +++++-------------------------------
 1 file changed, 6 insertions(+), 46 deletions(-)
drivers/mmc/host/sdhci-esdhc-imx.c +0 -0
index f1e1385..f2cd5b0 100644
@@ -100,18 +100,15 @@

[...]

drivers/mmc/host/sdhci-esdhc-imx.c line 107

Quoted 5 lines
drivers/mmc/host/sdhci-esdhc-imx.c +4 -0
+#define IMX35_ESDHC	(ESDHC_FLAG_ENGCM07207)
+#define IMX51_ESDHC	(0)
+#define IMX53_ESDHC	(ESDHC_FLAG_MULTIBLK_NO_INT)
+#define IMX6Q_USDHC	(ESDHC_FLAG_USDHC)

Useless parenthesis.

Lothar Wa?mann

Signature · 9 lines
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Gesch?ftsf?hrer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info at karo-electronics.de
___________________________________________________________
author
#11 lore raw

PATCH 6/6 mmc: sdhci-esdhc-imx: create struct esdhc_soc_data

In reply to Shawn Guo

Currently, the SoC functional flags are passed through of_device_id.data by casting the integer to void pointer. This is less scalable considering we may have more SoC specific data to define in the future.

Let's create a struct esdhc_soc_data to define SoC specific data like the 'flags' and pass the data using the structure pointer.

---
 drivers/mmc/host/sdhci-esdhc-imx.c |   62 +++++++++++++++++++++++-------------
 1 file changed, 40 insertions(+), 22 deletions(-)
drivers/mmc/host/sdhci-esdhc-imx.c +40 -22
index f2cd5b0..d3d34cf 100644
@@ -100,19 +100,37 @@
  */
 #define ESDHC_FLAG_USDHC		BIT(3)
 
-#define IMX25_ESDHC	(ESDHC_FLAG_NO_DMAS_BITS | ESDHC_FLAG_ENGCM07207)
-#define IMX35_ESDHC	(ESDHC_FLAG_ENGCM07207)
-#define IMX51_ESDHC	(0)
-#define IMX53_ESDHC	(ESDHC_FLAG_MULTIBLK_NO_INT)
-#define IMX6Q_USDHC	(ESDHC_FLAG_USDHC)
+struct esdhc_soc_data {
+	u32 flags;
+};
+
+static struct esdhc_soc_data esdhc_imx25_data = {
+	.flags = ESDHC_FLAG_NO_DMAS_BITS | ESDHC_FLAG_ENGCM07207,
+};
+
+static struct esdhc_soc_data esdhc_imx35_data = {
+	.flags = ESDHC_FLAG_ENGCM07207,
+};
+
+static struct esdhc_soc_data esdhc_imx51_data = {
+	.flags = 0,
+};
+
+static struct esdhc_soc_data esdhc_imx53_data = {
+	.flags = ESDHC_FLAG_MULTIBLK_NO_INT,
+};
+
+static struct esdhc_soc_data esdhc_imx6q_data = {
+	.flags = ESDHC_FLAG_USDHC,
+};
 
 struct pltfm_imx_data {
-	int flags;
 	u32 scratchpad;
 	struct pinctrl *pinctrl;
 	struct pinctrl_state *pins_default;
 	struct pinctrl_state *pins_100mhz;
 	struct pinctrl_state *pins_200mhz;
+	const struct esdhc_soc_data *socdata;
 	struct esdhc_platform_data boarddata;
 	struct clk *clk_ipg;
 	struct clk *clk_ahb;
@@ -128,13 +146,13 @@ struct pltfm_imx_data {
 static struct platform_device_id imx_esdhc_devtype[] = {
 	{
 		.name = "sdhci-esdhc-imx25",
-		.driver_data = IMX25_ESDHC,
+		.driver_data = (kernel_ulong_t) &esdhc_imx25_data,
 	}, {
 		.name = "sdhci-esdhc-imx35",
-		.driver_data = IMX35_ESDHC,
+		.driver_data = (kernel_ulong_t) &esdhc_imx35_data,
 	}, {
 		.name = "sdhci-esdhc-imx51",
-		.driver_data = IMX51_ESDHC,
+		.driver_data = (kernel_ulong_t) &esdhc_imx51_data,
 	}, {
 		/* sentinel */
 	}
@@ -142,18 +160,18 @@ static struct platform_device_id imx_esdhc_devtype[] = {
 MODULE_DEVICE_TABLE(platform, imx_esdhc_devtype);
 
 static const struct of_device_id imx_esdhc_dt_ids[] = {
-	{ .compatible = "fsl,imx25-esdhc", .data = (void *) IMX25_ESDHC, },
-	{ .compatible = "fsl,imx35-esdhc", .data = (void *) IMX35_ESDHC, },
-	{ .compatible = "fsl,imx51-esdhc", .data = (void *) IMX51_ESDHC, },
-	{ .compatible = "fsl,imx53-esdhc", .data = (void *) IMX53_ESDHC, },
-	{ .compatible = "fsl,imx6q-usdhc", .data = (void *) IMX6Q_USDHC, },
+	{ .compatible = "fsl,imx25-esdhc", .data = &esdhc_imx25_data, },
+	{ .compatible = "fsl,imx35-esdhc", .data = &esdhc_imx35_data, },
+	{ .compatible = "fsl,imx51-esdhc", .data = &esdhc_imx51_data, },
+	{ .compatible = "fsl,imx53-esdhc", .data = &esdhc_imx53_data, },
+	{ .compatible = "fsl,imx6q-usdhc", .data = &esdhc_imx6q_data, },
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, imx_esdhc_dt_ids);
 
 static inline int esdhc_is_usdhc(struct pltfm_imx_data *data)
 {
-	return !!(data->flags & ESDHC_FLAG_USDHC);
+	return !!(data->socdata->flags & ESDHC_FLAG_USDHC);
 }
 
 static inline void esdhc_clrset_le(struct sdhci_host *host, u32 mask, u32 val, int reg)
@@ -251,7 +269,7 @@ static void esdhc_writel_le(struct sdhci_host *host, u32 val, int reg)
 		}
 	}
 
-	if (unlikely((imx_data->flags & ESDHC_FLAG_MULTIBLK_NO_INT)
+	if (unlikely((imx_data->socdata->flags & ESDHC_FLAG_MULTIBLK_NO_INT)
 				&& (reg == SDHCI_INT_STATUS)
 				&& (val & SDHCI_INT_DATA_END))) {
 			u32 v;
@@ -350,7 +368,7 @@ static void esdhc_writew_le(struct sdhci_host *host, u16 val, int reg)
 		writel(new_val , host->ioaddr + ESDHC_MIX_CTRL);
 		return;
 	case SDHCI_TRANSFER_MODE:
-		if ((imx_data->flags & ESDHC_FLAG_MULTIBLK_NO_INT)
+		if ((imx_data->socdata->flags & ESDHC_FLAG_MULTIBLK_NO_INT)
 				&& (host->cmd->opcode == SD_IO_RW_EXTENDED)
 				&& (host->cmd->data->blocks > 1)
 				&& (host->cmd->data->flags & MMC_DATA_READ)) {
@@ -382,7 +400,7 @@ static void esdhc_writew_le(struct sdhci_host *host, u16 val, int reg)
 			val |= SDHCI_CMD_ABORTCMD;
 
 		if ((host->cmd->opcode == MMC_SET_BLOCK_COUNT) &&
-		    (imx_data->flags & ESDHC_FLAG_MULTIBLK_NO_INT))
+		    (imx_data->socdata->flags & ESDHC_FLAG_MULTIBLK_NO_INT))
 			imx_data->multiblock_status = MULTIBLK_IN_PROCESS;
 
 		if (esdhc_is_usdhc(imx_data))
@@ -419,7 +437,7 @@ static void esdhc_writeb_le(struct sdhci_host *host, u8 val, int reg)
 		/* ensure the endianness */
 		new_val |= ESDHC_HOST_CONTROL_LE;
 		/* bits 8&9 are reserved on mx25 */
-		if (!(imx_data->flags & ESDHC_FLAG_NO_DMAS_BITS)) {
+		if (!(imx_data->socdata->flags & ESDHC_FLAG_NO_DMAS_BITS)) {
 			/* DMA mode bits are shifted */
 			new_val |= (val & SDHCI_CTRL_DMA_MASK) << 5;
 		}
@@ -838,8 +856,8 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
 		goto free_sdhci;
 	}
 
-	imx_data->flags = of_id ? (int) of_id->data :
-				    pdev->id_entry->driver_data;
+	imx_data->socdata = of_id ? of_id->data : (struct esdhc_soc_data *)
+						  pdev->id_entry->driver_data;
 	pltfm_host->priv = imx_data;
 
 	imx_data->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
@@ -882,7 +900,7 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
 
 	host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;
 
-	if (imx_data->flags & ESDHC_FLAG_ENGCM07207)
+	if (imx_data->socdata->flags & ESDHC_FLAG_ENGCM07207)
 		/* Fix errata ENGcm07207 present on i.MX25 and i.MX35 */
 		host->quirks |= SDHCI_QUIRK_NO_MULTIBLOCK
 			| SDHCI_QUIRK_BROKEN_ADMA;
Signature · 1 line
1.7.9.5
#12 lore raw

cover mmc: sdhci-esdhc-imx: eliminate enum imx_esdhc_type

In reply to Shawn Guo

Am Montag, den 14.10.2013, 16:23 +0800 schrieb Shawn Guo:

Quoted 7 lines

When I was reviewing Dong's imx6sl standard tuning patches, I found that it's a little clumsy to use enum imx_esdhc_type for handling features and quirks on different esdhc variants. Instead, the approach used in fec driver (drivers/net/ethernet/freescale/fec_main.c) should be more scalable in the long run. It defines flags for all those features and quirks and creates a mapping between esdhc variant and the flags.

Quoted 6 lines

Actually, sdhci-esdhc-imx driver already has one such flag, i.e. ESDHC_FLAG_MULTIBLK_NO_INT, but there is currently an unnecessary translation between the flag and imx_esdhc_type. The series creates another 3 flags and identify features/quirks using these flags and then eliminate enum imx_esdhc_type completely.

Other than the comment on patch 2 this series, with the addition of patch 6/6 is

Quoted 10 lines

Shawn Guo (5):
mmc: sdhci-esdhc-imx: add flag ESDHC_FLAG_NO_DMAS_BITS
mmc: sdhci-esdhc-imx: add flag ESDHC_FLAG_ENGCM07207
mmc: sdhci-esdhc-imx: add flag ESDHC_FLAG_USDHC
mmc: sdhci-esdhc-imx: pdev->id_entry should be immutable
mmc: sdhci-esdhc-imx: eliminate enum imx_esdhc_type

 drivers/mmc/host/sdhci-esdhc-imx.c |  108 +++++++++++++++---------------------
 1 file changed, 45 insertions(+), 63 deletions(-)
Signature · 4 lines
Pengutronix e.K.                           | Lucas Stach                 |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-5076 |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#13 lore raw

cover mmc: sdhci-esdhc-imx: eliminate enum imx_esdhc_type

In reply to Shawn Guo
Quoted 9 lines · Shawn Guo

When I was reviewing Dong's imx6sl standard tuning patches, I found that it's a little clumsy to use enum imx_esdhc_type for handling features and quirks on different esdhc variants.

Instead, the approach used in
fec driver (drivers/net/ethernet/freescale/fec_main.c) should be more scalable in the long run. It defines flags for all those features and quirks and creates a mapping between esdhc variant and the flags.

It cause troubles if i try to rebase my patch series based on it because esdhc/usdhc also have a lot register difference.

Originally we could simply use is_imx*_usdhc to handle those tiny difference, however, now if you eliminate the entire is_imx*_usdhc, we may have to add a lot arbitrary and hard to naming flags for register offset/mask different issue.
It does not make too much sense.
e.g.
http://www.spinics.net/lists/arm-kernel/msg278507.html
http://permalink.gmane.org/gmane.linux.kernel.mmc/22934
Add maybe even more when we keep adding new features like:
mx5 DDR support and etc.(register offset is different between imx5&imx6) It's hard to say how many similar cases left for me currently.

Looking at fec_main.c, the flags seem more like for simply features. Not the same complicated situation as esdhc/usdhc.
I'm not sure this is so suitable for esdhc/usdhc.

Due to the problems this patch may introduce, it's probably may be good to stick the old way to me since i did not see quite neccessary to switch to new way on current code.
Or you may find a better fix for this issue.

Regards
Dong Aisheng

Quoted 19 lines

Actually, sdhci-esdhc-imx driver already has one such flag, i.e. ESDHC_FLAG_MULTIBLK_NO_INT, but there is currently an unnecessary translation between the flag and imx_esdhc_type. The series creates another 3 flags and identify features/quirks using these flags and then eliminate enum imx_esdhc_type completely.

Shawn Guo (5):
mmc: sdhci-esdhc-imx: add flag ESDHC_FLAG_NO_DMAS_BITS
mmc: sdhci-esdhc-imx: add flag ESDHC_FLAG_ENGCM07207
mmc: sdhci-esdhc-imx: add flag ESDHC_FLAG_USDHC
mmc: sdhci-esdhc-imx: pdev->id_entry should be immutable
mmc: sdhci-esdhc-imx: eliminate enum imx_esdhc_type

 drivers/mmc/host/sdhci-esdhc-imx.c |  108 +++++++++++++++---------------------
 1 file changed, 45 insertions(+), 63 deletions(-)
Signature · 1 line
1.7.9.5
author
#14 lore raw

cover mmc: sdhci-esdhc-imx: eliminate enum imx_esdhc_type

Quoted 5 lines · Dong Aisheng
Quoted 4 lines · Shawn Guo

When I was reviewing Dong's imx6sl standard tuning patches, I found that it's a little clumsy to use enum imx_esdhc_type for handling features and quirks on different esdhc variants.

Quoted 8 lines
Quoted 5 lines

Instead, the approach used in
fec driver (drivers/net/ethernet/freescale/fec_main.c) should be more scalable in the long run. It defines flags for all those features and quirks and creates a mapping between esdhc variant and the flags.

It cause troubles if i try to rebase my patch series based on it because esdhc/usdhc also have a lot register difference.

We now have data structure esdhc_soc_data, which can handle whatever differences between these variants.

Quoted 1 line

Originally we could simply use is_imx*_usdhc to handle those tiny difference,

No. The addition of is_imx6_usdhc() is a sign that we're not going to handle these differences easily. Saying if a feature like std_tuning is only available on imx6sl and imx6slx, is_imx6_usdhc() will not fit then, and you need if (is_imx6sl_usdhc() || is_imx6slx_usdhc()) for it. Furthermore, think about it when you have imx7x come to play here, something like if (is_imx6sl_usdhc() || is_imx6slx_usdhc() || is_imx7x_usdhc())? The if-clause will become a mess sooner or later.

Quoted 7 lines

however, now if you eliminate the entire is_imx*_usdhc, we may have to add a lot arbitrary and hard to naming flags for register offset/mask different issue.
It does not make too much sense.
e.g.
http://www.spinics.net/lists/arm-kernel/msg278507.html
http://permalink.gmane.org/gmane.linux.kernel.mmc/22934

Having flags for them make sense to me. By doing so, we can get the "characters" of particular SoC from reading its 'flags' variable.

Quoted 3 lines

Add maybe even more when we keep adding new features like:
mx5 DDR support and etc.(register offset is different between imx5&imx6) It's hard to say how many similar cases left for me currently.

The register difference introduced by adding new features can just be covered by the feature flag, I think.

Shawn

Quoted 8 lines

Looking at fec_main.c, the flags seem more like for simply features. Not the same complicated situation as esdhc/usdhc.
I'm not sure this is so suitable for esdhc/usdhc.

Due to the problems this patch may introduce, it's probably may be good to stick the old way to me since i did not see quite neccessary to switch to new way on current code.
Or you may find a better fix for this issue.

author
#15 lore raw

cover mmc: sdhci-esdhc-imx: eliminate enum imx_esdhc_type

In reply to Dong Aisheng
Quoted 11 lines · Dong Aisheng
Quoted 9 lines · Shawn Guo

When I was reviewing Dong's imx6sl standard tuning patches, I found that it's a little clumsy to use enum imx_esdhc_type for handling features and quirks on different esdhc variants.

Instead, the approach used in
fec driver (drivers/net/ethernet/freescale/fec_main.c) should be more scalable in the long run. It defines flags for all those features and quirks and creates a mapping between esdhc variant and the flags.

Quoted 4 lines

It cause troubles if i try to rebase my patch series based on it because esdhc/usdhc also have a lot register difference.

Originally we could simply use is_imx*_usdhc to handle those tiny difference,

Okay. After you demonstrate those register differences we will need to handle, I agree that is_imx*_usdhc() thing might be more handy than flags for handling those tiny register differences. So I will respin the series to create flags only for those features, quirk, errata such things and leave the register differences to be handled by is_imx*_usdhc().

Shawn