TinyDRM ST7735 with BeagleBone?

Hi David, I was excited to see you’ve written a TinyDRM driver for the 1.8" Adafruit TFT. Have you tried it out with a BeagleBone?

I’d like to use with the BeagleBone Black and am thinking about how go about it. I imagine I would need to create a device tree overlay to initialize your driver with the appropriate settings?

Thanks!
Drew

Hi Drew,

I haven't used it with a BeagleBone. Creating a device tree overlay should be easy though.

If you want to use the backlight, you need to create a node at the root level like this:

 backlight: backlight \{
     compatible = "gpio\-backlight";
     gpios = <&gpio 44 GPIO\_ACTIVE\_HIGH>;
 \};

Then add a child node to the SPI device for the display kind of like this:

&spi1 {
status = "okay";
pinctrl-0 = <&ev3_lcd_pins>;
pinctrl-names = "default";

 display@0\{
     status = &quot;okay&quot;;
     compatible = &quot;jianda,jd\-t18003\-t01&quot;, &quot;sitronix,st7735r&quot;;
     reg = &lt;0&gt;;
     spi\-max\-frequency = &lt;32000000&gt;;
     dc\-gpios = &lt;&amp;gpio 43 GPIO\_ACTIVE\_HIGH&gt;;
     reset\-gpios = &lt;&amp;gpio 80 GPIO\_ACTIVE\_HIGH&gt;;
     backlight = &amp;backlight;
     rotation = &lt;270&gt;;
 \};

};

Obviously you will need to change some things and put it in DT overlay format, but it should get you pointed in the right direction.

Thanks for the insights, David.

For comparison, this is how I load fbtft for this 1.8" Adafruit ST7735R TFT LCD:

sudo modprobe fbtft_device busnum=1 name=adafruit18 gpios=dc:48,reset:60

I can then use fbi to display an image on the display.

For TinyDRM, I have now added the display node from your example to
BB-SPIDEV1-00A0.dts:

Hi Drew,

I haven't used it with a BeagleBone. Creating a device tree overlay should
be easy though.

If you want to use the backlight, you need to create a node at the root
level like this:

     backlight: backlight {
         compatible = "gpio-backlight";
         gpios = <&gpio 44 GPIO_ACTIVE_HIGH>;
     };

Then add a child node to the SPI device for the display kind of like this:

&spi1 {
     status = "okay";
     pinctrl-0 = <&ev3_lcd_pins>;
     pinctrl-names = "default";

     display@0{
         status = "okay";
         compatible = "jianda,jd-t18003-t01", "sitronix,st7735r";
         reg = <0>;
         spi-max-frequency = <32000000>;
         dc-gpios = <&gpio 43 GPIO_ACTIVE_HIGH>;
         reset-gpios = <&gpio 80 GPIO_ACTIVE_HIGH>;
         backlight = &backlight;
         rotation = <270>;
     };
};

Obviously you will need to change some things and put it in DT overlay
format, but it should get you pointed in the right direction.

Thanks for the insights, David.

For comparison, this is how I load fbtft for this 1.8" Adafruit ST7735R TFT LCD:

sudo modprobe fbtft_device busnum=1 name=adafruit18 gpios=dc:48,reset:60

I can then use fbi to display an image on the display.

For TinyDRM, I have now added the display node from your example to
BB-SPIDEV1-00A0.dts:

+
+ display@0{
+ status = "okay";
+ compatible = "jianda,jd-t18003-t01",
"sitronix,st7735r";
+ reg = <0>;
+ spi-max-frequency = <16000000>;
+ /*
Beagleboard:Cape Expansion Headers - eLinux.org */
+ dc-gpios = <&gpio1 28 0>; /* dc:48
   P9.15 GPIO1_16 */

Are you sure your phandles are correct here? They don't match the comments. Should it be <&gpio1 16 0> instead?

+ reset-gpios = <&gpio1 16 0>; /*
reset:60 P9.12 GPIO1_28 */

And then <&gpio1 28 0> here?

Here is the full BB-SPIDEV1-00A0.dts:
https://gist.github.com/pdp7/aee5664598059c9b9a9020f107957f80

I have P9.12 connected to LCD reset pin. I have P9.15 connected to
LCD dc pin. For fbtft driver, this translated to GPIO_60 for reset
and GPIO_48 for dc. This is based on this pinout diagram:
https://elinux.org/File:Cape_expansion_headers.PNG

For this dts file, I was trying to figure out what appropriate gpio
phandle. I looked at this table for the P9 header:
https://elinux.org/File:H9Pinout.PNG

I believe that gpio1[16] corresponds to P9.15 which is LCD dc pin, and
gpio1[28] corresponds to P9.12 which is LCD reset pin.

My understanding of those mappings may be incorrect, so I'd appreciate
any additional feedback.

Thanks,
Drew

those mappings are correct

GPIO1_28 P9-12 U18 = mapping /sys/class/gpio60
GPIO1_16 P9-15 R13 = mapping /sys/class/gpio48

You understand correct, but I think you have swapped the values in your device tree overlay. You say "gpio1[16] corresponds to P9.15 which is LCD dc pin", but in the overlay, you have dc-gpios = <&gpio1 28 0>;. Likewise "gpio1[28] corresponds to P9.12 which is LCD reset pin.", but you have reset-gpios = <&gpio1 16 0>;.

Thanks! I had DC and Reset swapped in the overlay file. I’ve fixed and the display is now working! The console is displayed after bootup and libdrm modetest is able to display color bars OK.

Here is the updated dts:
https://gist.github.com/pdp7/aee5664598059c9b9a9020f107957f80

Thanks,
Drew

fyi - I've created a bb.org-overlays pull request to add an overlay
named BB-LCD-ADAFRUIT-18-SPI1-00A0.dts for the Adafruit 1.8" LCD on
SPI1:

https://github.com/beagleboard/bb.org-overlays/pull/68

Drew, David:
I’ve adapted the tinyDRM dtc to work with the Adafruit 2.4" TFT LCD display. It’s working fine with SPI 1. Currently it uses P9_14 for the backlight.

How do I switch it to use P9_16 for the backlight?

I’ve tried changing all the P9_14’s to P9_16s, but that doesn’t work. P9_14 is the A side of the pwm
and P9_16 is the B side, so I think there’s a bit I need to flip, but don’t know what it is.

–Mark

p.s. The exercise for my students will be to switch it to SPI 0!

[1] https://github.com/MarkAYoder/BeagleBoard-exercises/tree/master/displays/ili9341/tinyDRM

Did you also change pwms = <&ehrpwm1 *0* 500000 0>; to pwms = <&ehrpwm1 *1* 500000 0>; ?

David:
Thanks. I did not. How do I discover what those values ( 1 500000 0) are?

–Mark

David:
I just tested it and it works! Thanks.

–Mark

From the (not so clear) device tree binding docs. The ehrpwm docs say the last number is flags and only PWM_POLARITY_INVERTED is supported. The generic PWM bindings doc says "pwm-specifier typically encodes the chip-relative PWM number and the PWM
period in nanoseconds." So since the EHRPWMs have an A and B channel, the first number can be 0 or 1. The second number is the default period for the PWM.

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/pwm/pwm-tiehrpwm.txt
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/pwm/pwm.txt

Super!