16 changes: 11 additions & 5 deletions src/drivers/intel/fsp2_0/header_display.c
Expand Up @@ -6,16 +6,22 @@
void fsp_print_header_info(const struct fsp_header *hdr)
{
union fsp_revision revision;
union extended_fsp_revision ext_revision;
ext_revision.val = 0;

revision.val = hdr->fsp_revision;
/* For FSP 2.3 and later use extended image revision field present in header
* for build number and revision calculation */
if (CONFIG(PLATFORM_USES_FSP2_3))
ext_revision.val = hdr->extended_fsp_revision;

revision.val = hdr->fsp_revision;
printk(BIOS_SPEW, "Spec version: v%u.%u\n", (hdr->spec_version >> 4),
hdr->spec_version & 0xf);
printk(BIOS_SPEW, "Revision: %u.%u.%u, Build Number %u\n",
revision.rev.major,
revision.rev.minor,
revision.rev.revision,
revision.rev.bld_num);
revision.rev.major,
revision.rev.minor,
((ext_revision.rev.revision << 8) | revision.rev.revision),
((ext_revision.rev.bld_num << 8) | revision.rev.bld_num));
printk(BIOS_SPEW, "Type: %s/%s\n",
(hdr->component_attribute & 1) ? "release" : "debug",
(hdr->component_attribute & 2) ? "official" : "test");
Expand Down
10 changes: 10 additions & 0 deletions src/drivers/intel/fsp2_0/include/fsp/debug.h
Expand Up @@ -5,7 +5,17 @@

#include <fsp/util.h>

enum fsp_log_level {
FSP_LOG_LEVEL_DISABLE = 0,
FSP_LOG_LEVEL_ERR,
FSP_LOG_LEVEL_ERR_WARN,
FSP_LOG_LEVEL_ERR_WARN_INFO,
FSP_LOG_LEVEL_ERR_WARN_INFO_EVENT,
FSP_LOG_LEVEL_VERBOSE
};

/* FSP debug API */
enum fsp_log_level fsp_map_console_log_level(void);
void fsp_debug_before_memory_init(fsp_memory_init_fn memory_init,
const FSPM_UPD *fspm_old_upd,
const FSPM_UPD *fspm_new_upd);
Expand Down
1 change: 1 addition & 0 deletions src/drivers/intel/fsp2_0/include/fsp/info_header.h
Expand Up @@ -14,6 +14,7 @@
#if CONFIG(PLATFORM_USES_FSP2_X86_32)
struct fsp_header {
uint32_t fsp_revision;
uint16_t extended_fsp_revision;
uint32_t image_size;
uint32_t image_base;
uint16_t image_attribute;
Expand Down
8 changes: 8 additions & 0 deletions src/drivers/intel/fsp2_0/include/fsp/util.h
Expand Up @@ -60,6 +60,14 @@ union fsp_revision {
} rev;
};

union extended_fsp_revision {
uint16_t val;
struct {
uint8_t bld_num;
uint8_t revision;
} rev;
};

#if CONFIG_UDK_VERSION < CONFIG_UDK_2017_VERSION
enum resource_type {
EFI_RESOURCE_SYSTEM_MEMORY = 0,
Expand Down
3 changes: 1 addition & 2 deletions src/drivers/intel/fsp2_0/memory_init.c
Expand Up @@ -309,9 +309,8 @@ static void do_fsp_memory_init(const struct fspm_context *context, bool s3wake)
/* Handle any errors returned by FspMemoryInit */
fsp_handle_reset(status);
if (status != FSP_SUCCESS) {
printk(BIOS_CRIT, "FspMemoryInit returned 0x%08x\n", status);
die_with_post_code(POST_RAM_FAILURE,
"FspMemoryInit returned an error!\n");
"FspMemoryInit returned with error 0x%08x!\n", status);
}

do_fsp_post_memory_init(s3wake, fsp_version);
Expand Down
94 changes: 58 additions & 36 deletions src/drivers/intel/fsp2_0/notify.c
Expand Up @@ -4,56 +4,82 @@
#include <console/console.h>
#include <cpu/x86/mtrr.h>
#include <fsp/util.h>
#include <timestamp.h>
#include <mode_switch.h>
#include <timestamp.h>
#include <types.h>

struct fsp_notify_phase_data {
enum fsp_notify_phase notify_phase;
uint8_t post_code_before;
uint8_t post_code_after;
enum timestamp_id timestamp_before;
enum timestamp_id timestamp_after;
};

static const struct fsp_notify_phase_data notify_data[] = {
{
.notify_phase = AFTER_PCI_ENUM,
.post_code_before = POST_FSP_NOTIFY_BEFORE_ENUMERATE,
.post_code_after = POST_FSP_NOTIFY_AFTER_ENUMERATE,
.timestamp_before = TS_FSP_BEFORE_ENUMERATE,
.timestamp_after = TS_FSP_AFTER_ENUMERATE,
},
{
.notify_phase = READY_TO_BOOT,
.post_code_before = POST_FSP_NOTIFY_BEFORE_FINALIZE,
.post_code_after = POST_FSP_NOTIFY_AFTER_FINALIZE,
.timestamp_before = TS_FSP_BEFORE_FINALIZE,
.timestamp_after = TS_FSP_AFTER_FINALIZE,
},
{
.notify_phase = END_OF_FIRMWARE,
.post_code_before = POST_FSP_NOTIFY_BEFORE_END_OF_FIRMWARE,
.post_code_after = POST_FSP_NOTIFY_AFTER_END_OF_FIRMWARE,
.timestamp_before = TS_FSP_BEFORE_END_OF_FIRMWARE,
.timestamp_after = TS_FSP_AFTER_END_OF_FIRMWARE,
},
};

static const struct fsp_notify_phase_data *get_notify_phase_data(enum fsp_notify_phase phase)
{
for (size_t i = 0; i < ARRAY_SIZE(notify_data); i++) {
if (notify_data[i].notify_phase == phase)
return &notify_data[i];
}
die("Unknown FSP notify phase %u\n", phase);
}

static void fsp_notify(enum fsp_notify_phase phase)
{
uint32_t ret;
fsp_notify_fn fspnotify;
const struct fsp_notify_phase_data *data = get_notify_phase_data(phase);
struct fsp_notify_params notify_params = { .phase = phase };
fsp_notify_fn fspnotify;
uint32_t ret;

if (!fsps_hdr.notify_phase_entry_offset)
die("Notify_phase_entry_offset is zero!\n");

fspnotify = (void *) (uintptr_t)(fsps_hdr.image_base +
fspnotify = (void *)(uintptr_t)(fsps_hdr.image_base +
fsps_hdr.notify_phase_entry_offset);
fsp_before_debug_notify(fspnotify, &notify_params);

if (phase == AFTER_PCI_ENUM) {
timestamp_add_now(TS_FSP_BEFORE_ENUMERATE);
post_code(POST_FSP_NOTIFY_BEFORE_ENUMERATE);
} else if (phase == READY_TO_BOOT) {
timestamp_add_now(TS_FSP_BEFORE_FINALIZE);
post_code(POST_FSP_NOTIFY_BEFORE_FINALIZE);
} else if (phase == END_OF_FIRMWARE) {
timestamp_add_now(TS_FSP_BEFORE_END_OF_FIRMWARE);
post_code(POST_FSP_NOTIFY_BEFORE_END_OF_FIRMWARE);
}
timestamp_add_now(data->timestamp_before);
post_code(data->post_code_before);

if (ENV_X86_64 && CONFIG(PLATFORM_USES_FSP2_X86_32))
ret = protected_mode_call_1arg(fspnotify, (uintptr_t)&notify_params);
else
ret = fspnotify(&notify_params);

if (phase == AFTER_PCI_ENUM) {
timestamp_add_now(TS_FSP_AFTER_ENUMERATE);
post_code(POST_FSP_NOTIFY_AFTER_ENUMERATE);
} else if (phase == READY_TO_BOOT) {
timestamp_add_now(TS_FSP_AFTER_FINALIZE);
post_code(POST_FSP_NOTIFY_AFTER_FINALIZE);
} else if (phase == END_OF_FIRMWARE) {
timestamp_add_now(TS_FSP_AFTER_END_OF_FIRMWARE);
post_code(POST_FSP_NOTIFY_AFTER_END_OF_FIRMWARE);
}
timestamp_add_now(data->timestamp_after);
post_code(data->post_code_after);

fsp_debug_after_notify(ret);

/* Handle any errors returned by FspNotify */
fsp_handle_reset(ret);
if (ret != FSP_SUCCESS) {
printk(BIOS_SPEW, "FspNotify returned 0x%08x\n", ret);
die("FspNotify returned an error!\n");
}
if (ret != FSP_SUCCESS)
die("FspNotify returned with error 0x%08x!\n", ret);

/* Allow the platform to run something after FspNotify */
platform_fsp_notify_status(phase);
Expand All @@ -70,14 +96,10 @@ static void fsp_notify_dummy(void *arg)
fsp_notify(END_OF_FIRMWARE);
}

BOOT_STATE_INIT_ENTRY(BS_DEV_ENABLE, BS_ON_ENTRY, fsp_notify_dummy,
(void *) AFTER_PCI_ENUM);
BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, fsp_notify_dummy,
(void *) READY_TO_BOOT);
BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, fsp_notify_dummy,
(void *) READY_TO_BOOT);
BOOT_STATE_INIT_ENTRY(BS_DEV_ENABLE, BS_ON_ENTRY, fsp_notify_dummy, (void *)AFTER_PCI_ENUM);
BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_LOAD, BS_ON_EXIT, fsp_notify_dummy, (void *)READY_TO_BOOT);
BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, fsp_notify_dummy, (void *)READY_TO_BOOT);

__weak void platform_fsp_notify_status(
enum fsp_notify_phase phase)
__weak void platform_fsp_notify_status(enum fsp_notify_phase phase)
{
}
6 changes: 2 additions & 4 deletions src/drivers/intel/fsp2_0/temp_ram_exit.c
Expand Up @@ -29,10 +29,8 @@ static void fsp_temp_ram_exit(void)
printk(BIOS_DEBUG, "Calling TempRamExit: %p\n", temp_ram_exit);
status = temp_ram_exit(NULL);

if (status != FSP_SUCCESS) {
printk(BIOS_CRIT, "TempRamExit returned 0x%08x\n", status);
die("TempRamExit returned an error!\n");
}
if (status != FSP_SUCCESS)
die("TempRamExit returned with error 0x%08x!\n", status);

cbfs_unmap(mapping);
}
Expand Down
6 changes: 5 additions & 1 deletion src/drivers/intel/fsp2_0/util.c
Expand Up @@ -14,7 +14,9 @@

static uint32_t fsp_hdr_get_expected_min_length(void)
{
if (CONFIG(PLATFORM_USES_FSP2_2))
if (CONFIG(PLATFORM_USES_FSP2_3))
return 80;
else if (CONFIG(PLATFORM_USES_FSP2_2))
return 76;
else if (CONFIG(PLATFORM_USES_FSP2_1))
return 72;
Expand Down Expand Up @@ -70,6 +72,8 @@ enum cb_err fsp_identify(struct fsp_header *hdr, const void *fsp_blob)
hdr->silicon_init_entry_offset = read32(raw_hdr + 68);
if (CONFIG(PLATFORM_USES_FSP2_2))
hdr->multi_phase_si_init_entry_offset = read32(raw_hdr + 72);
if (CONFIG(PLATFORM_USES_FSP2_3))
hdr->extended_fsp_revision = read16(raw_hdr + 76);

return CB_SUCCESS;
}
Expand Down
12 changes: 6 additions & 6 deletions src/drivers/intel/gma/acpi/common.asl
Expand Up @@ -9,7 +9,7 @@
Store (Match (BRIG, MEQ, Arg0, MTR, Zero, 2), Local0)
If (LEqual (Local0, Ones))
{
Return (Subtract(SizeOf(BRIG), One))
Return (SizeOf(BRIG) - 1)
}
Return (Local0)
}
Expand Down Expand Up @@ -40,9 +40,9 @@
Store (BRID (XBQC ()), Local0)
If (LNotEqual (Local0, 2))
{
Decrement (Local0)
Local0--
}
XBCM (DerefOf (Index (BRIG, Local0)))
XBCM (DerefOf (BRIG[Local0]))
}
}

Expand All @@ -56,10 +56,10 @@
Notify (LCD0, 0x86)
} Else {
Store (BRID (XBQC ()), Local0)
If (LNotEqual (Local0, Subtract(SizeOf(BRIG), One)))
If (LNotEqual (Local0, SizeOf(BRIG) - 1))
{
Increment (Local0)
Local0++
}
XBCM (DerefOf (Index (BRIG, Local0)))
XBCM (DerefOf (BRIG[Local0]))
}
}
22 changes: 10 additions & 12 deletions src/drivers/intel/gma/acpi/configure_brightness_levels.asl
Expand Up @@ -53,7 +53,7 @@

/* Always keep BCLP up to date, even if driver is not ready.
It requires a full 8-bit brightness value. 255 = 100% */
Store (Divide (Multiply (Arg0, 255), 100), Local1)
Store (Arg0 * 255 / 100, Local1)
If (LGreater(Local1, 255)) {
Store (255, Local1)
}
Expand Down Expand Up @@ -83,7 +83,7 @@
Return (Ones)
}
}
Decrement (Local0)
Local0--
}

Return (Ones)
Expand All @@ -100,12 +100,12 @@
/* Divide round closest */
Method (DRCL, 2)
{
Return (Divide (Add (Arg0, Divide (Arg1, 2)), Arg1))
Return ((Arg0 + Arg1 / 2) / Arg1)
}

Method (XBCM, 1, NotSerialized)
{
Store (DRCL (Multiply (Arg0, BCLM), 100), BCLV)
Store (DRCL (Arg0 * BCLM, 100), BCLV)
}

/* Find value closest to BCLV in BRIG (which must be ordered) */
Expand All @@ -117,26 +117,24 @@
Return (Zero)
}
/* Local0: current percentage */
Store (DRCL (Multiply (BCLV, 100), BCLM), Local0)
Store (DRCL (BCLV * 100, BCLM), Local0)

/* Local1: loop index (selectable values start at 2 in BRIG) */
Store (2, Local1)
While (LLess (Local1, Subtract (SizeOf (BRIG), 1))) {
While (LLess (Local1, SizeOf (BRIG) - 1)) {
/* Local[23]: adjacent values in BRIG */
Store (DeRefOf (Index (BRIG, Local1)), Local2)
Store (DeRefOf (Index (BRIG, Add (Local1, 1))), Local3)
Store (DeRefOf (BRIG[Local1]), Local2)
Store (DeRefOf (BRIG[Local1 + 1]), Local3)

If (LLess (Local0, Local3)) {
If (LOr (LLess (Local0, Local2),
LLess (Subtract (Local0, Local2),
Subtract (Local3, Local0)))) {
If (LLess (Local0, Local2) || LLess (Local0 - Local2, Local3 - Local0)) {
Return (Local2)
} Else {
Return (Local3)
}
}

Increment (Local1)
Local1++
}

/* Didn't find greater/equal value: use the last */
Expand Down
8 changes: 4 additions & 4 deletions src/drivers/intel/pmc_mux/conn/chip.h
Expand Up @@ -6,10 +6,10 @@
#include <boot/coreboot_tables.h>

struct drivers_intel_pmc_mux_conn_config {
/* 1-based port numbers (from SoC point of view) */
int usb2_port_number;
/* 1-based port numbers (from SoC point of view) */
int usb3_port_number;
/* A pointer to the SoC's USB-2 device */
DEVTREE_CONST struct device *usb2_port;
/* A pointer to the SoC's USB-3 device */
DEVTREE_CONST struct device *usb3_port;
/* Orientation of the sideband signals (SBU) */
enum type_c_orientation sbu_orientation;
/* Orientation of the High Speed lines */
Expand Down
17 changes: 11 additions & 6 deletions src/drivers/intel/pmc_mux/conn/conn.c
Expand Up @@ -16,6 +16,11 @@ static void conn_init(struct device *dev)
total_conn_count++;
}

static unsigned int get_usb_port_number(const struct device *usb_port)
{
return usb_port->path.usb.port_id + 1;
}

static struct type_c_info *conn_get_cbmem_buffer(void)
{
struct type_c_info *info;
Expand Down Expand Up @@ -57,8 +62,8 @@ static void conn_write_cbmem_entry(struct device *dev)

count = info->port_count;
port_info = &info->port_info[count];
port_info->usb2_port_number = config->usb2_port_number;
port_info->usb3_port_number = config->usb3_port_number;
port_info->usb2_port_number = get_usb_port_number(config->usb2_port);
port_info->usb3_port_number = get_usb_port_number(config->usb3_port);
port_info->sbu_orientation = config->sbu_orientation;
port_info->data_orientation = config->hsl_orientation;

Expand Down Expand Up @@ -109,8 +114,8 @@ static void conn_fill_ssdt(const struct device *dev)

/* _DSD, Device-Specific Data */
dsd = acpi_dp_new_table("_DSD");
acpi_dp_add_integer(dsd, "usb2-port-number", config->usb2_port_number);
acpi_dp_add_integer(dsd, "usb3-port-number", config->usb3_port_number);
acpi_dp_add_integer(dsd, "usb2-port-number", get_usb_port_number(config->usb2_port));
acpi_dp_add_integer(dsd, "usb3-port-number", get_usb_port_number(config->usb3_port));

/*
* The kernel assumes that these Type-C signals (SBUs and HSLs) follow the CC lines,
Expand Down Expand Up @@ -161,8 +166,8 @@ bool intel_pmc_mux_conn_get_ports(const struct device *conn, unsigned int *usb2_
return false;

mux_config = conn->chip_info;
*usb2_port = mux_config->usb2_port_number;
*usb3_port = mux_config->usb3_port_number;
*usb2_port = get_usb_port_number(mux_config->usb2_port);
*usb3_port = get_usb_port_number(mux_config->usb3_port);

return true;
};
6 changes: 3 additions & 3 deletions src/drivers/ipmi/ipmi_fru.c
Expand Up @@ -189,7 +189,7 @@ static enum cb_err read_fru_chassis_info_area(const int port, const uint8_t id,

info->chassis_custom = malloc(info->custom_count * sizeof(char *));
if (!info->chassis_custom) {
printk(BIOS_ERR, "%s failed to malloc %ld bytes for "
printk(BIOS_ERR, "%s failed to malloc %zu bytes for "
"chassis custom data array.\n", __func__,
info->custom_count * sizeof(char *));
ret = CB_ERR;
Expand Down Expand Up @@ -288,7 +288,7 @@ static enum cb_err read_fru_board_info_area(const int port, const uint8_t id,

info->board_custom = malloc(info->custom_count * sizeof(char *));
if (!info->board_custom) {
printk(BIOS_ERR, "%s failed to malloc %ld bytes for "
printk(BIOS_ERR, "%s failed to malloc %zu bytes for "
"board custom data array.\n", __func__,
info->custom_count * sizeof(char *));
ret = CB_ERR;
Expand Down Expand Up @@ -395,7 +395,7 @@ static enum cb_err read_fru_product_info_area(const int port, const uint8_t id,

info->product_custom = malloc(info->custom_count * sizeof(char *));
if (!info->product_custom) {
printk(BIOS_ERR, "%s failed to malloc %ld bytes for "
printk(BIOS_ERR, "%s failed to malloc %zu bytes for "
"product custom data array.\n", __func__,
info->custom_count * sizeof(char *));
ret = CB_ERR;
Expand Down
6 changes: 3 additions & 3 deletions src/drivers/ipmi/ipmi_ops.h
Expand Up @@ -111,7 +111,7 @@ struct fru_product_info {
char *asset_tag;
char *fru_file_id;
char **product_custom;
int custom_count; /* Number of custom fields */
size_t custom_count; /* Number of custom fields */
};

struct fru_board_info {
Expand All @@ -121,15 +121,15 @@ struct fru_board_info {
char *part_number;
char *fru_file_id;
char **board_custom;
int custom_count;
size_t custom_count;
};

struct fru_chassis_info {
uint8_t chassis_type;
char *chassis_partnumber;
char *serial_number;
char **chassis_custom;
int custom_count;
size_t custom_count;
};

struct fru_info_str {
Expand Down
5 changes: 5 additions & 0 deletions src/drivers/net/chip.h
Expand Up @@ -8,6 +8,11 @@

struct drivers_net_config {
uint16_t customized_leds;
/* RTL8125 LED settings */
uint8_t led_feature;
uint16_t customized_led0;
uint16_t customized_led2;

unsigned int wake; /* Wake pin for ACPI _PRW */

/* Does the device have a power resource? */
Expand Down
88 changes: 66 additions & 22 deletions src/drivers/net/r8168.c
Expand Up @@ -29,6 +29,9 @@
#define CMD_REG 0x37
#define CMD_REG_RESET 0x10
#define CMD_LED0_LED1 0x18
#define CMD_LED_FEATURE 0x94
#define CMD_LEDSEL0 0x18
#define CMD_LEDSEL2 0x84

#define CFG_9346 0x50
#define CFG_9346_LOCK 0x00
Expand Down Expand Up @@ -249,28 +252,69 @@ static void r8168_set_customized_led(struct device *dev, u16 io_base)
if (!config)
return;

/* Read the customized LED setting from devicetree */
printk(BIOS_DEBUG, "r8168: Customized LED 0x%x\n", config->customized_leds);

/*
* Refer to RTL8111H datasheet 7.2 Customizable LED Configuration
* Starting from offset 0x18
* Bit[15:12] LED Feature Control(FC)
* Bit[11:08] LED Select for PINLED2
* Bit[07:04] LED Select for PINLED1
* Bit[03:00] LED Select for PINLED0
*
* Speed Link10M Link100M Link1000M ACT/Full
* LED0 Bit0 Bit1 Bit2 Bit3
* LED1 Bit4 Bit5 Bit6 Bit7
* LED2 Bit8 Bit9 Bit10 Bit11
* FC Bit12 Bit13 Bit14 Bit15
*/

/* Set customized LED registers */
outw(config->customized_leds, io_base + CMD_LED0_LED1);
printk(BIOS_DEBUG, "r8168: read back LED setting as 0x%x\n",
inw(io_base + CMD_LED0_LED1));
if (dev->device == PCI_DEVICE_ID_REALTEK_8125) {
/* Set LED global Feature register */
outb(config->led_feature, io_base + CMD_LED_FEATURE);
printk(BIOS_DEBUG, "r8125: read back LED global feature setting as 0x%x\n",
inb(io_base + CMD_LED_FEATURE));

/*
* Refer to RTL8125 datasheet 5.Customizable LED Configuration
* Register Name IO Address
* LEDSEL0 0x18
* LEDSEL2 0x84
* LEDFEATURE 0x94
*
* LEDSEL Bit[] Description
* Bit0 Link10M
* Bit1 Link100M
* Bit3 Link1000M
* Bit5 Link2.5G
* Bit9 ACT
* Bit10 preboot enable
* Bit11 lp enable
* Bit12 active low/high
*
* LEDFEATURE Description
* Bit0 LED Table V1/V2
* Bit1~3 Reserved
* Bit4~5 LED Blinking Duty Cycle 12.5%/ 25%/ 50%/ 75%
* Bit6~7 LED Blinking Freq. 240ms/160ms/80ms/Link-Speed-Dependent
*/

/* Set customized LED0 register */
outw(config->customized_led0, io_base + CMD_LEDSEL0);
printk(BIOS_DEBUG, "r8125: read back LED0 setting as 0x%x\n",
inw(io_base + CMD_LEDSEL0));

/* Set customized LED2 register */
outw(config->customized_led2, io_base + CMD_LEDSEL2);
printk(BIOS_DEBUG, "r8125: read back LED2 setting as 0x%x\n",
inw(io_base + CMD_LEDSEL2));
} else {
/* Read the customized LED setting from devicetree */
printk(BIOS_DEBUG, "r8168: Customized LED 0x%x\n", config->customized_leds);

/*
* Refer to RTL8111H datasheet 7.2 Customizable LED Configuration
* Starting from offset 0x18
* Bit[15:12] LED Feature Control(FC)
* Bit[11:08] LED Select for PINLED2
* Bit[07:04] LED Select for PINLED1
* Bit[03:00] LED Select for PINLED0
*
* Speed Link10M Link100M Link1000M ACT/Full
* LED0 Bit0 Bit1 Bit2 Bit3
* LED1 Bit4 Bit5 Bit6 Bit7
* LED2 Bit8 Bit9 Bit10 Bit11
* FC Bit12 Bit13 Bit14 Bit15
*/

/* Set customized LED registers */
outw(config->customized_leds, io_base + CMD_LED0_LED1);
printk(BIOS_DEBUG, "r8168: read back LED setting as 0x%x\n",
inw(io_base + CMD_LED0_LED1));
}
}

static void r8168_init(struct device *dev)
Expand Down
14 changes: 12 additions & 2 deletions src/drivers/spi/spi-generic.c
Expand Up @@ -98,8 +98,18 @@ unsigned int spi_crop_chunk(const struct spi_slave *slave, unsigned int cmd_len,
if (deduct_opcode_len)
cmd_len--;

if (deduct_cmd_len && (ctrlr_max > cmd_len))
ctrlr_max -= cmd_len;
/* Subtract command length from useable buffer size. If
deduct_opcode_len is set, only subtract the number command bytes
after the opcode. If the adjusted cmd_len is larger than ctrlr_max
return 0 to inidicate an error. */
if (deduct_cmd_len) {
if (ctrlr_max >= cmd_len) {
ctrlr_max -= cmd_len;
} else {
ctrlr_max = 0;
printk(BIOS_WARNING, "%s: Command longer than buffer\n", __func__);
}
}

return MIN(ctrlr_max, buf_len);
}
Expand Down
1 change: 0 additions & 1 deletion src/drivers/ti/sn65dsi86bridge/sn65dsi86bridge.c
@@ -1,7 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-only */

#include <console/console.h>
#include <delay.h>
#include <endian.h>
#include <device/i2c_simple.h>
#include <dp_aux.h>
Expand Down
1 change: 0 additions & 1 deletion src/drivers/tpm/ppi.c
@@ -1,7 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-only */

#include <types.h>
#include <stddef.h>
#include <acpi/acpi.h>
#include <acpi/acpigen.h>
#include <acpi/acpi_device.h>
Expand Down
1 change: 0 additions & 1 deletion src/drivers/tpm/ppi_stub.c
@@ -1,7 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-only */

#include <types.h>
#include <stddef.h>
#include <acpi/acpi.h>
#include <acpi/acpigen.h>
#include <acpi/acpi_device.h>
Expand Down
1 change: 0 additions & 1 deletion src/drivers/wifi/generic/smbios.c
Expand Up @@ -3,7 +3,6 @@
#include <device/device.h>
#include <device/pci_ids.h>
#include <smbios.h>
#include <string.h>

#include "wifi_private.h"

Expand Down
24 changes: 12 additions & 12 deletions src/ec/apple/acpi/battery.asl
Expand Up @@ -91,13 +91,13 @@ Device(BAT0)

Method(_BIF, 0, NotSerialized)
{
Index(BATS, 0x01) = ^^SBRW(0x0B, 0x18) * 10
Index(BATS, 0x02) = ^^SBRW(0x0B, 0x10) * 10
BATS[1] = ^^SBRW(0x0B, 0x18) * 10
BATS[2] = ^^SBRW(0x0B, 0x10) * 10

Index(BATS, 0x04) = ^^SBRW(0x0B, 0x19)
Index(BATS, 0x09) = ^^SBRB(0x0B, 0x21)
Index(BATS, 0x0B) = ^^SBRB(0x0B, 0x22)
Index(BATS, 0x0C) = ^^SBRB(0x0B, 0x20)
BATS[4] = ^^SBRW(0x0B, 0x19)
BATS[9] = ^^SBRB(0x0B, 0x21)
BATS[11] = ^^SBRB(0x0B, 0x22)
BATS[12] = ^^SBRB(0x0B, 0x20)

Return(BATS)
}
Expand All @@ -124,7 +124,7 @@ Device(BAT0)
}

Local1 = ^^SBRW(0x0B, 0x09)
Index(BATI, 0x03) = Local1
BATI[3] = Local1
Local0 = ^^SBRW(0x0B, 0x0A)

/* Sign-extend Local0. */
Expand All @@ -136,16 +136,16 @@ Device(BAT0)
}

Local0 *= Local1
Index(BATI, 1) = Local0 / 1000
Index(BATI, 2) = ^^SBRW(0x0B, 0x0F) * 10
BATI[1] = Local0 / 1000
BATI[2] = ^^SBRW(0x0B, 0x0F) * 10
If (HPAC) {
If (!(^^SBRW(0x0B, 0x16) & 0x40)) {
Index(BATI, 0) = 2
BATI[0] = 2
} Else {
Index(BATI, 0) = 0
BATI[0] = 0
}
} Else {
Index(BATI, 0) = 1
BATI[0] = 1
}

Return(BATI)
Expand Down
57 changes: 28 additions & 29 deletions src/ec/google/chromeec/acpi/battery.asl
Expand Up @@ -22,7 +22,7 @@ Method (BTSW, 1)
While (LNotEqual (BTIX, Arg0))
{
Sleep (1)
Decrement (Local0)
Local0--
If (LEqual (Local0, Zero))
{
Return (One)
Expand Down Expand Up @@ -68,27 +68,27 @@ Method (BBIF, 2, Serialized)
Return (Arg1)
}
// Last Full Charge Capacity
Store (BTDF, Index (Arg1, 2))
Store (BTDF, Arg1[2])

// Design Voltage
Store (BTDV, Index (Arg1, 4))
Store (BTDV, Arg1[4])

// Design Capacity
Store (BTDA, Local0)
Store (Local0, Index (Arg1, 1))
Store (Local0, Arg1[1])

// Design Capacity of Warning
Divide (Multiply (Local0, DWRN), 100, , Local2)
Store (Local2, Index (Arg1, 5))
Divide (Local0 * DWRN, 100, , Local2)
Store (Local2, Arg1[5])

// Design Capacity of Low
Divide (Multiply (Local0, DLOW), 100, , Local2)
Store (Local2, Index (Arg1, 6))
Divide (Local0 * DLOW, 100, , Local2)
Store (Local2, Arg1[6])

// Get battery info from mainboard
Store (ToString(Concatenate(BMOD, 0x00)), Index (Arg1, 9))
Store (ToString(Concatenate(BSER, 0x00)), Index (Arg1, 10))
Store (ToString(Concatenate(BMFG, 0x00)), Index (Arg1, 12))
Store (ToString(Concatenate(BMOD, 0x00)), Arg1[9])
Store (ToString(Concatenate(BSER, 0x00)), Arg1[10])
Store (ToString(Concatenate(BMFG, 0x00)), Arg1[12])

Release (^BATM)
Return (Arg1)
Expand All @@ -108,30 +108,30 @@ Method (BBIX, 2, Serialized)
Return (Arg1)
}
// Last Full Charge Capacity
Store (BTDF, Index (Arg1, 3))
Store (BTDF, Arg1[3])

// Design Voltage
Store (BTDV, Index (Arg1, 5))
Store (BTDV, Arg1[5])

// Design Capacity
Store (BTDA, Local0)
Store (Local0, Index (Arg1, 2))
Store (Local0, Arg1[2])

// Design Capacity of Warning
Divide (Multiply (Local0, DWRN), 100, , Local2)
Store (Local2, Index (Arg1, 6))
Divide (Local0 * DWRN, 100, , Local2)
Store (Local2, Arg1[6])

// Design Capacity of Low
Divide (Multiply (Local0, DLOW), 100, , Local2)
Store (Local2, Index (Arg1, 7))
Divide (Local0 * DLOW, 100, , Local2)
Store (Local2, Arg1[7])

// Cycle Count
Store (BTCC, Index (Arg1, 8))
Store (BTCC, Arg1[8])

// Get battery info from mainboard
Store (ToString(Concatenate(BMOD, 0x00)), Index (Arg1, 16))
Store (ToString(Concatenate(BSER, 0x00)), Index (Arg1, 17))
Store (ToString(Concatenate(BMFG, 0x00)), Index (Arg1, 19))
Store (ToString(Concatenate(BMOD, 0x00)), Arg1[16])
Store (ToString(Concatenate(BSER, 0x00)), Arg1[17])
Store (ToString(Concatenate(BMFG, 0x00)), Arg1[19])

Release (^BATM)
Return (Arg1)
Expand Down Expand Up @@ -177,7 +177,7 @@ Method (BBST, 4, Serialized)
If (BFCR) {
Or (Local1, 0x04, Local1)
}
Store (Local1, Index (Arg1, 0))
Store (Local1, Arg1[0])

// Notify if battery state has changed since last time
If (LNotEqual (Local1, DeRefOf (Arg2))) {
Expand All @@ -195,13 +195,13 @@ Method (BBST, 4, Serialized)
//
// 1: BATTERY PRESENT RATE
//
Store (BTPR, Index (Arg1, 1))
Store (BTPR, Arg1[1])

//
// 2: BATTERY REMAINING CAPACITY
//
Store (BTRA, Local1)
If (LAnd (Arg3, LAnd (ACEX, LNot (LAnd (BFDC, BFCG))))) {
If (Arg3 && ACEX && !(BFDC && BFCG)) {
// On AC power and battery is neither charging
// nor discharging. Linux expects a full battery
// to report same capacity as last full charge.
Expand All @@ -210,18 +210,17 @@ Method (BBST, 4, Serialized)

// See if within ~6% of full
ShiftRight (Local2, 4, Local3)
If (LAnd (LGreater (Local1, Subtract (Local2, Local3)),
LLess (Local1, Add (Local2, Local3))))
If (LGreater (Local1, Local2 - Local3) && LLess (Local1, Local2 + Local3))
{
Store (Local2, Local1)
}
}
Store (Local1, Index (Arg1, 2))
Store (Local1, Arg1[2])

//
// 3: BATTERY PRESENT VOLTAGE
//
Store (BTVO, Index (Arg1, 3))
Store (BTVO, Arg1[3])

Release (^BATM)
Return (Arg1)
Expand Down
52 changes: 26 additions & 26 deletions src/ec/google/chromeec/acpi/ec.asl
Expand Up @@ -198,7 +198,7 @@ Device (EC0)
}

/* Adjust by offset to get Kelvin */
Add (\_SB.PCI0.LPCB.EC0.TOFS, Local0, Local0)
Local0 += \_SB.PCI0.LPCB.EC0.TOFS

/* Convert to 1/10 Kelvin */
Multiply (Local0, 10, Local0)
Expand All @@ -209,7 +209,7 @@ Device (EC0)
// Lid Closed Event
Method (_Q01, 0, NotSerialized)
{
Store ("EC: LID CLOSE", Debug)
Printf ("EC: LID CLOSE")
Store (LIDS, \LIDS)
#ifdef EC_ENABLE_LID_SWITCH
Notify (LID0, 0x80)
Expand All @@ -219,7 +219,7 @@ Device (EC0)
// Lid Open Event
Method (_Q02, 0, NotSerialized)
{
Store ("EC: LID OPEN", Debug)
Printf ("EC: LID OPEN")
Store (LIDS, \LIDS)
Notify (CREC, 0x2)
#ifdef EC_ENABLE_LID_SWITCH
Expand All @@ -230,13 +230,13 @@ Device (EC0)
// Power Button
Method (_Q03, 0, NotSerialized)
{
Store ("EC: POWER BUTTON", Debug)
Printf ("EC: POWER BUTTON")
}

// AC Connected
Method (_Q04, 0, NotSerialized)
{
Store ("EC: AC CONNECTED", Debug)
Printf ("EC: AC CONNECTED")
Store (ACEX, \PWRS)
Notify (AC, 0x80)
#ifdef DPTF_ENABLE_CHARGER
Expand All @@ -250,7 +250,7 @@ Device (EC0)
// AC Disconnected
Method (_Q05, 0, NotSerialized)
{
Store ("EC: AC DISCONNECTED", Debug)
Printf ("EC: AC DISCONNECTED")
Store (ACEX, \PWRS)
Notify (AC, 0x80)
#ifdef DPTF_ENABLE_CHARGER
Expand All @@ -264,21 +264,21 @@ Device (EC0)
// Battery Low Event
Method (_Q06, 0, NotSerialized)
{
Store ("EC: BATTERY LOW", Debug)
Printf ("EC: BATTERY LOW")
Notify (BAT0, 0x80)
}

// Battery Critical Event
Method (_Q07, 0, NotSerialized)
{
Store ("EC: BATTERY CRITICAL", Debug)
Printf ("EC: BATTERY CRITICAL")
Notify (BAT0, 0x80)
}

// Battery Info Event
Method (_Q08, 0, NotSerialized)
{
Store ("EC: BATTERY INFO", Debug)
Printf ("EC: BATTERY INFO")
Notify (BAT0, 0x81)
#ifdef EC_ENABLE_SECOND_BATTERY_DEVICE
If (CondRefOf (BAT1)) {
Expand All @@ -290,49 +290,49 @@ Device (EC0)
// Thermal Overload Event
Method (_Q0A, 0, NotSerialized)
{
Store ("EC: THERMAL OVERLOAD", Debug)
Printf ("EC: THERMAL OVERLOAD")
Notify (\_TZ, 0x80)
}

// Thermal Event
Method (_Q0B, 0, NotSerialized)
{
Store ("EC: THERMAL", Debug)
Printf ("EC: THERMAL")
Notify (\_TZ, 0x80)
}

// USB Charger
Method (_Q0C, 0, NotSerialized)
{
Store ("EC: USB CHARGER", Debug)
Printf ("EC: USB CHARGER")
}

// Key Pressed
Method (_Q0D, 0, NotSerialized)
{
Store ("EC: KEY PRESSED", Debug)
Printf ("EC: KEY PRESSED")
Notify (CREC, 0x2)
}

// Thermal Shutdown Imminent
Method (_Q10, 0, NotSerialized)
{
Store ("EC: THERMAL SHUTDOWN", Debug)
Printf ("EC: THERMAL SHUTDOWN")
Notify (\_TZ, 0x80)
}

// Battery Shutdown Imminent
Method (_Q11, 0, NotSerialized)
{
Store ("EC: BATTERY SHUTDOWN", Debug)
Printf ("EC: BATTERY SHUTDOWN")
Notify (BAT0, 0x80)
}

// Throttle Start
Method (_Q12, 0, NotSerialized)
{
#ifdef EC_ENABLE_THROTTLING_HANDLER
Store ("EC: THROTTLE START", Debug)
Printf ("EC: THROTTLE START")
\_TZ.THRT (1)
#endif
}
Expand All @@ -341,7 +341,7 @@ Device (EC0)
Method (_Q13, 0, NotSerialized)
{
#ifdef EC_ENABLE_THROTTLING_HANDLER
Store ("EC: THROTTLE STOP", Debug)
Printf ("EC: THROTTLE STOP")
\_TZ.THRT (0)
#endif
}
Expand All @@ -350,15 +350,15 @@ Device (EC0)
// PD event
Method (_Q16, 0, NotSerialized)
{
Store ("EC: GOT PD EVENT", Debug)
Printf ("EC: GOT PD EVENT")
Notify (\_SB.PCI0.LPCB.EC0.CREC.ECPD, 0x80)
}
#endif

// Battery Status
Method (_Q17, 0, NotSerialized)
{
Store ("EC: BATTERY STATUS", Debug)
Printf ("EC: BATTERY STATUS")
Notify (BAT0, 0x80)
#ifdef EC_ENABLE_SECOND_BATTERY_DEVICE
If (CondRefOf (BAT1)) {
Expand All @@ -370,23 +370,23 @@ Device (EC0)
// MKBP interrupt.
Method (_Q1B, 0, NotSerialized)
{
Store ("EC: MKBP", Debug)
Printf ("EC: MKBP")
Notify (CREC, 0x80)
}

#ifdef EC_ENABLE_PD_MCU_DEVICE
// USB MUX Interrupt
Method (_Q1C, 0, NotSerialized)
{
Store ("EC: USB MUX", Debug)
Printf ("EC: USB MUX")
Notify (\_SB.PCI0.LPCB.EC0.CREC.ECPD, 0x80)
}
#endif

// TABLET mode switch Event
Method (_Q1D, 0, NotSerialized)
{
Store ("EC: TABLET mode switch Event", Debug)
Printf ("EC: TABLET mode switch Event")
Notify (CREC, 0x2)
#ifdef EC_ENABLE_MULTIPLE_DPTF_PROFILES
\_SB.DPTF.TPET()
Expand Down Expand Up @@ -426,7 +426,7 @@ Device (EC0)
Divide (ToInteger (Arg1), 10, , Local1)

/* Adjust by EC temperature offset */
Subtract (Local1, ^TOFS, ^PATT)
^PATT = Local1 - ^TOFS

/* Set commit value with SELECT=0 and ENABLE=1 */
Store (0x02, ^PATC)
Expand All @@ -453,7 +453,7 @@ Device (EC0)
Divide (ToInteger (Arg1), 10, , Local1)

/* Adjust by EC temperature offset */
Subtract (Local1, ^TOFS, ^PATT)
^PATT = Local1 - ^TOFS

/* Set commit value with SELECT=1 and ENABLE=1 */
Store (0x03, ^PATC)
Expand Down Expand Up @@ -489,7 +489,7 @@ Device (EC0)
*/
Method (_Q09, 0, NotSerialized)
{
If (LNot(Acquire (^PATM, 1000))) {
If (!Acquire (^PATM, 1000)) {
/* Read sensor ID for event */
Store (^PATI, Local0)

Expand Down Expand Up @@ -542,7 +542,7 @@ Device (EC0)
If (LEqual (^DDPN, 0)) {
Return (^TBMD)
} Else {
Subtract (^DDPN, 1, Local0)
Local0 = ^DDPN - 1
Return (Local0)
}
}
Expand Down
11 changes: 9 additions & 2 deletions src/ec/google/chromeec/ec_acpi.c
Expand Up @@ -144,13 +144,20 @@ static void fill_ssdt_typec_device(const struct device *dev)
struct ec_google_chromeec_config *config = dev->chip_info;
int rv;
int i;
unsigned int num_ports;
unsigned int num_ports = 0;
struct device *usb2_port;
struct device *usb3_port;
struct device *usb4_port;
struct acpi_pld pld = {0};
uint32_t pcap_mask = 0;

if (google_chromeec_get_num_pd_ports(&num_ports))
rv = google_chromeec_get_num_pd_ports(&num_ports);
if (rv || num_ports == 0)
return;

/* If we can't get port caps, we shouldn't bother creating a device. */
rv = google_chromeec_get_cmd_versions(EC_CMD_GET_PD_PORT_CAPS, &pcap_mask);
if (rv || pcap_mask == 0)
return;

acpigen_write_scope(acpi_device_path(dev));
Expand Down
14 changes: 10 additions & 4 deletions src/ec/hp/kbc1126/Kconfig
Expand Up @@ -27,6 +27,12 @@ config KBC1126_FIRMWARE
Select this option to add the two firmware blobs for KBC1126.
You need these two blobs to power on your machine.

config ECFW_PTR_ADDR
default 0xffffff00

config ECFW_PTR_SIZE
default 8

config KBC1126_FW1
string "KBC1126 firmware #1 path and filename"
depends on KBC1126_FIRMWARE
Expand All @@ -37,9 +43,9 @@ config KBC1126_FW1
vendor firmware.

config KBC1126_FW1_OFFSET
string "Offset of KBC1126 firmware #1"
hex "Offset of KBC1126 firmware #1"
depends on KBC1126_FIRMWARE
default "0xfffe8000"
default 0xfffe8000

config KBC1126_FW2
string "KBC1126 filename #2 path and filename"
Expand All @@ -51,8 +57,8 @@ config KBC1126_FW2
vendor firmware.

config KBC1126_FW2_OFFSET
string "Offset of KBC1126 firmware #2"
hex "Offset of KBC1126 firmware #2"
depends on KBC1126_FIRMWARE
default "0xfffd0000"
default 0xfffd0000

endif
12 changes: 2 additions & 10 deletions src/ec/hp/kbc1126/Makefile.inc
@@ -1,7 +1,8 @@
## SPDX-License-Identifier: GPL-2.0-only

ifeq ($(CONFIG_EC_HP_KBC1126_ECFW_IN_CBFS),y)
KBC1126_EC_INSERT:=$(top)/util/kbc1126/kbc1126_ec_insert

bootblock-y += ecfw_ptr.c

ifeq ($(CONFIG_KBC1126_FIRMWARE),y)
cbfs-files-y += ecfw1.bin
Expand All @@ -16,15 +17,6 @@ ecfw2.bin-position := $(CONFIG_KBC1126_FW2_OFFSET)
ecfw2.bin-type := raw
endif

$(call add_intermediate, kbc1126_ec_insert)
ifeq ($(CONFIG_KBC1126_FIRMWARE),y)
printf " Building kbc1126_ec_insert.\n"
$(MAKE) -C util/kbc1126
printf " KBC1126 Inserting KBC1126 firmware blobs.\n"
$(KBC1126_EC_INSERT) $(obj)/coreboot.pre \
$(CONFIG_KBC1126_FW1_OFFSET) $(CONFIG_KBC1126_FW2_OFFSET)
endif

build_complete::
ifeq ($(CONFIG_KBC1126_FIRMWARE),)
printf "\n** WARNING **\n"
Expand Down
2 changes: 1 addition & 1 deletion src/ec/hp/kbc1126/acpi/ac.asl
Expand Up @@ -65,7 +65,7 @@ Device (AC)

Method (_Q06, 0, NotSerialized)
{
Store ("EC: AC STATUS", Debug)
Printf ("EC: AC STATUS")
PWUP (0x05, (0x02 | 0x01))
If (BTDR (0x02))
{
Expand Down
12 changes: 6 additions & 6 deletions src/ec/hp/kbc1126/acpi/battery.asl
Expand Up @@ -230,7 +230,7 @@ Method (\ISTR, 2, Serialized)
{
Local1--
Divide (Local0, 10, Local2, Local0)
Add (Local2, 48, Index (NUMB, Local1))
NUMB[Local1] = Local2 + 48
}
ToString (NUMB, Arg1, Local3)
Return (Local3)
Expand Down Expand Up @@ -437,7 +437,7 @@ Method (SBTN, 2, Serialized)

Method (_Q03, 0, NotSerialized)
{
Store ("EC: _Q03", Debug)
Printf ("EC: _Q03")
Acquire (BTMX, 0xFFFF)
Local0 = NDCB
Release (BTMX)
Expand All @@ -447,7 +447,7 @@ Method (_Q03, 0, NotSerialized)

Method (_Q08, 0, NotSerialized)
{
Store ("EC: PRIMARY BATTERY ATTACHED/DETACHED", Debug)
Printf ("EC: PRIMARY BATTERY ATTACHED/DETACHED")
PWUP (0x06, 0x01)
Local0 = GBAP ()
If ((Local0 != 0x02))
Expand All @@ -467,7 +467,7 @@ Method (_Q08, 0, NotSerialized)

Method (_Q09, 0, NotSerialized)
{
Store ("EC: PRIMARY BATTERY STATUS", Debug)
Printf ("EC: PRIMARY BATTERY STATUS")
PWUP (0x04, 0x01)
If (BTDR (0x02))
{
Expand All @@ -477,7 +477,7 @@ Method (_Q09, 0, NotSerialized)

Method (_Q18, 0, NotSerialized)
{
Store("EC: SECONDARY BATTERY ATTACHED/DETACHED", Debug)
Printf ("EC: SECONDARY BATTERY ATTACHED/DETACHED")
PWUP (0x06, 0x02)
Local0 = GBAP ()
If ((Local0 != 0x01))
Expand All @@ -497,7 +497,7 @@ Method (_Q18, 0, NotSerialized)

Method (_Q19, 0, NotSerialized)
{
Store ("EC: SECONDARY BATTERY STATUS", Debug)
Printf ("EC: SECONDARY BATTERY STATUS")
PWUP (0x04, 0x02)
If (BTDR (0x02))
{
Expand Down
10 changes: 5 additions & 5 deletions src/ec/hp/kbc1126/acpi/ec.asl
Expand Up @@ -202,27 +202,27 @@ Device (EC0)

Method (_Q04, 0, NotSerialized)
{
Store ("EC: _Q04", Debug)
Printf ("EC: _Q04")
PNOT()
}

Method (_Q05, 0, NotSerialized)
{
Store ("EC: _Q05", Debug)
Printf ("EC: _Q05")
}

Method (_Q0B, 0, NotSerialized)
{
Store ("EC: _Q0B", Debug)
Printf ("EC: _Q0B")
}

Method (_Q0C, 0, NotSerialized)
{
Store ("EC: _Q0C", Debug)
Printf ("EC: _Q0C")
}

Method (_Q0D, 0, NotSerialized)
{
Store ("EC: _Q0D", Debug)
Printf ("EC: _Q0D")
}
}
2 changes: 1 addition & 1 deletion src/ec/hp/kbc1126/acpi/lid.asl
Expand Up @@ -12,6 +12,6 @@ Device (LID)

Method (_Q0A, 0, NotSerialized)
{
Store ("EC: LID STATUS", Debug)
Printf ("EC: LID STATUS")
Notify (LID, 0x80)
}
16 changes: 16 additions & 0 deletions src/ec/hp/kbc1126/ecfw_ptr.c
@@ -0,0 +1,16 @@
/* SPDX-License-Identifier: GPL-2.0-only */

#include <endian.h>
#include "ecfw_ptr.h"

/*
* Address info for EC SMSC KBC1098/KBC1126 to find their firmware blobs,
* linked to CONFIG_ECFW_PTR_ADDR via src/arch/x86/bootblock.ld
*/
__attribute__((used, __section__(".ecfw_ptr")))
const struct ecfw_ptr ecfw_ptr = {
.fw1.off = cpu_to_be16((uint16_t)(CONFIG_KBC1126_FW1_OFFSET >> 8)),
.fw1.inv = cpu_to_be16((uint16_t)~(CONFIG_KBC1126_FW1_OFFSET >> 8)),
.fw2.off = cpu_to_be16((uint16_t)(CONFIG_KBC1126_FW2_OFFSET >> 8)),
.fw2.inv = cpu_to_be16((uint16_t)~(CONFIG_KBC1126_FW2_OFFSET >> 8)),
};
20 changes: 20 additions & 0 deletions src/ec/hp/kbc1126/ecfw_ptr.h
@@ -0,0 +1,20 @@
/* SPDX-License-Identifier: GPL-2.0-only */

#ifndef _EC_HP_KBC1126_PTR_H
#define _EC_HP_KBC1126_PTR_H

#include <stdint.h>

struct __attribute__((__packed__)) ecfw_addr {
/* 8-byte offset of firmware blob in big endian */
uint16_t off;
/* bitwise inverse of "off", for error checking */
uint16_t inv;
};

struct __attribute__((__packed__)) ecfw_ptr {
struct ecfw_addr fw1;
struct ecfw_addr fw2;
};

#endif
6 changes: 3 additions & 3 deletions src/ec/kontron/it8516e/acpi/pm_channels.asl
Expand Up @@ -36,7 +36,7 @@ Device (PM1) {
Return (0)
}
Multiply (Local0, 10, Local0) /* Convert to 10th °C */
Return (Add (Local0, 2732)) /* Return as 10th Kelvin */
Return (Local0 + 2732) /* Return as 10th Kelvin */
}
}
#endif
Expand Down Expand Up @@ -91,8 +91,8 @@ Device (PM2) {
Release (EC_MUTEX)

Or (ShiftLeft (Local1, 8), Local0, Local0)
Store (Divide (Multiply (Local0, 10), 64), Local0) /* Convert to 10th °C */
Return (Add (Local0, 2732)) /* Return as 10th Kelvin */
Store (Local0 * 10 / 64, Local0) /* Convert to 10th °C */
Return (Local0 + 2732) /* Return as 10th Kelvin */
}
}
#endif
2 changes: 1 addition & 1 deletion src/ec/kontron/kempld/kempld_gpio.c
Expand Up @@ -2,7 +2,7 @@

#include <stdint.h>
#include <arch/io.h>
#include <delay.h>

#include "chip.h"
#include "kempld.h"
#include "kempld_internal.h"
Expand Down
10 changes: 5 additions & 5 deletions src/ec/lenovo/h8/acpi/thermal.asl
Expand Up @@ -12,7 +12,7 @@ Scope(\_TZ)
Method(C2K, 1, NotSerialized)
{
Multiply(Arg0, 10, Local0)
Add (Local0, 2732, Local0)
Local0 += 2732
if (LLessEqual(Local0, 2732)) {
Return (3000)
}
Expand Down Expand Up @@ -73,7 +73,7 @@ External (\PPKG, MethodObj)
Method(_TMP) {
#if defined(EC_LENOVO_H8_ME_WORKAROUND)
/* Avoid tripping alarm if ME isn't booted at all yet */
If (LAnd (LNot (MEB1), LEqual (\_SB.PCI0.LPCB.EC.TMP0, 128))) {
If (!MEB1 && LEqual (\_SB.PCI0.LPCB.EC.TMP0, 128)) {
Return (C2K(40))
}
Store (1, MEB1)
Expand All @@ -85,11 +85,11 @@ External (\PPKG, MethodObj)
Store (GPSV (), Local0)

/* Active fan 10 degree below passive threshold */
Subtract (Local0, 10, Local0)
Local0 -= 10

If (\FLVL) {
/* Turn of 5 degree below trip point */
Subtract (Local0, 5, Local0)
Local0 -= 5
}

Return (C2K (Local0))
Expand Down Expand Up @@ -160,7 +160,7 @@ External (\PPKG, MethodObj)
Method(_TMP) {
#if defined(EC_LENOVO_H8_ME_WORKAROUND)
/* Avoid tripping alarm if ME isn't booted at all yet */
If (LAnd (LNot (MEB2), LEqual (\_SB.PCI0.LPCB.EC.TMP1, 128))) {
If (!MEB2 && LEqual (\_SB.PCI0.LPCB.EC.TMP1, 128)) {
Return (C2K(40))
}
Store (1, MEB2)
Expand Down
10 changes: 5 additions & 5 deletions src/ec/lenovo/h8/acpi/thinkpad.asl
Expand Up @@ -37,21 +37,21 @@ Device (HKEY)
Store (BTN, Local0)
If (LNotEqual (Local0, Zero)) {
Store (Zero, BTN)
Add (Local0, 0x1000, Local0)
Local0 += 0x1000
Return (Local0)
}
Store (BTAB, Local0)
If (LNotEqual (Local0, Zero)) {
Store (Zero, BTAB)
Add (Local0, 0x5000, Local0)
Local0 += 0x5000
Return (Local0)
}
Return (Zero)
}

/* Report event */
Method (RHK, 1, NotSerialized) {
ShiftLeft (One, Subtract (Arg0, 1), Local0)
ShiftLeft (One, Arg0 - 1, Local0)
If (And (EMSK, Local0)) {
Store (Arg0, BTN)
Notify (HKEY, 0x80)
Expand All @@ -60,7 +60,7 @@ Device (HKEY)

/* Report tablet */
Method (RTAB, 1, NotSerialized) {
ShiftLeft (One, Subtract (Arg0, 1), Local0)
ShiftLeft (One, Arg0 - 1, Local0)
If (And (ETAB, Local0)) {
Store (Arg0, BTAB)
Notify (HKEY, 0x80)
Expand All @@ -84,7 +84,7 @@ Device (HKEY)
/* Enable/disable event. */
Method (MHKM, 2, NotSerialized) {
If (LLessEqual (Arg0, 0x20)) {
ShiftLeft (One, Subtract (Arg0, 1), Local0)
ShiftLeft (One, Arg0 - 1, Local0)
If (Arg1)
{
Or (DHKN, Local0, DHKN)
Expand Down
54 changes: 27 additions & 27 deletions src/ec/purism/librem-ec/acpi/ec.asl
Expand Up @@ -34,7 +34,7 @@ Device (\_SB.PCI0.LPCB.EC0)
Name (ECOK, Zero)
Method (_REG, 2, Serialized) // _REG: Region Availability
{
Debug = Concatenate("EC: _REG", Concatenate(ToHexString(Arg0), Concatenate(" ", ToHexString(Arg1))))
Printf ("EC: _REG %o %o", ToHexString(Arg0), ToHexString(Arg1))
If ((Arg0 == 0x03) && (Arg1 == One)) {
// Enable hardware touchpad lock, airplane mode, and keyboard backlight keys
ECOS = 1
Expand Down Expand Up @@ -63,15 +63,15 @@ Device (\_SB.PCI0.LPCB.EC0)
}

Method (PTS, 1, Serialized) {
Debug = Concatenate("EC: PTS: ", ToHexString(Arg0))
Printf ("EC: PTS: %o", ToHexString(Arg0))
If (ECOK) {
// Clear wake cause
WFNO = Zero
}
}

Method (WAK, 1, Serialized) {
Debug = Concatenate("EC: WAK: ", ToHexString(Arg0))
Printf ("EC: WAK: %o", ToHexString(Arg0))
If (ECOK) {
// Set current AC state
^^^^AC.ACFG = ADP
Expand All @@ -91,63 +91,63 @@ Device (\_SB.PCI0.LPCB.EC0)

Method (_Q0A, 0, NotSerialized) // Touchpad Toggle
{
Debug = "EC: Touchpad Toggle"
Printf ("EC: Touchpad Toggle")
}

Method (_Q0B, 0, NotSerialized) // Screen Toggle
{
Debug = "EC: Screen Toggle"
Printf ("EC: Screen Toggle")
}

Method (_Q0C, 0, NotSerialized) // Mute
{
Debug = "EC: Mute"
Printf ("EC: Mute")
}

Method (_Q0D, 0, NotSerialized) // Keyboard Backlight
{
Debug = "EC: Keyboard Backlight"
Printf ("EC: Keyboard Backlight")
}

Method (_Q0E, 0, NotSerialized) // Volume Down
{
Debug = "EC: Volume Down"
Printf ("EC: Volume Down")
}

Method (_Q0F, 0, NotSerialized) // Volume Up
{
Debug = "EC: Volume Up"
Printf ("EC: Volume Up")
}

Method (_Q10, 0, NotSerialized) // Switch Video Mode
{
Debug = "EC: Switch Video Mode"
Printf ("EC: Switch Video Mode")
}

Method (_Q11, 0, NotSerialized) // Brightness Down
{
Debug = "EC: Brightness Down"
Printf ("EC: Brightness Down")
if (^^^^HIDD.HRDY) {
^^^^HIDD.HPEM (20)
}
}

Method (_Q12, 0, NotSerialized) // Brightness Up
{
Debug = "EC: Brightness Up"
Printf ("EC: Brightness Up")
if (^^^^HIDD.HRDY) {
^^^^HIDD.HPEM (19)
}
}

Method (_Q13, 0, NotSerialized) // Camera Toggle
{
Debug = "EC: Camera Toggle"
Printf ("EC: Camera Toggle")
}

Method (_Q14, 0, NotSerialized) // Airplane Mode
{
Debug = "EC: Airplane Mode"
Printf ("EC: Airplane Mode")
if (^^^^HIDD.HRDY) {
^^^^HIDD.HPEM (8)
}
Expand All @@ -156,13 +156,13 @@ Device (\_SB.PCI0.LPCB.EC0)

Method (_Q15, 0, NotSerialized) // Suspend Button
{
Debug = "EC: Suspend Button"
Printf ("EC: Suspend Button")
Notify (SLPB, 0x80)
}

Method (_Q16, 0, NotSerialized) // AC Detect
{
Debug = "EC: AC Detect"
Printf ("EC: AC Detect")
^^^^AC.ACFG = ADP
Notify (AC, 0x80) // Status Change
If (BAT0)
Expand All @@ -174,25 +174,25 @@ Device (\_SB.PCI0.LPCB.EC0)

Method (_Q17, 0, NotSerialized) // BAT0 Update
{
Debug = "EC: BAT0 Update (17)"
Printf ("EC: BAT0 Update (17)")
Notify (^^^^BAT0, 0x81) // Information Change
}

Method (_Q19, 0, NotSerialized) // BAT0 Update
{
Debug = "EC: BAT0 Update (19)"
Printf ("EC: BAT0 Update (19)")
Notify (^^^^BAT0, 0x81) // Information Change
}

Method (_Q1B, 0, NotSerialized) // Lid Close
{
Debug = "EC: Lid Close"
Printf ("EC: Lid Close")
Notify (LID0, 0x80)
}

Method (_Q1C, 0, NotSerialized) // Thermal Trip
{
Debug = "EC: Thermal Trip"
Printf ("EC: Thermal Trip")
/* TODO
Notify (\_TZ.TZ0, 0x81) // Thermal Trip Point Change
Notify (\_TZ.TZ0, 0x80) // Thermal Status Change
Expand All @@ -201,30 +201,30 @@ Device (\_SB.PCI0.LPCB.EC0)

Method (_Q1D, 0, NotSerialized) // Power Button
{
Debug = "EC: Power Button"
Printf ("EC: Power Button")
Notify (PWRB, 0x80)
}

Method (_Q50, 0, NotSerialized) // Other Events
{
Local0 = OEM4
If (Local0 == 0x8A) {
Debug = "EC: White Keyboard Backlight"
Printf ("EC: White Keyboard Backlight")
Notify (^^^^LIEC, 0x80)
} ElseIf (Local0 == 0x9F) {
Debug = "EC: Color Keyboard Toggle"
Printf ("EC: Color Keyboard Toggle")
Notify (^^^^LIEC, 0x81)
} ElseIf (Local0 == 0x81) {
Debug = "EC: Color Keyboard Down"
Printf ("EC: Color Keyboard Down")
Notify (^^^^LIEC, 0x82)
} ElseIf (Local0 == 0x82) {
Debug = "EC: Color Keyboard Up"
Printf ("EC: Color Keyboard Up")
Notify (^^^^LIEC, 0x83)
} ElseIf (Local0 == 0x80) {
Debug = "EC: Color Keyboard Color Change"
Printf ("EC: Color Keyboard Color Change")
Notify (^^^^LIEC, 0x84)
} Else {
Debug = Concatenate("EC: Other: ", ToHexString(Local0))
Printf ("EC: Other: %o", ToHexString(Local0))
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/ec/purism/librem-ec/acpi/librem-ec.asl
Expand Up @@ -11,13 +11,13 @@ Device (LIEC) {
Name (_UID, 0)

Method (RSET, 0, Serialized) {
Debug = "LIEC: RSET"
Printf ("LIEC: RSET")
SAPL(0)
SKBL(0)
}

Method (INIT, 0, Serialized) {
Debug = "LIEC: INIT"
Printf ("LIEC: INIT")
RSET()
If (^^PCI0.LPCB.EC0.ECOK) {
// Set flags to use software control
Expand All @@ -29,7 +29,7 @@ Device (LIEC) {
}

Method (FINI, 0, Serialized) {
Debug = "LIEC: FINI"
Printf ("LIEC: FINI")
RSET()
If (^^PCI0.LPCB.EC0.ECOK) {
// Set flags to use hardware control
Expand Down
34 changes: 16 additions & 18 deletions src/ec/quanta/ene_kb3940q/acpi/ec.asl
Expand Up @@ -12,7 +12,7 @@ Device (EC0)
{
Name (_HID, EISAID ("PNP0C09"))
Name (_UID, 1)
Name (_GPE, Add(EC_SCI_GPI, 16)) // GPE for Runtime SCI
Name (_GPE, EC_SCI_GPI + 16) // GPE for Runtime SCI

OperationRegion (ERAM, EmbeddedControl, 0x00, 0xff)
Field (ERAM, ByteAcc, Lock, Preserve)
Expand Down Expand Up @@ -135,13 +135,11 @@ Device (EC0)

// Find and program number of P-States
Store (SizeOf (\_SB.CP00._PSS), MPST)
Store ("Programming number of P-states: ", Debug)
Store (MPST, Debug)
Printf ("Programming number of P-states: %o", MPST)

// Find and program the current P-State
Store(\_SB.CP00._PPC, NPST)
Store ("Programming Current P-state: ", Debug)
Store (NPST, Debug)
Printf ("Programming Current P-state: %o", NPST)
}

/*
Expand All @@ -163,26 +161,26 @@ Device (EC0)
// Wifi Button Event
Method (_Q07)
{
Store ("Wifi Button Event 0x07", Debug)
Printf ("Wifi Button Event 0x07")
}

// Thermal Event
Method (_Q08)
{
Store ("Thermal Event 0x08", Debug)
Printf ("Thermal Event 0x08")
Notify(\_TZ.THRM, 0x80)
}

// Pstate Down
Method (_Q0E)
{
Store ("Pstate Event 0x0E", Debug)
Printf ("Pstate Event 0x0E")

Store(\_SB.CP00._PPC, Local0)
Subtract(PPCM, 0x01, Local1)
Local1 = PPCM - 1

If(LLess(Local0, Local1)) {
Increment(Local0)
Local0++
\PPCN ()
}

Expand All @@ -192,11 +190,11 @@ Device (EC0)
// Pstate Up
Method (_Q0F)
{
Store ("Pstate Event 0x0F", Debug)
Printf ("Pstate Event 0x0F")
Store(\_SB.CP00._PPC, Local0)

If(Local0) {
Decrement(Local0)
Local0--
\PPCN ()
}

Expand All @@ -206,7 +204,7 @@ Device (EC0)
// AC Power Connected
Method (_Q10, 0, NotSerialized)
{
Store ("AC Insertion Event 0x10", Debug)
Printf ("AC Insertion Event 0x10")
Store (One, \PWRS)
Notify (AC, 0x80)
Notify (BATX, 0x80)
Expand All @@ -216,7 +214,7 @@ Device (EC0)
// AC Power Removed
Method (_Q11, 0, NotSerialized)
{
Store ("AC Detach Event 0x11", Debug)
Printf ("AC Detach Event 0x11")
Store (Zero, \PWRS)
Notify (AC, 0x80)
Notify (BATX, 0x80)
Expand All @@ -226,7 +224,7 @@ Device (EC0)
// Battery State Change - Attach Event
Method (_Q12, 0, NotSerialized)
{
Store ("Battery Insertion Event 0x12", Debug)
Printf ("Battery Insertion Event 0x12")

Notify (BATX, 0x81)
Notify (BATX, 0x80)
Expand All @@ -236,7 +234,7 @@ Device (EC0)
// Battery State Change - Detach Event
Method (_Q13, 0, NotSerialized)
{
Store ("Battery Detach Event 0x13", Debug)
Printf ("Battery Detach Event 0x13")

Notify (BATX, 0x81)
Notify (BATX, 0x80)
Expand All @@ -247,15 +245,15 @@ Device (EC0)
// Battery State Change Event
Method (_Q14, 0, NotSerialized)
{
Store ("Battery State Change Event 0x14", Debug)
Printf ("Battery State Change Event 0x14")

Notify (BATX, 0x80)
}

// Lid Switch Event
Method (_Q06)
{
Store ("Lid Switch Event 0x06", Debug)
Printf ("Lid Switch Event 0x06")
sleep(20)
Store (LIDF, \LIDS)
Notify (\_SB.LID0, 0x80)
Expand Down
43 changes: 21 additions & 22 deletions src/ec/quanta/it8518/acpi/battery.asl
Expand Up @@ -67,7 +67,7 @@ Device (BATX)
{
// EC Is not ready
Sleep (5)
Decrement (Local0)
Local0--
If (LEqual (Local0, Zero))
{
Break
Expand Down Expand Up @@ -106,7 +106,7 @@ Device (BATX)
// ACPI spec : 0 - mWh : 1 - mAh
//
Store(SBCM, Local7)
XOr (Local7, One, Index (PBIF, 0))
XOr (Local7, One, PBIF[0])

//
// Information ID 0 -
Expand All @@ -119,11 +119,11 @@ Device (BATX)
//
If (Local7)
{
Multiply (SBFC, 10, Index (PBIF, 2))
Multiply (SBFC, 10, PBIF[2])
}
Else
{
Store (SBFC, Index (PBIF, 2))
Store (SBFC, PBIF[2])
}

//
Expand All @@ -143,24 +143,24 @@ Device (BATX)
{
Store (SBDC, Local0)
}
Store (Local0, Index(PBIF, One))
Store (Local0, PBIF[1])

//
// Design capacity of High (5%)
// Design capacity of Low (1%)
//
Divide (Local0, 20, , Index (PBIF, 5))
Divide (Local0, 100, , Index (PBIF, 6))
Divide (Local0, 20, , PBIF[5])
Divide (Local0, 100, , PBIF[6])

//
// Design voltage
//
Store (SBDV, Index (PBIF, 4))
Store (SBDV, PBIF[4])

//
// Serial Number
//
Store (ToHexString (SBSN), Index (PBIF, 10))
Store (ToHexString (SBSN), PBIF[10])

//
// Information ID 4 -
Expand All @@ -171,7 +171,7 @@ Device (BATX)
//
// Battery Type - Device Chemistry
//
Store (ToString (Concatenate(SBCH, 0x00)), Index (PBIF, 11))
Store (ToString (Concatenate(SBCH, 0x00)), PBIF[11])

//
// Information ID 5 -
Expand All @@ -182,7 +182,7 @@ Device (BATX)
//
// OEM Information - Manufacturer Name
//
Store (ToString (Concatenate(SBMN, 0x00)), Index (PBIF, 12))
Store (ToString (Concatenate(SBMN, 0x00)), PBIF[12])

//
// Information ID 6 -
Expand All @@ -193,7 +193,7 @@ Device (BATX)
//
// Model Number - Device Name
//
Store (ToString (Concatenate(SBDN, 0x00)), Index (PBIF, 9))
Store (ToString (Concatenate(SBDN, 0x00)), PBIF[9])

Return (PBIF)
}
Expand Down Expand Up @@ -255,7 +255,7 @@ Device (BATX)
// Flag if the battery level is critical
And (Local0, 0x04, Local4)
Or (Local1, Local4, Local1)
Store (Local1, Index (PBST, 0))
Store (Local1, PBST[0])

//
// 1: BATTERY PRESENT RATE/CURRENT
Expand All @@ -265,7 +265,7 @@ Device (BATX)
{
If (And (Local0, 1))
{
Subtract (0x10000, Local1, Local1)
Local1 = 0x10000 - Local1
}
Else
{
Expand All @@ -275,21 +275,21 @@ Device (BATX)
}
Else
{
If (LNot (AND (Local0, 2)))
If (!(AND (Local0, 2)))
{
// Battery is not charging
Store (Zero, Local1)
}
}

XOr (DerefOf (Index (PBIF, Zero)), One, Local6)
XOr (DerefOf (PBIF[0]), One, Local6)

If (Local6)
{
Multiply (ECVO, Local1, Local1)
Divide (Local1, 1000, , Local1)
}
Store (Local1, Index (PBST, One))
Store (Local1, PBST[1])

//
// 2: BATTERY REMAINING CAPACITY
Expand All @@ -306,7 +306,7 @@ Device (BATX)
Store (ECRC, Local1)
}

If (LAnd (BFWK, LAnd (ACPW, LNot (Local0))))
If (BFWK && ACPW && !Local0)
{
// On AC power and battery is neither charging
// nor discharging. Linux expects a full battery
Expand All @@ -317,18 +317,17 @@ Device (BATX)

// See if within ~3% of full
ShiftRight (Local2, 5, Local3)
If (LAnd (LGreater (Local1, Subtract (Local2, Local3)),
LLess (Local1, Add (Local2, Local3))))
If (LGreater (Local1, Local2 - Local3) && LLess (Local1, Local2 + Local3))
{
Store (Local2, Local1)
}
}
Store (Local1, Index (PBST, 2))
Store (Local1, PBST[2])

//
// 3: BATTERY PRESENT VOLTAGE
//
Store (ECVO, Index (PBST, 3))
Store (ECVO, PBST[3])

Return (PBST)
}
Expand Down
5 changes: 2 additions & 3 deletions src/ec/quanta/it8518/acpi/ec.asl
Expand Up @@ -10,7 +10,7 @@ Device (EC0)
{
Name (_HID, EISAID ("PNP0C09"))
Name (_UID, 1)
Name (_GPE, Add(EC_SCI_GPI, 16)) // GPE for Runtime SCI
Name (_GPE, EC_SCI_GPI + 16) // GPE for Runtime SCI

// EC RAM fields
OperationRegion(ERAM, EmbeddedControl, 0, 0xFF)
Expand Down Expand Up @@ -556,8 +556,7 @@ Device (EC0)
// TODO Which temperature corresponds to the CPU?
Store (TMP0, Local0)
/* So that we don't get a warning that Local0 is unused. */
Increment (Local0)

Local0++
}

/* Attention Codes
Expand Down
38 changes: 18 additions & 20 deletions src/ec/smsc/mec1308/acpi/battery.asl
Expand Up @@ -81,15 +81,15 @@ Device (BAT0)
Method (_BIF, 0, Serialized)
{
// Update fields from EC
Store (SWAB (BTDA), Index (PBIF, 1))
Store (SWAB (BTDF), Index (PBIF, 2))
Store (SWAB (BTDV), Index (PBIF, 4))
Store (SWAB (BTDL), Index (PBIF, 6))
Store (SWAB (BTDA), PBIF[1])
Store (SWAB (BTDF), PBIF[2])
Store (SWAB (BTDV), PBIF[4])
Store (SWAB (BTDL), PBIF[6])

// Get battery info from mainboard
Store (\BATM, Index (PBIF, 9))
Store (\BATS, Index (PBIF, 10))
Store (\BATV, Index (PBIF, 12))
Store (\BATM, PBIF[9])
Store (\BATS, PBIF[10])
Store (\BATV, PBIF[12])

Return (PBIF)
}
Expand Down Expand Up @@ -120,7 +120,7 @@ Device (BAT0)
// Flag if the battery level is critical
And (Local0, 0x04, Local4)
Or (Local1, Local4, Local1)
Store (Local1, Index (PBST, 0))
Store (Local1, PBST[0])

// Notify if battery state has changed since last time
If (LNotEqual (Local1, BSTP)) {
Expand All @@ -133,24 +133,22 @@ Device (BAT0)
//

Store (SWAB (BTPR), Local1)
If (LAnd (LNotEqual (Local1, 0xFFFFFFFF),
LGreaterEqual (Local1, 0x8000))) {
If (LNotEqual (Local1, 0xFFFFFFFF) && LGreaterEqual (Local1, 0x8000)) {
Xor (Local1, 0xFFFF, Local1)
Increment (Local1)
Local1++
}
Store (Local1, Index (PBST, 1))
Store (Local1, PBST[1])

//
// 2: BATTERY REMAINING CAPACITY
//
Store (SWAB (BTRA), Local1)
If (LAnd (LNotEqual (Local1, 0xFFFFFFFF),
LGreaterEqual (Local1, 0x8000))) {
If (LNotEqual (Local1, 0xFFFFFFFF) && LGreaterEqual (Local1, 0x8000)) {
Xor (Local1, 0xFFFF, Local1)
Increment (Local1)
Local1++
}

If (LAnd (BFWK, LAnd (ACEX, LNot (Local0)))) {
If (BFWK && ACEX && !Local0) {
// On AC power and battery is neither charging
// nor discharging. Linux expects a full battery
// to report same capacity as last full charge.
Expand All @@ -159,18 +157,18 @@ Device (BAT0)

// See if within ~3% of full
ShiftRight (Local2, 5, Local3)
If (LAnd (LGreater (Local1, Subtract (Local2, Local3)),
LLess (Local1, Add (Local2, Local3))))
If (LGreater (Local1, Local2 - Local3) &&
LLess (Local1, Local2 + Local3))
{
Store (Local2, Local1)
}
}
Store (Local1, Index (PBST, 2))
Store (Local1, PBST[2])

//
// 3: BATTERY PRESENT VOLTAGE
//
Store (SWAB (BTVO), Index (PBST, 3))
Store (SWAB (BTVO), PBST[3])

Return (PBST)
}
Expand Down
2 changes: 1 addition & 1 deletion src/ec/smsc/mec1308/acpi/ec.asl
Expand Up @@ -69,7 +69,7 @@ Device (EC0)
// Force a read of CPU temperature
Store (CPUT, Local0)
/* So that we don't get a warning that Local0 is unused. */
Increment (Local0)
Local0++
}

PowerResource (FNP0, 0, 0)
Expand Down
4 changes: 4 additions & 0 deletions src/ec/starlabs/merlin/Kconfig
Expand Up @@ -55,3 +55,7 @@ config EC_STARLABS_MERLIN
config EC_VARIANT_DIR
string
default "merlin" if EC_STARLABS_MERLIN

config EC_GPE_SCI
hex
default 0x50
4 changes: 2 additions & 2 deletions src/ec/starlabs/merlin/acpi/cmos.asl
Expand Up @@ -26,8 +26,8 @@ Field (CMS2, ByteAcc, NoLock, Preserve)
IndexField (IND2, DAT2, ByteAcc, NoLock, Preserve)
{
Offset (0x80),
FLKS, 8, // Function Lock State
TPLS, 8, // Trackpad State
FLKC, 8, // Function Lock State
TPLC, 8, // Trackpad State
KLBC, 8, // Keyboard Backlight Brightness
KLSC, 8, // Keyboard Backlight State
}
4 changes: 2 additions & 2 deletions src/ec/starlabs/merlin/acpi/ec.asl
Expand Up @@ -10,7 +10,7 @@ Scope (\_SB.PCI0.LPCB)
{
Name (_HID, EisaId ("PNP0C09"))
Name (_UID, 0x01)
Name (_GPE, EC_GPE_SCI)
Name (_GPE, CONFIG_EC_GPE_SCI)
Name (ECAV, 0x00)
Name (ECTK, 0x01)
Name (B2ST, 0x00)
Expand Down Expand Up @@ -126,7 +126,7 @@ Scope (\_SB.PCI0.LPCB)
}
Sleep (1)
Arg1 = Arg0
Add (Local1, 1, Local1)
Local1 += 1
If (Local1 == 0x03) {
Break
}
Expand Down
4 changes: 2 additions & 2 deletions src/ec/starlabs/merlin/acpi/hid.asl
Expand Up @@ -303,7 +303,7 @@ Device (HIDD) // HID Device
//
Case (0x03)
{
HDSM (DeRefOf(Index(Arg3, 0x00)))
HDSM (DeRefOf(Arg3[0]))
}
//
// Function 4, HDEM. HID Driver Event Method.
Expand Down Expand Up @@ -332,7 +332,7 @@ Device (HIDD) // HID Device
//
Case (0x06)
{
BTNE (DeRefOf(Index(Arg3, 0x00)))
BTNE (DeRefOf(Arg3[0]))
}
//
// Function 7 HEBC. Button implemented state.
Expand Down
24 changes: 12 additions & 12 deletions src/ec/starlabs/merlin/acpi/keyboard.asl
Expand Up @@ -2,25 +2,25 @@

Method(_Q80) // Volume up
{
Store ("-----> _Q80", Debug)
Printf ("-----> _Q80")
Notify (\_SB.HIDD, 0xC4)
Notify (\_SB.HIDD, 0xC5)
Store ("<----- _Q80", Debug)
Printf ("<----- _Q80")
}

Method(_Q81) // Volume down
{
Store ("-----> _Q81", Debug)
Printf ("-----> _Q81")
Notify (\_SB.HIDD, 0xC6)
Notify (\_SB.HIDD, 0xC7)
Store ("<----- _Q81", Debug)
Printf ("<----- _Q81")
}

Method(_Q99) // Wireless mode
{
Store ("-----> _Q99", Debug)
Printf ("-----> _Q99")
^^^^HIDD.HPEM (8)
Store ("<----- _Q99", Debug)
Printf ("<----- _Q99")
}

Method(_Q06) // Brightness decrease
Expand All @@ -40,20 +40,20 @@ Method(_Q08) // FN lock QEvent

Method(_Q54) // Power Button Event
{
Store ("-----> _Q54", Debug)
Store ("<----- _Q54", Debug)
Printf ("-----> _Q54")
Printf ("<----- _Q54")
}

Method(_QD5) // 10 second power button press
{
Store ("-----> _QD5", Debug)
Printf ("-----> _QD5")
\_SB.PWPR()
Store ("<----- _QD5", Debug)
Printf ("<----- _QD5")
}

Method(_QD6) // 10 second power button de-press
{
Store ("-----> _QD6", Debug)
Printf ("-----> _QD6")
\_SB.PWRR()
Store ("<----- _QD6", Debug)
Printf ("<----- _QD6")
}
4 changes: 2 additions & 2 deletions src/ec/starlabs/merlin/acpi/suspend.asl
Expand Up @@ -7,8 +7,8 @@ Method (RPTS, 1, NotSerialized)
If ((Arg0 == 0x04) || (Arg0 == 0x05))
{
/* Store current EC settings */
\_SB.PCI0.LPCB.EC.TPLA = \_SB.PCI0.LPCB.TPLS
\_SB.PCI0.LPCB.EC.FLKA = \_SB.PCI0.LPCB.FLKS
\_SB.PCI0.LPCB.EC.TPLE = \_SB.PCI0.LPCB.TPLC
\_SB.PCI0.LPCB.EC.FLKE = \_SB.PCI0.LPCB.FLKC
\_SB.PCI0.LPCB.EC.KLBE = \_SB.PCI0.LPCB.KLBC
}
}
Expand Down
1 change: 0 additions & 1 deletion src/ec/starlabs/merlin/ec.c
@@ -1,7 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-only */

#include <console/console.h>
#include <delay.h>
#include <device/device.h>
#include <device/pnp.h>
#include <ec/acpi/ec.h>
Expand Down
4 changes: 2 additions & 2 deletions src/ec/starlabs/merlin/variants/apl/emem.asl
Expand Up @@ -16,7 +16,7 @@ Field (ECF2, ByteAcc, Lock, Preserve)
CDEV, 8, // Control Device
OSFG, 8, // OS Flag
CWFU, 8, // CW2015 Full
TPLA, 8, // Trackpad State
TPLE, 8, // Trackpad State
AFG3, 8, // After G3
CLTP, 8, // Close Trackpad
WKOL, 8, // Wake on Lid
Expand All @@ -39,7 +39,7 @@ Field (ECF2, ByteAcc, Lock, Preserve)
ECT9, 8, // EC Build Time 9

Offset(0x2c),
FLKA, 8, // Function Lock State
FLKE, 8, // Function Lock State

Offset(0x30),
STEF, 8, // Sensor T Error F
Expand Down
14 changes: 7 additions & 7 deletions src/ec/starlabs/merlin/variants/apl/events.asl
Expand Up @@ -36,15 +36,15 @@ Method (_Q07, 0, NotSerialized) // Event: Backlight Brightness Up

Method (_Q08, 0, NotSerialized) // Event: Function Lock
{
FLKS = FLKA
FLKC = FLKE
}
//
// TODO:
// Below Q Events need to be added
//
// Method (_Q04, 0, NotSerialized) // Event: Trackpad Lock
// {
// TPLS = TPLA
// TPLC = TPLE
// }
//
// Method (_Q__, 0, NotSerialized) // Event: Keyboard Backlight Brightness
Expand All @@ -70,27 +70,27 @@ Method (_QD6, 0, NotSerialized) // Event: 10 Second Power Button Released

Method (_Q22, 0, NotSerialized) // Event: CHARGER_T
{
Store ("EC: CHARGER_T", Debug)
Printf ("EC: CHARGER_T")
}

Method (_Q80, 0, NotSerialized) // Event: Volume Up
{
Store ("EC: VOLUME_UP", Debug)
Printf ("EC: VOLUME_UP")
}

Method (_Q81, 0, NotSerialized) // Event: Volume Down
{
Store ("EC: VOLUME_DOWN", Debug)
Printf ("EC: VOLUME_DOWN")
}

Method (_Q54, 0, NotSerialized) // Event: Power Button Press
{
Store ("EC: PWRBTN", Debug)
Printf ("EC: PWRBTN")
}

Method (_QF0, 0, NotSerialized) // Event: Temperature Report
{
Store ("EC: Temperature Report", Debug)
Printf ("EC: Temperature Report")
}

Method (_QF1, 0, NotSerialized) // Event: Temperature Trigger
Expand Down
4 changes: 2 additions & 2 deletions src/ec/starlabs/merlin/variants/cml/emem.asl
Expand Up @@ -27,7 +27,7 @@ Field (ECF2, ByteAcc, Lock, Preserve)
OSFG, 8, // OS Flag

Offset(0x14),
TPLA, 8, // Trackpad State
TPLE, 8, // Trackpad State
AFG3, 8, // After G3
CLTP, 8, // Close Trackpad
WKOL, 8, // Wake on Lid
Expand All @@ -51,7 +51,7 @@ Field (ECF2, ByteAcc, Lock, Preserve)
ECT7, 8, // EC Build Time 7
ECT8, 8, // EC Build Time 8
ECT9, 8, // EC Build Time 9
FLKA, 8, // Function Lock State
FLKE, 8, // Function Lock State
MICF, 8, // Mic Flag
MUTF, 8, // Mute Flag
BC12, 8, // BC12 Flag
Expand Down
20 changes: 10 additions & 10 deletions src/ec/starlabs/merlin/variants/cml/events.asl
Expand Up @@ -36,12 +36,12 @@ Method (_Q07, 0, NotSerialized) // Event: Backlight Brightness Up

Method (_Q08, 0, NotSerialized) // Event: Function Lock
{
FLKS = FLKA
FLKC = FLKE
}

Method (_Q04, 0, NotSerialized) // Event: Trackpad Lock
{
TPLS = TPLA
TPLC = TPLE
}
//
// TODO:
Expand Down Expand Up @@ -69,7 +69,7 @@ Method (_QD6, 0, NotSerialized) // Event: 10 Second Power Button Released

Method (_Q22, 0, NotSerialized) // Event: CHARGER_T
{
Store ("EC: CHARGER_T", Debug)
Printf ("EC: CHARGER_T")
}

Method (_Q40, 0, NotSerialized) // Event: AC and DC Power
Expand Down Expand Up @@ -99,22 +99,22 @@ Method (_Q44, 0, NotSerialized) // Event: AC Power Only

Method (_Q80, 0, NotSerialized) // Event: Volume Up
{
Store ("EC: VOLUME_UP", Debug)
Printf ("EC: VOLUME_UP")
}

Method (_Q81, 0, NotSerialized) // Event: Volume Down
{
Store ("EC: VOLUME_DOWN", Debug)
Printf ("EC: VOLUME_DOWN")
}

Method (_Q54, 0, NotSerialized) // Event: Power Button Press
{
Store ("EC: PWRBTN", Debug)
Printf ("EC: PWRBTN")
}

Method (_QF0, 0, NotSerialized) // Event: Temperature Report
{
Store ("EC: Temperature Report", Debug)
Printf ("EC: Temperature Report")
}

Method (_QF1, 0, NotSerialized) // Event: Temperature Trigger
Expand All @@ -129,15 +129,15 @@ Method (_QF1, 0, NotSerialized) // Event: Temperature Trigger

Method (_Q02, 0, NotSerialized) // Event: APP
{
Store ("EC: APP", Debug)
Printf ("EC: APP")
}

Method (_Q82, 0, NotSerialized) // Event: MIC
{
Store ("EC: MIC", Debug)
Printf ("EC: MIC")
}

Method (_Q83, 0, NotSerialized) // Event: MUTE
{
Store ("EC: MUTE", Debug)
Printf ("EC: MUTE")
}
4 changes: 2 additions & 2 deletions src/ec/starlabs/merlin/variants/glk/emem.asl
Expand Up @@ -16,7 +16,7 @@ Field (ECF2, ByteAcc, Lock, Preserve)
CDEV, 8, // Control Device
OSFG, 8, // OS Flag
CWFU, 8, // CW2015 Full
TPLA, 8, // Trackpad State
TPLE, 8, // Trackpad State
AFG3, 8, // After G3
CLTP, 8, // Close Trackpad
WKOL, 8, // Wake on Lid
Expand All @@ -39,7 +39,7 @@ Field (ECF2, ByteAcc, Lock, Preserve)
ECT9, 8, // EC Build Time 9

Offset(0x2c),
FLKA, 8, // Function Lock State
FLKE, 8, // Function Lock State

Offset(0x30),
STEF, 8, // Sensor T Error F
Expand Down
14 changes: 7 additions & 7 deletions src/ec/starlabs/merlin/variants/glk/events.asl
Expand Up @@ -36,15 +36,15 @@ Method (_Q07, 0, NotSerialized) // Event: Backlight Brightness Up

Method (_Q08, 0, NotSerialized) // Event: Function Lock
{
FLKS = FLKA
FLKC = FLKE
}
//
// TODO:
// Below Q Events need to be added
//
// Method (_Q04, 0, NotSerialized) // Event: Trackpad Lock
// {
// TPLS = TPLA
// TPLC = TPLE
// }
//
// Method (_Q__, 0, NotSerialized) // Event: Keyboard Backlight Brightness
Expand All @@ -70,27 +70,27 @@ Method (_QD6, 0, NotSerialized) // Event: 10 Second Power Button Released

Method (_Q22, 0, NotSerialized) // Event: CHARGER_T
{
Store ("EC: CHARGER_T", Debug)
Printf ("EC: CHARGER_T")
}

Method (_Q80, 0, NotSerialized) // Event: Volume Up
{
Store ("EC: VOLUME_UP", Debug)
Printf ("EC: VOLUME_UP")
}

Method (_Q81, 0, NotSerialized) // Event: Volume Down
{
Store ("EC: VOLUME_DOWN", Debug)
Printf ("EC: VOLUME_DOWN")
}

Method (_Q54, 0, NotSerialized) // Event: Power Button Press
{
Store ("EC: PWRBTN", Debug)
Printf ("EC: PWRBTN")
}

Method (_QF0, 0, NotSerialized) // Event: Temperature Report
{
Store ("EC: Temperature Report", Debug)
Printf ("EC: Temperature Report")
}

Method (_QF1, 0, NotSerialized) // Event: Temperature Trigger
Expand Down
4 changes: 2 additions & 2 deletions src/ec/starlabs/merlin/variants/kbl/emem.asl
Expand Up @@ -22,7 +22,7 @@ Field (ECF2, ByteAcc, Lock, Preserve)
OSFG, 8, // OS Flag

Offset(0x14),
TPLA, 8, // Trackpad State
TPLE, 8, // Trackpad State

Offset(0x18),
KLSE, 8, // Keyboard Backlight State
Expand All @@ -34,7 +34,7 @@ Field (ECF2, ByteAcc, Lock, Preserve)
TCHF, 8, // Thermal Charge Flag

Offset(0x2c),
FLKA, 8, // Function Lock State
FLKE, 8, // Function Lock State

Offset(0x30),
STEF, 8, // Sensor T Error F
Expand Down
70 changes: 35 additions & 35 deletions src/ec/starlabs/merlin/variants/kbl/events.asl
Expand Up @@ -36,15 +36,15 @@ Method (_Q07, 0, NotSerialized) // Event: Backlight Brightness Up

Method (_Q08, 0, NotSerialized) // Event: Function Lock
{
FLKS = FLKA
FLKC = FLKE
}
//
// TODO:
// Below Q Events need to be added
//
// Method (_Q04, 0, NotSerialized) // Event: Trackpad Lock
// {
// TPLS = TPLA
// TPLC = TPLE
// }
//
// Method (_Q__, 0, NotSerialized) // Event: Keyboard Backlight Brightness
Expand All @@ -71,7 +71,7 @@ Method (_QD6, 0, NotSerialized) // Event: 10 Second Power Button Released

Method (_Q22, 0, NotSerialized) // Event: CHARGER_T
{
Store ("EC: CHARGER_T", Debug)
Printf ("EC: CHARGER_T")
}

//
Expand Down Expand Up @@ -105,22 +105,22 @@ Method (_Q22, 0, NotSerialized) // Event: CHARGER_T

Method (_Q80, 0, NotSerialized) // Event: Volume Up
{
Store ("EC: VOLUME_UP", Debug)
Printf ("EC: VOLUME_UP")
}

Method (_Q81, 0, NotSerialized) // Event: Volume Down
{
Store ("EC: VOLUME_DOWN", Debug)
Printf ("EC: VOLUME_DOWN")
}

Method (_Q54, 0, NotSerialized) // Event: Power Button Press
{
Store ("EC: PWRBTN", Debug)
Printf ("EC: PWRBTN")
}

Method (_QF0, 0, NotSerialized) // Event: Temperature Report
{
Store ("EC: Temperature Report", Debug)
Printf ("EC: Temperature Report")
}

Method (_QF1, 0, NotSerialized) // Event: Temperature Trigger
Expand All @@ -135,141 +135,141 @@ Method (_QF1, 0, NotSerialized) // Event: Temperature Trigger

Method (_Q85, 0, NotSerialized) // Event: HOME
{
Store ("EC: HOME", Debug)
Printf ("EC: HOME")
}

Method (_Q79, 0, NotSerialized) // Event: USB Type-C
{
Store ("EC: USB Type-C", Debug)
Printf ("EC: USB Type-C")
UCEV()
}

Method (_Q0E, 0, NotSerialized) // Event: SLEEP
{
Store ("EC: SLEEP", Debug)
Printf ("EC: SLEEP")
}

Method (_Q13, 0, NotSerialized) // Event: BRIGHTNESS
{
Store ("EC: BRIGHTNESS", Debug)
Printf ("EC: BRIGHTNESS")
}

Method (_Q20, 0, NotSerialized) // Event: CPU_T
{
Store ("EC: CPU_T", Debug)
Printf ("EC: CPU_T")
}

Method (_Q21, 0, NotSerialized) // Event: SKIN_T
{
Store ("EC: SKIN_T", Debug)
Printf ("EC: SKIN_T")
}

Method (_Q30, 0, NotSerialized) // Event: THROT_OFF
{
Store ("EC: THROT_OFF", Debug)
Printf ("EC: THROT_OFF")
}

Method (_Q31, 0, NotSerialized) // Event: THROT_LV1
{
Store ("EC: THROT_LV1", Debug)
Printf ("EC: THROT_LV1")
}

Method (_Q32, 0, NotSerialized) // Event: THROT_LV2
{
Store ("EC: THROT_LV2", Debug)
Printf ("EC: THROT_LV2")
}

Method (_Q33, 0, NotSerialized) // Event: THROT_LV3
{
Store ("EC: THROT_LV3", Debug)
Printf ("EC: THROT_LV3")
}

Method (_Q34, 0, NotSerialized) // Event: THROT_LV4
{
Store ("EC: THROT_LV4", Debug)
Printf ("EC: THROT_LV4")
}

Method (_Q35, 0, NotSerialized) // Event: THROT_LV5
{
Store ("EC: THROT_LV5", Debug)
Printf ("EC: THROT_LV5")
}

Method (_Q36, 0, NotSerialized) // Event: THROT_LV6
{
Store ("EC: THROT_LV6", Debug)
Printf ("EC: THROT_LV6")
}

Method (_Q37, 0, NotSerialized) // Event: THROT_LV7
{
Store ("EC: THROT_LV7", Debug)
Printf ("EC: THROT_LV7")
}

Method (_Q38, 0, NotSerialized) // Event: CPU_DN_SPEED
{
Store ("EC: CPU_DN_SPEED", Debug)
Printf ("EC: CPU_DN_SPEED")
}

Method (_Q3C, 0, NotSerialized) // Event: CPU_UP_SPEED
{
Store ("EC: CPU_UP_SPEED", Debug)
Printf ("EC: CPU_UP_SPEED")
}

Method (_Q3D, 0, NotSerialized) // Event: CPU_TURBO_OFF
{
Store ("EC: CPU_TURBO_OFF", Debug)
Printf ("EC: CPU_TURBO_OFF")
}

Method (_Q3E, 0, NotSerialized) // Event: CPU_TURBO_ON
{
Store ("EC: CPU_TURBO_ON", Debug)
Printf ("EC: CPU_TURBO_ON")
}

Method (_Q3F, 0, NotSerialized) // Event: SHUTDOWN
{
Store ("EC: SHUTDOWN", Debug)
Printf ("EC: SHUTDOWN")
}

Method (_Q01, 0, NotSerialized) // Event: F1 Hot Key
{
Store ("EC: F1", Debug)
Printf ("EC: F1")
}

Method (_Q02, 0, NotSerialized) // Event: F2 Hot Key
{
Store ("EC: F2", Debug)
Printf ("EC: F2")
}

Method (_Q03, 0, NotSerialized) // Event: F3 Hot Key
{
Store ("EC: F3", Debug)
Printf ("EC: F3")
}

Method (_Q04, 0, NotSerialized) // Event: F4 Hot Key
{
Store ("EC: F4", Debug)
Printf ("EC: F4")
}

Method (_Q05, 0, NotSerialized) // Event: F5 Hot Key
{
Store ("EC: F5", Debug)
Printf ("EC: F5")
}

Method (_Q09, 0, NotSerialized) // Event: F9 Hot Key
{
Store ("EC: F9", Debug)
Printf ("EC: F9")
}

Method (_Q10, 0, NotSerialized) // Event: F10 Hot Key
{
Store ("EC: F10", Debug)
Printf ("EC: F10")
}

Method (_Q11, 0, NotSerialized) // Event: F11 Hot Key
{
Store ("EC: F11", Debug)
Printf ("EC: F11")
}

Method (_Q12, 0, NotSerialized) // Event: F12 Hot Key
{
Store ("EC: F6", Debug)
Printf ("EC: F6")
}
4 changes: 2 additions & 2 deletions src/ec/starlabs/merlin/variants/merlin/emem.asl
Expand Up @@ -38,8 +38,8 @@ Field (ECF2, ByteAcc, Lock, Preserve)

Offset(0x30), // Keyboard:
FCLA, 8, // Fn Ctrl Reverse
FLKA, 8, // Function Lock State
TPLA, 8, // Trackpad State
FLKE, 8, // Function Lock State
TPLE, 8, // Trackpad State
KLBE, 8, // Keyboard Backlight Brightness
KLSE, 8, // Keyboard Backlight State
KLTE, 8, // Keyboard Backlight Timeout
Expand Down
78 changes: 39 additions & 39 deletions src/ec/starlabs/merlin/variants/merlin/events.asl
Expand Up @@ -36,12 +36,12 @@ Method (_Q06) // Event: Backlight Brightness Up

Method (_Q87) // Event: Function Lock
{
FLKS = FLKA
FLKC = FLKE
}

Method (_Q88) // Event: Trackpad Lock
{
TPLS = TPLA
TPLC = TPLE
}
Method (_Q11) // Event: Keyboard Backlight Brightness
{
Expand All @@ -56,17 +56,17 @@ Method (_Q99) // Event: Airplane Mode

Method (_QD5) // Event: 10 Second Power Button Pressed
{
Store ("EC: 10 Second Power Button Pressed", Debug)
Printf ("EC: 10 Second Power Button Pressed")
}

Method (_QD6) // Event: 10 Second Power Button Released
{
Store ("EC: 10 Second Power Button Release", Debug)
Printf ("EC: 10 Second Power Button Release")
}

Method (_Q22, 0, NotSerialized) // Event: CHARGER_T
{
Store ("EC: CHARGER_T", Debug)
Printf ("EC: CHARGER_T")
}

Method (_Q40) // Event: AC_DC
Expand Down Expand Up @@ -96,22 +96,22 @@ Method (_Q44) // Event: AC_ONLY

Method (_Q80, 0, NotSerialized) // Event: VOLUME_UP
{
Store ("EC: VOLUME_UP", Debug)
Printf ("EC: VOLUME_UP")
}

Method (_Q81, 0, NotSerialized) // Event: VOLUME_DOWN
{
Store ("EC: VOLUME_DOWN", Debug)
Printf ("EC: VOLUME_DOWN")
}

Method (_Q54, 0, NotSerialized) // Event: PWRBTN
{
Store ("EC: PWRBTN", Debug)
Printf ("EC: PWRBTN")
}

Method (_QF0) // Event: Temperature Report
{
Store ("EC: Temperature Report", Debug)
Printf ("EC: Temperature Report")
}

Method (_QF1) // Event: Temperature Trigger
Expand All @@ -125,143 +125,143 @@ Method (_QF1) // Event: Temperature Trigger

Method (_Q79, 0, NotSerialized) // Event: USB Type-C
{
Store ("EC: USB Type-C", Debug)
Printf ("EC: USB Type-C")
UCEV()
}

Method (_Q85, 0, NotSerialized) // Event: HOME
{
Store ("EC: HOME", Debug)
Printf ("EC: HOME")
}

Method (_Q01) // Event: F1 Hot Key
{
Store ("EC: F1", Debug)
Printf ("EC: F1")
}

Method (_Q02) // Event: F2 Hot Key
{
Store ("EC: F2", Debug)
Printf ("EC: F2")
}

Method (_Q03) // Event: F3 Hot Key
{
Store ("EC: F3", Debug)
Printf ("EC: F3")
}

Method (_Q04) // Event: F4 Hot Key
{
Store ("EC: F4", Debug)
Printf ("EC: F4")
}

Method (_Q08) // Event: F5 Hot Key
{
Store ("EC: F5", Debug)
Printf ("EC: F5")
}

Method (_Q09) // Event: F6 Hot Key
{
Store ("EC: F6", Debug)
Printf ("EC: F6")
}

Method (_Q07) // Event: F7 Hot Key
{
Store ("EC: F7", Debug)
Printf ("EC: F7")
}

Method (_Q10) // Event: F10 Hot Key
{
Store ("EC: F10", Debug)
Printf ("EC: F10")
}

Method (_Q12) // Event: F12 Hot Key
{
Store ("EC: F6", Debug)
Printf ("EC: F6")
}

Method (_Q0E, 0, NotSerialized) // Event: SLEEP
{
Store ("EC: SLEEP", Debug)
Printf ("EC: SLEEP")
}

Method (_Q13, 0, NotSerialized) // Event: BRIGHTNESS
{
Store ("EC: BRIGHTNESS", Debug)
Printf ("EC: BRIGHTNESS")
}

Method (_Q20, 0, NotSerialized) // Event: CPU_T
{
Store ("EC: CPU_T", Debug)
Printf ("EC: CPU_T")
}

Method (_Q21, 0, NotSerialized) // Event: SKIN_T
{
Store ("EC: SKIN_T", Debug)
Printf ("EC: SKIN_T")
}

Method (_Q30, 0, NotSerialized) // Event: THROT_OFF
{
Store ("EC: THROT_OFF", Debug)
Printf ("EC: THROT_OFF")
}

Method (_Q31, 0, NotSerialized) // Event: THROT_LV1
{
Store ("EC: THROT_LV1", Debug)
Printf ("EC: THROT_LV1")
}

Method (_Q32, 0, NotSerialized) // Event: THROT_LV2
{
Store ("EC: THROT_LV2", Debug)
Printf ("EC: THROT_LV2")
}

Method (_Q33, 0, NotSerialized) // Event: THROT_LV3
{
Store ("EC: THROT_LV3", Debug)
Printf ("EC: THROT_LV3")
}

Method (_Q34, 0, NotSerialized) // Event: THROT_LV4
{
Store ("EC: THROT_LV4", Debug)
Printf ("EC: THROT_LV4")
}

Method (_Q35, 0, NotSerialized) // Event: THROT_LV5
{
Store ("EC: THROT_LV5", Debug)
Printf ("EC: THROT_LV5")
}

Method (_Q36, 0, NotSerialized) // Event: THROT_LV6
{
Store ("EC: THROT_LV6", Debug)
Printf ("EC: THROT_LV6")
}

Method (_Q37, 0, NotSerialized) // Event: THROT_LV7
{
Store ("EC: THROT_LV7", Debug)
Printf ("EC: THROT_LV7")
}

Method (_Q38, 0, NotSerialized) // Event: CPU_DN_SPEED
{
Store ("EC: CPU_DN_SPEED", Debug)
Printf ("EC: CPU_DN_SPEED")
}

Method (_Q3C, 0, NotSerialized) // Event: CPU_UP_SPEED
{
Store ("EC: CPU_UP_SPEED", Debug)
Printf ("EC: CPU_UP_SPEED")
}

Method (_Q3D, 0, NotSerialized) // Event: CPU_TURBO_OFF
{
Store ("EC: CPU_TURBO_OFF", Debug)
Printf ("EC: CPU_TURBO_OFF")
}

Method (_Q3E, 0, NotSerialized) // Event: CPU_TURBO_ON
{
Store ("EC: CPU_TURBO_ON", Debug)
Printf ("EC: CPU_TURBO_ON")
}

Method (_Q3F, 0, NotSerialized) // Event: SHUTDOWN
{
Store ("EC: SHUTDOWN", Debug)
Printf ("EC: SHUTDOWN")
}

Method (_Q45) // Event: SENSOR_T76
Expand All @@ -271,10 +271,10 @@ Method (_Q45) // Event: SENSOR_T76

Method (_Q48, 0, NotSerialized) // Event: Fan Turbo On
{
Store ("EC: Fan Turbo On", Debug)
Printf ("EC: Fan Turbo On")
}

Method (_Q49, 0, NotSerialized) // Event: Fan Turbo Off
{
Store ("EC: Fan Turbo Off", Debug)
Printf ("EC: Fan Turbo Off")
}
4 changes: 2 additions & 2 deletions src/ec/starlabs/merlin/variants/tgl/emem.asl
Expand Up @@ -17,10 +17,10 @@ Field (ECF2, ByteAcc, Lock, Preserve)
KLBE, 8, // Keyboard Backlight Brightness
KLSE, 8, // Keyboard Backlight State
BDID, 8, // Board ID
TPLA, 8, // Trackpad State
TPLE, 8, // Trackpad State
KBCD, 8, // Rotate Flag
WIFI, 8, // WiFi Enable
FLKA, 8, // Function Lock State
FLKE, 8, // Function Lock State
KLTE, 8, // Keyboard Backlight Timeout

Offset(0x13),
Expand Down