SDMMC:
authorxbw <xbw@rock-chips.com>
Fri, 14 Mar 2014 08:22:19 +0000 (16:22 +0800)
committerxbw <xbw@rock-chips.com>
Fri, 14 Mar 2014 08:30:48 +0000 (16:30 +0800)
1.Optimizing operational processes SDMMC.
2.Eliminate the normal error message.

drivers/mmc/core/core.c [changed mode: 0644->0755]
drivers/mmc/host/rk_sdmmc.c
drivers/mmc/host/rk_sdmmc.h
drivers/mmc/host/rk_sdmmc_of.c

old mode 100644 (file)
new mode 100755 (executable)
index 51e288c..6c56ec5
@@ -2369,6 +2369,7 @@ static int mmc_rescan_try_freq(struct mmc_host *host, unsigned freq)
         * if the card is being re-initialized, just send it.  CMD52
         * should be ignored by SD/eMMC cards.
         */
+#if 0
        sdio_reset(host);
        mmc_go_idle(host);
 
@@ -2381,6 +2382,30 @@ static int mmc_rescan_try_freq(struct mmc_host *host, unsigned freq)
                return 0;
        if (!mmc_attach_mmc(host))
                return 0;
+#else
+    /*
+    * Simplifying the process of initializing the card.
+    * modifyed by xbw, at 2014-03-14
+    */
+       if(host->restrict_caps & RESTRICT_CARD_TYPE_SDIO)
+           sdio_reset(host);
+
+       mmc_go_idle(host);
+       
+       if(host->restrict_caps & (RESTRICT_CARD_TYPE_SDIO |RESTRICT_CARD_TYPE_SD))
+           mmc_send_if_cond(host, host->ocr_avail);
+
+    /* Order's important: probe SDIO, then SD, then MMC */
+       if ((host->restrict_caps &RESTRICT_CARD_TYPE_SDIO) && !mmc_attach_sdio(host))
+               return 0;
+       if ((host->restrict_caps &RESTRICT_CARD_TYPE_SD) && !mmc_attach_sd(host))
+               return 0;
+       if ((host->restrict_caps &(RESTRICT_CARD_TYPE_EMMC|RESTRICT_CARD_TYPE_SD)) && !mmc_attach_mmc(host))
+               return 0;   
+#endif
+
+
+
 
        mmc_power_off(host);
        return -EIO;
index 259dda15dca8d821e7245031647b9223a51682cf..d4c713c7535bccfa8331ca849fb1347b5b42f337 100755 (executable)
@@ -58,9 +58,9 @@
 #define DW_MCI_FREQ_MAX        50000000//200000000     /* unit: HZ */
 #define DW_MCI_FREQ_MIN        300000//400000          /* unit: HZ */
 
-#define SDMMC_DATA_TIMEOUT_SD  500000; /*max is 250ms refer to Spec; Maybe adapt the value to the sick card.*/
-#define SDMMC_DATA_TIMEOUT_SDIO        250000
-#define SDMMC_DATA_TIMEOUT_EMMC        2500000
+#define SDMMC_DATA_TIMEOUT_SD  500; /*max is 250ms refer to Spec; Maybe adapt the value to the sick card.*/
+#define SDMMC_DATA_TIMEOUT_SDIO        250
+#define SDMMC_DATA_TIMEOUT_EMMC        2500
 
 #ifdef CONFIG_MMC_DW_IDMAC
 #define IDMAC_INT_CLR          (SDMMC_IDMAC_INT_AI | SDMMC_IDMAC_INT_NI | \
@@ -856,8 +856,15 @@ static void dw_mci_setup_bus(struct dw_mci_slot *slot, bool force_clkinit)
 
        host->current_speed = clock;
 
+    if(slot->ctype != slot->pre_ctype)
+            MMC_DBG_BOOT_FUNC("Bus speed=%dHz,Bus width=%s.[%s]", \
+                div ? ((host->bus_hz / div) >> 1):host->bus_hz, \
+                (slot->ctype == SDMMC_CTYPE_4BIT)?"4bits":"8bits", mmc_hostname(host->mmc));
+    slot->pre_ctype = slot->ctype;
+
        /* Set the current slot bus width */
        mci_writel(host, CTYPE, (slot->ctype << slot->id));
+
 }
 
 static void dw_mci_wait_unbusy(struct dw_mci *host)
@@ -1013,6 +1020,7 @@ static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
        default:
                /* set default 1 bit mode */
                slot->ctype = SDMMC_CTYPE_1BIT;
+               slot->pre_ctype = SDMMC_CTYPE_1BIT;
        }
 
        regs = mci_readl(slot->host, UHS_REG);
@@ -1335,8 +1343,9 @@ static void dw_mci_command_complete(struct dw_mci *host, struct mmc_command *cmd
     MMC_DBG_CMD_FUNC(" command complete, cmd=%d,cmdError=0x%x [%s]",cmd->opcode, cmd->error,mmc_hostname(host->mmc));
 
        if (cmd->error) {
-           MMC_DBG_ERR_FUNC(" command complete, cmd=%d,cmdError=0x%x [%s]",\
-               cmd->opcode, cmd->error,mmc_hostname(host->mmc));
+           if(MMC_SEND_STATUS != cmd->opcode)
+           MMC_DBG_ERR_FUNC(" command complete, cmd=%d,cmdError=0x%x [%s]",\
+               cmd->opcode, cmd->error,mmc_hostname(host->mmc));
                
                /* newer ip versions need a delay between retries */
                if (host->quirks & DW_MCI_QUIRK_RETRY_DELAY)
@@ -1348,6 +1357,7 @@ static void dw_mci_command_complete(struct dw_mci *host, struct mmc_command *cmd
 static void dw_mci_tasklet_func(unsigned long priv)
 {
        struct dw_mci *host = (struct dw_mci *)priv;
+    struct dw_mci_slot *slot = mmc_priv(host->mmc);
        struct mmc_data *data;
        struct mmc_command *cmd;
        enum dw_mci_state state;
@@ -1447,9 +1457,11 @@ static void dw_mci_tasklet_func(unsigned long priv)
                        set_bit(EVENT_DATA_COMPLETE, &host->completed_events);
                        status = host->data_status;
 
-                       if (status & DW_MCI_DATA_ERROR_FLAGS) {         
-                MMC_DBG_ERR_FUNC("Pre-state[%d]-->NowState[%d]: DW_MCI_DATA_ERROR_FLAGS, datastatus=0x%x [%s]",\
-                        prev_state,state,status, mmc_hostname(host->mmc));
+                       if (status & DW_MCI_DATA_ERROR_FLAGS) { 
+                           if((SDMMC_CTYPE_1BIT != slot->ctype)&&(MMC_SEND_EXT_CSD == host->mrq->cmd->opcode))
+                    MMC_DBG_ERR_FUNC("Pre-state[%d]-->NowState[%d]: DW_MCI_DATA_ERROR_FLAGS,datastatus=0x%x [%s]",\
+                            prev_state,state, status, mmc_hostname(host->mmc));
+                            
                        if (status & SDMMC_INT_DRTO) {
                                        data->error = -ETIMEDOUT;
                                } else if (status & SDMMC_INT_DCRC) {
index 7dd14b54aee9e5539dac730e46ad80817dd106df..46db159f7b6619150d3a25e115fbb6aefa65a221 100755 (executable)
@@ -281,6 +281,7 @@ struct dw_mci_slot {
        int                     wp_gpio;
     int         pwr_en_gpio;
        u32                     ctype;
+       u32         pre_ctype;
 
        struct mmc_request      *mrq;
        struct list_head        queue_node;
index 1030668ce99eb07340f59ddc8302a4fa3fb7acdd..dc674204735aa529b466bc0cc19c415d52668dfc 100755 (executable)
 \r
 #include "rk_sdmmc_of.h"\r
 \r
-u32 mmc_debug_level;\r
+u32 mmc_debug_level= MMC_DBG_ERROR;//MMC_DBG_ALL;//set the value refer to file rk_sdmmc_of.h\r
+\r
 \r
 static void rockchip_mmc_of_dump(struct rk_sdmmc_of *rk_mmc_property)\r
-{\r
-    mmc_debug_level = MMC_DBG_ERROR;//MMC_DBG_ALL;//set the value refer to file rk_sdmmc_of.h\r
-    \r
-    MMC_DBG_BOOT_FUNC("=========rockchip mmc dts dump info start== 2014-03-12 14:23 ======");\r
+{    \r
+    MMC_DBG_BOOT_FUNC("=========rockchip mmc dts dump info start== 2014-03-14 15:51 ======");\r
  /*   \r
     MMC_DBG_BOOT_FUNC("mmc,caps: 0x%x",rk_mmc_property->mmc_caps);\r
     MMC_DBG_BOOT_FUNC("mmc,ocr:  0x%x",rk_mmc_property->mmc_ocr);\r