All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rahul Sharma <rahul.sharma@samsung.com>
To: linux-samsung-soc@vger.kernel.org, dri-devel@lists.freedesktop.org
Cc: kgene.kim@samsung.com, sw0312.kim@samsung.com,
	inki.dae@samsung.com, seanpaul@chromium.org,
	l.stach@pengutronix.de, tomasz.figa@gmail.com,
	s.nawrocki@samsung.com, joshi@samsung.com, r.sh.open@gmail.com,
	Rahul Sharma <rahul.sharma@samsung.com>
Subject: [PATCH 3/7] drm/exynos: add hdmiphy pmu bit control in hdmiphy driver
Date: Fri, 30 Aug 2013 12:29:30 +0530	[thread overview]
Message-ID: <1377845974-28373-4-git-send-email-rahul.sharma@samsung.com> (raw)
In-Reply-To: <1377845974-28373-1-git-send-email-rahul.sharma@samsung.com>

Before hdmiphy operation like config, start etc, hdmiphy
bit in PMU block should be enabled. Earlier this happens
in hdmi drvier through a dummy "hdmiphy" clock.

Signed-off-by: Rahul Sharma <rahul.sharma@samsung.com>
---
 .../devicetree/bindings/video/exynos_hdmiphy.txt   |    6 ++
 drivers/gpu/drm/exynos/exynos_drm_hdmi.h           |    2 +
 drivers/gpu/drm/exynos/exynos_hdmi.c               |    2 +
 drivers/gpu/drm/exynos/exynos_hdmiphy.c            |   82 ++++++++++++++++++++
 4 files changed, 92 insertions(+)

diff --git a/Documentation/devicetree/bindings/video/exynos_hdmiphy.txt b/Documentation/devicetree/bindings/video/exynos_hdmiphy.txt
index 162f641..f6bf096 100644
--- a/Documentation/devicetree/bindings/video/exynos_hdmiphy.txt
+++ b/Documentation/devicetree/bindings/video/exynos_hdmiphy.txt
@@ -6,10 +6,16 @@ Required properties:
 	2) "samsung,exynos4210-hdmiphy".
 	3) "samsung,exynos4212-hdmiphy".
 - reg: I2C address of the hdmiphy device.
+- phy-power-control: this child node represents phy power control
+	register which is inside the pmu block (power management unit).
 
 Example:
 
 	hdmiphy {
 		compatible = "samsung,exynos4210-hdmiphy";
 		reg = <0x38>;
+
+		phy-power-control {
+				reg = <0x10040700 0x04>;
+		};
 	};
diff --git a/drivers/gpu/drm/exynos/exynos_drm_hdmi.h b/drivers/gpu/drm/exynos/exynos_drm_hdmi.h
index 1c839f8..9a14f96 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_hdmi.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_hdmi.h
@@ -68,6 +68,8 @@ void exynos_mixer_ops_register(struct exynos_mixer_ops *ops);
 int exynos_hdmiphy_driver_register(void);
 void exynos_hdmiphy_driver_unregister(void);
 
+void exynos_hdmiphy_poweron(struct device *dev);
+void exynos_hdmiphy_poweroff(struct device *dev);
 void exynos_hdmiphy_enable(struct device *dev);
 void exynos_hdmiphy_disable(struct device *dev);
 int exynos_hdmiphy_check_mode(struct device *dev,
diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c
index cd1d921..a6234fc 100644
--- a/drivers/gpu/drm/exynos/exynos_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
@@ -1131,6 +1131,7 @@ static void hdmiphy_poweron(struct hdmi_context *hdata)
 	if (hdata->type == HDMI_TYPE14)
 		hdmi_reg_writemask(hdata, HDMI_PHY_CON_0, 0,
 			HDMI_PHY_POWER_OFF_EN);
+	exynos_hdmiphy_poweron(hdata->hdmiphy_dev);
 }
 
 static void hdmiphy_poweroff(struct hdmi_context *hdata)
@@ -1138,6 +1139,7 @@ static void hdmiphy_poweroff(struct hdmi_context *hdata)
 	if (hdata->type == HDMI_TYPE14)
 		hdmi_reg_writemask(hdata, HDMI_PHY_CON_0, ~0,
 			HDMI_PHY_POWER_OFF_EN);
+	exynos_hdmiphy_poweroff(hdata->hdmiphy_dev);
 }
 
 static void hdmi_conf_apply(struct hdmi_context *hdata)
diff --git a/drivers/gpu/drm/exynos/exynos_hdmiphy.c b/drivers/gpu/drm/exynos/exynos_hdmiphy.c
index 82daa42..b1b8a0f 100644
--- a/drivers/gpu/drm/exynos/exynos_hdmiphy.c
+++ b/drivers/gpu/drm/exynos/exynos_hdmiphy.c
@@ -30,6 +30,9 @@ struct hdmiphy_context {
 	struct device		*dev;
 	struct hdmiphy_config	*current_conf;
 
+	/* hdmiphy resources */
+	void __iomem		*phy_pow_ctrl_reg;
+
 	struct hdmiphy_config	*confs;
 	unsigned int		nr_confs;
 };
@@ -225,6 +228,49 @@ static struct hdmiphy_config *hdmiphy_find_conf(struct hdmiphy_context *hdata,
 	return NULL;
 }
 
+static int hdmiphy_dt_parse_power_control(struct hdmiphy_context *hdata)
+{
+	struct device_node *phy_pow_ctrl_node;
+	u32 buf[2];
+	int ret = 0;
+
+	phy_pow_ctrl_node = of_get_child_by_name(hdata->dev->of_node,
+			"phy-power-control");
+	if (!phy_pow_ctrl_node) {
+		DRM_ERROR("Failed to find phy power control node\n");
+		ret = -ENODEV;
+		goto fail;
+	}
+
+	/* reg property holds two informations: addr of pmu register, size */
+	if (of_property_read_u32_array(phy_pow_ctrl_node, "reg",
+			(u32 *)&buf, 2)) {
+		DRM_ERROR("faild to get phy power control reg\n");
+		ret = -EINVAL;
+		goto fail;
+	}
+
+	hdata->phy_pow_ctrl_reg = devm_ioremap(hdata->dev, buf[0], buf[1]);
+	if (!hdata->phy_pow_ctrl_reg) {
+		DRM_ERROR("failed to ioremap phy pmu reg\n");
+		ret = -ENOMEM;
+		goto fail;
+	}
+
+fail:
+	of_node_put(phy_pow_ctrl_node);
+	return ret;
+}
+
+static inline void hdmiphy_pow_ctrl_reg_writemask(
+			struct hdmiphy_context *hdata,
+			u32 value, u32 mask)
+{
+	u32 old = readl(hdata->phy_pow_ctrl_reg);
+	value = (value & mask) | (old & ~mask);
+	writel(value, hdata->phy_pow_ctrl_reg);
+}
+
 static int hdmiphy_reg_writeb(struct hdmiphy_context *hdata,
 			u32 reg_offset, u8 value)
 {
@@ -353,6 +399,36 @@ void exynos_hdmiphy_disable(struct device *dev)
 	}
 }
 
+void exynos_hdmiphy_poweron(struct device *dev)
+{
+	struct hdmiphy_context *hdata = dev_get_drvdata(dev);
+
+	DRM_DEBUG_KMS("[%d]\n", __LINE__);
+
+	if (!hdata) {
+		DRM_ERROR("Invalid arg: hdmiphy device pointer.\n");
+		return;
+	}
+
+	hdmiphy_pow_ctrl_reg_writemask(hdata, PMU_HDMI_PHY_ENABLE,
+		PMU_HDMI_PHY_CONTROL_MASK);
+}
+
+void exynos_hdmiphy_poweroff(struct device *dev)
+{
+	struct hdmiphy_context *hdata = dev_get_drvdata(dev);
+
+	DRM_DEBUG_KMS("[%d]\n", __LINE__);
+
+	if (!hdata) {
+		DRM_ERROR("Invalid arg: hdmiphy device pointer.\n");
+		return;
+	}
+
+	hdmiphy_pow_ctrl_reg_writemask(hdata, PMU_HDMI_PHY_DISABLE,
+		PMU_HDMI_PHY_CONTROL_MASK);
+}
+
 int exynos_hdmiphy_conf_apply(struct device *dev)
 {
 	struct hdmiphy_context *hdata = dev_get_drvdata(dev);
@@ -413,6 +489,7 @@ static int hdmiphy_i2c_device_probe(struct i2c_client *client,
 	struct hdmiphy_context *hdata;
 	struct hdmiphy_drv_data *drv;
 	const struct of_device_id *match;
+	int ret;
 
 	DRM_DEBUG_KMS("[%d]\n", __LINE__);
 
@@ -436,6 +513,11 @@ static int hdmiphy_i2c_device_probe(struct i2c_client *client,
 	hdata->nr_confs = drv->count;
 
 	i2c_set_clientdata(client, hdata);
+	ret = hdmiphy_dt_parse_power_control(hdata);
+	if (ret) {
+		DRM_ERROR("failed to map hdmiphy pow control reg.\n");
+		return ret;
+	}
 
 	return 0;
 }
-- 
1.7.10.4

  parent reply	other threads:[~2013-08-30  6:37 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-30  6:59 [PATCH 0/7] drm/exynos: move hdmiphy related code to hdmiphy driver Rahul Sharma
2013-08-30  6:59 ` [PATCH 1/7] " Rahul Sharma
2013-09-03 14:45   ` Sean Paul
2013-09-04  5:47     ` Rahul Sharma
2013-09-04  7:37       ` Inki Dae
2013-09-04 14:51         ` Sean Paul
2013-09-05  4:16           ` Inki Dae
2013-09-05  4:43             ` Rahul Sharma
2013-09-05  5:22               ` Inki Dae
2013-09-05  6:03                 ` Rahul Sharma
2013-09-05  6:19                   ` Inki Dae
2013-09-05 13:19                     ` Sean Paul
2013-09-05 13:50                       ` Inki Dae
2013-09-05 16:31                         ` Sylwester Nawrocki
2013-09-06  3:37                         ` Rahul Sharma
2013-09-06 13:51                           ` Sean Paul
2013-09-10  8:27                             ` Rahul Sharma
2013-09-16 12:40                               ` Inki Dae
2013-09-27  4:53                                 ` Rahul Sharma
2013-09-28 16:10                                   ` Inki Dae
     [not found]                                     ` <CAAQKjZPtxLAJOz6573+hEPZokEnvGF8BTMXoxcYUQ8zySAn-OA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-09-29 22:08                                       ` Sylwester Nawrocki
2013-09-29 23:13                                         ` Tomasz Figa
2013-10-01  4:40                                           ` Inki Dae
     [not found]                                     ` <5248A4EE.9000708@samsung.com>
     [not found]                                       ` <gmail.com@samsung.com>
     [not found]                                         ` <5248A4EE.9000708-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-10-01  4:39                                           ` Inki Dae
2013-10-03  2:28                                             ` Shirish S
2013-10-28  6:06                                               ` Shirish S
2013-09-04 14:33       ` Sean Paul
2013-09-30 10:50   ` Tushar Behera
2013-08-30  6:59 ` [PATCH 2/7] drm/exynos: remove dummy hdmiphy clock Rahul Sharma
2013-09-03 15:58   ` Sean Paul
2013-08-30  6:59 ` Rahul Sharma [this message]
2013-09-03 16:10   ` [PATCH 3/7] drm/exynos: add hdmiphy pmu bit control in hdmiphy driver Sean Paul
2013-08-30  6:59 ` [PATCH 4/7] drm/exynos: add support for exynos5420 hdmiphy Rahul Sharma
2013-09-03 16:15   ` Sean Paul
2013-08-30  6:59 ` [PATCH 5/7] exynos/drm: fix ddc i2c device probe failure Rahul Sharma
2013-08-30  6:59 ` [PATCH 6/7] ARM: dts: update hdmiphy dt node for exynos5250 Rahul Sharma
2013-08-30  6:59 ` [PATCH 7/7] ARM: dts: update hdmiphy dt node for exynos5420 Rahul Sharma
2013-08-30  8:33 ` [PATCH 0/7] drm/exynos: move hdmiphy related code to hdmiphy driver Inki Dae
2013-08-30  9:06   ` Inki Dae
2013-08-30 10:05   ` Rahul Sharma
2013-09-02  5:08     ` Inki Dae
2013-09-02  6:28       ` Rahul Sharma
2013-09-02  7:22         ` Inki Dae
2013-09-02  9:06           ` Rahul Sharma
2013-09-02 10:06             ` Inki Dae

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1377845974-28373-4-git-send-email-rahul.sharma@samsung.com \
    --to=rahul.sharma@samsung.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=inki.dae@samsung.com \
    --cc=joshi@samsung.com \
    --cc=kgene.kim@samsung.com \
    --cc=l.stach@pengutronix.de \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=r.sh.open@gmail.com \
    --cc=s.nawrocki@samsung.com \
    --cc=seanpaul@chromium.org \
    --cc=sw0312.kim@samsung.com \
    --cc=tomasz.figa@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.