1.to support eMMC.
authorxbw <xbw@rock-chips.com>
Tue, 11 Mar 2014 02:01:46 +0000 (10:01 +0800)
committerxbw <xbw@rock-chips.com>
Tue, 11 Mar 2014 02:01:46 +0000 (10:01 +0800)
2.Resolve conflicts pin used to wifi-sdio-det.
3.Resolve the clock conflict between sd and sdio.

arch/arm/boot/dts/rk3188-mmc.dtsi
block/partitions/Makefile
block/partitions/check.c [changed mode: 0644->0755]
drivers/mmc/card/block.c [changed mode: 0644->0755]
drivers/mmc/core/mmc.c
drivers/mmc/host/rk_sdmmc.c
include/linux/mmc/host.h
include/linux/mmc/mmc.h
include/linux/mmc/rk_mmc.h

index 795c12500a6e552d0f6304dafc712c3c25b8a1fc..7af74975f783d55495138263efee324c9ec9d047 100755 (executable)
@@ -32,6 +32,8 @@
                 
                 num-slots = <1>;
                supports-highspeed;
+               supports-emmc;
+                bootpart-no-access;
                fifo-depth = <0x80>;
 
                  
                pinctrl-1 = <&sd0_cd_gpio>; //for int gpio?
            clocks = <&clk_gates2 11>;
             clock-frequency = <50000000>;
-            clock-freq-min-max = <200000 50000000>;        
+            clock-freq-min-max = <400000 50000000>;        
 
            num-slots = <1>;
            supports-highspeed;
+           supports-sd;
            broken-cd;
            card-detect-delay = <200>;
            pwr-gpios = <&gpio3 GPIO_A1 GPIO_ACTIVE_LOW>; /*pwr_en = GPIO3_A1*/
@@ -94,6 +97,7 @@
             
             num-slots = <1>;
            supports-highspeed;
+            supports-sdio;
            fifo-depth = <0x100>;
            
             mmc,caps = <(MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ |MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED)>;
index 03af8eac51da81bf4f89cc49d7d9ca466d38c54b..1e5d63d1f01c5e9bd538529b67de9561a54890fd 100644 (file)
@@ -18,3 +18,6 @@ obj-$(CONFIG_IBM_PARTITION) += ibm.o
 obj-$(CONFIG_EFI_PARTITION) += efi.o
 obj-$(CONFIG_KARMA_PARTITION) += karma.o
 obj-$(CONFIG_SYSV68_PARTITION) += sysv68.o
+
+#added for emmc in Rockchip project.
+obj-$(CONFIG_MMC_DW_ROCKCHIP) += mtdpart.o
old mode 100644 (file)
new mode 100755 (executable)
index 19ba207..2b7baa0
@@ -19,6 +19,7 @@
 #include <linux/genhd.h>
 
 #include "check.h"
+#include "mtdpart.h"
 
 #include "acorn.h"
 #include "amiga.h"
@@ -104,6 +105,11 @@ static int (*check_part[])(struct parsed_partitions *) = {
 #ifdef CONFIG_SYSV68_PARTITION
        sysv68_partition,
 #endif
+
+#if CONFIG_MMC_DW_ROCKCHIP
+    mtdpart_partition,
+#endif
+
        NULL
 };
 
old mode 100644 (file)
new mode 100755 (executable)
index 0241a61f32d60c8a2b99eb547f6a8c3281d4b30f..1cccea4eca440a42e8c5b028c2174faefd16066e 100755 (executable)
@@ -349,10 +349,6 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd)
                 * There are two boot regions of equal size, defined in
                 * multiples of 128K.
                 */
-              #if 0
-               //emmc: We do NOT alloc boot partition now. noted by xbw, at 2014-03-09
-               card->ext_csd.boot_size = 0;
-          #else  
                if (ext_csd[EXT_CSD_BOOT_MULT] && mmc_boot_partition_access(card->host)) {
                        for (idx = 0; idx < MMC_NUM_BOOT_PARTITION; idx++) {
                                part_size = ext_csd[EXT_CSD_BOOT_MULT] << 17;
@@ -362,7 +358,6 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd)
                                        MMC_BLK_DATA_AREA_BOOT);
                        }
                }
-             #endif
        }
 
        card->ext_csd.raw_hc_erase_gap_size =
@@ -507,12 +502,14 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd)
                 * RPMB regions are defined in multiples of 128K.
                 */
                card->ext_csd.raw_rpmb_size_mult = ext_csd[EXT_CSD_RPMB_MULT];
+               #if 0 //noted by xbw,2014-03-11
                if (ext_csd[EXT_CSD_RPMB_MULT] && mmc_host_cmd23(card->host)) {
                        mmc_part_add(card, ext_csd[EXT_CSD_RPMB_MULT] << 17,
                                EXT_CSD_PART_CONFIG_ACC_RPMB,
                                "rpmb", 0, false,
                                MMC_BLK_DATA_AREA_RPMB);
                }
+               #endif
        }
 
        card->ext_csd.raw_erased_mem_count = ext_csd[EXT_CSD_ERASED_MEM_CONT];
index eac2a1f74b9918e931357d68da858437cd4133d7..12caf5db93e9b915ef8b4c9933322ac27b41aa42 100755 (executable)
@@ -1056,6 +1056,14 @@ static int dw_mci_get_cd(struct mmc_host *mmc)
        struct dw_mci_board *brd = slot->host->pdata;
        struct dw_mci *host = slot->host;
        int gpio_cd = mmc_gpio_get_cd(mmc);
+       
+    if (mmc->cardtype_restrict & RESTRICT_CARD_TYPE_SDIO){
+        spin_lock_bh(&host->lock);
+        set_bit(DW_MMC_CARD_PRESENT, &slot->flags);
+        spin_unlock_bh(&host->lock);
+        
+        return 1;
+    }
 
        /* Use platform get_cd function, else try onboard card detect */
        if (brd->quirks & DW_MCI_QUIRK_BROKEN_CARD_DETECTION)
@@ -1458,13 +1466,11 @@ static void dw_mci_tasklet_func(unsigned long priv)
             
                        dw_mci_request_end(host, host->mrq);
                        goto unlock;
-            printk("%d..%s: ===test===\n", __LINE__, __FUNCTION__); 
 
                case STATE_DATA_ERROR:
                        if (!test_and_clear_bit(EVENT_XFER_COMPLETE,
                                                &host->pending_events))
                                break;
-            printk("%d..%s: ===test===\n", __LINE__, __FUNCTION__); 
 
                        state = STATE_DATA_BUSY;
                        break;
@@ -2289,6 +2295,14 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id)
         printk("%d..%s: fmin=%d, fmax=%d \n", __LINE__,__FUNCTION__,mmc->f_min, mmc->f_max);    
        }
 #endif
+
+       if (of_find_property(host->dev->of_node, "supports-sd", NULL))
+               mmc->cardtype_restrict |= RESTRICT_CARD_TYPE_SD;        
+       if (of_find_property(host->dev->of_node, "supports-sdio", NULL))
+               mmc->cardtype_restrict |= RESTRICT_CARD_TYPE_SDIO;      
+       if (of_find_property(host->dev->of_node, "supports-emmc", NULL))
+               mmc->cardtype_restrict |= RESTRICT_CARD_TYPE_EMMC;
+
        if (host->pdata->get_ocr)
                mmc->ocr_avail = host->pdata->get_ocr(id);
        else
@@ -2528,6 +2542,8 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host)
 
        if (of_find_property(np, "keep-power-in-suspend", NULL))
                pdata->pm_caps |= MMC_PM_KEEP_POWER;
+               
+
 
        if (of_find_property(np, "enable-sdio-wakeup", NULL))
                pdata->pm_caps |= MMC_PM_WAKE_SDIO_IRQ;
@@ -2543,6 +2559,8 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host)
 
        if (of_get_property(np, "cd-inverted", NULL))
                pdata->caps2 |= MMC_CAP2_CD_ACTIVE_HIGH;
+       if (of_get_property(np, "bootpart-no-access", NULL))
+               pdata->caps2 |= MMC_CAP2_BOOTPART_NOACC;        
 
        return pdata;
 }
index 47d016eeb046aefe8e8805e4e5a8357954205266..59f8afd0b8ce2024e93d966881a94e6623a6a469 100755 (executable)
@@ -196,10 +196,6 @@ struct mmc_supply {
        struct regulator *vqmmc;        /* Optional Vccq supply */
 };
 
-#define HOST_IS_EMMC(host)  (host->unused)
-#define SDMMC_SUPPORT_EMMC(host)    (host->rk_sdmmc_emmc_used)
-
-
 struct mmc_host {
        struct device           *parent;
        struct device           class_dev;
@@ -289,6 +285,11 @@ struct mmc_host {
 #define MMC_CAP2_SANITIZE      (1 << 15)               /* Support Sanitize */
 
        mmc_pm_flag_t           pm_caps;        /* supported pm features */
+       
+    u32        cardtype_restrict;      /*restrict the SDMMC controller to support card type;1--SD card; 2--sdio; 4--eMMC */
+#define RESTRICT_CARD_TYPE_SD  (1 << 0)        /*noted by XBW, Rockchip Co.Ld*/
+#define RESTRICT_CARD_TYPE_SDIO        (1 << 1)        
+#define RESTRICT_CARD_TYPE_EMMC        (1 << 2)        
 
 #ifdef CONFIG_MMC_CLKGATE
        int                     clk_requests;   /* internal reference counter */
@@ -310,8 +311,6 @@ struct mmc_host {
        unsigned int            max_blk_size;   /* maximum size of one mmc block */
        unsigned int            max_blk_count;  /* maximum number of blocks in one req */
        unsigned int            max_discard_to; /* max. discard timeout in ms */
-       unsigned short      rk_sdmmc_emmc_used; //rk29_sdmmc driver support emmc
-       int                 host_dev_id;
 
        /* private data */
        spinlock_t              lock;           /* lock for claim and bus ops */
index 8f0131f1231b70c5866b2550e9c3195ef759f091..50bcde3677ca19d19baf5da199fbcb73ab29df25 100755 (executable)
@@ -418,12 +418,4 @@ struct _mmc_csd {
 #define MMC_SWITCH_MODE_CLEAR_BITS     0x02    /* Clear bits which are 1 in value */
 #define MMC_SWITCH_MODE_WRITE_BYTE     0x03    /* Set target to value */
 
-#define FOD_FREQ              (300000)    //  in the identify stage, unit: hz,  max is 400Khz,                                      //  the least frequency is FREQ_HCLK_MAX/8
-#define SD_FPP_FREQ           (24000000)  //   normal sd freq,  25Mhz
-#define SDHC_FPP_FREQ         (49500000)  // SDHC in the highspeed. unit is hz,  max is 50Mhz.
-#define MMC_FPP_FREQ          (19000000)  // MMC freq, unit is hz,   max is 20MHz
-#define MMCHS_26_FPP_FREQ     (24500000)  //  highspeed mode support 26M  HS-MMC, unit is hz, max is 26Mhz,
-#define MMCHS_52_FPP_FREQ     (51500000)  //  highspeed support 52M HS-MMC,   unit is hz,   max is 52Mhz,
-
-
 #endif /* LINUX_MMC_MMC_H */
index 4433c76f4dab13a15e50af034a24c225aa050f2e..c14510e37c905ac372170734c5ebaa36cc1107bf 100755 (executable)
@@ -239,6 +239,7 @@ struct dw_mci_board {
        u32 caps;       /* Capabilities */
        u32 caps2;      /* More capabilities */
        u32 pm_caps;    /* PM capabilities */
+       u32 cardtype_restrict;  /*restrict the SDMMC controller to support card type;1--SD card; 2--sdio; 4--eMMC */
        /*
         * Override fifo depth. If 0, autodetect it from the FIFOTH register,
         * but note that this may not be reliable after a bootloader has used