From: Vladimir Serbinenko Date: Mon, 22 Feb 2016 18:33:13 +0000 (+0100) Subject: cleaner X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6c9512b610facbd2f22f8db454e3d1b0e3d38d12;p=thirdparty%2Fgrub.git cleaner --- diff --git a/grub-core/term/arm/cros_ec.c b/grub-core/term/arm/cros_ec.c index 28ba2847f..169503d11 100644 --- a/grub-core/term/arm/cros_ec.c +++ b/grub-core/term/arm/cros_ec.c @@ -167,73 +167,6 @@ enum ec_status { EC_RES_BUSY = 16 /* Up but too busy. Should retry */ }; -/* - * Host event codes. Note these are 1-based, not 0-based, because ACPI query - * EC command uses code 0 to mean "no event pending". We explicitly specify - * each value in the enum listing so they won't change if we delete/insert an - * item or rearrange the list (it needs to be stable across platforms, not - * just within a single compiled instance). - */ -enum host_event_code { - EC_HOST_EVENT_LID_CLOSED = 1, - EC_HOST_EVENT_LID_OPEN = 2, - EC_HOST_EVENT_POWER_BUTTON = 3, - EC_HOST_EVENT_AC_CONNECTED = 4, - EC_HOST_EVENT_AC_DISCONNECTED = 5, - EC_HOST_EVENT_BATTERY_LOW = 6, - EC_HOST_EVENT_BATTERY_CRITICAL = 7, - EC_HOST_EVENT_BATTERY = 8, - EC_HOST_EVENT_THERMAL_THRESHOLD = 9, - EC_HOST_EVENT_THERMAL_OVERLOAD = 10, - EC_HOST_EVENT_THERMAL = 11, - EC_HOST_EVENT_USB_CHARGER = 12, - EC_HOST_EVENT_KEY_PRESSED = 13, - /* - * EC has finished initializing the host interface. The host can check - * for this event following sending a EC_CMD_REBOOT_EC command to - * determine when the EC is ready to accept subsequent commands. - */ - EC_HOST_EVENT_INTERFACE_READY = 14, - /* Keyboard recovery combo has been pressed */ - EC_HOST_EVENT_KEYBOARD_RECOVERY = 15, - - /* Shutdown due to thermal overload */ - EC_HOST_EVENT_THERMAL_SHUTDOWN = 16, - /* Shutdown due to battery level too low */ - EC_HOST_EVENT_BATTERY_SHUTDOWN = 17, - - /* Suggest that the AP throttle itself */ - EC_HOST_EVENT_THROTTLE_START = 18, - /* Suggest that the AP resume normal speed */ - EC_HOST_EVENT_THROTTLE_STOP = 19, - - /* Hang detect logic detected a hang and host event timeout expired */ - EC_HOST_EVENT_HANG_DETECT = 20, - /* Hang detect logic detected a hang and warm rebooted the AP */ - EC_HOST_EVENT_HANG_REBOOT = 21, - - /* PD MCU triggering host event */ - EC_HOST_EVENT_PD_MCU = 22, - - /* Battery Status flags have changed */ - EC_HOST_EVENT_BATTERY_STATUS = 23, - - /* EC encountered a panic, triggering a reset */ - EC_HOST_EVENT_PANIC = 24, - - /* Keyboard fastboot combo has been pressed */ - EC_HOST_EVENT_KEYBOARD_FASTBOOT = 25, - - /* - * The high bit of the event mask is not used as a host event code. If - * it reads back as set, then the entire event mask should be - * considered invalid by the host. This can happen when reading the - * raw event status via EC_MEMMAP_HOST_EVENTS but the LPC interface is - * not initialized on the EC, or improperly configured on the host. - */ - EC_HOST_EVENT_INVALID = 32 -}; - /* Flags for ec_lpc_host_args.flags */ /* * Args are from host. Data area at EC_LPC_ADDR_HOST_PARAM contains command @@ -1398,451 +1331,6 @@ enum gpio_get_subcmd { EC_GPIO_GET_INFO = 2, }; -/*****************************************************************************/ -/* I2C commands. Only available when flash write protect is unlocked. */ - -/* - * TODO(crosbug.com/p/23570): These commands are deprecated, and will be - * removed soon. Use EC_CMD_I2C_PASSTHRU instead. - */ - -/* Read I2C bus */ -#define EC_CMD_I2C_READ 0x94 - -struct ec_params_i2c_read { - uint16_t addr; /* 8-bit address (7-bit shifted << 1) */ - uint8_t read_size; /* Either 8 or 16. */ - uint8_t port; - uint8_t offset; -} __packed; -struct ec_response_i2c_read { - uint16_t data; -} __packed; - -/* Write I2C bus */ -#define EC_CMD_I2C_WRITE 0x95 - -struct ec_params_i2c_write { - uint16_t data; - uint16_t addr; /* 8-bit address (7-bit shifted << 1) */ - uint8_t write_size; /* Either 8 or 16. */ - uint8_t port; - uint8_t offset; -} __packed; - -/*****************************************************************************/ -/* Charge state commands. Only available when flash write protect unlocked. */ - -/* Force charge state machine to stop charging the battery or force it to - * discharge the battery. - */ -#define EC_CMD_CHARGE_CONTROL 0x96 -#define EC_VER_CHARGE_CONTROL 1 - -enum ec_charge_control_mode { - CHARGE_CONTROL_NORMAL = 0, - CHARGE_CONTROL_IDLE, - CHARGE_CONTROL_DISCHARGE, -}; - -struct ec_params_charge_control { - uint32_t mode; /* enum charge_control_mode */ -} __packed; - -/*****************************************************************************/ -/* Console commands. Only available when flash write protect is unlocked. */ - -/* Snapshot console output buffer for use by EC_CMD_CONSOLE_READ. */ -#define EC_CMD_CONSOLE_SNAPSHOT 0x97 - -/* - * Read data from the saved snapshot. If the subcmd parameter is - * CONSOLE_READ_NEXT, this will return data starting from the beginning of - * the latest snapshot. If it is CONSOLE_READ_RECENT, it will start from the - * end of the previous snapshot. - * - * The params are only looked at in version >= 1 of this command. Prior - * versions will just default to CONSOLE_READ_NEXT behavior. - * - * Response is null-terminated string. Empty string, if there is no more - * remaining output. - */ -#define EC_CMD_CONSOLE_READ 0x98 - -enum ec_console_read_subcmd { - CONSOLE_READ_NEXT = 0, - CONSOLE_READ_RECENT -}; - -struct ec_params_console_read_v1 { - uint8_t subcmd; /* enum ec_console_read_subcmd */ -} __packed; - -/*****************************************************************************/ - -/* - * Cut off battery power immediately or after the host has shut down. - * - * return EC_RES_INVALID_COMMAND if unsupported by a board/battery. - * EC_RES_SUCCESS if the command was successful. - * EC_RES_ERROR if the cut off command failed. - */ -#define EC_CMD_BATTERY_CUT_OFF 0x99 - -#define EC_BATTERY_CUTOFF_FLAG_AT_SHUTDOWN (1 << 0) - -struct ec_params_battery_cutoff { - uint8_t flags; -} __packed; - -/*****************************************************************************/ -/* USB port mux control. */ - -/* - * Switch USB mux or return to automatic switching. - */ -#define EC_CMD_USB_MUX 0x9a - -struct ec_params_usb_mux { - uint8_t mux; -} __packed; - -/*****************************************************************************/ -/* LDOs / FETs control. */ - -enum ec_ldo_state { - EC_LDO_STATE_OFF = 0, /* the LDO / FET is shut down */ - EC_LDO_STATE_ON = 1, /* the LDO / FET is ON / providing power */ -}; - -/* - * Switch on/off a LDO. - */ -#define EC_CMD_LDO_SET 0x9b - -struct ec_params_ldo_set { - uint8_t index; - uint8_t state; -} __packed; - -/* - * Get LDO state. - */ -#define EC_CMD_LDO_GET 0x9c - -struct ec_params_ldo_get { - uint8_t index; -} __packed; - -struct ec_response_ldo_get { - uint8_t state; -} __packed; - -/*****************************************************************************/ -/* Power info. */ - -/* - * Get power info. - */ -#define EC_CMD_POWER_INFO 0x9d - -struct ec_response_power_info { - uint32_t usb_dev_type; - uint16_t voltage_ac; - uint16_t voltage_system; - uint16_t current_system; - uint16_t usb_current_limit; -} __packed; - -/*****************************************************************************/ -/* I2C passthru command */ - -#define EC_CMD_I2C_PASSTHRU 0x9e - -/* Read data; if not present, message is a write */ -#define EC_I2C_FLAG_READ (1 << 15) - -/* Mask for address */ -#define EC_I2C_ADDR_MASK 0x3ff - -#define EC_I2C_STATUS_NAK (1 << 0) /* Transfer was not acknowledged */ -#define EC_I2C_STATUS_TIMEOUT (1 << 1) /* Timeout during transfer */ - -/* Any error */ -#define EC_I2C_STATUS_ERROR (EC_I2C_STATUS_NAK | EC_I2C_STATUS_TIMEOUT) - -struct ec_params_i2c_passthru_msg { - uint16_t addr_flags; /* I2C slave address (7 or 10 bits) and flags */ - uint16_t len; /* Number of bytes to read or write */ -} __packed; - -struct ec_params_i2c_passthru { - uint8_t port; /* I2C port number */ - uint8_t num_msgs; /* Number of messages */ - struct ec_params_i2c_passthru_msg msg[]; - /* Data to write for all messages is concatenated here */ -} __packed; - -struct ec_response_i2c_passthru { - uint8_t i2c_status; /* Status flags (EC_I2C_STATUS_...) */ - uint8_t num_msgs; /* Number of messages processed */ - uint8_t data[]; /* Data read by messages concatenated here */ -} __packed; - -/*****************************************************************************/ -/* Power button hang detect */ - -#define EC_CMD_HANG_DETECT 0x9f - -/* Reasons to start hang detection timer */ -/* Power button pressed */ -#define EC_HANG_START_ON_POWER_PRESS (1 << 0) - -/* Lid closed */ -#define EC_HANG_START_ON_LID_CLOSE (1 << 1) - - /* Lid opened */ -#define EC_HANG_START_ON_LID_OPEN (1 << 2) - -/* Start of AP S3->S0 transition (booting or resuming from suspend) */ -#define EC_HANG_START_ON_RESUME (1 << 3) - -/* Reasons to cancel hang detection */ - -/* Power button released */ -#define EC_HANG_STOP_ON_POWER_RELEASE (1 << 8) - -/* Any host command from AP received */ -#define EC_HANG_STOP_ON_HOST_COMMAND (1 << 9) - -/* Stop on end of AP S0->S3 transition (suspending or shutting down) */ -#define EC_HANG_STOP_ON_SUSPEND (1 << 10) - -/* - * If this flag is set, all the other fields are ignored, and the hang detect - * timer is started. This provides the AP a way to start the hang timer - * without reconfiguring any of the other hang detect settings. Note that - * you must previously have configured the timeouts. - */ -#define EC_HANG_START_NOW (1 << 30) - -/* - * If this flag is set, all the other fields are ignored (including - * EC_HANG_START_NOW). This provides the AP a way to stop the hang timer - * without reconfiguring any of the other hang detect settings. - */ -#define EC_HANG_STOP_NOW (1 << 31) - -struct ec_params_hang_detect { - /* Flags; see EC_HANG_* */ - uint32_t flags; - - /* Timeout in msec before generating host event, if enabled */ - uint16_t host_event_timeout_msec; - - /* Timeout in msec before generating warm reboot, if enabled */ - uint16_t warm_reboot_timeout_msec; -} __packed; - -/*****************************************************************************/ -/* Commands for battery charging */ - -/* - * This is the single catch-all host command to exchange data regarding the - * charge state machine (v2 and up). - */ -#define EC_CMD_CHARGE_STATE 0xa0 - -/* Subcommands for this host command */ -enum charge_state_command { - CHARGE_STATE_CMD_GET_STATE, - CHARGE_STATE_CMD_GET_PARAM, - CHARGE_STATE_CMD_SET_PARAM, - CHARGE_STATE_NUM_CMDS -}; - -/* - * Known param numbers are defined here. Ranges are reserved for board-specific - * params, which are handled by the particular implementations. - */ -enum charge_state_params { - CS_PARAM_CHG_VOLTAGE, /* charger voltage limit */ - CS_PARAM_CHG_CURRENT, /* charger current limit */ - CS_PARAM_CHG_INPUT_CURRENT, /* charger input current limit */ - CS_PARAM_CHG_STATUS, /* charger-specific status */ - CS_PARAM_CHG_OPTION, /* charger-specific options */ - CS_PARAM_LIMIT_POWER, /* - * Check if power is limited due to - * low battery and / or a weak external - * charger. READ ONLY. - */ - /* How many so far? */ - CS_NUM_BASE_PARAMS, - - /* Range for CONFIG_CHARGER_PROFILE_OVERRIDE params */ - CS_PARAM_CUSTOM_PROFILE_MIN = 0x10000, - CS_PARAM_CUSTOM_PROFILE_MAX = 0x1ffff, - - /* Other custom param ranges go here... */ -}; - -struct ec_params_charge_state { - uint8_t cmd; /* enum charge_state_command */ - union { - struct { - /* no args */ - } get_state; - - struct { - uint32_t param; /* enum charge_state_param */ - } get_param; - - struct { - uint32_t param; /* param to set */ - uint32_t value; /* value to set */ - } set_param; - }; -} __packed; - -struct ec_response_charge_state { - union { - struct { - int ac; - int chg_voltage; - int chg_current; - int chg_input_current; - int batt_state_of_charge; - } get_state; - - struct { - uint32_t value; - } get_param; - struct { - /* no return values */ - } set_param; - }; -} __packed; - - -/* - * Set maximum battery charging current. - */ -#define EC_CMD_CHARGE_CURRENT_LIMIT 0xa1 - -struct ec_params_current_limit { - uint32_t limit; /* in mA */ -} __packed; - -/* - * Set maximum external voltage / current. - */ -#define EC_CMD_EXTERNAL_POWER_LIMIT 0xa2 - -/* Command v0 is used only on Spring and is obsolete + unsupported */ -struct ec_params_external_power_limit_v1 { - uint16_t current_lim; /* in mA, or EC_POWER_LIMIT_NONE to clear limit */ - uint16_t voltage_lim; /* in mV, or EC_POWER_LIMIT_NONE to clear limit */ -} __packed; - -#define EC_POWER_LIMIT_NONE 0xffff - -/*****************************************************************************/ -/* Hibernate/Deep Sleep Commands */ - -/* Set the delay before going into hibernation. */ -#define EC_CMD_HIBERNATION_DELAY 0xa8 - -struct ec_params_hibernation_delay { - /* - * Seconds to wait in G3 before hibernate. Pass in 0 to read the - * current settings without changing them. - */ - uint32_t seconds; -}; - -struct ec_response_hibernation_delay { - /* - * The current time in seconds in which the system has been in the G3 - * state. This value is reset if the EC transitions out of G3. - */ - uint32_t time_g3; - - /* - * The current time remaining in seconds until the EC should hibernate. - * This value is also reset if the EC transitions out of G3. - */ - uint32_t time_remaining; - - /* - * The current time in seconds that the EC should wait in G3 before - * hibernating. - */ - uint32_t hibernate_delay; -}; - - -/*****************************************************************************/ -/* Smart battery pass-through */ - -/* Get / Set 16-bit smart battery registers */ -#define EC_CMD_SB_READ_WORD 0xb0 -#define EC_CMD_SB_WRITE_WORD 0xb1 - -/* Get / Set string smart battery parameters - * formatted as SMBUS "block". - */ -#define EC_CMD_SB_READ_BLOCK 0xb2 -#define EC_CMD_SB_WRITE_BLOCK 0xb3 - -struct ec_params_sb_rd { - uint8_t reg; -} __packed; - -struct ec_response_sb_rd_word { - uint16_t value; -} __packed; - -struct ec_params_sb_wr_word { - uint8_t reg; - uint16_t value; -} __packed; - -struct ec_response_sb_rd_block { - uint8_t data[32]; -} __packed; - -struct ec_params_sb_wr_block { - uint8_t reg; - uint16_t data[32]; -} __packed; - - -/*****************************************************************************/ -/* Battery vendor parameters - * - * Get or set vendor-specific parameters in the battery. Implementations may - * differ between boards or batteries. On a set operation, the response - * contains the actual value set, which may be rounded or clipped from the - * requested value. - */ - -#define EC_CMD_BATTERY_VENDOR_PARAM 0xb4 - -enum ec_battery_vendor_param_mode { - BATTERY_VENDOR_PARAM_MODE_GET = 0, - BATTERY_VENDOR_PARAM_MODE_SET, -}; - -struct ec_params_battery_vendor_param { - uint32_t param; - uint32_t value; - uint8_t mode; -} __packed; - -struct ec_response_battery_vendor_param { - uint32_t value; -} __packed; - /* * Resend last response (not supported on LPC). *