[2/4] UBUNTU: SAUCE: Redpine: fix reset card issue

Message ID 1515419650-21101-2-git-send-email-amitkarwar@gmail.com
State New
Headers show
Series
  • Untitled series #21926
Related show

Commit Message

Amitkumar Karwar Jan. 8, 2018, 1:54 p.m.
From: Prameela Rani Garnepudi <prameela.j04cs@gmail.com>

BugLink: https://bugs.launchpad.net/bugs/1736097
BugLink: https://bugs.launchpad.net/bugs/1738169

Sometimes we don't get response for SDIO commands during reset.
Additional parameter 'expected response' is added to cmd52readbyte()
and cmd52writebyte(). This parameter is false during reset (To avoid
waiting for response) and true while disabling or enabling SDIO
interrupts.

Signed-off-by: Prameela Rani Garnepudi <prameela.j04cs@gmail.com>
Signed-off-by: Amitkumar Karwar <amit.karwar@redpinesignals.com>
---
 ubuntu/rsi/rsi_91x_sdio.c | 38 +++++++++++++++++++++++---------------
 1 file changed, 23 insertions(+), 15 deletions(-)

Patch

diff --git a/ubuntu/rsi/rsi_91x_sdio.c b/ubuntu/rsi/rsi_91x_sdio.c
index 336f059..a2e25d0 100644
--- a/ubuntu/rsi/rsi_91x_sdio.c
+++ b/ubuntu/rsi/rsi_91x_sdio.c
@@ -88,7 +88,8 @@  static u32 rsi_sdio_set_cmd52_arg(bool rw,
  */
 static int rsi_cmd52writebyte(struct mmc_card *card,
 			      u32 address,
-			      u8 byte)
+			      u8 byte,
+			      bool expect_resp)
 {
 	struct mmc_command io_cmd;
 	u32 arg;
@@ -97,7 +98,9 @@  static int rsi_cmd52writebyte(struct mmc_card *card,
 	arg = rsi_sdio_set_cmd52_arg(1, 0, 0, address, byte);
 	io_cmd.opcode = SD_IO_RW_DIRECT;
 	io_cmd.arg = arg;
-	io_cmd.flags = /*MMC_RSP_R5 | */MMC_CMD_AC;
+	io_cmd.flags = MMC_CMD_AC;
+	if (expect_resp)
+		io_cmd.flags |= MMC_RSP_R5;
 
 	return mmc_wait_for_cmd(card->host, &io_cmd, 0);
 }
@@ -112,7 +115,8 @@  static int rsi_cmd52writebyte(struct mmc_card *card,
  */
 static int rsi_cmd52readbyte(struct mmc_card *card,
 			     u32 address,
-			     u8 *byte)
+			     u8 *byte,
+			     bool expect_resp)
 {
 	struct mmc_command io_cmd;
 	u32 arg;
@@ -122,7 +126,9 @@  static int rsi_cmd52readbyte(struct mmc_card *card,
 	arg = rsi_sdio_set_cmd52_arg(0, 0, 0, address, 0);
 	io_cmd.opcode = SD_IO_RW_DIRECT;
 	io_cmd.arg = arg;
-	io_cmd.flags = /*MMC_RSP_R5 | */MMC_CMD_AC;
+	io_cmd.flags = MMC_CMD_AC;
+	if (expect_resp)
+		io_cmd.flags |= MMC_RSP_R5;
 
 	err = mmc_wait_for_cmd(card->host, &io_cmd, 0);
 	if ((!err) && (byte))
@@ -311,7 +317,7 @@  static void rsi_reset_card(struct sdio_func *pfunction)
 	/* Reset 9110 chip */
 	err = rsi_cmd52writebyte(pfunction->card,
 				 SDIO_CCCR_ABORT,
-				 (1 << 3));
+				 (1 << 3), true);
 
 	/* Card will not send any response as it is getting reset immediately
 	 * Hence expect a timeout status from host controller
@@ -446,14 +452,16 @@  static void rsi_reset_card(struct sdio_func *pfunction)
 	/* Enable high speed */
 	if (card->host->caps & MMC_CAP_SD_HIGHSPEED) {
 		ven_rsi_dbg(ERR_ZONE, "%s: Set high speed mode\n", __func__);
-		err = rsi_cmd52readbyte(card, SDIO_CCCR_SPEED, &cmd52_resp);
+		err = rsi_cmd52readbyte(card, SDIO_CCCR_SPEED, &cmd52_resp,
+					true);
 		if (err) {
 			ven_rsi_dbg(ERR_ZONE, "%s: CCCR speed reg read failed: %d\n",
 				__func__, err);
 		} else {
 			err = rsi_cmd52writebyte(card,
 						 SDIO_CCCR_SPEED,
-						 (cmd52_resp | SDIO_SPEED_EHS));
+						 (cmd52_resp | SDIO_SPEED_EHS),
+						 true);
 			if (err) {
 				ven_rsi_dbg(ERR_ZONE,
 					"%s: CCR speed regwrite failed %d\n",
@@ -482,7 +490,7 @@  static void rsi_reset_card(struct sdio_func *pfunction)
 		err = rsi_cmd52writebyte(card,
 					 SDIO_CCCR_IF,
 					 (SDIO_BUS_CD_DISABLE |
-					  SDIO_BUS_WIDTH_4BIT));
+					  SDIO_BUS_WIDTH_4BIT), true);
 		if (err) {
 			ven_rsi_dbg(ERR_ZONE, "%s: Set bus mode failed : %d\n",
 				__func__, err);
@@ -1220,7 +1228,7 @@  static int rsi_sdio_disable_interrupts(struct sdio_func *pfunction)
 	ven_rsi_dbg(ERR_ZONE, "\nInterrupts cleared");
 
 	sdio_claim_host(pfunction);
-	ret = rsi_cmd52readbyte(pfunction->card, 0x04, &data);
+	ret = rsi_cmd52readbyte(pfunction->card, 0x04, &data, false);
 	if (ret < 0) {
 		ven_rsi_dbg(ERR_ZONE,
 			"%s: Failed to read INTR_EN register\n",
@@ -1233,7 +1241,7 @@  static int rsi_sdio_disable_interrupts(struct sdio_func *pfunction)
 	/* And bit0 and b1 */
 	data &= 0xfc;
 
-	ret = rsi_cmd52writebyte(pfunction->card, 0x04, data);
+	ret = rsi_cmd52writebyte(pfunction->card, 0x04, data, false);
 	if (ret < 0) {
 		ven_rsi_dbg(ERR_ZONE,
 			"%s: Failed to Write to INTR_EN register\n",
@@ -1241,7 +1249,7 @@  static int rsi_sdio_disable_interrupts(struct sdio_func *pfunction)
 		sdio_release_host(pfunction);
 		return ret;
 	}
-	ret = rsi_cmd52readbyte(pfunction->card, 0x04, &data);
+	ret = rsi_cmd52readbyte(pfunction->card, 0x04, &data, false);
 	if (ret < 0) {
 		ven_rsi_dbg(ERR_ZONE,
 			"%s: Failed to read INTR_EN register\n",
@@ -1262,7 +1270,7 @@  static int rsi_sdio_enable_interrupts(struct sdio_func *pfunction)
 	int ret;
 
 	sdio_claim_host(pfunction);
-	ret = rsi_cmd52readbyte(pfunction->card, 0x04, &data);
+	ret = rsi_cmd52readbyte(pfunction->card, 0x04, &data, false);
 	if (ret < 0) {
 		ven_rsi_dbg(ERR_ZONE,
 			"%s: Failed to read INTR_EN register\n", __func__);
@@ -1274,7 +1282,7 @@  static int rsi_sdio_enable_interrupts(struct sdio_func *pfunction)
 	/* Enable b1 and b0 */
 	data |= 0x03;
 
-	ret = rsi_cmd52writebyte(pfunction->card, 0x04, data);
+	ret = rsi_cmd52writebyte(pfunction->card, 0x04, data, false);
 	if (ret < 0) {
 		ven_rsi_dbg(ERR_ZONE,
 			"%s: Failed to Write to INTR_EN register\n",
@@ -1282,8 +1290,8 @@  static int rsi_sdio_enable_interrupts(struct sdio_func *pfunction)
 		sdio_release_host(pfunction);
 		return ret;
 	}
-	
-        ret = rsi_cmd52readbyte(pfunction->card, 0x04, &data);
+
+	ret = rsi_cmd52readbyte(pfunction->card, 0x04, &data, false);
 	if (ret < 0) {
 		ven_rsi_dbg(ERR_ZONE,
 			"%s: Failed to read INTR_EN register\n", __func__);