Skip to contentSkip to conversation

Add DSI support for RK3128

PATCH Applied Alex Bee 2 participants 10 messages May 9, 2024 – May 28, 2024

Subsystems (6)
lore
Share & tools
lore

Alex Bee

author
#0 lore raw

v3 cover Add DSI support for RK3128

This series aims to add support for the DesignWare MIPI DSI controller and the Innoslicon D-PHY found in RK3128 SoCs. The code additions are rather
tiny: It only need some code in the Rockchip dw-mipi-dsi glue layer for this SoC and do some changes in the SoC's clock driver. Support for the phy was already added when the Innosilicon D-PHY driver was initially submitted. I tested it with a 800x1280 DSI panel where all 4 lanes that are supported are used.

changes in v2:
To improve power-efficiency when the DSI controller is not in use, I dropped the patch which made hclk_vio_h2p a critical clock and instead added support for an AHB clock to the DSI controller driver and updated the bindings and the addition to the SoC DT accordingly.

Link to v1:
https://lore.kernel.org/linux-kernel/[email protected]/

changes in v3:
Dropped the changes for the additional AHB clock for the DSI controller, as it's not part of the IP block. (Heiko)

Link to v2:
https://lore.kernel.org/linux-kernel/[email protected]/

Please see individual patches for details about the changes.

Alex Bee (7):
dt-bindings: display: rockchip,dw-mipi-dsi: Document RK3128 DSI
dt-bindings: clock: rk3128: Add PCLK_MIPIPHY
clk: rockchip: rk3128: Export PCLK_MIPIPHY
clk: rockchip: rk3128: Add hclk_vio_h2p to critical clocks drm/rockchip: dsi: Add support for RK3128
ARM: dts: rockchip: Add D-PHY for RK3128
ARM: dts: rockchip: Add DSI for RK3128

 .../rockchip/rockchip,dw-mipi-dsi.yaml        |  2 +
 arch/arm/boot/dts/rockchip/rk3128.dtsi        | 50 +++++++++++++++++++
 drivers/clk/rockchip/clk-rk3128.c             |  3 +-
 .../gpu/drm/rockchip/dw-mipi-dsi-rockchip.c   | 20 ++++++++
 include/dt-bindings/clock/rk3128-cru.h        |  1 +
 5 files changed, 75 insertions(+), 1 deletion(-)
Signature · 1 line
2.43.2
author
#1 lore raw

PATCH v3 1/7 dt-bindings: display: rockchip,dw-mipi-dsi: Document RK3128 DSI

Document the MIPI DSI controller for Rockchip RK3128. The integration is similar to PX30 so it's bindings-constraints can be re-used.

---
changes since v1:
- added ahb clock

changes since v2:
- revert added ahb clock

 .../rockchip/rockchip,dw-mipi-dsi.yaml        | 25 ++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/display/rockchip/rockchip,dw-mipi-dsi.yaml +2 -0
index ccf79e738fa1..ccd71c5324af 100644
@@ -15,6 +15,7 @@ properties:
     items:
       - enum:
           - rockchip,px30-mipi-dsi
+          - rockchip,rk3128-mipi-dsi
           - rockchip,rk3288-mipi-dsi
           - rockchip,rk3399-mipi-dsi
           - rockchip,rk3568-mipi-dsi
@@ -77,6 +78,7 @@ allOf:
           contains:
             enum:
               - rockchip,px30-mipi-dsi
+              - rockchip,rk3128-mipi-dsi
               - rockchip,rk3568-mipi-dsi
               - rockchip,rv1126-mipi-dsi
 
Signature · 1 line
2.43.2
author
#2 lore raw

PATCH v3 2/7 dt-bindings: clock: rk3128: Add PCLK_MIPIPHY

In reply to Alex Bee

The DPHY's APB clock is required to be exposed in order to be able to enable it and access the phy's registers.

---
changes since v1:
- none

 include/dt-bindings/clock/rk3128-cru.h | 1 +
 1 file changed, 1 insertion(+)
include/dt-bindings/clock/rk3128-cru.h +1 -0
index 6a47825dac5d..1be455ba4985 100644
@@ -116,6 +116,7 @@
 #define PCLK_GMAC		367
 #define PCLK_PMU_PRE		368
 #define PCLK_SIM_CARD		369
+#define PCLK_MIPIPHY		370
 
 /* hclk gates */
 #define HCLK_SPDIF		440
Signature · 1 line
2.43.2
author
#3 lore raw

PATCH v3 3/7 clk: rockchip: rk3128: Export PCLK_MIPIPHY

In reply to Alex Bee

Export the D-DHY's APB clock for usage in the DT. Also drop the CLK_IGNORE_UNUSED-flag, as the clock will be enabled on demand.

---
changes since v1:
- reword commit message

 drivers/clk/rockchip/clk-rk3128.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/rockchip/clk-rk3128.c +1 -1
index 75071e0cd321..a20d1fd25e2a 100644
@@ -526,7 +526,7 @@ static struct rockchip_clk_branch common_clk_branches[] __initdata = {
 	GATE(PCLK_ACODEC, "pclk_acodec", "pclk_cpu", 0, RK2928_CLKGATE_CON(5), 14, GFLAGS),
 	GATE(0, "pclk_ddrupctl", "pclk_cpu", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(5), 7, GFLAGS),
 	GATE(0, "pclk_grf", "pclk_cpu", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(5), 4, GFLAGS),
-	GATE(0, "pclk_mipiphy", "pclk_cpu", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(5), 0, GFLAGS),
+	GATE(PCLK_MIPIPHY, "pclk_mipiphy", "pclk_cpu", 0, RK2928_CLKGATE_CON(5), 0, GFLAGS),
 
 	GATE(0, "pclk_pmu", "pclk_pmu_pre", 0, RK2928_CLKGATE_CON(9), 2, GFLAGS),
 	GATE(0, "pclk_pmu_niu", "pclk_pmu_pre", CLK_IGNORE_UNUSED, RK2928_CLKGATE_CON(9), 3, GFLAGS),
Signature · 1 line
2.43.2
author
#4 lore raw

PATCH v3 4/7 clk: rockchip: rk3128: Add hclk_vio_h2p to critical clocks

In reply to Alex Bee

The DSI controller needs this clock to be enabled in order to be able to access the registers. Make it critical for that purpose.

---
changes since v1:
- dropped patch

changes since v2:
-re-added patch

 drivers/clk/rockchip/clk-rk3128.c | 1 +
 1 file changed, 1 insertion(+)
drivers/clk/rockchip/clk-rk3128.c +1 -0
index a20d1fd25e2a..d076b7971f33 100644
@@ -563,6 +563,7 @@ static const char *const rk3128_critical_clocks[] __initconst = {
 	"pclk_cpu",
 	"aclk_peri",
 	"hclk_peri",
+	"hclk_vio_h2p",
 	"pclk_peri",
 	"pclk_pmu",
 	"sclk_timer5",
Signature · 1 line
2.43.2
author
#5 lore raw

PATCH v3 5/7 drm/rockchip: dsi: Add support for RK3128

In reply to Alex Bee

The DesignWare MIPI DSI controller found RK3128 SoCs supports up to 4 DSI data lanes. Similar to PX30/RK356x/RV1126 it uses an external D-PHY.

---
changes since v1:
- none

 .../gpu/drm/rockchip/dw-mipi-dsi-rockchip.c   | 20 +++++++++++++++++++
 1 file changed, 20 insertions(+)
drivers/gpu/drm/rockchip/dw-mipi-dsi-rockchip.c +20 -0
index 4cc8ed8f4fbd..58a44af0e9ad 100644
@@ -153,6 +153,11 @@
 #define PX30_DSI_TURNDISABLE		BIT(5)
 #define PX30_DSI_LCDC_SEL		BIT(0)
 
+#define RK3128_GRF_LVDS_CON0		0x0150
+#define RK3128_DSI_FORCETXSTOPMODE	GENMASK(13, 10)
+#define RK3128_DSI_FORCERXMODE		BIT(9)
+#define RK3128_DSI_TURNDISABLE		BIT(8)
+
 #define RK3288_GRF_SOC_CON6		0x025c
 #define RK3288_DSI0_LCDC_SEL		BIT(6)
 #define RK3288_DSI1_LCDC_SEL		BIT(9)
@@ -1493,6 +1498,18 @@ static const struct rockchip_dw_dsi_chip_data px30_chip_data[] = {
 	{ /* sentinel */ }
 };
 
+static const struct rockchip_dw_dsi_chip_data rk3128_chip_data[] = {
+	{
+		.reg = 0x10110000,
+		.lanecfg1_grf_reg = RK3128_GRF_LVDS_CON0,
+		.lanecfg1 = HIWORD_UPDATE(0, RK3128_DSI_TURNDISABLE |
+					     RK3128_DSI_FORCERXMODE |
+					     RK3128_DSI_FORCETXSTOPMODE),
+		.max_data_lanes = 4,
+	},
+	{ /* sentinel */ }
+};
+
 static const struct rockchip_dw_dsi_chip_data rk3288_chip_data[] = {
 	{
 		.reg = 0xff960000,
@@ -1670,6 +1687,9 @@ static const struct of_device_id dw_mipi_dsi_rockchip_dt_ids[] = {
 	{
 	 .compatible = "rockchip,px30-mipi-dsi",
 	 .data = &px30_chip_data,
+	}, {
+	 .compatible = "rockchip,rk3128-mipi-dsi",
+	 .data = &rk3128_chip_data,
 	}, {
 	 .compatible = "rockchip,rk3288-mipi-dsi",
 	 .data = &rk3288_chip_data,
Signature · 1 line
2.43.2
author
#6 lore raw

PATCH v3 6/7 ARM: dts: rockchip: Add D-PHY for RK3128

In reply to Alex Bee

The InnoSilicon D-PHY found in RK3128 SoCs supports DSI/LVDS/TTL with a maximum transfer rate of 1 Gbps per lane. While adding it, also add it's clocks to RK3128_PD_VIO powerdomain as the phy is part of it.

---
changes since v1:
- also added SCLK_MIPI_24M to powerdomain
- reword commit message

 arch/arm/boot/dts/rockchip/rk3128.dtsi | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
arch/arm/boot/dts/rockchip/rk3128.dtsi +14 -0
index fb98873fd94e..fbd95bb08cd3 100644
@@ -216,6 +216,8 @@ power-domain@RK3128_PD_VIO {
 					 <&cru ACLK_LCDC0>,
 					 <&cru HCLK_LCDC0>,
 					 <&cru PCLK_MIPI>,
+					 <&cru PCLK_MIPIPHY>,
+					 <&cru SCLK_MIPI_24M>,
 					 <&cru ACLK_RGA>,
 					 <&cru HCLK_RGA>,
 					 <&cru ACLK_VIO0>,
@@ -496,6 +498,18 @@ hdmi_out: port@1 {
 		};
 	};
 
+	dphy: phy@20038000 {
+		compatible = "rockchip,rk3128-dsi-dphy";
+		reg = <0x20038000 0x4000>;
+		clocks = <&cru SCLK_MIPI_24M>, <&cru PCLK_MIPIPHY>;
+		clock-names = "ref", "pclk";
+		resets = <&cru SRST_MIPIPHY_P>;
+		reset-names = "apb";
+		power-domains = <&power RK3128_PD_VIO>;
+		#phy-cells = <0>;
+		status = "disabled";
+	};
+
 	timer0: timer@20044000 {
 		compatible = "rockchip,rk3128-timer", "rockchip,rk3288-timer";
 		reg = <0x20044000 0x20>;
Signature · 1 line
2.43.2
author
#7 lore raw

PATCH v3 7/7 ARM: dts: rockchip: Add DSI for RK3128

In reply to Alex Bee

Add the Designware MIPI DSI controller and it's port nodes.

---
changes since v1:
- added HCLK_VIO_H2P as ahb clock

changes since v2:
- dropped ahb clock again

 arch/arm/boot/dts/rockchip/rk3128.dtsi | 36 ++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
arch/arm/boot/dts/rockchip/rk3128.dtsi +36 -0
index fbd95bb08cd3..7f2bf3e51082 100644
@@ -277,6 +277,42 @@ vop_out_hdmi: endpoint@0 {
 				reg = <0>;
 				remote-endpoint = <&hdmi_in_vop>;
 			};
+
+			vop_out_dsi: endpoint@1 {
+				reg = <1>;
+				remote-endpoint = <&dsi_in_vop>;
+			};
+		};
+	};
+
+	dsi: dsi@10110000 {
+		compatible = "rockchip,rk3128-mipi-dsi", "snps,dw-mipi-dsi";
+		reg = <0x10110000 0x4000>;
+		interrupts = <GIC_SPI 33 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&cru PCLK_MIPI>;
+		clock-names = "pclk";
+		phys = <&dphy>;
+		phy-names = "dphy";
+		resets = <&cru SRST_VIO_MIPI_DSI>;
+		reset-names = "apb";
+		rockchip,grf = <&grf>;
+		power-domains = <&power RK3128_PD_VIO>;
+		status = "disabled";
+
+		ports {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			dsi_in: port@0 {
+				reg = <0>;
+				dsi_in_vop: endpoint {
+					remote-endpoint = <&vop_out_dsi>;
+				};
+			};
+
+			dsi_out: port@1 {
+				reg = <1>;
+			};
 		};
 	};
 
Signature · 1 line
2.43.2
maintainer Applied
#8 lore raw

Re: (subset) [PATCH v3 0/7] Add DSI support for RK3128

In reply to Alex Bee
Quoted 9 lines · Alex Bee

This series aims to add support for the DesignWare MIPI DSI controller and the Innoslicon D-PHY found in RK3128 SoCs. The code additions are rather
tiny: It only need some code in the Rockchip dw-mipi-dsi glue layer for this SoC and do some changes in the SoC's clock driver. Support for the phy was already added when the Innosilicon D-PHY driver was initially submitted. I tested it with a 800x1280 DSI panel where all 4 lanes that are supported are used.

[...]

Applied, thanks!

[1/7] dt-bindings: display: rockchip,dw-mipi-dsi: Document RK3128 DSI

      commit: 9bb3d9ad3e19f16efc34f427a58e480424c56a16
[5/7] drm/rockchip: dsi: Add support for RK3128
      commit: 62545c719e26ec9f62efab7e9582deb73265b6d0

Best regards,

Signature · 1 line
Heiko Stuebner <[email protected]>
maintainer Applied
#9 lore raw

Re: (subset) [PATCH v3 0/7] Add DSI support for RK3128

In reply to Alex Bee
Quoted 9 lines · Alex Bee

This series aims to add support for the DesignWare MIPI DSI controller and the Innoslicon D-PHY found in RK3128 SoCs. The code additions are rather
tiny: It only need some code in the Rockchip dw-mipi-dsi glue layer for this SoC and do some changes in the SoC's clock driver. Support for the phy was already added when the Innosilicon D-PHY driver was initially submitted. I tested it with a 800x1280 DSI panel where all 4 lanes that are supported are used.

[...]

Applied, thanks!

[2/7] dt-bindings: clock: rk3128: Add PCLK_MIPIPHY

      commit: 14a1d1dc35d346a1523f38f6517c349dfa447a58
[3/7] clk: rockchip: rk3128: Export PCLK_MIPIPHY
      commit: 577c04fbf255f81f26507a7ffb2477fce50c214d
[4/7] clk: rockchip: rk3128: Add hclk_vio_h2p to critical clocks
      commit: e745698209837a952d4515bc02cddd5a31a644b9
[6/7] ARM: dts: rockchip: Add D-PHY for RK3128
      commit: 45b22b83e00b1ec36d5de53b797cd9d8545a0d34
[7/7] ARM: dts: rockchip: Add DSI for RK3128
      commit: 73fc389129dfe22b5706b4b6cbc1a4f86d1fbc1b

Best regards,

Signature · 1 line
Heiko Stuebner <[email protected]>