Skip to content

Commit 5030b2f

Browse files
committed
Input: synaptics-rmi4 - handle reset delay when using SMBus trsnsport
Touch controllers need some time after receiving reset command for the firmware to finish re-initializing and be ready to respond to commands from the host. The driver already had handling for the post-reset delay for I2C and SPI transports, this change adds the handling to SMBus-connected devices. SMBus devices are peculiar because they implement legacy PS/2 compatibility mode, so reset is actually issued by psmouse driver on the associated serio port, after which the control is passed to the RMI4 driver with SMBus companion device. Note that originally the delay was added to psmouse driver in 92e24e0 ("Input: psmouse - add delay when deactivating for SMBus mode"), but that resulted in an unwanted delay in "fast" reconnect handler for the serio port, so it was decided to revert the patch and have the delay being handled in the RMI4 driver, similar to the other transports. Tested-by: Jeffery Miller <[email protected]> Link: https://lore.kernel.org/r/ZR1yUFJ8a9Zt606N@penguin Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent e2cb5cc commit 5030b2f

File tree

2 files changed

+29
-22
lines changed

2 files changed

+29
-22
lines changed

drivers/input/mouse/synaptics.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1753,6 +1753,7 @@ static int synaptics_create_intertouch(struct psmouse *psmouse,
17531753
psmouse_matches_pnp_id(psmouse, topbuttonpad_pnp_ids) &&
17541754
!SYN_CAP_EXT_BUTTONS_STICK(info->ext_cap_10);
17551755
const struct rmi_device_platform_data pdata = {
1756+
.reset_delay_ms = 30,
17561757
.sensor_pdata = {
17571758
.sensor_type = rmi_sensor_touchpad,
17581759
.axis_align.flip_y = true,

drivers/input/rmi4/rmi_smbus.c

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,29 @@ static void rmi_smb_clear_state(struct rmi_smb_xport *rmi_smb)
235235

236236
static int rmi_smb_enable_smbus_mode(struct rmi_smb_xport *rmi_smb)
237237
{
238-
int retval;
238+
struct i2c_client *client = rmi_smb->client;
239+
int smbus_version;
240+
241+
/*
242+
* psmouse driver resets the controller, we only need to wait
243+
* to give the firmware chance to fully reinitialize.
244+
*/
245+
if (rmi_smb->xport.pdata.reset_delay_ms)
246+
msleep(rmi_smb->xport.pdata.reset_delay_ms);
239247

240248
/* we need to get the smbus version to activate the touchpad */
241-
retval = rmi_smb_get_version(rmi_smb);
242-
if (retval < 0)
243-
return retval;
249+
smbus_version = rmi_smb_get_version(rmi_smb);
250+
if (smbus_version < 0)
251+
return smbus_version;
252+
253+
rmi_dbg(RMI_DEBUG_XPORT, &client->dev, "Smbus version is %d",
254+
smbus_version);
255+
256+
if (smbus_version != 2 && smbus_version != 3) {
257+
dev_err(&client->dev, "Unrecognized SMB version %d\n",
258+
smbus_version);
259+
return -ENODEV;
260+
}
244261

245262
return 0;
246263
}
@@ -253,11 +270,10 @@ static int rmi_smb_reset(struct rmi_transport_dev *xport, u16 reset_addr)
253270
rmi_smb_clear_state(rmi_smb);
254271

255272
/*
256-
* we do not call the actual reset command, it has to be handled in
257-
* PS/2 or there will be races between PS/2 and SMBus.
258-
* PS/2 should ensure that a psmouse_reset is called before
259-
* intializing the device and after it has been removed to be in a known
260-
* state.
273+
* We do not call the actual reset command, it has to be handled in
274+
* PS/2 or there will be races between PS/2 and SMBus. PS/2 should
275+
* ensure that a psmouse_reset is called before initializing the
276+
* device and after it has been removed to be in a known state.
261277
*/
262278
return rmi_smb_enable_smbus_mode(rmi_smb);
263279
}
@@ -272,7 +288,6 @@ static int rmi_smb_probe(struct i2c_client *client)
272288
{
273289
struct rmi_device_platform_data *pdata = dev_get_platdata(&client->dev);
274290
struct rmi_smb_xport *rmi_smb;
275-
int smbus_version;
276291
int error;
277292

278293
if (!pdata) {
@@ -311,18 +326,9 @@ static int rmi_smb_probe(struct i2c_client *client)
311326
rmi_smb->xport.proto_name = "smb";
312327
rmi_smb->xport.ops = &rmi_smb_ops;
313328

314-
smbus_version = rmi_smb_get_version(rmi_smb);
315-
if (smbus_version < 0)
316-
return smbus_version;
317-
318-
rmi_dbg(RMI_DEBUG_XPORT, &client->dev, "Smbus version is %d",
319-
smbus_version);
320-
321-
if (smbus_version != 2 && smbus_version != 3) {
322-
dev_err(&client->dev, "Unrecognized SMB version %d\n",
323-
smbus_version);
324-
return -ENODEV;
325-
}
329+
error = rmi_smb_enable_smbus_mode(rmi_smb);
330+
if (error)
331+
return error;
326332

327333
i2c_set_clientdata(client, rmi_smb);
328334

0 commit comments

Comments
 (0)