From: Kaustabh Chakraborty <[email protected]>

Some replacement displays include third-party touch ICs which do not
report the product ID correctly unless we read directly from the
product ID register. Add a check and a fallback read to handle this.

Signed-off-by: Kaustabh Chakraborty <[email protected]>
Signed-off-by: Casey Connolly <[email protected]>
Signed-off-by: David Heidelberg <[email protected]>
---
 drivers/input/rmi4/rmi_f01.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/input/rmi4/rmi_f01.c b/drivers/input/rmi4/rmi_f01.c
index 47be64284b25e..2278e9b6a9207 100644
--- a/drivers/input/rmi4/rmi_f01.c
+++ b/drivers/input/rmi4/rmi_f01.c
@@ -245,16 +245,30 @@ static int rmi_f01_read_properties(struct rmi_device 
*rmi_dev,
                                return ret;
                        }
 
                        props->firmware_id = queries[1] << 8 | queries[0];
                        props->firmware_id += queries[2] * 65536;
                }
        }
 
+       /*
+        * Some aftermarket ICs put garbage into the product id field unless
+        * we read directly from the product id register.
+        */
+       if (props->product_id[0] < 0x20) {
+               ret = rmi_read_block(rmi_dev, query_base_addr + 11,
+                                      props->product_id, 
RMI_PRODUCT_ID_LENGTH);
+               if (ret) {
+                       dev_err(&rmi_dev->dev,
+                               "Failed to read product id: %d\n", ret);
+                       return ret;
+               }
+       }
+
        return 0;
 }
 
 const char *rmi_f01_get_product_ID(struct rmi_function *fn)
 {
        struct f01_data *f01 = dev_get_drvdata(&fn->dev);
 
        return f01->properties.product_id;

-- 
2.53.0



Reply via email to