Esempio n. 1
0
/*
 * Card detection callback from host.
 */
static void mmc_sd_detect(struct mmc_host *host)
{
	int err = 0;
#ifdef CONFIG_MMC_PARANOID_SD_INIT
        int retries = 5;
#endif
	DBG("[%s] s\n",__func__);

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

	/*
	 * Just check if our card has been removed.
	 */
#ifdef CONFIG_MMC_PARANOID_SD_INIT
	while(retries) {
		err = mmc_send_status(host->card, NULL);
		if (err) {
			retries--;
			udelay(5);
			continue;
		}
		break;
	}
	if (!retries) {
		printk(KERN_ERR "%s(%s): Unable to re-detect card (%d)\n",
		       __func__, mmc_hostname(host), err);
	}
#else
	err = mmc_send_status(host->card, NULL);
#endif
	mmc_release_host(host);

#ifdef CONFIG_MMC_UNSAFE_RESUME
	if (err || (host->card_attath_status == card_attach_status_change)) {
		host->card_attath_status = card_attach_status_unchange;
		mmc_sd_remove(host);
		mmc_claim_host(host);
		mmc_detach_bus(host);
		mmc_release_host(host);
	}
#else
	if (err) {
		mmc_sd_remove(host);

		mmc_claim_host(host);
		mmc_detach_bus(host);
		mmc_release_host(host);
	}
#endif

	DBG("[%s] e\n",__func__);
}
Esempio n. 2
0
/*
 * Resume callback from host.
 *
 * This function tries to determine if the same card is still present
 * and, if so, restore all state to it.
 */
static void mmc_sd_resume(struct mmc_host *host)
{
	int err = 0;
#ifdef CONFIG_MMC_PARANOID_SD_INIT
	int retries;
#endif

	BUG_ON(!host);
#ifndef CONFIG_ARCH_EMXX
	BUG_ON(!host->card);
#endif

	mmc_claim_host(host);
#ifdef CONFIG_ARCH_EMXX
	if (host->card[0]) {
		err = mmc_sd_init_card(host, host->ocr, host->card[0]);
		if (err) {
			mmc_sd_remove(host);
			mmc_detach_bus(host);
		}
	}
#else

#ifdef CONFIG_MMC_PARANOID_SD_INIT
	retries = 5;
	while (retries) {
		err = mmc_sd_init_card(host, host->ocr, host->card);

		if (err) {
			printk(KERN_ERR "%s: Re-init card rc = %d (retries = %d)\n",
			       mmc_hostname(host), err, retries);
			mdelay(5);
			retries--;
			continue;
		}
		break;
	}
#else
	err = mmc_sd_init_card(host, host->ocr, host->card);
#endif
#endif
	mmc_release_host(host);

#ifndef CONFIG_ARCH_EMXX
	if (err) {
		mmc_sd_remove(host);

		mmc_claim_host(host);
		mmc_detach_bus(host);
		mmc_release_host(host);
	}
#endif

}
Esempio n. 3
0
/*
 * Card detection callback from host.
 */
static void mmc_sd_detect(struct mmc_host *host)
{
	int err = 0;
#ifdef CONFIG_MMC_PARANOID_SD_INIT
        int retries = 5;
#endif

	BUG_ON(!host);
#ifdef CONFIG_ARCH_EMXX
	BUG_ON(!host->card[0]);
#else
	BUG_ON(!host->card);
#endif
       
	mmc_claim_host(host);

	/*
	 * Just check if our card has been removed.
	 */
#ifdef CONFIG_MMC_PARANOID_SD_INIT
	while(retries) {
#ifdef CONFIG_ARCH_EMXX
		err = mmc_send_status(host->card[0], NULL);
#else
		err = mmc_send_status(host->card, NULL);
#endif
		if (err) {
			retries--;
			udelay(5);
			continue;
		}
		break;
	}
	if (!retries) {
		printk(KERN_ERR "%s(%s): Unable to re-detect card (%d)\n",
		       __func__, mmc_hostname(host), err);
	}
#else
#ifdef CONFIG_ARCH_EMXX
	err = mmc_send_status(host->card[0], NULL);
#else
	err = mmc_send_status(host->card, NULL);
#endif
#endif
	mmc_release_host(host);

	if (err) {
		mmc_sd_remove(host);

		mmc_claim_host(host);
		mmc_detach_bus(host);
		mmc_release_host(host);
	}
}
Esempio n. 4
0
/*
 * When "deferred resume" fails, run another thread to stop mmcqd.
 */
static int mmc_sd_removal_thread(void *d)
{
	struct mmc_host *host = d;

	mmc_sd_remove(host);

	mmc_claim_host(host);
	mmc_detach_bus(host);
	mmc_release_host(host);

	return 0;
}
Esempio n. 5
0
static void mmc_sd_err_with_deferred_resume(struct mmc_host *host)
{
	if (mmc_bus_start_resume(host)) {
		host->bus_resume_flags |= MMC_BUSRESUME_FAILS_RESUME;
		kthread_run(mmc_sd_removal_thread, host, "mmcrd");
	} else {
		mmc_sd_remove(host);

		mmc_claim_host(host);
		mmc_detach_bus(host);
		mmc_release_host(host);
	}
}
Esempio n. 6
0
/*
 * Card detection callback from host.
 */
static int mmc_sd_detect(struct mmc_host *host)
{
	int err = 0;
#ifdef CONFIG_MMC_PARANOID_SD_INIT
        int retries = 5;
#endif

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

	/*
	 * Just check if our card has been removed.
	 */
#ifdef CONFIG_MMC_PARANOID_SD_INIT
	if(gpio_get_value(SD_CARD_DETECT) == 1)
	{
		MMC_printk("%s: sd skip re-detect card", mmc_hostname(host));
		err = 1;
	}
	else
	{
		while(retries) {
			err = mmc_send_status(host->card, NULL);
			if (err) {
				retries--;
				udelay(5);
				continue;
			}
			break;
		}
		if (!retries) {
			printk(KERN_ERR "%s(%s): Unable to re-detect card (%d)\n",
			       __func__, mmc_hostname(host), err);
		}
	}
#else
	err = mmc_send_status(host->card, NULL);
#endif
	mmc_release_host(host);

	if (err) {
		mmc_sd_remove(host);

		mmc_claim_host(host);
		mmc_detach_bus(host);
		mmc_release_host(host);
	}
	return err;
}
Esempio n. 7
0
/*
 * Resume callback from host.
 *
 * This function tries to determine if the same card is still present
 * and, if so, restore all state to it.
 */
static void mmc_sd_resume(struct mmc_host *host)
{
	int err;
#ifdef CONFIG_MMC_PARANOID_SD_INIT
	int retries;
#endif

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

	mmc_claim_host(host);
#ifdef CONFIG_MMC_PARANOID_SD_INIT
	retries = 5;
	while (retries) {
		err = mmc_sd_init_card(host, host->ocr, host->card);

		if (err) {
			printk(KERN_ERR "%s: Re-init card rc = %d (retries = %d)\n",
			       mmc_hostname(host), err, retries);
			mmc_power_off(host);
			mdelay(5);
			mmc_power_up(host);
			retries--;
			continue;
		}
		break;
	}
#else
	err = mmc_sd_init_card(host, host->ocr, host->card);
#endif
	mmc_release_host(host);

#ifdef CONFIG_MMC_BLOCK_DEFERRED_RESUME
	if (err)
		mmc_sd_err_with_deferred_resume(host);
#else
	if (err) {
		mmc_sd_remove(host);

		mmc_claim_host(host);
		mmc_detach_bus(host);
		mmc_release_host(host);
	}
#endif

}
Esempio n. 8
0
/*
 * Card detection callback from host.
 */
static void mmc_sd_detect(struct mmc_host *host)
{
	int err = 0;
#ifdef CONFIG_MMC_PARANOID_SD_INIT
        int retries = 5;
#endif

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

	if (host->card->err_count >= ERR_TRIGGER_REINIT)
		err = mmc_sd_init_card(host, host->ocr, host->card);
	/*
	 * Just check if our card has been removed.
	 */
#ifdef CONFIG_MMC_PARANOID_SD_INIT
	while(retries) {
		err = mmc_send_status(host->card, NULL);
		if (err) {
			retries--;
			udelay(5);
			continue;
		}
		break;
	}
	if (!retries) {
		printk(KERN_ERR "%s(%s): Unable to re-detect card (%d)\n",
		       __func__, mmc_hostname(host), err);
	}
#else
	if (!err)
		err = mmc_send_status(host->card, NULL);
#endif
	mmc_release_host(host);

	if (err) {
		mmc_sd_remove(host);

		mmc_claim_host(host);
		mmc_detach_bus(host);
		mmc_release_host(host);
	}
}
Esempio n. 9
0
/*
 * Card detection callback from host.
 */
static void mmc_sd_detect(struct mmc_host *host)
{
	int err = 0;
#ifdef CONFIG_MMC_PARANOID_SD_INIT
        int retries = 5;
#endif

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

	/*
	 * Just check if our card has been removed.
	 */
#ifdef CONFIG_MMC_PARANOID_SD_INIT
	while(retries) {
		err = mmc_send_status(host->card, NULL);
		if (err) {
			retries--;
			udelay(5);
			continue;
		}
		break;
	}
	if (!retries) {
		printk(KERN_ERR "%s(%s): Unable to re-detect card (%d)\n",
		       __func__, mmc_hostname(host), err);
	}
#else
	err = mmc_send_status(host->card, NULL);
#endif
	mmc_release_host(host);

	/* On Gen7, there is no error returned when the card is not inserted,
		so we also need to check the GPIO to know if the card is here
		or not. (FIXME : Find why there is no error instead) */
	if (err || (host->ops->get_cd && host->ops->get_cd(host) == 0)) {
		mmc_sd_remove(host);

		mmc_claim_host(host);
		mmc_detach_bus(host);
		mmc_release_host(host);
	}
}
Esempio n. 10
0
/*
 * Card detection callback from host.
 */
static void mmc_sd_detect(struct mmc_host *host)
{
	int err;

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

	mmc_claim_host(host);

	/*
	 * Just check if our card has been removed.
	 */
	err = mmc_send_status(host->card, NULL);

	mmc_release_host(host);

	if (err) {
		mmc_sd_remove(host);

		mmc_claim_host(host);
		mmc_detach_bus(host);
		mmc_release_host(host);
	}
}