Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

spidev cannot control the chip select signal

I use kernel 3.12.rc4 on an embedded linux device (olimex imx233 micro). My aim is to use /dev/spidev to be able to communicate with another spi device.

I edit arch/arm/boot/dts/imx23-olinuxino.dts as:

ssp1: ssp@80034000 {
  #address-cells = <1>;
  #size-cells = <0>;
  compatible = "fsl,imx23-spi";
  pinctrl-names = "default";
  pinctrl-0 = <&spi2_pins_a>;
  clock-frequency = <1000000>;
  status = "okay";

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

arch/arm/boot/dts/imx23.dtsi: has this config

spi2_pins_a: spi2@0 {
  reg = <0>;
  fsl,pinmux-ids = <
    0x0182 /* MX23_PAD_GPMI_WRN__SSP2_SCK */
    0x0142 /* MX23_PAD_GPMI_RDY1__SSP2_CMD */
    0x0002 /* MX23_PAD_GPMI_D00__SSP2_DATA0 */
    0x0032 /* MX23_PAD_GPMI_D03__SSP2_DATA3 */
  >;
  fsl,drive-strength = <1>;
  fsl,voltage = <1>;
  fsl,pull-up = <1>;
};

Device binding looks correct. When I compile the kernel I get the /dev/spidev1.1. After that I use spidev_test.c and monitor the pins by an oscilloscope. The SCK and MOSI output signals correctly, however, the chipselect is set to the logic high even during the data transfer.

Is there any way to determine why spidev cannot set to logic low during the transmission? It seems like either additional things needs to be passed on kernel or there is an issue on spidev that cannot control the chip select . I wonder if I need to change anything on the spidev.h or spidev.c on the driver/spi directory of the kernel? or how can I solve it?

The reference manual for the processor

like image 396
sven Avatar asked Oct 17 '13 02:10

sven


1 Answers

I never used device tree, but I try to help you anyway.

The kernel create the device /dev/spidev1.1, so spidev is connected to SPI bus 1, chip select 1. The chip select numeration start from 0, and you do not have any other device associated to SPI bus 1.

As far as I know reg = <1> tell to the SPI core that spidev is connected to chip select 1., but maybe your device is connected to the chip select 0. So, reg = <0>

like image 94
Federico Avatar answered Sep 26 '22 23:09

Federico