summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGaggery Tsai <gaggery.tsai@intel.com>2022-04-19 22:40:24 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-04-14 20:41:00 +0000
commit2b4c13f25254014c0098a83a7f5bcd4880f5bd62 (patch)
tree24c7c309e1f896c05b75282b5ab6786e1fce59eb
parent1366a27d9bfe4ee31899403f5d2aa82eeb81d0bc (diff)
downloadchrome-ec-2b4c13f25254014c0098a83a7f5bcd4880f5bd62.tar.gz
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 <gaggery.tsai@intel.com> Change-Id: Ib58ca89cf62a527b19f8e708462250f54beb5861 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3595286 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Li1 Feng <li1.feng@intel.com> Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Brandon Breitenstein <brandon.breitenstein@intel.corp-partner.google.com>
-rw-r--r--driver/retimer/bb_retimer.c16
1 files changed, 10 insertions, 6 deletions
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,
- "<port> <r/w> <reg> | <val>",
+ "<port> r <reg>"
+ "\n<port> w <reg> <val>",
"Read or write to BB retimer register");
#endif /* CONFIG_CMD_RETIMER */