Skip to contentSkip to conversation

MIPI DSI phy for rk3588

PATCH Superseded Heiko Stuebner 2 participants 7 messages Feb 13, 2025 – Mar 12, 2025

Subsystems (3)

v6 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

Heiko Stuebner

author maintainer
#0 lore raw

v6 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 v6:
- rebase onto 6.14-rc1
- add Krzysztof binding review
- v5 was sent at the beginning of december '24, so probably has been lost

changes in v5:
- add bitfield.h for the FIELD_PROP definition
(reported by kernel-test-robot)
- add Sebastian's Reviewed-by
- add Conor's Ack to the dt-binding

changes in v4:
- moved to #phy-cells = 1 as suggested by Sebastian, with the argument denoting the requested phy-type (C-PHY, D-PHY). This works similarly how the Mediatek C/D-PHY already implements this, see mails around:
https://lore.kernel.org/all/[email protected]/
- dropped Krzysztof's review tag from the binding because of this
- dropped custom UPDATE macro and use FIELD_PREP instead
- build a FIELD_PREP_HIWORD macro for the GRF settings
- add received Tested-by tags

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 C-/D-PHY schema
phy: rockchip: Add Samsung MIPI D-/C-PHY driver

 .../phy/rockchip,rk3588-mipi-dcphy.yaml       |   87 +
 drivers/phy/rockchip/Kconfig                  |   12 +
 drivers/phy/rockchip/Makefile                 |    1 +
 .../phy/rockchip/phy-rockchip-samsung-dcphy.c | 1604 +++++++++++++++++
 4 files changed, 1704 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.47.2
author maintainer
#1 lore raw

PATCH v6 1/2 dt-bindings: phy: Add Rockchip MIPI C-/D-PHY schema

From: Heiko Stuebner <[email protected]>

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

---
 .../phy/rockchip,rk3588-mipi-dcphy.yaml       | 87 +++++++++++++++++++
 1 file changed, 87 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/rockchip,rk3588-mipi-dcphy.yaml
Documentation/devicetree/bindings/phy/rockchip,rk3588-mipi-dcphy.yaml new file +87 -0
new file mode 100644
index 000000000000..c8ff5ba22a86
@@ -0,0 +1,87 @@
+# 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 D-/C-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: 1
+    description: |
+      Argument is mode to operate in. Supported modes are:
+        - PHY_TYPE_DPHY
+        - PHY_TYPE_CPHY
+      See include/dt-bindings/phy/phy.h for constants.
+
+  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 = <1>;
+      };
+    };
Signature · 1 line
2.47.2
author maintainer
#2 lore raw

PATCH v6 2/2 phy: rockchip: Add Samsung MIPI D-/C-PHY driver

In reply to Heiko Stuebner

From: Heiko Stuebner <[email protected]>

Add driver for the MIPI D-/C-PHY block based around a Samsung IP-block that is for example needed to drive a MIPI DSI output on rk3588.

Right now only the D-PHY portion is implemented, with the C-PHY part needing separate work.

---
 drivers/phy/rockchip/Kconfig                  |   12 +
 drivers/phy/rockchip/Makefile                 |    1 +
 .../phy/rockchip/phy-rockchip-samsung-dcphy.c | 1604 +++++++++++++++++
 3 files changed, 1617 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 +1604 -0

1,604 lines not on this page · raw message

Signature · 1 line
2.47.2
maintainer
#3 lore raw

Re: [PATCH v6 2/2] phy: rockchip: Add Samsung MIPI D-/C-PHY driver

drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c line 49

Quoted 13 lines · Heiko Stuebner

From: Heiko Stuebner <[email protected]>

drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c new file +11 -0
+#define PLL_CON0		0x0100
+#define PLL_EN			BIT(12)
+#define S_MASK			GENMASK(10, 8)
+#define S(x)			FIELD_PREP(S_MASK, x)
+#define P_MASK			GENMASK(5, 0)
+#define P(x)			FIELD_PREP(P_MASK, x)
+#define PLL_CON1		0x0104
+#define PLL_CON2		0x0108
+#define M_MASK			GENMASK(9, 0)
+#define M(x)			FIELD_PREP(M_MASK, x)
+#define PLL_CON3		0x010c

lower case, nice.

...

drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c line 104

Quoted 4 lines
drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c new file +4 -0
+#define COMBO_MD0_GNR_CON0	0x0400
+#define COMBO_MD0_GNR_CON1	0x0404
+#define COMBO_MD0_ANA_CON0	0x0408
+#define COMBO_MD0_ANA_CON1      0x040C

upper one!

drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c line 110

Quoted 6 lines
drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c new file +6 -0
+#define COMBO_MD0_ANA_CON2	0x0410
+
+#define COMBO_MD0_TIME_CON0	0x0430
+#define COMBO_MD0_TIME_CON1	0x0434
+#define COMBO_MD0_TIME_CON2	0x0438
+#define COMBO_MD0_TIME_CON3	0x043C

and few more, lets be lower case everywhere please?

Quoted 4 lines
drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c new file +4 -0
+	{ 200,  7,   1,  0, 33,  9,  0, 26,  5,  0, 11},
+	{ 190,  7,   1,  0, 32,  9,  0, 25,  5,  0, 11},
+	{ 180,  6,   1,  0, 32,  8,  0, 25,  5,  0, 10},
+	{ 170,  6,   0,  0, 32,  8,  0, 25,  5,  0, 10},

drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c line 882

Quoted 10 lines
drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c new file +10 -0
+	{ 160,  5,   0,  0, 31,  8,  0, 24,  4,  0,  9},
+	{ 150,  5,   0,  0, 31,  8,  0, 24,  5,  0,  9},
+	{ 140,  5,   0,  0, 31,  8,  0, 24,  5,  0,  8},
+	{ 130,  4,   0,  0, 30,  6,  0, 23,  3,  0,  8},
+	{ 120,  4,   0,  0, 30,  6,  0, 23,  3,  0,  7},
+	{ 110,  3,   0,  0, 30,  6,  0, 23,  3,  0,  7},
+	{ 100,  3,   0,  0, 29,  5,  0, 22,  2,  0,  6},
+	{  90,  3,   0,  0, 29,  5,  0, 22,  2,  0,  6},
+	{  80,  2,   0,  0, 28,  5,  0, 22,  2,  0,  5},
+};

any word on where this table came from, maybe worth documenting that part

drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c line 886

Quoted 4 lines
drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c new file +4 -0
+
+static void samsung_mipi_dcphy_bias_block_enable(struct samsung_mipi_dcphy *samsung)
+{
+	u32 bias_con2 = 0x3223;

magic value?

drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c line 941

Quoted 7 lines
drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c new file +7 -0
+static void samsung_mipi_dphy_lane_disable(struct samsung_mipi_dcphy *samsung)
+{
+	regmap_update_bits(samsung->regmap, DPHY_MC_GNR_CON0, PHY_ENABLE, 0);
+	regmap_update_bits(samsung->regmap, COMBO_MD0_GNR_CON0, PHY_ENABLE, 0);
+	regmap_update_bits(samsung->regmap, COMBO_MD1_GNR_CON0, PHY_ENABLE, 0);
+	regmap_update_bits(samsung->regmap, COMBO_MD2_GNR_CON0, PHY_ENABLE, 0);
+	regmap_update_bits(samsung->regmap, DPHY_MD3_GNR_CON0, PHY_ENABLE, 0);

Is writing to a register (mmio) faster than a switch case for checking lane count and disabling specific lanes?

Quoted 19 lines
drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c new file +19 -0
+static void samsung_mipi_dcphy_pll_configure(struct samsung_mipi_dcphy *samsung)
+{
+	regmap_update_bits(samsung->regmap, PLL_CON0, S_MASK | P_MASK,
+			   S(samsung->pll.scaler) | P(samsung->pll.prediv));
+
+	if (samsung->pll.dsm < 0) {
+		u16 dsm_tmp;
+
+		/* Using opposite number subtraction to find complement */
+		dsm_tmp = abs(samsung->pll.dsm);
+		dsm_tmp = dsm_tmp - 1;
+		dsm_tmp ^= 0xffff;
+		regmap_write(samsung->regmap, PLL_CON1, dsm_tmp);
+	} else {
+		regmap_write(samsung->regmap, PLL_CON1, samsung->pll.dsm);
+	}
+
+	regmap_update_bits(samsung->regmap, PLL_CON2,
+			   M_MASK, M(samsung->pll.fbdiv));

drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c line 972

Quoted 10 lines
drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c new file +10 -0
+
+	if (samsung->pll.ssc_en) {
+		regmap_write(samsung->regmap, PLL_CON3,
+			     MRR(samsung->pll.mrr) | MFR(samsung->pll.mfr));
+		regmap_update_bits(samsung->regmap, PLL_CON4, SSCG_EN, SSCG_EN);
+	}
+
+	regmap_write(samsung->regmap, PLL_CON5, RESET_N_SEL | PLL_ENABLE_SEL);
+	regmap_write(samsung->regmap, PLL_CON7, PLL_LOCK_CNT(0xf000));
+	regmap_write(samsung->regmap, PLL_CON8, PLL_STB_CNT(0xf000));

I guess you are writing to upper nibble, maybe define that, if we can

Quoted 4 lines
drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c new file +4 -0
+static __maybe_unused int samsung_mipi_dcphy_runtime_resume(struct device *dev)
+{
+	struct samsung_mipi_dcphy *samsung = dev_get_drvdata(dev);
+	int ret;

drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c line 1544

Quoted 10 lines
drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c new file +10 -0
+
+	ret = clk_prepare_enable(samsung->pclk);
+	if (ret) {
+		dev_err(samsung->dev, "Failed to enable pclk, %d\n", ret);
+		return ret;
+	}
+
+	clk_prepare_enable(samsung->ref_clk);
+	if (ret) {
+		dev_err(samsung->dev, "Failed to enable reference clock, %d\n", ret);

No rollback of pclk here?

Signature · 1 line
~Vinod
author maintainer
#4 lore raw

Re: [PATCH v6 2/2] phy: rockchip: Add Samsung MIPI D-/C-PHY driver

Hi Vinod,

thanks for the review.
I've dropped all the parts that would've just gotten a "ok, changed" ;-)

Am Freitag, 14. Februar 2025, 13:13:42 MEZ schrieb Vinod Koul:

Quoted 11 lines · Heiko Stuebner
Quoted 10 lines
drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c new file +9 -0
+	{ 200,  7,   1,  0, 33,  9,  0, 26,  5,  0, 11},
+	{ 190,  7,   1,  0, 32,  9,  0, 25,  5,  0, 11},
+	{ 180,  6,   1,  0, 32,  8,  0, 25,  5,  0, 10},
+	{ 170,  6,   0,  0, 32,  8,  0, 25,  5,  0, 10},
+	{ 160,  5,   0,  0, 31,  8,  0, 24,  4,  0,  9},
+	{ 150,  5,   0,  0, 31,  8,  0, 24,  5,  0,  9},
+	{ 140,  5,   0,  0, 31,  8,  0, 24,  5,  0,  8},
+	{ 130,  4,   0,  0, 30,  6,  0, 23,  3,  0,  8},
+	{ 120,  4,   0,  0, 30,  6,  0, 23,  3,  0,  7},
Quoted 8 lines

drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c line 882

Quoted 5 lines
drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c new file +5 -0
+	{ 110,  3,   0,  0, 30,  6,  0, 23,  3,  0,  7},
+	{ 100,  3,   0,  0, 29,  5,  0, 22,  2,  0,  6},
+	{  90,  3,   0,  0, 29,  5,  0, 22,  2,  0,  6},
+	{  80,  2,   0,  0, 28,  5,  0, 22,  2,  0,  5},
+};

any word on where this table came from, maybe worth documenting that part

sadly not.

The table itself came from the vendor-kernel, and I would assume there it came from some super-secret additional documentation Rockchip got with the IP documentation.

It is sadly not part of the RK3588 manual.

Quoted 6 lines

drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c line 886

Quoted 4 lines
drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c new file +4 -0
+
+static void samsung_mipi_dcphy_bias_block_enable(struct samsung_mipi_dcphy *samsung)
+{
+	u32 bias_con2 = 0x3223;

magic value?

Converted over to some more meaningful constants.
Did the same to bias_con0+1 below that one too.

Quoted 10 lines

drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c line 941

Quoted 7 lines
drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c new file +7 -0
+static void samsung_mipi_dphy_lane_disable(struct samsung_mipi_dcphy *samsung)
+{
+	regmap_update_bits(samsung->regmap, DPHY_MC_GNR_CON0, PHY_ENABLE, 0);
+	regmap_update_bits(samsung->regmap, COMBO_MD0_GNR_CON0, PHY_ENABLE, 0);
+	regmap_update_bits(samsung->regmap, COMBO_MD1_GNR_CON0, PHY_ENABLE, 0);
+	regmap_update_bits(samsung->regmap, COMBO_MD2_GNR_CON0, PHY_ENABLE, 0);
+	regmap_update_bits(samsung->regmap, DPHY_MD3_GNR_CON0, PHY_ENABLE, 0);

Is writing to a register (mmio) faster than a switch case for checking lane count and disabling specific lanes?

It might make sense to mimic the lane_enable way of doing things, even if just for things looking the same in both functions.

I guess disabling lanes does not really care about minimal speed differences a switch/case would cause :-)

Quoted 24 lines
Quoted 24 lines
drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c new file +23 -0
+static void samsung_mipi_dcphy_pll_configure(struct samsung_mipi_dcphy *samsung)
+{
+	regmap_update_bits(samsung->regmap, PLL_CON0, S_MASK | P_MASK,
+			   S(samsung->pll.scaler) | P(samsung->pll.prediv));
+
+	if (samsung->pll.dsm < 0) {
+		u16 dsm_tmp;
+
+		/* Using opposite number subtraction to find complement */
+		dsm_tmp = abs(samsung->pll.dsm);
+		dsm_tmp = dsm_tmp - 1;
+		dsm_tmp ^= 0xffff;
+		regmap_write(samsung->regmap, PLL_CON1, dsm_tmp);
+	} else {
+		regmap_write(samsung->regmap, PLL_CON1, samsung->pll.dsm);
+	}
+
+	regmap_update_bits(samsung->regmap, PLL_CON2,
+			   M_MASK, M(samsung->pll.fbdiv));
+
+	if (samsung->pll.ssc_en) {
+		regmap_write(samsung->regmap, PLL_CON3,
+			     MRR(samsung->pll.mrr) | MFR(samsung->pll.mfr));
Quoted 8 lines

drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c line 972

Quoted 6 lines
drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c new file +6 -0
+		regmap_update_bits(samsung->regmap, PLL_CON4, SSCG_EN, SSCG_EN);
+	}
+
+	regmap_write(samsung->regmap, PLL_CON5, RESET_N_SEL | PLL_ENABLE_SEL);
+	regmap_write(samsung->regmap, PLL_CON7, PLL_LOCK_CNT(0xf000));
+	regmap_write(samsung->regmap, PLL_CON8, PLL_STB_CNT(0xf000));

I guess you are writing to upper nibble, maybe define that, if we can

Nope ... the value is defined as bits [15:0] and both being pll lock and stabilization timing control registers. Sadly yet again, their usage detail is not documented, the manual even does not supply a unit for the register value :-(

Heiko

maintainer
#5 lore raw

Re: [PATCH v6 2/2] phy: rockchip: Add Samsung MIPI D-/C-PHY driver

Sorry this slipped thru...

Quoted 26 lines · Heiko Stübner

Hi Vinod,

thanks for the review.
I've dropped all the parts that would've just gotten a "ok, changed" ;-)

Am Freitag, 14. Februar 2025, 13:13:42 MEZ schrieb Vinod Koul:

Quoted 11 lines · Heiko Stuebner
Quoted 10 lines
drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c new file +9 -0
+	{ 200,  7,   1,  0, 33,  9,  0, 26,  5,  0, 11},
+	{ 190,  7,   1,  0, 32,  9,  0, 25,  5,  0, 11},
+	{ 180,  6,   1,  0, 32,  8,  0, 25,  5,  0, 10},
+	{ 170,  6,   0,  0, 32,  8,  0, 25,  5,  0, 10},
+	{ 160,  5,   0,  0, 31,  8,  0, 24,  4,  0,  9},
+	{ 150,  5,   0,  0, 31,  8,  0, 24,  5,  0,  9},
+	{ 140,  5,   0,  0, 31,  8,  0, 24,  5,  0,  8},
+	{ 130,  4,   0,  0, 30,  6,  0, 23,  3,  0,  8},
+	{ 120,  4,   0,  0, 30,  6,  0, 23,  3,  0,  7},
Quoted 8 lines

drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c line 882

Quoted 5 lines
drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c new file +5 -0
+	{ 110,  3,   0,  0, 30,  6,  0, 23,  3,  0,  7},
+	{ 100,  3,   0,  0, 29,  5,  0, 22,  2,  0,  6},
+	{  90,  3,   0,  0, 29,  5,  0, 22,  2,  0,  6},
+	{  80,  2,   0,  0, 28,  5,  0, 22,  2,  0,  5},
+};

any word on where this table came from, maybe worth documenting that part

Quoted 3 lines

sadly not.

The table itself came from the vendor-kernel, and I would assume there

Maybe make a note that this is from vendor kernel

Quoted 28 lines

it came from some super-secret additional documentation Rockchip got with the IP documentation.

It is sadly not part of the RK3588 manual.

Quoted 6 lines

drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c line 886

Quoted 4 lines
drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c new file +4 -0
+
+static void samsung_mipi_dcphy_bias_block_enable(struct samsung_mipi_dcphy *samsung)
+{
+	u32 bias_con2 = 0x3223;

magic value?

Converted over to some more meaningful constants.
Did the same to bias_con0+1 below that one too.

Quoted 10 lines

drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c line 941

Quoted 7 lines
drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c new file +7 -0
+static void samsung_mipi_dphy_lane_disable(struct samsung_mipi_dcphy *samsung)
+{
+	regmap_update_bits(samsung->regmap, DPHY_MC_GNR_CON0, PHY_ENABLE, 0);
+	regmap_update_bits(samsung->regmap, COMBO_MD0_GNR_CON0, PHY_ENABLE, 0);
+	regmap_update_bits(samsung->regmap, COMBO_MD1_GNR_CON0, PHY_ENABLE, 0);
+	regmap_update_bits(samsung->regmap, COMBO_MD2_GNR_CON0, PHY_ENABLE, 0);
+	regmap_update_bits(samsung->regmap, DPHY_MD3_GNR_CON0, PHY_ENABLE, 0);

Is writing to a register (mmio) faster than a switch case for checking lane count and disabling specific lanes?

Quoted 5 lines

It might make sense to mimic the lane_enable way of doing things, even if just for things looking the same in both functions.

I guess disabling lanes does not really care about minimal speed differences a switch/case would cause :-)

ok

Quoted 34 lines
Quoted 25 lines
Quoted 25 lines
drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c new file +23 -0
+static void samsung_mipi_dcphy_pll_configure(struct samsung_mipi_dcphy *samsung)
+{
+	regmap_update_bits(samsung->regmap, PLL_CON0, S_MASK | P_MASK,
+			   S(samsung->pll.scaler) | P(samsung->pll.prediv));
+
+	if (samsung->pll.dsm < 0) {
+		u16 dsm_tmp;
+
+		/* Using opposite number subtraction to find complement */
+		dsm_tmp = abs(samsung->pll.dsm);
+		dsm_tmp = dsm_tmp - 1;
+		dsm_tmp ^= 0xffff;
+		regmap_write(samsung->regmap, PLL_CON1, dsm_tmp);
+	} else {
+		regmap_write(samsung->regmap, PLL_CON1, samsung->pll.dsm);
+	}
+
+	regmap_update_bits(samsung->regmap, PLL_CON2,
+			   M_MASK, M(samsung->pll.fbdiv));
+
+	if (samsung->pll.ssc_en) {
+		regmap_write(samsung->regmap, PLL_CON3,
+			     MRR(samsung->pll.mrr) | MFR(samsung->pll.mfr));
Quoted 8 lines

drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c line 972

Quoted 6 lines
drivers/phy/rockchip/phy-rockchip-samsung-dcphy.c new file +6 -0
+		regmap_update_bits(samsung->regmap, PLL_CON4, SSCG_EN, SSCG_EN);
+	}
+
+	regmap_write(samsung->regmap, PLL_CON5, RESET_N_SEL | PLL_ENABLE_SEL);
+	regmap_write(samsung->regmap, PLL_CON7, PLL_LOCK_CNT(0xf000));
+	regmap_write(samsung->regmap, PLL_CON8, PLL_STB_CNT(0xf000));

I guess you are writing to upper nibble, maybe define that, if we can

Quoted 4 lines

Nope ... the value is defined as bits [15:0] and both being pll lock and stabilization timing control registers. Sadly yet again, their usage detail is not documented, the manual even does not supply a unit for the register value :-(

:-(

Signature · 1 line
~Vinod
author maintainer Tested-by Quentin Schulz on the v6 series
#6 lore raw
In reply to Heiko Stuebner

Am Donnerstag, 13. Februar 2025, 22:05:46 MEZ schrieb Heiko Stuebner:

Quoted 54 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 v6:
- rebase onto 6.14-rc1
- add Krzysztof binding review
- v5 was sent at the beginning of december '24, so probably has been lost

changes in v5:
- add bitfield.h for the FIELD_PROP definition
(reported by kernel-test-robot)
- add Sebastian's Reviewed-by
- add Conor's Ack to the dt-binding

changes in v4:
- moved to #phy-cells = 1 as suggested by Sebastian, with the argument denoting the requested phy-type (C-PHY, D-PHY). This works similarly how the Mediatek C/D-PHY already implements this, see mails around:
https://lore.kernel.org/all/[email protected]/
- dropped Krzysztof's review tag from the binding because of this
- dropped custom UPDATE macro and use FIELD_PREP instead
- build a FIELD_PREP_HIWORD macro for the GRF settings
- add received Tested-by tags

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 C-/D-PHY schema
phy: rockchip: Add Samsung MIPI D-/C-PHY driver

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

Forgot to transplant from the v5 cover-letter - the series got a

on RK3588 Tiger with Haikou Video Demo in [0]

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