Skip to contentSkip to conversation

Fix active-low handling of MIPI CSI resets on i.MX8MQ

PATCH In review Robby Cai 3 participants 7 messages Mar 31 – Apr 14

Subsystems (3)
lore
Share & tools
lore

Robby Cai

author
#0 lore raw

cover Fix active-low handling of MIPI CSI resets on i.MX8MQ

Hi all,

This series updates the Device Tree bindings and reset controller driver to correctly reflect the active-low polarity of the MIPI CSI reset lines on i.MX8MQ.

The MIPI CSI reset signals are active-low, but the original reset identifiers and driver implementation did not clearly indicate or handle this polarity. Patch 1 updates the DT binding header to add *_RESET_N variants for the MIPI CSI reset definitions, while keeping the old names temporarily for DT ABI compatibility. Patch 2 updates the imx7 reset controller driver to correctly treat these resets as active-low.

Thanks,
Robby

Robby Cai (2):
dt-bindings: reset: imx8mq: Add _N suffix to
IMX8MQ_RESET_MIPI_CSI*_RESET
reset: imx7: Fix handling of MIPI CSI resets on i.MX8MQ

 drivers/reset/reset-imx7.c               | 18 ++++++++++++------
 include/dt-bindings/reset/imx8mq-reset.h | 18 ++++++++++++------
 2 files changed, 24 insertions(+), 12 deletions(-)
Signature · 1 line
2.37.1
author
#1 lore raw

PATCH 1/2 dt-bindings: reset: imx8mq: Add _N suffix to IMX8MQ_RESET_MIPI_CSI*_RESET

The assert logic of the MIPI CSI reset signals is active-low on i.MX8MQ, but the existing names do not indicate this explicitly. To improve consistency and clarity, append the _N suffix to all IMX8MQ_RESET_MIPI_CSI*_RESET definitions. The deprecated IMX8MQ_RESET_MIPI_CSI*_RESET versions remain temporarily for DT ABI compatibility and will be removed at an appropriate time in the future.

---
 include/dt-bindings/reset/imx8mq-reset.h | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
include/dt-bindings/reset/imx8mq-reset.h +12 -6
index 705870693ec2..83a155dbbd4a 100644
@@ -46,12 +46,18 @@
 #define IMX8MQ_RESET_PCIEPHY2_PERST		35	/* i.MX8MM/i.MX8MN does NOT support */
 #define IMX8MQ_RESET_PCIE2_CTRL_APPS_EN		36	/* i.MX8MM/i.MX8MN does NOT support */
 #define IMX8MQ_RESET_PCIE2_CTRL_APPS_TURNOFF	37	/* i.MX8MM/i.MX8MN does NOT support */
-#define IMX8MQ_RESET_MIPI_CSI1_CORE_RESET	38	/* i.MX8MM/i.MX8MN does NOT support */
-#define IMX8MQ_RESET_MIPI_CSI1_PHY_REF_RESET	39	/* i.MX8MM/i.MX8MN does NOT support */
-#define IMX8MQ_RESET_MIPI_CSI1_ESC_RESET	40	/* i.MX8MM/i.MX8MN does NOT support */
-#define IMX8MQ_RESET_MIPI_CSI2_CORE_RESET	41	/* i.MX8MM/i.MX8MN does NOT support */
-#define IMX8MQ_RESET_MIPI_CSI2_PHY_REF_RESET	42	/* i.MX8MM/i.MX8MN does NOT support */
-#define IMX8MQ_RESET_MIPI_CSI2_ESC_RESET	43	/* i.MX8MM/i.MX8MN does NOT support */
+#define IMX8MQ_RESET_MIPI_CSI1_CORE_RESET	38	/* Deprecated. Use *_RESET_N instead */
+#define IMX8MQ_RESET_MIPI_CSI1_CORE_RESET_N	38	/* i.MX8MM/i.MX8MN does NOT support */
+#define IMX8MQ_RESET_MIPI_CSI1_PHY_REF_RESET	39	/* Deprecated. Use *_RESET_N instead */
+#define IMX8MQ_RESET_MIPI_CSI1_PHY_REF_RESET_N	39	/* i.MX8MM/i.MX8MN does NOT support */
+#define IMX8MQ_RESET_MIPI_CSI1_ESC_RESET	40	/* Deprecated. Use *_RESET_N instead */
+#define IMX8MQ_RESET_MIPI_CSI1_ESC_RESET_N	40	/* i.MX8MM/i.MX8MN does NOT support */
+#define IMX8MQ_RESET_MIPI_CSI2_CORE_RESET	41	/* Deprecated. Use *_RESET_N instead */
+#define IMX8MQ_RESET_MIPI_CSI2_CORE_RESET_N	41	/* i.MX8MM/i.MX8MN does NOT support */
+#define IMX8MQ_RESET_MIPI_CSI2_PHY_REF_RESET	42	/* Deprecated. Use *_RESET_N instead */
+#define IMX8MQ_RESET_MIPI_CSI2_PHY_REF_RESET_N	42	/* i.MX8MM/i.MX8MN does NOT support */
+#define IMX8MQ_RESET_MIPI_CSI2_ESC_RESET	43	/* Deprecated. Use *_RESET_N instead */
+#define IMX8MQ_RESET_MIPI_CSI2_ESC_RESET_N	43	/* i.MX8MM/i.MX8MN does NOT support */
 #define IMX8MQ_RESET_DDRC1_PRST			44	/* i.MX8MN does NOT support */
 #define IMX8MQ_RESET_DDRC1_CORE_RESET		45	/* i.MX8MN does NOT support */
 #define IMX8MQ_RESET_DDRC1_PHY_RESET		46	/* i.MX8MN does NOT support */
Signature · 1 line
2.37.1
maintainer
#2 lore raw

Re: [PATCH 1/2] dt-bindings: reset: imx8mq: Add _N suffix to IMX8MQ_RESET_MIPI_CSI*_RESET

Quoted 6 lines · Robby Cai

The assert logic of the MIPI CSI reset signals is active-low on i.MX8MQ, but the existing names do not indicate this explicitly. To improve consistency and clarity, append the _N suffix to all IMX8MQ_RESET_MIPI_CSI*_RESET definitions. The deprecated IMX8MQ_RESET_MIPI_CSI*_RESET versions remain temporarily for DT ABI compatibility and will be removed at an appropriate time in the future.

The register description in the latest reference manual I can download, IMX8MDQLQRM Rev. 3.1 (06/2021), still call these bits MIPI_CSI1_CORE_RESET and so on (without _N). There is no mention of polarity in the bitfield description. Is a documentation update planned?

Right now I'd say this improves clarity, but reduces consistency with existing documentation.

Are these bits self-clearing, or can the reset be asserted by writing 0? As it stands, the CSI driver using these resets, imx8mq-mipi-csi2.c, only calls reset_control_assert() in imx8mq_mipi_csi_sw_reset():

/*
* these are most likely self-clearing reset bits. to make it
* more clear, the reset-imx7 driver should implement the
* .reset() operation.
*/
ret = reset_control_assert(state->rst);

This will probably have to be turned into a deassert together with the reset driver change.

regards
Philipp

author
#3 lore raw

Re: [PATCH 1/2] dt-bindings: reset: imx8mq: Add _N suffix to IMX8MQ_RESET_MIPI_CSI*_RESET

Quoted 8 lines · Philipp Zabel
Quoted 6 lines · Robby Cai

The assert logic of the MIPI CSI reset signals is active-low on i.MX8MQ, but the existing names do not indicate this explicitly. To improve consistency and clarity, append the _N suffix to all IMX8MQ_RESET_MIPI_CSI*_RESET definitions. The deprecated IMX8MQ_RESET_MIPI_CSI*_RESET versions remain temporarily for DT ABI compatibility and will be removed at an appropriate time in the future.

Quoted 5 lines

The register description in the latest reference manual I can download, IMX8MDQLQRM Rev. 3.1 (06/2021), still call these bits MIPI_CSI1_CORE_RESET and so on (without _N). There is no mention of polarity in the bitfield description. Is a documentation update planned?

Yes. A documentation update is already planned to clarify the reset polarity (active-low) and naming. The current RM description is incomplete and will be corrected in a future revision.

Quoted 15 lines

Right now I'd say this improves clarity, but reduces consistency with existing documentation.

Are these bits self-clearing, or can the reset be asserted by writing 0? As it stands, the CSI driver using these resets, imx8mq-mipi-csi2.c, only calls reset_control_assert() in imx8mq_mipi_csi_sw_reset():

/*
* these are most likely self-clearing reset bits. to make it
* more clear, the reset-imx7 driver should implement the
* .reset() operation.
*/
ret = reset_control_assert(state->rst);

Quoted 2 lines

This will probably have to be turned into a deassert together with the reset driver change.

No, these reset bits are not self-clearing.

According to the design team, the MIPI CSI reset logic on i.MX8MQ is identical to MIPI DSI: the reset is active-low and must be explicitly deasserted. Writing ��0�� asserts reset and it will remain asserted until cleared by software.

The current assumption in the CSI driver that these bits are self-clearing is therefore incorrect. This was exposed by the landing patch [1].

To fix this properly, the reset-imx7 driver needs to reflect the correct polarity, and the CSI driver should use deassert instead of only calling reset_control_assert(). The RM will also be updated to clarify this behavior.

[1] https://git.linuxtv.org/media.git/commit/?id=6d79bb8fd2aa25afccbd6aeec2821722fa0b5db5

Regards,
Robby

#4 lore raw

Re: [PATCH 1/2] dt-bindings: reset: imx8mq: Add _N suffix to IMX8MQ_RESET_MIPI_CSI*_RESET

In reply to Robby Cai
Quoted 18 lines · Robby Cai

The assert logic of the MIPI CSI reset signals is active-low on i.MX8MQ, but the existing names do not indicate this explicitly. To improve consistency and clarity, append the _N suffix to all IMX8MQ_RESET_MIPI_CSI*_RESET definitions. The deprecated IMX8MQ_RESET_MIPI_CSI*_RESET versions remain temporarily for DT ABI compatibility and will be removed at an appropriate time in the future.

---
 include/dt-bindings/reset/imx8mq-reset.h | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
include/dt-bindings/reset/imx8mq-reset.h +0 -0
index 705870693ec2..83a155dbbd4a 100644
@@ -46,12 +46,18 @@
 #define IMX8MQ_RESET_PCIEPHY2_PERST		35	/* i.MX8MM/i.MX8MN does NOT support */

include/dt-bindings/reset/imx8mq-reset.h line 50

Quoted 10 lines
include/dt-bindings/reset/imx8mq-reset.h +2 -6
 #define IMX8MQ_RESET_PCIE2_CTRL_APPS_EN		36	/* i.MX8MM/i.MX8MN does NOT support */
 #define IMX8MQ_RESET_PCIE2_CTRL_APPS_TURNOFF	37	/* i.MX8MM/i.MX8MN does NOT support */
-#define IMX8MQ_RESET_MIPI_CSI1_CORE_RESET	38	/* i.MX8MM/i.MX8MN does NOT support */
-#define IMX8MQ_RESET_MIPI_CSI1_PHY_REF_RESET	39	/* i.MX8MM/i.MX8MN does NOT support */
-#define IMX8MQ_RESET_MIPI_CSI1_ESC_RESET	40	/* i.MX8MM/i.MX8MN does NOT support */
-#define IMX8MQ_RESET_MIPI_CSI2_CORE_RESET	41	/* i.MX8MM/i.MX8MN does NOT support */
-#define IMX8MQ_RESET_MIPI_CSI2_PHY_REF_RESET	42	/* i.MX8MM/i.MX8MN does NOT support */
-#define IMX8MQ_RESET_MIPI_CSI2_ESC_RESET	43	/* i.MX8MM/i.MX8MN does NOT support */
+#define IMX8MQ_RESET_MIPI_CSI1_CORE_RESET	38	/* Deprecated. Use *_RESET_N instead */
+#define IMX8MQ_RESET_MIPI_CSI1_CORE_RESET_N	38	/* i.MX8MM/i.MX8MN does NOT support */

That's quite a churn for no need. The entire point of these values being the binding is that it describes the ABI for SW and DTS, not your hardware registers.

Whether signal is active low or high is kind of irrelevant. Linux uses it exactly the same way.

Best regards,
Krzysztof

author
#5 lore raw

Re: [PATCH 1/2] dt-bindings: reset: imx8mq: Add _N suffix to IMX8MQ_RESET_MIPI_CSI*_RESET

Quoted 34 lines · Krzysztof Kozlowski
Quoted 18 lines · Robby Cai

The assert logic of the MIPI CSI reset signals is active-low on i.MX8MQ, but the existing names do not indicate this explicitly. To improve consistency and clarity, append the _N suffix to all IMX8MQ_RESET_MIPI_CSI*_RESET definitions. The deprecated IMX8MQ_RESET_MIPI_CSI*_RESET versions remain temporarily for DT ABI compatibility and will be removed at an appropriate time in the future.

---
 include/dt-bindings/reset/imx8mq-reset.h | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
include/dt-bindings/reset/imx8mq-reset.h +0 -0
index 705870693ec2..83a155dbbd4a 100644
@@ -46,12 +46,18 @@
 #define IMX8MQ_RESET_PCIEPHY2_PERST		35	/* i.MX8MM/i.MX8MN does NOT support */

include/dt-bindings/reset/imx8mq-reset.h line 50

Quoted 10 lines
include/dt-bindings/reset/imx8mq-reset.h +2 -6
 #define IMX8MQ_RESET_PCIE2_CTRL_APPS_EN		36	/* i.MX8MM/i.MX8MN does NOT support */
 #define IMX8MQ_RESET_PCIE2_CTRL_APPS_TURNOFF	37	/* i.MX8MM/i.MX8MN does NOT support */
-#define IMX8MQ_RESET_MIPI_CSI1_CORE_RESET	38	/* i.MX8MM/i.MX8MN does NOT support */
-#define IMX8MQ_RESET_MIPI_CSI1_PHY_REF_RESET	39	/* i.MX8MM/i.MX8MN does NOT support */
-#define IMX8MQ_RESET_MIPI_CSI1_ESC_RESET	40	/* i.MX8MM/i.MX8MN does NOT support */
-#define IMX8MQ_RESET_MIPI_CSI2_CORE_RESET	41	/* i.MX8MM/i.MX8MN does NOT support */
-#define IMX8MQ_RESET_MIPI_CSI2_PHY_REF_RESET	42	/* i.MX8MM/i.MX8MN does NOT support */
-#define IMX8MQ_RESET_MIPI_CSI2_ESC_RESET	43	/* i.MX8MM/i.MX8MN does NOT support */
+#define IMX8MQ_RESET_MIPI_CSI1_CORE_RESET	38	/* Deprecated. Use *_RESET_N instead */
+#define IMX8MQ_RESET_MIPI_CSI1_CORE_RESET_N	38	/* i.MX8MM/i.MX8MN does NOT support */

That's quite a churn for no need. The entire point of these values being the binding is that it describes the ABI for SW and DTS, not your hardware registers.

Quoted 3 lines

Whether signal is active low or high is kind of irrelevant. Linux uses it exactly the same way.

The original naming was taken from the reference manual at the time. The upcoming RM revision will clarify that these resets are active-low and use the _N suffix, consistent with MIPI DSI.

However, I agree that the DT binding and naming need not be changed. I'll keep the existing binding and naming, and address this in v2 by fixing the reset logic in the driver only.

Regards,
Robby

author
#6 lore raw

PATCH 2/2 reset: imx7: Fix handling of MIPI CSI resets on i.MX8MQ

In reply to Robby Cai

The MIPI CSI reset signals on i.MX8MQ are active-low, but the reset controller driver previously treated them as active-high, resulting in incorrect assert/deassert behavior. Update the reset handling logic to correctly process these active-low reset lines.

---
 drivers/reset/reset-imx7.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/reset/reset-imx7.c +12 -6
index dd01fe11c5cb..b7048e1f10df 100644
@@ -202,12 +202,12 @@ static const struct imx7_src_signal imx8mq_src_signals[IMX8MQ_RESET_NUM] = {
 	[IMX8MQ_RESET_PCIEPHY2_PERST]		= { SRC_PCIE2_RCR, BIT(3) },
 	[IMX8MQ_RESET_PCIE2_CTRL_APPS_EN]	= { SRC_PCIE2_RCR, BIT(6) },
 	[IMX8MQ_RESET_PCIE2_CTRL_APPS_TURNOFF]	= { SRC_PCIE2_RCR, BIT(11) },
-	[IMX8MQ_RESET_MIPI_CSI1_CORE_RESET]	= { SRC_MIPIPHY1_RCR, BIT(0) },
-	[IMX8MQ_RESET_MIPI_CSI1_PHY_REF_RESET]	= { SRC_MIPIPHY1_RCR, BIT(1) },
-	[IMX8MQ_RESET_MIPI_CSI1_ESC_RESET]	= { SRC_MIPIPHY1_RCR, BIT(2) },
-	[IMX8MQ_RESET_MIPI_CSI2_CORE_RESET]	= { SRC_MIPIPHY2_RCR, BIT(0) },
-	[IMX8MQ_RESET_MIPI_CSI2_PHY_REF_RESET]	= { SRC_MIPIPHY2_RCR, BIT(1) },
-	[IMX8MQ_RESET_MIPI_CSI2_ESC_RESET]	= { SRC_MIPIPHY2_RCR, BIT(2) },
+	[IMX8MQ_RESET_MIPI_CSI1_CORE_RESET_N]	= { SRC_MIPIPHY1_RCR, BIT(0) },
+	[IMX8MQ_RESET_MIPI_CSI1_PHY_REF_RESET_N] = { SRC_MIPIPHY1_RCR, BIT(1) },
+	[IMX8MQ_RESET_MIPI_CSI1_ESC_RESET_N]	= { SRC_MIPIPHY1_RCR, BIT(2) },
+	[IMX8MQ_RESET_MIPI_CSI2_CORE_RESET_N]	= { SRC_MIPIPHY2_RCR, BIT(0) },
+	[IMX8MQ_RESET_MIPI_CSI2_PHY_REF_RESET_N] = { SRC_MIPIPHY2_RCR, BIT(1) },
+	[IMX8MQ_RESET_MIPI_CSI2_ESC_RESET_N]	= { SRC_MIPIPHY2_RCR, BIT(2) },
 	[IMX8MQ_RESET_DDRC1_PRST]		= { SRC_DDRC_RCR, BIT(0) },
 	[IMX8MQ_RESET_DDRC1_CORE_RESET]		= { SRC_DDRC_RCR, BIT(1) },
 	[IMX8MQ_RESET_DDRC1_PHY_RESET]		= { SRC_DDRC_RCR, BIT(2) },
@@ -236,6 +236,12 @@ static int imx8mq_reset_set(struct reset_controller_dev *rcdev,
 
 	case IMX8MQ_RESET_PCIE_CTRL_APPS_EN:
 	case IMX8MQ_RESET_PCIE2_CTRL_APPS_EN:
+	case IMX8MQ_RESET_MIPI_CSI1_CORE_RESET_N:
+	case IMX8MQ_RESET_MIPI_CSI1_PHY_REF_RESET_N:
+	case IMX8MQ_RESET_MIPI_CSI1_ESC_RESET_N:
+	case IMX8MQ_RESET_MIPI_CSI2_CORE_RESET_N:
+	case IMX8MQ_RESET_MIPI_CSI2_PHY_REF_RESET_N:
+	case IMX8MQ_RESET_MIPI_CSI2_ESC_RESET_N:
 	case IMX8MQ_RESET_MIPI_DSI_PCLK_RESET_N:
 	case IMX8MQ_RESET_MIPI_DSI_ESC_RESET_N:
 	case IMX8MQ_RESET_MIPI_DSI_DPI_RESET_N:
Signature · 1 line
2.37.1