From patchwork Thu Dec 9 06:47:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Ball X-Patchwork-Id: 393012 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oB96ltXS016135 for ; Thu, 9 Dec 2010 06:47:57 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755047Ab0LIGrz (ORCPT ); Thu, 9 Dec 2010 01:47:55 -0500 Received: from void.printf.net ([89.145.121.20]:56503 "EHLO void.printf.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754737Ab0LIGrx (ORCPT ); Thu, 9 Dec 2010 01:47:53 -0500 Received: from chris by void.printf.net with local (Exim 4.69) (envelope-from ) id 1PQaIB-0005oO-Eb; Thu, 09 Dec 2010 06:47:51 +0000 Date: Thu, 9 Dec 2010 06:47:51 +0000 From: Chris Ball To: Will Newton Cc: Linux Kernel list , linux-mmc@vger.kernel.org, Matt Fleming Subject: Re: [PATCH] dw_mmc: Add Synopsys DesignWare mmc host driver. Message-ID: <20101209064751.GA21128@void.printf.net> References: <20101208115510.GD10998@console-pimps.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Thu, 09 Dec 2010 06:47:57 +0000 (UTC) diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 7de6b42..9c5c33a 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -9,16 +9,6 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * */ #include @@ -119,20 +109,20 @@ static int dw_mci_req_show(struct seq_file *s, void *v) if (cmd) seq_printf(s, - "CMD%u(0x%x) flg %x rsp %x %x %x %x err %d\n", - cmd->opcode, cmd->arg, cmd->flags, - cmd->resp[0], cmd->resp[1], cmd->resp[2], - cmd->resp[2], cmd->error); + "CMD%u(0x%x) flg %x rsp %x %x %x %x err %d\n", + cmd->opcode, cmd->arg, cmd->flags, + cmd->resp[0], cmd->resp[1], cmd->resp[2], + cmd->resp[2], cmd->error); if (data) seq_printf(s, "DATA %u / %u * %u flg %x err %d\n", - data->bytes_xfered, data->blocks, - data->blksz, data->flags, data->error); + data->bytes_xfered, data->blocks, + data->blksz, data->flags, data->error); if (stop) seq_printf(s, - "CMD%u(0x%x) flg %x rsp %x %x %x %x err %d\n", - stop->opcode, stop->arg, stop->flags, - stop->resp[0], stop->resp[1], stop->resp[2], - stop->resp[2], stop->error); + "CMD%u(0x%x) flg %x rsp %x %x %x %x err %d\n", + stop->opcode, stop->arg, stop->flags, + stop->resp[0], stop->resp[1], stop->resp[2], + stop->resp[2], stop->error); } spin_unlock_bh(&slot->host->lock); @@ -190,12 +180,11 @@ static void dw_mci_init_debugfs(struct dw_mci_slot *slot) return; node = debugfs_create_file("regs", S_IRUSR, root, host, - &dw_mci_regs_fops); + &dw_mci_regs_fops); if (!node) goto err; - node = debugfs_create_file("req", S_IRUSR, root, slot, - &dw_mci_req_fops); + node = debugfs_create_file("req", S_IRUSR, root, slot, &dw_mci_req_fops); if (!node) goto err; @@ -204,12 +193,12 @@ static void dw_mci_init_debugfs(struct dw_mci_slot *slot) goto err; node = debugfs_create_x32("pending_events", S_IRUSR, root, - (u32 *)&host->pending_events); + (u32 *)&host->pending_events); if (!node) goto err; node = debugfs_create_x32("completed_events", S_IRUSR, root, - (u32 *)&host->completed_events); + (u32 *)&host->completed_events); if (!node) goto err; @@ -225,8 +214,7 @@ static void dw_mci_set_timeout(struct dw_mci *host) mci_writel(host, TMOUT, 0xffffffff); /* timeout (maximum) */ } -static u32 dw_mci_prepare_command(struct mmc_host *mmc, - struct mmc_command *cmd) +static u32 dw_mci_prepare_command(struct mmc_host *mmc, struct mmc_command *cmd) { struct mmc_data *data; u32 cmdr; @@ -243,7 +231,7 @@ static u32 dw_mci_prepare_command(struct mmc_host *mmc, cmdr |= SDMMC_CMD_RESP_EXP; /* expect the respond, need to set this bit */ if (cmd->flags & MMC_RSP_136) - cmdr |= SDMMC_CMD_RESP_LONG; /* expect long respond */ + cmdr |= SDMMC_CMD_RESP_LONG; } if (cmd->flags & MMC_RSP_CRC) @@ -253,7 +241,7 @@ static u32 dw_mci_prepare_command(struct mmc_host *mmc, if (data) { cmdr |= SDMMC_CMD_DAT_EXP; if (data->flags & MMC_DATA_STREAM) - cmdr |= SDMMC_CMD_STRM_MODE; /* set stream mode */ + cmdr |= SDMMC_CMD_STRM_MODE; if (data->flags & MMC_DATA_WRITE) cmdr |= SDMMC_CMD_DAT_WR; } @@ -265,9 +253,8 @@ static void dw_mci_start_command(struct dw_mci *host, struct mmc_command *cmd, u32 cmd_flags) { host->cmd = cmd; - dev_vdbg(&host->pdev->dev, - "start command: ARGR=0x%08x CMDR=0x%08x\n", - cmd->arg, cmd_flags); + dev_vdbg(&host->pdev->dev, "start command: ARGR=0x%08x CMDR=0x%08x\n", + cmd->arg, cmd_flags); /* write to CMDARG register */ mci_writel(host, CMDARG, cmd->arg); @@ -288,7 +275,6 @@ static void dw_mci_stop_dma(struct dw_mci *host) if (host->use_dma) { host->dma_ops->stop(host); host->dma_ops->cleanup(host); - } else { /* Data transfer was stopped by the interrupt handler */ set_bit(EVENT_XFER_COMPLETE, &host->pending_events); @@ -302,8 +288,8 @@ static void dw_mci_dma_cleanup(struct dw_mci *host) if (data) dma_unmap_sg(&host->pdev->dev, data->sg, data->sg_len, - ((data->flags & MMC_DATA_WRITE) - ? DMA_TO_DEVICE : DMA_FROM_DEVICE)); + ((data->flags & MMC_DATA_WRITE) + ? DMA_TO_DEVICE : DMA_FROM_DEVICE)); } static void dw_mci_idmac_stop_dma(struct dw_mci *host) @@ -340,8 +326,8 @@ static void dw_mci_idmac_complete_dma(struct dw_mci *host) } } -static void dw_mci_translate_sglist(struct dw_mci *host, - struct mmc_data *data, unsigned int sg_len) +static void dw_mci_translate_sglist(struct dw_mci *host, struct mmc_data *data, + unsigned int sg_len) { int i; struct idmac_desc *desc = host->sg_cpu; @@ -412,7 +398,7 @@ static int dw_mci_idmac_init(struct dw_mci *host) /* Mask out interrupts - get Tx & Rx complete only */ mci_writel(host, IDINTEN, SDMMC_IDMAC_INT_NI | SDMMC_IDMAC_INT_RI | - SDMMC_IDMAC_INT_TI); + SDMMC_IDMAC_INT_TI); /* Set the descriptor base address */ mci_writel(host, DBADDR, host->sg_dma); @@ -458,12 +444,11 @@ static int dw_mci_submit_data_dma(struct dw_mci *host, struct mmc_data *data) else direction = DMA_TO_DEVICE; - sg_len = dma_map_sg(&host->pdev->dev, data->sg, data->sg_len, - direction); + sg_len = dma_map_sg(&host->pdev->dev, data->sg, data->sg_len, direction); dev_vdbg(&host->pdev->dev, - "sd sg_cpu: %#lx sg_dma: %#lx sg_len: %d\n", - (unsigned long)host->sg_cpu, (unsigned long)host->sg_dma, + "sd sg_cpu: %#lx sg_dma: %#lx sg_len: %d\n", + (unsigned long)host->sg_cpu, (unsigned long)host->sg_dma, sg_len); /* Enable the DMA interface */ @@ -471,7 +456,7 @@ static int dw_mci_submit_data_dma(struct dw_mci *host, struct mmc_data *data) temp |= SDMMC_CTRL_DMA_ENABLE; mci_writel(host, CTRL, temp); - /* disable irq of RX & TX, let DMA handle it */ + /* Disable RX/TX IRQs, let DMA handle it */ temp = mci_readl(host, INTMASK); temp &= ~(SDMMC_INT_RXDR | SDMMC_INT_TXDR); mci_writel(host, INTMASK, temp); @@ -537,18 +522,17 @@ static void dw_mci_setup_bus(struct dw_mci_slot *slot) if (slot->clock != host->current_speed) { if (host->bus_hz % slot->clock) /* - * move the + 1 after the dvide - * to prevent over-clocking the card. + * move the "+ 1" after the divide to prevent + * over-clocking the card. */ div = ((host->bus_hz / slot->clock) >> 1) + 1; else div = (host->bus_hz / slot->clock) >> 1; dev_info(&slot->mmc->class_dev, - "Bus speed (slot %d) = %dHz (slot req %dHz, actual %dHZ" - " div = %d)\n", - slot->id, host->bus_hz, slot->clock, - div ? ((host->bus_hz / div) >> 1) : host->bus_hz, div); + "Bus speed (slot %d) = %dHz (slot req %dHz, actual %dHZ" + " div = %d)\n", slot->id, host->bus_hz, slot->clock, + div ? ((host->bus_hz / div) >> 1) : host->bus_hz, div); /* disable clock */ mci_writel(host, CLKENA, 0); @@ -556,21 +540,21 @@ static void dw_mci_setup_bus(struct dw_mci_slot *slot) /* inform CIU */ mci_send_cmd(slot, - SDMMC_CMD_UPD_CLK | SDMMC_CMD_PRV_DAT_WAIT, 0); + SDMMC_CMD_UPD_CLK | SDMMC_CMD_PRV_DAT_WAIT, 0); /* set clock to desired speed */ mci_writel(host, CLKDIV, div); /* inform CIU */ mci_send_cmd(slot, - SDMMC_CMD_UPD_CLK | SDMMC_CMD_PRV_DAT_WAIT, 0); + SDMMC_CMD_UPD_CLK | SDMMC_CMD_PRV_DAT_WAIT, 0); /* enable clock */ mci_writel(host, CLKENA, SDMMC_CLKEN_ENABLE); /* inform CIU */ mci_send_cmd(slot, - SDMMC_CMD_UPD_CLK | SDMMC_CMD_PRV_DAT_WAIT, 0); + SDMMC_CMD_UPD_CLK | SDMMC_CMD_PRV_DAT_WAIT, 0); host->current_speed = slot->clock; } @@ -579,8 +563,7 @@ static void dw_mci_setup_bus(struct dw_mci_slot *slot) mci_writel(host, CTYPE, slot->ctype); } -static void dw_mci_start_request(struct dw_mci *host, - struct dw_mci_slot *slot) +static void dw_mci_start_request(struct dw_mci *host, struct dw_mci_slot *slot) { struct mmc_request *mrq; struct mmc_command *cmd; @@ -632,7 +615,7 @@ static void dw_mci_queue_request(struct dw_mci *host, struct dw_mci_slot *slot, struct mmc_request *mrq) { dev_vdbg(&slot->mmc->class_dev, "queue request: state=%d\n", - host->state); + host->state); spin_lock_bh(&host->lock); slot->mrq = mrq; @@ -703,16 +686,15 @@ static int dw_mci_get_ro(struct mmc_host *mmc) struct dw_mci_slot *slot = mmc_priv(mmc); struct dw_mci_board *brd = slot->host->pdata; - if (brd->get_ro != NULL) { + /* Use platform get_ro function, else try on board write protect */ + if (brd->get_ro) read_only = brd->get_ro(slot->id); - } else { - /* Try on board write protect */ - read_only = + else + read_only = mci_readl(slot->host, WRTPRT) & (1 << slot->id) ? 1 : 0; - } dev_dbg(&mmc->class_dev, "card is %s\n", - read_only ? "read-only" : "read-write"); + read_only ? "read-only" : "read-write"); return read_only; } @@ -723,13 +705,17 @@ static int dw_mci_get_cd(struct mmc_host *mmc) struct dw_mci_slot *slot = mmc_priv(mmc); struct dw_mci_board *brd = slot->host->pdata; - if (brd->get_cd != NULL) + /* Use platform get_cd function, else try onboard card detect */ + if (brd->get_cd) present = !brd->get_cd(slot->id); - else /* try onboard card detect */ + else present = (mci_readl(slot->host, CDETECT) & (1 << slot->id)) - == 0 ? 1 : 0; + == 0 ? 1 : 0; - dev_dbg(&mmc->class_dev, "card is %spresent\n", present ? "" : "not "); + if (present) + dev_dbg("card is present\n"); + else + dev_dbg("card is not present\n"); return present; } @@ -754,10 +740,10 @@ static void dw_mci_request_end(struct dw_mci *host, struct mmc_request *mrq) host->mrq = NULL; if (!list_empty(&host->queue)) { slot = list_entry(host->queue.next, - struct dw_mci_slot, queue_node); + struct dw_mci_slot, queue_node); list_del(&slot->queue_node); dev_vdbg(&host->pdev->dev, "list not empty: %s is next\n", - mmc_hostname(slot->mmc)); + mmc_hostname(slot->mmc)); host->state = STATE_SENDING_CMD; dw_mci_start_request(host, slot); } else { @@ -767,12 +753,10 @@ static void dw_mci_request_end(struct dw_mci *host, struct mmc_request *mrq) spin_unlock(&host->lock); mmc_request_done(prev_mmc, mrq); - spin_lock(&host->lock); } -static void dw_mci_command_complete(struct dw_mci *host, - struct mmc_command *cmd) +static void dw_mci_command_complete(struct dw_mci *host, struct mmc_command *cmd) { u32 status = host->cmd_status; @@ -879,14 +863,14 @@ static void dw_mci_tasklet_func(unsigned long priv) set_bit(EVENT_DATA_COMPLETE, &host->completed_events); status = host->data_status; - if (unlikely(status & DW_MCI_DATA_ERROR_FLAGS)) { + if (status & DW_MCI_DATA_ERROR_FLAGS)) { if (status & SDMMC_INT_DTO) { dev_err(&host->pdev->dev, - "data timeout error\n"); + "data timeout error\n"); data->error = -ETIMEDOUT; } else if (status & SDMMC_INT_DCRC) { dev_err(&host->pdev->dev, - "data CRC error\n"); + "data CRC error\n"); data->error = -EILSEQ; } else { dev_err(&host->pdev->dev, @@ -938,80 +922,80 @@ unlock: static void dw_mci_push_data16(struct dw_mci *host, void *buf, int cnt) { - u16 *pData = (u16 *)buf; + u16 *pdata = (u16 *)buf; WARN_ON(cnt % 2 != 0); cnt = cnt >> 1; while (cnt > 0) { - mci_writew(host, DATA, *pData++); + mci_writew(host, DATA, *pdata++); cnt--; } } static void dw_mci_pull_data16(struct dw_mci *host, void *buf, int cnt) { - u16 *pData = (u16 *)buf; + u16 *pdata = (u16 *)buf; WARN_ON(cnt % 2 != 0); cnt = cnt >> 1; while (cnt > 0) { - *pData++ = mci_readw(host, DATA); + *pdata++ = mci_readw(host, DATA); cnt--; } } static void dw_mci_push_data32(struct dw_mci *host, void *buf, int cnt) { - u32 *pData = (u32 *)buf; + u32 *pdata = (u32 *)buf; WARN_ON(cnt % 4 != 0); - WARN_ON((unsigned long)pData & 0x3); + WARN_ON((unsigned long)pdata & 0x3); cnt = cnt >> 2; while (cnt > 0) { - mci_writel(host, DATA, *pData++); + mci_writel(host, DATA, *pdata++); cnt--; } } static void dw_mci_pull_data32(struct dw_mci *host, void *buf, int cnt) { - u32 *pData = (u32 *)buf; + u32 *pdata = (u32 *)buf; WARN_ON(cnt % 4 != 0); - WARN_ON((unsigned long)pData & 0x3); + WARN_ON((unsigned long)pdata & 0x3); cnt = cnt >> 2; while (cnt > 0) { - *pData++ = mci_readl(host, DATA); + *pdata++ = mci_readl(host, DATA); cnt--; } } static void dw_mci_push_data64(struct dw_mci *host, void *buf, int cnt) { - u64 *pData = (u64 *)buf; + u64 *pdata = (u64 *)buf; WARN_ON(cnt % 8 != 0); cnt = cnt >> 3; while (cnt > 0) { - mci_writeq(host, DATA, *pData++); + mci_writeq(host, DATA, *pdata++); cnt--; } } static void dw_mci_pull_data64(struct dw_mci *host, void *buf, int cnt) { - u64 *pData = (u64 *)buf; + u64 *pdata = (u64 *)buf; WARN_ON(cnt % 8 != 0); cnt = cnt >> 3; while (cnt > 0) { - *pData++ = mci_readq(host, DATA); + *pdata++ = mci_readq(host, DATA); cnt--; } } @@ -1031,7 +1015,7 @@ static void dw_mci_read_data_pio(struct dw_mci *host) if (count == 0) old_len = len; - if (likely(offset + len <= sg->length)) { + if (offset + len <= sg->length)) { host->pull_data(host, (void *)(buf + offset), len); offset += len; @@ -1049,7 +1033,7 @@ static void dw_mci_read_data_pio(struct dw_mci *host) } else { unsigned int remaining = sg->length - offset; host->pull_data(host, - (void *)(buf + offset), remaining); + (void *)(buf + offset), remaining); nbytes += remaining; flush_dcache_page(sg_page(sg)); @@ -1076,8 +1060,7 @@ static void dw_mci_read_data_pio(struct dw_mci *host) return; } count++; - } while (status & SDMMC_INT_RXDR); /*if the RXDR is ready - lets read again*/ + } while (status & SDMMC_INT_RXDR); /* if the RXDR is ready, read again */ len = SDMMC_GET_FCNT(mci_readl(host, STATUS)); host->pio_offset = offset; data->bytes_xfered += nbytes; @@ -1102,7 +1085,7 @@ static void dw_mci_write_data_pio(struct dw_mci *host) do { len = SDMMC_FIFO_SZ - (SDMMC_GET_FCNT(mci_readl(host, STATUS)) << shift); - if (likely(offset + len <= sg->length)) { + if (offset + len <= sg->length)) { host->push_data(host, (void *)(buf + offset), len); offset += len; @@ -1119,7 +1102,7 @@ static void dw_mci_write_data_pio(struct dw_mci *host) unsigned int remaining = sg->length - offset; host->push_data(host, - (void *)(buf + offset), remaining); + (void *)(buf + offset), remaining); nbytes += remaining; host->sg = sg = sg_next(sg); @@ -1145,7 +1128,7 @@ static void dw_mci_write_data_pio(struct dw_mci *host) tasklet_schedule(&host->tasklet); return; } - } while (status & SDMMC_INT_TXDR); /* if TXDR, lets write again */ + } while (status & SDMMC_INT_TXDR); /* if TXDR, write again */ host->pio_offset = offset; data->bytes_xfered += nbytes; @@ -1172,12 +1155,12 @@ static void dw_mci_cmd_interrupt(struct dw_mci *host, u32 status) static irqreturn_t dw_mci_interrupt(int irq, void *dev_id) { struct dw_mci *host = dev_id; - u32 status, pending; + u32 status, pending; unsigned int pass_count = 0; do { status = mci_readl(host, RINTSTS); - pending = mci_readl(host, MINTSTS);/* read only mask reg */ + pending = mci_readl(host, MINTSTS); /* read-only mask reg */ /* * DTO fix - version 2.10a and below, and only if internal DMA @@ -1201,7 +1184,7 @@ static irqreturn_t dw_mci_interrupt(int irq, void *dev_id) } if (pending & DW_MCI_DATA_ERROR_FLAGS) { - /* if there is an error, lets report DATA_ERROR */ + /* if there is an error, report DATA_ERROR */ mci_writel(host, RINTSTS, DW_MCI_DATA_ERROR_FLAGS); host->data_status = status; smp_wmb(); @@ -1209,7 +1192,6 @@ static irqreturn_t dw_mci_interrupt(int irq, void *dev_id) tasklet_schedule(&host->tasklet); } - if (pending & SDMMC_INT_DATA_OVER) { mci_writel(host, RINTSTS, SDMMC_INT_DATA_OVER); if (!host->data_status) @@ -1251,8 +1233,7 @@ static irqreturn_t dw_mci_interrupt(int irq, void *dev_id) /* Handle DMA interrupts */ pending = mci_readl(host, IDSTS); if (pending & (SDMMC_IDMAC_INT_TI | SDMMC_IDMAC_INT_RI)) { - mci_writel(host, IDSTS, SDMMC_IDMAC_INT_TI | - SDMMC_IDMAC_INT_RI); + mci_writel(host, IDSTS, SDMMC_IDMAC_INT_TI | SDMMC_IDMAC_INT_RI); mci_writel(host, IDSTS, SDMMC_IDMAC_INT_NI); set_bit(EVENT_DATA_COMPLETE, &host->pending_events); host->dma_ops->complete(host); @@ -1279,7 +1260,7 @@ static void dw_mci_tasklet_card(unsigned long data) spin_lock(&host->lock); dev_dbg(&slot->mmc->class_dev, "card %s\n", - present ? "inserted" : "removed"); + present ? "inserted" : "removed"); /* Card change detected */ slot->last_detect_state = present; @@ -1288,7 +1269,7 @@ static void dw_mci_tasklet_card(unsigned long data) if (present != 0) { if (host->pdata->setpower) host->pdata->setpower(slot->id, - mmc->ocr_avail); + mmc->ocr_avail); set_bit(DW_MMC_CARD_PRESENT, &slot->flags); } @@ -1358,10 +1339,9 @@ static void dw_mci_tasklet_card(unsigned long data) #ifdef CONFIG_MMC_DW_IDMAC ctrl = mci_readl(host, BMOD); - ctrl |= 0x01; /* Software reset of DMA */ + ctrl |= 0x01; /* Software reset of DMA */ mci_writel(host, BMOD, ctrl); #endif - } spin_unlock(&host->lock); @@ -1397,8 +1377,8 @@ static int __init dw_mci_init_slot(struct dw_mci *host, unsigned int id) mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34; /* - * Start with slot power disabled, - * will be enabled when card is detected + * Start with slot power disabled, it will be enabled when + * a card is detected. */ if (host->pdata->setpower) host->pdata->setpower(id, 0); @@ -1425,7 +1405,7 @@ static int __init dw_mci_init_slot(struct dw_mci *host, unsigned int id) mmc->max_req_size = host->pdata->blk_settings->max_req_size; mmc->max_seg_size = host->pdata->blk_settings->max_seg_size; } else { - /*useful defaults*/ + /* Useful defaults, if platform data is unset. */ mmc->max_segs = 64; mmc->max_blk_size = 65536; /* BLKSIZ is 16 bits */ mmc->max_blk_count = 512; @@ -1453,8 +1433,7 @@ static int __init dw_mci_init_slot(struct dw_mci *host, unsigned int id) return 0; } -static void dw_mci_cleanup_slot(struct dw_mci_slot *slot, - unsigned int id) +static void dw_mci_cleanup_slot(struct dw_mci_slot *slot, unsigned int id) { /* Shutdown detect IRQ */ if (slot->host->pdata->exit) @@ -1470,10 +1449,10 @@ static void dw_mci_init_dma(struct dw_mci *host) { /* Alloc memory for sg translation */ host->sg_cpu = dma_alloc_coherent(&host->pdev->dev, PAGE_SIZE, - &host->sg_dma, GFP_KERNEL); + &host->sg_dma, GFP_KERNEL); if (!host->sg_cpu) { dev_err(&host->pdev->dev, "%s: could not alloc DMA memory\n", - __func__); + __func__); goto no_dma; } @@ -1488,12 +1467,12 @@ static void dw_mci_init_dma(struct dw_mci *host) if (host->dma_ops->init) { if (host->dma_ops->init(host)) { - dev_err(&host->pdev->dev, "%s: Unable to initialise " - "DMA Controller.\n", __func__); + dev_err(&host->pdev->dev, "%s: Unable to initialize " + "DMA Controller.\n", __func__); goto no_dma; } } else { - dev_err(&host->pdev->dev, "DMA initialisation not found.\n"); + dev_err(&host->pdev->dev, "DMA initialization not found.\n"); goto no_dma; } @@ -1512,13 +1491,13 @@ static bool mci_wait_reset(struct device *dev, struct dw_mci *host) unsigned int ctrl; mci_writel(host, CTRL, (SDMMC_CTRL_RESET | - SDMMC_CTRL_FIFO_RESET | SDMMC_CTRL_DMA_RESET)); + SDMMC_CTRL_FIFO_RESET | SDMMC_CTRL_DMA_RESET)); - /* wait till resets clear */ + /* Wait until the reset bits clear */ do { ctrl = mci_readl(host, CTRL); - if (!(ctrl & (SDMMC_CTRL_RESET | - SDMMC_CTRL_FIFO_RESET | SDMMC_CTRL_DMA_RESET))) + if (!(ctrl & (SDMMC_CTRL_RESET | SDMMC_CTRL_FIFO_RESET | + SDMMC_CTRL_DMA_RESET))) return true; } while (time_before(jiffies, timeout)); @@ -1556,15 +1535,14 @@ static int dw_mci_probe(struct platform_device *pdev) } if (((pdata->num_slots > 1) && !(pdata->select_slot)) - || !(pdata->init)) { + || !(pdata->init)) { dev_err(&pdev->dev, "Platform data wrong\n"); ret = -ENODEV; goto err_freehost; } if (!pdata->bus_hz) { - dev_err(&pdev->dev, - "Bus speed undefined in platform data!\n"); + dev_err(&pdev->dev, "Bus speed undefined in platform data!\n"); ret = -ENODEV; goto err_freehost; } @@ -1601,21 +1579,21 @@ static int dw_mci_probe(struct platform_device *pdev) } else { /* Check for a reserved value, and warn if it is */ WARN((i != 1), - "HCON reports a reserved host data width!\n" - "Defaulting to 32-bit access.\n"); + "HCON reports a reserved host data width!\n" + "Defaulting to 32-bit access.\n"); host->push_data = dw_mci_push_data32; host->pull_data = dw_mci_pull_data32; width = 32; host->data_shift = 2; } - /* reset all blocks */ + /* Reset all blocks */ if (!mci_wait_reset(&pdev->dev, host)) { ret = -ENODEV; goto err_dmaunmap; } - /* Clear the interrupts for the host controller */ + /* Clear the interrupts for the host controller */ mci_writel(host, RINTSTS, 0xFFFFFFFF); mci_writel(host, INTMASK, 0); /* disable all mmc interrupt first */ @@ -1623,13 +1601,13 @@ static int dw_mci_probe(struct platform_device *pdev) mci_writel(host, TMOUT, 0xFFFFFFFF); /* - * FIFO threshold settings RxMark = fifo_size/2-1, - * Tx Mark =fifo_size/2 DMA Size = 8 + * FIFO threshold settings RxMark = fifo_size/2 - 1, + * Tx Mark = fifo_size/2 DMA Size = 8 */ fifo_size = mci_readl(host, FIFOTH); fifo_size = (fifo_size >> 16) & 0x7ff; mci_writel(host, FIFOTH, ((0x2 << 28) | ((fifo_size/2 - 1) << 16) | - ((fifo_size/2) << 0))); + ((fifo_size/2) << 0))); /* disable clock to CIU */ mci_writel(host, CLKENA, 0); @@ -1637,7 +1615,7 @@ static int dw_mci_probe(struct platform_device *pdev) tasklet_init(&host->tasklet, dw_mci_tasklet_func, (unsigned long)host); tasklet_init(&host->card_tasklet, - dw_mci_tasklet_card, (unsigned long)host); + dw_mci_tasklet_card, (unsigned long)host); ret = request_irq(irq, dw_mci_interrupt, 0, "dw-mci", host); if (ret) @@ -1660,18 +1638,17 @@ static int dw_mci_probe(struct platform_device *pdev) } /* - * enable interrupt for command done, data over, data empty, - * receive ready and error such as transmit, receive timeout, crc error + * Enable interrupts for command done, data over, data empty, card det, + * receive ready, and errors such as transmit, receive timeout, crc error */ mci_writel(host, RINTSTS, 0xFFFFFFFF); mci_writel(host, INTMASK, SDMMC_INT_CMD_DONE | SDMMC_INT_DATA_OVER | - SDMMC_INT_TXDR | SDMMC_INT_RXDR | - DW_MCI_ERROR_FLAGS | SDMMC_INT_CD); - mci_writel(host, CTRL, SDMMC_CTRL_INT_ENABLE); /*enable mci interrupt*/ + SDMMC_INT_TXDR | SDMMC_INT_RXDR | + DW_MCI_ERROR_FLAGS | SDMMC_INT_CD); + mci_writel(host, CTRL, SDMMC_CTRL_INT_ENABLE); /* Enable mci interrupt */ dev_info(&pdev->dev, "DW MMC controller at irq %d, " - "%d bit host data width\n", - irq, width); + "%d bit host data width\n", irq, width); if (host->quirks & DW_MCI_QUIRK_IDMAC_DTO) dev_info(&pdev->dev, "Internal DMAC interrupt fix enabled.\n"); @@ -1690,7 +1667,7 @@ err_dmaunmap: if (host->use_dma && host->dma_ops->exit) host->dma_ops->exit(host); dma_free_coherent(&host->pdev->dev, PAGE_SIZE, - host->sg_cpu, host->sg_dma); + host->sg_cpu, host->sg_dma); iounmap(host->regs); err_freehost: