Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TinyDRM ILI9486 overlay, and minor bcm2835-codec logging tweak #5588

Merged
merged 5 commits into from
Sep 1, 2023

Conversation

6by9
Copy link
Contributor

@6by9 6by9 commented Aug 30, 2023

https://forums.raspberrypi.com/viewtopic.php?t=355484 for the TinyDRM overlay.

bcm2835-codec change for #5582

@@ -98,5 +100,7 @@
fps = <&piscreen>,"fps:0";
debug = <&piscreen>,"debug:0";
xohms = <&piscreen_ts>,"ti,x-plate-ohms;0";
drm = <&piscreen>,"compatible=waveshare,rpi-lcd-35",
<&piscreen>,"reset-gpios:8=GPIO_ACTIVE_HIGH";
Copy link
Contributor

@pelwell pelwell Aug 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this works?:

$ dtmerge arch/arm/boot/dts/bcm2711-rpi-4-b.dtb base.dtb -
$ dtmerge base.dtb merged.dtb arch/arm/boot/dts/overlays/piscreen.dtbo drm
DTOVERLAY[error]: invalid override value 'GPIO_ACTIVE_HIGH' - ignored

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right - my update script to push the change to the Pi obviously didn't for some reason (probably PEBKAC).

@6by9
Copy link
Contributor Author

6by9 commented Aug 31, 2023

Actually there's a bigger problem. In the non-drm case (compatible ilitek,ili9486), both drivers get loaded

pi@pi:~ $ modinfo fb_ili9486
filename:       /lib/modules/6.1.47-v8+/kernel/drivers/staging/fbtft/fb_ili9486.ko.xz
license:        GPL
author:         Noralf Tronnes
description:    FB driver for the ILI9486 LCD Controller
alias:          platform:ili9486
alias:          spi:ili9486
alias:          platform:fb_ili9486
alias:          spi:fb_ili9486
srcversion:     A87A9FEB7E5C3553E7CDE5A
alias:          of:N*T*Cilitek,ili9486C*
alias:          of:N*T*Cilitek,ili9486
depends:        fbtft
staging:        Y
intree:         Y
name:           fb_ili9486
vermagic:       6.1.47-v8+ SMP preempt mod_unload modversions aarch64

pi@pi:~ $ modinfo ili9486
filename:       /lib/modules/6.1.47-v8+/kernel/drivers/gpu/drm/tiny/ili9486.ko.xz
license:        GPL
author:         Kamlesh Gurudasani <[email protected]>
description:    Ilitek ILI9486 DRM driver
srcversion:     6FBFCC0E15DDF43CA36470A
alias:          of:N*T*Cozzmaker,piscreenC*
alias:          of:N*T*Cozzmaker,piscreen
alias:          of:N*T*Cwaveshare,rpi-lcd-35C*
alias:          of:N*T*Cwaveshare,rpi-lcd-35
alias:          spi:ili9486
depends:        drm_kms_helper,drm,drm_mipi_dbi,backlight,drm_dma_helper
intree:         Y
name:           ili9486
vermagic:       6.1.47-v8+ SMP preempt mod_unload modversions aarch64

Presumably it's of:N*T*Cilitek,ili9486 vs spi:ili9486 causing the issue.

@pelwell
Copy link
Contributor

pelwell commented Aug 31, 2023

Presumably it's of:NTCilitek,ili9486 vs spi:ili9486 causing the issue.

Sorry, missed this pseudo-question - yes, that is probably the cauase.

Can we just disable the fbtft version?

@6by9
Copy link
Contributor Author

6by9 commented Aug 31, 2023

Can we just disable the fbtft version?

Not really unless we change the overlay to only supporting the DRM one.

Both are mainline drivers, so probably worth reporting to mainline to see what they want to do. The fact that SPI has this secondary matching (and complaining if the SPI alias is missing) is really a bit ugly.

@pelwell
Copy link
Contributor

pelwell commented Sep 1, 2023

In the same way that the fbtft driver uses spi:fb_ili9486, we could patch the upstream DRM driver so it also uses a prefix for the SPI alias, e.g. spi:drm_ili9486.

Adds the DRM driver for the ILI9486.

Signed-off-by: Dave Stevenson <[email protected]>
@6by9
Copy link
Contributor Author

6by9 commented Sep 1, 2023

I'm not totally sure on how the spi_id table is used, except that the SPI core whinges if a compatible string device name isn't present in the spi_id table as well. So it complains on ili9486 as rpi-lcd-35 and piscreen aren't present.
(It also complains that ili9486 is missing for fb_ili9486).

Easiest fix is

@ -187,7 +187,8 @@ static const struct of_device_id ili9486_of_match[] = {
 MODULE_DEVICE_TABLE(of, ili9486_of_match);
 
 static const struct spi_device_id ili9486_id[] = {
-       { "ili9486", 0 },
+       { "rpi-lcd-35", 0 },
+       { "piscreen", 0 },
        { }
 };
 MODULE_DEVICE_TABLE(spi, ili9486_id);

thus silencing the SPI core code on the mismatch, and removing the clash.

Whilst at it I'll add the missing spi_device_id entries in ads7846 (the touchscreen driver) so at least with the DRM option the SPI core is happy.

@pelwell
Copy link
Contributor

pelwell commented Sep 1, 2023

This also works, if you prefer:

<&piscreen>,"reset-gpios:8=",<GPIO_ACTIVE_HIGH>;

but I'm happy to merge as is.

@6by9
Copy link
Contributor Author

6by9 commented Sep 1, 2023

This also works, if you prefer:

Give me two mins to update to that - it's much nicer.

Adds the option of selecting the DRM/KMS TinyDRM driver for
this panel, rather than the deprecated FBTFT one.

Signed-off-by: Dave Stevenson <[email protected]>
For "Really Good Reasons" [1] the SPI core requires a match
between compatible device strings and the name in spi_device_id.

The ili9486 driver uses compatible strings "waveshare,rpi-lcd-35"
and "ozzmaker,piscreen", but "rpi-lcd-35" and "piscreen" are missing,
so add them.

Compatible string "ilitek,ili9486" is already used by
staging/fbtft/fb_ili9486, therefore leaving it present in ili9486 as an
spi_device_id causes the incorrect module to be loaded, therefore remove
this id.

[1] https://elixir.bootlin.com/linux/latest/source/drivers/spi/spi.c#L487

Signed-off-by: Dave Stevenson <[email protected]>
The SPI core logs error messages if a compatible string device
name is not also present as an spi_device_id.

No spi_device_id values are specified by the driver, therefore
we get 4 log lines every time it is loaded:
SPI driver ads7846 has no spi_device_id for ti,tsc2046
SPI driver ads7846 has no spi_device_id for ti,ads7843
SPI driver ads7846 has no spi_device_id for ti,ads7845
SPI driver ads7846 has no spi_device_id for ti,ads7873

Add the spi_device_id values for these devices.

Signed-off-by: Dave Stevenson <[email protected]>
The debug message from bcm2835_codec_buf_prepare when the buffer
size is incorrect can be a little spammy if the application isn't
careful on how it drives it, therefore drop the priority of the
message.

Signed-off-by: Dave Stevenson <[email protected]>
@pelwell pelwell merged commit 65742d7 into raspberrypi:rpi-6.1.y Sep 1, 2023
11 checks passed
popcornmix added a commit to raspberrypi/firmware that referenced this pull request Sep 5, 2023
kernel: configs: Raise 8250 UART limit to 5 on BCM2711
See: raspberrypi/linux#5590

kernel: drivers: irqchip: irq-bcm2835: Concurrency fix
See: raspberrypi/linux#5589

kernel: TinyDRM ILI9486 overlay, and minor bcm2835-codec logging tweak
See: raspberrypi/linux#5588
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants