2013-12-31 01:22:42 +00:00
|
|
|
/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
|
2012-04-24 03:39:17 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 and
|
|
|
|
* only version 2 as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/io.h>
|
|
|
|
#include <linux/of_device.h>
|
2012-12-14 06:49:58 +00:00
|
|
|
#include <linux/of_gpio.h>
|
|
|
|
#include <linux/gpio.h>
|
2012-08-14 05:57:11 +00:00
|
|
|
#include <linux/err.h>
|
|
|
|
#include <linux/regulator/consumer.h>
|
2012-04-24 03:39:17 +00:00
|
|
|
|
|
|
|
#include "mdss.h"
|
|
|
|
#include "mdss_panel.h"
|
|
|
|
#include "mdss_dsi.h"
|
2013-03-26 21:10:40 +00:00
|
|
|
#include "mdss_debug.h"
|
2012-04-24 03:39:17 +00:00
|
|
|
|
2013-03-12 22:19:17 +00:00
|
|
|
static int mdss_dsi_regulator_init(struct platform_device *pdev)
|
2012-08-14 05:57:11 +00:00
|
|
|
{
|
2013-03-12 22:19:17 +00:00
|
|
|
struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL;
|
2012-12-14 06:49:58 +00:00
|
|
|
|
2013-03-12 22:19:17 +00:00
|
|
|
if (!pdev) {
|
|
|
|
pr_err("%s: invalid input\n", __func__);
|
|
|
|
return -EINVAL;
|
2012-08-14 05:57:11 +00:00
|
|
|
}
|
|
|
|
|
2013-03-12 22:19:17 +00:00
|
|
|
ctrl_pdata = platform_get_drvdata(pdev);
|
|
|
|
if (!ctrl_pdata) {
|
|
|
|
pr_err("%s: invalid driver data\n", __func__);
|
2012-08-14 05:57:11 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2013-06-29 01:35:23 +00:00
|
|
|
return msm_dss_config_vreg(&pdev->dev,
|
|
|
|
ctrl_pdata->power_data.vreg_config,
|
|
|
|
ctrl_pdata->power_data.num_vreg, 1);
|
2012-08-14 05:57:11 +00:00
|
|
|
}
|
|
|
|
|
2012-12-14 06:49:58 +00:00
|
|
|
static int mdss_dsi_panel_power_on(struct mdss_panel_data *pdata, int enable)
|
2012-08-14 05:57:11 +00:00
|
|
|
{
|
|
|
|
int ret;
|
2012-12-14 06:49:58 +00:00
|
|
|
struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL;
|
|
|
|
|
|
|
|
if (pdata == NULL) {
|
|
|
|
pr_err("%s: Invalid input data\n", __func__);
|
2013-06-29 01:35:23 +00:00
|
|
|
ret = -EINVAL;
|
|
|
|
goto error;
|
2012-12-14 06:49:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ctrl_pdata = container_of(pdata, struct mdss_dsi_ctrl_pdata,
|
|
|
|
panel_data);
|
2012-08-14 05:57:11 +00:00
|
|
|
pr_debug("%s: enable=%d\n", __func__, enable);
|
|
|
|
|
|
|
|
if (enable) {
|
2013-06-29 01:35:23 +00:00
|
|
|
ret = msm_dss_enable_vreg(
|
|
|
|
ctrl_pdata->power_data.vreg_config,
|
|
|
|
ctrl_pdata->power_data.num_vreg, 1);
|
|
|
|
if (ret) {
|
|
|
|
pr_err("%s:Failed to enable vregs.rc=%d\n",
|
|
|
|
__func__, ret);
|
|
|
|
goto error;
|
2012-08-14 05:57:11 +00:00
|
|
|
}
|
|
|
|
|
2014-02-04 18:56:01 +00:00
|
|
|
ret = mdss_dsi_panel_reset(pdata, 1);
|
|
|
|
if (ret) {
|
|
|
|
pr_err("%s: Panel reset failed. rc=%d\n",
|
|
|
|
__func__, ret);
|
|
|
|
if (msm_dss_enable_vreg(
|
|
|
|
ctrl_pdata->power_data.vreg_config,
|
|
|
|
ctrl_pdata->power_data.num_vreg, 0))
|
|
|
|
pr_err("Disable vregs failed\n");
|
|
|
|
goto error;
|
2013-11-21 01:25:19 +00:00
|
|
|
}
|
2012-08-14 05:57:11 +00:00
|
|
|
} else {
|
2012-08-14 06:23:11 +00:00
|
|
|
|
2013-11-21 01:25:19 +00:00
|
|
|
ret = mdss_dsi_panel_reset(pdata, 0);
|
|
|
|
if (ret) {
|
|
|
|
pr_err("%s: Panel reset failed. rc=%d\n",
|
|
|
|
__func__, ret);
|
|
|
|
goto error;
|
|
|
|
}
|
2013-06-29 01:35:23 +00:00
|
|
|
ret = msm_dss_enable_vreg(
|
|
|
|
ctrl_pdata->power_data.vreg_config,
|
|
|
|
ctrl_pdata->power_data.num_vreg, 0);
|
|
|
|
if (ret) {
|
|
|
|
pr_err("%s: Failed to disable vregs.rc=%d\n",
|
|
|
|
__func__, ret);
|
2012-08-14 05:57:11 +00:00
|
|
|
}
|
|
|
|
}
|
2013-06-29 01:35:23 +00:00
|
|
|
error:
|
|
|
|
return ret;
|
2012-08-14 05:57:11 +00:00
|
|
|
}
|
2012-04-24 03:39:17 +00:00
|
|
|
|
2013-03-12 22:19:17 +00:00
|
|
|
static void mdss_dsi_put_dt_vreg_data(struct device *dev,
|
|
|
|
struct dss_module_power *module_power)
|
|
|
|
{
|
|
|
|
if (!module_power) {
|
|
|
|
pr_err("%s: invalid input\n", __func__);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (module_power->vreg_config) {
|
|
|
|
devm_kfree(dev, module_power->vreg_config);
|
|
|
|
module_power->vreg_config = NULL;
|
|
|
|
}
|
|
|
|
module_power->num_vreg = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mdss_dsi_get_dt_vreg_data(struct device *dev,
|
|
|
|
struct dss_module_power *mp)
|
|
|
|
{
|
2013-06-29 01:35:23 +00:00
|
|
|
int i = 0, rc = 0;
|
|
|
|
u32 tmp = 0;
|
|
|
|
struct device_node *of_node = NULL, *supply_node = NULL;
|
2013-03-12 22:19:17 +00:00
|
|
|
|
|
|
|
if (!dev || !mp) {
|
|
|
|
pr_err("%s: invalid input\n", __func__);
|
|
|
|
rc = -EINVAL;
|
2013-11-15 04:19:37 +00:00
|
|
|
return rc;
|
2013-03-12 22:19:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
of_node = dev->of_node;
|
|
|
|
|
|
|
|
mp->num_vreg = 0;
|
2013-06-29 01:35:23 +00:00
|
|
|
for_each_child_of_node(of_node, supply_node) {
|
|
|
|
if (!strncmp(supply_node->name, "qcom,platform-supply-entry",
|
|
|
|
26))
|
|
|
|
++mp->num_vreg;
|
2013-03-12 22:19:17 +00:00
|
|
|
}
|
2013-06-29 01:35:23 +00:00
|
|
|
if (mp->num_vreg == 0) {
|
2013-03-12 22:19:17 +00:00
|
|
|
pr_debug("%s: no vreg\n", __func__);
|
2013-06-29 01:35:23 +00:00
|
|
|
goto novreg;
|
|
|
|
} else {
|
|
|
|
pr_debug("%s: vreg found. count=%d\n", __func__, mp->num_vreg);
|
2013-03-12 22:19:17 +00:00
|
|
|
}
|
|
|
|
|
2013-06-29 01:35:23 +00:00
|
|
|
mp->vreg_config = devm_kzalloc(dev, sizeof(struct dss_vreg) *
|
|
|
|
mp->num_vreg, GFP_KERNEL);
|
|
|
|
if (!mp->vreg_config) {
|
|
|
|
pr_err("%s: can't alloc vreg mem\n", __func__);
|
2013-03-12 22:19:17 +00:00
|
|
|
rc = -ENOMEM;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2013-06-29 01:35:23 +00:00
|
|
|
for_each_child_of_node(of_node, supply_node) {
|
|
|
|
if (!strncmp(supply_node->name, "qcom,platform-supply-entry",
|
|
|
|
26)) {
|
|
|
|
const char *st = NULL;
|
|
|
|
/* vreg-name */
|
|
|
|
rc = of_property_read_string(supply_node,
|
|
|
|
"qcom,supply-name", &st);
|
|
|
|
if (rc) {
|
|
|
|
pr_err("%s: error reading name. rc=%d\n",
|
|
|
|
__func__, rc);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
snprintf(mp->vreg_config[i].vreg_name,
|
|
|
|
ARRAY_SIZE((mp->vreg_config[i].vreg_name)),
|
|
|
|
"%s", st);
|
|
|
|
/* vreg-min-voltage */
|
|
|
|
rc = of_property_read_u32(supply_node,
|
|
|
|
"qcom,supply-min-voltage", &tmp);
|
|
|
|
if (rc) {
|
|
|
|
pr_err("%s: error reading min volt. rc=%d\n",
|
|
|
|
__func__, rc);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
mp->vreg_config[i].min_voltage = tmp;
|
|
|
|
|
|
|
|
/* vreg-max-voltage */
|
|
|
|
rc = of_property_read_u32(supply_node,
|
|
|
|
"qcom,supply-max-voltage", &tmp);
|
|
|
|
if (rc) {
|
|
|
|
pr_err("%s: error reading max volt. rc=%d\n",
|
|
|
|
__func__, rc);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
mp->vreg_config[i].max_voltage = tmp;
|
|
|
|
|
|
|
|
/* enable-load */
|
|
|
|
rc = of_property_read_u32(supply_node,
|
|
|
|
"qcom,supply-enable-load", &tmp);
|
|
|
|
if (rc) {
|
|
|
|
pr_err("%s: error reading enable load. rc=%d\n",
|
|
|
|
__func__, rc);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
mp->vreg_config[i].enable_load = tmp;
|
|
|
|
|
|
|
|
/* disable-load */
|
|
|
|
rc = of_property_read_u32(supply_node,
|
|
|
|
"qcom,supply-disable-load", &tmp);
|
|
|
|
if (rc) {
|
|
|
|
pr_err("%s: error reading disable load. rc=%d\n",
|
|
|
|
__func__, rc);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
mp->vreg_config[i].disable_load = tmp;
|
|
|
|
|
|
|
|
/* pre-sleep */
|
|
|
|
rc = of_property_read_u32(supply_node,
|
|
|
|
"qcom,supply-pre-on-sleep", &tmp);
|
|
|
|
if (rc) {
|
|
|
|
pr_debug("%s: error reading supply pre sleep value. rc=%d\n",
|
|
|
|
__func__, rc);
|
|
|
|
}
|
|
|
|
mp->vreg_config[i].pre_on_sleep = (!rc ? tmp : 0);
|
2013-03-12 22:19:17 +00:00
|
|
|
|
2013-06-29 01:35:23 +00:00
|
|
|
rc = of_property_read_u32(supply_node,
|
|
|
|
"qcom,supply-pre-off-sleep", &tmp);
|
|
|
|
if (rc) {
|
|
|
|
pr_debug("%s: error reading supply pre sleep value. rc=%d\n",
|
|
|
|
__func__, rc);
|
|
|
|
}
|
|
|
|
mp->vreg_config[i].pre_off_sleep = (!rc ? tmp : 0);
|
|
|
|
|
|
|
|
/* post-sleep */
|
|
|
|
rc = of_property_read_u32(supply_node,
|
|
|
|
"qcom,supply-post-on-sleep", &tmp);
|
|
|
|
if (rc) {
|
|
|
|
pr_debug("%s: error reading supply post sleep value. rc=%d\n",
|
|
|
|
__func__, rc);
|
|
|
|
}
|
|
|
|
mp->vreg_config[i].post_on_sleep = (!rc ? tmp : 0);
|
2013-03-12 22:19:17 +00:00
|
|
|
|
2013-06-29 01:35:23 +00:00
|
|
|
rc = of_property_read_u32(supply_node,
|
|
|
|
"qcom,supply-post-off-sleep", &tmp);
|
|
|
|
if (rc) {
|
|
|
|
pr_debug("%s: error reading supply post sleep value. rc=%d\n",
|
|
|
|
__func__, rc);
|
|
|
|
}
|
|
|
|
mp->vreg_config[i].post_off_sleep = (!rc ? tmp : 0);
|
|
|
|
|
|
|
|
pr_debug("%s: %s min=%d, max=%d, enable=%d, disable=%d, preonsleep=%d, postonsleep=%d, preoffsleep=%d, postoffsleep=%d\n",
|
|
|
|
__func__,
|
|
|
|
mp->vreg_config[i].vreg_name,
|
|
|
|
mp->vreg_config[i].min_voltage,
|
|
|
|
mp->vreg_config[i].max_voltage,
|
|
|
|
mp->vreg_config[i].enable_load,
|
|
|
|
mp->vreg_config[i].disable_load,
|
|
|
|
mp->vreg_config[i].pre_on_sleep,
|
|
|
|
mp->vreg_config[i].post_on_sleep,
|
|
|
|
mp->vreg_config[i].pre_off_sleep,
|
|
|
|
mp->vreg_config[i].post_off_sleep
|
|
|
|
);
|
|
|
|
++i;
|
2013-03-12 22:19:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
error:
|
|
|
|
if (mp->vreg_config) {
|
|
|
|
devm_kfree(dev, mp->vreg_config);
|
|
|
|
mp->vreg_config = NULL;
|
|
|
|
}
|
2013-06-29 01:35:23 +00:00
|
|
|
novreg:
|
2013-03-12 22:19:17 +00:00
|
|
|
mp->num_vreg = 0;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2013-06-20 00:37:50 +00:00
|
|
|
static int mdss_dsi_get_panel_cfg(char *panel_cfg)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
struct mdss_panel_cfg *pan_cfg = NULL;
|
|
|
|
|
|
|
|
if (!panel_cfg)
|
|
|
|
return MDSS_PANEL_INTF_INVALID;
|
|
|
|
|
|
|
|
pan_cfg = mdss_panel_intf_type(MDSS_PANEL_INTF_DSI);
|
|
|
|
if (IS_ERR(pan_cfg)) {
|
|
|
|
return PTR_ERR(pan_cfg);
|
|
|
|
} else if (!pan_cfg) {
|
|
|
|
panel_cfg[0] = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
pr_debug("%s:%d: cfg:[%s]\n", __func__, __LINE__,
|
|
|
|
pan_cfg->arg_cfg);
|
|
|
|
rc = strlcpy(panel_cfg, pan_cfg->arg_cfg,
|
|
|
|
sizeof(pan_cfg->arg_cfg));
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2012-08-25 04:38:36 +00:00
|
|
|
static int mdss_dsi_off(struct mdss_panel_data *pdata)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
2012-12-14 06:49:58 +00:00
|
|
|
struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL;
|
2013-08-27 20:18:08 +00:00
|
|
|
struct mdss_panel_info *panel_info = NULL;
|
2012-08-25 04:38:36 +00:00
|
|
|
|
2012-12-14 06:49:58 +00:00
|
|
|
if (pdata == NULL) {
|
|
|
|
pr_err("%s: Invalid input data\n", __func__);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2013-02-01 03:36:15 +00:00
|
|
|
if (!pdata->panel_info.panel_power_on) {
|
|
|
|
pr_warn("%s:%d Panel already off.\n", __func__, __LINE__);
|
2014-01-28 09:11:45 +00:00
|
|
|
return 0;
|
2013-02-01 03:36:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pdata->panel_info.panel_power_on = 0;
|
|
|
|
|
2012-12-14 06:49:58 +00:00
|
|
|
ctrl_pdata = container_of(pdata, struct mdss_dsi_ctrl_pdata,
|
|
|
|
panel_data);
|
2013-03-26 21:10:40 +00:00
|
|
|
|
2013-08-27 20:18:08 +00:00
|
|
|
panel_info = &ctrl_pdata->panel_data.panel_info;
|
2013-03-26 21:10:40 +00:00
|
|
|
pr_debug("%s+: ctrl=%p ndx=%d\n", __func__,
|
|
|
|
ctrl_pdata, ctrl_pdata->ndx);
|
|
|
|
|
2013-05-01 16:51:46 +00:00
|
|
|
if (pdata->panel_info.type == MIPI_CMD_PANEL)
|
|
|
|
mdss_dsi_clk_ctrl(ctrl_pdata, 1);
|
2012-04-24 03:39:17 +00:00
|
|
|
|
2012-08-25 04:38:36 +00:00
|
|
|
/* disable DSI controller */
|
|
|
|
mdss_dsi_controller_cfg(0, pdata);
|
|
|
|
|
2013-04-18 22:18:35 +00:00
|
|
|
/* disable DSI phy */
|
2013-10-17 01:44:09 +00:00
|
|
|
mdss_dsi_phy_disable(ctrl_pdata);
|
2013-05-06 23:10:03 +00:00
|
|
|
|
2013-10-17 01:44:09 +00:00
|
|
|
mdss_dsi_clk_ctrl(ctrl_pdata, 0);
|
2013-05-06 23:10:03 +00:00
|
|
|
|
2012-12-14 06:49:58 +00:00
|
|
|
ret = mdss_dsi_panel_power_on(pdata, 0);
|
2012-08-14 05:57:11 +00:00
|
|
|
if (ret) {
|
|
|
|
pr_err("%s: Panel power off failed\n", __func__);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-08-27 20:18:08 +00:00
|
|
|
if (panel_info->dynamic_fps
|
|
|
|
&& (panel_info->dfps_update == DFPS_SUSPEND_RESUME_MODE)
|
|
|
|
&& (panel_info->new_fps != panel_info->mipi.frame_rate))
|
|
|
|
panel_info->mipi.frame_rate = panel_info->new_fps;
|
|
|
|
|
2012-04-24 03:39:17 +00:00
|
|
|
pr_debug("%s-:\n", __func__);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-02-01 03:36:15 +00:00
|
|
|
int mdss_dsi_on(struct mdss_panel_data *pdata)
|
2012-04-24 03:39:17 +00:00
|
|
|
{
|
|
|
|
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;
|
2013-03-28 22:29:05 +00:00
|
|
|
u32 ystride, bpp, data, dst_bpp;
|
2013-09-04 01:20:02 +00:00
|
|
|
u32 dummy_xres = 0, dummy_yres = 0;
|
2012-08-25 04:32:45 +00:00
|
|
|
struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL;
|
2013-08-27 20:18:08 +00:00
|
|
|
u32 hsync_period, vsync_period;
|
2012-08-25 04:32:45 +00:00
|
|
|
|
2012-12-14 06:49:58 +00:00
|
|
|
if (pdata == NULL) {
|
2012-08-25 04:32:45 +00:00
|
|
|
pr_err("%s: Invalid input data\n", __func__);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2012-04-24 03:39:17 +00:00
|
|
|
|
2013-02-01 03:36:15 +00:00
|
|
|
if (pdata->panel_info.panel_power_on) {
|
|
|
|
pr_warn("%s:%d Panel already on.\n", __func__, __LINE__);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-12-14 06:49:58 +00:00
|
|
|
ctrl_pdata = container_of(pdata, struct mdss_dsi_ctrl_pdata,
|
|
|
|
panel_data);
|
2013-03-26 21:10:40 +00:00
|
|
|
|
|
|
|
pr_debug("%s+: ctrl=%p ndx=%d\n",
|
|
|
|
__func__, ctrl_pdata, ctrl_pdata->ndx);
|
|
|
|
|
2012-04-24 03:39:17 +00:00
|
|
|
pinfo = &pdata->panel_info;
|
|
|
|
|
2013-11-07 00:37:31 +00:00
|
|
|
ret = msm_dss_enable_vreg(ctrl_pdata->power_data.vreg_config,
|
|
|
|
ctrl_pdata->power_data.num_vreg, 1);
|
2012-08-25 04:38:36 +00:00
|
|
|
if (ret) {
|
2013-11-07 00:37:31 +00:00
|
|
|
pr_err("%s:Failed to enable vregs. rc=%d\n", __func__, ret);
|
2012-08-25 04:38:36 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2012-08-14 06:31:30 +00:00
|
|
|
|
2013-11-21 01:25:19 +00:00
|
|
|
if (!pdata->panel_info.mipi.lp11_init) {
|
|
|
|
ret = mdss_dsi_panel_reset(pdata, 1);
|
|
|
|
if (ret) {
|
|
|
|
pr_err("%s: Panel reset failed. rc=%d\n",
|
|
|
|
__func__, ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
2013-09-12 17:17:41 +00:00
|
|
|
ret = mdss_dsi_bus_clk_start(ctrl_pdata);
|
2013-05-06 23:10:03 +00:00
|
|
|
if (ret) {
|
|
|
|
pr_err("%s: failed to enable bus clocks. rc=%d\n", __func__,
|
|
|
|
ret);
|
2013-11-21 01:25:19 +00:00
|
|
|
ret = mdss_dsi_panel_power_on(pdata, 0);
|
|
|
|
if (ret) {
|
|
|
|
pr_err("%s: Panel reset failed. rc=%d\n",
|
|
|
|
__func__, ret);
|
|
|
|
return ret;
|
|
|
|
}
|
2013-11-07 00:37:31 +00:00
|
|
|
pdata->panel_info.panel_power_on = 0;
|
2013-05-06 23:10:03 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-11-21 01:25:19 +00:00
|
|
|
pdata->panel_info.panel_power_on = 1;
|
2012-08-25 04:32:45 +00:00
|
|
|
mdss_dsi_phy_sw_reset((ctrl_pdata->ctrl_base));
|
2012-08-14 06:31:30 +00:00
|
|
|
mdss_dsi_phy_init(pdata);
|
2013-09-12 17:17:41 +00:00
|
|
|
mdss_dsi_bus_clk_stop(ctrl_pdata);
|
2012-08-14 06:31:30 +00:00
|
|
|
|
2013-05-01 16:51:46 +00:00
|
|
|
mdss_dsi_clk_ctrl(ctrl_pdata, 1);
|
2012-04-24 03:39:17 +00:00
|
|
|
|
|
|
|
clk_rate = pdata->panel_info.clk_rate;
|
|
|
|
clk_rate = min(clk_rate, pdata->panel_info.clk_max);
|
|
|
|
|
2013-03-28 22:29:05 +00:00
|
|
|
dst_bpp = pdata->panel_info.fbc.enabled ?
|
|
|
|
(pdata->panel_info.fbc.target_bpp) : (pinfo->bpp);
|
|
|
|
|
|
|
|
hbp = mult_frac(pdata->panel_info.lcdc.h_back_porch, dst_bpp,
|
|
|
|
pdata->panel_info.bpp);
|
|
|
|
hfp = mult_frac(pdata->panel_info.lcdc.h_front_porch, dst_bpp,
|
|
|
|
pdata->panel_info.bpp);
|
|
|
|
vbp = mult_frac(pdata->panel_info.lcdc.v_back_porch, dst_bpp,
|
|
|
|
pdata->panel_info.bpp);
|
|
|
|
vfp = mult_frac(pdata->panel_info.lcdc.v_front_porch, dst_bpp,
|
|
|
|
pdata->panel_info.bpp);
|
|
|
|
hspw = mult_frac(pdata->panel_info.lcdc.h_pulse_width, dst_bpp,
|
|
|
|
pdata->panel_info.bpp);
|
2012-04-24 03:39:17 +00:00
|
|
|
vspw = pdata->panel_info.lcdc.v_pulse_width;
|
2013-03-28 22:29:05 +00:00
|
|
|
width = mult_frac(pdata->panel_info.xres, dst_bpp,
|
|
|
|
pdata->panel_info.bpp);
|
2012-04-24 03:39:17 +00:00
|
|
|
height = pdata->panel_info.yres;
|
|
|
|
|
|
|
|
if (pdata->panel_info.type == MIPI_VIDEO_PANEL) {
|
|
|
|
dummy_xres = pdata->panel_info.lcdc.xres_pad;
|
|
|
|
dummy_yres = pdata->panel_info.lcdc.yres_pad;
|
2013-08-27 20:18:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
vsync_period = vspw + vbp + height + dummy_yres + vfp;
|
|
|
|
hsync_period = hspw + hbp + width + dummy_xres + hfp;
|
2012-04-24 03:39:17 +00:00
|
|
|
|
2013-08-27 20:18:08 +00:00
|
|
|
mipi = &pdata->panel_info.mipi;
|
|
|
|
if (pdata->panel_info.type == MIPI_VIDEO_PANEL) {
|
2012-08-25 04:32:45 +00:00
|
|
|
MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x24,
|
2012-04-24 03:39:17 +00:00
|
|
|
((hspw + hbp + width + dummy_xres) << 16 |
|
|
|
|
(hspw + hbp)));
|
2012-08-25 04:32:45 +00:00
|
|
|
MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x28,
|
2012-04-24 03:39:17 +00:00
|
|
|
((vspw + vbp + height + dummy_yres) << 16 |
|
|
|
|
(vspw + vbp)));
|
2012-08-25 04:32:45 +00:00
|
|
|
MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x2C,
|
2013-08-27 20:18:08 +00:00
|
|
|
((vsync_period - 1) << 16)
|
|
|
|
| (hsync_period - 1));
|
2012-04-24 03:39:17 +00:00
|
|
|
|
2012-08-25 04:32:45 +00:00
|
|
|
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));
|
2012-04-24 03:39:17 +00:00
|
|
|
|
|
|
|
} 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;
|
2012-08-25 04:32:45 +00:00
|
|
|
MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x60, data);
|
|
|
|
MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x58, data);
|
2012-04-24 03:39:17 +00:00
|
|
|
|
|
|
|
/* DSI_COMMAND_MODE_MDP_STREAM_TOTAL */
|
|
|
|
data = height << 16 | width;
|
2012-08-25 04:32:45 +00:00
|
|
|
MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x64, data);
|
|
|
|
MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x5C, data);
|
2012-04-24 03:39:17 +00:00
|
|
|
}
|
|
|
|
|
2012-09-29 01:48:15 +00:00
|
|
|
mdss_dsi_sw_reset(pdata);
|
2012-04-24 03:39:17 +00:00
|
|
|
mdss_dsi_host_init(mipi, pdata);
|
|
|
|
|
2013-11-07 00:37:31 +00:00
|
|
|
/*
|
|
|
|
* Issue hardware reset line after enabling the DSI clocks and data
|
|
|
|
* data lanes for LP11 init
|
|
|
|
*/
|
2013-11-21 01:25:19 +00:00
|
|
|
if (pdata->panel_info.mipi.lp11_init) {
|
|
|
|
ret = mdss_dsi_panel_reset(pdata, 1);
|
|
|
|
if (ret) {
|
|
|
|
pr_err("%s: Panel reset failed. rc=%d\n",
|
|
|
|
__func__, ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
2013-11-07 00:37:31 +00:00
|
|
|
if (pdata->panel_info.mipi.init_delay)
|
|
|
|
usleep(pdata->panel_info.mipi.init_delay);
|
|
|
|
|
2012-04-24 03:39:17 +00:00
|
|
|
if (mipi->force_clk_lane_hs) {
|
|
|
|
u32 tmp;
|
|
|
|
|
2012-08-25 04:32:45 +00:00
|
|
|
tmp = MIPI_INP((ctrl_pdata->ctrl_base) + 0xac);
|
2012-04-24 03:39:17 +00:00
|
|
|
tmp |= (1<<28);
|
2012-08-25 04:32:45 +00:00
|
|
|
MIPI_OUTP((ctrl_pdata->ctrl_base) + 0xac, tmp);
|
2012-04-24 03:39:17 +00:00
|
|
|
wmb();
|
|
|
|
}
|
|
|
|
|
2013-05-01 16:51:46 +00:00
|
|
|
if (pdata->panel_info.type == MIPI_CMD_PANEL)
|
|
|
|
mdss_dsi_clk_ctrl(ctrl_pdata, 0);
|
|
|
|
|
2013-03-26 21:10:40 +00:00
|
|
|
pr_debug("%s-:\n", __func__);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mdss_dsi_unblank(struct mdss_panel_data *pdata)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
struct mipi_panel_info *mipi;
|
|
|
|
struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL;
|
|
|
|
|
|
|
|
pr_debug("%s+:\n", __func__);
|
|
|
|
|
|
|
|
if (pdata == NULL) {
|
|
|
|
pr_err("%s: Invalid input data\n", __func__);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ctrl_pdata = container_of(pdata, struct mdss_dsi_ctrl_pdata,
|
|
|
|
panel_data);
|
|
|
|
mipi = &pdata->panel_info.mipi;
|
|
|
|
|
2013-04-23 19:24:05 +00:00
|
|
|
if (!(ctrl_pdata->ctrl_state & CTRL_STATE_PANEL_INIT)) {
|
2013-05-09 03:10:40 +00:00
|
|
|
ret = ctrl_pdata->on(pdata);
|
|
|
|
if (ret) {
|
|
|
|
pr_err("%s: unable to initialize the panel\n",
|
|
|
|
__func__);
|
|
|
|
return ret;
|
|
|
|
}
|
2013-04-23 19:24:05 +00:00
|
|
|
ctrl_pdata->ctrl_state |= CTRL_STATE_PANEL_INIT;
|
2012-04-24 03:39:17 +00:00
|
|
|
}
|
|
|
|
|
2013-05-30 03:11:57 +00:00
|
|
|
if (pdata->panel_info.type == MIPI_CMD_PANEL) {
|
|
|
|
if (mipi->vsync_enable && mipi->hw_vsync_mode
|
|
|
|
&& gpio_is_valid(ctrl_pdata->disp_te_gpio)) {
|
|
|
|
mdss_dsi_set_tear_on(ctrl_pdata);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-26 21:10:40 +00:00
|
|
|
pr_debug("%s-:\n", __func__);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mdss_dsi_blank(struct mdss_panel_data *pdata)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
2013-05-30 03:11:57 +00:00
|
|
|
struct mipi_panel_info *mipi;
|
2013-03-26 21:10:40 +00:00
|
|
|
struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL;
|
|
|
|
|
|
|
|
pr_debug("%s+:\n", __func__);
|
|
|
|
|
|
|
|
if (pdata == NULL) {
|
|
|
|
pr_err("%s: Invalid input data\n", __func__);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ctrl_pdata = container_of(pdata, struct mdss_dsi_ctrl_pdata,
|
|
|
|
panel_data);
|
2013-05-30 03:11:57 +00:00
|
|
|
mipi = &pdata->panel_info.mipi;
|
2013-03-26 21:10:40 +00:00
|
|
|
|
|
|
|
mdss_dsi_op_mode_config(DSI_CMD_MODE, pdata);
|
|
|
|
|
2013-05-30 03:11:57 +00:00
|
|
|
if (pdata->panel_info.type == MIPI_CMD_PANEL) {
|
|
|
|
if (mipi->vsync_enable && mipi->hw_vsync_mode
|
|
|
|
&& gpio_is_valid(ctrl_pdata->disp_te_gpio)) {
|
|
|
|
mdss_dsi_set_tear_off(ctrl_pdata);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-23 19:24:05 +00:00
|
|
|
if (ctrl_pdata->ctrl_state & CTRL_STATE_PANEL_INIT) {
|
2013-05-09 03:10:40 +00:00
|
|
|
ret = ctrl_pdata->off(pdata);
|
|
|
|
if (ret) {
|
|
|
|
pr_err("%s: Panel OFF failed\n", __func__);
|
|
|
|
return ret;
|
|
|
|
}
|
2013-04-23 19:24:05 +00:00
|
|
|
ctrl_pdata->ctrl_state &= ~CTRL_STATE_PANEL_INIT;
|
|
|
|
}
|
|
|
|
pr_debug("%s-:End\n", __func__);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int mdss_dsi_cont_splash_on(struct mdss_panel_data *pdata)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
struct mipi_panel_info *mipi;
|
|
|
|
struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL;
|
|
|
|
|
|
|
|
pr_info("%s:%d DSI on for continuous splash.\n", __func__, __LINE__);
|
|
|
|
|
|
|
|
if (pdata == NULL) {
|
|
|
|
pr_err("%s: Invalid input data\n", __func__);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
mipi = &pdata->panel_info.mipi;
|
|
|
|
|
|
|
|
ctrl_pdata = container_of(pdata, struct mdss_dsi_ctrl_pdata,
|
|
|
|
panel_data);
|
|
|
|
|
|
|
|
pr_debug("%s+: ctrl=%p ndx=%d\n", __func__,
|
|
|
|
ctrl_pdata, ctrl_pdata->ndx);
|
|
|
|
|
|
|
|
WARN((ctrl_pdata->ctrl_state & CTRL_STATE_PANEL_INIT),
|
|
|
|
"Incorrect Ctrl state=0x%x\n", ctrl_pdata->ctrl_state);
|
|
|
|
|
|
|
|
mdss_dsi_sw_reset(pdata);
|
|
|
|
mdss_dsi_host_init(mipi, pdata);
|
2013-07-23 17:35:48 +00:00
|
|
|
mdss_dsi_op_mode_config(mipi->mode, pdata);
|
2013-04-23 19:24:05 +00:00
|
|
|
|
|
|
|
if (ctrl_pdata->on_cmds.link_state == DSI_LP_MODE) {
|
|
|
|
ret = mdss_dsi_unblank(pdata);
|
|
|
|
if (ret) {
|
|
|
|
pr_err("%s: unblank failed\n", __func__);
|
|
|
|
return ret;
|
|
|
|
}
|
2013-03-26 21:10:40 +00:00
|
|
|
}
|
2013-04-23 19:24:05 +00:00
|
|
|
|
2012-12-14 06:49:58 +00:00
|
|
|
pr_debug("%s-:End\n", __func__);
|
2012-04-24 03:39:17 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-08-27 20:18:08 +00:00
|
|
|
static int mdss_dsi_dfps_config(struct mdss_panel_data *pdata, int new_fps)
|
|
|
|
{
|
|
|
|
int rc = 0;
|
|
|
|
struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL;
|
|
|
|
u32 dsi_ctrl;
|
|
|
|
|
|
|
|
pr_debug("%s+:\n", __func__);
|
|
|
|
|
|
|
|
if (pdata == NULL) {
|
|
|
|
pr_err("%s: Invalid input data\n", __func__);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ctrl_pdata = container_of(pdata, struct mdss_dsi_ctrl_pdata,
|
2013-09-20 20:47:01 +00:00
|
|
|
panel_data);
|
2013-08-27 20:18:08 +00:00
|
|
|
|
|
|
|
if (!ctrl_pdata->panel_data.panel_info.dynamic_fps) {
|
|
|
|
pr_err("%s: Dynamic fps not enabled for this panel\n",
|
|
|
|
__func__);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (new_fps !=
|
|
|
|
ctrl_pdata->panel_data.panel_info.mipi.frame_rate) {
|
|
|
|
if (pdata->panel_info.dfps_update
|
2014-01-17 11:19:22 +00:00
|
|
|
== DFPS_IMMEDIATE_PORCH_UPDATE_MODE) {
|
|
|
|
u32 hsync_period, vsync_period;
|
|
|
|
u32 new_dsi_v_total, current_dsi_v_total;
|
|
|
|
vsync_period =
|
|
|
|
mdss_panel_get_vtotal(&pdata->panel_info);
|
|
|
|
hsync_period =
|
|
|
|
mdss_panel_get_htotal(&pdata->panel_info);
|
|
|
|
current_dsi_v_total =
|
|
|
|
MIPI_INP((ctrl_pdata->ctrl_base) + 0x2C);
|
|
|
|
new_dsi_v_total =
|
|
|
|
((vsync_period - 1) << 16) | (hsync_period - 1);
|
|
|
|
MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x2C,
|
|
|
|
(current_dsi_v_total | 0x8000000));
|
|
|
|
if (new_dsi_v_total & 0x8000000) {
|
|
|
|
MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x2C,
|
|
|
|
new_dsi_v_total);
|
|
|
|
} else {
|
|
|
|
MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x2C,
|
|
|
|
(new_dsi_v_total | 0x8000000));
|
|
|
|
MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x2C,
|
|
|
|
(new_dsi_v_total & 0x7ffffff));
|
|
|
|
}
|
|
|
|
pdata->panel_info.mipi.frame_rate = new_fps;
|
|
|
|
} else {
|
|
|
|
rc = mdss_dsi_clk_div_config
|
|
|
|
(&ctrl_pdata->panel_data.panel_info, new_fps);
|
|
|
|
if (rc) {
|
|
|
|
pr_err("%s: unable to initialize the clk dividers\n",
|
|
|
|
__func__);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
ctrl_pdata->pclk_rate =
|
|
|
|
pdata->panel_info.mipi.dsi_pclk_rate;
|
|
|
|
ctrl_pdata->byte_clk_rate =
|
|
|
|
pdata->panel_info.clk_rate / 8;
|
|
|
|
|
|
|
|
if (pdata->panel_info.dfps_update
|
|
|
|
== DFPS_IMMEDIATE_CLK_UPDATE_MODE) {
|
|
|
|
dsi_ctrl = MIPI_INP((ctrl_pdata->ctrl_base) +
|
|
|
|
0x0004);
|
|
|
|
pdata->panel_info.mipi.frame_rate = new_fps;
|
|
|
|
dsi_ctrl &= ~0x2;
|
|
|
|
MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x0004,
|
|
|
|
dsi_ctrl);
|
|
|
|
mdss_dsi_controller_cfg(true, pdata);
|
|
|
|
mdss_dsi_clk_ctrl(ctrl_pdata, 0);
|
|
|
|
mdss_dsi_clk_ctrl(ctrl_pdata, 1);
|
|
|
|
dsi_ctrl |= 0x2;
|
|
|
|
MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x0004,
|
|
|
|
dsi_ctrl);
|
|
|
|
}
|
2013-08-27 20:18:08 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
pr_debug("%s: Panel is already at this FPS\n", __func__);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2013-09-20 20:47:01 +00:00
|
|
|
static int mdss_dsi_ctl_partial_update(struct mdss_panel_data *pdata)
|
|
|
|
{
|
|
|
|
int rc = -EINVAL;
|
|
|
|
u32 data;
|
|
|
|
struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL;
|
|
|
|
|
|
|
|
if (pdata == NULL) {
|
|
|
|
pr_err("%s: Invalid input data\n", __func__);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ctrl_pdata = container_of(pdata, struct mdss_dsi_ctrl_pdata,
|
|
|
|
panel_data);
|
|
|
|
|
|
|
|
/* DSI_COMMAND_MODE_MDP_STREAM_CTRL */
|
|
|
|
data = (((pdata->panel_info.roi_w * 3) + 1) << 16) |
|
|
|
|
(pdata->panel_info.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 = pdata->panel_info.roi_h << 16 | pdata->panel_info.roi_w;
|
|
|
|
MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x64, data);
|
|
|
|
MIPI_OUTP((ctrl_pdata->ctrl_base) + 0x5C, data);
|
|
|
|
|
|
|
|
if (ctrl_pdata->partial_update_fnc)
|
|
|
|
rc = ctrl_pdata->partial_update_fnc(pdata);
|
|
|
|
|
|
|
|
if (rc) {
|
|
|
|
pr_err("%s: unable to initialize the panel\n",
|
|
|
|
__func__);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2012-11-06 00:51:27 +00:00
|
|
|
static int mdss_dsi_event_handler(struct mdss_panel_data *pdata,
|
|
|
|
int event, void *arg)
|
|
|
|
{
|
|
|
|
int rc = 0;
|
2013-01-25 19:30:25 +00:00
|
|
|
struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL;
|
2012-11-06 00:51:27 +00:00
|
|
|
|
2013-01-25 19:30:25 +00:00
|
|
|
if (pdata == NULL) {
|
|
|
|
pr_err("%s: Invalid input data\n", __func__);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
ctrl_pdata = container_of(pdata, struct mdss_dsi_ctrl_pdata,
|
|
|
|
panel_data);
|
2013-03-26 21:10:40 +00:00
|
|
|
pr_debug("%s+:event=%d\n", __func__, event);
|
|
|
|
|
2012-11-06 00:51:27 +00:00
|
|
|
switch (event) {
|
|
|
|
case MDSS_EVENT_UNBLANK:
|
2013-03-26 21:10:40 +00:00
|
|
|
rc = mdss_dsi_on(pdata);
|
2013-07-23 17:35:48 +00:00
|
|
|
mdss_dsi_op_mode_config(pdata->panel_info.mipi.mode,
|
|
|
|
pdata);
|
2013-05-06 16:06:20 +00:00
|
|
|
if (ctrl_pdata->on_cmds.link_state == DSI_LP_MODE)
|
2013-03-26 21:10:40 +00:00
|
|
|
rc = mdss_dsi_unblank(pdata);
|
2012-11-06 00:51:27 +00:00
|
|
|
break;
|
2013-03-26 21:10:40 +00:00
|
|
|
case MDSS_EVENT_PANEL_ON:
|
2013-04-23 19:24:05 +00:00
|
|
|
ctrl_pdata->ctrl_state |= CTRL_STATE_MDP_ACTIVE;
|
2013-05-06 16:06:20 +00:00
|
|
|
if (ctrl_pdata->on_cmds.link_state == DSI_HS_MODE)
|
2013-03-26 21:10:40 +00:00
|
|
|
rc = mdss_dsi_unblank(pdata);
|
|
|
|
break;
|
2012-11-06 00:51:27 +00:00
|
|
|
case MDSS_EVENT_BLANK:
|
2013-05-06 16:06:20 +00:00
|
|
|
if (ctrl_pdata->off_cmds.link_state == DSI_HS_MODE)
|
2013-03-26 21:10:40 +00:00
|
|
|
rc = mdss_dsi_blank(pdata);
|
2012-11-06 00:51:27 +00:00
|
|
|
break;
|
2013-03-26 21:10:40 +00:00
|
|
|
case MDSS_EVENT_PANEL_OFF:
|
2013-04-23 19:24:05 +00:00
|
|
|
ctrl_pdata->ctrl_state &= ~CTRL_STATE_MDP_ACTIVE;
|
2013-05-06 16:06:20 +00:00
|
|
|
if (ctrl_pdata->off_cmds.link_state == DSI_LP_MODE)
|
2013-03-26 21:10:40 +00:00
|
|
|
rc = mdss_dsi_blank(pdata);
|
2012-11-06 00:51:27 +00:00
|
|
|
rc = mdss_dsi_off(pdata);
|
|
|
|
break;
|
2013-02-01 03:36:15 +00:00
|
|
|
case MDSS_EVENT_CONT_SPLASH_FINISH:
|
2013-04-23 19:24:05 +00:00
|
|
|
ctrl_pdata->ctrl_state &= ~CTRL_STATE_MDP_ACTIVE;
|
2013-05-06 16:06:20 +00:00
|
|
|
if (ctrl_pdata->on_cmds.link_state == DSI_LP_MODE) {
|
2013-02-01 03:36:15 +00:00
|
|
|
rc = mdss_dsi_cont_splash_on(pdata);
|
|
|
|
} else {
|
|
|
|
pr_debug("%s:event=%d, Dsi On not called: ctrl_state: %d\n",
|
|
|
|
__func__, event,
|
2013-05-06 16:06:20 +00:00
|
|
|
ctrl_pdata->on_cmds.link_state);
|
2013-02-01 03:36:15 +00:00
|
|
|
rc = -EINVAL;
|
|
|
|
}
|
|
|
|
break;
|
2013-05-01 16:51:46 +00:00
|
|
|
case MDSS_EVENT_PANEL_CLK_CTRL:
|
2013-11-21 19:41:18 +00:00
|
|
|
mdss_dsi_clk_req(ctrl_pdata, (int) (unsigned long) arg);
|
2013-05-01 16:51:46 +00:00
|
|
|
break;
|
|
|
|
case MDSS_EVENT_DSI_CMDLIST_KOFF:
|
2013-08-15 17:00:03 +00:00
|
|
|
ctrl_pdata->recovery = (struct mdss_panel_recovery *)arg;
|
2013-05-01 16:51:46 +00:00
|
|
|
mdss_dsi_cmdlist_commit(ctrl_pdata, 1);
|
2013-10-17 00:37:15 +00:00
|
|
|
break;
|
2013-08-27 20:18:08 +00:00
|
|
|
case MDSS_EVENT_PANEL_UPDATE_FPS:
|
|
|
|
if (arg != NULL) {
|
2013-11-21 19:41:18 +00:00
|
|
|
rc = mdss_dsi_dfps_config(pdata,
|
|
|
|
(int) (unsigned long) arg);
|
2013-08-27 20:18:08 +00:00
|
|
|
pr_debug("%s:update fps to = %d\n",
|
2013-11-21 19:41:18 +00:00
|
|
|
__func__, (int) (unsigned long) arg);
|
2013-08-27 20:18:08 +00:00
|
|
|
}
|
2013-05-01 16:51:46 +00:00
|
|
|
break;
|
2013-04-23 19:24:05 +00:00
|
|
|
case MDSS_EVENT_CONT_SPLASH_BEGIN:
|
|
|
|
if (ctrl_pdata->off_cmds.link_state == DSI_HS_MODE) {
|
|
|
|
/* Panel is Enabled in Bootloader */
|
|
|
|
rc = mdss_dsi_blank(pdata);
|
|
|
|
}
|
|
|
|
break;
|
2013-09-20 20:47:01 +00:00
|
|
|
case MDSS_EVENT_ENABLE_PARTIAL_UPDATE:
|
|
|
|
rc = mdss_dsi_ctl_partial_update(pdata);
|
|
|
|
break;
|
2013-01-25 19:30:25 +00:00
|
|
|
default:
|
|
|
|
pr_debug("%s: unhandled event=%d\n", __func__, event);
|
|
|
|
break;
|
2012-11-06 00:51:27 +00:00
|
|
|
}
|
2013-03-26 21:10:40 +00:00
|
|
|
pr_debug("%s-:event=%d, rc=%d\n", __func__, event, rc);
|
2012-11-06 00:51:27 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2013-12-12 05:54:09 +00:00
|
|
|
static struct device_node *mdss_dsi_pref_prim_panel(
|
|
|
|
struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
struct device_node *dsi_pan_node = NULL;
|
|
|
|
|
|
|
|
pr_debug("%s:%d: Select primary panel from dt\n",
|
|
|
|
__func__, __LINE__);
|
|
|
|
dsi_pan_node = of_parse_phandle(pdev->dev.of_node,
|
|
|
|
"qcom,dsi-pref-prim-pan", 0);
|
|
|
|
if (!dsi_pan_node)
|
|
|
|
pr_err("%s:can't find panel phandle\n", __func__);
|
|
|
|
|
|
|
|
return dsi_pan_node;
|
|
|
|
}
|
|
|
|
|
2013-06-20 00:37:50 +00:00
|
|
|
/**
|
|
|
|
* mdss_dsi_find_panel_of_node(): find device node of dsi panel
|
|
|
|
* @pdev: platform_device of the dsi ctrl node
|
|
|
|
* @panel_cfg: string containing intf specific config data
|
|
|
|
*
|
|
|
|
* Function finds the panel device node using the interface
|
|
|
|
* specific configuration data. This configuration data is
|
|
|
|
* could be derived from the result of bootloader's GCDB
|
|
|
|
* panel detection mechanism. If such config data doesn't
|
|
|
|
* exist then this panel returns the default panel configured
|
|
|
|
* in the device tree.
|
|
|
|
*
|
|
|
|
* returns pointer to panel node on success, NULL on error.
|
|
|
|
*/
|
|
|
|
static struct device_node *mdss_dsi_find_panel_of_node(
|
|
|
|
struct platform_device *pdev, char *panel_cfg)
|
|
|
|
{
|
2013-12-31 01:22:42 +00:00
|
|
|
int len, i;
|
|
|
|
int ctrl_id = pdev->id - 1;
|
|
|
|
char panel_name[MDSS_MAX_PANEL_LEN];
|
|
|
|
char ctrl_id_stream[3] = "0:";
|
|
|
|
char *stream = NULL, *pan = NULL;
|
2013-06-20 00:37:50 +00:00
|
|
|
struct device_node *dsi_pan_node = NULL, *mdss_node = NULL;
|
|
|
|
|
2013-12-31 01:22:42 +00:00
|
|
|
len = strlen(panel_cfg);
|
|
|
|
if (!len) {
|
2013-06-20 00:37:50 +00:00
|
|
|
/* no panel cfg chg, parse dt */
|
|
|
|
pr_debug("%s:%d: no cmd line cfg present\n",
|
|
|
|
__func__, __LINE__);
|
2013-12-31 01:22:42 +00:00
|
|
|
goto end;
|
2013-06-20 00:37:50 +00:00
|
|
|
} else {
|
2013-12-31 01:22:42 +00:00
|
|
|
if (ctrl_id == 1)
|
|
|
|
strlcpy(ctrl_id_stream, "1:", 3);
|
|
|
|
|
|
|
|
stream = strnstr(panel_cfg, ctrl_id_stream, len);
|
|
|
|
if (!stream) {
|
|
|
|
pr_err("controller config is not present\n");
|
|
|
|
goto end;
|
2013-06-20 00:37:50 +00:00
|
|
|
}
|
2013-12-31 01:22:42 +00:00
|
|
|
stream += 2;
|
|
|
|
|
|
|
|
pan = strnchr(stream, strlen(stream), ':');
|
|
|
|
if (!pan) {
|
|
|
|
strlcpy(panel_name, stream, MDSS_MAX_PANEL_LEN);
|
|
|
|
} else {
|
|
|
|
for (i = 0; (stream + i) < pan; i++)
|
|
|
|
panel_name[i] = *(stream + i);
|
|
|
|
panel_name[i] = 0;
|
2013-06-20 00:37:50 +00:00
|
|
|
}
|
2013-12-31 01:22:42 +00:00
|
|
|
|
2013-06-20 00:37:50 +00:00
|
|
|
pr_debug("%s:%d:%s:%s\n", __func__, __LINE__,
|
|
|
|
panel_cfg, panel_name);
|
|
|
|
|
|
|
|
mdss_node = of_parse_phandle(pdev->dev.of_node,
|
|
|
|
"qcom,mdss-mdp", 0);
|
|
|
|
|
|
|
|
if (!mdss_node) {
|
|
|
|
pr_err("%s: %d: mdss_node null\n",
|
|
|
|
__func__, __LINE__);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
dsi_pan_node = of_find_node_by_name(mdss_node,
|
|
|
|
panel_name);
|
|
|
|
if (!dsi_pan_node) {
|
2013-12-12 05:54:09 +00:00
|
|
|
pr_err("%s: invalid pan node, selecting prim panel\n",
|
2013-06-20 00:37:50 +00:00
|
|
|
__func__);
|
2013-12-31 01:22:42 +00:00
|
|
|
goto end;
|
2013-06-20 00:37:50 +00:00
|
|
|
}
|
2013-12-31 01:22:42 +00:00
|
|
|
return dsi_pan_node;
|
2013-06-20 00:37:50 +00:00
|
|
|
}
|
2013-12-31 01:22:42 +00:00
|
|
|
end:
|
|
|
|
dsi_pan_node = mdss_dsi_pref_prim_panel(pdev);
|
2013-12-12 05:54:09 +00:00
|
|
|
|
2013-06-20 00:37:50 +00:00
|
|
|
return dsi_pan_node;
|
|
|
|
}
|
|
|
|
|
2012-12-14 06:49:58 +00:00
|
|
|
static int mdss_dsi_ctrl_probe(struct platform_device *pdev)
|
2012-04-24 03:39:17 +00:00
|
|
|
{
|
|
|
|
int rc = 0;
|
2013-01-25 19:30:25 +00:00
|
|
|
u32 index;
|
2013-03-12 22:19:17 +00:00
|
|
|
struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL;
|
2013-06-20 00:37:50 +00:00
|
|
|
struct device_node *dsi_pan_node = NULL;
|
|
|
|
char panel_cfg[MDSS_MAX_PANEL_LEN];
|
|
|
|
const char *ctrl_name;
|
|
|
|
bool cmd_cfg_cont_splash = true;
|
|
|
|
|
|
|
|
if (!mdss_is_ready()) {
|
|
|
|
pr_err("%s: MDP not probed yet!\n", __func__);
|
|
|
|
return -EPROBE_DEFER;
|
|
|
|
}
|
2013-01-25 19:30:25 +00:00
|
|
|
|
2013-06-20 00:37:50 +00:00
|
|
|
if (!pdev->dev.of_node) {
|
|
|
|
pr_err("DSI driver only supports device tree probe\n");
|
|
|
|
return -ENOTSUPP;
|
|
|
|
}
|
2013-01-25 19:30:25 +00:00
|
|
|
|
2013-06-20 00:37:50 +00:00
|
|
|
ctrl_pdata = platform_get_drvdata(pdev);
|
|
|
|
if (!ctrl_pdata) {
|
|
|
|
ctrl_pdata = devm_kzalloc(&pdev->dev,
|
|
|
|
sizeof(struct mdss_dsi_ctrl_pdata),
|
|
|
|
GFP_KERNEL);
|
2013-03-12 22:19:17 +00:00
|
|
|
if (!ctrl_pdata) {
|
2013-06-20 00:37:50 +00:00
|
|
|
pr_err("%s: FAILED: cannot alloc dsi ctrl\n",
|
|
|
|
__func__);
|
|
|
|
rc = -ENOMEM;
|
|
|
|
goto error_no_mem;
|
2013-03-12 22:19:17 +00:00
|
|
|
}
|
2013-06-20 00:37:50 +00:00
|
|
|
platform_set_drvdata(pdev, ctrl_pdata);
|
|
|
|
}
|
2013-03-12 22:19:17 +00:00
|
|
|
|
2013-06-20 00:37:50 +00:00
|
|
|
ctrl_name = of_get_property(pdev->dev.of_node, "label", NULL);
|
|
|
|
if (!ctrl_name)
|
|
|
|
pr_info("%s:%d, DSI Ctrl name not specified\n",
|
|
|
|
__func__, __LINE__);
|
|
|
|
else
|
|
|
|
pr_info("%s: DSI Ctrl name = %s\n",
|
|
|
|
__func__, ctrl_name);
|
2013-01-25 19:30:25 +00:00
|
|
|
|
2013-06-20 00:37:50 +00:00
|
|
|
rc = of_property_read_u32(pdev->dev.of_node,
|
|
|
|
"cell-index", &index);
|
|
|
|
if (rc) {
|
|
|
|
dev_err(&pdev->dev,
|
|
|
|
"%s: Cell-index not specified, rc=%d\n",
|
|
|
|
__func__, rc);
|
|
|
|
goto error_no_mem;
|
|
|
|
}
|
2013-01-25 19:30:25 +00:00
|
|
|
|
2013-06-20 00:37:50 +00:00
|
|
|
if (index == 0)
|
|
|
|
pdev->id = 1;
|
|
|
|
else
|
|
|
|
pdev->id = 2;
|
2013-01-25 19:30:25 +00:00
|
|
|
|
2013-06-20 00:37:50 +00:00
|
|
|
rc = of_platform_populate(pdev->dev.of_node,
|
|
|
|
NULL, NULL, &pdev->dev);
|
|
|
|
if (rc) {
|
|
|
|
dev_err(&pdev->dev,
|
|
|
|
"%s: failed to add child nodes, rc=%d\n",
|
|
|
|
__func__, rc);
|
2014-02-22 00:07:02 +00:00
|
|
|
goto error_no_mem;
|
2013-06-20 00:37:50 +00:00
|
|
|
}
|
2013-03-12 22:19:17 +00:00
|
|
|
|
2013-06-20 00:37:50 +00:00
|
|
|
/* Parse the regulator information */
|
|
|
|
rc = mdss_dsi_get_dt_vreg_data(&pdev->dev,
|
|
|
|
&ctrl_pdata->power_data);
|
|
|
|
if (rc) {
|
|
|
|
pr_err("%s: failed to get vreg data from dt. rc=%d\n",
|
|
|
|
__func__, rc);
|
|
|
|
goto error_vreg;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* DSI panels can be different between controllers */
|
|
|
|
rc = mdss_dsi_get_panel_cfg(panel_cfg);
|
|
|
|
if (!rc)
|
|
|
|
/* dsi panel cfg not present */
|
|
|
|
pr_warn("%s:%d:dsi specific cfg not present\n",
|
|
|
|
__func__, __LINE__);
|
2012-04-24 03:39:17 +00:00
|
|
|
|
2013-06-20 00:37:50 +00:00
|
|
|
/* find panel device node */
|
|
|
|
dsi_pan_node = mdss_dsi_find_panel_of_node(pdev, panel_cfg);
|
|
|
|
if (!dsi_pan_node) {
|
|
|
|
pr_err("%s: can't find panel node %s\n", __func__, panel_cfg);
|
|
|
|
goto error_pan_node;
|
2012-04-24 03:39:17 +00:00
|
|
|
}
|
|
|
|
|
2013-08-13 05:58:27 +00:00
|
|
|
cmd_cfg_cont_splash = mdss_panel_get_boot_cfg() ? true : false;
|
|
|
|
|
2013-09-11 01:54:24 +00:00
|
|
|
rc = mdss_dsi_panel_init(dsi_pan_node, ctrl_pdata, cmd_cfg_cont_splash);
|
2013-06-20 00:37:50 +00:00
|
|
|
if (rc) {
|
|
|
|
pr_err("%s: dsi panel init failed\n", __func__);
|
|
|
|
goto error_pan_node;
|
|
|
|
}
|
|
|
|
|
2013-09-11 01:54:24 +00:00
|
|
|
rc = dsi_panel_device_register(dsi_pan_node, ctrl_pdata);
|
2013-06-20 00:37:50 +00:00
|
|
|
if (rc) {
|
|
|
|
pr_err("%s: dsi panel dev reg failed\n", __func__);
|
|
|
|
goto error_pan_node;
|
|
|
|
}
|
|
|
|
|
|
|
|
pr_debug("%s: Dsi Ctrl->%d initialized\n", __func__, index);
|
2012-04-24 03:39:17 +00:00
|
|
|
return 0;
|
2013-03-12 22:19:17 +00:00
|
|
|
|
2013-06-20 00:37:50 +00:00
|
|
|
error_pan_node:
|
|
|
|
of_node_put(dsi_pan_node);
|
|
|
|
error_vreg:
|
|
|
|
mdss_dsi_put_dt_vreg_data(&pdev->dev, &ctrl_pdata->power_data);
|
2013-03-12 22:19:17 +00:00
|
|
|
error_no_mem:
|
|
|
|
devm_kfree(&pdev->dev, ctrl_pdata);
|
|
|
|
|
|
|
|
return rc;
|
2012-04-24 03:39:17 +00:00
|
|
|
}
|
|
|
|
|
2012-12-14 06:49:58 +00:00
|
|
|
static int mdss_dsi_ctrl_remove(struct platform_device *pdev)
|
2012-04-24 03:39:17 +00:00
|
|
|
{
|
|
|
|
struct msm_fb_data_type *mfd;
|
2013-03-12 22:19:17 +00:00
|
|
|
struct mdss_dsi_ctrl_pdata *ctrl_pdata = platform_get_drvdata(pdev);
|
2012-04-24 03:39:17 +00:00
|
|
|
|
2013-03-12 22:19:17 +00:00
|
|
|
if (!ctrl_pdata) {
|
|
|
|
pr_err("%s: no driver data\n", __func__);
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (msm_dss_config_vreg(&pdev->dev,
|
|
|
|
ctrl_pdata->power_data.vreg_config,
|
|
|
|
ctrl_pdata->power_data.num_vreg, 1) < 0)
|
|
|
|
pr_err("%s: failed to de-init vregs\n", __func__);
|
|
|
|
mdss_dsi_put_dt_vreg_data(&pdev->dev, &ctrl_pdata->power_data);
|
2012-04-24 03:39:17 +00:00
|
|
|
mfd = platform_get_drvdata(pdev);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct device dsi_dev;
|
|
|
|
|
2012-12-14 06:49:58 +00:00
|
|
|
int mdss_dsi_retrieve_ctrl_resources(struct platform_device *pdev, int mode,
|
2013-03-26 21:10:40 +00:00
|
|
|
struct mdss_dsi_ctrl_pdata *ctrl)
|
2012-12-14 06:49:58 +00:00
|
|
|
{
|
|
|
|
int rc = 0;
|
|
|
|
u32 index;
|
|
|
|
struct resource *mdss_dsi_mres;
|
|
|
|
|
|
|
|
rc = of_property_read_u32(pdev->dev.of_node, "cell-index", &index);
|
|
|
|
if (rc) {
|
|
|
|
dev_err(&pdev->dev,
|
|
|
|
"%s: Cell-index not specified, rc=%d\n",
|
|
|
|
__func__, rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (index == 0) {
|
|
|
|
if (mode != DISPLAY_1) {
|
|
|
|
pr_err("%s:%d Panel->Ctrl mapping is wrong",
|
|
|
|
__func__, __LINE__);
|
|
|
|
return -EPERM;
|
|
|
|
}
|
|
|
|
} else if (index == 1) {
|
|
|
|
if (mode != DISPLAY_2) {
|
|
|
|
pr_err("%s:%d Panel->Ctrl mapping is wrong",
|
|
|
|
__func__, __LINE__);
|
|
|
|
return -EPERM;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
pr_err("%s:%d Unknown Ctrl mapped to panel",
|
|
|
|
__func__, __LINE__);
|
|
|
|
return -EPERM;
|
|
|
|
}
|
|
|
|
|
|
|
|
mdss_dsi_mres = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
|
|
if (!mdss_dsi_mres) {
|
|
|
|
pr_err("%s:%d unable to get the DSI ctrl resources",
|
|
|
|
__func__, __LINE__);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2013-03-26 21:10:40 +00:00
|
|
|
ctrl->ctrl_base = ioremap(mdss_dsi_mres->start,
|
2012-12-14 06:49:58 +00:00
|
|
|
resource_size(mdss_dsi_mres));
|
2013-03-26 21:10:40 +00:00
|
|
|
if (!(ctrl->ctrl_base)) {
|
2012-12-14 06:49:58 +00:00
|
|
|
pr_err("%s:%d unable to remap dsi resources",
|
|
|
|
__func__, __LINE__);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2013-03-26 21:10:40 +00:00
|
|
|
ctrl->reg_size = resource_size(mdss_dsi_mres);
|
|
|
|
|
|
|
|
pr_info("%s: dsi base=%x size=%x\n",
|
2013-11-21 19:41:18 +00:00
|
|
|
__func__, (int) (unsigned long) ctrl->ctrl_base,
|
|
|
|
ctrl->reg_size);
|
2013-03-26 21:10:40 +00:00
|
|
|
|
2012-12-14 06:49:58 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-06-20 00:37:50 +00:00
|
|
|
int dsi_panel_device_register(struct device_node *pan_node,
|
2013-09-11 01:54:24 +00:00
|
|
|
struct mdss_dsi_ctrl_pdata *ctrl_pdata)
|
2012-04-24 03:39:17 +00:00
|
|
|
{
|
|
|
|
struct mipi_panel_info *mipi;
|
2013-06-29 01:35:23 +00:00
|
|
|
int rc, i, len;
|
2013-07-31 01:47:33 +00:00
|
|
|
struct mdss_panel_info *pinfo = &(ctrl_pdata->panel_data.panel_info);
|
2012-12-14 06:49:58 +00:00
|
|
|
struct device_node *dsi_ctrl_np = NULL;
|
|
|
|
struct platform_device *ctrl_pdev = NULL;
|
2013-08-27 20:18:08 +00:00
|
|
|
bool dynamic_fps;
|
2013-06-29 01:35:23 +00:00
|
|
|
const char *data;
|
2012-04-24 03:39:17 +00:00
|
|
|
|
2013-07-31 01:47:33 +00:00
|
|
|
mipi = &(pinfo->mipi);
|
2012-04-24 03:39:17 +00:00
|
|
|
|
2013-07-31 01:47:33 +00:00
|
|
|
pinfo->type =
|
2012-04-24 03:39:17 +00:00
|
|
|
((mipi->mode == DSI_VIDEO_MODE)
|
|
|
|
? MIPI_VIDEO_PANEL : MIPI_CMD_PANEL);
|
|
|
|
|
2013-07-31 01:47:33 +00:00
|
|
|
rc = mdss_dsi_clk_div_config(pinfo, mipi->frame_rate);
|
2012-04-24 03:39:17 +00:00
|
|
|
if (rc) {
|
|
|
|
pr_err("%s: unable to initialize the clk dividers\n", __func__);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2013-06-20 00:37:50 +00:00
|
|
|
dsi_ctrl_np = of_parse_phandle(pan_node,
|
2013-06-29 01:35:23 +00:00
|
|
|
"qcom,mdss-dsi-panel-controller", 0);
|
2012-12-14 06:49:58 +00:00
|
|
|
if (!dsi_ctrl_np) {
|
|
|
|
pr_err("%s: Dsi controller node not initialized\n", __func__);
|
|
|
|
return -EPROBE_DEFER;
|
|
|
|
}
|
|
|
|
|
|
|
|
ctrl_pdev = of_find_device_by_node(dsi_ctrl_np);
|
|
|
|
|
2013-03-12 22:19:17 +00:00
|
|
|
rc = mdss_dsi_regulator_init(ctrl_pdev);
|
2012-12-14 06:49:58 +00:00
|
|
|
if (rc) {
|
2013-06-20 00:37:50 +00:00
|
|
|
pr_err("%s: failed to init regulator, rc=%d\n",
|
2012-12-14 06:49:58 +00:00
|
|
|
__func__, rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2013-06-29 01:35:23 +00:00
|
|
|
data = of_get_property(ctrl_pdev->dev.of_node,
|
|
|
|
"qcom,platform-strength-ctrl", &len);
|
|
|
|
if ((!data) || (len != 2)) {
|
|
|
|
pr_err("%s:%d, Unable to read Phy Strength ctrl settings",
|
|
|
|
__func__, __LINE__);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2013-07-31 01:47:33 +00:00
|
|
|
pinfo->mipi.dsi_phy_db.strength[0] = data[0];
|
|
|
|
pinfo->mipi.dsi_phy_db.strength[1] = data[1];
|
2013-06-29 01:35:23 +00:00
|
|
|
|
|
|
|
data = of_get_property(ctrl_pdev->dev.of_node,
|
|
|
|
"qcom,platform-regulator-settings", &len);
|
|
|
|
if ((!data) || (len != 7)) {
|
|
|
|
pr_err("%s:%d, Unable to read Phy regulator settings",
|
|
|
|
__func__, __LINE__);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
for (i = 0; i < len; i++) {
|
2013-07-31 01:47:33 +00:00
|
|
|
pinfo->mipi.dsi_phy_db.regulator[i]
|
2013-06-29 01:35:23 +00:00
|
|
|
= data[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
data = of_get_property(ctrl_pdev->dev.of_node,
|
|
|
|
"qcom,platform-bist-ctrl", &len);
|
|
|
|
if ((!data) || (len != 6)) {
|
|
|
|
pr_err("%s:%d, Unable to read Phy Bist Ctrl settings",
|
|
|
|
__func__, __LINE__);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
for (i = 0; i < len; i++) {
|
2013-07-31 01:47:33 +00:00
|
|
|
pinfo->mipi.dsi_phy_db.bistctrl[i]
|
2013-06-29 01:35:23 +00:00
|
|
|
= data[i];
|
|
|
|
}
|
2013-01-25 19:30:25 +00:00
|
|
|
|
2013-06-29 01:35:23 +00:00
|
|
|
data = of_get_property(ctrl_pdev->dev.of_node,
|
|
|
|
"qcom,platform-lane-config", &len);
|
|
|
|
if ((!data) || (len != 45)) {
|
|
|
|
pr_err("%s:%d, Unable to read Phy lane configure settings",
|
|
|
|
__func__, __LINE__);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
for (i = 0; i < len; i++) {
|
2013-07-31 01:47:33 +00:00
|
|
|
pinfo->mipi.dsi_phy_db.lanecfg[i] =
|
2013-06-29 01:35:23 +00:00
|
|
|
data[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
ctrl_pdata->shared_pdata.broadcast_enable = of_property_read_bool(
|
2013-06-20 00:37:50 +00:00
|
|
|
pan_node, "qcom,mdss-dsi-panel-broadcast-mode");
|
2013-06-29 01:35:23 +00:00
|
|
|
|
2013-08-27 20:18:08 +00:00
|
|
|
dynamic_fps = of_property_read_bool(pan_node,
|
|
|
|
"qcom,mdss-dsi-pan-enable-dynamic-fps");
|
|
|
|
if (dynamic_fps) {
|
2013-07-31 01:47:33 +00:00
|
|
|
pinfo->dynamic_fps = true;
|
2013-08-27 20:18:08 +00:00
|
|
|
data = of_get_property(pan_node,
|
|
|
|
"qcom,mdss-dsi-pan-fps-update", NULL);
|
|
|
|
if (data) {
|
|
|
|
if (!strcmp(data, "dfps_suspend_resume_mode")) {
|
2013-07-31 01:47:33 +00:00
|
|
|
pinfo->dfps_update =
|
2013-08-27 20:18:08 +00:00
|
|
|
DFPS_SUSPEND_RESUME_MODE;
|
|
|
|
pr_debug("%s: dfps mode: suspend/resume\n",
|
|
|
|
__func__);
|
|
|
|
} else if (!strcmp(data,
|
|
|
|
"dfps_immediate_clk_mode")) {
|
2013-07-31 01:47:33 +00:00
|
|
|
pinfo->dfps_update =
|
2013-08-27 20:18:08 +00:00
|
|
|
DFPS_IMMEDIATE_CLK_UPDATE_MODE;
|
|
|
|
pr_debug("%s: dfps mode: Immediate clk\n",
|
|
|
|
__func__);
|
2014-01-17 11:19:22 +00:00
|
|
|
} else if (!strcmp(data,
|
|
|
|
"dfps_immediate_porch_mode")) {
|
|
|
|
pinfo->dfps_update =
|
|
|
|
DFPS_IMMEDIATE_PORCH_UPDATE_MODE;
|
|
|
|
pr_debug("%s: dfps mode: Immediate porch\n",
|
|
|
|
__func__);
|
2013-08-27 20:18:08 +00:00
|
|
|
} else {
|
|
|
|
pr_debug("%s: dfps to default mode\n",
|
|
|
|
__func__);
|
2013-07-31 01:47:33 +00:00
|
|
|
pinfo->dfps_update =
|
2013-08-27 20:18:08 +00:00
|
|
|
DFPS_SUSPEND_RESUME_MODE;
|
|
|
|
pr_debug("%s: dfps mode: suspend/resume\n",
|
|
|
|
__func__);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
pr_debug("%s: dfps update mode not configured\n",
|
|
|
|
__func__);
|
2013-07-31 01:47:33 +00:00
|
|
|
pinfo->dynamic_fps = false;
|
2013-08-27 20:18:08 +00:00
|
|
|
pr_debug("%s: dynamic FPS disabled\n",
|
|
|
|
__func__);
|
|
|
|
}
|
2013-07-31 01:47:33 +00:00
|
|
|
pinfo->new_fps = pinfo->mipi.frame_rate;
|
2013-08-27 20:18:08 +00:00
|
|
|
}
|
|
|
|
|
2013-06-29 01:35:23 +00:00
|
|
|
ctrl_pdata->disp_en_gpio = of_get_named_gpio(ctrl_pdev->dev.of_node,
|
|
|
|
"qcom,platform-enable-gpio", 0);
|
2013-06-20 00:37:50 +00:00
|
|
|
|
2013-11-21 01:25:19 +00:00
|
|
|
if (!gpio_is_valid(ctrl_pdata->disp_en_gpio))
|
2012-12-14 06:49:58 +00:00
|
|
|
pr_err("%s:%d, Disp_en gpio not specified\n",
|
|
|
|
__func__, __LINE__);
|
|
|
|
|
2013-09-10 02:24:54 +00:00
|
|
|
ctrl_pdata->bklt_en_gpio = of_get_named_gpio(ctrl_pdev->dev.of_node,
|
|
|
|
"qcom,platform-bklight-en-gpio", 0);
|
2013-11-21 01:25:19 +00:00
|
|
|
if (!gpio_is_valid(ctrl_pdata->bklt_en_gpio))
|
2013-09-10 02:24:54 +00:00
|
|
|
pr_info("%s: bklt_en gpio not specified\n", __func__);
|
|
|
|
|
2013-07-31 01:47:33 +00:00
|
|
|
if (pinfo->type == MIPI_CMD_PANEL) {
|
2013-09-03 18:22:24 +00:00
|
|
|
ctrl_pdata->disp_te_gpio = of_get_named_gpio
|
|
|
|
(ctrl_pdev->dev.of_node, "qcom,platform-te-gpio", 0);
|
|
|
|
if (!gpio_is_valid(ctrl_pdata->disp_te_gpio))
|
|
|
|
pr_err("%s:%d, Disp_te gpio not specified\n",
|
|
|
|
__func__, __LINE__);
|
|
|
|
}
|
|
|
|
|
2013-09-20 02:24:51 +00:00
|
|
|
if (gpio_is_valid(ctrl_pdata->disp_te_gpio) &&
|
|
|
|
pinfo->type == MIPI_CMD_PANEL) {
|
2013-03-26 21:10:40 +00:00
|
|
|
rc = gpio_request(ctrl_pdata->disp_te_gpio, "disp_te");
|
|
|
|
if (rc) {
|
|
|
|
pr_err("request TE gpio failed, rc=%d\n",
|
|
|
|
rc);
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
rc = gpio_tlmm_config(GPIO_CFG(
|
|
|
|
ctrl_pdata->disp_te_gpio, 1,
|
|
|
|
GPIO_CFG_INPUT,
|
|
|
|
GPIO_CFG_PULL_DOWN,
|
|
|
|
GPIO_CFG_2MA),
|
|
|
|
GPIO_CFG_ENABLE);
|
|
|
|
|
|
|
|
if (rc) {
|
|
|
|
pr_err("%s: unable to config tlmm = %d\n",
|
|
|
|
__func__, ctrl_pdata->disp_te_gpio);
|
|
|
|
gpio_free(ctrl_pdata->disp_te_gpio);
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = gpio_direction_input(ctrl_pdata->disp_te_gpio);
|
|
|
|
if (rc) {
|
|
|
|
pr_err("set_direction for disp_en gpio failed, rc=%d\n",
|
|
|
|
rc);
|
|
|
|
gpio_free(ctrl_pdata->disp_te_gpio);
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
pr_debug("%s: te_gpio=%d\n", __func__,
|
|
|
|
ctrl_pdata->disp_te_gpio);
|
|
|
|
}
|
|
|
|
|
2013-06-29 01:35:23 +00:00
|
|
|
ctrl_pdata->rst_gpio = of_get_named_gpio(ctrl_pdev->dev.of_node,
|
|
|
|
"qcom,platform-reset-gpio", 0);
|
2013-11-21 01:25:19 +00:00
|
|
|
if (!gpio_is_valid(ctrl_pdata->rst_gpio))
|
2012-12-14 06:49:58 +00:00
|
|
|
pr_err("%s:%d, reset gpio not specified\n",
|
|
|
|
__func__, __LINE__);
|
|
|
|
|
2013-08-07 01:53:51 +00:00
|
|
|
if (pinfo->mode_gpio_state != MODE_GPIO_NOT_VALID) {
|
|
|
|
|
|
|
|
ctrl_pdata->mode_gpio = of_get_named_gpio(
|
|
|
|
ctrl_pdev->dev.of_node,
|
|
|
|
"qcom,platform-mode-gpio", 0);
|
2013-11-21 01:25:19 +00:00
|
|
|
if (!gpio_is_valid(ctrl_pdata->mode_gpio))
|
2013-08-07 01:53:51 +00:00
|
|
|
pr_info("%s:%d, mode gpio not specified\n",
|
|
|
|
__func__, __LINE__);
|
|
|
|
}
|
|
|
|
|
2012-12-14 06:49:58 +00:00
|
|
|
if (mdss_dsi_clk_init(ctrl_pdev, ctrl_pdata)) {
|
|
|
|
pr_err("%s: unable to initialize Dsi ctrl clks\n", __func__);
|
|
|
|
return -EPERM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mdss_dsi_retrieve_ctrl_resources(ctrl_pdev,
|
2013-07-31 01:47:33 +00:00
|
|
|
pinfo->pdest,
|
2013-03-26 21:10:40 +00:00
|
|
|
ctrl_pdata)) {
|
2012-12-14 06:49:58 +00:00
|
|
|
pr_err("%s: unable to get Dsi controller res\n", __func__);
|
|
|
|
return -EPERM;
|
|
|
|
}
|
|
|
|
|
2012-11-06 00:51:27 +00:00
|
|
|
ctrl_pdata->panel_data.event_handler = mdss_dsi_event_handler;
|
2013-09-06 01:37:32 +00:00
|
|
|
ctrl_pdata->check_status = mdss_dsi_bta_status_check;
|
2012-12-14 06:49:58 +00:00
|
|
|
|
2013-03-26 21:10:40 +00:00
|
|
|
if (ctrl_pdata->bklt_ctrl == BL_PWM)
|
|
|
|
mdss_dsi_panel_pwm_cfg(ctrl_pdata);
|
|
|
|
|
2013-04-30 17:03:00 +00:00
|
|
|
mdss_dsi_ctrl_init(ctrl_pdata);
|
2012-04-24 03:39:17 +00:00
|
|
|
/*
|
|
|
|
* register in mdp driver
|
|
|
|
*/
|
2013-02-01 03:36:15 +00:00
|
|
|
|
2013-08-27 20:18:08 +00:00
|
|
|
ctrl_pdata->pclk_rate = mipi->dsi_pclk_rate;
|
2013-07-31 01:47:33 +00:00
|
|
|
ctrl_pdata->byte_clk_rate = pinfo->clk_rate / 8;
|
2013-05-06 23:10:03 +00:00
|
|
|
pr_debug("%s: pclk=%d, bclk=%d\n", __func__,
|
|
|
|
ctrl_pdata->pclk_rate, ctrl_pdata->byte_clk_rate);
|
|
|
|
|
2013-04-23 19:24:05 +00:00
|
|
|
ctrl_pdata->ctrl_state = CTRL_STATE_UNKNOWN;
|
2013-02-01 03:36:15 +00:00
|
|
|
|
2013-09-11 01:54:24 +00:00
|
|
|
if (pinfo->cont_splash_enabled) {
|
|
|
|
pinfo->panel_power_on = 1;
|
2013-05-13 20:04:09 +00:00
|
|
|
rc = mdss_dsi_panel_power_on(&(ctrl_pdata->panel_data), 1);
|
|
|
|
if (rc) {
|
|
|
|
pr_err("%s: Panel power on failed\n", __func__);
|
|
|
|
return rc;
|
|
|
|
}
|
2013-02-01 03:36:15 +00:00
|
|
|
|
2013-05-01 16:51:46 +00:00
|
|
|
mdss_dsi_clk_ctrl(ctrl_pdata, 1);
|
2013-04-23 19:24:05 +00:00
|
|
|
ctrl_pdata->ctrl_state |=
|
|
|
|
(CTRL_STATE_PANEL_INIT | CTRL_STATE_MDP_ACTIVE);
|
2013-09-11 01:54:24 +00:00
|
|
|
} else {
|
|
|
|
pinfo->panel_power_on = 0;
|
2013-05-06 23:10:03 +00:00
|
|
|
}
|
2013-02-01 03:36:15 +00:00
|
|
|
|
2012-12-14 06:49:58 +00:00
|
|
|
rc = mdss_register_panel(ctrl_pdev, &(ctrl_pdata->panel_data));
|
2012-04-24 03:39:17 +00:00
|
|
|
if (rc) {
|
2013-06-20 00:37:50 +00:00
|
|
|
pr_err("%s: unable to register MIPI DSI panel\n", __func__);
|
2012-04-24 03:39:17 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2013-07-31 01:47:33 +00:00
|
|
|
if (pinfo->pdest == DISPLAY_1) {
|
2013-03-26 21:10:40 +00:00
|
|
|
mdss_debug_register_base("dsi0",
|
|
|
|
ctrl_pdata->ctrl_base, ctrl_pdata->reg_size);
|
|
|
|
ctrl_pdata->ndx = 0;
|
|
|
|
} else {
|
|
|
|
mdss_debug_register_base("dsi1",
|
|
|
|
ctrl_pdata->ctrl_base, ctrl_pdata->reg_size);
|
|
|
|
ctrl_pdata->ndx = 1;
|
|
|
|
}
|
|
|
|
|
2013-06-20 00:37:50 +00:00
|
|
|
pr_debug("%s: Panel data initialized\n", __func__);
|
2012-04-24 03:39:17 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-12-14 06:49:58 +00:00
|
|
|
static const struct of_device_id mdss_dsi_ctrl_dt_match[] = {
|
|
|
|
{.compatible = "qcom,mdss-dsi-ctrl"},
|
2012-04-24 03:39:17 +00:00
|
|
|
{}
|
|
|
|
};
|
2012-12-14 06:49:58 +00:00
|
|
|
MODULE_DEVICE_TABLE(of, mdss_dsi_ctrl_dt_match);
|
2012-04-24 03:39:17 +00:00
|
|
|
|
2012-12-14 06:49:58 +00:00
|
|
|
static struct platform_driver mdss_dsi_ctrl_driver = {
|
|
|
|
.probe = mdss_dsi_ctrl_probe,
|
|
|
|
.remove = mdss_dsi_ctrl_remove,
|
2012-04-24 03:39:17 +00:00
|
|
|
.shutdown = NULL,
|
|
|
|
.driver = {
|
2012-12-14 06:49:58 +00:00
|
|
|
.name = "mdss_dsi_ctrl",
|
|
|
|
.of_match_table = mdss_dsi_ctrl_dt_match,
|
2012-04-24 03:39:17 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static int mdss_dsi_register_driver(void)
|
|
|
|
{
|
2012-12-14 06:49:58 +00:00
|
|
|
return platform_driver_register(&mdss_dsi_ctrl_driver);
|
2012-04-24 03:39:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int __init mdss_dsi_driver_init(void)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = mdss_dsi_register_driver();
|
|
|
|
if (ret) {
|
|
|
|
pr_err("mdss_dsi_register_driver() failed!\n");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
module_init(mdss_dsi_driver_init);
|
|
|
|
|
|
|
|
static void __exit mdss_dsi_driver_cleanup(void)
|
|
|
|
{
|
2012-12-14 06:49:58 +00:00
|
|
|
platform_driver_unregister(&mdss_dsi_ctrl_driver);
|
2012-04-24 03:39:17 +00:00
|
|
|
}
|
|
|
|
module_exit(mdss_dsi_driver_cleanup);
|
|
|
|
|
|
|
|
MODULE_LICENSE("GPL v2");
|
|
|
|
MODULE_DESCRIPTION("DSI controller driver");
|
|
|
|
MODULE_AUTHOR("Chandan Uddaraju <chandanu@codeaurora.org>");
|