Example #1
0
/*
 * Unregister a new MMC card with the driver model, and
 * (eventually) free it.
 */
void mmc_remove_card(struct mmc_card *card)
{
#ifdef CONFIG_DEBUG_FS
	mmc_remove_card_debugfs(card);
#endif

	if (mmc_card_present(card)) {
		if (mmc_host_is_spi(card->host)) {
			pr_info("%s: SPI card removed\n",
				mmc_hostname(card->host));
		} else {
			pr_info("%s: card %04x removed\n",
				mmc_hostname(card->host), card->rca);
		}
        
        #ifdef CONFIG_HUAWEI_KERNEL
        if(MMC_TYPE_SD  == card->type)
        {
            hw_extern_sdcard_remove();
        }
        #endif

		device_del(&card->dev);
	}

	kfree(card->wr_pack_stats.packing_events);

	put_device(&card->dev);
}
Example #2
0
/*
 * Unregister a new MMC card with the driver model, and
 * (eventually) free it.
 */
void mmc_remove_card(struct mmc_card *card)
{
#if   0//def CONFIG_USB_S3C_OTGD   /*viking for Malata ICON*/
	if(card->type != MMC_TYPE_SDIO)
	{
		if(strcmp(mmc_hostname(card->host), MMC_SDCARD) == 0)
		{
			Notify_SDMMC_Insert(0);
			printk("####### notify Sdcard remove\n");
		}
		else
		if(strcmp(mmc_hostname(card->host), MMC_INAND) == 0)	
		{
			Notify_iNand_Insert(0);
			printk("####### notify iNand remove\n");
		}
	}
#endif
#ifdef CONFIG_DEBUG_FS
	mmc_remove_card_debugfs(card);
#endif

	if (mmc_card_present(card)) {
		if (mmc_host_is_spi(card->host)) {
			printk(KERN_INFO "%s: SPI card removed\n",
				mmc_hostname(card->host));
		} else {
			printk(KERN_INFO "%s: card %04x removed\n",
				mmc_hostname(card->host), card->rca);
		}
		device_del(&card->dev);
	}

	put_device(&card->dev);
}
Example #3
0
/*
 * Unregister a new MMC card with the driver model, and
 * (eventually) free it.
 */
void mmc_remove_card(struct mmc_card *card)
{
#ifdef CONFIG_MMC_BLOCK_DEFERRED_RESUME
	if (mmc_bus_needs_resume(card->host)) {
		card->host->bus_resume_flags &= ~MMC_BUSRESUME_NEEDS_RESUME;
		printk(KERN_INFO "%s: MMC card is removed so no need to resume the bus.\n",
			mmc_hostname(card->host));
	}
#endif
#ifdef CONFIG_DEBUG_FS
	mmc_remove_card_debugfs(card);
#endif

	if (mmc_card_present(card)) {
		if (mmc_host_is_spi(card->host)) {
			printk(KERN_INFO "%s: SPI card removed\n",
				mmc_hostname(card->host));
		} else {
			printk(KERN_INFO "%s: card %04x removed\n",
				mmc_hostname(card->host), card->rca);
		}
		device_del(&card->dev);
	}

	put_device(&card->dev);
}
Example #4
0
/*
 * Unregister a new MMC card with the driver model, and
 * (eventually) free it.
 */
void mmc_remove_card(struct mmc_card *card)
{
#ifdef CONFIG_DEBUG_FS
	mmc_remove_card_debugfs(card);
#endif

	if (mmc_card_present(card)) {
		if (mmc_host_is_spi(card->host)) {
			printk(KERN_INFO "%s: SPI card removed\n",
				mmc_hostname(card->host));
		} else {
			printk(KERN_INFO "%s: card %04x removed\n",
				mmc_hostname(card->host), card->rca);
#if defined (CONFIG_MIPS_BCM_NDVD)
			{
				extern void brcm_sdio_intr_disable(void);
				/*
				 * Must disable interrupts for boards with
				 * switched SDIO power.
				 */
				brcm_sdio_intr_disable();
				card->host->card_enable = 1;
			}
#endif
		}
		device_del(&card->dev);
	}

	put_device(&card->dev);
}
Example #5
0
/*
 * Unregister a new MMC card with the driver model, and
 * (eventually) free it.
 */
void mmc_remove_card(struct mmc_card *card)
{
#ifdef CONFIG_DEBUG_FS
    mmc_remove_card_debugfs(card);
#endif

    if (mmc_card_present(card)) {
        if (mmc_host_is_spi(card->host)) {
            pr_info("%s: SPI card removed\n",
                    mmc_hostname(card->host));
        } else {
            pr_info("%s: card %04x removed\n",
                    mmc_hostname(card->host), card->rca);
        }
#ifdef  CONFIG_MMC_SD_BATTLOG_CUST_SH
        if (mmc_detection_status_check(card->host))
            mmc_post_detection(card->host, SD_SOFT_REMOVED);
        else
            mmc_post_detection(card->host, SD_PHY_REMOVED);
#endif /* CONFIG_MMC_SD_BATTLOG_CUST_SH */
        device_del(&card->dev);
    }

    kfree(card->wr_pack_stats.packing_events);

    put_device(&card->dev);
}
/*
 * Initializes a host.
 */
static int sd_init(struct sd_host *host)
{
	int retval;

	spin_lock_init(&host->lock);

	host->refcnt = 0;
	set_bit(__SD_MEDIA_CHANGED, &host->flags);

	host->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
	sd_set_clock(host, SD_SPI_CLK);
	sd_calc_timeouts(host);

	retval = sd_init_blk_dev(host);
	if (!retval) {
		retval = sd_revalidate_disk(host->disk);
		if (retval < 0 || !mmc_card_present(&host->card)) {
			retval = -ENODEV;
			goto err_blk_dev;
		}

		retval = sd_init_io_thread(host);
		if (retval)
			goto err_blk_dev;

		add_disk(host->disk);
	}

	return retval;

err_blk_dev:
	sd_exit_blk_dev(host);
	return retval;
}
/*
 * Unregister a new MMC card with the driver model, and
 * (eventually) free it.
 */
void mmc_remove_card(struct mmc_card *card)
{
#ifdef CONFIG_DEBUG_FS
	mmc_remove_card_debugfs(card);
#endif

	if (mmc_card_present(card)) {
		if (mmc_host_is_spi(card->host)) {
			printk(KERN_INFO "%s: SPI card removed\n",
				mmc_hostname(card->host));
		} else {
			printk(KERN_INFO "%s: card %04x removed\n",
				mmc_hostname(card->host), card->rca);
		}
        
#ifdef CONFIG_HUAWEI_KERNEL
        if(MMC_TYPE_SD  == card->type)
        {
            hw_extern_sdcard_remove();
        }
#endif

		device_del(&card->dev);
	}

	put_device(&card->dev);
}
Example #8
0
/*
 * @brief try to deinitialize device and unmount FATFS.
 * @param dev_type:
 *		  type of the device,like SD card
 * @param dev_id:
 *		  the ID of the device.
 * @retval  0 if unmount success or other if dev not exist or FATFS not mount before.
 */
static int fs_ctrl_unmount(enum fs_mnt_dev_type dev_type, uint32_t dev_id)
{
	struct mmc_card *card;
	FRESULT fs_ret;
	int ret = 0;

	if (fs_ctrl.fs != NULL) {
		fs_ret = f_mount(NULL, "", 0);
		if (fs_ret != FR_OK) {
			FS_ERROR("unmount fail ret:%d\n", fs_ret);
		}
		free(fs_ctrl.fs);
		fs_ctrl.fs = NULL;
	} else {
		ret = -1;
	}

	card = mmc_card_open(dev_id);
	if (card == NULL) {
		FS_ERROR("card open fail\n");
	} else {
		if (mmc_card_present(card)) {
			mmc_card_deinit(card);
		}
		mmc_card_close(dev_id);
		mmc_card_delete(dev_id, 0);
	}

	fs_ctrl.mount_status = FS_MNT_STATUS_UNMOUNT;
	return ret;
}
Example #9
0
/*
 * Unregister a new MMC card with the driver model, and
 * (eventually) free it.
 */
void mmc_remove_card(struct mmc_card *card)
{
#ifdef CONFIG_DEBUG_FS
	mmc_remove_card_debugfs(card);
#endif

	if (mmc_card_present(card)) {
		if (mmc_host_is_spi(card->host)) {
			pr_info("%s: SPI card removed\n",
				mmc_hostname(card->host));
		} else {
			pr_info("%s: card %04x removed\n",
				mmc_hostname(card->host), card->rca);
			#ifdef CONFIG_SKY_WLAN_BCM4330  // 2013-08-29 thkim_wifi check wifi mmc card
			if(!strcmp(CHECK_WLAN_MMC, mmc_hostname(card->host))){
				pr_info("%s: pantech wlan mmc card %04x removed\n",
				mmc_hostname(card->host), card->rca);
				dump_stack();
				}
			#endif
		}
		device_del(&card->dev);
	}

	kfree(card->wr_pack_stats.packing_events);

	put_device(&card->dev);
}
Example #10
0
/*
 * Internal function.  Unregister a new MMC card with the
 * driver model, and (eventually) free it.
 */
void mmc_remove_card(struct mmc_card *card)
{
	if (mmc_card_present(card))
		device_del(&card->dev);

	put_device(&card->dev);
}
Example #11
0
File: bus.c Project: cilynx/dd-wrt
/*
 * Unregister a new MMC card with the driver model, and
 * (eventually) free it.
 */
void mmc_remove_card(struct mmc_card *card)
{
	if (mmc_card_present(card)) {
		printk(KERN_INFO "%s: card %04x removed\n",
			mmc_hostname(card->host), card->rca);

		if (card->host->bus_ops->sysfs_remove)
			card->host->bus_ops->sysfs_remove(card->host, card);
		device_del(&card->dev);
	}

	put_device(&card->dev);
}
/*
 * Unregister a new MMC card with the driver model, and
 * (eventually) free it.
 */
void mmc_remove_card(struct mmc_card *card)
{
#ifdef CONFIG_DEBUG_FS
	mmc_remove_card_debugfs(card);
#endif

	if (mmc_card_present(card)) {
		if (mmc_host_is_spi(card->host)) {
			pr_info("%s: SPI card removed\n",
				mmc_hostname(card->host));
		} else {
			pr_info("%s: card %04x removed\n",
				mmc_hostname(card->host), card->rca);
		}
		device_del(&card->dev);
	}

	put_device(&card->dev);
}
Example #13
0
static void mmc_omap_cover_handler(unsigned long param)
{
	struct mmc_omap_slot *slot = (struct mmc_omap_slot *)param;
	int cover_open = mmc_omap_cover_is_open(slot);

	mmc_detect_change(slot->mmc, 0);
	if (!cover_open)
		return;

	/*
	 * If no card is inserted, we postpone polling until
	 * the cover has been closed.
	 */
	if (slot->mmc->card == NULL || !mmc_card_present(slot->mmc->card))
		return;

	mod_timer(&slot->cover_timer,
		  jiffies + msecs_to_jiffies(OMAP_MMC_COVER_POLL_DELAY));
}
Example #14
0
/*
 * Unregister a new MMC card with the driver model, and
 * (eventually) free it.
 */
void mmc_remove_card(struct mmc_card *card)
{
#ifdef CONFIG_DEBUG_FS
	mmc_remove_card_debugfs(card);
#endif

	if (mmc_card_present(card)) {
		if (mmc_host_is_spi(card->host)) {
			printk(KERN_INFO "%s: SPI card removed\n",
				mmc_hostname(card->host));
		} else {
			printk(KERN_INFO "%s: card %04x removed\n",
				mmc_hostname(card->host), card->rca);
		}
printk("%s: device_del\n", __FUNCTION__);
		device_del(&card->dev);
	}

	put_device(&card->dev);
}
Example #15
0
/*
 * Unregister a new MMC card with the driver model, and
 * (eventually) free it.
 */
void mmc_remove_card(struct mmc_card *card)
{
#ifdef CONFIG_DEBUG_FS
	mmc_remove_card_debugfs(card);
#endif

	if (mmc_card_present(card)) {
		//if(!HOST_IS_EMMC(card->host))
		//	mmc_card_clr_present(card);
		if (mmc_host_is_spi(card->host)) {
			printk(KERN_INFO "%s: SPI card removed\n",
				mmc_hostname(card->host));
		} else {
			printk(KERN_INFO "%s: card %04x removed\n",
				mmc_hostname(card->host), card->rca);
		}
		device_del(&card->dev);
	}

	put_device(&card->dev);
}
Example #16
0
/*
 * Unregister a new MMC card with the driver model, and
 * (eventually) free it.
 */
void mmc_remove_card(struct mmc_card *card)
{
#ifdef CONFIG_DEBUG_FS
    mmc_remove_card_debugfs(card);
#endif

    if (mmc_card_present(card)) {
        if (mmc_host_is_spi(card->host)) {
            printk(KERN_INFO "%s: SPI card removed\n",
                   mmc_hostname(card->host));
        } else {
            printk(KERN_INFO "%s: card %04x removed\n",
                   mmc_hostname(card->host), card->rca);
        }
        device_del(&card->dev);
    }

    kfree(card->wr_pack_stats.packing_events);

    put_device(&card->dev);
}
Example #17
0
/*
 * Unregister a new MMC card with the driver model, and
 * (eventually) free it.
 */
void mmc_remove_card(struct mmc_card *card)
{
#ifdef CONFIG_DEBUG_FS
	mmc_remove_card_debugfs(card);
#endif

	if (mmc_card_present(card)) {
		if (mmc_host_is_spi(card->host)) {
			printk(KERN_INFO "%s: SPI card removed\n",
				mmc_hostname(card->host));
		} else {
			printk(KERN_INFO "%s: card %04x removed\n",
				mmc_hostname(card->host), card->rca);
		}
#ifdef CONFIG_MACH_SEMC_ZEUS
		mmc_card_set_removed(card);
#endif /* CONFIG_MACH_SEMC_ZEUS */
		device_del(&card->dev);
	}

	put_device(&card->dev);
}
Example #18
0
/*
 * Unregister a new MMC card with the driver model, and
 * (eventually) free it.
 */
void mmc_remove_card(struct mmc_card *card)
{
#ifdef CONFIG_DEBUG_FS
	mmc_remove_card_debugfs(card);
#endif

	if (mmc_card_present(card)) {
		if (mmc_host_is_spi(card->host)) {
			printk(KERN_INFO "%s: SPI card removed\n",
				mmc_hostname(card->host));
		} else {
			printk(KERN_INFO "%s: card %04x removed\n",
				mmc_hostname(card->host), card->rca);
		}
/*LGE_UPDATE_S DYLEE */
		printk(KERN_INFO "[LGE] mmc device remove\n");	//LGE_UPDATE E720 BCPARK
/*LGE_UPDATE_E DYLEE */
		device_del(&card->dev);
	}

	put_device(&card->dev);
}
Example #19
0
/*
 * Unregister a new MMC card with the driver model, and
 * (eventually) free it.
 */
void mmc_remove_card(struct mmc_card *card)
{
#ifdef CONFIG_DEBUG_FS
	mmc_remove_card_debugfs(card);
#endif

	if (mmc_card_present(card)) {
#if defined(CONFIG_SDMMC_RK29) && defined(CONFIG_SDMMC_RK29_OLD)
		mmc_card_clr_present(card);
#endif		
		if (mmc_host_is_spi(card->host)) {
			printk(KERN_INFO "%s: SPI card removed\n",
				mmc_hostname(card->host));
		} else {
			printk(KERN_INFO "%s: card %04x removed\n",
				mmc_hostname(card->host), card->rca);
		}
		device_del(&card->dev);
	}

	put_device(&card->dev);
}
Example #20
0
/*
 * @brief try to scan device and mount FATFS.
 * @param dev_type:
 *        type of the device,like SD card
 * @param dev_id:
 *        the ID of the device.
 * @retval  0 if mount success or other if failed.
 */
static int fs_ctrl_mount(enum fs_mnt_dev_type dev_type, uint32_t dev_id)
{
	struct mmc_card *card;
	FRESULT fs_ret;
	int mmc_ret;
	int ret = -1;

	if (mmc_card_create(dev_id) != 0) {
		FS_ERROR("card create fail\n");
		goto out;
	}
	card = mmc_card_open(dev_id);
	if (card == NULL) {
		FS_ERROR("card open fail\n");
		goto err_card;
	}
	if (!mmc_card_present(card)) {
		mmc_ret = mmc_rescan(card, 0);
		if (mmc_ret != 0) {
			FS_ERROR("scan fail\n");
			mmc_card_close(dev_id);
			goto err_card;
		} else {
			FS_INFO("sd card init\n");
		}
	}
	mmc_card_close(dev_id);

	if (fs_ctrl.fs == NULL) {
		FATFS *fs = malloc(sizeof(FATFS));
		if (fs == NULL) {
			FS_ERROR("no mem\n");
			goto err_fs;
		}
		fs_ret = f_mount(fs, "", 0);
		if (fs_ret != FR_OK) {
			FS_ERROR("mount fail ret:%d\n", fs_ret);
			free(fs);
			goto err_fs;
		} else {
			FS_INFO("mount success\n");
			fs_ctrl.fs = fs;
		}
	}
	ret = 0;
	goto out;

err_fs:
	if (mmc_card_present(card))
		mmc_card_deinit(card);

err_card:
	mmc_card_delete(dev_id, 0);

out:
	if (ret == 0) {
		fs_ctrl.mount_status = FS_MNT_STATUS_MOUNT_OK;
	} else {
		fs_ctrl.mount_status = FS_MNT_STATUS_MOUNT_FAIL;
	}
	return ret;
}
Example #21
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);
    }
}