summaryrefslogtreecommitdiff
path: root/modules/hardware
diff options
context:
space:
mode:
authorMel <mel@rnrd.eu>2025-04-30 17:47:52 +0200
committerMel <mel@rnrd.eu>2025-04-30 17:47:52 +0200
commit79b7600448b8713b4aefcdfb1229dfe2caad0d26 (patch)
tree45c688a86af00419355ad1537681a1d6d16ee842 /modules/hardware
parente8f9e3f6ed6c0dc8e0df8ac513cf1d129d8c1877 (diff)
downloadnetwork-79b7600448b8713b4aefcdfb1229dfe2caad0d26.tar.zst
network-79b7600448b8713b4aefcdfb1229dfe2caad0d26.zip
Parameterize ADS7846 touchscreen device tree
Signed-off-by: Mel <mel@rnrd.eu>
Diffstat (limited to 'modules/hardware')
-rw-r--r--modules/hardware/ads7846.nix33
1 files changed, 21 insertions, 12 deletions
diff --git a/modules/hardware/ads7846.nix b/modules/hardware/ads7846.nix
index bb1fe61..4d7582a 100644
--- a/modules/hardware/ads7846.nix
+++ b/modules/hardware/ads7846.nix
@@ -5,7 +5,7 @@
services =
let
calibrationPoints = "3900 200 200 3900";
- calibrationMatrix = "-1 0 1 0 1 0 0 0 1";
+ calibrationMatrix = "-1 0 1 0 1 0";
in
{
libinput.enable = true;
@@ -29,8 +29,17 @@
hardware.deviceTree =
let
- # todo: parameter-ize this more.
+ cs = 1;
penirq = 25;
+ penirq_pull = 2;
+ speed = 50000;
+ pmin = 0;
+ pmax = 255;
+ xohms = 150;
+ xmin = 200;
+ xmax = 3900;
+ ymin = 200;
+ ymax = 3900;
in
{
overlays = [
@@ -77,7 +86,7 @@
ads7846_pins: ads7846_pins {
brcm,pins = <${toString penirq}>; /* mel: previously illegal value of 255 */
brcm,function = <0>; /* in */
- brcm,pull = <0>; /* none */
+ brcm,pull = <${toString penirq_pull}>; /* none */
};
};
};
@@ -91,23 +100,23 @@
ads7846: ads7846@1 {
compatible = "ti,ads7846";
- reg = <1>;
+ reg = <${toString cs}>;
pinctrl-names = "default";
pinctrl-0 = <&ads7846_pins>;
- spi-max-frequency = <2000000>;
+ spi-max-frequency = <${toString speed}>;
interrupts = <${toString penirq} 2>; /* high-to-low edge triggered */
interrupt-parent = <&gpio>;
pendown-gpio = <&gpio ${toString penirq} 1>;
/* driver defaults */
- ti,x-min = /bits/ 16 <0>;
- ti,y-min = /bits/ 16 <0>;
- ti,x-max = /bits/ 16 <0x0FFF>;
- ti,y-max = /bits/ 16 <0x0FFF>;
- ti,pressure-min = /bits/ 16 <0>;
- ti,pressure-max = /bits/ 16 <0xFFFF>;
- ti,x-plate-ohms = /bits/ 16 <400>;
+ ti,x-min = /bits/ 16 <${toString xmin}>;
+ ti,y-min = /bits/ 16 <${toString ymin}>;
+ ti,x-max = /bits/ 16 <${toString xmax}>;
+ ti,y-max = /bits/ 16 <${toString ymax}>;
+ ti,pressure-min = /bits/ 16 <${toString pmin}>;
+ ti,pressure-max = /bits/ 16 <${toString pmax}>;
+ ti,x-plate-ohms = /bits/ 16 <${toString xohms}>;
};
};
};