Merge tag 'v4.11-rc5' into next
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 3 Apr 2017 19:01:20 +0000 (12:01 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 3 Apr 2017 19:01:20 +0000 (12:01 -0700)
Sync up with mainline to bring in changes to input subsystem merged
through other trees.

1  2 
drivers/input/mouse/alps.c
drivers/input/mouse/alps.h
include/linux/mfd/cros_ec_commands.h

@@@ -106,36 -106,39 +106,36 @@@ static const struct alps_nibble_command
  #define ALPS_DUALPOINT_WITH_PRESSURE  0x400   /* device can report trackpoint pressure */
  
  static const struct alps_model_info alps_model_data[] = {
 -      { { 0x32, 0x02, 0x14 }, 0x00, { ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT } },      /* Toshiba Salellite Pro M10 */
 -      { { 0x33, 0x02, 0x0a }, 0x00, { ALPS_PROTO_V1, 0x88, 0xf8, 0 } },                               /* UMAX-530T */
 -      { { 0x53, 0x02, 0x0a }, 0x00, { ALPS_PROTO_V2, 0xf8, 0xf8, 0 } },
 -      { { 0x53, 0x02, 0x14 }, 0x00, { ALPS_PROTO_V2, 0xf8, 0xf8, 0 } },
 -      { { 0x60, 0x03, 0xc8 }, 0x00, { ALPS_PROTO_V2, 0xf8, 0xf8, 0 } },                               /* HP ze1115 */
 -      { { 0x63, 0x02, 0x0a }, 0x00, { ALPS_PROTO_V2, 0xf8, 0xf8, 0 } },
 -      { { 0x63, 0x02, 0x14 }, 0x00, { ALPS_PROTO_V2, 0xf8, 0xf8, 0 } },
 -      { { 0x63, 0x02, 0x28 }, 0x00, { ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_FW_BK_2 } },            /* Fujitsu Siemens S6010 */
 -      { { 0x63, 0x02, 0x3c }, 0x00, { ALPS_PROTO_V2, 0x8f, 0x8f, ALPS_WHEEL } },              /* Toshiba Satellite S2400-103 */
 -      { { 0x63, 0x02, 0x50 }, 0x00, { ALPS_PROTO_V2, 0xef, 0xef, ALPS_FW_BK_1 } },            /* NEC Versa L320 */
 -      { { 0x63, 0x02, 0x64 }, 0x00, { ALPS_PROTO_V2, 0xf8, 0xf8, 0 } },
 -      { { 0x63, 0x03, 0xc8 }, 0x00, { ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT } },      /* Dell Latitude D800 */
 -      { { 0x73, 0x00, 0x0a }, 0x00, { ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_DUALPOINT } },          /* ThinkPad R61 8918-5QG */
 -      { { 0x73, 0x02, 0x0a }, 0x00, { ALPS_PROTO_V2, 0xf8, 0xf8, 0 } },
 -      { { 0x73, 0x02, 0x14 }, 0x00, { ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_FW_BK_2 } },            /* Ahtec Laptop */
 -
        /*
         * XXX This entry is suspicious. First byte has zero lower nibble,
         * which is what a normal mouse would report. Also, the value 0x0e
         * isn't valid per PS/2 spec.
         */
 -      { { 0x20, 0x02, 0x0e }, 0x00, { ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT } },
 -
 -      { { 0x22, 0x02, 0x0a }, 0x00, { ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT } },
 -      { { 0x22, 0x02, 0x14 }, 0x00, { ALPS_PROTO_V2, 0xff, 0xff, ALPS_PASS | ALPS_DUALPOINT } },      /* Dell Latitude D600 */
 -      /* Dell Latitude E5500, E6400, E6500, Precision M4400 */
 -      { { 0x62, 0x02, 0x14 }, 0x00, { ALPS_PROTO_V2, 0xcf, 0xcf,
 -              ALPS_PASS | ALPS_DUALPOINT | ALPS_PS2_INTERLEAVED } },
 -      { { 0x73, 0x00, 0x14 }, 0x00, { ALPS_PROTO_V6, 0xff, 0xff, ALPS_DUALPOINT } },          /* Dell XT2 */
 -      { { 0x73, 0x02, 0x50 }, 0x00, { ALPS_PROTO_V2, 0xcf, 0xcf, ALPS_FOUR_BUTTONS } },       /* Dell Vostro 1400 */
 -      { { 0x52, 0x01, 0x14 }, 0x00, { ALPS_PROTO_V2, 0xff, 0xff,
 +      { { 0x20, 0x02, 0x0e }, { ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT } },
 +
 +      { { 0x22, 0x02, 0x0a }, { ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT } },
 +      { { 0x22, 0x02, 0x14 }, { ALPS_PROTO_V2, 0xff, 0xff, ALPS_PASS | ALPS_DUALPOINT } },    /* Dell Latitude D600 */
 +      { { 0x32, 0x02, 0x14 }, { ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT } },    /* Toshiba Salellite Pro M10 */
 +      { { 0x33, 0x02, 0x0a }, { ALPS_PROTO_V1, 0x88, 0xf8, 0 } },                             /* UMAX-530T */
 +      { { 0x52, 0x01, 0x14 }, { ALPS_PROTO_V2, 0xff, 0xff,
                ALPS_PASS | ALPS_DUALPOINT | ALPS_PS2_INTERLEAVED } },                          /* Toshiba Tecra A11-11L */
 -      { { 0x73, 0x02, 0x64 }, 0x8a, { ALPS_PROTO_V4, 0x8f, 0x8f, 0 } },
 +      { { 0x53, 0x02, 0x0a }, { ALPS_PROTO_V2, 0xf8, 0xf8, 0 } },
 +      { { 0x53, 0x02, 0x14 }, { ALPS_PROTO_V2, 0xf8, 0xf8, 0 } },
 +      { { 0x60, 0x03, 0xc8 }, { ALPS_PROTO_V2, 0xf8, 0xf8, 0 } },                             /* HP ze1115 */
 +      { { 0x62, 0x02, 0x14 }, { ALPS_PROTO_V2, 0xcf, 0xcf,
 +              ALPS_PASS | ALPS_DUALPOINT | ALPS_PS2_INTERLEAVED } },                          /* Dell Latitude E5500, E6400, E6500, Precision M4400 */
 +      { { 0x63, 0x02, 0x0a }, { ALPS_PROTO_V2, 0xf8, 0xf8, 0 } },
 +      { { 0x63, 0x02, 0x14 }, { ALPS_PROTO_V2, 0xf8, 0xf8, 0 } },
 +      { { 0x63, 0x02, 0x28 }, { ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_FW_BK_2 } },                  /* Fujitsu Siemens S6010 */
 +      { { 0x63, 0x02, 0x3c }, { ALPS_PROTO_V2, 0x8f, 0x8f, ALPS_WHEEL } },                    /* Toshiba Satellite S2400-103 */
 +      { { 0x63, 0x02, 0x50 }, { ALPS_PROTO_V2, 0xef, 0xef, ALPS_FW_BK_1 } },                  /* NEC Versa L320 */
 +      { { 0x63, 0x02, 0x64 }, { ALPS_PROTO_V2, 0xf8, 0xf8, 0 } },
 +      { { 0x63, 0x03, 0xc8 }, { ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT } },    /* Dell Latitude D800 */
 +      { { 0x73, 0x00, 0x0a }, { ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_DUALPOINT } },                /* ThinkPad R61 8918-5QG */
 +      { { 0x73, 0x00, 0x14 }, { ALPS_PROTO_V6, 0xff, 0xff, ALPS_DUALPOINT } },                /* Dell XT2 */
 +      { { 0x73, 0x02, 0x0a }, { ALPS_PROTO_V2, 0xf8, 0xf8, 0 } },
 +      { { 0x73, 0x02, 0x14 }, { ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_FW_BK_2 } },                  /* Ahtec Laptop */
 +      { { 0x73, 0x02, 0x50 }, { ALPS_PROTO_V2, 0xcf, 0xcf, ALPS_FOUR_BUTTONS } },             /* Dell Vostro 1400 */
  };
  
  static const struct alps_protocol_info alps_v3_protocol_data = {
@@@ -146,10 -149,6 +146,10 @@@ static const struct alps_protocol_info 
        ALPS_PROTO_V3_RUSHMORE, 0x8f, 0x8f, ALPS_DUALPOINT
  };
  
 +static const struct alps_protocol_info alps_v4_protocol_data = {
 +      ALPS_PROTO_V4, 0x8f, 0x8f, 0
 +};
 +
  static const struct alps_protocol_info alps_v5_protocol_data = {
        ALPS_PROTO_V5, 0xc8, 0xd8, 0
  };
@@@ -162,10 -161,6 +162,10 @@@ static const struct alps_protocol_info 
        ALPS_PROTO_V8, 0x18, 0x18, 0
  };
  
 +static const struct alps_protocol_info alps_v9_protocol_data = {
 +      ALPS_PROTO_V9, 0xc8, 0xc8, 0
 +};
 +
  /*
   * Some v2 models report the stick buttons in separate bits
   */
@@@ -1287,10 -1282,8 +1287,8 @@@ static int alps_decode_ss4_v2(struct al
        /* handle buttons */
        if (pkt_id == SS4_PACKET_ID_STICK) {
                f->ts_left = !!(SS4_BTN_V2(p) & 0x01);
-               if (!(priv->flags & ALPS_BUTTONPAD)) {
-                       f->ts_right = !!(SS4_BTN_V2(p) & 0x02);
-                       f->ts_middle = !!(SS4_BTN_V2(p) & 0x04);
-               }
+               f->ts_right = !!(SS4_BTN_V2(p) & 0x02);
+               f->ts_middle = !!(SS4_BTN_V2(p) & 0x04);
        } else {
                f->left = !!(SS4_BTN_V2(p) & 0x01);
                if (!(priv->flags & ALPS_BUTTONPAD)) {
@@@ -2467,14 -2460,34 +2465,34 @@@ static int alps_update_device_area_ss4_
        int num_y_electrode;
        int x_pitch, y_pitch, x_phys, y_phys;
  
-       num_x_electrode = SS4_NUMSENSOR_XOFFSET + (otp[1][0] & 0x0F);
-       num_y_electrode = SS4_NUMSENSOR_YOFFSET + ((otp[1][0] >> 4) & 0x0F);
+       if (IS_SS4PLUS_DEV(priv->dev_id)) {
+               num_x_electrode =
+                       SS4PLUS_NUMSENSOR_XOFFSET + (otp[0][2] & 0x0F);
+               num_y_electrode =
+                       SS4PLUS_NUMSENSOR_YOFFSET + ((otp[0][2] >> 4) & 0x0F);
+               priv->x_max =
+                       (num_x_electrode - 1) * SS4PLUS_COUNT_PER_ELECTRODE;
+               priv->y_max =
+                       (num_y_electrode - 1) * SS4PLUS_COUNT_PER_ELECTRODE;
  
-       priv->x_max = (num_x_electrode - 1) * SS4_COUNT_PER_ELECTRODE;
-       priv->y_max = (num_y_electrode - 1) * SS4_COUNT_PER_ELECTRODE;
+               x_pitch = (otp[0][1] & 0x0F) + SS4PLUS_MIN_PITCH_MM;
+               y_pitch = ((otp[0][1] >> 4) & 0x0F) + SS4PLUS_MIN_PITCH_MM;
  
-       x_pitch = ((otp[1][2] >> 2) & 0x07) + SS4_MIN_PITCH_MM;
-       y_pitch = ((otp[1][2] >> 5) & 0x07) + SS4_MIN_PITCH_MM;
+       } else {
+               num_x_electrode =
+                       SS4_NUMSENSOR_XOFFSET + (otp[1][0] & 0x0F);
+               num_y_electrode =
+                       SS4_NUMSENSOR_YOFFSET + ((otp[1][0] >> 4) & 0x0F);
+               priv->x_max =
+                       (num_x_electrode - 1) * SS4_COUNT_PER_ELECTRODE;
+               priv->y_max =
+                       (num_y_electrode - 1) * SS4_COUNT_PER_ELECTRODE;
+               x_pitch = ((otp[1][2] >> 2) & 0x07) + SS4_MIN_PITCH_MM;
+               y_pitch = ((otp[1][2] >> 5) & 0x07) + SS4_MIN_PITCH_MM;
+       }
  
        x_phys = x_pitch * (num_x_electrode - 1); /* In 0.1 mm units */
        y_phys = y_pitch * (num_y_electrode - 1); /* In 0.1 mm units */
@@@ -2490,7 -2503,10 +2508,10 @@@ static int alps_update_btn_info_ss4_v2(
  {
        unsigned char is_btnless;
  
-       is_btnless = (otp[1][1] >> 3) & 0x01;
+       if (IS_SS4PLUS_DEV(priv->dev_id))
+               is_btnless = (otp[1][0] >> 1) & 0x01;
+       else
+               is_btnless = (otp[1][1] >> 3) & 0x01;
  
        if (is_btnless)
                priv->flags |= ALPS_BUTTONPAD;
        return 0;
  }
  
+ static int alps_update_dual_info_ss4_v2(unsigned char otp[][4],
+                                      struct alps_data *priv)
+ {
+       bool is_dual = false;
+       if (IS_SS4PLUS_DEV(priv->dev_id))
+               is_dual = (otp[0][0] >> 4) & 0x01;
+       if (is_dual)
+               priv->flags |= ALPS_DUALPOINT |
+                                       ALPS_DUALPOINT_WITH_PRESSURE;
+       return 0;
+ }
  static int alps_set_defaults_ss4_v2(struct psmouse *psmouse,
                                    struct alps_data *priv)
  {
  
        alps_update_btn_info_ss4_v2(otp, priv);
  
+       alps_update_dual_info_ss4_v2(otp, priv);
        return 0;
  }
  
@@@ -2758,10 -2791,6 +2796,6 @@@ static int alps_set_protocol(struct psm
                if (alps_set_defaults_ss4_v2(psmouse, priv))
                        return -EIO;
  
-               if (priv->fw_ver[1] == 0x1)
-                       priv->flags |= ALPS_DUALPOINT |
-                                       ALPS_DUALPOINT_WITH_PRESSURE;
                break;
        }
  
@@@ -2777,8 -2806,12 +2811,8 @@@ static const struct alps_protocol_info 
        for (i = 0; i < ARRAY_SIZE(alps_model_data); i++) {
                model = &alps_model_data[i];
  
 -              if (!memcmp(e7, model->signature, sizeof(model->signature)) &&
 -                  (!model->command_mode_resp ||
 -                   model->command_mode_resp == ec[2])) {
 -
 +              if (!memcmp(e7, model->signature, sizeof(model->signature)))
                        return &model->protocol_info;
 -              }
        }
  
        return NULL;
@@@ -2816,10 -2849,7 +2850,10 @@@ static int alps_identify(struct psmous
  
        protocol = alps_match_table(e7, ec);
        if (!protocol) {
 -              if (e7[0] == 0x73 && e7[1] == 0x03 && e7[2] == 0x50 &&
 +              if (e7[0] == 0x73 && e7[1] == 0x02 && e7[2] == 0x64 &&
 +                         ec[2] == 0x8a) {
 +                      protocol = &alps_v4_protocol_data;
 +              } else if (e7[0] == 0x73 && e7[1] == 0x03 && e7[2] == 0x50 &&
                           ec[0] == 0x73 && (ec[1] == 0x01 || ec[1] == 0x02)) {
                        protocol = &alps_v5_protocol_data;
                } else if (ec[0] == 0x88 &&
                           ec[2] >= 0x90 && ec[2] <= 0x9d) {
                        protocol = &alps_v3_protocol_data;
                } else if (e7[0] == 0x73 && e7[1] == 0x03 &&
-                          e7[2] == 0x14 && ec[1] == 0x02) {
-                       protocol = &alps_v8_protocol_data;
-               } else if (e7[0] == 0x73 && e7[1] == 0x03 &&
-                          e7[2] == 0x28 && ec[1] == 0x01) {
+                          (e7[2] == 0x14 || e7[2] == 0x28)) {
                        protocol = &alps_v8_protocol_data;
 +              } else if (e7[0] == 0x73 && e7[1] == 0x03 && e7[2] == 0xc8) {
 +                      protocol = &alps_v9_protocol_data;
 +                      psmouse_warn(psmouse,
 +                                   "Unsupported ALPS V9 touchpad: E7=%3ph, EC=%3ph\n",
 +                                   e7, ec);
 +                      return -EINVAL;
                } else {
                        psmouse_dbg(psmouse,
                                    "Likely not an ALPS touchpad: E7=%3ph, EC=%3ph\n", e7, ec);
        }
  
        if (priv) {
-               /* Save the Firmware version */
+               /* Save Device ID and Firmware version */
+               memcpy(priv->dev_id, e7, 3);
                memcpy(priv->fw_ver, ec, 3);
                error = alps_set_protocol(psmouse, priv, protocol);
                if (error)
@@@ -23,7 -23,6 +23,7 @@@
  #define ALPS_PROTO_V6         0x600
  #define ALPS_PROTO_V7         0x700   /* t3btl t4s */
  #define ALPS_PROTO_V8         0x800   /* SS4btl SS4s */
 +#define ALPS_PROTO_V9         0x900   /* ss3btl */
  
  #define MAX_TOUCHES   4
  
@@@ -55,6 -54,16 +55,16 @@@ enum SS4_PACKET_ID 
  
  #define SS4_MASK_NORMAL_BUTTONS               0x07
  
+ #define SS4PLUS_COUNT_PER_ELECTRODE   128
+ #define SS4PLUS_NUMSENSOR_XOFFSET     16
+ #define SS4PLUS_NUMSENSOR_YOFFSET     5
+ #define SS4PLUS_MIN_PITCH_MM          37
+ #define IS_SS4PLUS_DEV(_b)    (((_b[0]) == 0x73) &&   \
+                                ((_b[1]) == 0x03) &&   \
+                                ((_b[2]) == 0x28)              \
+                               )
  #define SS4_IS_IDLE_V2(_b)    (((_b[0]) == 0x18) &&           \
                                 ((_b[1]) == 0x10) &&           \
                                 ((_b[2]) == 0x00) &&           \
@@@ -163,6 -172,10 +173,6 @@@ struct alps_protocol_info 
  /**
   * struct alps_model_info - touchpad ID table
   * @signature: E7 response string to match.
 - * @command_mode_resp: For V3/V4 touchpads, the final byte of the EC response
 - *   (aka command mode response) identifies the firmware minor version.  This
 - *   can be used to distinguish different hardware models which are not
 - *   uniquely identifiable through their E7 responses.
   * @protocol_info: information about protocol used by the device.
   *
   * Many (but not all) ALPS touchpads can be identified by looking at the
   */
  struct alps_model_info {
        u8 signature[3];
 -      u8 command_mode_resp;
        struct alps_protocol_info protocol_info;
  };
  
@@@ -279,6 -293,7 +289,7 @@@ struct alps_data 
        int addr_command;
        u16 proto_version;
        u8 byte0, mask0;
+       u8 dev_id[3];
        u8 fw_ver[3];
        int flags;
        int x_max;
@@@ -1441,7 -1441,8 +1441,8 @@@ enum motionsensor_type 
        MOTIONSENSE_TYPE_PROX = 3,
        MOTIONSENSE_TYPE_LIGHT = 4,
        MOTIONSENSE_TYPE_ACTIVITY = 5,
-       MOTIONSENSE_TYPE_MAX
+       MOTIONSENSE_TYPE_BARO = 6,
+       MOTIONSENSE_TYPE_MAX,
  };
  
  /* List of motion sensor locations. */
@@@ -2040,9 -2041,6 +2041,9 @@@ enum ec_mkbp_event 
        /* The state of the switches have changed. */
        EC_MKBP_EVENT_SWITCH = 4,
  
 +      /* EC sent a sysrq command */
 +      EC_MKBP_EVENT_SYSRQ = 6,
 +
        /* Number of MKBP events */
        EC_MKBP_EVENT_COUNT,
  };
@@@ -2055,7 -2053,6 +2056,7 @@@ union ec_response_get_next_data 
  
        uint32_t   buttons;
        uint32_t   switches;
 +      uint32_t   sysrq;
  } __packed;
  
  struct ec_response_get_next_event {
@@@ -2551,6 -2548,20 +2552,20 @@@ struct ec_params_ext_power_current_limi
        uint32_t limit; /* in mA */
  } __packed;
  
+ /* Inform the EC when entering a sleep state */
+ #define EC_CMD_HOST_SLEEP_EVENT 0xa9
+ enum host_sleep_event {
+       HOST_SLEEP_EVENT_S3_SUSPEND   = 1,
+       HOST_SLEEP_EVENT_S3_RESUME    = 2,
+       HOST_SLEEP_EVENT_S0IX_SUSPEND = 3,
+       HOST_SLEEP_EVENT_S0IX_RESUME  = 4
+ };
+ struct ec_params_host_sleep_event {
+       uint8_t sleep_event;
+ } __packed;
  /*****************************************************************************/
  /* Smart battery pass-through */