Example #1
0
int msmsdcc_suspend(struct platform_device *dev, pm_message_t state)
{
	struct mmc_host *mmc = mmc_get_drvdata(dev);
	int rc = 0;

	if (mmc) {
		struct msmsdcc_host *host = mmc_priv(mmc);
		void __iomem *base = host->base;
		uint32_t status;
		unsigned long timeleft = jiffies + msecs_to_jiffies(100);

		if (host->stat_irq)
			disable_irq(host->stat_irq);

		do {
			status = readl(base + MMCISTATUS);
			if (!(status & (MCI_TXFIFOEMPTY | MCI_RXFIFOEMPTY)))
				break;
			cpu_relax();
		} while (time_is_after_jiffies(timeleft));

		if (mmc->card && mmc->card->type != MMC_TYPE_SDIO)
			rc = mmc_suspend_host(mmc, state);
		if (!rc) {
			writel(0, host->base + MMCIMASK0);

			if (host->clks_on) {
				clk_disable(host->clk);
				clk_disable(host->pclk);
				host->clks_on = 0;
			}
		}
	}
	return rc;
}
Example #2
0
static int
msmsdcc_suspend(struct platform_device *dev, pm_message_t state)
{
	struct mmc_host *mmc = mmc_get_drvdata(dev);
	struct msmsdcc_host *host = mmc_priv(mmc);
	int rc = 0;
	pr_debug("%s ++ entering\n", __func__);

#ifdef CONFIG_MMC_AUTO_SUSPEND
	if (test_and_set_bit(0, &host->suspended))
		return 0;
#endif
	if (mmc) {
		if (host->plat->status_irq)
			disable_irq(host->plat->status_irq);

		if (!mmc->card || mmc->card->type != MMC_TYPE_SDIO)
			rc = mmc_suspend_host(mmc, state);
		if (!rc) {
			writel(0, host->base + MMCIMASK0);

			if (host->clks_on) {
				clk_disable(host->clk);
				clk_disable(host->pclk);
				host->clks_on = 0;
			}
		}

		if (host->plat->sdiowakeup_irq)
			enable_irq(host->plat->sdiowakeup_irq);
	}
	pr_debug("%s -- leaving\n", __func__);
	return rc;
}
int msmsdcc_suspend(struct platform_device *dev, pm_message_t state)
{
	struct mmc_host *mmc = mmc_get_drvdata(dev);
	int rc = 0;

	if (mmc) {
		struct msmsdcc_host *host = mmc_priv(mmc);

		if (host->stat_irq)
			disable_irq(host->stat_irq);

		if (mmc->card && mmc->card->type != MMC_TYPE_SDIO)
			rc = mmc_suspend_host(mmc, state);
		if (!rc) {
			writel(0, host->base + MMCIMASK0);

			if (host->clks_on) {
				clk_disable(host->clk);
				clk_disable(host->pclk);
				host->clks_on = 0;
			}
		}
	}
	return rc;
}
int msmsdcc_resume(struct platform_device *dev)
{
	struct mmc_host *mmc = mmc_get_drvdata(dev);
	unsigned long flags;

	if (mmc) {
		struct msmsdcc_host *host = mmc_priv(mmc);

		spin_lock_irqsave(&host->lock, flags);

		if (!host->clks_on) {
			clk_enable(host->pclk);
			clk_enable(host->clk);
			host->clks_on = 1;
		}

		writel(host->saved_irq0mask, host->base + MMCIMASK0);

		spin_unlock_irqrestore(&host->lock, flags);

		if (mmc->card && mmc->card->type != MMC_TYPE_SDIO)
#ifdef CONFIG_MMC_MSM7X00A_RESUME_IN_WQ
			schedule_work(&host->resume_task);
#else
			mmc_resume_host(mmc);
		if (host->stat_irq)
			enable_irq(host->stat_irq);
#endif
		else if (host->stat_irq)
			enable_irq(host->stat_irq);
	}
	return 0;
}
static int
msmsdcc_resume(struct platform_device *dev)
{
	struct mmc_host *mmc = mmc_get_drvdata(dev);
	unsigned long flags;

	if (mmc) {
		struct msmsdcc_host *host = mmc_priv(mmc);

		spin_lock_irqsave(&host->lock, flags);

		if (!host->clks_on) {
			clk_enable(host->pclk);
			clk_enable(host->clk);
			host->clks_on = 1;
		}

		writel(host->saved_irq0mask, host->base + MMCIMASK0);

		spin_unlock_irqrestore(&host->lock, flags);

		if (mmc->card && mmc->card->type != MMC_TYPE_SDIO)
			mmc_resume_host(mmc);
		if (host->stat_irq)
			enable_irq(host->stat_irq);
	}
	return 0;
}
Example #6
0
static int mmc_blk_suspend(struct mmc_card *card, pm_message_t state)
{
	struct mmc_blk_data *md = mmc_get_drvdata(card);

	if (md) {
		mmc_queue_suspend(&md->queue);
	}
	return 0;
}
static int simple_mmc_get_disk_info(struct mbr_part_info *mpi, unsigned char *name)
{
    int i = 0;
    char* no_partition_name = "n/a";
    struct disk_part_iter piter;
    struct hd_struct *part;
    struct msdc_host *host;
    struct gendisk *disk;
    struct __mmc_blk_data *md;

    if(!name || !mpi)
        return -EINVAL;

    /* emmc always in slot0 */
    host = msdc_get_host(MSDC_EMMC,MSDC_BOOT_EN,0);
    BUG_ON(!host);
    BUG_ON(!host->mmc);
    BUG_ON(!host->mmc->card);

    md = mmc_get_drvdata(host->mmc->card);
    BUG_ON(!md);
    BUG_ON(!md->disk);

    disk = md->disk;

    /* use this way to find partition info is to avoid handle addr transfer in scatter file
     * and 64bit address calculate */
    disk_part_iter_init(&piter, disk, 0);
    while ((part = disk_part_iter_next(&piter))){
        for (i = 0; i < PART_NUM; i++) {
			if ((PartInfo[i].partition_idx != 0)
				&& (PartInfo[i].partition_idx == part->partno)) {
#if DEBUG_MMC_IOCTL
				pr_debug("part_name = %s    name = %s\n", PartInfo[i].name, name);
#endif
				if (!strncmp(PartInfo[i].name, name, PARTITION_NAME_LENGTH)) {
					mpi->start_sector = part->start_sect;
					mpi->nr_sects = part->nr_sects;
					mpi->part_no = part->partno;
					if (i < PART_NUM) {
						mpi->part_name = PartInfo[i].name;
					} else {
						mpi->part_name = no_partition_name;
					}

					disk_part_iter_exit(&piter);
					return 0;
				}

				break;
			}
		}
	}
	disk_part_iter_exit(&piter);

	return 1;
}
Example #8
0
static int mmc_blk_resume(struct mmc_card *card)
{
	struct mmc_blk_data *md = mmc_get_drvdata(card);

	if (md) {
		mmc_blk_set_blksize(md, card);
		mmc_queue_resume(&md->queue);
	}
	return 0;
}
int mt65xx_mmc_change_disk_info(unsigned int px, unsigned int addr, unsigned int size)
{
#ifdef MTK_EMMC_SUPPORT

    struct disk_part_iter piter;
	struct hd_struct *part;
	struct msdc_host *host;
	struct gendisk *disk;
    struct __mmc_blk_data *md;
    int i;
    /* emmc always in slot0 */
	host = msdc_get_host(MSDC_EMMC,MSDC_BOOT_EN,0);
	BUG_ON(!host);
	BUG_ON(!host->mmc);
	BUG_ON(!host->mmc->card);

	md = mmc_get_drvdata(host->mmc->card);
	BUG_ON(!md);
	BUG_ON(!md->disk);
	disk = md->disk;
    disk_part_iter_init(&piter, disk, 0);

	for(i=0;i<PART_NUM;i++){
		if((PartInfo[i].partition_idx == px)&&((!strncmp(PartInfo[i].name,"usrdata",7))||(!strncmp(PartInfo[i].name,"sec_ro",6))||(!strncmp(PartInfo[i].name,"android",7))||(!strncmp(PartInfo[i].name,"cache",5)))){
			printk("update %s,need reduce 1MB in block device\n",PartInfo[i].name);
			size -= (0x100000)/512;
		}
	}
    while ((part = disk_part_iter_next(&piter))){
      
            if (px != 0 && px == part->partno) {
//#if DEBUG_MMC_IOCTL
                printk("[mt65xx_mmc_change_disk_info]px = %d size %llx -> %x offset %llx -> %x\n",px,part->nr_sects,size,part->start_sect,addr);
//#endif                
               
                    part->start_sect = addr;           
                    part->nr_sects = size;           

                    disk_part_iter_exit(&piter);
                    return 0;
                

             
            }
        
    }
    disk_part_iter_exit(&piter);

    return 1;
#else
    return 0;
#endif
}
Example #10
0
static int msmsdcc_remove(struct platform_device *pdev)
{
	struct mmc_host *mmc = mmc_get_drvdata(pdev);
	struct mmc_platform_data *plat;
	struct msmsdcc_host *host;

	if (!mmc)
		return -ENXIO;

	host = mmc_priv(mmc);

	DBG(host, "Removing SDCC2 device = %d\n", pdev->id);
	plat = host->plat;

	if (!plat->status_irq)
		sysfs_remove_group(&pdev->dev.kobj, &dev_attr_grp);

	tasklet_kill(&host->dma_tlet);
	mmc_remove_host(mmc);

	if (plat->status_irq)
		free_irq(plat->status_irq, host);

	if (plat->sdiowakeup_irq) {
		set_irq_wake(host->plat->sdiowakeup_irq, 0);
		free_irq(plat->sdiowakeup_irq, host);
	}

	free_irq(host->irqres->start, host);
	free_irq(host->irqres->end, host);

	writel(0, host->base + MMCIMASK0);
	writel(0, host->base + MMCIMASK1);
	writel(MCI_CLEAR_STATIC_MASK, host->base + MMCICLEAR);
	writel(0, host->base + MMCIDATACTRL);
	writel(0, host->base + MMCICOMMAND);

	clk_put(host->clk);
	clk_put(host->pclk);

	dma_free_coherent(NULL, sizeof(struct msmsdcc_nc_dmadata),
			host->dma.nc, host->dma.nc_busaddr);
	iounmap(host->base);
	mmc_free_host(mmc);

#ifdef CONFIG_HAS_EARLYSUSPEND
	unregister_early_suspend(&host->early_suspend);
#endif

	return 0;
}
Example #11
0
static int simple_mmc_get_disk_info(struct mbr_part_info* mpi, unsigned char* name)
{
    char* no_partition_name = "n/a";
    struct disk_part_iter piter;
    struct hd_struct *part;
    struct msdc_host *host;
    struct gendisk *disk;
    struct __mmc_blk_data *md;
    
    /* emmc always in slot0 */
    host = msdc_get_host(MSDC_EMMC,MSDC_BOOT_EN,0);
    BUG_ON(!host);
    BUG_ON(!host->mmc);
    BUG_ON(!host->mmc->card);

    md = mmc_get_drvdata(host->mmc->card);
    BUG_ON(!md);
    BUG_ON(!md->disk);

    disk = md->disk;
    
    /* use this way to find partition info is to avoid handle addr transfer in scatter file 
     * and 64bit address calculate */
    disk_part_iter_init(&piter, disk, 0);
    while ((part = disk_part_iter_next(&piter))){
#if DEBUG_MMC_IOCTL
        printk("part_name = %s    name = %s\n", part->info->volname, name);
#endif                
        if (!strncmp(part->info->volname, name, PARTITION_NAME_LENGTH)){
            mpi->start_sector = part->start_sect;           
            mpi->nr_sects = part->nr_sects;           
            mpi->part_no = part->partno; 
            if (part->info){
                mpi->part_name = part->info->volname;
            } else {
                mpi->part_name = no_partition_name;
            }

            disk_part_iter_exit(&piter);
            return 0;
        }
    }
    disk_part_iter_exit(&piter);

    return 1;
}
Example #12
0
void ReConfigDefaultModeData(int mmc_channel, struct mmc_card *card, enum cardstattype type)
{
	char nodename[19];
	struct mmc_blk_data *md = mmc_get_drvdata(card);

	strcpy(nodename, MMC_BLOCK_PREFIX);

	if(type == CARD_INSERT)
	{
		strcpy(DefaultModeData[mmc_channel].file, strcat(nodename, md->disk->disk_name));
		printk("####### ReConfigDefaultModeData: channel=%d, file=%s\n", mmc_channel, DefaultModeData[mmc_channel].file);
	}
	else
	if(type == CARD_REMOVE)
	{

	}
}
static int
msmsdcc_resume(struct platform_device *dev)
{
//#ifdef LG_FW_SD_CARD
#if 0
	printk(KERN_ERR "[yoohoo] msmsdcc_resume : start \n");
	return 0;
#else
	struct mmc_host *mmc = mmc_get_drvdata(dev);
	struct msmsdcc_host *host = mmc_priv(mmc);
	unsigned long flags;

#ifdef CONFIG_MMC_AUTO_SUSPEND
	if (!test_and_clear_bit(0, &host->suspended))
		return 0;
#endif
	if (mmc) {
		spin_lock_irqsave(&host->lock, flags);
		if (!host->clks_on) {
			clk_enable(host->pclk);
			clk_enable(host->clk);
			host->clks_on = 1;
		}

		writel(MCI_IRQENABLE, host->base + MMCIMASK0);

		spin_unlock_irqrestore(&host->lock, flags);

		if (!mmc->card || mmc->card->type != MMC_TYPE_SDIO)
#ifdef CONFIG_MMC_MSM7X00A_RESUME_IN_WQ
			schedule_work(&host->resume_task);
#else
			mmc_resume_host(mmc);
			if (host->plat->status_irq)
				enable_irq(host->plat->status_irq);
#endif
		else if (host->plat->status_irq)
			enable_irq(host->plat->status_irq);
	}
	return 0;
#endif
}
Example #14
0
static int
msmsdcc_resume(struct platform_device *dev)
{
	struct mmc_host *mmc = mmc_get_drvdata(dev);
	struct msmsdcc_host *host = mmc_priv(mmc);
	unsigned long flags;
	pr_debug("%s ++ entering\n", __func__);

#ifdef CONFIG_MMC_AUTO_SUSPEND
	if (!test_and_clear_bit(0, &host->suspended))
		return 0;
#endif
	if (mmc) {
		spin_lock_irqsave(&host->lock, flags);
		if (!host->clks_on) {
			clk_enable(host->pclk);
			clk_enable(host->clk);
			host->clks_on = 1;
		}

		writel(host->mci_irqenable, host->base + MMCIMASK0);

		spin_unlock_irqrestore(&host->lock, flags);

		if (host->plat->sdiowakeup_irq)
			disable_irq(host->plat->sdiowakeup_irq);

		if (!mmc->card || mmc->card->type != MMC_TYPE_SDIO) {
#ifdef CONFIG_MMC_MSM7X00A_RESUME_IN_WQ
			schedule_work(&host->resume_task);
#else
			mmc_resume_host(mmc);
			if (host->plat->status_irq)
				enable_irq(host->plat->status_irq);
#endif
		} else if (host->plat->status_irq)
			enable_irq(host->plat->status_irq);

	}
	pr_debug("%s -- leaving\n", __func__);
	return 0;
}
Example #15
0
static void mmc_blk_remove(struct mmc_card *card)
{
	struct mmc_blk_data *md = mmc_get_drvdata(card);

	if (md) {
		int devidx;

		/* Stop new requests from getting into the queue */
		del_gendisk(md->disk);

		/* Then flush out any already in there */
		mmc_cleanup_queue(&md->queue);

		devidx = md->disk->first_minor >> MMC_SHIFT;
		__clear_bit(devidx, dev_use);

		mmc_blk_put(md);
	}
	mmc_set_drvdata(card, NULL);
}
Example #16
0
static void mmc_blk_remove(struct mmc_card *card)
{
	struct mmc_blk_data *md = mmc_get_drvdata(card);

	if (md) {
		int devidx;

		del_gendisk(md->disk);

		/*
		 * I think this is needed.
		 */
		md->disk->queue = NULL;

		devidx = md->disk->first_minor >> MMC_SHIFT;
		__clear_bit(devidx, dev_use);

		mmc_blk_put(md);
	}
	mmc_set_drvdata(card, NULL);
}
int msmsdcc_remove(struct platform_device *dev)
{
	struct mmc_host *mmc = mmc_get_drvdata(dev);
	struct msmsdcc_host *host = mmc_priv(mmc);

#if defined(CONFIG_DEBUG_FS)
	msmsdcc_dbg_deletehost();
#endif
	mmc_release_host(mmc);
	free_irq(host->irqres->start, host);
	free_irq(host->irqres->end, host);
	if (host->stat_irq)
		free_irq(host->stat_irq, host);

	spin_lock(&host->lock);

	del_timer(&host->timer);
	del_timer(&host->command_timer);

	clk_disable(host->clk);
	clk_put(host->clk);
	clk_disable(host->pclk);
	clk_put(host->pclk);

	dma_free_coherent(
	    NULL,
	    sizeof(struct msmsdcc_nc_dmadata),
	    host->dma.nc,
	    host->dma.nc_busaddr);

	spin_unlock(&host->lock);

	mmc_free_host(mmc);

	return 0;
}
static int
msmsdcc_suspend(struct platform_device *dev, pm_message_t state)
{
//#ifdef LG_FW_SD_CARD
#if 0
	printk(KERN_ERR "[yoohoo] msmsdcc_suspend : start \n");
	return 0;
#else
	struct mmc_host *mmc = mmc_get_drvdata(dev);
	struct msmsdcc_host *host = mmc_priv(mmc);
	int rc = 0;

#ifdef CONFIG_MMC_AUTO_SUSPEND
	if (test_and_set_bit(0, &host->suspended))
		return 0;
#endif
	if (mmc) {
		if (host->plat->status_irq)
			disable_irq(host->plat->status_irq);

		if (!mmc->card || mmc->card->type != MMC_TYPE_SDIO)
			rc = mmc_suspend_host(mmc, state);
		if (!rc) {
			writel(0, host->base + MMCIMASK0);

			if (host->clks_on) {
				clk_disable(host->clk);
				clk_disable(host->pclk);
				host->clks_on = 0;
			}
		}
	}
	return rc;
#endif

}