linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 01/10] dt-bindings: display/msm: dsi-controller-main: Fix deprecated QCM2290 compatible
       [not found] <20230211115110.1462920-1-konrad.dybcio@linaro.org>
@ 2023-02-11 11:51 ` Konrad Dybcio
  2023-02-11 11:51 ` [PATCH 02/10] drm/msm/dsi: Turn msm_dsi_config::io_start into a 2d array Konrad Dybcio
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 22+ messages in thread
From: Konrad Dybcio @ 2023-02-11 11:51 UTC (permalink / raw)
  To: linux-arm-msm, andersson, agross, krzysztof.kozlowski
  Cc: marijn.suijten, Konrad Dybcio, Rob Clark, Abhinav Kumar,
	Dmitry Baryshkov, Sean Paul, David Airlie, Daniel Vetter,
	Rob Herring, Krzysztof Kozlowski, Krishna Manikandan,
	Bryan O'Donoghue, dri-devel, freedreno, devicetree,
	linux-kernel

The qcom, prefix was missed previously. Fix it.

Fixes: 0c0f65c6dd44 ("dt-bindings: msm: dsi-controller-main: Add compatible strings for every current SoC")
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
---
 .../devicetree/bindings/display/msm/dsi-controller-main.yaml    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/display/msm/dsi-controller-main.yaml b/Documentation/devicetree/bindings/display/msm/dsi-controller-main.yaml
index e75a3efe4dac..2494817c1bd6 100644
--- a/Documentation/devicetree/bindings/display/msm/dsi-controller-main.yaml
+++ b/Documentation/devicetree/bindings/display/msm/dsi-controller-main.yaml
@@ -33,7 +33,7 @@ properties:
           - const: qcom,mdss-dsi-ctrl
       - items:
           - enum:
-              - dsi-ctrl-6g-qcm2290
+              - qcom,dsi-ctrl-6g-qcm2290
           - const: qcom,mdss-dsi-ctrl
         deprecated: true
 
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 02/10] drm/msm/dsi: Turn msm_dsi_config::io_start into a 2d array
       [not found] <20230211115110.1462920-1-konrad.dybcio@linaro.org>
  2023-02-11 11:51 ` [PATCH 01/10] dt-bindings: display/msm: dsi-controller-main: Fix deprecated QCM2290 compatible Konrad Dybcio
@ 2023-02-11 11:51 ` Konrad Dybcio
  2023-02-11 13:17   ` Dmitry Baryshkov
  2023-02-11 11:51 ` [PATCH 03/10] drm/msm/dsi: Zero-terminate msm_dsi_config::io_start Konrad Dybcio
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 22+ messages in thread
From: Konrad Dybcio @ 2023-02-11 11:51 UTC (permalink / raw)
  To: linux-arm-msm, andersson, agross, krzysztof.kozlowski
  Cc: marijn.suijten, Konrad Dybcio, Rob Clark, Abhinav Kumar,
	Dmitry Baryshkov, Sean Paul, David Airlie, Daniel Vetter,
	Douglas Anderson, Neil Armstrong, Loic Poulain, Vinod Koul,
	Vladimir Lypak, dri-devel, freedreno, linux-kernel

Currently, we allow for MAX_DSI entries in io_start to facilitate for
MAX_DSI number of DSI hosts at different addresses. The configuration
is matched against the DSI CTRL hardware revision read back from the
component. We need a way to resolve situations where multiple SoCs
with different register maps may use the same version of DSI CTRL. In
preparation to do so, make msm_dsi_config a 2d array where each entry
represents a set of configurations adequate for a given SoC.

This is totally fine to do, as the only differentiating factors
between same-version-different-SoCs configurations are the number of
DSI hosts (1 or 2, at least as of today) and the set of registers.
The regulator setup is the same, because the DSI hardware is the same,
regardless of the SoC it was implemented in.

Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
---
 drivers/gpu/drm/msm/dsi/dsi_cfg.c  | 52 ++++++++++++++++++++++--------
 drivers/gpu/drm/msm/dsi/dsi_cfg.h  |  5 ++-
 drivers/gpu/drm/msm/dsi/dsi_host.c |  2 +-
 3 files changed, 44 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/msm/dsi/dsi_cfg.c b/drivers/gpu/drm/msm/dsi/dsi_cfg.c
index 6d21f0b33411..068d45b3a8f0 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_cfg.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_cfg.c
@@ -21,7 +21,9 @@ static const struct msm_dsi_config apq8064_dsi_cfg = {
 	.num_regulators = ARRAY_SIZE(apq8064_dsi_regulators),
 	.bus_clk_names = dsi_v2_bus_clk_names,
 	.num_bus_clks = ARRAY_SIZE(dsi_v2_bus_clk_names),
-	.io_start = { 0x4700000, 0x5800000 },
+	.io_start = {
+		{ 0x4700000, 0x5800000 },
+	},
 	.num_dsi = 2,
 };
 
@@ -41,7 +43,9 @@ static const struct msm_dsi_config msm8974_apq8084_dsi_cfg = {
 	.num_regulators = ARRAY_SIZE(msm8974_apq8084_regulators),
 	.bus_clk_names = dsi_6g_bus_clk_names,
 	.num_bus_clks = ARRAY_SIZE(dsi_6g_bus_clk_names),
-	.io_start = { 0xfd922800, 0xfd922b00 },
+	.io_start = {
+		{ 0xfd922800, 0xfd922b00 },
+	},
 	.num_dsi = 2,
 };
 
@@ -60,7 +64,9 @@ static const struct msm_dsi_config msm8916_dsi_cfg = {
 	.num_regulators = ARRAY_SIZE(msm8916_dsi_regulators),
 	.bus_clk_names = dsi_8916_bus_clk_names,
 	.num_bus_clks = ARRAY_SIZE(dsi_8916_bus_clk_names),
-	.io_start = { 0x1a98000 },
+	.io_start = {
+		{ 0x1a98000 },
+	},
 	.num_dsi = 1,
 };
 
@@ -79,7 +85,9 @@ static const struct msm_dsi_config msm8976_dsi_cfg = {
 	.num_regulators = ARRAY_SIZE(msm8976_dsi_regulators),
 	.bus_clk_names = dsi_8976_bus_clk_names,
 	.num_bus_clks = ARRAY_SIZE(dsi_8976_bus_clk_names),
-	.io_start = { 0x1a94000, 0x1a96000 },
+	.io_start = {
+		{ 0x1a94000, 0x1a96000 },
+	},
 	.num_dsi = 2,
 };
 
@@ -98,7 +106,9 @@ static const struct msm_dsi_config msm8994_dsi_cfg = {
 	.num_regulators = ARRAY_SIZE(msm8994_dsi_regulators),
 	.bus_clk_names = dsi_6g_bus_clk_names,
 	.num_bus_clks = ARRAY_SIZE(dsi_6g_bus_clk_names),
-	.io_start = { 0xfd998000, 0xfd9a0000 },
+	.io_start = {
+		{ 0xfd998000, 0xfd9a0000 },
+	},
 	.num_dsi = 2,
 };
 
@@ -118,7 +128,9 @@ static const struct msm_dsi_config msm8996_dsi_cfg = {
 	.num_regulators = ARRAY_SIZE(msm8996_dsi_regulators),
 	.bus_clk_names = dsi_8996_bus_clk_names,
 	.num_bus_clks = ARRAY_SIZE(dsi_8996_bus_clk_names),
-	.io_start = { 0x994000, 0x996000 },
+	.io_start = {
+		{ 0x994000, 0x996000 },
+	},
 	.num_dsi = 2,
 };
 
@@ -137,7 +149,9 @@ static const struct msm_dsi_config msm8998_dsi_cfg = {
 	.num_regulators = ARRAY_SIZE(msm8998_dsi_regulators),
 	.bus_clk_names = dsi_msm8998_bus_clk_names,
 	.num_bus_clks = ARRAY_SIZE(dsi_msm8998_bus_clk_names),
-	.io_start = { 0xc994000, 0xc996000 },
+	.io_start = {
+		{ 0xc994000, 0xc996000 },
+	},
 	.num_dsi = 2,
 };
 
@@ -155,7 +169,9 @@ static const struct msm_dsi_config sdm660_dsi_cfg = {
 	.num_regulators = ARRAY_SIZE(sdm660_dsi_regulators),
 	.bus_clk_names = dsi_sdm660_bus_clk_names,
 	.num_bus_clks = ARRAY_SIZE(dsi_sdm660_bus_clk_names),
-	.io_start = { 0xc994000, 0xc996000 },
+	.io_start = {
+		{ 0xc994000, 0xc996000 },
+	},
 	.num_dsi = 2,
 };
 
@@ -177,7 +193,9 @@ static const struct msm_dsi_config sdm845_dsi_cfg = {
 	.num_regulators = ARRAY_SIZE(sdm845_dsi_regulators),
 	.bus_clk_names = dsi_sdm845_bus_clk_names,
 	.num_bus_clks = ARRAY_SIZE(dsi_sdm845_bus_clk_names),
-	.io_start = { 0xae94000, 0xae96000 },
+	.io_start = {
+		{ 0xae94000, 0xae96000 },
+	},
 	.num_dsi = 2,
 };
 
@@ -191,7 +209,9 @@ static const struct msm_dsi_config sm8550_dsi_cfg = {
 	.num_regulators = ARRAY_SIZE(sm8550_dsi_regulators),
 	.bus_clk_names = dsi_sdm845_bus_clk_names,
 	.num_bus_clks = ARRAY_SIZE(dsi_sdm845_bus_clk_names),
-	.io_start = { 0xae94000, 0xae96000 },
+	.io_start = {
+		{ 0xae94000, 0xae96000 },
+	},
 	.num_dsi = 2,
 };
 
@@ -205,7 +225,9 @@ static const struct msm_dsi_config sc7180_dsi_cfg = {
 	.num_regulators = ARRAY_SIZE(sc7180_dsi_regulators),
 	.bus_clk_names = dsi_sc7180_bus_clk_names,
 	.num_bus_clks = ARRAY_SIZE(dsi_sc7180_bus_clk_names),
-	.io_start = { 0xae94000 },
+	.io_start = {
+		{ 0xae94000 },
+	},
 	.num_dsi = 1,
 };
 
@@ -223,7 +245,9 @@ static const struct msm_dsi_config sc7280_dsi_cfg = {
 	.num_regulators = ARRAY_SIZE(sc7280_dsi_regulators),
 	.bus_clk_names = dsi_sc7280_bus_clk_names,
 	.num_bus_clks = ARRAY_SIZE(dsi_sc7280_bus_clk_names),
-	.io_start = { 0xae94000, 0xae96000 },
+	.io_start = {
+		{ 0xae94000, 0xae96000 },
+	},
 	.num_dsi = 2,
 };
 
@@ -241,7 +265,9 @@ static const struct msm_dsi_config qcm2290_dsi_cfg = {
 	.num_regulators = ARRAY_SIZE(qcm2290_dsi_cfg_regulators),
 	.bus_clk_names = dsi_qcm2290_bus_clk_names,
 	.num_bus_clks = ARRAY_SIZE(dsi_qcm2290_bus_clk_names),
-	.io_start = { 0x5e94000 },
+	.io_start = {
+		{ 0x5e94000 },
+	},
 	.num_dsi = 1,
 };
 
diff --git a/drivers/gpu/drm/msm/dsi/dsi_cfg.h b/drivers/gpu/drm/msm/dsi/dsi_cfg.h
index 44be4a88aa83..df9f09876ccb 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_cfg.h
+++ b/drivers/gpu/drm/msm/dsi/dsi_cfg.h
@@ -32,13 +32,16 @@
 
 #define DSI_6G_REG_SHIFT	4
 
+/* Maximum number of configurations matched against the same hw revision */
+#define VARIANTS_MAX			2
+
 struct msm_dsi_config {
 	u32 io_offset;
 	const struct regulator_bulk_data *regulator_data;
 	int num_regulators;
 	const char * const *bus_clk_names;
 	const int num_bus_clks;
-	const resource_size_t io_start[DSI_MAX];
+	const resource_size_t io_start[VARIANTS_MAX][DSI_MAX];
 	const int num_dsi;
 };
 
diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
index 18fa30e1e858..22ba8726b0ea 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -1869,7 +1869,7 @@ static int dsi_host_get_id(struct msm_dsi_host *msm_host)
 		return -EINVAL;
 
 	for (i = 0; i < cfg->num_dsi; i++) {
-		if (cfg->io_start[i] == res->start)
+		if (cfg->io_start[0][i] == res->start)
 			return i;
 	}
 
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 03/10] drm/msm/dsi: Zero-terminate msm_dsi_config::io_start
       [not found] <20230211115110.1462920-1-konrad.dybcio@linaro.org>
  2023-02-11 11:51 ` [PATCH 01/10] dt-bindings: display/msm: dsi-controller-main: Fix deprecated QCM2290 compatible Konrad Dybcio
  2023-02-11 11:51 ` [PATCH 02/10] drm/msm/dsi: Turn msm_dsi_config::io_start into a 2d array Konrad Dybcio
@ 2023-02-11 11:51 ` Konrad Dybcio
  2023-02-11 13:19   ` Dmitry Baryshkov
  2023-02-11 11:51 ` [PATCH 04/10] drm/msm/dsi: dsi_host: Fix DSI index detection when version clash occurs Konrad Dybcio
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 22+ messages in thread
From: Konrad Dybcio @ 2023-02-11 11:51 UTC (permalink / raw)
  To: linux-arm-msm, andersson, agross, krzysztof.kozlowski
  Cc: marijn.suijten, Konrad Dybcio, Rob Clark, Abhinav Kumar,
	Dmitry Baryshkov, Sean Paul, David Airlie, Daniel Vetter,
	Douglas Anderson, Loic Poulain, Neil Armstrong, Vinod Koul,
	Vladimir Lypak, dri-devel, freedreno, linux-kernel

In preparation for supporting multiple sets of possible base registers,
Zero-terminate the array that contains them to remove the need of
specifying num_dsi for each set.

Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
---
 drivers/gpu/drm/msm/dsi/dsi_cfg.c  | 39 ++++++++++--------------------
 drivers/gpu/drm/msm/dsi/dsi_cfg.h  |  4 +--
 drivers/gpu/drm/msm/dsi/dsi_host.c |  2 +-
 3 files changed, 16 insertions(+), 29 deletions(-)

diff --git a/drivers/gpu/drm/msm/dsi/dsi_cfg.c b/drivers/gpu/drm/msm/dsi/dsi_cfg.c
index 068d45b3a8f0..5f62c563bd1c 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_cfg.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_cfg.c
@@ -22,9 +22,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 },
+		{ 0x4700000, 0x5800000, 0 },
 	},
-	.num_dsi = 2,
 };
 
 static const char * const dsi_6g_bus_clk_names[] = {
@@ -44,9 +43,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 },
+		{ 0xfd922800, 0xfd922b00, 0 },
 	},
-	.num_dsi = 2,
 };
 
 static const char * const dsi_8916_bus_clk_names[] = {
@@ -65,9 +63,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 },
+		{ 0x1a98000, 0 },
 	},
-	.num_dsi = 1,
 };
 
 static const char * const dsi_8976_bus_clk_names[] = {
@@ -86,9 +83,8 @@ static const struct msm_dsi_config msm8976_dsi_cfg = {
 	.bus_clk_names = dsi_8976_bus_clk_names,
 	.num_bus_clks = ARRAY_SIZE(dsi_8976_bus_clk_names),
 	.io_start = {
-		{ 0x1a94000, 0x1a96000 },
+		{ 0x1a94000, 0x1a96000, 0 },
 	},
-	.num_dsi = 2,
 };
 
 static const struct regulator_bulk_data msm8994_dsi_regulators[] = {
@@ -107,9 +103,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 },
+		{ 0xfd998000, 0xfd9a0000, 0 },
 	},
-	.num_dsi = 2,
 };
 
 static const char * const dsi_8996_bus_clk_names[] = {
@@ -129,9 +124,8 @@ static const struct msm_dsi_config msm8996_dsi_cfg = {
 	.bus_clk_names = dsi_8996_bus_clk_names,
 	.num_bus_clks = ARRAY_SIZE(dsi_8996_bus_clk_names),
 	.io_start = {
-		{ 0x994000, 0x996000 },
+		{ 0x994000, 0x996000, 0 },
 	},
-	.num_dsi = 2,
 };
 
 static const char * const dsi_msm8998_bus_clk_names[] = {
@@ -150,9 +144,8 @@ static const struct msm_dsi_config msm8998_dsi_cfg = {
 	.bus_clk_names = dsi_msm8998_bus_clk_names,
 	.num_bus_clks = ARRAY_SIZE(dsi_msm8998_bus_clk_names),
 	.io_start = {
-		{ 0xc994000, 0xc996000 },
+		{ 0xc994000, 0xc996000, 0 },
 	},
-	.num_dsi = 2,
 };
 
 static const char * const dsi_sdm660_bus_clk_names[] = {
@@ -170,9 +163,8 @@ static const struct msm_dsi_config sdm660_dsi_cfg = {
 	.bus_clk_names = dsi_sdm660_bus_clk_names,
 	.num_bus_clks = ARRAY_SIZE(dsi_sdm660_bus_clk_names),
 	.io_start = {
-		{ 0xc994000, 0xc996000 },
+		{ 0xc994000, 0xc996000, 0 },
 	},
-	.num_dsi = 2,
 };
 
 static const char * const dsi_sdm845_bus_clk_names[] = {
@@ -194,9 +186,8 @@ static const struct msm_dsi_config sdm845_dsi_cfg = {
 	.bus_clk_names = dsi_sdm845_bus_clk_names,
 	.num_bus_clks = ARRAY_SIZE(dsi_sdm845_bus_clk_names),
 	.io_start = {
-		{ 0xae94000, 0xae96000 },
+		{ 0xae94000, 0xae96000, 0 },
 	},
-	.num_dsi = 2,
 };
 
 static const struct regulator_bulk_data sm8550_dsi_regulators[] = {
@@ -210,9 +201,8 @@ static const struct msm_dsi_config sm8550_dsi_cfg = {
 	.bus_clk_names = dsi_sdm845_bus_clk_names,
 	.num_bus_clks = ARRAY_SIZE(dsi_sdm845_bus_clk_names),
 	.io_start = {
-		{ 0xae94000, 0xae96000 },
+		{ 0xae94000, 0xae96000, 0 },
 	},
-	.num_dsi = 2,
 };
 
 static const struct regulator_bulk_data sc7180_dsi_regulators[] = {
@@ -226,9 +216,8 @@ static const struct msm_dsi_config sc7180_dsi_cfg = {
 	.bus_clk_names = dsi_sc7180_bus_clk_names,
 	.num_bus_clks = ARRAY_SIZE(dsi_sc7180_bus_clk_names),
 	.io_start = {
-		{ 0xae94000 },
+		{ 0xae94000, 0 },
 	},
-	.num_dsi = 1,
 };
 
 static const char * const dsi_sc7280_bus_clk_names[] = {
@@ -246,9 +235,8 @@ static const struct msm_dsi_config sc7280_dsi_cfg = {
 	.bus_clk_names = dsi_sc7280_bus_clk_names,
 	.num_bus_clks = ARRAY_SIZE(dsi_sc7280_bus_clk_names),
 	.io_start = {
-		{ 0xae94000, 0xae96000 },
+		{ 0xae94000, 0xae96000, 0 },
 	},
-	.num_dsi = 2,
 };
 
 static const char * const dsi_qcm2290_bus_clk_names[] = {
@@ -266,9 +254,8 @@ static const struct msm_dsi_config qcm2290_dsi_cfg = {
 	.bus_clk_names = dsi_qcm2290_bus_clk_names,
 	.num_bus_clks = ARRAY_SIZE(dsi_qcm2290_bus_clk_names),
 	.io_start = {
-		{ 0x5e94000 },
+		{ 0x5e94000, 0 },
 	},
-	.num_dsi = 1,
 };
 
 static const struct msm_dsi_host_cfg_ops msm_dsi_v2_host_ops = {
diff --git a/drivers/gpu/drm/msm/dsi/dsi_cfg.h b/drivers/gpu/drm/msm/dsi/dsi_cfg.h
index df9f09876ccb..03493cc6b772 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_cfg.h
+++ b/drivers/gpu/drm/msm/dsi/dsi_cfg.h
@@ -41,8 +41,8 @@ struct msm_dsi_config {
 	int num_regulators;
 	const char * const *bus_clk_names;
 	const int num_bus_clks;
-	const resource_size_t io_start[VARIANTS_MAX][DSI_MAX];
-	const int num_dsi;
+	/* Allow + 1 entry for the zero-terminator */
+	const resource_size_t io_start[VARIANTS_MAX][DSI_MAX + 1];
 };
 
 struct msm_dsi_host_cfg_ops {
diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
index 22ba8726b0ea..f5092b4d0757 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -1868,7 +1868,7 @@ static int dsi_host_get_id(struct msm_dsi_host *msm_host)
 	if (!res)
 		return -EINVAL;
 
-	for (i = 0; i < cfg->num_dsi; i++) {
+	for (i = 0; cfg->io_start[0][i]; i++) {
 		if (cfg->io_start[0][i] == res->start)
 			return i;
 	}
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 04/10] drm/msm/dsi: dsi_host: Fix DSI index detection when version clash occurs
       [not found] <20230211115110.1462920-1-konrad.dybcio@linaro.org>
                   ` (2 preceding siblings ...)
  2023-02-11 11:51 ` [PATCH 03/10] drm/msm/dsi: Zero-terminate msm_dsi_config::io_start Konrad Dybcio
@ 2023-02-11 11:51 ` Konrad Dybcio
  2023-02-11 13:26   ` Dmitry Baryshkov
  2023-02-11 11:51 ` [PATCH 05/10] drm/msm/dsi: dsi_cfg: Deduplicate identical structs Konrad Dybcio
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 22+ messages in thread
From: Konrad Dybcio @ 2023-02-11 11:51 UTC (permalink / raw)
  To: linux-arm-msm, andersson, agross, krzysztof.kozlowski
  Cc: marijn.suijten, Konrad Dybcio, Rob Clark, Abhinav Kumar,
	Dmitry Baryshkov, Sean Paul, David Airlie, Daniel Vetter,
	Neil Armstrong, Vinod Koul, Douglas Anderson, Loic Poulain,
	Vladimir Lypak, Archit Taneja, dri-devel, freedreno,
	linux-kernel

Now that msm_dsi_config is ready to accept multiple sets of registers
(where array[n][idx] holds the base registers of DSI(idx) for the nth
entry), loop through all available configs to resolve hw version
clashes.

Fixes: 32280d66fd44 ("drm/msm/dsi: Don't get DSI index from DT")
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
---
 drivers/gpu/drm/msm/dsi/dsi_cfg.h  |  1 +
 drivers/gpu/drm/msm/dsi/dsi_host.c | 12 +++++++-----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/msm/dsi/dsi_cfg.h b/drivers/gpu/drm/msm/dsi/dsi_cfg.h
index 03493cc6b772..4a47705234bd 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_cfg.h
+++ b/drivers/gpu/drm/msm/dsi/dsi_cfg.h
@@ -43,6 +43,7 @@ struct msm_dsi_config {
 	const int num_bus_clks;
 	/* Allow + 1 entry for the zero-terminator */
 	const resource_size_t io_start[VARIANTS_MAX][DSI_MAX + 1];
+	const int num_variants;
 };
 
 struct msm_dsi_host_cfg_ops {
diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
index f5092b4d0757..8dfa69bcff77 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -1862,16 +1862,18 @@ 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;
+	int i, j, num_variants;
 
 	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dsi_ctrl");
 	if (!res)
 		return -EINVAL;
 
-	for (i = 0; cfg->io_start[0][i]; i++) {
-		if (cfg->io_start[0][i] == res->start)
-			return i;
-	}
+	num_variants = cfg->num_variants ? cfg->num_variants : 1;
+
+	for (i = 0; i < num_variants; i++)
+		for (j = 0; cfg->io_start[i][j]; j++)
+			if (cfg->io_start[i][j] == res->start)
+				return j;
 
 	return -EINVAL;
 }
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 05/10] drm/msm/dsi: dsi_cfg: Deduplicate identical structs
       [not found] <20230211115110.1462920-1-konrad.dybcio@linaro.org>
                   ` (3 preceding siblings ...)
  2023-02-11 11:51 ` [PATCH 04/10] drm/msm/dsi: dsi_host: Fix DSI index detection when version clash occurs Konrad Dybcio
@ 2023-02-11 11:51 ` Konrad Dybcio
  2023-02-11 15:52   ` Dmitry Baryshkov
  2023-02-11 11:51 ` [PATCH 06/10] drm/msm/dsi: dsi_cfg: Merge SC7180 config into SDM845 Konrad Dybcio
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 22+ messages in thread
From: Konrad Dybcio @ 2023-02-11 11:51 UTC (permalink / raw)
  To: linux-arm-msm, andersson, agross, krzysztof.kozlowski
  Cc: marijn.suijten, Konrad Dybcio, Rob Clark, Abhinav Kumar,
	Dmitry Baryshkov, Sean Paul, David Airlie, Daniel Vetter,
	Douglas Anderson, Neil Armstrong, Loic Poulain,
	AngeloGioacchino Del Regno, Archit Taneja, Harigovindan P,
	Rajeev Nandan, Stephen Boyd, dri-devel, freedreno, linux-kernel

Some structs were defined multiple times for no apparent reason.
Deduplicate them.

Fixes: 3f3c8aff1f8f ("drm/msm/dsi: Add configuration for 8x76")
Fixes: 3a3ff88a0fc1 ("drm/msm/dsi: Add 8x96 info in dsi_cfg")
Fixes: 6125bd327e16 ("drm/msm: add DSI support for sc7180")
Fixes: 65c391b31994 ("drm/msm/dsi: Add DSI support for SC7280")
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
---
 drivers/gpu/drm/msm/dsi/dsi_cfg.c | 77 +++++++++++--------------------
 1 file changed, 26 insertions(+), 51 deletions(-)

diff --git a/drivers/gpu/drm/msm/dsi/dsi_cfg.c b/drivers/gpu/drm/msm/dsi/dsi_cfg.c
index 5f62c563bd1c..860681bfc084 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_cfg.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_cfg.c
@@ -47,41 +47,32 @@ static const struct msm_dsi_config msm8974_apq8084_dsi_cfg = {
 	},
 };
 
-static const char * const dsi_8916_bus_clk_names[] = {
+static const char * const dsi_v1_3_1_clk_names[] = {
 	"mdp_core", "iface", "bus",
 };
 
-static const struct regulator_bulk_data msm8916_dsi_regulators[] = {
+static const struct regulator_bulk_data dsi_v1_3_1_regulators[] = {
 	{ .supply = "vdda", .init_load_uA = 100000 },	/* 1.2 V */
 	{ .supply = "vddio", .init_load_uA = 100000 },	/* 1.8 V */
 };
 
 static const struct msm_dsi_config msm8916_dsi_cfg = {
 	.io_offset = DSI_6G_REG_SHIFT,
-	.regulator_data = msm8916_dsi_regulators,
-	.num_regulators = ARRAY_SIZE(msm8916_dsi_regulators),
-	.bus_clk_names = dsi_8916_bus_clk_names,
-	.num_bus_clks = ARRAY_SIZE(dsi_8916_bus_clk_names),
+	.regulator_data = dsi_v1_3_1_regulators,
+	.num_regulators = ARRAY_SIZE(dsi_v1_3_1_regulators),
+	.bus_clk_names = dsi_v1_3_1_clk_names,
+	.num_bus_clks = ARRAY_SIZE(dsi_v1_3_1_clk_names),
 	.io_start = {
 		{ 0x1a98000, 0 },
 	},
 };
 
-static const char * const dsi_8976_bus_clk_names[] = {
-	"mdp_core", "iface", "bus",
-};
-
-static const struct regulator_bulk_data msm8976_dsi_regulators[] = {
-	{ .supply = "vdda", .init_load_uA = 100000 },	/* 1.2 V */
-	{ .supply = "vddio", .init_load_uA = 100000 },	/* 1.8 V */
-};
-
 static const struct msm_dsi_config msm8976_dsi_cfg = {
 	.io_offset = DSI_6G_REG_SHIFT,
-	.regulator_data = msm8976_dsi_regulators,
-	.num_regulators = ARRAY_SIZE(msm8976_dsi_regulators),
-	.bus_clk_names = dsi_8976_bus_clk_names,
-	.num_bus_clks = ARRAY_SIZE(dsi_8976_bus_clk_names),
+	.regulator_data = dsi_v1_3_1_regulators,
+	.num_regulators = ARRAY_SIZE(dsi_v1_3_1_regulators),
+	.bus_clk_names = dsi_v1_3_1_clk_names,
+	.num_bus_clks = ARRAY_SIZE(dsi_v1_3_1_clk_names),
 	.io_start = {
 		{ 0x1a94000, 0x1a96000, 0 },
 	},
@@ -107,10 +98,6 @@ static const struct msm_dsi_config msm8994_dsi_cfg = {
 	},
 };
 
-static const char * const dsi_8996_bus_clk_names[] = {
-	"mdp_core", "iface", "bus", "core_mmss",
-};
-
 static const struct regulator_bulk_data msm8996_dsi_regulators[] = {
 	{ .supply = "vdda", .init_load_uA = 18160 },	/* 1.25 V */
 	{ .supply = "vcca", .init_load_uA = 17000 },	/* 0.925 V */
@@ -121,8 +108,8 @@ static const struct msm_dsi_config msm8996_dsi_cfg = {
 	.io_offset = DSI_6G_REG_SHIFT,
 	.regulator_data = msm8996_dsi_regulators,
 	.num_regulators = ARRAY_SIZE(msm8996_dsi_regulators),
-	.bus_clk_names = dsi_8996_bus_clk_names,
-	.num_bus_clks = ARRAY_SIZE(dsi_8996_bus_clk_names),
+	.bus_clk_names = dsi_6g_bus_clk_names,
+	.num_bus_clks = ARRAY_SIZE(dsi_6g_bus_clk_names),
 	.io_start = {
 		{ 0x994000, 0x996000, 0 },
 	},
@@ -167,24 +154,20 @@ static const struct msm_dsi_config sdm660_dsi_cfg = {
 	},
 };
 
-static const char * const dsi_sdm845_bus_clk_names[] = {
+static const char * const dsi_v2_4_clk_names[] = {
 	"iface", "bus",
 };
 
-static const char * const dsi_sc7180_bus_clk_names[] = {
-	"iface", "bus",
-};
-
-static const struct regulator_bulk_data sdm845_dsi_regulators[] = {
+static const struct regulator_bulk_data dsi_v2_4_regulators[] = {
 	{ .supply = "vdda", .init_load_uA = 21800 },	/* 1.2 V */
 };
 
 static const struct msm_dsi_config sdm845_dsi_cfg = {
 	.io_offset = DSI_6G_REG_SHIFT,
-	.regulator_data = sdm845_dsi_regulators,
-	.num_regulators = ARRAY_SIZE(sdm845_dsi_regulators),
-	.bus_clk_names = dsi_sdm845_bus_clk_names,
-	.num_bus_clks = ARRAY_SIZE(dsi_sdm845_bus_clk_names),
+	.regulator_data = dsi_v2_4_regulators,
+	.num_regulators = ARRAY_SIZE(dsi_v2_4_regulators),
+	.bus_clk_names = dsi_v2_4_clk_names,
+	.num_bus_clks = ARRAY_SIZE(dsi_v2_4_clk_names),
 	.io_start = {
 		{ 0xae94000, 0xae96000, 0 },
 	},
@@ -198,32 +181,24 @@ static const struct msm_dsi_config sm8550_dsi_cfg = {
 	.io_offset = DSI_6G_REG_SHIFT,
 	.regulator_data = sm8550_dsi_regulators,
 	.num_regulators = ARRAY_SIZE(sm8550_dsi_regulators),
-	.bus_clk_names = dsi_sdm845_bus_clk_names,
-	.num_bus_clks = ARRAY_SIZE(dsi_sdm845_bus_clk_names),
+	.bus_clk_names = dsi_v2_4_clk_names,
+	.num_bus_clks = ARRAY_SIZE(dsi_v2_4_clk_names),
 	.io_start = {
 		{ 0xae94000, 0xae96000, 0 },
 	},
 };
 
-static const struct regulator_bulk_data sc7180_dsi_regulators[] = {
-	{ .supply = "vdda", .init_load_uA = 21800 },	/* 1.2 V */
-};
-
 static const struct msm_dsi_config sc7180_dsi_cfg = {
 	.io_offset = DSI_6G_REG_SHIFT,
-	.regulator_data = sc7180_dsi_regulators,
-	.num_regulators = ARRAY_SIZE(sc7180_dsi_regulators),
-	.bus_clk_names = dsi_sc7180_bus_clk_names,
-	.num_bus_clks = ARRAY_SIZE(dsi_sc7180_bus_clk_names),
+	.regulator_data = dsi_v2_4_regulators,
+	.num_regulators = ARRAY_SIZE(dsi_v2_4_regulators),
+	.bus_clk_names = dsi_v2_4_clk_names,
+	.num_bus_clks = ARRAY_SIZE(dsi_v2_4_clk_names),
 	.io_start = {
 		{ 0xae94000, 0 },
 	},
 };
 
-static const char * const dsi_sc7280_bus_clk_names[] = {
-	"iface", "bus",
-};
-
 static const struct regulator_bulk_data sc7280_dsi_regulators[] = {
 	{ .supply = "vdda", .init_load_uA = 8350 },	/* 1.2 V */
 };
@@ -232,8 +207,8 @@ static const struct msm_dsi_config sc7280_dsi_cfg = {
 	.io_offset = DSI_6G_REG_SHIFT,
 	.regulator_data = sc7280_dsi_regulators,
 	.num_regulators = ARRAY_SIZE(sc7280_dsi_regulators),
-	.bus_clk_names = dsi_sc7280_bus_clk_names,
-	.num_bus_clks = ARRAY_SIZE(dsi_sc7280_bus_clk_names),
+	.bus_clk_names = dsi_v2_4_clk_names,
+	.num_bus_clks = ARRAY_SIZE(dsi_v2_4_clk_names),
 	.io_start = {
 		{ 0xae94000, 0xae96000, 0 },
 	},
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 06/10] drm/msm/dsi: dsi_cfg: Merge SC7180 config into SDM845
       [not found] <20230211115110.1462920-1-konrad.dybcio@linaro.org>
                   ` (4 preceding siblings ...)
  2023-02-11 11:51 ` [PATCH 05/10] drm/msm/dsi: dsi_cfg: Deduplicate identical structs Konrad Dybcio
@ 2023-02-11 11:51 ` Konrad Dybcio
  2023-02-11 15:52   ` Dmitry Baryshkov
  2023-02-11 11:51 ` [PATCH 07/10] drm/msm/dsi: Switch the QCM2290-specific compatible to index autodetection Konrad Dybcio
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 22+ messages in thread
From: Konrad Dybcio @ 2023-02-11 11:51 UTC (permalink / raw)
  To: linux-arm-msm, andersson, agross, krzysztof.kozlowski
  Cc: marijn.suijten, Konrad Dybcio, Rob Clark, Abhinav Kumar,
	Dmitry Baryshkov, Sean Paul, David Airlie, Daniel Vetter,
	Douglas Anderson, Loic Poulain, Neil Armstrong, Harigovindan P,
	dri-devel, freedreno, linux-kernel

The configs are identical, other than the number of *maximum* DSI
hosts allowed. This isn't an issue, unless somebody deliberately
tries to access the inexistent host by adding a dt node for it.

Remove the SC7180 struct and point the hw revision match to the
SDM845's one. On a note, this could have been done back when
7180 support was introduced.

Fixes: 6125bd327e16 ("drm/msm: add DSI support for sc7180")
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
---
 drivers/gpu/drm/msm/dsi/dsi_cfg.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/msm/dsi/dsi_cfg.c b/drivers/gpu/drm/msm/dsi/dsi_cfg.c
index 860681bfc084..142a0f1e2576 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_cfg.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_cfg.c
@@ -169,7 +169,7 @@ static const struct msm_dsi_config sdm845_dsi_cfg = {
 	.bus_clk_names = dsi_v2_4_clk_names,
 	.num_bus_clks = ARRAY_SIZE(dsi_v2_4_clk_names),
 	.io_start = {
-		{ 0xae94000, 0xae96000, 0 },
+		{ 0xae94000, 0xae96000, 0 }, /* SDM845 / SDM670 / SC7180 */
 	},
 };
 
@@ -188,17 +188,6 @@ static const struct msm_dsi_config sm8550_dsi_cfg = {
 	},
 };
 
-static const struct msm_dsi_config sc7180_dsi_cfg = {
-	.io_offset = DSI_6G_REG_SHIFT,
-	.regulator_data = dsi_v2_4_regulators,
-	.num_regulators = ARRAY_SIZE(dsi_v2_4_regulators),
-	.bus_clk_names = dsi_v2_4_clk_names,
-	.num_bus_clks = ARRAY_SIZE(dsi_v2_4_clk_names),
-	.io_start = {
-		{ 0xae94000, 0 },
-	},
-};
-
 static const struct regulator_bulk_data sc7280_dsi_regulators[] = {
 	{ .supply = "vdda", .init_load_uA = 8350 },	/* 1.2 V */
 };
@@ -299,7 +288,7 @@ static const struct msm_dsi_cfg_handler dsi_cfg_handlers[] = {
 	{MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V2_4_0,
 		&sdm845_dsi_cfg, &msm_dsi_6g_v2_host_ops},
 	{MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V2_4_1,
-		&sc7180_dsi_cfg, &msm_dsi_6g_v2_host_ops},
+		&sdm845_dsi_cfg, &msm_dsi_6g_v2_host_ops},
 	{MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V2_5_0,
 		&sc7280_dsi_cfg, &msm_dsi_6g_v2_host_ops},
 	{MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V2_6_0,
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 07/10] drm/msm/dsi: Switch the QCM2290-specific compatible to index autodetection
       [not found] <20230211115110.1462920-1-konrad.dybcio@linaro.org>
                   ` (5 preceding siblings ...)
  2023-02-11 11:51 ` [PATCH 06/10] drm/msm/dsi: dsi_cfg: Merge SC7180 config into SDM845 Konrad Dybcio
@ 2023-02-11 11:51 ` Konrad Dybcio
  2023-02-11 11:51 ` [PATCH 08/10] drm/msm/dsi: Remove custom DSI config handling Konrad Dybcio
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 22+ messages in thread
From: Konrad Dybcio @ 2023-02-11 11:51 UTC (permalink / raw)
  To: linux-arm-msm, andersson, agross, krzysztof.kozlowski
  Cc: marijn.suijten, Konrad Dybcio, Rob Clark, Abhinav Kumar,
	Dmitry Baryshkov, Sean Paul, David Airlie, Daniel Vetter,
	Kuogee Hsieh, Loic Poulain, Johan Hovold, Vinod Koul,
	Douglas Anderson, Neil Armstrong, dri-devel, freedreno,
	linux-kernel

Now that the logic can handle multiple sets of registers, move
the QCM2290 to the common logic and mark it deprecated. This allows us
to remove a couple of structs, saving some memory.

Fixes: ee1f09678f14 ("drm/msm/dsi: Add support for qcm2290 dsi controller")
Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
---
 drivers/gpu/drm/msm/dsi/dsi.c     |  4 +++-
 drivers/gpu/drm/msm/dsi/dsi_cfg.c | 29 +++--------------------------
 2 files changed, 6 insertions(+), 27 deletions(-)

diff --git a/drivers/gpu/drm/msm/dsi/dsi.c b/drivers/gpu/drm/msm/dsi/dsi.c
index 31fdee2052be..90d43628b22b 100644
--- a/drivers/gpu/drm/msm/dsi/dsi.c
+++ b/drivers/gpu/drm/msm/dsi/dsi.c
@@ -174,7 +174,9 @@ static int dsi_dev_remove(struct platform_device *pdev)
 
 static const struct of_device_id dt_match[] = {
 	{ .compatible = "qcom,mdss-dsi-ctrl", .data = NULL /* autodetect cfg */ },
-	{ .compatible = "qcom,dsi-ctrl-6g-qcm2290", .data = &qcm2290_dsi_cfg_handler },
+
+	/* Deprecated, don't use */
+	{ .compatible = "qcom,dsi-ctrl-6g-qcm2290", .data = NULL },
 	{}
 };
 
diff --git a/drivers/gpu/drm/msm/dsi/dsi_cfg.c b/drivers/gpu/drm/msm/dsi/dsi_cfg.c
index 142a0f1e2576..81d41f247040 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_cfg.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_cfg.c
@@ -169,8 +169,10 @@ static const struct msm_dsi_config sdm845_dsi_cfg = {
 	.bus_clk_names = dsi_v2_4_clk_names,
 	.num_bus_clks = ARRAY_SIZE(dsi_v2_4_clk_names),
 	.io_start = {
-		{ 0xae94000, 0xae96000, 0 }, /* SDM845 / SDM670 / SC7180 */
+		{ 0xae94000, 0xae96000, 0 }, /* SDM845 / SDM670 */
+		{ 0x5e94000, 0 }, /* QCM2290 / SM6115 / SM6125 / SM6375 */
 	},
+	.num_variants = 2,
 };
 
 static const struct regulator_bulk_data sm8550_dsi_regulators[] = {
@@ -203,25 +205,6 @@ static const struct msm_dsi_config sc7280_dsi_cfg = {
 	},
 };
 
-static const char * const dsi_qcm2290_bus_clk_names[] = {
-	"iface", "bus",
-};
-
-static const struct regulator_bulk_data qcm2290_dsi_cfg_regulators[] = {
-	{ .supply = "vdda", .init_load_uA = 21800 },	/* 1.2 V */
-};
-
-static const struct msm_dsi_config qcm2290_dsi_cfg = {
-	.io_offset = DSI_6G_REG_SHIFT,
-	.regulator_data = qcm2290_dsi_cfg_regulators,
-	.num_regulators = ARRAY_SIZE(qcm2290_dsi_cfg_regulators),
-	.bus_clk_names = dsi_qcm2290_bus_clk_names,
-	.num_bus_clks = ARRAY_SIZE(dsi_qcm2290_bus_clk_names),
-	.io_start = {
-		{ 0x5e94000, 0 },
-	},
-};
-
 static const struct msm_dsi_host_cfg_ops msm_dsi_v2_host_ops = {
 	.link_clk_set_rate = dsi_link_clk_set_rate_v2,
 	.link_clk_enable = dsi_link_clk_enable_v2,
@@ -312,9 +295,3 @@ const struct msm_dsi_cfg_handler *msm_dsi_cfg_get(u32 major, u32 minor)
 
 	return cfg_hnd;
 }
-
-/*  Non autodetect configs */
-const struct msm_dsi_cfg_handler qcm2290_dsi_cfg_handler = {
-	.cfg = &qcm2290_dsi_cfg,
-	.ops = &msm_dsi_6g_v2_host_ops,
-};
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 08/10] drm/msm/dsi: Remove custom DSI config handling
       [not found] <20230211115110.1462920-1-konrad.dybcio@linaro.org>
                   ` (6 preceding siblings ...)
  2023-02-11 11:51 ` [PATCH 07/10] drm/msm/dsi: Switch the QCM2290-specific compatible to index autodetection Konrad Dybcio
@ 2023-02-11 11:51 ` Konrad Dybcio
  2023-02-11 15:53   ` Dmitry Baryshkov
  2023-02-11 11:51 ` [PATCH 09/10] dt-bindings: display/msm: dsi-controller-main: Add SM6115 Konrad Dybcio
  2023-02-11 11:51 ` [PATCH 10/10] arm64: dts: qcom: sm6115: Use the correct DSI compatible Konrad Dybcio
  9 siblings, 1 reply; 22+ messages in thread
From: Konrad Dybcio @ 2023-02-11 11:51 UTC (permalink / raw)
  To: linux-arm-msm, andersson, agross, krzysztof.kozlowski
  Cc: marijn.suijten, Konrad Dybcio, Rob Clark, Abhinav Kumar,
	Dmitry Baryshkov, Sean Paul, David Airlie, Daniel Vetter,
	Johan Hovold, Loic Poulain, Kuogee Hsieh, Vinod Koul,
	Douglas Anderson, Vladimir Lypak, dri-devel, freedreno,
	linux-kernel

Now that the only user is handled by common code, remove the option to
specify custom handlers through match data.

This is effectively a revert of commit:
5ae15e76271 ("drm/msm/dsi: Allow to specify dsi config as pdata")

Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
---
 drivers/gpu/drm/msm/dsi/dsi.c      | 4 ++--
 drivers/gpu/drm/msm/dsi/dsi_host.c | 4 ----
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/msm/dsi/dsi.c b/drivers/gpu/drm/msm/dsi/dsi.c
index 90d43628b22b..e0b911af618d 100644
--- a/drivers/gpu/drm/msm/dsi/dsi.c
+++ b/drivers/gpu/drm/msm/dsi/dsi.c
@@ -173,10 +173,10 @@ static int dsi_dev_remove(struct platform_device *pdev)
 }
 
 static const struct of_device_id dt_match[] = {
-	{ .compatible = "qcom,mdss-dsi-ctrl", .data = NULL /* autodetect cfg */ },
+	{ .compatible = "qcom,mdss-dsi-ctrl" },
 
 	/* Deprecated, don't use */
-	{ .compatible = "qcom,dsi-ctrl-6g-qcm2290", .data = NULL },
+	{ .compatible = "qcom,dsi-ctrl-6g-qcm2290" },
 	{}
 };
 
diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
index 8dfa69bcff77..79c33d066348 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -214,10 +214,6 @@ static const struct msm_dsi_cfg_handler *dsi_get_config(
 	int ret;
 	u32 major = 0, minor = 0;
 
-	cfg_hnd = device_get_match_data(dev);
-	if (cfg_hnd)
-		return cfg_hnd;
-
 	ahb_clk = msm_clk_get(msm_host->pdev, "iface");
 	if (IS_ERR(ahb_clk)) {
 		pr_err("%s: cannot get interface clock\n", __func__);
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 09/10] dt-bindings: display/msm: dsi-controller-main: Add SM6115
       [not found] <20230211115110.1462920-1-konrad.dybcio@linaro.org>
                   ` (7 preceding siblings ...)
  2023-02-11 11:51 ` [PATCH 08/10] drm/msm/dsi: Remove custom DSI config handling Konrad Dybcio
@ 2023-02-11 11:51 ` Konrad Dybcio
  2023-02-11 11:51 ` [PATCH 10/10] arm64: dts: qcom: sm6115: Use the correct DSI compatible Konrad Dybcio
  9 siblings, 0 replies; 22+ messages in thread
From: Konrad Dybcio @ 2023-02-11 11:51 UTC (permalink / raw)
  To: linux-arm-msm, andersson, agross, krzysztof.kozlowski
  Cc: marijn.suijten, Konrad Dybcio, Rob Clark, Abhinav Kumar,
	Dmitry Baryshkov, Sean Paul, David Airlie, Daniel Vetter,
	Rob Herring, Krzysztof Kozlowski, Krishna Manikandan, dri-devel,
	freedreno, devicetree, linux-kernel

Add a compatible for the DSI on SM6115.

Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
---
 .../devicetree/bindings/display/msm/dsi-controller-main.yaml    | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/display/msm/dsi-controller-main.yaml b/Documentation/devicetree/bindings/display/msm/dsi-controller-main.yaml
index 2494817c1bd6..f195530ae964 100644
--- a/Documentation/devicetree/bindings/display/msm/dsi-controller-main.yaml
+++ b/Documentation/devicetree/bindings/display/msm/dsi-controller-main.yaml
@@ -25,6 +25,7 @@ properties:
               - qcom,sc7280-dsi-ctrl
               - qcom,sdm660-dsi-ctrl
               - qcom,sdm845-dsi-ctrl
+              - qcom,sm6115-dsi-ctrl
               - qcom,sm8150-dsi-ctrl
               - qcom,sm8250-dsi-ctrl
               - qcom,sm8350-dsi-ctrl
@@ -351,6 +352,7 @@ allOf:
           contains:
             enum:
               - qcom,sdm845-dsi-ctrl
+              - qcom,sm6115-dsi-ctrl
     then:
       properties:
         clocks:
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 10/10] arm64: dts: qcom: sm6115: Use the correct DSI compatible
       [not found] <20230211115110.1462920-1-konrad.dybcio@linaro.org>
                   ` (8 preceding siblings ...)
  2023-02-11 11:51 ` [PATCH 09/10] dt-bindings: display/msm: dsi-controller-main: Add SM6115 Konrad Dybcio
@ 2023-02-11 11:51 ` Konrad Dybcio
  9 siblings, 0 replies; 22+ messages in thread
From: Konrad Dybcio @ 2023-02-11 11:51 UTC (permalink / raw)
  To: linux-arm-msm, andersson, agross, krzysztof.kozlowski
  Cc: marijn.suijten, Konrad Dybcio, Rob Herring, Krzysztof Kozlowski,
	devicetree, linux-kernel

Use the non-deprecated, SoC-specific DSI compatible.

Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
---
 arch/arm64/boot/dts/qcom/sm6115.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/qcom/sm6115.dtsi b/arch/arm64/boot/dts/qcom/sm6115.dtsi
index bff067ed2e94..15811be82acc 100644
--- a/arch/arm64/boot/dts/qcom/sm6115.dtsi
+++ b/arch/arm64/boot/dts/qcom/sm6115.dtsi
@@ -1447,7 +1447,7 @@ opp-384000000 {
 			};
 
 			mdss_dsi0: dsi@5e94000 {
-				compatible = "qcom,dsi-ctrl-6g-qcm2290";
+				compatible = "qcom,sm6115-dsi-ctrl", "qcom,mdss-dsi-ctrl";
 				reg = <0x0 0x05e94000 0x0 0x400>;
 				reg-names = "dsi_ctrl";
 
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH 02/10] drm/msm/dsi: Turn msm_dsi_config::io_start into a 2d array
  2023-02-11 11:51 ` [PATCH 02/10] drm/msm/dsi: Turn msm_dsi_config::io_start into a 2d array Konrad Dybcio
@ 2023-02-11 13:17   ` Dmitry Baryshkov
  2023-02-13  9:16     ` Konrad Dybcio
  0 siblings, 1 reply; 22+ messages in thread
From: Dmitry Baryshkov @ 2023-02-11 13:17 UTC (permalink / raw)
  To: Konrad Dybcio, linux-arm-msm, andersson, agross, krzysztof.kozlowski
  Cc: marijn.suijten, Rob Clark, Abhinav Kumar, Sean Paul,
	David Airlie, Daniel Vetter, Douglas Anderson, Neil Armstrong,
	Loic Poulain, Vinod Koul, Vladimir Lypak, dri-devel, freedreno,
	linux-kernel

On 11/02/2023 13:51, Konrad Dybcio wrote:
> Currently, we allow for MAX_DSI entries in io_start to facilitate for
> MAX_DSI number of DSI hosts at different addresses. The configuration
> is matched against the DSI CTRL hardware revision read back from the
> component. We need a way to resolve situations where multiple SoCs
> with different register maps may use the same version of DSI CTRL. In
> preparation to do so, make msm_dsi_config a 2d array where each entry
> represents a set of configurations adequate for a given SoC.
> 
> This is totally fine to do, as the only differentiating factors
> between same-version-different-SoCs configurations are the number of
> DSI hosts (1 or 2, at least as of today) and the set of registers.

s/set of registers/starting address/ ?

> The regulator setup is the same, because the DSI hardware is the same,
> regardless of the SoC it was implemented in.
> 
> Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
> ---
>   drivers/gpu/drm/msm/dsi/dsi_cfg.c  | 52 ++++++++++++++++++++++--------
>   drivers/gpu/drm/msm/dsi/dsi_cfg.h  |  5 ++-
>   drivers/gpu/drm/msm/dsi/dsi_host.c |  2 +-
>   3 files changed, 44 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/dsi/dsi_cfg.c b/drivers/gpu/drm/msm/dsi/dsi_cfg.c
> index 6d21f0b33411..068d45b3a8f0 100644
> --- a/drivers/gpu/drm/msm/dsi/dsi_cfg.c
> +++ b/drivers/gpu/drm/msm/dsi/dsi_cfg.c
> @@ -21,7 +21,9 @@ static const struct msm_dsi_config apq8064_dsi_cfg = {
>   	.num_regulators = ARRAY_SIZE(apq8064_dsi_regulators),
>   	.bus_clk_names = dsi_v2_bus_clk_names,
>   	.num_bus_clks = ARRAY_SIZE(dsi_v2_bus_clk_names),
> -	.io_start = { 0x4700000, 0x5800000 },
> +	.io_start = {
> +		{ 0x4700000, 0x5800000 },
> +	},
>   	.num_dsi = 2,
>   };
>   
> @@ -41,7 +43,9 @@ static const struct msm_dsi_config msm8974_apq8084_dsi_cfg = {
>   	.num_regulators = ARRAY_SIZE(msm8974_apq8084_regulators),
>   	.bus_clk_names = dsi_6g_bus_clk_names,
>   	.num_bus_clks = ARRAY_SIZE(dsi_6g_bus_clk_names),
> -	.io_start = { 0xfd922800, 0xfd922b00 },
> +	.io_start = {
> +		{ 0xfd922800, 0xfd922b00 },
> +	},
>   	.num_dsi = 2,
>   };
>   
> @@ -60,7 +64,9 @@ static const struct msm_dsi_config msm8916_dsi_cfg = {
>   	.num_regulators = ARRAY_SIZE(msm8916_dsi_regulators),
>   	.bus_clk_names = dsi_8916_bus_clk_names,
>   	.num_bus_clks = ARRAY_SIZE(dsi_8916_bus_clk_names),
> -	.io_start = { 0x1a98000 },
> +	.io_start = {
> +		{ 0x1a98000 },
> +	},
>   	.num_dsi = 1,
>   };
>   
> @@ -79,7 +85,9 @@ static const struct msm_dsi_config msm8976_dsi_cfg = {
>   	.num_regulators = ARRAY_SIZE(msm8976_dsi_regulators),
>   	.bus_clk_names = dsi_8976_bus_clk_names,
>   	.num_bus_clks = ARRAY_SIZE(dsi_8976_bus_clk_names),
> -	.io_start = { 0x1a94000, 0x1a96000 },
> +	.io_start = {
> +		{ 0x1a94000, 0x1a96000 },
> +	},
>   	.num_dsi = 2,
>   };
>   
> @@ -98,7 +106,9 @@ static const struct msm_dsi_config msm8994_dsi_cfg = {
>   	.num_regulators = ARRAY_SIZE(msm8994_dsi_regulators),
>   	.bus_clk_names = dsi_6g_bus_clk_names,
>   	.num_bus_clks = ARRAY_SIZE(dsi_6g_bus_clk_names),
> -	.io_start = { 0xfd998000, 0xfd9a0000 },
> +	.io_start = {
> +		{ 0xfd998000, 0xfd9a0000 },
> +	},
>   	.num_dsi = 2,
>   };
>   
> @@ -118,7 +128,9 @@ static const struct msm_dsi_config msm8996_dsi_cfg = {
>   	.num_regulators = ARRAY_SIZE(msm8996_dsi_regulators),
>   	.bus_clk_names = dsi_8996_bus_clk_names,
>   	.num_bus_clks = ARRAY_SIZE(dsi_8996_bus_clk_names),
> -	.io_start = { 0x994000, 0x996000 },
> +	.io_start = {
> +		{ 0x994000, 0x996000 },
> +	},
>   	.num_dsi = 2,
>   };
>   
> @@ -137,7 +149,9 @@ static const struct msm_dsi_config msm8998_dsi_cfg = {
>   	.num_regulators = ARRAY_SIZE(msm8998_dsi_regulators),
>   	.bus_clk_names = dsi_msm8998_bus_clk_names,
>   	.num_bus_clks = ARRAY_SIZE(dsi_msm8998_bus_clk_names),
> -	.io_start = { 0xc994000, 0xc996000 },
> +	.io_start = {
> +		{ 0xc994000, 0xc996000 },
> +	},
>   	.num_dsi = 2,
>   };
>   
> @@ -155,7 +169,9 @@ static const struct msm_dsi_config sdm660_dsi_cfg = {
>   	.num_regulators = ARRAY_SIZE(sdm660_dsi_regulators),
>   	.bus_clk_names = dsi_sdm660_bus_clk_names,
>   	.num_bus_clks = ARRAY_SIZE(dsi_sdm660_bus_clk_names),
> -	.io_start = { 0xc994000, 0xc996000 },
> +	.io_start = {
> +		{ 0xc994000, 0xc996000 },
> +	},
>   	.num_dsi = 2,
>   };
>   
> @@ -177,7 +193,9 @@ static const struct msm_dsi_config sdm845_dsi_cfg = {
>   	.num_regulators = ARRAY_SIZE(sdm845_dsi_regulators),
>   	.bus_clk_names = dsi_sdm845_bus_clk_names,
>   	.num_bus_clks = ARRAY_SIZE(dsi_sdm845_bus_clk_names),
> -	.io_start = { 0xae94000, 0xae96000 },
> +	.io_start = {
> +		{ 0xae94000, 0xae96000 },
> +	},
>   	.num_dsi = 2,
>   };
>   
> @@ -191,7 +209,9 @@ static const struct msm_dsi_config sm8550_dsi_cfg = {
>   	.num_regulators = ARRAY_SIZE(sm8550_dsi_regulators),
>   	.bus_clk_names = dsi_sdm845_bus_clk_names,
>   	.num_bus_clks = ARRAY_SIZE(dsi_sdm845_bus_clk_names),
> -	.io_start = { 0xae94000, 0xae96000 },
> +	.io_start = {
> +		{ 0xae94000, 0xae96000 },
> +	},
>   	.num_dsi = 2,
>   };
>   
> @@ -205,7 +225,9 @@ static const struct msm_dsi_config sc7180_dsi_cfg = {
>   	.num_regulators = ARRAY_SIZE(sc7180_dsi_regulators),
>   	.bus_clk_names = dsi_sc7180_bus_clk_names,
>   	.num_bus_clks = ARRAY_SIZE(dsi_sc7180_bus_clk_names),
> -	.io_start = { 0xae94000 },
> +	.io_start = {
> +		{ 0xae94000 },
> +	},
>   	.num_dsi = 1,
>   };
>   
> @@ -223,7 +245,9 @@ static const struct msm_dsi_config sc7280_dsi_cfg = {
>   	.num_regulators = ARRAY_SIZE(sc7280_dsi_regulators),
>   	.bus_clk_names = dsi_sc7280_bus_clk_names,
>   	.num_bus_clks = ARRAY_SIZE(dsi_sc7280_bus_clk_names),
> -	.io_start = { 0xae94000, 0xae96000 },
> +	.io_start = {
> +		{ 0xae94000, 0xae96000 },
> +	},
>   	.num_dsi = 2,
>   };
>   
> @@ -241,7 +265,9 @@ static const struct msm_dsi_config qcm2290_dsi_cfg = {
>   	.num_regulators = ARRAY_SIZE(qcm2290_dsi_cfg_regulators),
>   	.bus_clk_names = dsi_qcm2290_bus_clk_names,
>   	.num_bus_clks = ARRAY_SIZE(dsi_qcm2290_bus_clk_names),
> -	.io_start = { 0x5e94000 },
> +	.io_start = {
> +		{ 0x5e94000 },
> +	},
>   	.num_dsi = 1,
>   };
>   
> diff --git a/drivers/gpu/drm/msm/dsi/dsi_cfg.h b/drivers/gpu/drm/msm/dsi/dsi_cfg.h
> index 44be4a88aa83..df9f09876ccb 100644
> --- a/drivers/gpu/drm/msm/dsi/dsi_cfg.h
> +++ b/drivers/gpu/drm/msm/dsi/dsi_cfg.h
> @@ -32,13 +32,16 @@
>   
>   #define DSI_6G_REG_SHIFT	4
>   
> +/* Maximum number of configurations matched against the same hw revision */
> +#define VARIANTS_MAX			2
> +
>   struct msm_dsi_config {
>   	u32 io_offset;
>   	const struct regulator_bulk_data *regulator_data;
>   	int num_regulators;
>   	const char * const *bus_clk_names;
>   	const int num_bus_clks;
> -	const resource_size_t io_start[DSI_MAX];
> +	const resource_size_t io_start[VARIANTS_MAX][DSI_MAX];
>   	const int num_dsi;
>   };
>   
> diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
> index 18fa30e1e858..22ba8726b0ea 100644
> --- a/drivers/gpu/drm/msm/dsi/dsi_host.c
> +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
> @@ -1869,7 +1869,7 @@ static int dsi_host_get_id(struct msm_dsi_host *msm_host)
>   		return -EINVAL;
>   
>   	for (i = 0; i < cfg->num_dsi; i++) {
> -		if (cfg->io_start[i] == res->start)
> +		if (cfg->io_start[0][i] == res->start)
>   			return i;
>   	}
>   

-- 
With best wishes
Dmitry


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 03/10] drm/msm/dsi: Zero-terminate msm_dsi_config::io_start
  2023-02-11 11:51 ` [PATCH 03/10] drm/msm/dsi: Zero-terminate msm_dsi_config::io_start Konrad Dybcio
@ 2023-02-11 13:19   ` Dmitry Baryshkov
  2023-02-13  9:18     ` Konrad Dybcio
  0 siblings, 1 reply; 22+ messages in thread
From: Dmitry Baryshkov @ 2023-02-11 13:19 UTC (permalink / raw)
  To: Konrad Dybcio, linux-arm-msm, andersson, agross, krzysztof.kozlowski
  Cc: marijn.suijten, Rob Clark, Abhinav Kumar, Sean Paul,
	David Airlie, Daniel Vetter, Douglas Anderson, Loic Poulain,
	Neil Armstrong, Vinod Koul, Vladimir Lypak, dri-devel, freedreno,
	linux-kernel

On 11/02/2023 13:51, Konrad Dybcio wrote:
> In preparation for supporting multiple sets of possible base registers,
> Zero-terminate the array that contains them to remove the need of
> specifying num_dsi for each set.
> 
> Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
> ---
>   drivers/gpu/drm/msm/dsi/dsi_cfg.c  | 39 ++++++++++--------------------
>   drivers/gpu/drm/msm/dsi/dsi_cfg.h  |  4 +--
>   drivers/gpu/drm/msm/dsi/dsi_host.c |  2 +-
>   3 files changed, 16 insertions(+), 29 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/dsi/dsi_cfg.c b/drivers/gpu/drm/msm/dsi/dsi_cfg.c
> index 068d45b3a8f0..5f62c563bd1c 100644
> --- a/drivers/gpu/drm/msm/dsi/dsi_cfg.c
> +++ b/drivers/gpu/drm/msm/dsi/dsi_cfg.c
> @@ -22,9 +22,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 },
> +		{ 0x4700000, 0x5800000, 0 },
>   	},
> -	.num_dsi = 2,
>   };
>   
>   static const char * const dsi_6g_bus_clk_names[] = {
> @@ -44,9 +43,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 },
> +		{ 0xfd922800, 0xfd922b00, 0 },
>   	},
> -	.num_dsi = 2,
>   };
>   
>   static const char * const dsi_8916_bus_clk_names[] = {
> @@ -65,9 +63,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 },
> +		{ 0x1a98000, 0 },
>   	},
> -	.num_dsi = 1,
>   };
>   
>   static const char * const dsi_8976_bus_clk_names[] = {
> @@ -86,9 +83,8 @@ static const struct msm_dsi_config msm8976_dsi_cfg = {
>   	.bus_clk_names = dsi_8976_bus_clk_names,
>   	.num_bus_clks = ARRAY_SIZE(dsi_8976_bus_clk_names),
>   	.io_start = {
> -		{ 0x1a94000, 0x1a96000 },
> +		{ 0x1a94000, 0x1a96000, 0 },
>   	},
> -	.num_dsi = 2,
>   };
>   
>   static const struct regulator_bulk_data msm8994_dsi_regulators[] = {
> @@ -107,9 +103,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 },
> +		{ 0xfd998000, 0xfd9a0000, 0 },
>   	},
> -	.num_dsi = 2,
>   };
>   
>   static const char * const dsi_8996_bus_clk_names[] = {
> @@ -129,9 +124,8 @@ static const struct msm_dsi_config msm8996_dsi_cfg = {
>   	.bus_clk_names = dsi_8996_bus_clk_names,
>   	.num_bus_clks = ARRAY_SIZE(dsi_8996_bus_clk_names),
>   	.io_start = {
> -		{ 0x994000, 0x996000 },
> +		{ 0x994000, 0x996000, 0 },
>   	},
> -	.num_dsi = 2,
>   };
>   
>   static const char * const dsi_msm8998_bus_clk_names[] = {
> @@ -150,9 +144,8 @@ static const struct msm_dsi_config msm8998_dsi_cfg = {
>   	.bus_clk_names = dsi_msm8998_bus_clk_names,
>   	.num_bus_clks = ARRAY_SIZE(dsi_msm8998_bus_clk_names),
>   	.io_start = {
> -		{ 0xc994000, 0xc996000 },
> +		{ 0xc994000, 0xc996000, 0 },
>   	},
> -	.num_dsi = 2,
>   };
>   
>   static const char * const dsi_sdm660_bus_clk_names[] = {
> @@ -170,9 +163,8 @@ static const struct msm_dsi_config sdm660_dsi_cfg = {
>   	.bus_clk_names = dsi_sdm660_bus_clk_names,
>   	.num_bus_clks = ARRAY_SIZE(dsi_sdm660_bus_clk_names),
>   	.io_start = {
> -		{ 0xc994000, 0xc996000 },
> +		{ 0xc994000, 0xc996000, 0 },
>   	},
> -	.num_dsi = 2,
>   };
>   
>   static const char * const dsi_sdm845_bus_clk_names[] = {
> @@ -194,9 +186,8 @@ static const struct msm_dsi_config sdm845_dsi_cfg = {
>   	.bus_clk_names = dsi_sdm845_bus_clk_names,
>   	.num_bus_clks = ARRAY_SIZE(dsi_sdm845_bus_clk_names),
>   	.io_start = {
> -		{ 0xae94000, 0xae96000 },
> +		{ 0xae94000, 0xae96000, 0 },
>   	},
> -	.num_dsi = 2,
>   };
>   
>   static const struct regulator_bulk_data sm8550_dsi_regulators[] = {
> @@ -210,9 +201,8 @@ static const struct msm_dsi_config sm8550_dsi_cfg = {
>   	.bus_clk_names = dsi_sdm845_bus_clk_names,
>   	.num_bus_clks = ARRAY_SIZE(dsi_sdm845_bus_clk_names),
>   	.io_start = {
> -		{ 0xae94000, 0xae96000 },
> +		{ 0xae94000, 0xae96000, 0 },
>   	},
> -	.num_dsi = 2,
>   };
>   
>   static const struct regulator_bulk_data sc7180_dsi_regulators[] = {
> @@ -226,9 +216,8 @@ static const struct msm_dsi_config sc7180_dsi_cfg = {
>   	.bus_clk_names = dsi_sc7180_bus_clk_names,
>   	.num_bus_clks = ARRAY_SIZE(dsi_sc7180_bus_clk_names),
>   	.io_start = {
> -		{ 0xae94000 },
> +		{ 0xae94000, 0 },
>   	},
> -	.num_dsi = 1,
>   };
>   
>   static const char * const dsi_sc7280_bus_clk_names[] = {
> @@ -246,9 +235,8 @@ static const struct msm_dsi_config sc7280_dsi_cfg = {
>   	.bus_clk_names = dsi_sc7280_bus_clk_names,
>   	.num_bus_clks = ARRAY_SIZE(dsi_sc7280_bus_clk_names),
>   	.io_start = {
> -		{ 0xae94000, 0xae96000 },
> +		{ 0xae94000, 0xae96000, 0 },
>   	},
> -	.num_dsi = 2,
>   };
>   
>   static const char * const dsi_qcm2290_bus_clk_names[] = {
> @@ -266,9 +254,8 @@ static const struct msm_dsi_config qcm2290_dsi_cfg = {
>   	.bus_clk_names = dsi_qcm2290_bus_clk_names,
>   	.num_bus_clks = ARRAY_SIZE(dsi_qcm2290_bus_clk_names),
>   	.io_start = {
> -		{ 0x5e94000 },
> +		{ 0x5e94000, 0 },
>   	},
> -	.num_dsi = 1,
>   };
>   
>   static const struct msm_dsi_host_cfg_ops msm_dsi_v2_host_ops = {
> diff --git a/drivers/gpu/drm/msm/dsi/dsi_cfg.h b/drivers/gpu/drm/msm/dsi/dsi_cfg.h
> index df9f09876ccb..03493cc6b772 100644
> --- a/drivers/gpu/drm/msm/dsi/dsi_cfg.h
> +++ b/drivers/gpu/drm/msm/dsi/dsi_cfg.h
> @@ -41,8 +41,8 @@ struct msm_dsi_config {
>   	int num_regulators;
>   	const char * const *bus_clk_names;
>   	const int num_bus_clks;
> -	const resource_size_t io_start[VARIANTS_MAX][DSI_MAX];
> -	const int num_dsi;
> +	/* Allow + 1 entry for the zero-terminator */
> +	const resource_size_t io_start[VARIANTS_MAX][DSI_MAX + 1];
>   };
>   
>   struct msm_dsi_host_cfg_ops {
> diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
> index 22ba8726b0ea..f5092b4d0757 100644
> --- a/drivers/gpu/drm/msm/dsi/dsi_host.c
> +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
> @@ -1868,7 +1868,7 @@ static int dsi_host_get_id(struct msm_dsi_host *msm_host)
>   	if (!res)
>   		return -EINVAL;
>   
> -	for (i = 0; i < cfg->num_dsi; i++) {
> +	for (i = 0; cfg->io_start[0][i]; i++) {
>   		if (cfg->io_start[0][i] == res->start)
>   			return i;
>   	}

I think we have the easier way to do this: always loop towards DSI_MAX. 
Empty cells will contain the value of 0 which can not match against 
valid starting address.

Also please shift this patch to the first place, it will be logical to 
add VARIANT_MAX after removing num_dsi.

-- 
With best wishes
Dmitry


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 04/10] drm/msm/dsi: dsi_host: Fix DSI index detection when version clash occurs
  2023-02-11 11:51 ` [PATCH 04/10] drm/msm/dsi: dsi_host: Fix DSI index detection when version clash occurs Konrad Dybcio
@ 2023-02-11 13:26   ` Dmitry Baryshkov
  2023-02-13  9:19     ` Konrad Dybcio
  0 siblings, 1 reply; 22+ messages in thread
From: Dmitry Baryshkov @ 2023-02-11 13:26 UTC (permalink / raw)
  To: Konrad Dybcio, linux-arm-msm, andersson, agross, krzysztof.kozlowski
  Cc: marijn.suijten, Rob Clark, Abhinav Kumar, Sean Paul,
	David Airlie, Daniel Vetter, Neil Armstrong, Vinod Koul,
	Douglas Anderson, Loic Poulain, Vladimir Lypak, Archit Taneja,
	dri-devel, freedreno, linux-kernel

On 11/02/2023 13:51, Konrad Dybcio wrote:
> Now that msm_dsi_config is ready to accept multiple sets of registers
> (where array[n][idx] holds the base registers of DSI(idx) for the nth
> entry), loop through all available configs to resolve hw version
> clashes.
> 
> Fixes: 32280d66fd44 ("drm/msm/dsi: Don't get DSI index from DT")

Do we really want to backport this patch (and other patches from this 
series to older kernels?)

> Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
> ---
>   drivers/gpu/drm/msm/dsi/dsi_cfg.h  |  1 +
>   drivers/gpu/drm/msm/dsi/dsi_host.c | 12 +++++++-----
>   2 files changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/dsi/dsi_cfg.h b/drivers/gpu/drm/msm/dsi/dsi_cfg.h
> index 03493cc6b772..4a47705234bd 100644
> --- a/drivers/gpu/drm/msm/dsi/dsi_cfg.h
> +++ b/drivers/gpu/drm/msm/dsi/dsi_cfg.h
> @@ -43,6 +43,7 @@ struct msm_dsi_config {
>   	const int num_bus_clks;
>   	/* Allow + 1 entry for the zero-terminator */
>   	const resource_size_t io_start[VARIANTS_MAX][DSI_MAX + 1];
> +	const int num_variants;
>   };
>   
>   struct msm_dsi_host_cfg_ops {
> diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
> index f5092b4d0757..8dfa69bcff77 100644
> --- a/drivers/gpu/drm/msm/dsi/dsi_host.c
> +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
> @@ -1862,16 +1862,18 @@ 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;
> +	int i, j, num_variants;
>   
>   	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dsi_ctrl");
>   	if (!res)
>   		return -EINVAL;
>   
> -	for (i = 0; cfg->io_start[0][i]; i++) {
> -		if (cfg->io_start[0][i] == res->start)
> -			return i;
> -	}
> +	num_variants = cfg->num_variants ? cfg->num_variants : 1;
> +
> +	for (i = 0; i < num_variants; i++)
> +		for (j = 0; cfg->io_start[i][j]; j++)
> +			if (cfg->io_start[i][j] == res->start)
> +				return j;
>   
>   	return -EINVAL;
>   }

Please squash this together with the patch 'drm/msm/dsi: Turn 
msm_dsi_config::io_start into a 2d array'.

-- 
With best wishes
Dmitry


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 05/10] drm/msm/dsi: dsi_cfg: Deduplicate identical structs
  2023-02-11 11:51 ` [PATCH 05/10] drm/msm/dsi: dsi_cfg: Deduplicate identical structs Konrad Dybcio
@ 2023-02-11 15:52   ` Dmitry Baryshkov
  2023-02-13  9:20     ` Konrad Dybcio
  0 siblings, 1 reply; 22+ messages in thread
From: Dmitry Baryshkov @ 2023-02-11 15:52 UTC (permalink / raw)
  To: Konrad Dybcio, linux-arm-msm, andersson, agross, krzysztof.kozlowski
  Cc: marijn.suijten, Rob Clark, Abhinav Kumar, Sean Paul,
	David Airlie, Daniel Vetter, Douglas Anderson, Neil Armstrong,
	Loic Poulain, AngeloGioacchino Del Regno, Archit Taneja,
	Harigovindan P, Rajeev Nandan, Stephen Boyd, dri-devel,
	freedreno, linux-kernel

On 11/02/2023 13:51, Konrad Dybcio wrote:
> Some structs were defined multiple times for no apparent reason.
> Deduplicate them.
> 
> Fixes: 3f3c8aff1f8f ("drm/msm/dsi: Add configuration for 8x76")
> Fixes: 3a3ff88a0fc1 ("drm/msm/dsi: Add 8x96 info in dsi_cfg")
> Fixes: 6125bd327e16 ("drm/msm: add DSI support for sc7180")
> Fixes: 65c391b31994 ("drm/msm/dsi: Add DSI support for SC7280")

I think we should drop these Fixes headers. There are no issues to be 
fixed in those versions. The code was inefficient and resulted in 
duplication of data, but that's all.

Other than that:

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

> Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
> ---
>   drivers/gpu/drm/msm/dsi/dsi_cfg.c | 77 +++++++++++--------------------
>   1 file changed, 26 insertions(+), 51 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/dsi/dsi_cfg.c b/drivers/gpu/drm/msm/dsi/dsi_cfg.c
> index 5f62c563bd1c..860681bfc084 100644
> --- a/drivers/gpu/drm/msm/dsi/dsi_cfg.c
> +++ b/drivers/gpu/drm/msm/dsi/dsi_cfg.c
> @@ -47,41 +47,32 @@ static const struct msm_dsi_config msm8974_apq8084_dsi_cfg = {
>   	},
>   };
>   
> -static const char * const dsi_8916_bus_clk_names[] = {
> +static const char * const dsi_v1_3_1_clk_names[] = {
>   	"mdp_core", "iface", "bus",
>   };
>   
> -static const struct regulator_bulk_data msm8916_dsi_regulators[] = {
> +static const struct regulator_bulk_data dsi_v1_3_1_regulators[] = {
>   	{ .supply = "vdda", .init_load_uA = 100000 },	/* 1.2 V */
>   	{ .supply = "vddio", .init_load_uA = 100000 },	/* 1.8 V */
>   };
>   
>   static const struct msm_dsi_config msm8916_dsi_cfg = {
>   	.io_offset = DSI_6G_REG_SHIFT,
> -	.regulator_data = msm8916_dsi_regulators,
> -	.num_regulators = ARRAY_SIZE(msm8916_dsi_regulators),
> -	.bus_clk_names = dsi_8916_bus_clk_names,
> -	.num_bus_clks = ARRAY_SIZE(dsi_8916_bus_clk_names),
> +	.regulator_data = dsi_v1_3_1_regulators,
> +	.num_regulators = ARRAY_SIZE(dsi_v1_3_1_regulators),
> +	.bus_clk_names = dsi_v1_3_1_clk_names,
> +	.num_bus_clks = ARRAY_SIZE(dsi_v1_3_1_clk_names),
>   	.io_start = {
>   		{ 0x1a98000, 0 },
>   	},
>   };
>   
> -static const char * const dsi_8976_bus_clk_names[] = {
> -	"mdp_core", "iface", "bus",
> -};
> -
> -static const struct regulator_bulk_data msm8976_dsi_regulators[] = {
> -	{ .supply = "vdda", .init_load_uA = 100000 },	/* 1.2 V */
> -	{ .supply = "vddio", .init_load_uA = 100000 },	/* 1.8 V */
> -};
> -
>   static const struct msm_dsi_config msm8976_dsi_cfg = {
>   	.io_offset = DSI_6G_REG_SHIFT,
> -	.regulator_data = msm8976_dsi_regulators,
> -	.num_regulators = ARRAY_SIZE(msm8976_dsi_regulators),
> -	.bus_clk_names = dsi_8976_bus_clk_names,
> -	.num_bus_clks = ARRAY_SIZE(dsi_8976_bus_clk_names),
> +	.regulator_data = dsi_v1_3_1_regulators,
> +	.num_regulators = ARRAY_SIZE(dsi_v1_3_1_regulators),
> +	.bus_clk_names = dsi_v1_3_1_clk_names,
> +	.num_bus_clks = ARRAY_SIZE(dsi_v1_3_1_clk_names),
>   	.io_start = {
>   		{ 0x1a94000, 0x1a96000, 0 },
>   	},
> @@ -107,10 +98,6 @@ static const struct msm_dsi_config msm8994_dsi_cfg = {
>   	},
>   };
>   
> -static const char * const dsi_8996_bus_clk_names[] = {
> -	"mdp_core", "iface", "bus", "core_mmss",
> -};
> -
>   static const struct regulator_bulk_data msm8996_dsi_regulators[] = {
>   	{ .supply = "vdda", .init_load_uA = 18160 },	/* 1.25 V */
>   	{ .supply = "vcca", .init_load_uA = 17000 },	/* 0.925 V */
> @@ -121,8 +108,8 @@ static const struct msm_dsi_config msm8996_dsi_cfg = {
>   	.io_offset = DSI_6G_REG_SHIFT,
>   	.regulator_data = msm8996_dsi_regulators,
>   	.num_regulators = ARRAY_SIZE(msm8996_dsi_regulators),
> -	.bus_clk_names = dsi_8996_bus_clk_names,
> -	.num_bus_clks = ARRAY_SIZE(dsi_8996_bus_clk_names),
> +	.bus_clk_names = dsi_6g_bus_clk_names,
> +	.num_bus_clks = ARRAY_SIZE(dsi_6g_bus_clk_names),
>   	.io_start = {
>   		{ 0x994000, 0x996000, 0 },
>   	},
> @@ -167,24 +154,20 @@ static const struct msm_dsi_config sdm660_dsi_cfg = {
>   	},
>   };
>   
> -static const char * const dsi_sdm845_bus_clk_names[] = {
> +static const char * const dsi_v2_4_clk_names[] = {
>   	"iface", "bus",
>   };
>   
> -static const char * const dsi_sc7180_bus_clk_names[] = {
> -	"iface", "bus",
> -};
> -
> -static const struct regulator_bulk_data sdm845_dsi_regulators[] = {
> +static const struct regulator_bulk_data dsi_v2_4_regulators[] = {
>   	{ .supply = "vdda", .init_load_uA = 21800 },	/* 1.2 V */
>   };
>   
>   static const struct msm_dsi_config sdm845_dsi_cfg = {
>   	.io_offset = DSI_6G_REG_SHIFT,
> -	.regulator_data = sdm845_dsi_regulators,
> -	.num_regulators = ARRAY_SIZE(sdm845_dsi_regulators),
> -	.bus_clk_names = dsi_sdm845_bus_clk_names,
> -	.num_bus_clks = ARRAY_SIZE(dsi_sdm845_bus_clk_names),
> +	.regulator_data = dsi_v2_4_regulators,
> +	.num_regulators = ARRAY_SIZE(dsi_v2_4_regulators),
> +	.bus_clk_names = dsi_v2_4_clk_names,
> +	.num_bus_clks = ARRAY_SIZE(dsi_v2_4_clk_names),
>   	.io_start = {
>   		{ 0xae94000, 0xae96000, 0 },
>   	},
> @@ -198,32 +181,24 @@ static const struct msm_dsi_config sm8550_dsi_cfg = {
>   	.io_offset = DSI_6G_REG_SHIFT,
>   	.regulator_data = sm8550_dsi_regulators,
>   	.num_regulators = ARRAY_SIZE(sm8550_dsi_regulators),
> -	.bus_clk_names = dsi_sdm845_bus_clk_names,
> -	.num_bus_clks = ARRAY_SIZE(dsi_sdm845_bus_clk_names),
> +	.bus_clk_names = dsi_v2_4_clk_names,
> +	.num_bus_clks = ARRAY_SIZE(dsi_v2_4_clk_names),
>   	.io_start = {
>   		{ 0xae94000, 0xae96000, 0 },
>   	},
>   };
>   
> -static const struct regulator_bulk_data sc7180_dsi_regulators[] = {
> -	{ .supply = "vdda", .init_load_uA = 21800 },	/* 1.2 V */
> -};
> -
>   static const struct msm_dsi_config sc7180_dsi_cfg = {
>   	.io_offset = DSI_6G_REG_SHIFT,
> -	.regulator_data = sc7180_dsi_regulators,
> -	.num_regulators = ARRAY_SIZE(sc7180_dsi_regulators),
> -	.bus_clk_names = dsi_sc7180_bus_clk_names,
> -	.num_bus_clks = ARRAY_SIZE(dsi_sc7180_bus_clk_names),
> +	.regulator_data = dsi_v2_4_regulators,
> +	.num_regulators = ARRAY_SIZE(dsi_v2_4_regulators),
> +	.bus_clk_names = dsi_v2_4_clk_names,
> +	.num_bus_clks = ARRAY_SIZE(dsi_v2_4_clk_names),
>   	.io_start = {
>   		{ 0xae94000, 0 },
>   	},
>   };
>   
> -static const char * const dsi_sc7280_bus_clk_names[] = {
> -	"iface", "bus",
> -};
> -
>   static const struct regulator_bulk_data sc7280_dsi_regulators[] = {
>   	{ .supply = "vdda", .init_load_uA = 8350 },	/* 1.2 V */
>   };
> @@ -232,8 +207,8 @@ static const struct msm_dsi_config sc7280_dsi_cfg = {
>   	.io_offset = DSI_6G_REG_SHIFT,
>   	.regulator_data = sc7280_dsi_regulators,
>   	.num_regulators = ARRAY_SIZE(sc7280_dsi_regulators),
> -	.bus_clk_names = dsi_sc7280_bus_clk_names,
> -	.num_bus_clks = ARRAY_SIZE(dsi_sc7280_bus_clk_names),
> +	.bus_clk_names = dsi_v2_4_clk_names,
> +	.num_bus_clks = ARRAY_SIZE(dsi_v2_4_clk_names),
>   	.io_start = {
>   		{ 0xae94000, 0xae96000, 0 },
>   	},

-- 
With best wishes
Dmitry


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 06/10] drm/msm/dsi: dsi_cfg: Merge SC7180 config into SDM845
  2023-02-11 11:51 ` [PATCH 06/10] drm/msm/dsi: dsi_cfg: Merge SC7180 config into SDM845 Konrad Dybcio
@ 2023-02-11 15:52   ` Dmitry Baryshkov
  2023-02-13  9:20     ` Konrad Dybcio
  0 siblings, 1 reply; 22+ messages in thread
From: Dmitry Baryshkov @ 2023-02-11 15:52 UTC (permalink / raw)
  To: Konrad Dybcio, linux-arm-msm, andersson, agross, krzysztof.kozlowski
  Cc: marijn.suijten, Rob Clark, Abhinav Kumar, Sean Paul,
	David Airlie, Daniel Vetter, Douglas Anderson, Loic Poulain,
	Neil Armstrong, Harigovindan P, dri-devel, freedreno,
	linux-kernel

On 11/02/2023 13:51, Konrad Dybcio wrote:
> The configs are identical, other than the number of *maximum* DSI
> hosts allowed. This isn't an issue, unless somebody deliberately
> tries to access the inexistent host by adding a dt node for it.
> 
> Remove the SC7180 struct and point the hw revision match to the
> SDM845's one. On a note, this could have been done back when
> 7180 support was introduced.
> 
> Fixes: 6125bd327e16 ("drm/msm: add DSI support for sc7180")

Same comment regarding Fixes

Other than that:

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

> Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
> ---
>   drivers/gpu/drm/msm/dsi/dsi_cfg.c | 15 ++-------------
>   1 file changed, 2 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/dsi/dsi_cfg.c b/drivers/gpu/drm/msm/dsi/dsi_cfg.c
> index 860681bfc084..142a0f1e2576 100644
> --- a/drivers/gpu/drm/msm/dsi/dsi_cfg.c
> +++ b/drivers/gpu/drm/msm/dsi/dsi_cfg.c
> @@ -169,7 +169,7 @@ static const struct msm_dsi_config sdm845_dsi_cfg = {
>   	.bus_clk_names = dsi_v2_4_clk_names,
>   	.num_bus_clks = ARRAY_SIZE(dsi_v2_4_clk_names),
>   	.io_start = {
> -		{ 0xae94000, 0xae96000, 0 },
> +		{ 0xae94000, 0xae96000, 0 }, /* SDM845 / SDM670 / SC7180 */
>   	},
>   };
>   
> @@ -188,17 +188,6 @@ static const struct msm_dsi_config sm8550_dsi_cfg = {
>   	},
>   };
>   
> -static const struct msm_dsi_config sc7180_dsi_cfg = {
> -	.io_offset = DSI_6G_REG_SHIFT,
> -	.regulator_data = dsi_v2_4_regulators,
> -	.num_regulators = ARRAY_SIZE(dsi_v2_4_regulators),
> -	.bus_clk_names = dsi_v2_4_clk_names,
> -	.num_bus_clks = ARRAY_SIZE(dsi_v2_4_clk_names),
> -	.io_start = {
> -		{ 0xae94000, 0 },
> -	},
> -};
> -
>   static const struct regulator_bulk_data sc7280_dsi_regulators[] = {
>   	{ .supply = "vdda", .init_load_uA = 8350 },	/* 1.2 V */
>   };
> @@ -299,7 +288,7 @@ static const struct msm_dsi_cfg_handler dsi_cfg_handlers[] = {
>   	{MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V2_4_0,
>   		&sdm845_dsi_cfg, &msm_dsi_6g_v2_host_ops},
>   	{MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V2_4_1,
> -		&sc7180_dsi_cfg, &msm_dsi_6g_v2_host_ops},
> +		&sdm845_dsi_cfg, &msm_dsi_6g_v2_host_ops},
>   	{MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V2_5_0,
>   		&sc7280_dsi_cfg, &msm_dsi_6g_v2_host_ops},
>   	{MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V2_6_0,

-- 
With best wishes
Dmitry


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 08/10] drm/msm/dsi: Remove custom DSI config handling
  2023-02-11 11:51 ` [PATCH 08/10] drm/msm/dsi: Remove custom DSI config handling Konrad Dybcio
@ 2023-02-11 15:53   ` Dmitry Baryshkov
  0 siblings, 0 replies; 22+ messages in thread
From: Dmitry Baryshkov @ 2023-02-11 15:53 UTC (permalink / raw)
  To: Konrad Dybcio, linux-arm-msm, andersson, agross, krzysztof.kozlowski
  Cc: marijn.suijten, Rob Clark, Abhinav Kumar, Sean Paul,
	David Airlie, Daniel Vetter, Johan Hovold, Loic Poulain,
	Kuogee Hsieh, Vinod Koul, Douglas Anderson, Vladimir Lypak,
	dri-devel, freedreno, linux-kernel

On 11/02/2023 13:51, Konrad Dybcio wrote:
> Now that the only user is handled by common code, remove the option to
> specify custom handlers through match data.
> 
> This is effectively a revert of commit:
> 5ae15e76271 ("drm/msm/dsi: Allow to specify dsi config as pdata")
> 
> Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

> ---
>   drivers/gpu/drm/msm/dsi/dsi.c      | 4 ++--
>   drivers/gpu/drm/msm/dsi/dsi_host.c | 4 ----
>   2 files changed, 2 insertions(+), 6 deletions(-)
-- 
With best wishes
Dmitry


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 02/10] drm/msm/dsi: Turn msm_dsi_config::io_start into a 2d array
  2023-02-11 13:17   ` Dmitry Baryshkov
@ 2023-02-13  9:16     ` Konrad Dybcio
  0 siblings, 0 replies; 22+ messages in thread
From: Konrad Dybcio @ 2023-02-13  9:16 UTC (permalink / raw)
  To: Dmitry Baryshkov, linux-arm-msm, andersson, agross, krzysztof.kozlowski
  Cc: marijn.suijten, Rob Clark, Abhinav Kumar, Sean Paul,
	David Airlie, Daniel Vetter, Douglas Anderson, Neil Armstrong,
	Loic Poulain, Vinod Koul, Vladimir Lypak, dri-devel, freedreno,
	linux-kernel



On 11.02.2023 14:17, Dmitry Baryshkov wrote:
> On 11/02/2023 13:51, Konrad Dybcio wrote:
>> Currently, we allow for MAX_DSI entries in io_start to facilitate for
>> MAX_DSI number of DSI hosts at different addresses. The configuration
>> is matched against the DSI CTRL hardware revision read back from the
>> component. We need a way to resolve situations where multiple SoCs
>> with different register maps may use the same version of DSI CTRL. In
>> preparation to do so, make msm_dsi_config a 2d array where each entry
>> represents a set of configurations adequate for a given SoC.
>>
>> This is totally fine to do, as the only differentiating factors
>> between same-version-different-SoCs configurations are the number of
>> DSI hosts (1 or 2, at least as of today) and the set of registers.
> 
> s/set of registers/starting address/ ?
Well, *technically* they both are accurate, as having the same DSI
HW at the same base address implies the entire DSI host address space
is the same.. But I can clean this up.

Konrad
> 
>> The regulator setup is the same, because the DSI hardware is the same,
>> regardless of the SoC it was implemented in.
>>
>> Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
>> ---
>>   drivers/gpu/drm/msm/dsi/dsi_cfg.c  | 52 ++++++++++++++++++++++--------
>>   drivers/gpu/drm/msm/dsi/dsi_cfg.h  |  5 ++-
>>   drivers/gpu/drm/msm/dsi/dsi_host.c |  2 +-
>>   3 files changed, 44 insertions(+), 15 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/msm/dsi/dsi_cfg.c b/drivers/gpu/drm/msm/dsi/dsi_cfg.c
>> index 6d21f0b33411..068d45b3a8f0 100644
>> --- a/drivers/gpu/drm/msm/dsi/dsi_cfg.c
>> +++ b/drivers/gpu/drm/msm/dsi/dsi_cfg.c
>> @@ -21,7 +21,9 @@ static const struct msm_dsi_config apq8064_dsi_cfg = {
>>       .num_regulators = ARRAY_SIZE(apq8064_dsi_regulators),
>>       .bus_clk_names = dsi_v2_bus_clk_names,
>>       .num_bus_clks = ARRAY_SIZE(dsi_v2_bus_clk_names),
>> -    .io_start = { 0x4700000, 0x5800000 },
>> +    .io_start = {
>> +        { 0x4700000, 0x5800000 },
>> +    },
>>       .num_dsi = 2,
>>   };
>>   @@ -41,7 +43,9 @@ static const struct msm_dsi_config msm8974_apq8084_dsi_cfg = {
>>       .num_regulators = ARRAY_SIZE(msm8974_apq8084_regulators),
>>       .bus_clk_names = dsi_6g_bus_clk_names,
>>       .num_bus_clks = ARRAY_SIZE(dsi_6g_bus_clk_names),
>> -    .io_start = { 0xfd922800, 0xfd922b00 },
>> +    .io_start = {
>> +        { 0xfd922800, 0xfd922b00 },
>> +    },
>>       .num_dsi = 2,
>>   };
>>   @@ -60,7 +64,9 @@ static const struct msm_dsi_config msm8916_dsi_cfg = {
>>       .num_regulators = ARRAY_SIZE(msm8916_dsi_regulators),
>>       .bus_clk_names = dsi_8916_bus_clk_names,
>>       .num_bus_clks = ARRAY_SIZE(dsi_8916_bus_clk_names),
>> -    .io_start = { 0x1a98000 },
>> +    .io_start = {
>> +        { 0x1a98000 },
>> +    },
>>       .num_dsi = 1,
>>   };
>>   @@ -79,7 +85,9 @@ static const struct msm_dsi_config msm8976_dsi_cfg = {
>>       .num_regulators = ARRAY_SIZE(msm8976_dsi_regulators),
>>       .bus_clk_names = dsi_8976_bus_clk_names,
>>       .num_bus_clks = ARRAY_SIZE(dsi_8976_bus_clk_names),
>> -    .io_start = { 0x1a94000, 0x1a96000 },
>> +    .io_start = {
>> +        { 0x1a94000, 0x1a96000 },
>> +    },
>>       .num_dsi = 2,
>>   };
>>   @@ -98,7 +106,9 @@ static const struct msm_dsi_config msm8994_dsi_cfg = {
>>       .num_regulators = ARRAY_SIZE(msm8994_dsi_regulators),
>>       .bus_clk_names = dsi_6g_bus_clk_names,
>>       .num_bus_clks = ARRAY_SIZE(dsi_6g_bus_clk_names),
>> -    .io_start = { 0xfd998000, 0xfd9a0000 },
>> +    .io_start = {
>> +        { 0xfd998000, 0xfd9a0000 },
>> +    },
>>       .num_dsi = 2,
>>   };
>>   @@ -118,7 +128,9 @@ static const struct msm_dsi_config msm8996_dsi_cfg = {
>>       .num_regulators = ARRAY_SIZE(msm8996_dsi_regulators),
>>       .bus_clk_names = dsi_8996_bus_clk_names,
>>       .num_bus_clks = ARRAY_SIZE(dsi_8996_bus_clk_names),
>> -    .io_start = { 0x994000, 0x996000 },
>> +    .io_start = {
>> +        { 0x994000, 0x996000 },
>> +    },
>>       .num_dsi = 2,
>>   };
>>   @@ -137,7 +149,9 @@ static const struct msm_dsi_config msm8998_dsi_cfg = {
>>       .num_regulators = ARRAY_SIZE(msm8998_dsi_regulators),
>>       .bus_clk_names = dsi_msm8998_bus_clk_names,
>>       .num_bus_clks = ARRAY_SIZE(dsi_msm8998_bus_clk_names),
>> -    .io_start = { 0xc994000, 0xc996000 },
>> +    .io_start = {
>> +        { 0xc994000, 0xc996000 },
>> +    },
>>       .num_dsi = 2,
>>   };
>>   @@ -155,7 +169,9 @@ static const struct msm_dsi_config sdm660_dsi_cfg = {
>>       .num_regulators = ARRAY_SIZE(sdm660_dsi_regulators),
>>       .bus_clk_names = dsi_sdm660_bus_clk_names,
>>       .num_bus_clks = ARRAY_SIZE(dsi_sdm660_bus_clk_names),
>> -    .io_start = { 0xc994000, 0xc996000 },
>> +    .io_start = {
>> +        { 0xc994000, 0xc996000 },
>> +    },
>>       .num_dsi = 2,
>>   };
>>   @@ -177,7 +193,9 @@ static const struct msm_dsi_config sdm845_dsi_cfg = {
>>       .num_regulators = ARRAY_SIZE(sdm845_dsi_regulators),
>>       .bus_clk_names = dsi_sdm845_bus_clk_names,
>>       .num_bus_clks = ARRAY_SIZE(dsi_sdm845_bus_clk_names),
>> -    .io_start = { 0xae94000, 0xae96000 },
>> +    .io_start = {
>> +        { 0xae94000, 0xae96000 },
>> +    },
>>       .num_dsi = 2,
>>   };
>>   @@ -191,7 +209,9 @@ static const struct msm_dsi_config sm8550_dsi_cfg = {
>>       .num_regulators = ARRAY_SIZE(sm8550_dsi_regulators),
>>       .bus_clk_names = dsi_sdm845_bus_clk_names,
>>       .num_bus_clks = ARRAY_SIZE(dsi_sdm845_bus_clk_names),
>> -    .io_start = { 0xae94000, 0xae96000 },
>> +    .io_start = {
>> +        { 0xae94000, 0xae96000 },
>> +    },
>>       .num_dsi = 2,
>>   };
>>   @@ -205,7 +225,9 @@ static const struct msm_dsi_config sc7180_dsi_cfg = {
>>       .num_regulators = ARRAY_SIZE(sc7180_dsi_regulators),
>>       .bus_clk_names = dsi_sc7180_bus_clk_names,
>>       .num_bus_clks = ARRAY_SIZE(dsi_sc7180_bus_clk_names),
>> -    .io_start = { 0xae94000 },
>> +    .io_start = {
>> +        { 0xae94000 },
>> +    },
>>       .num_dsi = 1,
>>   };
>>   @@ -223,7 +245,9 @@ static const struct msm_dsi_config sc7280_dsi_cfg = {
>>       .num_regulators = ARRAY_SIZE(sc7280_dsi_regulators),
>>       .bus_clk_names = dsi_sc7280_bus_clk_names,
>>       .num_bus_clks = ARRAY_SIZE(dsi_sc7280_bus_clk_names),
>> -    .io_start = { 0xae94000, 0xae96000 },
>> +    .io_start = {
>> +        { 0xae94000, 0xae96000 },
>> +    },
>>       .num_dsi = 2,
>>   };
>>   @@ -241,7 +265,9 @@ static const struct msm_dsi_config qcm2290_dsi_cfg = {
>>       .num_regulators = ARRAY_SIZE(qcm2290_dsi_cfg_regulators),
>>       .bus_clk_names = dsi_qcm2290_bus_clk_names,
>>       .num_bus_clks = ARRAY_SIZE(dsi_qcm2290_bus_clk_names),
>> -    .io_start = { 0x5e94000 },
>> +    .io_start = {
>> +        { 0x5e94000 },
>> +    },
>>       .num_dsi = 1,
>>   };
>>   diff --git a/drivers/gpu/drm/msm/dsi/dsi_cfg.h b/drivers/gpu/drm/msm/dsi/dsi_cfg.h
>> index 44be4a88aa83..df9f09876ccb 100644
>> --- a/drivers/gpu/drm/msm/dsi/dsi_cfg.h
>> +++ b/drivers/gpu/drm/msm/dsi/dsi_cfg.h
>> @@ -32,13 +32,16 @@
>>     #define DSI_6G_REG_SHIFT    4
>>   +/* Maximum number of configurations matched against the same hw revision */
>> +#define VARIANTS_MAX            2
>> +
>>   struct msm_dsi_config {
>>       u32 io_offset;
>>       const struct regulator_bulk_data *regulator_data;
>>       int num_regulators;
>>       const char * const *bus_clk_names;
>>       const int num_bus_clks;
>> -    const resource_size_t io_start[DSI_MAX];
>> +    const resource_size_t io_start[VARIANTS_MAX][DSI_MAX];
>>       const int num_dsi;
>>   };
>>   diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
>> index 18fa30e1e858..22ba8726b0ea 100644
>> --- a/drivers/gpu/drm/msm/dsi/dsi_host.c
>> +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
>> @@ -1869,7 +1869,7 @@ static int dsi_host_get_id(struct msm_dsi_host *msm_host)
>>           return -EINVAL;
>>         for (i = 0; i < cfg->num_dsi; i++) {
>> -        if (cfg->io_start[i] == res->start)
>> +        if (cfg->io_start[0][i] == res->start)
>>               return i;
>>       }
>>   
> 

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 03/10] drm/msm/dsi: Zero-terminate msm_dsi_config::io_start
  2023-02-11 13:19   ` Dmitry Baryshkov
@ 2023-02-13  9:18     ` Konrad Dybcio
  2023-02-13 11:41       ` Dmitry Baryshkov
  0 siblings, 1 reply; 22+ messages in thread
From: Konrad Dybcio @ 2023-02-13  9:18 UTC (permalink / raw)
  To: Dmitry Baryshkov, linux-arm-msm, andersson, agross, krzysztof.kozlowski
  Cc: marijn.suijten, Rob Clark, Abhinav Kumar, Sean Paul,
	David Airlie, Daniel Vetter, Douglas Anderson, Loic Poulain,
	Neil Armstrong, Vinod Koul, Vladimir Lypak, dri-devel, freedreno,
	linux-kernel



On 11.02.2023 14:19, Dmitry Baryshkov wrote:
> On 11/02/2023 13:51, Konrad Dybcio wrote:
>> In preparation for supporting multiple sets of possible base registers,
>> Zero-terminate the array that contains them to remove the need of
>> specifying num_dsi for each set.
>>
>> Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
>> ---
>>   drivers/gpu/drm/msm/dsi/dsi_cfg.c  | 39 ++++++++++--------------------
>>   drivers/gpu/drm/msm/dsi/dsi_cfg.h  |  4 +--
>>   drivers/gpu/drm/msm/dsi/dsi_host.c |  2 +-
>>   3 files changed, 16 insertions(+), 29 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/msm/dsi/dsi_cfg.c b/drivers/gpu/drm/msm/dsi/dsi_cfg.c
>> index 068d45b3a8f0..5f62c563bd1c 100644
>> --- a/drivers/gpu/drm/msm/dsi/dsi_cfg.c
>> +++ b/drivers/gpu/drm/msm/dsi/dsi_cfg.c
>> @@ -22,9 +22,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 },
>> +        { 0x4700000, 0x5800000, 0 },
>>       },
>> -    .num_dsi = 2,
>>   };
>>     static const char * const dsi_6g_bus_clk_names[] = {
>> @@ -44,9 +43,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 },
>> +        { 0xfd922800, 0xfd922b00, 0 },
>>       },
>> -    .num_dsi = 2,
>>   };
>>     static const char * const dsi_8916_bus_clk_names[] = {
>> @@ -65,9 +63,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 },
>> +        { 0x1a98000, 0 },
>>       },
>> -    .num_dsi = 1,
>>   };
>>     static const char * const dsi_8976_bus_clk_names[] = {
>> @@ -86,9 +83,8 @@ static const struct msm_dsi_config msm8976_dsi_cfg = {
>>       .bus_clk_names = dsi_8976_bus_clk_names,
>>       .num_bus_clks = ARRAY_SIZE(dsi_8976_bus_clk_names),
>>       .io_start = {
>> -        { 0x1a94000, 0x1a96000 },
>> +        { 0x1a94000, 0x1a96000, 0 },
>>       },
>> -    .num_dsi = 2,
>>   };
>>     static const struct regulator_bulk_data msm8994_dsi_regulators[] = {
>> @@ -107,9 +103,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 },
>> +        { 0xfd998000, 0xfd9a0000, 0 },
>>       },
>> -    .num_dsi = 2,
>>   };
>>     static const char * const dsi_8996_bus_clk_names[] = {
>> @@ -129,9 +124,8 @@ static const struct msm_dsi_config msm8996_dsi_cfg = {
>>       .bus_clk_names = dsi_8996_bus_clk_names,
>>       .num_bus_clks = ARRAY_SIZE(dsi_8996_bus_clk_names),
>>       .io_start = {
>> -        { 0x994000, 0x996000 },
>> +        { 0x994000, 0x996000, 0 },
>>       },
>> -    .num_dsi = 2,
>>   };
>>     static const char * const dsi_msm8998_bus_clk_names[] = {
>> @@ -150,9 +144,8 @@ static const struct msm_dsi_config msm8998_dsi_cfg = {
>>       .bus_clk_names = dsi_msm8998_bus_clk_names,
>>       .num_bus_clks = ARRAY_SIZE(dsi_msm8998_bus_clk_names),
>>       .io_start = {
>> -        { 0xc994000, 0xc996000 },
>> +        { 0xc994000, 0xc996000, 0 },
>>       },
>> -    .num_dsi = 2,
>>   };
>>     static const char * const dsi_sdm660_bus_clk_names[] = {
>> @@ -170,9 +163,8 @@ static const struct msm_dsi_config sdm660_dsi_cfg = {
>>       .bus_clk_names = dsi_sdm660_bus_clk_names,
>>       .num_bus_clks = ARRAY_SIZE(dsi_sdm660_bus_clk_names),
>>       .io_start = {
>> -        { 0xc994000, 0xc996000 },
>> +        { 0xc994000, 0xc996000, 0 },
>>       },
>> -    .num_dsi = 2,
>>   };
>>     static const char * const dsi_sdm845_bus_clk_names[] = {
>> @@ -194,9 +186,8 @@ static const struct msm_dsi_config sdm845_dsi_cfg = {
>>       .bus_clk_names = dsi_sdm845_bus_clk_names,
>>       .num_bus_clks = ARRAY_SIZE(dsi_sdm845_bus_clk_names),
>>       .io_start = {
>> -        { 0xae94000, 0xae96000 },
>> +        { 0xae94000, 0xae96000, 0 },
>>       },
>> -    .num_dsi = 2,
>>   };
>>     static const struct regulator_bulk_data sm8550_dsi_regulators[] = {
>> @@ -210,9 +201,8 @@ static const struct msm_dsi_config sm8550_dsi_cfg = {
>>       .bus_clk_names = dsi_sdm845_bus_clk_names,
>>       .num_bus_clks = ARRAY_SIZE(dsi_sdm845_bus_clk_names),
>>       .io_start = {
>> -        { 0xae94000, 0xae96000 },
>> +        { 0xae94000, 0xae96000, 0 },
>>       },
>> -    .num_dsi = 2,
>>   };
>>     static const struct regulator_bulk_data sc7180_dsi_regulators[] = {
>> @@ -226,9 +216,8 @@ static const struct msm_dsi_config sc7180_dsi_cfg = {
>>       .bus_clk_names = dsi_sc7180_bus_clk_names,
>>       .num_bus_clks = ARRAY_SIZE(dsi_sc7180_bus_clk_names),
>>       .io_start = {
>> -        { 0xae94000 },
>> +        { 0xae94000, 0 },
>>       },
>> -    .num_dsi = 1,
>>   };
>>     static const char * const dsi_sc7280_bus_clk_names[] = {
>> @@ -246,9 +235,8 @@ static const struct msm_dsi_config sc7280_dsi_cfg = {
>>       .bus_clk_names = dsi_sc7280_bus_clk_names,
>>       .num_bus_clks = ARRAY_SIZE(dsi_sc7280_bus_clk_names),
>>       .io_start = {
>> -        { 0xae94000, 0xae96000 },
>> +        { 0xae94000, 0xae96000, 0 },
>>       },
>> -    .num_dsi = 2,
>>   };
>>     static const char * const dsi_qcm2290_bus_clk_names[] = {
>> @@ -266,9 +254,8 @@ static const struct msm_dsi_config qcm2290_dsi_cfg = {
>>       .bus_clk_names = dsi_qcm2290_bus_clk_names,
>>       .num_bus_clks = ARRAY_SIZE(dsi_qcm2290_bus_clk_names),
>>       .io_start = {
>> -        { 0x5e94000 },
>> +        { 0x5e94000, 0 },
>>       },
>> -    .num_dsi = 1,
>>   };
>>     static const struct msm_dsi_host_cfg_ops msm_dsi_v2_host_ops = {
>> diff --git a/drivers/gpu/drm/msm/dsi/dsi_cfg.h b/drivers/gpu/drm/msm/dsi/dsi_cfg.h
>> index df9f09876ccb..03493cc6b772 100644
>> --- a/drivers/gpu/drm/msm/dsi/dsi_cfg.h
>> +++ b/drivers/gpu/drm/msm/dsi/dsi_cfg.h
>> @@ -41,8 +41,8 @@ struct msm_dsi_config {
>>       int num_regulators;
>>       const char * const *bus_clk_names;
>>       const int num_bus_clks;
>> -    const resource_size_t io_start[VARIANTS_MAX][DSI_MAX];
>> -    const int num_dsi;
>> +    /* Allow + 1 entry for the zero-terminator */
>> +    const resource_size_t io_start[VARIANTS_MAX][DSI_MAX + 1];
>>   };
>>     struct msm_dsi_host_cfg_ops {
>> diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
>> index 22ba8726b0ea..f5092b4d0757 100644
>> --- a/drivers/gpu/drm/msm/dsi/dsi_host.c
>> +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
>> @@ -1868,7 +1868,7 @@ static int dsi_host_get_id(struct msm_dsi_host *msm_host)
>>       if (!res)
>>           return -EINVAL;
>>   -    for (i = 0; i < cfg->num_dsi; i++) {
>> +    for (i = 0; cfg->io_start[0][i]; i++) {
>>           if (cfg->io_start[0][i] == res->start)
>>               return i;
>>       }
> 
> I think we have the easier way to do this: always loop towards DSI_MAX. Empty cells will contain the value of 0 which can not match against valid starting address.
Yep, your approach will save us NUM_ENTRIES*sizeof(u64) memory!

> 
> Also please shift this patch to the first place, it will be logical to add VARIANT_MAX after removing num_dsi.
Ack.

Konrad
> 

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 04/10] drm/msm/dsi: dsi_host: Fix DSI index detection when version clash occurs
  2023-02-11 13:26   ` Dmitry Baryshkov
@ 2023-02-13  9:19     ` Konrad Dybcio
  0 siblings, 0 replies; 22+ messages in thread
From: Konrad Dybcio @ 2023-02-13  9:19 UTC (permalink / raw)
  To: Dmitry Baryshkov, linux-arm-msm, andersson, agross, krzysztof.kozlowski
  Cc: marijn.suijten, Rob Clark, Abhinav Kumar, Sean Paul,
	David Airlie, Daniel Vetter, Neil Armstrong, Vinod Koul,
	Douglas Anderson, Loic Poulain, Vladimir Lypak, Archit Taneja,
	dri-devel, freedreno, linux-kernel



On 11.02.2023 14:26, Dmitry Baryshkov wrote:
> On 11/02/2023 13:51, Konrad Dybcio wrote:
>> Now that msm_dsi_config is ready to accept multiple sets of registers
>> (where array[n][idx] holds the base registers of DSI(idx) for the nth
>> entry), loop through all available configs to resolve hw version
>> clashes.
>>
>> Fixes: 32280d66fd44 ("drm/msm/dsi: Don't get DSI index from DT")
> 
> Do we really want to backport this patch (and other patches from this series to older kernels?)
> 
>> Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
>> ---
>>   drivers/gpu/drm/msm/dsi/dsi_cfg.h  |  1 +
>>   drivers/gpu/drm/msm/dsi/dsi_host.c | 12 +++++++-----
>>   2 files changed, 8 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/msm/dsi/dsi_cfg.h b/drivers/gpu/drm/msm/dsi/dsi_cfg.h
>> index 03493cc6b772..4a47705234bd 100644
>> --- a/drivers/gpu/drm/msm/dsi/dsi_cfg.h
>> +++ b/drivers/gpu/drm/msm/dsi/dsi_cfg.h
>> @@ -43,6 +43,7 @@ struct msm_dsi_config {
>>       const int num_bus_clks;
>>       /* Allow + 1 entry for the zero-terminator */
>>       const resource_size_t io_start[VARIANTS_MAX][DSI_MAX + 1];
>> +    const int num_variants;
>>   };
>>     struct msm_dsi_host_cfg_ops {
>> diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
>> index f5092b4d0757..8dfa69bcff77 100644
>> --- a/drivers/gpu/drm/msm/dsi/dsi_host.c
>> +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
>> @@ -1862,16 +1862,18 @@ 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;
>> +    int i, j, num_variants;
>>         res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dsi_ctrl");
>>       if (!res)
>>           return -EINVAL;
>>   -    for (i = 0; cfg->io_start[0][i]; i++) {
>> -        if (cfg->io_start[0][i] == res->start)
>> -            return i;
>> -    }
>> +    num_variants = cfg->num_variants ? cfg->num_variants : 1;
>> +
>> +    for (i = 0; i < num_variants; i++)
>> +        for (j = 0; cfg->io_start[i][j]; j++)
>> +            if (cfg->io_start[i][j] == res->start)
>> +                return j;
>>         return -EINVAL;
>>   }
> 
> Please squash this together with the patch 'drm/msm/dsi: Turn msm_dsi_config::io_start into a 2d array'.
Ack

Konrad
> 

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 05/10] drm/msm/dsi: dsi_cfg: Deduplicate identical structs
  2023-02-11 15:52   ` Dmitry Baryshkov
@ 2023-02-13  9:20     ` Konrad Dybcio
  0 siblings, 0 replies; 22+ messages in thread
From: Konrad Dybcio @ 2023-02-13  9:20 UTC (permalink / raw)
  To: Dmitry Baryshkov, linux-arm-msm, andersson, agross, krzysztof.kozlowski
  Cc: marijn.suijten, Rob Clark, Abhinav Kumar, Sean Paul,
	David Airlie, Daniel Vetter, Douglas Anderson, Neil Armstrong,
	Loic Poulain, AngeloGioacchino Del Regno, Archit Taneja,
	Harigovindan P, Rajeev Nandan, Stephen Boyd, dri-devel,
	freedreno, linux-kernel



On 11.02.2023 16:52, Dmitry Baryshkov wrote:
> On 11/02/2023 13:51, Konrad Dybcio wrote:
>> Some structs were defined multiple times for no apparent reason.
>> Deduplicate them.
>>
>> Fixes: 3f3c8aff1f8f ("drm/msm/dsi: Add configuration for 8x76")
>> Fixes: 3a3ff88a0fc1 ("drm/msm/dsi: Add 8x96 info in dsi_cfg")
>> Fixes: 6125bd327e16 ("drm/msm: add DSI support for sc7180")
>> Fixes: 65c391b31994 ("drm/msm/dsi: Add DSI support for SC7280")
> 
> I think we should drop these Fixes headers. There are no issues to be fixed in those versions. The code was inefficient and resulted in duplication of data, but that's all.
I see. I won't object!

Konrad
> 
> Other than that:
> 
> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> 
>> Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
>> ---
>>   drivers/gpu/drm/msm/dsi/dsi_cfg.c | 77 +++++++++++--------------------
>>   1 file changed, 26 insertions(+), 51 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/msm/dsi/dsi_cfg.c b/drivers/gpu/drm/msm/dsi/dsi_cfg.c
>> index 5f62c563bd1c..860681bfc084 100644
>> --- a/drivers/gpu/drm/msm/dsi/dsi_cfg.c
>> +++ b/drivers/gpu/drm/msm/dsi/dsi_cfg.c
>> @@ -47,41 +47,32 @@ static const struct msm_dsi_config msm8974_apq8084_dsi_cfg = {
>>       },
>>   };
>>   -static const char * const dsi_8916_bus_clk_names[] = {
>> +static const char * const dsi_v1_3_1_clk_names[] = {
>>       "mdp_core", "iface", "bus",
>>   };
>>   -static const struct regulator_bulk_data msm8916_dsi_regulators[] = {
>> +static const struct regulator_bulk_data dsi_v1_3_1_regulators[] = {
>>       { .supply = "vdda", .init_load_uA = 100000 },    /* 1.2 V */
>>       { .supply = "vddio", .init_load_uA = 100000 },    /* 1.8 V */
>>   };
>>     static const struct msm_dsi_config msm8916_dsi_cfg = {
>>       .io_offset = DSI_6G_REG_SHIFT,
>> -    .regulator_data = msm8916_dsi_regulators,
>> -    .num_regulators = ARRAY_SIZE(msm8916_dsi_regulators),
>> -    .bus_clk_names = dsi_8916_bus_clk_names,
>> -    .num_bus_clks = ARRAY_SIZE(dsi_8916_bus_clk_names),
>> +    .regulator_data = dsi_v1_3_1_regulators,
>> +    .num_regulators = ARRAY_SIZE(dsi_v1_3_1_regulators),
>> +    .bus_clk_names = dsi_v1_3_1_clk_names,
>> +    .num_bus_clks = ARRAY_SIZE(dsi_v1_3_1_clk_names),
>>       .io_start = {
>>           { 0x1a98000, 0 },
>>       },
>>   };
>>   -static const char * const dsi_8976_bus_clk_names[] = {
>> -    "mdp_core", "iface", "bus",
>> -};
>> -
>> -static const struct regulator_bulk_data msm8976_dsi_regulators[] = {
>> -    { .supply = "vdda", .init_load_uA = 100000 },    /* 1.2 V */
>> -    { .supply = "vddio", .init_load_uA = 100000 },    /* 1.8 V */
>> -};
>> -
>>   static const struct msm_dsi_config msm8976_dsi_cfg = {
>>       .io_offset = DSI_6G_REG_SHIFT,
>> -    .regulator_data = msm8976_dsi_regulators,
>> -    .num_regulators = ARRAY_SIZE(msm8976_dsi_regulators),
>> -    .bus_clk_names = dsi_8976_bus_clk_names,
>> -    .num_bus_clks = ARRAY_SIZE(dsi_8976_bus_clk_names),
>> +    .regulator_data = dsi_v1_3_1_regulators,
>> +    .num_regulators = ARRAY_SIZE(dsi_v1_3_1_regulators),
>> +    .bus_clk_names = dsi_v1_3_1_clk_names,
>> +    .num_bus_clks = ARRAY_SIZE(dsi_v1_3_1_clk_names),
>>       .io_start = {
>>           { 0x1a94000, 0x1a96000, 0 },
>>       },
>> @@ -107,10 +98,6 @@ static const struct msm_dsi_config msm8994_dsi_cfg = {
>>       },
>>   };
>>   -static const char * const dsi_8996_bus_clk_names[] = {
>> -    "mdp_core", "iface", "bus", "core_mmss",
>> -};
>> -
>>   static const struct regulator_bulk_data msm8996_dsi_regulators[] = {
>>       { .supply = "vdda", .init_load_uA = 18160 },    /* 1.25 V */
>>       { .supply = "vcca", .init_load_uA = 17000 },    /* 0.925 V */
>> @@ -121,8 +108,8 @@ static const struct msm_dsi_config msm8996_dsi_cfg = {
>>       .io_offset = DSI_6G_REG_SHIFT,
>>       .regulator_data = msm8996_dsi_regulators,
>>       .num_regulators = ARRAY_SIZE(msm8996_dsi_regulators),
>> -    .bus_clk_names = dsi_8996_bus_clk_names,
>> -    .num_bus_clks = ARRAY_SIZE(dsi_8996_bus_clk_names),
>> +    .bus_clk_names = dsi_6g_bus_clk_names,
>> +    .num_bus_clks = ARRAY_SIZE(dsi_6g_bus_clk_names),
>>       .io_start = {
>>           { 0x994000, 0x996000, 0 },
>>       },
>> @@ -167,24 +154,20 @@ static const struct msm_dsi_config sdm660_dsi_cfg = {
>>       },
>>   };
>>   -static const char * const dsi_sdm845_bus_clk_names[] = {
>> +static const char * const dsi_v2_4_clk_names[] = {
>>       "iface", "bus",
>>   };
>>   -static const char * const dsi_sc7180_bus_clk_names[] = {
>> -    "iface", "bus",
>> -};
>> -
>> -static const struct regulator_bulk_data sdm845_dsi_regulators[] = {
>> +static const struct regulator_bulk_data dsi_v2_4_regulators[] = {
>>       { .supply = "vdda", .init_load_uA = 21800 },    /* 1.2 V */
>>   };
>>     static const struct msm_dsi_config sdm845_dsi_cfg = {
>>       .io_offset = DSI_6G_REG_SHIFT,
>> -    .regulator_data = sdm845_dsi_regulators,
>> -    .num_regulators = ARRAY_SIZE(sdm845_dsi_regulators),
>> -    .bus_clk_names = dsi_sdm845_bus_clk_names,
>> -    .num_bus_clks = ARRAY_SIZE(dsi_sdm845_bus_clk_names),
>> +    .regulator_data = dsi_v2_4_regulators,
>> +    .num_regulators = ARRAY_SIZE(dsi_v2_4_regulators),
>> +    .bus_clk_names = dsi_v2_4_clk_names,
>> +    .num_bus_clks = ARRAY_SIZE(dsi_v2_4_clk_names),
>>       .io_start = {
>>           { 0xae94000, 0xae96000, 0 },
>>       },
>> @@ -198,32 +181,24 @@ static const struct msm_dsi_config sm8550_dsi_cfg = {
>>       .io_offset = DSI_6G_REG_SHIFT,
>>       .regulator_data = sm8550_dsi_regulators,
>>       .num_regulators = ARRAY_SIZE(sm8550_dsi_regulators),
>> -    .bus_clk_names = dsi_sdm845_bus_clk_names,
>> -    .num_bus_clks = ARRAY_SIZE(dsi_sdm845_bus_clk_names),
>> +    .bus_clk_names = dsi_v2_4_clk_names,
>> +    .num_bus_clks = ARRAY_SIZE(dsi_v2_4_clk_names),
>>       .io_start = {
>>           { 0xae94000, 0xae96000, 0 },
>>       },
>>   };
>>   -static const struct regulator_bulk_data sc7180_dsi_regulators[] = {
>> -    { .supply = "vdda", .init_load_uA = 21800 },    /* 1.2 V */
>> -};
>> -
>>   static const struct msm_dsi_config sc7180_dsi_cfg = {
>>       .io_offset = DSI_6G_REG_SHIFT,
>> -    .regulator_data = sc7180_dsi_regulators,
>> -    .num_regulators = ARRAY_SIZE(sc7180_dsi_regulators),
>> -    .bus_clk_names = dsi_sc7180_bus_clk_names,
>> -    .num_bus_clks = ARRAY_SIZE(dsi_sc7180_bus_clk_names),
>> +    .regulator_data = dsi_v2_4_regulators,
>> +    .num_regulators = ARRAY_SIZE(dsi_v2_4_regulators),
>> +    .bus_clk_names = dsi_v2_4_clk_names,
>> +    .num_bus_clks = ARRAY_SIZE(dsi_v2_4_clk_names),
>>       .io_start = {
>>           { 0xae94000, 0 },
>>       },
>>   };
>>   -static const char * const dsi_sc7280_bus_clk_names[] = {
>> -    "iface", "bus",
>> -};
>> -
>>   static const struct regulator_bulk_data sc7280_dsi_regulators[] = {
>>       { .supply = "vdda", .init_load_uA = 8350 },    /* 1.2 V */
>>   };
>> @@ -232,8 +207,8 @@ static const struct msm_dsi_config sc7280_dsi_cfg = {
>>       .io_offset = DSI_6G_REG_SHIFT,
>>       .regulator_data = sc7280_dsi_regulators,
>>       .num_regulators = ARRAY_SIZE(sc7280_dsi_regulators),
>> -    .bus_clk_names = dsi_sc7280_bus_clk_names,
>> -    .num_bus_clks = ARRAY_SIZE(dsi_sc7280_bus_clk_names),
>> +    .bus_clk_names = dsi_v2_4_clk_names,
>> +    .num_bus_clks = ARRAY_SIZE(dsi_v2_4_clk_names),
>>       .io_start = {
>>           { 0xae94000, 0xae96000, 0 },
>>       },
> 

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 06/10] drm/msm/dsi: dsi_cfg: Merge SC7180 config into SDM845
  2023-02-11 15:52   ` Dmitry Baryshkov
@ 2023-02-13  9:20     ` Konrad Dybcio
  0 siblings, 0 replies; 22+ messages in thread
From: Konrad Dybcio @ 2023-02-13  9:20 UTC (permalink / raw)
  To: Dmitry Baryshkov, linux-arm-msm, andersson, agross, krzysztof.kozlowski
  Cc: marijn.suijten, Rob Clark, Abhinav Kumar, Sean Paul,
	David Airlie, Daniel Vetter, Douglas Anderson, Loic Poulain,
	Neil Armstrong, Harigovindan P, dri-devel, freedreno,
	linux-kernel



On 11.02.2023 16:52, Dmitry Baryshkov wrote:
> On 11/02/2023 13:51, Konrad Dybcio wrote:
>> The configs are identical, other than the number of *maximum* DSI
>> hosts allowed. This isn't an issue, unless somebody deliberately
>> tries to access the inexistent host by adding a dt node for it.
>>
>> Remove the SC7180 struct and point the hw revision match to the
>> SDM845's one. On a note, this could have been done back when
>> 7180 support was introduced.
>>
>> Fixes: 6125bd327e16 ("drm/msm: add DSI support for sc7180")
> 
> Same comment regarding Fixes
Ack.

Konrad
> 
> Other than that:
> 
> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> 
>> Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
>> ---
>>   drivers/gpu/drm/msm/dsi/dsi_cfg.c | 15 ++-------------
>>   1 file changed, 2 insertions(+), 13 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/msm/dsi/dsi_cfg.c b/drivers/gpu/drm/msm/dsi/dsi_cfg.c
>> index 860681bfc084..142a0f1e2576 100644
>> --- a/drivers/gpu/drm/msm/dsi/dsi_cfg.c
>> +++ b/drivers/gpu/drm/msm/dsi/dsi_cfg.c
>> @@ -169,7 +169,7 @@ static const struct msm_dsi_config sdm845_dsi_cfg = {
>>       .bus_clk_names = dsi_v2_4_clk_names,
>>       .num_bus_clks = ARRAY_SIZE(dsi_v2_4_clk_names),
>>       .io_start = {
>> -        { 0xae94000, 0xae96000, 0 },
>> +        { 0xae94000, 0xae96000, 0 }, /* SDM845 / SDM670 / SC7180 */
>>       },
>>   };
>>   @@ -188,17 +188,6 @@ static const struct msm_dsi_config sm8550_dsi_cfg = {
>>       },
>>   };
>>   -static const struct msm_dsi_config sc7180_dsi_cfg = {
>> -    .io_offset = DSI_6G_REG_SHIFT,
>> -    .regulator_data = dsi_v2_4_regulators,
>> -    .num_regulators = ARRAY_SIZE(dsi_v2_4_regulators),
>> -    .bus_clk_names = dsi_v2_4_clk_names,
>> -    .num_bus_clks = ARRAY_SIZE(dsi_v2_4_clk_names),
>> -    .io_start = {
>> -        { 0xae94000, 0 },
>> -    },
>> -};
>> -
>>   static const struct regulator_bulk_data sc7280_dsi_regulators[] = {
>>       { .supply = "vdda", .init_load_uA = 8350 },    /* 1.2 V */
>>   };
>> @@ -299,7 +288,7 @@ static const struct msm_dsi_cfg_handler dsi_cfg_handlers[] = {
>>       {MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V2_4_0,
>>           &sdm845_dsi_cfg, &msm_dsi_6g_v2_host_ops},
>>       {MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V2_4_1,
>> -        &sc7180_dsi_cfg, &msm_dsi_6g_v2_host_ops},
>> +        &sdm845_dsi_cfg, &msm_dsi_6g_v2_host_ops},
>>       {MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V2_5_0,
>>           &sc7280_dsi_cfg, &msm_dsi_6g_v2_host_ops},
>>       {MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V2_6_0,
> 

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH 03/10] drm/msm/dsi: Zero-terminate msm_dsi_config::io_start
  2023-02-13  9:18     ` Konrad Dybcio
@ 2023-02-13 11:41       ` Dmitry Baryshkov
  0 siblings, 0 replies; 22+ messages in thread
From: Dmitry Baryshkov @ 2023-02-13 11:41 UTC (permalink / raw)
  To: Konrad Dybcio, linux-arm-msm, andersson, agross, krzysztof.kozlowski
  Cc: marijn.suijten, Rob Clark, Abhinav Kumar, Sean Paul,
	David Airlie, Daniel Vetter, Douglas Anderson, Loic Poulain,
	Neil Armstrong, Vinod Koul, Vladimir Lypak, dri-devel, freedreno,
	linux-kernel

On 13/02/2023 11:18, Konrad Dybcio wrote:
> 
> 
> On 11.02.2023 14:19, Dmitry Baryshkov wrote:
>> On 11/02/2023 13:51, Konrad Dybcio wrote:
>>> In preparation for supporting multiple sets of possible base registers,
>>> Zero-terminate the array that contains them to remove the need of
>>> specifying num_dsi for each set.
>>>
>>> Signed-off-by: Konrad Dybcio <konrad.dybcio@linaro.org>
>>> ---
>>>    drivers/gpu/drm/msm/dsi/dsi_cfg.c  | 39 ++++++++++--------------------
>>>    drivers/gpu/drm/msm/dsi/dsi_cfg.h  |  4 +--
>>>    drivers/gpu/drm/msm/dsi/dsi_host.c |  2 +-
>>>    3 files changed, 16 insertions(+), 29 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/msm/dsi/dsi_cfg.c b/drivers/gpu/drm/msm/dsi/dsi_cfg.c
>>> index 068d45b3a8f0..5f62c563bd1c 100644
>>> --- a/drivers/gpu/drm/msm/dsi/dsi_cfg.c
>>> +++ b/drivers/gpu/drm/msm/dsi/dsi_cfg.c
>>> @@ -22,9 +22,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 },
>>> +        { 0x4700000, 0x5800000, 0 },
>>>        },
>>> -    .num_dsi = 2,
>>>    };
>>>      static const char * const dsi_6g_bus_clk_names[] = {
>>> @@ -44,9 +43,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 },
>>> +        { 0xfd922800, 0xfd922b00, 0 },
>>>        },
>>> -    .num_dsi = 2,
>>>    };
>>>      static const char * const dsi_8916_bus_clk_names[] = {
>>> @@ -65,9 +63,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 },
>>> +        { 0x1a98000, 0 },
>>>        },
>>> -    .num_dsi = 1,
>>>    };
>>>      static const char * const dsi_8976_bus_clk_names[] = {
>>> @@ -86,9 +83,8 @@ static const struct msm_dsi_config msm8976_dsi_cfg = {
>>>        .bus_clk_names = dsi_8976_bus_clk_names,
>>>        .num_bus_clks = ARRAY_SIZE(dsi_8976_bus_clk_names),
>>>        .io_start = {
>>> -        { 0x1a94000, 0x1a96000 },
>>> +        { 0x1a94000, 0x1a96000, 0 },
>>>        },
>>> -    .num_dsi = 2,
>>>    };
>>>      static const struct regulator_bulk_data msm8994_dsi_regulators[] = {
>>> @@ -107,9 +103,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 },
>>> +        { 0xfd998000, 0xfd9a0000, 0 },
>>>        },
>>> -    .num_dsi = 2,
>>>    };
>>>      static const char * const dsi_8996_bus_clk_names[] = {
>>> @@ -129,9 +124,8 @@ static const struct msm_dsi_config msm8996_dsi_cfg = {
>>>        .bus_clk_names = dsi_8996_bus_clk_names,
>>>        .num_bus_clks = ARRAY_SIZE(dsi_8996_bus_clk_names),
>>>        .io_start = {
>>> -        { 0x994000, 0x996000 },
>>> +        { 0x994000, 0x996000, 0 },
>>>        },
>>> -    .num_dsi = 2,
>>>    };
>>>      static const char * const dsi_msm8998_bus_clk_names[] = {
>>> @@ -150,9 +144,8 @@ static const struct msm_dsi_config msm8998_dsi_cfg = {
>>>        .bus_clk_names = dsi_msm8998_bus_clk_names,
>>>        .num_bus_clks = ARRAY_SIZE(dsi_msm8998_bus_clk_names),
>>>        .io_start = {
>>> -        { 0xc994000, 0xc996000 },
>>> +        { 0xc994000, 0xc996000, 0 },
>>>        },
>>> -    .num_dsi = 2,
>>>    };
>>>      static const char * const dsi_sdm660_bus_clk_names[] = {
>>> @@ -170,9 +163,8 @@ static const struct msm_dsi_config sdm660_dsi_cfg = {
>>>        .bus_clk_names = dsi_sdm660_bus_clk_names,
>>>        .num_bus_clks = ARRAY_SIZE(dsi_sdm660_bus_clk_names),
>>>        .io_start = {
>>> -        { 0xc994000, 0xc996000 },
>>> +        { 0xc994000, 0xc996000, 0 },
>>>        },
>>> -    .num_dsi = 2,
>>>    };
>>>      static const char * const dsi_sdm845_bus_clk_names[] = {
>>> @@ -194,9 +186,8 @@ static const struct msm_dsi_config sdm845_dsi_cfg = {
>>>        .bus_clk_names = dsi_sdm845_bus_clk_names,
>>>        .num_bus_clks = ARRAY_SIZE(dsi_sdm845_bus_clk_names),
>>>        .io_start = {
>>> -        { 0xae94000, 0xae96000 },
>>> +        { 0xae94000, 0xae96000, 0 },
>>>        },
>>> -    .num_dsi = 2,
>>>    };
>>>      static const struct regulator_bulk_data sm8550_dsi_regulators[] = {
>>> @@ -210,9 +201,8 @@ static const struct msm_dsi_config sm8550_dsi_cfg = {
>>>        .bus_clk_names = dsi_sdm845_bus_clk_names,
>>>        .num_bus_clks = ARRAY_SIZE(dsi_sdm845_bus_clk_names),
>>>        .io_start = {
>>> -        { 0xae94000, 0xae96000 },
>>> +        { 0xae94000, 0xae96000, 0 },
>>>        },
>>> -    .num_dsi = 2,
>>>    };
>>>      static const struct regulator_bulk_data sc7180_dsi_regulators[] = {
>>> @@ -226,9 +216,8 @@ static const struct msm_dsi_config sc7180_dsi_cfg = {
>>>        .bus_clk_names = dsi_sc7180_bus_clk_names,
>>>        .num_bus_clks = ARRAY_SIZE(dsi_sc7180_bus_clk_names),
>>>        .io_start = {
>>> -        { 0xae94000 },
>>> +        { 0xae94000, 0 },
>>>        },
>>> -    .num_dsi = 1,
>>>    };
>>>      static const char * const dsi_sc7280_bus_clk_names[] = {
>>> @@ -246,9 +235,8 @@ static const struct msm_dsi_config sc7280_dsi_cfg = {
>>>        .bus_clk_names = dsi_sc7280_bus_clk_names,
>>>        .num_bus_clks = ARRAY_SIZE(dsi_sc7280_bus_clk_names),
>>>        .io_start = {
>>> -        { 0xae94000, 0xae96000 },
>>> +        { 0xae94000, 0xae96000, 0 },
>>>        },
>>> -    .num_dsi = 2,
>>>    };
>>>      static const char * const dsi_qcm2290_bus_clk_names[] = {
>>> @@ -266,9 +254,8 @@ static const struct msm_dsi_config qcm2290_dsi_cfg = {
>>>        .bus_clk_names = dsi_qcm2290_bus_clk_names,
>>>        .num_bus_clks = ARRAY_SIZE(dsi_qcm2290_bus_clk_names),
>>>        .io_start = {
>>> -        { 0x5e94000 },
>>> +        { 0x5e94000, 0 },
>>>        },
>>> -    .num_dsi = 1,
>>>    };
>>>      static const struct msm_dsi_host_cfg_ops msm_dsi_v2_host_ops = {
>>> diff --git a/drivers/gpu/drm/msm/dsi/dsi_cfg.h b/drivers/gpu/drm/msm/dsi/dsi_cfg.h
>>> index df9f09876ccb..03493cc6b772 100644
>>> --- a/drivers/gpu/drm/msm/dsi/dsi_cfg.h
>>> +++ b/drivers/gpu/drm/msm/dsi/dsi_cfg.h
>>> @@ -41,8 +41,8 @@ struct msm_dsi_config {
>>>        int num_regulators;
>>>        const char * const *bus_clk_names;
>>>        const int num_bus_clks;
>>> -    const resource_size_t io_start[VARIANTS_MAX][DSI_MAX];
>>> -    const int num_dsi;
>>> +    /* Allow + 1 entry for the zero-terminator */
>>> +    const resource_size_t io_start[VARIANTS_MAX][DSI_MAX + 1];
>>>    };
>>>      struct msm_dsi_host_cfg_ops {
>>> diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
>>> index 22ba8726b0ea..f5092b4d0757 100644
>>> --- a/drivers/gpu/drm/msm/dsi/dsi_host.c
>>> +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
>>> @@ -1868,7 +1868,7 @@ static int dsi_host_get_id(struct msm_dsi_host *msm_host)
>>>        if (!res)
>>>            return -EINVAL;
>>>    -    for (i = 0; i < cfg->num_dsi; i++) {
>>> +    for (i = 0; cfg->io_start[0][i]; i++) {
>>>            if (cfg->io_start[0][i] == res->start)
>>>                return i;
>>>        }
>>
>> I think we have the easier way to do this: always loop towards DSI_MAX. Empty cells will contain the value of 0 which can not match against valid starting address.
> Yep, your approach will save us NUM_ENTRIES*sizeof(u64) memory!

As for me it not about saving memory, but rather about the driver logic. 
Compare:
- We have two possible DSI hosts, one which is ocassionally absent thus 
the address is 0

vs

- We have a zero-terminated list of 2+1 entries for not more than two 
DSI hosts.

> 
>>
>> Also please shift this patch to the first place, it will be logical to add VARIANT_MAX after removing num_dsi.
> Ack.
> 
> Konrad
>>

-- 
With best wishes
Dmitry


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2023-02-13 11:41 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20230211115110.1462920-1-konrad.dybcio@linaro.org>
2023-02-11 11:51 ` [PATCH 01/10] dt-bindings: display/msm: dsi-controller-main: Fix deprecated QCM2290 compatible Konrad Dybcio
2023-02-11 11:51 ` [PATCH 02/10] drm/msm/dsi: Turn msm_dsi_config::io_start into a 2d array Konrad Dybcio
2023-02-11 13:17   ` Dmitry Baryshkov
2023-02-13  9:16     ` Konrad Dybcio
2023-02-11 11:51 ` [PATCH 03/10] drm/msm/dsi: Zero-terminate msm_dsi_config::io_start Konrad Dybcio
2023-02-11 13:19   ` Dmitry Baryshkov
2023-02-13  9:18     ` Konrad Dybcio
2023-02-13 11:41       ` Dmitry Baryshkov
2023-02-11 11:51 ` [PATCH 04/10] drm/msm/dsi: dsi_host: Fix DSI index detection when version clash occurs Konrad Dybcio
2023-02-11 13:26   ` Dmitry Baryshkov
2023-02-13  9:19     ` Konrad Dybcio
2023-02-11 11:51 ` [PATCH 05/10] drm/msm/dsi: dsi_cfg: Deduplicate identical structs Konrad Dybcio
2023-02-11 15:52   ` Dmitry Baryshkov
2023-02-13  9:20     ` Konrad Dybcio
2023-02-11 11:51 ` [PATCH 06/10] drm/msm/dsi: dsi_cfg: Merge SC7180 config into SDM845 Konrad Dybcio
2023-02-11 15:52   ` Dmitry Baryshkov
2023-02-13  9:20     ` Konrad Dybcio
2023-02-11 11:51 ` [PATCH 07/10] drm/msm/dsi: Switch the QCM2290-specific compatible to index autodetection Konrad Dybcio
2023-02-11 11:51 ` [PATCH 08/10] drm/msm/dsi: Remove custom DSI config handling Konrad Dybcio
2023-02-11 15:53   ` Dmitry Baryshkov
2023-02-11 11:51 ` [PATCH 09/10] dt-bindings: display/msm: dsi-controller-main: Add SM6115 Konrad Dybcio
2023-02-11 11:51 ` [PATCH 10/10] arm64: dts: qcom: sm6115: Use the correct DSI compatible Konrad Dybcio

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).