diff --git a/drivers/hid/spi-hid/spi-hid-core.c b/drivers/hid/spi-hid/spi-hid-core.c
index ef5fb11f23..901c8d9ace 100644
--- a/drivers/hid/spi-hid/spi-hid-core.c
+++ b/drivers/hid/spi-hid/spi-hid-core.c
@@ -280,8 +280,8 @@ static const char *spi_hid_power_mode_string(enum hidspi_power_state power_state
/*
* Wait for the device descriptor response after reset; the device then takes
- * requests. Set READY here: the report descriptor check that normally sets it
- * needs power_lock, which callers hold.
+ * requests. Set READY here for devices that reuse their HID instance. Devices
+ * that rebind after reset become ready when the new HID instance is parsed.
*/
static int spi_hid_wait_for_reset(struct spi_hid *shid)
{@@ -294,7 +294,8 @@ static int spi_hid_wait_for_reset(struct spi_hid *shid)
return -ETIMEDOUT;
}
- set_bit(SPI_HID_READY, &shid->flags);
+ if (!shid->conf->rebind_after_reset)
+ set_bit(SPI_HID_READY, &shid->flags);
return 0;
}
@@ -422,6 +423,9 @@ static int spi_hid_resume(struct spi_hid *shid)
schedule_work(&shid->reset_work);
return -ETIMEDOUT;
}
+ /* Refresh recreates the HID device after a successful handshake. */
+ if (was_reset && shid->conf->rebind_after_reset)
+ return 0;
/* HID requests would fail while the device is not ready. */
if (!test_bit(SPI_HID_READY, &shid->flags))
return 0;
@@ -910,8 +914,9 @@ static void spi_hid_refresh_device(struct spi_hid *shid)
(size_t)error);
}
- /* Same report descriptor, so no need to create a new hid device. */
- if (new_crc32 == shid->report_descriptor_crc32) {
+ /* Some devices lose userspace-selected modes even with the same CRC. */
+ if (new_crc32 == shid->report_descriptor_crc32 &&
+ !shid->conf->rebind_after_reset) {
shid->reset_attempts = 0;
set_bit(SPI_HID_READY, &shid->flags);
return;diff --git a/drivers/hid/spi-hid/spi-hid-of.c b/drivers/hid/spi-hid/spi-hid-of.c
index 5148b6b1dd..7d3ce1fd89 100644
--- a/drivers/hid/spi-hid/spi-hid-of.c
+++ b/drivers/hid/spi-hid/spi-hid-of.c
@@ -62,6 +62,19 @@ static const struct spi_hid_of_data microsoft_g6_data = {
.minimal_reset_delay_ms = 100,
};
+static const struct spi_hid_of_data romulus13_data = {
+ .conf = {
+ .input_report_header_address = 0x1000,
+ .input_report_body_address = 0x1004,
+ .output_report_address = 0x2000,
+ .read_opcode = 0xeb,
+ .write_opcode = 0xe2,
+ .rebind_after_reset = true,
+ },
+ .post_power_on_delay_ms = 1000,
+ .minimal_reset_delay_ms = 300,
+};
+
static int spi_hid_of_populate_config(struct spi_hid_of_config *conf,
struct device *dev)
{@@ -176,12 +189,14 @@ static int spi_hid_of_probe(struct spi_mem *mem)
}
static const struct of_device_id spi_hid_of_match[] = {
+ { .compatible = "microsoft,romulus13-touchpad", .data = &romulus13_data },
{ .compatible = "microsoft,g6-touch-digitizer", .data = µsoft_g6_data },
{ }
};
MODULE_DEVICE_TABLE(of, spi_hid_of_match);
static const struct spi_device_id spi_hid_of_id_table[] = {
+ { .name = "romulus13-touchpad", .driver_data = (kernel_ulong_t)&romulus13_data },
{ .name = "g6-touch-digitizer", .driver_data = (kernel_ulong_t)µsoft_g6_data },
{ }
};diff --git a/drivers/hid/spi-hid/spi-hid.h b/drivers/hid/spi-hid/spi-hid.h
index e87d1cf05e..2b2f62c837 100644
--- a/drivers/hid/spi-hid/spi-hid.h
+++ b/drivers/hid/spi-hid/spi-hid.h
@@ -17,6 +17,8 @@ struct spi_hid_conf {
u32 output_report_address;
u8 read_opcode;
u8 write_opcode;
+ /* Reconnect hidraw clients when reset loses device-specific state. */
+ bool rebind_after_reset;
};
/**