i.MX8 ov5640_mipi_v3 driver problem - SOLVED

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

i.MX8 ov5640_mipi_v3 driver problem - SOLVED

3,853 Views
draven
Contributor III

Solved Edit : 

First problem was at hardware.

If I load ov5640_mipi_v3 as module I got error. But with build-in there was no problem. I could get video.

------------------------------------------------------------------------------------------------------------

Hi all,

I try to work ov5640 camera with mipi csi.

I2c connection is ok and working.

But when I insmod module, I get errors.

root@imx8qxpmek:~# insmod ov5640_mipi_v3.ko
[ 60.292833] koda girdi
[ 60.292844] pin control
[ 60.295276] clock ayari
[ 60.297825] ov5640_mipi_v3 16-003c: 16-003c supply DOVDD not found, using dummy regulator
[ 60.308687] ov5640_mipi_v3 16-003c: Linked as a consumer to regulator.0
[ 60.315387] ov5640_mipi_v3 16-003c: 16-003c supply DVDD not found, using dummy regulator
[ 60.323624] ov5640_mipi_v3 16-003c: 16-003c supply AVDD not found, using dummy regulator
[ 60.803638] Subdev's name =
[ 60.806536] Media_entitiy's name = (null)
[ 60.810595] line 214 graph_obj = null
[ 60.810605] entitiy line : 223
[ 60.815132] mx8-img-md: Registered sensor subdevice: ov5640_mipi_v3 16-003c (1)
[ 60.825558] entity line = 685, source pad = 12, sink_pad = 0
[ 60.825605] ------------[ cut here ]------------
[ 60.835880] kernel BUG at drivers/media/media-entity.c:158!
[ 60.841451] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP
[ 60.846940] Modules linked in: ov5640_mipi_v3(+)
[ 60.851563] Process insmod (pid: 4227, stack limit = 0x(____ptrval____))
[ 60.858273] CPU: 0 PID: 4227 Comm: insmod Not tainted 4.19.35-1.1.0+g0f9917c56d59 #5
[ 60.866017] Hardware name: TQ Systems i.MX8QXP TQMa8XQP (DT)
[ 60.871675] pstate: 40000005 (nZcv daif -PAN -UAO)
[ 60.876479] pc : media_gobj_create+0xec/0xf0
[ 60.880754] lr : media_create_pad_link+0x10c/0x1b8
[ 60.885546] sp : ffff000022013820
[ 60.888856] x29: ffff000022013820 x28: ffff80002907e858
[ 60.894173] x27: 00000000000002a0 x26: 0000000000000000
[ 60.899490] x25: 00000000fffffff4 x24: ffff80002446c180
[ 60.904806] x23: 0000000000000001 x22: 0000000000000000
[ 60.910123] x21: 000000000000000c x20: ffff80002907e998
[ 60.915440] x19: ffff80002907e858 x18: 0000000000000001
[ 60.920756] x17: 0000000000000001 x16: 0000000000000007
[ 60.926073] x15: ffffffffffffffff x14: ffff0000096b86c8
[ 60.931390] x13: ffff0000098a0c60 x12: ffff0000098a08af
[ 60.936707] x11: 0000000000000001 x10: ffff000022013820
[ 60.942024] x9 : ffff000022013820 x8 : 30203d206461705f
[ 60.947340] x7 : ffff00000989f000 x6 : 00000000000001b1
[ 60.952657] x5 : 0000000000000000 x4 : ffff80002bf310c0
[ 60.957974] x3 : ffff80002bf310c0 x2 : ffff80002446c180
[ 60.963290] x1 : 0000000000000002 x0 : 0000000000000000
[ 60.968607] Call trace:
[ 60.971052] media_gobj_create+0xec/0xf0
[ 60.974981] subdev_notifier_complete+0x98/0x660
[ 60.979602] v4l2_async_notifier_try_complete.part.3+0x44/0x60
[ 60.985439] v4l2_async_register_subdev+0xf8/0x1c0
[ 60.990241] ov5640_probe+0x580/0x5fc [ov5640_mipi_v3]
[ 60.995388] i2c_device_probe+0x264/0x2c0
[ 60.999401] really_probe+0x1c8/0x280
[ 61.003065] driver_probe_device+0x54/0xe8
[ 61.007165] __driver_attach+0xe4/0xe8
[ 61.010918] bus_for_each_dev+0x70/0xc0
[ 61.014758] driver_attach+0x20/0x28
[ 61.018337] bus_add_driver+0x1dc/0x208
[ 61.022178] driver_register+0x60/0x110
[ 61.026018] i2c_register_driver+0x44/0x88
[ 61.030121] ov5640_i2c_driver_init+0x20/0x1000 [ov5640_mipi_v3]
[ 61.036131] do_one_initcall+0x74/0x178
[ 61.039971] do_init_module+0x54/0x1c8
[ 61.043723] load_module+0x1bc0/0x2130
[ 61.047476] __se_sys_finit_module+0xb8/0xc8
[ 61.051750] __arm64_sys_finit_module+0x18/0x20
[ 61.056286] el0_svc_common+0x84/0xf0
[ 61.059951] el0_svc_handler+0x2c/0x80
[ 61.063703] el0_svc+0x8/0xc
[ 61.066581] Code: f9405001 91000421 f9005001 d65f03c0 (d4210000)
[ 61.072679] ---[ end trace bdbbcc0d3c6e70a0 ]---

Message from syslogd@imx8qxpmek at Tue Feb 11 17:59:18 2020 ...
imx8qxpmek kernel: [ 60.841451] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP

Message from syslogd@imx8qxpmek at Tue Feb 11 17:59:18 2020 ...
imx8qxpmek kernel: [ 60.851563] Process insmod (pid: 4227, stack limit = 0x(____ptrval____))

Message from syslogd@imx8qxpmek at Tue Feb 11 17:59:18 2020 ...
imx8qxpmek kernel: [ 61.066581] Code: f9405001 91000421 f9005001 d65f03c0 (d4210000)
Segmentation fault
root@imx8qxpmek:~#

Because sensor->subdev seems NULL where ov5640_probe function.

ov5640_probe function in ov5640_mipi_v3.c = 

pr_warn("Subdev's name = %s\n",sd->name); -> empty
pr_warn("Media_entitiy's name = %s\n",sd->entity.name); -> NULL

v4l2_i2c_subdev_init(sd, client, &ov5640_subdev_ops);

And bug is here : 

media-entitiy.c function:

void media_gobj_create(struct media_device *mdev,
enum media_gobj_type type,
struct media_gobj *gobj)
{
BUG_ON(!mdev);         // BUG POINT HERE

I think somethings missing in my device tree. But I couldn't find. 

My device tree :

&isi_0 {
interface = <2 0 2>;
status = "okay";
};

&isi_1 {
status = "disabled";
};

&isi_2 {
status = "disabled";
};

&isi_3 {
status = "disabled";
};


&vpu {
status = "disabled";
};

&vpu_decoder {
core_type = <1>;
status = "okay";
};

&vpu_encoder {
core_type = <1>;
status = "okay";
};

&i2c0_csi0 {
#address-cells = <1>;
#size-cells = <0>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_csi0_lpi2c0>;
clock-frequency = <100000>;
status = "okay";

ov5640_mipi: ov5640_mipi@3c {
compatible = "ovti,ov5640_mipi_v3";
reg = <0x3c>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_mipi_csi0>;
clocks = <&clk IMX8QXP_CLK_DUMMY>;
clock-names = "csi_mclk";
csi_id = <0>;
pwn-gpios = <&gpio3 7 GPIO_ACTIVE_LOW>;
rst-gpios = <&gpio3 8 GPIO_ACTIVE_HIGH>;
mclk = <24000000>;
mclk_source = <0>;
mipi_csi;
status = "okay";
port {
ov5640_mipi_ep: endpoint {
remote-endpoint = <&mipi_csi0_ep>;
};
};
};


};

&mipi_csi_0 {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";

port@0 {
reg = <0>;
mipi_csi0_ep: endpoint {
remote-endpoint = <&ov5640_mipi_ep>;
data-lanes = <0 1>;
};
};
};

4 Replies

3,388 Views
prasad_imx8
Contributor III

Hello! Did you solve this problem with the patch? what was the issue really?

0 Kudos
Reply

3,548 Views
wanbenzhou
Contributor II

I  have the same problem,   how to solve it?

0 Kudos
Reply

3,562 Views
vinothkumars
Senior Contributor IV

Hi, yildizberat@gmail.com‌ ,

Follow this patch,

diff --git a/arch/arm64/boot/dts/freescale/fsl-imx8qm-mek-car.dts b/arch/arm64/boot/dts/freescale/fsl-imx8qm-mek-car.dts
index 6ba38b0..0ad5a05 100644
--- a/arch/arm64/boot/dts/freescale/fsl-imx8qm-mek-car.dts
+++ b/arch/arm64/boot/dts/freescale/fsl-imx8qm-mek-car.dts
@@ -597,9 +597,9 @@
assigned-clock-rates = <24000000>;
power-domains = <&pd_csi0_i2c0>;
pinctrl-names = "default";
- status = "okay";
+ status = "disabled";
clock-frequency = <1000000>;
- pinctrl-0 = <&pinctrl_mipi_csi0_en>;
+ /* pinctrl-0 = <&pinctrl_mipi_csi0_en>; */
max9286_mipi@6A {
compatible = "maxim,max9286_mipi";
reg = <0x6A>;
@@ -767,7 +767,7 @@
assigned-clock-rates = <600000000>;
power-domains =<&pd_isi_ch1>;
low_latency;
- status = "okay";
+ status = "disabled";
};

isi_2: isi@58120000 {
@@ -781,7 +781,7 @@
assigned-clock-rates = <600000000>;
power-domains =<&pd_isi_ch2>;
low_latency;
- status = "okay";
+ status = "disabled";
};

isi_3: isi@58130000 {
@@ -795,7 +795,7 @@
assigned-clock-rates = <600000000>;
power-domains =<&pd_isi_ch3>;
low_latency;
- status = "okay";
:...skipping...
commit bd77202ca4bdd53313d45a790379f1dbc951ae7b
Author: VinothS <vinothkumar.sekar@embitel.com>
Date: Sat Jan 25 20:06:14 2020 +0530

Added OV5640 MIPI CSI board (mini SAS) camera driver in dts file

diff --git a/arch/arm64/boot/dts/freescale/fsl-imx8qm-mek-car.dts b/arch/arm64/boot/dts/freescale/fsl-imx8qm-mek-car.dts
index 6ba38b0..0ad5a05 100644
--- a/arch/arm64/boot/dts/freescale/fsl-imx8qm-mek-car.dts
+++ b/arch/arm64/boot/dts/freescale/fsl-imx8qm-mek-car.dts
@@ -597,9 +597,9 @@
assigned-clock-rates = <24000000>;
power-domains = <&pd_csi0_i2c0>;
pinctrl-names = "default";
- status = "okay";
+ status = "disabled";
clock-frequency = <1000000>;
- pinctrl-0 = <&pinctrl_mipi_csi0_en>;
+ /* pinctrl-0 = <&pinctrl_mipi_csi0_en>; */
max9286_mipi@6A {
compatible = "maxim,max9286_mipi";
reg = <0x6A>;
@@ -767,7 +767,7 @@
assigned-clock-rates = <600000000>;
power-domains =<&pd_isi_ch1>;
low_latency;
- status = "okay";
+ status = "disabled";
};

isi_2: isi@58120000 {
@@ -781,7 +781,7 @@
assigned-clock-rates = <600000000>;
power-domains =<&pd_isi_ch2>;
low_latency;
- status = "okay";
+ status = "disabled";
};

isi_3: isi@58130000 {
@@ -795,7 +795,7 @@
assigned-clock-rates = <600000000>;
power-domains =<&pd_isi_ch3>;
low_latency;
- status = "okay";
+ status = "disabled";
};

isi_4: isi@58140000 {
@@ -868,7 +868,7 @@
#address-cells = <1>;
#size-cells = <0>;
virtual-channel;
- status = "okay";
+ status = "disabled";

/* Camera 0 MIPI CSI-2 (CSIS0) */
port@0 {
@@ -898,7 +898,7 @@
#address-cells = <1>;
#size-cells = <0>;
virtual-channel;
- status = "okay";
+ status = "disabled";

/* Camera 0 MIPI CSI-2 (CSIS1) */
port@1 {
@@ -961,19 +961,72 @@
assigned-clock-rates = <200000000>;
power-domains =<&pd_jpgenc>;
};
+
};

};

+
&iomuxc {
- imx8qm-mek {
- pinctrl_mipi_csi0_en: mipi_csi0_en{
- fsl,pins = <
- SC_P_MIPI_CSI0_GPIO0_00_LSIO_GPIO1_IO27 0x00000021
- SC_P_MIPI_CSI0_GPIO0_01_LSIO_GPIO1_IO28 0x00000021
- >;
- };
- };
+ imx8qm-mek {
+ pinctrl_mipi_csi0: mipicsi0grp{
+ fsl,pins = <
+ SC_P_MIPI_CSI0_MCLK_OUT_MIPI_CSI0_ACM_MCLK_OUT 0xC0000041
+ SC_P_MIPI_CSI0_GPIO0_00_LSIO_GPIO1_IO27 0x00000021
+ SC_P_MIPI_CSI0_GPIO0_01_LSIO_GPIO1_IO28 0x00000021
+ >;
+ };
+
+ };
+};
+
+&i2c0_mipi_csi0 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ clock-frequency = <100000>;
+ status = "okay";
+
+ /* MIPI-CSI2 camera */
+ ov5640_mipi: ov5640_mipi@3c {
+ compatible = "ovti,ov5640_mipi_v3";
+ reg = <0x3c>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_mipi_csi0>;
+ clocks = <&clk IMX8QM_24MHZ>;
+ clock-names = "csi_mclk";
+ csi_id = <0>;
+ pwn-gpios = <&gpio1 28 GPIO_ACTIVE_LOW>;
+ rst-gpios = <&gpio1 27 GPIO_ACTIVE_HIGH>;
+ mclk = <24000000>;
+ mclk_source = <0>;
+ mipi_csi;
+ status = "okay";
+ port {
+ ov5640_mipi_ep: endpoint {
+ remote-endpoint = <&mipi_csi0_ep>;
+ };
+ };
+ };
+
+ max9286_mipi@6A {
+ status = "disabled";
+ };
+};
+
+&mipi_csi_0 {
+ /delete-property/virtual-channel;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ status = "okay";
+
+ /* Camera 0 MIPI CSI-2 (CSIS0) */
+ port@0 {
+ reg = <0>;
+ mipi_csi0_ep: endpoint {
+ remote-endpoint = <&ov5640_mipi_ep>;
+ data-lanes = <1 2>;
+ };
+ };
};

&gpio1 {
diff --git a/arch/arm64/boot/dts/freescale/fsl-imx8qm-mek-domu-car.dts b/arch/arm64/boot/dts/freescale/fsl-imx8qm-mek-domu-car.dts
index e552a10..df79b4a 100644
--- a/arch/arm64/boot/dts/freescale/fsl-imx8qm-mek-domu-car.dts
+++ b/arch/arm64/boot/dts/freescale/fsl-imx8qm-mek-domu-car.dts
@@ -732,7 +732,7 @@
#address-cells = <1>;
#size-cells = <0>;
virtual-channel;
- status = "okay";
+ status = "disabled";

/* Camera 0 MIPI CSI-2 (CSIS0) */
port@0 {
diff --git a/arch/arm64/configs/android_car_defconfig b/arch/arm64/configs/android_car_defconfig
index 9ea402b..439b166 100644
--- a/arch/arm64/configs/android_car_defconfig
+++ b/arch/arm64/configs/android_car_defconfig
@@ -2682,7 +2682,7 @@ CONFIG_IMX8_MIPI_CSI2=m
CONFIG_IMX8_PARALLEL_CSI=y
CONFIG_IMX8_MIPI_CSI2_YAV=y
CONFIG_MXC_CAMERA_OV5640_V3=y
-CONFIG_MXC_CAMERA_OV5640_MIPI_V3=m
+CONFIG_MXC_CAMERA_OV5640_MIPI_V3=y
CONFIG_GMSL_MAX9286=m
CONFIG_IMX8_JPEG=y
CONFIG_IMX8_HDMI_RX=y
(END)

Regards,

VinothS,

Regards,
Vinothkumar Sekar

3,562 Views
joanxie
NXP TechSupport
NXP TechSupport

pls refer to the application note which tell you how to enable ov5640, you need use the correct dtb file when you program the image to your board:

i.MX 8M Applications Processor | Arm® Cortex®-A53, Cortex-M4 | 4K display resolution | NXP 

find "Quick Start Guide for MINISASTOCSI for i.MX 8M Evaluation Kit"