/* * acquire ctrl->mutex first */ void mdss_dsi_clk_ctrl(struct mdss_dsi_ctrl_pdata *ctrl, int enable) { mutex_lock(&ctrl->mutex); if (enable) { if (ctrl->clk_cnt == 0) { mdss_dsi_enable_bus_clocks(ctrl); mdss_dsi_prepare_clocks(ctrl); mdss_dsi_clk_enable(ctrl); } ctrl->clk_cnt++; } else { if (ctrl->clk_cnt) { ctrl->clk_cnt--; if (ctrl->clk_cnt == 0) { mdss_dsi_clk_disable(ctrl); mdss_dsi_unprepare_clocks(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); mutex_unlock(&ctrl->mutex); }
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; }
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_on(struct mdss_panel_data *pdata) { int ret = 0; u32 clk_rate; struct mdss_panel_info *pinfo; struct mipi_panel_info *mipi; u32 hbp, hfp, vbp, vfp, hspw, vspw, width, height; u32 ystride, bpp, data; u32 dummy_xres, dummy_yres; struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL; ctrl_pdata = container_of(pdata, struct mdss_dsi_ctrl_pdata, panel_data); if (!ctrl_pdata) { pr_err("%s: Invalid input data\n", __func__); return -EINVAL; } pinfo = &pdata->panel_info; ret = mdss_dsi_panel_power_on(1); if (ret) { pr_err("%s: Panel power on failed\n", __func__); return ret; } mdss_dsi_phy_sw_reset((ctrl_pdata->ctrl_base)); mdss_dsi_phy_init(pdata); mdss_dsi_prepare_clocks(); mdss_dsi_clk_enable(pdata); clk_rate = pdata->panel_info.clk_rate; clk_rate = min(clk_rate, pdata->panel_info.clk_max); hbp = pdata->panel_info.lcdc.h_back_porch; hfp = pdata->panel_info.lcdc.h_front_porch; vbp = pdata->panel_info.lcdc.v_back_porch; vfp = pdata->panel_info.lcdc.v_front_porch; hspw = pdata->panel_info.lcdc.h_pulse_width; vspw = pdata->panel_info.lcdc.v_pulse_width; width = pdata->panel_info.xres; height = pdata->panel_info.yres; mipi = &pdata->panel_info.mipi; if (pdata->panel_info.type == MIPI_VIDEO_PANEL) { dummy_xres = pdata->panel_info.lcdc.xres_pad; dummy_yres = pdata->panel_info.lcdc.yres_pad; MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x24, ((hspw + hbp + width + dummy_xres) << 16 | (hspw + hbp))); MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x28, ((vspw + vbp + height + dummy_yres) << 16 | (vspw + vbp))); MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x2C, (vspw + vbp + height + dummy_yres + vfp - 1) << 16 | (hspw + hbp + width + dummy_xres + hfp - 1)); MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x30, (hspw << 16)); MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x34, 0); MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x38, (vspw << 16)); } else { /* command mode */ if (mipi->dst_format == DSI_CMD_DST_FORMAT_RGB888) bpp = 3; else if (mipi->dst_format == DSI_CMD_DST_FORMAT_RGB666) bpp = 3; else if (mipi->dst_format == DSI_CMD_DST_FORMAT_RGB565) bpp = 2; else bpp = 3; /* Default format set to RGB888 */ ystride = width * bpp + 1; /* DSI_COMMAND_MODE_MDP_STREAM_CTRL */ data = (ystride << 16) | (mipi->vc << 8) | DTYPE_DCS_LWRITE; MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x60, data); MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x58, data); /* DSI_COMMAND_MODE_MDP_STREAM_TOTAL */ data = height << 16 | width; MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x64, data); MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x5C, data); } mdss_dsi_sw_reset(pdata); mdss_dsi_host_init(mipi, pdata); if (mipi->force_clk_lane_hs) { u32 tmp; tmp = MIPI_INP((ctrl_pdata->ctrl_base) + 0xac); tmp |= (1<<28); MIPI_OUTP((ctrl_pdata->ctrl_base) + 0xac, tmp); wmb(); } ret = ctrl_pdata->on(pdata); if (ret) { pr_err("%s: unable to initialize the panel\n", __func__); return ret; } mdss_dsi_op_mode_config(mipi->mode, pdata); pr_debug("%s-:\n", __func__); return ret; }
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; }