Custom Allwinner V3s boards


#61

Hi,
About XCLK , I’m afraid it could be turned on without camera.
XCLK is defined for camera and when camera going to be probed, XCLK is turned on.
After probe is finished, it could go off.
When camera going to be used (opened video device) , XCLK once again going on…
When device is unused/closed , XCLK could go off or stay on…
… And so on …
So, XCLK behavior depend on camera driver and correct way it always off when camera not in use, power down mode, etc.
Could be for some camera clock is on all the time, but still it need be turned on by camera drive at probe time.


#62

Ok that makes sense. Could you check if everything is correct with my dt?
I cut the first one, because it would be to long.
sun8i-v3s:

  soc {
	compatible = "simple-bus";
	#address-cells = <1>;
	#size-cells = <1>;
	ranges;

csi1: csi@1cb4000 {
	compatible = "allwinner,sun8i-v3s-csi";
	reg = <0x01cb4000 0x1000>;
	interrupts = <GIC_SPI 84 IRQ_TYPE_LEVEL_HIGH>;
	clocks = <&ccu CLK_BUS_CSI>,
	 <&ccu CLK_CSI1_SCLK>,
	 <&ccu CLK_DRAM_CSI>;
	clock-names = "bus", "mod", "ram";
	resets = <&ccu RST_BUS_CSI>;

port {
	/* Parallel bus endpoint */
	csi1_ep: endpoint {
		remote-endpoint = <&ov2640>;
		bus-width = <10>;

		/* If hsync-active/vsync-active are missing,
		   embedded BT.656 sync is used */
		hsync-active = <0>; /* Active low */
		vsync-active = <0>; /* Active low */
		pclk-sample = <1>;  /* Rising */
	};
};
 };
 ..............

spi0_pins: spi0 {
			pins = "PC0", "PC1", "PC2", "PC3";
			function = "spi0";
		};
	
		csi1_pins: csi1 {
			pins = "PE1";
			function = "csi1";
		};
};

sun8i-v3s-licheepizero:

&i2c0 { 
status = "okay";

ov2640: camera@30 {
		compatible = "ovti,ov2640";
		reg = <0x30>;
		clocks = <&ccu CLK_CSI1_MCLK>;
		clock-names = "xvclk";
		assigned-clock-rates = <24000000>;
		
		port {
			ov2640_0: endpoint {
				remote-endpoint = <&csi1>;
			};
		};
	};

};


#63

Sorry, you have mistakes, and also I will give suggestions:
Suggestion:
sun8i-v3s.dtsi you better to leave only “csi1: …” definition without port.
In this file going to be placed only things related to CPU ant it interfaces.
(there is “pio” too, but lets move those to “sun8i-v3s-licheepizero.dts” file).

In file sun8i-v3s-licheepizero you need:

&pio {
    csi1_pins: csi1-pins@0 {
        pins = "PE0","PE2",...;
        function = "csi";
    };

    csi1_mclk: csi1-mclk@0 {
        pins = "PE1";
        function = "csi";
    };
};

So put attention on :

  • Those pins are defined on previously existing pio (defined in …v3s.dtsi )
  • Pins for videodata/sync/pclk from camera is for CSI interface, need be defined all pins that going to be used !!! check datasheet .
  • Pin for camera XCLK is another one (MCLK pin from CPU)
  • All those pins need have function definition CSI (not csi1/2/3 etc)

Next in the …lichepizero.dts file you need:

&csi1{
    status = "okay";
    pinctrl-names = "default";
    pinctrl-0 = <&csi1_pins>;

    port {
        /* Every thing you defined, but need correct : 
        remote-endpoint = <&ov2640_0>;
           Check Bus width you going to use 
           (how many data lines will be connected to camera)
        */
    };
};

Put attention :

  • register pins going to be used CSI video transfer.
  • remote endpoint is Camera endpoint (not camera itself)

Next in the …lichepizero.dts file you need:

&i2c0 {
    ov2640: camera@30 {
        /* Every thing you defined , but add : 
        pinctrl-names = "default";
        pinctrl-0 = <&csi1_mclk>;
             And check clock-names parameter. */
        port {
            /* Every thing you defined, but need correct : 
            remote-endpoint = <&csi1_ep>;
               Check, could be you need define bus width,
               sync, pclk parameters for camera too.
             */
        };
    };
};

Put attention :

  • register pin going to be used for camera XCLK.
  • remote endpoint is CSI1 endpoint (not CSI1 itself).

#64

Very very nice you helped me a lot :smiley:
If I now try to capture video from /dev/video the MCLK pin should output 24Mhz right?
And I have to remove the lcd / display engine and mixer part of the devicetree? I think they interfere with each other right?


#65

In my situation MCLK pin output clock only on second device open (capture open).
Yes, LCD need be disconnected, because those pin need be used by camera. And probably disabled in Device Tree. Other vice you will have pin registering conflict.


#66

@petit_miner How is the camera connection coming along? Very interested in your progress!


#67

@nullbert I’m working on a new development board featuring the V3s.
The project is uploaded at Github.
It will take some time to get the layout done.