Skip to content

Commit 30216a3

Browse files
committed
fix ps2m not work on boot
If the touchpad is touched during early boot, sometimes the ec i2c controller can get stuck and needs to be kicked to restart communication with the touchpad. This fixes the issue that touchpad does not work in windows installer if the user touches it during the boot process Signed-off-by: Kieran Levin <[email protected]>
1 parent ac24e5a commit 30216a3

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

board/hx20/ps2mouse.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,9 @@ void read_touchpad_in_report(void)
329329
int xfer_len = 0;
330330
int16_t x, y;
331331
uint8_t response_byte = 0x08;
332+
333+
/* Make sure report id is set to an invalid value */
334+
data[2] = 0;
332335
/*dont trigger disable state during our own transactions*/
333336
gpio_disable_interrupt(GPIO_EC_I2C_3_SDA);
334337
i2c_lock(I2C_PORT_TOUCHPAD, 1);
@@ -338,6 +341,11 @@ void read_touchpad_in_report(void)
338341
if (rv != EC_SUCCESS)
339342
goto read_failed;
340343
xfer_len = (data[1]<<8) + data[0];
344+
if (xfer_len == 0) {
345+
/* touchpad has reset per i2c-hid-protocol 7.3 */
346+
CPRINTS("PS2M Touchpad Reset");
347+
goto read_failed;
348+
}
341349
xfer_len = MIN(126, xfer_len-2);
342350
rv = i2c_xfer_unlocked(I2C_PORT_TOUCHPAD,
343351
TOUCHPAD_I2C_HID_EP | I2C_FLAG_ADDR16_LITTLE_ENDIAN,
@@ -354,6 +362,10 @@ void read_touchpad_in_report(void)
354362
/* try again some other time later if the TP keeps interrupting us */
355363
detected_host_packet = true;
356364
inreport_retries = 0;
365+
MCHP_I2C_CTRL(MCHP_I2C_CTRL4) = BIT(7) |
366+
BIT(6) |
367+
BIT(3) |
368+
BIT(0);
357369
CPRINTS("PS2M Too many retries");
358370
} else {
359371
hook_call_deferred(&retry_tp_read_evt_deferred_data, 25*MSEC);

0 commit comments

Comments
 (0)