peci: Check for hardware error
Check if any hardware error bits are set instead of checking for only command completion. Move logging of WrPkgConfig() errors from power to peci. Ref: IT5570E V0.3.2 datasheet Signed-off-by: Tim Crawford <tcrawford@system76.com>
This commit is contained in:
committed by
Jeremy Soller
parent
373dc36676
commit
dd97946056
@ -277,8 +277,8 @@ bool peci_available(void) {
|
|||||||
|
|
||||||
// Returns true on success, false on error
|
// Returns true on success, false on error
|
||||||
bool peci_get_temp(int16_t *data) {
|
bool peci_get_temp(int16_t *data) {
|
||||||
// Wait for completion
|
// Wait for any in-progress transaction to complete
|
||||||
while (HOSTAR & 1) {}
|
while (HOSTAR & BIT(0)) {}
|
||||||
// Clear status
|
// Clear status
|
||||||
HOSTAR = HOSTAR;
|
HOSTAR = HOSTAR;
|
||||||
|
|
||||||
@ -299,22 +299,23 @@ bool peci_get_temp(int16_t *data) {
|
|||||||
while (HOSTAR & 1) {}
|
while (HOSTAR & 1) {}
|
||||||
|
|
||||||
uint8_t status = HOSTAR;
|
uint8_t status = HOSTAR;
|
||||||
if (status & BIT(1)) {
|
if (status & 0xEC) {
|
||||||
|
ERROR("peci_get_temp: hardware error: 0x%02X\n", status);
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
// Read two byte temperature data if finished successfully
|
// Read two byte temperature data if finished successfully
|
||||||
uint8_t low = HORDDR;
|
uint8_t low = HORDDR;
|
||||||
uint8_t high = HORDDR;
|
uint8_t high = HORDDR;
|
||||||
*data = (((int16_t)high << 8) | (int16_t)low);
|
*data = (((int16_t)high << 8) | (int16_t)low);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns positive completion code on success, negative completion code or
|
// Returns positive completion code on success, negative completion code or
|
||||||
// negative (0x1000 | status register) on PECI hardware error
|
// negative (0x1000 | status register) on PECI hardware error
|
||||||
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) {
|
||||||
// Wait for completion
|
// Wait for any in-progress transaction to complete
|
||||||
while (HOSTAR & 1) {}
|
while (HOSTAR & BIT(0)) {}
|
||||||
// Clear status
|
// Clear status
|
||||||
HOSTAR = HOSTAR;
|
HOSTAR = HOSTAR;
|
||||||
|
|
||||||
@ -348,17 +349,21 @@ int16_t peci_wr_pkg_config(uint8_t index, uint16_t param, uint32_t data) {
|
|||||||
// Wait for completion
|
// Wait for completion
|
||||||
while (HOSTAR & 1) {}
|
while (HOSTAR & 1) {}
|
||||||
|
|
||||||
int16_t status = (int16_t)HOSTAR;
|
uint8_t status = HOSTAR;
|
||||||
if (status & BIT(1)) {
|
if (status & 0xEC) {
|
||||||
int16_t cc = (int16_t)HORDDR;
|
ERROR("peci_wr_pkg_config: hardware error: 0x%02X\n", status);
|
||||||
if (cc & 0x80) {
|
|
||||||
return -cc;
|
|
||||||
} else {
|
|
||||||
return cc;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return -(0x1000 | status);
|
return -(0x1000 | status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t cc = HORDDR;
|
||||||
|
|
||||||
|
if (cc == 0x40) {
|
||||||
|
TRACE("peci_wr_pkg_config: command successful\n");
|
||||||
|
return cc;
|
||||||
|
}
|
||||||
|
|
||||||
|
ERROR("peci_wr_pkg_config: command error: 0x%02X\n", cc);
|
||||||
|
return -((int16_t)cc);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // CONFIG_BUS_ESPI
|
#endif // CONFIG_BUS_ESPI
|
||||||
|
@ -318,15 +318,7 @@ static bool power_peci_limit(bool ac) {
|
|||||||
// Set PL4 using PECI
|
// Set PL4 using PECI
|
||||||
int16_t res = peci_wr_pkg_config(60, 0, ((uint32_t)watts) * 8);
|
int16_t res = peci_wr_pkg_config(60, 0, ((uint32_t)watts) * 8);
|
||||||
DEBUG("power_peci_limit %d = %d\n", watts, res);
|
DEBUG("power_peci_limit %d = %d\n", watts, res);
|
||||||
if (res == 0x40) {
|
return res == 0x40;
|
||||||
return true;
|
|
||||||
} else if (res < 0) {
|
|
||||||
ERROR("power_peci_limit failed: 0x%02X\n", -res);
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
ERROR("power_peci_limit unknown response: 0x%02X\n", res);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the power draw limit depending on if on AC or DC power
|
// Set the power draw limit depending on if on AC or DC power
|
||||||
|
Reference in New Issue
Block a user