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.

Input: raydium_i2c_ts - read device version in bootloader mode

Add support reading device ID when controller is in bootloader mode, which
may happen if firmware update has been interrupted.

Signed-off-by: simba.hsu <simba.hsu@rad-ic.com>
Link: https://lore.kernel.org/r/20210818063644.8654-1-simba.hsu@rad-ic.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

simba.hsu and committed by
Dmitry Torokhov
d5f9c43d 58ae4004

+43 -7
+43 -7
drivers/input/touchscreen/raydium_i2c_ts.c
··· 37 37 #define RM_CMD_BOOT_READ 0x44 /* send wait bl data ready*/ 38 38 39 39 #define RM_BOOT_RDY 0xFF /* bl data ready */ 40 + #define RM_BOOT_CMD_READHWID 0x0E /* read hwid */ 40 41 41 42 /* I2C main commands */ 42 43 #define RM_CMD_QUERY_BANK 0x2B ··· 291 290 return 0; 292 291 } 293 292 293 + static int raydium_i2c_query_ts_bootloader_info(struct raydium_data *ts) 294 + { 295 + struct i2c_client *client = ts->client; 296 + static const u8 get_hwid[] = { RM_BOOT_CMD_READHWID, 297 + 0x10, 0xc0, 0x01, 0x00, 0x04, 0x00 }; 298 + u8 rbuf[5] = { 0 }; 299 + u32 hw_ver; 300 + int error; 301 + 302 + error = raydium_i2c_send(client, RM_CMD_BOOT_WRT, 303 + get_hwid, sizeof(get_hwid)); 304 + if (error) { 305 + dev_err(&client->dev, "WRT HWID command failed: %d\n", error); 306 + return error; 307 + } 308 + 309 + error = raydium_i2c_send(client, RM_CMD_BOOT_ACK, rbuf, 1); 310 + if (error) { 311 + dev_err(&client->dev, "Ack HWID command failed: %d\n", error); 312 + return error; 313 + } 314 + 315 + error = raydium_i2c_read(client, RM_CMD_BOOT_CHK, rbuf, sizeof(rbuf)); 316 + if (error) { 317 + dev_err(&client->dev, "Read HWID command failed: %d (%4ph)\n", 318 + error, rbuf + 1); 319 + hw_ver = 0xffffffffUL; 320 + } else { 321 + hw_ver = get_unaligned_be32(rbuf + 1); 322 + } 323 + 324 + ts->info.hw_ver = cpu_to_le32(hw_ver); 325 + ts->info.main_ver = 0xff; 326 + ts->info.sub_ver = 0xff; 327 + 328 + return error; 329 + } 330 + 294 331 static int raydium_i2c_query_ts_info(struct raydium_data *ts) 295 332 { 296 333 struct i2c_client *client = ts->client; ··· 427 388 if (error) 428 389 ts->boot_mode = RAYDIUM_TS_BLDR; 429 390 430 - if (ts->boot_mode == RAYDIUM_TS_BLDR) { 431 - ts->info.hw_ver = cpu_to_le32(0xffffffffUL); 432 - ts->info.main_ver = 0xff; 433 - ts->info.sub_ver = 0xff; 434 - } else { 391 + if (ts->boot_mode == RAYDIUM_TS_BLDR) 392 + raydium_i2c_query_ts_bootloader_info(ts); 393 + else 435 394 raydium_i2c_query_ts_info(ts); 436 - } 437 395 438 396 return error; 439 397 } ··· 1254 1218 raydium_i2c_suspend, raydium_i2c_resume); 1255 1219 1256 1220 static const struct i2c_device_id raydium_i2c_id[] = { 1257 - { "raydium_i2c" , 0 }, 1221 + { "raydium_i2c", 0 }, 1258 1222 { "rm32380", 0 }, 1259 1223 { /* sentinel */ } 1260 1224 };