cros_ec_python.constants.LPC
1from .COMMON import BIT 2from typing import Final 3 4# I/O addresses for ACPI commands 5EC_LPC_ADDR_ACPI_DATA : Final = 0x62 6EC_LPC_ADDR_ACPI_CMD : Final = 0x66 7 8# I/O addresses for host command 9EC_LPC_ADDR_HOST_DATA : Final = 0x200 10EC_LPC_ADDR_HOST_CMD : Final = 0x204 11 12# I/O addresses for host command args and params 13# Protocol version 2 14EC_LPC_ADDR_HOST_ARGS : Final = 0x800 # And 0x801, 0x802, 0x803 15EC_LPC_ADDR_HOST_PARAM : Final = 0x804 # For version 2 params; size is 16 # EC_PROTO2_MAX_PARAM_SIZE 17 18# Protocol version 3 19EC_LPC_ADDR_HOST_PACKET : Final = 0x800 # Offset of version 3 packet 20EC_LPC_HOST_PACKET_SIZE : Final = 0x100 # Max size of version 3 packet 21 22 23# The actual block is 0x800-0x8ff, but some BIOSes think it's 0x880-0x8ff 24# and they tell the kernel that so we have to think of it as two parts. 25# 26# Other BIOSes report only the I/O port region spanned by the Microchip 27# MEC series EC; an attempt to address a larger region may fail. 28 29EC_HOST_CMD_REGION0 : Final = 0x800 30EC_HOST_CMD_REGION1 : Final = 0x880 31EC_HOST_CMD_REGION_SIZE : Final = 0x80 32EC_HOST_CMD_MEC_REGION_SIZE : Final = 0x8 33 34# EC command register bit functions 35EC_LPC_CMDR_DATA : Final = BIT(0) # Data ready for host to read 36EC_LPC_CMDR_PENDING : Final = BIT(1) # Write pending to EC 37EC_LPC_CMDR_BUSY : Final = BIT(2) # EC is busy processing a command 38EC_LPC_CMDR_CMD : Final = BIT(3) # Last host write was a command 39EC_LPC_CMDR_ACPI_BRST : Final = BIT(4) # Burst mode (not used) 40EC_LPC_CMDR_SCI : Final = BIT(5) # SCI event is pending 41EC_LPC_CMDR_SMI : Final = BIT(6) # SMI event is pending 42 43EC_LPC_ADDR_MEMMAP : Final = 0x900 44EC_LPC_ADDR_MEMMAP_FWAMD : Final = 0xE00 # Address on AMD Framework Laptops 45 46 47# Value written to legacy command port / prefix byte to indicate protocol 48# 3+ structs are being used. Usage is bus-dependent. 49 50EC_COMMAND_PROTOCOL_3: Final = 0xda 51 52EC_HOST_REQUEST_VERSION: Final = 3 53 54EC_HOST_RESPONSE_VERSION: Final = 3 55 56 57# LPC command status byte masks 58# EC has written a byte in the data register and host hasn't read it yet 59EC_LPC_STATUS_TO_HOST :Final = 0x01 60# Host has written a command/data byte and the EC hasn't read it yet 61EC_LPC_STATUS_FROM_HOST :Final = 0x02 62# EC is processing a command 63EC_LPC_STATUS_PROCESSING :Final = 0x04 64# Last write to EC was a command, not data 65EC_LPC_STATUS_LAST_CMD :Final = 0x08 66# EC is in burst mode 67EC_LPC_STATUS_BURST_MODE :Final = 0x10 68# SCI event is pending (requesting SCI query) 69EC_LPC_STATUS_SCI_PENDING :Final = 0x20 70# SMI event is pending (requesting SMI query) 71EC_LPC_STATUS_SMI_PENDING :Final = 0x40 72# (reserved) 73EC_LPC_STATUS_RESERVED :Final = 0x80 74 75 76# EC is busy. This covers both the EC processing a command, and the host has 77# written a new command but the EC hasn't picked it up yet. 78 79EC_LPC_STATUS_BUSY_MASK :Final = EC_LPC_STATUS_FROM_HOST | EC_LPC_STATUS_PROCESSING 80 81 82# Flags for ec_lpc_host_args.flags 83# 84# Args are from host. Data area at EC_LPC_ADDR_HOST_PARAM contains command 85# params. 86# 87# If EC gets a command and this flag is not set, this is an old-style command. 88# Command version is 0 and params from host are at EC_LPC_ADDR_OLD_PARAM with 89# unknown length. EC must respond with an old-style response (that is, 90# without setting EC_HOST_ARGS_FLAG_TO_HOST). 91 92EC_HOST_ARGS_FLAG_FROM_HOST: Final = 0x01 93 94# Args are from EC. Data area at EC_LPC_ADDR_HOST_PARAM contains response. 95# 96# If EC responds to a command and this flag is not set, this is an old-style 97# response. Command version is 0 and response data from EC is at 98# EC_LPC_ADDR_OLD_PARAM with unknown length. 99 100EC_HOST_ARGS_FLAG_TO_HOST: Final = 0x02
EC_LPC_ADDR_ACPI_DATA: Final =
98
EC_LPC_ADDR_ACPI_CMD: Final =
102
EC_LPC_ADDR_HOST_DATA: Final =
512
EC_LPC_ADDR_HOST_CMD: Final =
516
EC_LPC_ADDR_HOST_ARGS: Final =
2048
EC_LPC_ADDR_HOST_PARAM: Final =
2052
EC_LPC_ADDR_HOST_PACKET: Final =
2048
EC_LPC_HOST_PACKET_SIZE: Final =
256
EC_HOST_CMD_REGION0: Final =
2048
EC_HOST_CMD_REGION1: Final =
2176
EC_HOST_CMD_REGION_SIZE: Final =
128
EC_HOST_CMD_MEC_REGION_SIZE: Final =
8
EC_LPC_CMDR_DATA: Final =
1
EC_LPC_CMDR_PENDING: Final =
2
EC_LPC_CMDR_BUSY: Final =
4
EC_LPC_CMDR_CMD: Final =
8
EC_LPC_CMDR_ACPI_BRST: Final =
16
EC_LPC_CMDR_SCI: Final =
32
EC_LPC_CMDR_SMI: Final =
64
EC_LPC_ADDR_MEMMAP: Final =
2304
EC_LPC_ADDR_MEMMAP_FWAMD: Final =
3584
EC_COMMAND_PROTOCOL_3: Final =
218
EC_HOST_REQUEST_VERSION: Final =
3
EC_HOST_RESPONSE_VERSION: Final =
3
EC_LPC_STATUS_TO_HOST: Final =
1
EC_LPC_STATUS_FROM_HOST: Final =
2
EC_LPC_STATUS_PROCESSING: Final =
4
EC_LPC_STATUS_LAST_CMD: Final =
8
EC_LPC_STATUS_BURST_MODE: Final =
16
EC_LPC_STATUS_SCI_PENDING: Final =
32
EC_LPC_STATUS_SMI_PENDING: Final =
64
EC_LPC_STATUS_RESERVED: Final =
128
EC_LPC_STATUS_BUSY_MASK: Final =
6
EC_HOST_ARGS_FLAG_FROM_HOST: Final =
1
EC_HOST_ARGS_FLAG_TO_HOST: Final =
2