How to configure custom camera MIPI sensor dts on IMX8MN

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

How to configure custom camera MIPI sensor dts on IMX8MN

4,142 Views
SoniaArevalo
Contributor I

Hello, I’m trying to add a IMX258 camera MIPI sensor to my IMX8MN board.

First, I added imx258 driver to the system and I enabled it on Kernel.

Then, I modified dts file for camera configuration:

 

i2c3 {
/* Oscillator on camera board*/
imx258_clk: clk {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <19200000>;
};

camera: camera@6c {
compatible = "sony,imx258";
reg = <0x6c>;
pinctrl-names = "default";
pintctrl-0 = <&pinctrl_csi_pwn>, <&pinctrl_csi_rst>;
clocks = <&imx258_clk>;
clock-names = "clk";
assigned-clocks = <&imx258_clk>;
assigned-clock-rates = <19200000>;
port {
sensor_ep: endpoint {
remote-endpoint = <&mipi1_sensor_ep>;
data-lanes = <1 2 3 4>;
clocks-lanes = <0>;
link-frequencies = /bits/ 64 <633600000>;
};
};
};
};
 &mipi_csi_1 {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
port@0 {
reg = <0>;
mipi1_sensor_ep: endpoint {
remote-endpoint = <&sensor_ep>;
data-lanes = <2>;
csis-hs-settle = <13>;
csis-clk-settle = <2>;
csis-wclk;
};
};
};

 

However, I think that u-boot is not finding this sensor because I get this message:

 

Can't find cec device id=0x3c

fail to probe panel device adv7535@3d

failed to get any video link display timings

probe video device failed, ret -22

 

Also, I got this dmesg about mipi:

[ 1.998898] mxc-mipi-csi2-sam 32e30000.csi: 32e30000.csi supply mipi-phy not found, using dummy regulator

[ 2.008905] mxc-mipi-csi2-sam 32e30000.csi: lanes: 2, hs_settle: 13, clk_settle: 2, wclk: 1, freq: 333000000

 

What should I do to solve it?

Best regards,

Sonia.

0 Kudos
9 Replies

4,131 Views
khang_letruong
Senior Contributor III

Hi again,

One more thing :

However, I think that u-boot is not finding this sensor because I get this message

It is not the responsibility of u-boot but kernel to find the sensor's configuration from the kernel dts and load the associated driver (for example imx258.c in your case). You should enable the debug message within imx258.c to see the probing progress.If the probing is successful, you will see appear /dev/videoX depending on your system.

For quick check, you can also type dmesg | grep "imx258".

Best Regards,
Khang

0 Kudos

4,109 Views
SoniaArevalo
Contributor I

Hi Khang, many thanks for your answer.

 

I modified some things in dts file:

imx258: imx258_mipi@34 {
        compatible = "sony,imx258";
        reg = <0x34>;
        pinctrl-names = "default";
        pintctrl-0 = <&pinctrl_csi_pwn>, <&pinctrl_csi_rst>;
        clocks = <&clk IMX8MN_CLK_CLKO1>;
        clock-names = "xclk";
        assigned-clocks = <&clk IMX8MN_CLK_CLKO1>;
        assigned-clock-parents = <&clk IMX8MN_CLK_24M>;
        assigned-clock-rates = <24000000>;
        csi_id = <0>;
        powerdown-gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>;
        reset-gpios = <&gpio1 6 GPIO_ACTIVE_LOW>;
        mclk = <24000000>;
        mclk_source = <0>;
        mipi_csi_1;
        status = "okay";
        port {
                   imx258_ep: endpoint {
                            remote-endpoint = <&mipi1_sensor_ep>;
                            data-lanes = <1 2>;
                           clocks-lanes = <0>;
                    };
       };

};

 

I also added imx258 to kernel and I got this in dmesg:

[ 69.905026] bus: 'i2c': add driver imx258

 

However I still can’t see i2c device at i2cdetect or /dev/video0.

Any idea?

 

Best regards, Sonia.

0 Kudos

4,101 Views
khang_letruong
Senior Contributor III

Hi @SoniaArevalo ,

Let me take an example of the imx258 driver in the NXP's linux-imx repository : https://source.codeaurora.org/external/imx/linux-imx/tree/drivers/media/i2c/imx258.c?h=lf-5.10.y

You should first make sure that the imx258_probe() function returns 0. You can add more debug messages (dev_info(), dev_error(), ...) to print out the execution progress of that function.

Best Regards,
Khang

0 Kudos

4,097 Views
khang_letruong
Senior Contributor III

Btw, Sony's sensors usually have I2C address as 0x1a for master/stand-alone and 0x36 (or 0x37) for slave  if I remember well.

Meanwhile, I saw in your previous messages :

camera: camera@6c {
compatible = "sony,imx258";
reg = <0x6c>;

or

 

imx258: imx258_mipi@34 {
        compatible = "sony,imx258";
        reg = <0x34>;

 

Could you confirm that you use correct I2C address for your IMX258 sensor ?

Regards,
Khang

0 Kudos

4,067 Views
SoniaArevalo
Contributor I

Hello again,

I noticed that my NXP’s clock was not working, so I connected an external clock and then I could see by i2cdetect the correct addres: 0x1a.

Am I missing something that is making the clock not work? Should I modify something at dts file?

WhatsApp Image 2022-02-21 at 15.37.08.jpeg

 

This is the dts chaged:

 

/* Oscillator on camera board*/

imx258_clk: clk {

compatible = "fixed-clock";

#clock-cells = <0>;

clock-frequency = <19200000>;

};

 

imx258: imx258_mipi@1a {

compatible = "sony,imx258";

reg = <0x1a>;

pinctrl-names = "default";

pintctrl-0 = <&pinctrl_csi_pwn>, <&pinctrl_csi_rst>;

clocks = <&imx258_clk>;

clock-names = "clk";

csi_id = <0>;

powerdown-gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>;

reset-gpios = <&gpio1 6 GPIO_ACTIVE_LOW>;

mipi_csi_1;

status = "okay";

port {

imx258_ep: endpoint {

remote-endpoint = <&mipi1_sensor_ep>;

data-lanes = <1 2>;

clocks-lanes = <0>;

};

};

 

};

 

I think that the dirver is loaded, because I'm getting this information.

 

WhatsApp Image 2022-02-21 at 16.01.45.jpeg

 

However, I can not find the way to check dev_info() or dev_error(), that I added to imx258.c file as you recommend me.

 

Thank you very much for your help.

Best regards, Sonia.

 

 

 

0 Kudos

4,063 Views
khang_letruong
Senior Contributor III

HI @SoniaArevalo ,

Am I missing something that is making the clock not work? Should I modify something at dts file?

You can refer to the default imx8mn-evk.dtsi for the 24-MHz clock for ov5640. However, most of Sony's sensors require 37.125MHz, or 74.25Mhz or  54Mhz.  Therefore, I would be better to use external clock for precise timing.

I think that the dirver is loaded, because I'm getting this information.

You can check with lsmod command to see if it is listed. And potentially re-verify if the address 0x1a is still detected by i2cdetect (if the module with that address is failed to load, the assigned I2C address also disappears).

However, I can not find the way to check dev_info() or dev_error(), that I added to imx258.c file as you recommend me.

From the board's console, you can do dmesg | grep "the-message-printed-dev_info-or-dev_error"

Btw, could you share the imx258.c driver that you are using if it is different than https://source.codeaurora.org/external/imx/linux-imx/tree/drivers/media/i2c/imx258.c?h=lf-5.10.y

Best Regards,

K.

0 Kudos

4,047 Views
SoniaArevalo
Contributor I

Hi again Khang,

I've read in the datasheet that the frequency for the imx258 camera is between 6 MHz and 27 MHZ, I'd like to share with you the datasheet but it's confidential, so we can arrange this part by private message if i'ts able to you.

For that reason I set the same frequency than the ov5640 in the DTS. During the hardware test, adding the external oscillator at same frequency, I've obtained the i2c address as I told you.

I've appreciate that for the OV5640, the CLKO1 pin oscillate only during the kernel start-up and camera detection, and also for under the v4l2 operations. In that case, for the imx258 didn't do it, and I added the external clock for easy working c kernel code.

Also, I've added debug print messages in the imx258.c by my own, but I can't see any response during start-up, modprobe or dmesg filtering message process. I'm a little bit worried about it. I'm not sure if I'm following your recommendations correctly.

However, I can appreciate that before a modprobe, the lsmod show that it's loaded but not used.

error_module.png

I attach you here the modified kernel code too, which without modifcations it's the same for both kernel versions 5.4 and 5.10.

As I understand it, right now, the imx258 camera it's alive, because I can find the i2c slave address and it means that this part of the hardware is correct. As the kernel doesn't start-up correclty the driver, the mipi-csi doesn't work too (i can't get image output), and probably it cause that the /dev/video0 doesn't appear.

So I'm near to solve the issue, but I can't find where exactly is the trouble, I hope you can help me on it.

 

I'll be waiting your news as soon as possible.

 

Many thanks for your supporty, I really appreciate it.

 

Best regards, S.

0 Kudos

4,022 Views
khang_letruong
Senior Contributor III

Hi @SoniaArevalo ,

Can you try to replace :

#ifdef CONFIG_ACPI
static const struct acpi_device_id imx258_acpi_ids[] = {
	{ "SONY258A" },
	{ /* sentinel */ }
};

MODULE_DEVICE_TABLE(acpi, imx258_acpi_ids);
#endif

with :

static const struct of_device_id imx258_dt_ids[] = {
	{ .compatible = "sony,imx258" },
	{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, imx258_dt_ids);

 

like in the example of imx219, please ?

Regards,
K.

0 Kudos

4,133 Views
khang_letruong
Senior Contributor III

Hi @SoniaArevalo ,

Can't find cec device id=0x3c

fail to probe panel device adv7535@3d

failed to get any video link display timings

probe video device failed, ret -22

The above error should come from the fact that you did not connect/use a MIPI-DSI to HDMI bridge board. It is not relevant to the MIPI-CSI2 interfacing with the IMX258 sensor at all.

[ 1.998898] mxc-mipi-csi2-sam 32e30000.csi: 32e30000.csi supply mipi-phy not found, using dummy regulator

[ 2.008905] mxc-mipi-csi2-sam 32e30000.csi: lanes: 2, hs_settle: 13, clk_settle: 2, wclk: 1, freq: 333000000

Above message is about the probing/initialization of the MIPI-CSI2 interface which is configured from below dts node : 

 &mipi_csi_1 {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
port@0 {
reg = <0>;
mipi1_sensor_ep: endpoint {
remote-endpoint = <&sensor_ep>;
data-lanes = <2>;
csis-hs-settle = <13>;
csis-clk-settle = <2>;
csis-wclk;
};
};
};

Therefore, the messages you shared are not really an issue and you do not need to solve.

Best Regards,
Khang

 

 

 

 

0 Kudos