Skip to contentSkip to conversation

MIPI DSI phy for rk3588

PATCH Superseded Heiko Stuebner 3 participants 7 messages Nov 13, 2024 – Nov 24, 2024

Subsystems (3)

v3 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

Heiko Stuebner

author maintainer
#0 lore raw

v3 cover MIPI DSI phy for rk3588

This adds the phy driver need for DSI output on rk3588.

The phy itself is used for both DSI output and CSI input, though the CSI part for the whole chain needs a lot more work, so is left out for now and only the DSI part implemented.

This allows the rk3588 with its current VOP support to drive a DSI display using the DSI2 controller driver I'll submit in a next step.

Only generic phy interfaces are used, so the DSI part is pretty straight forward.

changes in v3:
- add Krzysztof review tag to the binding
- address Sebastian's review comments
- better error handling
- dropping empty function
- headers
- not using of_match_ptr - this should also make the test-robot happier

changes in v2:
- fix error in dt-binding example
- drop unused frequency table
- pull in some more recent improvements from the vendor-kernel which includes a lot less magic values
- already include the support for rk3576
- use dev_err_probe

Heiko Stuebner (2):
dt-bindings: phy: Add Rockchip MIPI CSI/DSI PHY schema
phy: rockchip: Add Samsung CSI/DSI Combo DCPHY driver

 .../phy/rockchip,rk3588-mipi-dcphy.yaml       |   82 +
 drivers/phy/rockchip/Kconfig                  |   12 +
 drivers/phy/rockchip/Makefile                 |    1 +
 .../phy/rockchip/phy-rockchip-samsung-dcphy.c | 1647 +++++++++++++++++
 4 files changed, 1742 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/rockchip,rk3588-mipi-dcphy.yaml
 create mode 100644 drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c
Signature · 1 line
2.45.2
author maintainer
#1 lore raw

PATCH v3 1/2 dt-bindings: phy: Add Rockchip MIPI CSI/DSI PHY schema

From: Heiko Stuebner <[email protected]>

Add dt-binding schema for the MIPI CSI/DSI PHY found on Rockchip RK3588 SoCs.

---
 .../phy/rockchip,rk3588-mipi-dcphy.yaml       | 82 +++++++++++++++++++
 1 file changed, 82 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/rockchip,rk3588-mipi-dcphy.yaml
Documentation/devicetree/bindings/phy/rockchip,rk3588-mipi-dcphy.yaml new file +82 -0
new file mode 100644
index 000000000000..5ee8d7246fa0
@@ -0,0 +1,82 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/phy/rockchip,rk3588-mipi-dcphy.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Rockchip MIPI CSI/DSI PHY with Samsung IP block
+
+maintainers:
+  - Guochun Huang <[email protected]>
+  - Heiko Stuebner <[email protected]>
+
+properties:
+  compatible:
+    enum:
+      - rockchip,rk3576-mipi-dcphy
+      - rockchip,rk3588-mipi-dcphy
+
+  reg:
+    maxItems: 1
+
+  "#phy-cells":
+    const: 0
+
+  clocks:
+    maxItems: 2
+
+  clock-names:
+    items:
+      - const: pclk
+      - const: ref
+
+  resets:
+    maxItems: 4
+
+  reset-names:
+    items:
+      - const: m_phy
+      - const: apb
+      - const: grf
+      - const: s_phy
+
+  rockchip,grf:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description:
+      Phandle to the syscon managing the 'mipi dcphy general register files'.
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - resets
+  - reset-names
+  - "#phy-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/rockchip,rk3588-cru.h>
+    #include <dt-bindings/reset/rockchip,rk3588-cru.h>
+
+    soc {
+      #address-cells = <2>;
+      #size-cells = <2>;
+
+      phy@feda0000 {
+        compatible = "rockchip,rk3588-mipi-dcphy";
+        reg = <0x0 0xfeda0000 0x0 0x10000>;
+        clocks = <&cru PCLK_MIPI_DCPHY0>,
+                 <&cru CLK_USBDPPHY_MIPIDCPPHY_REF>;
+        clock-names = "pclk", "ref";
+        resets = <&cru SRST_M_MIPI_DCPHY0>,
+                 <&cru SRST_P_MIPI_DCPHY0>,
+                 <&cru SRST_P_MIPI_DCPHY0_GRF>,
+                 <&cru SRST_S_MIPI_DCPHY0>;
+        reset-names = "m_phy", "apb", "grf", "s_phy";
+        rockchip,grf = <&mipidcphy0_grf>;
+        #phy-cells = <0>;
+      };
+    };
Signature · 1 line
2.45.2
#2 lore raw

Re: [PATCH v3 1/2] dt-bindings: phy: Add Rockchip MIPI CSI/DSI PHY schema

Hi,

Quoted 31 lines · Heiko Stuebner

From: Heiko Stuebner <[email protected]>

Add dt-binding schema for the MIPI CSI/DSI PHY found on Rockchip RK3588 SoCs.

---
 .../phy/rockchip,rk3588-mipi-dcphy.yaml       | 82 +++++++++++++++++++
 1 file changed, 82 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/rockchip,rk3588-mipi-dcphy.yaml
Documentation/devicetree/bindings/phy/rockchip,rk3588-mipi-dcphy.yaml new file +13 -0
new file mode 100644
index 000000000000..5ee8d7246fa0
@@ -0,0 +1,82 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/phy/rockchip,rk3588-mipi-dcphy.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Rockchip MIPI CSI/DSI PHY with Samsung IP block
+
+maintainers:
+  - Guochun Huang <[email protected]>
+  - Heiko Stuebner <[email protected]>
+
+properties:

Documentation/devicetree/bindings/phy/rockchip,rk3588-mipi-dcphy.yaml line 23

Quoted 10 lines
Documentation/devicetree/bindings/phy/rockchip,rk3588-mipi-dcphy.yaml new file +10 -0
+  compatible:
+    enum:
+      - rockchip,rk3576-mipi-dcphy
+      - rockchip,rk3588-mipi-dcphy
+
+  reg:
+    maxItems: 1
+
+  "#phy-cells":
+    const: 0

I would expect an argument to select between D-PHY and C-PHY mode, so that the binding is ready for it even when the driver does not yet support it. E.g. something like

'#phy-cells':
const: 1
description: |
Supported modes are:
- PHY_TYPE_DPHY
- PHY_TYPE_CPHY
See include/dt-bindings/phy/phy.h for constants.

This would match how it works for the naneng Combo PHY to switch between PCIe/SATA/USB3. Also Mediatek CSI DC-PHY handles it that way upstream (with just D-PHY being supported). I see that the driver stack you send upstream expects, that the PHY user (e.g. the DSI controller) instead manually calls phy_set_mode(phy, <mode>). To me it seems more sensible to just get this automaically from DT.

Otherwise the whole series LGTM.

Greetings,

-- Sebastian

Quoted 62 lines
Documentation/devicetree/bindings/phy/rockchip,rk3588-mipi-dcphy.yaml new file +58 -0
+  clocks:
+    maxItems: 2
+
+  clock-names:
+    items:
+      - const: pclk
+      - const: ref
+
+  resets:
+    maxItems: 4
+
+  reset-names:
+    items:
+      - const: m_phy
+      - const: apb
+      - const: grf
+      - const: s_phy
+
+  rockchip,grf:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description:
+      Phandle to the syscon managing the 'mipi dcphy general register files'.
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - resets
+  - reset-names
+  - "#phy-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/rockchip,rk3588-cru.h>
+    #include <dt-bindings/reset/rockchip,rk3588-cru.h>
+
+    soc {
+      #address-cells = <2>;
+      #size-cells = <2>;
+
+      phy@feda0000 {
+        compatible = "rockchip,rk3588-mipi-dcphy";
+        reg = <0x0 0xfeda0000 0x0 0x10000>;
+        clocks = <&cru PCLK_MIPI_DCPHY0>,
+                 <&cru CLK_USBDPPHY_MIPIDCPPHY_REF>;
+        clock-names = "pclk", "ref";
+        resets = <&cru SRST_M_MIPI_DCPHY0>,
+                 <&cru SRST_P_MIPI_DCPHY0>,
+                 <&cru SRST_P_MIPI_DCPHY0_GRF>,
+                 <&cru SRST_S_MIPI_DCPHY0>;
+        reset-names = "m_phy", "apb", "grf", "s_phy";
+        rockchip,grf = <&mipidcphy0_grf>;
+        #phy-cells = <0>;
+      };
+    };
Signature · 1 line
2.45.2
author maintainer
#3 lore raw

Re: [PATCH v3 1/2] dt-bindings: phy: Add Rockchip MIPI CSI/DSI PHY schema

Am Freitag, 22. November 2024, 19:49:20 CET schrieb Sebastian Reichel:

Quoted 57 lines

Hi,

Quoted 31 lines · Heiko Stuebner

From: Heiko Stuebner <[email protected]>

Add dt-binding schema for the MIPI CSI/DSI PHY found on Rockchip RK3588 SoCs.

---
 .../phy/rockchip,rk3588-mipi-dcphy.yaml       | 82 +++++++++++++++++++
 1 file changed, 82 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/rockchip,rk3588-mipi-dcphy.yaml
Documentation/devicetree/bindings/phy/rockchip,rk3588-mipi-dcphy.yaml new file +13 -0
new file mode 100644
index 000000000000..5ee8d7246fa0
@@ -0,0 +1,82 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/phy/rockchip,rk3588-mipi-dcphy.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Rockchip MIPI CSI/DSI PHY with Samsung IP block
+
+maintainers:
+  - Guochun Huang <[email protected]>
+  - Heiko Stuebner <[email protected]>
+
+properties:

Documentation/devicetree/bindings/phy/rockchip,rk3588-mipi-dcphy.yaml line 23

Quoted 10 lines
Documentation/devicetree/bindings/phy/rockchip,rk3588-mipi-dcphy.yaml new file +10 -0
+  compatible:
+    enum:
+      - rockchip,rk3576-mipi-dcphy
+      - rockchip,rk3588-mipi-dcphy
+
+  reg:
+    maxItems: 1
+
+  "#phy-cells":
+    const: 0

I would expect an argument to select between D-PHY and C-PHY mode, so that the binding is ready for it even when the driver does not yet support it. E.g. something like

'#phy-cells':
const: 1
description: |
Supported modes are:
- PHY_TYPE_DPHY
- PHY_TYPE_CPHY
See include/dt-bindings/phy/phy.h for constants.

Quoted 6 lines

This would match how it works for the naneng Combo PHY to switch between PCIe/SATA/USB3. Also Mediatek CSI DC-PHY handles it that way upstream (with just D-PHY being supported). I see that the driver stack you send upstream expects, that the PHY user (e.g. the DSI controller) instead manually calls phy_set_mode(phy, <mode>). To me it seems more sensible to just get this automaically from DT.

The mode-selection for the phy is definitly tied to the hardware-design. Depending on how the board is designed, it'll always do either D-PHY or C-PHY mode.

I guess it mostly just feels strange when so far the parameter was used to identify say an individual clock from the clock controller.

But reading the Medietek discussion (up to [0]) it looks like that is a nice way to do this, so I'll adapt things in the next version.

Heiko

[0] https://lore.kernel.org/all/[email protected]/

Quoted 65 lines

Otherwise the whole series LGTM.

Greetings,

-- Sebastian

Quoted 58 lines
Documentation/devicetree/bindings/phy/rockchip,rk3588-mipi-dcphy.yaml new file +58 -0
+  clocks:
+    maxItems: 2
+
+  clock-names:
+    items:
+      - const: pclk
+      - const: ref
+
+  resets:
+    maxItems: 4
+
+  reset-names:
+    items:
+      - const: m_phy
+      - const: apb
+      - const: grf
+      - const: s_phy
+
+  rockchip,grf:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description:
+      Phandle to the syscon managing the 'mipi dcphy general register files'.
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - resets
+  - reset-names
+  - "#phy-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/rockchip,rk3588-cru.h>
+    #include <dt-bindings/reset/rockchip,rk3588-cru.h>
+
+    soc {
+      #address-cells = <2>;
+      #size-cells = <2>;
+
+      phy@feda0000 {
+        compatible = "rockchip,rk3588-mipi-dcphy";
+        reg = <0x0 0xfeda0000 0x0 0x10000>;
+        clocks = <&cru PCLK_MIPI_DCPHY0>,
+                 <&cru CLK_USBDPPHY_MIPIDCPPHY_REF>;
+        clock-names = "pclk", "ref";
+        resets = <&cru SRST_M_MIPI_DCPHY0>,
+                 <&cru SRST_P_MIPI_DCPHY0>,
+                 <&cru SRST_P_MIPI_DCPHY0_GRF>,
+                 <&cru SRST_S_MIPI_DCPHY0>;
+        reset-names = "m_phy", "apb", "grf", "s_phy";
+        rockchip,grf = <&mipidcphy0_grf>;
+        #phy-cells = <0>;
+      };
+    };
Signature · 3 lines
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy
author maintainer
#4 lore raw

PATCH v3 2/2 phy: rockchip: Add Samsung CSI/DSI Combo DCPHY driver

In reply to Heiko Stuebner

From: Heiko Stuebner <[email protected]>

Add phy driver needed to drive either a MIPI DSI output to a DSI display or MIPI CSI input from a camera on rk3588.

Right now only the DSI portion is implemented as the whole camera part needs more work in general.

---
 drivers/phy/rockchip/Kconfig                  |   12 +
 drivers/phy/rockchip/Makefile                 |    1 +
 .../phy/rockchip/phy-rockchip-samsung-dcphy.c | 1647 +++++++++++++++++
 3 files changed, 1660 insertions(+)
 create mode 100644 drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c
drivers/phy/rockchip/Kconfig +12 -0
index 2f7a05f21dc5..2bfb42996503 100644
@@ -83,6 +83,18 @@ config PHY_ROCKCHIP_PCIE
 	help
 	  Enable this to support the Rockchip PCIe PHY.
 
+config PHY_ROCKCHIP_SAMSUNG_DCPHY
+	tristate "Rockchip Samsung MIPI DCPHY driver"
+	depends on (ARCH_ROCKCHIP || COMPILE_TEST)
+	select GENERIC_PHY
+	select GENERIC_PHY_MIPI_DPHY
+	help
+	  Enable this to support the Rockchip MIPI DCPHY with
+	  Samsung IP block.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called phy-rockchip-samsung-dcphy
+
 config PHY_ROCKCHIP_SAMSUNG_HDPTX
 	tristate "Rockchip Samsung HDMI/eDP Combo PHY driver"
 	depends on (ARCH_ROCKCHIP || COMPILE_TEST) && OF
drivers/phy/rockchip/Makefile +1 -0
index 010a824e32ce..117aaffd037d 100644
@@ -8,6 +8,7 @@ obj-$(CONFIG_PHY_ROCKCHIP_INNO_HDMI)	+= phy-rockchip-inno-hdmi.o
 obj-$(CONFIG_PHY_ROCKCHIP_INNO_USB2)	+= phy-rockchip-inno-usb2.o
 obj-$(CONFIG_PHY_ROCKCHIP_NANENG_COMBO_PHY)	+= phy-rockchip-naneng-combphy.o
 obj-$(CONFIG_PHY_ROCKCHIP_PCIE)		+= phy-rockchip-pcie.o
+obj-$(CONFIG_PHY_ROCKCHIP_SAMSUNG_DCPHY)	+= phy-rockchip-samsung-dcphy.o
 obj-$(CONFIG_PHY_ROCKCHIP_SAMSUNG_HDPTX)	+= phy-rockchip-samsung-hdptx.o
 obj-$(CONFIG_PHY_ROCKCHIP_SNPS_PCIE3)	+= phy-rockchip-snps-pcie3.o
 obj-$(CONFIG_PHY_ROCKCHIP_TYPEC)	+= phy-rockchip-typec.o
drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c new file +1647 -0

1,647 lines not on this page · raw message

Signature · 1 line
2.45.2
Tested-by on the v3 series
#5 lore raw
In reply to Heiko Stuebner

Hello Heiko,

Quoted 33 lines

This adds the phy driver need for DSI output on rk3588.

The phy itself is used for both DSI output and CSI input, though the CSI part for the whole chain needs a lot more work, so is left out for now and only the DSI part implemented.

This allows the rk3588 with its current VOP support to drive a DSI display using the DSI2 controller driver I'll submit in a next step.

Only generic phy interfaces are used, so the DSI part is pretty straight forward.

changes in v3:
- add Krzysztof review tag to the binding
- address Sebastian's review comments
- better error handling
- dropping empty function
- headers
- not using of_match_ptr - this should also make the test-robot happier

changes in v2:
- fix error in dt-binding example
- drop unused frequency table
- pull in some more recent improvements from the vendor-kernel which includes a lot less magic values
- already include the support for rk3576
- use dev_err_probe

Heiko Stuebner (2):
dt-bindings: phy: Add Rockchip MIPI CSI/DSI PHY schema
phy: rockchip: Add Samsung CSI/DSI Combo DCPHY driver

Quoted 10 lines
 .../phy/rockchip,rk3588-mipi-dcphy.yaml       |   82 +
 drivers/phy/rockchip/Kconfig                  |   12 +
 drivers/phy/rockchip/Makefile                 |    1 +
 .../phy/rockchip/phy-rockchip-samsung-dcphy.c | 1647 +++++++++++++++++
 4 files changed, 1742 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/rockchip,rk3588-mipi-dcphy.yaml
 create mode 100644 drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c
Signature · 1 line
2.45.2

Thank you very much for these patches!

I tested this series on top of v6.12 with DSI/LVDS bridge in the following configuration:

RK3588 Tiger SoM (dsi0) --> TC358775 DSI/LVDS bridge --> LVDS display

I did not observe any undesirable artifacts on the display. Display blank/unblank works correctly.

Kind regards
Daniel

Tested-by on the v3 series
#6 lore raw
In reply to Heiko Stuebner

Hi,

Quoted 33 lines · Heiko Stuebner

This adds the phy driver need for DSI output on rk3588.

The phy itself is used for both DSI output and CSI input, though the CSI part for the whole chain needs a lot more work, so is left out for now and only the DSI part implemented.

This allows the rk3588 with its current VOP support to drive a DSI display using the DSI2 controller driver I'll submit in a next step.

Only generic phy interfaces are used, so the DSI part is pretty straight forward.

changes in v3:
- add Krzysztof review tag to the binding
- address Sebastian's review comments
- better error handling
- dropping empty function
- headers
- not using of_match_ptr - this should also make the test-robot happier

changes in v2:
- fix error in dt-binding example
- drop unused frequency table
- pull in some more recent improvements from the vendor-kernel which includes a lot less magic values
- already include the support for rk3576
- use dev_err_probe

Heiko Stuebner (2):
dt-bindings: phy: Add Rockchip MIPI CSI/DSI PHY schema
phy: rockchip: Add Samsung CSI/DSI Combo DCPHY driver

Quoted 7 lines
 .../phy/rockchip,rk3588-mipi-dcphy.yaml       |   82 +
 drivers/phy/rockchip/Kconfig                  |   12 +
 drivers/phy/rockchip/Makefile                 |    1 +
 .../phy/rockchip/phy-rockchip-samsung-dcphy.c | 1647 +++++++++++++++++
 4 files changed, 1742 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/rockchip,rk3588-mipi-dcphy.yaml
 create mode 100644 drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c

The series works for me on the RK3588 EVB1:

Greetings,

-- Sebastian