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.

PROCESSOR-SDK-AM62X: Am62x SPI Interface

Part Number: PROCESSOR-SDK-AM62X
Other Parts Discussed in Thread: ADC128S052, SYSCONFIG

Hi team,

I have trying to interface adc(adc128s052) to the main_SPI2 on Am62x. I have done the changes in Device tree file and Menuconfig.

Device tree:

main_mcspi2_pins_default: main-mcspi2-pins-default {

pinctrl-single,pins = <

AM62X_IOPAD(0x1AC, PIN_OUTPUT, 1) /* (B20) SPI2_CS0*/
AM62X_IOPAD(0x198, PIN_INPUT, 1) /* (A19) SPI2_DI */
AM62X_IOPAD(0x194, PIN_OUTPUT, 1) /* (B19) SPI2_DO */
AM62X_IOPAD(0x1B0, PIN_OUTPUT, 1) /* (A20) SPI2_CLK */
>;
};
main_spi2{
pinctrl-names = "default";
pinctrl-0 = <&main_mcspi2_pins_default>;
status = "okay";
adc@0 {
compatible = "ti,adc128s052";
reg = <0>;
vref-supply = <&vcc_3v3_sys>;
spi-max-frequency = <1000000>;
#io-channel-cells = <1>;
};

In Menuconfig:

Enable the Device Driver as module:

Device Drivers -> iio -> analog and digital converters -> adc128s052.

After building copied Image and dtb file to sd card.

while trying to access from user space from sys/bus/iio/devices/iio:device0/

cat in_voltage0_raw

The output is always 0. I have tried checking all the voltage channels.

While trying to tap the mcspi signals using Logic analyzer can't able to get any signals on the pins not even clock.

And also i tried to check with spidev,by following the Link below.

software-dl.ti.com/.../SPI.html

but the result was same, no clock is generated on the SPI Pins.

I think i am missing something, can anyone kindly guide me through this.

Regards,

Murali Chikkanna

  • Hi Murali,

    AM62X_IOPAD(0x1AC, PIN_OUTPUT, 1) /* (B20) SPI2_CS0*/
    AM62X_IOPAD(0x198, PIN_INPUT, 1) /* (A19) SPI2_DI */
    AM62X_IOPAD(0x194, PIN_OUTPUT, 1) /* (B19) SPI2_DO */
    AM62X_IOPAD(0x1B0, PIN_OUTPUT, 1) /* (A20) SPI2_CLK */
    >;

    How is this pinmux generated? Please use SysConfig to generate the pinmux configuration.

  • Hi Liu,

    main_mcspi2_pins_default: main-mcspi2-pins-default {
    pinctrl-single,pins = <
    AM62X_IOPAD(0x1ac, PIN_OUTPUT, 1) /* (B20) SPI2_CS0*/
    AM62X_IOPAD(0x198, PIN_INPUT, 1) /* (A19) SPI2_DI */
    AM62X_IOPAD(0x194, PIN_OUTPUT, 1) /* (B19) SPI2_DO */
    AM62X_IOPAD(0x1b0, PIN_OUTPUT, 1) /* (A20) SPI2_CLK */
    >;
    };

    Thanks for the reply, I have generated pinmux through sysconfig, still i couldnt able to read any raw voltage from ADC channels. it only reads Zero in all the channels.

    root@am62xx-evm:/# cat /sys/bus/iio/devices/iio\:device0/in_voltage0_raw

    0
    root@am62xx-evm:/# cat /sys/bus/iio/devices/iio\:device0/in_voltage1_raw
    0
    root@am62xx-evm:/# cat /sys/bus/iio/devices/iio\:device0/in_voltage2_raw
    0
    root@am62xx-evm:/# cat /sys/bus/iio/devices/iio\:device0/in_voltage3_raw
    0
    root@am62xx-evm:/# cat /sys/bus/iio/devices/iio\:device0/in_voltage4_raw
    0
    root@am62xx-evm:/# cat /sys/bus/iio/devices/iio\:device0/in_voltage5_raw
    0
    root@am62xx-evm:/# cat /sys/bus/iio/devices/iio\:device0/in_voltage6_raw
    0
    root@am62xx-evm:/# cat /sys/bus/iio/devices/iio\:device0/in_voltage7_raw
    0
    root@am62xx-evm:/# cat /sys/bus/iio/devices/iio\:device0/in_voltage_scale
    0.805664062
    root@am62xx-evm:/# cat /sys/bus/iio/devices/iio\:device0/in_voltage_scale
    0.805664062

    Regards,

    Murali C

  • Hi Murali,

    I remembered last time when I tested SPI, the pinmux generated in SysConfig has PIN_INPUT on all the SPI pins, not PIN_OUTPUT.

  • Hi Liu,

    Sorry it was a mistake, yes the sysconfig generated pinumux has only INPUT Pins as shown below.

    AM62X_IOPAD(0x01b0, PIN_INPUT, 1)       /* (A20) MCASP0_ACLKR.SPI2_CLK */
    AM62X_IOPAD(0x01ac, PIN_INPUT, 1)       /* (E19) MCASP0_AFSR.SPI2_CS0 */
    AM62X_IOPAD(0x0194, PIN_INPUT, 1)       /* (B19) MCASP0_AXR3.SPI2_D0 */
    AM62X_IOPAD(0x0198, PIN_INPUT, 1)        /* (A19) MCASP0_AXR2.SPI2_D1 */
    But i think, i had found out something, i built adc as a dynamic module and copied the module to /home folder and then i ran a command to insert the 
    module insmod ti-adc128s052.ko, it just installs a device under /sys/bus/iio/devices/ with or without connecting adc module to the spi pins, but it is not probing the device.
    i tried to do modprobe ti-adc128S052.ko, it throws the error modprobe: FATAL: Module .ko not found in directory /lib/modules/5.10.153-g3eee621d16.
    Then i tried installing the modules using eg: sudo make ARCH=arm64 INSTALL_MOD_PATH=/media/murali/root modules_install. This command install's the modules inside /lib/modules/5.10.153-g3eee621d16/kernel/drivers/iio/adc. But still the same issue.
    can't able to probe module.
    Regards,
    Murali C
  • Hi,

    Can anyone reply on this.

    Regards,

    Murali C

  • Murali,

    I think this is the correct configuration, but note that 0x01ac is actually E19, not B20, which you originally had:

    &main_pmx0 {
        myspi2_pins_default: myspi2-pins-default {
            pinctrl-single,pins = <
                AM62X_IOPAD(0x01b0, PIN_OUTPUT, 1) /* (A20) MCASP0_ACLKR.SPI2_CLK */
                AM62X_IOPAD(0x0194, PIN_OUTPUT, 1) /* (B19) MCASP0_AXR3.SPI2_D0 */
                AM62X_IOPAD(0x0198, PIN_INPUT, 1) /* (A19) MCASP0_AXR2.SPI2_D1 */
                AM62X_IOPAD(0x01ac, PIN_OUTPUT, 1) /* (E19) MCASP0_AFSR.SPI2_CS0 */
            >;
        };
    };

    The following E2E thread seems to have an example of a successful configuration: https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1122795/sk-am62-accessing-spi-onto-sk-am62-board-from-linux/4187982#4187982

    You might want to have a look over that example, and also remove the ADC driver from the equation for the moment, and simply try to get something on the SPI port.

    Thanks,

    Stuart

  • Hi Stuart,

    Thanks for replying. 

    I changed the Pinmux as before, and tested the MCSPI0,I can able to get something on the SPI Port by probing.

    I have followed the link shared by you above and tested with SPIDEV, by running the file inside file-system.

    Kindly find the attached screenshot of the SPI signals probed. But still the clock is not behaving as expected.

    Regards,

    Murali C 

  • Screenshot with spi signals mentioned and the command used:

    root@am62xx-evm:/home# ./spidev_test -D /dev/spidev3.0 -s 500000 -p aa55 -v