From f166bcf553d5e2baecf466349e84c4d297bc1d2a Mon Sep 17 00:00:00 2001
From: Felix Gerking <felix.gerking@garz-fricke.com>
Date: Wed, 6 Jul 2022 12:22:16 +0200
Subject: [PATCH] mxt-touch: Pull support for atmel mxt touch from dunfell
 branch

* imx6:mxt-touch: Add kernel support for atmel mxt touch
  BCS 746-000886
  (cherry picked from commit 82cbcf67a86c10ea3719637ae7b4e87fe58d0944)

* maxTouch:udev: Add udev rule to skip maxTouch fwr loading fallback

  The current version of the atmel_mxt_ts driver tries to load a controller
  configuration on each driver probe. However, if no config is provided or
  can't be provided because the driver is built-in, the driver probing process
  is delayed by 60 seconds because of a sysfs firmware load fallback.
  Added a udev rule that automatically cancels the sysfs firmware fallback.

  BCS 746-000892
  (cherry picked from commit 55a34692b3cff31cb0f9ca3a400af843fa74f0b8)

* atmel-mxt: convert recipe to new syntax
---
 .../linux-seconorth-5.10/imx6guf/defconfig    |  1 +
 .../atmel-mxt-skip-fwr-fallback.bb            | 20 +++++++++++++++++++
 .../skip_atmel-mxt_fwr_fallback.rules         |  2 ++
 .../packagegroup-seconorth-touchdriver.bb     | 12 +++++++++--
 4 files changed, 33 insertions(+), 2 deletions(-)
 create mode 100644 recipes-kernel/touchdriver/atmel-mxt-skip-fwr-fallback.bb
 create mode 100644 recipes-kernel/touchdriver/atmel-mxt-skip-fwr-fallback/skip_atmel-mxt_fwr_fallback.rules

diff --git a/recipes-kernel/linux/linux-seconorth-5.10/imx6guf/defconfig b/recipes-kernel/linux/linux-seconorth-5.10/imx6guf/defconfig
index 3733e4f0..e311624e 100644
--- a/recipes-kernel/linux/linux-seconorth-5.10/imx6guf/defconfig
+++ b/recipes-kernel/linux/linux-seconorth-5.10/imx6guf/defconfig
@@ -181,6 +181,7 @@ CONFIG_INPUT_TOUCHSCREEN=y
 CONFIG_TOUCHSCREEN_ADS7846=y
 CONFIG_TOUCHSCREEN_AD7879=y
 CONFIG_TOUCHSCREEN_AD7879_I2C=y
+CONFIG_TOUCHSCREEN_ATMEL_MXT=y
 CONFIG_TOUCHSCREEN_EGALAX=y
 CONFIG_TOUCHSCREEN_GOODIX=y
 CONFIG_TOUCHSCREEN_MAX11801=y
diff --git a/recipes-kernel/touchdriver/atmel-mxt-skip-fwr-fallback.bb b/recipes-kernel/touchdriver/atmel-mxt-skip-fwr-fallback.bb
new file mode 100644
index 00000000..4ef759e1
--- /dev/null
+++ b/recipes-kernel/touchdriver/atmel-mxt-skip-fwr-fallback.bb
@@ -0,0 +1,20 @@
+SUMMARY = "Workaround to skip the sysfs firmware fallback of the atmel maxTouch at boot up"
+# The current version of the atmel_mxt_ts driver tries to load a controller configuration
+# on each driver probe. However, if no config is provided or can't be provided because
+# the driver is build in, the driver probing process is delayed by 60 seconds because
+# of a sysfs firmware load fallback. To shorten this delay, this recipe adds a udev rule
+# that cancels the sysfs firmware fallback.
+
+LICENSE = "Apache-2.0"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
+
+FILESEXTRAPATHS:append := "${THISDIR}/${PN}:"
+
+SRC_URI += " \
+    file://skip_atmel-mxt_fwr_fallback.rules \
+"
+
+do_install() {
+    install -d ${D}${sysconfdir}/udev/rules.d/
+    install -m 0644 ${WORKDIR}/skip_atmel-mxt_fwr_fallback.rules ${D}${sysconfdir}/udev/rules.d
+}
diff --git a/recipes-kernel/touchdriver/atmel-mxt-skip-fwr-fallback/skip_atmel-mxt_fwr_fallback.rules b/recipes-kernel/touchdriver/atmel-mxt-skip-fwr-fallback/skip_atmel-mxt_fwr_fallback.rules
new file mode 100644
index 00000000..e4244226
--- /dev/null
+++ b/recipes-kernel/touchdriver/atmel-mxt-skip-fwr-fallback/skip_atmel-mxt_fwr_fallback.rules
@@ -0,0 +1,2 @@
+ACTION=="add", SUBSYSTEM=="firmware", ENV{FIRMWARE}=="maxtouch.cfg", ATTR{loading}="-1"
+
diff --git a/recipes-kernel/touchdriver/packagegroup-seconorth-touchdriver.bb b/recipes-kernel/touchdriver/packagegroup-seconorth-touchdriver.bb
index 3a68e8d3..7ac47d39 100644
--- a/recipes-kernel/touchdriver/packagegroup-seconorth-touchdriver.bb
+++ b/recipes-kernel/touchdriver/packagegroup-seconorth-touchdriver.bb
@@ -5,7 +5,6 @@ inherit packagegroup
 
 
 UNUSED_DRIVERS = " \
-	atmel-mxt \
 	auo-pixcir \
 	edt-ft5x06 \
 	himax \
@@ -19,8 +18,17 @@ RDEPENDS:${PN} = " \
 	scx0500633 \
 "
 
-RDEPENDS:${PN}:append_mx6q  = " \
+RDEPENDS:${PN}:append:mx6q  = " \
 	sis-i2c \
 	eetii2c \ 
 	ni-force-ts \
 "
+
+# This is not used for fng system, so use the override
+# this is ugly as the override comes from the distro
+# layer. But this hack is ugly anyway an may be
+# replaced using the atmel driver instead of the mainline
+# driver
+RDEPENDS:${PN}:append:seconorth  = " \
+	atmel-mxt-skip-fwr-fallback \
+"
-- 
GitLab