All of lore.kernel.org
 help / color / mirror / Atom feed
From: Archit Taneja <architt@codeaurora.org>
To: robdclark@gmail.com
Cc: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org,
	robh@kernel.org, Archit Taneja <architt@codeaurora.org>
Subject: [PATCH v2 18/25] drm/msm/dsi: Don't get DSI index from DT
Date: Thu, 23 Jun 2016 19:43:23 +0530	[thread overview]
Message-ID: <1466691210-22779-19-git-send-email-architt@codeaurora.org> (raw)
In-Reply-To: <1466691210-22779-1-git-send-email-architt@codeaurora.org>

The DSI host and PHY driver currently expects the DT bindings to provide
custom properties "qcom,dsi-host-index" and "qcom,dsi-phy-index" so that
the driver can identify which DSI instance it is.

The binding isn't acceptable, but the driver still needs to figure out
what its instance id. This is now done by storing the mmio starting
addresses for each DSI instance in every SoC version in the driver. The
driver then identifies the index number by trying to match the stored
address with comparing the resource start address we get from DT.

We don't have compatible strings for DSI PHY on each SoC, but only the
DSI PHY type. We only support one SoC version for each PHY type, so we
get away doing the same thing above for the PHY driver. We can revisit
this when we support two SoCs with the same DSI PHY.

Signed-off-by: Archit Taneja <architt@codeaurora.org>
---
v2:
 - New patch

 drivers/gpu/drm/msm/dsi/dsi_cfg.c               |  8 ++++++
 drivers/gpu/drm/msm/dsi/dsi_cfg.h               |  2 ++
 drivers/gpu/drm/msm/dsi/dsi_host.c              | 33 +++++++++++++++++++------
 drivers/gpu/drm/msm/dsi/phy/dsi_phy.c           | 32 +++++++++++++++++++++---
 drivers/gpu/drm/msm/dsi/phy/dsi_phy.h           |  2 ++
 drivers/gpu/drm/msm/dsi/phy/dsi_phy_20nm.c      |  4 ++-
 drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm.c      |  4 +++
 drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm_8960.c |  2 ++
 8 files changed, 75 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/msm/dsi/dsi_cfg.c b/drivers/gpu/drm/msm/dsi/dsi_cfg.c
index 93c1ee0..63436d8 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_cfg.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_cfg.c
@@ -29,6 +29,8 @@ static const struct msm_dsi_config apq8064_dsi_cfg = {
 	},
 	.bus_clk_names = dsi_v2_bus_clk_names,
 	.num_bus_clks = ARRAY_SIZE(dsi_v2_bus_clk_names),
+	.io_start = { 0x4700000, 0x5800000 },
+	.num_dsi = 2,
 };
 
 static const char * const dsi_6g_bus_clk_names[] = {
@@ -48,6 +50,8 @@ static const struct msm_dsi_config msm8974_apq8084_dsi_cfg = {
 	},
 	.bus_clk_names = dsi_6g_bus_clk_names,
 	.num_bus_clks = ARRAY_SIZE(dsi_6g_bus_clk_names),
+	.io_start = { 0xfd922800, 0xfd922b00 },
+	.num_dsi = 2,
 };
 
 static const char * const dsi_8916_bus_clk_names[] = {
@@ -66,6 +70,8 @@ static const struct msm_dsi_config msm8916_dsi_cfg = {
 	},
 	.bus_clk_names = dsi_8916_bus_clk_names,
 	.num_bus_clks = ARRAY_SIZE(dsi_8916_bus_clk_names),
+	.io_start = { 0x1a98000 },
+	.num_dsi = 1,
 };
 
 static const struct msm_dsi_config msm8994_dsi_cfg = {
@@ -84,6 +90,8 @@ static const struct msm_dsi_config msm8994_dsi_cfg = {
 	},
 	.bus_clk_names = dsi_6g_bus_clk_names,
 	.num_bus_clks = ARRAY_SIZE(dsi_6g_bus_clk_names),
+	.io_start = { 0xfd998000, 0xfd9a0000 },
+	.num_dsi = 2,
 };
 
 static const struct msm_dsi_cfg_handler dsi_cfg_handlers[] = {
diff --git a/drivers/gpu/drm/msm/dsi/dsi_cfg.h b/drivers/gpu/drm/msm/dsi/dsi_cfg.h
index a68c836..eeacc323 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_cfg.h
+++ b/drivers/gpu/drm/msm/dsi/dsi_cfg.h
@@ -34,6 +34,8 @@ struct msm_dsi_config {
 	struct dsi_reg_config reg_cfg;
 	const char * const *bus_clk_names;
 	const int num_bus_clks;
+	const resource_size_t io_start[DSI_MAX];
+	const int num_dsi;
 };
 
 struct msm_dsi_cfg_handler {
diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
index e6a8cd1..80d8594 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -1605,13 +1605,6 @@ static int dsi_host_parse_dt(struct msm_dsi_host *msm_host)
 	struct device_node *endpoint, *device_node;
 	int ret;
 
-	ret = of_property_read_u32(np, "qcom,dsi-host-index", &msm_host->id);
-	if (ret) {
-		dev_err(dev, "%s: host index not specified, ret=%d\n",
-			__func__, ret);
-		return ret;
-	}
-
 	/*
 	 * Get the endpoint of the output port of the DSI host. In our case,
 	 * this is mapped to port number with reg = 1. Don't return an error if
@@ -1659,6 +1652,25 @@ err:
 	return ret;
 }
 
+static int dsi_host_get_id(struct msm_dsi_host *msm_host)
+{
+	struct platform_device *pdev = msm_host->pdev;
+	const struct msm_dsi_config *cfg = msm_host->cfg_hnd->cfg;
+	struct resource *res;
+	int i;
+
+	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dsi_ctrl");
+	if (!res)
+		return -EINVAL;
+
+	for (i = 0; i < cfg->num_dsi; i++) {
+		if (cfg->io_start[i] == res->start)
+			return i;
+	}
+
+	return -EINVAL;
+}
+
 int msm_dsi_host_init(struct msm_dsi *msm_dsi)
 {
 	struct msm_dsi_host *msm_host = NULL;
@@ -1695,6 +1707,13 @@ int msm_dsi_host_init(struct msm_dsi *msm_dsi)
 		goto fail;
 	}
 
+	msm_host->id = dsi_host_get_id(msm_host);
+	if (msm_host->id < 0) {
+		ret = msm_host->id;
+		pr_err("%s: unable to identify DSI host index\n", __func__);
+		goto fail;
+	}
+
 	/* fixup base address by io offset */
 	msm_host->ctrl_base += msm_host->cfg_hnd->cfg->io_offset;
 
diff --git a/drivers/gpu/drm/msm/dsi/phy/dsi_phy.c b/drivers/gpu/drm/msm/dsi/phy/dsi_phy.c
index e2f42d8..f39386e 100644
--- a/drivers/gpu/drm/msm/dsi/phy/dsi_phy.c
+++ b/drivers/gpu/drm/msm/dsi/phy/dsi_phy.c
@@ -271,6 +271,30 @@ static const struct of_device_id dsi_phy_dt_match[] = {
 	{}
 };
 
+/*
+ * Currently, we only support one SoC for each PHY type. When we have multiple
+ * SoCs for the same PHY, we can try to make the index searching a bit more
+ * clever.
+ */
+static int dsi_phy_get_id(struct msm_dsi_phy *phy)
+{
+	struct platform_device *pdev = phy->pdev;
+	const struct msm_dsi_phy_cfg *cfg = phy->cfg;
+	struct resource *res;
+	int i;
+
+	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dsi_phy");
+	if (!res)
+		return -EINVAL;
+
+	for (i = 0; i < cfg->num_dsi_phy; i++) {
+		if (cfg->io_start[i] == res->start)
+			return i;
+	}
+
+	return -EINVAL;
+}
+
 static int dsi_phy_driver_probe(struct platform_device *pdev)
 {
 	struct msm_dsi_phy *phy;
@@ -289,10 +313,10 @@ static int dsi_phy_driver_probe(struct platform_device *pdev)
 	phy->cfg = match->data;
 	phy->pdev = pdev;
 
-	ret = of_property_read_u32(dev->of_node,
-				"qcom,dsi-phy-index", &phy->id);
-	if (ret) {
-		dev_err(dev, "%s: PHY index not specified, %d\n",
+	phy->id = dsi_phy_get_id(phy);
+	if (phy->id < 0) {
+		ret = phy->id;
+		dev_err(dev, "%s: couldn't identify PHY index, %d\n",
 			__func__, ret);
 		goto fail;
 	}
diff --git a/drivers/gpu/drm/msm/dsi/phy/dsi_phy.h b/drivers/gpu/drm/msm/dsi/phy/dsi_phy.h
index 0d54ed0..f24a854 100644
--- a/drivers/gpu/drm/msm/dsi/phy/dsi_phy.h
+++ b/drivers/gpu/drm/msm/dsi/phy/dsi_phy.h
@@ -38,6 +38,8 @@ struct msm_dsi_phy_cfg {
 	 * Fill default H/W values in illegal cells, eg. cell {0, 1}.
 	 */
 	bool src_pll_truthtable[DSI_MAX][DSI_MAX];
+	const resource_size_t io_start[DSI_MAX];
+	const int num_dsi_phy;
 };
 
 extern const struct msm_dsi_phy_cfg dsi_phy_28nm_hpm_cfgs;
diff --git a/drivers/gpu/drm/msm/dsi/phy/dsi_phy_20nm.c b/drivers/gpu/drm/msm/dsi/phy/dsi_phy_20nm.c
index f4bc11a..c757e20 100644
--- a/drivers/gpu/drm/msm/dsi/phy/dsi_phy_20nm.c
+++ b/drivers/gpu/drm/msm/dsi/phy/dsi_phy_20nm.c
@@ -145,6 +145,8 @@ const struct msm_dsi_phy_cfg dsi_phy_20nm_cfgs = {
 	.ops = {
 		.enable = dsi_20nm_phy_enable,
 		.disable = dsi_20nm_phy_disable,
-	}
+	},
+	.io_start = { 0xfd998300, 0xfd9a0300 },
+	.num_dsi_phy = 2,
 };
 
diff --git a/drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm.c b/drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm.c
index 96d1852..63d7fba 100644
--- a/drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm.c
+++ b/drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm.c
@@ -145,6 +145,8 @@ const struct msm_dsi_phy_cfg dsi_phy_28nm_hpm_cfgs = {
 		.enable = dsi_28nm_phy_enable,
 		.disable = dsi_28nm_phy_disable,
 	},
+	.io_start = { 0xfd922b00, 0xfd923100 },
+	.num_dsi_phy = 2,
 };
 
 const struct msm_dsi_phy_cfg dsi_phy_28nm_lp_cfgs = {
@@ -160,5 +162,7 @@ const struct msm_dsi_phy_cfg dsi_phy_28nm_lp_cfgs = {
 		.enable = dsi_28nm_phy_enable,
 		.disable = dsi_28nm_phy_disable,
 	},
+	.io_start = { 0x1a98500 },
+	.num_dsi_phy = 1,
 };
 
diff --git a/drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm_8960.c b/drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm_8960.c
index 213355a..7bdb9de 100644
--- a/drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm_8960.c
+++ b/drivers/gpu/drm/msm/dsi/phy/dsi_phy_28nm_8960.c
@@ -192,4 +192,6 @@ const struct msm_dsi_phy_cfg dsi_phy_28nm_8960_cfgs = {
 		.enable = dsi_28nm_phy_enable,
 		.disable = dsi_28nm_phy_disable,
 	},
+	.io_start = { 0x4700300, 0x5800300 },
+	.num_dsi_phy = 2,
 };
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

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

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-16 11:36 [PATCH 00/22] drm/msm: Enable DT support Archit Taneja
2016-06-16 11:36 ` [PATCH 01/22] drm/msm: Drop the id_table in platform_driver Archit Taneja
2016-06-16 11:36 ` [PATCH 02/22] drm/msm: Remove unused fields Archit Taneja
2016-06-16 11:36 ` [PATCH 03/22] drm/msm: Get irq number within kms driver itself Archit Taneja
2016-06-16 11:36 ` [PATCH 04/22] drm/msm/mdp5: Add MDSS top level driver Archit Taneja
2016-06-16 11:36 ` [PATCH 05/22] drm/msm/mdp5: Create a separate MDP5 device Archit Taneja
2016-06-16 11:36 ` [PATCH 06/22] drm/msm/mdp5: Prepare new kms_init funcs Archit Taneja
2016-06-16 11:36 ` [PATCH 07/22] drm/msm/mdp5: Use the new hierarchy and drop old irq management Archit Taneja
2016-06-16 11:36 ` [PATCH 08/22] drm/msm/mdp5: Remove old kms init/destroy funcs Archit Taneja
2016-06-16 11:36 ` [PATCH 09/22] drm/msm/mdp5: Use updated MDP5 register names Archit Taneja
2016-06-16 11:36 ` [PATCH 10/22] drm/msm/mdp5: Update the register offsets of MDP5 sub-blocks Archit Taneja
2016-06-16 11:36 ` [PATCH 11/22] drm/msm: Call pm_runtime_enable/disable for newly created devices Archit Taneja
2016-06-16 11:36 ` [PATCH 12/22] drm/msm/mdp5: Add missing mdp5_enable/disable calls Archit Taneja
2016-06-16 11:36 ` [PATCH 13/22] drm/msm: Create separate funcs for adding display/gpu components Archit Taneja
2016-06-16 11:36 ` [PATCH 14/22] drm/msm: Add display components by parsing MDP ports Archit Taneja
2016-06-16 11:36 ` [PATCH 15/22] drm/msm: Add components for MDP5 Archit Taneja
2016-06-16 11:36 ` [PATCH 16/22] drm/msm: Drop the gpu binding Archit Taneja
2016-06-16 11:36 ` [PATCH 17/22] drm/msm/mdp5: Update compatible strings for MDSS/MDP5 Archit Taneja
2016-06-16 11:36 ` [PATCH 18/22] dt-bindings: msm/mdp4: Create a separate binding doc for MDP4 Archit Taneja
2016-06-20 12:53   ` Rob Herring
2016-06-16 11:36 ` [PATCH 19/22] dt-bindings: msm/mdp5: Add MDP5 display bindings Archit Taneja
2016-06-20 12:57   ` Rob Herring
2016-06-16 11:36 ` [PATCH 20/22] dt-bindings: msm/mdp: Provide details on MDP interface ports Archit Taneja
2016-06-20 13:01   ` Rob Herring
2016-06-16 11:36 ` [PATCH 21/22] arm64: dts: msm8916: Add display support Archit Taneja
2016-06-20 13:04   ` Rob Herring
2016-06-20 13:47     ` Archit Taneja
2016-06-16 11:36 ` [PATCH 22/22] arm64: dts: apq8016-sbc: Add HDMI " Archit Taneja
2016-06-23 14:13 ` [PATCH v2 00/25] drm/msm: Enable DT support Archit Taneja
2016-06-23 14:13   ` [PATCH v2 01/25] drm/msm: Drop the id_table in platform_driver Archit Taneja
2016-06-23 14:13   ` [PATCH v2 02/25] drm/msm: Remove unused fields Archit Taneja
2016-06-23 14:13   ` [PATCH v2 03/25] drm/msm: Get irq number within kms driver itself Archit Taneja
2016-06-23 14:13   ` [PATCH v2 04/25] drm/msm/mdp5: Add MDSS top level driver Archit Taneja
2016-06-23 14:13   ` [PATCH v2 05/25] drm/msm/mdp5: Create a separate MDP5 device Archit Taneja
2016-06-23 14:13   ` [PATCH v2 06/25] drm/msm/mdp5: Prepare new kms_init funcs Archit Taneja
2016-06-23 14:13   ` [PATCH v2 07/25] drm/msm/mdp5: Use the new hierarchy and drop old irq management Archit Taneja
2016-06-23 14:13   ` [PATCH v2 08/25] drm/msm/mdp5: Remove old kms init/destroy funcs Archit Taneja
2016-06-23 14:13   ` [PATCH v2 09/25] drm/msm/mdp5: Use updated MDP5 register names Archit Taneja
2016-06-23 14:13   ` [PATCH v2 10/25] drm/msm/mdp5: Update the register offsets of MDP5 sub-blocks Archit Taneja
2016-06-23 14:13   ` [PATCH v2 11/25] drm/msm: Call pm_runtime_enable/disable for newly created devices Archit Taneja
2016-06-23 14:13   ` [PATCH v2 12/25] drm/msm/mdp5: Add missing mdp5_enable/disable calls Archit Taneja
2016-06-23 14:13   ` [PATCH v2 13/25] drm/msm: Create separate funcs for adding display/gpu components Archit Taneja
2016-06-23 14:13   ` [PATCH v2 14/25] drm/msm: Add display components by parsing MDP ports Archit Taneja
2016-06-23 14:13   ` [PATCH v2 15/25] drm/msm: Add components for MDP5 Archit Taneja
2016-06-23 14:13   ` [PATCH v2 16/25] drm/msm: Drop the gpu binding Archit Taneja
2016-06-23 14:13   ` [PATCH v2 17/25] drm/msm/mdp5: Update compatible strings for MDSS/MDP5 Archit Taneja
2016-07-11  8:39     ` Matthias Brugger
2016-07-11 11:33       ` Rob Clark
2016-06-23 14:13   ` Archit Taneja [this message]
2016-06-23 14:45     ` [PATCH v2 18/25] drm/msm/dsi: Don't get DSI index from DT Rob Herring
2016-06-24  5:00       ` Archit Taneja
2016-06-23 14:13   ` [PATCH v2 19/25] dt-bindings: msm/mdp4: Create a separate binding doc for MDP4 Archit Taneja
2016-06-23 14:13   ` [PATCH v2 20/25] dt-bindings: msm/mdp5: Add MDP5 display bindings Archit Taneja
2016-06-23 14:13   ` [PATCH v2 21/25] dt-bindings: msm/mdp: Provide details on MDP interface ports Archit Taneja
2016-06-23 14:13   ` [PATCH v2 22/25] dt-bindings: msm/dsi: Remove unused properties Archit Taneja
2016-08-26  4:55     ` Archit Taneja
2016-06-23 14:13   ` [PATCH v2 23/25] dt-bindings: display/msm: Remove power domain property from encoder nodes Archit Taneja
2016-08-26  4:55     ` Archit Taneja
2016-06-23 14:13   ` [PATCH v2 24/25] arm64: dts: msm8916: Add display support Archit Taneja
2016-08-26  4:57     ` Archit Taneja
2016-08-26 12:12       ` Rob Herring
     [not found]     ` <1466691210-22779-25-git-send-email-architt-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2016-08-26  5:33       ` Andy Gross
     [not found]   ` <1466691210-22779-1-git-send-email-architt-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2016-06-23 14:13     ` [PATCH v2 25/25] arm64: dts: apq8016-sbc: Add HDMI " Archit Taneja
2016-08-26  4:58       ` Archit Taneja
2016-08-26  5:34       ` Andy Gross

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=1466691210-22779-19-git-send-email-architt@codeaurora.org \
    --to=architt@codeaurora.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=robdclark@gmail.com \
    --cc=robh@kernel.org \
    /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.