Skip to contentSkip to conversation

mmc: dw_mmc: add support for use_hold_reg

PATCH In review [email protected] 2 participants 3 messages Dec 13, 2012 – Dec 14, 2012

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

PATCH 1/1 mmc: dw_mmc: add support for use_hold_reg

From: Dinh Nguyen <[email protected]>

Add code to read value of the use_hold_reg in the cmd register so that the cmdflags can be correct.

---
 drivers/mmc/host/dw_mmc.c  |    6 ++++++
 drivers/mmc/host/dw_mmc.h  |    1 +
 include/linux/mmc/dw_mmc.h |    3 +++
 3 files changed, 10 insertions(+)
drivers/mmc/host/dw_mmc.c +6 -0
index 323c502..490490b 100644
@@ -265,6 +265,9 @@ static u32 dw_mci_prepare_command(struct mmc_host *mmc, struct mmc_command *cmd)
 	if (drv_data && drv_data->prepare_command)
 		drv_data->prepare_command(slot->host, &cmdr);
 
+	if (slot->host->use_hold_reg)
+		cmdr |= SDMMC_CMD_USE_HOLD_REG;
+
 	return cmdr;
 }
 
@@ -2183,6 +2186,9 @@ int dw_mci_probe(struct dw_mci *host)
 		host->data_shift = 2;
 	}
 
+	/* Get the USE_HOLD_REG */
+	host->use_hold_reg = mci_readl(host, CMD) & SDMMC_CMD_USE_HOLD_REG;
+
 	/* Reset all blocks */
 	if (!mci_wait_reset(host->dev, host))
 		return -ENODEV;
drivers/mmc/host/dw_mmc.h +1 -0
index 53b8fd9..6172900 100644
@@ -111,6 +111,7 @@
 #define SDMMC_INT_ERROR			0xbfc2
 /* Command register defines */
 #define SDMMC_CMD_START			BIT(31)
+#define SDMMC_CMD_USE_HOLD_REG		BIT(29)
 #define SDMMC_CMD_CCS_EXP		BIT(23)
 #define SDMMC_CMD_CEATA_RD		BIT(22)
 #define SDMMC_CMD_UPD_CLK		BIT(21)
include/linux/mmc/dw_mmc.h +3 -0
index 34be4f4..36cab8a 100644
@@ -187,6 +187,9 @@ struct dw_mci {
 	struct regulator	*vmmc;	/* Power regulator */
 	unsigned long		irq_flags; /* IRQ flags */
 	int			irq;
+
+	/* Set to one for SDR12 and SDR25 */
+	unsigned int use_hold_reg;
 };
 
 /* DMA ops for Internal/External DMAC interface */
Signature · 1 line
1.7.9.5
maintainer
#1 lore raw

Hi Dinh,

According to DesignWare Spec, we need to check which bus-mode use. You can refer to "https://patchwork.kernel.org/patch/1379521/". I know that hold_reg didn't use always, although hold_reg is set.

Best Regards,
Jaehoon Chung

Quoted 63 lines · On 12/14/2012 05:03 AM, [email protected] wrote:

From: Dinh Nguyen <[email protected]>

Add code to read value of the use_hold_reg in the cmd register so that the cmdflags can be correct.

---
 drivers/mmc/host/dw_mmc.c  |    6 ++++++
 drivers/mmc/host/dw_mmc.h  |    1 +
 include/linux/mmc/dw_mmc.h |    3 +++
 3 files changed, 10 insertions(+)
drivers/mmc/host/dw_mmc.c +6 -0
index 323c502..490490b 100644
@@ -265,6 +265,9 @@ static u32 dw_mci_prepare_command(struct mmc_host *mmc, struct mmc_command *cmd)
 	if (drv_data && drv_data->prepare_command)
 		drv_data->prepare_command(slot->host, &cmdr);
 
+	if (slot->host->use_hold_reg)
+		cmdr |= SDMMC_CMD_USE_HOLD_REG;
+
 	return cmdr;
 }
 
@@ -2183,6 +2186,9 @@ int dw_mci_probe(struct dw_mci *host)
 		host->data_shift = 2;
 	}
 
+	/* Get the USE_HOLD_REG */
+	host->use_hold_reg = mci_readl(host, CMD) & SDMMC_CMD_USE_HOLD_REG;
+
 	/* Reset all blocks */
 	if (!mci_wait_reset(host->dev, host))
 		return -ENODEV;
drivers/mmc/host/dw_mmc.h +1 -0
index 53b8fd9..6172900 100644
@@ -111,6 +111,7 @@
 #define SDMMC_INT_ERROR			0xbfc2
 /* Command register defines */
 #define SDMMC_CMD_START			BIT(31)
+#define SDMMC_CMD_USE_HOLD_REG		BIT(29)
 #define SDMMC_CMD_CCS_EXP		BIT(23)
 #define SDMMC_CMD_CEATA_RD		BIT(22)
 #define SDMMC_CMD_UPD_CLK		BIT(21)
include/linux/mmc/dw_mmc.h +3 -0
index 34be4f4..36cab8a 100644
@@ -187,6 +187,9 @@ struct dw_mci {
 	struct regulator	*vmmc;	/* Power regulator */
 	unsigned long		irq_flags; /* IRQ flags */
 	int			irq;
+
+	/* Set to one for SDR12 and SDR25 */
+	unsigned int use_hold_reg;
 };
 
 /* DMA ops for Internal/External DMAC interface */
#2 lore raw
Quoted 5 lines · Jaehoon Chung

Hi Dinh,

According to DesignWare Spec, we need to check which bus-mode use. You can refer to "https://patchwork.kernel.org/patch/1379521/". I know that hold_reg didn't use always, although hold_reg is set.

Hi Jaehoon,

Thanks for the info. So then my question is what is the correct way to add support for use_hold_reg?

Our implementation of the IP is using the use_hold_reg in its default state. The driver taken as is did not work.

Should we be adding a similar file dw_mmc-exynos.c to add this?

Thanks,

Dinh

Quoted 70 lines

Best Regards,
Jaehoon Chung

Quoted 63 lines · On 12/14/2012 05:03 AM, [email protected] wrote:

From: Dinh Nguyen <[email protected]>

Add code to read value of the use_hold_reg in the cmd register so that the cmdflags can be correct.

---
 drivers/mmc/host/dw_mmc.c  |    6 ++++++
 drivers/mmc/host/dw_mmc.h  |    1 +
 include/linux/mmc/dw_mmc.h |    3 +++
 3 files changed, 10 insertions(+)
drivers/mmc/host/dw_mmc.c +6 -0
index 323c502..490490b 100644
@@ -265,6 +265,9 @@ static u32 dw_mci_prepare_command(struct mmc_host *mmc, struct mmc_command *cmd)
 	if (drv_data && drv_data->prepare_command)
 		drv_data->prepare_command(slot->host, &cmdr);
 
+	if (slot->host->use_hold_reg)
+		cmdr |= SDMMC_CMD_USE_HOLD_REG;
+
 	return cmdr;
 }
 
@@ -2183,6 +2186,9 @@ int dw_mci_probe(struct dw_mci *host)
 		host->data_shift = 2;
 	}
 
+	/* Get the USE_HOLD_REG */
+	host->use_hold_reg = mci_readl(host, CMD) & SDMMC_CMD_USE_HOLD_REG;
+
 	/* Reset all blocks */
 	if (!mci_wait_reset(host->dev, host))
 		return -ENODEV;
drivers/mmc/host/dw_mmc.h +1 -0
index 53b8fd9..6172900 100644
@@ -111,6 +111,7 @@
 #define SDMMC_INT_ERROR			0xbfc2
 /* Command register defines */
 #define SDMMC_CMD_START			BIT(31)
+#define SDMMC_CMD_USE_HOLD_REG		BIT(29)
 #define SDMMC_CMD_CCS_EXP		BIT(23)
 #define SDMMC_CMD_CEATA_RD		BIT(22)
 #define SDMMC_CMD_UPD_CLK		BIT(21)
include/linux/mmc/dw_mmc.h +3 -0
index 34be4f4..36cab8a 100644
@@ -187,6 +187,9 @@ struct dw_mci {
 	struct regulator	*vmmc;	/* Power regulator */
 	unsigned long		irq_flags; /* IRQ flags */
 	int			irq;
+
+	/* Set to one for SDR12 and SDR25 */
+	unsigned int use_hold_reg;
 };
 
 /* DMA ops for Internal/External DMAC interface */