Skip to contentSkip to conversation

soc: imx: imx8m-blk-ctrl: Fix imx8mm mipi reset

PATCH Superseded Adam Ford 7 participants 29 messages Nov 6, 2021 – Nov 29, 2021

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Adam Ford

author
#0 lore raw

PATCH v2 1/5 soc: imx: imx8m-blk-ctrl: Fix imx8mm mipi reset

Most of the blk-ctrl reset bits are found in one register, however there are two bits in offset 8 for pulling the MIPI DPHY out of reset and these need to be set when IMX8MM_DISPBLK_PD_MIPI_CSI is brought out of reset or the MIPI_CSI hangs.

Fixes 926e57c065df ("soc: imx: imx8m-blk-ctrl: add DISP blk-ctrl")

---

V2: Make a note that the extra register is only for Mini/Nano DISPLAY_BLK_CTRL
Rename the new register to mipi_phy_rst_mask
Encapsulate the edits to this register with an if-statement

 drivers/soc/imx/imx8m-blk-ctrl.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/soc/imx/imx8m-blk-ctrl.c +18 -0
index 519b3651d1d9..581eb4bc7f7d 100644
@@ -17,6 +17,7 @@
 
 #define BLK_SFT_RSTN	0x0
 #define BLK_CLK_EN	0x4
+#define BLK_MIPI_RESET_DIV	0x8 /* Mini/Nano DISPLAY_BLK_CTRL only */
 
 struct imx8m_blk_ctrl_domain;
 
@@ -36,6 +37,15 @@ struct imx8m_blk_ctrl_domain_data {
 	const char *gpc_name;
 	u32 rst_mask;
 	u32 clk_mask;
+
+	/*
+	 * i.MX8M Mini and Nano have a third DISPLAY_BLK_CTRL register
+	 * which is used to control the reset for the MIPI Phy.
+	 * Since it's only present in certain circumstances,
+	 * an if-statement should be used before setting and clearing this
+	 * register.
+	 */
+	u32 mipi_phy_rst_mask;
 };
 
 #define DOMAIN_MAX_CLKS 3
@@ -78,6 +88,8 @@ static int imx8m_blk_ctrl_power_on(struct generic_pm_domain *genpd)
 
 	/* put devices into reset */
 	regmap_clear_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
+	if (data->mipi_phy_rst_mask)
+		regmap_clear_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
 
 	/* enable upstream and blk-ctrl clocks to allow reset to propagate */
 	ret = clk_bulk_prepare_enable(data->num_clks, domain->clks);
@@ -99,6 +111,8 @@ static int imx8m_blk_ctrl_power_on(struct generic_pm_domain *genpd)
 
 	/* release reset */
 	regmap_set_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
+	if (data->mipi_phy_rst_mask)
+		regmap_set_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
 
 	/* disable upstream clocks */
 	clk_bulk_disable_unprepare(data->num_clks, domain->clks);
@@ -120,6 +134,9 @@ static int imx8m_blk_ctrl_power_off(struct generic_pm_domain *genpd)
 	struct imx8m_blk_ctrl *bc = domain->bc;
 
 	/* put devices into reset and disable clocks */
+	if (data->mipi_phy_rst_mask)
+		regmap_clear_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
+
 	regmap_clear_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
 	regmap_clear_bits(bc->regmap, BLK_CLK_EN, data->clk_mask);
 
@@ -488,6 +505,7 @@ static const struct imx8m_blk_ctrl_domain_data imx8mm_disp_blk_ctl_domain_data[]
 		.gpc_name = "mipi-csi",
 		.rst_mask = BIT(3) | BIT(4),
 		.clk_mask = BIT(10) | BIT(11),
+		.mipi_phy_rst_mask = BIT(16) | BIT(17),
 	},
 };
 
Signature · 1 line
2.32.0
author
#1 lore raw

PATCH v2 2/5 arm64: dts: imx8mm: Add CSI nodes

There is a csi bridge and csis interface that tie together to allow csi2 capture.

---
V2: No change

 arch/arm64/boot/dts/freescale/imx8mm.dtsi | 51 +++++++++++++++++++++++
 1 file changed, 51 insertions(+)
arch/arm64/boot/dts/freescale/imx8mm.dtsi +51 -0
index c2f3f118f82e..1f69c14d953f 100644
@@ -1068,6 +1068,22 @@ aips4: bus@32c00000 {
 			#size-cells = <1>;
 			ranges = <0x32c00000 0x32c00000 0x400000>;
 
+			csi: csi@32e20000 {
+				compatible = "fsl,imx8mm-csi", "fsl,imx7-csi";
+				reg = <0x32e20000 0x1000>;
+				interrupts = <GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>;
+				clocks = <&clk IMX8MM_CLK_CSI1_ROOT>;
+				clock-names = "mclk";
+				power-domains = <&disp_blk_ctrl IMX8MM_DISPBLK_PD_CSI_BRIDGE>;
+				status = "disabled";
+
+				port {
+					csi_in: endpoint {
+						remote-endpoint = <&imx8mm_mipi_csi_out>;
+					};
+				};
+			};
+
 			disp_blk_ctrl: blk-ctrl@32e28000 {
 				compatible = "fsl,imx8mm-disp-blk-ctrl", "syscon";
 				reg = <0x32e28000 0x100>;
@@ -1095,6 +1111,41 @@ disp_blk_ctrl: blk-ctrl@32e28000 {
 				#power-domain-cells = <1>;
 			};
 
+			mipi_csi: mipi-csi@32e30000 {
+				compatible = "fsl,imx8mm-mipi-csi2";
+				reg = <0x32e30000 0x1000>;
+				interrupts = <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>;
+				assigned-clocks = <&clk IMX8MM_CLK_CSI1_CORE>,
+						  <&clk IMX8MM_CLK_CSI1_PHY_REF>;
+				assigned-clock-parents = <&clk IMX8MM_SYS_PLL2_1000M>,
+							  <&clk IMX8MM_SYS_PLL2_1000M>;
+				clock-frequency = <333000000>;
+				clocks = <&clk IMX8MM_CLK_DISP_APB_ROOT>,
+					 <&clk IMX8MM_CLK_CSI1_ROOT>,
+					 <&clk IMX8MM_CLK_CSI1_PHY_REF>,
+					 <&clk IMX8MM_CLK_DISP_AXI_ROOT>;
+				clock-names = "pclk", "wrap", "phy", "axi";
+				power-domains = <&disp_blk_ctrl IMX8MM_DISPBLK_PD_MIPI_CSI>;
+				status = "disabled";
+
+				ports {
+					#address-cells = <1>;
+					#size-cells = <0>;
+
+					port@0 {
+						reg = <0>;
+					};
+
+					port@1 {
+						reg = <1>;
+
+						imx8mm_mipi_csi_out: endpoint {
+							remote-endpoint = <&csi_in>;
+						};
+					};
+				};
+			};
+
 			usbotg1: usb@32e40000 {
 				compatible = "fsl,imx8mm-usb", "fsl,imx7d-usb";
 				reg = <0x32e40000 0x200>;
Signature · 1 line
2.32.0
author
#3 lore raw

PATCH v2 3/5 arm64: defconfig: Enable VIDEO_IMX_MEDIA

In reply to Adam Ford

To use a camera, the CSIS and CSI drivers need to be enabled with VIDEO_IMX_MEDIA.

---
V2: No Change

 arch/arm64/configs/defconfig | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/configs/defconfig +1 -0
index f2e2b9bdd702..bc261cf2ef5a 100644
@@ -958,6 +958,7 @@ CONFIG_MFD_CROS_EC_DEV=y
 CONFIG_STAGING=y
 CONFIG_STAGING_MEDIA=y
 CONFIG_VIDEO_HANTRO=m
+CONFIG_VIDEO_IMX_MEDIA=m
 CONFIG_CHROME_PLATFORMS=y
 CONFIG_CROS_EC=y
 CONFIG_CROS_EC_I2C=y
Signature · 1 line
2.32.0
reviewer Reviewed-by on v2 3/5
#4 lore raw

Re: [PATCH V2 3/5] arm64: defconfig: Enable VIDEO_IMX_MEDIA

Quoted 3 lines · Adam Ford

To use a camera, the CSIS and CSI drivers need to be enabled with VIDEO_IMX_MEDIA.

author
#5 lore raw

PATCH v2 4/5 arm64: dts: imx8mm-beacon: Enable OV5640 Camera

In reply to Adam Ford

The baseboard has support for a TDNext 5640 Camera which uses an OV5640 connected to a 2-lane CSI2 interface.

With the CSI and mipi_csi2 drivers pointing to an OV5640 camera, the media pipeline can be configured with the following:

    media-ctl --links "'ov5640 1-003c':0->'imx7-mipi-csis.0':0[1]"

The camera and various nodes in the pipeline can be configured for UYVY:

    media-ctl -v -V "'ov5640 1-003c':0 [fmt:UYVY8_1X16/640x480 field:none]"
    media-ctl -v -V "'csi':0 [fmt:UYVY8_1X16/640x480 field:none]"

---
V2: No change

 .../freescale/imx8mm-beacon-baseboard.dtsi    | 58 +++++++++++++++++++
 1 file changed, 58 insertions(+)
arch/arm64/boot/dts/freescale/imx8mm-beacon-baseboard.dtsi +58 -0
index 6f5e63696ec0..0fb95f4a5e78 100644
@@ -43,6 +43,16 @@ reg_audio: regulator-audio {
 		enable-active-high;
 	};
 
+	reg_camera: regulator-camera {
+		compatible = "regulator-fixed";
+		regulator-name = "mipi_pwr";
+		regulator-min-microvolt = <2800000>;
+		regulator-max-microvolt = <2800000>;
+		gpio = <&pca6416_1 0 GPIO_ACTIVE_HIGH>;
+		enable-active-high;
+		startup-delay-us = <100000>;
+	};
+
 	reg_usdhc2_vmmc: regulator-usdhc2 {
 		compatible = "regulator-fixed";
 		regulator-name = "VSD_3V3";
@@ -67,6 +77,10 @@ sound {
 	};
 };
 
+&csi {
+	status = "okay";
+};
+
 &ecspi2 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&pinctrl_espi2>;
@@ -90,6 +104,30 @@ &i2c2 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&pinctrl_i2c2>;
 	status = "okay";
+
+	camera@3c {
+		compatible = "ovti,ov5640";
+		pinctrl-names = "default";
+		pinctrl-0 = <&pinctrl_ov5640>;
+		reg = <0x3c>;
+		clocks = <&clk IMX8MM_CLK_CLKO1>;
+		clock-names = "xclk";
+		assigned-clocks = <&clk IMX8MM_CLK_CLKO1>;
+		assigned-clock-parents = <&clk IMX8MM_CLK_24M>;
+		assigned-clock-rates = <24000000>;
+		AVDD-supply = <&reg_camera>;  /* 2.8v */
+		powerdown-gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>;
+		reset-gpios = <&gpio1 6 GPIO_ACTIVE_LOW>;
+
+		port {
+			/* MIPI CSI-2 bus endpoint */
+			ov5640_to_mipi_csi2: endpoint {
+				remote-endpoint = <&imx8mm_mipi_csi_in>;
+				clock-lanes = <0>;
+				data-lanes = <1 2>;
+			};
+		};
+	};
 };
 
 &i2c4 {
@@ -141,6 +179,18 @@ pca6416_1: gpio@21 {
 	};
 };
 
+&mipi_csi {
+	status = "okay";
+	ports {
+		port@0 {
+			imx8mm_mipi_csi_in: endpoint {
+				remote-endpoint = <&ov5640_to_mipi_csi2>;
+				data-lanes = <1 2>;
+			};
+		};
+	};
+};
+
 &sai3 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&pinctrl_sai3>;
@@ -209,6 +259,14 @@ MX8MM_IOMUXC_SAI3_RXFS_GPIO4_IO28	0x41
 		>;
 	};
 
+	pinctrl_ov5640: ov5640grp {
+		fsl,pins = <
+			MX8MM_IOMUXC_GPIO1_IO07_GPIO1_IO7		0x19
+			MX8MM_IOMUXC_GPIO1_IO06_GPIO1_IO6		0x19
+			MX8MM_IOMUXC_GPIO1_IO14_CCMSRCGPCMIX_CLKO1	0x59
+		>;
+	};
+
 	pinctrl_pcal6414: pcal6414-gpiogrp {
 		fsl,pins = <
 			MX8MM_IOMUXC_SAI2_MCLK_GPIO4_IO27		0x19
Signature · 1 line
2.32.0
reviewer Reviewed-by on v2 4/5
#6 lore raw

Re: [PATCH V2 4/5] arm64: dts: imx8mm-beacon: Enable OV5640 Camera

Quoted 7 lines · Adam Ford

The baseboard has support for a TDNext 5640 Camera which uses an OV5640 connected to a 2-lane CSI2 interface.

With the CSI and mipi_csi2 drivers pointing to an OV5640 camera, the media pipeline can be configured with the following:

Quoted 7 lines
    media-ctl --links "'ov5640 1-003c':0->'imx7-mipi-csis.0':0[1]"

The camera and various nodes in the pipeline can be configured for UYVY:

    media-ctl -v -V "'ov5640 1-003c':0 [fmt:UYVY8_1X16/640x480 field:none]"
    media-ctl -v -V "'csi':0 [fmt:UYVY8_1X16/640x480 field:none]"
#7 lore raw

Re: [PATCH V2 4/5] arm64: dts: imx8mm-beacon: Enable OV5640 Camera

In reply to Adam Ford

Hi Adam,

Thank you for the patch.

Quoted 6 lines · Adam Ford

The baseboard has support for a TDNext 5640 Camera which uses an OV5640 connected to a 2-lane CSI2 interface.

With the CSI and mipi_csi2 drivers pointing to an OV5640 camera, the media pipeline can be configured with the following:

Quoted 7 lines
    media-ctl --links "'ov5640 1-003c':0->'imx7-mipi-csis.0':0[1]"

The camera and various nodes in the pipeline can be configured for UYVY:

    media-ctl -v -V "'ov5640 1-003c':0 [fmt:UYVY8_1X16/640x480 field:none]"
    media-ctl -v -V "'csi':0 [fmt:UYVY8_1X16/640x480 field:none]"

As the ov5640 is on an add-on module, would a DT overlay be better ?

Quoted 103 lines

---
V2: No change

 .../freescale/imx8mm-beacon-baseboard.dtsi    | 58 +++++++++++++++++++
 1 file changed, 58 insertions(+)
arch/arm64/boot/dts/freescale/imx8mm-beacon-baseboard.dtsi +58 -0
index 6f5e63696ec0..0fb95f4a5e78 100644
@@ -43,6 +43,16 @@ reg_audio: regulator-audio {
 		enable-active-high;
 	};
 
+	reg_camera: regulator-camera {
+		compatible = "regulator-fixed";
+		regulator-name = "mipi_pwr";
+		regulator-min-microvolt = <2800000>;
+		regulator-max-microvolt = <2800000>;
+		gpio = <&pca6416_1 0 GPIO_ACTIVE_HIGH>;
+		enable-active-high;
+		startup-delay-us = <100000>;
+	};
+
 	reg_usdhc2_vmmc: regulator-usdhc2 {
 		compatible = "regulator-fixed";
 		regulator-name = "VSD_3V3";
@@ -67,6 +77,10 @@ sound {
 	};
 };
 
+&csi {
+	status = "okay";
+};
+
 &ecspi2 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&pinctrl_espi2>;
@@ -90,6 +104,30 @@ &i2c2 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&pinctrl_i2c2>;
 	status = "okay";
+
+	camera@3c {
+		compatible = "ovti,ov5640";
+		pinctrl-names = "default";
+		pinctrl-0 = <&pinctrl_ov5640>;
+		reg = <0x3c>;
+		clocks = <&clk IMX8MM_CLK_CLKO1>;
+		clock-names = "xclk";
+		assigned-clocks = <&clk IMX8MM_CLK_CLKO1>;
+		assigned-clock-parents = <&clk IMX8MM_CLK_24M>;
+		assigned-clock-rates = <24000000>;
+		AVDD-supply = <&reg_camera>;  /* 2.8v */
+		powerdown-gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>;
+		reset-gpios = <&gpio1 6 GPIO_ACTIVE_LOW>;
+
+		port {
+			/* MIPI CSI-2 bus endpoint */
+			ov5640_to_mipi_csi2: endpoint {
+				remote-endpoint = <&imx8mm_mipi_csi_in>;
+				clock-lanes = <0>;
+				data-lanes = <1 2>;
+			};
+		};
+	};
 };
 
 &i2c4 {
@@ -141,6 +179,18 @@ pca6416_1: gpio@21 {
 	};
 };
 
+&mipi_csi {
+	status = "okay";
+	ports {
+		port@0 {
+			imx8mm_mipi_csi_in: endpoint {
+				remote-endpoint = <&ov5640_to_mipi_csi2>;
+				data-lanes = <1 2>;
+			};
+		};
+	};
+};
+
 &sai3 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&pinctrl_sai3>;
@@ -209,6 +259,14 @@ MX8MM_IOMUXC_SAI3_RXFS_GPIO4_IO28	0x41
 		>;
 	};
 
+	pinctrl_ov5640: ov5640grp {
+		fsl,pins = <
+			MX8MM_IOMUXC_GPIO1_IO07_GPIO1_IO7		0x19
+			MX8MM_IOMUXC_GPIO1_IO06_GPIO1_IO6		0x19
+			MX8MM_IOMUXC_GPIO1_IO14_CCMSRCGPCMIX_CLKO1	0x59
+		>;
+	};
+
 	pinctrl_pcal6414: pcal6414-gpiogrp {
 		fsl,pins = <
 			MX8MM_IOMUXC_SAI2_MCLK_GPIO4_IO27		0x19
Signature · 3 lines
Regards,

Laurent Pinchart
author
#8 lore raw

Re: [PATCH V2 4/5] arm64: dts: imx8mm-beacon: Enable OV5640 Camera

Quoted 14 lines · Laurent Pinchart

Hi Adam,

Thank you for the patch.

Quoted 8 lines · Adam Ford

The baseboard has support for a TDNext 5640 Camera which uses an OV5640 connected to a 2-lane CSI2 interface.

With the CSI and mipi_csi2 drivers pointing to an OV5640 camera, the media pipeline can be configured with the following:

    media-ctl --links "'ov5640 1-003c':0->'imx7-mipi-csis.0':0[1]"
Quoted 7 lines
Quoted 5 lines

The camera and various nodes in the pipeline can be configured for UYVY:

    media-ctl -v -V "'ov5640 1-003c':0 [fmt:UYVY8_1X16/640x480 field:none]"
    media-ctl -v -V "'csi':0 [fmt:UYVY8_1X16/640x480 field:none]"

As the ov5640 is on an add-on module, would a DT overlay be better ?

At least for the Beacon / LogicPD boards, I would prefer to avoid the overlays. We have an i.M6Q and an OMAP3 board with cameras enabled in our development kit device trees. If the cameras are not connected, they just display a message that the cameras are not communicating and move on. I'm OK with that.

Quoted 109 lines
Quoted 94 lines

---
V2: No change

 .../freescale/imx8mm-beacon-baseboard.dtsi    | 58 +++++++++++++++++++
 1 file changed, 58 insertions(+)
arch/arm64/boot/dts/freescale/imx8mm-beacon-baseboard.dtsi +51 -0
index 6f5e63696ec0..0fb95f4a5e78 100644
@@ -43,6 +43,16 @@ reg_audio: regulator-audio {
              enable-active-high;
      };
 
+     reg_camera: regulator-camera {
+             compatible = "regulator-fixed";
+             regulator-name = "mipi_pwr";
+             regulator-min-microvolt = <2800000>;
+             regulator-max-microvolt = <2800000>;
+             gpio = <&pca6416_1 0 GPIO_ACTIVE_HIGH>;
+             enable-active-high;
+             startup-delay-us = <100000>;
+     };
+
      reg_usdhc2_vmmc: regulator-usdhc2 {
              compatible = "regulator-fixed";
              regulator-name = "VSD_3V3";
@@ -67,6 +77,10 @@ sound {
      };
 };
 
+&csi {
+     status = "okay";
+};
+
 &ecspi2 {
      pinctrl-names = "default";
      pinctrl-0 = <&pinctrl_espi2>;
@@ -90,6 +104,30 @@ &i2c2 {
      pinctrl-names = "default";
      pinctrl-0 = <&pinctrl_i2c2>;
      status = "okay";
+
+     camera@3c {
+             compatible = "ovti,ov5640";
+             pinctrl-names = "default";
+             pinctrl-0 = <&pinctrl_ov5640>;
+             reg = <0x3c>;
+             clocks = <&clk IMX8MM_CLK_CLKO1>;
+             clock-names = "xclk";
+             assigned-clocks = <&clk IMX8MM_CLK_CLKO1>;
+             assigned-clock-parents = <&clk IMX8MM_CLK_24M>;
+             assigned-clock-rates = <24000000>;
+             AVDD-supply = <&reg_camera>;  /* 2.8v */
+             powerdown-gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>;
+             reset-gpios = <&gpio1 6 GPIO_ACTIVE_LOW>;
+
+             port {
+                     /* MIPI CSI-2 bus endpoint */
+                     ov5640_to_mipi_csi2: endpoint {
+                             remote-endpoint = <&imx8mm_mipi_csi_in>;
+                             clock-lanes = <0>;
+                             data-lanes = <1 2>;
+                     };
+             };
+     };
 };
 
 &i2c4 {
@@ -141,6 +179,18 @@ pca6416_1: gpio@21 {
      };
 };
 
+&mipi_csi {
+     status = "okay";
+     ports {
+             port@0 {
+                     imx8mm_mipi_csi_in: endpoint {
+                             remote-endpoint = <&ov5640_to_mipi_csi2>;
+                             data-lanes = <1 2>;
+                     };
+             };
+     };
+};
+
 &sai3 {
      pinctrl-names = "default";
      pinctrl-0 = <&pinctrl_sai3>;
@@ -209,6 +259,14 @@ MX8MM_IOMUXC_SAI3_RXFS_GPIO4_IO28        0x41
              >;
      };
 
+     pinctrl_ov5640: ov5640grp {

arch/arm64/boot/dts/freescale/imx8mm-beacon-baseboard.dtsi MX8MM_IOMUXC_SAI3_RXFS_GPIO4_IO28 0x41 · line 272

Quoted 10 lines
arch/arm64/boot/dts/freescale/imx8mm-beacon-baseboard.dtsi +7 -0
+             fsl,pins = <
+                     MX8MM_IOMUXC_GPIO1_IO07_GPIO1_IO7               0x19
+                     MX8MM_IOMUXC_GPIO1_IO06_GPIO1_IO6               0x19
+                     MX8MM_IOMUXC_GPIO1_IO14_CCMSRCGPCMIX_CLKO1      0x59
+             >;
+     };
+
      pinctrl_pcal6414: pcal6414-gpiogrp {
              fsl,pins = <
                      MX8MM_IOMUXC_SAI2_MCLK_GPIO4_IO27               0x19

--
Regards,

Laurent Pinchart

#9 lore raw

Re: [PATCH V2 4/5] arm64: dts: imx8mm-beacon: Enable OV5640 Camera

Hi Adam,

Quoted 16 lines · Adam Ford
Quoted 15 lines · Laurent Pinchart
Quoted 13 lines · Adam Ford

The baseboard has support for a TDNext 5640 Camera which uses an OV5640 connected to a 2-lane CSI2 interface.

With the CSI and mipi_csi2 drivers pointing to an OV5640 camera, the media pipeline can be configured with the following:

    media-ctl --links "'ov5640 1-003c':0->'imx7-mipi-csis.0':0[1]"

The camera and various nodes in the pipeline can be configured for UYVY:

    media-ctl -v -V "'ov5640 1-003c':0 [fmt:UYVY8_1X16/640x480 field:none]"
    media-ctl -v -V "'csi':0 [fmt:UYVY8_1X16/640x480 field:none]"
Quoted 7 lines
Quoted 1 line

As the ov5640 is on an add-on module, would a DT overlay be better ?

At least for the Beacon / LogicPD boards, I would prefer to avoid the overlays. We have an i.M6Q and an OMAP3 board with cameras enabled in our development kit device trees. If the cameras are not connected, they just display a message that the cameras are not communicating and move on. I'm OK with that.

You know the board better than I do, so I won't push against this, but I still think it may not lead to the best user experience, especially if a user wanted to connect a different sensor to the development board.

Quoted 103 lines
Quoted 103 lines
Quoted 103 lines

---
V2: No change

 .../freescale/imx8mm-beacon-baseboard.dtsi    | 58 +++++++++++++++++++
 1 file changed, 58 insertions(+)
arch/arm64/boot/dts/freescale/imx8mm-beacon-baseboard.dtsi +58 -0
index 6f5e63696ec0..0fb95f4a5e78 100644
@@ -43,6 +43,16 @@ reg_audio: regulator-audio {
              enable-active-high;
      };
 
+     reg_camera: regulator-camera {
+             compatible = "regulator-fixed";
+             regulator-name = "mipi_pwr";
+             regulator-min-microvolt = <2800000>;
+             regulator-max-microvolt = <2800000>;
+             gpio = <&pca6416_1 0 GPIO_ACTIVE_HIGH>;
+             enable-active-high;
+             startup-delay-us = <100000>;
+     };
+
      reg_usdhc2_vmmc: regulator-usdhc2 {
              compatible = "regulator-fixed";
              regulator-name = "VSD_3V3";
@@ -67,6 +77,10 @@ sound {
      };
 };
 
+&csi {
+     status = "okay";
+};
+
 &ecspi2 {
      pinctrl-names = "default";
      pinctrl-0 = <&pinctrl_espi2>;
@@ -90,6 +104,30 @@ &i2c2 {
      pinctrl-names = "default";
      pinctrl-0 = <&pinctrl_i2c2>;
      status = "okay";
+
+     camera@3c {
+             compatible = "ovti,ov5640";
+             pinctrl-names = "default";
+             pinctrl-0 = <&pinctrl_ov5640>;
+             reg = <0x3c>;
+             clocks = <&clk IMX8MM_CLK_CLKO1>;
+             clock-names = "xclk";
+             assigned-clocks = <&clk IMX8MM_CLK_CLKO1>;
+             assigned-clock-parents = <&clk IMX8MM_CLK_24M>;
+             assigned-clock-rates = <24000000>;
+             AVDD-supply = <&reg_camera>;  /* 2.8v */
+             powerdown-gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>;
+             reset-gpios = <&gpio1 6 GPIO_ACTIVE_LOW>;
+
+             port {
+                     /* MIPI CSI-2 bus endpoint */
+                     ov5640_to_mipi_csi2: endpoint {
+                             remote-endpoint = <&imx8mm_mipi_csi_in>;
+                             clock-lanes = <0>;
+                             data-lanes = <1 2>;
+                     };
+             };
+     };
 };
 
 &i2c4 {
@@ -141,6 +179,18 @@ pca6416_1: gpio@21 {
      };
 };
 
+&mipi_csi {
+     status = "okay";
+     ports {
+             port@0 {
+                     imx8mm_mipi_csi_in: endpoint {
+                             remote-endpoint = <&ov5640_to_mipi_csi2>;
+                             data-lanes = <1 2>;
+                     };
+             };
+     };
+};
+
 &sai3 {
      pinctrl-names = "default";
      pinctrl-0 = <&pinctrl_sai3>;
@@ -209,6 +259,14 @@ MX8MM_IOMUXC_SAI3_RXFS_GPIO4_IO28        0x41
              >;
      };
 
+     pinctrl_ov5640: ov5640grp {
+             fsl,pins = <
+                     MX8MM_IOMUXC_GPIO1_IO07_GPIO1_IO7               0x19
+                     MX8MM_IOMUXC_GPIO1_IO06_GPIO1_IO6               0x19
+                     MX8MM_IOMUXC_GPIO1_IO14_CCMSRCGPCMIX_CLKO1      0x59
+             >;
+     };
+
      pinctrl_pcal6414: pcal6414-gpiogrp {
              fsl,pins = <
                      MX8MM_IOMUXC_SAI2_MCLK_GPIO4_IO27               0x19
Signature · 3 lines
Regards,

Laurent Pinchart
#10 lore raw

Re: (EXT) Re: [PATCH V2 4/5] arm64: dts: imx8mm-beacon: Enable OV5640 Camera

Am Dienstag, dem 23.11.2021 um 02:15 +0200 schrieb Laurent Pinchart:

Quoted 39 lines

Hi Adam,

Quoted 26 lines · Adam Ford
Quoted 18 lines · Laurent Pinchart
Quoted 17 lines · Adam Ford

The baseboard has support for a TDNext 5640 Camera which uses an OV5640 connected to a 2-lane CSI2 interface.

With the CSI and mipi_csi2 drivers pointing to an OV5640 camera, the media
pipeline can be configured with the following:

    media-ctl --links "'ov5640 1-003c':0->'imx7-mipi-

csis.0':0[1]"

The camera and various nodes in the pipeline can be configured for UYVY:

    media-ctl -v -V "'ov5640 1-003c':0 [fmt:UYVY8_1X16/640x480
field:none]"
    media-ctl -v -V "'csi':0 [fmt:UYVY8_1X16/640x480

field:none]"

Quoted 6 lines
Quoted 3 lines

Signed-off-by: Adam Ford <
[email protected]

Quoted 1 line

As the ov5640 is on an add-on module, would a DT overlay be better ?

Quoted 9 lines

At least for the Beacon / LogicPD boards, I would prefer to avoid the
overlays. We have an i.M6Q and an OMAP3 board with cameras enabled in
our development kit device trees. If the cameras are not connected,
they just display a message that the cameras are not communicating and
move on. I'm OK with that.

Quoted 5 lines

You know the board better than I do, so I won't push against this, but I
still think it may not lead to the best user experience, especially if a
user wanted to connect a different sensor to the development board.

I see the advantages of overlays compared to "stacked" .dts files. But is there any general supported interface how to actually apply an overlay?
Documentation/devicetree/overlay-notes.rst
states of_overlay_fdt_apply() but there is only exactly one user in- kernel (rcar-du). Is it expected that the bootloader like u-boot shall apply the .dtbo files?

Best regards,
Alexander

#11 lore raw

Re: (EXT) Re: [PATCH V2 4/5] arm64: dts: imx8mm-beacon: Enable OV5640 Camera

Hi Alexander,

Quoted 30 lines · Alexander Stein

Am Dienstag, dem 23.11.2021 um 02:15 +0200 schrieb Laurent Pinchart:

Quoted 25 lines · Adam Ford
Quoted 16 lines · Laurent Pinchart
Quoted 15 lines · Adam Ford
Quoted 13 lines

The baseboard has support for a TDNext 5640 Camera which uses an OV5640 connected to a 2-lane CSI2 interface.

With the CSI and mipi_csi2 drivers pointing to an OV5640 camera, the media pipeline can be configured with the following:

    media-ctl --links "'ov5640 1-003c':0->'imx7-mipi-csis.0':0[1]"

The camera and various nodes in the pipeline can be configured for UYVY:

    media-ctl -v -V "'ov5640 1-003c':0 [fmt:UYVY8_1X16/640x480 field:none]"
    media-ctl -v -V "'csi':0 [fmt:UYVY8_1X16/640x480 field:none]"
Quoted 7 lines
Quoted 1 line

As the ov5640 is on an add-on module, would a DT overlay be better ?

At least for the Beacon / LogicPD boards, I would prefer to avoid the overlays. We have an i.M6Q and an OMAP3 board with cameras enabled in our development kit device trees. If the cameras are not connected, they just display a message that the cameras are not communicating and move on. I'm OK with that.

Quoted 3 lines

You know the board better than I do, so I won't push against this, but I still think it may not lead to the best user experience, especially if a user wanted to connect a different sensor to the development board.

Quoted 6 lines

I see the advantages of overlays compared to "stacked" .dts files. But is there any general supported interface how to actually apply an overlay? Documentation/devicetree/overlay-notes.rst
states of_overlay_fdt_apply() but there is only exactly one user in- kernel (rcar-du). Is it expected that the bootloader like u-boot shall apply the .dtbo files?

I believe the boot loader is expected to apply overlays nowadays, yes. That's my personal workflow.

Signature · 3 lines
Regards,

Laurent Pinchart
#12 lore raw

Re: (EXT) Re: [PATCH V2 4/5] arm64: dts: imx8mm-beacon: Enable OV5640 Camera

Quoted 41 lines · Laurent Pinchart

Hi Alexander,

Quoted 30 lines · Alexander Stein

Am Dienstag, dem 23.11.2021 um 02:15 +0200 schrieb Laurent Pinchart:

Quoted 25 lines · Adam Ford
Quoted 16 lines · Laurent Pinchart
Quoted 15 lines · Adam Ford
Quoted 13 lines

The baseboard has support for a TDNext 5640 Camera which uses an OV5640 connected to a 2-lane CSI2 interface.

With the CSI and mipi_csi2 drivers pointing to an OV5640 camera, the media pipeline can be configured with the following:

    media-ctl --links "'ov5640 1-003c':0->'imx7-mipi-csis.0':0[1]"

The camera and various nodes in the pipeline can be configured for UYVY:

    media-ctl -v -V "'ov5640 1-003c':0 [fmt:UYVY8_1X16/640x480 field:none]"
    media-ctl -v -V "'csi':0 [fmt:UYVY8_1X16/640x480 field:none]"
Quoted 7 lines
Quoted 1 line

As the ov5640 is on an add-on module, would a DT overlay be better ?

At least for the Beacon / LogicPD boards, I would prefer to avoid the overlays. We have an i.M6Q and an OMAP3 board with cameras enabled in our development kit device trees. If the cameras are not connected, they just display a message that the cameras are not communicating and move on. I'm OK with that.

Quoted 3 lines

You know the board better than I do, so I won't push against this, but I still think it may not lead to the best user experience, especially if a user wanted to connect a different sensor to the development board.

Quoted 6 lines

I see the advantages of overlays compared to "stacked" .dts files. But is there any general supported interface how to actually apply an overlay? Documentation/devicetree/overlay-notes.rst
states of_overlay_fdt_apply() but there is only exactly one user in- kernel (rcar-du). Is it expected that the bootloader like u-boot shall apply the .dtbo files?

Quoted 3 lines

I believe the boot loader is expected to apply overlays nowadays, yes. That's my personal workflow.

That is my understanding as well. I believe the support to apply dt overlays within Linux (which the rpi kernel still uses) never got merged due to race conditions so the focus was moved to bootloader.

I also have begun submitting some dt overlay files [1] [2] which I will likely repost later this week removing the RFC.

My understanding is that these should be '.dtbo' files in the Linux Makefile which are handled. My boards use the U-Boot bootloader and to handle the dt overlays there you need to:
- set CONFIG_OF_LIBFDT_OVERLAY=y which gives you the 'fdt apply' command
- use 'fdt addr <addr> && fdt resize && fdt apply <loadaddr>' prior to booting with booti
- Note that there is some support at the FIT level as well for overlays if you need them applied to U-Boot's live dt (I don't for my needs)

In my U-Boot environment I use scripts for loading the fdt and applying the overlays. For example for booting kernel/dtb from network I use:
boot_net setenv fsload tftpboot; run loadfdt && run apply_overlays && $fsload $kernel_addr_r venice/Image && booti $kernel_addr_r - $fdt_addr_r
loadfdt if $fsload $fdt_addr_r $dir/$fdt_file1; then echo loaded $fdt_file1; elif $fsload $fdt_addr_r $dir/$fdt_file2; then echo loaded $fdt_file2; elif $fsload $fdt_addr_r $dir/$fdt_file3; then echo loaded $fdt_file3; elif $fsload $fdt_addr_r $dir/$fdt_file4; then echo loaded $fdt_file4; elif $fsload $fdt_addr_r $dir/$fdt_file5; then echo loaded $fdt_file5; fi
apply_overlays fdt addr $fdt_addr_r && fdt resize && for i in "$fdt_overlays"; do $fsload $loadaddr $dir/$i && fdt apply $loadaddr && echo applied $i...; done

Best regards,

Tim
[1] https://www.spinics.net/lists/arm-kernel/msg933447.html
[2] https://www.spinics.net/lists/arm-kernel/msg933638.html

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author
#13 lore raw

PATCH v2 5/5 arm64: defconfig: Enable OV5640

In reply to Adam Ford

The Beacon EmbeddedWorks imx8mm development kit has a TD Next 5640 Camera. Enable the OV5640 driver to use the camera.

---
V2: No Change

 arch/arm64/configs/defconfig | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/configs/defconfig +1 -0
index bc261cf2ef5a..4c1eb9aae5e5 100644
@@ -668,6 +668,7 @@ CONFIG_VIDEO_QCOM_VENUS=m
 CONFIG_SDR_PLATFORM_DRIVERS=y
 CONFIG_VIDEO_RCAR_DRIF=m
 CONFIG_VIDEO_IMX219=m
+CONFIG_VIDEO_OV5640=m
 CONFIG_VIDEO_OV5645=m
 CONFIG_VIDEO_QCOM_CAMSS=m
 CONFIG_DRM=m
Signature · 1 line
2.32.0
reviewer Reviewed-by on v2 5/5
#14 lore raw

Re: [PATCH V2 5/5] arm64: defconfig: Enable OV5640

Quoted 5 lines · Adam Ford

The Beacon EmbeddedWorks imx8mm development kit has a TD Next 5640 Camera. Enable the OV5640 driver to use the camera.

Maybe this one could be squashed with the other defconfig patch. Either way:

reviewer Reviewed-by on v2 1/5
#15 lore raw
In reply to Adam Ford

Hi Adam,

Quoted 8 lines · Adam Ford

Most of the blk-ctrl reset bits are found in one register, however there are two bits in offset 8 for pulling the MIPI DPHY out of reset and these need to be set when IMX8MM_DISPBLK_PD_MIPI_CSI is brought out of reset or the MIPI_CSI hangs.

Fixes 926e57c065df ("soc: imx: imx8m-blk-ctrl: add DISP blk-ctrl")
Reviewed-by on v2 1/5
#16 lore raw
In reply to Adam Ford

Am Samstag, dem 06.11.2021 um 10:54 -0500 schrieb Adam Ford:

Quoted 7 lines

Most of the blk-ctrl reset bits are found in one register, however there are two bits in offset 8 for pulling the MIPI DPHY out of reset and these need to be set when IMX8MM_DISPBLK_PD_MIPI_CSI is brought out of reset or the MIPI_CSI hangs.

Fixes 926e57c065df ("soc: imx: imx8m-blk-ctrl: add DISP blk-ctrl")
Quoted 73 lines

---

V2: Make a note that the extra register is only for Mini/Nano DISPLAY_BLK_CTRL
Rename the new register to mipi_phy_rst_mask
Encapsulate the edits to this register with an if-statement

 drivers/soc/imx/imx8m-blk-ctrl.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/soc/imx/imx8m-blk-ctrl.c +18 -0
index 519b3651d1d9..581eb4bc7f7d 100644
@@ -17,6 +17,7 @@
 
 #define BLK_SFT_RSTN	0x0
 #define BLK_CLK_EN	0x4
+#define BLK_MIPI_RESET_DIV	0x8 /* Mini/Nano DISPLAY_BLK_CTRL only */
 
 struct imx8m_blk_ctrl_domain;
 
@@ -36,6 +37,15 @@ struct imx8m_blk_ctrl_domain_data {
 	const char *gpc_name;
 	u32 rst_mask;
 	u32 clk_mask;
+
+	/*
+	 * i.MX8M Mini and Nano have a third DISPLAY_BLK_CTRL register
+	 * which is used to control the reset for the MIPI Phy.
+	 * Since it's only present in certain circumstances,
+	 * an if-statement should be used before setting and clearing this
+	 * register.
+	 */
+	u32 mipi_phy_rst_mask;
 };
 
 #define DOMAIN_MAX_CLKS 3
@@ -78,6 +88,8 @@ static int imx8m_blk_ctrl_power_on(struct generic_pm_domain *genpd)
 
 	/* put devices into reset */
 	regmap_clear_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
+	if (data->mipi_phy_rst_mask)
+		regmap_clear_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
 
 	/* enable upstream and blk-ctrl clocks to allow reset to propagate */
 	ret = clk_bulk_prepare_enable(data->num_clks, domain->clks);
@@ -99,6 +111,8 @@ static int imx8m_blk_ctrl_power_on(struct generic_pm_domain *genpd)
 
 	/* release reset */
 	regmap_set_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
+	if (data->mipi_phy_rst_mask)
+		regmap_set_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
 
 	/* disable upstream clocks */
 	clk_bulk_disable_unprepare(data->num_clks, domain->clks);
@@ -120,6 +134,9 @@ static int imx8m_blk_ctrl_power_off(struct generic_pm_domain *genpd)
 	struct imx8m_blk_ctrl *bc = domain->bc;
 
 	/* put devices into reset and disable clocks */
+	if (data->mipi_phy_rst_mask)
+		regmap_clear_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
+
 	regmap_clear_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
 	regmap_clear_bits(bc->regmap, BLK_CLK_EN, data->clk_mask);
 
@@ -488,6 +505,7 @@ static const struct imx8m_blk_ctrl_domain_data imx8mm_disp_blk_ctl_domain_data[]
 		.gpc_name = "mipi-csi",
 		.rst_mask = BIT(3) | BIT(4),
 		.clk_mask = BIT(10) | BIT(11),
+		.mipi_phy_rst_mask = BIT(16) | BIT(17),
 	},
 };
 
#17 lore raw
In reply to Adam Ford
Quoted 6 lines · Adam Ford

Most of the blk-ctrl reset bits are found in one register, however there are two bits in offset 8 for pulling the MIPI DPHY out of reset and these need to be set when IMX8MM_DISPBLK_PD_MIPI_CSI is brought out of reset or the MIPI_CSI hangs.

Quoted 7 lines
Fixes 926e57c065df ("soc: imx: imx8m-blk-ctrl: add DISP blk-ctrl")

---

V2: Make a note that the extra register is only for Mini/Nano DISPLAY_BLK_CTRL
Rename the new register to mipi_phy_rst_mask
Encapsulate the edits to this register with an if-statement

This is DPHY reset mask, not sure we can handle this via blk-ctrl. Marek has similar patch to support this [1]. we need to phandle the phy in host node in order to work this.

However this current patch change seems directly handling dphy reset which indeed fine me as well.

Quoted 19 lines
 drivers/soc/imx/imx8m-blk-ctrl.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/soc/imx/imx8m-blk-ctrl.c +1 -0
index 519b3651d1d9..581eb4bc7f7d 100644
@@ -17,6 +17,7 @@
 
 #define BLK_SFT_RSTN   0x0
 #define BLK_CLK_EN     0x4
+#define BLK_MIPI_RESET_DIV     0x8 /* Mini/Nano DISPLAY_BLK_CTRL only */
 
 struct imx8m_blk_ctrl_domain;
 
@@ -36,6 +37,15 @@ struct imx8m_blk_ctrl_domain_data {
        const char *gpc_name;
        u32 rst_mask;

drivers/soc/imx/imx8m-blk-ctrl.c struct imx8m_blk_ctrl_domain_data { · line 48

Quoted 10 lines
drivers/soc/imx/imx8m-blk-ctrl.c +9 -0
        u32 clk_mask;
+
+       /*
+        * i.MX8M Mini and Nano have a third DISPLAY_BLK_CTRL register
+        * which is used to control the reset for the MIPI Phy.
+        * Since it's only present in certain circumstances,
+        * an if-statement should be used before setting and clearing this
+        * register.
+        */
+       u32 mipi_phy_rst_mask;

May be dphy_rst_mask (above comment may not be required, as it understand directly with commit message).

Quoted 32 lines
drivers/soc/imx/imx8m-blk-ctrl.c +7 -0
 };
 
 #define DOMAIN_MAX_CLKS 3
@@ -78,6 +88,8 @@ static int imx8m_blk_ctrl_power_on(struct generic_pm_domain *genpd)
 
        /* put devices into reset */
        regmap_clear_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
+       if (data->mipi_phy_rst_mask)
+               regmap_clear_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
 
        /* enable upstream and blk-ctrl clocks to allow reset to propagate */
        ret = clk_bulk_prepare_enable(data->num_clks, domain->clks);
@@ -99,6 +111,8 @@ static int imx8m_blk_ctrl_power_on(struct generic_pm_domain *genpd)
 
        /* release reset */
        regmap_set_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
+       if (data->mipi_phy_rst_mask)
+               regmap_set_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
 
        /* disable upstream clocks */
        clk_bulk_disable_unprepare(data->num_clks, domain->clks);
@@ -120,6 +134,9 @@ static int imx8m_blk_ctrl_power_off(struct generic_pm_domain *genpd)
        struct imx8m_blk_ctrl *bc = domain->bc;
 
        /* put devices into reset and disable clocks */
+       if (data->mipi_phy_rst_mask)
+               regmap_clear_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
+
        regmap_clear_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
        regmap_clear_bits(bc->regmap, BLK_CLK_EN, data->clk_mask);
 

drivers/soc/imx/imx8m-blk-ctrl.c static const struct imx8m_blk_ctrl_domain_data imx8mm_disp_blk_ctl_domain_data[] · line 508

Quoted 4 lines
drivers/soc/imx/imx8m-blk-ctrl.c +1 -0
@@ -488,6 +505,7 @@ static const struct imx8m_blk_ctrl_domain_data imx8mm_disp_blk_ctl_domain_data[]
                .gpc_name = "mipi-csi",
                .rst_mask = BIT(3) | BIT(4),
                .clk_mask = BIT(10) | BIT(11),
+               .mipi_phy_rst_mask = BIT(16) | BIT(17),

DPHY has BIT(17) for Master reset and BIT(16) for Slave reset. I think we just need master reset to enable. I've tested only BIT(17) on mipi-dsi gpc and it is working.

Jagan.

#18 lore raw
Quoted 87 lines · Jagan Teki
Quoted 6 lines · Adam Ford

Most of the blk-ctrl reset bits are found in one register, however there are two bits in offset 8 for pulling the MIPI DPHY out of reset and these need to be set when IMX8MM_DISPBLK_PD_MIPI_CSI is brought out of reset or the MIPI_CSI hangs.

Quoted 7 lines
Fixes 926e57c065df ("soc: imx: imx8m-blk-ctrl: add DISP blk-ctrl")

---

V2: Make a note that the extra register is only for Mini/Nano DISPLAY_BLK_CTRL
Rename the new register to mipi_phy_rst_mask
Encapsulate the edits to this register with an if-statement

This is DPHY reset mask, not sure we can handle this via blk-ctrl. Marek has similar patch to support this [1]. we need to phandle the phy in host node in order to work this.

However this current patch change seems directly handling dphy reset which indeed fine me as well.

Quoted 19 lines
 drivers/soc/imx/imx8m-blk-ctrl.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/soc/imx/imx8m-blk-ctrl.c +1 -0
index 519b3651d1d9..581eb4bc7f7d 100644
@@ -17,6 +17,7 @@
 
 #define BLK_SFT_RSTN   0x0
 #define BLK_CLK_EN     0x4
+#define BLK_MIPI_RESET_DIV     0x8 /* Mini/Nano DISPLAY_BLK_CTRL only */
 
 struct imx8m_blk_ctrl_domain;
 
@@ -36,6 +37,15 @@ struct imx8m_blk_ctrl_domain_data {
        const char *gpc_name;
        u32 rst_mask;

drivers/soc/imx/imx8m-blk-ctrl.c struct imx8m_blk_ctrl_domain_data { · line 48

Quoted 10 lines
drivers/soc/imx/imx8m-blk-ctrl.c +9 -0
        u32 clk_mask;
+
+       /*
+        * i.MX8M Mini and Nano have a third DISPLAY_BLK_CTRL register
+        * which is used to control the reset for the MIPI Phy.
+        * Since it's only present in certain circumstances,
+        * an if-statement should be used before setting and clearing this
+        * register.
+        */
+       u32 mipi_phy_rst_mask;

May be dphy_rst_mask (above comment may not be required, as it understand directly with commit message).

Quoted 31 lines
drivers/soc/imx/imx8m-blk-ctrl.c +7 -0
 };
 
 #define DOMAIN_MAX_CLKS 3
@@ -78,6 +88,8 @@ static int imx8m_blk_ctrl_power_on(struct generic_pm_domain *genpd)
 
        /* put devices into reset */
        regmap_clear_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
+       if (data->mipi_phy_rst_mask)
+               regmap_clear_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
 
        /* enable upstream and blk-ctrl clocks to allow reset to propagate */
        ret = clk_bulk_prepare_enable(data->num_clks, domain->clks);
@@ -99,6 +111,8 @@ static int imx8m_blk_ctrl_power_on(struct generic_pm_domain *genpd)
 
        /* release reset */
        regmap_set_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
+       if (data->mipi_phy_rst_mask)
+               regmap_set_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
 
        /* disable upstream clocks */
        clk_bulk_disable_unprepare(data->num_clks, domain->clks);
@@ -120,6 +134,9 @@ static int imx8m_blk_ctrl_power_off(struct generic_pm_domain *genpd)
        struct imx8m_blk_ctrl *bc = domain->bc;
 
        /* put devices into reset and disable clocks */
+       if (data->mipi_phy_rst_mask)
+               regmap_clear_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
+
        regmap_clear_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
        regmap_clear_bits(bc->regmap, BLK_CLK_EN, data->clk_mask);
 
Quoted 10 lines

drivers/soc/imx/imx8m-blk-ctrl.c static const struct imx8m_blk_ctrl_domain_data imx8mm_disp_blk_ctl_domain_data[] · line 508

Quoted 5 lines
drivers/soc/imx/imx8m-blk-ctrl.c +1 -0
@@ -488,6 +505,7 @@ static const struct imx8m_blk_ctrl_domain_data imx8mm_disp_blk_ctl_domain_data[]
                .gpc_name = "mipi-csi",
                .rst_mask = BIT(3) | BIT(4),
                .clk_mask = BIT(10) | BIT(11),
+               .mipi_phy_rst_mask = BIT(16) | BIT(17),

DPHY has BIT(17) for Master reset and BIT(16) for Slave reset. I think we just need master reset to enable. I've tested only BIT(17) on mipi-dsi gpc and it is working.

Jagan,

In my testing I had to use BIT(16) | BIT(17) in order to capture via CSI.

Best regards,

Tim

author
#19 lore raw
Quoted 100 lines · Tim Harvey
Quoted 87 lines · Jagan Teki
Quoted 6 lines · Adam Ford

Most of the blk-ctrl reset bits are found in one register, however there are two bits in offset 8 for pulling the MIPI DPHY out of reset and these need to be set when IMX8MM_DISPBLK_PD_MIPI_CSI is brought out of reset or the MIPI_CSI hangs.

Quoted 7 lines
Fixes 926e57c065df ("soc: imx: imx8m-blk-ctrl: add DISP blk-ctrl")

---

V2: Make a note that the extra register is only for Mini/Nano DISPLAY_BLK_CTRL
Rename the new register to mipi_phy_rst_mask
Encapsulate the edits to this register with an if-statement

This is DPHY reset mask, not sure we can handle this via blk-ctrl. Marek has similar patch to support this [1]. we need to phandle the phy in host node in order to work this.

However this current patch change seems directly handling dphy reset which indeed fine me as well.

Quoted 19 lines
 drivers/soc/imx/imx8m-blk-ctrl.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/soc/imx/imx8m-blk-ctrl.c +1 -0
index 519b3651d1d9..581eb4bc7f7d 100644
@@ -17,6 +17,7 @@
 
 #define BLK_SFT_RSTN   0x0
 #define BLK_CLK_EN     0x4
+#define BLK_MIPI_RESET_DIV     0x8 /* Mini/Nano DISPLAY_BLK_CTRL only */
 
 struct imx8m_blk_ctrl_domain;
 
@@ -36,6 +37,15 @@ struct imx8m_blk_ctrl_domain_data {
        const char *gpc_name;
        u32 rst_mask;

drivers/soc/imx/imx8m-blk-ctrl.c struct imx8m_blk_ctrl_domain_data { · line 48

Quoted 10 lines
drivers/soc/imx/imx8m-blk-ctrl.c +9 -0
        u32 clk_mask;
+
+       /*
+        * i.MX8M Mini and Nano have a third DISPLAY_BLK_CTRL register
+        * which is used to control the reset for the MIPI Phy.
+        * Since it's only present in certain circumstances,
+        * an if-statement should be used before setting and clearing this
+        * register.
+        */
+       u32 mipi_phy_rst_mask;

May be dphy_rst_mask (above comment may not be required, as it understand directly with commit message).

Quoted 31 lines
drivers/soc/imx/imx8m-blk-ctrl.c +7 -0
 };
 
 #define DOMAIN_MAX_CLKS 3
@@ -78,6 +88,8 @@ static int imx8m_blk_ctrl_power_on(struct generic_pm_domain *genpd)
 
        /* put devices into reset */
        regmap_clear_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
+       if (data->mipi_phy_rst_mask)
+               regmap_clear_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
 
        /* enable upstream and blk-ctrl clocks to allow reset to propagate */
        ret = clk_bulk_prepare_enable(data->num_clks, domain->clks);
@@ -99,6 +111,8 @@ static int imx8m_blk_ctrl_power_on(struct generic_pm_domain *genpd)
 
        /* release reset */
        regmap_set_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
+       if (data->mipi_phy_rst_mask)
+               regmap_set_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
 
        /* disable upstream clocks */
        clk_bulk_disable_unprepare(data->num_clks, domain->clks);
@@ -120,6 +134,9 @@ static int imx8m_blk_ctrl_power_off(struct generic_pm_domain *genpd)
        struct imx8m_blk_ctrl *bc = domain->bc;
 
        /* put devices into reset and disable clocks */
+       if (data->mipi_phy_rst_mask)
+               regmap_clear_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
+
        regmap_clear_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
        regmap_clear_bits(bc->regmap, BLK_CLK_EN, data->clk_mask);
 
Quoted 10 lines

drivers/soc/imx/imx8m-blk-ctrl.c static const struct imx8m_blk_ctrl_domain_data imx8mm_disp_blk_ctl_domain_data[] · line 508

Quoted 5 lines
drivers/soc/imx/imx8m-blk-ctrl.c +1 -0
@@ -488,6 +505,7 @@ static const struct imx8m_blk_ctrl_domain_data imx8mm_disp_blk_ctl_domain_data[]
                .gpc_name = "mipi-csi",
                .rst_mask = BIT(3) | BIT(4),
                .clk_mask = BIT(10) | BIT(11),
+               .mipi_phy_rst_mask = BIT(16) | BIT(17),

DPHY has BIT(17) for Master reset and BIT(16) for Slave reset. I think we just need master reset to enable. I've tested only BIT(17) on mipi-dsi gpc and it is working.

Quoted 3 lines

Jagan,

In my testing I had to use BIT(16) | BIT(17) in order to capture via CSI.

Lucas,

Based on this, should I redo the patch but without clearing bits 16 and 17? It seems like both DSI and CSI need at least bit 17, and CSI appears to need both. If we clear them, we risk stomping on one peripheral or another. If we need both, in theory, we could drop the need for a DPHY driver on the DSI side.

adam

Quoted 4 lines

Best regards,

Tim

#20 lore raw

Hi Adam,

Quoted 103 lines · Adam Ford
Quoted 98 lines · Tim Harvey
Quoted 86 lines · Jagan Teki
Quoted 6 lines · Adam Ford

Most of the blk-ctrl reset bits are found in one register, however there are two bits in offset 8 for pulling the MIPI DPHY out of reset and these need to be set when IMX8MM_DISPBLK_PD_MIPI_CSI is brought out of reset or the MIPI_CSI hangs.

Quoted 7 lines
Fixes 926e57c065df ("soc: imx: imx8m-blk-ctrl: add DISP blk-ctrl")

---

V2: Make a note that the extra register is only for Mini/Nano DISPLAY_BLK_CTRL
Rename the new register to mipi_phy_rst_mask
Encapsulate the edits to this register with an if-statement

This is DPHY reset mask, not sure we can handle this via blk-ctrl. Marek has similar patch to support this [1]. we need to phandle the phy in host node in order to work this.

However this current patch change seems directly handling dphy reset which indeed fine me as well.

Quoted 19 lines
 drivers/soc/imx/imx8m-blk-ctrl.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/soc/imx/imx8m-blk-ctrl.c +1 -0
index 519b3651d1d9..581eb4bc7f7d 100644
@@ -17,6 +17,7 @@
 
 #define BLK_SFT_RSTN   0x0
 #define BLK_CLK_EN     0x4
+#define BLK_MIPI_RESET_DIV     0x8 /* Mini/Nano DISPLAY_BLK_CTRL only */
 
 struct imx8m_blk_ctrl_domain;
 
@@ -36,6 +37,15 @@ struct imx8m_blk_ctrl_domain_data {
        const char *gpc_name;
        u32 rst_mask;

drivers/soc/imx/imx8m-blk-ctrl.c struct imx8m_blk_ctrl_domain_data { · line 48

Quoted 10 lines
drivers/soc/imx/imx8m-blk-ctrl.c +9 -0
        u32 clk_mask;
+
+       /*
+        * i.MX8M Mini and Nano have a third DISPLAY_BLK_CTRL register
+        * which is used to control the reset for the MIPI Phy.
+        * Since it's only present in certain circumstances,
+        * an if-statement should be used before setting and clearing this
+        * register.
+        */
+       u32 mipi_phy_rst_mask;

May be dphy_rst_mask (above comment may not be required, as it understand directly with commit message).

Quoted 31 lines
drivers/soc/imx/imx8m-blk-ctrl.c +7 -0
 };
 
 #define DOMAIN_MAX_CLKS 3
@@ -78,6 +88,8 @@ static int imx8m_blk_ctrl_power_on(struct generic_pm_domain *genpd)
 
        /* put devices into reset */
        regmap_clear_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
+       if (data->mipi_phy_rst_mask)
+               regmap_clear_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
 
        /* enable upstream and blk-ctrl clocks to allow reset to propagate */
        ret = clk_bulk_prepare_enable(data->num_clks, domain->clks);
@@ -99,6 +111,8 @@ static int imx8m_blk_ctrl_power_on(struct generic_pm_domain *genpd)
 
        /* release reset */
        regmap_set_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
+       if (data->mipi_phy_rst_mask)
+               regmap_set_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
 
        /* disable upstream clocks */
        clk_bulk_disable_unprepare(data->num_clks, domain->clks);
@@ -120,6 +134,9 @@ static int imx8m_blk_ctrl_power_off(struct generic_pm_domain *genpd)
        struct imx8m_blk_ctrl *bc = domain->bc;
 
        /* put devices into reset and disable clocks */
+       if (data->mipi_phy_rst_mask)
+               regmap_clear_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
+
        regmap_clear_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
        regmap_clear_bits(bc->regmap, BLK_CLK_EN, data->clk_mask);
 
Quoted 10 lines

drivers/soc/imx/imx8m-blk-ctrl.c static const struct imx8m_blk_ctrl_domain_data imx8mm_disp_blk_ctl_domain_data[] · line 508

Quoted 5 lines
drivers/soc/imx/imx8m-blk-ctrl.c +1 -0
@@ -488,6 +505,7 @@ static const struct imx8m_blk_ctrl_domain_data imx8mm_disp_blk_ctl_domain_data[]
                .gpc_name = "mipi-csi",
                .rst_mask = BIT(3) | BIT(4),
                .clk_mask = BIT(10) | BIT(11),
+               .mipi_phy_rst_mask = BIT(16) | BIT(17),

DPHY has BIT(17) for Master reset and BIT(16) for Slave reset. I think we just need master reset to enable. I've tested only BIT(17) on mipi-dsi gpc and it is working.

Quoted 3 lines

Jagan,

In my testing I had to use BIT(16) | BIT(17) in order to capture via CSI.

Quoted 7 lines

Lucas,

Based on this, should I redo the patch but without clearing bits 16 and 17? It seems like both DSI and CSI need at least bit 17, and CSI appears to need both. If we clear them, we risk stomping on one peripheral or another. If we need both, in theory, we could drop the need for a DPHY driver on the DSI side.

I've tested camera on the i.MX8MM with an NXP BSP v5.4-based kernel. Register BLK_MIPI_RESET_DIV is set to 0x00030000 by default. The camera still works if I clear bit 17, and doesn't if I clear bit 16.

Signature · 3 lines
Regards,

Laurent Pinchart
#21 lore raw
In reply to Adam Ford

Hi Adam,

Quoted 63 lines · Adam Ford

Most of the blk-ctrl reset bits are found in one register, however there are two bits in offset 8 for pulling the MIPI DPHY out of reset and these need to be set when IMX8MM_DISPBLK_PD_MIPI_CSI is brought out of reset or the MIPI_CSI hangs.

Fixes 926e57c065df ("soc: imx: imx8m-blk-ctrl: add DISP blk-ctrl")

---

V2: Make a note that the extra register is only for Mini/Nano DISPLAY_BLK_CTRL
Rename the new register to mipi_phy_rst_mask
Encapsulate the edits to this register with an if-statement

 drivers/soc/imx/imx8m-blk-ctrl.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/soc/imx/imx8m-blk-ctrl.c +14 -0
index 519b3651d1d9..581eb4bc7f7d 100644
@@ -17,6 +17,7 @@
 
 #define BLK_SFT_RSTN	0x0
 #define BLK_CLK_EN	0x4
+#define BLK_MIPI_RESET_DIV	0x8 /* Mini/Nano DISPLAY_BLK_CTRL only */
 
 struct imx8m_blk_ctrl_domain;
 
@@ -36,6 +37,15 @@ struct imx8m_blk_ctrl_domain_data {
 	const char *gpc_name;
 	u32 rst_mask;
 	u32 clk_mask;
+
+	/*
+	 * i.MX8M Mini and Nano have a third DISPLAY_BLK_CTRL register
+	 * which is used to control the reset for the MIPI Phy.
+	 * Since it's only present in certain circumstances,
+	 * an if-statement should be used before setting and clearing this
+	 * register.
+	 */
+	u32 mipi_phy_rst_mask;
 };
 
 #define DOMAIN_MAX_CLKS 3
@@ -78,6 +88,8 @@ static int imx8m_blk_ctrl_power_on(struct generic_pm_domain *genpd)
 
 	/* put devices into reset */
 	regmap_clear_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
+	if (data->mipi_phy_rst_mask)
+		regmap_clear_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
 
 	/* enable upstream and blk-ctrl clocks to allow reset to propagate */
 	ret = clk_bulk_prepare_enable(data->num_clks, domain->clks);
@@ -99,6 +111,8 @@ static int imx8m_blk_ctrl_power_on(struct generic_pm_domain *genpd)
 
 	/* release reset */
 	regmap_set_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
+	if (data->mipi_phy_rst_mask)
+		regmap_set_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
 
 	/* disable upstream clocks */
 	clk_bulk_disable_unprepare(data->num_clks, domain->clks);

drivers/soc/imx/imx8m-blk-ctrl.c static int imx8m_blk_ctrl_power_off(struct generic_pm_domain *genpd) · line 139

Quoted 6 lines
drivers/soc/imx/imx8m-blk-ctrl.c +3 -0
@@ -120,6 +134,9 @@ static int imx8m_blk_ctrl_power_off(struct generic_pm_domain *genpd)
 	struct imx8m_blk_ctrl *bc = domain->bc;
 
 	/* put devices into reset and disable clocks */
+	if (data->mipi_phy_rst_mask)
+		regmap_clear_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
+

Is it the best option to enable/disable both the master and slave MIPI DPHY, regardless of whether they're used or not ? Or would it be better to implement a reset controller to expose the two resets independently, and acquire them from the corresponding display and camera drivers ?

Quoted 11 lines
drivers/soc/imx/imx8m-blk-ctrl.c +1 -0
 	regmap_clear_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
 	regmap_clear_bits(bc->regmap, BLK_CLK_EN, data->clk_mask);
 
@@ -488,6 +505,7 @@ static const struct imx8m_blk_ctrl_domain_data imx8mm_disp_blk_ctl_domain_data[]
 		.gpc_name = "mipi-csi",
 		.rst_mask = BIT(3) | BIT(4),
 		.clk_mask = BIT(10) | BIT(11),
+		.mipi_phy_rst_mask = BIT(16) | BIT(17),
 	},
 };
 
Signature · 8 lines
Regards,

Laurent Pinchart

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#22 lore raw

Hi Adam,

Quoted 66 lines · Laurent Pinchart
Quoted 65 lines · Adam Ford

Most of the blk-ctrl reset bits are found in one register, however there are two bits in offset 8 for pulling the MIPI DPHY out of reset and these need to be set when IMX8MM_DISPBLK_PD_MIPI_CSI is brought out of reset or the MIPI_CSI hangs.

Fixes 926e57c065df ("soc: imx: imx8m-blk-ctrl: add DISP blk-ctrl")

---

V2: Make a note that the extra register is only for Mini/Nano DISPLAY_BLK_CTRL
Rename the new register to mipi_phy_rst_mask
Encapsulate the edits to this register with an if-statement

 drivers/soc/imx/imx8m-blk-ctrl.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/soc/imx/imx8m-blk-ctrl.c +14 -0
index 519b3651d1d9..581eb4bc7f7d 100644
@@ -17,6 +17,7 @@
 
 #define BLK_SFT_RSTN	0x0
 #define BLK_CLK_EN	0x4
+#define BLK_MIPI_RESET_DIV	0x8 /* Mini/Nano DISPLAY_BLK_CTRL only */
 
 struct imx8m_blk_ctrl_domain;
 
@@ -36,6 +37,15 @@ struct imx8m_blk_ctrl_domain_data {
 	const char *gpc_name;
 	u32 rst_mask;
 	u32 clk_mask;
+
+	/*
+	 * i.MX8M Mini and Nano have a third DISPLAY_BLK_CTRL register
+	 * which is used to control the reset for the MIPI Phy.
+	 * Since it's only present in certain circumstances,
+	 * an if-statement should be used before setting and clearing this
+	 * register.
+	 */
+	u32 mipi_phy_rst_mask;
 };
 
 #define DOMAIN_MAX_CLKS 3
@@ -78,6 +88,8 @@ static int imx8m_blk_ctrl_power_on(struct generic_pm_domain *genpd)
 
 	/* put devices into reset */
 	regmap_clear_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
+	if (data->mipi_phy_rst_mask)
+		regmap_clear_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
 
 	/* enable upstream and blk-ctrl clocks to allow reset to propagate */
 	ret = clk_bulk_prepare_enable(data->num_clks, domain->clks);
@@ -99,6 +111,8 @@ static int imx8m_blk_ctrl_power_on(struct generic_pm_domain *genpd)
 
 	/* release reset */
 	regmap_set_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
+	if (data->mipi_phy_rst_mask)
+		regmap_set_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
 
 	/* disable upstream clocks */
 	clk_bulk_disable_unprepare(data->num_clks, domain->clks);
@@ -120,6 +134,9 @@ static int imx8m_blk_ctrl_power_off(struct generic_pm_domain *genpd)
 	struct imx8m_blk_ctrl *bc = domain->bc;
 
Quoted 9 lines

drivers/soc/imx/imx8m-blk-ctrl.c static int imx8m_blk_ctrl_power_off(struct generic_pm_domain *genpd) · line 139

Quoted 4 lines
drivers/soc/imx/imx8m-blk-ctrl.c +3 -0
 	/* put devices into reset and disable clocks */
+	if (data->mipi_phy_rst_mask)
+		regmap_clear_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
+

Is it the best option to enable/disable both the master and slave MIPI DPHY, regardless of whether they're used or not ? Or would it be better to implement a reset controller to expose the two resets independently, and acquire them from the corresponding display and camera drivers ?

And I've now seen this has been raised by Jagan. I'll reply to that e-mail.

Quoted 11 lines
Quoted 11 lines
drivers/soc/imx/imx8m-blk-ctrl.c +1 -0
 	regmap_clear_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
 	regmap_clear_bits(bc->regmap, BLK_CLK_EN, data->clk_mask);
 
@@ -488,6 +505,7 @@ static const struct imx8m_blk_ctrl_domain_data imx8mm_disp_blk_ctl_domain_data[]
 		.gpc_name = "mipi-csi",
 		.rst_mask = BIT(3) | BIT(4),
 		.clk_mask = BIT(10) | BIT(11),
+		.mipi_phy_rst_mask = BIT(16) | BIT(17),
 	},
 };
 
Signature · 3 lines
Regards,

Laurent Pinchart
author
#23 lore raw
In reply to Laurent Pinchart
Quoted 69 lines · Laurent Pinchart

Hi Adam,

Quoted 65 lines · Adam Ford

Most of the blk-ctrl reset bits are found in one register, however there are two bits in offset 8 for pulling the MIPI DPHY out of reset and these need to be set when IMX8MM_DISPBLK_PD_MIPI_CSI is brought out of reset or the MIPI_CSI hangs.

Fixes 926e57c065df ("soc: imx: imx8m-blk-ctrl: add DISP blk-ctrl")

---

V2: Make a note that the extra register is only for Mini/Nano DISPLAY_BLK_CTRL
Rename the new register to mipi_phy_rst_mask
Encapsulate the edits to this register with an if-statement

 drivers/soc/imx/imx8m-blk-ctrl.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/soc/imx/imx8m-blk-ctrl.c +14 -0
index 519b3651d1d9..581eb4bc7f7d 100644
@@ -17,6 +17,7 @@
 
 #define BLK_SFT_RSTN 0x0
 #define BLK_CLK_EN   0x4
+#define BLK_MIPI_RESET_DIV   0x8 /* Mini/Nano DISPLAY_BLK_CTRL only */
 
 struct imx8m_blk_ctrl_domain;
 
@@ -36,6 +37,15 @@ struct imx8m_blk_ctrl_domain_data {
      const char *gpc_name;
      u32 rst_mask;
      u32 clk_mask;
+
+     /*
+      * i.MX8M Mini and Nano have a third DISPLAY_BLK_CTRL register
+      * which is used to control the reset for the MIPI Phy.
+      * Since it's only present in certain circumstances,
+      * an if-statement should be used before setting and clearing this
+      * register.
+      */
+     u32 mipi_phy_rst_mask;
 };
 
 #define DOMAIN_MAX_CLKS 3
@@ -78,6 +88,8 @@ static int imx8m_blk_ctrl_power_on(struct generic_pm_domain *genpd)
 
      /* put devices into reset */
      regmap_clear_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
+     if (data->mipi_phy_rst_mask)
+             regmap_clear_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
 
      /* enable upstream and blk-ctrl clocks to allow reset to propagate */
      ret = clk_bulk_prepare_enable(data->num_clks, domain->clks);
@@ -99,6 +111,8 @@ static int imx8m_blk_ctrl_power_on(struct generic_pm_domain *genpd)
 
      /* release reset */
      regmap_set_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
+     if (data->mipi_phy_rst_mask)
+             regmap_set_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
 
      /* disable upstream clocks */
      clk_bulk_disable_unprepare(data->num_clks, domain->clks);
@@ -120,6 +134,9 @@ static int imx8m_blk_ctrl_power_off(struct generic_pm_domain *genpd)
      struct imx8m_blk_ctrl *bc = domain->bc;
 
Quoted 9 lines

drivers/soc/imx/imx8m-blk-ctrl.c static int imx8m_blk_ctrl_power_off(struct generic_pm_domain *genpd) · line 139

Quoted 4 lines
drivers/soc/imx/imx8m-blk-ctrl.c +3 -0
      /* put devices into reset and disable clocks */
+     if (data->mipi_phy_rst_mask)
+             regmap_clear_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
+

Is it the best option to enable/disable both the master and slave MIPI DPHY, regardless of whether they're used or not ? Or would it be better to implement a reset controller to expose the two resets independently, and acquire them from the corresponding display and camera drivers ?

In some early attempts to implement the blk-ctrl driver, there was an attempt to enable a reset controller, but it caused some hanging and issues with suspend-resume due to chicken-egg issues where some items were coming up in the wrong order. I think the decision was made to make the resets part of the power domain so it's very clear that the order of operations. Lucas might be able to elaborate more on this.

If bits 16 and 17 can act independently and bit 16 only impacts the CSI and doesn't require bit 17, it seems reasonable to me to have the power-domain part of the CSI, since this would only be enabled when the CSI is active. The power domain is idled when the CSI is idled which would effectively place the phy in and out of reset only depending on the state of the CSI. I am guessing this reset bit should be assigned to DISPBLK_PD_MIPI_CSI and not DISPBLK_PD_CSI_BRIDGE, but I can run some more tests.

AFAIK, there is no phy driver for the CSI like there is the DSI, so adding that would require additional work to the CSI driver to work around this quirk. We don't have an acceptable DSI driver yet, so I'd like to push a V3 with just the corresponding bit enabled for MIPI_CSI after some testing. FWICT, NXP set both bits 16 and 17 in their ATF gpc code, and it never gets cleared, so I think having the bit set and cleared on demand is an improvement.

Quoted 4 lines
Quoted 4 lines
drivers/soc/imx/imx8m-blk-ctrl.c +0 -0
      regmap_clear_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
      regmap_clear_bits(bc->regmap, BLK_CLK_EN, data->clk_mask);
 
Quoted 8 lines

drivers/soc/imx/imx8m-blk-ctrl.c static const struct imx8m_blk_ctrl_domain_data imx8mm_disp_blk_ctl_domain_data[] · line 511

Quoted 8 lines
drivers/soc/imx/imx8m-blk-ctrl.c +1 -0
@@ -488,6 +505,7 @@ static const struct imx8m_blk_ctrl_domain_data imx8mm_disp_blk_ctl_domain_data[]
              .gpc_name = "mipi-csi",
              .rst_mask = BIT(3) | BIT(4),
              .clk_mask = BIT(10) | BIT(11),
+             .mipi_phy_rst_mask = BIT(16) | BIT(17),
      },
 };
 

adam

Quoted 5 lines

--
Regards,

Laurent Pinchart

#24 lore raw
Quoted 82 lines · Adam Ford
Quoted 69 lines · Laurent Pinchart

Hi Adam,

Quoted 65 lines · Adam Ford

Most of the blk-ctrl reset bits are found in one register, however there are two bits in offset 8 for pulling the MIPI DPHY out of reset and these need to be set when IMX8MM_DISPBLK_PD_MIPI_CSI is brought out of reset or the MIPI_CSI hangs.

Fixes 926e57c065df ("soc: imx: imx8m-blk-ctrl: add DISP blk-ctrl")

---

V2: Make a note that the extra register is only for Mini/Nano DISPLAY_BLK_CTRL
Rename the new register to mipi_phy_rst_mask
Encapsulate the edits to this register with an if-statement

 drivers/soc/imx/imx8m-blk-ctrl.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/soc/imx/imx8m-blk-ctrl.c +14 -0
index 519b3651d1d9..581eb4bc7f7d 100644
@@ -17,6 +17,7 @@
 
 #define BLK_SFT_RSTN 0x0
 #define BLK_CLK_EN   0x4
+#define BLK_MIPI_RESET_DIV   0x8 /* Mini/Nano DISPLAY_BLK_CTRL only */
 
 struct imx8m_blk_ctrl_domain;
 
@@ -36,6 +37,15 @@ struct imx8m_blk_ctrl_domain_data {
      const char *gpc_name;
      u32 rst_mask;
      u32 clk_mask;
+
+     /*
+      * i.MX8M Mini and Nano have a third DISPLAY_BLK_CTRL register
+      * which is used to control the reset for the MIPI Phy.
+      * Since it's only present in certain circumstances,
+      * an if-statement should be used before setting and clearing this
+      * register.
+      */
+     u32 mipi_phy_rst_mask;
 };
 
 #define DOMAIN_MAX_CLKS 3
@@ -78,6 +88,8 @@ static int imx8m_blk_ctrl_power_on(struct generic_pm_domain *genpd)
 
      /* put devices into reset */
      regmap_clear_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
+     if (data->mipi_phy_rst_mask)
+             regmap_clear_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
 
      /* enable upstream and blk-ctrl clocks to allow reset to propagate */
      ret = clk_bulk_prepare_enable(data->num_clks, domain->clks);
@@ -99,6 +111,8 @@ static int imx8m_blk_ctrl_power_on(struct generic_pm_domain *genpd)
 
      /* release reset */
      regmap_set_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
+     if (data->mipi_phy_rst_mask)
+             regmap_set_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
 
      /* disable upstream clocks */
      clk_bulk_disable_unprepare(data->num_clks, domain->clks);
@@ -120,6 +134,9 @@ static int imx8m_blk_ctrl_power_off(struct generic_pm_domain *genpd)
      struct imx8m_blk_ctrl *bc = domain->bc;
 
Quoted 9 lines

drivers/soc/imx/imx8m-blk-ctrl.c static int imx8m_blk_ctrl_power_off(struct generic_pm_domain *genpd) · line 139

Quoted 4 lines
drivers/soc/imx/imx8m-blk-ctrl.c +3 -0
      /* put devices into reset and disable clocks */
+     if (data->mipi_phy_rst_mask)
+             regmap_clear_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
+

Is it the best option to enable/disable both the master and slave MIPI DPHY, regardless of whether they're used or not ? Or would it be better to implement a reset controller to expose the two resets independently, and acquire them from the corresponding display and camera drivers ?

Quoted 6 lines

In some early attempts to implement the blk-ctrl driver, there was an attempt to enable a reset controller, but it caused some hanging and issues with suspend-resume due to chicken-egg issues where some items were coming up in the wrong order. I think the decision was made to make the resets part of the power domain so it's very clear that the order of operations. Lucas might be able to elaborate more on this.

I think supporting via phy driver make sense to me since this resent is DPHY specific and nothing related to blk-ctrl.

Quoted 10 lines

If bits 16 and 17 can act independently and bit 16 only impacts the CSI and doesn't require bit 17, it seems reasonable to me to have the power-domain part of the CSI, since this would only be enabled when the CSI is active. The power domain is idled when the CSI is idled which would effectively place the phy in and out of reset only depending on the state of the CSI. I am guessing this reset bit should be assigned to DISPBLK_PD_MIPI_CSI and not DISPBLK_PD_CSI_BRIDGE, but I can run some more tests.

Quoted 7 lines

AFAIK, there is no phy driver for the CSI like there is the DSI, so adding that would require additional work to the CSI driver to work around this quirk. We don't have an acceptable DSI driver yet, so I'd like to push a V3 with just the corresponding bit enabled for MIPI_CSI after some testing. FWICT, NXP set both bits 16 and 17 in their ATF gpc code, and it never gets cleared, so I think having the bit set and cleared on demand is an improvement.

How about using the previous one that Marek sent. Add it via CSI pipeline and i think it would directly.

https://www.spinics.net/lists/devicetree/msg381691.html

Jagan.

author
#25 lore raw
Quoted 91 lines · Jagan Teki
Quoted 82 lines · Adam Ford
Quoted 69 lines · Laurent Pinchart

Hi Adam,

Quoted 65 lines · Adam Ford

Most of the blk-ctrl reset bits are found in one register, however there are two bits in offset 8 for pulling the MIPI DPHY out of reset and these need to be set when IMX8MM_DISPBLK_PD_MIPI_CSI is brought out of reset or the MIPI_CSI hangs.

Fixes 926e57c065df ("soc: imx: imx8m-blk-ctrl: add DISP blk-ctrl")

---

V2: Make a note that the extra register is only for Mini/Nano DISPLAY_BLK_CTRL
Rename the new register to mipi_phy_rst_mask
Encapsulate the edits to this register with an if-statement

 drivers/soc/imx/imx8m-blk-ctrl.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/soc/imx/imx8m-blk-ctrl.c +14 -0
index 519b3651d1d9..581eb4bc7f7d 100644
@@ -17,6 +17,7 @@
 
 #define BLK_SFT_RSTN 0x0
 #define BLK_CLK_EN   0x4
+#define BLK_MIPI_RESET_DIV   0x8 /* Mini/Nano DISPLAY_BLK_CTRL only */
 
 struct imx8m_blk_ctrl_domain;
 
@@ -36,6 +37,15 @@ struct imx8m_blk_ctrl_domain_data {
      const char *gpc_name;
      u32 rst_mask;
      u32 clk_mask;
+
+     /*
+      * i.MX8M Mini and Nano have a third DISPLAY_BLK_CTRL register
+      * which is used to control the reset for the MIPI Phy.
+      * Since it's only present in certain circumstances,
+      * an if-statement should be used before setting and clearing this
+      * register.
+      */
+     u32 mipi_phy_rst_mask;
 };
 
 #define DOMAIN_MAX_CLKS 3
@@ -78,6 +88,8 @@ static int imx8m_blk_ctrl_power_on(struct generic_pm_domain *genpd)
 
      /* put devices into reset */
      regmap_clear_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
+     if (data->mipi_phy_rst_mask)
+             regmap_clear_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
 
      /* enable upstream and blk-ctrl clocks to allow reset to propagate */
      ret = clk_bulk_prepare_enable(data->num_clks, domain->clks);
@@ -99,6 +111,8 @@ static int imx8m_blk_ctrl_power_on(struct generic_pm_domain *genpd)
 
      /* release reset */
      regmap_set_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
+     if (data->mipi_phy_rst_mask)
+             regmap_set_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
 
      /* disable upstream clocks */
      clk_bulk_disable_unprepare(data->num_clks, domain->clks);
@@ -120,6 +134,9 @@ static int imx8m_blk_ctrl_power_off(struct generic_pm_domain *genpd)
      struct imx8m_blk_ctrl *bc = domain->bc;
 
Quoted 9 lines

drivers/soc/imx/imx8m-blk-ctrl.c static int imx8m_blk_ctrl_power_off(struct generic_pm_domain *genpd) · line 139

Quoted 4 lines
drivers/soc/imx/imx8m-blk-ctrl.c +3 -0
      /* put devices into reset and disable clocks */
+     if (data->mipi_phy_rst_mask)
+             regmap_clear_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
+

Is it the best option to enable/disable both the master and slave MIPI DPHY, regardless of whether they're used or not ? Or would it be better to implement a reset controller to expose the two resets independently, and acquire them from the corresponding display and camera drivers ?

Quoted 6 lines

In some early attempts to implement the blk-ctrl driver, there was an attempt to enable a reset controller, but it caused some hanging and issues with suspend-resume due to chicken-egg issues where some items were coming up in the wrong order. I think the decision was made to make the resets part of the power domain so it's very clear that the order of operations. Lucas might be able to elaborate more on this.

Quoted 2 lines

I think supporting via phy driver make sense to me since this resent is DPHY specific and nothing related to blk-ctrl.

I would disagree that isn't not blk-ctrl. The blk-ctrl controls the reset lines for the CSI and enables clocks. The additional register does the same thing to the MIPI CSI and DSI. The imx7-mipi-csis driver configures the dphy already, but this reset bit is not part of its IP block. It seems weird to me that a phy driver would reference a phy driver.

Quoted 19 lines
Quoted 11 lines

If bits 16 and 17 can act independently and bit 16 only impacts the CSI and doesn't require bit 17, it seems reasonable to me to have the power-domain part of the CSI, since this would only be enabled when the CSI is active. The power domain is idled when the CSI is idled which would effectively place the phy in and out of reset only depending on the state of the CSI. I am guessing this reset bit should be assigned to DISPBLK_PD_MIPI_CSI and not DISPBLK_PD_CSI_BRIDGE, but I can run some more tests.

Quoted 7 lines

AFAIK, there is no phy driver for the CSI like there is the DSI, so adding that would require additional work to the CSI driver to work around this quirk. We don't have an acceptable DSI driver yet, so I'd like to push a V3 with just the corresponding bit enabled for MIPI_CSI after some testing. FWICT, NXP set both bits 16 and 17 in their ATF gpc code, and it never gets cleared, so I think having the bit set and cleared on demand is an improvement.

Quoted 2 lines

How about using the previous one that Marek sent. Add it via CSI pipeline and i think it would directly.

That driver specifically addresses the DSI phy and bringing it out of reset is just one small part of what that driver does. I don't think adding CSI functionality to it would be appropriate for that driver as they are separate IP blocks.

If people don't want the blk-ctl to control this bit, I would advocate we should do a separate reset controller to be referenced byt the mipi-csis driver, but that was proposed before and declined. Since blt-ctrl already is pulling seemingly unrelated IP blocks by controlling their clocks and resets. The fact that NXP included it in their ATF power-domain controller tells me they considered it related to power domains and/or resets and not an explicit phy driver.

adam

Quoted 4 lines

https://www.spinics.net/lists/devicetree/msg381691.html

Jagan.

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#26 lore raw

Hi Adam,

Quoted 121 lines · Adam Ford
Quoted 85 lines · Jagan Teki
Quoted 77 lines · Adam Ford
Quoted 66 lines · Laurent Pinchart
Quoted 65 lines · Adam Ford

Most of the blk-ctrl reset bits are found in one register, however there are two bits in offset 8 for pulling the MIPI DPHY out of reset and these need to be set when IMX8MM_DISPBLK_PD_MIPI_CSI is brought out of reset or the MIPI_CSI hangs.

Fixes 926e57c065df ("soc: imx: imx8m-blk-ctrl: add DISP blk-ctrl")

---

V2: Make a note that the extra register is only for Mini/Nano DISPLAY_BLK_CTRL
Rename the new register to mipi_phy_rst_mask
Encapsulate the edits to this register with an if-statement

 drivers/soc/imx/imx8m-blk-ctrl.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/soc/imx/imx8m-blk-ctrl.c +14 -0
index 519b3651d1d9..581eb4bc7f7d 100644
@@ -17,6 +17,7 @@
 
 #define BLK_SFT_RSTN 0x0
 #define BLK_CLK_EN   0x4
+#define BLK_MIPI_RESET_DIV   0x8 /* Mini/Nano DISPLAY_BLK_CTRL only */
 
 struct imx8m_blk_ctrl_domain;
 
@@ -36,6 +37,15 @@ struct imx8m_blk_ctrl_domain_data {
      const char *gpc_name;
      u32 rst_mask;
      u32 clk_mask;
+
+     /*
+      * i.MX8M Mini and Nano have a third DISPLAY_BLK_CTRL register
+      * which is used to control the reset for the MIPI Phy.
+      * Since it's only present in certain circumstances,
+      * an if-statement should be used before setting and clearing this
+      * register.
+      */
+     u32 mipi_phy_rst_mask;
 };
 
 #define DOMAIN_MAX_CLKS 3
@@ -78,6 +88,8 @@ static int imx8m_blk_ctrl_power_on(struct generic_pm_domain *genpd)
 
      /* put devices into reset */
      regmap_clear_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
+     if (data->mipi_phy_rst_mask)
+             regmap_clear_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
 
      /* enable upstream and blk-ctrl clocks to allow reset to propagate */
      ret = clk_bulk_prepare_enable(data->num_clks, domain->clks);
@@ -99,6 +111,8 @@ static int imx8m_blk_ctrl_power_on(struct generic_pm_domain *genpd)
 
      /* release reset */
      regmap_set_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
+     if (data->mipi_phy_rst_mask)
+             regmap_set_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
 
      /* disable upstream clocks */
      clk_bulk_disable_unprepare(data->num_clks, domain->clks);
@@ -120,6 +134,9 @@ static int imx8m_blk_ctrl_power_off(struct generic_pm_domain *genpd)
      struct imx8m_blk_ctrl *bc = domain->bc;
 
Quoted 9 lines

drivers/soc/imx/imx8m-blk-ctrl.c static int imx8m_blk_ctrl_power_off(struct generic_pm_domain *genpd) · line 139

Quoted 4 lines
drivers/soc/imx/imx8m-blk-ctrl.c +3 -0
      /* put devices into reset and disable clocks */
+     if (data->mipi_phy_rst_mask)
+             regmap_clear_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
+

Is it the best option to enable/disable both the master and slave MIPI DPHY, regardless of whether they're used or not ? Or would it be better to implement a reset controller to expose the two resets independently, and acquire them from the corresponding display and camera drivers ?

Quoted 6 lines

In some early attempts to implement the blk-ctrl driver, there was an attempt to enable a reset controller, but it caused some hanging and issues with suspend-resume due to chicken-egg issues where some items were coming up in the wrong order. I think the decision was made to make the resets part of the power domain so it's very clear that the order of operations. Lucas might be able to elaborate more on this.

Quoted 2 lines

I think supporting via phy driver make sense to me since this resent is DPHY specific and nothing related to blk-ctrl.

I would disagree that isn't not blk-ctrl. The blk-ctrl controls the reset lines for the CSI and enables clocks. The additional register does the same thing to the MIPI CSI and DSI. The imx7-mipi-csis driver configures the dphy already, but this reset bit is not part of its IP block. It seems weird to me that a phy driver would reference a phy driver.

Quoted 17 lines
Quoted 9 lines

If bits 16 and 17 can act independently and bit 16 only impacts the CSI and doesn't require bit 17, it seems reasonable to me to have the power-domain part of the CSI, since this would only be enabled when the CSI is active. The power domain is idled when the CSI is idled which would effectively place the phy in and out of reset only depending on the state of the CSI. I am guessing this reset bit should be assigned to DISPBLK_PD_MIPI_CSI and not DISPBLK_PD_CSI_BRIDGE, but I can run some more tests.

Quoted 7 lines

AFAIK, there is no phy driver for the CSI like there is the DSI, so adding that would require additional work to the CSI driver to work around this quirk. We don't have an acceptable DSI driver yet, so I'd like to push a V3 with just the corresponding bit enabled for MIPI_CSI after some testing. FWICT, NXP set both bits 16 and 17 in their ATF gpc code, and it never gets cleared, so I think having the bit set and cleared on demand is an improvement.

Quoted 2 lines

How about using the previous one that Marek sent. Add it via CSI pipeline and i think it would directly.

That driver specifically addresses the DSI phy and bringing it out of reset is just one small part of what that driver does. I don't think adding CSI functionality to it would be appropriate for that driver as they are separate IP blocks.

Quoted 7 lines

If people don't want the blk-ctl to control this bit, I would advocate we should do a separate reset controller to be referenced byt the mipi-csis driver, but that was proposed before and declined. Since blt-ctrl already is pulling seemingly unrelated IP blocks by controlling their clocks and resets. The fact that NXP included it in their ATF power-domain controller tells me they considered it related to power domains and/or resets and not an explicit phy driver.

I think it's a bit more complicated than that, unfortunately. The BLK_CTRL is a mix of miscellaneous configuration bits thrown together. It contains enable/disable bits for clocks and resets, but also D-PHY configuration parameters (GPR_MIPI_[MS]_DPDN_SWAP_{CLK,DAT} in GPR_MIPI_RESET_DIV, and all the fields of the GPR_MIPI_M_PLL* and GPR_MIPI_[BMS]_DPHYCTL* registers). The latter should be controlled by PHY drivers, but we may be able to control get away with hardcoded values (possibly even hardware reset default values).

For the resets and clocks, reset and clock controllers could have been nice. I'm not sure if controlling them through a power domain could count as a bit of an abuse, as the power domain doesn't control power rails, but looking at the imx8m-blk-ctrl driver the on/off sequences required by the clocks and resets would be difficult to handle if clocks and resets were exposed separately. I'd say that in the worst case it's probably an acceptable hack.

For the D-PHY resets, exposing them through a reset controller would also be (in my opinion) the most pedantic approach, bus as we have power domains for the CSI and DSI controllers, controlling the corresponding D-PHY resets from there is in no case worse that what we have already.

The only part that bothers me is the control of the master D-PHY, used for MIPI DSI, from the MIPI CSI power domain. I've received feedback from NXP today that those two GPR reset signals are connected directly to the corresponding D-PHY, without any special combinatorial logic in-between. I think it would be worth a try to control bit 16 from the MIPI CSI power domain and bit 17 from the MIPI DSI power domain, especially given that bit 17 didn't make any difference in my camera tests on the i.MX8MM (I couldn't test display as my board doesn't use the DSI output). If we then run into any issue, we can try to figure it out.

Quoted 1 line
Quoted 1 line

https://www.spinics.net/lists/devicetree/msg381691.html

Signature · 8 lines
Regards,

Laurent Pinchart

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
author
#27 lore raw
Quoted 133 lines · Laurent Pinchart

Hi Adam,

Quoted 121 lines · Adam Ford
Quoted 85 lines · Jagan Teki
Quoted 77 lines · Adam Ford
Quoted 66 lines · Laurent Pinchart
Quoted 65 lines · Adam Ford

Most of the blk-ctrl reset bits are found in one register, however there are two bits in offset 8 for pulling the MIPI DPHY out of reset and these need to be set when IMX8MM_DISPBLK_PD_MIPI_CSI is brought out of reset or the MIPI_CSI hangs.

Fixes 926e57c065df ("soc: imx: imx8m-blk-ctrl: add DISP blk-ctrl")

---

V2: Make a note that the extra register is only for Mini/Nano DISPLAY_BLK_CTRL
Rename the new register to mipi_phy_rst_mask
Encapsulate the edits to this register with an if-statement

 drivers/soc/imx/imx8m-blk-ctrl.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/soc/imx/imx8m-blk-ctrl.c +14 -0
index 519b3651d1d9..581eb4bc7f7d 100644
@@ -17,6 +17,7 @@
 
 #define BLK_SFT_RSTN 0x0
 #define BLK_CLK_EN   0x4
+#define BLK_MIPI_RESET_DIV   0x8 /* Mini/Nano DISPLAY_BLK_CTRL only */
 
 struct imx8m_blk_ctrl_domain;
 
@@ -36,6 +37,15 @@ struct imx8m_blk_ctrl_domain_data {
      const char *gpc_name;
      u32 rst_mask;
      u32 clk_mask;
+
+     /*
+      * i.MX8M Mini and Nano have a third DISPLAY_BLK_CTRL register
+      * which is used to control the reset for the MIPI Phy.
+      * Since it's only present in certain circumstances,
+      * an if-statement should be used before setting and clearing this
+      * register.
+      */
+     u32 mipi_phy_rst_mask;
 };
 
 #define DOMAIN_MAX_CLKS 3
@@ -78,6 +88,8 @@ static int imx8m_blk_ctrl_power_on(struct generic_pm_domain *genpd)
 
      /* put devices into reset */
      regmap_clear_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
+     if (data->mipi_phy_rst_mask)
+             regmap_clear_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
 
      /* enable upstream and blk-ctrl clocks to allow reset to propagate */
      ret = clk_bulk_prepare_enable(data->num_clks, domain->clks);
@@ -99,6 +111,8 @@ static int imx8m_blk_ctrl_power_on(struct generic_pm_domain *genpd)
 
      /* release reset */
      regmap_set_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
+     if (data->mipi_phy_rst_mask)
+             regmap_set_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
 
      /* disable upstream clocks */
      clk_bulk_disable_unprepare(data->num_clks, domain->clks);
@@ -120,6 +134,9 @@ static int imx8m_blk_ctrl_power_off(struct generic_pm_domain *genpd)
      struct imx8m_blk_ctrl *bc = domain->bc;
 
Quoted 9 lines

drivers/soc/imx/imx8m-blk-ctrl.c static int imx8m_blk_ctrl_power_off(struct generic_pm_domain *genpd) · line 139

Quoted 4 lines
drivers/soc/imx/imx8m-blk-ctrl.c +3 -0
      /* put devices into reset and disable clocks */
+     if (data->mipi_phy_rst_mask)
+             regmap_clear_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
+

Is it the best option to enable/disable both the master and slave MIPI DPHY, regardless of whether they're used or not ? Or would it be better to implement a reset controller to expose the two resets independently, and acquire them from the corresponding display and camera drivers ?

Quoted 6 lines

In some early attempts to implement the blk-ctrl driver, there was an attempt to enable a reset controller, but it caused some hanging and issues with suspend-resume due to chicken-egg issues where some items were coming up in the wrong order. I think the decision was made to make the resets part of the power domain so it's very clear that the order of operations. Lucas might be able to elaborate more on this.

Quoted 2 lines

I think supporting via phy driver make sense to me since this resent is DPHY specific and nothing related to blk-ctrl.

I would disagree that isn't not blk-ctrl. The blk-ctrl controls the reset lines for the CSI and enables clocks. The additional register does the same thing to the MIPI CSI and DSI. The imx7-mipi-csis driver configures the dphy already, but this reset bit is not part of its IP block. It seems weird to me that a phy driver would reference a phy driver.

Quoted 17 lines
Quoted 9 lines

If bits 16 and 17 can act independently and bit 16 only impacts the CSI and doesn't require bit 17, it seems reasonable to me to have the power-domain part of the CSI, since this would only be enabled when the CSI is active. The power domain is idled when the CSI is idled which would effectively place the phy in and out of reset only depending on the state of the CSI. I am guessing this reset bit should be assigned to DISPBLK_PD_MIPI_CSI and not DISPBLK_PD_CSI_BRIDGE, but I can run some more tests.

Quoted 7 lines

AFAIK, there is no phy driver for the CSI like there is the DSI, so adding that would require additional work to the CSI driver to work around this quirk. We don't have an acceptable DSI driver yet, so I'd like to push a V3 with just the corresponding bit enabled for MIPI_CSI after some testing. FWICT, NXP set both bits 16 and 17 in their ATF gpc code, and it never gets cleared, so I think having the bit set and cleared on demand is an improvement.

Quoted 2 lines

How about using the previous one that Marek sent. Add it via CSI pipeline and i think it would directly.

That driver specifically addresses the DSI phy and bringing it out of reset is just one small part of what that driver does. I don't think adding CSI functionality to it would be appropriate for that driver as they are separate IP blocks.

Quoted 7 lines

If people don't want the blk-ctl to control this bit, I would advocate we should do a separate reset controller to be referenced byt the mipi-csis driver, but that was proposed before and declined. Since blt-ctrl already is pulling seemingly unrelated IP blocks by controlling their clocks and resets. The fact that NXP included it in their ATF power-domain controller tells me they considered it related to power domains and/or resets and not an explicit phy driver.

Quoted 8 lines

I think it's a bit more complicated than that, unfortunately. The BLK_CTRL is a mix of miscellaneous configuration bits thrown together. It contains enable/disable bits for clocks and resets, but also D-PHY configuration parameters (GPR_MIPI_[MS]_DPDN_SWAP_{CLK,DAT} in GPR_MIPI_RESET_DIV, and all the fields of the GPR_MIPI_M_PLL* and GPR_MIPI_[BMS]_DPHYCTL* registers). The latter should be controlled by PHY drivers, but we may be able to control get away with hardcoded values (possibly even hardware reset default values).

From my testing, the default values in this register block appeared sufficient to run
the OV5640 camera I have.

Quoted 3 lines

For the resets and clocks, reset and clock controllers could have been nice. I'm not sure if controlling them through a power domain could

That was attempted by Lucas and others, but there were a bunch of issues with hanging due to order of operations and the interactions between the bus clock from the blk-ctrl and the GPC power domains.

Quoted 5 lines

count as a bit of an abuse, as the power domain doesn't control power rails, but looking at the imx8m-blk-ctrl driver the on/off sequences required by the clocks and resets would be difficult to handle if clocks and resets were exposed separately. I'd say that in the worst case it's probably an acceptable hack.

So if I post a revision with only bit-16 and leaving bit 17 for the DSI Phy driver, do you have any objections? (see my comment below)

Quoted 6 lines

For the D-PHY resets, exposing them through a reset controller would also be (in my opinion) the most pedantic approach, bus as we have power domains for the CSI and DSI controllers, controlling the corresponding D-PHY resets from there is in no case worse that what we have already.

Quoted 10 lines

The only part that bothers me is the control of the master D-PHY, used for MIPI DSI, from the MIPI CSI power domain. I've received feedback from NXP today that those two GPR reset signals are connected directly to the corresponding D-PHY, without any special combinatorial logic in-between. I think it would be worth a try to control bit 16 from the MIPI CSI power domain and bit 17 from the MIPI DSI power domain, especially given that bit 17 didn't make any difference in my camera tests on the i.MX8MM (I couldn't test display as my board doesn't use the DSI output). If we then run into any issue, we can try to figure it out.

I went back to test this as well. With only bit 16 being used, it appeared to work too, so it seems like it's likely safe to leave bit 17 alone for this.

adam

Quoted 7 lines
Quoted 2 lines
Quoted 2 lines

https://www.spinics.net/lists/devicetree/msg381691.html

--
Regards,

Laurent Pinchart

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#28 lore raw

Hi Adam,

Quoted 150 lines · Adam Ford
Quoted 130 lines · Laurent Pinchart
Quoted 121 lines · Adam Ford
Quoted 85 lines · Jagan Teki
Quoted 77 lines · Adam Ford
Quoted 66 lines · Laurent Pinchart
Quoted 65 lines · Adam Ford

Most of the blk-ctrl reset bits are found in one register, however there are two bits in offset 8 for pulling the MIPI DPHY out of reset and these need to be set when IMX8MM_DISPBLK_PD_MIPI_CSI is brought out of reset or the MIPI_CSI hangs.

Fixes 926e57c065df ("soc: imx: imx8m-blk-ctrl: add DISP blk-ctrl")

---

V2: Make a note that the extra register is only for Mini/Nano DISPLAY_BLK_CTRL
Rename the new register to mipi_phy_rst_mask
Encapsulate the edits to this register with an if-statement

 drivers/soc/imx/imx8m-blk-ctrl.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/soc/imx/imx8m-blk-ctrl.c +14 -0
index 519b3651d1d9..581eb4bc7f7d 100644
@@ -17,6 +17,7 @@
 
 #define BLK_SFT_RSTN 0x0
 #define BLK_CLK_EN   0x4
+#define BLK_MIPI_RESET_DIV   0x8 /* Mini/Nano DISPLAY_BLK_CTRL only */
 
 struct imx8m_blk_ctrl_domain;
 
@@ -36,6 +37,15 @@ struct imx8m_blk_ctrl_domain_data {
      const char *gpc_name;
      u32 rst_mask;
      u32 clk_mask;
+
+     /*
+      * i.MX8M Mini and Nano have a third DISPLAY_BLK_CTRL register
+      * which is used to control the reset for the MIPI Phy.
+      * Since it's only present in certain circumstances,
+      * an if-statement should be used before setting and clearing this
+      * register.
+      */
+     u32 mipi_phy_rst_mask;
 };
 
 #define DOMAIN_MAX_CLKS 3
@@ -78,6 +88,8 @@ static int imx8m_blk_ctrl_power_on(struct generic_pm_domain *genpd)
 
      /* put devices into reset */
      regmap_clear_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
+     if (data->mipi_phy_rst_mask)
+             regmap_clear_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
 
      /* enable upstream and blk-ctrl clocks to allow reset to propagate */
      ret = clk_bulk_prepare_enable(data->num_clks, domain->clks);
@@ -99,6 +111,8 @@ static int imx8m_blk_ctrl_power_on(struct generic_pm_domain *genpd)
 
      /* release reset */
      regmap_set_bits(bc->regmap, BLK_SFT_RSTN, data->rst_mask);
+     if (data->mipi_phy_rst_mask)
+             regmap_set_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
 
      /* disable upstream clocks */
      clk_bulk_disable_unprepare(data->num_clks, domain->clks);
@@ -120,6 +134,9 @@ static int imx8m_blk_ctrl_power_off(struct generic_pm_domain *genpd)
      struct imx8m_blk_ctrl *bc = domain->bc;
 
Quoted 9 lines

drivers/soc/imx/imx8m-blk-ctrl.c static int imx8m_blk_ctrl_power_off(struct generic_pm_domain *genpd) · line 139

Quoted 4 lines
drivers/soc/imx/imx8m-blk-ctrl.c +3 -0
      /* put devices into reset and disable clocks */
+     if (data->mipi_phy_rst_mask)
+             regmap_clear_bits(bc->regmap, BLK_MIPI_RESET_DIV, data->mipi_phy_rst_mask);
+

Is it the best option to enable/disable both the master and slave MIPI DPHY, regardless of whether they're used or not ? Or would it be better to implement a reset controller to expose the two resets independently, and acquire them from the corresponding display and camera drivers ?

Quoted 6 lines

In some early attempts to implement the blk-ctrl driver, there was an attempt to enable a reset controller, but it caused some hanging and issues with suspend-resume due to chicken-egg issues where some items were coming up in the wrong order. I think the decision was made to make the resets part of the power domain so it's very clear that the order of operations. Lucas might be able to elaborate more on this.

Quoted 2 lines

I think supporting via phy driver make sense to me since this resent is DPHY specific and nothing related to blk-ctrl.

I would disagree that isn't not blk-ctrl. The blk-ctrl controls the reset lines for the CSI and enables clocks. The additional register does the same thing to the MIPI CSI and DSI. The imx7-mipi-csis driver configures the dphy already, but this reset bit is not part of its IP block. It seems weird to me that a phy driver would reference a phy driver.

Quoted 17 lines
Quoted 9 lines

If bits 16 and 17 can act independently and bit 16 only impacts the CSI and doesn't require bit 17, it seems reasonable to me to have the power-domain part of the CSI, since this would only be enabled when the CSI is active. The power domain is idled when the CSI is idled which would effectively place the phy in and out of reset only depending on the state of the CSI. I am guessing this reset bit should be assigned to DISPBLK_PD_MIPI_CSI and not DISPBLK_PD_CSI_BRIDGE, but I can run some more tests.

Quoted 7 lines

AFAIK, there is no phy driver for the CSI like there is the DSI, so adding that would require additional work to the CSI driver to work around this quirk. We don't have an acceptable DSI driver yet, so I'd like to push a V3 with just the corresponding bit enabled for MIPI_CSI after some testing. FWICT, NXP set both bits 16 and 17 in their ATF gpc code, and it never gets cleared, so I think having the bit set and cleared on demand is an improvement.

Quoted 2 lines

How about using the previous one that Marek sent. Add it via CSI pipeline and i think it would directly.

That driver specifically addresses the DSI phy and bringing it out of reset is just one small part of what that driver does. I don't think adding CSI functionality to it would be appropriate for that driver as they are separate IP blocks.

Quoted 7 lines

If people don't want the blk-ctl to control this bit, I would advocate we should do a separate reset controller to be referenced byt the mipi-csis driver, but that was proposed before and declined. Since blt-ctrl already is pulling seemingly unrelated IP blocks by controlling their clocks and resets. The fact that NXP included it in their ATF power-domain controller tells me they considered it related to power domains and/or resets and not an explicit phy driver.

Quoted 8 lines

I think it's a bit more complicated than that, unfortunately. The BLK_CTRL is a mix of miscellaneous configuration bits thrown together. It contains enable/disable bits for clocks and resets, but also D-PHY configuration parameters (GPR_MIPI_[MS]_DPDN_SWAP_{CLK,DAT} in GPR_MIPI_RESET_DIV, and all the fields of the GPR_MIPI_M_PLL* and GPR_MIPI_[BMS]_DPHYCTL* registers). The latter should be controlled by PHY drivers, but we may be able to control get away with hardcoded values (possibly even hardware reset default values).

From my testing, the default values in this register block appeared sufficient to run the OV5640 camera I have.

Quoted 2 lines

For the resets and clocks, reset and clock controllers could have been nice. I'm not sure if controlling them through a power domain could

That was attempted by Lucas and others, but there were a bunch of issues with hanging due to order of operations and the interactions between the bus clock from the blk-ctrl and the GPC power domains.

Quoted 8 lines
Quoted 5 lines

count as a bit of an abuse, as the power domain doesn't control power rails, but looking at the imx8m-blk-ctrl driver the on/off sequences required by the clocks and resets would be difficult to handle if clocks and resets were exposed separately. I'd say that in the worst case it's probably an acceptable hack.

So if I post a revision with only bit-16 and leaving bit 17 for the DSI Phy driver, do you have any objections? (see my comment below)

How about this ?

@@ -480,6 +497,7 @@ static const struct imx8m_blk_ctrl_domain_data imx8mm_disp_blk_ctl_domain_data[]
.gpc_name = "mipi-dsi",
.rst_mask = BIT(5),
.clk_mask = BIT(8) | BIT(9),
+ .mipi_phy_rst_mask = BIT(17),
},
[IMX8MM_DISPBLK_PD_MIPI_CSI] = {
.name = "dispblk-mipi-csi",
@@ -488,6 +506,7 @@ static const struct imx8m_blk_ctrl_domain_data imx8mm_disp_blk_ctl_domain_data[]
.gpc_name = "mipi-csi",
.rst_mask = BIT(3) | BIT(4),
.clk_mask = BIT(10) | BIT(11),
+ .mipi_phy_rst_mask = BIT(16),
},
};

Quoted 21 lines
Quoted 5 lines

For the D-PHY resets, exposing them through a reset controller would also be (in my opinion) the most pedantic approach, bus as we have power domains for the CSI and DSI controllers, controlling the corresponding D-PHY resets from there is in no case worse that what we have already.

Quoted 10 lines

The only part that bothers me is the control of the master D-PHY, used for MIPI DSI, from the MIPI CSI power domain. I've received feedback from NXP today that those two GPR reset signals are connected directly to the corresponding D-PHY, without any special combinatorial logic in-between. I think it would be worth a try to control bit 16 from the MIPI CSI power domain and bit 17 from the MIPI DSI power domain, especially given that bit 17 didn't make any difference in my camera tests on the i.MX8MM (I couldn't test display as my board doesn't use the DSI output). If we then run into any issue, we can try to figure it out.

I went back to test this as well. With only bit 16 being used, it appeared to work too, so it seems like it's likely safe to leave bit 17 alone for this.

Quoted 1 line
Quoted 1 line
Quoted 1 line

https://www.spinics.net/lists/devicetree/msg381691.html

Signature · 8 lines
Regards,

Laurent Pinchart

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel