diff options
-rw-r--r-- | driver/touchpad_st.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/driver/touchpad_st.c b/driver/touchpad_st.c index b6c20a2a6a..4f7292e445 100644 --- a/driver/touchpad_st.c +++ b/driver/touchpad_st.c @@ -67,6 +67,8 @@ static int tp_control; #define TP_CONTROL_SHALL_RESET (1 << 1) #define TP_CONTROL_SHALL_INITIALIZE (1 << 2) +static int dump_memory_on_error; + /* * Timestamp of last interrupt (32 bits are enough as we divide the value by 100 * and then put it in a 16-bit field). @@ -546,11 +548,13 @@ static void dump_error(void) */ static void dump_memory(void) { -#if 0 uint32_t size = 0x10000, rx_len = 512; uint32_t offset, i; uint8_t cmd[] = {0xFB, 0x00, 0x10, 0x00, 0x00}; + if (!dump_memory_on_error) + return; + for (offset = 0; offset < size; offset += 512) { cmd[3] = (offset >> 8) & 0xFF; cmd[4] = (offset >> 0) & 0xFF; @@ -572,7 +576,6 @@ static void dump_memory(void) } CPRINTF("===============================\n"); msleep(8); -#endif } /* @@ -1492,7 +1495,7 @@ USB_DECLARE_EP(USB_EP_ST_TOUCHPAD_INT, st_tp_interrupt_tx, st_tp_interrupt_tx, /* Debugging commands */ static int command_touchpad_st(int argc, char **argv) { - if (argc != 2) + if (argc < 2) return EC_ERROR_PARAM_COUNT; if (strcasecmp(argv[1], "version") == 0) { st_tp_read_system_info(1); @@ -1523,10 +1526,17 @@ static int command_touchpad_st(int argc, char **argv) dump_memory(); enable_deep_sleep(1); return EC_SUCCESS; + } else if (strcasecmp(argv[1], "memory_dump") == 0) { + if (argc == 3 && !parse_bool(argv[2], &dump_memory_on_error)) + return EC_ERROR_PARAM2; + + ccprintf("memory_dump: %d\n", dump_memory_on_error); + return EC_SUCCESS; } else { return EC_ERROR_PARAM1; } } DECLARE_CONSOLE_COMMAND(touchpad_st, command_touchpad_st, - "<enable|disable|version>", + "<enable | disable | version | calibrate | dump | " + "memory_dump <enable|disable>>", "Read write spi. id is spi_devices array index"); |