Add enum for PECI command codes

Signed-off-by: Tim Crawford <tcrawford@system76.com>
This commit is contained in:
Tim Crawford
2024-07-23 20:15:36 -06:00
committed by Jeremy Soller
parent face381354
commit 9e7f1952fa
2 changed files with 16 additions and 8 deletions

View File

@ -3,13 +3,21 @@
#ifndef _BOARD_PECI_H #ifndef _BOARD_PECI_H
#define _BOARD_PECI_H #define _BOARD_PECI_H
#include <stdbool.h>
#include <ec/peci.h> #include <ec/peci.h>
#include <stdbool.h>
extern bool peci_on; extern bool peci_on;
extern int16_t peci_temp; 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); void peci_init(void);
bool peci_available(void); bool peci_available(void);
int16_t peci_wr_pkg_config(uint8_t index, uint16_t param, uint32_t data); int16_t peci_wr_pkg_config(uint8_t index, uint16_t param, uint32_t data);

View File

@ -84,8 +84,8 @@ bool peci_get_temp(int16_t *const data) {
UDB[5] = 1; UDB[5] = 1;
// PECI read length // PECI read length
UDB[6] = 2; UDB[6] = 2;
// PECI command (0x01 = GetTemp) // PECI command
UDB[7] = 0x01; UDB[7] = PECI_CMD_GET_TEMP;
// Set upstream enable // Set upstream enable
ESUCTRL0 |= ESUCTRL0_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; UDB[5] = 10;
// PECI read length // PECI read length
UDB[6] = 1; UDB[6] = 1;
// PECI command (0xA5 = WrPkgConfig) // PECI command
UDB[7] = 0xA5; UDB[7] = PECI_CMD_WR_PKG_CONFIG;
// Write host ID // Write host ID
UDB[8] = 0; UDB[8] = 0;
@ -274,7 +274,7 @@ bool peci_get_temp(int16_t *const data) {
// Set read length // Set read length
HORDLR = 2; HORDLR = 2;
// Set command // Set command
HOCMDR = 1; HOCMDR = PECI_CMD_GET_TEMP;
// Start transaction // Start transaction
HOCTLR |= 1; HOCTLR |= 1;
@ -330,7 +330,7 @@ int16_t peci_wr_pkg_config(uint8_t index, uint16_t param, uint32_t data) {
// Set read length // Set read length
HORDLR = 1; HORDLR = 1;
// Set command // Set command
HOCMDR = 0xA5; HOCMDR = PECI_CMD_WR_PKG_CONFIG;
// Write host ID // Write host ID
HOWRDR = 0; HOWRDR = 0;