notro / fbtft

Linux Framebuffer drivers for small TFT LCD display modules. Development has moved to https://git.kernel.org/cgit/linux/kernel/git/gregkh/staging.git/tree/drivers/staging/fbtft?h=staging-testing
1.85k stars 493 forks source link

Invalid bits_per_word 9 (must be 8) #167

Closed martinlbb closed 9 years ago

martinlbb commented 9 years ago

Hi,

I am working on supporting a new ILI9341 device, who use 9 bit SPI.

When I use spi_dev, to read ILI9341 register, with raspberry module, everything works fine. However, when switching to Nostro's module (using rpi_update, branch loadadble module), I have a invalid bits_per_word 9 (must be 8). And then a failure.

Screen is attached to Rapsberry using MISO/MOSI/SCLK/CS and RESET/LED. It's a MTF0280QT-17 V2.0.

On current raspberry kernel and module, I can read register:

pi@gpiopi ~ $ spi/spidev_test --device /dev/spidev0.0 --bpw 9
spi mode: 0
bits per word: 9
max speed: 500000 Hz (500 KHz)

FF FF FF FF FF FF 
40 00 00 00 00 95 
FF FF FF FF FF FF 
FF FF FF FF FF FF 
FF FF FF FF FF FF 
DE AD BE EF BA AD 
F0 0D 

modinfo:

pi@gpiopi ~ $ modinfo spi_bcm2708
filename:       /lib/modules/3.12.31+/kernel/drivers/spi/spi-bcm2708.ko
alias:          platform:bcm2708_spi
license:        GPL v2
author:         Chris Boot <bootc@bootc.net>
description:    SPI controller driver for Broadcom BCM2708
srcversion:     959CE9EF19C17067C99B1B7
depends:        
intree:         Y
vermagic:       3.12.31+ preempt mod_unload modversions ARMv6 

After upgrading modules/kernel with Nostro's version, using sudo REPO_URI=https://github.com/notro/rpi-firmware rpi-update:

root@gpiopi:/home/pi# spi/spidev_test --device /dev/spidev0.0 --bpw 9
can't set bits per word: Invalid argument
Cancelling

Dmesg: [ 109.261226] spidev spi0.0: setup: invalid bits_per_word 9 (must be 8)

Modinfo:

root@gpiopi:/home/pi# modinfo spi_bcm2708
filename:       /lib/modules/3.12.25+/kernel/drivers/spi/spi-bcm2708.ko
alias:          platform:bcm2708_spi
license:        GPL v2
author:         Chris Boot <bootc@bootc.net>, Martin Sperl
description:    SPI controller driver for Broadcom BCM2708
srcversion:     DE4E6BEB9DE3C88E4FAB5AC
alias:          of:N*T*Cbrcm,bcm2708-spi*
depends:        
intree:         Y
vermagic:       3.12.25+ preempt mod_unload modversions ARMv6 
parm:           mode:Processing mode: 0=polling, 1=interrupt driven, 2=dma (default) (short)
parm:           realtime:Run the driver with realtime priority (bool)
parm:           debug:Turn on debug output (uint)

What can I do next? Replacing Nostro's spi8bcm2708 with rapsberry version?

Thanks :)

notro commented 9 years ago

The DMA capable spi-bcm2708 driver that I'm using doesn't support 9-bit. I work around this in FBTFT by zero padding the buffer and emulate using 8-bit (8x 9-bit = 9x 8-bit): https://github.com/notro/fbtft/blob/master/fbtft-io.c#L37

I you need native 9-bit support, you have to use the vanilla driver.

martinlbb commented 9 years ago

Hi Notro!

Thank you for this quick and usefull answer. I am gonna test it soon :)

And I let you know

martinlbb commented 9 years ago

Hi Notro,

I tried native 9 bit support with this ILI9341 screen. Unfortunately, nothing appear on screen, just backlight on.

Do you have any tip(s) to debug it, and make it running?

All the best!

notro commented 9 years ago

Please give the command you use to load fbtft_device.

martinlbb commented 9 years ago

I have tried many configurations:

I am using a breadbord to test screen, and try swaping MISO/MOSI (we never know). No luck.

PINOUT (TFT <-> Raspi) TFT 5V -> PIN 2 TFT GND -> PIN 6 TFT RESET -> PIN 22 (Gpio 25) TFT LED -> PIN 12 (Gpio 18)

CS -> PIN 24 (CS0)

SDI -> MOSI PIN 19 SDO -> MISO PIN 21 SCL -> SCLK PIN 23

From datasheet, I guess this screen is a 9 bit SPI using 4 wires (SCL/MISO/MOSI/CS).

Backlight is working fine.

First try: sudo modprobe name=mi0283qt-9a cs=0 gpios=reset:25,led:18 speed=16000000 rotate=90

Second try: sudo modprobe name=mi0283qt-9a cs=0 gpios=reset:25,led:18 speed=32000000 rotate=90

Each time a /dev/fb1 device is created, and driver seems to be okay. But, if I try fbi or a X session, nothing happens.

What do you suggest Notro as a next step?

Last question: which spi-bcm2708 do I need to use? The DMA's one (on your repo) or vanillia one?

An STMPE610 is also hooked on this board on CE1, using your code it successfully initialize and run smoothly (internal gpio and touchscreen).

Many thanks for your help Notro :)

notro commented 9 years ago

mi0283qt-9a uses the default init sequence in the driver: https://github.com/notro/fbtft/blob/master/fb_ili9341.c#L42

My guess is that you need a different init sequence. Does the datasheet have the sequence, or do you have access to some example code?

martinlbb commented 9 years ago

Factory datasheet is very short, with no init sequence. Here it is: https://www.wetransfer.com/downloads/325af0ca92b2a681d1d50e6b5a635bec20141113204538/853dcaf0d345c0e90a8581ce7a9c667520141113204538/15ddb8 (wrong link modified)

Nor I don't have access to any example code :(

It is hard to debug this, as I can't clearly identify if it is a software or hardware problem. This device a write only, isn't it?

martinlbb commented 9 years ago

Hi Notro!

I just had some informations from factory. They sent me a quick copy/paste of init sequence. And your guess was good. There is some differences :)

I try and let you know (crossing my fingers).