int mdss_dsi_clk_ctrl(struct mdss_dsi_ctrl_pdata *ctrl, int enable)
{
	int rc = 0;

	mutex_lock(&ctrl->mutex);
	if (enable) {
		if (ctrl->clk_cnt == 0) {
			rc = mdss_dsi_enable_bus_clocks(ctrl);
			if (rc) {
				pr_err("%s: failed to enable bus clks. rc=%d\n",
					__func__, rc);
				goto error;
			}

			rc = mdss_dsi_clk_set_rate(ctrl);
			if (rc) {
				pr_err("%s: failed to set clk rates. rc=%d\n",
					__func__, rc);
				mdss_dsi_disable_bus_clocks(ctrl);
				goto error;
			}

			rc = mdss_dsi_clk_prepare(ctrl);
			if (rc) {
				pr_err("%s: failed to prepare clks. rc=%d\n",
					__func__, rc);
				mdss_dsi_disable_bus_clocks(ctrl);
				goto error;
			}

			rc = mdss_dsi_clk_enable(ctrl);
			if (rc) {
				pr_err("%s: failed to enable clks. rc=%d\n",
					__func__, rc);
				mdss_dsi_clk_unprepare(ctrl);
				mdss_dsi_disable_bus_clocks(ctrl);
				goto error;
			}
		}
		ctrl->clk_cnt++;
	} else {
		if (ctrl->clk_cnt) {
			ctrl->clk_cnt--;
			if (ctrl->clk_cnt == 0) {
				mdss_dsi_clk_disable(ctrl);
				mdss_dsi_clk_unprepare(ctrl);
				mdss_dsi_disable_bus_clocks(ctrl);
			}
		}
	}
	pr_debug("%s: ctrl ndx=%d enabled=%d clk_cnt=%d\n",
			__func__, ctrl->ndx, enable, ctrl->clk_cnt);

error:
	mutex_unlock(&ctrl->mutex);
	return rc;
}
Esempio n. 2
0
static int mdss_dsi_enable_clks(struct mdss_dsi_ctrl_pdata *ctrl)
{
	int rc = 0;

			rc = mdss_dsi_enable_bus_clocks(ctrl);
			if (rc) {
				pr_err("%s: failed to enable bus clks. rc=%d\n",
					__func__, rc);
				goto error;
			}

			rc = mdss_dsi_clk_set_rate(ctrl);
			if (rc) {
				pr_err("%s: failed to set clk rates. rc=%d\n",
					__func__, rc);
				mdss_dsi_disable_bus_clocks(ctrl);
				goto error;
			}

			rc = mdss_dsi_clk_prepare(ctrl);
			if (rc) {
				pr_err("%s: failed to prepare clks. rc=%d\n",
					__func__, rc);
				mdss_dsi_disable_bus_clocks(ctrl);
				goto error;
			}

			rc = mdss_dsi_clk_enable(ctrl);
			if (rc) {
				pr_err("%s: failed to enable clks. rc=%d\n",
					__func__, rc);
				mdss_dsi_clk_unprepare(ctrl);
				mdss_dsi_disable_bus_clocks(ctrl);
				goto error;
			}

error:
	return rc;
}
static int mdss_dsi_enable_clks(struct mdss_dsi_ctrl_pdata *ctrl)
{
	int rc = 0;
#if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OCTA_CMD_WQXGA_S6TNMR7_PT_PANEL)
	rc = mdss_dsi_clk_set_rate(ctrl);
	if (rc) {
		pr_err("%s: failed to set clk rates. rc=%d\n",
			__func__, rc);
		goto error;
	}

	rc = mdss_dsi_clk_prepare(ctrl);
	if (rc) {
		pr_err("%s: failed to prepare clks. rc=%d\n",
			__func__, rc);
		goto error;
	}

	rc = mdss_dsi_clk_enable(ctrl);
	if (rc) {
		pr_err("%s: failed to enable clks. rc=%d\n",
			__func__, rc);
		mdss_dsi_clk_unprepare(ctrl);
		goto error;
	}
#else
	rc = mdss_dsi_enable_bus_clocks(ctrl);
	if (rc) {
		pr_err("%s: failed to enable bus clks. rc=%d\n",
			__func__, rc);
		goto error;
	}

	rc = mdss_dsi_clk_set_rate(ctrl);
	if (rc) {
		pr_err("%s: failed to set clk rates. rc=%d\n",
			__func__, rc);
		mdss_dsi_disable_bus_clocks(ctrl);
		goto error;
	}

	rc = mdss_dsi_clk_prepare(ctrl);
	if (rc) {
		pr_err("%s: failed to prepare clks. rc=%d\n",
			__func__, rc);
		mdss_dsi_disable_bus_clocks(ctrl);
		goto error;
	}

	rc = mdss_dsi_clk_enable(ctrl);
	if (rc) {
		pr_err("%s: failed to enable clks. rc=%d\n",
			__func__, rc);
		mdss_dsi_clk_unprepare(ctrl);
		mdss_dsi_disable_bus_clocks(ctrl);
		goto error;
	}

#endif

error:
	return rc;
}