From: Guido Günther <[email protected]>

With other probing issues out of the way (by marking LCD_1V8 always on)
it turns out we can't use either touch or DSI until we pulled both RESX
and TP_RSTN¹ so instead of guessing wait until the panel is up.

This replaces one hack (probe defers) by another (more reliable) one.

¹) This appeared to be otherwise since even a failed probe of the touch
controller (happening way too early before avdd/avee are up) is enough
and thaat only became appearend when not loading the touch controller
module at all.

Signed-off-by: Guido Günther <[email protected]>

When the (temporary) DT property "purism,panel-touchscreen-workaround"
is found, wait for the mantix panel to be prepared, before continuing
in probe().
---
 drivers/input/touchscreen/edt-ft5x06.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/input/touchscreen/edt-ft5x06.c 
b/drivers/input/touchscreen/edt-ft5x06.c
index 2a27750c76444..3084ae5fc320a 100644
--- a/drivers/input/touchscreen/edt-ft5x06.c
+++ b/drivers/input/touchscreen/edt-ft5x06.c
@@ -14,6 +14,8 @@
  *    http://www.glyn.com/Products/Displays
  */
 
+#define DEBUG
+
 #include <linux/debugfs.h>
 #include <linux/delay.h>
 #include <linux/gpio/consumer.h>
@@ -964,6 +966,9 @@ static int edt_ft5x06_ts_identify(struct i2c_client *client,
                        snprintf(model_name, EDT_NAME_LEN,
                                 "EVERVISION-FT5726NEi");
                        break;
+               case 0x02:   /* FT 8506 */
+                       snprintf(model_name, EDT_NAME_LEN, "Focaltec FT8006P");
+                       break;
                default:
                        snprintf(model_name, EDT_NAME_LEN,
                                 "generic ft5x06 (%02x)",
@@ -1136,6 +1141,8 @@ static void edt_ft5x06_disable_regulators(void *arg)
        regulator_disable(data->iovcc);
 }
 
+bool mantix_panel_prepared(void);
+
 static int edt_ft5x06_ts_probe(struct i2c_client *client)
 {
        const struct i2c_device_id *id = i2c_client_get_device_id(client);
@@ -1147,6 +1154,18 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client)
        int error;
        u32 report_rate;
 
+       if (device_property_read_bool(&client->dev,
+                                     "purism,panel-librem5-workaround")) {
+               /*
+                * Since the Librem 5's panel handles the reset via gpio we
+                * need to wait until the panel is up.
+                */
+               if (!mantix_panel_prepared()) {
+                       dev_dbg(&client->dev, "Panel not yet ready\n");
+                       return -EPROBE_DEFER;
+               }
+       }
+
        dev_dbg(&client->dev, "probing for EDT FT5x06 I2C\n");
 
        tsdata = devm_kzalloc(&client->dev, sizeof(*tsdata), GFP_KERNEL);
-- 
2.47.3

Reply via email to