Пример #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;
}
Пример #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
}
Пример #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
}
Пример #4
0
int mmc_card_sleepawake(struct mmc_host *host, int sleep)
{
	struct mmc_command cmd = {0};
	struct mmc_card *card = host->card;
	int err;

	if (sleep)
		mmc_deselect_cards(host);

	cmd.opcode = MMC_SLEEP_AWAKE;
	cmd.arg = card->rca << 16;
	if (sleep)
		cmd.arg |= 1 << 15;

	cmd.flags = MMC_RSP_R1B | MMC_CMD_AC;
	err = mmc_wait_for_cmd(host, &cmd, 0);
	if (err)
		return err;

	if (!(host->caps & MMC_CAP_WAIT_WHILE_BUSY))
		mmc_delay(DIV_ROUND_UP(card->ext_csd.sa_timeout, 10000));

	if (!sleep)
		err = mmc_select_card(card);

	return err;
}
Пример #5
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;
}
Пример #6
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;
}
Пример #7
0
int mmc_card_sleepawake(struct mmc_host *host, int sleep)
{
	struct mmc_command cmd = {0};
	struct mmc_card *card = host->card;
	int err;

	if (sleep)
		mmc_deselect_cards(host);

	cmd.opcode = MMC_SLEEP_AWAKE;
	cmd.arg = card->rca << 16;
	if (sleep)
		cmd.arg |= 1 << 15;

	cmd.flags = MMC_RSP_R1B | MMC_CMD_AC;
	err = mmc_wait_for_cmd(host, &cmd, 0);
	if (err)
		return err;

	/*
	 * If the host does not wait while the card signals busy, then we will
	 * will have to wait the sleep/awake timeout.  Note, we cannot use the
	 * SEND_STATUS command to poll the status because that command (and most
	 * others) is invalid while the card sleeps.
	 */
	if (!(host->caps & MMC_CAP_WAIT_WHILE_BUSY))
		mmc_delay(DIV_ROUND_UP(card->ext_csd.sa_timeout, 10000));

	if (!sleep)
		err = mmc_select_card(card);

	return err;
}
Пример #8
0
/*
 * Suspend callback from host.
 */
static void mmc_suspend(struct mmc_host *host)
{
	BUG_ON(!host);
	BUG_ON(!host->card);

	mmc_claim_host(host);
	mmc_deselect_cards(host);
	host->card->state &= ~MMC_STATE_HIGHSPEED;
	mmc_release_host(host);
}
Пример #9
0
/*
 * Suspend callback from host.
 */
static int mmc_sd_suspend(struct mmc_host *host)
{
    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;
}
Пример #10
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;
}
Пример #11
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;
}
Пример #12
0
int mmc_card_sleepawake(struct mmc_host *host, int sleep)
{
	struct mmc_command cmd = {0};
	struct mmc_card *card = host->card;
	int err;

	if (sleep)
		mmc_deselect_cards(host);

#ifdef CONFIG_HUAWEI_KERNEL
    /* Hynix eMMC not send CMD5 to avoid data partition read-only when sudden power off */
    if(EMMC_HYNIX_MID != card->cid.manfid)
    {
#endif    

    	cmd.opcode = MMC_SLEEP_AWAKE;
    	cmd.arg = card->rca << 16;
    	if (sleep)
    		cmd.arg |= 1 << 15;

    	cmd.flags = MMC_RSP_R1B | MMC_CMD_AC;
    	err = mmc_wait_for_cmd(host, &cmd, 0);
    	if (err)
    		return err;
#ifdef CONFIG_HUAWEI_KERNEL
    }
	else
	{
        printk("eMMC enter sleep mode without send CMD5!\r\n");
	}
#endif    
    


	/*
	 * If the host does not wait while the card signals busy, then we will
	 * will have to wait the sleep/awake timeout.  Note, we cannot use the
	 * SEND_STATUS command to poll the status because that command (and most
	 * others) is invalid while the card sleeps.
	 */
	if (!(host->caps & MMC_CAP_WAIT_WHILE_BUSY))
		mmc_delay(DIV_ROUND_UP(card->ext_csd.sa_timeout, 10000));

	if (!sleep)
		err = mmc_select_card(card);

	return err;
}
Пример #13
0
/*
 * Suspend callback from host.
 */
static int mmc_sd_suspend(struct mmc_host *host)
{
	BUG_ON(!host);
	BUG_ON(!host->card);

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

	return 0;
}
int mmc_card_sleepawake(struct mmc_host *host, int sleep)
{
	struct mmc_command cmd = {0};
	struct mmc_card *card = host->card;
	int err;
	unsigned long timeout;

	if (sleep)
		mmc_deselect_cards(host);

	cmd.opcode = MMC_SLEEP_AWAKE;
	cmd.arg = card->rca << 16;
	if (sleep)
		cmd.arg |= 1 << 15;

	cmd.flags = MMC_RSP_R1B | MMC_CMD_AC;
	err = mmc_wait_for_cmd(host, &cmd, 0);
	if (err)
		return err;

	/*
	 * If the host does not wait while the card signals busy, then we will
	 * will have to wait the sleep/awake timeout.  Note, we cannot use the
	 * SEND_STATUS command to poll the status because that command (and most
	 * others) is invalid while the card sleeps.
	 */
	if (!(host->caps & MMC_CAP_WAIT_WHILE_BUSY)) {
		/* longest waiting time in ms */
		timeout = DIV_ROUND_UP(card->ext_csd.sa_timeout, 10000);
		if (host->ops->mmc_poll_busy) {
			timeout = jiffies + msecs_to_jiffies(timeout);
			do {
				mmc_delay(1);
				if (!(host->ops->mmc_poll_busy)(host))
					break;
			} while(time_before(jiffies, timeout));
		}
		else
			mmc_delay(timeout);
	}

	if (!sleep)
		err = mmc_select_card(card);

	return err;
}
Пример #15
0
/*
 * Suspend callback from host.
 */
static int mmc_suspend(struct mmc_host *host)
{
	BUG_ON(!host);
	BUG_ON(!host->card);

	mmc_claim_host(host);
	if (!mmc_host_is_spi(host))	{
#if defined(CONFIG_PHONE_ARIES_CTC) // iNAND 24n Patch
		if (!strcmp(mmc_hostname(host), "mmc0"))
			mmc_switch(host->card, EXT_CSD_CMD_SET_NORMAL,
				EXT_CSD_BUS_WIDTH, EXT_CSD_BUS_WIDTH_1,0);
#endif
		mmc_deselect_cards(host);
	}
	host->card->state &= ~MMC_STATE_HIGHSPEED;
	mmc_release_host(host);

	return 0;
}
Пример #16
0
/*
 * Suspend callback from host.
 */
static void mmc_sd_suspend(struct mmc_host *host)
{
	BUG_ON(!host);
#ifdef CONFIG_ARCH_EMXX
	BUG_ON(!host->card[0]);
#else
	BUG_ON(!host->card);
#endif

	mmc_claim_host(host);
	if (!mmc_host_is_spi(host))
		mmc_deselect_cards(host);
#ifdef CONFIG_ARCH_EMXX
	host->card[0]->state &= ~MMC_STATE_HIGHSPEED;
#else
	host->card->state &= ~MMC_STATE_HIGHSPEED;
#endif
	mmc_release_host(host);
}
Пример #17
0
/*
 * Suspend callback from host.
 */
static int mmc_sd_suspend(struct mmc_host *host)
{
//20110922 [email protected] blocking SDcard re-init[Start]
#if 1
	return 0;
#else
	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;
#endif
//20110922 [email protected] blocking SDcard re-init[End]
}
Пример #18
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;
}
Пример #19
0
int mmc_card_sleepawake(struct mmc_host *host, int sleep)
{
	struct mmc_command cmd;
	struct mmc_card *card = host->card;
	int err;

	if (sleep)
		mmc_deselect_cards(host);

	memset(&cmd, 0, sizeof(struct mmc_command));

	cmd.opcode = MMC_SLEEP_AWAKE;
	cmd.arg = card->rca << 16;
	if (sleep)
		cmd.arg |= 1 << 15;

	cmd.flags = MMC_RSP_R1B | MMC_CMD_AC;
	err = mmc_wait_for_cmd(host, &cmd, 0);
	if (err)
		return err;

	/*
	 * If the host does not wait while the card signals busy, then we will
	 * will have to wait the sleep/awake timeout.  Note, we cannot use the
	 * SEND_STATUS command to poll the status because that command (and most
	 * others) is invalid while the card sleeps.
	 */
	if (!(host->caps & MMC_CAP_WAIT_WHILE_BUSY)) {
		/* JEDEC MMCA 4.41 specifies the timeout value is in 200ns..838.86ms
		   range. Round it up to 1us and use an appropriate delay method. */
		unsigned long us = DIV_ROUND_UP(card->ext_csd.sa_timeout, 10);
		if (us < 10)
			udelay(us);
		else
			usleep_range(us, us + 100);
	}
	if (!sleep)
		err = mmc_select_card(card);

	return err;
}
Пример #20
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;
}
Пример #21
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 (mmc_can_poweroff_notify(host->card))
		err = mmc_poweroff_notify(host, MMC_PW_OFF_NOTIFY_SHORT);
	else if (!mmc_host_is_spi(host))
		mmc_deselect_cards(host);

	if (!err)
		host->card->state &=
			~(MMC_STATE_HIGHSPEED | MMC_STATE_HIGHSPEED_200);

	mmc_release_host(host);

	return err;
}
Пример #22
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;
}