From bd6381e513123178593dc8af13b02afeacd912ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Christ?= Date: Sun, 26 Mar 2023 20:00:39 +0200 Subject: [PATCH 1/2] raspberry-pi/4: Add touch support for official 7" display. --- raspberry-pi/4/touch-ft5406.nix | 65 +++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 raspberry-pi/4/touch-ft5406.nix diff --git a/raspberry-pi/4/touch-ft5406.nix b/raspberry-pi/4/touch-ft5406.nix new file mode 100644 index 0000000..12bb768 --- /dev/null +++ b/raspberry-pi/4/touch-ft5406.nix @@ -0,0 +1,65 @@ +{ config, lib, ... }: + +let + cfg = config.hardware.raspberry-pi."4".touch-ft5406; +in +{ + options.hardware = { + raspberry-pi."4".touch-ft5406 = { + enable = lib.mkEnableOption '' + Enable the touch controller of the official Raspberry Pi touch diplay. + + The overlay is taken from the official Raspberry Pi Linux fork, and + the `compatible` field is updated to match the target device tree. + https://github.com/raspberrypi/linux/blob/14b35093ca68bf2c81bbc90aace5007142b40b40/arch/arm/boot/dts/overlays/rpi-ft5406-overlay.dts + + For more information about the touch display, please refer to: + https://www.raspberrypi.com/documentation/accessories/display.html + ''; + }; + }; + + config = lib.mkIf cfg.enable { + # Configure for modesetting in the device tree + hardware.deviceTree = { + overlays = [ + # this *should* be equivalent to (which doesn't work): + # https://github.com/raspberrypi/linux/blob/rpi-5.10.y/arch/arm/boot/dts/overlays/dwc2-overlay.dts + # but actually it's obtained using + # dtc -I dtb -O dts ${config.hardware.deviceTree.kernelPackage}/dtbs/overlays/dwc2.dtbo + # (changes: modified top-level "compatible" field) + # which is slightly different and works + { + name = "rpi-ft5406-overlay"; + dtsText = '' + /dts-v1/; + /plugin/; + + / { + compatible = "brcm,bcm2711"; + + fragment@0 { + target-path = "/soc/firmware"; + __overlay__ { + ts: touchscreen { + compatible = "raspberrypi,firmware-ts"; + touchscreen-size-x = <800>; + touchscreen-size-y = <480>; + }; + }; + }; + + __overrides__ { + touchscreen-size-x = <&ts>,"touchscreen-size-x:0"; + touchscreen-size-y = <&ts>,"touchscreen-size-y:0"; + touchscreen-inverted-x = <&ts>,"touchscreen-inverted-x?"; + touchscreen-inverted-y = <&ts>,"touchscreen-inverted-y?"; + touchscreen-swapped-x-y = <&ts>,"touchscreen-swapped-x-y?"; + }; + }; + ''; + } + ]; + }; + }; +} From 3023004e9903bc2f726da7c4a6724cf55f45bfff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Christ?= Date: Sun, 26 Mar 2023 20:11:16 +0200 Subject: [PATCH 2/2] raspberry-pi/4: Fix comments and indentation. --- raspberry-pi/4/touch-ft5406.nix | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/raspberry-pi/4/touch-ft5406.nix b/raspberry-pi/4/touch-ft5406.nix index 12bb768..5cc0a70 100644 --- a/raspberry-pi/4/touch-ft5406.nix +++ b/raspberry-pi/4/touch-ft5406.nix @@ -20,15 +20,8 @@ in }; config = lib.mkIf cfg.enable { - # Configure for modesetting in the device tree hardware.deviceTree = { overlays = [ - # this *should* be equivalent to (which doesn't work): - # https://github.com/raspberrypi/linux/blob/rpi-5.10.y/arch/arm/boot/dts/overlays/dwc2-overlay.dts - # but actually it's obtained using - # dtc -I dtb -O dts ${config.hardware.deviceTree.kernelPackage}/dtbs/overlays/dwc2.dtbo - # (changes: modified top-level "compatible" field) - # which is slightly different and works { name = "rpi-ft5406-overlay"; dtsText = '' @@ -55,7 +48,7 @@ in touchscreen-inverted-x = <&ts>,"touchscreen-inverted-x?"; touchscreen-inverted-y = <&ts>,"touchscreen-inverted-y?"; touchscreen-swapped-x-y = <&ts>,"touchscreen-swapped-x-y?"; - }; + }; }; ''; }