alexf58
Posts: 3
Joined: Fri Apr 12, 2019 3:11 am

DPI display and SPI without CE?

Fri Apr 12, 2019 3:39 am

I'm using DPI to directly drive a TFT screen in 18 bit mode. In fact RGB565 "mode 3", so that I can have PWM pin available for sound and SPI pins (GPIO 9,10,11) also free from DPI use. Unfortunately the SPI CE0 and CE1 are not available. I don't need hardware control over CE, I can do it with an available GPIO pin, but after some search it appears that even when SPI is used in no cs mode, the pins are still owned by the SPI driver.

There are alternative pins for SPI as well, but not wired to the connector. So I'm wondering if it's possible to enable spi in config.txt, but load an overlay that will leave the MISO,MOSI, and CLCK on GPIO 9,10,11 but remap CE to GPIO 35,36? I have found spi-gpio35-39-overlay.dts . Can I replace "brcm,pins = <37 38 39>;" with brcm,pins = <9 10 11>;?

Thanks.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2379
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: DPI display and SPI without CE?

Fri Apr 12, 2019 8:48 am

Have you tried the "spi0-cs" overlay?

Code: Select all

[email protected]:~$ dtoverlay -h spi0-cs
Name:   spi0-cs

Info:   Allows the (software) CS pins for SPI0 to be changed

Usage:  dtoverlay=spi0-cs,<param>=<val>

Params: cs0_pin                 GPIO pin for CS0 (default 8)
        cs1_pin                 GPIO pin for CS1 (default 7)

alexf58
Posts: 3
Joined: Fri Apr 12, 2019 3:11 am

Re: DPI display and SPI without CE?

Fri Apr 12, 2019 6:52 pm

That works! Thanks. I looked at that overlay but decided to ask just in case.

alexf58
Posts: 3
Joined: Fri Apr 12, 2019 3:11 am

Re: DPI display and SPI without CE?

Sat Apr 13, 2019 10:12 pm

So what actually worked is using spi0-cs to re-assign CS to GPIO35 which is an alternative for CE0. I have a GPIO pin (27) that I can control by software to use as a CS for my SPI slave. So my problem is solved. However a question remains.

Name: spi0-cs
Info: Allows the (software) CS pins for SPI0 to be changed

So it says SOFTWARE CS pins. I thought if I designate GPIO27 rather than 35, the driver will take care of CS. Not so, with "cs0_pin=27" the SPI driver refuses to load. Not a big deal, but am I wrong about the "software" CS pin and it can only assign one of the hardware designated pins for this job?

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2379
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: DPI display and SPI without CE?

Tue Apr 16, 2019 11:54 am

I can't immediately see a reason why "cs0_pin=27" would stop the driver from loading. I can think of three main possible causes (ignoring for a moment the precise mechanism):
1. The overlay doesn't apply.
2. The pinctrl subsystem detects a clash and the driver is skipped.
3. The driver is loaded but detects an error at runtime.

We can rule out 1 quickly by running "sudo vcdbg log msg" and looking for error messages about the overlay - I don't expect you to find any.

2 and 3 can investigated by looking for errors on the kernel side. Try running "dmesg -l err" (this just lists messages categorised as errors). If nothing relevant appears, look at all the kernel messages with "dmesg" and look for anything suspicious. If you aren't sure, upload it somewhere and post a link here for me to check.

Return to “Device Tree”