static int google_chromeec_command_version(void) { u8 id1, id2, flags; #if CONFIG_EC_GOOGLE_CHROMEEC_ACPI_MEMMAP if (read_memmap(&id1, EC_MEMMAP_ID) || read_memmap(&id2, EC_MEMMAP_ID + 1) || read_memmap(&flags, EC_MEMMAP_HOST_CMD_FLAGS)) { printk(BIOS_ERR, "Error reading memmap data.\n"); return -1; } #else id1 = read_byte(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_ID); id2 = read_byte(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_ID + 1); flags = read_byte(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_HOST_CMD_FLAGS); #endif if (id1 != 'E' || id2 != 'C') { printk(BIOS_ERR, "Missing Chromium EC memory map.\n"); return -1; } if (flags & EC_HOST_CMD_FLAG_VERSION_3) { return EC_HOST_CMD_FLAG_VERSION_3; } else if (flags & EC_HOST_CMD_FLAG_LPC_ARGS_SUPPORTED) { return EC_HOST_CMD_FLAG_LPC_ARGS_SUPPORTED; } else { printk(BIOS_ERR, "Chromium EC command version unsupported\n"); return -1; } }
static uint8_t read_byte(uint16_t addr) { if (addr >= 0x800 && addr <= 0x9ff) return read_memmap(addr); else return inb(addr); }