aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/host/sh_mmcif.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mmc/host/sh_mmcif.c')
-rw-r--r--drivers/mmc/host/sh_mmcif.c63
1 files changed, 30 insertions, 33 deletions
diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c
index 74e7aca271d4..b2f261cdaec1 100644
--- a/drivers/mmc/host/sh_mmcif.c
+++ b/drivers/mmc/host/sh_mmcif.c
@@ -18,15 +18,15 @@
18 18
19#include <linux/clk.h> 19#include <linux/clk.h>
20#include <linux/completion.h> 20#include <linux/completion.h>
21#include <linux/delay.h>
21#include <linux/dma-mapping.h> 22#include <linux/dma-mapping.h>
22#include <linux/mmc/host.h>
23#include <linux/mmc/card.h> 23#include <linux/mmc/card.h>
24#include <linux/mmc/core.h> 24#include <linux/mmc/core.h>
25#include <linux/mmc/host.h>
25#include <linux/mmc/mmc.h> 26#include <linux/mmc/mmc.h>
26#include <linux/mmc/sdio.h> 27#include <linux/mmc/sdio.h>
27#include <linux/delay.h>
28#include <linux/platform_device.h>
29#include <linux/mmc/sh_mmcif.h> 28#include <linux/mmc/sh_mmcif.h>
29#include <linux/platform_device.h>
30 30
31#define DRIVER_NAME "sh_mmcif" 31#define DRIVER_NAME "sh_mmcif"
32#define DRIVER_VERSION "2010-04-28" 32#define DRIVER_VERSION "2010-04-28"
@@ -154,7 +154,6 @@
154struct sh_mmcif_host { 154struct sh_mmcif_host {
155 struct mmc_host *mmc; 155 struct mmc_host *mmc;
156 struct mmc_data *data; 156 struct mmc_data *data;
157 struct mmc_command *cmd;
158 struct platform_device *pd; 157 struct platform_device *pd;
159 struct clk *hclk; 158 struct clk *hclk;
160 unsigned int clk; 159 unsigned int clk;
@@ -220,8 +219,8 @@ static int sh_mmcif_error_manage(struct sh_mmcif_host *host)
220 219
221 state1 = sh_mmcif_readl(host->addr, MMCIF_CE_HOST_STS1); 220 state1 = sh_mmcif_readl(host->addr, MMCIF_CE_HOST_STS1);
222 state2 = sh_mmcif_readl(host->addr, MMCIF_CE_HOST_STS2); 221 state2 = sh_mmcif_readl(host->addr, MMCIF_CE_HOST_STS2);
223 pr_debug("%s: ERR HOST_STS1 = %08x\n", DRIVER_NAME, state1); 222 dev_dbg(&host->pd->dev, "ERR HOST_STS1 = %08x\n", state1);
224 pr_debug("%s: ERR HOST_STS2 = %08x\n", DRIVER_NAME, state2); 223 dev_dbg(&host->pd->dev, "ERR HOST_STS2 = %08x\n", state2);
225 224
226 if (state1 & STS1_CMDSEQ) { 225 if (state1 & STS1_CMDSEQ) {
227 sh_mmcif_bitset(host, MMCIF_CE_CMD_CTRL, CMD_CTRL_BREAK); 226 sh_mmcif_bitset(host, MMCIF_CE_CMD_CTRL, CMD_CTRL_BREAK);
@@ -229,8 +228,8 @@ static int sh_mmcif_error_manage(struct sh_mmcif_host *host)
229 while (1) { 228 while (1) {
230 timeout--; 229 timeout--;
231 if (timeout < 0) { 230 if (timeout < 0) {
232 pr_err(DRIVER_NAME": Forceed end of " \ 231 dev_err(&host->pd->dev,
233 "command sequence timeout err\n"); 232 "Forceed end of command sequence timeout err\n");
234 return -EIO; 233 return -EIO;
235 } 234 }
236 if (!(sh_mmcif_readl(host->addr, MMCIF_CE_HOST_STS1) 235 if (!(sh_mmcif_readl(host->addr, MMCIF_CE_HOST_STS1)
@@ -239,18 +238,18 @@ static int sh_mmcif_error_manage(struct sh_mmcif_host *host)
239 mdelay(1); 238 mdelay(1);
240 } 239 }
241 sh_mmcif_sync_reset(host); 240 sh_mmcif_sync_reset(host);
242 pr_debug(DRIVER_NAME": Forced end of command sequence\n"); 241 dev_dbg(&host->pd->dev, "Forced end of command sequence\n");
243 return -EIO; 242 return -EIO;
244 } 243 }
245 244
246 if (state2 & STS2_CRC_ERR) { 245 if (state2 & STS2_CRC_ERR) {
247 pr_debug(DRIVER_NAME": Happened CRC error\n"); 246 dev_dbg(&host->pd->dev, ": Happened CRC error\n");
248 ret = -EIO; 247 ret = -EIO;
249 } else if (state2 & STS2_TIMEOUT_ERR) { 248 } else if (state2 & STS2_TIMEOUT_ERR) {
250 pr_debug(DRIVER_NAME": Happened Timeout error\n"); 249 dev_dbg(&host->pd->dev, ": Happened Timeout error\n");
251 ret = -ETIMEDOUT; 250 ret = -ETIMEDOUT;
252 } else { 251 } else {
253 pr_debug(DRIVER_NAME": Happened End/Index error\n"); 252 dev_dbg(&host->pd->dev, ": Happened End/Index error\n");
254 ret = -EIO; 253 ret = -EIO;
255 } 254 }
256 return ret; 255 return ret;
@@ -414,7 +413,7 @@ static u32 sh_mmcif_set_cmd(struct sh_mmcif_host *host,
414 tmp |= CMD_SET_RTYP_17B; 413 tmp |= CMD_SET_RTYP_17B;
415 break; 414 break;
416 default: 415 default:
417 pr_err(DRIVER_NAME": Not support type response.\n"); 416 dev_err(&host->pd->dev, "Unsupported response type.\n");
418 break; 417 break;
419 } 418 }
420 switch (opc) { 419 switch (opc) {
@@ -442,7 +441,7 @@ static u32 sh_mmcif_set_cmd(struct sh_mmcif_host *host,
442 tmp |= CMD_SET_DATW_8; 441 tmp |= CMD_SET_DATW_8;
443 break; 442 break;
444 default: 443 default:
445 pr_err(DRIVER_NAME": Not support bus width.\n"); 444 dev_err(&host->pd->dev, "Unsupported bus width.\n");
446 break; 445 break;
447 } 446 }
448 } 447 }
@@ -470,10 +469,10 @@ static u32 sh_mmcif_set_cmd(struct sh_mmcif_host *host,
470 return opc = ((opc << 24) | tmp); 469 return opc = ((opc << 24) | tmp);
471} 470}
472 471
473static u32 sh_mmcif_data_trans(struct sh_mmcif_host *host, 472static int sh_mmcif_data_trans(struct sh_mmcif_host *host,
474 struct mmc_request *mrq, u32 opc) 473 struct mmc_request *mrq, u32 opc)
475{ 474{
476 u32 ret; 475 int ret;
477 476
478 switch (opc) { 477 switch (opc) {
479 case MMC_READ_MULTIPLE_BLOCK: 478 case MMC_READ_MULTIPLE_BLOCK:
@@ -490,7 +489,7 @@ static u32 sh_mmcif_data_trans(struct sh_mmcif_host *host,
490 ret = sh_mmcif_single_read(host, mrq); 489 ret = sh_mmcif_single_read(host, mrq);
491 break; 490 break;
492 default: 491 default:
493 pr_err(DRIVER_NAME": NOT SUPPORT CMD = d'%08d\n", opc); 492 dev_err(&host->pd->dev, "UNSUPPORTED CMD = d'%08d\n", opc);
494 ret = -EINVAL; 493 ret = -EINVAL;
495 break; 494 break;
496 } 495 }
@@ -504,8 +503,6 @@ static void sh_mmcif_start_cmd(struct sh_mmcif_host *host,
504 int ret = 0, mask = 0; 503 int ret = 0, mask = 0;
505 u32 opc = cmd->opcode; 504 u32 opc = cmd->opcode;
506 505
507 host->cmd = cmd;
508
509 switch (opc) { 506 switch (opc) {
510 /* respons busy check */ 507 /* respons busy check */
511 case MMC_SWITCH: 508 case MMC_SWITCH:
@@ -553,8 +550,8 @@ static void sh_mmcif_start_cmd(struct sh_mmcif_host *host,
553 cmd->error = -ETIMEDOUT; 550 cmd->error = -ETIMEDOUT;
554 break; 551 break;
555 default: 552 default:
556 pr_debug("%s: Cmd(d'%d) err\n", 553 dev_dbg(&host->pd->dev, "Cmd(d'%d) err\n",
557 DRIVER_NAME, cmd->opcode); 554 cmd->opcode);
558 cmd->error = sh_mmcif_error_manage(host); 555 cmd->error = sh_mmcif_error_manage(host);
559 break; 556 break;
560 } 557 }
@@ -562,7 +559,7 @@ static void sh_mmcif_start_cmd(struct sh_mmcif_host *host,
562 return; 559 return;
563 } 560 }
564 if (!(cmd->flags & MMC_RSP_PRESENT)) { 561 if (!(cmd->flags & MMC_RSP_PRESENT)) {
565 cmd->error = ret; 562 cmd->error = 0;
566 return; 563 return;
567 } 564 }
568 sh_mmcif_get_response(host, cmd); 565 sh_mmcif_get_response(host, cmd);
@@ -587,7 +584,7 @@ static void sh_mmcif_stop_cmd(struct sh_mmcif_host *host,
587 else if (mrq->cmd->opcode == MMC_WRITE_MULTIPLE_BLOCK) 584 else if (mrq->cmd->opcode == MMC_WRITE_MULTIPLE_BLOCK)
588 sh_mmcif_bitset(host, MMCIF_CE_INT_MASK, MASK_MCMD12RBE); 585 sh_mmcif_bitset(host, MMCIF_CE_INT_MASK, MASK_MCMD12RBE);
589 else { 586 else {
590 pr_err(DRIVER_NAME": not support stop cmd\n"); 587 dev_err(&host->pd->dev, "unsupported stop cmd\n");
591 cmd->error = sh_mmcif_error_manage(host); 588 cmd->error = sh_mmcif_error_manage(host);
592 return; 589 return;
593 } 590 }
@@ -723,14 +720,14 @@ static irqreturn_t sh_mmcif_intr(int irq, void *dev_id)
723 sh_mmcif_bitclr(host, MMCIF_CE_INT_MASK, state); 720 sh_mmcif_bitclr(host, MMCIF_CE_INT_MASK, state);
724 err = 1; 721 err = 1;
725 } else { 722 } else {
726 pr_debug("%s: Not support int\n", DRIVER_NAME); 723 dev_dbg(&host->pd->dev, "Not support int\n");
727 sh_mmcif_writel(host->addr, MMCIF_CE_INT, ~state); 724 sh_mmcif_writel(host->addr, MMCIF_CE_INT, ~state);
728 sh_mmcif_bitclr(host, MMCIF_CE_INT_MASK, state); 725 sh_mmcif_bitclr(host, MMCIF_CE_INT_MASK, state);
729 err = 1; 726 err = 1;
730 } 727 }
731 if (err) { 728 if (err) {
732 host->sd_error = true; 729 host->sd_error = true;
733 pr_debug("%s: int err state = %08x\n", DRIVER_NAME, state); 730 dev_dbg(&host->pd->dev, "int err state = %08x\n", state);
734 } 731 }
735 if (state & ~(INT_CMD12RBE | INT_CMD12CRE)) 732 if (state & ~(INT_CMD12RBE | INT_CMD12CRE))
736 complete(&host->intr_wait); 733 complete(&host->intr_wait);
@@ -744,8 +741,8 @@ static int __devinit sh_mmcif_probe(struct platform_device *pdev)
744{ 741{
745 int ret = 0, irq[2]; 742 int ret = 0, irq[2];
746 struct mmc_host *mmc; 743 struct mmc_host *mmc;
747 struct sh_mmcif_host *host = NULL; 744 struct sh_mmcif_host *host;
748 struct sh_mmcif_plat_data *pd = NULL; 745 struct sh_mmcif_plat_data *pd;
749 struct resource *res; 746 struct resource *res;
750 void __iomem *reg; 747 void __iomem *reg;
751 char clk_name[8]; 748 char clk_name[8];
@@ -753,7 +750,7 @@ static int __devinit sh_mmcif_probe(struct platform_device *pdev)
753 irq[0] = platform_get_irq(pdev, 0); 750 irq[0] = platform_get_irq(pdev, 0);
754 irq[1] = platform_get_irq(pdev, 1); 751 irq[1] = platform_get_irq(pdev, 1);
755 if (irq[0] < 0 || irq[1] < 0) { 752 if (irq[0] < 0 || irq[1] < 0) {
756 pr_err(DRIVER_NAME": Get irq error\n"); 753 dev_err(&pdev->dev, "Get irq error\n");
757 return -ENXIO; 754 return -ENXIO;
758 } 755 }
759 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 756 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -766,7 +763,7 @@ static int __devinit sh_mmcif_probe(struct platform_device *pdev)
766 dev_err(&pdev->dev, "ioremap error.\n"); 763 dev_err(&pdev->dev, "ioremap error.\n");
767 return -ENOMEM; 764 return -ENOMEM;
768 } 765 }
769 pd = (struct sh_mmcif_plat_data *)(pdev->dev.platform_data); 766 pd = pdev->dev.platform_data;
770 if (!pd) { 767 if (!pd) {
771 dev_err(&pdev->dev, "sh_mmcif plat data error.\n"); 768 dev_err(&pdev->dev, "sh_mmcif plat data error.\n");
772 ret = -ENXIO; 769 ret = -ENXIO;
@@ -821,21 +818,21 @@ static int __devinit sh_mmcif_probe(struct platform_device *pdev)
821 818
822 ret = request_irq(irq[0], sh_mmcif_intr, 0, "sh_mmc:error", host); 819 ret = request_irq(irq[0], sh_mmcif_intr, 0, "sh_mmc:error", host);
823 if (ret) { 820 if (ret) {
824 pr_err(DRIVER_NAME": request_irq error (sh_mmc:error)\n"); 821 dev_err(&pdev->dev, "request_irq error (sh_mmc:error)\n");
825 goto clean_up2; 822 goto clean_up2;
826 } 823 }
827 ret = request_irq(irq[1], sh_mmcif_intr, 0, "sh_mmc:int", host); 824 ret = request_irq(irq[1], sh_mmcif_intr, 0, "sh_mmc:int", host);
828 if (ret) { 825 if (ret) {
829 free_irq(irq[0], host); 826 free_irq(irq[0], host);
830 pr_err(DRIVER_NAME": request_irq error (sh_mmc:int)\n"); 827 dev_err(&pdev->dev, "request_irq error (sh_mmc:int)\n");
831 goto clean_up2; 828 goto clean_up2;
832 } 829 }
833 830
834 sh_mmcif_writel(host->addr, MMCIF_CE_INT_MASK, MASK_ALL); 831 sh_mmcif_writel(host->addr, MMCIF_CE_INT_MASK, MASK_ALL);
835 sh_mmcif_detect(host->mmc); 832 sh_mmcif_detect(host->mmc);
836 833
837 pr_info("%s: driver version %s\n", DRIVER_NAME, DRIVER_VERSION); 834 dev_info(&pdev->dev, "driver version %s\n", DRIVER_VERSION);
838 pr_debug("%s: chip ver H'%04x\n", DRIVER_NAME, 835 dev_dbg(&pdev->dev, "chip ver H'%04x\n",
839 sh_mmcif_readl(host->addr, MMCIF_CE_VERSION) & 0x0000ffff); 836 sh_mmcif_readl(host->addr, MMCIF_CE_VERSION) & 0x0000ffff);
840 return ret; 837 return ret;
841 838