From 5590a891218d284a8ce9a803e52f6f4c0c610713 Mon Sep 17 00:00:00 2001 From: Jagannadha Sutradharudu Teki Date: Sat, 8 Sep 2012 19:28:01 +0530 Subject: [PATCH] Xilinx: ARM: mmc: zynq: Add support for bus width and sd version This patch adds support for bus width and sd version. Append data onto APP_SEND_SCR command handling in controller driver so that it can get the data from SCR correctly. Also, support for 1-bit and 4-bit buswidth is added in controller driver based on value read from SCR. Signed-off-by: Jagannadha Sutradharudu Teki --- drivers/mmc/zynq_mmc.c | 30 +++++++++++++++++++++++++----- drivers/mmc/zynq_mmc.h | 1 + 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/drivers/mmc/zynq_mmc.c b/drivers/mmc/zynq_mmc.c index 10f7dacaa77..6d237a0e98f 100644 --- a/drivers/mmc/zynq_mmc.c +++ b/drivers/mmc/zynq_mmc.c @@ -128,7 +128,7 @@ static void init_port(void) #define CMD2 (2) /* SEND_CID */ #define CMD3 (3) /* RELATIVE_ADDR */ #define CMD5 (5) /* SLEEP_WAKE (SDC) */ -#define CMD6 (6) /* SWITCH_FUNC */ +#define CMD6 (6) /* APP_SET_BUS_WIDTH */ #define CMD7 (7) /* SELECT */ #define CMD8 (8) /* SEND_IF_COND */ #define CMD9 (9) /* SEND_CSD */ @@ -153,8 +153,7 @@ static void init_port(void) * Determing the proper value for the command register for the indicated * command index. */ -static int -make_command (unsigned cmd) +static int make_command(unsigned cmd) { unsigned retval; @@ -183,6 +182,9 @@ make_command (unsigned cmd) case CMD5: retval |= RSP_R1b; break; + case CMD6: + retval |= RSP_R1; + break; case CMD7: retval |= RSP_R1; break; @@ -211,14 +213,13 @@ make_command (unsigned cmd) retval |= RSP_R3; break; case CMD51: - retval |= RSP_R1; + retval |= RSP_R1 | SD_CMD_DATA; break; case CMD52: case CMD55: retval |= RSP_R1; break; case CMD58: - case CMD6: break; default: printf("Unknown command CMD%d\n", cmd); @@ -242,6 +243,10 @@ static int zynq_sdh_request(struct mmc *mmc, struct mmc_cmd *cmd, cmd->response[0] = 0; cmdreg = make_command(cmd->cmdidx); + /* exit if command is SWITCH_FUNC, as it currently not supporting */ + if (data && (data->flags & MMC_DATA_READ) && (cmd->cmdidx == 6)) + return result; + /* Wait until the device is willing to accept commands */ do { status = sd_in32(SD_PRES_STATE_R); @@ -378,9 +383,24 @@ exit: static void zynq_sdh_set_ios(struct mmc *mmc) { + u16 sdhci_clkctrl; + debug("%s: voltages: 0x%x clock: 0x%x bus_width: 0x%x\n", __func__, mmc->voltages, mmc->clock, mmc->bus_width); + + sdhci_clkctrl = sd_in16(SD_HOST_CTRL_R); + + /* Configure the bus_width */ + if (mmc->bus_width == 4) + sdhci_clkctrl |= SD_HOST_4BIT; + else if (mmc->bus_width == 1) + sdhci_clkctrl &= ~SD_HOST_4BIT; + else + printf("Invalid bus_width\n"); + + sd_out16(SD_HOST_CTRL_R, sdhci_clkctrl); } + static int zynq_sdh_init(struct mmc *mmc) { debug(" zynq_sdh_init called\n"); diff --git a/drivers/mmc/zynq_mmc.h b/drivers/mmc/zynq_mmc.h index 4f3d3f91069..3000990382d 100644 --- a/drivers/mmc/zynq_mmc.h +++ b/drivers/mmc/zynq_mmc.h @@ -57,6 +57,7 @@ #define SD_CARD_WP 0x00080000 #define SD_HOST_CTRL_R 0x28 +#define SD_HOST_4BIT 0x02 #define SD_CD_TEST_INS 0x40 #define SD_CD_TEST 0x80 -- 2.47.3