Reduce variable usage to fit within paged data

This commit is contained in:
Jeremy Soller 2020-01-28 15:33:37 -07:00
parent ae4379199c
commit 8c72f42214
No known key found for this signature in database
GPG Key ID: E988B49EE78A7FB1
2 changed files with 5 additions and 63 deletions

View File

@ -12,9 +12,6 @@
int16_t peci_offset = 0;
int16_t peci_temp = 0;
uint8_t peci_duty = 0;
uint8_t peci_tcontrol = 0;
uint8_t peci_tjmax = T_JUNCTION;
static bool peci_config_loaded = false;
#define PECI_TEMP(X) (((int16_t)(X)) << 6)
#define PWM_DUTY(X) ((uint8_t)(((((uint16_t)(X)) * 255) + 99) / 100))
@ -78,55 +75,6 @@ void peci_init(void) {
PADCTLR = 0x02;
}
// Read tjmax using index 16 of RdPkgConfig
static void peci_config(void) {
// Wait for completion
while (HOSTAR & 1) {}
// Clear status
HOSTAR = HOSTAR;
// Enable PECI, clearing data fifo's
HOCTLR = (1 << 5) | (1 << 3);
// Set address to default
HOTRADDR = 0x30;
// Set write length
HOWRLR = 5;
// Set read length
HORDLR = 5;
// Set command
HOCMDR = 0xA1;
// Set Host ID ?
HOWRDR = 0x00;
// Set index
HOWRDR = 16;
// Set parameter
HOWRDR = 0;
HOWRDR = 0;
// Start transaction
HOCTLR |= 1;
// Wait for completion
while (HOSTAR & 1) {}
if (HOSTAR & (1 << 1)) {
// Use result if finished successfully
//TODO: check completion code
uint8_t data = HOWRDR;
// Throw away reserved byte
data = HOWRDR;
// Tead tcontrol for now
peci_tcontrol = HOWRDR;
// Read tjmax
peci_tjmax = HOWRDR;
// Throw away reserved byte
data = HOWRDR;
peci_config_loaded = true;
}
}
// PECI information can be found here: https://www.intel.com/content/dam/www/public/us/en/documents/design-guides/core-i7-lga-2011-guide.pdf
void peci_event(void) {
// Wait for completion
@ -156,12 +104,6 @@ void peci_event(void) {
uint8_t high = HORDDR;
peci_offset = ((int16_t)high << 8) | (int16_t)low;
// TODO: Update max value if possible
// if (!peci_config_loaded) {
// peci_config();
// }
// TODO: tjmax
peci_temp = PECI_TEMP(T_JUNCTION) + peci_offset;
peci_duty = fan_duty(peci_temp);
} else {

View File

@ -35,7 +35,7 @@ bool pmc_sci(struct Pmc * pmc, uint8_t sci) {
void pmc_event(struct Pmc * pmc) {
static enum PmcState state = PMC_STATE_DEFAULT;
static uint8_t state_data[2] = {0, 0};
static uint8_t state_data = 0;
uint16_t burst_timeout;
for (burst_timeout = 1; burst_timeout > 0; burst_timeout--) {
@ -94,16 +94,16 @@ void pmc_event(struct Pmc * pmc) {
switch (state) {
case PMC_STATE_ACPI_READ:
state = PMC_STATE_DEFAULT;
uint8_t value = acpi_read(data);
pmc_write(pmc, value, PMC_TIMEOUT);
state_data = acpi_read(data);
pmc_write(pmc, state_data, PMC_TIMEOUT);
break;
case PMC_STATE_ACPI_WRITE:
state = PMC_STATE_ACPI_WRITE_ADDR;
state_data[0] = data;
state_data = data;
break;
case PMC_STATE_ACPI_WRITE_ADDR:
state = PMC_STATE_DEFAULT;
acpi_write(state_data[0], data);
acpi_write(state_data, data);
break;
default:
state = PMC_STATE_DEFAULT;