Commit 69983404 authored by Guennadi Liakhovetski's avatar Guennadi Liakhovetski Committed by Chris Ball

mmc: sh_mmcif: remove now superfluous sh_mmcif_host::data member

Signed-off-by: default avatarGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: default avatarChris Ball <cjb@laptop.org>
parent f985da17
...@@ -208,7 +208,6 @@ enum mmcif_wait_for { ...@@ -208,7 +208,6 @@ enum mmcif_wait_for {
struct sh_mmcif_host { struct sh_mmcif_host {
struct mmc_host *mmc; struct mmc_host *mmc;
struct mmc_data *data;
struct mmc_request *mrq; struct mmc_request *mrq;
struct platform_device *pd; struct platform_device *pd;
struct sh_dmae_slave dma_slave_tx; struct sh_dmae_slave dma_slave_tx;
...@@ -253,19 +252,21 @@ static inline void sh_mmcif_bitclr(struct sh_mmcif_host *host, ...@@ -253,19 +252,21 @@ static inline void sh_mmcif_bitclr(struct sh_mmcif_host *host,
static void mmcif_dma_complete(void *arg) static void mmcif_dma_complete(void *arg)
{ {
struct sh_mmcif_host *host = arg; struct sh_mmcif_host *host = arg;
struct mmc_data *data = host->mrq->data;
dev_dbg(&host->pd->dev, "Command completed\n"); dev_dbg(&host->pd->dev, "Command completed\n");
if (WARN(!host->data, "%s: NULL data in DMA completion!\n", if (WARN(!data, "%s: NULL data in DMA completion!\n",
dev_name(&host->pd->dev))) dev_name(&host->pd->dev)))
return; return;
if (host->data->flags & MMC_DATA_READ) if (data->flags & MMC_DATA_READ)
dma_unmap_sg(host->chan_rx->device->dev, dma_unmap_sg(host->chan_rx->device->dev,
host->data->sg, host->data->sg_len, data->sg, data->sg_len,
DMA_FROM_DEVICE); DMA_FROM_DEVICE);
else else
dma_unmap_sg(host->chan_tx->device->dev, dma_unmap_sg(host->chan_tx->device->dev,
host->data->sg, host->data->sg_len, data->sg, data->sg_len,
DMA_TO_DEVICE); DMA_TO_DEVICE);
complete(&host->dma_complete); complete(&host->dma_complete);
...@@ -273,13 +274,14 @@ static void mmcif_dma_complete(void *arg) ...@@ -273,13 +274,14 @@ static void mmcif_dma_complete(void *arg)
static void sh_mmcif_start_dma_rx(struct sh_mmcif_host *host) static void sh_mmcif_start_dma_rx(struct sh_mmcif_host *host)
{ {
struct scatterlist *sg = host->data->sg; struct mmc_data *data = host->mrq->data;
struct scatterlist *sg = data->sg;
struct dma_async_tx_descriptor *desc = NULL; struct dma_async_tx_descriptor *desc = NULL;
struct dma_chan *chan = host->chan_rx; struct dma_chan *chan = host->chan_rx;
dma_cookie_t cookie = -EINVAL; dma_cookie_t cookie = -EINVAL;
int ret; int ret;
ret = dma_map_sg(chan->device->dev, sg, host->data->sg_len, ret = dma_map_sg(chan->device->dev, sg, data->sg_len,
DMA_FROM_DEVICE); DMA_FROM_DEVICE);
if (ret > 0) { if (ret > 0) {
host->dma_active = true; host->dma_active = true;
...@@ -295,7 +297,7 @@ static void sh_mmcif_start_dma_rx(struct sh_mmcif_host *host) ...@@ -295,7 +297,7 @@ static void sh_mmcif_start_dma_rx(struct sh_mmcif_host *host)
dma_async_issue_pending(chan); dma_async_issue_pending(chan);
} }
dev_dbg(&host->pd->dev, "%s(): mapped %d -> %d, cookie %d\n", dev_dbg(&host->pd->dev, "%s(): mapped %d -> %d, cookie %d\n",
__func__, host->data->sg_len, ret, cookie); __func__, data->sg_len, ret, cookie);
if (!desc) { if (!desc) {
/* DMA failed, fall back to PIO */ /* DMA failed, fall back to PIO */
...@@ -316,18 +318,19 @@ static void sh_mmcif_start_dma_rx(struct sh_mmcif_host *host) ...@@ -316,18 +318,19 @@ static void sh_mmcif_start_dma_rx(struct sh_mmcif_host *host)
} }
dev_dbg(&host->pd->dev, "%s(): desc %p, cookie %d, sg[%d]\n", __func__, dev_dbg(&host->pd->dev, "%s(): desc %p, cookie %d, sg[%d]\n", __func__,
desc, cookie, host->data->sg_len); desc, cookie, data->sg_len);
} }
static void sh_mmcif_start_dma_tx(struct sh_mmcif_host *host) static void sh_mmcif_start_dma_tx(struct sh_mmcif_host *host)
{ {
struct scatterlist *sg = host->data->sg; struct mmc_data *data = host->mrq->data;
struct scatterlist *sg = data->sg;
struct dma_async_tx_descriptor *desc = NULL; struct dma_async_tx_descriptor *desc = NULL;
struct dma_chan *chan = host->chan_tx; struct dma_chan *chan = host->chan_tx;
dma_cookie_t cookie = -EINVAL; dma_cookie_t cookie = -EINVAL;
int ret; int ret;
ret = dma_map_sg(chan->device->dev, sg, host->data->sg_len, ret = dma_map_sg(chan->device->dev, sg, data->sg_len,
DMA_TO_DEVICE); DMA_TO_DEVICE);
if (ret > 0) { if (ret > 0) {
host->dma_active = true; host->dma_active = true;
...@@ -343,7 +346,7 @@ static void sh_mmcif_start_dma_tx(struct sh_mmcif_host *host) ...@@ -343,7 +346,7 @@ static void sh_mmcif_start_dma_tx(struct sh_mmcif_host *host)
dma_async_issue_pending(chan); dma_async_issue_pending(chan);
} }
dev_dbg(&host->pd->dev, "%s(): mapped %d -> %d, cookie %d\n", dev_dbg(&host->pd->dev, "%s(): mapped %d -> %d, cookie %d\n",
__func__, host->data->sg_len, ret, cookie); __func__, data->sg_len, ret, cookie);
if (!desc) { if (!desc) {
/* DMA failed, fall back to PIO */ /* DMA failed, fall back to PIO */
...@@ -711,8 +714,11 @@ static void sh_mmcif_get_cmd12response(struct sh_mmcif_host *host, ...@@ -711,8 +714,11 @@ static void sh_mmcif_get_cmd12response(struct sh_mmcif_host *host,
} }
static u32 sh_mmcif_set_cmd(struct sh_mmcif_host *host, static u32 sh_mmcif_set_cmd(struct sh_mmcif_host *host,
struct mmc_request *mrq, struct mmc_command *cmd, u32 opc) struct mmc_request *mrq)
{ {
struct mmc_data *data = mrq->data;
struct mmc_command *cmd = mrq->cmd;
u32 opc = cmd->opcode;
u32 tmp = 0; u32 tmp = 0;
/* Response Type check */ /* Response Type check */
...@@ -744,7 +750,7 @@ static u32 sh_mmcif_set_cmd(struct sh_mmcif_host *host, ...@@ -744,7 +750,7 @@ static u32 sh_mmcif_set_cmd(struct sh_mmcif_host *host,
break; break;
} }
/* WDAT / DATW */ /* WDAT / DATW */
if (host->data) { if (data) {
tmp |= CMD_SET_WDAT; tmp |= CMD_SET_WDAT;
switch (host->bus_width) { switch (host->bus_width) {
case MMC_BUS_WIDTH_1: case MMC_BUS_WIDTH_1:
...@@ -768,7 +774,7 @@ static u32 sh_mmcif_set_cmd(struct sh_mmcif_host *host, ...@@ -768,7 +774,7 @@ static u32 sh_mmcif_set_cmd(struct sh_mmcif_host *host,
if (opc == MMC_READ_MULTIPLE_BLOCK || opc == MMC_WRITE_MULTIPLE_BLOCK) { if (opc == MMC_READ_MULTIPLE_BLOCK || opc == MMC_WRITE_MULTIPLE_BLOCK) {
tmp |= CMD_SET_CMLTE | CMD_SET_CMD12EN; tmp |= CMD_SET_CMLTE | CMD_SET_CMD12EN;
sh_mmcif_bitset(host, MMCIF_CE_BLOCK_SET, sh_mmcif_bitset(host, MMCIF_CE_BLOCK_SET,
mrq->data->blocks << 16); data->blocks << 16);
} }
/* RIDXC[1:0] check bits */ /* RIDXC[1:0] check bits */
if (opc == MMC_SEND_OP_COND || opc == MMC_ALL_SEND_CID || if (opc == MMC_SEND_OP_COND || opc == MMC_ALL_SEND_CID ||
...@@ -782,7 +788,7 @@ static u32 sh_mmcif_set_cmd(struct sh_mmcif_host *host, ...@@ -782,7 +788,7 @@ static u32 sh_mmcif_set_cmd(struct sh_mmcif_host *host,
opc == MMC_SEND_CSD || opc == MMC_SEND_CID) opc == MMC_SEND_CSD || opc == MMC_SEND_CID)
tmp |= CMD_SET_CRC7C_INTERNAL; tmp |= CMD_SET_CRC7C_INTERNAL;
return opc = ((opc << 24) | tmp); return (opc << 24) | tmp;
} }
static int sh_mmcif_data_trans(struct sh_mmcif_host *host, static int sh_mmcif_data_trans(struct sh_mmcif_host *host,
...@@ -830,12 +836,12 @@ static void sh_mmcif_start_cmd(struct sh_mmcif_host *host, ...@@ -830,12 +836,12 @@ static void sh_mmcif_start_cmd(struct sh_mmcif_host *host,
break; break;
} }
if (host->data) { if (mrq->data) {
sh_mmcif_writel(host->addr, MMCIF_CE_BLOCK_SET, 0); sh_mmcif_writel(host->addr, MMCIF_CE_BLOCK_SET, 0);
sh_mmcif_writel(host->addr, MMCIF_CE_BLOCK_SET, sh_mmcif_writel(host->addr, MMCIF_CE_BLOCK_SET,
mrq->data->blksz); mrq->data->blksz);
} }
opc = sh_mmcif_set_cmd(host, mrq, cmd, opc); opc = sh_mmcif_set_cmd(host, mrq);
sh_mmcif_writel(host->addr, MMCIF_CE_INT, 0xD80430C0); sh_mmcif_writel(host->addr, MMCIF_CE_INT, 0xD80430C0);
sh_mmcif_writel(host->addr, MMCIF_CE_INT_MASK, mask); sh_mmcif_writel(host->addr, MMCIF_CE_INT_MASK, mask);
...@@ -851,15 +857,16 @@ static void sh_mmcif_start_cmd(struct sh_mmcif_host *host, ...@@ -851,15 +857,16 @@ static void sh_mmcif_start_cmd(struct sh_mmcif_host *host,
static void sh_mmcif_stop_cmd(struct sh_mmcif_host *host, static void sh_mmcif_stop_cmd(struct sh_mmcif_host *host,
struct mmc_request *mrq) struct mmc_request *mrq)
{ {
struct mmc_command *cmd = mrq->stop; switch (mrq->cmd->opcode) {
case MMC_READ_MULTIPLE_BLOCK:
if (mrq->cmd->opcode == MMC_READ_MULTIPLE_BLOCK)
sh_mmcif_bitset(host, MMCIF_CE_INT_MASK, MASK_MCMD12DRE); sh_mmcif_bitset(host, MMCIF_CE_INT_MASK, MASK_MCMD12DRE);
else if (mrq->cmd->opcode == MMC_WRITE_MULTIPLE_BLOCK) break;
case MMC_WRITE_MULTIPLE_BLOCK:
sh_mmcif_bitset(host, MMCIF_CE_INT_MASK, MASK_MCMD12RBE); sh_mmcif_bitset(host, MMCIF_CE_INT_MASK, MASK_MCMD12RBE);
else { break;
default:
dev_err(&host->pd->dev, "unsupported stop cmd\n"); dev_err(&host->pd->dev, "unsupported stop cmd\n");
cmd->error = sh_mmcif_error_manage(host); mrq->stop->error = sh_mmcif_error_manage(host);
return; return;
} }
...@@ -905,7 +912,6 @@ static void sh_mmcif_request(struct mmc_host *mmc, struct mmc_request *mrq) ...@@ -905,7 +912,6 @@ static void sh_mmcif_request(struct mmc_host *mmc, struct mmc_request *mrq)
} }
host->mrq = mrq; host->mrq = mrq;
host->data = mrq->data;
sh_mmcif_start_cmd(host, mrq); sh_mmcif_start_cmd(host, mrq);
} }
...@@ -985,6 +991,7 @@ static struct mmc_host_ops sh_mmcif_ops = { ...@@ -985,6 +991,7 @@ static struct mmc_host_ops sh_mmcif_ops = {
static bool sh_mmcif_end_cmd(struct sh_mmcif_host *host) static bool sh_mmcif_end_cmd(struct sh_mmcif_host *host)
{ {
struct mmc_command *cmd = host->mrq->cmd; struct mmc_command *cmd = host->mrq->cmd;
struct mmc_data *data = host->mrq->data;
long time; long time;
if (host->sd_error) { if (host->sd_error) {
...@@ -1010,10 +1017,10 @@ static bool sh_mmcif_end_cmd(struct sh_mmcif_host *host) ...@@ -1010,10 +1017,10 @@ static bool sh_mmcif_end_cmd(struct sh_mmcif_host *host)
sh_mmcif_get_response(host, cmd); sh_mmcif_get_response(host, cmd);
if (!host->data) if (!data)
return false; return false;
if (host->mrq->data->flags & MMC_DATA_READ) { if (data->flags & MMC_DATA_READ) {
if (host->chan_rx) if (host->chan_rx)
sh_mmcif_start_dma_rx(host); sh_mmcif_start_dma_rx(host);
} else { } else {
...@@ -1022,8 +1029,8 @@ static bool sh_mmcif_end_cmd(struct sh_mmcif_host *host) ...@@ -1022,8 +1029,8 @@ static bool sh_mmcif_end_cmd(struct sh_mmcif_host *host)
} }
if (!host->dma_active) { if (!host->dma_active) {
host->data->error = sh_mmcif_data_trans(host, host->mrq, cmd->opcode); data->error = sh_mmcif_data_trans(host, host->mrq, cmd->opcode);
if (!host->data->error) if (!data->error)
return true; return true;
return false; return false;
} }
...@@ -1035,22 +1042,22 @@ static bool sh_mmcif_end_cmd(struct sh_mmcif_host *host) ...@@ -1035,22 +1042,22 @@ static bool sh_mmcif_end_cmd(struct sh_mmcif_host *host)
dev_err(host->mmc->parent, dev_err(host->mmc->parent,
"Error IRQ while waiting for DMA completion!\n"); "Error IRQ while waiting for DMA completion!\n");
/* Woken up by an error IRQ: abort DMA */ /* Woken up by an error IRQ: abort DMA */
if (host->data->flags & MMC_DATA_READ) if (data->flags & MMC_DATA_READ)
dmaengine_terminate_all(host->chan_rx); dmaengine_terminate_all(host->chan_rx);
else else
dmaengine_terminate_all(host->chan_tx); dmaengine_terminate_all(host->chan_tx);
host->data->error = sh_mmcif_error_manage(host); data->error = sh_mmcif_error_manage(host);
} else if (!time) { } else if (!time) {
host->data->error = -ETIMEDOUT; data->error = -ETIMEDOUT;
} else if (time < 0) { } else if (time < 0) {
host->data->error = time; data->error = time;
} }
sh_mmcif_bitclr(host, MMCIF_CE_BUF_ACC, sh_mmcif_bitclr(host, MMCIF_CE_BUF_ACC,
BUF_ACC_DMAREN | BUF_ACC_DMAWEN); BUF_ACC_DMAREN | BUF_ACC_DMAWEN);
host->dma_active = false; host->dma_active = false;
if (host->data->error) if (data->error)
host->data->bytes_xfered = 0; data->bytes_xfered = 0;
return false; return false;
} }
...@@ -1059,6 +1066,7 @@ static irqreturn_t sh_mmcif_irqt(int irq, void *dev_id) ...@@ -1059,6 +1066,7 @@ static irqreturn_t sh_mmcif_irqt(int irq, void *dev_id)
{ {
struct sh_mmcif_host *host = dev_id; struct sh_mmcif_host *host = dev_id;
struct mmc_request *mrq = host->mrq; struct mmc_request *mrq = host->mrq;
struct mmc_data *data = mrq->data;
cancel_delayed_work_sync(&host->timeout_work); cancel_delayed_work_sync(&host->timeout_work);
...@@ -1106,20 +1114,18 @@ static irqreturn_t sh_mmcif_irqt(int irq, void *dev_id) ...@@ -1106,20 +1114,18 @@ static irqreturn_t sh_mmcif_irqt(int irq, void *dev_id)
case MMCIF_WAIT_FOR_READ_END: case MMCIF_WAIT_FOR_READ_END:
case MMCIF_WAIT_FOR_WRITE_END: case MMCIF_WAIT_FOR_WRITE_END:
if (host->sd_error) if (host->sd_error)
mrq->data->error = sh_mmcif_error_manage(host); data->error = sh_mmcif_error_manage(host);
break; break;
default: default:
BUG(); BUG();
} }
if (host->wait_for != MMCIF_WAIT_FOR_STOP) { if (host->wait_for != MMCIF_WAIT_FOR_STOP) {
host->data = NULL; if (!mrq->cmd->error && data && !data->error)
data->bytes_xfered =
data->blocks * data->blksz;
if (!mrq->cmd->error && mrq->data && !mrq->data->error) if (mrq->stop && !mrq->cmd->error && (!data || !data->error)) {
mrq->data->bytes_xfered =
mrq->data->blocks * mrq->data->blksz;
if (mrq->stop && !mrq->cmd->error && (!mrq->data || !mrq->data->error)) {
sh_mmcif_stop_cmd(host, mrq); sh_mmcif_stop_cmd(host, mrq);
if (!mrq->stop->error) if (!mrq->stop->error)
return IRQ_HANDLED; return IRQ_HANDLED;
...@@ -1128,6 +1134,7 @@ static irqreturn_t sh_mmcif_irqt(int irq, void *dev_id) ...@@ -1128,6 +1134,7 @@ static irqreturn_t sh_mmcif_irqt(int irq, void *dev_id)
host->wait_for = MMCIF_WAIT_FOR_REQUEST; host->wait_for = MMCIF_WAIT_FOR_REQUEST;
host->state = STATE_IDLE; host->state = STATE_IDLE;
host->mrq = NULL;
mmc_request_done(host->mmc, mrq); mmc_request_done(host->mmc, mrq);
return IRQ_HANDLED; return IRQ_HANDLED;
...@@ -1223,7 +1230,7 @@ static void mmcif_timeout_work(struct work_struct *work) ...@@ -1223,7 +1230,7 @@ static void mmcif_timeout_work(struct work_struct *work)
case MMCIF_WAIT_FOR_WRITE: case MMCIF_WAIT_FOR_WRITE:
case MMCIF_WAIT_FOR_READ_END: case MMCIF_WAIT_FOR_READ_END:
case MMCIF_WAIT_FOR_WRITE_END: case MMCIF_WAIT_FOR_WRITE_END:
host->data->error = sh_mmcif_error_manage(host); mrq->data->error = sh_mmcif_error_manage(host);
break; break;
default: default:
BUG(); BUG();
...@@ -1231,7 +1238,6 @@ static void mmcif_timeout_work(struct work_struct *work) ...@@ -1231,7 +1238,6 @@ static void mmcif_timeout_work(struct work_struct *work)
host->state = STATE_IDLE; host->state = STATE_IDLE;
host->wait_for = MMCIF_WAIT_FOR_REQUEST; host->wait_for = MMCIF_WAIT_FOR_REQUEST;
host->data = NULL;
host->mrq = NULL; host->mrq = NULL;
mmc_request_done(host->mmc, mrq); mmc_request_done(host->mmc, mrq);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment