Tool/software: Linux
Hi,
I try to get DMA support for SPI 4 on the AM437.
I started adding the following lines on my am437.dts file:
&spi4 { status = "okay"; pinctrl-names = "default", "sleep"; pinctrl-0 = <&spi4_pins_default>; pinctrl-1 = <&spi4_pins_sleep>; ti,spi-num-cs = <1>; dmas=<&edma_xbar 55 0 0>, <&edma_xbar 56 0 0>; dma-names="tx0","rx0"; spidev4: spi@4 { compatible = "rohm,dh2228fv"; spi-max-frequency = <48000000>; reg = <0x0>; spi-cpol; spi-cpha; }; };
Now the output "spi spi2.0: not using DMA for McSPI (-19)" does not appear anymore, but the cpu load stays still very high, when I activate SPI transfer.
I tried many variations on dts file, but with no success.
Currently I activate SPI transfer by the following lines:
static int fd = 0;
static const char *device = "/dev/spidev2.0";
static uint8_t mode = SPI_CPHA | SPI_CPOL;
static uint8_t bits = 8;
static uint32_t speed = 160000;
static uint16_t delay = 0;
fd = open(device, O_RDWR); if (fd < 0) printf("can't open device"); ret = ioctl(fd, SPI_IOC_WR_MODE, &mode); if (ret == -1) printf("can't set spi mode"); ret = ioctl(fd, SPI_IOC_WR_BITS_PER_WORD, &bits); if (ret == -1) printf("can't set bits per word"); ret = ioctl(fd, SPI_IOC_WR_MAX_SPEED_HZ, &speed); if (ret == -1) printf("can't set max speed hz"); printf("spi mode: %d\n", mode); printf("bits per word: %d\n", bits); printf("max speed: %.2f MHz\n", (float)speed/1000000); struct spi_ioc_transfer tr = { //.tx_buf = (unsigned long)&cmd, //.rx_buf = (unsigned long)&rx_data, //.len = 1, .delay_usecs = delay, .speed_hz = speed, .bits_per_word = bits, }; ret = ioctl(fd, SPI_IOC_MESSAGE(1), tr); if (ret < 1) { // SPI still busy or failed printf("can't send spi message"); return -1; }
Is there anything wrong with this code? Can I check somehow if dma is used for the transfer?
Best regards
Stefan