Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b3aa55fb authored by Jeff Ohlstein's avatar Jeff Ohlstein Committed by Stephen Boyd
Browse files

msm: dma: Use clk_prepare and clk_unprepare



clk_prepare and clk_unprepare are now required to be called before
clk_enable and after clk_disable. Do this for the dma driver.
Additionally, split the msm_dmov_clk_toggle function into two, since we
always know the value of the second argument at compile time.

CRs-Fixed: 366651
Change-Id: I0ed229187f49352cfe59cbbf211f5cdabfe06a9d
Signed-off-by: default avatarJeff Ohlstein <johlstei@codeaurora.org>
parent 32a24796
Loading
Loading
Loading
Loading
+31 −32
Original line number Original line Diff line number Diff line
@@ -74,7 +74,6 @@ struct msm_dmov_conf {
};
};


static void msm_dmov_clock_work(struct work_struct *);
static void msm_dmov_clock_work(struct work_struct *);
static int msm_dmov_clk_toggle(int, int);


#ifdef CONFIG_ARCH_MSM8X60
#ifdef CONFIG_ARCH_MSM8X60


@@ -232,40 +231,40 @@ unsigned int msm_dmov_print_mask = MSM_DMOV_PRINT_ERRORS;
#define PRINT_FLOW(format, args...) \
#define PRINT_FLOW(format, args...) \
	MSM_DMOV_DPRINTF(MSM_DMOV_PRINT_FLOW, format, args);
	MSM_DMOV_DPRINTF(MSM_DMOV_PRINT_FLOW, format, args);


static int msm_dmov_clk_toggle(int adm, int on)
static int msm_dmov_clk_on(int adm)
{
{
	int ret = 0;
	int ret;


	if (on) {
	ret = clk_prepare_enable(dmov_conf[adm].clk);
		ret = clk_enable(dmov_conf[adm].clk);
	if (ret)
	if (ret)
			goto err;
		return ret;
	if (dmov_conf[adm].pclk) {
	if (dmov_conf[adm].pclk) {
			ret = clk_enable(dmov_conf[adm].pclk);
		ret = clk_prepare_enable(dmov_conf[adm].pclk);
		if (ret) {
		if (ret) {
				clk_disable(dmov_conf[adm].clk);
			clk_disable_unprepare(dmov_conf[adm].clk);
				goto err;
			return ret;
		}
		}
	}
	}
	if (dmov_conf[adm].ebiclk) {
	if (dmov_conf[adm].ebiclk) {
			ret = clk_enable(dmov_conf[adm].ebiclk);
		ret = clk_prepare_enable(dmov_conf[adm].ebiclk);
		if (ret) {
		if (ret) {
			if (dmov_conf[adm].pclk)
			if (dmov_conf[adm].pclk)
					clk_disable(dmov_conf[adm].pclk);
				clk_disable_unprepare(dmov_conf[adm].pclk);
				clk_disable(dmov_conf[adm].clk);
			clk_disable_unprepare(dmov_conf[adm].clk);
		}
		}
	}
	}
	} else {
		clk_disable(dmov_conf[adm].clk);
		if (dmov_conf[adm].pclk)
			clk_disable(dmov_conf[adm].pclk);
		if (dmov_conf[adm].ebiclk)
			clk_disable(dmov_conf[adm].ebiclk);
	}
err:
	return ret;
	return ret;
}
}


static void msm_dmov_clk_off(int adm)
{
	if (dmov_conf[adm].ebiclk)
		clk_disable_unprepare(dmov_conf[adm].ebiclk);
	if (dmov_conf[adm].pclk)
		clk_disable_unprepare(dmov_conf[adm].pclk);
	clk_disable_unprepare(dmov_conf[adm].clk);
}

static void msm_dmov_clock_work(struct work_struct *work)
static void msm_dmov_clock_work(struct work_struct *work)
{
{
	struct msm_dmov_conf *conf =
	struct msm_dmov_conf *conf =
@@ -274,7 +273,7 @@ static void msm_dmov_clock_work(struct work_struct *work)
	mutex_lock(&conf->lock);
	mutex_lock(&conf->lock);
	if (conf->clk_ctl == CLK_TO_BE_DIS) {
	if (conf->clk_ctl == CLK_TO_BE_DIS) {
		BUG_ON(conf->channel_active);
		BUG_ON(conf->channel_active);
		msm_dmov_clk_toggle(adm, 0);
		msm_dmov_clk_off(adm);
		conf->clk_ctl = CLK_DIS;
		conf->clk_ctl = CLK_DIS;
	}
	}
	mutex_unlock(&conf->lock);
	mutex_unlock(&conf->lock);
@@ -321,7 +320,7 @@ static void msm_dmov_enqueue_cmd_ext_work(struct work_struct *work)


	mutex_lock(&dmov_conf[adm].lock);
	mutex_lock(&dmov_conf[adm].lock);
	if (dmov_conf[adm].clk_ctl == CLK_DIS) {
	if (dmov_conf[adm].clk_ctl == CLK_DIS) {
		status = msm_dmov_clk_toggle(adm, 1);
		status = msm_dmov_clk_on(adm);
		if (status != 0)
		if (status != 0)
			goto error;
			goto error;
	}
	}
@@ -588,7 +587,7 @@ static int msm_dmov_suspend_late(struct device *dev)
	mutex_lock(&dmov_conf[adm].lock);
	mutex_lock(&dmov_conf[adm].lock);
	if (dmov_conf[adm].clk_ctl == CLK_TO_BE_DIS) {
	if (dmov_conf[adm].clk_ctl == CLK_TO_BE_DIS) {
		BUG_ON(dmov_conf[adm].channel_active);
		BUG_ON(dmov_conf[adm].channel_active);
		msm_dmov_clk_toggle(adm, 0);
		msm_dmov_clk_off(adm);
		dmov_conf[adm].clk_ctl = CLK_DIS;
		dmov_conf[adm].clk_ctl = CLK_DIS;
	}
	}
	mutex_unlock(&dmov_conf[adm].lock);
	mutex_unlock(&dmov_conf[adm].lock);
@@ -726,7 +725,7 @@ static int msm_dmov_probe(struct platform_device *pdev)
		PRINT_ERROR("Requesting ADM%d clocks failed\n", adm);
		PRINT_ERROR("Requesting ADM%d clocks failed\n", adm);
		goto out_irq;
		goto out_irq;
	}
	}
	ret = msm_dmov_clk_toggle(adm, 1);
	ret = msm_dmov_clk_on(adm);
	if (ret) {
	if (ret) {
		PRINT_ERROR("Enabling ADM%d clocks failed\n", adm);
		PRINT_ERROR("Enabling ADM%d clocks failed\n", adm);
		goto out_irq;
		goto out_irq;
@@ -743,7 +742,7 @@ static int msm_dmov_probe(struct platform_device *pdev)
		     DMOV_REG(DMOV_RSLT_CONF(i), adm));
		     DMOV_REG(DMOV_RSLT_CONF(i), adm));
	}
	}
	wmb();
	wmb();
	msm_dmov_clk_toggle(adm, 0);
	msm_dmov_clk_off(adm);
	return ret;
	return ret;
out_irq:
out_irq:
	free_irq(dmov_conf[adm].irq, NULL);
	free_irq(dmov_conf[adm].irq, NULL);