Example #1
0
/*
 * Suspend callback from host.
 */
static int mmc_suspend(struct mmc_host *host)
{
	int err = 0;

	BUG_ON(!host);
	BUG_ON(!host->card);

	mmc_claim_host(host);
	if (host->card->cid.manfid == 0x15) {
		if (!mmc_host_is_spi(host))
			mmc_deselect_cards(host);
	} else {
		/* for successful resuming for iNAND (manfid:0x45) */
		if(!strcmp(mmc_hostname(host),"mmc0") && host->card->cid.manfid == 0x45)
			mmc_switch(host->card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BUS_WIDTH, EXT_CSD_BUS_WIDTH_1, 0);

		if (mmc_card_can_sleep(host))
			err = mmc_card_sleep(host);
		else if (!mmc_host_is_spi(host))
			mmc_deselect_cards(host);
	}
	host->card->state &= ~MMC_STATE_HIGHSPEED;
	mmc_release_host(host);

	return err;
}
Example #2
0
/*
 * Suspend callback from host.
 */
static int mmc_suspend(struct mmc_host *host)
{
#if 1 // fixed high sleep current
	BUG_ON(!host);
	BUG_ON(!host->card);

	mmc_claim_host(host);
	if (!mmc_host_is_spi(host))
		mmc_deselect_cards(host);
	host->card->state &= ~MMC_STATE_HIGHSPEED;
	mmc_release_host(host);

	return 0;
#else
	int err = 0;

	BUG_ON(!host);
	BUG_ON(!host->card);

	mmc_claim_host(host);
	if (mmc_card_can_sleep(host))
		err = mmc_card_sleep(host);
	else if (!mmc_host_is_spi(host))
		mmc_deselect_cards(host);
	host->card->state &= ~MMC_STATE_HIGHSPEED;
	mmc_release_host(host);

	return err;
#endif
}
Example #3
0
/*
 * Suspend callback from host.
 */
static int mmc_suspend(struct mmc_host *host)
{
// 20110922 [email protected] SAMSUNG EMMC sleep current
#if 1
    BUG_ON(!host);
	BUG_ON(!host->card);
	
	mmc_claim_host(host);
	if (!mmc_host_is_spi(host))
		mmc_deselect_cards(host);
	host->card->state &= ~MMC_STATE_HIGHSPEED;
	mmc_release_host(host);
	
	return 0;
#else
	int err = 0;

	BUG_ON(!host);
	BUG_ON(!host->card);

	mmc_claim_host(host);
	if (mmc_card_can_sleep(host))
		err = mmc_card_sleep(host);
	else if (!mmc_host_is_spi(host))
		mmc_deselect_cards(host);
	host->card->state &= ~MMC_STATE_HIGHSPEED;
	mmc_release_host(host);

	return err;
#endif
}
Example #4
0
/*
 * Suspend callback from host.
 */
static int mmc_suspend(struct mmc_host *host)
{
	int err = 0;

	BUG_ON(!host);
	BUG_ON(!host->card);
	
	//pr_info("%s: @%s", mmc_hostname(host), __func__);//add by yansen 20120607 for mmc0: CMD5: Request timeout

	mmc_claim_host(host);

//modify by yansen 20120605 
//三星的MCP遇到过CMD5不响应或者mmc0: CMD5: Request timeout。
//去除sle_awake指令CMD5,由MCP自身进出POW_SAVE模式	
#ifndef CONFIG_OPPO_MODIFY 
	if (mmc_card_can_sleep(host))
		err = mmc_card_sleep(host);
	else if (!mmc_host_is_spi(host))
#else
	if (!mmc_host_is_spi(host))
#endif
		mmc_deselect_cards(host);
	host->card->state &= ~MMC_STATE_HIGHSPEED;
	mmc_release_host(host);

	return err;
}
Example #5
0
/*
 * Suspend callback from host.
 */
static int mmc_suspend(struct mmc_host *host)
{
	int err = 0;
#ifdef CONFIG_HUAWEI_KERNEL
    struct mmc_cid card_cid;
#endif
	BUG_ON(!host);
	BUG_ON(!host->card);

	mmc_claim_host(host);
    /* we set the bus width to 1 bit of sandisk EMMC before suspend
     * this is a workaroud method to avoid CMD2 CRC errors
     * when be waken up from suspend, and this code 
     * should be changed after confirmed with sandisk.
     */
#ifdef CONFIG_HUAWEI_KERNEL
    card_cid=host->card->cid;
	if(HUAWEI_SANDISK_MID==card_cid.manfid)
	{
		printk("Setting the bus width to 1 bit before sleep \n");
		mmc_switch(host->card, EXT_CSD_CMD_SET_NORMAL,
			EXT_CSD_BUS_WIDTH, EXT_CSD_BUS_WIDTH_1);
	}
#endif
	if (mmc_card_can_sleep(host))
		err = mmc_card_sleep(host);
	else if (!mmc_host_is_spi(host))
		mmc_deselect_cards(host);
	host->card->state &= ~MMC_STATE_HIGHSPEED;
	mmc_release_host(host);

	return err;
}
Example #6
0
/*
 * Suspend callback from host.
 */
static int mmc_suspend(struct mmc_host *host)
{
	int err = 0;
	BUG_ON(!host);
	BUG_ON(!host->card);
	if (mmc_card_can_sleep(host))
	err = mmc_card_sleep(host);
	else if (!mmc_host_is_spi(host))
	mmc_deselect_cards(host);
	host->card->state &= ~MMC_STATE_HIGHSPEED;
	
	return err;
}
Example #7
0
/*
 * Suspend callback from host.
 */
static int mmc_suspend(struct mmc_host *host)
{
	int err;

	BUG_ON(!host);
	BUG_ON(!host->card);

	mmc_claim_host(host);
	if (mmc_card_can_sleep(host)) {
		err = mmc_card_sleep(host);
		if (!err)
			mmc_card_set_sleep(host->card);
	} else if (!mmc_host_is_spi(host))
		mmc_deselect_cards(host);
	host->card->state &= ~(MMC_STATE_HIGHSPEED | MMC_STATE_HIGHSPEED_200);
	mmc_release_host(host);

	return 0;
}
/*
 * Suspend callback from host.
 */
static int mmc_suspend(struct mmc_host *host)
{
	int err = 0;

	BUG_ON(!host);
	BUG_ON(!host->card);

	mmc_claim_host(host);
	if (host->bkops_started) {
		host->bkops_trigger = 0;
	} else {
		if (mmc_card_can_sleep(host))
			err = mmc_card_sleep(host);
		else if (!mmc_host_is_spi(host))
			mmc_deselect_cards(host);
		host->card->state &= ~MMC_STATE_HIGHSPEED;
	}
	mmc_release_host(host);

	return err;
}
/* Handler for [DISABLED -> REGSLEEP / CARDSLEEP] transition */
static int omap_hsmmc_disabled_to_sleep(struct omap_hsmmc_host *host)
{
	int err, new_state;

	if (!mmc_try_claim_host(host->mmc))
		return 0;

	clk_enable(host->fclk);
	omap_hsmmc_context_restore(host);
	if (mmc_card_can_sleep(host->mmc)) {
		err = mmc_card_sleep(host->mmc);
		if (err < 0) {
			clk_disable(host->fclk);
			mmc_release_host(host->mmc);
			return err;
		}
		new_state = CARDSLEEP;
	} else {
		new_state = REGSLEEP;
	}
	if (mmc_slot(host).set_sleep)
		mmc_slot(host).set_sleep(host->dev, host->slot_id, 1, 0,
					 new_state == CARDSLEEP);
	/* FIXME: turn off bus power and perhaps interrupts too */
	clk_disable(host->fclk);
	host->dpm_state = new_state;

	mmc_release_host(host->mmc);

	dev_dbg(mmc_dev(host->mmc), "DISABLED -> %s\n",
		host->dpm_state == CARDSLEEP ? "CARDSLEEP" : "REGSLEEP");

	if ((host->mmc->caps & MMC_CAP_NONREMOVABLE) ||
	    mmc_slot(host).card_detect ||
	    (mmc_slot(host).get_cover_state &&
	     mmc_slot(host).get_cover_state(host->dev, host->slot_id)))
		return msecs_to_jiffies(OMAP_MMC_OFF_TIMEOUT);

	return 0;
}
/* Handler for [SLEEP -> ENABLED] transition */
static int omap_hsmmc_sleep_to_enabled(struct omap_hsmmc_host *host)
{
	if (!mmc_try_claim_host(host->mmc))
		return 0;

	clk_enable(host->fclk);
	omap_hsmmc_context_restore(host);
	if (mmc_slot(host).set_sleep)
		mmc_slot(host).set_sleep(host->dev, host->slot_id, 0,
			 host->vdd, host->dpm_state == CARDSLEEP);
	if (mmc_card_can_sleep(host->mmc))
		mmc_card_awake(host->mmc);

	dev_dbg(mmc_dev(host->mmc), "%s -> ENABLED\n",
		host->dpm_state == CARDSLEEP ? "CARDSLEEP" : "REGSLEEP");

	host->dpm_state = ENABLED;

	mmc_release_host(host->mmc);

	return 0;
}
Example #11
0
/*
 * Suspend callback from host.
 */
static int mmc_suspend(struct mmc_host *host)
{
	int err = 0;

	BUG_ON(!host);
	BUG_ON(!host->card);

	mmc_claim_host(host);
	if (host->card->cid.manfid == 0x15) {
		if (!mmc_host_is_spi(host))
			mmc_deselect_cards(host);
	} else {
		if (mmc_card_can_sleep(host))
			err = mmc_card_sleep(host);
		else if (!mmc_host_is_spi(host))
			mmc_deselect_cards(host);
	}
	host->card->state &= ~MMC_STATE_HIGHSPEED;
	mmc_release_host(host);

	return err;
}
/* Routine to resume the MMC device */
static int omap_mmc_resume(struct platform_device *pdev)
{
	int ret = 0;
	struct mmc_omap_host *host = platform_get_drvdata(pdev);

	if (host && !host->suspended){

		if (host->card_sleep){/*mmc is sleeping but mmc regulator  power on*/

			if (mmc_card_can_sleep(host->mmc))
				mmc_card_awake(host->mmc);

			host->card_sleep = 0;
		}
		return 0;
	}

	if (host) {

		if (host->card_sleep){
			host->card_sleep = 0;
		}

		if (host->pdata->resume) {
			ret = host->pdata->resume(&pdev->dev, host->slot_id);
			if (ret)
				dev_dbg(mmc_dev(host->mmc),
					"Unmask interrupt failed\n");
		}

		/* Notify the core to resume the host */
		ret = mmc_resume_host(host->mmc);
		if (ret == 0)
			host->suspended = 0;
	}

	return ret;
}
Example #13
0
/*
 * Suspend callback from host.
 */
static int mmc_suspend(struct mmc_host *host)
{
	int err = 0;

	BUG_ON(!host);
	BUG_ON(!host->card);

	mmc_claim_host(host);

//Begin Eric9_Luo@pegatron [20120409] Prevent eMMC suspend
#if 0
	if (mmc_card_can_sleep(host))
		err = mmc_card_sleep(host);
	else
#endif
//End Eric9_Luo@pegatron [20120409] Prevent eMMC suspend
	if (!mmc_host_is_spi(host))
		mmc_deselect_cards(host);
	host->card->state &= ~MMC_STATE_HIGHSPEED;
	mmc_release_host(host);

	return err;
}
static int omap_mmc_suspend(struct platform_device *pdev, pm_message_t state)
{
	int ret = 0;
	int err = 0;
	struct mmc_omap_host *host = platform_get_drvdata(pdev);

	if (host && host->suspended)
		return 0;

	if (host) {
		host->suspended = 1;

		if (host->card_sleep){
			dev_dbg(mmc_dev(host->mmc),"has been in sleep status\n");
		}
		else if (mmc_card_can_sleep(host->mmc)){
			err = mmc_card_sleep(host->mmc);

			if (err){
				dev_dbg(mmc_dev(host->mmc),"MMC sleep command CMD5 return error\n");
			}
			else{
				host->card_sleep = 1;
			}
		}

		if (host->pdata->suspend) {
			ret = host->pdata->suspend(&pdev->dev,
						host->slot_id);
			if (ret) {
				dev_dbg(mmc_dev(host->mmc),
					"Unable to handle MMC board"
					" level suspend\n");
				host->suspended = 0;
				return ret;
			}
		}
		cancel_work_sync(&host->mmc_carddetect_work);

		ret = mmc_suspend_host(host->mmc, state);
		if (ret == 0) {
			omap_hsmmc_enable_clks(host);

			OMAP_HSMMC_WRITE(host->base, ISE, 0);
			OMAP_HSMMC_WRITE(host->base, IE, 0);

			if (host->id == OMAP_MMC1_DEVID
					&& !(OMAP_HSMMC_READ(host->base, HCTL)
							& SDVSDET)) {
				OMAP_HSMMC_WRITE(host->base, HCTL,
					OMAP_HSMMC_READ(host->base, HCTL)
					& SDVSCLR);
				OMAP_HSMMC_WRITE(host->base, HCTL,
					OMAP_HSMMC_READ(host->base, HCTL)
					| SDVS30);
				OMAP_HSMMC_WRITE(host->base, HCTL,
					OMAP_HSMMC_READ(host->base, HCTL)
					| SDBP);
			}

			omap_hsmmc_disable_clks(host);
		} else {
			host->suspended = 0;
			if (host->pdata->resume) {
				ret = host->pdata->resume(&pdev->dev,
					host->slot_id);
				if (ret)
					dev_dbg(mmc_dev(host->mmc),
						"Unmask interrupt failed\n");
			}
		}

	}
	return ret;
}