X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=drivers%2Fmmc%2Fmmc_spi.c;h=a9d95fbd7470fa8bbca2e87d511486c255311c65;hb=3fd0a9ba8cee385e9a1f07419269a613c3af4500;hp=5b5b33a4b23d293a0afcf79345e98102fc8d1e7b;hpb=0f507779ca00d90cdd4bcc8252630370339b7ea6;p=u-boot diff --git a/drivers/mmc/mmc_spi.c b/drivers/mmc/mmc_spi.c index 5b5b33a4b2..a9d95fbd74 100644 --- a/drivers/mmc/mmc_spi.c +++ b/drivers/mmc/mmc_spi.c @@ -5,13 +5,14 @@ * Licensed under the GPL-2 or later. */ #include +#include #include #include #include #include #include #include -#include +#include /* MMC/SD in SPI mode reports R1 status always */ #define R1_SPI_IDLE (1 << 0) @@ -91,7 +92,7 @@ static uint mmc_spi_readdata(struct mmc *mmc, void *xbuf, spi_xfer(spi, bsize * 8, NULL, buf, 0); spi_xfer(spi, 2 * 8, NULL, &crc, 0); #ifdef CONFIG_MMC_SPI_CRC_ON - if (swab16(cyg_crc16(buf, bsize)) != crc) { + if (be_to_cpu16(crc16_ccitt(0, buf, bsize)) != crc) { debug("%s: CRC error\n", mmc->cfg->name); r1 = R1_SPI_COM_CRC; break; @@ -120,7 +121,7 @@ static uint mmc_spi_writedata(struct mmc *mmc, const void *xbuf, tok[1] = multi ? SPI_TOKEN_MULTI_WRITE : SPI_TOKEN_SINGLE; while (bcnt--) { #ifdef CONFIG_MMC_SPI_CRC_ON - crc = swab16(cyg_crc16((u8 *)buf, bsize)); + crc = cpu_to_be16(crc16_ccitt(0, (u8 *)buf, bsize)); #endif spi_xfer(spi, 2 * 8, tok, NULL, 0); spi_xfer(spi, bsize * 8, buf, NULL, 0); @@ -182,18 +183,18 @@ static int mmc_spi_request(struct mmc *mmc, struct mmc_cmd *cmd, spi_cs_activate(spi); r1 = mmc_spi_sendcmd(mmc, cmd->cmdidx, cmd->cmdarg); if (r1 == 0xff) { /* no response */ - ret = NO_CARD_ERR; + ret = -ENOMEDIUM; goto done; } else if (r1 & R1_SPI_COM_CRC) { - ret = COMM_ERR; + ret = -ECOMM; goto done; } else if (r1 & ~R1_SPI_IDLE) { /* other errors */ - ret = TIMEOUT; + ret = -ETIMEDOUT; goto done; } else if (cmd->resp_type == MMC_RSP_R2) { r1 = mmc_spi_readdata(mmc, cmd->response, 1, 16); for (i = 0; i < 4; i++) - cmd->response[i] = swab32(cmd->response[i]); + cmd->response[i] = be32_to_cpu(cmd->response[i]); debug("r128 %x %x %x %x\n", cmd->response[0], cmd->response[1], cmd->response[2], cmd->response[3]); } else if (!data) { @@ -205,7 +206,7 @@ static int mmc_spi_request(struct mmc *mmc, struct mmc_cmd *cmd, case SD_CMD_SEND_IF_COND: case MMC_CMD_SPI_READ_OCR: spi_xfer(spi, 4 * 8, NULL, cmd->response, 0); - cmd->response[0] = swab32(cmd->response[0]); + cmd->response[0] = be32_to_cpu(cmd->response[0]); debug("r32 %x\n", cmd->response[0]); break; case MMC_CMD_SEND_STATUS: @@ -225,9 +226,9 @@ static int mmc_spi_request(struct mmc *mmc, struct mmc_cmd *cmd, data->blocks, data->blocksize, (cmd->cmdidx == MMC_CMD_WRITE_MULTIPLE_BLOCK)); if (r1 & R1_SPI_COM_CRC) - ret = COMM_ERR; + ret = -ECOMM; else if (r1) /* other errors */ - ret = TIMEOUT; + ret = -ETIMEDOUT; } done: spi_cs_deactivate(spi); @@ -235,13 +236,14 @@ done: return ret; } -static void mmc_spi_set_ios(struct mmc *mmc) +static int mmc_spi_set_ios(struct mmc *mmc) { struct spi_slave *spi = mmc->priv; debug("%s: clock %u\n", __func__, mmc->clock); if (mmc->clock) spi_set_speed(spi, mmc->clock); + return 0; } static int mmc_spi_init_p(struct mmc *mmc)