Implement ACPI parameters from proprietary EC firmware
This commit is contained in:
parent
fe613e093c
commit
08c800fa6d
@ -2,6 +2,9 @@
|
||||
#include <board/battery.h>
|
||||
#include <board/peci.h>
|
||||
#include <common/debug.h>
|
||||
#include <ec/gpio.h>
|
||||
|
||||
static struct Gpio __code ACIN_N = GPIO(B, 6);
|
||||
|
||||
uint8_t acpi_read(uint8_t addr) {
|
||||
uint8_t data = 0;
|
||||
@ -20,16 +23,28 @@ uint8_t acpi_read(uint8_t addr) {
|
||||
ACPI_16((K) + 2, (V) >> 16)
|
||||
|
||||
switch (addr) {
|
||||
ACPI_16(0x00, battery_temp);
|
||||
ACPI_16(0x02, battery_voltage);
|
||||
ACPI_16(0x04, battery_current);
|
||||
ACPI_16(0x06, battery_charge);
|
||||
// Handle AC adapter and battery present
|
||||
case 0x10:
|
||||
if (!gpio_get(&ACIN_N)) {
|
||||
// AC adapter connected
|
||||
data |= 1 << 0;
|
||||
}
|
||||
// BAT0 always connected - TODO
|
||||
data |= 1 << 2;
|
||||
break;
|
||||
|
||||
ACPI_16(0x10, peci_offset);
|
||||
ACPI_16(0x12, peci_temp);
|
||||
ACPI_8 (0x14, peci_duty);
|
||||
ACPI_8 (0x15, peci_tcontrol);
|
||||
ACPI_8 (0x16, peci_tjmax);
|
||||
ACPI_16(0x16, battery_design_capacity);
|
||||
ACPI_16(0x1A, battery_full_capacity);
|
||||
ACPI_16(0x22, battery_design_voltage);
|
||||
|
||||
// Bypass status test in ACPI
|
||||
case 0x26:
|
||||
data |= 1 << 1;
|
||||
break;
|
||||
|
||||
ACPI_16(0x2A, battery_current);
|
||||
ACPI_16(0x2E, battery_remaining_capacity);
|
||||
ACPI_16(0x32, battery_voltage);
|
||||
|
||||
// Set size of flash (from old firmware)
|
||||
ACPI_8 (0xE5, 0x80);
|
||||
@ -39,6 +54,7 @@ uint8_t acpi_read(uint8_t addr) {
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
// If not in debug mode, data is not used, ignore warning
|
||||
#pragma save
|
||||
#pragma disable_warning 85
|
||||
|
@ -44,6 +44,10 @@ uint16_t battery_temp = 0;
|
||||
uint16_t battery_voltage = 0;
|
||||
uint16_t battery_current = 0;
|
||||
uint16_t battery_charge = 0;
|
||||
uint16_t battery_remaining_capacity = 0;
|
||||
uint16_t battery_full_capacity = 0;
|
||||
uint16_t battery_design_capacity = 0;
|
||||
uint16_t battery_design_voltage = 0;
|
||||
|
||||
void battery_event(void) {
|
||||
int res = 0;
|
||||
@ -60,6 +64,10 @@ void battery_event(void) {
|
||||
command(battery_voltage, 0x09);
|
||||
command(battery_current, 0x0A);
|
||||
command(battery_charge, 0x0D);
|
||||
command(battery_remaining_capacity, 0x0F);
|
||||
command(battery_full_capacity, 0x10);
|
||||
command(battery_design_capacity, 0x18);
|
||||
command(battery_design_voltage, 0x19);
|
||||
|
||||
#undef command
|
||||
}
|
||||
|
@ -7,6 +7,10 @@ extern uint16_t battery_temp;
|
||||
extern uint16_t battery_voltage;
|
||||
extern uint16_t battery_current;
|
||||
extern uint16_t battery_charge;
|
||||
extern uint16_t battery_remaining_capacity;
|
||||
extern uint16_t battery_full_capacity;
|
||||
extern uint16_t battery_design_capacity;
|
||||
extern uint16_t battery_design_voltage;
|
||||
|
||||
int battery_charger_disable(void);
|
||||
int battery_charger_enable(void);
|
||||
|
Loading…
x
Reference in New Issue
Block a user