Skip to content

Commit

Permalink
try to add suspend/active pinmux bits
Browse files Browse the repository at this point in the history
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
  • Loading branch information
johnstultz-work authored and sumitsemwal committed Jul 30, 2019
1 parent 8801e70 commit 1f37b09
Show file tree
Hide file tree
Showing 3 changed files with 164 additions and 0 deletions.
40 changes: 40 additions & 0 deletions arch/arm64/boot/dts/qcom/sdm845-blueline.dts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,42 @@
};
};

&pm8998_gpio {
/* Don't drive these, for display */
sde_pmgpio_active: sde_pmgpio_active {
pins = "gpio2", "gpio5";
function = "normal";
input-enable;
bias-disable;
power-source = <0>;
};
sde_pmgpio_suspend: sde_pmgpio_suspend {
pins = "gpio2", "gpio5";
function = "normal";
input-enable;
bias-disable;
power-source = <0>;
};
};

&sde_te_active {
mux {
pins = "gpio12";
};
config {
pins = "gpio12";
};
};

&sde_te_suspend {
mux {
pins = "gpio12";
};
config {
pins = "gpio12";
};
};

&adsp_pas {
status = "okay";

Expand Down Expand Up @@ -602,6 +638,10 @@

reset-gpios = <&tlmm 6 GPIO_ACTIVE_HIGH>;

pinctrl-names = "panel_active", "panel_suspend";
pinctrl-0 = <&sde_dsi_active &sde_te_active &sde_pmgpio_active>;
pinctrl-1 = <&sde_dsi_suspend &sde_te_suspend &sde_pmgpio_suspend>;

ports {
#address-cells = <1>;
#size-cells = <0>;
Expand Down
51 changes: 51 additions & 0 deletions arch/arm64/boot/dts/qcom/sdm845.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -2035,6 +2035,57 @@
function = "qup15";
};
};

sde_dsi_active: sde_dsi_active {
mux {
pins = "gpio6", "gpio52";
function = "gpio";
};

config {
pins = "gpio6", "gpio52";
drive-strength = <8>; /* 8 mA */
bias-disable = <0>; /* no pull */
};
};
sde_dsi_suspend: sde_dsi_suspend {
mux {
pins = "gpio6", "gpio52";
function = "gpio";
};

config {
pins = "gpio6", "gpio52";
drive-strength = <2>; /* 2 mA */
bias-pull-down; /* PULL DOWN */
};
};

sde_te_active: sde_te_active {
mux {
pins = "gpio10";
function = "mdp_vsync";
};

config {
pins = "gpio10";
drive-strength = <2>; /* 2 mA */
bias-pull-down; /* PULL DOWN */
};
};

sde_te_suspend: sde_te_suspend {
mux {
pins = "gpio10";
function = "mdp_vsync";
};

config {
pins = "gpio10";
drive-strength = <2>; /* 2 mA */
bias-pull-down; /* PULL DOWN */
};
};
};

gpu@5000000 {
Expand Down
73 changes: 73 additions & 0 deletions drivers/gpu/drm/panel/panel-lg-sw43408.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <linux/of_device.h>

#include <linux/gpio/consumer.h>
#include <linux/pinctrl/consumer.h>
#include <linux/regulator/consumer.h>

#include <drm/drm_device.h>
Expand Down Expand Up @@ -81,6 +82,11 @@ struct panel_info {

struct gpio_desc *reset_gpio;

struct pinctrl *pinctrl;
struct pinctrl_state *active;
struct pinctrl_state *suspend;


bool prepared;
bool enabled;
};
Expand Down Expand Up @@ -120,6 +126,23 @@ static int send_mipi_cmds(struct drm_panel *panel, const struct panel_cmd *cmds)
return 0;
}

static int panel_set_pinctrl_state(struct panel_info *panel, bool enable)
{
int rc = 0;
struct pinctrl_state *state;

if (enable)
state = panel->active;
else
state = panel->suspend;

rc = pinctrl_select_state(panel->pinctrl, state);
if (rc)
pr_err("[%s] failed to set pin state, rc=%d\n", panel->desc->panel_name,
rc);
return rc;
}

static int lg_panel_disable(struct drm_panel *panel)
{
struct panel_info *pinfo = to_panel_info(panel);
Expand All @@ -138,6 +161,12 @@ static int lg_panel_power_off(struct drm_panel *panel)

gpiod_set_value(pinfo->reset_gpio, 0);

ret = panel_set_pinctrl_state(pinfo, false);
if (ret) {
pr_err("[%s] failed to set pinctrl, rc=%d\n", pinfo->desc->panel_name, ret);
return ret;
}

for (i = 0; i < ARRAY_SIZE(pinfo->supplies); i++) {
ret = regulator_set_load(pinfo->supplies[i].consumer,
regulator_disable_loads[i]);
Expand Down Expand Up @@ -205,6 +234,12 @@ static int lg_panel_power_on(struct panel_info *pinfo)
if (ret < 0)
return ret;

ret = panel_set_pinctrl_state(pinfo, true);
if (ret) {
pr_err("[%s] failed to set pinctrl, rc=%d\n", pinfo->desc->panel_name, ret);
return ret;
}

/*
* Reset sequence of LG sw43408 panel requires the panel to be
* out of reset for 9ms, followed by being held in reset
Expand Down Expand Up @@ -432,6 +467,40 @@ static const struct of_device_id panel_of_match[] = {
};
MODULE_DEVICE_TABLE(of, panel_of_match);


static int panel_pinctrl_init(struct panel_info *panel)
{
struct device *dev = &panel->link->dev;
int rc = 0;

panel->pinctrl = devm_pinctrl_get(dev);
if (IS_ERR_OR_NULL(panel->pinctrl)) {
rc = PTR_ERR(panel->pinctrl);
pr_err("failed to get pinctrl, rc=%d\n", rc);
goto error;
}

panel->active = pinctrl_lookup_state(panel->pinctrl,
"panel_active");
if (IS_ERR_OR_NULL(panel->active)) {
rc = PTR_ERR(panel->active);
pr_err("failed to get pinctrl active state, rc=%d\n", rc);
goto error;
}

panel->suspend =
pinctrl_lookup_state(panel->pinctrl, "panel_suspend");

if (IS_ERR_OR_NULL(panel->suspend)) {
rc = PTR_ERR(panel->suspend);
pr_err("failed to get pinctrl suspend state, rc=%d\n", rc);
goto error;
}

error:
return rc;
}

static int panel_add(struct panel_info *pinfo)
{
struct device *dev = &pinfo->link->dev;
Expand All @@ -452,6 +521,10 @@ pr_err("In sw43408 panel add\n");
return PTR_ERR(pinfo->reset_gpio);
}

ret = panel_pinctrl_init(pinfo);
if (ret < 0)
return ret;

ret = lg_panel_backlight_init(pinfo);
if (ret < 0)
return ret;
Expand Down

0 comments on commit 1f37b09

Please sign in to comment.