Skip to content

Commit

Permalink
Add enum for PECI command codes
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Crawford <tcrawford@system76.com>
  • Loading branch information
crawfxrd committed Jul 24, 2024
1 parent face381 commit 57cd5fe
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
12 changes: 10 additions & 2 deletions src/board/system76/common/include/board/peci.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,21 @@
#ifndef _BOARD_PECI_H
#define _BOARD_PECI_H

#include <stdbool.h>

#include <ec/peci.h>
#include <stdbool.h>

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);
Expand Down
12 changes: 6 additions & 6 deletions src/board/system76/common/peci.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 57cd5fe

Please sign in to comment.