Enable the ST7789 SPI LCD using tinyDRM

Hi Support Team,

We have successfully enabled the st7789 sitronix SPI based LCD using the framebuffer (driver/staging/fbtft) driver. Now, we are trying to enable the same driver using GPU/DRM (drivers/gpu/drm/tinydrm/) drivers.

We have ported the driver with DRM/GPU subsystem path. While kernel probing the driver, we got the SPI-DMA related errors. Errors are as shown below:
root@linaro-alip:~# dmesg | grep -i st77
[ 1.362935] ei: func:st7789v_probe line:164
[ 1.368970] st7789v spi0.0: Failed to set dma mask -5
[ 1.373023] st7789v: probe of spi0.0 failed with error -5

We have debugged the file : drivers/gpu/drm/tinydrm/mipi-dbi.c and the function mipi_dbi_spi_init.

/*

  • Even though it’s not the SPI device that does DMA (the master does),
  • the dma mask is necessary for the dma_alloc_wc() in
  • drm_gem_cma_create(). The dma_addr returned will be a physical
  • adddress which might be different from the bus address, but this is
  • not a problem since the address will not be used.
  • The virtual address is used in the transfer and the SPI core
  • re-maps it on the SPI master device using the DMA streaming API
  • (spi_map_buf()).
    */
    if (!dev->coherent_dma_mask) {
    ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(32));
    if (ret) {
    dev_warn(dev, “Failed to set dma mask %d\n”, ret);
    return ret;
    }
    }

If we commented above code from the file, the DRI node is created and gives below error:
st7789v spi0.0: failed to allocate a buffer with size 131072

root@linaro-alip:~# cat /sys/kernel/debug/dri/0/name
st7789v dev=spi0.0 unique=spi0.0

Can you please help us, what will be the missing parameter?

Thanks,
Arjun