Beagleboard-xm spidev and camera sensor

I encountered some strange behavior with kernel 5.0.19 on the Beagleboard-xm.

If if I put the pin muxing to enable spidev inside the omap3-beagle-xm.dts DT the camera sensor (Aptina MT9P031) cannot capture all the 12 bits but only 9 (the maximum value for a white color is 511, all 9 bits to 1).

I cannot understand how this is possible but put inside comment the following muxing th camera is able to capture 12bit frames:

spi3_pins: pinmux_spi3_pins {
	pinctrl-single,pins = <
		OMAP3_CORE1_IOPAD(0x2128, PIN_INPUT | MUX_MODE1)	/* sdmmc2_clk.mcspi3_clk gpio_130 */
		OMAP3_CORE1_IOPAD(0x212a, PIN_OUTPUT | MUX_MODE1)	/* sdmmc2_cmd.mcspi3_simo gpio_131 */
		OMAP3_CORE1_IOPAD(0x212c, PIN_INPUT_PULLUP | MUX_MODE1)	/* sdmmc2_dat0.mcspi3_somi gpio_132 */
		OMAP3_CORE1_IOPAD(0x2130, PIN_OUTPUT | MUX_MODE1)	/* sdmmc2_dat2.mcspi3_cs1 gpio_134 */
		OMAP3_CORE1_IOPAD(0x2132, PIN_OUTPUT | MUX_MODE1)	/* sdmmc2_dat3.mcspi3_cs0 gpio_135 */
//	>;
};

spi4_pins: pinmux_spi4_pins {
	pinctrl-single,pins = <
		OMAP3_CORE1_IOPAD(0x215c, PIN_INPUT | MUX_MODE1)	/* mcbsp1_clkr.mcspi4_clk gpio_156 */
		OMAP3_CORE1_IOPAD(0x2160, PIN_OUTPUT | MUX_MODE1)	/* mcbsp1_dx.mcspi4_simo gpio_158 */
		OMAP3_CORE1_IOPAD(0x2162, PIN_INPUT_PULLUP | MUX_MODE1)	/* mcbsp1_dr.mcspi4_somi gpio_159 */
		OMAP3_CORE1_IOPAD(0x2166, PIN_OUTPUT | MUX_MODE1)	/* mcbsp1_fsx.mcspi4_cs0 gpio_161 */
	>;
};

I’ve also put inside comment the following:

&mcspi3 {
pinctrl-names = "default";
pinctrl-0 = <&spi3_pins>;
status = "okay";

spidev0: spi@0 {
	compatible = "spidev";
	reg = <0>;
	spi-max-frequency = <48000000>;
};

spidev1: spi@1 {
	compatible = "spidev";
	reg = <1>;
	spi-max-frequency = <48000000>;
};
};

&mcspi4 {
pinctrl-names = "default";
pinctrl-0 = <&spi4_pins>;
status = "okay";

spidev2: spi@0 {
	compatible = "spidev";
	reg = <0>;
	spi-max-frequency = <48000000>;
};
};

Hi @Lorenzo , sorry i’m a little confused… So just to confirm, you removed spi3_pins and spi4_pins, along with the two mcspi3/mcspi4 (spidev) nodes got the Aptina MT9P031 to correctly work in 12 bit mode?

Regards,

Hi @RobertCNelson ,
yes I confirm.
By reading the DM3730 TRM I see different offset values to put inside the macro OMAP3_CORE1_IOPAD.

Maybe the muxing inside the 5.0.19 tag is wrong?

Thank you

Is just a function to setup the pin’s. For the camera port, you should be setting each pin in the device tree instead of relying on the dm3730’s default pin behavior on bootup…

Regards,

I’ve written put the muxing inside the device tree for the McSpi but as I said it seems that the omap3-eagle-xn.dts inside the kernel tag 5.0.19 is wrong for the spi.
For exmaple inside the original device tree file (omap3-beagle-xm.dts) there is:

    OMAP3_CORE1_IOPAD(0x212C , PIN_INPUT_PULLUP | MUX_MODE1)	/* sdmmc2_dat0.mcspi3_somi gpio_132 */

But reading the DM3730 TRM it should be:

     OMAP3_CORE1_IOPAD(0x215C , PIN_INPUT_PULLUP | MUX_MODE1)	/* sdmmc2_dat0.mcspi3_somi gpio_132 */

Infact the 0x215C is the offset for CAMD11 in Mode 0.

The camera works even without putting mux inside the device tree I think because all the pins are set in Mode 0 by default.

I’m okay with just ripping out the “spi/spidev” pinmux and spi node, they are not set on mainline, and it’s been wrong for this long, thus no one has been using spidev. :wink:

Regards,

1 Like