Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Mar 2015 07:15:16 +0100
From:      Milan Obuch <freebsd-arm@dino.sk>
To:        Luiz Otavio O Souza <lists.br@gmail.com>
Cc:        freebsd-arm@freebsd.org
Subject:   Re: Raspberry Pi and PiTFT display - problem with driver
Message-ID:  <20150310071516.54d5b8d1@zeta.dino.sk>
In-Reply-To: <CAB=2f8z_Gp-bQCs7%2BKDmngYC3rnrd4iEWMbZyypGZjJhbf7VJg@mail.gmail.com>
References:  <20150308204438.18f403a1@zeta.dino.sk> <CAB=2f8z_Gp-bQCs7%2BKDmngYC3rnrd4iEWMbZyypGZjJhbf7VJg@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 10 Mar 2015 00:25:02 -0300
Luiz Otavio O Souza <lists.br@gmail.com> wrote:

> On 8 March 2015 at 16:44, Milan Obuch wrote:
> > Hi,
> >
> > I am trying to write a driver for PiTFT display, small 320x240 pixel
> > panel with touch screen. From software perspective, there are two
> > devices, touch screen controller with GPIO expander, STMPE610, and
> > TFT display controller/driver, ILI9341. Both are connected via SPI
> > bus, with one GPIO pin for the later.
> >
> > This is where a problem is - I found a way how to use SPI bus to
> > program STMPE610, how to read and write to its register, at present,
> > read chip identification and set/reset GPIO used to control LED
> > backlight. I did it a bit hackish for now, using sysctl, but it is
> > simple to use and works. Definitive aproach should be to create a
> > child device, gpioc, possibly, but it is much more complicated and
> > takes more time to do.
> >
> > ILI9341, on the other side, uses SPI with GPIO, so there is a
> > question how to do this - and, because this GPIO pin is used as
> > 'command byte flag', it is quite vital for proper function.
> >
> > So, first, how can I describe this requirement in FDT? Currently, I
> > just put there simple fragment:
> >
> > spi0 {
> >         ili0 {
> >                 compatible = "st,ili";
> >                 spi-chipselect = <0>;
> >         };
> >
> >         tsc0 {
> >                 compatible = "st,stmpe_tc";
> >                 spi-chipselect = <1>;
> >         };
> > };
> >
> > but this does not descibe fact ILI9341 uses one GPIO pin, in case of
> > PiTFT, GPIO 25. It is in some way similar to what gpioiic does, but
> > there is only one parent device, while I have two, spi bus and gpio
> > pin... I need some hint...
> >
> > Second, I need some way to 'acquire' this pin in driver, so it is
> > not possible to change its status with gpioctl, and obtain correct
> > values for use in GPIOBUS_PIN_* calls to set pin's value.
> >
> > Third, it is not yet clear to me how would be the best way to
> > implement this. According the docs, ILI9341 is programmed with
> > series of short data exchanges, with exactly one command byte send
> > to device, being flagged with active DC pin (connected to GPIO 25),
> > followed with short series of bytes being written to device or, in
> > case of status read and similar, being read from device, all with
> > DC pin being inactive. DC is short for 'data/command'.
> >
> > Anybody out there with some hint? I will try to write something
> > working first, which will be surely not nice at the beginning, but
> > it is much easier to change something you know a bit about
> > already...
> >
> > Regards,
> > Milan
> 
> Hi,
> 
> If you need help with the GPIO expander on STMPE610, let me know.
>

Thanks, I will write when necessary, but my immediate need is
fullfilled, there is just one pin used for backlight controll and my
sysctl is functional. No other pins are available for testing, so there
is no need to do it any other way. Also, touchscreen component is
useless without display beeing done, so I am trying to work on that one
now.

> Whenever is possible, we should try to use the default/vendor DTS for
> device.
> 
> I think this is the one used by PiTFT:
> https://github.com/notro/fbtft/blob/master/dts/rpi.dts
> 
> [...]
> &spi0 {
>     pitft@0{
>         compatible = "ilitek,ili9340";
>         reg = <0>;
>         status = "disabled";
>         spi-max-frequency = <32000000>;
>         rotate = <90>;
>         bgr;
>         buswidth = <8>;
>         dc-gpios = <&gpio 25 0>;
> [...]
>

Yes, looks so. I tried to find compiled dtb in my linux image used for
functional test, but it is not in boot partition here as is the case
with FreeBSD, so they must have different boot sequence regarding FDT
use.

Also, it looks like here is 'reg' property used in place of my
'spi-chipselect', no idea if it means the same or not. Some other
differences - in Adafruit's docs Ilitek's ILI9341 is mentioned, here is
ILI9340, no idea about the difference, either.

> In this case you can make use of ofw_gpiobus_parse_gpios() to parse
> the 'dc-gpios' property, here is an usage example:
> http://pastebin.com/4mbZFuv1
> 
> The struct gpiobus_pin contains everything you need to manipulate the
> GPIO pin (as in the example).
> 

Thanks, will use this as reference.

Regards,
Milan



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20150310071516.54d5b8d1>