media: i2c: ov5645: Fix CSI-2 CRC errors on RK3576 after init sequence
Subsystems (2)
PATCH 1/1 media: i2c: ov5645: Fix CSI-2 CRC errors on RK3576 after init sequence
On the RK3576 platform, after ov5645_global_init_setting completes and before stream on, the CSI host reports a high rate of CRC errors:
MIPI_CSI2 ERR1:0x1000000 (crc,vc: 0)
These errors occur exclusively in the window between init completion and stream on. Once preview starts and the sensor outputs valid HS data, no further CRC errors are observed.
Commit 092e8eb90a7d ("media: i2c: ov5645: Fix power sequence") reworked the power sequence to properly enter LP-11 during power-up. As part of this change, the SYSTEM_CTRL0_STOP (0x42) write in s_power() was replaced with usleep_range(500, 1000), leaving the sensor in wake state (0x3008 = 0x02) from init through to s_stream. Reverting this commit resolves the CRC errors, confirming it as the triggering change.
Restore the power-down state after init by appending { 0x3008, 0x42 } to the end of ov5645_global_init_setting[]. This powers down the sensor core after MIPI configuration is complete, while keeping the MIPI PHY active in LP-11. The sensor is then woken up only at s_stream time.
This preserves all LP-11 compliance improvements from commit 092e8eb90a7d ("media: i2c: ov5645: Fix power sequence") while eliminating the CRC errors on RK3576.
--- drivers/media/i2c/ov5645.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/i2c/ov5645.c +2 -1
@@ -351,7 +351,8 @@ static const struct reg_value ov5645_global_init_setting[] = { { 0x3008, 0x02 }, { OV5645_IO_MIPI_CTRL00, 0x40 }, { OV5645_MIPI_CTRL00, 0x24 }, - { OV5645_PAD_OUTPUT00, 0x70 } + { OV5645_PAD_OUTPUT00, 0x70 }, + { 0x3008, 0x42 } }; static const struct reg_value ov5645_setting_sxga[] = {
Signature · 1 line
2.34.1
Humble ping ...
Add linux-stable in Cc list
thanks
xiaolei
Quoted 45 lines · Xiaolei Wang
On the RK3576 platform, after
ov5645_global_init_settingcompletes and before stream on, the CSI host reports a high rate of CRC errors:MIPI_CSI2 ERR1:0x1000000 (crc,vc: 0)These errors occur exclusively in the window between init completion and stream on. Once preview starts and the sensor outputs valid HS data, no further CRC errors are observed.
Commit
092e8eb90a7d("media: i2c: ov5645: Fix power sequence") reworked the power sequence to properly enter LP-11 during power-up. As part of this change, theSYSTEM_CTRL0_STOP(0x42) write ins_power()was replaced withusleep_range(500, 1000), leaving the sensor in wake state (0x3008=0x02) from init through tos_stream. Reverting this commit resolves the CRC errors, confirming it as the triggering change.Restore the power-down state after init by appending {
0x3008,0x42} to the end of ov5645_global_init_setting[]. This powers down the sensor core after MIPI configuration is complete, while keeping the MIPI PHY active in LP-11. The sensor is then woken up only ats_streamtime.This preserves all LP-11 compliance improvements from commit
092e8eb90a7d("media: i2c: ov5645: Fix power sequence") while eliminating the CRC errors on RK3576.Fixes 092e8eb90a7d ("media: i2c: ov5645: Fix power sequence")Signed-off-by Xiaolei Wang <[email protected]>--- drivers/media/i2c/ov5645.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/media/i2c/ov5645.c +2
-1@@ -351,7 +351,8 @@ static const struct reg_value ov5645_global_init_setting[] = { { 0x3008, 0x02 }, { OV5645_IO_MIPI_CTRL00, 0x40 }, { OV5645_MIPI_CTRL00, 0x24 }, - { OV5645_PAD_OUTPUT00, 0x70 } + { OV5645_PAD_OUTPUT00, 0x70 }, + { 0x3008, 0x42 } }; static const struct reg_value ov5645_setting_sxga[] = {
Sakari Ailus
maintainerHi Xiaolei,
Quoted 36 lines · Xiaolei Wang
On the RK3576 platform, after
ov5645_global_init_settingcompletes and before stream on, the CSI host reports a high rate of CRC errors:
MIPI_CSI2ERR1:0x1000000 (crc,vc: 0)These errors occur exclusively in the window between init completion and stream on. Once preview starts and the sensor outputs valid HS data, no further CRC errors are observed.
Commit
092e8eb90a7d("media: i2c: ov5645: Fix power sequence") reworked the power sequence to properly enter LP-11 during power-up. As part of this change, theSYSTEM_CTRL0_STOP(0x42) write ins_power()was replaced withusleep_range(500, 1000), leaving the sensor in wake state (0x3008=0x02) from init through tos_stream. Reverting this commit resolves the CRC errors, confirming it as the triggering change.Restore the power-down state after init by appending {
0x3008,0x42} to the end of ov5645_global_init_setting[]. This powers down the sensor core after MIPI configuration is complete, while keeping the MIPI PHY active in LP-11. The sensor is then woken up only ats_streamtime.This preserves all LP-11 compliance improvements from commit
092e8eb90a7d("media: i2c: ov5645: Fix power sequence") while eliminating the CRC errors on RK3576.Fixes 092e8eb90a7d ("media: i2c: ov5645: Fix power sequence")Signed-off-by Xiaolei Wang <[email protected]>--- drivers/media/i2c/ov5645.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/media/i2c/ov5645.c +0
-0
drivers/media/i2c/ov5645.c static const struct reg_value ov5645_global_init_setting[] = { · line 355
Quoted 6 lines
drivers/media/i2c/ov5645.c +2
-1@@ -351,7 +351,8 @@ static const struct reg_value ov5645_global_init_setting[] = { { 0x3008, 0x02 }, { OV5645_IO_MIPI_CTRL00, 0x40 }, { OV5645_MIPI_CTRL00, 0x24 }, - { OV5645_PAD_OUTPUT00, 0x70 } + { OV5645_PAD_OUTPUT00, 0x70 }, + { 0x3008, 0x42 }
Is the earlier write of 0x3008 still appropriate?
Quoted 3 lines
drivers/media/i2c/ov5645.c +0
-0};static const struct reg_value ov5645_setting_sxga[] = {
Signature · 1 line
Sakari Ailus
Quoted 32 lines · Sakari Ailus
Quoted 31 lines · Xiaolei Wang
On the RK3576 platform, after
ov5645_global_init_settingcompletes and before stream on, the CSI host reports a high rate of CRC errors:
MIPI_CSI2ERR1:0x1000000 (crc,vc: 0)These errors occur exclusively in the window between init completion and stream on. Once preview starts and the sensor outputs valid HS data, no further CRC errors are observed.
Commit
092e8eb90a7d("media: i2c: ov5645: Fix power sequence") reworked the power sequence to properly enter LP-11 during power-up. As part of this change, theSYSTEM_CTRL0_STOP(0x42) write ins_power()was replaced withusleep_range(500, 1000), leaving the sensor in wake state (0x3008=0x02) from init through tos_stream. Reverting this commit resolves the CRC errors, confirming it as the triggering change.Restore the power-down state after init by appending {
0x3008,0x42} to the end of ov5645_global_init_setting[]. This powers down the sensor core after MIPI configuration is complete, while keeping the MIPI PHY active in LP-11. The sensor is then woken up only ats_streamtime.This preserves all LP-11 compliance improvements from commit
092e8eb90a7d("media: i2c: ov5645: Fix power sequence") while eliminating the CRC errors on RK3576.Fixes 092e8eb90a7d ("media: i2c: ov5645: Fix power sequence")Signed-off-by Xiaolei Wang <[email protected]>--- drivers/media/i2c/ov5645.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 11 lines
drivers/media/i2c/ov5645.c static const struct reg_value ov5645_global_init_setting[] = { · line 355
Quoted 11 lines
drivers/media/i2c/ov5645.c +2
-1@@ -351,7 +351,8 @@ static const struct reg_value ov5645_global_init_setting[] = { { 0x3008, 0x02 }, { OV5645_IO_MIPI_CTRL00, 0x40 }, { OV5645_MIPI_CTRL00, 0x24 }, - { OV5645_PAD_OUTPUT00, 0x70 } + { OV5645_PAD_OUTPUT00, 0x70 }, + { 0x3008, 0x42 }
While at it, please use the register macro.
Quoted 1 line
Is the earlier write of
0x3008still appropriate?
There are four earlier writes of register 0x3008. The whole initialization sequence likely needs a cleanup. It's not clear why software suspend needs to be disabled briefly during initialization.
Quoted 3 lines
Quoted 3 lines
drivers/media/i2c/ov5645.c +0
-0};static const struct reg_value ov5645_setting_sxga[] = {
Signature · 3 lines
Regards, Laurent Pinchart
Hi Laurent,
Thank you so much for your review.
Quoted 33 lines · Laurent Pinchart
Quoted 32 lines · Sakari Ailus
Quoted 31 lines · Xiaolei Wang
On the RK3576 platform, after
ov5645_global_init_settingcompletes and before stream on, the CSI host reports a high rate of CRC errors:MIPI_CSI2 ERR1:0x1000000 (crc,vc: 0)These errors occur exclusively in the window between init completion and stream on. Once preview starts and the sensor outputs valid HS data, no further CRC errors are observed.
Commit
092e8eb90a7d("media: i2c: ov5645: Fix power sequence") reworked the power sequence to properly enter LP-11 during power-up. As part of this change, theSYSTEM_CTRL0_STOP(0x42) write ins_power()was replaced withusleep_range(500, 1000), leaving the sensor in wake state (0x3008=0x02) from init through tos_stream. Reverting this commit resolves the CRC errors, confirming it as the triggering change.Restore the power-down state after init by appending {
0x3008,0x42} to the end of ov5645_global_init_setting[]. This powers down the sensor core after MIPI configuration is complete, while keeping the MIPI PHY active in LP-11. The sensor is then woken up only ats_streamtime.This preserves all LP-11 compliance improvements from commit
092e8eb90a7d("media: i2c: ov5645: Fix power sequence") while eliminating the CRC errors on RK3576.Fixes 092e8eb90a7d ("media: i2c: ov5645: Fix power sequence")Signed-off-by Xiaolei Wang <[email protected]>--- drivers/media/i2c/ov5645.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 12 lines
Quoted 11 lines
drivers/media/i2c/ov5645.c static const struct reg_value ov5645_global_init_setting[] = { · line 355
Quoted 11 lines
drivers/media/i2c/ov5645.c +2
-1@@ -351,7 +351,8 @@ static const struct reg_value ov5645_global_init_setting[] = { { 0x3008, 0x02 }, { OV5645_IO_MIPI_CTRL00, 0x40 }, { OV5645_MIPI_CTRL00, 0x24 }, - { OV5645_PAD_OUTPUT00, 0x70 } + { OV5645_PAD_OUTPUT00, 0x70 }, + { 0x3008, 0x42 }While at it, please use the register macro.
Will do in v2.
Quoted 4 lines
Quoted 2 lines
Is the earlier write of
0x3008still appropriate?There are four earlier writes of register
0x3008. The whole initialization sequence likely needs a cleanup.
The ov5645_global_init_setting register may come directly from
the manufacturer.
I gave this a try. Three of the four writes can simply be dropped,
leaving only the { 0x3008, 0x42 } near the beginning of the table:
{ 0x5a24, 0x00 },
- { 0x3008, 0x02 },
{ 0x3503, 0x00 },
...
{ 0x0601, 0x02 },
- { 0x3008, 0x42 },
- { 0x3008, 0x02 },
{ OV5645_IO_MIPI_CTRL00, 0x40 },
I tested this change on the Rockchip 3576 and IMX8MP platforms and found no problems.
Quoted 2 lines
It's not clear why
software suspend needs to be disabled briefly during initialization.
Yes, I noticed that the driver was configured with software suspend upon
power-up at the initial commit.
thanks
xiaolei
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/media/i2c/ov5645.c +0
-0};static const struct reg_value ov5645_setting_sxga[] = {
Hi Sakari,
Thank you so much for your review.
Quoted 34 lines · Sakari Ailus
Hi Xiaolei,
Quoted 31 lines · Xiaolei Wang
On the RK3576 platform, after
ov5645_global_init_settingcompletes and before stream on, the CSI host reports a high rate of CRC errors:MIPI_CSI2 ERR1:0x1000000 (crc,vc: 0)These errors occur exclusively in the window between init completion and stream on. Once preview starts and the sensor outputs valid HS data, no further CRC errors are observed.
Commit
092e8eb90a7d("media: i2c: ov5645: Fix power sequence") reworked the power sequence to properly enter LP-11 during power-up. As part of this change, theSYSTEM_CTRL0_STOP(0x42) write ins_power()was replaced withusleep_range(500, 1000), leaving the sensor in wake state (0x3008=0x02) from init through tos_stream. Reverting this commit resolves the CRC errors, confirming it as the triggering change.Restore the power-down state after init by appending {
0x3008,0x42} to the end of ov5645_global_init_setting[]. This powers down the sensor core after MIPI configuration is complete, while keeping the MIPI PHY active in LP-11. The sensor is then woken up only ats_streamtime.This preserves all LP-11 compliance improvements from commit
092e8eb90a7d("media: i2c: ov5645: Fix power sequence") while eliminating the CRC errors on RK3576.Fixes 092e8eb90a7d ("media: i2c: ov5645: Fix power sequence")Signed-off-by Xiaolei Wang <[email protected]>--- drivers/media/i2c/ov5645.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 12 lines
drivers/media/i2c/ov5645.c static const struct reg_value ov5645_global_init_setting[] = { · line 355
Quoted 11 lines
drivers/media/i2c/ov5645.c +2
-1@@ -351,7 +351,8 @@ static const struct reg_value ov5645_global_init_setting[] = { { 0x3008, 0x02 }, { OV5645_IO_MIPI_CTRL00, 0x40 }, { OV5645_MIPI_CTRL00, 0x24 }, - { OV5645_PAD_OUTPUT00, 0x70 } + { OV5645_PAD_OUTPUT00, 0x70 }, + { 0x3008, 0x42 }Is the earlier write of
0x3008still appropriate?
You're right, I tested removing the { 0x3008, 0x02 } write and the MIPI PHY still enters LP-11 correctly without it. The CRC errors are also gone.
The 0x02 was a leftover introduced by commit 092e8eb90a7d when it moved the 0x42 stop out of s_power() — the sensor doesn't need to be explicitly
woken in the init table since s_stream handles that later.
thanks
xiaolei
Quoted 3 lines
Quoted 3 lines
drivers/media/i2c/ov5645.c +0
-0};static const struct reg_value ov5645_setting_sxga[] = {