atmel_mxt_ts: [HACK DV20] load correct cfg file
authorHong Liu <hong.liu@intel.com>
Wed, 11 Apr 2012 07:50:18 +0000 (15:50 +0800)
committerbuildbot <buildbot@intel.com>
Fri, 13 Apr 2012 15:46:11 +0000 (08:46 -0700)
BZ: 31105

There are 3 touch panels used on medfield tablet, we need to load correct
cfg file to make touch work.
dv1.0       mxt1386         0x4c maxtouch.cfg
dv2.0       mxt1386_wintek  0x4c maxtouch_wintek.cfg
dv2.0       mxt1386_hanns   0x4d maxtouch_hanns.cfg

currently we use dev name to differentiate dv10 or dv20 panel, while uses
i2c slave address to differentiate two dv20 panels.

This hack can be removed once firmware can runtime detect panel type.

Change-Id: Ie1ba8793f2e311322b1b0f98772de5b1b6d4de7a
Signed-off-by: Hong Liu <hong.liu@intel.com>
Reviewed-on: http://android.intel.com:8080/43071
Reviewed-by: Wood, Brian J <brian.j.wood@intel.com>
Reviewed-by: Lebouc, Christophe <christophe.lebouc@intel.com>
Tested-by: Lebouc, Christophe <christophe.lebouc@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
arch/x86/platform/intel-mid/board-redridge.c
drivers/input/touchscreen/atmel_mxt_ts.c

index e5ae713..8ecd2a8 100644 (file)
@@ -1869,6 +1869,8 @@ struct devs_id __initconst device_ids[] = {
        {"mt9m114", SFI_DEV_TYPE_I2C, 0, &mt9m114_platform_data_init,
                                        &intel_ignore_i2c_device_register},
        {"mxt1386", SFI_DEV_TYPE_I2C, 0, &mxt_platform_data_init, NULL},
+       {"mxt1386_wintek", SFI_DEV_TYPE_I2C, 0, &mxt_platform_data_init, NULL},
+       {"mxt1386_hanns", SFI_DEV_TYPE_I2C, 0, &mxt_platform_data_init, NULL},
        {"audience_es305", SFI_DEV_TYPE_I2C, 0, &audience_platform_data_init,
                                                NULL},
        {"accel", SFI_DEV_TYPE_I2C, 0, &lis3dh_pdata_init, NULL},
index 4f6a868..1f7ac78 100644 (file)
@@ -266,6 +266,7 @@ struct mxt_data {
        bool is_stopped;
        u8 idle_acq_int;
        u8 actv_acq_int;
+       char devname[I2C_NAME_SIZE];
 #ifdef CONFIG_HAS_EARLYSUSPEND
        struct early_suspend esuspend;
 #endif
@@ -718,6 +719,35 @@ static int mxt_check_reg_init(struct mxt_data *data)
        return 0;
 }
 
+/*
+ * There are 3 touch panels used:
+ * dv1.0       mxt1386         0x4c maxtouch.cfg
+ * dv2.0       mxt1386_wintek  0x4c maxtouch_wintek.cfg
+ * dv2.0       mxt1386_hanns   0x4d maxtouch_hanns.cfg
+ * Currently we mannual check the device name and slave address to
+ * decide which cfg file to load.
+ *
+ * This hack can be removed once firmware can detect the panel runtime,
+ * and provides correct name + slave addr to driver.
+ */
+static void mxt_get_fwname(struct mxt_data *data, char *name, int size)
+{
+       struct i2c_client *client = data->client;
+       const char *fname;
+
+       if (!strncmp(data->devname, "mxt1386", sizeof(data->devname)))
+               fname = "maxtouch.cfg";
+       else {
+               if (client->addr == 0x4c)
+                       fname = "maxtouch_wintek.cfg";
+               else
+                       fname = "maxtouch_hanns.cfg";
+       }
+
+       strncpy(name, fname, size);
+       dev_info(&client->dev, "load firmware %s\n", name);
+}
+
 static int mxt_check_reg_init_fw(struct mxt_data *data)
 {
        struct mxt_object *object;
@@ -726,10 +756,13 @@ static int mxt_check_reg_init_fw(struct mxt_data *data)
        int i, j, config_offset;
        const struct firmware *cfg = NULL;
        int ret;
+       char fwname[32] = { 0 };
+
+       mxt_get_fwname(data, fwname, sizeof(fwname));
 
-       ret = request_firmware(&cfg, "maxtouch.cfg", dev);
+       ret = request_firmware(&cfg, fwname, dev);
        if (ret) {
-               dev_dbg(dev, "Unable to open maxtouch.cfg\n");
+               dev_dbg(dev, "Unable to open %s\n", fwname);
                return 0;
        }
 
@@ -1315,6 +1348,7 @@ static int __devinit mxt_probe(struct i2c_client *client,
        data->input_dev = input_dev;
        data->pdata = pdata;
        data->irq = client->irq;
+       memcpy(data->devname, id->name, sizeof(data->devname));
 
        if (pdata->init_platform_hw) {
                error = pdata->init_platform_hw(client);
@@ -1502,6 +1536,8 @@ static const struct i2c_device_id mxt_id[] = {
        { "atmel_mxt_ts", 0 },
        { "mXT224", 0 },
        { "mxt1386", 0 },
+       { "mxt1386_wintek", 0 },
+       { "mxt1386_hanns", 0 },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, mxt_id);