Merge branch 'master' of git://git.denx.de/u-boot-mmc
This commit is contained in:
		
						commit
						a60d94b204
					
				|  | @ -37,7 +37,7 @@ static int wait_for_command_end(struct mmc *dev, struct mmc_cmd *cmd) | ||||||
| 	writel(statusmask, &host->base->status_clear); | 	writel(statusmask, &host->base->status_clear); | ||||||
| 	if (hoststatus & SDI_STA_CTIMEOUT) { | 	if (hoststatus & SDI_STA_CTIMEOUT) { | ||||||
| 		debug("CMD%d time out\n", cmd->cmdidx); | 		debug("CMD%d time out\n", cmd->cmdidx); | ||||||
| 		return TIMEOUT; | 		return -ETIMEDOUT; | ||||||
| 	} else if ((hoststatus & SDI_STA_CCRCFAIL) && | 	} else if ((hoststatus & SDI_STA_CCRCFAIL) && | ||||||
| 		   (cmd->resp_type & MMC_RSP_CRC)) { | 		   (cmd->resp_type & MMC_RSP_CRC)) { | ||||||
| 		printf("CMD%d CRC error\n", cmd->cmdidx); | 		printf("CMD%d CRC error\n", cmd->cmdidx); | ||||||
|  |  | ||||||
|  | @ -109,9 +109,9 @@ sdh_send_cmd(struct mmc *mmc, struct mmc_cmd *mmc_cmd) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if (status & CMD_TIME_OUT) | 	if (status & CMD_TIME_OUT) | ||||||
| 		ret = TIMEOUT; | 		ret = -ETIMEDOUT; | ||||||
| 	else if (status & CMD_CRC_FAIL && flags & MMC_RSP_CRC) | 	else if (status & CMD_CRC_FAIL && flags & MMC_RSP_CRC) | ||||||
| 		ret = COMM_ERR; | 		ret = -ECOMM; | ||||||
| 	else | 	else | ||||||
| 		ret = 0; | 		ret = 0; | ||||||
| 
 | 
 | ||||||
|  | @ -136,7 +136,7 @@ static int sdh_setup_data(struct mmc *mmc, struct mmc_data *data) | ||||||
| 
 | 
 | ||||||
| 	/* Don't support write yet. */ | 	/* Don't support write yet. */ | ||||||
| 	if (data->flags & MMC_DATA_WRITE) | 	if (data->flags & MMC_DATA_WRITE) | ||||||
| 		return UNUSABLE_ERR; | 		return -EOPNOTSUPP; | ||||||
| #ifndef RSI_BLKSZ | #ifndef RSI_BLKSZ | ||||||
| 	data_ctl |= ((ffs(data->blocksize) - 1) << 4); | 	data_ctl |= ((ffs(data->blocksize) - 1) << 4); | ||||||
| #else | #else | ||||||
|  | @ -194,10 +194,10 @@ static int bfin_sdh_request(struct mmc *mmc, struct mmc_cmd *cmd, | ||||||
| 
 | 
 | ||||||
| 		if (status & DAT_TIME_OUT) { | 		if (status & DAT_TIME_OUT) { | ||||||
| 			bfin_write_SDH_STATUS_CLR(DAT_TIMEOUT_STAT); | 			bfin_write_SDH_STATUS_CLR(DAT_TIMEOUT_STAT); | ||||||
| 			ret |= TIMEOUT; | 			ret = -ETIMEDOUT; | ||||||
| 		} else if (status & (DAT_CRC_FAIL | RX_OVERRUN)) { | 		} else if (status & (DAT_CRC_FAIL | RX_OVERRUN)) { | ||||||
| 			bfin_write_SDH_STATUS_CLR(DAT_CRC_FAIL_STAT | RX_OVERRUN_STAT); | 			bfin_write_SDH_STATUS_CLR(DAT_CRC_FAIL_STAT | RX_OVERRUN_STAT); | ||||||
| 			ret |= COMM_ERR; | 			ret = -ECOMM; | ||||||
| 		} else | 		} else | ||||||
| 			bfin_write_SDH_STATUS_CLR(DAT_BLK_END_STAT | DAT_END_STAT); | 			bfin_write_SDH_STATUS_CLR(DAT_BLK_END_STAT | DAT_END_STAT); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -9,6 +9,7 @@ | ||||||
| #include <config.h> | #include <config.h> | ||||||
| #include <common.h> | #include <common.h> | ||||||
| #include <command.h> | #include <command.h> | ||||||
|  | #include <errno.h> | ||||||
| #include <mmc.h> | #include <mmc.h> | ||||||
| #include <part.h> | #include <part.h> | ||||||
| #include <malloc.h> | #include <malloc.h> | ||||||
|  | @ -66,7 +67,7 @@ dmmc_wait_fifo_status(volatile struct davinci_mmc_regs *regs, uint status) | ||||||
| 		udelay(100); | 		udelay(100); | ||||||
| 
 | 
 | ||||||
| 	if (wdog == 0) | 	if (wdog == 0) | ||||||
| 		return COMM_ERR; | 		return -ECOMM; | ||||||
| 
 | 
 | ||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
|  | @ -80,7 +81,7 @@ static int dmmc_busy_wait(volatile struct davinci_mmc_regs *regs) | ||||||
| 		udelay(10); | 		udelay(10); | ||||||
| 
 | 
 | ||||||
| 	if (wdog == 0) | 	if (wdog == 0) | ||||||
| 		return COMM_ERR; | 		return -ECOMM; | ||||||
| 
 | 
 | ||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
|  | @ -99,7 +100,7 @@ static int dmmc_check_status(volatile struct davinci_mmc_regs *regs, | ||||||
| 			return 0; | 			return 0; | ||||||
| 		} else if (mmcstatus & st_error) { | 		} else if (mmcstatus & st_error) { | ||||||
| 			if (mmcstatus & MMCST0_TOUTRS) | 			if (mmcstatus & MMCST0_TOUTRS) | ||||||
| 				return TIMEOUT; | 				return -ETIMEDOUT; | ||||||
| 			printf("[ ST0 ERROR %x]\n", mmcstatus); | 			printf("[ ST0 ERROR %x]\n", mmcstatus); | ||||||
| 			/*
 | 			/*
 | ||||||
| 			 * Ignore CRC errors as some MMC cards fail to | 			 * Ignore CRC errors as some MMC cards fail to | ||||||
|  | @ -107,7 +108,7 @@ static int dmmc_check_status(volatile struct davinci_mmc_regs *regs, | ||||||
| 			 */ | 			 */ | ||||||
| 			if (mmcstatus & MMCST0_CRCRS) | 			if (mmcstatus & MMCST0_CRCRS) | ||||||
| 				return 0; | 				return 0; | ||||||
| 			return COMM_ERR; | 			return -ECOMM; | ||||||
| 		} | 		} | ||||||
| 		udelay(10); | 		udelay(10); | ||||||
| 
 | 
 | ||||||
|  | @ -116,7 +117,7 @@ static int dmmc_check_status(volatile struct davinci_mmc_regs *regs, | ||||||
| 
 | 
 | ||||||
| 	printf("Status %x Timeout ST0:%x ST1:%x\n", st_ready, mmcstatus, | 	printf("Status %x Timeout ST0:%x ST1:%x\n", st_ready, mmcstatus, | ||||||
| 			get_val(®s->mmcst1)); | 			get_val(®s->mmcst1)); | ||||||
| 	return COMM_ERR; | 	return -ECOMM; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /*
 | /*
 | ||||||
|  |  | ||||||
|  | @ -13,7 +13,6 @@ | ||||||
| #include <memalign.h> | #include <memalign.h> | ||||||
| #include <mmc.h> | #include <mmc.h> | ||||||
| #include <dwmmc.h> | #include <dwmmc.h> | ||||||
| #include <asm-generic/errno.h> |  | ||||||
| 
 | 
 | ||||||
| #define PAGE_SIZE 4096 | #define PAGE_SIZE 4096 | ||||||
| 
 | 
 | ||||||
|  | @ -120,12 +119,14 @@ static int dwmci_data_transfer(struct dwmci_host *host, struct mmc_data *data) | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		if (host->fifo_mode && size) { | 		if (host->fifo_mode && size) { | ||||||
|  | 			len = 0; | ||||||
| 			if (data->flags == MMC_DATA_READ) { | 			if (data->flags == MMC_DATA_READ) { | ||||||
| 				if ((dwmci_readl(host, DWMCI_RINTSTS) & | 				if ((dwmci_readl(host, DWMCI_RINTSTS) & | ||||||
| 				     DWMCI_INTMSK_RXDR)) { | 				     DWMCI_INTMSK_RXDR)) { | ||||||
| 					len = dwmci_readl(host, DWMCI_STATUS); | 					len = dwmci_readl(host, DWMCI_STATUS); | ||||||
| 					len = (len >> DWMCI_FIFO_SHIFT) & | 					len = (len >> DWMCI_FIFO_SHIFT) & | ||||||
| 						    DWMCI_FIFO_MASK; | 						    DWMCI_FIFO_MASK; | ||||||
|  | 					len = min(size, len); | ||||||
| 					for (i = 0; i < len; i++) | 					for (i = 0; i < len; i++) | ||||||
| 						*buf++ = | 						*buf++ = | ||||||
| 						dwmci_readl(host, DWMCI_DATA); | 						dwmci_readl(host, DWMCI_DATA); | ||||||
|  | @ -139,6 +140,7 @@ static int dwmci_data_transfer(struct dwmci_host *host, struct mmc_data *data) | ||||||
| 					len = fifo_depth - ((len >> | 					len = fifo_depth - ((len >> | ||||||
| 						   DWMCI_FIFO_SHIFT) & | 						   DWMCI_FIFO_SHIFT) & | ||||||
| 						   DWMCI_FIFO_MASK); | 						   DWMCI_FIFO_MASK); | ||||||
|  | 					len = min(size, len); | ||||||
| 					for (i = 0; i < len; i++) | 					for (i = 0; i < len; i++) | ||||||
| 						dwmci_writel(host, DWMCI_DATA, | 						dwmci_writel(host, DWMCI_DATA, | ||||||
| 							     *buf++); | 							     *buf++); | ||||||
|  | @ -159,7 +161,7 @@ static int dwmci_data_transfer(struct dwmci_host *host, struct mmc_data *data) | ||||||
| 		if (get_timer(start) > timeout) { | 		if (get_timer(start) > timeout) { | ||||||
| 			debug("%s: Timeout waiting for data!\n", | 			debug("%s: Timeout waiting for data!\n", | ||||||
| 			      __func__); | 			      __func__); | ||||||
| 			ret = TIMEOUT; | 			ret = -ETIMEDOUT; | ||||||
| 			break; | 			break; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  | @ -204,7 +206,7 @@ static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, | ||||||
| 	while (dwmci_readl(host, DWMCI_STATUS) & DWMCI_BUSY) { | 	while (dwmci_readl(host, DWMCI_STATUS) & DWMCI_BUSY) { | ||||||
| 		if (get_timer(start) > timeout) { | 		if (get_timer(start) > timeout) { | ||||||
| 			debug("%s: Timeout on data busy\n", __func__); | 			debug("%s: Timeout on data busy\n", __func__); | ||||||
| 			return TIMEOUT; | 			return -ETIMEDOUT; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -270,7 +272,7 @@ static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, | ||||||
| 
 | 
 | ||||||
| 	if (i == retry) { | 	if (i == retry) { | ||||||
| 		debug("%s: Timeout.\n", __func__); | 		debug("%s: Timeout.\n", __func__); | ||||||
| 		return TIMEOUT; | 		return -ETIMEDOUT; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if (mask & DWMCI_INTMSK_RTO) { | 	if (mask & DWMCI_INTMSK_RTO) { | ||||||
|  | @ -283,7 +285,7 @@ static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, | ||||||
| 		 * CMD8, please keep that in mind. | 		 * CMD8, please keep that in mind. | ||||||
| 		 */ | 		 */ | ||||||
| 		debug("%s: Response Timeout.\n", __func__); | 		debug("%s: Response Timeout.\n", __func__); | ||||||
| 		return TIMEOUT; | 		return -ETIMEDOUT; | ||||||
| 	} else if (mask & DWMCI_INTMSK_RE) { | 	} else if (mask & DWMCI_INTMSK_RE) { | ||||||
| 		debug("%s: Response Error.\n", __func__); | 		debug("%s: Response Error.\n", __func__); | ||||||
| 		return -EIO; | 		return -EIO; | ||||||
|  |  | ||||||
|  | @ -10,12 +10,12 @@ | ||||||
| #include <fdtdec.h> | #include <fdtdec.h> | ||||||
| #include <libfdt.h> | #include <libfdt.h> | ||||||
| #include <malloc.h> | #include <malloc.h> | ||||||
|  | #include <errno.h> | ||||||
| #include <asm/arch/dwmmc.h> | #include <asm/arch/dwmmc.h> | ||||||
| #include <asm/arch/clk.h> | #include <asm/arch/clk.h> | ||||||
| #include <asm/arch/pinmux.h> | #include <asm/arch/pinmux.h> | ||||||
| #include <asm/arch/power.h> | #include <asm/arch/power.h> | ||||||
| #include <asm/gpio.h> | #include <asm/gpio.h> | ||||||
| #include <asm-generic/errno.h> |  | ||||||
| 
 | 
 | ||||||
| #define	DWMMC_MAX_CH_NUM		4 | #define	DWMMC_MAX_CH_NUM		4 | ||||||
| #define	DWMMC_MAX_FREQ			52000000 | #define	DWMMC_MAX_FREQ			52000000 | ||||||
|  |  | ||||||
|  | @ -12,11 +12,11 @@ | ||||||
| #include <config.h> | #include <config.h> | ||||||
| #include <common.h> | #include <common.h> | ||||||
| #include <command.h> | #include <command.h> | ||||||
|  | #include <errno.h> | ||||||
| #include <hwconfig.h> | #include <hwconfig.h> | ||||||
| #include <mmc.h> | #include <mmc.h> | ||||||
| #include <part.h> | #include <part.h> | ||||||
| #include <malloc.h> | #include <malloc.h> | ||||||
| #include <mmc.h> |  | ||||||
| #include <fsl_esdhc.h> | #include <fsl_esdhc.h> | ||||||
| #include <fdt_support.h> | #include <fdt_support.h> | ||||||
| #include <asm/io.h> | #include <asm/io.h> | ||||||
|  | @ -253,7 +253,7 @@ static int esdhc_setup_data(struct mmc *mmc, struct mmc_data *data) | ||||||
| 			if ((esdhc_read32(®s->prsstat) & | 			if ((esdhc_read32(®s->prsstat) & | ||||||
| 			    PRSSTAT_WPSPL) == 0) { | 			    PRSSTAT_WPSPL) == 0) { | ||||||
| 				printf("\nThe SD card is locked. Can not write to a locked card.\n\n"); | 				printf("\nThe SD card is locked. Can not write to a locked card.\n\n"); | ||||||
| 				return TIMEOUT; | 				return -ETIMEDOUT; | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  | @ -411,12 +411,12 @@ esdhc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data) | ||||||
| 	irqstat = esdhc_read32(®s->irqstat); | 	irqstat = esdhc_read32(®s->irqstat); | ||||||
| 
 | 
 | ||||||
| 	if (irqstat & CMD_ERR) { | 	if (irqstat & CMD_ERR) { | ||||||
| 		err = COMM_ERR; | 		err = -ECOMM; | ||||||
| 		goto out; | 		goto out; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if (irqstat & IRQSTAT_CTOE) { | 	if (irqstat & IRQSTAT_CTOE) { | ||||||
| 		err = TIMEOUT; | 		err = -ETIMEDOUT; | ||||||
| 		goto out; | 		goto out; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -442,7 +442,7 @@ esdhc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data) | ||||||
| 
 | 
 | ||||||
| 		if (timeout <= 0) { | 		if (timeout <= 0) { | ||||||
| 			printf("Timeout waiting for DAT0 to go high!\n"); | 			printf("Timeout waiting for DAT0 to go high!\n"); | ||||||
| 			err = TIMEOUT; | 			err = -ETIMEDOUT; | ||||||
| 			goto out; | 			goto out; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  | @ -471,12 +471,12 @@ esdhc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data) | ||||||
| 			irqstat = esdhc_read32(®s->irqstat); | 			irqstat = esdhc_read32(®s->irqstat); | ||||||
| 
 | 
 | ||||||
| 			if (irqstat & IRQSTAT_DTOE) { | 			if (irqstat & IRQSTAT_DTOE) { | ||||||
| 				err = TIMEOUT; | 				err = -ETIMEDOUT; | ||||||
| 				goto out; | 				goto out; | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
| 			if (irqstat & DATA_ERR) { | 			if (irqstat & DATA_ERR) { | ||||||
| 				err = COMM_ERR; | 				err = -ECOMM; | ||||||
| 				goto out; | 				goto out; | ||||||
| 			} | 			} | ||||||
| 		} while ((irqstat & DATA_COMPLETE) != DATA_COMPLETE); | 		} while ((irqstat & DATA_COMPLETE) != DATA_COMPLETE); | ||||||
|  |  | ||||||
|  | @ -34,7 +34,7 @@ static inline int ftsdc010_send_cmd(struct mmc *mmc, struct mmc_cmd *mmc_cmd) | ||||||
| { | { | ||||||
| 	struct ftsdc010_chip *chip = mmc->priv; | 	struct ftsdc010_chip *chip = mmc->priv; | ||||||
| 	struct ftsdc010_mmc __iomem *regs = chip->regs; | 	struct ftsdc010_mmc __iomem *regs = chip->regs; | ||||||
| 	int ret = TIMEOUT; | 	int ret = -ETIMEDOUT; | ||||||
| 	uint32_t ts, st; | 	uint32_t ts, st; | ||||||
| 	uint32_t cmd   = FTSDC010_CMD_IDX(mmc_cmd->cmdidx); | 	uint32_t cmd   = FTSDC010_CMD_IDX(mmc_cmd->cmdidx); | ||||||
| 	uint32_t arg   = mmc_cmd->cmdarg; | 	uint32_t arg   = mmc_cmd->cmdarg; | ||||||
|  | @ -126,7 +126,7 @@ static void ftsdc010_clkset(struct mmc *mmc, uint32_t rate) | ||||||
| 
 | 
 | ||||||
| static int ftsdc010_wait(struct ftsdc010_mmc __iomem *regs, uint32_t mask) | static int ftsdc010_wait(struct ftsdc010_mmc __iomem *regs, uint32_t mask) | ||||||
| { | { | ||||||
| 	int ret = TIMEOUT; | 	int ret = -ETIMEDOUT; | ||||||
| 	uint32_t st, ts; | 	uint32_t st, ts; | ||||||
| 
 | 
 | ||||||
| 	for (ts = get_timer(0); get_timer(ts) < CFG_CMD_TIMEOUT; ) { | 	for (ts = get_timer(0); get_timer(ts) < CFG_CMD_TIMEOUT; ) { | ||||||
|  | @ -151,7 +151,7 @@ static int ftsdc010_wait(struct ftsdc010_mmc __iomem *regs, uint32_t mask) | ||||||
| static int ftsdc010_request(struct mmc *mmc, struct mmc_cmd *cmd, | static int ftsdc010_request(struct mmc *mmc, struct mmc_cmd *cmd, | ||||||
| 	struct mmc_data *data) | 	struct mmc_data *data) | ||||||
| { | { | ||||||
| 	int ret = UNUSABLE_ERR; | 	int ret = -EOPNOTSUPP; | ||||||
| 	uint32_t len = 0; | 	uint32_t len = 0; | ||||||
| 	struct ftsdc010_chip *chip = mmc->priv; | 	struct ftsdc010_chip *chip = mmc->priv; | ||||||
| 	struct ftsdc010_mmc __iomem *regs = chip->regs; | 	struct ftsdc010_mmc __iomem *regs = chip->regs; | ||||||
|  | @ -279,7 +279,7 @@ static int ftsdc010_init(struct mmc *mmc) | ||||||
| 	uint32_t ts; | 	uint32_t ts; | ||||||
| 
 | 
 | ||||||
| 	if (readl(®s->status) & FTSDC010_STATUS_CARD_DETECT) | 	if (readl(®s->status) & FTSDC010_STATUS_CARD_DETECT) | ||||||
| 		return NO_CARD_ERR; | 		return -ENOMEDIUM; | ||||||
| 
 | 
 | ||||||
| 	if (readl(®s->status) & FTSDC010_STATUS_WRITE_PROT) { | 	if (readl(®s->status) & FTSDC010_STATUS_WRITE_PROT) { | ||||||
| 		printf("ftsdc010: write protected\n"); | 		printf("ftsdc010: write protected\n"); | ||||||
|  | @ -297,7 +297,7 @@ static int ftsdc010_init(struct mmc *mmc) | ||||||
| 	} | 	} | ||||||
| 	if (readl(®s->cmd) & FTSDC010_CMD_SDC_RST) { | 	if (readl(®s->cmd) & FTSDC010_CMD_SDC_RST) { | ||||||
| 		printf("ftsdc010: reset failed\n"); | 		printf("ftsdc010: reset failed\n"); | ||||||
| 		return UNUSABLE_ERR; | 		return -EOPNOTSUPP; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/* 2. enter low speed mode (400k card detection) */ | 	/* 2. enter low speed mode (400k card detection) */ | ||||||
|  |  | ||||||
|  | @ -213,7 +213,7 @@ mci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data) | ||||||
| 
 | 
 | ||||||
| 	if (!priv->initialized) { | 	if (!priv->initialized) { | ||||||
| 		puts ("MCI not initialized!\n"); | 		puts ("MCI not initialized!\n"); | ||||||
| 		return COMM_ERR; | 		return -ECOMM; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/* Figure out the transfer arguments */ | 	/* Figure out the transfer arguments */ | ||||||
|  | @ -238,10 +238,10 @@ mci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data) | ||||||
| 
 | 
 | ||||||
| 	if ((status & error_flags) & MMCI_BIT(RTOE)) { | 	if ((status & error_flags) & MMCI_BIT(RTOE)) { | ||||||
| 		dump_cmd(cmdr, cmd->cmdarg, status, "Command Time Out"); | 		dump_cmd(cmdr, cmd->cmdarg, status, "Command Time Out"); | ||||||
| 		return TIMEOUT; | 		return -ETIMEDOUT; | ||||||
| 	} else if (status & error_flags) { | 	} else if (status & error_flags) { | ||||||
| 		dump_cmd(cmdr, cmd->cmdarg, status, "Command Failed"); | 		dump_cmd(cmdr, cmd->cmdarg, status, "Command Failed"); | ||||||
| 		return COMM_ERR; | 		return -ECOMM; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/* Copy the response to the response buffer */ | 	/* Copy the response to the response buffer */ | ||||||
|  | @ -303,7 +303,7 @@ mci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data) | ||||||
| 			if (status) { | 			if (status) { | ||||||
| 				dump_cmd(cmdr, cmd->cmdarg, status, | 				dump_cmd(cmdr, cmd->cmdarg, status, | ||||||
| 					"Data Transfer Failed"); | 					"Data Transfer Failed"); | ||||||
| 				return COMM_ERR; | 				return -ECOMM; | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  | @ -315,7 +315,7 @@ mci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data) | ||||||
| 			if (status & error_flags) { | 			if (status & error_flags) { | ||||||
| 				dump_cmd(cmdr, cmd->cmdarg, status, | 				dump_cmd(cmdr, cmd->cmdarg, status, | ||||||
| 					"DTIP Wait Failed"); | 					"DTIP Wait Failed"); | ||||||
| 				return COMM_ERR; | 				return -ECOMM; | ||||||
| 			} | 			} | ||||||
| 			i++; | 			i++; | ||||||
| 		} while ((status & MMCI_BIT(DTIP)) && i < 10000); | 		} while ((status & MMCI_BIT(DTIP)) && i < 10000); | ||||||
|  |  | ||||||
|  | @ -169,7 +169,7 @@ void print_mmc_devices(char separator) | ||||||
| 
 | 
 | ||||||
| 	for (uclass_first_device(UCLASS_MMC, &dev); | 	for (uclass_first_device(UCLASS_MMC, &dev); | ||||||
| 	     dev; | 	     dev; | ||||||
| 	     uclass_next_device(&dev)) { | 	     uclass_next_device(&dev), first = false) { | ||||||
| 		struct mmc *m = mmc_get_mmc_dev(dev); | 		struct mmc *m = mmc_get_mmc_dev(dev); | ||||||
| 
 | 
 | ||||||
| 		if (!first) { | 		if (!first) { | ||||||
|  |  | ||||||
|  | @ -152,7 +152,7 @@ int mmc_send_status(struct mmc *mmc, int timeout) | ||||||
| 				printf("Status Error: 0x%08X\n", | 				printf("Status Error: 0x%08X\n", | ||||||
| 					cmd.response[0]); | 					cmd.response[0]); | ||||||
| #endif | #endif | ||||||
| 				return COMM_ERR; | 				return -ECOMM; | ||||||
| 			} | 			} | ||||||
| 		} else if (--retries < 0) | 		} else if (--retries < 0) | ||||||
| 			return err; | 			return err; | ||||||
|  | @ -168,7 +168,7 @@ int mmc_send_status(struct mmc *mmc, int timeout) | ||||||
| #if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT) | #if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT) | ||||||
| 		printf("Timeout waiting card ready\n"); | 		printf("Timeout waiting card ready\n"); | ||||||
| #endif | #endif | ||||||
| 		return TIMEOUT; | 		return -ETIMEDOUT; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	return 0; | 	return 0; | ||||||
|  | @ -344,7 +344,7 @@ static int sd_send_op_cond(struct mmc *mmc) | ||||||
| 			break; | 			break; | ||||||
| 
 | 
 | ||||||
| 		if (timeout-- <= 0) | 		if (timeout-- <= 0) | ||||||
| 			return UNUSABLE_ERR; | 			return -EOPNOTSUPP; | ||||||
| 
 | 
 | ||||||
| 		udelay(1000); | 		udelay(1000); | ||||||
| 	} | 	} | ||||||
|  | @ -430,7 +430,7 @@ static int mmc_complete_op_cond(struct mmc *mmc) | ||||||
| 			if (mmc->ocr & OCR_BUSY) | 			if (mmc->ocr & OCR_BUSY) | ||||||
| 				break; | 				break; | ||||||
| 			if (get_timer(start) > timeout) | 			if (get_timer(start) > timeout) | ||||||
| 				return UNUSABLE_ERR; | 				return -EOPNOTSUPP; | ||||||
| 			udelay(100); | 			udelay(100); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  | @ -1429,7 +1429,7 @@ static int mmc_startup(struct mmc *mmc) | ||||||
| 				   &test_csd[EXT_CSD_SEC_CNT], 4) == 0) | 				   &test_csd[EXT_CSD_SEC_CNT], 4) == 0) | ||||||
| 				break; | 				break; | ||||||
| 			else | 			else | ||||||
| 				err = SWITCH_ERR; | 				err = -EBADMSG; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		if (err) | 		if (err) | ||||||
|  | @ -1499,7 +1499,7 @@ static int mmc_send_if_cond(struct mmc *mmc) | ||||||
| 		return err; | 		return err; | ||||||
| 
 | 
 | ||||||
| 	if ((cmd.response[0] & 0xff) != 0xaa) | 	if ((cmd.response[0] & 0xff) != 0xaa) | ||||||
| 		return UNUSABLE_ERR; | 		return -EOPNOTSUPP; | ||||||
| 	else | 	else | ||||||
| 		mmc->version = SD_VERSION_2; | 		mmc->version = SD_VERSION_2; | ||||||
| 
 | 
 | ||||||
|  | @ -1526,7 +1526,7 @@ int mmc_start_init(struct mmc *mmc) | ||||||
| #if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT) | #if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT) | ||||||
| 		printf("MMC: no card present\n"); | 		printf("MMC: no card present\n"); | ||||||
| #endif | #endif | ||||||
| 		return NO_CARD_ERR; | 		return -ENOMEDIUM; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if (mmc->has_init) | 	if (mmc->has_init) | ||||||
|  | @ -1565,14 +1565,14 @@ int mmc_start_init(struct mmc *mmc) | ||||||
| 	err = sd_send_op_cond(mmc); | 	err = sd_send_op_cond(mmc); | ||||||
| 
 | 
 | ||||||
| 	/* If the command timed out, we check for an MMC card */ | 	/* If the command timed out, we check for an MMC card */ | ||||||
| 	if (err == TIMEOUT) { | 	if (err == -ETIMEDOUT) { | ||||||
| 		err = mmc_send_op_cond(mmc); | 		err = mmc_send_op_cond(mmc); | ||||||
| 
 | 
 | ||||||
| 		if (err) { | 		if (err) { | ||||||
| #if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT) | #if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT) | ||||||
| 			printf("Card did not respond to voltage select!\n"); | 			printf("Card did not respond to voltage select!\n"); | ||||||
| #endif | #endif | ||||||
| 			return UNUSABLE_ERR; | 			return -EOPNOTSUPP; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -5,6 +5,7 @@ | ||||||
|  * Licensed under the GPL-2 or later. |  * Licensed under the GPL-2 or later. | ||||||
|  */ |  */ | ||||||
| #include <common.h> | #include <common.h> | ||||||
|  | #include <errno.h> | ||||||
| #include <malloc.h> | #include <malloc.h> | ||||||
| #include <part.h> | #include <part.h> | ||||||
| #include <mmc.h> | #include <mmc.h> | ||||||
|  | @ -182,13 +183,13 @@ static int mmc_spi_request(struct mmc *mmc, struct mmc_cmd *cmd, | ||||||
| 	spi_cs_activate(spi); | 	spi_cs_activate(spi); | ||||||
| 	r1 = mmc_spi_sendcmd(mmc, cmd->cmdidx, cmd->cmdarg); | 	r1 = mmc_spi_sendcmd(mmc, cmd->cmdidx, cmd->cmdarg); | ||||||
| 	if (r1 == 0xff) { /* no response */ | 	if (r1 == 0xff) { /* no response */ | ||||||
| 		ret = NO_CARD_ERR; | 		ret = -ENOMEDIUM; | ||||||
| 		goto done; | 		goto done; | ||||||
| 	} else if (r1 & R1_SPI_COM_CRC) { | 	} else if (r1 & R1_SPI_COM_CRC) { | ||||||
| 		ret = COMM_ERR; | 		ret = -ECOMM; | ||||||
| 		goto done; | 		goto done; | ||||||
| 	} else if (r1 & ~R1_SPI_IDLE) { /* other errors */ | 	} else if (r1 & ~R1_SPI_IDLE) { /* other errors */ | ||||||
| 		ret = TIMEOUT; | 		ret = -ETIMEDOUT; | ||||||
| 		goto done; | 		goto done; | ||||||
| 	} else if (cmd->resp_type == MMC_RSP_R2) { | 	} else if (cmd->resp_type == MMC_RSP_R2) { | ||||||
| 		r1 = mmc_spi_readdata(mmc, cmd->response, 1, 16); | 		r1 = mmc_spi_readdata(mmc, cmd->response, 1, 16); | ||||||
|  | @ -225,9 +226,9 @@ static int mmc_spi_request(struct mmc *mmc, struct mmc_cmd *cmd, | ||||||
| 				data->blocks, data->blocksize, | 				data->blocks, data->blocksize, | ||||||
| 				(cmd->cmdidx == MMC_CMD_WRITE_MULTIPLE_BLOCK)); | 				(cmd->cmdidx == MMC_CMD_WRITE_MULTIPLE_BLOCK)); | ||||||
| 		if (r1 & R1_SPI_COM_CRC) | 		if (r1 & R1_SPI_COM_CRC) | ||||||
| 			ret = COMM_ERR; | 			ret = -ECOMM; | ||||||
| 		else if (r1) /* other errors */ | 		else if (r1) /* other errors */ | ||||||
| 			ret = TIMEOUT; | 			ret = -ETIMEDOUT; | ||||||
| 	} | 	} | ||||||
| done: | done: | ||||||
| 	spi_cs_deactivate(spi); | 	spi_cs_deactivate(spi); | ||||||
|  |  | ||||||
|  | @ -143,9 +143,7 @@ static int msm_sdc_probe(struct udevice *dev) | ||||||
| 	/* Set host controller version */ | 	/* Set host controller version */ | ||||||
| 	host->version = sdhci_readw(host, SDHCI_HOST_VERSION); | 	host->version = sdhci_readw(host, SDHCI_HOST_VERSION); | ||||||
| 
 | 
 | ||||||
| 	caps = sdhci_readl(host, SDHCI_CAPABILITIES); | 	ret = sdhci_setup_cfg(&plat->cfg, host, 0, 0); | ||||||
| 	ret = sdhci_setup_cfg(&plat->cfg, dev->name, host->bus_width, |  | ||||||
| 			      caps, 0, 0, host->version, host->quirks, 0); |  | ||||||
| 	host->mmc = &plat->mmc; | 	host->mmc = &plat->mmc; | ||||||
| 	if (ret) | 	if (ret) | ||||||
| 		return ret; | 		return ret; | ||||||
|  |  | ||||||
|  | @ -9,6 +9,7 @@ | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| #include <common.h> | #include <common.h> | ||||||
|  | #include <errno.h> | ||||||
| #include <malloc.h> | #include <malloc.h> | ||||||
| #include <part.h> | #include <part.h> | ||||||
| #include <mmc.h> | #include <mmc.h> | ||||||
|  | @ -172,15 +173,15 @@ static int mvebu_mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, | ||||||
| 			    (SDIO_ERR_CMD_TIMEOUT | SDIO_ERR_DATA_TIMEOUT)) { | 			    (SDIO_ERR_CMD_TIMEOUT | SDIO_ERR_DATA_TIMEOUT)) { | ||||||
| 				debug("%s: command READ timed out\n", | 				debug("%s: command READ timed out\n", | ||||||
| 				      DRIVER_NAME); | 				      DRIVER_NAME); | ||||||
| 				return TIMEOUT; | 				return -ETIMEDOUT; | ||||||
| 			} | 			} | ||||||
| 			debug("%s: command READ error\n", DRIVER_NAME); | 			debug("%s: command READ error\n", DRIVER_NAME); | ||||||
| 			return COMM_ERR; | 			return -ECOMM; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		if ((get_timer(0) - start) > TIMEOUT_DELAY) { | 		if ((get_timer(0) - start) > TIMEOUT_DELAY) { | ||||||
| 			debug("%s: command timed out\n", DRIVER_NAME); | 			debug("%s: command timed out\n", DRIVER_NAME); | ||||||
| 			return TIMEOUT; | 			return -ETIMEDOUT; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -232,7 +233,7 @@ static int mvebu_mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, | ||||||
| 
 | 
 | ||||||
| 	if (mvebu_mmc_read(SDIO_ERR_INTR_STATUS) & | 	if (mvebu_mmc_read(SDIO_ERR_INTR_STATUS) & | ||||||
| 		(SDIO_ERR_CMD_TIMEOUT | SDIO_ERR_DATA_TIMEOUT)) | 		(SDIO_ERR_CMD_TIMEOUT | SDIO_ERR_DATA_TIMEOUT)) | ||||||
| 		return TIMEOUT; | 		return -ETIMEDOUT; | ||||||
| 
 | 
 | ||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -211,11 +211,11 @@ static int mxcmci_finish_data(struct mxcmci_host *host, unsigned int stat) | ||||||
| 		} else if (stat & STATUS_CRC_WRITE_ERR) { | 		} else if (stat & STATUS_CRC_WRITE_ERR) { | ||||||
| 			u32 err_code = (stat >> 9) & 0x3; | 			u32 err_code = (stat >> 9) & 0x3; | ||||||
| 			if (err_code == 2) /* No CRC response */ | 			if (err_code == 2) /* No CRC response */ | ||||||
| 				data_error = TIMEOUT; | 				data_error = -ETIMEDOUT; | ||||||
| 			else | 			else | ||||||
| 				data_error = -EILSEQ; | 				data_error = -EILSEQ; | ||||||
| 		} else if (stat & STATUS_TIME_OUT_READ) { | 		} else if (stat & STATUS_TIME_OUT_READ) { | ||||||
| 			data_error = TIMEOUT; | 			data_error = -ETIMEDOUT; | ||||||
| 		} else { | 		} else { | ||||||
| 			data_error = -EIO; | 			data_error = -EIO; | ||||||
| 		} | 		} | ||||||
|  | @ -238,7 +238,7 @@ static int mxcmci_read_response(struct mxcmci_host *host, unsigned int stat) | ||||||
| 
 | 
 | ||||||
| 	if (stat & STATUS_TIME_OUT_RESP) { | 	if (stat & STATUS_TIME_OUT_RESP) { | ||||||
| 		printf("CMD TIMEOUT\n"); | 		printf("CMD TIMEOUT\n"); | ||||||
| 		return TIMEOUT; | 		return -ETIMEDOUT; | ||||||
| 	} else if (stat & STATUS_RESP_CRC_ERR && cmd->resp_type & MMC_RSP_CRC) { | 	} else if (stat & STATUS_RESP_CRC_ERR && cmd->resp_type & MMC_RSP_CRC) { | ||||||
| 		printf("cmd crc error\n"); | 		printf("cmd crc error\n"); | ||||||
| 		return -EILSEQ; | 		return -EILSEQ; | ||||||
|  |  | ||||||
|  | @ -84,7 +84,7 @@ static int mxsmmc_send_cmd_pio(struct mxsmmc_priv *priv, struct mmc_data *data) | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	return timeout ? 0 : COMM_ERR; | 	return timeout ? 0 : -ECOMM; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static int mxsmmc_send_cmd_dma(struct mxsmmc_priv *priv, struct mmc_data *data) | static int mxsmmc_send_cmd_dma(struct mxsmmc_priv *priv, struct mmc_data *data) | ||||||
|  | @ -120,7 +120,7 @@ static int mxsmmc_send_cmd_dma(struct mxsmmc_priv *priv, struct mmc_data *data) | ||||||
| 	mxs_dma_desc_append(dmach, priv->desc); | 	mxs_dma_desc_append(dmach, priv->desc); | ||||||
| 	if (mxs_dma_go(dmach)) { | 	if (mxs_dma_go(dmach)) { | ||||||
| 		bounce_buffer_stop(&bbstate); | 		bounce_buffer_stop(&bbstate); | ||||||
| 		return COMM_ERR; | 		return -ECOMM; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	bounce_buffer_stop(&bbstate); | 	bounce_buffer_stop(&bbstate); | ||||||
|  | @ -158,13 +158,13 @@ mxsmmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data) | ||||||
| 
 | 
 | ||||||
| 	if (!timeout) { | 	if (!timeout) { | ||||||
| 		printf("MMC%d: Bus busy timeout!\n", mmc->block_dev.devnum); | 		printf("MMC%d: Bus busy timeout!\n", mmc->block_dev.devnum); | ||||||
| 		return TIMEOUT; | 		return -ETIMEDOUT; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/* See if card is present */ | 	/* See if card is present */ | ||||||
| 	if (!mxsmmc_cd(priv)) { | 	if (!mxsmmc_cd(priv)) { | ||||||
| 		printf("MMC%d: No card detected!\n", mmc->block_dev.devnum); | 		printf("MMC%d: No card detected!\n", mmc->block_dev.devnum); | ||||||
| 		return NO_CARD_ERR; | 		return -ENOMEDIUM; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/* Start building CTRL0 contents */ | 	/* Start building CTRL0 contents */ | ||||||
|  | @ -203,7 +203,7 @@ mxsmmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data) | ||||||
| 			priv->mmc_is_wp(mmc->block_dev.devnum)) { | 			priv->mmc_is_wp(mmc->block_dev.devnum)) { | ||||||
| 			printf("MMC%d: Can not write a locked card!\n", | 			printf("MMC%d: Can not write a locked card!\n", | ||||||
| 				mmc->block_dev.devnum); | 				mmc->block_dev.devnum); | ||||||
| 			return UNUSABLE_ERR; | 			return -EOPNOTSUPP; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		ctrl0 |= SSP_CTRL0_DATA_XFER; | 		ctrl0 |= SSP_CTRL0_DATA_XFER; | ||||||
|  | @ -244,21 +244,21 @@ mxsmmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data) | ||||||
| 	if (!timeout) { | 	if (!timeout) { | ||||||
| 		printf("MMC%d: Command %d busy\n", | 		printf("MMC%d: Command %d busy\n", | ||||||
| 			mmc->block_dev.devnum, cmd->cmdidx); | 			mmc->block_dev.devnum, cmd->cmdidx); | ||||||
| 		return TIMEOUT; | 		return -ETIMEDOUT; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/* Check command timeout */ | 	/* Check command timeout */ | ||||||
| 	if (reg & SSP_STATUS_RESP_TIMEOUT) { | 	if (reg & SSP_STATUS_RESP_TIMEOUT) { | ||||||
| 		printf("MMC%d: Command %d timeout (status 0x%08x)\n", | 		printf("MMC%d: Command %d timeout (status 0x%08x)\n", | ||||||
| 			mmc->block_dev.devnum, cmd->cmdidx, reg); | 			mmc->block_dev.devnum, cmd->cmdidx, reg); | ||||||
| 		return TIMEOUT; | 		return -ETIMEDOUT; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/* Check command errors */ | 	/* Check command errors */ | ||||||
| 	if (reg & (SSP_STATUS_RESP_CRC_ERR | SSP_STATUS_RESP_ERR)) { | 	if (reg & (SSP_STATUS_RESP_CRC_ERR | SSP_STATUS_RESP_ERR)) { | ||||||
| 		printf("MMC%d: Command %d error (status 0x%08x)!\n", | 		printf("MMC%d: Command %d error (status 0x%08x)!\n", | ||||||
| 			mmc->block_dev.devnum, cmd->cmdidx, reg); | 			mmc->block_dev.devnum, cmd->cmdidx, reg); | ||||||
| 		return COMM_ERR; | 		return -ECOMM; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	/* Copy response to response buffer */ | 	/* Copy response to response buffer */ | ||||||
|  | @ -298,7 +298,7 @@ mxsmmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data) | ||||||
| 		SSP_STATUS_FIFO_OVRFLW | SSP_STATUS_FIFO_UNDRFLW)) { | 		SSP_STATUS_FIFO_OVRFLW | SSP_STATUS_FIFO_UNDRFLW)) { | ||||||
| 		printf("MMC%d: Data error with command %d (status 0x%08x)!\n", | 		printf("MMC%d: Data error with command %d (status 0x%08x)!\n", | ||||||
| 			mmc->block_dev.devnum, cmd->cmdidx, reg); | 			mmc->block_dev.devnum, cmd->cmdidx, reg); | ||||||
| 		return COMM_ERR; | 		return -ECOMM; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	return 0; | 	return 0; | ||||||
|  |  | ||||||
|  | @ -231,7 +231,7 @@ static int omap_hsmmc_init_setup(struct mmc *mmc) | ||||||
| 	while ((readl(&mmc_base->sysstatus) & RESETDONE) == 0) { | 	while ((readl(&mmc_base->sysstatus) & RESETDONE) == 0) { | ||||||
| 		if (get_timer(0) - start > MAX_RETRY_MS) { | 		if (get_timer(0) - start > MAX_RETRY_MS) { | ||||||
| 			printf("%s: timedout waiting for cc2!\n", __func__); | 			printf("%s: timedout waiting for cc2!\n", __func__); | ||||||
| 			return TIMEOUT; | 			return -ETIMEDOUT; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	writel(readl(&mmc_base->sysctl) | SOFTRESETALL, &mmc_base->sysctl); | 	writel(readl(&mmc_base->sysctl) | SOFTRESETALL, &mmc_base->sysctl); | ||||||
|  | @ -240,7 +240,7 @@ static int omap_hsmmc_init_setup(struct mmc *mmc) | ||||||
| 		if (get_timer(0) - start > MAX_RETRY_MS) { | 		if (get_timer(0) - start > MAX_RETRY_MS) { | ||||||
| 			printf("%s: timedout waiting for softresetall!\n", | 			printf("%s: timedout waiting for softresetall!\n", | ||||||
| 				__func__); | 				__func__); | ||||||
| 			return TIMEOUT; | 			return -ETIMEDOUT; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	writel(DTW_1_BITMODE | SDBP_PWROFF | SDVS_3V0, &mmc_base->hctl); | 	writel(DTW_1_BITMODE | SDBP_PWROFF | SDVS_3V0, &mmc_base->hctl); | ||||||
|  | @ -262,7 +262,7 @@ static int omap_hsmmc_init_setup(struct mmc *mmc) | ||||||
| 	while ((readl(&mmc_base->sysctl) & ICS_MASK) == ICS_NOTREADY) { | 	while ((readl(&mmc_base->sysctl) & ICS_MASK) == ICS_NOTREADY) { | ||||||
| 		if (get_timer(0) - start > MAX_RETRY_MS) { | 		if (get_timer(0) - start > MAX_RETRY_MS) { | ||||||
| 			printf("%s: timedout waiting for ics!\n", __func__); | 			printf("%s: timedout waiting for ics!\n", __func__); | ||||||
| 			return TIMEOUT; | 			return -ETIMEDOUT; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	writel(readl(&mmc_base->sysctl) | CEN_ENABLE, &mmc_base->sysctl); | 	writel(readl(&mmc_base->sysctl) | CEN_ENABLE, &mmc_base->sysctl); | ||||||
|  | @ -337,7 +337,7 @@ static int omap_hsmmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, | ||||||
| 		if (get_timer(0) - start > MAX_RETRY_MS) { | 		if (get_timer(0) - start > MAX_RETRY_MS) { | ||||||
| 			printf("%s: timedout waiting on cmd inhibit to clear\n", | 			printf("%s: timedout waiting on cmd inhibit to clear\n", | ||||||
| 					__func__); | 					__func__); | ||||||
| 			return TIMEOUT; | 			return -ETIMEDOUT; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	writel(0xFFFFFFFF, &mmc_base->stat); | 	writel(0xFFFFFFFF, &mmc_base->stat); | ||||||
|  | @ -346,7 +346,7 @@ static int omap_hsmmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, | ||||||
| 		if (get_timer(0) - start > MAX_RETRY_MS) { | 		if (get_timer(0) - start > MAX_RETRY_MS) { | ||||||
| 			printf("%s: timedout waiting for STAT (%x) to clear\n", | 			printf("%s: timedout waiting for STAT (%x) to clear\n", | ||||||
| 				__func__, readl(&mmc_base->stat)); | 				__func__, readl(&mmc_base->stat)); | ||||||
| 			return TIMEOUT; | 			return -ETIMEDOUT; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	/*
 | 	/*
 | ||||||
|  | @ -410,13 +410,13 @@ static int omap_hsmmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, | ||||||
| 		mmc_stat = readl(&mmc_base->stat); | 		mmc_stat = readl(&mmc_base->stat); | ||||||
| 		if (get_timer(0) - start > MAX_RETRY_MS) { | 		if (get_timer(0) - start > MAX_RETRY_MS) { | ||||||
| 			printf("%s : timeout: No status update\n", __func__); | 			printf("%s : timeout: No status update\n", __func__); | ||||||
| 			return TIMEOUT; | 			return -ETIMEDOUT; | ||||||
| 		} | 		} | ||||||
| 	} while (!mmc_stat); | 	} while (!mmc_stat); | ||||||
| 
 | 
 | ||||||
| 	if ((mmc_stat & IE_CTO) != 0) { | 	if ((mmc_stat & IE_CTO) != 0) { | ||||||
| 		mmc_reset_controller_fsm(mmc_base, SYSCTL_SRC); | 		mmc_reset_controller_fsm(mmc_base, SYSCTL_SRC); | ||||||
| 		return TIMEOUT; | 		return -ETIMEDOUT; | ||||||
| 	} else if ((mmc_stat & ERRI_MASK) != 0) | 	} else if ((mmc_stat & ERRI_MASK) != 0) | ||||||
| 		return -1; | 		return -1; | ||||||
| 
 | 
 | ||||||
|  | @ -464,7 +464,7 @@ static int mmc_read_data(struct hsmmc *mmc_base, char *buf, unsigned int size) | ||||||
| 			if (get_timer(0) - start > MAX_RETRY_MS) { | 			if (get_timer(0) - start > MAX_RETRY_MS) { | ||||||
| 				printf("%s: timedout waiting for status!\n", | 				printf("%s: timedout waiting for status!\n", | ||||||
| 						__func__); | 						__func__); | ||||||
| 				return TIMEOUT; | 				return -ETIMEDOUT; | ||||||
| 			} | 			} | ||||||
| 		} while (mmc_stat == 0); | 		} while (mmc_stat == 0); | ||||||
| 
 | 
 | ||||||
|  | @ -519,7 +519,7 @@ static int mmc_write_data(struct hsmmc *mmc_base, const char *buf, | ||||||
| 			if (get_timer(0) - start > MAX_RETRY_MS) { | 			if (get_timer(0) - start > MAX_RETRY_MS) { | ||||||
| 				printf("%s: timedout waiting for status!\n", | 				printf("%s: timedout waiting for status!\n", | ||||||
| 						__func__); | 						__func__); | ||||||
| 				return TIMEOUT; | 				return -ETIMEDOUT; | ||||||
| 			} | 			} | ||||||
| 		} while (mmc_stat == 0); | 		} while (mmc_stat == 0); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -33,15 +33,11 @@ static int arasan_sdhci_probe(struct udevice *dev) | ||||||
| 	struct rockchip_sdhc *prv = dev_get_priv(dev); | 	struct rockchip_sdhc *prv = dev_get_priv(dev); | ||||||
| 	struct sdhci_host *host = &prv->host; | 	struct sdhci_host *host = &prv->host; | ||||||
| 	int ret; | 	int ret; | ||||||
| 	u32 caps; |  | ||||||
| 
 | 
 | ||||||
| 	host->version = sdhci_readw(host, SDHCI_HOST_VERSION); |  | ||||||
| 	host->quirks = SDHCI_QUIRK_WAIT_SEND_CMD; | 	host->quirks = SDHCI_QUIRK_WAIT_SEND_CMD; | ||||||
| 
 | 
 | ||||||
| 	caps = sdhci_readl(host, SDHCI_CAPABILITIES); | 	ret = sdhci_setup_cfg(&plat->cfg, host, CONFIG_ROCKCHIP_SDHCI_MAX_FREQ, | ||||||
| 	ret = sdhci_setup_cfg(&plat->cfg, dev->name, host->bus_width, | 			EMMC_MIN_FREQ); | ||||||
| 			caps, CONFIG_ROCKCHIP_SDHCI_MAX_FREQ, EMMC_MIN_FREQ, |  | ||||||
| 			host->version, host->quirks, 0); |  | ||||||
| 
 | 
 | ||||||
| 	host->mmc = &plat->mmc; | 	host->mmc = &plat->mmc; | ||||||
| 	if (ret) | 	if (ret) | ||||||
|  |  | ||||||
|  | @ -133,7 +133,7 @@ s3cmmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data) | ||||||
| 
 | 
 | ||||||
| 	if (!timeout) { | 	if (!timeout) { | ||||||
| 		puts("S3C SDI: Command timed out!\n"); | 		puts("S3C SDI: Command timed out!\n"); | ||||||
| 		ret = TIMEOUT; | 		ret = -ETIMEDOUT; | ||||||
| 		goto error; | 		goto error; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -196,7 +196,7 @@ s3cmmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data) | ||||||
| 
 | 
 | ||||||
| 	if (!timeout) { | 	if (!timeout) { | ||||||
| 		puts("S3C SDI: Command timed out!\n"); | 		puts("S3C SDI: Command timed out!\n"); | ||||||
| 		ret = TIMEOUT; | 		ret = -ETIMEDOUT; | ||||||
| 		goto error; | 		goto error; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -68,7 +68,7 @@ static int s5p_sdhci_core_init(struct sdhci_host *host) | ||||||
| 	host->name = S5P_NAME; | 	host->name = S5P_NAME; | ||||||
| 
 | 
 | ||||||
| 	host->quirks = SDHCI_QUIRK_NO_HISPD_BIT | SDHCI_QUIRK_BROKEN_VOLTAGE | | 	host->quirks = SDHCI_QUIRK_NO_HISPD_BIT | SDHCI_QUIRK_BROKEN_VOLTAGE | | ||||||
| 		SDHCI_QUIRK_BROKEN_R1B | SDHCI_QUIRK_32BIT_DMA_ADDR | | 		SDHCI_QUIRK_32BIT_DMA_ADDR | | ||||||
| 		SDHCI_QUIRK_WAIT_SEND_CMD | SDHCI_QUIRK_USE_WIDE8; | 		SDHCI_QUIRK_WAIT_SEND_CMD | SDHCI_QUIRK_USE_WIDE8; | ||||||
| 	host->voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165_195; | 	host->voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165_195; | ||||||
| 	host->version = sdhci_readw(host, SDHCI_HOST_VERSION); | 	host->version = sdhci_readw(host, SDHCI_HOST_VERSION); | ||||||
|  |  | ||||||
|  | @ -170,7 +170,7 @@ static int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd, | ||||||
| 				       cmd_timeout); | 				       cmd_timeout); | ||||||
| 			} else { | 			} else { | ||||||
| 				puts("timeout.\n"); | 				puts("timeout.\n"); | ||||||
| 				return COMM_ERR; | 				return -ECOMM; | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 		time++; | 		time++; | ||||||
|  | @ -184,7 +184,8 @@ static int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd, | ||||||
| 		flags = SDHCI_CMD_RESP_LONG; | 		flags = SDHCI_CMD_RESP_LONG; | ||||||
| 	else if (cmd->resp_type & MMC_RSP_BUSY) { | 	else if (cmd->resp_type & MMC_RSP_BUSY) { | ||||||
| 		flags = SDHCI_CMD_RESP_SHORT_BUSY; | 		flags = SDHCI_CMD_RESP_SHORT_BUSY; | ||||||
| 		mask |= SDHCI_INT_DATA_END; | 		if (data) | ||||||
|  | 			mask |= SDHCI_INT_DATA_END; | ||||||
| 	} else | 	} else | ||||||
| 		flags = SDHCI_CMD_RESP_SHORT; | 		flags = SDHCI_CMD_RESP_SHORT; | ||||||
| 
 | 
 | ||||||
|  | @ -252,17 +253,17 @@ static int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd, | ||||||
| 		stat = sdhci_readl(host, SDHCI_INT_STATUS); | 		stat = sdhci_readl(host, SDHCI_INT_STATUS); | ||||||
| 		if (stat & SDHCI_INT_ERROR) | 		if (stat & SDHCI_INT_ERROR) | ||||||
| 			break; | 			break; | ||||||
| 	} while (((stat & mask) != mask) && |  | ||||||
| 		 (get_timer(start) < SDHCI_READ_STATUS_TIMEOUT)); |  | ||||||
| 
 | 
 | ||||||
| 	if (get_timer(start) >= SDHCI_READ_STATUS_TIMEOUT) { | 		if (get_timer(start) >= SDHCI_READ_STATUS_TIMEOUT) { | ||||||
| 		if (host->quirks & SDHCI_QUIRK_BROKEN_R1B) | 			if (host->quirks & SDHCI_QUIRK_BROKEN_R1B) { | ||||||
| 			return 0; | 				return 0; | ||||||
| 		else { | 			} else { | ||||||
| 			printf("%s: Timeout for status update!\n", __func__); | 				printf("%s: Timeout for status update!\n", | ||||||
| 			return TIMEOUT; | 				       __func__); | ||||||
|  | 				return -ETIMEDOUT; | ||||||
|  | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} while ((stat & mask) != mask); | ||||||
| 
 | 
 | ||||||
| 	if ((stat & (SDHCI_INT_ERROR | mask)) == mask) { | 	if ((stat & (SDHCI_INT_ERROR | mask)) == mask) { | ||||||
| 		sdhci_cmd_done(host, cmd); | 		sdhci_cmd_done(host, cmd); | ||||||
|  | @ -288,9 +289,9 @@ static int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd, | ||||||
| 	sdhci_reset(host, SDHCI_RESET_CMD); | 	sdhci_reset(host, SDHCI_RESET_CMD); | ||||||
| 	sdhci_reset(host, SDHCI_RESET_DATA); | 	sdhci_reset(host, SDHCI_RESET_DATA); | ||||||
| 	if (stat & SDHCI_INT_TIMEOUT) | 	if (stat & SDHCI_INT_TIMEOUT) | ||||||
| 		return TIMEOUT; | 		return -ETIMEDOUT; | ||||||
| 	else | 	else | ||||||
| 		return COMM_ERR; | 		return -ECOMM; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static int sdhci_set_clock(struct mmc *mmc, unsigned int clock) | static int sdhci_set_clock(struct mmc *mmc, unsigned int clock) | ||||||
|  | @ -510,18 +511,22 @@ static const struct mmc_ops sdhci_ops = { | ||||||
| }; | }; | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| int sdhci_setup_cfg(struct mmc_config *cfg, const char *name, int buswidth, | int sdhci_setup_cfg(struct mmc_config *cfg, struct sdhci_host *host, | ||||||
| 		    uint caps, u32 max_clk, u32 min_clk, uint version, | 		u32 max_clk, u32 min_clk) | ||||||
| 		    uint quirks, uint host_caps) |  | ||||||
| { | { | ||||||
| 	cfg->name = name; | 	u32 caps; | ||||||
|  | 
 | ||||||
|  | 	caps = sdhci_readl(host, SDHCI_CAPABILITIES); | ||||||
|  | 	host->version = sdhci_readw(host, SDHCI_HOST_VERSION); | ||||||
|  | 
 | ||||||
|  | 	cfg->name = host->name; | ||||||
| #ifndef CONFIG_DM_MMC_OPS | #ifndef CONFIG_DM_MMC_OPS | ||||||
| 	cfg->ops = &sdhci_ops; | 	cfg->ops = &sdhci_ops; | ||||||
| #endif | #endif | ||||||
| 	if (max_clk) | 	if (max_clk) | ||||||
| 		cfg->f_max = max_clk; | 		cfg->f_max = max_clk; | ||||||
| 	else { | 	else { | ||||||
| 		if (version >= SDHCI_SPEC_300) | 		if (SDHCI_GET_VERSION(host) >= SDHCI_SPEC_300) | ||||||
| 			cfg->f_max = (caps & SDHCI_CLOCK_V3_BASE_MASK) >> | 			cfg->f_max = (caps & SDHCI_CLOCK_V3_BASE_MASK) >> | ||||||
| 				SDHCI_CLOCK_BASE_SHIFT; | 				SDHCI_CLOCK_BASE_SHIFT; | ||||||
| 		else | 		else | ||||||
|  | @ -534,7 +539,7 @@ int sdhci_setup_cfg(struct mmc_config *cfg, const char *name, int buswidth, | ||||||
| 	if (min_clk) | 	if (min_clk) | ||||||
| 		cfg->f_min = min_clk; | 		cfg->f_min = min_clk; | ||||||
| 	else { | 	else { | ||||||
| 		if (version >= SDHCI_SPEC_300) | 		if (SDHCI_GET_VERSION(host) >= SDHCI_SPEC_300) | ||||||
| 			cfg->f_min = cfg->f_max / SDHCI_MAX_DIV_SPEC_300; | 			cfg->f_min = cfg->f_max / SDHCI_MAX_DIV_SPEC_300; | ||||||
| 		else | 		else | ||||||
| 			cfg->f_min = cfg->f_max / SDHCI_MAX_DIV_SPEC_200; | 			cfg->f_min = cfg->f_max / SDHCI_MAX_DIV_SPEC_200; | ||||||
|  | @ -548,16 +553,13 @@ int sdhci_setup_cfg(struct mmc_config *cfg, const char *name, int buswidth, | ||||||
| 		cfg->voltages |= MMC_VDD_165_195; | 		cfg->voltages |= MMC_VDD_165_195; | ||||||
| 
 | 
 | ||||||
| 	cfg->host_caps = MMC_MODE_HS | MMC_MODE_HS_52MHz | MMC_MODE_4BIT; | 	cfg->host_caps = MMC_MODE_HS | MMC_MODE_HS_52MHz | MMC_MODE_4BIT; | ||||||
| 	if (version >= SDHCI_SPEC_300) { | 	if (SDHCI_GET_VERSION(host) >= SDHCI_SPEC_300) { | ||||||
| 		if (caps & SDHCI_CAN_DO_8BIT) | 		if (caps & SDHCI_CAN_DO_8BIT) | ||||||
| 			cfg->host_caps |= MMC_MODE_8BIT; | 			cfg->host_caps |= MMC_MODE_8BIT; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if (quirks & SDHCI_QUIRK_NO_HISPD_BIT) | 	if (host->host_caps) | ||||||
| 		cfg->host_caps &= ~(MMC_MODE_HS | MMC_MODE_HS_52MHz); | 		cfg->host_caps |= host->host_caps; | ||||||
| 
 |  | ||||||
| 	if (host_caps) |  | ||||||
| 		cfg->host_caps |= host_caps; |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 	cfg->b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT; | 	cfg->b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT; | ||||||
|  | @ -573,10 +575,10 @@ int sdhci_bind(struct udevice *dev, struct mmc *mmc, struct mmc_config *cfg) | ||||||
| #else | #else | ||||||
| int add_sdhci(struct sdhci_host *host, u32 max_clk, u32 min_clk) | int add_sdhci(struct sdhci_host *host, u32 max_clk, u32 min_clk) | ||||||
| { | { | ||||||
|  | #ifdef CONFIG_MMC_SDMA | ||||||
| 	unsigned int caps; | 	unsigned int caps; | ||||||
| 
 | 
 | ||||||
| 	caps = sdhci_readl(host, SDHCI_CAPABILITIES); | 	caps = sdhci_readl(host, SDHCI_CAPABILITIES); | ||||||
| #ifdef CONFIG_MMC_SDMA |  | ||||||
| 	if (!(caps & SDHCI_CAN_DO_SDMA)) { | 	if (!(caps & SDHCI_CAN_DO_SDMA)) { | ||||||
| 		printf("%s: Your controller doesn't support SDMA!!\n", | 		printf("%s: Your controller doesn't support SDMA!!\n", | ||||||
| 		       __func__); | 		       __func__); | ||||||
|  | @ -584,9 +586,7 @@ int add_sdhci(struct sdhci_host *host, u32 max_clk, u32 min_clk) | ||||||
| 	} | 	} | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| 	if (sdhci_setup_cfg(&host->cfg, host->name, host->bus_width, caps, | 	if (sdhci_setup_cfg(&host->cfg, host, max_clk, min_clk)) { | ||||||
| 			    max_clk, min_clk, SDHCI_GET_VERSION(host), |  | ||||||
| 			    host->quirks, host->host_caps)) { |  | ||||||
| 		printf("%s: Hardware doesn't specify base clock frequency\n", | 		printf("%s: Hardware doesn't specify base clock frequency\n", | ||||||
| 		       __func__); | 		       __func__); | ||||||
| 		return -EINVAL; | 		return -EINVAL; | ||||||
|  |  | ||||||
|  | @ -168,7 +168,7 @@ static int sh_mmcif_error_manage(struct sh_mmcif_host *host) | ||||||
| 	if (state2 & STS2_CRC_ERR) | 	if (state2 & STS2_CRC_ERR) | ||||||
| 		ret = -EILSEQ; | 		ret = -EILSEQ; | ||||||
| 	else if (state2 & STS2_TIMEOUT_ERR) | 	else if (state2 & STS2_TIMEOUT_ERR) | ||||||
| 		ret = TIMEOUT; | 		ret = -ETIMEDOUT; | ||||||
| 	else | 	else | ||||||
| 		ret = -EILSEQ; | 		ret = -EILSEQ; | ||||||
| 	return ret; | 	return ret; | ||||||
|  | @ -483,7 +483,7 @@ static int sh_mmcif_start_cmd(struct sh_mmcif_host *host, | ||||||
| 		case MMC_CMD_ALL_SEND_CID: | 		case MMC_CMD_ALL_SEND_CID: | ||||||
| 		case MMC_CMD_SELECT_CARD: | 		case MMC_CMD_SELECT_CARD: | ||||||
| 		case MMC_CMD_APP_CMD: | 		case MMC_CMD_APP_CMD: | ||||||
| 			ret = TIMEOUT; | 			ret = -ETIMEDOUT; | ||||||
| 			break; | 			break; | ||||||
| 		default: | 		default: | ||||||
| 			printf(DRIVER_NAME": Cmd(d'%d) err\n", cmd->cmdidx); | 			printf(DRIVER_NAME": Cmd(d'%d) err\n", cmd->cmdidx); | ||||||
|  | @ -520,14 +520,14 @@ static int sh_mmcif_request(struct mmc *mmc, struct mmc_cmd *cmd, | ||||||
| 
 | 
 | ||||||
| 	switch (cmd->cmdidx) { | 	switch (cmd->cmdidx) { | ||||||
| 	case MMC_CMD_APP_CMD: | 	case MMC_CMD_APP_CMD: | ||||||
| 		return TIMEOUT; | 		return -ETIMEDOUT; | ||||||
| 	case MMC_CMD_SEND_EXT_CSD: /* = SD_SEND_IF_COND (8) */ | 	case MMC_CMD_SEND_EXT_CSD: /* = SD_SEND_IF_COND (8) */ | ||||||
| 		if (data) | 		if (data) | ||||||
| 			/* ext_csd */ | 			/* ext_csd */ | ||||||
| 			break; | 			break; | ||||||
| 		else | 		else | ||||||
| 			/* send_if_cond cmd (not support) */ | 			/* send_if_cond cmd (not support) */ | ||||||
| 			return TIMEOUT; | 			return -ETIMEDOUT; | ||||||
| 	default: | 	default: | ||||||
| 		break; | 		break; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -232,7 +232,7 @@ static int sh_sdhi_error_manage(struct sh_sdhi_host *host) | ||||||
| 	e_state2 = sh_sdhi_readw(host, SDHI_ERR_STS2); | 	e_state2 = sh_sdhi_readw(host, SDHI_ERR_STS2); | ||||||
| 	if (e_state2 & ERR_STS2_SYS_ERROR) { | 	if (e_state2 & ERR_STS2_SYS_ERROR) { | ||||||
| 		if (e_state2 & ERR_STS2_RES_STOP_TIMEOUT) | 		if (e_state2 & ERR_STS2_RES_STOP_TIMEOUT) | ||||||
| 			ret = TIMEOUT; | 			ret = -ETIMEDOUT; | ||||||
| 		else | 		else | ||||||
| 			ret = -EILSEQ; | 			ret = -EILSEQ; | ||||||
| 		debug("%s: ERR_STS2 = %04x\n", | 		debug("%s: ERR_STS2 = %04x\n", | ||||||
|  | @ -246,7 +246,7 @@ static int sh_sdhi_error_manage(struct sh_sdhi_host *host) | ||||||
| 	if (e_state1 & ERR_STS1_CRC_ERROR || e_state1 & ERR_STS1_CMD_ERROR) | 	if (e_state1 & ERR_STS1_CRC_ERROR || e_state1 & ERR_STS1_CMD_ERROR) | ||||||
| 		ret = -EILSEQ; | 		ret = -EILSEQ; | ||||||
| 	else | 	else | ||||||
| 		ret = TIMEOUT; | 		ret = -ETIMEDOUT; | ||||||
| 
 | 
 | ||||||
| 	debug("%s: ERR_STS1 = %04x\n", | 	debug("%s: ERR_STS1 = %04x\n", | ||||||
| 	      DRIVER_NAME, sh_sdhi_readw(host, SDHI_ERR_STS1)); | 	      DRIVER_NAME, sh_sdhi_readw(host, SDHI_ERR_STS1)); | ||||||
|  | @ -566,7 +566,7 @@ static int sh_sdhi_start_cmd(struct sh_sdhi_host *host, | ||||||
| 		case MMC_CMD_SELECT_CARD: | 		case MMC_CMD_SELECT_CARD: | ||||||
| 		case SD_CMD_SEND_IF_COND: | 		case SD_CMD_SEND_IF_COND: | ||||||
| 		case MMC_CMD_APP_CMD: | 		case MMC_CMD_APP_CMD: | ||||||
| 			ret = TIMEOUT; | 			ret = -ETIMEDOUT; | ||||||
| 			break; | 			break; | ||||||
| 		default: | 		default: | ||||||
| 			debug(DRIVER_NAME": Cmd(d'%d) err\n", opc); | 			debug(DRIVER_NAME": Cmd(d'%d) err\n", opc); | ||||||
|  |  | ||||||
|  | @ -304,7 +304,7 @@ static int mmc_rint_wait(struct mmc *mmc, unsigned int timeout_msecs, | ||||||
| 		    (status & SUNXI_MMC_RINT_INTERRUPT_ERROR_BIT)) { | 		    (status & SUNXI_MMC_RINT_INTERRUPT_ERROR_BIT)) { | ||||||
| 			debug("%s timeout %x\n", what, | 			debug("%s timeout %x\n", what, | ||||||
| 			      status & SUNXI_MMC_RINT_INTERRUPT_ERROR_BIT); | 			      status & SUNXI_MMC_RINT_INTERRUPT_ERROR_BIT); | ||||||
| 			return TIMEOUT; | 			return -ETIMEDOUT; | ||||||
| 		} | 		} | ||||||
| 		udelay(1000); | 		udelay(1000); | ||||||
| 	} while (!(status & done_bit)); | 	} while (!(status & done_bit)); | ||||||
|  | @ -375,7 +375,7 @@ static int sunxi_mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, | ||||||
| 		if (ret) { | 		if (ret) { | ||||||
| 			error = readl(&mmchost->reg->rint) & \ | 			error = readl(&mmchost->reg->rint) & \ | ||||||
| 				SUNXI_MMC_RINT_INTERRUPT_ERROR_BIT; | 				SUNXI_MMC_RINT_INTERRUPT_ERROR_BIT; | ||||||
| 			error = TIMEOUT; | 			error = -ETIMEDOUT; | ||||||
| 			goto out; | 			goto out; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  | @ -402,7 +402,7 @@ static int sunxi_mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, | ||||||
| 			status = readl(&mmchost->reg->status); | 			status = readl(&mmchost->reg->status); | ||||||
| 			if (!timeout_msecs--) { | 			if (!timeout_msecs--) { | ||||||
| 				debug("busy timeout\n"); | 				debug("busy timeout\n"); | ||||||
| 				error = TIMEOUT; | 				error = -ETIMEDOUT; | ||||||
| 				goto out; | 				goto out; | ||||||
| 			} | 			} | ||||||
| 			udelay(1000); | 			udelay(1000); | ||||||
|  |  | ||||||
|  | @ -9,6 +9,7 @@ | ||||||
| 
 | 
 | ||||||
| #include <bouncebuf.h> | #include <bouncebuf.h> | ||||||
| #include <common.h> | #include <common.h> | ||||||
|  | #include <errno.h> | ||||||
| #include <asm/gpio.h> | #include <asm/gpio.h> | ||||||
| #include <asm/io.h> | #include <asm/io.h> | ||||||
| #ifndef CONFIG_TEGRA186 | #ifndef CONFIG_TEGRA186 | ||||||
|  | @ -216,14 +217,14 @@ static int mmc_send_cmd_bounced(struct mmc *mmc, struct mmc_cmd *cmd, | ||||||
| 	if (i == retry) { | 	if (i == retry) { | ||||||
| 		printf("%s: waiting for status update\n", __func__); | 		printf("%s: waiting for status update\n", __func__); | ||||||
| 		writel(mask, &host->reg->norintsts); | 		writel(mask, &host->reg->norintsts); | ||||||
| 		return TIMEOUT; | 		return -ETIMEDOUT; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if (mask & TEGRA_MMC_NORINTSTS_CMD_TIMEOUT) { | 	if (mask & TEGRA_MMC_NORINTSTS_CMD_TIMEOUT) { | ||||||
| 		/* Timeout Error */ | 		/* Timeout Error */ | ||||||
| 		debug("timeout: %08x cmd %d\n", mask, cmd->cmdidx); | 		debug("timeout: %08x cmd %d\n", mask, cmd->cmdidx); | ||||||
| 		writel(mask, &host->reg->norintsts); | 		writel(mask, &host->reg->norintsts); | ||||||
| 		return TIMEOUT; | 		return -ETIMEDOUT; | ||||||
| 	} else if (mask & TEGRA_MMC_NORINTSTS_ERR_INTERRUPT) { | 	} else if (mask & TEGRA_MMC_NORINTSTS_ERR_INTERRUPT) { | ||||||
| 		/* Error Interrupt */ | 		/* Error Interrupt */ | ||||||
| 		debug("error: %08x cmd %d\n", mask, cmd->cmdidx); | 		debug("error: %08x cmd %d\n", mask, cmd->cmdidx); | ||||||
|  | @ -257,7 +258,7 @@ static int mmc_send_cmd_bounced(struct mmc *mmc, struct mmc_cmd *cmd, | ||||||
| 			if (i == retry) { | 			if (i == retry) { | ||||||
| 				printf("%s: card is still busy\n", __func__); | 				printf("%s: card is still busy\n", __func__); | ||||||
| 				writel(mask, &host->reg->norintsts); | 				writel(mask, &host->reg->norintsts); | ||||||
| 				return TIMEOUT; | 				return -ETIMEDOUT; | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
| 			cmd->response[0] = readl(&host->reg->rspreg0); | 			cmd->response[0] = readl(&host->reg->rspreg0); | ||||||
|  |  | ||||||
|  | @ -162,7 +162,7 @@ static int uniphier_sd_check_error(struct uniphier_sd_priv *priv) | ||||||
| 		 * display error log since this might be a part of sequence to | 		 * display error log since this might be a part of sequence to | ||||||
| 		 * distinguish between SD and MMC. | 		 * distinguish between SD and MMC. | ||||||
| 		 */ | 		 */ | ||||||
| 		return TIMEOUT; | 		return -ETIMEDOUT; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if (info2 & UNIPHIER_SD_INFO2_ERR_TO) { | 	if (info2 & UNIPHIER_SD_INFO2_ERR_TO) { | ||||||
|  |  | ||||||
|  | @ -40,10 +40,8 @@ static int arasan_sdhci_probe(struct udevice *dev) | ||||||
| 	host->version = sdhci_readw(host, SDHCI_HOST_VERSION); | 	host->version = sdhci_readw(host, SDHCI_HOST_VERSION); | ||||||
| 
 | 
 | ||||||
| 	caps = sdhci_readl(host, SDHCI_CAPABILITIES); | 	caps = sdhci_readl(host, SDHCI_CAPABILITIES); | ||||||
| 	ret = sdhci_setup_cfg(&plat->cfg, dev->name, host->bus_width, | 	ret = sdhci_setup_cfg(&plat->cfg, host, CONFIG_ZYNQ_SDHCI_MAX_FREQ, | ||||||
| 			      caps, CONFIG_ZYNQ_SDHCI_MAX_FREQ, | 			      CONFIG_ZYNQ_SDHCI_MIN_FREQ); | ||||||
| 			      CONFIG_ZYNQ_SDHCI_MIN_FREQ, host->version, |  | ||||||
| 			      host->quirks, 0); |  | ||||||
| 	host->mmc = &plat->mmc; | 	host->mmc = &plat->mmc; | ||||||
| 	if (ret) | 	if (ret) | ||||||
| 		return ret; | 		return ret; | ||||||
|  |  | ||||||
|  | @ -105,7 +105,7 @@ | ||||||
| 
 | 
 | ||||||
| /* Status Register */ | /* Status Register */ | ||||||
| #define DWMCI_BUSY		(1 << 9) | #define DWMCI_BUSY		(1 << 9) | ||||||
| #define DWMCI_FIFO_MASK		0x1ff | #define DWMCI_FIFO_MASK		0x1fff | ||||||
| #define DWMCI_FIFO_SHIFT	17 | #define DWMCI_FIFO_SHIFT	17 | ||||||
| 
 | 
 | ||||||
| /* FIFOTH Register */ | /* FIFOTH Register */ | ||||||
|  |  | ||||||
|  | @ -66,12 +66,6 @@ | ||||||
| #define MMC_DATA_READ		1 | #define MMC_DATA_READ		1 | ||||||
| #define MMC_DATA_WRITE		2 | #define MMC_DATA_WRITE		2 | ||||||
| 
 | 
 | ||||||
| #define NO_CARD_ERR		-16 /* No SD/MMC card inserted */ |  | ||||||
| #define UNUSABLE_ERR		-17 /* Unusable Card */ |  | ||||||
| #define COMM_ERR		-18 /* Communications Error */ |  | ||||||
| #define TIMEOUT			-19 |  | ||||||
| #define SWITCH_ERR		-20 /* Card reports failure to switch mode */ |  | ||||||
| 
 |  | ||||||
| #define MMC_CMD_GO_IDLE_STATE		0 | #define MMC_CMD_GO_IDLE_STATE		0 | ||||||
| #define MMC_CMD_SEND_OP_COND		1 | #define MMC_CMD_SEND_OP_COND		1 | ||||||
| #define MMC_CMD_ALL_SEND_CID		2 | #define MMC_CMD_ALL_SEND_CID		2 | ||||||
|  |  | ||||||
|  | @ -367,19 +367,12 @@ static inline u8 sdhci_readb(struct sdhci_host *host, int reg) | ||||||
|  * See msm_sdhci.c for an example. |  * See msm_sdhci.c for an example. | ||||||
|  * |  * | ||||||
|  * @cfg:	Configuration structure to fill in (generally &plat->mmc) |  * @cfg:	Configuration structure to fill in (generally &plat->mmc) | ||||||
|  * @name:	Device name (normally dev->name) |  * @host:	SDHCI host structure | ||||||
|  * @buswidth:	Bus width (in bits, such as 4 or 8) |  | ||||||
|  * @caps:	Host capabilities (MMC_MODE_...) |  | ||||||
|  * @max_clk:	Maximum supported clock speed in HZ (0 for default) |  * @max_clk:	Maximum supported clock speed in HZ (0 for default) | ||||||
|  * @min_clk:	Minimum supported clock speed in HZ (0 for default) |  * @min_clk:	Minimum supported clock speed in HZ (0 for default) | ||||||
|  * @version:	Host controller version (generally read from the |  | ||||||
|  *		SDHCI_HOST_VERSION register) |  | ||||||
|  * @quirks:	Quick flags (SDHCI_QUIRK_...) |  | ||||||
|  * @host_caps:	Additional host capabilities (0 if none) |  | ||||||
|  */ |  */ | ||||||
| int sdhci_setup_cfg(struct mmc_config *cfg, const char *name, int buswidth, | int sdhci_setup_cfg(struct mmc_config *cfg, struct sdhci_host *host, | ||||||
| 		    uint caps, u32 max_clk, u32 min_clk, uint version, | 		    u32 max_clk, u32 min_clk); | ||||||
| 		    uint quirks, uint host_caps); |  | ||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|  * sdhci_bind() - Set up a new MMC block device |  * sdhci_bind() - Set up a new MMC block device | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue