dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Yakir Yang <ykk@rock-chips.com>
To: Mark Yao <yzq@rock-chips.com>, Inki Dae <inki.dae@samsung.com>,
	Jingoo Han <jingoohan1@gmail.com>,
	Heiko Stuebner <heiko@sntech.de>
Cc: "Javier Martinez Canillas" <javier@osg.samsung.com>,
	"Stéphane Marchesin" <marcheu@chromium.org>,
	"Tomasz Figa" <tomasz.figa@chromium.com>,
	"David Airlie" <airlied@linux.ie>,
	daniel.vetter@ffwll.ch, "Thierry Reding" <treding@nvidia.com>,
	dianders@chromium.org,
	"Krzysztof Kozlowski" <k.kozlowski@samsung.com>,
	emil.l.velikov@gmail.com,
	"Dan Carpenter" <dan.carpenter@oracle.com>,
	"Yakir Yang" <ykk@rock-chips.com>,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linux-samsung-soc@vger.kernel.org,
	linux-rockchip@lists.infradead.org
Subject: [PATCH v3 02/10] drm/rockchip: analogix_dp: split the lcdc select setting into device data
Date: Tue, 14 Jun 2016 19:46:08 +0800	[thread overview]
Message-ID: <1465904768-805-1-git-send-email-ykk@rock-chips.com> (raw)
In-Reply-To: <1465904718-663-1-git-send-email-ykk@rock-chips.com>

eDP controller need to declare which vop provide the video source,
and it's defined in GRF registers.

But different chips have different GRF register address, so we need to
create a device data to declare the GRF messages for each chips.

Signed-off-by: Yakir Yang <ykk@rock-chips.com>
Acked-by: Mark Yao <mark.yao@rock-chips.com>
---
Changes in v3:
- Write a kerneldoc-style comment explaining the chips data fields (Tomasz, reviewed at Google Gerrit)
    [https://chromium-review.googlesource.com/#/c/346313/10/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c@39]
- Drop the '.lcdcsel_mask' number in chips data field (Tomasz, reviewed at Google Gerrit)
    [https://chromium-review.googlesource.com/#/c/346313/10/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c@382]
- Add acked flag from Mark.

Changes in v2: None

 drivers/gpu/drm/rockchip/analogix_dp-rockchip.c | 39 +++++++++++++++++++------
 1 file changed, 30 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
index 2bc8a7e..3855f46 100644
--- a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
+++ b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
@@ -14,6 +14,7 @@
 
 #include <linux/component.h>
 #include <linux/mfd/syscon.h>
+#include <linux/of_device.h>
 #include <linux/of_graph.h>
 #include <linux/regmap.h>
 #include <linux/reset.h>
@@ -35,11 +36,17 @@
 
 #define to_dp(nm)	container_of(nm, struct rockchip_dp_device, nm)
 
-/* dp grf register offset */
-#define GRF_SOC_CON6                            0x025c
-#define GRF_EDP_LCD_SEL_MASK                    BIT(5)
-#define GRF_EDP_SEL_VOP_LIT                     BIT(5)
-#define GRF_EDP_SEL_VOP_BIG                     0
+/**
+ * struct rockchip_dp_chip_data - splite the grf setting of kind of chips
+ * @lcdsel_grf_reg: grf register offset of lcdc select
+ * @lcdsel_big: reg value of selecting vop big for eDP
+ * @lcdsel_lit: reg value of selecting vop little for eDP
+ */
+struct rockchip_dp_chip_data {
+	u32	lcdsel_grf_reg;
+	u32	lcdsel_big;
+	u32	lcdsel_lit;
+};
 
 struct rockchip_dp_device {
 	struct drm_device        *drm_dev;
@@ -51,6 +58,8 @@ struct rockchip_dp_device {
 	struct regmap            *grf;
 	struct reset_control     *rst;
 
+	const struct rockchip_dp_chip_data *data;
+
 	struct analogix_dp_plat_data plat_data;
 };
 
@@ -119,13 +128,13 @@ static void rockchip_dp_drm_encoder_enable(struct drm_encoder *encoder)
 		return;
 
 	if (ret)
-		val = GRF_EDP_SEL_VOP_LIT | (GRF_EDP_LCD_SEL_MASK << 16);
+		val = dp->data->lcdsel_lit;
 	else
-		val = GRF_EDP_SEL_VOP_BIG | (GRF_EDP_LCD_SEL_MASK << 16);
+		val = dp->data->lcdsel_big;
 
 	dev_dbg(dp->dev, "vop %s output to dp\n", (ret) ? "LIT" : "BIG");
 
-	ret = regmap_write(dp->grf, GRF_SOC_CON6, val);
+	ret = regmap_write(dp->grf, dp->data->lcdsel_grf_reg, val);
 	if (ret != 0) {
 		dev_err(dp->dev, "Could not write to GRF: %d\n", ret);
 		return;
@@ -246,6 +255,7 @@ static int rockchip_dp_bind(struct device *dev, struct device *master,
 			    void *data)
 {
 	struct rockchip_dp_device *dp = dev_get_drvdata(dev);
+	const struct rockchip_dp_chip_data *dp_data;
 	struct drm_device *drm_dev = data;
 	int ret;
 
@@ -256,10 +266,15 @@ static int rockchip_dp_bind(struct device *dev, struct device *master,
 	 */
 	dev_set_drvdata(dev, NULL);
 
+	dp_data = of_device_get_match_data(dev);
+	if (!dp_data)
+		return -ENODEV;
+
 	ret = rockchip_dp_init(dp);
 	if (ret < 0)
 		return ret;
 
+	dp->data = dp_data;
 	dp->drm_dev = drm_dev;
 
 	ret = rockchip_dp_drm_create_encoder(dp);
@@ -365,8 +380,14 @@ static const struct dev_pm_ops rockchip_dp_pm_ops = {
 	SET_SYSTEM_SLEEP_PM_OPS(rockchip_dp_suspend, rockchip_dp_resume)
 };
 
+static const struct rockchip_dp_chip_data rk3288_dp = {
+	.lcdsel_grf_reg = 0x025c,
+	.lcdsel_big = 0 | BIT(21),
+	.lcdsel_lit = BIT(5) | BIT(21),
+};
+
 static const struct of_device_id rockchip_dp_dt_ids[] = {
-	{.compatible = "rockchip,rk3288-dp",},
+	{.compatible = "rockchip,rk3288-dp", .data = &rk3288_dp },
 	{}
 };
 MODULE_DEVICE_TABLE(of, rockchip_dp_dt_ids);
-- 
1.9.1

  parent reply	other threads:[~2016-06-14 11:46 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-14 11:45 [PATCH v3 0/10] Yakir Yang
     [not found] ` <1465904718-663-1-git-send-email-ykk-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
2016-06-14 11:46   ` [PATCH v3 01/10] drm/bridge: analogix_dp: rename RK3288_DP to ROCKCHIP_DP Yakir Yang
2016-06-23 13:20     ` Sean Paul
2016-06-14 11:46   ` [PATCH v3 03/10] drm/bridge: analogix_dp: correct the register bit define error in ANALOGIX_DP_PLL_REG_1 Yakir Yang
2016-06-23 14:33     ` Sean Paul
2016-06-29  7:11       ` Yakir Yang
2016-06-14 11:46   ` [PATCH v3 06/10] drm/rockchip: analogix_dp: make panel detect to an optional action Yakir Yang
2016-06-23 14:10     ` Sean Paul
2016-06-29  6:43       ` Yakir Yang
2016-06-14 11:46   ` [PATCH v3 08/10] drm/rockchip: analogix_dp: correct the connector display color format and bpc Yakir Yang
2016-06-23 14:19     ` Sean Paul
2016-06-29  6:41       ` Yakir Yang
2016-06-14 11:46   ` [PATCH v3 10/10] drm/bridge: analogix_dp: fix no drm hpd event when panel plug in Yakir Yang
2016-06-22  2:31     ` [PATCH v3.1 1/2] drm/rockchip: analogix_dp: introduce the pclk for grf Yakir Yang
2016-06-23  1:46       ` [PATCH v4 " Yakir Yang
2016-06-23  1:47       ` [PATCH v4 2/2] dt-bindings: analogix_dp: rockchip: correct the wrong compatible name Yakir Yang
2016-06-23  5:17         ` Doug Anderson
2016-06-29  3:32           ` Yakir Yang
2016-06-23  1:58       ` [PATCH v4.1 1/2] drm/rockchip: analogix_dp: introduce the pclk for grf Yakir Yang
2016-06-23  5:16         ` Doug Anderson
2016-06-29  3:35           ` Yakir Yang
     [not found]     ` <1465904802-1164-1-git-send-email-ykk-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
2016-06-22  2:31       ` [PATCH v3.1 2/2] dt-bindings: analogix_dp: rockchip: correct the wrong compatible name Yakir Yang
2016-06-23 14:24     ` [PATCH v3 10/10] drm/bridge: analogix_dp: fix no drm hpd event when panel plug in Sean Paul
2016-06-29  3:35       ` Yakir Yang
2016-06-14 11:46 ` Yakir Yang [this message]
2016-06-23 14:32   ` [PATCH v3 02/10] drm/rockchip: analogix_dp: split the lcdc select setting into device data Sean Paul
2016-06-23 16:16     ` Heiko Stuebner
2016-06-29  7:09       ` [PATCH v3 02/10] drm/rockchip: analogix_dp: split the lcdc select setting into device data[Involving remittance information, please pay attention to the safety of property] Yakir Yang
2016-06-14 11:46 ` [PATCH v3 04/10] drm/bridge: analogix_dp: some rockchip chips need to flip REF_CLK bit setting Yakir Yang
2016-06-23 13:27   ` Sean Paul
2016-06-29  7:13     ` Yakir Yang
2016-06-14 11:46 ` [PATCH v3 05/10] drm/rockchip: analogix_dp: add rk3399 eDP support Yakir Yang
2016-06-14 15:24   ` Doug Anderson
2016-06-15  1:56     ` Yakir Yang
2016-06-15  9:25       ` Tomasz Figa
2016-06-16  2:16         ` Yakir Yang
2016-06-23 13:48   ` Sean Paul
2016-06-29  6:58     ` Yakir Yang
2016-06-14 11:46 ` [PATCH v3 07/10] drm/bridge: analogix_dp: passing the connector as an argument in .get_modes() Yakir Yang
2016-06-14 16:26   ` Daniel Vetter
2016-06-14 16:26   ` Daniel Vetter
2016-06-14 16:28     ` Daniel Vetter
2016-06-15  1:58       ` Yakir Yang
2016-06-23 14:11   ` Sean Paul
2016-06-14 11:46 ` [PATCH v3 09/10] drm/rockchip: analogix_dp: update the comments about why need to hardcode VOP output mode Yakir Yang
2016-06-23 14:22   ` Sean Paul
2016-06-29  6:42     ` Yakir Yang
2016-06-15  9:27 ` [PATCH v3 0/10] Tomasz Figa
2016-06-16  2:15   ` Yakir Yang
2016-06-21 13:46 ` Archit Taneja
2016-06-22  2:24   ` Yakir Yang
2016-06-22  3:23     ` Archit Taneja

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=1465904768-805-1-git-send-email-ykk@rock-chips.com \
    --to=ykk@rock-chips.com \
    --cc=airlied@linux.ie \
    --cc=dan.carpenter@oracle.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dianders@chromium.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=emil.l.velikov@gmail.com \
    --cc=heiko@sntech.de \
    --cc=inki.dae@samsung.com \
    --cc=javier@osg.samsung.com \
    --cc=jingoohan1@gmail.com \
    --cc=k.kozlowski@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=marcheu@chromium.org \
    --cc=tomasz.figa@chromium.com \
    --cc=treding@nvidia.com \
    --cc=yzq@rock-chips.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).