summaryrefslogtreecommitdiff
path: root/common/peci.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/peci.c')
-rw-r--r--common/peci.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/common/peci.c b/common/peci.c
index e0f03c95dd..b124d6b67b 100644
--- a/common/peci.c
+++ b/common/peci.c
@@ -1,4 +1,4 @@
-/* Copyright 2019 The Chromium OS Authors. All rights reserved.
+/* Copyright 2019 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -8,12 +8,13 @@
#include "chipset.h"
#include "console.h"
#include "peci.h"
+#include "printf.h"
#include "util.h"
static int peci_get_cpu_temp(int *cpu_temp)
{
int rv;
- uint8_t r_buf[PECI_GET_TEMP_READ_LENGTH] = {0};
+ uint8_t r_buf[PECI_GET_TEMP_READ_LENGTH] = { 0 };
struct peci_data peci = {
.cmd_code = PECI_CMD_GET_TEMP,
.addr = PECI_TARGET_ADDRESS,
@@ -72,10 +73,10 @@ int peci_temp_sensor_get_val(int idx, int *temp_ptr)
/*****************************************************************************/
/* Console commands */
#ifdef CONFIG_CMD_PECI
-static int peci_cmd(int argc, char **argv)
+static int peci_cmd(int argc, const char **argv)
{
- uint8_t r_buf[PECI_READ_DATA_FIFO_SIZE] = {0};
- uint8_t w_buf[PECI_WRITE_DATA_FIFO_SIZE] = {0};
+ uint8_t r_buf[PECI_READ_DATA_FIFO_SIZE] = { 0 };
+ uint8_t w_buf[PECI_WRITE_DATA_FIFO_SIZE] = { 0 };
struct peci_data peci = {
.w_buf = w_buf,
.r_buf = r_buf,
@@ -139,15 +140,20 @@ static int peci_cmd(int argc, char **argv)
if (peci_transaction(&peci)) {
ccprintf("PECI transaction error\n");
return EC_ERROR_UNKNOWN;
+ } else {
+ char str_buf[hex_str_buf_size(peci.r_len)];
+
+ snprintf_hex_buffer(str_buf, sizeof(str_buf),
+ HEX_BUF(r_buf, sizeof(str_buf)));
+ ccprintf("PECI read data: %s\n", str_buf);
+
+ return EC_SUCCESS;
}
- ccprintf("PECI read data: %ph\n", HEX_BUF(r_buf, peci.r_len));
- return EC_SUCCESS;
}
-DECLARE_CONSOLE_COMMAND(peci, peci_cmd,
- "addr wlen rlen cmd timeout(us)",
+DECLARE_CONSOLE_COMMAND(peci, peci_cmd, "addr wlen rlen cmd timeout(us)",
"PECI command");
-static int command_peci_temp(int argc, char **argv)
+static int command_peci_temp(int argc, const char **argv)
{
int t;
@@ -159,7 +165,6 @@ static int command_peci_temp(int argc, char **argv)
ccprintf("CPU temp: %d K, %d C\n", t, K_TO_C(t));
return EC_SUCCESS;
}
-DECLARE_CONSOLE_COMMAND(pecitemp, command_peci_temp,
- NULL,
+DECLARE_CONSOLE_COMMAND(pecitemp, command_peci_temp, NULL,
"Print CPU temperature");
#endif /* CONFIG_CMD_PECI */