How to set up Device Tree for second camera on DB820c

Does anyone know what changes I would have to make to the device tree to get a second mipi camera working on the DB820c? A different CCI and I2C bus would need to be used, correct? I would want to use CCI_I2C_SDA1 and CCI_I2C_SCL1 with CAM_MCLK2, instead of CCI_I2C_SDA0 and CCI_I2C_SCL0, and CAM_MCLK0. Would the a0c000 address need to change to something else:
cci@a0c000 {
status = “ok”;

		camera_rear@3b {

Any help would be great,
Kim

Not necessarily, you can drive several cameras with only one CCI/I2C bus. At initialization camera will be configured with different I2C addresses. So you can have several camera child devices under the cci@a0c000 nodes.

AFAIK, The 820C/APW8096 has only one CCI controller, I assume you can route the CCI controller pins to either SDA0/SCL0 or SDA1/SCL1, but you still use the same controller. @todortomov do you confirm ?

It has one CCI controller but that contoller can drive two hardware CCI buses. So Kim’s question is valid however the software support for the second CCI bus is still in progress, it is not ready yet.

Hi Loic and todor,
I think I’ve just confirmed that CCI1 is not working, but CCI0 is working. This is on a development board that has a snapdragon 820 processor. I attached a camera that requires no I2C commands for setting up the camera and am able to capture video from the camera after configuring the device tree to port2 for that camera and it comes up correctly as /dev/video2:
camss@a00000 {
status = “ok”
ports {

port@2 {
reg = <2>;
csiphy2_ep: endpoint {
clock-lanes = <7>;
data-lanes = <0 1>;
remote-endpoint = <&camera_ep>;
//status = “disabled”;
};
};
This camera also works on port@0. Another camera I have does require I2C and only works on port@0.
Do you have a timeline for when the other CCI bus will be working?

Thanks for the help and confirmation,
kimbo

Any update on this?
I want to use the second MIPI port as well as the first port on the Dragonboard 820c.
Thanks,
tamo2

@todortomov
@Loic

Any update on software support for second CCI bus?

Thanks,
Arun

Well, I’ve not yet tested it but this branch should support it: loic.poulain/linux.git - [no description]

It contains patch for msm8916/8996 CCI driver, which is a bit different from the kernel 4.14 one and contains support for the second bus. I’ve not yet tested it with 820c, so you may want to wait a bit or test it on your side, this requests to update the msm8996/apq8096 dts with correct compatible string and subnodes (cci, i2c-bus@0, i2c-bus@1…)

Thanks @Loic for the reply

I have ported the CCI changes supporting two buses from loic.poulain/linux.git - [no description] branch to kernel-4.14.89.
OV5645 on CCI1 bus

getting these errors,
root@820-devkit:~# dmesg | grep ov5645
[ 12.904595] ov5645 5-003c: ov5645_write_reg_to: write reg error -110 on addr 0x3c: reg=0x3100, val=0x78
[ 12.904597] ov5645 5-003c: could not change i2c address
[ 12.904622] ov5645 5-003c: could not power up OV5645
[ 12.905743] ov5645: probe of 5-003c failed with error -110
root@820-devkit:~# dmesg | grep cci
[ 12.787388] i2c-qcom-cci a0c000.cci: master 1 queue 0 timeout
[ 12.904582] i2c-qcom-cci a0c000.cci: CCI halt timeout
[ 12.904586] i2c-qcom-cci a0c000.cci: cci i2c xfer error -110

I have made dts entries like this,
https://github.com/dasariarun/cci/blob/master/board.dts
https://github.com/dasariarun/cci/blob/master/msm8996.dtsi

Any idea to debug it further?

Thanks,
Arun

Well, did you update pinctrl accordingly? I assume camera_primary_default configure muxing for routing some pins to cci master 0 and now you also want to route some other pins to cci master 1.
e.g. cci0_default and ccu1_default: LKML: Todor Tomov: [PATCH 1/2] arm64: dts: qcom: Add Camera Control Interface pinctrls

@Loic

Thanks for the reply. I have checked pin muxing and probed MCLK1, CCI I2C lines and reset lines. seems these are fine, but still getting the same error. I am working with kernel - 4.14.89.

Thanks,
Arun

Do you see the CCI/I2C signal at init?

@Loic
At bootup time, CCI/I2C clock is seen for a particular time period and the data line is low at the time after that data line is always high.

One more issue missing i2c-bus@1, If i make status disable for CCI I2Cbus@0 node
[ 2.792378] i2c-qcom-cci a0c000.cci: Missing i2c-bus@1 child node
[ 2.799822] i2c-qcom-cci: probe of a0c000.cci failed with error -22

Regards,
Arun

Look like a pin muxing issue.

You can not disable this subnode since the CCI driver expect two i2c-bus subnodes, however you can disable the subnode child (ov5640) if necessary.

Thanks @Loic
I made some changes to i2c-qcom-cci.c driver(removed return -ETIMEDOUT in cci_run_queue API) and now master 1 bus is up and detecting the ov5645 camera sensor(CCI1 and CSI1).
[ 35.273784] ov5645 5-003c: OV5645 detected at address 0x3c

using these commands for camera preview,

media-ctl -d /dev/media0 -l ‘“msm_csiphy1”:1->“msm_csid1”:0[1],“msm_csid1”:1->“msm_ispif1”:0[1],“msm_ispif1”:1->“msm_vfe0_rdi1”:0[1]’

media-ctl -d /dev/media0 -V ‘“ov5645 5-003c”:0[fmt:UYVY2X8/1920x1080 field:none],“msm_csiphy1”:0[fmt:UYVY2X8/1920x1080 field:none],“msm_csid1”:0[fmt:UYVY2X8/1920x1080 field:none],“msm_ispif1”:0[fmt:UYVY2X8/1920x1080 field:none],“msm_vfe0_rdi1”:0[fmt:UYVY2X8/1920x1080 field:none]’

gst-launch-1.0 v4l2src device=/dev/video1 ! ‘video/x-raw,format=UYVY,width=1920,height=1080,framerate=30/1’ ! glimagesink

but seems no preview. is there anything wrong with the commands?

dmesg logs after running above commands in capure script,
[ 293.707894] qcom-camss a34000.camss: CSIPHY 3PH HW Version = 0x10000000
[ 293.708258] qcom-camss a34000.camss: VFE HW Version = 0x70020000
[ 293.714623] qcom-camss a34000.camss: VFE HW Version = 0x70020000
[ 293.720109] qcom-camss a34000.camss: VFE HW Version = 0x70020000
[ 293.726059] qcom-camss a34000.camss: VFE HW Version = 0x70020000
[ 293.732065] qcom-camss a34000.camss: VFE HW Version = 0x70020000
[ 293.738022] qcom-camss a34000.camss: VFE HW Version = 0x70020000
[ 293.744025] qcom-camss a34000.camss: VFE HW Version = 0x70020000
[ 294.034433] qcom-camss a34000.camss: CSIPHY 3PH HW Version = 0x10000000
[ 294.034756] qcom-camss a34000.camss: VFE HW Version = 0x70020000

after ctrl+c
[ 313.637437] qcom-camss a34000.camss: VFE sof timeout
[ 314.149327] qcom-camss a34000.camss: VFE reg update timeout

Thanks,
Arun

Did you update your device tree, AFAIU you’re using CCI1 and CSI1 (not CCI0 and CSI0), so you may want to create a second camera port under camss:

+				port@1 {
+					reg = <1>;
+					csiphy1_ep: endpoint {
+						clock-lanes = <1>;
+						data-lanes = <0 2>;
+						remote-endpoint = <&ov5645_2_ep>;
+						status = "okay";
+					};
+				};

And point to it from your I2C endpoint (remote-endpoint = <&csiphy1_ep>;)

@Loic

Yeah, I have already added second camera node under camss, same way as you mentioned.
https://github.com/dasariarun/cci/blob/master/board.dts
https://github.com/dasariarun/cci/blob/master/msm8996.dtsi
is there anything wrong with the commands and devicetree entries?

update:
OV5645 wih CCI1-CSI1 working. Thanks @Loic

Thanks,
Arun

Cool, the dts looks good. what was the problem finally? is there anything to change in the current CCI driver?

@Loic
removing the property, clock-frequency = <400000> from the dts node worked for me.
There are few changes in the driver,

  1. Ported driver to 4.14.89 kernel. There are few APIs not present in 4.14.89(example: devm_clk_bulk_get_all) so used alternative APIs
  2. Removed return statement, return -ETIMEDOUT in cci_run_queue API

Thanks,
Arun

@Loic

but you defined only i2c-bus@0, loic.poulain/linux.git - [no description]

board is not booting if i add both i2c-bus@0 and i2c-bus@1(booting once in 3-4 times and camera working once board boots). If i disable i2c-bus@0 board boots fine always but facing error missing i2c-bus@1 and OV5645 is not detected

Update: solved the boot issue. Issue is seen because i2c-bus@0 dts entries are incomplete.

Thanks,
Arun