* [PATCH] drm/msm/hdmi: Use pinctrl in HDMI driver
@ 2015-05-29 13:49 Stephane Viau
2015-05-29 14:56 ` Ivan T. Ivanov
0 siblings, 1 reply; 2+ messages in thread
From: Stephane Viau @ 2015-05-29 13:49 UTC (permalink / raw)
To: dri-devel; +Cc: linux-arm-msm, linux-kernel, robdclark, Stephane Viau
Some targets (eg: msm8994) use the pinctrl framework to configure
interface pins. This change adds support for initialization and
pinctrl active/sleep state control for the HDMI driver.
Signed-off-by: Stephane Viau <sviau@codeaurora.org>
---
drivers/gpu/drm/msm/hdmi/hdmi.c | 25 +++++++++++++++++++++++++
drivers/gpu/drm/msm/hdmi/hdmi.h | 5 +++++
drivers/gpu/drm/msm/hdmi/hdmi_connector.c | 31 +++++++++++++++++++++++++++++++
3 files changed, 61 insertions(+)
diff --git a/drivers/gpu/drm/msm/hdmi/hdmi.c b/drivers/gpu/drm/msm/hdmi/hdmi.c
index 8145362..6120666 100644
--- a/drivers/gpu/drm/msm/hdmi/hdmi.c
+++ b/drivers/gpu/drm/msm/hdmi/hdmi.c
@@ -354,6 +354,20 @@ static int get_gpio(struct device *dev, struct device_node *of_node, const char
}
return gpio;
}
+
+static struct pinctrl_state *get_pinctrl_state(struct device *dev,
+ struct pinctrl *pinctrl, const char *name)
+{
+ struct pinctrl_state *state = pinctrl_lookup_state(pinctrl, name);
+
+ if (IS_ERR_OR_NULL(state)) {
+ dev_err(dev, "failed to get pinctrl state \"%s\" (%ld)",
+ name, PTR_ERR(state));
+ return NULL;
+ }
+
+ return state;
+}
#endif
static int hdmi_bind(struct device *dev, struct device *master, void *data)
@@ -365,6 +379,7 @@ static int hdmi_bind(struct device *dev, struct device *master, void *data)
#ifdef CONFIG_OF
struct device_node *of_node = dev->of_node;
const struct of_device_id *match;
+ struct pinctrl *pinctrl;
match = of_match_node(dt_match, of_node);
if (match && match->data) {
@@ -383,6 +398,16 @@ static int hdmi_bind(struct device *dev, struct device *master, void *data)
hdmi_cfg->mux_sel_gpio = get_gpio(dev, of_node, "qcom,hdmi-tx-mux-sel");
hdmi_cfg->mux_lpm_gpio = get_gpio(dev, of_node, "qcom,hdmi-tx-mux-lpm");
+ /* not all targets have pinctrl, do not fail in case of error: */
+ pinctrl = devm_pinctrl_get(dev);
+ if (IS_ERR_OR_NULL(pinctrl)) {
+ dev_warn(dev, "cannot get pinctrl: %s\n", of_node->name);
+ } else {
+ hdmi_cfg->active = get_pinctrl_state(dev, pinctrl, "hdmi_active");
+ hdmi_cfg->sleep = get_pinctrl_state(dev, pinctrl, "hdmi_sleep");
+ hdmi_cfg->pinctrl = pinctrl;
+ DBG("pinctrl initialized.");
+ }
#else
static struct hdmi_platform_config config = {};
static const char *hpd_clk_names[] = {
diff --git a/drivers/gpu/drm/msm/hdmi/hdmi.h b/drivers/gpu/drm/msm/hdmi/hdmi.h
index a155c4a..4742df2 100644
--- a/drivers/gpu/drm/msm/hdmi/hdmi.h
+++ b/drivers/gpu/drm/msm/hdmi/hdmi.h
@@ -22,6 +22,7 @@
#include <linux/clk.h>
#include <linux/platform_device.h>
#include <linux/regulator/consumer.h>
+#include <linux/pinctrl/consumer.h>
#include <linux/hdmi.h>
#include "msm_drv.h"
@@ -95,6 +96,10 @@ struct hdmi_platform_config {
/* gpio's: */
int ddc_clk_gpio, ddc_data_gpio, hpd_gpio, mux_en_gpio, mux_sel_gpio;
int mux_lpm_gpio;
+
+ /* pinctrl: */
+ struct pinctrl *pinctrl;
+ struct pinctrl_state *active, *sleep;
};
void hdmi_set_mode(struct hdmi *hdmi, bool power_on);
diff --git a/drivers/gpu/drm/msm/hdmi/hdmi_connector.c b/drivers/gpu/drm/msm/hdmi/hdmi_connector.c
index 914bf95..6bbda54 100644
--- a/drivers/gpu/drm/msm/hdmi/hdmi_connector.c
+++ b/drivers/gpu/drm/msm/hdmi/hdmi_connector.c
@@ -181,6 +181,23 @@ error1:
return ret;
}
+static int pinctrl_config(struct hdmi *hdmi, bool on)
+{
+ struct drm_device *dev = hdmi->dev;
+ const struct hdmi_platform_config *config = hdmi->config;
+ struct pinctrl_state *state = on ? config->active : config->sleep;
+ int ret;
+
+ ret = pinctrl_select_state(config->pinctrl, state);
+ if (ret)
+ dev_err(dev->dev, "failed to set pinctrl state to %s: %d\n",
+ on ? "active" : "sleep", ret);
+
+ DBG("pinctrl %s", on ? "on" : "off");
+
+ return ret;
+}
+
static int hpd_enable(struct hdmi_connector *hdmi_connector)
{
struct hdmi *hdmi = hdmi_connector->hdmi;
@@ -199,6 +216,14 @@ static int hpd_enable(struct hdmi_connector *hdmi_connector)
}
}
+ if (config->pinctrl) {
+ ret = pinctrl_config(hdmi, true);
+ if (ret) {
+ dev_err(dev->dev, "can't configure pinctrl: %d\n", ret);
+ goto fail;
+ }
+ }
+
ret = gpio_config(hdmi, true);
if (ret) {
dev_err(dev->dev, "failed to configure GPIOs: %d\n", ret);
@@ -268,6 +293,12 @@ static void hdp_disable(struct hdmi_connector *hdmi_connector)
if (ret)
dev_warn(dev->dev, "failed to unconfigure GPIOs: %d\n", ret);
+ if (config->pinctrl) {
+ ret = pinctrl_config(hdmi, false);
+ if (ret)
+ dev_warn(dev->dev, "can't configure pinctrl: %d\n", ret);
+ }
+
for (i = 0; i < config->hpd_reg_cnt; i++) {
ret = regulator_disable(hdmi->hpd_regs[i]);
if (ret)
--
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] drm/msm/hdmi: Use pinctrl in HDMI driver
2015-05-29 13:49 [PATCH] drm/msm/hdmi: Use pinctrl in HDMI driver Stephane Viau
@ 2015-05-29 14:56 ` Ivan T. Ivanov
0 siblings, 0 replies; 2+ messages in thread
From: Ivan T. Ivanov @ 2015-05-29 14:56 UTC (permalink / raw)
To: Stephane Viau; +Cc: dri-devel, linux-arm-msm, linux-kernel, robdclark
Hi Stephane,
On Fri, 2015-05-29 at 09:49 -0400, Stephane Viau wrote:
> Some targets (eg: msm8994) use the pinctrl framework to configure
> interface pins. This change adds support for initialization and
> pinctrl active/sleep state control for the HDMI driver.
>
> Signed-off-by: Stephane Viau <sviau@codeaurora.org>
> ---
> drivers/gpu/drm/msm/hdmi/hdmi.c | 25 +++++++++++++++++++++++++
> drivers/gpu/drm/msm/hdmi/hdmi.h | 5 +++++
> drivers/gpu/drm/msm/hdmi/hdmi_connector.c | 31 +++++++++++++++++++++++++++++++
> 3 files changed, 61 insertions(+)
>
No devicetree binding documentation?
> static int hdmi_bind(struct device *dev, struct device *master, void *data)
> @@ -365,6 +379,7 @@ static int hdmi_bind(struct device *dev, struct device *master, void *data)
> #ifdef CONFIG_OF
> struct device_node *of_node = dev->of_node;
> const struct of_device_id *match;
> + struct pinctrl *pinctrl;
>
> match = of_match_node(dt_match, of_node);
> if (match && match->data) {
> @@ -383,6 +398,16 @@ static int hdmi_bind(struct device *dev, struct device *master, void *data)
> hdmi_cfg->mux_sel_gpio = get_gpio(dev, of_node, "qcom,hdmi-tx-mux-sel");
> hdmi_cfg->mux_lpm_gpio = get_gpio(dev, of_node, "qcom,hdmi-tx-mux-lpm");
>
> + /* not all targets have pinctrl, do not fail in case of error: */
> + pinctrl = devm_pinctrl_get(dev);
> + if (IS_ERR_OR_NULL(pinctrl)) {
> + dev_warn(dev, "cannot get pinctrl: %s\n", of_node->name);
> + } else {
> + hdmi_cfg->active = get_pinctrl_state(dev, pinctrl, "hdmi_active");
> + hdmi_cfg->sleep = get_pinctrl_state(dev, pinctrl, "hdmi_sleep");
How this differs from PINCTRL_STATE_DEFAULT and PINCTRL_STATE_SLEEP?
Regards,
Ivan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-05-29 14:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-29 13:49 [PATCH] drm/msm/hdmi: Use pinctrl in HDMI driver Stephane Viau
2015-05-29 14:56 ` Ivan T. Ivanov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox