static int ti_pipe3_enable_clocks(struct ti_pipe3 *phy)
{
	int ret = 0;

	ret = ti_pipe3_enable_refclk(phy);
	if (ret)
		return ret;

	if (!IS_ERR(phy->wkupclk)) {
		ret = clk_prepare_enable(phy->wkupclk);
		if (ret) {
			dev_err(phy->dev, "Failed to enable wkupclk %d\n", ret);
			goto disable_refclk;
		}
	}

	if (!IS_ERR(phy->div_clk)) {
		ret = clk_prepare_enable(phy->div_clk);
		if (ret) {
			dev_err(phy->dev, "Failed to enable div_clk %d\n", ret);
			goto disable_wkupclk;
		}
	}

	return 0;

disable_wkupclk:
	if (!IS_ERR(phy->wkupclk))
		clk_disable_unprepare(phy->wkupclk);
disable_refclk:
	ti_pipe3_disable_refclk(phy);

	return ret;
}
Example #2
0
static int ti_pipe3_enable_clocks(struct ti_pipe3 *phy)
{
	int ret = 0;
	unsigned long flags;

	spin_lock_irqsave(&phy->lock, flags);
	if (phy->enabled)
		goto err1;

	ret = ti_pipe3_enable_refclk(phy);
	if (ret)
		goto err1;

	if (!IS_ERR(phy->wkupclk)) {
		ret = clk_prepare_enable(phy->wkupclk);
		if (ret) {
			dev_err(phy->dev, "Failed to enable wkupclk %d\n", ret);
			goto err2;
		}
	}

	if (!IS_ERR(phy->div_clk)) {
		ret = clk_prepare_enable(phy->div_clk);
		if (ret) {
			dev_err(phy->dev, "Failed to enable div_clk %d\n", ret);
			goto err3;
		}
	}

	phy->enabled = true;
	spin_unlock_irqrestore(&phy->lock, flags);
	return 0;

err3:
	if (!IS_ERR(phy->wkupclk))
		clk_disable_unprepare(phy->wkupclk);

err2:
	if (!IS_ERR(phy->refclk))
		clk_disable_unprepare(phy->refclk);

	ti_pipe3_disable_refclk(phy);
err1:
	spin_unlock_irqrestore(&phy->lock, flags);
	return ret;
}