This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/TRF7970A: SPI interfacing problems between DLP7970ABP and an i.MX6 SBC

Part Number: TRF7970A

Tool/software: Linux

I am trying to get the TRF7970A-based DLP7970ABP NFC Booster Pack board connected through SPI with a NXP/Freescale i.MX6Quad Cortex A9 SBC, and then to test it with neard.

I have tested adding spidev first to the device tree following this guide and I was able to successfully probe it and create an SPI loopback as the guide suggests. The device tree looked like this:

ecspi1 {
  fsl,spi-num-chipselects = <1>;
  cs-gpios = <&gpio2 30 GPIO_ACTIVE_HIGH>;
  pinctrl-names = "default";
  pinctrl-0 = <&pinctrl_ecspi1>;
  status = "okay";

  spidev0: spi@0 { 
     #address-cells = <1>;
     #size-cells = <1>;
     compatible = "spidev";
     reg = <0>; 
     spi-max-frequency = <2000000>;
     status = "okay";
   };
};

I then removed spidev node and replaced it with a node for the TRF7970A:

ecspi1 {
      fsl,spi-num-chipselects = <1>;
      cs-gpios = <&gpio2 30 GPIO_ACTIVE_HIGH>;
      pinctrl-names = "default";
      pinctrl-0 = <&pinctrl_ecspi1>;
      status = "okay";

      nfc@0 {
              #address-cells = <1>;
              #size-cells = <1>;
              compatible = "ti,trf7970a";
              reg = <0>;
              spi-max-frequency = <2000000>;
              interrupt-parent = <&gpio2>;
              interrupts = <23 IRQ_TYPE_LEVEL_HIGH>;
              ti,enable-gpios = <&gpio4 10 GPIO_ACTIVE_HIGH>;
              vin-supply = <&bperi>;
              autosuspend-delay = <30000>;
              irq-status-read-quirk;
              en2-rf-quirk;
              clock-frequency = <13560000>;
              status = "okay";
      };
};

I get the following messages while the kernel boots up (the following is a result of dmesg | grep spi):

spi_imx 2008000.ecspi: probed
trf7970a spi0.0: No EN2 GPIO property
spi0.0 supply vdd-io not found, using dummy regulator

The message on the second line comes from this line in the trf7970a.c driver file.

I have read the trf7970a.txt guidelines and that is why I omitted an EN2 parameter, as I thought it was optional. vdd-io is also optional.

No spi device is coming up in /dev/ as spidev did, and modprobe trf7970a does not return anything.

The pin description of ecspi1 is the following:

ecspi1 {
  pinctrl_ecspi1: ecspi1 {
    fsl,pins = <
      MX6QDL_PAD_EIM_D17__ECSPI1_MISO 0x100b1
      MX6QDL_PAD_EIM_D18__ECSPI1_MOSI 0x100b1
      MX6QDL_PAD_EIM_D16__ECSPI1_SCLK 0x100b1
      MX6QDL_PAD_EIM_EB2__GPIO2_IO30 0x100b1
      MX6QDL_PAD_KEY_COL2__GPIO4_IO10 0x100b1
      MX6QDL_PAD_EIM_CS0__GPIO2_IO23 0x100b1
    >;
  };
};

The following are the the pinouts for the SBC and DLP7970ABP board I'm using:

Apart from the obvious ones, I have connected:
SBC pin 5 (SS0) to pin 9 (Slave Select) of the TI board 
SBC pin 6 (SS1) to pin 10 (Enable)
SBC pin 7 (SPI_IRQ) to pin 18 (IRQ (1) default) 

I would like to test this device with neard, installed from this recipe, but I reckon something is wrong with the SPI parameters in the device tree node so I don't think I can do much with neard for now.

Do you think it's a wiring issue, an SPI node setup issue or some parameters are wrong in the device tree? I am quite lost at this point, any help is appreciated.

  • Hi dathpo.

    I'm not familiar with the SBC you're using so I can't verify your pinmux or SPI setup. Given that caveat, I'll try to help.

    The EN2 message is just an informational message so don't worry about that.

    - Have you set up the necessary regulator(s) in the DTS file (see vdd-io)? It appear that you haven't according to the message above. Be sure the chip has power.
    - Have you double-checked for pinmux conflicts?
    - Do you have the EN, etc. configured correctly?

    Mark
    --
  • Hi dathpo,

    Can you please send me your device tree entries, I have also worked on TRF7970A with IMX6Q Sabre SD board.

    Also check you SPI Chip select,EN,EN2 and IRQ is properly configured.

    If I check your GPIO pinmux, the value (0x100b1) is same for SPI and GPIO.

    Can you please check this?

    Also have you cross compiled neard? Which kernel version you are using?



    Regards
    Deep

  • Thank you both for your help.

    One thing I forgot to mention in my OP is that while the latest usable Linux kernel version for my SBC is v4.9.81, I have copied the latest version of the trf7970a.c driver from v4.18, mainly because from what I understood the driver in the v4.9.81 version did not yet consider the EN2 parameter optional. This change gave me the errors (new ones compared to v4.9.81) I reported in my OP.
    Is what I did a good idea?

    Mark Greer_ said:

    - Have you set up the necessary regulator(s) in the DTS file (see vdd-io)? It appear that you haven't according to the message above. Be sure the chip has power.

    Hi Mark, thanks for your answer. The following regulators are defined in the imx6qdl-ccimx6.dtsi file:

    I used BUCKPERI for vin, I wouldn't know what to use for vdd-io-supply. Do I need to include vdd-io-supply in the parameters?

     

    Mark Greer_ said:

    - Have you double-checked for pinmux conflicts?

    If you're referring to configuring the same pad (i.e. MX6QDL_PAD_EIM_CS0__GPIO2_IO23) twice in the device tree, I haven't changed any of the values in the pin configuration (fsl,pins) for ecspi1, they were set like that as default. Should I still look for any?

     

    Mark Greer_ said:

    - Do you have the EN, etc. configured correctly?

    I have assigned GPIO_4_10 as the GPIO connected to EN, and set it as high. On the SBC side that is connected to pin 6 (SP1_SS1)

    Is this configured correctly? Should I choose another GPIO?

    deep ter said:

    Can you please send me your device tree entries, I have also worked on TRF7970A with IMX6Q Sabre SD board.

    OK so the trf7970a node definition and pin configuration that I sent in the OP are both from the imx6qdl-ccimx6sbc.dtsi file (is this ok?), the following are ecspi1, gpio2 (that I use as interrupt parent) and aliases defined in imx6qdl.dtsi:

    Do you want to see more?

    deep ter said:

    Also check you SPI Chip select,EN,EN2 and IRQ is properly configured.

    I think my problem lies here. I have one chip select enabled for ecspi1 (cs-gpios = <&gpio2 30 GPIO_ACTIVE_HIGH>), although the example here shows two. I remember trying setting those two but got an error in the kernel bootup so I left it at one.
    What should I change?

    deep ter said:

    If I check your GPIO pinmux, the value (0x100b1) is same for SPI and GPIO.

    Can you please check this?

    Yes these are the defaults, I worked out that the value for the pin CONFIG (0x100b1) means that the following config settings are enabled:
    PAD_CTL_HYS

    PAD_CTL_SPEED_MED

    PAD_CTL_DSE_40ohm

    PAD_CTL_SRE_FAST

    I thought they can be the same value for multiple pads as they represent settings. I thought the important factor was to not have the same pad (MXQDL_PAD_EIM_CS0__XXXX_XXXX or whatever) configured twice in the device tree.

    deep ter said:

    Also have you cross compiled neard? Which kernel version you are using?

    Yes I have cross-compiled the neard package and I can start, stop and restart the daemon and execute commands for neard. Kernel version as mentioned above is v4.9.81.

  • Hi Dathpo,

    I checked the file imx6qdl-ccimx6sbc.dtsi.
    Here the enable and resets of all the interfaces are in put in hog group.
    I had also added my EN and IRQ in the hog group.
    Try adding your enable(EN) and IRQ in hog group with pad value 0x80000000.

    Also after adding them there,when the linux boots up,probe your (EN) signal and check whether it has gone HIGH after your driver is called.

    Thanks
    Deep