Den 29.11.2021 10.39, skrev Maxime Ripard:
Hi,
On Wed, Nov 24, 2021 at 04:03:07PM -0600, David Lechner wrote:
quoted
On 11/24/21 9:07 AM, Noralf Trønnes wrote:
quoted
This patchset adds a missing piece for decommissioning the
staging/fbtft/fb_st7735r.c driver namely a way to configure the
controller from Device Tree.
All fbtft drivers have builtin support for one display panel and all
other panels using that controller are configured using the Device Tree
'init' property. This property is supported by all fbtft drivers and
provides a generic way to set register values or issue commands
(depending on the type of controller).
It is common for these types of displays to have a datasheet listing the
necessary controller settings/commands or some example code doing the
same.
This is how the panel directly supported by the fb_st7735r staging
driver is described using Device Tree with that driver:
width = <160>;
height = <128>;
init = <0x1000001
0x2000096
0x1000011
0x20000ff
0x10000B1 0x01 0x2C 0x2D
0x10000B4 0x07
0x10000C0 0xA2 0x02 0x84
0x10000C1 0xC5
0x10000C2 0x0A 0x00
0x10000C5 0x0E
0x100003a 0x55
0x1000036 0x60
0x10000E0 0x0F 0x1A 0x0F 0x18 0x2F 0x28 0x20 0x22
0x1F 0x1B 0x23 0x37 0x00 0x07 0x02 0x10
0x10000E1 0x0F 0x1B 0x0F 0x17 0x33 0x2C 0x29 0x2E
0x30 0x30 0x39 0x3F 0x00 0x07 0x03 0x10
60 more quoted lines
Like Geert I wondered about this statement, since you need to change the
DT to use such a display. But if you count overlays as not changing the
DT, ok.
Let's set aside those constraints for a moment though. For most of these
devices, you wouldn't even be able to come up with a proper compatible.
All of those displays are typically a panel and a controller glued
together, and the exact initialization sequence depends on both. The
panel is never really mentioned, neither is its manufacturer, or its
exact product id. In other words, we wouldn't be able to come up with a
good compatible for them.
Let's now assume we do have access to all those info and can come up
with a good, upstreamable, compatible. We now require the user to
contribute it upstream, and then expect them to wait for 1-2 years for
that patch to show up in their distribution of choice.
And then, if we were to get those patches, chances are we don't really
want them anyway since we would be drowning in those small patches
no-one really wants to review.
So yeah, the solution we have is probably a good solution for "real"
panels, glued to a device (and even then, the recent discussion around
panel-edp shows that it has a few shortcomings). But it's a *terrible*
solution for all parties involved when it comes to those kind of
displays.
Really good writeup of the situation Maxime!
I agree that it doesn't really fit in the DT either though. Noralf, what
kind of data do we need to setup a display in fbtft? The init sequence,
and maybe some enable/reset GPIO, plus some timing duration maybe?
There's one similar situation I can think of: wifi chips. Those also
need a few infos from the DT (like what bus it's connected to, enable
GPIO, etc) and a different sequence (firmware), sometimes different from
one board to the other.
Could we have a binding that would be something like:
panel@42 {
compatible = "panel-spi";
model = "panel-from-random-place-42";
enable-gpios = <&...>;
}
And then, the driver would request the init sequence through the
firmware mechanism using a name generated from the model property.
It allows to support multiple devices in a given system, since the
firmware name wouldn't conflict, it makes a decent binding, and users
can adjust the init sequence easily (maybe with a bit of tooling)
Would that work?
I really like this idea. An added benefit is that one driver can handle
all MIPI DBI compatible controllers avoiding the need to do a patchset
like this for all the various MIPI DBI controllers. The firmware will
just contain numeric commands with parameters, so no need for different
controller drivers to handle the controller specific command names.
The following is a list of the MIPI DBI compatible controllers currently
in staging/fbtft: ili9341, hx8357d, st7735r, ili9163, ili9163, ili9163,
ili9163, ili9486, ili9481, tinylcd, s6d02a1, s6d02a1, hx8340bn, ili9340.
The compatible needs to be a bit more specific though since there are 2
major SPI protocols for these display: MIPI DBI and the one used by
ILI9325 and others.
The full binding would be something like this:
panel@42 {
compatible = "panel-mipi-dbi-spi";
model = "panel-from-random-place-42";
/* The MIPI DBI spec lists these powers supply pins */
vdd-supply = <&...>;
vddi-supply = <&...>;
/* Optional gpio to drive the RESX line */
reset-gpios = <&...>;
/*
* D/CX: Data/Command, Command is active low
* Abcense: Interface option 1 (D/C embedded in 9-bit word)
* Precense: Interface option 3
*/
dc-gpios = <&...>;
/*
* If set the driver won't try to read from the controller to see
* if it's already configured by the bootloader or previously by
* the driver. A readable controller avoids flicker and/or delay
* enabling the pipeline.16 more lines