All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] mmc: sdhci-esdhc-imx: eliminate enum imx_esdhc_type
@ 2013-10-14  8:23 ` Shawn Guo
  0 siblings, 0 replies; 32+ messages in thread
From: Shawn Guo @ 2013-10-14  8:23 UTC (permalink / raw)
  To: linux-mmc; +Cc: Dong Aisheng, Chris Ball, linux-arm-kernel, 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.

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(-)

-- 
1.7.9.5



^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 0/5] mmc: sdhci-esdhc-imx: eliminate enum imx_esdhc_type
@ 2013-10-14  8:23 ` Shawn Guo
  0 siblings, 0 replies; 32+ messages in thread
From: Shawn Guo @ 2013-10-14  8:23 UTC (permalink / raw)
  To: linux-arm-kernel

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(-)

-- 
1.7.9.5

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 1/5] mmc: sdhci-esdhc-imx: add flag ESDHC_FLAG_NO_DMAS_BITS
  2013-10-14  8:23 ` Shawn Guo
@ 2013-10-14  8:23   ` Shawn Guo
  -1 siblings, 0 replies; 32+ messages in thread
From: Shawn Guo @ 2013-10-14  8:23 UTC (permalink / raw)
  To: linux-mmc; +Cc: Dong Aisheng, Chris Ball, linux-arm-kernel, Shawn Guo

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.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/mmc/host/sdhci-esdhc-imx.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index b9899e9..e046917 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -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);
-- 
1.7.9.5



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 1/5] mmc: sdhci-esdhc-imx: add flag ESDHC_FLAG_NO_DMAS_BITS
@ 2013-10-14  8:23   ` Shawn Guo
  0 siblings, 0 replies; 32+ messages in thread
From: Shawn Guo @ 2013-10-14  8:23 UTC (permalink / raw)
  To: linux-arm-kernel

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.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/mmc/host/sdhci-esdhc-imx.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index b9899e9..e046917 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -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);
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 2/5] mmc: sdhci-esdhc-imx: add flag ESDHC_FLAG_ENGCM07207
  2013-10-14  8:23 ` Shawn Guo
@ 2013-10-14  8:23   ` Shawn Guo
  -1 siblings, 0 replies; 32+ messages in thread
From: Shawn Guo @ 2013-10-14  8:23 UTC (permalink / raw)
  To: linux-mmc; +Cc: Dong Aisheng, Chris Ball, linux-arm-kernel, 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.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/mmc/host/sdhci-esdhc-imx.c |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index e046917..a5d7d15 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -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;
-- 
1.7.9.5



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 2/5] mmc: sdhci-esdhc-imx: add flag ESDHC_FLAG_ENGCM07207
@ 2013-10-14  8:23   ` Shawn Guo
  0 siblings, 0 replies; 32+ messages in thread
From: Shawn Guo @ 2013-10-14  8:23 UTC (permalink / raw)
  To: linux-arm-kernel

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

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/mmc/host/sdhci-esdhc-imx.c |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index e046917..a5d7d15 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -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;
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 3/5] mmc: sdhci-esdhc-imx: add flag ESDHC_FLAG_USDHC
  2013-10-14  8:23 ` Shawn Guo
@ 2013-10-14  8:23   ` Shawn Guo
  -1 siblings, 0 replies; 32+ messages in thread
From: Shawn Guo @ 2013-10-14  8:23 UTC (permalink / raw)
  To: linux-mmc; +Cc: Dong Aisheng, Chris Ball, linux-arm-kernel, 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.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/mmc/host/sdhci-esdhc-imx.c |   37 ++++++++++++++++++++++++------------
 1 file changed, 25 insertions(+), 12 deletions(-)

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index a5d7d15..63a6024 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -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,
-- 
1.7.9.5



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 3/5] mmc: sdhci-esdhc-imx: add flag ESDHC_FLAG_USDHC
@ 2013-10-14  8:23   ` Shawn Guo
  0 siblings, 0 replies; 32+ messages in thread
From: Shawn Guo @ 2013-10-14  8:23 UTC (permalink / raw)
  To: linux-arm-kernel

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.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/mmc/host/sdhci-esdhc-imx.c |   37 ++++++++++++++++++++++++------------
 1 file changed, 25 insertions(+), 12 deletions(-)

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index a5d7d15..63a6024 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -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,
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 4/5] mmc: sdhci-esdhc-imx: pdev->id_entry should be immutable
  2013-10-14  8:23 ` Shawn Guo
@ 2013-10-14  8:23   ` Shawn Guo
  -1 siblings, 0 replies; 32+ messages in thread
From: Shawn Guo @ 2013-10-14  8:23 UTC (permalink / raw)
  To: linux-mmc; +Cc: Dong Aisheng, Chris Ball, linux-arm-kernel, 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.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/mmc/host/sdhci-esdhc-imx.c |   21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index 63a6024..f1e1385 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -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))
-- 
1.7.9.5



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 4/5] mmc: sdhci-esdhc-imx: pdev->id_entry should be immutable
@ 2013-10-14  8:23   ` Shawn Guo
  0 siblings, 0 replies; 32+ messages in thread
From: Shawn Guo @ 2013-10-14  8:23 UTC (permalink / raw)
  To: linux-arm-kernel

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.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/mmc/host/sdhci-esdhc-imx.c |   21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index 63a6024..f1e1385 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -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))
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 5/5] mmc: sdhci-esdhc-imx: eliminate enum imx_esdhc_type
  2013-10-14  8:23 ` Shawn Guo
@ 2013-10-14  8:23   ` Shawn Guo
  -1 siblings, 0 replies; 32+ messages in thread
From: Shawn Guo @ 2013-10-14  8:23 UTC (permalink / raw)
  To: linux-mmc; +Cc: Dong Aisheng, Chris Ball, linux-arm-kernel, 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.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/mmc/host/sdhci-esdhc-imx.c |   52 +++++-------------------------------
 1 file changed, 6 insertions(+), 46 deletions(-)

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index f1e1385..f2cd5b0 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -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.
-- 
1.7.9.5



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 5/5] mmc: sdhci-esdhc-imx: eliminate enum imx_esdhc_type
@ 2013-10-14  8:23   ` Shawn Guo
  0 siblings, 0 replies; 32+ messages in thread
From: Shawn Guo @ 2013-10-14  8:23 UTC (permalink / raw)
  To: linux-arm-kernel

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.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/mmc/host/sdhci-esdhc-imx.c |   52 +++++-------------------------------
 1 file changed, 6 insertions(+), 46 deletions(-)

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index f1e1385..f2cd5b0 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -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.
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* Re: [PATCH 5/5] mmc: sdhci-esdhc-imx: eliminate enum imx_esdhc_type
  2013-10-14  8:23   ` Shawn Guo
@ 2013-10-14  8:31     ` Lucas Stach
  -1 siblings, 0 replies; 32+ messages in thread
From: Lucas Stach @ 2013-10-14  8:31 UTC (permalink / raw)
  To: Shawn Guo; +Cc: linux-mmc, Chris Ball, Dong Aisheng, linux-arm-kernel

Hi Shawn,

Am Montag, den 14.10.2013, 16:23 +0800 schrieb 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.
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> ---
>  drivers/mmc/host/sdhci-esdhc-imx.c |   52 +++++-------------------------------
>  1 file changed, 6 insertions(+), 46 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
> index f1e1385..f2cd5b0 100644
> --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> @@ -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)
>  
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
>  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.

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


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 5/5] mmc: sdhci-esdhc-imx: eliminate enum imx_esdhc_type
@ 2013-10-14  8:31     ` Lucas Stach
  0 siblings, 0 replies; 32+ messages in thread
From: Lucas Stach @ 2013-10-14  8:31 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Shawn,

Am Montag, den 14.10.2013, 16:23 +0800 schrieb 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.
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> ---
>  drivers/mmc/host/sdhci-esdhc-imx.c |   52 +++++-------------------------------
>  1 file changed, 6 insertions(+), 46 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
> index f1e1385..f2cd5b0 100644
> --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> @@ -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)
>  
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
>  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.

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

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 5/5] mmc: sdhci-esdhc-imx: eliminate enum imx_esdhc_type
  2013-10-14  8:23   ` Shawn Guo
@ 2013-10-14  8:44     ` Lothar Waßmann
  -1 siblings, 0 replies; 32+ messages in thread
From: Lothar Waßmann @ 2013-10-14  8:44 UTC (permalink / raw)
  To: Shawn Guo; +Cc: linux-mmc, Chris Ball, Dong Aisheng, linux-arm-kernel


Shawn Guo wrote:
> 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.
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> ---
>  drivers/mmc/host/sdhci-esdhc-imx.c |   52 +++++-------------------------------
>  1 file changed, 6 insertions(+), 46 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
> index f1e1385..f2cd5b0 100644
> --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> @@ -100,18 +100,15 @@
[...]
> +#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
-- 
___________________________________________________________

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@karo-electronics.de
___________________________________________________________

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 5/5] mmc: sdhci-esdhc-imx: eliminate enum imx_esdhc_type
@ 2013-10-14  8:44     ` Lothar Waßmann
  0 siblings, 0 replies; 32+ messages in thread
From: Lothar Waßmann @ 2013-10-14  8:44 UTC (permalink / raw)
  To: linux-arm-kernel


Shawn Guo wrote:
> 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.
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> ---
>  drivers/mmc/host/sdhci-esdhc-imx.c |   52 +++++-------------------------------
>  1 file changed, 6 insertions(+), 46 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
> index f1e1385..f2cd5b0 100644
> --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> @@ -100,18 +100,15 @@
[...]
> +#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
-- 
___________________________________________________________

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
___________________________________________________________

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 5/5] mmc: sdhci-esdhc-imx: eliminate enum imx_esdhc_type
  2013-10-14  8:31     ` Lucas Stach
@ 2013-10-14 13:27       ` Shawn Guo
  -1 siblings, 0 replies; 32+ messages in thread
From: Shawn Guo @ 2013-10-14 13:27 UTC (permalink / raw)
  To: Lucas Stach; +Cc: linux-mmc, Chris Ball, Dong Aisheng, linux-arm-kernel

On Mon, Oct 14, 2013 at 10:31:51AM +0200, Lucas Stach wrote:
> > +#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.

> 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


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 5/5] mmc: sdhci-esdhc-imx: eliminate enum imx_esdhc_type
@ 2013-10-14 13:27       ` Shawn Guo
  0 siblings, 0 replies; 32+ messages in thread
From: Shawn Guo @ 2013-10-14 13:27 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Oct 14, 2013 at 10:31:51AM +0200, Lucas Stach wrote:
> > +#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.

> 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

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 5/5] mmc: sdhci-esdhc-imx: eliminate enum imx_esdhc_type
  2013-10-14 13:27       ` Shawn Guo
@ 2013-10-14 13:56         ` Shawn Guo
  -1 siblings, 0 replies; 32+ messages in thread
From: Shawn Guo @ 2013-10-14 13:56 UTC (permalink / raw)
  To: Lucas Stach; +Cc: linux-mmc, Chris Ball, Dong Aisheng, linux-arm-kernel

On Mon, Oct 14, 2013 at 09:27:59PM +0800, Shawn Guo wrote:
> On Mon, Oct 14, 2013 at 10:31:51AM +0200, Lucas Stach wrote:
> > > +#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.
> 
> > 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


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 5/5] mmc: sdhci-esdhc-imx: eliminate enum imx_esdhc_type
@ 2013-10-14 13:56         ` Shawn Guo
  0 siblings, 0 replies; 32+ messages in thread
From: Shawn Guo @ 2013-10-14 13:56 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Oct 14, 2013 at 09:27:59PM +0800, Shawn Guo wrote:
> On Mon, Oct 14, 2013 at 10:31:51AM +0200, Lucas Stach wrote:
> > > +#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.
> 
> > 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

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 6/6] mmc: sdhci-esdhc-imx: create struct esdhc_soc_data
  2013-10-14  8:23 ` Shawn Guo
@ 2013-10-15  4:55   ` Shawn Guo
  -1 siblings, 0 replies; 32+ messages in thread
From: Shawn Guo @ 2013-10-15  4:55 UTC (permalink / raw)
  To: linux-mmc; +Cc: linux-arm-kernel, kernel, Chris Ball, Dong Aisheng, 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.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/mmc/host/sdhci-esdhc-imx.c |   62 +++++++++++++++++++++++-------------
 1 file changed, 40 insertions(+), 22 deletions(-)

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index f2cd5b0..d3d34cf 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -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;
-- 
1.7.9.5



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 6/6] mmc: sdhci-esdhc-imx: create struct esdhc_soc_data
@ 2013-10-15  4:55   ` Shawn Guo
  0 siblings, 0 replies; 32+ messages in thread
From: Shawn Guo @ 2013-10-15  4:55 UTC (permalink / raw)
  To: linux-arm-kernel

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.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 drivers/mmc/host/sdhci-esdhc-imx.c |   62 +++++++++++++++++++++++-------------
 1 file changed, 40 insertions(+), 22 deletions(-)

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index f2cd5b0..d3d34cf 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -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;
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* Re: [PATCH 2/5] mmc: sdhci-esdhc-imx: add flag ESDHC_FLAG_ENGCM07207
  2013-10-14  8:23   ` Shawn Guo
@ 2013-10-15  6:49     ` Lucas Stach
  -1 siblings, 0 replies; 32+ messages in thread
From: Lucas Stach @ 2013-10-15  6:49 UTC (permalink / raw)
  To: Shawn Guo; +Cc: linux-mmc, Chris Ball, Dong Aisheng, linux-arm-kernel

Am Montag, den 14.10.2013, 16:23 +0800 schrieb 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.
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> ---
>  drivers/mmc/host/sdhci-esdhc-imx.c |   10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
> index e046917..a5d7d15 100644
> --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> @@ -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/

> + */
> +#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;

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


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 2/5] mmc: sdhci-esdhc-imx: add flag ESDHC_FLAG_ENGCM07207
@ 2013-10-15  6:49     ` Lucas Stach
  0 siblings, 0 replies; 32+ messages in thread
From: Lucas Stach @ 2013-10-15  6:49 UTC (permalink / raw)
  To: linux-arm-kernel

Am Montag, den 14.10.2013, 16:23 +0800 schrieb 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.
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> ---
>  drivers/mmc/host/sdhci-esdhc-imx.c |   10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
> index e046917..a5d7d15 100644
> --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> @@ -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/

> + */
> +#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;

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

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 0/5] mmc: sdhci-esdhc-imx: eliminate enum imx_esdhc_type
  2013-10-14  8:23 ` Shawn Guo
@ 2013-10-15  6:50   ` Lucas Stach
  -1 siblings, 0 replies; 32+ messages in thread
From: Lucas Stach @ 2013-10-15  6:50 UTC (permalink / raw)
  To: Shawn Guo; +Cc: linux-mmc, Chris Ball, Dong Aisheng, linux-arm-kernel

Am Montag, den 14.10.2013, 16:23 +0800 schrieb 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.
> 
> 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
Reviewed-by: Lucas Stach <l.stach@pengutronix.de>

> 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(-)
> 

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


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 0/5] mmc: sdhci-esdhc-imx: eliminate enum imx_esdhc_type
@ 2013-10-15  6:50   ` Lucas Stach
  0 siblings, 0 replies; 32+ messages in thread
From: Lucas Stach @ 2013-10-15  6:50 UTC (permalink / raw)
  To: linux-arm-kernel

Am Montag, den 14.10.2013, 16:23 +0800 schrieb 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.
> 
> 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
Reviewed-by: Lucas Stach <l.stach@pengutronix.de>

> 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(-)
> 

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

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 0/5] mmc: sdhci-esdhc-imx: eliminate enum imx_esdhc_type
  2013-10-14  8:23 ` Shawn Guo
@ 2013-10-15  7:36   ` Dong Aisheng
  -1 siblings, 0 replies; 32+ messages in thread
From: Dong Aisheng @ 2013-10-15  7:36 UTC (permalink / raw)
  To: Shawn Guo; +Cc: linux-mmc, Chris Ball, linux-arm-kernel

On Mon, Oct 14, 2013 at 04:23:39PM +0800, Shawn Guo wrote:
> 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

> 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(-)
> 
> -- 
> 1.7.9.5
> 


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 0/5] mmc: sdhci-esdhc-imx: eliminate enum imx_esdhc_type
@ 2013-10-15  7:36   ` Dong Aisheng
  0 siblings, 0 replies; 32+ messages in thread
From: Dong Aisheng @ 2013-10-15  7:36 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Oct 14, 2013 at 04:23:39PM +0800, Shawn Guo wrote:
> 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

> 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(-)
> 
> -- 
> 1.7.9.5
> 

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 0/5] mmc: sdhci-esdhc-imx: eliminate enum imx_esdhc_type
  2013-10-15  7:36   ` Dong Aisheng
@ 2013-10-15  8:54     ` Shawn Guo
  -1 siblings, 0 replies; 32+ messages in thread
From: Shawn Guo @ 2013-10-15  8:54 UTC (permalink / raw)
  To: Dong Aisheng; +Cc: linux-mmc, Chris Ball, linux-arm-kernel

On Tue, Oct 15, 2013 at 03:36:32PM +0800, Dong Aisheng wrote:
> On Mon, Oct 14, 2013 at 04:23:39PM +0800, Shawn Guo wrote:
> > 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.

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

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

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

> 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

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


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 0/5] mmc: sdhci-esdhc-imx: eliminate enum imx_esdhc_type
@ 2013-10-15  8:54     ` Shawn Guo
  0 siblings, 0 replies; 32+ messages in thread
From: Shawn Guo @ 2013-10-15  8:54 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Oct 15, 2013 at 03:36:32PM +0800, Dong Aisheng wrote:
> On Mon, Oct 14, 2013 at 04:23:39PM +0800, Shawn Guo wrote:
> > 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.

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

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

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

> 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

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

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 0/5] mmc: sdhci-esdhc-imx: eliminate enum imx_esdhc_type
  2013-10-15  7:36   ` Dong Aisheng
@ 2013-10-16 15:19     ` Shawn Guo
  -1 siblings, 0 replies; 32+ messages in thread
From: Shawn Guo @ 2013-10-16 15:19 UTC (permalink / raw)
  To: Dong Aisheng; +Cc: linux-mmc, Chris Ball, linux-arm-kernel

On Tue, Oct 15, 2013 at 03:36:32PM +0800, Dong Aisheng wrote:
> On Mon, Oct 14, 2013 at 04:23:39PM +0800, Shawn Guo wrote:
> > 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,

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


^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 0/5] mmc: sdhci-esdhc-imx: eliminate enum imx_esdhc_type
@ 2013-10-16 15:19     ` Shawn Guo
  0 siblings, 0 replies; 32+ messages in thread
From: Shawn Guo @ 2013-10-16 15:19 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Oct 15, 2013 at 03:36:32PM +0800, Dong Aisheng wrote:
> On Mon, Oct 14, 2013 at 04:23:39PM +0800, Shawn Guo wrote:
> > 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,

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

^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2013-10-16 15:19 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-14  8:23 [PATCH 0/5] mmc: sdhci-esdhc-imx: eliminate enum imx_esdhc_type Shawn Guo
2013-10-14  8:23 ` Shawn Guo
2013-10-14  8:23 ` [PATCH 1/5] mmc: sdhci-esdhc-imx: add flag ESDHC_FLAG_NO_DMAS_BITS Shawn Guo
2013-10-14  8:23   ` Shawn Guo
2013-10-14  8:23 ` [PATCH 2/5] mmc: sdhci-esdhc-imx: add flag ESDHC_FLAG_ENGCM07207 Shawn Guo
2013-10-14  8:23   ` Shawn Guo
2013-10-15  6:49   ` Lucas Stach
2013-10-15  6:49     ` Lucas Stach
2013-10-14  8:23 ` [PATCH 3/5] mmc: sdhci-esdhc-imx: add flag ESDHC_FLAG_USDHC Shawn Guo
2013-10-14  8:23   ` Shawn Guo
2013-10-14  8:23 ` [PATCH 4/5] mmc: sdhci-esdhc-imx: pdev->id_entry should be immutable Shawn Guo
2013-10-14  8:23   ` Shawn Guo
2013-10-14  8:23 ` [PATCH 5/5] mmc: sdhci-esdhc-imx: eliminate enum imx_esdhc_type Shawn Guo
2013-10-14  8:23   ` Shawn Guo
2013-10-14  8:31   ` Lucas Stach
2013-10-14  8:31     ` Lucas Stach
2013-10-14 13:27     ` Shawn Guo
2013-10-14 13:27       ` Shawn Guo
2013-10-14 13:56       ` Shawn Guo
2013-10-14 13:56         ` Shawn Guo
2013-10-14  8:44   ` Lothar Waßmann
2013-10-14  8:44     ` Lothar Waßmann
2013-10-15  4:55 ` [PATCH 6/6] mmc: sdhci-esdhc-imx: create struct esdhc_soc_data Shawn Guo
2013-10-15  4:55   ` Shawn Guo
2013-10-15  6:50 ` [PATCH 0/5] mmc: sdhci-esdhc-imx: eliminate enum imx_esdhc_type Lucas Stach
2013-10-15  6:50   ` Lucas Stach
2013-10-15  7:36 ` Dong Aisheng
2013-10-15  7:36   ` Dong Aisheng
2013-10-15  8:54   ` Shawn Guo
2013-10-15  8:54     ` Shawn Guo
2013-10-16 15:19   ` Shawn Guo
2013-10-16 15:19     ` Shawn Guo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.