notro / tinydrm

Discontinued. Out of tree tinydrm modules
https://github.com/notro/tinydrm/wiki
99 stars 27 forks source link

ST7796 Driver #22

Closed kjngineering closed 3 years ago

kjngineering commented 4 years ago

Hi Notro,

I've been using FBTFT for some time, but there are some benefits in tinydrm so I have been trying to change over. Writing my driver in FBTFT was really straightforward (based off examples) and it worked perfectly:

https://github.com/kjngineering/ST7796S/blob/master/fb_st7796s.c

   st7796s@0 {
    reg = <0>;
    compatible = "sitronix,st7796s";
    pinctrl-names = "default";
    spi-max-frequency = <55000000>;
    rotate = <180>;
    bgr;
    fps = <30>;
    buswidth = <8>;
    reset-gpios = <&pio 4 1 GPIO_ACTIVE_HIGH>; //PE1
    dc-gpios = <&pio 1 5 GPIO_ACTIVE_HIGH>; //PB5
    debug = <0>;
   };

However writing the driver for tindrm has not been as simple. Although I made it harder on myself flicking between several kernel versions that had significant drm header changes. I had a go writing the driver, but I cannot get any meaningful results.

https://github.com/kjngineering/ST7796S/blob/master/st7796s.c

display@0 {
    reg = <0>;
    compatible = "sitronix,st7796s";
    spi-max-frequency = <20000000>;
    rotation = <0>;
    reset-gpios = <&pio 4 1 GPIO_ACTIVE_HIGH>; //PE1
    dc-gpios = <&pio 1 5 GPIO_ACTIVE_HIGH>; //PB5
    debug = <0>;
    status = "okay";
};

At the moment I am stuck with repetitive spi transfer issues at initialization:

[ 54.601107] st7796s spi0.0: SPI transfer failed: -110 [ 54.606250] spi_master spi0: failed to transfer one message from queue [ 54.722664] spi_master spi0: spi0.0: timeout transferring 1 bytes@10000000Hz

It looks like the screen gets halfway through initialization before running into these (screen flashes, i get some static). I cannot figure out why, comparing the two drivers it should work the same but I think I am missing something in the SPI transfer mode 8-bit v 16-bit? But I cannot fix it. Switching back to the FBTFT config works fine.

I have tried reducing SPI speed and several other ideas without success.

Platform is Allwinner H3, Linux is 5.4.45 LTS via Buildroot.

kjngineering commented 4 years ago

as a bit of a follow up:

After it fails spi transfers continuously for 1628 seconds:

[ 1628.891125] st7796s spi0.0: SPI transfer failed: -110
[ 1628.896277] spi_master spi0: failed to transfer one message from queue

The screen works and I get a console print out of that last line. If I run a test it works fine (gamma is out but that can be fixed).

So what is causing issues early on?

notro commented 4 years ago

Errno 110 is ETIMEDOUT. Looks like you can get it from drivers/spi/spi.c or drivers/spi/spi-sun6i.c (I believe this is the one used by H3). Does your fbtft driver work on the same kernel as the failing DRM driver? A driver should not cause a timeout in the SPI controller driver/subsystem. The SPI controller doesn't know if anything is connected to the bus, it just runs the clock blindly, so neither device nor client driver should cause a timeout.

kjngineering commented 3 years ago

FBTFT version worked on the same kernel.

I cannot say for sure what the cause was, but I re-ported the driver from scratch, checked my hardware and SPI patches and got this working. I will eventually do a PR to add the drivers to mainline once it is polished,

I will close this issue now.