From 9e7f1952fa8d6962ab713286a79cca98ef1dcbaf Mon Sep 17 00:00:00 2001 From: Tim Crawford Date: Tue, 23 Jul 2024 20:15:36 -0600 Subject: [PATCH] Add enum for PECI command codes Signed-off-by: Tim Crawford --- src/board/system76/common/include/board/peci.h | 12 ++++++++++-- src/board/system76/common/peci.c | 12 ++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/board/system76/common/include/board/peci.h b/src/board/system76/common/include/board/peci.h index e9138723d..4a6ceebce 100644 --- a/src/board/system76/common/include/board/peci.h +++ b/src/board/system76/common/include/board/peci.h @@ -3,13 +3,21 @@ #ifndef _BOARD_PECI_H #define _BOARD_PECI_H -#include - #include +#include extern bool peci_on; extern int16_t peci_temp; +enum PeciCmd { + PECI_CMD_PING = 0x00, + PECI_CMD_GET_TEMP = 0x01, + PECI_CMD_RD_PKG_CONFIG = 0xA1, + PECI_CMD_WR_PKG_CONFIG = 0xA5, + PECI_CMD_RD_IAMSR = 0xB1, + PECI_CMD_GET_DIB = 0xF7, +}; + void peci_init(void); bool peci_available(void); int16_t peci_wr_pkg_config(uint8_t index, uint16_t param, uint32_t data); diff --git a/src/board/system76/common/peci.c b/src/board/system76/common/peci.c index 8102703e2..d168bd6db 100644 --- a/src/board/system76/common/peci.c +++ b/src/board/system76/common/peci.c @@ -84,8 +84,8 @@ bool peci_get_temp(int16_t *const data) { UDB[5] = 1; // PECI read length UDB[6] = 2; - // PECI command (0x01 = GetTemp) - UDB[7] = 0x01; + // PECI command + UDB[7] = PECI_CMD_GET_TEMP; // Set upstream enable ESUCTRL0 |= ESUCTRL0_ENABLE; @@ -167,8 +167,8 @@ int16_t peci_wr_pkg_config(uint8_t index, uint16_t param, uint32_t data) { UDB[5] = 10; // PECI read length UDB[6] = 1; - // PECI command (0xA5 = WrPkgConfig) - UDB[7] = 0xA5; + // PECI command + UDB[7] = PECI_CMD_WR_PKG_CONFIG; // Write host ID UDB[8] = 0; @@ -274,7 +274,7 @@ bool peci_get_temp(int16_t *const data) { // Set read length HORDLR = 2; // Set command - HOCMDR = 1; + HOCMDR = PECI_CMD_GET_TEMP; // Start transaction HOCTLR |= 1; @@ -330,7 +330,7 @@ int16_t peci_wr_pkg_config(uint8_t index, uint16_t param, uint32_t data) { // Set read length HORDLR = 1; // Set command - HOCMDR = 0xA5; + HOCMDR = PECI_CMD_WR_PKG_CONFIG; // Write host ID HOWRDR = 0;