AnsweredAssumed Answered

i.MX8 ov5640_mipi_v3 driver problem - SOLVED

Question asked by berat yildiz on Feb 12, 2020

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>;
};
};
};

 

Outcomes