mirror of
https://github.com/torvalds/linux.git
synced 2024-11-16 00:52:01 +00:00
tifm_sd: prettify
This patch introduces no semantic changes - it is here for estetic purposes. Signed-off-by: Alex Dubov <oakad@yahoo.com> Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
This commit is contained in:
parent
8e02f8581c
commit
2e8ce5e741
@ -118,7 +118,7 @@ static void tifm_sd_kunmap_atomic(char *buffer, struct mmc_data *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int tifm_sd_transfer_data(struct tifm_dev *sock, struct tifm_sd *host,
|
static int tifm_sd_transfer_data(struct tifm_dev *sock, struct tifm_sd *host,
|
||||||
unsigned int host_status)
|
unsigned int host_status)
|
||||||
{
|
{
|
||||||
struct mmc_command *cmd = host->req->cmd;
|
struct mmc_command *cmd = host->req->cmd;
|
||||||
unsigned int t_val = 0, cnt = 0;
|
unsigned int t_val = 0, cnt = 0;
|
||||||
@ -159,7 +159,7 @@ static int tifm_sd_transfer_data(struct tifm_dev *sock, struct tifm_sd *host,
|
|||||||
t_val |= ((buffer[host->buffer_pos++])
|
t_val |= ((buffer[host->buffer_pos++])
|
||||||
<< 8) & 0xff00;
|
<< 8) & 0xff00;
|
||||||
writel(t_val,
|
writel(t_val,
|
||||||
sock->addr + SOCK_MMCSD_DATA);
|
sock->addr + SOCK_MMCSD_DATA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -220,7 +220,7 @@ static void tifm_sd_exec(struct tifm_sd *host, struct mmc_command *cmd)
|
|||||||
cmd_mask |= TIFM_MMCSD_READ;
|
cmd_mask |= TIFM_MMCSD_READ;
|
||||||
|
|
||||||
dev_dbg(&sock->dev, "executing opcode 0x%x, arg: 0x%x, mask: 0x%x\n",
|
dev_dbg(&sock->dev, "executing opcode 0x%x, arg: 0x%x, mask: 0x%x\n",
|
||||||
cmd->opcode, cmd->arg, cmd_mask);
|
cmd->opcode, cmd->arg, cmd_mask);
|
||||||
|
|
||||||
writel((cmd->arg >> 16) & 0xffff, sock->addr + SOCK_MMCSD_ARG_HIGH);
|
writel((cmd->arg >> 16) & 0xffff, sock->addr + SOCK_MMCSD_ARG_HIGH);
|
||||||
writel(cmd->arg & 0xffff, sock->addr + SOCK_MMCSD_ARG_LOW);
|
writel(cmd->arg & 0xffff, sock->addr + SOCK_MMCSD_ARG_LOW);
|
||||||
@ -324,7 +324,7 @@ change_state:
|
|||||||
|
|
||||||
/* Called from interrupt handler */
|
/* Called from interrupt handler */
|
||||||
static unsigned int tifm_sd_signal_irq(struct tifm_dev *sock,
|
static unsigned int tifm_sd_signal_irq(struct tifm_dev *sock,
|
||||||
unsigned int sock_irq_status)
|
unsigned int sock_irq_status)
|
||||||
{
|
{
|
||||||
struct tifm_sd *host;
|
struct tifm_sd *host;
|
||||||
unsigned int host_status = 0, fifo_status = 0;
|
unsigned int host_status = 0, fifo_status = 0;
|
||||||
@ -350,11 +350,11 @@ static unsigned int tifm_sd_signal_irq(struct tifm_dev *sock,
|
|||||||
if (host_status & TIFM_MMCSD_ERRMASK) {
|
if (host_status & TIFM_MMCSD_ERRMASK) {
|
||||||
if (host_status & TIFM_MMCSD_CERR)
|
if (host_status & TIFM_MMCSD_CERR)
|
||||||
error_code = MMC_ERR_FAILED;
|
error_code = MMC_ERR_FAILED;
|
||||||
else if (host_status &
|
else if (host_status
|
||||||
(TIFM_MMCSD_CTO | TIFM_MMCSD_DTO))
|
& (TIFM_MMCSD_CTO | TIFM_MMCSD_DTO))
|
||||||
error_code = MMC_ERR_TIMEOUT;
|
error_code = MMC_ERR_TIMEOUT;
|
||||||
else if (host_status &
|
else if (host_status
|
||||||
(TIFM_MMCSD_CCRC | TIFM_MMCSD_DCRC))
|
& (TIFM_MMCSD_CCRC | TIFM_MMCSD_DCRC))
|
||||||
error_code = MMC_ERR_BADCRC;
|
error_code = MMC_ERR_BADCRC;
|
||||||
|
|
||||||
writel(TIFM_FIFO_INT_SETALL,
|
writel(TIFM_FIFO_INT_SETALL,
|
||||||
@ -382,8 +382,8 @@ static unsigned int tifm_sd_signal_irq(struct tifm_dev *sock,
|
|||||||
|
|
||||||
if (host_status & TIFM_MMCSD_CB)
|
if (host_status & TIFM_MMCSD_CB)
|
||||||
host->flags |= CARD_BUSY;
|
host->flags |= CARD_BUSY;
|
||||||
if ((host_status & TIFM_MMCSD_EOFB) &&
|
if ((host_status & TIFM_MMCSD_EOFB)
|
||||||
(host->flags & CARD_BUSY)) {
|
&& (host->flags & CARD_BUSY)) {
|
||||||
host->written_blocks++;
|
host->written_blocks++;
|
||||||
host->flags &= ~CARD_BUSY;
|
host->flags &= ~CARD_BUSY;
|
||||||
}
|
}
|
||||||
@ -393,22 +393,23 @@ static unsigned int tifm_sd_signal_irq(struct tifm_dev *sock,
|
|||||||
tifm_sd_process_cmd(sock, host, host_status);
|
tifm_sd_process_cmd(sock, host, host_status);
|
||||||
done:
|
done:
|
||||||
dev_dbg(&sock->dev, "host_status %x, fifo_status %x\n",
|
dev_dbg(&sock->dev, "host_status %x, fifo_status %x\n",
|
||||||
host_status, fifo_status);
|
host_status, fifo_status);
|
||||||
spin_unlock(&sock->lock);
|
spin_unlock(&sock->lock);
|
||||||
return sock_irq_status;
|
return sock_irq_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tifm_sd_prepare_data(struct tifm_sd *card, struct mmc_command *cmd)
|
static void tifm_sd_prepare_data(struct tifm_sd *host, struct mmc_command *cmd)
|
||||||
{
|
{
|
||||||
struct tifm_dev *sock = card->dev;
|
struct tifm_dev *sock = host->dev;
|
||||||
unsigned int dest_cnt;
|
unsigned int dest_cnt;
|
||||||
|
|
||||||
/* DMA style IO */
|
/* DMA style IO */
|
||||||
|
dev_dbg(&sock->dev, "setting dma for %d blocks\n",
|
||||||
|
cmd->data->blocks);
|
||||||
writel(TIFM_FIFO_INT_SETALL,
|
writel(TIFM_FIFO_INT_SETALL,
|
||||||
sock->addr + SOCK_DMA_FIFO_INT_ENABLE_CLEAR);
|
sock->addr + SOCK_DMA_FIFO_INT_ENABLE_CLEAR);
|
||||||
writel(ilog2(cmd->data->blksz) - 2,
|
writel(ilog2(cmd->data->blksz) - 2,
|
||||||
sock->addr + SOCK_FIFO_PAGE_SIZE);
|
sock->addr + SOCK_FIFO_PAGE_SIZE);
|
||||||
writel(TIFM_FIFO_ENABLE, sock->addr + SOCK_FIFO_CONTROL);
|
writel(TIFM_FIFO_ENABLE, sock->addr + SOCK_FIFO_CONTROL);
|
||||||
writel(TIFM_FIFO_INTMASK, sock->addr + SOCK_DMA_FIFO_INT_ENABLE_SET);
|
writel(TIFM_FIFO_INTMASK, sock->addr + SOCK_DMA_FIFO_INT_ENABLE_SET);
|
||||||
|
|
||||||
@ -422,7 +423,7 @@ static void tifm_sd_prepare_data(struct tifm_sd *card, struct mmc_command *cmd)
|
|||||||
if (cmd->data->flags & MMC_DATA_WRITE) {
|
if (cmd->data->flags & MMC_DATA_WRITE) {
|
||||||
writel(TIFM_MMCSD_TXDE, sock->addr + SOCK_MMCSD_BUFFER_CONFIG);
|
writel(TIFM_MMCSD_TXDE, sock->addr + SOCK_MMCSD_BUFFER_CONFIG);
|
||||||
writel(dest_cnt | TIFM_DMA_TX | TIFM_DMA_EN,
|
writel(dest_cnt | TIFM_DMA_TX | TIFM_DMA_EN,
|
||||||
sock->addr + SOCK_DMA_CONTROL);
|
sock->addr + SOCK_DMA_CONTROL);
|
||||||
} else {
|
} else {
|
||||||
writel(TIFM_MMCSD_RXDE, sock->addr + SOCK_MMCSD_BUFFER_CONFIG);
|
writel(TIFM_MMCSD_RXDE, sock->addr + SOCK_MMCSD_BUFFER_CONFIG);
|
||||||
writel(dest_cnt | TIFM_DMA_EN, sock->addr + SOCK_DMA_CONTROL);
|
writel(dest_cnt | TIFM_DMA_EN, sock->addr + SOCK_DMA_CONTROL);
|
||||||
@ -430,7 +431,7 @@ static void tifm_sd_prepare_data(struct tifm_sd *card, struct mmc_command *cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void tifm_sd_set_data_timeout(struct tifm_sd *host,
|
static void tifm_sd_set_data_timeout(struct tifm_sd *host,
|
||||||
struct mmc_data *data)
|
struct mmc_data *data)
|
||||||
{
|
{
|
||||||
struct tifm_dev *sock = host->dev;
|
struct tifm_dev *sock = host->dev;
|
||||||
unsigned int data_timeout = data->timeout_clks;
|
unsigned int data_timeout = data->timeout_clks;
|
||||||
@ -448,7 +449,7 @@ static void tifm_sd_set_data_timeout(struct tifm_sd *host,
|
|||||||
sock->addr + SOCK_MMCSD_SDIO_MODE_CONFIG);
|
sock->addr + SOCK_MMCSD_SDIO_MODE_CONFIG);
|
||||||
} else {
|
} else {
|
||||||
data_timeout = (data_timeout >> 10) + 1;
|
data_timeout = (data_timeout >> 10) + 1;
|
||||||
if(data_timeout > 0xffff)
|
if (data_timeout > 0xffff)
|
||||||
data_timeout = 0; /* set to unlimited */
|
data_timeout = 0; /* set to unlimited */
|
||||||
writel(data_timeout, sock->addr + SOCK_MMCSD_DATA_TO);
|
writel(data_timeout, sock->addr + SOCK_MMCSD_DATA_TO);
|
||||||
writel(TIFM_MMCSD_DPE
|
writel(TIFM_MMCSD_DPE
|
||||||
@ -499,7 +500,7 @@ static void tifm_sd_request(struct mmc_host *mmc, struct mmc_request *mrq)
|
|||||||
mod_timer(&host->timer, jiffies + host->timeout_jiffies);
|
mod_timer(&host->timer, jiffies + host->timeout_jiffies);
|
||||||
host->state = CMD;
|
host->state = CMD;
|
||||||
writel(TIFM_CTRL_LED | readl(sock->addr + SOCK_CONTROL),
|
writel(TIFM_CTRL_LED | readl(sock->addr + SOCK_CONTROL),
|
||||||
sock->addr + SOCK_CONTROL);
|
sock->addr + SOCK_CONTROL);
|
||||||
tifm_sd_exec(host, mrq->cmd);
|
tifm_sd_exec(host, mrq->cmd);
|
||||||
spin_unlock_irqrestore(&sock->lock, flags);
|
spin_unlock_irqrestore(&sock->lock, flags);
|
||||||
return;
|
return;
|
||||||
@ -539,8 +540,8 @@ static void tifm_sd_end_cmd(unsigned long data)
|
|||||||
r_data = mrq->cmd->data;
|
r_data = mrq->cmd->data;
|
||||||
if (r_data) {
|
if (r_data) {
|
||||||
if (r_data->flags & MMC_DATA_WRITE) {
|
if (r_data->flags & MMC_DATA_WRITE) {
|
||||||
r_data->bytes_xfered = host->written_blocks *
|
r_data->bytes_xfered = host->written_blocks
|
||||||
r_data->blksz;
|
* r_data->blksz;
|
||||||
} else {
|
} else {
|
||||||
r_data->bytes_xfered = r_data->blocks -
|
r_data->bytes_xfered = r_data->blocks -
|
||||||
readl(sock->addr + SOCK_MMCSD_NUM_BLOCKS) - 1;
|
readl(sock->addr + SOCK_MMCSD_NUM_BLOCKS) - 1;
|
||||||
@ -554,7 +555,7 @@ static void tifm_sd_end_cmd(unsigned long data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
writel((~TIFM_CTRL_LED) & readl(sock->addr + SOCK_CONTROL),
|
writel((~TIFM_CTRL_LED) & readl(sock->addr + SOCK_CONTROL),
|
||||||
sock->addr + SOCK_CONTROL);
|
sock->addr + SOCK_CONTROL);
|
||||||
|
|
||||||
spin_unlock_irqrestore(&sock->lock, flags);
|
spin_unlock_irqrestore(&sock->lock, flags);
|
||||||
mmc_request_done(mmc, mrq);
|
mmc_request_done(mmc, mrq);
|
||||||
@ -582,14 +583,14 @@ static void tifm_sd_request_nodma(struct mmc_host *mmc, struct mmc_request *mrq)
|
|||||||
if (r_data) {
|
if (r_data) {
|
||||||
tifm_sd_set_data_timeout(host, r_data);
|
tifm_sd_set_data_timeout(host, r_data);
|
||||||
|
|
||||||
host->buffer_size = mrq->cmd->data->blocks *
|
host->buffer_size = mrq->cmd->data->blocks
|
||||||
mrq->cmd->data->blksz;
|
* mrq->cmd->data->blksz;
|
||||||
|
|
||||||
writel(TIFM_MMCSD_BUFINT |
|
writel(TIFM_MMCSD_BUFINT
|
||||||
readl(sock->addr + SOCK_MMCSD_INT_ENABLE),
|
| readl(sock->addr + SOCK_MMCSD_INT_ENABLE),
|
||||||
sock->addr + SOCK_MMCSD_INT_ENABLE);
|
sock->addr + SOCK_MMCSD_INT_ENABLE);
|
||||||
writel(((TIFM_MMCSD_FIFO_SIZE - 1) << 8) |
|
writel(((TIFM_MMCSD_FIFO_SIZE - 1) << 8)
|
||||||
(TIFM_MMCSD_FIFO_SIZE - 1),
|
| (TIFM_MMCSD_FIFO_SIZE - 1),
|
||||||
sock->addr + SOCK_MMCSD_BUFFER_CONFIG);
|
sock->addr + SOCK_MMCSD_BUFFER_CONFIG);
|
||||||
|
|
||||||
host->written_blocks = 0;
|
host->written_blocks = 0;
|
||||||
@ -603,7 +604,7 @@ static void tifm_sd_request_nodma(struct mmc_host *mmc, struct mmc_request *mrq)
|
|||||||
mod_timer(&host->timer, jiffies + host->timeout_jiffies);
|
mod_timer(&host->timer, jiffies + host->timeout_jiffies);
|
||||||
host->state = CMD;
|
host->state = CMD;
|
||||||
writel(TIFM_CTRL_LED | readl(sock->addr + SOCK_CONTROL),
|
writel(TIFM_CTRL_LED | readl(sock->addr + SOCK_CONTROL),
|
||||||
sock->addr + SOCK_CONTROL);
|
sock->addr + SOCK_CONTROL);
|
||||||
tifm_sd_exec(host, mrq->cmd);
|
tifm_sd_exec(host, mrq->cmd);
|
||||||
spin_unlock_irqrestore(&sock->lock, flags);
|
spin_unlock_irqrestore(&sock->lock, flags);
|
||||||
return;
|
return;
|
||||||
@ -642,8 +643,8 @@ static void tifm_sd_end_cmd_nodma(unsigned long data)
|
|||||||
sock->addr + SOCK_MMCSD_INT_ENABLE);
|
sock->addr + SOCK_MMCSD_INT_ENABLE);
|
||||||
|
|
||||||
if (r_data->flags & MMC_DATA_WRITE) {
|
if (r_data->flags & MMC_DATA_WRITE) {
|
||||||
r_data->bytes_xfered = host->written_blocks *
|
r_data->bytes_xfered = host->written_blocks
|
||||||
r_data->blksz;
|
* r_data->blksz;
|
||||||
} else {
|
} else {
|
||||||
r_data->bytes_xfered = r_data->blocks -
|
r_data->bytes_xfered = r_data->blocks -
|
||||||
readl(sock->addr + SOCK_MMCSD_NUM_BLOCKS) - 1;
|
readl(sock->addr + SOCK_MMCSD_NUM_BLOCKS) - 1;
|
||||||
@ -656,7 +657,7 @@ static void tifm_sd_end_cmd_nodma(unsigned long data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
writel((~TIFM_CTRL_LED) & readl(sock->addr + SOCK_CONTROL),
|
writel((~TIFM_CTRL_LED) & readl(sock->addr + SOCK_CONTROL),
|
||||||
sock->addr + SOCK_CONTROL);
|
sock->addr + SOCK_CONTROL);
|
||||||
|
|
||||||
spin_unlock_irqrestore(&sock->lock, flags);
|
spin_unlock_irqrestore(&sock->lock, flags);
|
||||||
|
|
||||||
@ -707,9 +708,9 @@ static void tifm_sd_ios(struct mmc_host *mmc, struct mmc_ios *ios)
|
|||||||
writel(TIFM_MMCSD_4BBUS | readl(sock->addr + SOCK_MMCSD_CONFIG),
|
writel(TIFM_MMCSD_4BBUS | readl(sock->addr + SOCK_MMCSD_CONFIG),
|
||||||
sock->addr + SOCK_MMCSD_CONFIG);
|
sock->addr + SOCK_MMCSD_CONFIG);
|
||||||
} else {
|
} else {
|
||||||
writel((~TIFM_MMCSD_4BBUS) &
|
writel((~TIFM_MMCSD_4BBUS)
|
||||||
readl(sock->addr + SOCK_MMCSD_CONFIG),
|
& readl(sock->addr + SOCK_MMCSD_CONFIG),
|
||||||
sock->addr + SOCK_MMCSD_CONFIG);
|
sock->addr + SOCK_MMCSD_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ios->clock) {
|
if (ios->clock) {
|
||||||
@ -728,23 +729,24 @@ static void tifm_sd_ios(struct mmc_host *mmc, struct mmc_ios *ios)
|
|||||||
if ((20000000 / clk_div1) > (24000000 / clk_div2)) {
|
if ((20000000 / clk_div1) > (24000000 / clk_div2)) {
|
||||||
host->clk_freq = 20000000;
|
host->clk_freq = 20000000;
|
||||||
host->clk_div = clk_div1;
|
host->clk_div = clk_div1;
|
||||||
writel((~TIFM_CTRL_FAST_CLK) &
|
writel((~TIFM_CTRL_FAST_CLK)
|
||||||
readl(sock->addr + SOCK_CONTROL),
|
& readl(sock->addr + SOCK_CONTROL),
|
||||||
sock->addr + SOCK_CONTROL);
|
sock->addr + SOCK_CONTROL);
|
||||||
} else {
|
} else {
|
||||||
host->clk_freq = 24000000;
|
host->clk_freq = 24000000;
|
||||||
host->clk_div = clk_div2;
|
host->clk_div = clk_div2;
|
||||||
writel(TIFM_CTRL_FAST_CLK |
|
writel(TIFM_CTRL_FAST_CLK
|
||||||
readl(sock->addr + SOCK_CONTROL),
|
| readl(sock->addr + SOCK_CONTROL),
|
||||||
sock->addr + SOCK_CONTROL);
|
sock->addr + SOCK_CONTROL);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
host->clk_div = 0;
|
host->clk_div = 0;
|
||||||
}
|
}
|
||||||
host->clk_div &= TIFM_MMCSD_CLKMASK;
|
host->clk_div &= TIFM_MMCSD_CLKMASK;
|
||||||
writel(host->clk_div | ((~TIFM_MMCSD_CLKMASK) &
|
writel(host->clk_div
|
||||||
readl(sock->addr + SOCK_MMCSD_CONFIG)),
|
| ((~TIFM_MMCSD_CLKMASK)
|
||||||
sock->addr + SOCK_MMCSD_CONFIG);
|
& readl(sock->addr + SOCK_MMCSD_CONFIG)),
|
||||||
|
sock->addr + SOCK_MMCSD_CONFIG);
|
||||||
|
|
||||||
if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN)
|
if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN)
|
||||||
host->flags |= OPENDRAIN;
|
host->flags |= OPENDRAIN;
|
||||||
@ -855,8 +857,8 @@ static int tifm_sd_probe(struct tifm_dev *sock)
|
|||||||
struct tifm_sd *host;
|
struct tifm_sd *host;
|
||||||
int rc = -EIO;
|
int rc = -EIO;
|
||||||
|
|
||||||
if (!(TIFM_SOCK_STATE_OCCUPIED &
|
if (!(TIFM_SOCK_STATE_OCCUPIED
|
||||||
readl(sock->addr + SOCK_PRESENT_STATE))) {
|
& readl(sock->addr + SOCK_PRESENT_STATE))) {
|
||||||
printk(KERN_WARNING DRIVER_NAME ": card gone, unexpectedly\n");
|
printk(KERN_WARNING DRIVER_NAME ": card gone, unexpectedly\n");
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@ -914,7 +916,7 @@ static void tifm_sd_remove(struct tifm_dev *sock)
|
|||||||
|
|
||||||
/* The meaning of the bit majority in this constant is unknown. */
|
/* The meaning of the bit majority in this constant is unknown. */
|
||||||
writel(0xfff8 & readl(sock->addr + SOCK_CONTROL),
|
writel(0xfff8 & readl(sock->addr + SOCK_CONTROL),
|
||||||
sock->addr + SOCK_CONTROL);
|
sock->addr + SOCK_CONTROL);
|
||||||
|
|
||||||
tifm_set_drvdata(sock, NULL);
|
tifm_set_drvdata(sock, NULL);
|
||||||
mmc_free_host(mmc);
|
mmc_free_host(mmc);
|
||||||
|
Loading…
Reference in New Issue
Block a user