Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add enum for PECI command codes #491

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading