コード例 #1
0
static void goldfish_mmc_request(struct mmc_host *mmc, struct mmc_request *req)
{
	struct goldfish_mmc_host *host = mmc_priv(mmc);

	WARN_ON(host->mrq != NULL);

	host->mrq = req;
	goldfish_mmc_prepare_data(host, req);
	goldfish_mmc_start_command(host, req->cmd);

	/* this is to avoid accidentally being detected as an SDIO card in mmc_attach_sdio() */
	if (req->cmd->opcode == SD_IO_SEND_OP_COND &&
		req->cmd->flags == (MMC_RSP_SPI_R4 | MMC_RSP_R4 | MMC_CMD_BCR)) {
		req->cmd->error = -EINVAL;
	}
}
コード例 #2
0
ファイル: goldfishmmc.c プロジェクト: Aresthu/ucore_plus
static void
goldfish_mmc_xfer_done(struct goldfish_mmc_host *host, struct mmc_data *data)
{
	if (host->dma_in_use) {
		enum dma_data_direction dma_data_dir;

		if (data->flags & MMC_DATA_WRITE)
			dma_data_dir = DMA_TO_DEVICE;
		else
			dma_data_dir = DMA_FROM_DEVICE;

		if (dma_data_dir == DMA_FROM_DEVICE) {
			// we don't really have DMA, so we need to copy from our platform driver buffer
			uint8_t *dest = (uint8_t *) sg_virt(data->sg);
			memcpy(dest, host->virt_base, data->sg->length);
		}

		host->data->bytes_xfered += data->sg->length;

		dma_unmap_sg(mmc_dev(host->mmc), data->sg, host->sg_len,
			     dma_data_dir);
	}

	host->data = NULL;
	host->sg_len = 0;

	/* NOTE:  MMC layer will sometimes poll-wait CMD13 next, issuing
	 * dozens of requests until the card finishes writing data.
	 * It'd be cheaper to just wait till an EOFB interrupt arrives...
	 */

	if (!data->stop) {
		host->mrq = NULL;
		mmc_request_done(host->mmc, data->mrq);
		return;
	}

	goldfish_mmc_start_command(host, data->stop);
}