From 2b4c13f25254014c0098a83a7f5bcd4880f5bd62 Mon Sep 17 00:00:00 2001 From: Gaggery Tsai Date: Tue, 19 Apr 2022 22:40:24 -0700 Subject: retimer: Fix bb to support 32-bits write This patch fixes bb command to support 32-bits negative number (int) write. For a 32-bits i2c write, it doesn't need to judge the strtol is negative or positive number or even a zero. BUG=None BRANCH=None TEST=run $bb 3 w 7 0xd0000022 to force burnside bridge entering USB3 compliance mode and check $bb 3 r 7 to ensure the value is written. Signed-off-by: Gaggery Tsai Change-Id: Ib58ca89cf62a527b19f8e708462250f54beb5861 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3595286 Reviewed-by: Daisuke Nojiri Reviewed-by: Li1 Feng Tested-by: Vijay P Hiremath Reviewed-by: Brandon Breitenstein --- driver/retimer/bb_retimer.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'driver') diff --git a/driver/retimer/bb_retimer.c b/driver/retimer/bb_retimer.c index 88eb4835fc..cd18a7a6ef 100644 --- a/driver/retimer/bb_retimer.c +++ b/driver/retimer/bb_retimer.c @@ -676,7 +676,9 @@ const struct usb_mux_driver bb_usb_retimer = { static int console_command_bb_retimer(int argc, const char **argv) { char rw, *e; - int port, reg, data, val = 0; + int port; + uint8_t reg; + uint32_t data, val = 0; int rv = EC_SUCCESS; const struct usb_mux *mux; const struct usb_mux_chain *mux_chain; @@ -706,14 +708,14 @@ static int console_command_bb_retimer(int argc, const char **argv) return EC_ERROR_PARAM2; /* Get register address */ - reg = strtoi(argv[3], &e, 0); - if (*e || reg < 0) + reg = (uint8_t)strtoull(argv[3], &e, 0); + if (*e) return EC_ERROR_PARAM3; /* Get value to be written */ if (rw == 'w') { - val = strtoi(argv[4], &e, 0); - if (*e || val < 0) + val = strtoull(argv[4], &e, 0); + if (*e) return EC_ERROR_PARAM4; } @@ -738,7 +740,9 @@ static int console_command_bb_retimer(int argc, const char **argv) return rv; } +/* TODO(b/278138274): Use common console command for all Retimers */ DECLARE_CONSOLE_COMMAND(bb, console_command_bb_retimer, - " | ", + " r " + "\n w ", "Read or write to BB retimer register"); #endif /* CONFIG_CMD_RETIMER */ -- cgit v1.2.1