aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc
diff options
context:
space:
mode:
authorAlex Dubov <oakad@yahoo.com>2007-04-12 03:05:24 -0400
committerPierre Ossman <drzeus@drzeus.cx>2007-05-01 07:04:15 -0400
commit5897d657b58efb244b1f82a912ee93e5141ed14c (patch)
tree22328db6efe081b2c38cfad28666d43f53ac87c9 /drivers/mmc
parent72dc9d9619dd4682f4197e7a7f19af22fd6516a7 (diff)
tifm_sd: fix resume handler
Resume should not explicitly check for media type. Instead, it may relay on success of socket initialization. Small changes are introduced to tifm_sd_initialize to make it more robust. Signed-off-by: Alex Dubov <oakad@yahoo.com> Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
Diffstat (limited to 'drivers/mmc')
-rw-r--r--drivers/mmc/tifm_sd.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/drivers/mmc/tifm_sd.c b/drivers/mmc/tifm_sd.c
index 103060f490a6..d20ccfcd911e 100644
--- a/drivers/mmc/tifm_sd.c
+++ b/drivers/mmc/tifm_sd.c
@@ -36,7 +36,6 @@ module_param(fixed_timeout, bool, 0644);
36#define TIFM_MMCSD_INAB 0x0080 /* abort / initialize command */ 36#define TIFM_MMCSD_INAB 0x0080 /* abort / initialize command */
37#define TIFM_MMCSD_READ 0x8000 37#define TIFM_MMCSD_READ 0x8000
38 38
39#define TIFM_MMCSD_DATAMASK 0x401d /* set bits: CERR, EOFB, BRS, CB, EOC */
40#define TIFM_MMCSD_ERRMASK 0x01e0 /* set bits: CCRC, CTO, DCRC, DTO */ 39#define TIFM_MMCSD_ERRMASK 0x01e0 /* set bits: CCRC, CTO, DCRC, DTO */
41#define TIFM_MMCSD_EOC 0x0001 /* end of command phase */ 40#define TIFM_MMCSD_EOC 0x0001 /* end of command phase */
42#define TIFM_MMCSD_CB 0x0004 /* card enter busy state */ 41#define TIFM_MMCSD_CB 0x0004 /* card enter busy state */
@@ -731,7 +730,7 @@ static int tifm_sd_initialize_host(struct tifm_sd *host)
731 sock->addr + SOCK_MMCSD_CONFIG); 730 sock->addr + SOCK_MMCSD_CONFIG);
732 731
733 /* wait up to 0.51 sec for reset */ 732 /* wait up to 0.51 sec for reset */
734 for (rc = 2; rc <= 256; rc <<= 1) { 733 for (rc = 32; rc <= 256; rc <<= 1) {
735 if (1 & readl(sock->addr + SOCK_MMCSD_SYSTEM_STATUS)) { 734 if (1 & readl(sock->addr + SOCK_MMCSD_SYSTEM_STATUS)) {
736 rc = 0; 735 rc = 0;
737 break; 736 break;
@@ -740,8 +739,8 @@ static int tifm_sd_initialize_host(struct tifm_sd *host)
740 } 739 }
741 740
742 if (rc) { 741 if (rc) {
743 printk(KERN_ERR DRIVER_NAME 742 printk(KERN_ERR "%s : controller failed to reset\n",
744 ": controller failed to reset\n"); 743 sock->dev.bus_id);
745 return -ENODEV; 744 return -ENODEV;
746 } 745 }
747 746
@@ -754,8 +753,7 @@ static int tifm_sd_initialize_host(struct tifm_sd *host)
754 writel(64, sock->addr + SOCK_MMCSD_COMMAND_TO); 753 writel(64, sock->addr + SOCK_MMCSD_COMMAND_TO);
755 writel(TIFM_MMCSD_INAB, sock->addr + SOCK_MMCSD_COMMAND); 754 writel(TIFM_MMCSD_INAB, sock->addr + SOCK_MMCSD_COMMAND);
756 755
757 /* INAB should take much less than reset */ 756 for (rc = 16; rc <= 64; rc <<= 1) {
758 for (rc = 1; rc <= 16; rc <<= 1) {
759 host_status = readl(sock->addr + SOCK_MMCSD_STATUS); 757 host_status = readl(sock->addr + SOCK_MMCSD_STATUS);
760 writel(host_status, sock->addr + SOCK_MMCSD_STATUS); 758 writel(host_status, sock->addr + SOCK_MMCSD_STATUS);
761 if (!(host_status & TIFM_MMCSD_ERRMASK) 759 if (!(host_status & TIFM_MMCSD_ERRMASK)
@@ -767,12 +765,14 @@ static int tifm_sd_initialize_host(struct tifm_sd *host)
767 } 765 }
768 766
769 if (rc) { 767 if (rc) {
770 printk(KERN_ERR DRIVER_NAME 768 printk(KERN_ERR
771 ": card not ready - probe failed on initialization\n"); 769 "%s : card not ready - probe failed on initialization\n",
770 sock->dev.bus_id);
772 return -ENODEV; 771 return -ENODEV;
773 } 772 }
774 773
775 writel(TIFM_MMCSD_DATAMASK | TIFM_MMCSD_ERRMASK, 774 writel(TIFM_MMCSD_CERR | TIFM_MMCSD_BRS | TIFM_MMCSD_EOC
775 | TIFM_MMCSD_ERRMASK,
776 sock->addr + SOCK_MMCSD_INT_ENABLE); 776 sock->addr + SOCK_MMCSD_INT_ENABLE);
777 mmiowb(); 777 mmiowb();
778 778
@@ -887,14 +887,17 @@ static int tifm_sd_resume(struct tifm_dev *sock)
887{ 887{
888 struct mmc_host *mmc = tifm_get_drvdata(sock); 888 struct mmc_host *mmc = tifm_get_drvdata(sock);
889 struct tifm_sd *host = mmc_priv(mmc); 889 struct tifm_sd *host = mmc_priv(mmc);
890 int rc;
890 891
891 if (sock->type != TIFM_TYPE_SD 892 rc = tifm_sd_initialize_host(host);
892 || tifm_sd_initialize_host(host)) { 893 dev_dbg(&sock->dev, "resume initialize %d\n", rc);
893 tifm_eject(sock); 894
894 return 0; 895 if (rc)
895 } else { 896 host->eject = 1;
896 return mmc_resume_host(mmc); 897 else
897 } 898 rc = mmc_resume_host(mmc);
899
900 return rc;
898} 901}
899 902
900#else 903#else