Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

USB: typec: tsp6598x: Add cmd timeout and response delay

Some commands in tps25750 take longer than 1 second
to complete, and some responses need some delay before
the result becomes available.

Signed-off-by: Abdel Alkuor <abdelalkuor@geotab.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20231003155842.57313-3-alkuor@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Abdel Alkuor and committed by
Greg Kroah-Hartman
6ab6ad09 6060d554

+15 -4
+15 -4
drivers/usb/typec/tipd/core.c
··· 282 282 power_supply_changed(tps->psy); 283 283 } 284 284 285 - static int tps6598x_exec_cmd(struct tps6598x *tps, const char *cmd, 285 + static int tps6598x_exec_cmd_tmo(struct tps6598x *tps, const char *cmd, 286 286 size_t in_len, u8 *in_data, 287 - size_t out_len, u8 *out_data) 287 + size_t out_len, u8 *out_data, 288 + u32 cmd_timeout_ms, u32 res_delay_ms) 288 289 { 289 290 unsigned long timeout; 290 291 u32 val; ··· 308 307 if (ret < 0) 309 308 return ret; 310 309 311 - /* XXX: Using 1s for now, but it may not be enough for every command. */ 312 - timeout = jiffies + msecs_to_jiffies(1000); 310 + timeout = jiffies + msecs_to_jiffies(cmd_timeout_ms); 313 311 314 312 do { 315 313 ret = tps6598x_read32(tps, TPS_REG_CMD1, &val); ··· 320 320 if (time_is_before_jiffies(timeout)) 321 321 return -ETIMEDOUT; 322 322 } while (val); 323 + 324 + /* some commands require delay for the result to be available */ 325 + mdelay(res_delay_ms); 323 326 324 327 if (out_len) { 325 328 ret = tps6598x_block_read(tps, TPS_REG_DATA1, ··· 346 343 } 347 344 348 345 return 0; 346 + } 347 + 348 + static int tps6598x_exec_cmd(struct tps6598x *tps, const char *cmd, 349 + size_t in_len, u8 *in_data, 350 + size_t out_len, u8 *out_data) 351 + { 352 + return tps6598x_exec_cmd_tmo(tps, cmd, in_len, in_data, 353 + out_len, out_data, 1000, 0); 349 354 } 350 355 351 356 static int tps6598x_dr_set(struct typec_port *port, enum typec_data_role role)