Merge git://git.kernel.org/pub/scm/linux/kernel/git/pkl/squashfs-next
[pandora-kernel.git] / drivers / input / mouse / elantech.c
index 9cfc70a..09b93b1 100644 (file)
@@ -10,8 +10,6 @@
  * Trademarks are the property of their respective owners.
  */
 
-#define pr_fmt(fmt) KBUILD_BASENAME ": " fmt
-
 #include <linux/delay.h>
 #include <linux/slab.h>
 #include <linux/module.h>
 #define elantech_debug(fmt, ...)                                       \
        do {                                                            \
                if (etd->debug)                                         \
-                       printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__);  \
+                       psmouse_printk(KERN_DEBUG, psmouse,             \
+                                       fmt, ##__VA_ARGS__);            \
        } while (0)
 
-static bool force_elantech;
-module_param_named(force_elantech, force_elantech, bool, 0644);
-MODULE_PARM_DESC(force_elantech, "Force the Elantech PS/2 protocol extension to be used, 1 = enabled, 0 = disabled (default).");
-
 /*
  * Send a Synaptics style sliced query command
  */
@@ -40,7 +35,7 @@ static int synaptics_send_cmd(struct psmouse *psmouse, unsigned char c,
 {
        if (psmouse_sliced_command(psmouse, c) ||
            ps2_command(&psmouse->ps2dev, param, PSMOUSE_CMD_GETINFO)) {
-               pr_err("synaptics_send_cmd query 0x%02x failed.\n", c);
+               psmouse_err(psmouse, "%s query 0x%02x failed.\n", __func__, c);
                return -1;
        }
 
@@ -69,7 +64,7 @@ static int elantech_ps2_command(struct psmouse *psmouse,
        } while (tries > 0);
 
        if (rc)
-               pr_err("ps2 command 0x%02x failed.\n", command);
+               psmouse_err(psmouse, "ps2 command 0x%02x failed.\n", command);
 
        return rc;
 }
@@ -84,7 +79,7 @@ static int elantech_read_reg(struct psmouse *psmouse, unsigned char reg,
        unsigned char param[3];
        int rc = 0;
 
-       if (reg < 0x10 || reg > 0x26)
+       if (reg < 0x07 || reg > 0x26)
                return -1;
 
        if (reg > 0x11 && reg < 0x20)
@@ -109,7 +104,7 @@ static int elantech_read_reg(struct psmouse *psmouse, unsigned char reg,
                }
                break;
 
-       case 3:
+       case 3 ... 4:
                if (elantech_ps2_command(psmouse, NULL, ETP_PS2_CUSTOM_COMMAND) ||
                    elantech_ps2_command(psmouse, NULL, ETP_REGISTER_READWRITE) ||
                    elantech_ps2_command(psmouse, NULL, ETP_PS2_CUSTOM_COMMAND) ||
@@ -121,9 +116,11 @@ static int elantech_read_reg(struct psmouse *psmouse, unsigned char reg,
        }
 
        if (rc)
-               pr_err("failed to read register 0x%02x.\n", reg);
-       else
+               psmouse_err(psmouse, "failed to read register 0x%02x.\n", reg);
+       else if (etd->hw_version != 4)
                *val = param[0];
+       else
+               *val = param[1];
 
        return rc;
 }
@@ -137,7 +134,7 @@ static int elantech_write_reg(struct psmouse *psmouse, unsigned char reg,
        struct elantech_data *etd = psmouse->private;
        int rc = 0;
 
-       if (reg < 0x10 || reg > 0x26)
+       if (reg < 0x07 || reg > 0x26)
                return -1;
 
        if (reg > 0x11 && reg < 0x20)
@@ -176,11 +173,26 @@ static int elantech_write_reg(struct psmouse *psmouse, unsigned char reg,
                        rc = -1;
                }
                break;
+
+       case 4:
+               if (elantech_ps2_command(psmouse, NULL, ETP_PS2_CUSTOM_COMMAND) ||
+                   elantech_ps2_command(psmouse, NULL, ETP_REGISTER_READWRITE) ||
+                   elantech_ps2_command(psmouse, NULL, ETP_PS2_CUSTOM_COMMAND) ||
+                   elantech_ps2_command(psmouse, NULL, reg) ||
+                   elantech_ps2_command(psmouse, NULL, ETP_PS2_CUSTOM_COMMAND) ||
+                   elantech_ps2_command(psmouse, NULL, ETP_REGISTER_READWRITE) ||
+                   elantech_ps2_command(psmouse, NULL, ETP_PS2_CUSTOM_COMMAND) ||
+                   elantech_ps2_command(psmouse, NULL, val) ||
+                   elantech_ps2_command(psmouse, NULL, PSMOUSE_CMD_SETSCALE11)) {
+                       rc = -1;
+               }
+               break;
        }
 
        if (rc)
-               pr_err("failed to write register 0x%02x with value 0x%02x.\n",
-                       reg, val);
+               psmouse_err(psmouse,
+                           "failed to write register 0x%02x with value 0x%02x.\n",
+                           reg, val);
 
        return rc;
 }
@@ -188,13 +200,13 @@ static int elantech_write_reg(struct psmouse *psmouse, unsigned char reg,
 /*
  * Dump a complete mouse movement packet to the syslog
  */
-static void elantech_packet_dump(unsigned char *packet, int size)
+static void elantech_packet_dump(struct psmouse *psmouse)
 {
        int     i;
 
-       printk(KERN_DEBUG pr_fmt("PS/2 packet ["));
-       for (i = 0; i < size; i++)
-               printk("%s0x%02x ", (i) ? ", " : " ", packet[i]);
+       psmouse_printk(KERN_DEBUG, psmouse, "PS/2 packet [");
+       for (i = 0; i < psmouse->pktsize; i++)
+               printk("%s0x%02x ", i ? ", " : " ", psmouse->packet[i]);
        printk("]\n");
 }
 
@@ -409,12 +421,12 @@ static void elantech_report_absolute_v3(struct psmouse *psmouse,
                         * byte 1:   .    .    .    .  ax11 ax10 ax9  ax8
                         * byte 2: ax7  ax6  ax5  ax4  ax3  ax2  ax1  ax0
                         */
-                       etd->prev_x = ((packet[1] & 0x0f) << 8) | packet[2];
+                       etd->mt[0].x = ((packet[1] & 0x0f) << 8) | packet[2];
                        /*
                         * byte 4:   .    .    .    .  ay11 ay10 ay9  ay8
                         * byte 5: ay7  ay6  ay5  ay4  ay3  ay2  ay1  ay0
                         */
-                       etd->prev_y = etd->y_max -
+                       etd->mt[0].y = etd->y_max -
                                (((packet[4] & 0x0f) << 8) | packet[5]);
                        /*
                         * wait for next packet
@@ -423,8 +435,8 @@ static void elantech_report_absolute_v3(struct psmouse *psmouse,
                }
 
                /* packet_type == PACKET_V3_TAIL */
-               x1 = etd->prev_x;
-               y1 = etd->prev_y;
+               x1 = etd->mt[0].x;
+               y1 = etd->mt[0].y;
                x2 = ((packet[1] & 0x0f) << 8) | packet[2];
                y2 = etd->y_max - (((packet[4] & 0x0f) << 8) | packet[5]);
                break;
@@ -450,6 +462,129 @@ static void elantech_report_absolute_v3(struct psmouse *psmouse,
        input_sync(dev);
 }
 
+static void elantech_input_sync_v4(struct psmouse *psmouse)
+{
+       struct input_dev *dev = psmouse->dev;
+       unsigned char *packet = psmouse->packet;
+
+       input_report_key(dev, BTN_LEFT, packet[0] & 0x01);
+       input_report_key(dev, BTN_RIGHT, packet[0] & 0x02);
+       input_mt_report_pointer_emulation(dev, true);
+       input_sync(dev);
+}
+
+static void process_packet_status_v4(struct psmouse *psmouse)
+{
+       struct input_dev *dev = psmouse->dev;
+       unsigned char *packet = psmouse->packet;
+       unsigned fingers;
+       int i;
+
+       /* notify finger state change */
+       fingers = packet[1] & 0x1f;
+       for (i = 0; i < ETP_MAX_FINGERS; i++) {
+               if ((fingers & (1 << i)) == 0) {
+                       input_mt_slot(dev, i);
+                       input_mt_report_slot_state(dev, MT_TOOL_FINGER, false);
+               }
+       }
+
+       elantech_input_sync_v4(psmouse);
+}
+
+static void process_packet_head_v4(struct psmouse *psmouse)
+{
+       struct input_dev *dev = psmouse->dev;
+       struct elantech_data *etd = psmouse->private;
+       unsigned char *packet = psmouse->packet;
+       int id = ((packet[3] & 0xe0) >> 5) - 1;
+       int pres, traces;
+
+       if (id < 0)
+               return;
+
+       etd->mt[id].x = ((packet[1] & 0x0f) << 8) | packet[2];
+       etd->mt[id].y = etd->y_max - (((packet[4] & 0x0f) << 8) | packet[5]);
+       pres = (packet[1] & 0xf0) | ((packet[4] & 0xf0) >> 4);
+       traces = (packet[0] & 0xf0) >> 4;
+
+       input_mt_slot(dev, id);
+       input_mt_report_slot_state(dev, MT_TOOL_FINGER, true);
+
+       input_report_abs(dev, ABS_MT_POSITION_X, etd->mt[id].x);
+       input_report_abs(dev, ABS_MT_POSITION_Y, etd->mt[id].y);
+       input_report_abs(dev, ABS_MT_PRESSURE, pres);
+       input_report_abs(dev, ABS_MT_TOUCH_MAJOR, traces * etd->width);
+       /* report this for backwards compatibility */
+       input_report_abs(dev, ABS_TOOL_WIDTH, traces);
+
+       elantech_input_sync_v4(psmouse);
+}
+
+static void process_packet_motion_v4(struct psmouse *psmouse)
+{
+       struct input_dev *dev = psmouse->dev;
+       struct elantech_data *etd = psmouse->private;
+       unsigned char *packet = psmouse->packet;
+       int weight, delta_x1 = 0, delta_y1 = 0, delta_x2 = 0, delta_y2 = 0;
+       int id, sid;
+
+       id = ((packet[0] & 0xe0) >> 5) - 1;
+       if (id < 0)
+               return;
+
+       sid = ((packet[3] & 0xe0) >> 5) - 1;
+       weight = (packet[0] & 0x10) ? ETP_WEIGHT_VALUE : 1;
+       /*
+        * Motion packets give us the delta of x, y values of specific fingers,
+        * but in two's complement. Let the compiler do the conversion for us.
+        * Also _enlarge_ the numbers to int, in case of overflow.
+        */
+       delta_x1 = (signed char)packet[1];
+       delta_y1 = (signed char)packet[2];
+       delta_x2 = (signed char)packet[4];
+       delta_y2 = (signed char)packet[5];
+
+       etd->mt[id].x += delta_x1 * weight;
+       etd->mt[id].y -= delta_y1 * weight;
+       input_mt_slot(dev, id);
+       input_report_abs(dev, ABS_MT_POSITION_X, etd->mt[id].x);
+       input_report_abs(dev, ABS_MT_POSITION_Y, etd->mt[id].y);
+
+       if (sid >= 0) {
+               etd->mt[sid].x += delta_x2 * weight;
+               etd->mt[sid].y -= delta_y2 * weight;
+               input_mt_slot(dev, sid);
+               input_report_abs(dev, ABS_MT_POSITION_X, etd->mt[sid].x);
+               input_report_abs(dev, ABS_MT_POSITION_Y, etd->mt[sid].y);
+       }
+
+       elantech_input_sync_v4(psmouse);
+}
+
+static void elantech_report_absolute_v4(struct psmouse *psmouse,
+                                       int packet_type)
+{
+       switch (packet_type) {
+       case PACKET_V4_STATUS:
+               process_packet_status_v4(psmouse);
+               break;
+
+       case PACKET_V4_HEAD:
+               process_packet_head_v4(psmouse);
+               break;
+
+       case PACKET_V4_MOTION:
+               process_packet_motion_v4(psmouse);
+               break;
+
+       case PACKET_UNKNOWN:
+       default:
+               /* impossible to get here */
+               break;
+       }
+}
+
 static int elantech_packet_check_v1(struct psmouse *psmouse)
 {
        struct elantech_data *etd = psmouse->private;
@@ -474,6 +609,18 @@ static int elantech_packet_check_v1(struct psmouse *psmouse)
               etd->parity[packet[3]] == p3;
 }
 
+static int elantech_debounce_check_v2(struct psmouse *psmouse)
+{
+        /*
+         * When we encounter packet that matches this exactly, it means the
+         * hardware is in debounce status. Just ignore the whole packet.
+         */
+        const u8 debounce_packet[] = { 0x84, 0xff, 0xff, 0x02, 0xff, 0xff };
+        unsigned char *packet = psmouse->packet;
+
+        return !memcmp(packet, debounce_packet, sizeof(debounce_packet));
+}
+
 static int elantech_packet_check_v2(struct psmouse *psmouse)
 {
        struct elantech_data *etd = psmouse->private;
@@ -504,7 +651,7 @@ static int elantech_packet_check_v2(struct psmouse *psmouse)
 
 /*
  * We check the constant bits to determine what packet type we get,
- * so packet checking is mandatory for v3 hardware.
+ * so packet checking is mandatory for v3 and later hardware.
  */
 static int elantech_packet_check_v3(struct psmouse *psmouse)
 {
@@ -527,6 +674,25 @@ static int elantech_packet_check_v3(struct psmouse *psmouse)
        return PACKET_UNKNOWN;
 }
 
+static int elantech_packet_check_v4(struct psmouse *psmouse)
+{
+       unsigned char *packet = psmouse->packet;
+
+       if ((packet[0] & 0x0c) == 0x04 &&
+           (packet[3] & 0x1f) == 0x11)
+               return PACKET_V4_HEAD;
+
+       if ((packet[0] & 0x0c) == 0x04 &&
+           (packet[3] & 0x1f) == 0x12)
+               return PACKET_V4_MOTION;
+
+       if ((packet[0] & 0x0c) == 0x04 &&
+           (packet[3] & 0x1f) == 0x10)
+               return PACKET_V4_STATUS;
+
+       return PACKET_UNKNOWN;
+}
+
 /*
  * Process byte stream from mouse and handle complete packets
  */
@@ -539,7 +705,7 @@ static psmouse_ret_t elantech_process_byte(struct psmouse *psmouse)
                return PSMOUSE_GOOD_DATA;
 
        if (etd->debug > 1)
-               elantech_packet_dump(psmouse->packet, psmouse->pktsize);
+               elantech_packet_dump(psmouse);
 
        switch (etd->hw_version) {
        case 1:
@@ -550,6 +716,10 @@ static psmouse_ret_t elantech_process_byte(struct psmouse *psmouse)
                break;
 
        case 2:
+               /* ignore debounce */
+               if (elantech_debounce_check_v2(psmouse))
+                       return PSMOUSE_FULL_PACKET;
+
                if (etd->paritycheck && !elantech_packet_check_v2(psmouse))
                        return PSMOUSE_BAD_DATA;
 
@@ -567,6 +737,14 @@ static psmouse_ret_t elantech_process_byte(struct psmouse *psmouse)
 
                elantech_report_absolute_v3(psmouse, packet_type);
                break;
+
+       case 4:
+               packet_type = elantech_packet_check_v4(psmouse);
+               if (packet_type == PACKET_UNKNOWN)
+                       return PSMOUSE_BAD_DATA;
+
+               elantech_report_absolute_v4(psmouse, packet_type);
+               break;
        }
 
        return PSMOUSE_FULL_PACKET;
@@ -610,13 +788,20 @@ static int elantech_set_absolute_mode(struct psmouse *psmouse)
                        rc = -1;
 
                break;
+
+       case 4:
+               etd->reg_07 = 0x01;
+               if (elantech_write_reg(psmouse, 0x07, etd->reg_07))
+                       rc = -1;
+
+               goto skip_readback_reg_10; /* v4 has no reg 0x10 to read */
        }
 
        if (rc == 0) {
                /*
                 * Read back reg 0x10. For hardware version 1 we must make
                 * sure the absolute mode bit is set. For hardware version 2
-                * the touchpad is probably initalising and not ready until
+                * the touchpad is probably initializing and not ready until
                 * we read back the value we just wrote.
                 */
                do {
@@ -629,27 +814,31 @@ static int elantech_set_absolute_mode(struct psmouse *psmouse)
                } while (tries > 0);
 
                if (rc) {
-                       pr_err("failed to read back register 0x10.\n");
+                       psmouse_err(psmouse,
+                                   "failed to read back register 0x10.\n");
                } else if (etd->hw_version == 1 &&
                           !(val & ETP_R10_ABSOLUTE_MODE)) {
-                       pr_err("touchpad refuses to switch to absolute mode.\n");
+                       psmouse_err(psmouse,
+                                   "touchpad refuses to switch to absolute mode.\n");
                        rc = -1;
                }
        }
 
+ skip_readback_reg_10:
        if (rc)
-               pr_err("failed to initialise registers.\n");
+               psmouse_err(psmouse, "failed to initialise registers.\n");
 
        return rc;
 }
 
 static int elantech_set_range(struct psmouse *psmouse,
                              unsigned int *x_min, unsigned int *y_min,
-                             unsigned int *x_max, unsigned int *y_max)
+                             unsigned int *x_max, unsigned int *y_max,
+                             unsigned int *width)
 {
        struct elantech_data *etd = psmouse->private;
        unsigned char param[3];
-       int i;
+       unsigned char traces;
 
        switch (etd->hw_version) {
        case 1:
@@ -668,12 +857,33 @@ static int elantech_set_range(struct psmouse *psmouse,
                        *x_max = ETP_XMAX_V2;
                        *y_max = ETP_YMAX_V2;
                } else {
+                       int i;
+                       int fixed_dpi;
+
                        i = (etd->fw_version > 0x020800 &&
                             etd->fw_version < 0x020900) ? 1 : 2;
-                       *x_min = 0;
-                       *y_min = 0;
-                       *x_max = (etd->capabilities[1] - i) * 64;
-                       *y_max = (etd->capabilities[2] - i) * 64;
+
+                       if (synaptics_send_cmd(psmouse, ETP_FW_ID_QUERY, param))
+                               return -1;
+
+                       fixed_dpi = param[1] & 0x10;
+
+                       if (((etd->fw_version >> 16) == 0x14) && fixed_dpi) {
+                               if (synaptics_send_cmd(psmouse, ETP_SAMPLE_QUERY, param))
+                                       return -1;
+
+                               *x_max = (etd->capabilities[1] - i) * param[1] / 2;
+                               *y_max = (etd->capabilities[2] - i) * param[2] / 2;
+                       } else if (etd->fw_version == 0x040216) {
+                               *x_max = 819;
+                               *y_max = 405;
+                       } else if (etd->fw_version == 0x040219 || etd->fw_version == 0x040215) {
+                               *x_max = 900;
+                               *y_max = 500;
+                       } else {
+                               *x_max = (etd->capabilities[1] - i) * 64;
+                               *y_max = (etd->capabilities[2] - i) * 64;
+                       }
                }
                break;
 
@@ -684,6 +894,19 @@ static int elantech_set_range(struct psmouse *psmouse,
                *x_max = (0x0f & param[0]) << 8 | param[1];
                *y_max = (0xf0 & param[0]) << 4 | param[2];
                break;
+
+       case 4:
+               if (synaptics_send_cmd(psmouse, ETP_FW_ID_QUERY, param))
+                       return -1;
+
+               *x_max = (0x0f & param[0]) << 8 | param[1];
+               *y_max = (0xf0 & param[0]) << 4 | param[2];
+               traces = etd->capabilities[1];
+               if ((traces < 2) || (traces > *x_max))
+                       return -1;
+
+               *width = *x_max / (traces - 1);
+               break;
        }
 
        return 0;
@@ -696,9 +919,9 @@ static int elantech_set_input_params(struct psmouse *psmouse)
 {
        struct input_dev *dev = psmouse->dev;
        struct elantech_data *etd = psmouse->private;
-       unsigned int x_min = 0, y_min = 0, x_max = 0, y_max = 0;
+       unsigned int x_min = 0, y_min = 0, x_max = 0, y_max = 0, width = 0;
 
-       if (elantech_set_range(psmouse, &x_min, &y_min, &x_max, &y_max))
+       if (elantech_set_range(psmouse, &x_min, &y_min, &x_max, &y_max, &width))
                return -1;
 
        __set_bit(EV_KEY, dev->evbit);
@@ -742,9 +965,37 @@ static int elantech_set_input_params(struct psmouse *psmouse)
                input_set_abs_params(dev, ABS_MT_POSITION_X, x_min, x_max, 0, 0);
                input_set_abs_params(dev, ABS_MT_POSITION_Y, y_min, y_max, 0, 0);
                break;
+
+       case 4:
+               __set_bit(BTN_TOOL_QUADTAP, dev->keybit);
+               /* For X to recognize me as touchpad. */
+               input_set_abs_params(dev, ABS_X, x_min, x_max, 0, 0);
+               input_set_abs_params(dev, ABS_Y, y_min, y_max, 0, 0);
+               /*
+                * range of pressure and width is the same as v2,
+                * report ABS_PRESSURE, ABS_TOOL_WIDTH for compatibility.
+                */
+               input_set_abs_params(dev, ABS_PRESSURE, ETP_PMIN_V2,
+                                    ETP_PMAX_V2, 0, 0);
+               input_set_abs_params(dev, ABS_TOOL_WIDTH, ETP_WMIN_V2,
+                                    ETP_WMAX_V2, 0, 0);
+               /* Multitouch capable pad, up to 5 fingers. */
+               input_mt_init_slots(dev, ETP_MAX_FINGERS);
+               input_set_abs_params(dev, ABS_MT_POSITION_X, x_min, x_max, 0, 0);
+               input_set_abs_params(dev, ABS_MT_POSITION_Y, y_min, y_max, 0, 0);
+               input_set_abs_params(dev, ABS_MT_PRESSURE, ETP_PMIN_V2,
+                                    ETP_PMAX_V2, 0, 0);
+               /*
+                * The firmware reports how many trace lines the finger spans,
+                * convert to surface unit as Protocol-B requires.
+                */
+               input_set_abs_params(dev, ABS_MT_TOUCH_MAJOR, 0,
+                                    ETP_WMAX_V2 * width, 0, 0);
+               break;
        }
 
        etd->y_max = y_max;
+       etd->width = width;
 
        return 0;
 }
@@ -816,6 +1067,7 @@ static ssize_t elantech_set_int_attr(struct psmouse *psmouse,
                            elantech_show_int_attr,                     \
                            elantech_set_int_attr)
 
+ELANTECH_INT_ATTR(reg_07, 0x07);
 ELANTECH_INT_ATTR(reg_10, 0x10);
 ELANTECH_INT_ATTR(reg_11, 0x11);
 ELANTECH_INT_ATTR(reg_20, 0x20);
@@ -829,6 +1081,7 @@ ELANTECH_INT_ATTR(debug, 0);
 ELANTECH_INT_ATTR(paritycheck, 0);
 
 static struct attribute *elantech_attrs[] = {
+       &psmouse_attr_reg_07.dattr.attr,
        &psmouse_attr_reg_10.dattr.attr,
        &psmouse_attr_reg_11.dattr.attr,
        &psmouse_attr_reg_20.dattr.attr,
@@ -880,7 +1133,7 @@ int elantech_detect(struct psmouse *psmouse, bool set_properties)
            ps2_command(ps2dev,  NULL, PSMOUSE_CMD_SETSCALE11) ||
            ps2_command(ps2dev,  NULL, PSMOUSE_CMD_SETSCALE11) ||
            ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO)) {
-               pr_debug("sending Elantech magic knock failed.\n");
+               psmouse_dbg(psmouse, "sending Elantech magic knock failed.\n");
                return -1;
        }
 
@@ -890,8 +1143,9 @@ int elantech_detect(struct psmouse *psmouse, bool set_properties)
         */
        if (param[0] != 0x3c || param[1] != 0x03 ||
            (param[2] != 0xc8 && param[2] != 0x00)) {
-               pr_debug("unexpected magic knock result 0x%02x, 0x%02x, 0x%02x.\n",
-                        param[0], param[1], param[2]);
+               psmouse_dbg(psmouse,
+                           "unexpected magic knock result 0x%02x, 0x%02x, 0x%02x.\n",
+                           param[0], param[1], param[2]);
                return -1;
        }
 
@@ -901,20 +1155,18 @@ int elantech_detect(struct psmouse *psmouse, bool set_properties)
         * to Elantech magic knock and there might be more.
         */
        if (synaptics_send_cmd(psmouse, ETP_FW_VERSION_QUERY, param)) {
-               pr_debug("failed to query firmware version.\n");
+               psmouse_dbg(psmouse, "failed to query firmware version.\n");
                return -1;
        }
 
-       pr_debug("Elantech version query result 0x%02x, 0x%02x, 0x%02x.\n",
-                param[0], param[1], param[2]);
+       psmouse_dbg(psmouse,
+                   "Elantech version query result 0x%02x, 0x%02x, 0x%02x.\n",
+                   param[0], param[1], param[2]);
 
        if (!elantech_is_signature_valid(param)) {
-               if (!force_elantech) {
-                       pr_debug("Probably not a real Elantech touchpad. Aborting.\n");
-                       return -1;
-               }
-
-               pr_debug("Probably not a real Elantech touchpad. Enabling anyway due to force_elantech.\n");
+               psmouse_dbg(psmouse,
+                           "Probably not a real Elantech touchpad. Aborting.\n");
+               return -1;
        }
 
        if (set_properties) {
@@ -945,7 +1197,8 @@ static int elantech_reconnect(struct psmouse *psmouse)
                return -1;
 
        if (elantech_set_absolute_mode(psmouse)) {
-               pr_err("failed to put touchpad back into absolute mode.\n");
+               psmouse_err(psmouse,
+                           "failed to put touchpad back into absolute mode.\n");
                return -1;
        }
 
@@ -957,12 +1210,16 @@ static int elantech_reconnect(struct psmouse *psmouse)
  */
 static int elantech_set_properties(struct elantech_data *etd)
 {
+       int ver = (etd->fw_version & 0x0f0000) >> 16;
+
        if (etd->fw_version < 0x020030 || etd->fw_version == 0x020600)
                etd->hw_version = 1;
        else if (etd->fw_version < 0x150600)
                etd->hw_version = 2;
-       else if ((etd->fw_version & 0x0f0000) >> 16 == 5)
+       else if (ver == 5)
                etd->hw_version = 3;
+       else if (ver == 6)
+               etd->hw_version = 4;
        else
                return -1;
 
@@ -1011,42 +1268,46 @@ int elantech_init(struct psmouse *psmouse)
         * Do the version query again so we can store the result
         */
        if (synaptics_send_cmd(psmouse, ETP_FW_VERSION_QUERY, param)) {
-               pr_err("failed to query firmware version.\n");
+               psmouse_err(psmouse, "failed to query firmware version.\n");
                goto init_fail;
        }
        etd->fw_version = (param[0] << 16) | (param[1] << 8) | param[2];
 
        if (elantech_set_properties(etd)) {
-               pr_err("unknown hardware version, aborting...\n");
+               psmouse_err(psmouse, "unknown hardware version, aborting...\n");
                goto init_fail;
        }
-       pr_info("assuming hardware version %d "
-               "(with firmware version 0x%02x%02x%02x)\n",
-               etd->hw_version, param[0], param[1], param[2]);
+       psmouse_info(psmouse,
+                    "assuming hardware version %d (with firmware version 0x%02x%02x%02x)\n",
+                    etd->hw_version, param[0], param[1], param[2]);
 
        if (synaptics_send_cmd(psmouse, ETP_CAPABILITIES_QUERY,
            etd->capabilities)) {
-               pr_err("failed to query capabilities.\n");
+               psmouse_err(psmouse, "failed to query capabilities.\n");
                goto init_fail;
        }
-       pr_info("Synaptics capabilities query result 0x%02x, 0x%02x, 0x%02x.\n",
-               etd->capabilities[0], etd->capabilities[1],
-               etd->capabilities[2]);
+       psmouse_info(psmouse,
+                    "Synaptics capabilities query result 0x%02x, 0x%02x, 0x%02x.\n",
+                    etd->capabilities[0], etd->capabilities[1],
+                    etd->capabilities[2]);
 
        if (elantech_set_absolute_mode(psmouse)) {
-               pr_err("failed to put touchpad into absolute mode.\n");
+               psmouse_err(psmouse,
+                           "failed to put touchpad into absolute mode.\n");
                goto init_fail;
        }
 
        if (elantech_set_input_params(psmouse)) {
-               pr_err("failed to query touchpad range.\n");
+               psmouse_err(psmouse, "failed to query touchpad range.\n");
                goto init_fail;
        }
 
        error = sysfs_create_group(&psmouse->ps2dev.serio->dev.kobj,
                                   &elantech_attr_group);
        if (error) {
-               pr_err("failed to create sysfs attributes, error: %d.\n", error);
+               psmouse_err(psmouse,
+                           "failed to create sysfs attributes, error: %d.\n",
+                           error);
                goto init_fail;
        }