From 7dcb2b4f0aa4a265ded7c830e692fcdb65ca48da Mon Sep 17 00:00:00 2001 From: xbw Date: Tue, 11 Mar 2014 10:01:46 +0800 Subject: [PATCH] 1.to support eMMC. 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 | 6 +++++- block/partitions/Makefile | 3 +++ block/partitions/check.c | 6 ++++++ drivers/mmc/card/block.c | 0 drivers/mmc/core/mmc.c | 7 ++----- drivers/mmc/host/rk_sdmmc.c | 22 ++++++++++++++++++++-- include/linux/mmc/host.h | 11 +++++------ include/linux/mmc/mmc.h | 8 -------- include/linux/mmc/rk_mmc.h | 1 + 9 files changed, 42 insertions(+), 22 deletions(-) mode change 100644 => 100755 block/partitions/check.c mode change 100644 => 100755 drivers/mmc/card/block.c diff --git a/arch/arm/boot/dts/rk3188-mmc.dtsi b/arch/arm/boot/dts/rk3188-mmc.dtsi index 795c12500a6e..7af74975f783 100755 --- a/arch/arm/boot/dts/rk3188-mmc.dtsi +++ b/arch/arm/boot/dts/rk3188-mmc.dtsi @@ -32,6 +32,8 @@ num-slots = <1>; supports-highspeed; + supports-emmc; + bootpart-no-access; fifo-depth = <0x80>; @@ -57,10 +59,11 @@ 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)>; diff --git a/block/partitions/Makefile b/block/partitions/Makefile index 03af8eac51da..1e5d63d1f01c 100644 --- a/block/partitions/Makefile +++ b/block/partitions/Makefile @@ -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 diff --git a/block/partitions/check.c b/block/partitions/check.c old mode 100644 new mode 100755 index 19ba207ea7d1..2b7baa061454 --- a/block/partitions/check.c +++ b/block/partitions/check.c @@ -19,6 +19,7 @@ #include #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 }; diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c old mode 100644 new mode 100755 diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 0241a61f32d6..1cccea4eca44 100755 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -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]; diff --git a/drivers/mmc/host/rk_sdmmc.c b/drivers/mmc/host/rk_sdmmc.c index eac2a1f74b99..12caf5db93e9 100755 --- a/drivers/mmc/host/rk_sdmmc.c +++ b/drivers/mmc/host/rk_sdmmc.c @@ -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; } diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 47d016eeb046..59f8afd0b8ce 100755 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -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 */ diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h index 8f0131f1231b..50bcde3677ca 100755 --- a/include/linux/mmc/mmc.h +++ b/include/linux/mmc/mmc.h @@ -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 */ diff --git a/include/linux/mmc/rk_mmc.h b/include/linux/mmc/rk_mmc.h index 4433c76f4dab..c14510e37c90 100755 --- a/include/linux/mmc/rk_mmc.h +++ b/include/linux/mmc/rk_mmc.h @@ -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 -- 2.34.1