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;
}
static void ti_pipe3_disable_clocks(struct ti_pipe3 *phy)
{
	if (!IS_ERR(phy->wkupclk))
		clk_disable_unprepare(phy->wkupclk);
	ti_pipe3_disable_refclk(phy);
	if (!IS_ERR(phy->div_clk))
		clk_disable_unprepare(phy->div_clk);
}
Ejemplo n.º 3
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;
}
Ejemplo n.º 4
0
static void ti_pipe3_disable_clocks(struct ti_pipe3 *phy)
{
	unsigned long flags;

	spin_lock_irqsave(&phy->lock, flags);
	if (!phy->enabled) {
		spin_unlock_irqrestore(&phy->lock, flags);
		return;
	}

	if (!IS_ERR(phy->wkupclk))
		clk_disable_unprepare(phy->wkupclk);
	/* Don't disable refclk for SATA PHY due to Errata i783 */
	if (!of_device_is_compatible(phy->dev->of_node, "ti,phy-pipe3-sata"))
		ti_pipe3_disable_refclk(phy);
	if (!IS_ERR(phy->div_clk))
		clk_disable_unprepare(phy->div_clk);
	phy->enabled = false;
	spin_unlock_irqrestore(&phy->lock, flags);
}