Beispiel #1
0
static int mmc_clk_try_enable(struct mmc_omap_host *host)
{
	unsigned long flags;
	int ret = 0;

	spin_lock_irqsave(&host->clk_lock, flags);
	if (host->ifclks_enabled)
		goto done;
	ret = clk_enable(host->iclk);
	if (ret)
		goto clk_en_err1;
	ret = clk_enable(host->fclk);
	if (ret)
		goto clk_en_err2;
	host->ifclks_enabled = 1;

#ifdef CONFIG_OMAP34XX_OFFMODE
	if (context_restore_required(host->fclk))
		omap2_hsmmc_restore_ctx(host);
#endif

done:
	spin_unlock_irqrestore(&host->clk_lock, flags);
	return ret;

clk_en_err2:
	clk_disable(host->iclk);
clk_en_err1:
	dev_dbg(mmc_dev(host->mmc),
		"Unable to enable MMC clocks \n");
	spin_unlock_irqrestore(&host->clk_lock, flags);
	return ret;
}
static int omap_hsmmc_enable_clks(struct mmc_omap_host *host)
{
	unsigned long flags, timeout;
	int ret = 0;

	spin_lock_irqsave(&host->clk_lock, flags);

	if (host->clks_enabled)
		goto done;

	ret = clk_enable(host->iclk);
	if (ret)
		goto clk_en_err1;

	ret = clk_enable(host->fclk);
	if (ret)
		goto clk_en_err2;

	host->clks_enabled = 1;

	if (cpu_is_omap2430()) {
		/*
		 * MMC can still work without debounce clock.
		 */
		if (IS_ERR(host->dbclk))
			dev_warn(mmc_dev(host->mmc),
			"Failed to get debounce clock\n");
		else
			if (clk_enable(host->dbclk) != 0)
				dev_dbg(mmc_dev(host->mmc), "Enabling debounce"
						" clk failed\n");
			else
				host->dbclk_enabled = 1;
	}

	if (!(host->pdata->context_loss) ||
		(host->pdata->context_loss(host->dev) != host->off_counter)) {
			/* Coming out of OFF:
			 * The SRA bit of SYSCTL reg has a wrong reset
			 * value.
			 * The bit resets automatically in subsequent
			 * reads. Idealy it should have been 0 as per
			 * the reset value of the register.
			 * Wait for the reset to complete */
			timeout = jiffies +
				msecs_to_jiffies(MMC_TIMEOUT_MS);
			while ((OMAP_HSMMC_READ(host->base, SYSSTATUS)
				& RESETDONE) != RESETDONE
				&& time_before(jiffies, timeout))
				;
			omap2_hsmmc_restore_ctx(host);
	}

done:
	spin_unlock_irqrestore(&host->clk_lock, flags);
	return ret;
clk_en_err2:
	clk_disable(host->iclk);
clk_en_err1:
	dev_dbg(mmc_dev(host->mmc),
		"Unable to enable MMC clocks \n");
	spin_unlock_irqrestore(&host->clk_lock, flags);
	return ret;
}