Exemple #1
0
void mmc_rescan(struct work_struct *work)
{
	struct mmc_host *host =
		container_of(work, struct mmc_host, detect.work);
	u32 ocr;
	int err;

	mmc_bus_get(host);

	/* if there is a card registered, check whether it is still present */
	if ((host->bus_ops != NULL) && host->bus_ops->detect && !host->bus_dead)
		host->bus_ops->detect(host);

	mmc_bus_put(host);


	mmc_bus_get(host);

	/* if there still is a card present, stop here */
	if (host->bus_ops != NULL) {
		mmc_bus_put(host);
		goto out;
	}

	/* detect a newly inserted card */

	/*
	 * Only we can add a new handler, so it's safe to
	 * release the lock here.
	 */
	mmc_bus_put(host);

	if (host->ops->get_cd && host->ops->get_cd(host) == 0)
		goto out;

	mmc_claim_host(host);

	mmc_power_up(host);
	mmc_go_idle(host);

	mmc_send_if_cond(host, host->ocr_avail);

	/*
	 * First we search for SDIO...
	 */
	err = mmc_send_io_op_cond(host, 0, &ocr);
	if (!err) {
		if (mmc_attach_sdio(host, ocr))
			mmc_power_off(host);
		goto out;
	}

	/*
	 * ...then normal SD...
	 */
	err = mmc_send_app_op_cond(host, 0, &ocr);
	if (!err) {
		if (mmc_attach_sd(host, ocr))
			mmc_power_off(host);
		goto out;
	}

	/*
	 * ...and finally MMC.
	 */
	err = mmc_send_op_cond(host, 0, &ocr);
	if (!err) {
		if (mmc_attach_mmc(host, ocr))
			mmc_power_off(host);
		goto out;
	}

	mmc_release_host(host);
	mmc_power_off(host);

out:
	if (host->caps & MMC_CAP_NEEDS_POLL)
		mmc_schedule_delayed_work(&host->detect, HZ);
}
Exemple #2
0
void mmc_rescan(struct work_struct *work)
{
	struct mmc_host *host =
		container_of(work, struct mmc_host, detect.work);
	u32 ocr;
	int err;
	int extend_wakelock = 0;

	mmc_bus_get(host);

	/* if there is a card registered, check whether it is still present */
	if ((host->bus_ops != NULL) && host->bus_ops->detect && !host->bus_dead) {
		if(host->ops->get_cd && host->ops->get_cd(host) == 0) {
			if(host->bus_ops->remove)
				host->bus_ops->remove(host);

			mmc_claim_host(host);
			mmc_detach_bus(host);
			mmc_release_host(host);
		}
		else
			host->bus_ops->detect(host);
	}

	/* If the card was removed the bus will be marked
	 * as dead - extend the wakelock so userspace
	 * can respond */
	if (host->bus_dead)
		extend_wakelock = 1;

	mmc_bus_put(host);


	mmc_bus_get(host);

	/* if there still is a card present, stop here */
	if (host->bus_ops != NULL) {
		mmc_bus_put(host);
		goto out;
	}

	/* detect a newly inserted card */

	/*
	 * Only we can add a new handler, so it's safe to
	 * release the lock here.
	 */
	mmc_bus_put(host);

	if (host->ops->get_cd && host->ops->get_cd(host) == 0)
		goto out;

	mmc_claim_host(host);

	mmc_power_up(host);
	mmc_go_idle(host);

	mmc_send_if_cond(host, host->ocr_avail);

	/*
	 * First we search for SDIO...
	 */
	printk(KERN_DEBUG "*** DEBUG : First we search for SDIO...(%d)***\n", host->index);
	err = mmc_send_io_op_cond(host, 0, &ocr);
	if (!err) {
		if (mmc_attach_sdio(host, ocr))
			mmc_power_off(host);
		extend_wakelock = 1;
		goto out;
	}

	/*
	 * ...then normal SD...
	 */
	printk(KERN_DEBUG "*** DEBUG : ...then normal SD...(%d) ***\n", host->index);
	err = mmc_send_app_op_cond(host, 0, &ocr);
	if (!err) {
		if (mmc_attach_sd(host, ocr))
			mmc_power_off(host);
		extend_wakelock = 1;
		goto out;
	}

	/*
	 * ...and finally MMC.
	 */
	printk(KERN_DEBUG "*** DEBUG : ...and finally MMC. (%d)***\n", host->index);
	err = mmc_send_op_cond(host, 0, &ocr);
	if (!err) {
		if (mmc_attach_mmc(host, ocr))
			mmc_power_off(host);
		extend_wakelock = 1;
		goto out;
	}

	mmc_release_host(host);
	mmc_power_off(host);

out:
	if (--wakelock_refs > 0) {
		pr_debug("%s: other host want the wakelock\n", mmc_hostname(host));
	}
	else {
#if defined(CONFIG_MMC_BLOCK_DEFERRED_RESUME) && defined(CONFIG_MACH_S5PC110_P1)
		wake_lock_timeout(&mmc_delayed_work_wake_lock, 3*HZ);
#else /* CONFIG_MMC_BLOCK_DEFERRED_RESUME && CONFIG_MACH_S5PC110_P1 */
		if (extend_wakelock)
			wake_lock_timeout(&mmc_delayed_work_wake_lock, HZ / 2);
		else
			wake_unlock(&mmc_delayed_work_wake_lock);
#endif /* CONFIG_MMC_BLOCK_DEFERRED_RESUME && CONFIG_MACH_S5PC110_P1 */
	}
	if (host->caps & MMC_CAP_NEEDS_POLL)
		mmc_schedule_delayed_work(&host->detect, HZ);
}
void mmc_rescan(struct work_struct *work)
{
	struct mmc_host *host =
		container_of(work, struct mmc_host, detect.work);
	u32 ocr;
	int err;

	mmc_bus_get(host);

	if (host->bus_ops == NULL) {
		/*
		 * Only we can add a new handler, so it's safe to
		 * release the lock here.
		 */
		mmc_bus_put(host);

		if (host->ops->get_cd && host->ops->get_cd(host) == 0)
			goto out;

		mmc_claim_host(host);

		mmc_power_up(host);
		mmc_go_idle(host);

		mmc_send_if_cond(host, host->ocr_avail);

		/*
		 * First we search for SDIO...
		 */
		err = mmc_send_io_op_cond(host, 0, &ocr);
		if (!err) {
			if (mmc_attach_sdio(host, ocr))
				mmc_power_off(host);
			goto out;
		}

		/*
		 * ...then normal SD...
		 */
		err = mmc_send_app_op_cond(host, 0, &ocr);
		if (!err) {
			if (mmc_attach_sd(host, ocr))
				mmc_power_off(host);
			goto out;
		}

		/*
		 * ...and finally MMC.
		 */
		err = mmc_send_op_cond(host, 0, &ocr);
		if (!err) {
			if (mmc_attach_mmc(host, ocr))
				mmc_power_off(host);
			goto out;
		}

		mmc_release_host(host);
		mmc_power_off(host);
	} else {
		if (host->bus_ops->detect && !host->bus_dead)
			host->bus_ops->detect(host);

		mmc_bus_put(host);
	}
out:
	/* give userspace some time to react */
	wake_lock_timeout(&mmc_delayed_work_wake_lock, HZ / 2);

	if (host->caps & MMC_CAP_NEEDS_POLL)
		mmc_schedule_delayed_work(&host->detect, HZ);
}
Exemple #4
0
void mmc_rescan(struct work_struct *work)
{
	struct mmc_host *host =
		container_of(work, struct mmc_host, detect.work);
	u32 ocr;
	int err;
	unsigned long flags;
	int extend_wakelock = 0;

	spin_lock_irqsave(&host->lock, flags);

	if (host->rescan_disable) {
		spin_unlock_irqrestore(&host->lock, flags);
		return;
	}

	spin_unlock_irqrestore(&host->lock, flags);


	mmc_bus_get(host);

	/* if there is a card registered, check whether it is still present */
	if ((host->bus_ops != NULL) && host->bus_ops->detect && !host->bus_dead) {
		if(host->ops->get_cd && host->ops->get_cd(host) == 0) {
			if(host->bus_ops->remove)
				host->bus_ops->remove(host);

			mmc_claim_host(host);
			mmc_detach_bus(host);
			mmc_release_host(host);
		}
		else
			host->bus_ops->detect(host);
	}

	/* If the card was removed the bus will be marked
	 * as dead - extend the wakelock so userspace
	 * can respond */
	if (host->bus_dead)
		extend_wakelock = 1;

	mmc_bus_put(host);


	mmc_bus_get(host);

	/* if there still is a card present, stop here */
	if (host->bus_ops != NULL) {
		mmc_bus_put(host);
		goto out;
	}

	/* detect a newly inserted card */

	/*
	 * Only we can add a new handler, so it's safe to
	 * release the lock here.
	 */
	mmc_bus_put(host);

	if (host->ops->get_cd && host->ops->get_cd(host) == 0)
		goto out;

	mmc_claim_host(host);

	mmc_power_up(host);
	sdio_reset(host);
	mmc_go_idle(host);

	mmc_send_if_cond(host, host->ocr_avail);

	/*
	 * First we search for SDIO...
	 */
	err = mmc_send_io_op_cond(host, 0, &ocr);
	if (!err) {
		if (mmc_attach_sdio(host, ocr))
			mmc_power_off(host);
		extend_wakelock = 1;
		goto out;
	}

	/*
	 * ...then normal SD...
	 */
	err = mmc_send_app_op_cond(host, 0, &ocr);
	if (!err) {
		if (mmc_attach_sd(host, ocr))
			mmc_power_off(host);
		extend_wakelock = 1;
		goto out;
	}

	/*
	 * ...and finally MMC.
	 */
	err = mmc_send_op_cond(host, 0, &ocr);
	if (!err) {
		if (mmc_attach_mmc(host, ocr))
			mmc_power_off(host);
		extend_wakelock = 1;
		goto out;
	}

	mmc_release_host(host);
	mmc_power_off(host);

out:
	if (extend_wakelock)
		wake_lock_timeout(&mmc_delayed_work_wake_lock, HZ / 2);
	else
		wake_unlock(&mmc_delayed_work_wake_lock);

	if (host->caps & MMC_CAP_NEEDS_POLL)
		mmc_schedule_delayed_work(&host->detect, HZ);
}
Exemple #5
0
void mmc_rescan(struct work_struct *work)
{
	struct mmc_host *host =
		container_of(work, struct mmc_host, detect.work);
	u32 ocr;
	int err = 0;
	int extend_wakelock = 0;
#ifdef CONFIG_MMC_PARANOID_SD_INIT
	int retries = 2;
#endif

	mmc_bus_get(host);

	/* if there is a card registered, check whether it is still present */
	if ((host->bus_ops != NULL) && host->bus_ops->detect && !host->bus_dead) {
		host->bus_ops->detect(host);

	/* If the card was removed the bus will be marked
	 * as dead - extend the wakelock so userspace
	 * can respond */
		if (host->bus_dead)
			extend_wakelock = 1;
	}
	mmc_bus_put(host);


	mmc_bus_get(host);

	/* if there still is a card present, stop here */
	if (host->bus_ops != NULL) {
		mmc_bus_put(host);
		goto out;
	}

	/* detect a newly inserted card */

	/*
	 * Only we can add a new handler, so it's safe to
	 * release the lock here.
	 */
	mmc_bus_put(host);

	if (host->ops->get_cd && host->ops->get_cd(host) == 0)
		goto out;
retry:
	mmc_claim_host(host);

	mmc_power_up(host);
	mmc_go_idle(host);

	mmc_send_if_cond(host, host->ocr_avail);

	/*
	 * First we search for SDIO...
	 */
	err = mmc_send_io_op_cond(host, 0, &ocr);
	if (!err) {
		if (mmc_attach_sdio(host, ocr))
			mmc_power_off(host);
		extend_wakelock = 1;
		goto out;
	}

	/*
	 * ...then normal SD...
	 */
	err = mmc_send_app_op_cond(host, 0, &ocr);
	if (!err) {
		if (mmc_attach_sd(host, ocr))
			mmc_power_off(host);
		extend_wakelock = 1;
		goto out;
	}

	/*
	 * ...and finally MMC.
	 */
	err = mmc_send_op_cond(host, 0, &ocr);
	if (!err) {
		if (mmc_attach_mmc(host, ocr))
			mmc_power_off(host);
		extend_wakelock = 1;
		goto out;
	}

	mmc_release_host(host);
	mmc_power_off(host);

out:
#ifdef CONFIG_MMC_PARANOID_SD_INIT
	if (err && (err != -ENOMEDIUM) && retries) {
		printk(KERN_INFO "%s: Re-scan card rc = %d (retries = %d)\n",
			mmc_hostname(host), err, retries);
		retries--;
		goto retry;
	}
#endif

	if (extend_wakelock)
		wake_lock_timeout(&host->wakelock, 5 * HZ);
	else
		wake_unlock(&host->wakelock);

	if (host->caps & MMC_CAP_NEEDS_POLL)
		mmc_schedule_delayed_work(&host->detect, HZ);
}
Exemple #6
0
void mmc_rescan(struct work_struct *work)
{
    struct mmc_host *host =
        container_of(work, struct mmc_host, detect.work);
    u32 ocr;
    int err;
    int extend_wakelock = 0;

    mmc_bus_get(host);

    if (host->ops->get_cd && host->ops->get_cd(host) == 0)
    {
        if (host->bus_ops && !host->bus_dead) {
            if (host->bus_ops->remove)
                host->bus_ops->remove(host);

            mmc_claim_host(host);
            mmc_detach_bus(host);
            mmc_release_host(host);
        }
        extend_wakelock = 1;
    }
    else
    {
        if ((host->bus_ops != NULL) &&
                host->bus_ops->detect && !host->bus_dead) {
            if (host->index == 1) {
                if (!q_wlan_flag)
                    host->bus_ops->detect(host);
                printk("[MMC]> host name %s, q_wlan_flag: %d\n", mmc_hostname(host), q_wlan_flag);
            } else {
                host->bus_ops->detect(host);
                printk("[MMC]> host name %s, q_wlan_flag: %d\n", mmc_hostname(host), q_wlan_flag);
            }
        }
        if (host->bus_dead)
            extend_wakelock = 1;

    }

#if 0
    /* if there is a card registered, check whether it is still present */
    if ((host->bus_ops != NULL) && host->bus_ops->detect && !host->bus_dead)
        host->bus_ops->detect(host);

    /* If the card was removed the bus will be marked
     * as dead - extend the wakelock so userspace
     * can respond */
    if (host->bus_dead)
        extend_wakelock = 1;
#endif

    mmc_bus_put(host);


    mmc_bus_get(host);

    /* if there still is a card present, stop here */
    if (host->bus_ops != NULL) {
        mmc_bus_put(host);
        goto out;
    }

    /* detect a newly inserted card */

    /*
     * Only we can add a new handler, so it's safe to
     * release the lock here.
     */
    mmc_bus_put(host);

    if (host->ops->get_cd && host->ops->get_cd(host) == 0)
        goto out;

    mmc_claim_host(host);

    mmc_power_up(host);
    mmc_go_idle(host);

    mmc_send_if_cond(host, host->ocr_avail);

    /*
     * First we search for SDIO...
     */
    err = mmc_send_io_op_cond(host, 0, &ocr);
    if (!err) {
        if (mmc_attach_sdio(host, ocr))
            mmc_power_off(host);
        extend_wakelock = 1;
        goto out;
    }

    /*
     * ...then normal SD...
     */
    err = mmc_send_app_op_cond(host, 0, &ocr);
    if (!err) {
        if (mmc_attach_sd(host, ocr))
            mmc_power_off(host);
        extend_wakelock = 1;
        goto out;
    }

    /*
     * ...and finally MMC.
     */
    err = mmc_send_op_cond(host, 0, &ocr);
    if (!err) {
        if (mmc_attach_mmc(host, ocr))
            mmc_power_off(host);
        extend_wakelock = 1;
        goto out;
    }

    mmc_release_host(host);
    mmc_power_off(host);

out:
    if (extend_wakelock)
        wake_lock_timeout(&mmc_delayed_work_wake_lock, HZ / 2);
    else
        wake_unlock(&mmc_delayed_work_wake_lock);

    if (host->caps & MMC_CAP_NEEDS_POLL)
        mmc_schedule_delayed_work(&host->detect, HZ);

    if (host->ops->notify_card_present)
    {
        if (host->card)
        {
            host->ops->notify_card_present(host, mmc_card_present(host->card));
        }
        else
        {
            host->ops->notify_card_present(host, 0);
        }
    }

    if (host->ops->enable_cd_irq)
    {
        host->ops->enable_cd_irq(host);
    }
}
Exemple #7
0
void mmc_rescan(struct work_struct *work)
{
	struct mmc_host *host =
		container_of(work, struct mmc_host, detect.work);
	u32 ocr;
	int err;
	int extend_wakelock = 0;
	
	mmc_bus_get(host);

	/* if there is a card registered, check whether it is still present */
	if ((host->bus_ops != NULL) && host->bus_ops->detect && !host->bus_dead) {
		if(host->ops->get_cd && host->ops->get_cd(host) == 0) {
			if(host->bus_ops->remove)
				host->bus_ops->remove(host);

			mmc_claim_host(host);
			mmc_detach_bus(host);
			mmc_release_host(host);
		}
		else
			host->bus_ops->detect(host);
	}

	/* If the card was removed the bus will be marked
	 * as dead - extend the wakelock so userspace
	 * can respond */
	if (host->bus_dead)
		extend_wakelock = 1;

	mmc_bus_put(host);

	mmc_bus_get(host);

	/* if there still is a card present, stop here */
	if (host->bus_ops != NULL) {
		mmc_bus_put(host);
		goto out;
	}

	/* detect a newly inserted card */

	/*
	 * Only we can add a new handler, so it's safe to
	 * release the lock here.
	 */
	mmc_bus_put(host);

	if (host->ops->get_cd && host->ops->get_cd(host) == 0)
		goto out;

	mmc_claim_host(host);

	mmc_power_up(host);
	mmc_go_idle(host);

	mmc_send_if_cond(host, host->ocr_avail);

	/*
	 * First we search for SDIO...
	 */
	printk(KERN_DEBUG "*** DEBUG : First we search for SDIO...(%d)***\n", host->index);
	err = mmc_send_io_op_cond(host, 0, &ocr);
	if (!err) {
		if (mmc_attach_sdio(host, ocr))
			mmc_power_off(host);
		extend_wakelock = 1;
		goto out;
	}

	/*
	 * ...then normal SD...
	 */
	printk(KERN_DEBUG "*** DEBUG : ...then normal SD...(%d) ***\n", host->index);
	err = mmc_send_app_op_cond(host, 0, &ocr);
	if (!err) {
		if (mmc_attach_sd(host, ocr))
			mmc_power_off(host);
		extend_wakelock = 1;
		goto out;
	}

	/*
	 * ...and finally MMC.
	 */
	printk(KERN_DEBUG "*** DEBUG : ...and finally MMC. (%d)***\n", host->index);
	err = mmc_send_op_cond(host, 0, &ocr);
	if (!err) {
		if (mmc_attach_mmc(host, ocr))
			mmc_power_off(host);
		extend_wakelock = 1;
		goto out;
	}

	mmc_release_host(host);
	mmc_power_off(host);

out:
#if 0
	//if (extend_wakelock)
	//	wake_lock_timeout(&mmc_delayed_work_wake_lock, HZ / 2);
	//else
	//	wake_unlock(&mmc_delayed_work_wake_lock);
#else
	if (atomic_dec_return(&wakelock_refs) > 0) {
		printk(KERN_DEBUG "Another host want the wakelock : %d\n", atomic_read(&wakelock_refs));
	}
	else {
		printk(KERN_DEBUG "mmc%d: wake_lock_timeout 1sec %d\n", host->index, atomic_read(&wakelock_refs));
		wake_lock_timeout(&mmc_delayed_work_wake_lock, msecs_to_jiffies(1000));
	}
#endif

	if (host->caps & MMC_CAP_NEEDS_POLL)
		mmc_schedule_delayed_work(&host->detect, HZ);
}
Exemple #8
0
void mmc_rescan(struct work_struct *work)
{
	struct mmc_host *host =
		container_of(work, struct mmc_host, detect.work);
	u32 ocr;
	int err;

#ifdef CONFIG_MIPS_BCM_NDVD
	{
		extern void brcm_sdio_clr_seq_en(void);
		/*
		 * this addresses JIRA HWGRAIN-84 : sequential accesses merge disable.
		 * when using merging of sequential accesses on the SCB bus, transfer
		 * complete interrupts assert the cpu before data is actually present
		 * in the DMA buffers. this, because a bug in the A2S bridge. when 
		 * merging is disabled, data is written to the DMA buffers 
		 * immediatelly, i.e. synchronized with interrupt assertion.
		 * this bug affects commands with data < scb_burst_size. card detection
		 * and initialization commands are sensitive to this issue, therefore
		 * we disable merging during card detection.
		 */
		brcm_sdio_clr_seq_en();
	}
#endif // CONFIG_MIPS_BCM_NDVD  
   
	mmc_bus_get(host);

	if (host->bus_ops == NULL) {
		/*
		 * Only we can add a new handler, so it's safe to
		 * release the lock here.
		 */
		mmc_bus_put(host);

		if (host->ops->get_cd && host->ops->get_cd(host) == 0)
			goto out;

		mmc_claim_host(host);

		mmc_power_up(host);
		mmc_go_idle(host);

		mmc_send_if_cond(host, host->ocr_avail);

		/*
		 * First we search for SDIO...
		 */
		err = mmc_send_io_op_cond(host, 0, &ocr);
		if (!err) {
			if (mmc_attach_sdio(host, ocr))
				mmc_power_off(host);
			goto out;
		}

		/*
		 * ...then normal SD...
		 */
		err = mmc_send_app_op_cond(host, 0, &ocr);
		if (!err) {
			if (mmc_attach_sd(host, ocr))
				mmc_power_off(host);
			goto out;
		}

		/*
		 * ...and finally MMC.
		 */
		err = mmc_send_op_cond(host, 0, &ocr);
		if (!err) {
			if (mmc_attach_mmc(host, ocr))
				mmc_power_off(host);
			goto out;
		}

		mmc_release_host(host);
		mmc_power_off(host);
	} else {
		if (host->bus_ops->detect && !host->bus_dead)
			host->bus_ops->detect(host);

		mmc_bus_put(host);
	}
out:
	if (host->caps & MMC_CAP_NEEDS_POLL)
		mmc_schedule_delayed_work(&host->detect, HZ);

#ifdef CONFIG_MIPS_BCM_NDVD
	{
		extern void brcm_sdio_set_seq_en(void);
		/*
		 * this addresses JIRA HWGRAIN-84.
		 * re-enable merging on the SCB bus, after card detection/init complete.  
		 */
		brcm_sdio_set_seq_en();
	}
#endif // CONFIG_MIPS_BCM_NDVD  
           
}
Exemple #9
0
void mmc_rescan(struct work_struct *work)
{
	struct mmc_host *host =
		container_of(work, struct mmc_host, detect.work);
	u32 ocr;
	int err;
	int extend_wakelock = 0;

	mmc_bus_get(host);

	/* if there is a card registered, check whether it is still present */
	if ((host->bus_ops != NULL) && host->bus_ops->detect && !host->bus_dead)
		host->bus_ops->detect(host);

	/* If the card was removed the bus will be marked
	 * as dead - extend the wakelock so userspace
	 * can respond */
	if (host->bus_dead)
		extend_wakelock = 1;

	mmc_bus_put(host);


	mmc_bus_get(host);

	/* if there still is a card present, stop here */
	if (host->bus_ops != NULL) {
		mmc_bus_put(host);
		goto out;
	}

	/* detect a newly inserted card */

	/*
	 * Only we can add a new handler, so it's safe to
	 * release the lock here.
	 */
	mmc_bus_put(host);

	if (host->ops->get_cd && host->ops->get_cd(host) == 0)
		goto out;

	mmc_claim_host(host);

	mmc_power_up(host);
	mmc_go_idle(host);

	mmc_send_if_cond(host, host->ocr_avail);

	/*
	 * First we search for SDIO...
	 */
	err = mmc_send_io_op_cond(host, 0, &ocr);
	if (!err) {
		if (mmc_attach_sdio(host, ocr))
			mmc_power_off(host);
		extend_wakelock = 1;
		goto out;
	}

	/*
	 * ...then normal SD...
	 */
	err = mmc_send_app_op_cond(host, 0, &ocr);
	if (!err) {
		if (mmc_attach_sd(host, ocr))
			mmc_power_off(host);
		extend_wakelock = 1;
		goto out;
	}

	/*
	 * ...and finally MMC.
	 */
	err = mmc_send_op_cond(host, 0, &ocr);
	if (!err) {
		if (mmc_attach_mmc(host, ocr))
			mmc_power_off(host);
		extend_wakelock = 1;
		goto out;
	}

	mmc_release_host(host);
	mmc_power_off(host);

out:
    // FIH_FOX, BillHJChang	{ 20090904,  Modify for UMS currect handle
	if(host->index == 0) 
	{
		if(host->bus_ops == NULL)
			storage_state = false;
		else
			storage_state = true;

		printk(KERN_INFO"%s: (storage_state : %d)\n",__func__,storage_state);
	}
	// FIH_F0X, BillHJChang	}

    /* FIH, BillHJChang, 2009/11/20 { */
	/* [FXX_CR], issue of card detect fail in suspend mode */
	#ifdef CONFIG_FIH_FXX
		if(host->index == 0) 
		{
		wake_lock_timeout(&mmc_delayed_work_wake_lock, HZ * 2);		
		wake_lock_timeout(&sdcard_idle_wake_lock, HZ * 2);	

		}
		else
		{
		wake_unlock(&mmc_delayed_work_wake_lock);
		wake_unlock(&sdcard_idle_wake_lock);
		}
	#else
	    if (extend_wakelock)
		    wake_lock_timeout(&mmc_delayed_work_wake_lock, HZ / 2);
	    else
		    wake_unlock(&mmc_delayed_work_wake_lock);
    #endif
    /* } FIH, BillHJChang, 2009/11/20 */

	if (host->caps & MMC_CAP_NEEDS_POLL)
		mmc_schedule_delayed_work(&host->detect, HZ);
}
Exemple #10
0
void mmc_rescan(struct work_struct *work)
{
	struct mmc_host *host =
		container_of(work, struct mmc_host, detect.work);
	u32 ocr;
	int err;
	int extend_wakelock = 0;
#ifdef MMC_PATCH_2
	unsigned int attached = 0;
#endif
	
        NV_DRIVER_TRACE(("mmc_rescan\n"));
	mmc_bus_get(host);

	/* if there is a card registered, check whether it is still present */
	if ((host->bus_ops != NULL) && host->bus_ops->detect && !host->bus_dead)
	{
		host->bus_ops->detect(host);
	}
	/* If the card was removed the bus will be marked
	 * as dead - extend the wakelock so userspace
	 * can respond */
	if (host->bus_dead)
	{	
                extend_wakelock = 1;
	}
    
        NV_DRIVER_TRACE(("mmc_rescan extend_wakelock=%d\n",extend_wakelock));
	mmc_bus_put(host);


	mmc_bus_get(host);
	/* if there still is a card present, stop here */
	if (host->bus_ops != NULL) {
		mmc_bus_put(host);
		goto out;
	}
    
	/* detect a newly inserted card */

	/*
	 * Only we can add a new handler, so it's safe to
	 * release the lock here.
	 */
	mmc_bus_put(host);
	if (host->ops->get_cd && host->ops->get_cd(host) == 0)
		goto out;
	mmc_claim_host(host);

	mmc_power_up(host);
	mmc_go_idle(host);

	mmc_send_if_cond(host, host->ocr_avail);

	/*
	 * First we search for SDIO...
	 */
	err = mmc_send_io_op_cond(host, 0, &ocr);
	if (!err) {
		if (mmc_attach_sdio(host, ocr))
#ifdef MMC_PATCH_2
		{
#endif
			mmc_power_off(host);
#ifdef MMC_PATCH_2
                } else {
                        attached = 1;
                }
#endif
		extend_wakelock = 1;
		goto out;
	}
        NV_DRIVER_TRACE(("mmc_rescan 7\n"));
	/*
	 * ...then normal SD...
	 */
	err = mmc_send_app_op_cond(host, 0, &ocr);
	if (!err) {
		if (mmc_attach_sd(host, ocr))
#ifdef MMC_PATCH_2
		{
#endif
			mmc_power_off(host);
#ifdef MMC_PATCH_2
                } else {
                        attached = 1;
                }
#endif
		extend_wakelock = 1;
		goto out;
	}
	/*
	 * ...and finally MMC.
	 */
	err = mmc_send_op_cond(host, 0, &ocr);
	if (!err) {
		if (mmc_attach_mmc(host, ocr))
#ifdef MMC_PATCH_2
		{
#endif
			mmc_power_off(host);
#ifdef MMC_PATCH_2
                } else {
                        attached = 1;
                }
#endif
		extend_wakelock = 1;
		goto out;
	}
	mmc_release_host(host);
	mmc_power_off(host);

out:
        NV_DRIVER_TRACE(("mmc_rescan out\n"));
	if (extend_wakelock)
		wake_lock_timeout(&mmc_delayed_work_wake_lock, HZ / 2);
	else
		wake_unlock(&mmc_delayed_work_wake_lock);

	if (host->caps & MMC_CAP_NEEDS_POLL)
		queue_delayed_work(workqueue, &host->detect, HZ);

#ifdef MMC_PATCH_2
	/* Create a one-shot timer work, work after 1 second */
        if(!strcmp(mmc_hostname(host), "mmc1")) {
                printk("Try to add timer for %s ---------------- \n", mmc_hostname(host));
                
                if(timer_inited){
                        init_timer(&detect_timer);
                        detect_timer.data = (unsigned long)host;
                        detect_timer.function = sdhci_tegra_card_detect;
                        detect_timer.expires = jiffies + HZ;
                        add_timer(&detect_timer);
                        timer_inited = 1;
                } else {
                        if(!timer_pending(&detect_timer)) {
                                return;
                        } else {
                                add_timer(&detect_timer);
                        }
                }
        }
#endif
}
Exemple #11
0
void mmc_rescan(struct work_struct *work)
{
	struct mmc_host *host =
		container_of(work, struct mmc_host, detect.work);
	u32 ocr;
	int err;

	mmc_bus_get(host);

	if (host->bus_ops == NULL) {
		/*
		 * Only we can add a new handler, so it's safe to
		 * release the lock here.
		 */
		mmc_bus_put(host);

		mmc_claim_host(host);

		mmc_power_up(host);
		mmc_go_idle(host);

		mmc_send_if_cond(host, host->ocr_avail);

		/*
		 * First we search for SDIO...
		 */
		err = mmc_send_io_op_cond(host, 0, &ocr);
		if (!err) {
			if (mmc_attach_sdio(host, ocr))
				mmc_power_off(host);
			return;
		}

		/*
		 * ...then normal SD...
		 */
		err = mmc_send_app_op_cond(host, 0, &ocr);
		if (!err) {
			if (mmc_attach_sd(host, ocr))
				mmc_power_off(host);
			return;
		}

		/*
		 * ...and finally MMC.
		 */
		err = mmc_send_op_cond(host, 0, &ocr);
		if (!err) {
			if (mmc_attach_mmc(host, ocr))
				mmc_power_off(host);
			return;
		}

		mmc_release_host(host);
		mmc_power_off(host);
	} else {
		if (host->bus_ops->detect && !host->bus_dead)
			host->bus_ops->detect(host);

		mmc_bus_put(host);
	}
}
Exemple #12
0
void mmc_rescan(struct work_struct *work)
{
	struct mmc_host *host =
		container_of(work, struct mmc_host, detect.work);
    struct atsmb_host *atsmb_host = mmc_priv(host);
	u32 ocr;
	int err;
	int extend_wakelock = 0;
	int retry = 5;
	DBG("[%s] s\n",__func__);

	host->card_scan_status = false;

	while(retry > 0) {
		retry--;
		mmc_bus_get(host);
	
		/* if there is a card registered, check whether it is still present */
		if ((host->bus_ops != NULL) && host->bus_ops->detect && !host->bus_dead)
			host->bus_ops->detect(host);
	
		/* If the card was removed the bus will be marked
		 * as dead - extend the wakelock so userspace
		 * can respond */
		if (host->bus_dead)
			extend_wakelock = 1;
	
		mmc_bus_put(host);
	
	
		mmc_bus_get(host);
	
		/* if there still is a card present, stop here */
		if (host->bus_ops != NULL) {
			mmc_bus_put(host);
			goto out;
		}
	
		/* detect a newly inserted card */
	
		/*
		 * Only we can add a new handler, so it's safe to
		 * release the lock here.
		 */
		mmc_bus_put(host);
	
		if (host->ops->get_cd && host->ops->get_cd(host) == 0)
			goto out;
	
		mmc_claim_host(host);
	
		mmc_power_up(host);
		mmc_go_idle(host);
	
		mmc_send_if_cond(host, host->ocr_avail);
	
#if 1	//zhf: marked by James Tian
		/*
		 * First we search for SDIO...
		 */
		err = mmc_send_io_op_cond(host, 0, &ocr);
		if (!err) {
			if (mmc_attach_sdio(host, ocr))
				mmc_power_off(host);
			extend_wakelock = 1;
			goto out;
		}
#endif
	
		/*
		 * ...then normal SD...
		 */
		err = mmc_send_app_op_cond(host, 0, &ocr);
		if (!err) {
			if (mmc_attach_sd(host, ocr))
				mmc_power_off(host);
			extend_wakelock = 1;
			goto out;
		}
	
		/*
		 * ...and finally MMC.
		 */
		err = mmc_send_op_cond(host, 0, &ocr);
		if (!err) {
			if (mmc_attach_mmc(host, ocr))
				mmc_power_off(host);
			extend_wakelock = 1;
			goto out;
		}
	
		mmc_release_host(host);
		mmc_power_off(host);
	
out:
		if (extend_wakelock)
			wake_lock_timeout(&mmc_delayed_work_wake_lock, HZ / 2);
		else
			wake_unlock(&mmc_delayed_work_wake_lock);
	
		if (host->caps & MMC_CAP_NEEDS_POLL)
			mmc_schedule_delayed_work(&host->detect, HZ);
			
		DBG("[%s]retry = %d slot = %x power = %x\n",
			__func__,retry,host->ops->get_slot_status(host),
			host->ios.power_mode);

		if((host->ops->get_slot_status(host) == 0) ||
			(host->ios.power_mode != MMC_POWER_OFF))
			break;

		msleep(1000);	
	}	

	if (host->ios.power_mode != MMC_POWER_OFF)
		host->card_scan_status = true;
    printk("SD%d Host Clock %dHz\n",host->wmt_host_index, atsmb_host->current_clock);
	DBG("[%s] e\n",__func__);
}
Exemple #13
0
void mmc_rescan(struct work_struct *work)
{
	struct mmc_host *host =
		container_of(work, struct mmc_host, detect.work);
	u32 ocr;
	int err;

	unsigned int eint0msk = 0;	
	int ext_CD_int = 0;

	ext_CD_int = readl(S3C64XX_GPNDAT);
	ext_CD_int &= 0x40;	/* GPN6 */
	if( system_rev >= 0x20 )
		ext_CD_int = !ext_CD_int;

	mmc_bus_get(host);
    printk("kimhyuns mmc_rescan hostindex=%d\n", host->index);

	if (host->bus_ops == NULL) {
	    printk("kimhyuns mmc_rescan host->bus_ops == NULL \n");
		/*
		 * Only we can add a new handler, so it's safe to
		 * release the lock here.
		 */
		mmc_bus_put(host);

		if (host->ops->get_cd && host->ops->get_cd(host) == 0)
			goto out;

		mmc_claim_host(host);

		mmc_power_up(host);
		mmc_go_idle(host);

		mmc_send_if_cond(host, host->ocr_avail);
		/*
		 * First we search for SDIO...
		 */
		err = mmc_send_io_op_cond(host, 0, &ocr);
		if (!err) {
			if (mmc_attach_sdio(host, ocr))
				mmc_power_off(host);
			goto out;
		}

		/*
		 * ...then normal SD...
		 */
		err = mmc_send_app_op_cond(host, 0, &ocr);
		if (!err) {
			if (mmc_attach_sd(host, ocr))
				mmc_power_off(host);
			goto out;
		}

		/*
		 * ...and finally MMC.
		 */
		err = mmc_send_op_cond(host, 0, &ocr);
		if (!err) {
			if (mmc_attach_mmc(host, ocr))
				mmc_power_off(host);
			goto out;
		}

		mmc_release_host(host);
		mmc_power_off(host);
	}
	else 
	{
    printk("kimhyuns mmc_rescan else \n");	
		if (host->bus_ops->detect && !host->bus_dead)
			host->bus_ops->detect(host);

		mmc_bus_put(host);

		if(host->index ==0 && g_rescan_retry)
		{
			ext_CD_int = readl(S3C64XX_GPNDAT);
			ext_CD_int &= 0x40;	/* GPN6 */
			if( system_rev >= 0x20 )
				ext_CD_int = !ext_CD_int;

			if (!ext_CD_int)
			{
				mmc_detect_change(host, msecs_to_jiffies(200));
				g_rescan_retry = 0;
//		if(is_inited_wake_lock==1) //kimhyuns probe에서 수정함.
				{
					printk("kimhyuns mmc_rescan unlock 1 \n");					
					wake_unlock(&sdcard_scan_wake_lock);//kimhyuns_add
				}
			}
		}
	}

	if (!ext_CD_int)
	{
		eint0msk = __raw_readl(S3C64XX_EINT0MASK);
		eint0msk &= 0x0FFFFFFF & ~(1 << 6);
		__raw_writel(eint0msk, S3C64XX_EINT0MASK);
	}
		
out:
	if(host->index ==0 && g_rescan_retry)
	{
		g_rescan_retry = 0;
//		if(is_inited_wake_lock==1) //kimhyuns probe에서 수정함.
		{
			printk("kimhyuns mmc_rescan unlock 2 \n");					
			//wake_unlock(&sdcard_scan_wake_lock);//kimhyuns_add
			wake_lock_timeout(&sdcard_scan_wake_lock, msecs_to_jiffies(5000)); //give some timer for the media scanner to run
		}
	}
	if (host->caps & MMC_CAP_NEEDS_POLL)
		mmc_schedule_delayed_work(&host->detect, HZ);
}
Exemple #14
0
void mmc_rescan(struct work_struct *work)
{
	struct mmc_host *host =
		container_of(work, struct mmc_host, detect.work);
	u32 ocr;
	int err;
	int extend_wakelock = 0;
	int ret;

	unsigned long flags;

	/*
        * Add checking gpio pin status before initialization of bus.
        * If the GPIO pin status is changed, check gpio pin status again.
        * Should check until it's stable.
        * [email protected], 2010-09-27
        */
	if (host->ops->get_status){
		ret = host->ops->get_status(host);
		if (ret == 1) {
			mmc_schedule_delayed_work(&host->detect, HZ / 3);
			return;
		}
	}

	spin_lock_irqsave(&host->lock, flags);
	if (host->rescan_disable) {
		spin_unlock_irqrestore(&host->lock, flags);
		return;
	}
	spin_unlock_irqrestore(&host->lock, flags);

	mmc_bus_get(host);

	/*
	 * if there is a _removable_ card registered, check whether it is
	 * still present
	 */
	if (host->bus_ops && host->bus_ops->detect && !host->bus_dead
	    && !(host->caps & MMC_CAP_NONREMOVABLE)) {
		host->bus_ops->detect(host);
		/* If the card was removed the bus will be marked
		 * as dead - extend the wakelock so userspace
		 * can respond */
		if (host->bus_dead)
			extend_wakelock = 1;
	}

	mmc_bus_put(host);


	mmc_bus_get(host);

	/* if there still is a card present, stop here */
	if (host->bus_ops != NULL) {
		mmc_bus_put(host);
		goto out;
	}

	/* detect a newly inserted card */

	/*
	 * Only we can add a new handler, so it's safe to
	 * release the lock here.
	 */
	mmc_bus_put(host);

	if (host->ops->get_cd && host->ops->get_cd(host) == 0)
		goto out;

	mmc_claim_host(host);

	mmc_power_up(host);
	sdio_reset(host);
	mmc_go_idle(host);

	mmc_send_if_cond(host, host->ocr_avail);

	/*
	 * First we search for SDIO...
	 */
	err = mmc_send_io_op_cond(host, 0, &ocr);
	if (!err) {
		if (mmc_attach_sdio(host, ocr))
			mmc_power_off(host);
		extend_wakelock = 1;
		goto out;
	}

	/*
	 * ...then normal SD...
	 */
	err = mmc_send_app_op_cond(host, 0, &ocr);
	if (!err) {
		if (mmc_attach_sd(host, ocr))
			mmc_power_off(host);
		extend_wakelock = 1;
		goto out;
	}

	/*
	 * ...and finally MMC.
	 */
	err = mmc_send_op_cond(host, 0, &ocr);
	if (!err) {
		if (mmc_attach_mmc(host, ocr))
			mmc_power_off(host);
		extend_wakelock = 1;
		goto out;
	}

	mmc_release_host(host);
	mmc_power_off(host);

out:
	if (extend_wakelock)
		wake_lock_timeout(&mmc_delayed_work_wake_lock, HZ / 2);
	else
		wake_unlock(&mmc_delayed_work_wake_lock);

	if (host->caps & MMC_CAP_NEEDS_POLL)
		mmc_schedule_delayed_work(&host->detect, HZ);
}
Exemple #15
0
void mmc_rescan(struct work_struct *work)
{
	struct mmc_host *host =
		container_of(work, struct mmc_host, detect.work);
	u32 ocr;
	int err;
	unsigned long flags;
	int extend_wakelock = 0;

	spin_lock_irqsave(&host->lock, flags);

	if (host->rescan_disable) {
		spin_unlock_irqrestore(&host->lock, flags);
		if (atomic_dec_return(&wakelock_refs) > 0) {
			printk(KERN_DEBUG "Another host want the wakelock : %d\n", atomic_read(&wakelock_refs));
		}else {
			printk(KERN_DEBUG "unlock case1 : mmc%d: wake_lock_timeout 0.5 sec %d\n", host->index, atomic_read(&wakelock_refs));
			wake_lock_timeout(&mmc_delayed_work_wake_lock, msecs_to_jiffies(500));
		}
		return;
	}

	spin_unlock_irqrestore(&host->lock, flags);

//[NAGSM_Android_HDLNC_SDcard_shinjonghyun_20100504 : mutual exclusion when MoviNand and SD cardusing using this funtion
//	mutex_lock(&host->carddetect_lock); 
//]NAGSM_Android_HDLNC_SDcard_shinjonghyun_20100504 : mutual exclusion when MoviNand and SD cardusing using this funtion	

	mmc_bus_get(host);

	/* if there is a card registered, check whether it is still present */
	if ((host->bus_ops != NULL) && host->bus_ops->detect && !host->bus_dead) {
		if(host->ops->get_cd && host->ops->get_cd(host) == 0) {
			if(host->bus_ops->remove)
				host->bus_ops->remove(host);

			mmc_claim_host(host);
			mmc_detach_bus(host);
			mmc_release_host(host);
		}
		else
			host->bus_ops->detect(host);
	}

	/* If the card was removed the bus will be marked
	 * as dead - extend the wakelock so userspace
	 * can respond */
	if (host->bus_dead)
		extend_wakelock = 1;

	mmc_bus_put(host);


	mmc_bus_get(host);

	printk(KERN_DEBUG "*** DEBUG : start %s (mmc%d)***\n", __func__, host->index);

	/* if there still is a card present, stop here */
	if (host->bus_ops != NULL) {
		mmc_bus_put(host);
		goto out;
	}

	/* detect a newly inserted card */

	/*
	 * Only we can add a new handler, so it's safe to
	 * release the lock here.
	 */
	mmc_bus_put(host);

	if (host->ops->get_cd && host->ops->get_cd(host) == 0)
		goto out;

	mmc_claim_host(host);

	mmc_power_up(host);
	sdio_reset(host);
	mmc_go_idle(host);

	mmc_send_if_cond(host, host->ocr_avail);

	/*
	 * First we search for SDIO...
	 */
	printk(KERN_DEBUG "*** DEBUG : First we search for SDIO...(%d)***\n", host->index);
	err = mmc_send_io_op_cond(host, 0, &ocr);
	if (!err) {
		if (mmc_attach_sdio(host, ocr))
			mmc_power_off(host);
		extend_wakelock = 1;
		goto out;
	}

	/*
	 * ...then normal SD...
	 */
	printk(KERN_DEBUG "*** DEBUG : ...then normal SD...(%d) ***\n", host->index);
	err = mmc_send_app_op_cond(host, 0, &ocr);
	if (!err) {
		if (mmc_attach_sd(host, ocr))
			mmc_power_off(host);
		extend_wakelock = 1;
		goto out;
	}

	/*
	 * ...and finally MMC.
	 */
	printk(KERN_DEBUG "*** DEBUG : ...and finally MMC. (%d)***\n", host->index);
	err = mmc_send_op_cond(host, 0, &ocr);
	if (!err) {
		if (mmc_attach_mmc(host, ocr))
			mmc_power_off(host);
		extend_wakelock = 1;
		goto out;
	}

	printk(KERN_DEBUG "*** DEBUG : end %s (mmc%d)***\n", __func__, host->index);

	mmc_release_host(host);
	mmc_power_off(host);

out:
#if 0
	//if (extend_wakelock)
	//	wake_lock_timeout(&mmc_delayed_work_wake_lock, HZ / 2);
	//else
	//	wake_unlock(&mmc_delayed_work_wake_lock);
#else
	if (atomic_dec_return(&wakelock_refs) > 0) {
		printk(KERN_DEBUG "Another host want the wakelock : %d\n", atomic_read(&wakelock_refs));
	}
	else {
		printk(KERN_DEBUG "unlock case2 : mmc%d: wake_lock_timeout 0.5 sec %d\n", host->index, atomic_read(&wakelock_refs));
		wake_lock_timeout(&mmc_delayed_work_wake_lock, msecs_to_jiffies(500));
	}
#endif

	if (host->caps & MMC_CAP_NEEDS_POLL)
		mmc_schedule_delayed_work(&host->detect, HZ);
//[NAGSM_Android_HDLNC_SDcard_shinjonghyun_20100504 : mutual exclusion when MoviNand and SD cardusing using this funtion
//	mutex_unlock(&host->carddetect_lock); 
//]NAGSM_Android_HDLNC_SDcard_shinjonghyun_20100504 : mutual exclusion when MoviNand and SD cardusing using this funtion

}
Exemple #16
0
static void mmc_rescan(struct work_struct *work)
{
	struct mmc_host *host =
		container_of(work, struct mmc_host, detect.work);
	u32 ocr;
	int err;

	if(fo_k){
		fo_k = 0;
		return;		
	}	 
	
	printk(" mmc_rescan... \n");
	mmc_bus_get(host);

	if (host->bus_ops == NULL) {
		/*
		 * Only we can add a new handler, so it's safe to
		 * release the lock here.
		 */
		if(pollux_gpio_getpin(SDI_CD_IO)) {
			printk("  mmc_rescan 1===> no card \n");
			mmc_bus_put(host);
			return;
		}
		mmc_bus_put(host);
		mmc_claim_host(host);
		mmc_power_up(host);
		if(pollux_gpio_getpin(SDI_CD_IO)) {
			printk("  mmc_rescan 2===> no card \n");
			mmc_power_off(host);
			mmc_release_host(host);
			return;
		}
		
		mmc_go_idle(host);
		mmc_send_if_cond(host, host->ocr_avail);

		err = mmc_send_app_op_cond(host, 0, &ocr);
		if (err == MMC_ERR_NONE) {
			if (mmc_attach_sd(host, ocr)){
				printk("mmc_attach_sd_error .... \n");
				mmc_power_off(host);
				fo_k = 1;
			}						
		} else {
			/*
			 * If we fail to detect any SD cards then try
			 * searching for MMC cards.
			 */
			if(pollux_gpio_getpin(SDI_CD_IO)) {
				printk("  mmc_rescan 4===> no card \n");
				mmc_power_off(host);
				mmc_release_host(host);
				return;
			}
			
			err = mmc_send_op_cond(host, 0, &ocr);
			if (err == MMC_ERR_NONE) {
				if (mmc_attach_mmc(host, ocr))
					mmc_power_off(host);
			} else {
				mmc_power_off(host);
				mmc_release_host(host);
			}
		}
	} else {
		if (host->bus_ops->detect && !host->bus_dead)
			host->bus_ops->detect(host);

		mmc_bus_put(host);
	}
}