Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e6650504 authored by Manoj Rao's avatar Manoj Rao
Browse files

msm: mdss: dsi: add pinctrl support



Add pinctrl support for the installation
of the required GPIOs from DT. Document
properties in bindings.
Make appropriate changes in the driver to
initialize and set the pins to active and sleep
states during unblank and blank stages respectively
in DSI driver.

Change-Id: Ib58d9162d915adace38ca36a0a3af9fa964d8039
Signed-off-by: default avatarManoj Rao <manojraj@codeaurora.org>
Signed-off-by: default avatarJeevan Shriram <jshriram@codeaurora.org>
parent 7b21ec62
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -52,6 +52,12 @@ Optional properties:
- qcom,platform-bklight-en-gpio:	Specifies the gpio used to enable display back-light
- qcom,platform-mode-gpio:		Select video/command mode of panel through gpio when it supports
					both modes.
- pinctrl-names:			List of names to assign mdss pin states defined in pinctrl device node
					Refer to pinctrl-bindings.txt
- pinctrl-<0..n>:			Lists phandles each pointing to the pin configuration node within a pin
					controller. These pin configurations are installed in the pinctrl
					device node. Refer to pinctrl-bindings.txt


Example:
        mdss_dsi0: qcom,mdss_dsi@fd922800 {
@@ -76,6 +82,9 @@ Example:
			00 c0 00 00 00 00 00 01 bb];
		qcom,mdss-fb-map = <&mdss_fb0>;
		qcom,mdss-mdp = <&mdss_mdp>;
		pinctrl-names = "mdss_default", "mdss_sleep";
		pinctrl-0 = <&mdss_dsi_active>;
		pinctrl-1 = <&mdss_dsi_suspend>;
		qcom,platform-reset-gpio = <&msmgpio 25 1>;
		qcom,platform-te-gpio = <&msmgpio 24 0>;
		qcom,platform-enable-gpio = <&msmgpio 58 1>;
+3 −0
Original line number Diff line number Diff line
@@ -27,6 +27,9 @@

#define MAX_DRV_SUP_MMB_BLKS	44

#define MDSS_PINCTRL_STATE_DEFAULT "mdss_default"
#define MDSS_PINCTRL_STATE_SLEEP  "mdss_sleep"

enum mdss_mdp_clk_type {
	MDSS_CLK_AHB,
	MDSS_CLK_AXI,
+63 −1
Original line number Diff line number Diff line
@@ -641,6 +641,59 @@ int mdss_dsi_on(struct mdss_panel_data *pdata)
	return 0;
}

static int mdss_dsi_pinctrl_set_state(
	struct mdss_dsi_ctrl_pdata *ctrl_pdata,
	bool active)
{
	struct pinctrl_state *pin_state;
	int rc = -EFAULT;

	if (IS_ERR_OR_NULL(ctrl_pdata->pin_res.pinctrl))
		return PTR_ERR(ctrl_pdata->pin_res.pinctrl);

	pin_state = active ? ctrl_pdata->pin_res.gpio_state_active
				: ctrl_pdata->pin_res.gpio_state_suspend;
	if (!IS_ERR_OR_NULL(pin_state)) {
		rc = pinctrl_select_state(ctrl_pdata->pin_res.pinctrl,
				pin_state);
		if (rc)
			pr_err("%s: can not set %s pins\n", __func__,
			       active ? MDSS_PINCTRL_STATE_DEFAULT
			       : MDSS_PINCTRL_STATE_SLEEP);
	} else {
		pr_err("%s: invalid '%s' pinstate\n", __func__,
		       active ? MDSS_PINCTRL_STATE_DEFAULT
		       : MDSS_PINCTRL_STATE_SLEEP);
	}
	return rc;
}

static int mdss_dsi_pinctrl_init(struct platform_device *pdev)
{
	struct mdss_dsi_ctrl_pdata *ctrl_pdata;

	ctrl_pdata = platform_get_drvdata(pdev);
	ctrl_pdata->pin_res.pinctrl = devm_pinctrl_get(&pdev->dev);
	if (IS_ERR_OR_NULL(ctrl_pdata->pin_res.pinctrl)) {
		pr_err("%s: failed to get pinctrl\n", __func__);
		return PTR_ERR(ctrl_pdata->pin_res.pinctrl);
	}

	ctrl_pdata->pin_res.gpio_state_active
		= pinctrl_lookup_state(ctrl_pdata->pin_res.pinctrl,
				MDSS_PINCTRL_STATE_DEFAULT);
	if (IS_ERR_OR_NULL(ctrl_pdata->pin_res.gpio_state_active))
		pr_warn("%s: can not get default pinstate\n", __func__);

	ctrl_pdata->pin_res.gpio_state_suspend
		= pinctrl_lookup_state(ctrl_pdata->pin_res.pinctrl,
				MDSS_PINCTRL_STATE_SLEEP);
	if (IS_ERR_OR_NULL(ctrl_pdata->pin_res.gpio_state_suspend))
		pr_warn("%s: can not get sleep pinstate\n", __func__);

	return 0;
}

static int mdss_dsi_unblank(struct mdss_panel_data *pdata)
{
	int ret = 0;
@@ -657,6 +710,8 @@ static int mdss_dsi_unblank(struct mdss_panel_data *pdata)
	ctrl_pdata = container_of(pdata, struct mdss_dsi_ctrl_pdata,
				panel_data);
	mipi  = &pdata->panel_info.mipi;
	if (mdss_dsi_pinctrl_set_state(ctrl_pdata, true))
		pr_debug("dsi unblank: pinctrl not enabled\n");

	if (!(ctrl_pdata->ctrl_state & CTRL_STATE_PANEL_INIT)) {
		ret = ctrl_pdata->on(pdata);
@@ -725,6 +780,9 @@ static int mdss_dsi_blank(struct mdss_panel_data *pdata)
		}
		ctrl_pdata->ctrl_state &= ~CTRL_STATE_PANEL_INIT;
	}
	if (mdss_dsi_pinctrl_set_state(ctrl_pdata, false))
		pr_debug("dsi blank: pinctrl not enabled\n");

	pr_debug("%s-:End\n", __func__);
	return ret;
}
@@ -1129,11 +1187,15 @@ static int mdss_dsi_ctrl_probe(struct platform_device *pdev)
		goto error_no_mem;
	}

	rc = mdss_dsi_pinctrl_init(pdev);
	if (rc)
		pr_warn("%s: failed to get pin resources\n", __func__);

	/* 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",
		pr_err("%s: failed to get vreg data from dt, rc=%d\n",
		       __func__, rc);
		goto error_vreg;
	}
+9 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#include <linux/mdss_io_util.h>
#include <mach/scm-io.h>
#include <linux/irqreturn.h>
#include <linux/pinctrl/consumer.h>

#include "mdss_panel.h"
#include "mdss_dsi_cmd.h"
@@ -213,6 +214,12 @@ struct dsi_drv_cm_data {
	int broadcast_enable;
};

struct dsi_pinctrl_res {
	struct pinctrl *pinctrl;
	struct pinctrl_state *gpio_state_active;
	struct pinctrl_state *gpio_state_suspend;
};

enum {
	DSI_CTRL_0,
	DSI_CTRL_1,
@@ -292,6 +299,8 @@ struct mdss_dsi_ctrl_pdata {

	struct dsi_buf tx_buf;
	struct dsi_buf rx_buf;

	struct dsi_pinctrl_res pin_res;
};

int dsi_panel_device_register(struct device_node *pan_node,