Merge branches 'ib-mfd-clk-gpio-power-regulator-rtc-5.3', 'ib-mfd-clk-regulator-rtc-5.3', 'ib-mfd-cros-5.3' and 'ib-mfd-regulator-5.3' into ibs-for-mfd-merged
···4141 };4242 };4343};4444+4545+TI LP87561 PMIC:4646+4747+This is a single output 4-phase regulator configuration4848+4949+Required properties:5050+ - compatible: "ti,lp87561-q1"5151+ - reg: I2C slave address.5252+ - gpio-controller: Marks the device node as a GPIO Controller.5353+ - #gpio-cells: Should be two. The first cell is the pin number and5454+ the second cell is used to specify flags.5555+ See ../gpio/gpio.txt for more information.5656+ - xxx-in-supply: Phandle to parent supply node of each regulator5757+ populated under regulators node. xxx should match5858+ the supply_name populated in driver.5959+Example:6060+6161+lp87561_pmic: pmic@62 {6262+ compatible = "ti,lp87561-q1";6363+ reg = <0x62>;6464+ gpio-controller;6565+ #gpio-cells = <2>;6666+6767+ buck3210-in-supply = <&vsys_3v3>;6868+6969+ regulators: regulators {7070+ buck3210_reg: buck3210 {7171+ /* VDD_CORE */7272+ regulator-name = "buck3210";7373+ regulator-min-microvolt = <800000>;7474+ regulator-max-microvolt = <800000>;7575+ regulator-always-on;7676+ regulator-boot-on;7777+ };7878+ };7979+};
+44
Documentation/devicetree/bindings/mfd/rk808.txt
···33The rk8xx family current members:44rk80555rk80866+rk80977+rk81768rk81879810Required properties:911- compatible: "rockchip,rk805"1012- compatible: "rockchip,rk808"1313+- compatible: "rockchip,rk809"1414+- compatible: "rockchip,rk817"1115- compatible: "rockchip,rk818"1216- reg: I2C slave address1317- interrupts: the interrupt outputs of the controller.···4844 for 2 host gpio's used for dvs. The format of the gpio specifier depends in4945 the gpio controller. If DVS GPIOs aren't present, voltage changes will happen5046 very quickly with no slow ramp time.4747+4848+Optional shared RK809 and RK817 properties:4949+- vcc1-supply: The input supply for DCDC_REG15050+- vcc2-supply: The input supply for DCDC_REG25151+- vcc3-supply: The input supply for DCDC_REG35252+- vcc4-supply: The input supply for DCDC_REG45353+- vcc5-supply: The input supply for LDO_REG1, LDO_REG2, LDO_REG35454+- vcc6-supply: The input supply for LDO_REG4, LDO_REG5, LDO_REG65555+- vcc7-supply: The input supply for LDO_REG7, LDO_REG8, LDO_REG95656+5757+Optional RK809 properties:5858+- vcc8-supply: The input supply for SWITCH_REG15959+- vcc9-supply: The input supply for DCDC_REG5, SWITCH_REG26060+6161+Optional RK817 properties:6262+- vcc8-supply: The input supply for BOOST6363+- vcc9-supply: The input supply for OTG_SWITCH51645265Optional RK818 properties:5366- vcc1-supply: The input supply for DCDC_REG1···10786 - SWITCH_REGn10887 - valid values for n are 1 to 2109888989+Following regulators of the RK809 and RK817 PMIC blocks are supported. Note that9090+the 'n' in regulator name, as in DCDC_REGn or LDOn, represents the DCDC or LDO9191+number as described in RK809 and RK817 datasheets.9292+9393+ - DCDC_REGn9494+ - valid values for n are 1 to 5 for RK809.9595+ - valid values for n are 1 to 4 for RK817.9696+ - LDO_REGn9797+ - valid values for n are 1 to 9 for RK809.9898+ - valid values for n are 1 to 9 for RK817.9999+ - SWITCH_REGn100100+ - valid values for n are 1 to 2 for RK809.101101+ - BOOST for RK817102102+ - OTG_SWITCH for RK817103103+110104Following regulators of the RK818 PMIC block are supported. Note that111105the 'n' in regulator name, as in DCDC_REGn or LDOn, represents the DCDC or LDO112106number as described in RK818 datasheet.···13397 - SWITCH_REG13498 - HDMI_SWITCH13599 - OTG_SWITCH100100+101101+It is necessary to configure three pins for both the RK809 and RK817, the three102102+pins are "gpio_ts" "gpio_gt" "gpio_slp".103103+ The gpio_gt and gpio_ts pins support the gpio function.104104+ The gpio_slp pin is for controlling the pmic states, as below:105105+ - reset106106+ - power down107107+ - sleep136108137109Standard regulator bindings are used inside regulator subnodes. Check138110 Documentation/devicetree/bindings/regulator/regulator.txt
+4-5
drivers/clk/Kconfig
···5353 This driver supports Maxim 9485 Programmable Audio Clock Generator54545555config COMMON_CLK_RK8085656- tristate "Clock driver for RK805/RK808/RK818"5656+ tristate "Clock driver for RK805/RK808/RK809/RK817/RK818"5757 depends on MFD_RK8085858 ---help---5959- This driver supports RK805, RK808 and RK818 crystal oscillator clock. These6060- multi-function devices have two fixed-rate oscillators,6161- clocked at 32KHz each. Clkout1 is always on, Clkout2 can off6262- by control register.5959+ This driver supports RK805, RK809 and RK817, RK808 and RK818 crystal oscillator clock.6060+ These multi-function devices have two fixed-rate oscillators, clocked at 32KHz each.6161+ Clkout1 is always on, Clkout2 can off by control register.63626463config COMMON_CLK_HI655X6564 tristate "Clock driver for Hi655x" if EXPERT
+63-1
drivers/clk/clk-rk808.c
···9696 return idx ? &rk808_clkout->clkout2_hw : &rk808_clkout->clkout1_hw;9797}98989999+static int rk817_clkout2_enable(struct clk_hw *hw, bool enable)100100+{101101+ struct rk808_clkout *rk808_clkout = container_of(hw,102102+ struct rk808_clkout,103103+ clkout2_hw);104104+ struct rk808 *rk808 = rk808_clkout->rk808;105105+106106+ return regmap_update_bits(rk808->regmap, RK817_SYS_CFG(1),107107+ RK817_CLK32KOUT2_EN,108108+ enable ? RK817_CLK32KOUT2_EN : 0);109109+}110110+111111+static int rk817_clkout2_prepare(struct clk_hw *hw)112112+{113113+ return rk817_clkout2_enable(hw, true);114114+}115115+116116+static void rk817_clkout2_unprepare(struct clk_hw *hw)117117+{118118+ rk817_clkout2_enable(hw, false);119119+}120120+121121+static int rk817_clkout2_is_prepared(struct clk_hw *hw)122122+{123123+ struct rk808_clkout *rk808_clkout = container_of(hw,124124+ struct rk808_clkout,125125+ clkout2_hw);126126+ struct rk808 *rk808 = rk808_clkout->rk808;127127+ unsigned int val;128128+129129+ int ret = regmap_read(rk808->regmap, RK817_SYS_CFG(1), &val);130130+131131+ if (ret < 0)132132+ return 0;133133+134134+ return (val & RK817_CLK32KOUT2_EN) ? 1 : 0;135135+}136136+137137+static const struct clk_ops rk817_clkout2_ops = {138138+ .prepare = rk817_clkout2_prepare,139139+ .unprepare = rk817_clkout2_unprepare,140140+ .is_prepared = rk817_clkout2_is_prepared,141141+ .recalc_rate = rk808_clkout_recalc_rate,142142+};143143+144144+static const struct clk_ops *rkpmic_get_ops(long variant)145145+{146146+ switch (variant) {147147+ case RK809_ID:148148+ case RK817_ID:149149+ return &rk817_clkout2_ops;150150+ /*151151+ * For the default case, it match the following PMIC type.152152+ * RK805_ID153153+ * RK808_ID154154+ * RK818_ID155155+ */156156+ default:157157+ return &rk808_clkout2_ops;158158+ }159159+}160160+99161static int rk808_clkout_probe(struct platform_device *pdev)100162{101163 struct rk808 *rk808 = dev_get_drvdata(pdev->dev.parent);···189127 return ret;190128191129 init.name = "rk808-clkout2";192192- init.ops = &rk808_clkout2_ops;130130+ init.ops = rkpmic_get_ops(rk808->variant);193131 rk808_clkout->clkout2_hw.init = &init;194132195133 /* optional override of the clockname */
+3-3
drivers/mfd/Kconfig
···10301030 different functionality of the device.1031103110321032config MFD_RK80810331033- tristate "Rockchip RK805/RK808/RK818 Power Management Chip"10331033+ tristate "Rockchip RK805/RK808/RK809/RK817/RK818 Power Management Chip"10341034 depends on I2C && OF10351035 select MFD_CORE10361036 select REGMAP_I2C10371037 select REGMAP_IRQ10381038 help10391039- If you say yes here you get support for the RK805, RK808 and RK81810401040- Power Management chips.10391039+ If you say yes here you get support for the RK805, RK808, RK809,10401040+ RK817 and RK818 Power Management chips.10411041 This driver provides common support for accessing the device10421042 through I2C interface. The device supports multiple sub-devices10431043 including interrupts, RTC, LDO & DCDC regulators, and onkey.
···762762 outputs which can be controlled by i2c communication.763763764764config REGULATOR_RK808765765- tristate "Rockchip RK805/RK808/RK818 Power regulators"765765+ tristate "Rockchip RK805/RK808/RK809/RK817/RK818 Power regulators"766766 depends on MFD_RK808767767 help768768 Select this option to enable the power regulator of ROCKCHIP769769- PMIC RK805,RK808 and RK818.769769+ PMIC RK805,RK809&RK817,RK808 and RK818.770770 This driver supports the control of different power rails of device771771 through regulator interface. The device supports multiple DCDC/LDO772772 outputs which can be controlled by i2c communication.
···373373 will be called rtc-max77686.374374375375config RTC_DRV_RK808376376- tristate "Rockchip RK805/RK808/RK818 RTC"376376+ tristate "Rockchip RK805/RK808/RK809/RK817/RK818 RTC"377377 depends on MFD_RK808378378 help379379 If you say yes here you will get support for the380380- RTC of RK805, RK808 and RK818 PMIC.380380+ RTC of RK805, RK809 and RK817, RK808 and RK818 PMIC.381381382382 This driver can also be built as a module. If so, the module383383 will be called rk808-rtc.
+54-14
drivers/rtc/rtc-rk808.c
···5050#define NUM_TIME_REGS (RK808_WEEKS_REG - RK808_SECONDS_REG + 1)5151#define NUM_ALARM_REGS (RK808_ALARM_YEARS_REG - RK808_ALARM_SECONDS_REG + 1)52525353+struct rk_rtc_compat_reg {5454+ unsigned int ctrl_reg;5555+ unsigned int status_reg;5656+ unsigned int alarm_seconds_reg;5757+ unsigned int int_reg;5858+ unsigned int seconds_reg;5959+};6060+5361struct rk808_rtc {5462 struct rk808 *rk808;5563 struct rtc_device *rtc;6464+ struct rk_rtc_compat_reg *creg;5665 int irq;5766};5867···110101 int ret;111102112103 /* Force an update of the shadowed registers right now */113113- ret = regmap_update_bits(rk808->regmap, RK808_RTC_CTRL_REG,104104+ ret = regmap_update_bits(rk808->regmap, rk808_rtc->creg->ctrl_reg,114105 BIT_RTC_CTRL_REG_RTC_GET_TIME,115106 BIT_RTC_CTRL_REG_RTC_GET_TIME);116107 if (ret) {···124115 * 32khz. If we clear the GET_TIME bit here, the time of i2c transfer125116 * certainly more than 31.25us: 16 * 2.5us at 400kHz bus frequency.126117 */127127- ret = regmap_update_bits(rk808->regmap, RK808_RTC_CTRL_REG,118118+ ret = regmap_update_bits(rk808->regmap, rk808_rtc->creg->ctrl_reg,128119 BIT_RTC_CTRL_REG_RTC_GET_TIME,129120 0);130121 if (ret) {···132123 return ret;133124 }134125135135- ret = regmap_bulk_read(rk808->regmap, RK808_SECONDS_REG,126126+ ret = regmap_bulk_read(rk808->regmap, rk808_rtc->creg->seconds_reg,136127 rtc_data, NUM_TIME_REGS);137128 if (ret) {138129 dev_err(dev, "Failed to bulk read rtc_data: %d\n", ret);···171162 rtc_data[6] = bin2bcd(tm->tm_wday);172163173164 /* Stop RTC while updating the RTC registers */174174- ret = regmap_update_bits(rk808->regmap, RK808_RTC_CTRL_REG,165165+ ret = regmap_update_bits(rk808->regmap, rk808_rtc->creg->ctrl_reg,175166 BIT_RTC_CTRL_REG_STOP_RTC_M,176167 BIT_RTC_CTRL_REG_STOP_RTC_M);177168 if (ret) {···179170 return ret;180171 }181172182182- ret = regmap_bulk_write(rk808->regmap, RK808_SECONDS_REG,173173+ ret = regmap_bulk_write(rk808->regmap, rk808_rtc->creg->seconds_reg,183174 rtc_data, NUM_TIME_REGS);184175 if (ret) {185176 dev_err(dev, "Failed to bull write rtc_data: %d\n", ret);186177 return ret;187178 }188179 /* Start RTC again */189189- ret = regmap_update_bits(rk808->regmap, RK808_RTC_CTRL_REG,180180+ ret = regmap_update_bits(rk808->regmap, rk808_rtc->creg->ctrl_reg,190181 BIT_RTC_CTRL_REG_STOP_RTC_M, 0);191182 if (ret) {192183 dev_err(dev, "Failed to update RTC control: %d\n", ret);···204195 uint32_t int_reg;205196 int ret;206197207207- ret = regmap_bulk_read(rk808->regmap, RK808_ALARM_SECONDS_REG,198198+ ret = regmap_bulk_read(rk808->regmap,199199+ rk808_rtc->creg->alarm_seconds_reg,208200 alrm_data, NUM_ALARM_REGS);201201+ if (ret) {202202+ dev_err(dev, "Failed to read RTC alarm date REG: %d\n", ret);203203+ return ret;204204+ }209205210206 alrm->time.tm_sec = bcd2bin(alrm_data[0] & SECONDS_REG_MSK);211207 alrm->time.tm_min = bcd2bin(alrm_data[1] & MINUTES_REG_MAK);···220206 alrm->time.tm_year = (bcd2bin(alrm_data[5] & YEARS_REG_MSK)) + 100;221207 rockchip_to_gregorian(&alrm->time);222208223223- ret = regmap_read(rk808->regmap, RK808_RTC_INT_REG, &int_reg);209209+ ret = regmap_read(rk808->regmap, rk808_rtc->creg->int_reg, &int_reg);224210 if (ret) {225211 dev_err(dev, "Failed to read RTC INT REG: %d\n", ret);226212 return ret;···239225 struct rk808 *rk808 = rk808_rtc->rk808;240226 int ret;241227242242- ret = regmap_update_bits(rk808->regmap, RK808_RTC_INT_REG,228228+ ret = regmap_update_bits(rk808->regmap, rk808_rtc->creg->int_reg,243229 BIT_RTC_INTERRUPTS_REG_IT_ALARM_M, 0);244230245231 return ret;···250236 struct rk808 *rk808 = rk808_rtc->rk808;251237 int ret;252238253253- ret = regmap_update_bits(rk808->regmap, RK808_RTC_INT_REG,239239+ ret = regmap_update_bits(rk808->regmap, rk808_rtc->creg->int_reg,254240 BIT_RTC_INTERRUPTS_REG_IT_ALARM_M,255241 BIT_RTC_INTERRUPTS_REG_IT_ALARM_M);256242···280266 alrm_data[4] = bin2bcd(alrm->time.tm_mon + 1);281267 alrm_data[5] = bin2bcd(alrm->time.tm_year - 100);282268283283- ret = regmap_bulk_write(rk808->regmap, RK808_ALARM_SECONDS_REG,269269+ ret = regmap_bulk_write(rk808->regmap,270270+ rk808_rtc->creg->alarm_seconds_reg,284271 alrm_data, NUM_ALARM_REGS);285272 if (ret) {286273 dev_err(dev, "Failed to bulk write: %d\n", ret);···325310 struct i2c_client *client = rk808->i2c;326311 int ret;327312328328- ret = regmap_write(rk808->regmap, RK808_RTC_STATUS_REG,313313+ ret = regmap_write(rk808->regmap, rk808_rtc->creg->status_reg,329314 RTC_STATUS_MASK);330315 if (ret) {331316 dev_err(&client->dev,···376361static SIMPLE_DEV_PM_OPS(rk808_rtc_pm_ops,377362 rk808_rtc_suspend, rk808_rtc_resume);378363364364+static struct rk_rtc_compat_reg rk808_creg = {365365+ .ctrl_reg = RK808_RTC_CTRL_REG,366366+ .status_reg = RK808_RTC_STATUS_REG,367367+ .alarm_seconds_reg = RK808_ALARM_SECONDS_REG,368368+ .int_reg = RK808_RTC_INT_REG,369369+ .seconds_reg = RK808_SECONDS_REG,370370+};371371+372372+static struct rk_rtc_compat_reg rk817_creg = {373373+ .ctrl_reg = RK817_RTC_CTRL_REG,374374+ .status_reg = RK817_RTC_STATUS_REG,375375+ .alarm_seconds_reg = RK817_ALARM_SECONDS_REG,376376+ .int_reg = RK817_RTC_INT_REG,377377+ .seconds_reg = RK817_SECONDS_REG,378378+};379379+379380static int rk808_rtc_probe(struct platform_device *pdev)380381{381382 struct rk808 *rk808 = dev_get_drvdata(pdev->dev.parent);···402371 if (rk808_rtc == NULL)403372 return -ENOMEM;404373374374+ switch (rk808->variant) {375375+ case RK809_ID:376376+ case RK817_ID:377377+ rk808_rtc->creg = &rk817_creg;378378+ break;379379+ default:380380+ rk808_rtc->creg = &rk808_creg;381381+ break;382382+ }405383 platform_set_drvdata(pdev, rk808_rtc);406384 rk808_rtc->rk808 = rk808;407385408386 /* start rtc running by default, and use shadowed timer. */409409- ret = regmap_update_bits(rk808->regmap, RK808_RTC_CTRL_REG,387387+ ret = regmap_update_bits(rk808->regmap, rk808_rtc->creg->ctrl_reg,410388 BIT_RTC_CTRL_REG_STOP_RTC_M |411389 BIT_RTC_CTRL_REG_RTC_READSEL_M,412390 BIT_RTC_CTRL_REG_RTC_READSEL_M);···425385 return ret;426386 }427387428428- ret = regmap_write(rk808->regmap, RK808_RTC_STATUS_REG,388388+ ret = regmap_write(rk808->regmap, rk808_rtc->creg->status_reg,429389 RTC_STATUS_MASK);430390 if (ret) {431391 dev_err(&pdev->dev,
+2889-725
include/linux/mfd/cros_ec_commands.h
···11+/* SPDX-License-Identifier: GPL-2.0 */12/*23 * Host communication command constants for ChromeOS EC34 *45 * Copyright (C) 2012 Google, Inc56 *66- * This software is licensed under the terms of the GNU General Public77- * License version 2, as published by the Free Software Foundation, and88- * may be copied, distributed, and modified under those terms.99- *1010- * This program is distributed in the hope that it will be useful,1111- * but WITHOUT ANY WARRANTY; without even the implied warranty of1212- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1313- * GNU General Public License for more details.1414- *1515- * The ChromeOS EC multi function device is used to mux all the requests1616- * to the EC device for its multiple features: keyboard controller,1717- * battery charging and regulator control, firmware update.1818- *1919- * NOTE: This file is copied verbatim from the ChromeOS EC Open Source2020- * project in an attempt to make future updates easy to make.77+ * NOTE: This file is auto-generated from ChromeOS EC Open Source code from88+ * https://chromium.googlesource.com/chromiumos/platform/ec/+/master/include/ec_commands.h219 */1010+1111+/* Host communication command constants for Chrome EC */22122313#ifndef __CROS_EC_COMMANDS_H2414#define __CROS_EC_COMMANDS_H1515+1616+1717+1818+1919+#define BUILD_ASSERT(_cond)25202621/*2722 * Current version of this protocol···2833#define EC_PROTO_VERSION 0x0000000229343035/* Command version mask */3131-#define EC_VER_MASK(version) (1UL << (version))3636+#define EC_VER_MASK(version) BIT(version)32373338/* I/O addresses for ACPI commands */3439#define EC_LPC_ADDR_ACPI_DATA 0x62···4247/* Protocol version 2 */4348#define EC_LPC_ADDR_HOST_ARGS 0x800 /* And 0x801, 0x802, 0x803 */4449#define EC_LPC_ADDR_HOST_PARAM 0x804 /* For version 2 params; size is4545- * EC_PROTO2_MAX_PARAM_SIZE */5050+ * EC_PROTO2_MAX_PARAM_SIZE5151+ */4652/* Protocol version 3 */4753#define EC_LPC_ADDR_HOST_PACKET 0x800 /* Offset of version 3 packet */4854#define EC_LPC_HOST_PACKET_SIZE 0x100 /* Max size of version 3 packet */49555050-/* The actual block is 0x800-0x8ff, but some BIOSes think it's 0x880-0x8ff5151- * and they tell the kernel that so we have to think of it as two parts. */5656+/*5757+ * The actual block is 0x800-0x8ff, but some BIOSes think it's 0x880-0x8ff5858+ * and they tell the kernel that so we have to think of it as two parts.5959+ */5260#define EC_HOST_CMD_REGION0 0x8005361#define EC_HOST_CMD_REGION1 0x8805462#define EC_HOST_CMD_REGION_SIZE 0x8055635664/* EC command register bit functions */5757-#define EC_LPC_CMDR_DATA (1 << 0) /* Data ready for host to read */5858-#define EC_LPC_CMDR_PENDING (1 << 1) /* Write pending to EC */5959-#define EC_LPC_CMDR_BUSY (1 << 2) /* EC is busy processing a command */6060-#define EC_LPC_CMDR_CMD (1 << 3) /* Last host write was a command */6161-#define EC_LPC_CMDR_ACPI_BRST (1 << 4) /* Burst mode (not used) */6262-#define EC_LPC_CMDR_SCI (1 << 5) /* SCI event is pending */6363-#define EC_LPC_CMDR_SMI (1 << 6) /* SMI event is pending */6565+#define EC_LPC_CMDR_DATA BIT(0) /* Data ready for host to read */6666+#define EC_LPC_CMDR_PENDING BIT(1) /* Write pending to EC */6767+#define EC_LPC_CMDR_BUSY BIT(2) /* EC is busy processing a command */6868+#define EC_LPC_CMDR_CMD BIT(3) /* Last host write was a command */6969+#define EC_LPC_CMDR_ACPI_BRST BIT(4) /* Burst mode (not used) */7070+#define EC_LPC_CMDR_SCI BIT(5) /* SCI event is pending */7171+#define EC_LPC_CMDR_SMI BIT(6) /* SMI event is pending */64726573#define EC_LPC_ADDR_MEMMAP 0x9006674#define EC_MEMMAP_SIZE 255 /* ACPI IO buffer max is 255 bytes */···8385/* Unused 0x28 - 0x2f */8486#define EC_MEMMAP_SWITCHES 0x30 /* 8 bits */8587/* Unused 0x31 - 0x33 */8686-#define EC_MEMMAP_HOST_EVENTS 0x34 /* 32 bits */8787-/* Reserve 0x38 - 0x3f for additional host event-related stuff */8888-/* Battery values are all 32 bits */8888+#define EC_MEMMAP_HOST_EVENTS 0x34 /* 64 bits */8989+/* Battery values are all 32 bits, unless otherwise noted. */8990#define EC_MEMMAP_BATT_VOLT 0x40 /* Battery Present Voltage */9091#define EC_MEMMAP_BATT_RATE 0x44 /* Battery Present Rate */9192#define EC_MEMMAP_BATT_CAP 0x48 /* Battery Remaining Capacity */9292-#define EC_MEMMAP_BATT_FLAG 0x4c /* Battery State, defined below */9393+#define EC_MEMMAP_BATT_FLAG 0x4c /* Battery State, see below (8-bit) */9494+#define EC_MEMMAP_BATT_COUNT 0x4d /* Battery Count (8-bit) */9595+#define EC_MEMMAP_BATT_INDEX 0x4e /* Current Battery Data Index (8-bit) */9696+/* Unused 0x4f */9397#define EC_MEMMAP_BATT_DCAP 0x50 /* Battery Design Capacity */9498#define EC_MEMMAP_BATT_DVLT 0x54 /* Battery Design Voltage */9599#define EC_MEMMAP_BATT_LFCC 0x58 /* Battery Last Full Charge Capacity */···105105/* Unused 0x84 - 0x8f */106106#define EC_MEMMAP_ACC_STATUS 0x90 /* Accelerometer status (8 bits )*/107107/* Unused 0x91 */108108-#define EC_MEMMAP_ACC_DATA 0x92 /* Accelerometer data 0x92 - 0x9f */108108+#define EC_MEMMAP_ACC_DATA 0x92 /* Accelerometers data 0x92 - 0x9f */109109+/* 0x92: Lid Angle if available, LID_ANGLE_UNRELIABLE otherwise */110110+/* 0x94 - 0x99: 1st Accelerometer */111111+/* 0x9a - 0x9f: 2nd Accelerometer */109112#define EC_MEMMAP_GYRO_DATA 0xa0 /* Gyroscope data 0xa0 - 0xa5 */110110-/* Unused 0xa6 - 0xfe (remember, 0xff is NOT part of the memmap region) */113113+/* Unused 0xa6 - 0xdf */111114115115+/*116116+ * ACPI is unable to access memory mapped data at or above this offset due to117117+ * limitations of the ACPI protocol. Do not place data in the range 0xe0 - 0xfe118118+ * which might be needed by ACPI.119119+ */120120+#define EC_MEMMAP_NO_ACPI 0xe0112121113122/* Define the format of the accelerometer mapped memory status byte. */114123#define EC_MEMMAP_ACC_STATUS_SAMPLE_ID_MASK 0x0f115115-#define EC_MEMMAP_ACC_STATUS_BUSY_BIT (1 << 4)116116-#define EC_MEMMAP_ACC_STATUS_PRESENCE_BIT (1 << 7)124124+#define EC_MEMMAP_ACC_STATUS_BUSY_BIT BIT(4)125125+#define EC_MEMMAP_ACC_STATUS_PRESENCE_BIT BIT(7)117126118127/* Number of temp sensors at EC_MEMMAP_TEMP_SENSOR */119128#define EC_TEMP_SENSOR_ENTRIES 16···166157#define EC_BATT_FLAG_DISCHARGING 0x04167158#define EC_BATT_FLAG_CHARGING 0x08168159#define EC_BATT_FLAG_LEVEL_CRITICAL 0x10160160+/* Set if some of the static/dynamic data is invalid (or outdated). */161161+#define EC_BATT_FLAG_INVALID_DATA 0x20169162170163/* Switch flags at EC_MEMMAP_SWITCHES */171164#define EC_SWITCH_LID_OPEN 0x01···193182#define EC_WIRELESS_SWITCH_WWAN 0x04 /* WWAN power */194183#define EC_WIRELESS_SWITCH_WLAN_POWER 0x08 /* WLAN power */195184185185+/*****************************************************************************/186186+/*187187+ * ACPI commands188188+ *189189+ * These are valid ONLY on the ACPI command/data port.190190+ */191191+192192+/*193193+ * ACPI Read Embedded Controller194194+ *195195+ * This reads from ACPI memory space on the EC (EC_ACPI_MEM_*).196196+ *197197+ * Use the following sequence:198198+ *199199+ * - Write EC_CMD_ACPI_READ to EC_LPC_ADDR_ACPI_CMD200200+ * - Wait for EC_LPC_CMDR_PENDING bit to clear201201+ * - Write address to EC_LPC_ADDR_ACPI_DATA202202+ * - Wait for EC_LPC_CMDR_DATA bit to set203203+ * - Read value from EC_LPC_ADDR_ACPI_DATA204204+ */205205+#define EC_CMD_ACPI_READ 0x0080206206+207207+/*208208+ * ACPI Write Embedded Controller209209+ *210210+ * This reads from ACPI memory space on the EC (EC_ACPI_MEM_*).211211+ *212212+ * Use the following sequence:213213+ *214214+ * - Write EC_CMD_ACPI_WRITE to EC_LPC_ADDR_ACPI_CMD215215+ * - Wait for EC_LPC_CMDR_PENDING bit to clear216216+ * - Write address to EC_LPC_ADDR_ACPI_DATA217217+ * - Wait for EC_LPC_CMDR_PENDING bit to clear218218+ * - Write value to EC_LPC_ADDR_ACPI_DATA219219+ */220220+#define EC_CMD_ACPI_WRITE 0x0081221221+222222+/*223223+ * ACPI Burst Enable Embedded Controller224224+ *225225+ * This enables burst mode on the EC to allow the host to issue several226226+ * commands back-to-back. While in this mode, writes to mapped multi-byte227227+ * data are locked out to ensure data consistency.228228+ */229229+#define EC_CMD_ACPI_BURST_ENABLE 0x0082230230+231231+/*232232+ * ACPI Burst Disable Embedded Controller233233+ *234234+ * This disables burst mode on the EC and stops preventing EC writes to mapped235235+ * multi-byte data.236236+ */237237+#define EC_CMD_ACPI_BURST_DISABLE 0x0083238238+239239+/*240240+ * ACPI Query Embedded Controller241241+ *242242+ * This clears the lowest-order bit in the currently pending host events, and243243+ * sets the result code to the 1-based index of the bit (event 0x00000001 = 1,244244+ * event 0x80000000 = 32), or 0 if no event was pending.245245+ */246246+#define EC_CMD_ACPI_QUERY_EVENT 0x0084247247+248248+/* Valid addresses in ACPI memory space, for read/write commands */249249+250250+/* Memory space version; set to EC_ACPI_MEM_VERSION_CURRENT */251251+#define EC_ACPI_MEM_VERSION 0x00252252+/*253253+ * Test location; writing value here updates test compliment byte to (0xff -254254+ * value).255255+ */256256+#define EC_ACPI_MEM_TEST 0x01257257+/* Test compliment; writes here are ignored. */258258+#define EC_ACPI_MEM_TEST_COMPLIMENT 0x02259259+260260+/* Keyboard backlight brightness percent (0 - 100) */261261+#define EC_ACPI_MEM_KEYBOARD_BACKLIGHT 0x03262262+/* DPTF Target Fan Duty (0-100, 0xff for auto/none) */263263+#define EC_ACPI_MEM_FAN_DUTY 0x04264264+265265+/*266266+ * DPTF temp thresholds. Any of the EC's temp sensors can have up to two267267+ * independent thresholds attached to them. The current value of the ID268268+ * register determines which sensor is affected by the THRESHOLD and COMMIT269269+ * registers. The THRESHOLD register uses the same EC_TEMP_SENSOR_OFFSET scheme270270+ * as the memory-mapped sensors. The COMMIT register applies those settings.271271+ *272272+ * The spec does not mandate any way to read back the threshold settings273273+ * themselves, but when a threshold is crossed the AP needs a way to determine274274+ * which sensor(s) are responsible. Each reading of the ID register clears and275275+ * returns one sensor ID that has crossed one of its threshold (in either276276+ * direction) since the last read. A value of 0xFF means "no new thresholds277277+ * have tripped". Setting or enabling the thresholds for a sensor will clear278278+ * the unread event count for that sensor.279279+ */280280+#define EC_ACPI_MEM_TEMP_ID 0x05281281+#define EC_ACPI_MEM_TEMP_THRESHOLD 0x06282282+#define EC_ACPI_MEM_TEMP_COMMIT 0x07283283+/*284284+ * Here are the bits for the COMMIT register:285285+ * bit 0 selects the threshold index for the chosen sensor (0/1)286286+ * bit 1 enables/disables the selected threshold (0 = off, 1 = on)287287+ * Each write to the commit register affects one threshold.288288+ */289289+#define EC_ACPI_MEM_TEMP_COMMIT_SELECT_MASK BIT(0)290290+#define EC_ACPI_MEM_TEMP_COMMIT_ENABLE_MASK BIT(1)291291+/*292292+ * Example:293293+ *294294+ * Set the thresholds for sensor 2 to 50 C and 60 C:295295+ * write 2 to [0x05] -- select temp sensor 2296296+ * write 0x7b to [0x06] -- C_TO_K(50) - EC_TEMP_SENSOR_OFFSET297297+ * write 0x2 to [0x07] -- enable threshold 0 with this value298298+ * write 0x85 to [0x06] -- C_TO_K(60) - EC_TEMP_SENSOR_OFFSET299299+ * write 0x3 to [0x07] -- enable threshold 1 with this value300300+ *301301+ * Disable the 60 C threshold, leaving the 50 C threshold unchanged:302302+ * write 2 to [0x05] -- select temp sensor 2303303+ * write 0x1 to [0x07] -- disable threshold 1304304+ */305305+306306+/* DPTF battery charging current limit */307307+#define EC_ACPI_MEM_CHARGING_LIMIT 0x08308308+309309+/* Charging limit is specified in 64 mA steps */310310+#define EC_ACPI_MEM_CHARGING_LIMIT_STEP_MA 64311311+/* Value to disable DPTF battery charging limit */312312+#define EC_ACPI_MEM_CHARGING_LIMIT_DISABLED 0xff313313+314314+/*315315+ * Report device orientation316316+ * Bits Definition317317+ * 3:1 Device DPTF Profile Number (DDPN)318318+ * 0 = Reserved for backward compatibility (indicates no valid319319+ * profile number. Host should fall back to using TBMD).320320+ * 1..7 = DPTF Profile number to indicate to host which table needs321321+ * to be loaded.322322+ * 0 Tablet Mode Device Indicator (TBMD)323323+ */324324+#define EC_ACPI_MEM_DEVICE_ORIENTATION 0x09325325+#define EC_ACPI_MEM_TBMD_SHIFT 0326326+#define EC_ACPI_MEM_TBMD_MASK 0x1327327+#define EC_ACPI_MEM_DDPN_SHIFT 1328328+#define EC_ACPI_MEM_DDPN_MASK 0x7329329+330330+/*331331+ * Report device features. Uses the same format as the host command, except:332332+ *333333+ * bit 0 (EC_FEATURE_LIMITED) changes meaning from "EC code has a limited set334334+ * of features", which is of limited interest when the system is already335335+ * interpreting ACPI bytecode, to "EC_FEATURES[0-7] is not supported". Since336336+ * these are supported, it defaults to 0.337337+ * This allows detecting the presence of this field since older versions of338338+ * the EC codebase would simply return 0xff to that unknown address. Check339339+ * FEATURES0 != 0xff (or FEATURES0[0] == 0) to make sure that the other bits340340+ * are valid.341341+ */342342+#define EC_ACPI_MEM_DEVICE_FEATURES0 0x0a343343+#define EC_ACPI_MEM_DEVICE_FEATURES1 0x0b344344+#define EC_ACPI_MEM_DEVICE_FEATURES2 0x0c345345+#define EC_ACPI_MEM_DEVICE_FEATURES3 0x0d346346+#define EC_ACPI_MEM_DEVICE_FEATURES4 0x0e347347+#define EC_ACPI_MEM_DEVICE_FEATURES5 0x0f348348+#define EC_ACPI_MEM_DEVICE_FEATURES6 0x10349349+#define EC_ACPI_MEM_DEVICE_FEATURES7 0x11350350+351351+#define EC_ACPI_MEM_BATTERY_INDEX 0x12352352+353353+/*354354+ * USB Port Power. Each bit indicates whether the corresponding USB ports' power355355+ * is enabled (1) or disabled (0).356356+ * bit 0 USB port ID 0357357+ * ...358358+ * bit 7 USB port ID 7359359+ */360360+#define EC_ACPI_MEM_USB_PORT_POWER 0x13361361+362362+/*363363+ * ACPI addresses 0x20 - 0xff map to EC_MEMMAP offset 0x00 - 0xdf. This data364364+ * is read-only from the AP. Added in EC_ACPI_MEM_VERSION 2.365365+ */366366+#define EC_ACPI_MEM_MAPPED_BEGIN 0x20367367+#define EC_ACPI_MEM_MAPPED_SIZE 0xe0368368+369369+/* Current version of ACPI memory address space */370370+#define EC_ACPI_MEM_VERSION_CURRENT 2371371+372372+196373/*197374 * This header file is used in coreboot both in C and ACPI code. The ACPI code198375 * is pre-processed to handle constants but the ASL compiler is unable to199376 * handle actual C code so keep it separate.200377 */201201-#ifndef __ACPI__378378+202379203380/*204204- * Define __packed if someone hasn't beat us to it. Linux kernel style205205- * checking prefers __packed over __attribute__((packed)).381381+ * Attributes for EC request and response packets. Just defining __packed382382+ * results in inefficient assembly code on ARM, if the structure is actually383383+ * 32-bit aligned, as it should be for all buffers.384384+ *385385+ * Be very careful when adding these to existing structures. They will round386386+ * up the structure size to the specified boundary.387387+ *388388+ * Also be very careful to make that if a structure is included in some other389389+ * parent structure that the alignment will still be true given the packing of390390+ * the parent structure. This is particularly important if the sub-structure391391+ * will be passed as a pointer to another function, since that function will392392+ * not know about the misaligment caused by the parent structure's packing.393393+ *394394+ * Also be very careful using __packed - particularly when nesting non-packed395395+ * structures inside packed ones. In fact, DO NOT use __packed directly;396396+ * always use one of these attributes.397397+ *398398+ * Once everything is annotated properly, the following search strings should399399+ * not return ANY matches in this file other than right here:400400+ *401401+ * "__packed" - generates inefficient code; all sub-structs must also be packed402402+ *403403+ * "struct [^_]" - all structs should be annotated, except for structs that are404404+ * members of other structs/unions (and their original declarations should be405405+ * annotated).206406 */207207-#ifndef __packed208208-#define __packed __attribute__((packed))209209-#endif407407+408408+/*409409+ * Packed structures make no assumption about alignment, so they do inefficient410410+ * byte-wise reads.411411+ */412412+#define __ec_align1 __packed413413+#define __ec_align2 __packed414414+#define __ec_align4 __packed415415+#define __ec_align_size1 __packed416416+#define __ec_align_offset1 __packed417417+#define __ec_align_offset2 __packed418418+#define __ec_todo_packed __packed419419+#define __ec_todo_unpacked420420+210421211422/* LPC command status byte masks */212423/* EC has written a byte in the data register and host hasn't read it yet */···439206#define EC_LPC_STATUS_PROCESSING 0x04440207/* Last write to EC was a command, not data */441208#define EC_LPC_STATUS_LAST_CMD 0x08442442-/* EC is in burst mode. Unsupported by Chrome EC, so this bit is never set */209209+/* EC is in burst mode */443210#define EC_LPC_STATUS_BURST_MODE 0x10444211/* SCI event is pending (requesting SCI query) */445212#define EC_LPC_STATUS_SCI_PENDING 0x20···455222#define EC_LPC_STATUS_BUSY_MASK \456223 (EC_LPC_STATUS_FROM_HOST | EC_LPC_STATUS_PROCESSING)457224458458-/* Host command response codes */225225+/*226226+ * Host command response codes (16-bit). Note that response codes should be227227+ * stored in a uint16_t rather than directly in a value of this type.228228+ */459229enum ec_status {460230 EC_RES_SUCCESS = 0,461231 EC_RES_INVALID_COMMAND = 1,···474238 EC_RES_OVERFLOW = 11, /* Table / data overflow */475239 EC_RES_INVALID_HEADER = 12, /* Header contains invalid data */476240 EC_RES_REQUEST_TRUNCATED = 13, /* Didn't get the entire request */477477- EC_RES_RESPONSE_TOO_BIG = 14 /* Response was too big to handle */241241+ EC_RES_RESPONSE_TOO_BIG = 14, /* Response was too big to handle */242242+ EC_RES_BUS_ERROR = 15, /* Communications bus error */243243+ EC_RES_BUSY = 16, /* Up but too busy. Should retry */244244+ EC_RES_INVALID_HEADER_VERSION = 17, /* Header version invalid */245245+ EC_RES_INVALID_HEADER_CRC = 18, /* Header CRC invalid */246246+ EC_RES_INVALID_DATA_CRC = 19, /* Data CRC invalid */247247+ EC_RES_DUP_UNAVAILABLE = 20, /* Can't resend response */478248};479249480250/*···500258 EC_HOST_EVENT_BATTERY_CRITICAL = 7,501259 EC_HOST_EVENT_BATTERY = 8,502260 EC_HOST_EVENT_THERMAL_THRESHOLD = 9,503503- EC_HOST_EVENT_THERMAL_OVERLOAD = 10,261261+ /* Event generated by a device attached to the EC */262262+ EC_HOST_EVENT_DEVICE = 10,504263 EC_HOST_EVENT_THERMAL = 11,505264 EC_HOST_EVENT_USB_CHARGER = 12,506265 EC_HOST_EVENT_KEY_PRESSED = 13,···528285 EC_HOST_EVENT_HANG_DETECT = 20,529286 /* Hang detect logic detected a hang and warm rebooted the AP */530287 EC_HOST_EVENT_HANG_REBOOT = 21,288288+531289 /* PD MCU triggering host event */532290 EC_HOST_EVENT_PD_MCU = 22,291291+292292+ /* Battery Status flags have changed */293293+ EC_HOST_EVENT_BATTERY_STATUS = 23,294294+295295+ /* EC encountered a panic, triggering a reset */296296+ EC_HOST_EVENT_PANIC = 24,297297+298298+ /* Keyboard fastboot combo has been pressed */299299+ EC_HOST_EVENT_KEYBOARD_FASTBOOT = 25,300300+301301+ /* EC RTC event occurred */302302+ EC_HOST_EVENT_RTC = 26,303303+304304+ /* Emulate MKBP event */305305+ EC_HOST_EVENT_MKBP = 27,533306534307 /* EC desires to change state of host-controlled USB mux */535308 EC_HOST_EVENT_USB_MUX = 28,536309537537- /* EC RTC event occurred */538538- EC_HOST_EVENT_RTC = 26,310310+ /* TABLET/LAPTOP mode or detachable base attach/detach event */311311+ EC_HOST_EVENT_MODE_CHANGE = 29,312312+313313+ /* Keyboard recovery combo with hardware reinitialization */314314+ EC_HOST_EVENT_KEYBOARD_RECOVERY_HW_REINIT = 30,539315540316 /*541317 * The high bit of the event mask is not used as a host event code. If···566304 EC_HOST_EVENT_INVALID = 32567305};568306/* Host event mask */569569-#define EC_HOST_EVENT_MASK(event_code) (1UL << ((event_code) - 1))307307+#define EC_HOST_EVENT_MASK(event_code) BIT_ULL((event_code) - 1)570308571309/**572310 * struct ec_lpc_host_args - Arguments at EC_LPC_ADDR_HOST_ARGS···581319 uint8_t command_version;582320 uint8_t data_size;583321 uint8_t checksum;584584-} __packed;322322+} __ec_align4;585323586324/* Flags for ec_lpc_host_args.flags */587325/*···591329 * If EC gets a command and this flag is not set, this is an old-style command.592330 * Command version is 0 and params from host are at EC_LPC_ADDR_OLD_PARAM with593331 * unknown length. EC must respond with an old-style response (that is,594594- * withouth setting EC_HOST_ARGS_FLAG_TO_HOST).332332+ * without setting EC_HOST_ARGS_FLAG_TO_HOST).595333 */596334#define EC_HOST_ARGS_FLAG_FROM_HOST 0x01597335/*···752490 uint8_t command_version;753491 uint8_t reserved;754492 uint16_t data_len;755755-} __packed;493493+} __ec_align4;756494757495#define EC_HOST_RESPONSE_VERSION 3758496···771509 uint16_t result;772510 uint16_t data_len;773511 uint16_t reserved;774774-} __packed;512512+} __ec_align4;513513+514514+/*****************************************************************************/515515+516516+/*517517+ * Host command protocol V4.518518+ *519519+ * Packets always start with a request or response header. They are followed520520+ * by data_len bytes of data. If the data_crc_present flag is set, the data521521+ * bytes are followed by a CRC-8 of that data, using using x^8 + x^2 + x + 1522522+ * polynomial.523523+ *524524+ * Host algorithm when sending a request q:525525+ *526526+ * 101) tries_left=(some value, e.g. 3);527527+ * 102) q.seq_num++528528+ * 103) q.seq_dup=0529529+ * 104) Calculate q.header_crc.530530+ * 105) Send request q to EC.531531+ * 106) Wait for response r. Go to 201 if received or 301 if timeout.532532+ *533533+ * 201) If r.struct_version != 4, go to 301.534534+ * 202) If r.header_crc mismatches calculated CRC for r header, go to 301.535535+ * 203) If r.data_crc_present and r.data_crc mismatches, go to 301.536536+ * 204) If r.seq_num != q.seq_num, go to 301.537537+ * 205) If r.seq_dup == q.seq_dup, return success.538538+ * 207) If r.seq_dup == 1, go to 301.539539+ * 208) Return error.540540+ *541541+ * 301) If --tries_left <= 0, return error.542542+ * 302) If q.seq_dup == 1, go to 105.543543+ * 303) q.seq_dup = 1544544+ * 304) Go to 104.545545+ *546546+ * EC algorithm when receiving a request q.547547+ * EC has response buffer r, error buffer e.548548+ *549549+ * 101) If q.struct_version != 4, set e.result = EC_RES_INVALID_HEADER_VERSION550550+ * and go to 301551551+ * 102) If q.header_crc mismatches calculated CRC, set e.result =552552+ * EC_RES_INVALID_HEADER_CRC and go to 301553553+ * 103) If q.data_crc_present, calculate data CRC. If that mismatches the CRC554554+ * byte at the end of the packet, set e.result = EC_RES_INVALID_DATA_CRC555555+ * and go to 301.556556+ * 104) If q.seq_dup == 0, go to 201.557557+ * 105) If q.seq_num != r.seq_num, go to 201.558558+ * 106) If q.seq_dup == r.seq_dup, go to 205, else go to 203.559559+ *560560+ * 201) Process request q into response r.561561+ * 202) r.seq_num = q.seq_num562562+ * 203) r.seq_dup = q.seq_dup563563+ * 204) Calculate r.header_crc564564+ * 205) If r.data_len > 0 and data is no longer available, set e.result =565565+ * EC_RES_DUP_UNAVAILABLE and go to 301.566566+ * 206) Send response r.567567+ *568568+ * 301) e.seq_num = q.seq_num569569+ * 302) e.seq_dup = q.seq_dup570570+ * 303) Calculate e.header_crc.571571+ * 304) Send error response e.572572+ */573573+574574+/* Version 4 request from host */575575+struct ec_host_request4 {576576+ /*577577+ * bits 0-3: struct_version: Structure version (=4)578578+ * bit 4: is_response: Is response (=0)579579+ * bits 5-6: seq_num: Sequence number580580+ * bit 7: seq_dup: Sequence duplicate flag581581+ */582582+ uint8_t fields0;583583+584584+ /*585585+ * bits 0-4: command_version: Command version586586+ * bits 5-6: Reserved (set 0, ignore on read)587587+ * bit 7: data_crc_present: Is data CRC present after data588588+ */589589+ uint8_t fields1;590590+591591+ /* Command code (EC_CMD_*) */592592+ uint16_t command;593593+594594+ /* Length of data which follows this header (not including data CRC) */595595+ uint16_t data_len;596596+597597+ /* Reserved (set 0, ignore on read) */598598+ uint8_t reserved;599599+600600+ /* CRC-8 of above fields, using x^8 + x^2 + x + 1 polynomial */601601+ uint8_t header_crc;602602+} __ec_align4;603603+604604+/* Version 4 response from EC */605605+struct ec_host_response4 {606606+ /*607607+ * bits 0-3: struct_version: Structure version (=4)608608+ * bit 4: is_response: Is response (=1)609609+ * bits 5-6: seq_num: Sequence number610610+ * bit 7: seq_dup: Sequence duplicate flag611611+ */612612+ uint8_t fields0;613613+614614+ /*615615+ * bits 0-6: Reserved (set 0, ignore on read)616616+ * bit 7: data_crc_present: Is data CRC present after data617617+ */618618+ uint8_t fields1;619619+620620+ /* Result code (EC_RES_*) */621621+ uint16_t result;622622+623623+ /* Length of data which follows this header (not including data CRC) */624624+ uint16_t data_len;625625+626626+ /* Reserved (set 0, ignore on read) */627627+ uint8_t reserved;628628+629629+ /* CRC-8 of above fields, using x^8 + x^2 + x + 1 polynomial */630630+ uint8_t header_crc;631631+} __ec_align4;632632+633633+/* Fields in fields0 byte */634634+#define EC_PACKET4_0_STRUCT_VERSION_MASK 0x0f635635+#define EC_PACKET4_0_IS_RESPONSE_MASK 0x10636636+#define EC_PACKET4_0_SEQ_NUM_SHIFT 5637637+#define EC_PACKET4_0_SEQ_NUM_MASK 0x60638638+#define EC_PACKET4_0_SEQ_DUP_MASK 0x80639639+640640+/* Fields in fields1 byte */641641+#define EC_PACKET4_1_COMMAND_VERSION_MASK 0x1f /* (request only) */642642+#define EC_PACKET4_1_DATA_CRC_PRESENT_MASK 0x80775643776644/*****************************************************************************/777645/*778646 * Notes on commands:779647 *780648 * Each command is an 16-bit command value. Commands which take params or781781- * return response data specify structs for that data. If no struct is649649+ * return response data specify structures for that data. If no structure is782650 * specified, the command does not input or output data, respectively.783651 * Parameter/response length is implicit in the structs. Some underlying784652 * communication protocols (I2C, SPI) may add length or checksum headers, but785653 * those are implementation-dependent and not defined here.654654+ *655655+ * All commands MUST be #defined to be 4-digit UPPER CASE hex values656656+ * (e.g., 0x00AB, not 0xab) for CONFIG_HOSTCMD_SECTION_SORTED to work.786657 */787658788659/*****************************************************************************/···925530 * Get protocol version, used to deal with non-backward compatible protocol926531 * changes.927532 */928928-#define EC_CMD_PROTO_VERSION 0x00533533+#define EC_CMD_PROTO_VERSION 0x0000929534930535/**931536 * struct ec_response_proto_version - Response to the proto version command.···933538 */934539struct ec_response_proto_version {935540 uint32_t version;936936-} __packed;541541+} __ec_align4;937542938543/*939544 * Hello. This is a simple command to test the EC is responsive to940545 * commands.941546 */942942-#define EC_CMD_HELLO 0x01547547+#define EC_CMD_HELLO 0x0001943548944549/**945550 * struct ec_params_hello - Parameters to the hello command.···947552 */948553struct ec_params_hello {949554 uint32_t in_data;950950-} __packed;555555+} __ec_align4;951556952557/**953558 * struct ec_response_hello - Response to the hello command.···955560 */956561struct ec_response_hello {957562 uint32_t out_data;958958-} __packed;563563+} __ec_align4;959564960565/* Get version number */961961-#define EC_CMD_GET_VERSION 0x02566566+#define EC_CMD_GET_VERSION 0x0002962567963568enum ec_current_image {964569 EC_IMAGE_UNKNOWN = 0,···978583 char version_string_rw[32];979584 char reserved[32];980585 uint32_t current_image;981981-} __packed;586586+} __ec_align4;982587983588/* Read test */984984-#define EC_CMD_READ_TEST 0x03589589+#define EC_CMD_READ_TEST 0x0003985590986591/**987592 * struct ec_params_read_test - Parameters for the read test command.···991596struct ec_params_read_test {992597 uint32_t offset;993598 uint32_t size;994994-} __packed;599599+} __ec_align4;995600996601/**997602 * struct ec_response_read_test - Response to the read test command.···999604 */1000605struct ec_response_read_test {1001606 uint32_t data[32];10021002-} __packed;607607+} __ec_align4;10036081004609/*1005610 * Get build information1006611 *1007612 * Response is null-terminated string.1008613 */10091009-#define EC_CMD_GET_BUILD_INFO 0x04614614+#define EC_CMD_GET_BUILD_INFO 0x000410106151011616/* Get chip info */10121012-#define EC_CMD_GET_CHIP_INFO 0x05617617+#define EC_CMD_GET_CHIP_INFO 0x000510136181014619/**1015620 * struct ec_response_get_chip_info - Response to the get chip info command.···1021626 char vendor[32];1022627 char name[32];1023628 char revision[32];10241024-} __packed;629629+} __ec_align4;10256301026631/* Get board HW version */10271027-#define EC_CMD_GET_BOARD_VERSION 0x06632632+#define EC_CMD_GET_BOARD_VERSION 0x000610286331029634/**1030635 * struct ec_response_board_version - Response to the board version command.···1032637 */1033638struct ec_response_board_version {1034639 uint16_t board_version;10351035-} __packed;640640+} __ec_align2;10366411037642/*1038643 * Read memory-mapped data.···1042647 *1043648 * Response is params.size bytes of data.1044649 */10451045-#define EC_CMD_READ_MEMMAP 0x07650650+#define EC_CMD_READ_MEMMAP 0x000710466511047652/**1048653 * struct ec_params_read_memmap - Parameters for the read memory map command.···1052657struct ec_params_read_memmap {1053658 uint8_t offset;1054659 uint8_t size;10551055-} __packed;660660+} __ec_align1;10566611057662/* Read versions supported for a command */10581058-#define EC_CMD_GET_CMD_VERSIONS 0x08663663+#define EC_CMD_GET_CMD_VERSIONS 0x000810596641060665/**1061666 * struct ec_params_get_cmd_versions - Parameters for the get command versions.···1063668 */1064669struct ec_params_get_cmd_versions {1065670 uint8_t cmd;10661066-} __packed;671671+} __ec_align1;10676721068673/**1069674 * struct ec_params_get_cmd_versions_v1 - Parameters for the get command···1072677 */1073678struct ec_params_get_cmd_versions_v1 {1074679 uint16_t cmd;10751075-} __packed;680680+} __ec_align2;10766811077682/**1078683 * struct ec_response_get_cmd_version - Response to the get command versions.···1081686 */1082687struct ec_response_get_cmd_versions {1083688 uint32_t version_mask;10841084-} __packed;689689+} __ec_align4;10856901086691/*10871087- * Check EC communcations status (busy). This is needed on i2c/spi but not692692+ * Check EC communications status (busy). This is needed on i2c/spi but not1088693 * on lpc since it has its own out-of-band busy indicator.1089694 *1090695 * lpc must read the status from the command register. Attempting this on1091696 * lpc will overwrite the args/parameter space and corrupt its data.1092697 */10931093-#define EC_CMD_GET_COMMS_STATUS 0x09698698+#define EC_CMD_GET_COMMS_STATUS 0x000910946991095700/* Avoid using ec_status which is for return values */1096701enum ec_comms_status {10971097- EC_COMMS_STATUS_PROCESSING = 1 << 0, /* Processing cmd */702702+ EC_COMMS_STATUS_PROCESSING = BIT(0), /* Processing cmd */1098703};10997041100705/**···1104709 */1105710struct ec_response_get_comms_status {1106711 uint32_t flags; /* Mask of enum ec_comms_status */11071107-} __packed;712712+} __ec_align4;11087131109714/* Fake a variety of responses, purely for testing purposes. */11101110-#define EC_CMD_TEST_PROTOCOL 0x0a715715+#define EC_CMD_TEST_PROTOCOL 0x000A11117161112717/* Tell the EC what to send back to us. */1113718struct ec_params_test_protocol {1114719 uint32_t ec_result;1115720 uint32_t ret_len;1116721 uint8_t buf[32];11171117-} __packed;722722+} __ec_align4;11187231119724/* Here it comes... */1120725struct ec_response_test_protocol {1121726 uint8_t buf[32];11221122-} __packed;727727+} __ec_align4;112372811241124-/* Get prococol information */11251125-#define EC_CMD_GET_PROTOCOL_INFO 0x0b729729+/* Get protocol information */730730+#define EC_CMD_GET_PROTOCOL_INFO 0x000B11267311127732/* Flags for ec_response_get_protocol_info.flags */1128733/* EC_RES_IN_PROGRESS may be returned if a command is slow */11291129-#define EC_PROTOCOL_INFO_IN_PROGRESS_SUPPORTED (1 << 0)734734+#define EC_PROTOCOL_INFO_IN_PROGRESS_SUPPORTED BIT(0)11307351131736/**1132737 * struct ec_response_get_protocol_info - Response to the get protocol info.···1142747 uint16_t max_request_packet_size;1143748 uint16_t max_response_packet_size;1144749 uint32_t flags;11451145-} __packed;750750+} __ec_align4;114675111477521148753/*****************************************************************************/···1160765struct ec_params_get_set_value {1161766 uint32_t flags;1162767 uint32_t value;11631163-} __packed;768768+} __ec_align4;11647691165770struct ec_response_get_set_value {1166771 uint32_t flags;1167772 uint32_t value;11681168-} __packed;773773+} __ec_align4;116977411701170-/* More than one command can use these structs to get/set paramters. */11711171-#define EC_CMD_GSV_PAUSE_IN_S5 0x0c775775+/* More than one command can use these structs to get/set parameters. */776776+#define EC_CMD_GSV_PAUSE_IN_S5 0x000C11727771173778/*****************************************************************************/1174779/* List the features supported by the firmware */11751175-#define EC_CMD_GET_FEATURES 0x0d780780+#define EC_CMD_GET_FEATURES 0x000D11767811177782/* Supported features */1178783enum ec_feature_code {···1279884 EC_FEATURE_REFINED_TABLET_MODE_HYSTERESIS = 37,1280885 /* EC supports audio codec. */1281886 EC_FEATURE_AUDIO_CODEC = 38,12821282- /* EC Supports SCP. */887887+ /* The MCU is a System Companion Processor (SCP). */1283888 EC_FEATURE_SCP = 39,1284889 /* The MCU is an Integrated Sensor Hub */1285890 EC_FEATURE_ISH = 40,1286891};128789212881288-#define EC_FEATURE_MASK_0(event_code) (1UL << (event_code % 32))12891289-#define EC_FEATURE_MASK_1(event_code) (1UL << (event_code - 32))893893+#define EC_FEATURE_MASK_0(event_code) BIT(event_code % 32)894894+#define EC_FEATURE_MASK_1(event_code) BIT(event_code - 32)12908951291896struct ec_response_get_features {1292897 uint32_t flags[2];12931293-} __packed;898898+} __ec_align4;899899+900900+/*****************************************************************************/901901+/* Get the board's SKU ID from EC */902902+#define EC_CMD_GET_SKU_ID 0x000E903903+904904+/* Set SKU ID from AP */905905+#define EC_CMD_SET_SKU_ID 0x000F906906+907907+struct ec_sku_id_info {908908+ uint32_t sku_id;909909+} __ec_align4;12949101295911/*****************************************************************************/1296912/* Flash commands */12979131298914/* Get flash info */12991299-#define EC_CMD_FLASH_INFO 0x10915915+#define EC_CMD_FLASH_INFO 0x0010916916+#define EC_VER_FLASH_INFO 213009171301918/**1302919 * struct ec_response_flash_info - Response to the flash info command.···1327920 uint32_t write_block_size;1328921 uint32_t erase_block_size;1329922 uint32_t protect_block_size;13301330-} __packed;923923+} __ec_align4;133192413321332-/* Flags for version 1+ flash info command */13331333-/* EC flash erases bits to 0 instead of 1 */13341334-#define EC_FLASH_INFO_ERASE_TO_0 (1 << 0)925925+/*926926+ * Flags for version 1+ flash info command927927+ * EC flash erases bits to 0 instead of 1.928928+ */929929+#define EC_FLASH_INFO_ERASE_TO_0 BIT(0)930930+931931+/*932932+ * Flash must be selected for read/write/erase operations to succeed. This may933933+ * be necessary on a chip where write/erase can be corrupted by other board934934+ * activity, or where the chip needs to enable some sort of programming voltage,935935+ * or where the read/write/erase operations require cleanly suspending other936936+ * chip functionality.937937+ */938938+#define EC_FLASH_INFO_SELECT_REQUIRED BIT(1)13359391336940/**1337941 * struct ec_response_flash_info_1 - Response to the flash info v1 command.···1364946 * fields following.1365947 *1366948 * gcc anonymous structs don't seem to get along with the __packed directive;13671367- * if they did we'd define the version 0 struct as a sub-struct of this one.949949+ * if they did we'd define the version 0 structure as a sub-structure of this950950+ * one.951951+ *952952+ * Version 2 supports flash banks of different sizes:953953+ * The caller specified the number of banks it has preallocated954954+ * (num_banks_desc)955955+ * The EC returns the number of banks describing the flash memory.956956+ * It adds banks descriptions up to num_banks_desc.1368957 */1369958struct ec_response_flash_info_1 {1370959 /* Version 0 fields; see above for description */···1383958 /* Version 1 adds these fields: */1384959 uint32_t write_ideal_size;1385960 uint32_t flags;13861386-} __packed;961961+} __ec_align4;962962+963963+struct ec_params_flash_info_2 {964964+ /* Number of banks to describe */965965+ uint16_t num_banks_desc;966966+ /* Reserved; set 0; ignore on read */967967+ uint8_t reserved[2];968968+} __ec_align4;969969+970970+struct ec_flash_bank {971971+ /* Number of sector is in this bank. */972972+ uint16_t count;973973+ /* Size in power of 2 of each sector (8 --> 256 bytes) */974974+ uint8_t size_exp;975975+ /* Minimal write size for the sectors in this bank */976976+ uint8_t write_size_exp;977977+ /* Erase size for the sectors in this bank */978978+ uint8_t erase_size_exp;979979+ /* Size for write protection, usually identical to erase size. */980980+ uint8_t protect_size_exp;981981+ /* Reserved; set 0; ignore on read */982982+ uint8_t reserved[2];983983+};984984+985985+struct ec_response_flash_info_2 {986986+ /* Total flash in the EC. */987987+ uint32_t flash_size;988988+ /* Flags; see EC_FLASH_INFO_* */989989+ uint32_t flags;990990+ /* Maximum size to use to send data to write to the EC. */991991+ uint32_t write_ideal_size;992992+ /* Number of banks present in the EC. */993993+ uint16_t num_banks_total;994994+ /* Number of banks described in banks array. */995995+ uint16_t num_banks_desc;996996+ struct ec_flash_bank banks[0];997997+} __ec_align4;13879981388999/*13891000 * Read flash13901001 *13911002 * Response is params.size bytes of data.13921003 */13931393-#define EC_CMD_FLASH_READ 0x1110041004+#define EC_CMD_FLASH_READ 0x00111394100513951006/**13961007 * struct ec_params_flash_read - Parameters for the flash read command.···1436975struct ec_params_flash_read {1437976 uint32_t offset;1438977 uint32_t size;14391439-} __packed;978978+} __ec_align4;14409791441980/* Write flash */14421442-#define EC_CMD_FLASH_WRITE 0x12981981+#define EC_CMD_FLASH_WRITE 0x00121443982#define EC_VER_FLASH_WRITE 114449831445984/* Version 0 of the flash command supported only 64 bytes of data */···1454993 uint32_t offset;1455994 uint32_t size;1456995 /* Followed by data to write */14571457-} __packed;996996+} __ec_align4;14589971459998/* Erase flash */14601460-#define EC_CMD_FLASH_ERASE 0x13999999+#define EC_CMD_FLASH_ERASE 0x00131461100014621001/**14631463- * struct ec_params_flash_erase - Parameters for the flash erase command.10021002+ * struct ec_params_flash_erase - Parameters for the flash erase command, v0.14641003 * @offset: Byte offset to erase.14651004 * @size: Size to erase in bytes.14661005 */14671006struct ec_params_flash_erase {14681007 uint32_t offset;14691008 uint32_t size;14701470-} __packed;10091009+} __ec_align4;10101010+10111011+/*10121012+ * v1 add async erase:10131013+ * subcommands can returns:10141014+ * EC_RES_SUCCESS : erased (see ERASE_SECTOR_ASYNC case below).10151015+ * EC_RES_INVALID_PARAM : offset/size are not aligned on a erase boundary.10161016+ * EC_RES_ERROR : other errors.10171017+ * EC_RES_BUSY : an existing erase operation is in progress.10181018+ * EC_RES_ACCESS_DENIED: Trying to erase running image.10191019+ *10201020+ * When ERASE_SECTOR_ASYNC returns EC_RES_SUCCESS, the operation is just10211021+ * properly queued. The user must call ERASE_GET_RESULT subcommand to get10221022+ * the proper result.10231023+ * When ERASE_GET_RESULT returns EC_RES_BUSY, the caller must wait and send10241024+ * ERASE_GET_RESULT again to get the result of ERASE_SECTOR_ASYNC.10251025+ * ERASE_GET_RESULT command may timeout on EC where flash access is not10261026+ * permitted while erasing. (For instance, STM32F4).10271027+ */10281028+enum ec_flash_erase_cmd {10291029+ FLASH_ERASE_SECTOR, /* Erase and wait for result */10301030+ FLASH_ERASE_SECTOR_ASYNC, /* Erase and return immediately. */10311031+ FLASH_ERASE_GET_RESULT, /* Ask for last erase result */10321032+};10331033+10341034+/**10351035+ * struct ec_params_flash_erase_v1 - Parameters for the flash erase command, v1.10361036+ * @cmd: One of ec_flash_erase_cmd.10371037+ * @reserved: Pad byte; currently always contains 0.10381038+ * @flag: No flags defined yet; set to 0.10391039+ * @params: Same as v0 parameters.10401040+ */10411041+struct ec_params_flash_erase_v1 {10421042+ uint8_t cmd;10431043+ uint8_t reserved;10441044+ uint16_t flag;10451045+ struct ec_params_flash_erase params;10461046+} __ec_align4;1471104714721048/*14731049 * Get/set flash protection.···15161018 *15171019 * If mask=0, simply returns the current flags state.15181020 */15191519-#define EC_CMD_FLASH_PROTECT 0x1510211021+#define EC_CMD_FLASH_PROTECT 0x001515201022#define EC_VER_FLASH_PROTECT 1 /* Command version 1 */1521102315221024/* Flags for flash protection */15231025/* RO flash code protected when the EC boots */15241524-#define EC_FLASH_PROTECT_RO_AT_BOOT (1 << 0)10261026+#define EC_FLASH_PROTECT_RO_AT_BOOT BIT(0)15251027/*15261028 * RO flash code protected now. If this bit is set, at-boot status cannot15271029 * be changed.15281030 */15291529-#define EC_FLASH_PROTECT_RO_NOW (1 << 1)10311031+#define EC_FLASH_PROTECT_RO_NOW BIT(1)15301032/* Entire flash code protected now, until reboot. */15311531-#define EC_FLASH_PROTECT_ALL_NOW (1 << 2)10331033+#define EC_FLASH_PROTECT_ALL_NOW BIT(2)15321034/* Flash write protect GPIO is asserted now */15331533-#define EC_FLASH_PROTECT_GPIO_ASSERTED (1 << 3)10351035+#define EC_FLASH_PROTECT_GPIO_ASSERTED BIT(3)15341036/* Error - at least one bank of flash is stuck locked, and cannot be unlocked */15351535-#define EC_FLASH_PROTECT_ERROR_STUCK (1 << 4)10371037+#define EC_FLASH_PROTECT_ERROR_STUCK BIT(4)15361038/*15371039 * Error - flash protection is in inconsistent state. At least one bank of15381040 * flash which should be protected is not protected. Usually fixed by15391041 * re-requesting the desired flags, or by a hard reset if that fails.15401042 */15411541-#define EC_FLASH_PROTECT_ERROR_INCONSISTENT (1 << 5)15421542-/* Entile flash code protected when the EC boots */15431543-#define EC_FLASH_PROTECT_ALL_AT_BOOT (1 << 6)10431043+#define EC_FLASH_PROTECT_ERROR_INCONSISTENT BIT(5)10441044+/* Entire flash code protected when the EC boots */10451045+#define EC_FLASH_PROTECT_ALL_AT_BOOT BIT(6)10461046+/* RW flash code protected when the EC boots */10471047+#define EC_FLASH_PROTECT_RW_AT_BOOT BIT(7)10481048+/* RW flash code protected now. */10491049+#define EC_FLASH_PROTECT_RW_NOW BIT(8)10501050+/* Rollback information flash region protected when the EC boots */10511051+#define EC_FLASH_PROTECT_ROLLBACK_AT_BOOT BIT(9)10521052+/* Rollback information flash region protected now */10531053+#define EC_FLASH_PROTECT_ROLLBACK_NOW BIT(10)10541054+1544105515451056/**15461057 * struct ec_params_flash_protect - Parameters for the flash protect command.···15591052struct ec_params_flash_protect {15601053 uint32_t mask;15611054 uint32_t flags;15621562-} __packed;10551055+} __ec_align4;1563105615641057/**15651058 * struct ec_response_flash_protect - Response to the flash protect command.···15741067 uint32_t flags;15751068 uint32_t valid_flags;15761069 uint32_t writable_flags;15771577-} __packed;10701070+} __ec_align4;1578107115791072/*15801073 * Note: commands 0x14 - 0x19 version 0 were old commands to get/set flash···15821075 */1583107615841077/* Get the region offset/size */15851585-#define EC_CMD_FLASH_REGION_INFO 0x1610781078+#define EC_CMD_FLASH_REGION_INFO 0x001615861079#define EC_VER_FLASH_REGION_INFO 11587108015881081enum ec_flash_region {15891082 /* Region which holds read-only EC image */15901083 EC_FLASH_REGION_RO = 0,15911591- /* Region which holds rewritable EC image */15921592- EC_FLASH_REGION_RW,10841084+ /*10851085+ * Region which holds active RW image. 'Active' is different from10861086+ * 'running'. Active means 'scheduled-to-run'. Since RO image always10871087+ * scheduled to run, active/non-active applies only to RW images (for10881088+ * the same reason 'update' applies only to RW images. It's a state of10891089+ * an image on a flash. Running image can be RO, RW_A, RW_B but active10901090+ * image can only be RW_A or RW_B. In recovery mode, an active RW image10911091+ * doesn't enter 'running' state but it's still active on a flash.10921092+ */10931093+ EC_FLASH_REGION_ACTIVE,15931094 /*15941095 * Region which should be write-protected in the factory (a superset of15951096 * EC_FLASH_REGION_RO)15961097 */15971098 EC_FLASH_REGION_WP_RO,10991099+ /* Region which holds updatable (non-active) RW image */11001100+ EC_FLASH_REGION_UPDATE,15981101 /* Number of regions */15991102 EC_FLASH_REGION_COUNT,16001103};11041104+/*11051105+ * 'RW' is vague if there are multiple RW images; we mean the active one,11061106+ * so the old constant is deprecated.11071107+ */11081108+#define EC_FLASH_REGION_RW EC_FLASH_REGION_ACTIVE1601110916021110/**16031111 * struct ec_params_flash_region_info - Parameters for the flash region info···16211099 */16221100struct ec_params_flash_region_info {16231101 uint32_t region;16241624-} __packed;11021102+} __ec_align4;1625110316261104struct ec_response_flash_region_info {16271105 uint32_t offset;16281106 uint32_t size;16291629-} __packed;11071107+} __ec_align4;1630110816311109/* Read/write VbNvContext */16321632-#define EC_CMD_VBNV_CONTEXT 0x1711101110+#define EC_CMD_VBNV_CONTEXT 0x001716331111#define EC_VER_VBNV_CONTEXT 116341112#define EC_VBNV_BLOCK_SIZE 1616351113···16411119struct ec_params_vbnvcontext {16421120 uint32_t op;16431121 uint8_t block[EC_VBNV_BLOCK_SIZE];16441644-} __packed;11221122+} __ec_align4;1645112316461124struct ec_response_vbnvcontext {16471125 uint8_t block[EC_VBNV_BLOCK_SIZE];16481648-} __packed;11261126+} __ec_align4;11271127+11281128+11291129+/* Get SPI flash information */11301130+#define EC_CMD_FLASH_SPI_INFO 0x001811311131+11321132+struct ec_response_flash_spi_info {11331133+ /* JEDEC info from command 0x9F (manufacturer, memory type, size) */11341134+ uint8_t jedec[3];11351135+11361136+ /* Pad byte; currently always contains 0 */11371137+ uint8_t reserved0;11381138+11391139+ /* Manufacturer / device ID from command 0x90 */11401140+ uint8_t mfr_dev_id[2];11411141+11421142+ /* Status registers from command 0x05 and 0x35 */11431143+ uint8_t sr1, sr2;11441144+} __ec_align1;11451145+11461146+11471147+/* Select flash during flash operations */11481148+#define EC_CMD_FLASH_SELECT 0x001911491149+11501150+/**11511151+ * struct ec_params_flash_select - Parameters for the flash select command.11521152+ * @select: 1 to select flash, 0 to deselect flash11531153+ */11541154+struct ec_params_flash_select {11551155+ uint8_t select;11561156+} __ec_align4;11571157+1649115816501159/*****************************************************************************/16511160/* PWM commands */1652116116531162/* Get fan target RPM */16541654-#define EC_CMD_PWM_GET_FAN_TARGET_RPM 0x2011631163+#define EC_CMD_PWM_GET_FAN_TARGET_RPM 0x00201655116416561165struct ec_response_pwm_get_fan_rpm {16571166 uint32_t rpm;16581658-} __packed;11671167+} __ec_align4;1659116816601169/* Set target fan RPM */16611661-#define EC_CMD_PWM_SET_FAN_TARGET_RPM 0x2111701170+#define EC_CMD_PWM_SET_FAN_TARGET_RPM 0x00211662117116631663-struct ec_params_pwm_set_fan_target_rpm {11721172+/* Version 0 of input params */11731173+struct ec_params_pwm_set_fan_target_rpm_v0 {16641174 uint32_t rpm;16651665-} __packed;11751175+} __ec_align4;11761176+11771177+/* Version 1 of input params */11781178+struct ec_params_pwm_set_fan_target_rpm_v1 {11791179+ uint32_t rpm;11801180+ uint8_t fan_idx;11811181+} __ec_align_size1;1666118216671183/* Get keyboard backlight */16681668-#define EC_CMD_PWM_GET_KEYBOARD_BACKLIGHT 0x2211841184+/* OBSOLETE - Use EC_CMD_PWM_SET_DUTY */11851185+#define EC_CMD_PWM_GET_KEYBOARD_BACKLIGHT 0x00221669118616701187struct ec_response_pwm_get_keyboard_backlight {16711188 uint8_t percent;16721189 uint8_t enabled;16731673-} __packed;11901190+} __ec_align1;1674119116751192/* Set keyboard backlight */16761676-#define EC_CMD_PWM_SET_KEYBOARD_BACKLIGHT 0x2311931193+/* OBSOLETE - Use EC_CMD_PWM_SET_DUTY */11941194+#define EC_CMD_PWM_SET_KEYBOARD_BACKLIGHT 0x00231677119516781196struct ec_params_pwm_set_keyboard_backlight {16791197 uint8_t percent;16801680-} __packed;11981198+} __ec_align1;1681119916821200/* Set target fan PWM duty cycle */16831683-#define EC_CMD_PWM_SET_FAN_DUTY 0x2412011201+#define EC_CMD_PWM_SET_FAN_DUTY 0x00241684120216851685-struct ec_params_pwm_set_fan_duty {12031203+/* Version 0 of input params */12041204+struct ec_params_pwm_set_fan_duty_v0 {16861205 uint32_t percent;16871687-} __packed;12061206+} __ec_align4;1688120716891689-#define EC_CMD_PWM_SET_DUTY 0x2512081208+/* Version 1 of input params */12091209+struct ec_params_pwm_set_fan_duty_v1 {12101210+ uint32_t percent;12111211+ uint8_t fan_idx;12121212+} __ec_align_size1;12131213+12141214+#define EC_CMD_PWM_SET_DUTY 0x002516901215/* 16 bit duty cycle, 0xffff = 100% */16911216#define EC_PWM_MAX_DUTY 0xffff16921217···17511182 uint16_t duty; /* Duty cycle, EC_PWM_MAX_DUTY = 100% */17521183 uint8_t pwm_type; /* ec_pwm_type */17531184 uint8_t index; /* Type-specific index, or 0 if unique */17541754-} __packed;11851185+} __ec_align4;1755118617561756-#define EC_CMD_PWM_GET_DUTY 0x2611871187+#define EC_CMD_PWM_GET_DUTY 0x00261757118817581189struct ec_params_pwm_get_duty {17591190 uint8_t pwm_type; /* ec_pwm_type */17601191 uint8_t index; /* Type-specific index, or 0 if unique */17611761-} __packed;11921192+} __ec_align1;1762119317631194struct ec_response_pwm_get_duty {17641195 uint16_t duty; /* Duty cycle, EC_PWM_MAX_DUTY = 100% */17651765-} __packed;11961196+} __ec_align2;1766119717671198/*****************************************************************************/17681199/*···17711202 * into a subcommand. We'll make separate structs for subcommands with17721203 * different input args, so that we know how much to expect.17731204 */17741774-#define EC_CMD_LIGHTBAR_CMD 0x2812051205+#define EC_CMD_LIGHTBAR_CMD 0x00281775120617761207struct rgb_s {17771208 uint8_t r, g, b;17781778-};12091209+} __ec_todo_unpacked;1779121017801211#define LB_BATTERY_LEVELS 417811212···1815124618161247 /* Color palette */18171248 struct rgb_s color[8]; /* 0-3 are Google colors */18181818-} __packed;12491249+} __ec_todo_packed;1819125018201251struct lightbar_params_v1 {18211252 /* Timing */···18281259 int32_t s3_sleep_for;18291260 int32_t s3_ramp_up;18301261 int32_t s3_ramp_down;12621262+ int32_t s5_ramp_up;12631263+ int32_t s5_ramp_down;18311264 int32_t tap_tick_delay;12651265+ int32_t tap_gate_delay;18321266 int32_t tap_display_time;1833126718341268 /* Tap-for-battery params */···18591287 uint8_t s0_idx[2][LB_BATTERY_LEVELS]; /* AP is running */18601288 uint8_t s3_idx[2][LB_BATTERY_LEVELS]; /* AP is sleeping */1861128912901290+ /* s5: single color pulse on inhibited power-up */12911291+ uint8_t s5_idx;12921292+18621293 /* Color palette */18631294 struct rgb_s color[8]; /* 0-3 are Google colors */18641864-} __packed;12951295+} __ec_todo_packed;1865129618661866-/* Lightbar program */12971297+/* Lightbar command params v212981298+ * crbug.com/46771612991299+ *13001300+ * lightbar_parms_v1 was too big for i2c, therefore in v2, we split them up by13011301+ * logical groups to make it more manageable ( < 120 bytes).13021302+ *13031303+ * NOTE: Each of these groups must be less than 120 bytes.13041304+ */13051305+13061306+struct lightbar_params_v2_timing {13071307+ /* Timing */13081308+ int32_t google_ramp_up;13091309+ int32_t google_ramp_down;13101310+ int32_t s3s0_ramp_up;13111311+ int32_t s0_tick_delay[2]; /* AC=0/1 */13121312+ int32_t s0a_tick_delay[2]; /* AC=0/1 */13131313+ int32_t s0s3_ramp_down;13141314+ int32_t s3_sleep_for;13151315+ int32_t s3_ramp_up;13161316+ int32_t s3_ramp_down;13171317+ int32_t s5_ramp_up;13181318+ int32_t s5_ramp_down;13191319+ int32_t tap_tick_delay;13201320+ int32_t tap_gate_delay;13211321+ int32_t tap_display_time;13221322+} __ec_todo_packed;13231323+13241324+struct lightbar_params_v2_tap {13251325+ /* Tap-for-battery params */13261326+ uint8_t tap_pct_red;13271327+ uint8_t tap_pct_green;13281328+ uint8_t tap_seg_min_on;13291329+ uint8_t tap_seg_max_on;13301330+ uint8_t tap_seg_osc;13311331+ uint8_t tap_idx[3];13321332+} __ec_todo_packed;13331333+13341334+struct lightbar_params_v2_oscillation {13351335+ /* Oscillation */13361336+ uint8_t osc_min[2]; /* AC=0/1 */13371337+ uint8_t osc_max[2]; /* AC=0/1 */13381338+ uint8_t w_ofs[2]; /* AC=0/1 */13391339+} __ec_todo_packed;13401340+13411341+struct lightbar_params_v2_brightness {13421342+ /* Brightness limits based on the backlight and AC. */13431343+ uint8_t bright_bl_off_fixed[2]; /* AC=0/1 */13441344+ uint8_t bright_bl_on_min[2]; /* AC=0/1 */13451345+ uint8_t bright_bl_on_max[2]; /* AC=0/1 */13461346+} __ec_todo_packed;13471347+13481348+struct lightbar_params_v2_thresholds {13491349+ /* Battery level thresholds */13501350+ uint8_t battery_threshold[LB_BATTERY_LEVELS - 1];13511351+} __ec_todo_packed;13521352+13531353+struct lightbar_params_v2_colors {13541354+ /* Map [AC][battery_level] to color index */13551355+ uint8_t s0_idx[2][LB_BATTERY_LEVELS]; /* AP is running */13561356+ uint8_t s3_idx[2][LB_BATTERY_LEVELS]; /* AP is sleeping */13571357+13581358+ /* s5: single color pulse on inhibited power-up */13591359+ uint8_t s5_idx;13601360+13611361+ /* Color palette */13621362+ struct rgb_s color[8]; /* 0-3 are Google colors */13631363+} __ec_todo_packed;13641364+13651365+/* Lightbar program. */18671366#define EC_LB_PROG_LEN 19218681367struct lightbar_program {18691368 uint8_t size;18701369 uint8_t data[EC_LB_PROG_LEN];18711871-};13701370+} __ec_todo_unpacked;1872137118731372struct ec_params_lightbar {18741373 uint8_t cmd; /* Command (see enum lightbar_command) */18751374 union {18761876- struct {18771877- /* no args */18781878- } dump, off, on, init, get_seq, get_params_v0, get_params_v1,18791879- version, get_brightness, get_demo, suspend, resume;13751375+ /*13761376+ * The following commands have no args:13771377+ *13781378+ * dump, off, on, init, get_seq, get_params_v0, get_params_v1,13791379+ * version, get_brightness, get_demo, suspend, resume,13801380+ * get_params_v2_timing, get_params_v2_tap, get_params_v2_osc,13811381+ * get_params_v2_bright, get_params_v2_thlds,13821382+ * get_params_v2_colors13831383+ *13841384+ * Don't use an empty struct, because C++ hates that.13851385+ */1880138618811881- struct {13871387+ struct __ec_todo_unpacked {18821388 uint8_t num;18831389 } set_brightness, seq, demo;1884139018851885- struct {13911391+ struct __ec_todo_unpacked {18861392 uint8_t ctrl, reg, value;18871393 } reg;1888139418891889- struct {13951395+ struct __ec_todo_unpacked {18901396 uint8_t led, red, green, blue;18911397 } set_rgb;1892139818931893- struct {13991399+ struct __ec_todo_unpacked {18941400 uint8_t led;18951401 } get_rgb;1896140218971897- struct {14031403+ struct __ec_todo_unpacked {18981404 uint8_t enable;18991405 } manual_suspend_ctrl;1900140619011407 struct lightbar_params_v0 set_params_v0;19021408 struct lightbar_params_v1 set_params_v1;14091409+14101410+ struct lightbar_params_v2_timing set_v2par_timing;14111411+ struct lightbar_params_v2_tap set_v2par_tap;14121412+ struct lightbar_params_v2_oscillation set_v2par_osc;14131413+ struct lightbar_params_v2_brightness set_v2par_bright;14141414+ struct lightbar_params_v2_thresholds set_v2par_thlds;14151415+ struct lightbar_params_v2_colors set_v2par_colors;14161416+19031417 struct lightbar_program set_program;19041418 };19051905-} __packed;14191419+} __ec_todo_packed;1906142019071421struct ec_response_lightbar {19081422 union {19091909- struct {19101910- struct {14231423+ struct __ec_todo_unpacked {14241424+ struct __ec_todo_unpacked {19111425 uint8_t reg;19121426 uint8_t ic0;19131427 uint8_t ic1;19141428 } vals[23];19151429 } dump;1916143019171917- struct {14311431+ struct __ec_todo_unpacked {19181432 uint8_t num;19191433 } get_seq, get_brightness, get_demo;1920143419211435 struct lightbar_params_v0 get_params_v0;19221436 struct lightbar_params_v1 get_params_v1;1923143719241924- struct {14381438+14391439+ struct lightbar_params_v2_timing get_params_v2_timing;14401440+ struct lightbar_params_v2_tap get_params_v2_tap;14411441+ struct lightbar_params_v2_oscillation get_params_v2_osc;14421442+ struct lightbar_params_v2_brightness get_params_v2_bright;14431443+ struct lightbar_params_v2_thresholds get_params_v2_thlds;14441444+ struct lightbar_params_v2_colors get_params_v2_colors;14451445+14461446+ struct __ec_todo_unpacked {19251447 uint32_t num;19261448 uint32_t flags;19271449 } version;1928145019291929- struct {14511451+ struct __ec_todo_unpacked {19301452 uint8_t red, green, blue;19311453 } get_rgb;1932145419331933- struct {19341934- /* no return params */19351935- } off, on, init, set_brightness, seq, reg, set_rgb,19361936- demo, set_params_v0, set_params_v1,19371937- set_program, manual_suspend_ctrl, suspend, resume;14551455+ /*14561456+ * The following commands have no response:14571457+ *14581458+ * off, on, init, set_brightness, seq, reg, set_rgb, demo,14591459+ * set_params_v0, set_params_v1, set_program,14601460+ * manual_suspend_ctrl, suspend, resume, set_v2par_timing,14611461+ * set_v2par_tap, set_v2par_osc, set_v2par_bright,14621462+ * set_v2par_thlds, set_v2par_colors14631463+ */19381464 };19391939-} __packed;14651465+} __ec_todo_packed;1940146619411467/* Lightbar commands */19421468enum lightbar_command {···20601390 LIGHTBAR_CMD_MANUAL_SUSPEND_CTRL = 19,20611391 LIGHTBAR_CMD_SUSPEND = 20,20621392 LIGHTBAR_CMD_RESUME = 21,13931393+ LIGHTBAR_CMD_GET_PARAMS_V2_TIMING = 22,13941394+ LIGHTBAR_CMD_SET_PARAMS_V2_TIMING = 23,13951395+ LIGHTBAR_CMD_GET_PARAMS_V2_TAP = 24,13961396+ LIGHTBAR_CMD_SET_PARAMS_V2_TAP = 25,13971397+ LIGHTBAR_CMD_GET_PARAMS_V2_OSCILLATION = 26,13981398+ LIGHTBAR_CMD_SET_PARAMS_V2_OSCILLATION = 27,13991399+ LIGHTBAR_CMD_GET_PARAMS_V2_BRIGHTNESS = 28,14001400+ LIGHTBAR_CMD_SET_PARAMS_V2_BRIGHTNESS = 29,14011401+ LIGHTBAR_CMD_GET_PARAMS_V2_THRESHOLDS = 30,14021402+ LIGHTBAR_CMD_SET_PARAMS_V2_THRESHOLDS = 31,14031403+ LIGHTBAR_CMD_GET_PARAMS_V2_COLORS = 32,14041404+ LIGHTBAR_CMD_SET_PARAMS_V2_COLORS = 33,20631405 LIGHTBAR_NUM_CMDS20641406};2065140720661408/*****************************************************************************/20671409/* LED control commands */2068141020692069-#define EC_CMD_LED_CONTROL 0x2914111411+#define EC_CMD_LED_CONTROL 0x00292070141220711413enum ec_led_id {20721414 /* LED to indicate battery state of charge */···20901408 EC_LED_ID_POWER_LED,20911409 /* LED on power adapter or its plug */20921410 EC_LED_ID_ADAPTER_LED,14111411+ /* LED to indicate left side */14121412+ EC_LED_ID_LEFT_LED,14131413+ /* LED to indicate right side */14141414+ EC_LED_ID_RIGHT_LED,14151415+ /* LED to indicate recovery mode with HW_REINIT */14161416+ EC_LED_ID_RECOVERY_HW_REINIT_LED,14171417+ /* LED to indicate sysrq debug mode. */14181418+ EC_LED_ID_SYSRQ_DEBUG_LED,2093141920941420 EC_LED_ID_COUNT20951421};2096142220971423/* LED control flags */20982098-#define EC_LED_FLAGS_QUERY (1 << 0) /* Query LED capability only */20992099-#define EC_LED_FLAGS_AUTO (1 << 1) /* Switch LED back to automatic control */14241424+#define EC_LED_FLAGS_QUERY BIT(0) /* Query LED capability only */14251425+#define EC_LED_FLAGS_AUTO BIT(1) /* Switch LED back to automatic control */2100142621011427enum ec_led_colors {21021428 EC_LED_COLOR_RED = 0,···21121422 EC_LED_COLOR_BLUE,21131423 EC_LED_COLOR_YELLOW,21141424 EC_LED_COLOR_WHITE,14251425+ EC_LED_COLOR_AMBER,2115142621161427 EC_LED_COLOR_COUNT21171428};···21221431 uint8_t flags; /* Control flags */2123143221241433 uint8_t brightness[EC_LED_COLOR_COUNT];21252125-} __packed;14341434+} __ec_align1;2126143521271436struct ec_response_led_control {21281437 /*···21331442 * Other values means the LED is control by PWM.21341443 */21351444 uint8_t brightness_range[EC_LED_COLOR_COUNT];21362136-} __packed;14451445+} __ec_align1;2137144621381447/*****************************************************************************/21391448/* Verified boot commands */···21441453 */2145145421461455/* Verified boot hash command */21472147-#define EC_CMD_VBOOT_HASH 0x2A14561456+#define EC_CMD_VBOOT_HASH 0x002A2148145721491458struct ec_params_vboot_hash {21501459 uint8_t cmd; /* enum ec_vboot_hash_cmd */···21541463 uint32_t offset; /* Offset in flash to hash */21551464 uint32_t size; /* Number of bytes to hash */21561465 uint8_t nonce_data[64]; /* Nonce data; ignored if nonce_size=0 */21572157-} __packed;14661466+} __ec_align4;2158146721591468struct ec_response_vboot_hash {21601469 uint8_t status; /* enum ec_vboot_hash_status */···21641473 uint32_t offset; /* Offset in flash which was hashed */21651474 uint32_t size; /* Number of bytes hashed */21661475 uint8_t hash_digest[64]; /* Hash digest data */21672167-} __packed;14761476+} __ec_align4;2168147721691478enum ec_vboot_hash_cmd {21701479 EC_VBOOT_HASH_GET = 0, /* Get current hash status */···21881497 * If one of these is specified, the EC will automatically update offset and21891498 * size to the correct values for the specified image (RO or RW).21901499 */21912191-#define EC_VBOOT_HASH_OFFSET_RO 0xfffffffe21922192-#define EC_VBOOT_HASH_OFFSET_RW 0xfffffffd15001500+#define EC_VBOOT_HASH_OFFSET_RO 0xfffffffe15011501+#define EC_VBOOT_HASH_OFFSET_ACTIVE 0xfffffffd15021502+#define EC_VBOOT_HASH_OFFSET_UPDATE 0xfffffffc15031503+15041504+/*15051505+ * 'RW' is vague if there are multiple RW images; we mean the active one,15061506+ * so the old constant is deprecated.15071507+ */15081508+#define EC_VBOOT_HASH_OFFSET_RW EC_VBOOT_HASH_OFFSET_ACTIVE2193150921941510/*****************************************************************************/21951511/*21961512 * Motion sense commands. We'll make separate structs for sub-commands with21971513 * different input args, so that we know how much to expect.21981514 */21992199-#define EC_CMD_MOTION_SENSE_CMD 0x2B15151515+#define EC_CMD_MOTION_SENSE_CMD 0x002B2200151622011517/* Motion sense commands */22021518enum motionsense_command {···2222152422231525 /*22241526 * EC Rate command is a setter/getter command for the EC sampling rate22252225- * of all motion sensors in milliseconds.15271527+ * in milliseconds.15281528+ * It is per sensor, the EC run sample task at the minimum of all15291529+ * sensors EC_RATE.15301530+ * For sensors without hardware FIFO, EC_RATE should be equals to 1/ODR15311531+ * to collect all the sensor samples.15321532+ * For sensor with hardware FIFO, EC_RATE is used as the maximal delay15331533+ * to process of all motion sensors in milliseconds.22261534 */22271535 MOTIONSENSE_CMD_EC_RATE = 2,22281536···22591555 MOTIONSENSE_CMD_DATA = 6,2260155622611557 /*22622262- * Perform low level calibration.. On sensors that support it, ask to22632263- * do offset calibration.15581558+ * Return sensor fifo info.15591559+ */15601560+ MOTIONSENSE_CMD_FIFO_INFO = 7,15611561+15621562+ /*15631563+ * Insert a flush element in the fifo and return sensor fifo info.15641564+ * The host can use that element to synchronize its operation.15651565+ */15661566+ MOTIONSENSE_CMD_FIFO_FLUSH = 8,15671567+15681568+ /*15691569+ * Return a portion of the fifo.15701570+ */15711571+ MOTIONSENSE_CMD_FIFO_READ = 9,15721572+15731573+ /*15741574+ * Perform low level calibration.15751575+ * On sensors that support it, ask to do offset calibration.22641576 */22651577 MOTIONSENSE_CMD_PERFORM_CALIB = 10,2266157822671579 /*22682268- * Sensor Offset command is a setter/getter command for the offset used22692269- * for calibration. The offsets can be calculated by the host, or via15801580+ * Sensor Offset command is a setter/getter command for the offset15811581+ * used for calibration.15821582+ * The offsets can be calculated by the host, or via22701583 * PERFORM_CALIB command.22711584 */22721585 MOTIONSENSE_CMD_SENSOR_OFFSET = 11,2273158622742274- /* Number of motionsense sub-commands. */22752275- MOTIONSENSE_NUM_CMDS22762276-};22772277-22782278-enum motionsensor_id {22792279- EC_MOTION_SENSOR_ACCEL_BASE = 0,22802280- EC_MOTION_SENSOR_ACCEL_LID = 1,22812281- EC_MOTION_SENSOR_GYRO = 2,15871587+ /*15881588+ * List available activities for a MOTION sensor.15891589+ * Indicates if they are enabled or disabled.15901590+ */15911591+ MOTIONSENSE_CMD_LIST_ACTIVITIES = 12,2282159222831593 /*22842284- * Note, if more sensors are added and this count changes, the padding22852285- * in ec_response_motion_sense dump command must be modified.15941594+ * Activity management15951595+ * Enable/Disable activity recognition.22861596 */22872287- EC_MOTION_SENSOR_COUNT = 315971597+ MOTIONSENSE_CMD_SET_ACTIVITY = 13,15981598+15991599+ /*16001600+ * Lid Angle16011601+ */16021602+ MOTIONSENSE_CMD_LID_ANGLE = 14,16031603+16041604+ /*16051605+ * Allow the FIFO to trigger interrupt via MKBP events.16061606+ * By default the FIFO does not send interrupt to process the FIFO16071607+ * until the AP is ready or it is coming from a wakeup sensor.16081608+ */16091609+ MOTIONSENSE_CMD_FIFO_INT_ENABLE = 15,16101610+16111611+ /*16121612+ * Spoof the readings of the sensors. The spoofed readings can be set16131613+ * to arbitrary values, or will lock to the last read actual values.16141614+ */16151615+ MOTIONSENSE_CMD_SPOOF = 16,16161616+16171617+ /* Set lid angle for tablet mode detection. */16181618+ MOTIONSENSE_CMD_TABLET_MODE_LID_ANGLE = 17,16191619+16201620+ /*16211621+ * Sensor Scale command is a setter/getter command for the calibration16221622+ * scale.16231623+ */16241624+ MOTIONSENSE_CMD_SENSOR_SCALE = 18,16251625+16261626+ /* Number of motionsense sub-commands. */16271627+ MOTIONSENSE_NUM_CMDS22881628};2289162922901630/* List of motion sensor types. */···23401592 MOTIONSENSE_TYPE_LIGHT = 4,23411593 MOTIONSENSE_TYPE_ACTIVITY = 5,23421594 MOTIONSENSE_TYPE_BARO = 6,15951595+ MOTIONSENSE_TYPE_SYNC = 7,23431596 MOTIONSENSE_TYPE_MAX,23441597};23451598···23481599enum motionsensor_location {23491600 MOTIONSENSE_LOC_BASE = 0,23501601 MOTIONSENSE_LOC_LID = 1,16021602+ MOTIONSENSE_LOC_CAMERA = 2,23511603 MOTIONSENSE_LOC_MAX,23521604};2353160523541606/* List of motion sensor chips. */23551607enum motionsensor_chip {23561608 MOTIONSENSE_CHIP_KXCJ9 = 0,16091609+ MOTIONSENSE_CHIP_LSM6DS0 = 1,16101610+ MOTIONSENSE_CHIP_BMI160 = 2,16111611+ MOTIONSENSE_CHIP_SI1141 = 3,16121612+ MOTIONSENSE_CHIP_SI1142 = 4,16131613+ MOTIONSENSE_CHIP_SI1143 = 5,16141614+ MOTIONSENSE_CHIP_KX022 = 6,16151615+ MOTIONSENSE_CHIP_L3GD20H = 7,16161616+ MOTIONSENSE_CHIP_BMA255 = 8,16171617+ MOTIONSENSE_CHIP_BMP280 = 9,16181618+ MOTIONSENSE_CHIP_OPT3001 = 10,16191619+ MOTIONSENSE_CHIP_BH1730 = 11,16201620+ MOTIONSENSE_CHIP_GPIO = 12,16211621+ MOTIONSENSE_CHIP_LIS2DH = 13,16221622+ MOTIONSENSE_CHIP_LSM6DSM = 14,16231623+ MOTIONSENSE_CHIP_LIS2DE = 15,16241624+ MOTIONSENSE_CHIP_LIS2MDL = 16,16251625+ MOTIONSENSE_CHIP_LSM6DS3 = 17,16261626+ MOTIONSENSE_CHIP_LSM6DSO = 18,16271627+ MOTIONSENSE_CHIP_LNG2DM = 19,16281628+ MOTIONSENSE_CHIP_MAX,23571629};2358163016311631+/* List of orientation positions */16321632+enum motionsensor_orientation {16331633+ MOTIONSENSE_ORIENTATION_LANDSCAPE = 0,16341634+ MOTIONSENSE_ORIENTATION_PORTRAIT = 1,16351635+ MOTIONSENSE_ORIENTATION_UPSIDE_DOWN_PORTRAIT = 2,16361636+ MOTIONSENSE_ORIENTATION_UPSIDE_DOWN_LANDSCAPE = 3,16371637+ MOTIONSENSE_ORIENTATION_UNKNOWN = 4,16381638+};16391639+16401640+struct ec_response_motion_sensor_data {16411641+ /* Flags for each sensor. */16421642+ uint8_t flags;16431643+ /* Sensor number the data comes from. */16441644+ uint8_t sensor_num;16451645+ /* Each sensor is up to 3-axis. */16461646+ union {16471647+ int16_t data[3];16481648+ struct __ec_todo_packed {16491649+ uint16_t reserved;16501650+ uint32_t timestamp;16511651+ };16521652+ struct __ec_todo_unpacked {16531653+ uint8_t activity; /* motionsensor_activity */16541654+ uint8_t state;16551655+ int16_t add_info[2];16561656+ };16571657+ };16581658+} __ec_todo_packed;16591659+16601660+/* Note: used in ec_response_get_next_data */16611661+struct ec_response_motion_sense_fifo_info {16621662+ /* Size of the fifo */16631663+ uint16_t size;16641664+ /* Amount of space used in the fifo */16651665+ uint16_t count;16661666+ /* Timestamp recorded in us.16671667+ * aka accurate timestamp when host event was triggered.16681668+ */16691669+ uint32_t timestamp;16701670+ /* Total amount of vector lost */16711671+ uint16_t total_lost;16721672+ /* Lost events since the last fifo_info, per sensors */16731673+ uint16_t lost[0];16741674+} __ec_todo_packed;16751675+16761676+struct ec_response_motion_sense_fifo_data {16771677+ uint32_t number_data;16781678+ struct ec_response_motion_sensor_data data[0];16791679+} __ec_todo_packed;16801680+16811681+/* List supported activity recognition */16821682+enum motionsensor_activity {16831683+ MOTIONSENSE_ACTIVITY_RESERVED = 0,16841684+ MOTIONSENSE_ACTIVITY_SIG_MOTION = 1,16851685+ MOTIONSENSE_ACTIVITY_DOUBLE_TAP = 2,16861686+ MOTIONSENSE_ACTIVITY_ORIENTATION = 3,16871687+};16881688+16891689+struct ec_motion_sense_activity {16901690+ uint8_t sensor_num;16911691+ uint8_t activity; /* one of enum motionsensor_activity */16921692+ uint8_t enable; /* 1: enable, 0: disable */16931693+ uint8_t reserved;16941694+ uint16_t parameters[3]; /* activity dependent parameters */16951695+} __ec_todo_unpacked;16961696+23591697/* Module flag masks used for the dump sub-command. */23602360-#define MOTIONSENSE_MODULE_FLAG_ACTIVE (1<<0)16981698+#define MOTIONSENSE_MODULE_FLAG_ACTIVE BIT(0)2361169923621700/* Sensor flag masks used for the dump sub-command. */23632363-#define MOTIONSENSE_SENSOR_FLAG_PRESENT (1<<0)17011701+#define MOTIONSENSE_SENSOR_FLAG_PRESENT BIT(0)17021702+17031703+/*17041704+ * Flush entry for synchronization.17051705+ * data contains time stamp17061706+ */17071707+#define MOTIONSENSE_SENSOR_FLAG_FLUSH BIT(0)17081708+#define MOTIONSENSE_SENSOR_FLAG_TIMESTAMP BIT(1)17091709+#define MOTIONSENSE_SENSOR_FLAG_WAKEUP BIT(2)17101710+#define MOTIONSENSE_SENSOR_FLAG_TABLET_MODE BIT(3)17111711+#define MOTIONSENSE_SENSOR_FLAG_ODR BIT(4)2364171223651713/*23661714 * Send this value for the data element to only perform a read. If you···2468162224691623#define EC_MOTION_SENSE_INVALID_CALIB_TEMP 0x80002470162416251625+/* MOTIONSENSE_CMD_SENSOR_OFFSET subcommand flag */24711626/* Set Calibration information */24722472-#define MOTION_SENSE_SET_OFFSET 116271627+#define MOTION_SENSE_SET_OFFSET BIT(0)2473162824742474-struct ec_response_motion_sensor_data {24752475- /* Flags for each sensor. */24762476- uint8_t flags;24772477- /* Sensor number the data comes from */24782478- uint8_t sensor_num;24792479- /* Each sensor is up to 3-axis. */24802480- union {24812481- int16_t data[3];24822482- struct {24832483- uint16_t rsvd;24842484- uint32_t timestamp;24852485- } __packed;24862486- struct {24872487- uint8_t activity; /* motionsensor_activity */24882488- uint8_t state;24892489- int16_t add_info[2];24902490- };24912491- };24922492-} __packed;16291629+/* Default Scale value, factor 1. */16301630+#define MOTION_SENSE_DEFAULT_SCALE BIT(15)16311631+16321632+#define LID_ANGLE_UNRELIABLE 50016331633+16341634+enum motionsense_spoof_mode {16351635+ /* Disable spoof mode. */16361636+ MOTIONSENSE_SPOOF_MODE_DISABLE = 0,16371637+16381638+ /* Enable spoof mode, but use provided component values. */16391639+ MOTIONSENSE_SPOOF_MODE_CUSTOM,16401640+16411641+ /* Enable spoof mode, but use the current sensor values. */16421642+ MOTIONSENSE_SPOOF_MODE_LOCK_CURRENT,16431643+16441644+ /* Query the current spoof mode status for the sensor. */16451645+ MOTIONSENSE_SPOOF_MODE_QUERY,16461646+};2493164724941648struct ec_params_motion_sense {24951649 uint8_t cmd;24961650 union {24971651 /* Used for MOTIONSENSE_CMD_DUMP. */24982498- struct {24992499- /* no args */16521652+ struct __ec_todo_unpacked {16531653+ /*16541654+ * Maximal number of sensor the host is expecting.16551655+ * 0 means the host is only interested in the number16561656+ * of sensors controlled by the EC.16571657+ */16581658+ uint8_t max_sensor_count;25001659 } dump;2501166025021661 /*25032503- * Used for MOTIONSENSE_CMD_EC_RATE and25042504- * MOTIONSENSE_CMD_KB_WAKE_ANGLE.16621662+ * Used for MOTIONSENSE_CMD_KB_WAKE_ANGLE.25051663 */25062506- struct {25072507- /* Data to set or EC_MOTION_SENSE_NO_VALUE to read. */16641664+ struct __ec_todo_unpacked {16651665+ /* Data to set or EC_MOTION_SENSE_NO_VALUE to read.16661666+ * kb_wake_angle: angle to wakup AP.16671667+ */25081668 int16_t data;25092509- } ec_rate, kb_wake_angle;16691669+ } kb_wake_angle;16701670+16711671+ /*16721672+ * Used for MOTIONSENSE_CMD_INFO, MOTIONSENSE_CMD_DATA16731673+ * and MOTIONSENSE_CMD_PERFORM_CALIB.16741674+ */16751675+ struct __ec_todo_unpacked {16761676+ uint8_t sensor_num;16771677+ } info, info_3, data, fifo_flush, perform_calib,16781678+ list_activities;16791679+16801680+ /*16811681+ * Used for MOTIONSENSE_CMD_EC_RATE, MOTIONSENSE_CMD_SENSOR_ODR16821682+ * and MOTIONSENSE_CMD_SENSOR_RANGE.16831683+ */16841684+ struct __ec_todo_unpacked {16851685+ uint8_t sensor_num;16861686+16871687+ /* Rounding flag, true for round-up, false for down. */16881688+ uint8_t roundup;16891689+16901690+ uint16_t reserved;16911691+16921692+ /* Data to set or EC_MOTION_SENSE_NO_VALUE to read. */16931693+ int32_t data;16941694+ } ec_rate, sensor_odr, sensor_range;2510169525111696 /* Used for MOTIONSENSE_CMD_SENSOR_OFFSET */25122512- struct {16971697+ struct __ec_todo_packed {25131698 uint8_t sensor_num;2514169925151700 /*···25661689 * Compass: 1/16 uT25671690 */25681691 int16_t offset[3];25692569- } __packed sensor_offset;16921692+ } sensor_offset;2570169325712571- /* Used for MOTIONSENSE_CMD_INFO. */25722572- struct {25732573- uint8_t sensor_num;25742574- } info;25752575-25762576- /*25772577- * Used for MOTIONSENSE_CMD_SENSOR_ODR and25782578- * MOTIONSENSE_CMD_SENSOR_RANGE.25792579- */25802580- struct {25812581- /* Should be element of enum motionsensor_id. */16941694+ /* Used for MOTIONSENSE_CMD_SENSOR_SCALE */16951695+ struct __ec_todo_packed {25821696 uint8_t sensor_num;2583169725842584- /* Rounding flag, true for round-up, false for down. */25852585- uint8_t roundup;16981698+ /*16991699+ * bit 0: If set (MOTION_SENSE_SET_OFFSET), set17001700+ * the calibration information in the EC.17011701+ * If unset, just retrieve calibration information.17021702+ */17031703+ uint16_t flags;2586170425872587- uint16_t reserved;17051705+ /*17061706+ * Temperature at calibration, in units of 0.01 C17071707+ * 0x8000: invalid / unknown.17081708+ * 0x0: 0C17091709+ * 0x7fff: +327.67C17101710+ */17111711+ int16_t temp;2588171225892589- /* Data to set or EC_MOTION_SENSE_NO_VALUE to read. */25902590- int32_t data;25912591- } sensor_odr, sensor_range;17131713+ /*17141714+ * Scale for calibration:17151715+ * By default scale is 1, it is encoded on 16bits:17161716+ * 1 = BIT(15)17171717+ * ~2 = 0xFFFF17181718+ * ~0 = 0.17191719+ */17201720+ uint16_t scale[3];17211721+ } sensor_scale;17221722+17231723+17241724+ /* Used for MOTIONSENSE_CMD_FIFO_INFO */17251725+ /* (no params) */17261726+17271727+ /* Used for MOTIONSENSE_CMD_FIFO_READ */17281728+ struct __ec_todo_unpacked {17291729+ /*17301730+ * Number of expected vector to return.17311731+ * EC may return less or 0 if none available.17321732+ */17331733+ uint32_t max_data_vector;17341734+ } fifo_read;17351735+17361736+ struct ec_motion_sense_activity set_activity;17371737+17381738+ /* Used for MOTIONSENSE_CMD_LID_ANGLE */17391739+ /* (no params) */17401740+17411741+ /* Used for MOTIONSENSE_CMD_FIFO_INT_ENABLE */17421742+ struct __ec_todo_unpacked {17431743+ /*17441744+ * 1: enable, 0 disable fifo,17451745+ * EC_MOTION_SENSE_NO_VALUE return value.17461746+ */17471747+ int8_t enable;17481748+ } fifo_int_enable;17491749+17501750+ /* Used for MOTIONSENSE_CMD_SPOOF */17511751+ struct __ec_todo_packed {17521752+ uint8_t sensor_id;17531753+17541754+ /* See enum motionsense_spoof_mode. */17551755+ uint8_t spoof_enable;17561756+17571757+ /* Ignored, used for alignment. */17581758+ uint8_t reserved;17591759+17601760+ /* Individual component values to spoof. */17611761+ int16_t components[3];17621762+ } spoof;17631763+17641764+ /* Used for MOTIONSENSE_CMD_TABLET_MODE_LID_ANGLE. */17651765+ struct __ec_todo_unpacked {17661766+ /*17671767+ * Lid angle threshold for switching between tablet and17681768+ * clamshell mode.17691769+ */17701770+ int16_t lid_angle;17711771+17721772+ /*17731773+ * Hysteresis degree to prevent fluctuations between17741774+ * clamshell and tablet mode if lid angle keeps17751775+ * changing around the threshold. Lid motion driver will17761776+ * use lid_angle + hys_degree to trigger tablet mode and17771777+ * lid_angle - hys_degree to trigger clamshell mode.17781778+ */17791779+ int16_t hys_degree;17801780+ } tablet_mode_threshold;25921781 };25932593-} __packed;17821782+} __ec_todo_packed;2594178325951784struct ec_response_motion_sense {25961785 union {25972597- /* Used for MOTIONSENSE_CMD_DUMP. */25982598- struct {17861786+ /* Used for MOTIONSENSE_CMD_DUMP */17871787+ struct __ec_todo_unpacked {25991788 /* Flags representing the motion sensor module. */26001789 uint8_t module_flags;26011790···26761733 } dump;2677173426781735 /* Used for MOTIONSENSE_CMD_INFO. */26792679- struct {17361736+ struct __ec_todo_unpacked {26801737 /* Should be element of enum motionsensor_type. */26811738 uint8_t type;26821739···26871744 uint8_t chip;26881745 } info;2689174617471747+ /* Used for MOTIONSENSE_CMD_INFO version 3 */17481748+ struct __ec_todo_unpacked {17491749+ /* Should be element of enum motionsensor_type. */17501750+ uint8_t type;17511751+17521752+ /* Should be element of enum motionsensor_location. */17531753+ uint8_t location;17541754+17551755+ /* Should be element of enum motionsensor_chip. */17561756+ uint8_t chip;17571757+17581758+ /* Minimum sensor sampling frequency */17591759+ uint32_t min_frequency;17601760+17611761+ /* Maximum sensor sampling frequency */17621762+ uint32_t max_frequency;17631763+17641764+ /* Max number of sensor events that could be in fifo */17651765+ uint32_t fifo_max_event_count;17661766+ } info_3;17671767+26901768 /* Used for MOTIONSENSE_CMD_DATA */26911769 struct ec_response_motion_sensor_data data;2692177026931771 /*26941772 * Used for MOTIONSENSE_CMD_EC_RATE, MOTIONSENSE_CMD_SENSOR_ODR,26952695- * MOTIONSENSE_CMD_SENSOR_RANGE, and26962696- * MOTIONSENSE_CMD_KB_WAKE_ANGLE.17731773+ * MOTIONSENSE_CMD_SENSOR_RANGE,17741774+ * MOTIONSENSE_CMD_KB_WAKE_ANGLE,17751775+ * MOTIONSENSE_CMD_FIFO_INT_ENABLE and17761776+ * MOTIONSENSE_CMD_SPOOF.26971777 */26982698- struct {17781778+ struct __ec_todo_unpacked {26991779 /* Current value of the parameter queried. */27001780 int32_t ret;27012701- } ec_rate, sensor_odr, sensor_range, kb_wake_angle;17811781+ } ec_rate, sensor_odr, sensor_range, kb_wake_angle,17821782+ fifo_int_enable, spoof;2702178327032703- /* Used for MOTIONSENSE_CMD_SENSOR_OFFSET */27042704- struct {17841784+ /*17851785+ * Used for MOTIONSENSE_CMD_SENSOR_OFFSET,17861786+ * PERFORM_CALIB.17871787+ */17881788+ struct __ec_todo_unpacked {27051789 int16_t temp;27061790 int16_t offset[3];27071791 } sensor_offset, perform_calib;17921792+17931793+ /* Used for MOTIONSENSE_CMD_SENSOR_SCALE */17941794+ struct __ec_todo_unpacked {17951795+ int16_t temp;17961796+ uint16_t scale[3];17971797+ } sensor_scale;17981798+17991799+ struct ec_response_motion_sense_fifo_info fifo_info, fifo_flush;18001800+18011801+ struct ec_response_motion_sense_fifo_data fifo_read;18021802+18031803+ struct __ec_todo_packed {18041804+ uint16_t reserved;18051805+ uint32_t enabled;18061806+ uint32_t disabled;18071807+ } list_activities;18081808+18091809+ /* No params for set activity */18101810+18111811+ /* Used for MOTIONSENSE_CMD_LID_ANGLE */18121812+ struct __ec_todo_unpacked {18131813+ /*18141814+ * Angle between 0 and 360 degree if available,18151815+ * LID_ANGLE_UNRELIABLE otherwise.18161816+ */18171817+ uint16_t value;18181818+ } lid_angle;18191819+18201820+ /* Used for MOTIONSENSE_CMD_TABLET_MODE_LID_ANGLE. */18211821+ struct __ec_todo_unpacked {18221822+ /*18231823+ * Lid angle threshold for switching between tablet and18241824+ * clamshell mode.18251825+ */18261826+ uint16_t lid_angle;18271827+18281828+ /* Hysteresis degree. */18291829+ uint16_t hys_degree;18301830+ } tablet_mode_threshold;18311831+27081832 };27092709-} __packed;18331833+} __ec_todo_packed;18341834+18351835+/*****************************************************************************/18361836+/* Force lid open command */18371837+18381838+/* Make lid event always open */18391839+#define EC_CMD_FORCE_LID_OPEN 0x002C18401840+18411841+struct ec_params_force_lid_open {18421842+ uint8_t enabled;18431843+} __ec_align1;18441844+18451845+/*****************************************************************************/18461846+/* Configure the behavior of the power button */18471847+#define EC_CMD_CONFIG_POWER_BUTTON 0x002D18481848+18491849+enum ec_config_power_button_flags {18501850+ /* Enable/Disable power button pulses for x86 devices */18511851+ EC_POWER_BUTTON_ENABLE_PULSE = BIT(0),18521852+};18531853+18541854+struct ec_params_config_power_button {18551855+ /* See enum ec_config_power_button_flags */18561856+ uint8_t flags;18571857+} __ec_align1;2710185827111859/*****************************************************************************/27121860/* USB charging control commands */2713186127141862/* Set USB port charging mode */27152715-#define EC_CMD_USB_CHARGE_SET_MODE 0x3018631863+#define EC_CMD_USB_CHARGE_SET_MODE 0x00302716186427171865struct ec_params_usb_charge_set_mode {27181866 uint8_t usb_port_id;27192719- uint8_t mode;27202720-} __packed;18671867+ uint8_t mode:7;18681868+ uint8_t inhibit_charge:1;18691869+} __ec_align1;2721187027221871/*****************************************************************************/27231872/* Persistent storage for host */···28181783#define EC_PSTORE_SIZE_MAX 642819178428201785/* Get persistent storage info */28212821-#define EC_CMD_PSTORE_INFO 0x4017861786+#define EC_CMD_PSTORE_INFO 0x00402822178728231788struct ec_response_pstore_info {28241789 /* Persistent storage size, in bytes */28251790 uint32_t pstore_size;28261791 /* Access size; read/write offset and size must be a multiple of this */28271792 uint32_t access_size;28282828-} __packed;17931793+} __ec_align4;2829179428301795/*28311796 * Read persistent storage28321797 *28331798 * Response is params.size bytes of data.28341799 */28352835-#define EC_CMD_PSTORE_READ 0x4118001800+#define EC_CMD_PSTORE_READ 0x00412836180128371802struct ec_params_pstore_read {28381803 uint32_t offset; /* Byte offset to read */28391804 uint32_t size; /* Size to read in bytes */28402840-} __packed;18051805+} __ec_align4;2841180628421807/* Write persistent storage */28432843-#define EC_CMD_PSTORE_WRITE 0x4218081808+#define EC_CMD_PSTORE_WRITE 0x00422844180928451810struct ec_params_pstore_write {28461811 uint32_t offset; /* Byte offset to write */28471812 uint32_t size; /* Size to write in bytes */28481813 uint8_t data[EC_PSTORE_SIZE_MAX];28492849-} __packed;18141814+} __ec_align4;2850181528511816/*****************************************************************************/28521817/* Real-time clock */···28541819/* RTC params and response structures */28551820struct ec_params_rtc {28561821 uint32_t time;28572857-} __packed;18221822+} __ec_align4;2858182328591824struct ec_response_rtc {28601825 uint32_t time;28612861-} __packed;18261826+} __ec_align4;2862182728631828/* These use ec_response_rtc */28642864-#define EC_CMD_RTC_GET_VALUE 0x4428652865-#define EC_CMD_RTC_GET_ALARM 0x4518291829+#define EC_CMD_RTC_GET_VALUE 0x004418301830+#define EC_CMD_RTC_GET_ALARM 0x00452866183128671832/* These all use ec_params_rtc */28682868-#define EC_CMD_RTC_SET_VALUE 0x4628692869-#define EC_CMD_RTC_SET_ALARM 0x4718331833+#define EC_CMD_RTC_SET_VALUE 0x004618341834+#define EC_CMD_RTC_SET_ALARM 0x00472870183528712871-/* Pass as param to SET_ALARM to clear the current alarm */18361836+/* Pass as time param to SET_ALARM to clear the current alarm */28721837#define EC_RTC_ALARM_CLEAR 02873183828741839/*****************************************************************************/···28781843#define EC_PORT80_SIZE_MAX 322879184428801845/* Get last port80 code from previous boot */28812881-#define EC_CMD_PORT80_LAST_BOOT 0x4828822882-#define EC_CMD_PORT80_READ 0x4818461846+#define EC_CMD_PORT80_LAST_BOOT 0x004818471847+#define EC_CMD_PORT80_READ 0x00482883184828841849enum ec_port80_subcmd {28851850 EC_PORT80_GET_INFO = 0,···28891854struct ec_params_port80_read {28901855 uint16_t subcmd;28911856 union {28922892- struct {18571857+ struct __ec_todo_unpacked {28931858 uint32_t offset;28941859 uint32_t num_entries;28951860 } read_buffer;28961861 };28972897-} __packed;18621862+} __ec_todo_packed;2898186328991864struct ec_response_port80_read {29001865 union {29012901- struct {18661866+ struct __ec_todo_unpacked {29021867 uint32_t writes;29031868 uint32_t history_size;29041869 uint32_t last_boot;29051870 } get_info;29062906- struct {18711871+ struct __ec_todo_unpacked {29071872 uint16_t codes[EC_PORT80_SIZE_MAX];29081873 } data;29091874 };29102910-} __packed;18751875+} __ec_todo_packed;2911187629121877struct ec_response_port80_last_boot {29131878 uint16_t code;29142914-} __packed;18791879+} __ec_align2;18801880+18811881+/*****************************************************************************/18821882+/* Temporary secure storage for host verified boot use */18831883+18841884+/* Number of bytes in a vstore slot */18851885+#define EC_VSTORE_SLOT_SIZE 6418861886+18871887+/* Maximum number of vstore slots */18881888+#define EC_VSTORE_SLOT_MAX 3218891889+18901890+/* Get persistent storage info */18911891+#define EC_CMD_VSTORE_INFO 0x004918921892+struct ec_response_vstore_info {18931893+ /* Indicates which slots are locked */18941894+ uint32_t slot_locked;18951895+ /* Total number of slots available */18961896+ uint8_t slot_count;18971897+} __ec_align_size1;18981898+18991899+/*19001900+ * Read temporary secure storage19011901+ *19021902+ * Response is EC_VSTORE_SLOT_SIZE bytes of data.19031903+ */19041904+#define EC_CMD_VSTORE_READ 0x004A19051905+19061906+struct ec_params_vstore_read {19071907+ uint8_t slot; /* Slot to read from */19081908+} __ec_align1;19091909+19101910+struct ec_response_vstore_read {19111911+ uint8_t data[EC_VSTORE_SLOT_SIZE];19121912+} __ec_align1;19131913+19141914+/*19151915+ * Write temporary secure storage and lock it.19161916+ */19171917+#define EC_CMD_VSTORE_WRITE 0x004B19181918+19191919+struct ec_params_vstore_write {19201920+ uint8_t slot; /* Slot to write to */19211921+ uint8_t data[EC_VSTORE_SLOT_SIZE];19221922+} __ec_align1;2915192329161924/*****************************************************************************/29171925/* Thermal engine commands. Note that there are two implementations. We'll···29631885 * Version 1 separates the CPU thermal limits from the fan control.29641886 */2965188729662966-#define EC_CMD_THERMAL_SET_THRESHOLD 0x5029672967-#define EC_CMD_THERMAL_GET_THRESHOLD 0x5118881888+#define EC_CMD_THERMAL_SET_THRESHOLD 0x005018891889+#define EC_CMD_THERMAL_GET_THRESHOLD 0x00512968189029691891/* The version 0 structs are opaque. You have to know what they are for29701892 * the get/set commands to make any sense.···29751897 uint8_t sensor_type;29761898 uint8_t threshold_id;29771899 uint16_t value;29782978-} __packed;19001900+} __ec_align2;2979190129801902/* Version 0 - get */29811903struct ec_params_thermal_get_threshold {29821904 uint8_t sensor_type;29831905 uint8_t threshold_id;29842984-} __packed;19061906+} __ec_align1;2985190729861908struct ec_response_thermal_get_threshold {29871909 uint16_t value;29882988-} __packed;19101910+} __ec_align2;298919112990191229911913/* The version 1 structs are visible. */···29971919 EC_TEMP_THRESH_COUNT29981920};2999192130003000-/* Thermal configuration for one temperature sensor. Temps are in degrees K.19221922+/*19231923+ * Thermal configuration for one temperature sensor. Temps are in degrees K.30011924 * Zero values will be silently ignored by the thermal task.19251925+ *19261926+ * Set 'temp_host' value allows thermal task to trigger some event with 1 degree19271927+ * hysteresis.19281928+ * For example,19291929+ * temp_host[EC_TEMP_THRESH_HIGH] = 300 K19301930+ * temp_host_release[EC_TEMP_THRESH_HIGH] = 0 K19311931+ * EC will throttle ap when temperature >= 301 K, and release throttling when19321932+ * temperature <= 299 K.19331933+ *19341934+ * Set 'temp_host_release' value allows thermal task has a custom hysteresis.19351935+ * For example,19361936+ * temp_host[EC_TEMP_THRESH_HIGH] = 300 K19371937+ * temp_host_release[EC_TEMP_THRESH_HIGH] = 295 K19381938+ * EC will throttle ap when temperature >= 301 K, and release throttling when19391939+ * temperature <= 294 K.19401940+ *19411941+ * Note that this structure is a sub-structure of19421942+ * ec_params_thermal_set_threshold_v1, but maintains its alignment there.30021943 */30031944struct ec_thermal_config {30041945 uint32_t temp_host[EC_TEMP_THRESH_COUNT]; /* levels of hotness */19461946+ uint32_t temp_host_release[EC_TEMP_THRESH_COUNT]; /* release levels */30051947 uint32_t temp_fan_off; /* no active cooling needed */30061948 uint32_t temp_fan_max; /* max active cooling needed */30073007-} __packed;19491949+} __ec_align4;3008195030091951/* Version 1 - get config for one sensor. */30101952struct ec_params_thermal_get_threshold_v1 {30111953 uint32_t sensor_num;30123012-} __packed;19541954+} __ec_align4;30131955/* This returns a struct ec_thermal_config */3014195630153015-/* Version 1 - set config for one sensor.30163016- * Use read-modify-write for best results! */19571957+/*19581958+ * Version 1 - set config for one sensor.19591959+ * Use read-modify-write for best results!19601960+ */30171961struct ec_params_thermal_set_threshold_v1 {30181962 uint32_t sensor_num;30191963 struct ec_thermal_config cfg;30203020-} __packed;19641964+} __ec_align4;30211965/* This returns no data */3022196630231967/****************************************************************************/3024196830251969/* Toggle automatic fan control */30263026-#define EC_CMD_THERMAL_AUTO_FAN_CTRL 0x5219701970+#define EC_CMD_THERMAL_AUTO_FAN_CTRL 0x00523027197130283028-/* Get TMP006 calibration data */30293029-#define EC_CMD_TMP006_GET_CALIBRATION 0x5319721972+/* Version 1 of input params */19731973+struct ec_params_auto_fan_ctrl_v1 {19741974+ uint8_t fan_idx;19751975+} __ec_align1;3030197619771977+/* Get/Set TMP006 calibration data */19781978+#define EC_CMD_TMP006_GET_CALIBRATION 0x005319791979+#define EC_CMD_TMP006_SET_CALIBRATION 0x005419801980+19811981+/*19821982+ * The original TMP006 calibration only needed four params, but now we need19831983+ * more. Since the algorithm is nothing but magic numbers anyway, we'll leave19841984+ * the params opaque. The v1 "get" response will include the algorithm number19851985+ * and how many params it requires. That way we can change the EC code without19861986+ * needing to update this file. We can also use a different algorithm on each19871987+ * sensor.19881988+ */19891989+19901990+/* This is the same struct for both v0 and v1. */30311991struct ec_params_tmp006_get_calibration {30321992 uint8_t index;30333033-} __packed;19931993+} __ec_align1;3034199430353035-struct ec_response_tmp006_get_calibration {19951995+/* Version 0 */19961996+struct ec_response_tmp006_get_calibration_v0 {30361997 float s0;30371998 float b0;30381999 float b1;30392000 float b2;30403040-} __packed;20012001+} __ec_align4;3041200230423042-/* Set TMP006 calibration data */30433043-#define EC_CMD_TMP006_SET_CALIBRATION 0x5430443044-30453045-struct ec_params_tmp006_set_calibration {20032003+struct ec_params_tmp006_set_calibration_v0 {30462004 uint8_t index;30473047- uint8_t reserved[3]; /* Reserved; set 0 */20052005+ uint8_t reserved[3];30482006 float s0;30492007 float b0;30502008 float b1;30512009 float b2;30523052-} __packed;20102010+} __ec_align4;20112011+20122012+/* Version 1 */20132013+struct ec_response_tmp006_get_calibration_v1 {20142014+ uint8_t algorithm;20152015+ uint8_t num_params;20162016+ uint8_t reserved[2];20172017+ float val[0];20182018+} __ec_align4;20192019+20202020+struct ec_params_tmp006_set_calibration_v1 {20212021+ uint8_t index;20222022+ uint8_t algorithm;20232023+ uint8_t num_params;20242024+ uint8_t reserved;20252025+ float val[0];20262026+} __ec_align4;20272027+3053202830542029/* Read raw TMP006 data */30553055-#define EC_CMD_TMP006_GET_RAW 0x5520302030+#define EC_CMD_TMP006_GET_RAW 0x00553056203130572032struct ec_params_tmp006_get_raw {30582033 uint8_t index;30593059-} __packed;20342034+} __ec_align1;3060203530612036struct ec_response_tmp006_get_raw {30622037 int32_t t; /* In 1/100 K */30632038 int32_t v; /* In nV */30643064-};20392039+} __ec_align4;3065204030662041/*****************************************************************************/30672042/* MKBP - Matrix KeyBoard Protocol */···31291998 * to obtain the instantaneous state, use EC_CMD_MKBP_INFO with the type31301999 * EC_MKBP_INFO_CURRENT and event EC_MKBP_EVENT_KEY_MATRIX.31312000 */31323132-#define EC_CMD_MKBP_STATE 0x6020012001+#define EC_CMD_MKBP_STATE 0x00603133200231342003/*31352004 * Provide information about various MKBP things. See enum ec_mkbp_info_type.31362005 */31373137-#define EC_CMD_MKBP_INFO 0x6120062006+#define EC_CMD_MKBP_INFO 0x00613138200731392008struct ec_response_mkbp_info {31402009 uint32_t rows;31412010 uint32_t cols;31422011 /* Formerly "switches", which was 0. */31432012 uint8_t reserved;31443144-} __packed;20132013+} __ec_align_size1;3145201431462015struct ec_params_mkbp_info {31472016 uint8_t info_type;31482017 uint8_t event_type;31493149-} __packed;20182018+} __ec_align1;3150201931512020enum ec_mkbp_info_type {31522021 /*···31882057};3189205831902059/* Simulate key press */31913191-#define EC_CMD_MKBP_SIMULATE_KEY 0x6220602060+#define EC_CMD_MKBP_SIMULATE_KEY 0x00623192206131932062struct ec_params_mkbp_simulate_key {31942063 uint8_t col;31952064 uint8_t row;31962065 uint8_t pressed;31973197-} __packed;20662066+} __ec_align1;20672067+20682068+#define EC_CMD_GET_KEYBOARD_ID 0x006320692069+20702070+struct ec_response_keyboard_id {20712071+ uint32_t keyboard_id;20722072+} __ec_align4;20732073+20742074+enum keyboard_id {20752075+ KEYBOARD_ID_UNSUPPORTED = 0,20762076+ KEYBOARD_ID_UNREADABLE = 0xffffffff,20772077+};3198207831992079/* Configure keyboard scanning */32003200-#define EC_CMD_MKBP_SET_CONFIG 0x6432013201-#define EC_CMD_MKBP_GET_CONFIG 0x6520802080+#define EC_CMD_MKBP_SET_CONFIG 0x006420812081+#define EC_CMD_MKBP_GET_CONFIG 0x00653202208232032083/* flags */32042084enum mkbp_config_flags {···32172075};3218207632192077enum mkbp_config_valid {32203220- EC_MKBP_VALID_SCAN_PERIOD = 1 << 0,32213221- EC_MKBP_VALID_POLL_TIMEOUT = 1 << 1,32223222- EC_MKBP_VALID_MIN_POST_SCAN_DELAY = 1 << 3,32233223- EC_MKBP_VALID_OUTPUT_SETTLE = 1 << 4,32243224- EC_MKBP_VALID_DEBOUNCE_DOWN = 1 << 5,32253225- EC_MKBP_VALID_DEBOUNCE_UP = 1 << 6,32263226- EC_MKBP_VALID_FIFO_MAX_DEPTH = 1 << 7,20782078+ EC_MKBP_VALID_SCAN_PERIOD = BIT(0),20792079+ EC_MKBP_VALID_POLL_TIMEOUT = BIT(1),20802080+ EC_MKBP_VALID_MIN_POST_SCAN_DELAY = BIT(3),20812081+ EC_MKBP_VALID_OUTPUT_SETTLE = BIT(4),20822082+ EC_MKBP_VALID_DEBOUNCE_DOWN = BIT(5),20832083+ EC_MKBP_VALID_DEBOUNCE_UP = BIT(6),20842084+ EC_MKBP_VALID_FIFO_MAX_DEPTH = BIT(7),32272085};3228208632293229-/* Configuration for our key scanning algorithm */20872087+/*20882088+ * Configuration for our key scanning algorithm.20892089+ *20902090+ * Note that this is used as a sub-structure of20912091+ * ec_{params/response}_mkbp_get_config.20922092+ */32302093struct ec_mkbp_config {32312094 uint32_t valid_mask; /* valid fields */32322095 uint8_t flags; /* some flags (enum mkbp_config_flags) */···32512104 uint16_t debounce_up_us; /* time for debounce on key up */32522105 /* maximum depth to allow for fifo (0 = no keyscan output) */32532106 uint8_t fifo_max_depth;32543254-} __packed;21072107+} __ec_align_size1;3255210832562109struct ec_params_mkbp_set_config {32572110 struct ec_mkbp_config config;32583258-} __packed;21112111+} __ec_align_size1;3259211232602113struct ec_response_mkbp_get_config {32612114 struct ec_mkbp_config config;32623262-} __packed;21152115+} __ec_align_size1;3263211632642117/* Run the key scan emulation */32653265-#define EC_CMD_KEYSCAN_SEQ_CTRL 0x6621182118+#define EC_CMD_KEYSCAN_SEQ_CTRL 0x00663266211932672120enum ec_keyscan_seq_cmd {32682121 EC_KEYSCAN_SEQ_STATUS = 0, /* Get status information */···32772130 * Indicates this scan was processed by the EC. Due to timing, some32782131 * scans may be skipped.32792132 */32803280- EC_KEYSCAN_SEQ_FLAG_DONE = 1 << 0,21332133+ EC_KEYSCAN_SEQ_FLAG_DONE = BIT(0),32812134};3282213532832136struct ec_collect_item {32842137 uint8_t flags; /* some flags (enum ec_collect_flags) */32853285-};21382138+} __ec_align1;3286213932872140struct ec_params_keyscan_seq_ctrl {32882141 uint8_t cmd; /* Command to send (enum ec_keyscan_seq_cmd) */32892142 union {32903290- struct {21432143+ struct __ec_align1 {32912144 uint8_t active; /* still active */32922145 uint8_t num_items; /* number of items */32932146 /* Current item being presented */32942147 uint8_t cur_item;32952148 } status;32963296- struct {21492149+ struct __ec_todo_unpacked {32972150 /*32982151 * Absolute time for this scan, measured from the32992152 * start of the sequence.···33012154 uint32_t time_us;33022155 uint8_t scan[0]; /* keyscan data */33032156 } add;33043304- struct {21572157+ struct __ec_align1 {33052158 uint8_t start_item; /* First item to return */33062159 uint8_t num_items; /* Number of items to return */33072160 } collect;33082161 };33093309-} __packed;21622162+} __ec_todo_packed;3310216333112164struct ec_result_keyscan_seq_ctrl {33122165 union {33133313- struct {21662166+ struct __ec_todo_unpacked {33142167 uint8_t num_items; /* Number of items */33152168 /* Data for each item */33162169 struct ec_collect_item item[0];33172170 } collect;33182171 };33193319-} __packed;21722172+} __ec_todo_packed;3320217333212174/*33223322- * Command for retrieving the next pending MKBP event from the EC device21752175+ * Get the next pending MKBP event.33232176 *33243324- * The device replies with UNAVAILABLE if there aren't any pending events.21772177+ * Returns EC_RES_UNAVAILABLE if there is no event pending.33252178 */33263326-#define EC_CMD_GET_NEXT_EVENT 0x6721792179+#define EC_CMD_GET_NEXT_EVENT 0x006721802180+21812181+#define EC_MKBP_HAS_MORE_EVENTS_SHIFT 721822182+21832183+/*21842184+ * We use the most significant bit of the event type to indicate to the host21852185+ * that the EC has more MKBP events available to provide.21862186+ */21872187+#define EC_MKBP_HAS_MORE_EVENTS BIT(EC_MKBP_HAS_MORE_EVENTS_SHIFT)21882188+21892189+/* The mask to apply to get the raw event type */21902190+#define EC_MKBP_EVENT_TYPE_MASK (BIT(EC_MKBP_HAS_MORE_EVENTS_SHIFT) - 1)3327219133282192enum ec_mkbp_event {33292193 /* Keyboard matrix changed. The event data is the new matrix state. */···33522194 /* The state of the switches have changed. */33532195 EC_MKBP_EVENT_SWITCH = 4,3354219633553355- /* EC sent a sysrq command */21972197+ /* New Fingerprint sensor event, the event data is fp_events bitmap. */21982198+ EC_MKBP_EVENT_FINGERPRINT = 5,21992199+22002200+ /*22012201+ * Sysrq event: send emulated sysrq. The event data is sysrq,22022202+ * corresponding to the key to be pressed.22032203+ */33562204 EC_MKBP_EVENT_SYSRQ = 6,22052205+22062206+ /*22072207+ * New 64-bit host event.22082208+ * The event data is 8 bytes of host event flags.22092209+ */22102210+ EC_MKBP_EVENT_HOST_EVENT64 = 7,3357221133582212 /* Notify the AP that something happened on CEC */33592213 EC_MKBP_EVENT_CEC_EVENT = 8,···33762206 /* Number of MKBP events */33772207 EC_MKBP_EVENT_COUNT,33782208};22092209+BUILD_ASSERT(EC_MKBP_EVENT_COUNT <= EC_MKBP_EVENT_TYPE_MASK);3379221033803380-union ec_response_get_next_data {33813381- uint8_t key_matrix[13];22112211+union __ec_align_offset1 ec_response_get_next_data {22122212+ uint8_t key_matrix[13];3382221333832214 /* Unaligned */33843384- uint32_t host_event;33853385-33863386- uint32_t buttons;33873387- uint32_t switches;33883388- uint32_t sysrq;33893389-} __packed;33903390-33913391-union ec_response_get_next_data_v1 {33923392- uint8_t key_matrix[16];33932215 uint32_t host_event;22162216+ uint64_t host_event64;22172217+22182218+ struct __ec_todo_unpacked {22192219+ /* For aligning the fifo_info */22202220+ uint8_t reserved[3];22212221+ struct ec_response_motion_sense_fifo_info info;22222222+ } sensor_fifo;22232223+33942224 uint32_t buttons;22252225+33952226 uint32_t switches;22272227+22282228+ uint32_t fp_events;22292229+33962230 uint32_t sysrq;22312231+22322232+ /* CEC events from enum mkbp_cec_event */33972233 uint32_t cec_events;22342234+};22352235+22362236+union __ec_align_offset1 ec_response_get_next_data_v1 {22372237+ uint8_t key_matrix[16];22382238+22392239+ /* Unaligned */22402240+ uint32_t host_event;22412241+ uint64_t host_event64;22422242+22432243+ struct __ec_todo_unpacked {22442244+ /* For aligning the fifo_info */22452245+ uint8_t reserved[3];22462246+ struct ec_response_motion_sense_fifo_info info;22472247+ } sensor_fifo;22482248+22492249+ uint32_t buttons;22502250+22512251+ uint32_t switches;22522252+22532253+ uint32_t fp_events;22542254+22552255+ uint32_t sysrq;22562256+22572257+ /* CEC events from enum mkbp_cec_event */22582258+ uint32_t cec_events;22592259+33982260 uint8_t cec_message[16];33993399-} __packed;22612261+};22622262+BUILD_ASSERT(sizeof(union ec_response_get_next_data_v1) == 16);3400226334012264struct ec_response_get_next_event {34022265 uint8_t event_type;34032266 /* Followed by event data if any */34042267 union ec_response_get_next_data data;34053405-} __packed;22682268+} __ec_align1;3406226934072270struct ec_response_get_next_event_v1 {34082271 uint8_t event_type;34092272 /* Followed by event data if any */34102273 union ec_response_get_next_data_v1 data;34113411-} __packed;22742274+} __ec_align1;3412227534132276/* Bit indices for buttons and switches.*/34142277/* Buttons */34152278#define EC_MKBP_POWER_BUTTON 034162279#define EC_MKBP_VOL_UP 134172280#define EC_MKBP_VOL_DOWN 222812281+#define EC_MKBP_RECOVERY 33418228234192283/* Switches */34202284#define EC_MKBP_LID_OPEN 034212285#define EC_MKBP_TABLET_MODE 134222286#define EC_MKBP_BASE_ATTACHED 23423228722882288+/* Run keyboard factory test scanning */22892289+#define EC_CMD_KEYBOARD_FACTORY_TEST 0x006822902290+22912291+struct ec_response_keyboard_factory_test {22922292+ uint16_t shorted; /* Keyboard pins are shorted */22932293+} __ec_align2;22942294+22952295+/* Fingerprint events in 'fp_events' for EC_MKBP_EVENT_FINGERPRINT */22962296+#define EC_MKBP_FP_RAW_EVENT(fp_events) ((fp_events) & 0x00FFFFFF)22972297+#define EC_MKBP_FP_ERRCODE(fp_events) ((fp_events) & 0x0000000F)22982298+#define EC_MKBP_FP_ENROLL_PROGRESS_OFFSET 422992299+#define EC_MKBP_FP_ENROLL_PROGRESS(fpe) (((fpe) & 0x00000FF0) \23002300+ >> EC_MKBP_FP_ENROLL_PROGRESS_OFFSET)23012301+#define EC_MKBP_FP_MATCH_IDX_OFFSET 1223022302+#define EC_MKBP_FP_MATCH_IDX_MASK 0x0000F00023032303+#define EC_MKBP_FP_MATCH_IDX(fpe) (((fpe) & EC_MKBP_FP_MATCH_IDX_MASK) \23042304+ >> EC_MKBP_FP_MATCH_IDX_OFFSET)23052305+#define EC_MKBP_FP_ENROLL BIT(27)23062306+#define EC_MKBP_FP_MATCH BIT(28)23072307+#define EC_MKBP_FP_FINGER_DOWN BIT(29)23082308+#define EC_MKBP_FP_FINGER_UP BIT(30)23092309+#define EC_MKBP_FP_IMAGE_READY BIT(31)23102310+/* code given by EC_MKBP_FP_ERRCODE() when EC_MKBP_FP_ENROLL is set */23112311+#define EC_MKBP_FP_ERR_ENROLL_OK 023122312+#define EC_MKBP_FP_ERR_ENROLL_LOW_QUALITY 123132313+#define EC_MKBP_FP_ERR_ENROLL_IMMOBILE 223142314+#define EC_MKBP_FP_ERR_ENROLL_LOW_COVERAGE 323152315+#define EC_MKBP_FP_ERR_ENROLL_INTERNAL 523162316+/* Can be used to detect if image was usable for enrollment or not. */23172317+#define EC_MKBP_FP_ERR_ENROLL_PROBLEM_MASK 123182318+/* code given by EC_MKBP_FP_ERRCODE() when EC_MKBP_FP_MATCH is set */23192319+#define EC_MKBP_FP_ERR_MATCH_NO 023202320+#define EC_MKBP_FP_ERR_MATCH_NO_INTERNAL 623212321+#define EC_MKBP_FP_ERR_MATCH_NO_TEMPLATES 723222322+#define EC_MKBP_FP_ERR_MATCH_NO_LOW_QUALITY 223232323+#define EC_MKBP_FP_ERR_MATCH_NO_LOW_COVERAGE 423242324+#define EC_MKBP_FP_ERR_MATCH_YES 123252325+#define EC_MKBP_FP_ERR_MATCH_YES_UPDATED 323262326+#define EC_MKBP_FP_ERR_MATCH_YES_UPDATE_FAILED 523272327+23282328+34242329/*****************************************************************************/34252330/* Temperature sensor commands */3426233134272332/* Read temperature sensor info */34283428-#define EC_CMD_TEMP_SENSOR_GET_INFO 0x7023332333+#define EC_CMD_TEMP_SENSOR_GET_INFO 0x00703429233434302335struct ec_params_temp_sensor_get_info {34312336 uint8_t id;34323432-} __packed;23372337+} __ec_align1;3433233834342339struct ec_response_temp_sensor_get_info {34352340 char sensor_name[32];34362341 uint8_t sensor_type;34373437-} __packed;23422342+} __ec_align1;3438234334392344/*****************************************************************************/34402345···35222277/*****************************************************************************/35232278/* Host event commands */3524227922802280+22812281+/* Obsolete. New implementation should use EC_CMD_HOST_EVENT instead */35252282/*35262283 * Host event mask params and response structures, shared by all of the host35272284 * event commands below.35282285 */35292286struct ec_params_host_event_mask {35302287 uint32_t mask;35313531-} __packed;22882288+} __ec_align4;3532228935332290struct ec_response_host_event_mask {35342291 uint32_t mask;35353535-} __packed;22922292+} __ec_align4;3536229335372294/* These all use ec_response_host_event_mask */35383538-#define EC_CMD_HOST_EVENT_GET_B 0x8735393539-#define EC_CMD_HOST_EVENT_GET_SMI_MASK 0x8835403540-#define EC_CMD_HOST_EVENT_GET_SCI_MASK 0x8935413541-#define EC_CMD_HOST_EVENT_GET_WAKE_MASK 0x8d22952295+#define EC_CMD_HOST_EVENT_GET_B 0x008722962296+#define EC_CMD_HOST_EVENT_GET_SMI_MASK 0x008822972297+#define EC_CMD_HOST_EVENT_GET_SCI_MASK 0x008922982298+#define EC_CMD_HOST_EVENT_GET_WAKE_MASK 0x008D3542229935432300/* These all use ec_params_host_event_mask */35443544-#define EC_CMD_HOST_EVENT_SET_SMI_MASK 0x8a35453545-#define EC_CMD_HOST_EVENT_SET_SCI_MASK 0x8b35463546-#define EC_CMD_HOST_EVENT_CLEAR 0x8c35473547-#define EC_CMD_HOST_EVENT_SET_WAKE_MASK 0x8e35483548-#define EC_CMD_HOST_EVENT_CLEAR_B 0x8f23012301+#define EC_CMD_HOST_EVENT_SET_SMI_MASK 0x008A23022302+#define EC_CMD_HOST_EVENT_SET_SCI_MASK 0x008B23032303+#define EC_CMD_HOST_EVENT_CLEAR 0x008C23042304+#define EC_CMD_HOST_EVENT_SET_WAKE_MASK 0x008E23052305+#define EC_CMD_HOST_EVENT_CLEAR_B 0x008F23062306+23072307+/*23082308+ * Unified host event programming interface - Should be used by newer versions23092309+ * of BIOS/OS to program host events and masks23102310+ */23112311+23122312+struct ec_params_host_event {23132313+23142314+ /* Action requested by host - one of enum ec_host_event_action. */23152315+ uint8_t action;23162316+23172317+ /*23182318+ * Mask type that the host requested the action on - one of23192319+ * enum ec_host_event_mask_type.23202320+ */23212321+ uint8_t mask_type;23222322+23232323+ /* Set to 0, ignore on read */23242324+ uint16_t reserved;23252325+23262326+ /* Value to be used in case of set operations. */23272327+ uint64_t value;23282328+} __ec_align4;23292329+23302330+/*23312331+ * Response structure returned by EC_CMD_HOST_EVENT.23322332+ * Update the value on a GET request. Set to 0 on GET/CLEAR23332333+ */23342334+23352335+struct ec_response_host_event {23362336+23372337+ /* Mask value in case of get operation */23382338+ uint64_t value;23392339+} __ec_align4;23402340+23412341+enum ec_host_event_action {23422342+ /*23432343+ * params.value is ignored. Value of mask_type populated23442344+ * in response.value23452345+ */23462346+ EC_HOST_EVENT_GET,23472347+23482348+ /* Bits in params.value are set */23492349+ EC_HOST_EVENT_SET,23502350+23512351+ /* Bits in params.value are cleared */23522352+ EC_HOST_EVENT_CLEAR,23532353+};23542354+23552355+enum ec_host_event_mask_type {23562356+23572357+ /* Main host event copy */23582358+ EC_HOST_EVENT_MAIN,23592359+23602360+ /* Copy B of host events */23612361+ EC_HOST_EVENT_B,23622362+23632363+ /* SCI Mask */23642364+ EC_HOST_EVENT_SCI_MASK,23652365+23662366+ /* SMI Mask */23672367+ EC_HOST_EVENT_SMI_MASK,23682368+23692369+ /* Mask of events that should be always reported in hostevents */23702370+ EC_HOST_EVENT_ALWAYS_REPORT_MASK,23712371+23722372+ /* Active wake mask */23732373+ EC_HOST_EVENT_ACTIVE_WAKE_MASK,23742374+23752375+ /* Lazy wake mask for S0ix */23762376+ EC_HOST_EVENT_LAZY_WAKE_MASK_S0IX,23772377+23782378+ /* Lazy wake mask for S3 */23792379+ EC_HOST_EVENT_LAZY_WAKE_MASK_S3,23802380+23812381+ /* Lazy wake mask for S5 */23822382+ EC_HOST_EVENT_LAZY_WAKE_MASK_S5,23832383+};23842384+23852385+#define EC_CMD_HOST_EVENT 0x00A43549238635502387/*****************************************************************************/35512388/* Switch commands */3552238935532390/* Enable/disable LCD backlight */35543554-#define EC_CMD_SWITCH_ENABLE_BKLIGHT 0x9023912391+#define EC_CMD_SWITCH_ENABLE_BKLIGHT 0x00903555239235562393struct ec_params_switch_enable_backlight {35572394 uint8_t enabled;35583558-} __packed;23952395+} __ec_align1;3559239635602397/* Enable/disable WLAN/Bluetooth */35613561-#define EC_CMD_SWITCH_ENABLE_WIRELESS 0x9123982398+#define EC_CMD_SWITCH_ENABLE_WIRELESS 0x009135622399#define EC_VER_SWITCH_ENABLE_WIRELESS 13563240035642401/* Version 0 params; no response */35652402struct ec_params_switch_enable_wireless_v0 {35662403 uint8_t enabled;35673567-} __packed;24042404+} __ec_align1;3568240535692406/* Version 1 params */35702407struct ec_params_switch_enable_wireless_v1 {···3665233836662339 /* Which flags to copy from suspend_flags */36672340 uint8_t suspend_mask;36683668-} __packed;23412341+} __ec_align1;3669234236702343/* Version 1 response */36712344struct ec_response_switch_enable_wireless_v1 {···3674234736752348 /* Flags to leave enabled in S3 */36762349 uint8_t suspend_flags;36773677-} __packed;23502350+} __ec_align1;3678235136792352/*****************************************************************************/36802353/* GPIO commands. Only available on EC if write protect has been disabled. */3681235436822355/* Set GPIO output value */36833683-#define EC_CMD_GPIO_SET 0x9223562356+#define EC_CMD_GPIO_SET 0x00923684235736852358struct ec_params_gpio_set {36862359 char name[32];36872360 uint8_t val;36883688-} __packed;23612361+} __ec_align1;3689236236902363/* Get GPIO value */36913691-#define EC_CMD_GPIO_GET 0x9323642364+#define EC_CMD_GPIO_GET 0x00933692236536932366/* Version 0 of input params and response */36942367struct ec_params_gpio_get {36952368 char name[32];36963696-} __packed;23692369+} __ec_align1;23702370+36972371struct ec_response_gpio_get {36982372 uint8_t val;36993699-} __packed;23732373+} __ec_align1;3700237437012375/* Version 1 of input params and response */37022376struct ec_params_gpio_get_v1 {37032377 uint8_t subcmd;37042378 union {37053705- struct {23792379+ struct __ec_align1 {37062380 char name[32];37072381 } get_value_by_name;37083708- struct {23822382+ struct __ec_align1 {37092383 uint8_t index;37102384 } get_info;37112385 };37123712-} __packed;23862386+} __ec_align1;3713238737142388struct ec_response_gpio_get_v1 {37152389 union {37163716- struct {23902390+ struct __ec_align1 {37172391 uint8_t val;37182392 } get_value_by_name, get_count;37193719- struct {23932393+ struct __ec_todo_unpacked {37202394 uint8_t val;37212395 char name[32];37222396 uint32_t flags;37232397 } get_info;37242398 };37253725-} __packed;23992399+} __ec_todo_packed;3726240037272401enum gpio_get_subcmd {37282402 EC_GPIO_GET_BY_NAME = 0,···37352407/* I2C commands. Only available when flash write protect is unlocked. */3736240837372409/*37383738- * TODO(crosbug.com/p/23570): These commands are deprecated, and will be37393739- * removed soon. Use EC_CMD_I2C_XFER instead.24102410+ * CAUTION: These commands are deprecated, and are not supported anymore in EC24112411+ * builds >= 8398.0.0 (see crosbug.com/p/23570).24122412+ *24132413+ * Use EC_CMD_I2C_PASSTHRU instead.37402414 */3741241537422416/* Read I2C bus */37433743-#define EC_CMD_I2C_READ 0x9424172417+#define EC_CMD_I2C_READ 0x00943744241837452419struct ec_params_i2c_read {37462420 uint16_t addr; /* 8-bit address (7-bit shifted << 1) */37472421 uint8_t read_size; /* Either 8 or 16. */37482422 uint8_t port;37492423 uint8_t offset;37503750-} __packed;24242424+} __ec_align_size1;24252425+37512426struct ec_response_i2c_read {37522427 uint16_t data;37533753-} __packed;24282428+} __ec_align2;3754242937552430/* Write I2C bus */37563756-#define EC_CMD_I2C_WRITE 0x9524312431+#define EC_CMD_I2C_WRITE 0x00953757243237582433struct ec_params_i2c_write {37592434 uint16_t data;···37642433 uint8_t write_size; /* Either 8 or 16. */37652434 uint8_t port;37662435 uint8_t offset;37673767-} __packed;24362436+} __ec_align_size1;3768243737692438/*****************************************************************************/37702439/* Charge state commands. Only available when flash write protect unlocked. */···37722441/* Force charge state machine to stop charging the battery or force it to37732442 * discharge the battery.37742443 */37753775-#define EC_CMD_CHARGE_CONTROL 0x9624442444+#define EC_CMD_CHARGE_CONTROL 0x009637762445#define EC_VER_CHARGE_CONTROL 13777244637782447enum ec_charge_control_mode {···3783245237842453struct ec_params_charge_control {37852454 uint32_t mode; /* enum charge_control_mode */37863786-} __packed;24552455+} __ec_align4;3787245637882457/*****************************************************************************/37893789-/* Console commands. Only available when flash write protect is unlocked. */3790245837912459/* Snapshot console output buffer for use by EC_CMD_CONSOLE_READ. */37923792-#define EC_CMD_CONSOLE_SNAPSHOT 0x9724602460+#define EC_CMD_CONSOLE_SNAPSHOT 0x00973793246137942462/*37952463 * Read data from the saved snapshot. If the subcmd parameter is···38022472 * Response is null-terminated string. Empty string, if there is no more38032473 * remaining output.38042474 */38053805-#define EC_CMD_CONSOLE_READ 0x9824752475+#define EC_CMD_CONSOLE_READ 0x00983806247638072477enum ec_console_read_subcmd {38082478 CONSOLE_READ_NEXT = 0,···3811248138122482struct ec_params_console_read_v1 {38132483 uint8_t subcmd; /* enum ec_console_read_subcmd */38143814-} __packed;24842484+} __ec_align1;3815248538162486/*****************************************************************************/38172487···38222492 * EC_RES_SUCCESS if the command was successful.38232493 * EC_RES_ERROR if the cut off command failed.38242494 */24952495+#define EC_CMD_BATTERY_CUT_OFF 0x00993825249638263826-#define EC_CMD_BATTERY_CUT_OFF 0x9938273827-38283828-#define EC_BATTERY_CUTOFF_FLAG_AT_SHUTDOWN (1 << 0)24972497+#define EC_BATTERY_CUTOFF_FLAG_AT_SHUTDOWN BIT(0)3829249838302499struct ec_params_battery_cutoff {38312500 uint8_t flags;38323832-} __packed;25012501+} __ec_align1;3833250238342503/*****************************************************************************/38352504/* USB port mux control. */···38362507/*38372508 * Switch USB mux or return to automatic switching.38382509 */38393839-#define EC_CMD_USB_MUX 0x9a25102510+#define EC_CMD_USB_MUX 0x009A3840251138412512struct ec_params_usb_mux {38422513 uint8_t mux;38433843-} __packed;25142514+} __ec_align1;3844251538452516/*****************************************************************************/38462517/* LDOs / FETs control. */···38532524/*38542525 * Switch on/off a LDO.38552526 */38563856-#define EC_CMD_LDO_SET 0x9b25272527+#define EC_CMD_LDO_SET 0x009B3857252838582529struct ec_params_ldo_set {38592530 uint8_t index;38602531 uint8_t state;38613861-} __packed;25322532+} __ec_align1;3862253338632534/*38642535 * Get LDO state.38652536 */38663866-#define EC_CMD_LDO_GET 0x9c25372537+#define EC_CMD_LDO_GET 0x009C3867253838682539struct ec_params_ldo_get {38692540 uint8_t index;38703870-} __packed;25412541+} __ec_align1;3871254238722543struct ec_response_ldo_get {38732544 uint8_t state;38743874-} __packed;25452545+} __ec_align1;3875254638762547/*****************************************************************************/38772548/* Power info. */···38792550/*38802551 * Get power info.38812552 */38823882-#define EC_CMD_POWER_INFO 0x9d25532553+#define EC_CMD_POWER_INFO 0x009D3883255438842555struct ec_response_power_info {38852556 uint32_t usb_dev_type;···38872558 uint16_t voltage_system;38882559 uint16_t current_system;38892560 uint16_t usb_current_limit;38903890-} __packed;25612561+} __ec_align4;3891256238922563/*****************************************************************************/38932564/* I2C passthru command */3894256538953895-#define EC_CMD_I2C_PASSTHRU 0x9e25662566+#define EC_CMD_I2C_PASSTHRU 0x009E3896256738972568/* Read data; if not present, message is a write */38983898-#define EC_I2C_FLAG_READ (1 << 15)25692569+#define EC_I2C_FLAG_READ BIT(15)3899257039002571/* Mask for address */39012572#define EC_I2C_ADDR_MASK 0x3ff3902257339033903-#define EC_I2C_STATUS_NAK (1 << 0) /* Transfer was not acknowledged */39043904-#define EC_I2C_STATUS_TIMEOUT (1 << 1) /* Timeout during transfer */25742574+#define EC_I2C_STATUS_NAK BIT(0) /* Transfer was not acknowledged */25752575+#define EC_I2C_STATUS_TIMEOUT BIT(1) /* Timeout during transfer */3905257639062577/* Any error */39072578#define EC_I2C_STATUS_ERROR (EC_I2C_STATUS_NAK | EC_I2C_STATUS_TIMEOUT)···39092580struct ec_params_i2c_passthru_msg {39102581 uint16_t addr_flags; /* I2C slave address (7 or 10 bits) and flags */39112582 uint16_t len; /* Number of bytes to read or write */39123912-} __packed;25832583+} __ec_align2;3913258439142585struct ec_params_i2c_passthru {39152586 uint8_t port; /* I2C port number */39162587 uint8_t num_msgs; /* Number of messages */39172588 struct ec_params_i2c_passthru_msg msg[];39182589 /* Data to write for all messages is concatenated here */39193919-} __packed;25902590+} __ec_align2;3920259139212592struct ec_response_i2c_passthru {39222593 uint8_t i2c_status; /* Status flags (EC_I2C_STATUS_...) */39232594 uint8_t num_msgs; /* Number of messages processed */39242595 uint8_t data[]; /* Data read by messages concatenated here */39253925-} __packed;25962596+} __ec_align1;3926259739272598/*****************************************************************************/39282599/* Power button hang detect */3929260039303930-#define EC_CMD_HANG_DETECT 0x9f26012601+#define EC_CMD_HANG_DETECT 0x009F3931260239322603/* Reasons to start hang detection timer */39332604/* Power button pressed */39343934-#define EC_HANG_START_ON_POWER_PRESS (1 << 0)26052605+#define EC_HANG_START_ON_POWER_PRESS BIT(0)3935260639362607/* Lid closed */39373937-#define EC_HANG_START_ON_LID_CLOSE (1 << 1)26082608+#define EC_HANG_START_ON_LID_CLOSE BIT(1)3938260939392610 /* Lid opened */39403940-#define EC_HANG_START_ON_LID_OPEN (1 << 2)26112611+#define EC_HANG_START_ON_LID_OPEN BIT(2)3941261239422613/* Start of AP S3->S0 transition (booting or resuming from suspend) */39433943-#define EC_HANG_START_ON_RESUME (1 << 3)26142614+#define EC_HANG_START_ON_RESUME BIT(3)3944261539452616/* Reasons to cancel hang detection */3946261739472618/* Power button released */39483948-#define EC_HANG_STOP_ON_POWER_RELEASE (1 << 8)26192619+#define EC_HANG_STOP_ON_POWER_RELEASE BIT(8)3949262039502621/* Any host command from AP received */39513951-#define EC_HANG_STOP_ON_HOST_COMMAND (1 << 9)26222622+#define EC_HANG_STOP_ON_HOST_COMMAND BIT(9)3952262339532624/* Stop on end of AP S0->S3 transition (suspending or shutting down) */39543954-#define EC_HANG_STOP_ON_SUSPEND (1 << 10)26252625+#define EC_HANG_STOP_ON_SUSPEND BIT(10)3955262639562627/*39572628 * If this flag is set, all the other fields are ignored, and the hang detect···39592630 * without reconfiguring any of the other hang detect settings. Note that39602631 * you must previously have configured the timeouts.39612632 */39623962-#define EC_HANG_START_NOW (1 << 30)26332633+#define EC_HANG_START_NOW BIT(30)3963263439642635/*39652636 * If this flag is set, all the other fields are ignored (including39662637 * EC_HANG_START_NOW). This provides the AP a way to stop the hang timer39672638 * without reconfiguring any of the other hang detect settings.39682639 */39693969-#define EC_HANG_STOP_NOW (1 << 31)26402640+#define EC_HANG_STOP_NOW BIT(31)3970264139712642struct ec_params_hang_detect {39722643 /* Flags; see EC_HANG_* */···3977264839782649 /* Timeout in msec before generating warm reboot, if enabled */39792650 uint16_t warm_reboot_timeout_msec;39803980-} __packed;26512651+} __ec_align4;3981265239822653/*****************************************************************************/39832654/* Commands for battery charging */···39862657 * This is the single catch-all host command to exchange data regarding the39872658 * charge state machine (v2 and up).39882659 */39893989-#define EC_CMD_CHARGE_STATE 0xa026602660+#define EC_CMD_CHARGE_STATE 0x00A03990266139912662/* Subcommands for this host command */39922663enum charge_state_command {···40062677 CS_PARAM_CHG_INPUT_CURRENT, /* charger input current limit */40072678 CS_PARAM_CHG_STATUS, /* charger-specific status */40082679 CS_PARAM_CHG_OPTION, /* charger-specific options */26802680+ CS_PARAM_LIMIT_POWER, /*26812681+ * Check if power is limited due to26822682+ * low battery and / or a weak external26832683+ * charger. READ ONLY.26842684+ */40092685 /* How many so far? */40102686 CS_NUM_BASE_PARAMS,40112687···40182684 CS_PARAM_CUSTOM_PROFILE_MIN = 0x10000,40192685 CS_PARAM_CUSTOM_PROFILE_MAX = 0x1ffff,4020268626872687+ /* Range for CONFIG_CHARGE_STATE_DEBUG params */26882688+ CS_PARAM_DEBUG_MIN = 0x20000,26892689+ CS_PARAM_DEBUG_CTL_MODE = 0x20000,26902690+ CS_PARAM_DEBUG_MANUAL_MODE,26912691+ CS_PARAM_DEBUG_SEEMS_DEAD,26922692+ CS_PARAM_DEBUG_SEEMS_DISCONNECTED,26932693+ CS_PARAM_DEBUG_BATT_REMOVED,26942694+ CS_PARAM_DEBUG_MANUAL_CURRENT,26952695+ CS_PARAM_DEBUG_MANUAL_VOLTAGE,26962696+ CS_PARAM_DEBUG_MAX = 0x2ffff,26972697+40212698 /* Other custom param ranges go here... */40222699};4023270040242701struct ec_params_charge_state {40252702 uint8_t cmd; /* enum charge_state_command */40262703 union {40274027- struct {40284028- /* no args */40294029- } get_state;27042704+ /* get_state has no args */4030270540314031- struct {27062706+ struct __ec_todo_unpacked {40322707 uint32_t param; /* enum charge_state_param */40332708 } get_param;4034270940354035- struct {27102710+ struct __ec_todo_unpacked {40362711 uint32_t param; /* param to set */40372712 uint32_t value; /* value to set */40382713 } set_param;40392714 };40404040-} __packed;27152715+} __ec_todo_packed;4041271640422717struct ec_response_charge_state {40432718 union {40444044- struct {27192719+ struct __ec_align4 {40452720 int ac;40462721 int chg_voltage;40472722 int chg_current;···40582715 int batt_state_of_charge;40592716 } get_state;4060271740614061- struct {27182718+ struct __ec_align4 {40622719 uint32_t value;40632720 } get_param;40644064- struct {40654065- /* no return values */40664066- } set_param;27212721+27222722+ /* set_param returns no args */40672723 };40684068-} __packed;27242724+} __ec_align4;406927254070272640712727/*40722728 * Set maximum battery charging current.40732729 */40744074-#define EC_CMD_CHARGE_CURRENT_LIMIT 0xa127302730+#define EC_CMD_CHARGE_CURRENT_LIMIT 0x00A14075273140762732struct ec_params_current_limit {40772733 uint32_t limit; /* in mA */40784078-} __packed;27342734+} __ec_align4;4079273540802736/*40812737 * Set maximum external voltage / current.···40852743struct ec_params_external_power_limit_v1 {40862744 uint16_t current_lim; /* in mA, or EC_POWER_LIMIT_NONE to clear limit */40872745 uint16_t voltage_lim; /* in mV, or EC_POWER_LIMIT_NONE to clear limit */40884088-} __packed;27462746+} __ec_align2;4089274740902748#define EC_POWER_LIMIT_NONE 0xffff4091274927502750+/*27512751+ * Set maximum voltage & current of a dedicated charge port27522752+ */27532753+#define EC_CMD_OVERRIDE_DEDICATED_CHARGER_LIMIT 0x00A327542754+27552755+struct ec_params_dedicated_charger_limit {27562756+ uint16_t current_lim; /* in mA */27572757+ uint16_t voltage_lim; /* in mV */27582758+} __ec_align2;27592759+27602760+/*****************************************************************************/27612761+/* Hibernate/Deep Sleep Commands */27622762+27632763+/* Set the delay before going into hibernation. */27642764+#define EC_CMD_HIBERNATION_DELAY 0x00A827652765+27662766+struct ec_params_hibernation_delay {27672767+ /*27682768+ * Seconds to wait in G3 before hibernate. Pass in 0 to read the27692769+ * current settings without changing them.27702770+ */27712771+ uint32_t seconds;27722772+} __ec_align4;27732773+27742774+struct ec_response_hibernation_delay {27752775+ /*27762776+ * The current time in seconds in which the system has been in the G327772777+ * state. This value is reset if the EC transitions out of G3.27782778+ */27792779+ uint32_t time_g3;27802780+27812781+ /*27822782+ * The current time remaining in seconds until the EC should hibernate.27832783+ * This value is also reset if the EC transitions out of G3.27842784+ */27852785+ uint32_t time_remaining;27862786+27872787+ /*27882788+ * The current time in seconds that the EC should wait in G3 before27892789+ * hibernating.27902790+ */27912791+ uint32_t hibernate_delay;27922792+} __ec_align4;27932793+40922794/* Inform the EC when entering a sleep state */40934093-#define EC_CMD_HOST_SLEEP_EVENT 0xa927952795+#define EC_CMD_HOST_SLEEP_EVENT 0x00A94094279640952797enum host_sleep_event {40962798 HOST_SLEEP_EVENT_S3_SUSPEND = 1,40972799 HOST_SLEEP_EVENT_S3_RESUME = 2,40982800 HOST_SLEEP_EVENT_S0IX_SUSPEND = 3,40994099- HOST_SLEEP_EVENT_S0IX_RESUME = 428012801+ HOST_SLEEP_EVENT_S0IX_RESUME = 4,28022802+ /* S3 suspend with additional enabled wake sources */28032803+ HOST_SLEEP_EVENT_S3_WAKEABLE_SUSPEND = 5,41002804};4101280541022806struct ec_params_host_sleep_event {41032807 uint8_t sleep_event;41044104-} __packed;28082808+} __ec_align1;4105280941062810/*41072811 * Use a default timeout value (CONFIG_SLEEP_TIMEOUT_MS) for detecting sleep···4178279041792791 /* No parameters for non-suspend messages. */41802792 };41814181-} __packed;27932793+} __ec_align2;4182279441832795/* A timeout occurred when this bit is set */41842796#define EC_HOST_RESUME_SLEEP_TIMEOUT 0x80000000···4204281642052817 /* No response fields for non-resume messages. */42062818 };42074207-} __packed;28192819+} __ec_align4;28202820+28212821+/*****************************************************************************/28222822+/* Device events */28232823+#define EC_CMD_DEVICE_EVENT 0x00AA28242824+28252825+enum ec_device_event {28262826+ EC_DEVICE_EVENT_TRACKPAD,28272827+ EC_DEVICE_EVENT_DSP,28282828+ EC_DEVICE_EVENT_WIFI,28292829+};28302830+28312831+enum ec_device_event_param {28322832+ /* Get and clear pending device events */28332833+ EC_DEVICE_EVENT_PARAM_GET_CURRENT_EVENTS,28342834+ /* Get device event mask */28352835+ EC_DEVICE_EVENT_PARAM_GET_ENABLED_EVENTS,28362836+ /* Set device event mask */28372837+ EC_DEVICE_EVENT_PARAM_SET_ENABLED_EVENTS,28382838+};28392839+28402840+#define EC_DEVICE_EVENT_MASK(event_code) BIT(event_code % 32)28412841+28422842+struct ec_params_device_event {28432843+ uint32_t event_mask;28442844+ uint8_t param;28452845+} __ec_align_size1;28462846+28472847+struct ec_response_device_event {28482848+ uint32_t event_mask;28492849+} __ec_align4;4208285042092851/*****************************************************************************/42102852/* Smart battery pass-through */4211285342122854/* Get / Set 16-bit smart battery registers */42134213-#define EC_CMD_SB_READ_WORD 0xb042144214-#define EC_CMD_SB_WRITE_WORD 0xb128552855+#define EC_CMD_SB_READ_WORD 0x00B028562856+#define EC_CMD_SB_WRITE_WORD 0x00B14215285742162858/* Get / Set string smart battery parameters42172859 * formatted as SMBUS "block".42182860 */42194219-#define EC_CMD_SB_READ_BLOCK 0xb242204220-#define EC_CMD_SB_WRITE_BLOCK 0xb328612861+#define EC_CMD_SB_READ_BLOCK 0x00B228622862+#define EC_CMD_SB_WRITE_BLOCK 0x00B34221286342222864struct ec_params_sb_rd {42232865 uint8_t reg;42244224-} __packed;28662866+} __ec_align1;4225286742262868struct ec_response_sb_rd_word {42272869 uint16_t value;42284228-} __packed;28702870+} __ec_align2;4229287142302872struct ec_params_sb_wr_word {42312873 uint8_t reg;42322874 uint16_t value;42334233-} __packed;28752875+} __ec_align1;4234287642352877struct ec_response_sb_rd_block {42362878 uint8_t data[32];42374237-} __packed;28792879+} __ec_align1;4238288042392881struct ec_params_sb_wr_block {42402882 uint8_t reg;42412883 uint16_t data[32];42424242-} __packed;28842884+} __ec_align1;4243288542442886/*****************************************************************************/42452887/* Battery vendor parameters···42802862 * requested value.42812863 */4282286442834283-#define EC_CMD_BATTERY_VENDOR_PARAM 0xb428652865+#define EC_CMD_BATTERY_VENDOR_PARAM 0x00B44284286642852867enum ec_battery_vendor_param_mode {42862868 BATTERY_VENDOR_PARAM_MODE_GET = 0,···42912873 uint32_t param;42922874 uint32_t value;42932875 uint8_t mode;42944294-} __packed;28762876+} __ec_align_size1;4295287742962878struct ec_response_battery_vendor_param {42972879 uint32_t value;42984298-} __packed;28802880+} __ec_align4;4299288143002882/*****************************************************************************/28832883+/*28842884+ * Smart Battery Firmware Update Commands28852885+ */28862886+#define EC_CMD_SB_FW_UPDATE 0x00B528872887+28882888+enum ec_sb_fw_update_subcmd {28892889+ EC_SB_FW_UPDATE_PREPARE = 0x0,28902890+ EC_SB_FW_UPDATE_INFO = 0x1, /*query sb info */28912891+ EC_SB_FW_UPDATE_BEGIN = 0x2, /*check if protected */28922892+ EC_SB_FW_UPDATE_WRITE = 0x3, /*check if protected */28932893+ EC_SB_FW_UPDATE_END = 0x4,28942894+ EC_SB_FW_UPDATE_STATUS = 0x5,28952895+ EC_SB_FW_UPDATE_PROTECT = 0x6,28962896+ EC_SB_FW_UPDATE_MAX = 0x7,28972897+};28982898+28992899+#define SB_FW_UPDATE_CMD_WRITE_BLOCK_SIZE 3229002900+#define SB_FW_UPDATE_CMD_STATUS_SIZE 229012901+#define SB_FW_UPDATE_CMD_INFO_SIZE 829022902+29032903+struct ec_sb_fw_update_header {29042904+ uint16_t subcmd; /* enum ec_sb_fw_update_subcmd */29052905+ uint16_t fw_id; /* firmware id */29062906+} __ec_align4;29072907+29082908+struct ec_params_sb_fw_update {29092909+ struct ec_sb_fw_update_header hdr;29102910+ union {29112911+ /* EC_SB_FW_UPDATE_PREPARE = 0x0 */29122912+ /* EC_SB_FW_UPDATE_INFO = 0x1 */29132913+ /* EC_SB_FW_UPDATE_BEGIN = 0x2 */29142914+ /* EC_SB_FW_UPDATE_END = 0x4 */29152915+ /* EC_SB_FW_UPDATE_STATUS = 0x5 */29162916+ /* EC_SB_FW_UPDATE_PROTECT = 0x6 */29172917+ /* Those have no args */29182918+29192919+ /* EC_SB_FW_UPDATE_WRITE = 0x3 */29202920+ struct __ec_align4 {29212921+ uint8_t data[SB_FW_UPDATE_CMD_WRITE_BLOCK_SIZE];29222922+ } write;29232923+ };29242924+} __ec_align4;29252925+29262926+struct ec_response_sb_fw_update {29272927+ union {29282928+ /* EC_SB_FW_UPDATE_INFO = 0x1 */29292929+ struct __ec_align1 {29302930+ uint8_t data[SB_FW_UPDATE_CMD_INFO_SIZE];29312931+ } info;29322932+29332933+ /* EC_SB_FW_UPDATE_STATUS = 0x5 */29342934+ struct __ec_align1 {29352935+ uint8_t data[SB_FW_UPDATE_CMD_STATUS_SIZE];29362936+ } status;29372937+ };29382938+} __ec_align1;29392939+29402940+/*29412941+ * Entering Verified Boot Mode Command29422942+ * Default mode is VBOOT_MODE_NORMAL if EC did not receive this command.29432943+ * Valid Modes are: normal, developer, and recovery.29442944+ */29452945+#define EC_CMD_ENTERING_MODE 0x00B629462946+29472947+struct ec_params_entering_mode {29482948+ int vboot_mode;29492949+} __ec_align4;29502950+29512951+#define VBOOT_MODE_NORMAL 029522952+#define VBOOT_MODE_DEVELOPER 129532953+#define VBOOT_MODE_RECOVERY 229542954+29552955+/*****************************************************************************/29562956+/*29572957+ * I2C passthru protection command: Protects I2C tunnels against access on29582958+ * certain addresses (board-specific).29592959+ */29602960+#define EC_CMD_I2C_PASSTHRU_PROTECT 0x00B729612961+29622962+enum ec_i2c_passthru_protect_subcmd {29632963+ EC_CMD_I2C_PASSTHRU_PROTECT_STATUS = 0x0,29642964+ EC_CMD_I2C_PASSTHRU_PROTECT_ENABLE = 0x1,29652965+};29662966+29672967+struct ec_params_i2c_passthru_protect {29682968+ uint8_t subcmd;29692969+ uint8_t port; /* I2C port number */29702970+} __ec_align1;29712971+29722972+struct ec_response_i2c_passthru_protect {29732973+ uint8_t status; /* Status flags (0: unlocked, 1: locked) */29742974+} __ec_align1;29752975+29762976+29772977+/*****************************************************************************/29782978+/*29792979+ * HDMI CEC commands29802980+ *29812981+ * These commands are for sending and receiving message via HDMI CEC29822982+ */29832983+29842984+#define MAX_CEC_MSG_LEN 1629852985+29862986+/* CEC message from the AP to be written on the CEC bus */29872987+#define EC_CMD_CEC_WRITE_MSG 0x00B829882988+29892989+/**29902990+ * struct ec_params_cec_write - Message to write to the CEC bus29912991+ * @msg: message content to write to the CEC bus29922992+ */29932993+struct ec_params_cec_write {29942994+ uint8_t msg[MAX_CEC_MSG_LEN];29952995+} __ec_align1;29962996+29972997+/* Set various CEC parameters */29982998+#define EC_CMD_CEC_SET 0x00BA29992999+30003000+/**30013001+ * struct ec_params_cec_set - CEC parameters set30023002+ * @cmd: parameter type, can be CEC_CMD_ENABLE or CEC_CMD_LOGICAL_ADDRESS30033003+ * @val: in case cmd is CEC_CMD_ENABLE, this field can be 0 to disable CEC30043004+ * or 1 to enable CEC functionality, in case cmd is30053005+ * CEC_CMD_LOGICAL_ADDRESS, this field encodes the requested logical30063006+ * address between 0 and 15 or 0xff to unregister30073007+ */30083008+struct ec_params_cec_set {30093009+ uint8_t cmd; /* enum cec_command */30103010+ uint8_t val;30113011+} __ec_align1;30123012+30133013+/* Read various CEC parameters */30143014+#define EC_CMD_CEC_GET 0x00BB30153015+30163016+/**30173017+ * struct ec_params_cec_get - CEC parameters get30183018+ * @cmd: parameter type, can be CEC_CMD_ENABLE or CEC_CMD_LOGICAL_ADDRESS30193019+ */30203020+struct ec_params_cec_get {30213021+ uint8_t cmd; /* enum cec_command */30223022+} __ec_align1;30233023+30243024+/**30253025+ * struct ec_response_cec_get - CEC parameters get response30263026+ * @val: in case cmd was CEC_CMD_ENABLE, this field will 0 if CEC is30273027+ * disabled or 1 if CEC functionality is enabled,30283028+ * in case cmd was CEC_CMD_LOGICAL_ADDRESS, this will encode the30293029+ * configured logical address between 0 and 15 or 0xff if unregistered30303030+ */30313031+struct ec_response_cec_get {30323032+ uint8_t val;30333033+} __ec_align1;30343034+30353035+/* CEC parameters command */30363036+enum cec_command {30373037+ /* CEC reading, writing and events enable */30383038+ CEC_CMD_ENABLE,30393039+ /* CEC logical address */30403040+ CEC_CMD_LOGICAL_ADDRESS,30413041+};30423042+30433043+/* Events from CEC to AP */30443044+enum mkbp_cec_event {30453045+ /* Outgoing message was acknowledged by a follower */30463046+ EC_MKBP_CEC_SEND_OK = BIT(0),30473047+ /* Outgoing message was not acknowledged */30483048+ EC_MKBP_CEC_SEND_FAILED = BIT(1),30493049+};30503050+30513051+/*****************************************************************************/30523052+43013053/* Commands for I2S recording on audio codec. */4302305443033055#define EC_CMD_CODEC_I2S 0x00BC30563056+#define EC_WOV_I2S_SAMPLE_RATE 480004304305743053058enum ec_codec_i2s_subcmd {43063059 EC_CODEC_SET_SAMPLE_DEPTH = 0x0,···44812892 EC_CODEC_I2S_SET_CONFIG = 0x4,44822893 EC_CODEC_I2S_SET_TDM_CONFIG = 0x5,44832894 EC_CODEC_I2S_SET_BCLK = 0x6,28952895+ EC_CODEC_I2S_SUBCMD_COUNT = 0x7,44842896};4485289744862898enum ec_sample_depth_value {···44982908 EC_DAI_FMT_PCM_TDM = 5,44992909};4500291045014501-struct ec_param_codec_i2s {45024502- /*45034503- * enum ec_codec_i2s_subcmd45044504- */29112911+/*29122912+ * For subcommand EC_CODEC_GET_GAIN.29132913+ */29142914+struct __ec_align1 ec_codec_i2s_gain {29152915+ uint8_t left;29162916+ uint8_t right;29172917+};29182918+29192919+struct __ec_todo_unpacked ec_param_codec_i2s_tdm {29202920+ int16_t ch0_delay; /* 0 to 496 */29212921+ int16_t ch1_delay; /* -1 to 496 */29222922+ uint8_t adjacent_to_ch0;29232923+ uint8_t adjacent_to_ch1;29242924+};29252925+29262926+struct __ec_todo_packed ec_param_codec_i2s {29272927+ /* enum ec_codec_i2s_subcmd */45052928 uint8_t cmd;45062929 union {45072930 /*···45272924 * EC_CODEC_SET_GAIN45282925 * Value should be 0~43 for both channels.45292926 */45304530- struct ec_param_codec_i2s_set_gain {45314531- uint8_t left;45324532- uint8_t right;45334533- } __packed gain;29272927+ struct ec_codec_i2s_gain gain;4534292845352929 /*45362930 * EC_CODEC_I2S_ENABLE···45362936 uint8_t i2s_enable;4537293745382938 /*45394539- * EC_CODEC_I2S_SET_COFNIG29392939+ * EC_CODEC_I2S_SET_CONFIG45402940 * Value should be one of ec_i2s_config.45412941 */45422942 uint8_t i2s_config;···45452945 * EC_CODEC_I2S_SET_TDM_CONFIG45462946 * Value should be one of ec_i2s_config.45472947 */45484548- struct ec_param_codec_i2s_tdm {45494549- /*45504550- * 0 to 49645514551- */45524552- int16_t ch0_delay;45534553- /*45544554- * -1 to 49645554555- */45564556- int16_t ch1_delay;45574557- uint8_t adjacent_to_ch0;45584558- uint8_t adjacent_to_ch1;45594559- } __packed tdm_param;29482948+ struct ec_param_codec_i2s_tdm tdm_param;4560294945612950 /*45622951 * EC_CODEC_I2S_SET_BCLK45632952 */45642953 uint32_t bclk;45652954 };45664566-} __packed;29552955+};4567295645684568-/*45694569- * For subcommand EC_CODEC_GET_GAIN.45704570- */45714571-struct ec_response_codec_gain {45724572- uint8_t left;45734573- uint8_t right;45744574-} __packed;4575295745762958/*****************************************************************************/45772959/* System commands */···45622980 * TODO(crosbug.com/p/23747): This is a confusing name, since it doesn't45632981 * necessarily reboot the EC. Rename to "image" or something similar?45642982 */45654565-#define EC_CMD_REBOOT_EC 0xd229832983+#define EC_CMD_REBOOT_EC 0x00D24566298445672985/* Command */45682986enum ec_reboot_cmd {45692987 EC_REBOOT_CANCEL = 0, /* Cancel a pending reboot */45702988 EC_REBOOT_JUMP_RO = 1, /* Jump to RO without rebooting */45714571- EC_REBOOT_JUMP_RW = 2, /* Jump to RW without rebooting */29892989+ EC_REBOOT_JUMP_RW = 2, /* Jump to active RW without rebooting */45722990 /* (command 3 was jump to RW-B) */45732991 EC_REBOOT_COLD = 4, /* Cold-reboot */45742992 EC_REBOOT_DISABLE_JUMP = 5, /* Disable jump until next reboot */45754575- EC_REBOOT_HIBERNATE = 6 /* Hibernate EC */29932993+ EC_REBOOT_HIBERNATE = 6, /* Hibernate EC */29942994+ EC_REBOOT_HIBERNATE_CLEAR_AP_OFF = 7, /* and clears AP_OFF flag */45762995};4577299645782997/* Flags for ec_params_reboot_ec.reboot_flags */45794579-#define EC_REBOOT_FLAG_RESERVED0 (1 << 0) /* Was recovery request */45804580-#define EC_REBOOT_FLAG_ON_AP_SHUTDOWN (1 << 1) /* Reboot after AP shutdown */29982998+#define EC_REBOOT_FLAG_RESERVED0 BIT(0) /* Was recovery request */29992999+#define EC_REBOOT_FLAG_ON_AP_SHUTDOWN BIT(1) /* Reboot after AP shutdown */30003000+#define EC_REBOOT_FLAG_SWITCH_RW_SLOT BIT(2) /* Switch RW slot */4581300145823002struct ec_params_reboot_ec {45833003 uint8_t cmd; /* enum ec_reboot_cmd */45843004 uint8_t flags; /* See EC_REBOOT_FLAG_* */45854585-} __packed;30053005+} __ec_align1;4586300645873007/*45883008 * Get information on last EC panic.···45923008 * Returns variable-length platform-dependent panic information. See panic.h45933009 * for details.45943010 */45954595-#define EC_CMD_GET_PANIC_INFO 0xd345964596-45974597-/*****************************************************************************/45984598-/*45994599- * ACPI commands46004600- *46014601- * These are valid ONLY on the ACPI command/data port.46024602- */46034603-46044604-/*46054605- * ACPI Read Embedded Controller46064606- *46074607- * This reads from ACPI memory space on the EC (EC_ACPI_MEM_*).46084608- *46094609- * Use the following sequence:46104610- *46114611- * - Write EC_CMD_ACPI_READ to EC_LPC_ADDR_ACPI_CMD46124612- * - Wait for EC_LPC_CMDR_PENDING bit to clear46134613- * - Write address to EC_LPC_ADDR_ACPI_DATA46144614- * - Wait for EC_LPC_CMDR_DATA bit to set46154615- * - Read value from EC_LPC_ADDR_ACPI_DATA46164616- */46174617-#define EC_CMD_ACPI_READ 0x8046184618-46194619-/*46204620- * ACPI Write Embedded Controller46214621- *46224622- * This reads from ACPI memory space on the EC (EC_ACPI_MEM_*).46234623- *46244624- * Use the following sequence:46254625- *46264626- * - Write EC_CMD_ACPI_WRITE to EC_LPC_ADDR_ACPI_CMD46274627- * - Wait for EC_LPC_CMDR_PENDING bit to clear46284628- * - Write address to EC_LPC_ADDR_ACPI_DATA46294629- * - Wait for EC_LPC_CMDR_PENDING bit to clear46304630- * - Write value to EC_LPC_ADDR_ACPI_DATA46314631- */46324632-#define EC_CMD_ACPI_WRITE 0x8146334633-46344634-/*46354635- * ACPI Query Embedded Controller46364636- *46374637- * This clears the lowest-order bit in the currently pending host events, and46384638- * sets the result code to the 1-based index of the bit (event 0x00000001 = 1,46394639- * event 0x80000000 = 32), or 0 if no event was pending.46404640- */46414641-#define EC_CMD_ACPI_QUERY_EVENT 0x8446424642-46434643-/* Valid addresses in ACPI memory space, for read/write commands */46444644-46454645-/* Memory space version; set to EC_ACPI_MEM_VERSION_CURRENT */46464646-#define EC_ACPI_MEM_VERSION 0x0046474647-/*46484648- * Test location; writing value here updates test compliment byte to (0xff -46494649- * value).46504650- */46514651-#define EC_ACPI_MEM_TEST 0x0146524652-/* Test compliment; writes here are ignored. */46534653-#define EC_ACPI_MEM_TEST_COMPLIMENT 0x0246544654-46554655-/* Keyboard backlight brightness percent (0 - 100) */46564656-#define EC_ACPI_MEM_KEYBOARD_BACKLIGHT 0x0346574657-/* DPTF Target Fan Duty (0-100, 0xff for auto/none) */46584658-#define EC_ACPI_MEM_FAN_DUTY 0x0446594659-46604660-/*46614661- * DPTF temp thresholds. Any of the EC's temp sensors can have up to two46624662- * independent thresholds attached to them. The current value of the ID46634663- * register determines which sensor is affected by the THRESHOLD and COMMIT46644664- * registers. The THRESHOLD register uses the same EC_TEMP_SENSOR_OFFSET scheme46654665- * as the memory-mapped sensors. The COMMIT register applies those settings.46664666- *46674667- * The spec does not mandate any way to read back the threshold settings46684668- * themselves, but when a threshold is crossed the AP needs a way to determine46694669- * which sensor(s) are responsible. Each reading of the ID register clears and46704670- * returns one sensor ID that has crossed one of its threshold (in either46714671- * direction) since the last read. A value of 0xFF means "no new thresholds46724672- * have tripped". Setting or enabling the thresholds for a sensor will clear46734673- * the unread event count for that sensor.46744674- */46754675-#define EC_ACPI_MEM_TEMP_ID 0x0546764676-#define EC_ACPI_MEM_TEMP_THRESHOLD 0x0646774677-#define EC_ACPI_MEM_TEMP_COMMIT 0x0746784678-/*46794679- * Here are the bits for the COMMIT register:46804680- * bit 0 selects the threshold index for the chosen sensor (0/1)46814681- * bit 1 enables/disables the selected threshold (0 = off, 1 = on)46824682- * Each write to the commit register affects one threshold.46834683- */46844684-#define EC_ACPI_MEM_TEMP_COMMIT_SELECT_MASK (1 << 0)46854685-#define EC_ACPI_MEM_TEMP_COMMIT_ENABLE_MASK (1 << 1)46864686-/*46874687- * Example:46884688- *46894689- * Set the thresholds for sensor 2 to 50 C and 60 C:46904690- * write 2 to [0x05] -- select temp sensor 246914691- * write 0x7b to [0x06] -- C_TO_K(50) - EC_TEMP_SENSOR_OFFSET46924692- * write 0x2 to [0x07] -- enable threshold 0 with this value46934693- * write 0x85 to [0x06] -- C_TO_K(60) - EC_TEMP_SENSOR_OFFSET46944694- * write 0x3 to [0x07] -- enable threshold 1 with this value46954695- *46964696- * Disable the 60 C threshold, leaving the 50 C threshold unchanged:46974697- * write 2 to [0x05] -- select temp sensor 246984698- * write 0x1 to [0x07] -- disable threshold 146994699- */47004700-47014701-/* DPTF battery charging current limit */47024702-#define EC_ACPI_MEM_CHARGING_LIMIT 0x0847034703-47044704-/* Charging limit is specified in 64 mA steps */47054705-#define EC_ACPI_MEM_CHARGING_LIMIT_STEP_MA 6447064706-/* Value to disable DPTF battery charging limit */47074707-#define EC_ACPI_MEM_CHARGING_LIMIT_DISABLED 0xff47084708-47094709-/* Current version of ACPI memory address space */47104710-#define EC_ACPI_MEM_VERSION_CURRENT 147114711-47124712-47134713-/*****************************************************************************/47144714-/*47154715- * HDMI CEC commands47164716- *47174717- * These commands are for sending and receiving message via HDMI CEC47184718- */47194719-#define EC_MAX_CEC_MSG_LEN 1647204720-47214721-/* CEC message from the AP to be written on the CEC bus */47224722-#define EC_CMD_CEC_WRITE_MSG 0x00B847234723-47244724-/**47254725- * struct ec_params_cec_write - Message to write to the CEC bus47264726- * @msg: message content to write to the CEC bus47274727- */47284728-struct ec_params_cec_write {47294729- uint8_t msg[EC_MAX_CEC_MSG_LEN];47304730-} __packed;47314731-47324732-/* Set various CEC parameters */47334733-#define EC_CMD_CEC_SET 0x00BA47344734-47354735-/**47364736- * struct ec_params_cec_set - CEC parameters set47374737- * @cmd: parameter type, can be CEC_CMD_ENABLE or CEC_CMD_LOGICAL_ADDRESS47384738- * @val: in case cmd is CEC_CMD_ENABLE, this field can be 0 to disable CEC47394739- * or 1 to enable CEC functionality, in case cmd is CEC_CMD_LOGICAL_ADDRESS,47404740- * this field encodes the requested logical address between 0 and 1547414741- * or 0xff to unregister47424742- */47434743-struct ec_params_cec_set {47444744- uint8_t cmd; /* enum cec_command */47454745- uint8_t val;47464746-} __packed;47474747-47484748-/* Read various CEC parameters */47494749-#define EC_CMD_CEC_GET 0x00BB47504750-47514751-/**47524752- * struct ec_params_cec_get - CEC parameters get47534753- * @cmd: parameter type, can be CEC_CMD_ENABLE or CEC_CMD_LOGICAL_ADDRESS47544754- */47554755-struct ec_params_cec_get {47564756- uint8_t cmd; /* enum cec_command */47574757-} __packed;47584758-47594759-/**47604760- * struct ec_response_cec_get - CEC parameters get response47614761- * @val: in case cmd was CEC_CMD_ENABLE, this field will 0 if CEC is47624762- * disabled or 1 if CEC functionality is enabled,47634763- * in case cmd was CEC_CMD_LOGICAL_ADDRESS, this will encode the47644764- * configured logical address between 0 and 15 or 0xff if unregistered47654765- */47664766-struct ec_response_cec_get {47674767- uint8_t val;47684768-} __packed;47694769-47704770-/* CEC parameters command */47714771-enum ec_cec_command {47724772- /* CEC reading, writing and events enable */47734773- CEC_CMD_ENABLE,47744774- /* CEC logical address */47754775- CEC_CMD_LOGICAL_ADDRESS,47764776-};47774777-47784778-/* Events from CEC to AP */47794779-enum mkbp_cec_event {47804780- /* Outgoing message was acknowledged by a follower */47814781- EC_MKBP_CEC_SEND_OK = BIT(0),47824782- /* Outgoing message was not acknowledged */47834783- EC_MKBP_CEC_SEND_FAILED = BIT(1),47844784-};30113011+#define EC_CMD_GET_PANIC_INFO 0x00D34785301247863013/*****************************************************************************/47873014/*···46113216 *46123217 * Use EC_CMD_REBOOT_EC to reboot the EC more politely.46133218 */46144614-#define EC_CMD_REBOOT 0xd1 /* Think "die" */32193219+#define EC_CMD_REBOOT 0x00D1 /* Think "die" */4615322046163221/*46173222 * Resend last response (not supported on LPC).···46203225 * there was no previous command, or the previous command's response was too46213226 * big to save.46223227 */46234623-#define EC_CMD_RESEND_RESPONSE 0xdb32283228+#define EC_CMD_RESEND_RESPONSE 0x00DB4624322946253230/*46263231 * This header byte on a command indicate version 0. Any header byte less···46323237 *46333238 * The old EC interface must not use commands 0xdc or higher.46343239 */46354635-#define EC_CMD_VERSION0 0xdc46364636-46374637-#endif /* !__ACPI__ */32403240+#define EC_CMD_VERSION0 0x00DC4638324146393242/*****************************************************************************/46403243/*···46423249 */4643325046443251/* EC to PD MCU exchange status command */46454645-#define EC_CMD_PD_EXCHANGE_STATUS 0x10032523252+#define EC_CMD_PD_EXCHANGE_STATUS 0x010032533253+#define EC_VER_PD_EXCHANGE_STATUS 232543254+32553255+enum pd_charge_state {32563256+ PD_CHARGE_NO_CHANGE = 0, /* Don't change charge state */32573257+ PD_CHARGE_NONE, /* No charging allowed */32583258+ PD_CHARGE_5V, /* 5V charging only */32593259+ PD_CHARGE_MAX /* Charge at max voltage */32603260+};4646326146473262/* Status of EC being sent to PD */32633263+#define EC_STATUS_HIBERNATING BIT(0)32643264+46483265struct ec_params_pd_status {46494649- int8_t batt_soc; /* battery state of charge */46504650-} __packed;32663266+ uint8_t status; /* EC status */32673267+ int8_t batt_soc; /* battery state of charge */32683268+ uint8_t charge_state; /* charging state (from enum pd_charge_state) */32693269+} __ec_align1;4651327046523271/* Status of PD being sent back to EC */32723272+#define PD_STATUS_HOST_EVENT BIT(0) /* Forward host event to AP */32733273+#define PD_STATUS_IN_RW BIT(1) /* Running RW image */32743274+#define PD_STATUS_JUMPED_TO_IMAGE BIT(2) /* Current image was jumped to */32753275+#define PD_STATUS_TCPC_ALERT_0 BIT(3) /* Alert active in port 0 TCPC */32763276+#define PD_STATUS_TCPC_ALERT_1 BIT(4) /* Alert active in port 1 TCPC */32773277+#define PD_STATUS_TCPC_ALERT_2 BIT(5) /* Alert active in port 2 TCPC */32783278+#define PD_STATUS_TCPC_ALERT_3 BIT(6) /* Alert active in port 3 TCPC */32793279+#define PD_STATUS_EC_INT_ACTIVE (PD_STATUS_TCPC_ALERT_0 | \32803280+ PD_STATUS_TCPC_ALERT_1 | \32813281+ PD_STATUS_HOST_EVENT)46533282struct ec_response_pd_status {46544654- int8_t status; /* PD MCU status */46554655- uint32_t curr_lim_ma; /* input current limit */46564656-} __packed;32833283+ uint32_t curr_lim_ma; /* input current limit */32843284+ uint16_t status; /* PD MCU status */32853285+ int8_t active_charge_port; /* active charging port */32863286+} __ec_align_size1;32873287+32883288+/* AP to PD MCU host event status command, cleared on read */32893289+#define EC_CMD_PD_HOST_EVENT_STATUS 0x010432903290+32913291+/* PD MCU host event status bits */32923292+#define PD_EVENT_UPDATE_DEVICE BIT(0)32933293+#define PD_EVENT_POWER_CHANGE BIT(1)32943294+#define PD_EVENT_IDENTITY_RECEIVED BIT(2)32953295+#define PD_EVENT_DATA_SWAP BIT(3)32963296+struct ec_response_host_event_status {32973297+ uint32_t status; /* PD MCU host event status */32983298+} __ec_align4;4657329946583300/* Set USB type-C port role and muxes */46594659-#define EC_CMD_USB_PD_CONTROL 0x10133013301+#define EC_CMD_USB_PD_CONTROL 0x01014660330246613303enum usb_pd_control_role {46623304 USB_PD_CTRL_ROLE_NO_CHANGE = 0,···46993271 USB_PD_CTRL_ROLE_TOGGLE_OFF = 2,47003272 USB_PD_CTRL_ROLE_FORCE_SINK = 3,47013273 USB_PD_CTRL_ROLE_FORCE_SOURCE = 4,32743274+ USB_PD_CTRL_ROLE_FREEZE = 5,32753275+ USB_PD_CTRL_ROLE_COUNT47023276};4703327747043278enum usb_pd_control_mux {···47103280 USB_PD_CTRL_MUX_DP = 3,47113281 USB_PD_CTRL_MUX_DOCK = 4,47123282 USB_PD_CTRL_MUX_AUTO = 5,32833283+ USB_PD_CTRL_MUX_COUNT47133284};4714328547153286enum usb_pd_control_swap {···47263295 uint8_t role;47273296 uint8_t mux;47283297 uint8_t swap;47294729-} __packed;32983298+} __ec_align1;4730329947314731-#define PD_CTRL_RESP_ENABLED_COMMS (1 << 0) /* Communication enabled */47324732-#define PD_CTRL_RESP_ENABLED_CONNECTED (1 << 1) /* Device connected */47334733-#define PD_CTRL_RESP_ENABLED_PD_CAPABLE (1 << 2) /* Partner is PD capable */33003300+#define PD_CTRL_RESP_ENABLED_COMMS BIT(0) /* Communication enabled */33013301+#define PD_CTRL_RESP_ENABLED_CONNECTED BIT(1) /* Device connected */33023302+#define PD_CTRL_RESP_ENABLED_PD_CAPABLE BIT(2) /* Partner is PD capable */4734330347353304#define PD_CTRL_RESP_ROLE_POWER BIT(0) /* 0=SNK/1=SRC */47363305#define PD_CTRL_RESP_ROLE_DATA BIT(1) /* 0=UFP/1=DFP */···47403309#define PD_CTRL_RESP_ROLE_USB_COMM BIT(5) /* Partner USB comm capable */47413310#define PD_CTRL_RESP_ROLE_EXT_POWERED BIT(6) /* Partner externally powerd */4742331133123312+struct ec_response_usb_pd_control {33133313+ uint8_t enabled;33143314+ uint8_t role;33153315+ uint8_t polarity;33163316+ uint8_t state;33173317+} __ec_align1;33183318+47433319struct ec_response_usb_pd_control_v1 {47443320 uint8_t enabled;47453321 uint8_t role;47463322 uint8_t polarity;47473323 char state[32];47484748-} __packed;33243324+} __ec_align1;4749332547504750-#define EC_CMD_USB_PD_PORTS 0x10233263326+/* Values representing usbc PD CC state */33273327+#define USBC_PD_CC_NONE 0 /* No accessory connected */33283328+#define USBC_PD_CC_NO_UFP 1 /* No UFP accessory connected */33293329+#define USBC_PD_CC_AUDIO_ACC 2 /* Audio accessory connected */33303330+#define USBC_PD_CC_DEBUG_ACC 3 /* Debug accessory connected */33313331+#define USBC_PD_CC_UFP_ATTACHED 4 /* UFP attached to usbc */33323332+#define USBC_PD_CC_DFP_ATTACHED 5 /* DPF attached to usbc */33333333+33343334+struct ec_response_usb_pd_control_v2 {33353335+ uint8_t enabled;33363336+ uint8_t role;33373337+ uint8_t polarity;33383338+ char state[32];33393339+ uint8_t cc_state; /* USBC_PD_CC_*Encoded cc state */33403340+ uint8_t dp_mode; /* Current DP pin mode (MODE_DP_PIN_[A-E]) */33413341+ /* CL:1500994 Current cable type */33423342+ uint8_t reserved_cable_type;33433343+} __ec_align1;33443344+33453345+#define EC_CMD_USB_PD_PORTS 0x01024751334647523347/* Maximum number of PD ports on a device, num_ports will be <= this */47533348#define EC_USB_PD_MAX_PORTS 84754334947553350struct ec_response_usb_pd_ports {47563351 uint8_t num_ports;47574757-} __packed;33523352+} __ec_align1;4758335347594759-#define EC_CMD_USB_PD_POWER_INFO 0x10333543354+#define EC_CMD_USB_PD_POWER_INFO 0x01034760335547613356#define PD_POWER_CHARGING_PORT 0xff47623357struct ec_params_usb_pd_power_info {47633358 uint8_t port;47644764-} __packed;33593359+} __ec_align1;4765336047663361enum usb_chg_type {47673362 USB_CHG_TYPE_NONE,···48003343 USB_CHG_TYPE_OTHER,48013344 USB_CHG_TYPE_VBUS,48023345 USB_CHG_TYPE_UNKNOWN,33463346+ USB_CHG_TYPE_DEDICATED,48033347};48043348enum usb_power_roles {48053349 USB_PD_PORT_POWER_DISCONNECTED,···48143356 uint16_t voltage_now;48153357 uint16_t current_max;48163358 uint16_t current_lim;48174817-} __packed;33593359+} __ec_align2;4818336048193361struct ec_response_usb_pd_power_info {48203362 uint8_t role;···48233365 uint8_t reserved1;48243366 struct usb_chg_measures meas;48253367 uint32_t max_power;48264826-} __packed;33683368+} __ec_align4;4827336948284828-struct ec_params_usb_pd_info_request {48294829- uint8_t port;48304830-} __packed;4831337048323371/*48333372 * This command will return the number of USB PD charge port + the number···48343379#define EC_CMD_CHARGE_PORT_COUNT 0x010548353380struct ec_response_charge_port_count {48363381 uint8_t port_count;48374837-} __packed;33823382+} __ec_align1;33833383+33843384+/* Write USB-PD device FW */33853385+#define EC_CMD_USB_PD_FW_UPDATE 0x011033863386+33873387+enum usb_pd_fw_update_cmds {33883388+ USB_PD_FW_REBOOT,33893389+ USB_PD_FW_FLASH_ERASE,33903390+ USB_PD_FW_FLASH_WRITE,33913391+ USB_PD_FW_ERASE_SIG,33923392+};33933393+33943394+struct ec_params_usb_pd_fw_update {33953395+ uint16_t dev_id;33963396+ uint8_t cmd;33973397+ uint8_t port;33983398+ uint32_t size; /* Size to write in bytes */33993399+ /* Followed by data to write */34003400+} __ec_align4;34013401+34023402+/* Write USB-PD Accessory RW_HASH table entry */34033403+#define EC_CMD_USB_PD_RW_HASH_ENTRY 0x011134043404+/* RW hash is first 20 bytes of SHA-256 of RW section */34053405+#define PD_RW_HASH_SIZE 2034063406+struct ec_params_usb_pd_rw_hash_entry {34073407+ uint16_t dev_id;34083408+ uint8_t dev_rw_hash[PD_RW_HASH_SIZE];34093409+ uint8_t reserved; /*34103410+ * For alignment of current_image34113411+ * TODO(rspangler) but it's not aligned!34123412+ * Should have been reserved[2].34133413+ */34143414+ uint32_t current_image; /* One of ec_current_image */34153415+} __ec_align1;34163416+34173417+/* Read USB-PD Accessory info */34183418+#define EC_CMD_USB_PD_DEV_INFO 0x011234193419+34203420+struct ec_params_usb_pd_info_request {34213421+ uint8_t port;34223422+} __ec_align1;4838342348393424/* Read USB-PD Device discovery info */48403425#define EC_CMD_USB_PD_DISCOVERY 0x0113···48823387 uint16_t vid; /* USB-IF VID */48833388 uint16_t pid; /* USB-IF PID */48843389 uint8_t ptype; /* product type (hub,periph,cable,ama) */48854885-} __packed;33903390+} __ec_align_size1;4886339148873392/* Override default charge behavior */48883393#define EC_CMD_PD_CHARGE_PORT_OVERRIDE 0x0114···4896340148973402struct ec_params_charge_port_override {48983403 int16_t override_port; /* Override port# */48994899-} __packed;34043404+} __ec_align2;4900340549014901-/* Read (and delete) one entry of PD event log */34063406+/*34073407+ * Read (and delete) one entry of PD event log.34083408+ * TODO(crbug.com/751742): Make this host command more generic to accommodate34093409+ * future non-PD logs that use the same internal EC event_log.34103410+ */49023411#define EC_CMD_PD_GET_LOG_ENTRY 0x01154903341249043413struct ec_response_pd_log {···49113412 uint8_t size_port; /* [7:5] port number [4:0] payload size in bytes */49123413 uint16_t data; /* type-defined data payload */49133414 uint8_t payload[0]; /* optional additional data payload: 0..16 bytes */49144914-} __packed;34153415+} __ec_align4;4915341649163417/* The timestamp is the microsecond counter shifted to get about a ms. */49173418#define PD_LOG_TIMESTAMP_SHIFT 10 /* 1 LSB = 1024us */···49773478 uint8_t major;49783479 uint8_t minor;49793480 uint16_t build;49804980-} __packed;34813481+} __ec_align4;4981348249823483struct mcdp_info {49833484 uint8_t family[2];49843485 uint8_t chipid[2];49853486 struct mcdp_version irom;49863487 struct mcdp_version fw;49874987-} __packed;34883488+} __ec_align4;4988348949893490/* struct mcdp_info field decoding */49903491#define MCDP_CHIPID(chipid) ((chipid[0] << 8) | chipid[1])49913492#define MCDP_FAMILY(family) ((family[0] << 8) | family[1])4992349334943494+/* Get/Set USB-PD Alternate mode info */34953495+#define EC_CMD_USB_PD_GET_AMODE 0x011634963496+struct ec_params_usb_pd_get_mode_request {34973497+ uint16_t svid_idx; /* SVID index to get */34983498+ uint8_t port; /* port */34993499+} __ec_align_size1;35003500+35013501+struct ec_params_usb_pd_get_mode_response {35023502+ uint16_t svid; /* SVID */35033503+ uint16_t opos; /* Object Position */35043504+ uint32_t vdo[6]; /* Mode VDOs */35053505+} __ec_align4;35063506+35073507+#define EC_CMD_USB_PD_SET_AMODE 0x011735083508+35093509+enum pd_mode_cmd {35103510+ PD_EXIT_MODE = 0,35113511+ PD_ENTER_MODE = 1,35123512+ /* Not a command. Do NOT remove. */35133513+ PD_MODE_CMD_COUNT,35143514+};35153515+35163516+struct ec_params_usb_pd_set_mode_request {35173517+ uint32_t cmd; /* enum pd_mode_cmd */35183518+ uint16_t svid; /* SVID to set */35193519+ uint8_t opos; /* Object Position */35203520+ uint8_t port; /* port */35213521+} __ec_align4;35223522+35233523+/* Ask the PD MCU to record a log of a requested type */35243524+#define EC_CMD_PD_WRITE_LOG_ENTRY 0x011835253525+35263526+struct ec_params_pd_write_log_entry {35273527+ uint8_t type; /* event type : see PD_EVENT_xx above */35283528+ uint8_t port; /* port#, or 0 for events unrelated to a given port */35293529+} __ec_align1;35303530+35313531+35323532+/* Control USB-PD chip */35333533+#define EC_CMD_PD_CONTROL 0x011935343534+35353535+enum ec_pd_control_cmd {35363536+ PD_SUSPEND = 0, /* Suspend the PD chip (EC: stop talking to PD) */35373537+ PD_RESUME, /* Resume the PD chip (EC: start talking to PD) */35383538+ PD_RESET, /* Force reset the PD chip */35393539+ PD_CONTROL_DISABLE, /* Disable further calls to this command */35403540+ PD_CHIP_ON, /* Power on the PD chip */35413541+};35423542+35433543+struct ec_params_pd_control {35443544+ uint8_t chip; /* chip id */35453545+ uint8_t subcmd;35463546+} __ec_align1;35473547+49933548/* Get info about USB-C SS muxes */49944994-#define EC_CMD_USB_PD_MUX_INFO 0x11a35493549+#define EC_CMD_USB_PD_MUX_INFO 0x011A4995355049963551struct ec_params_usb_pd_mux_info {49973552 uint8_t port; /* USB-C port number */49984998-} __packed;35533553+} __ec_align1;4999355450003555/* Flags representing mux state */50015001-#define USB_PD_MUX_USB_ENABLED (1 << 0)50025002-#define USB_PD_MUX_DP_ENABLED (1 << 1)50035003-#define USB_PD_MUX_POLARITY_INVERTED (1 << 2)50045004-#define USB_PD_MUX_HPD_IRQ (1 << 3)35563556+#define USB_PD_MUX_USB_ENABLED BIT(0) /* USB connected */35573557+#define USB_PD_MUX_DP_ENABLED BIT(1) /* DP connected */35583558+#define USB_PD_MUX_POLARITY_INVERTED BIT(2) /* CC line Polarity inverted */35593559+#define USB_PD_MUX_HPD_IRQ BIT(3) /* HPD IRQ is asserted */35603560+#define USB_PD_MUX_HPD_LVL BIT(4) /* HPD level is asserted */5005356150063562struct ec_response_usb_pd_mux_info {50073563 uint8_t flags; /* USB_PD_MUX_*-encoded USB mux state */50085008-} __packed;35643564+} __ec_align1;35653565+35663566+#define EC_CMD_PD_CHIP_INFO 0x011B35673567+35683568+struct ec_params_pd_chip_info {35693569+ uint8_t port; /* USB-C port number */35703570+ uint8_t renew; /* Force renewal */35713571+} __ec_align1;35723572+35733573+struct ec_response_pd_chip_info {35743574+ uint16_t vendor_id;35753575+ uint16_t product_id;35763576+ uint16_t device_id;35773577+ union {35783578+ uint8_t fw_version_string[8];35793579+ uint64_t fw_version_number;35803580+ };35813581+} __ec_align2;35823582+35833583+struct ec_response_pd_chip_info_v1 {35843584+ uint16_t vendor_id;35853585+ uint16_t product_id;35863586+ uint16_t device_id;35873587+ union {35883588+ uint8_t fw_version_string[8];35893589+ uint64_t fw_version_number;35903590+ };35913591+ union {35923592+ uint8_t min_req_fw_version_string[8];35933593+ uint64_t min_req_fw_version_number;35943594+ };35953595+} __ec_align2;35963596+35973597+/* Run RW signature verification and get status */35983598+#define EC_CMD_RWSIG_CHECK_STATUS 0x011C35993599+36003600+struct ec_response_rwsig_check_status {36013601+ uint32_t status;36023602+} __ec_align4;36033603+36043604+/* For controlling RWSIG task */36053605+#define EC_CMD_RWSIG_ACTION 0x011D36063606+36073607+enum rwsig_action {36083608+ RWSIG_ACTION_ABORT = 0, /* Abort RWSIG and prevent jumping */36093609+ RWSIG_ACTION_CONTINUE = 1, /* Jump to RW immediately */36103610+};36113611+36123612+struct ec_params_rwsig_action {36133613+ uint32_t action;36143614+} __ec_align4;36153615+36163616+/* Run verification on a slot */36173617+#define EC_CMD_EFS_VERIFY 0x011E36183618+36193619+struct ec_params_efs_verify {36203620+ uint8_t region; /* enum ec_flash_region */36213621+} __ec_align1;36223622+36233623+/*36243624+ * Retrieve info from Cros Board Info store. Response is based on the data36253625+ * type. Integers return a uint32. Strings return a string, using the response36263626+ * size to determine how big it is.36273627+ */36283628+#define EC_CMD_GET_CROS_BOARD_INFO 0x011F36293629+/*36303630+ * Write info into Cros Board Info on EEPROM. Write fails if the board has36313631+ * hardware write-protect enabled.36323632+ */36333633+#define EC_CMD_SET_CROS_BOARD_INFO 0x012036343634+36353635+enum cbi_data_tag {36363636+ CBI_TAG_BOARD_VERSION = 0, /* uint32_t or smaller */36373637+ CBI_TAG_OEM_ID = 1, /* uint32_t or smaller */36383638+ CBI_TAG_SKU_ID = 2, /* uint32_t or smaller */36393639+ CBI_TAG_DRAM_PART_NUM = 3, /* variable length ascii, nul terminated. */36403640+ CBI_TAG_OEM_NAME = 4, /* variable length ascii, nul terminated. */36413641+ CBI_TAG_MODEL_ID = 5, /* uint32_t or smaller */36423642+ CBI_TAG_COUNT,36433643+};36443644+36453645+/*36463646+ * Flags to control read operation36473647+ *36483648+ * RELOAD: Invalidate cache and read data from EEPROM. Useful to verify36493649+ * write was successful without reboot.36503650+ */36513651+#define CBI_GET_RELOAD BIT(0)36523652+36533653+struct ec_params_get_cbi {36543654+ uint32_t tag; /* enum cbi_data_tag */36553655+ uint32_t flag; /* CBI_GET_* */36563656+} __ec_align4;36573657+36583658+/*36593659+ * Flags to control write behavior.36603660+ *36613661+ * NO_SYNC: Makes EC update data in RAM but skip writing to EEPROM. It's36623662+ * useful when writing multiple fields in a row.36633663+ * INIT: Need to be set when creating a new CBI from scratch. All fields36643664+ * will be initialized to zero first.36653665+ */36663666+#define CBI_SET_NO_SYNC BIT(0)36673667+#define CBI_SET_INIT BIT(1)36683668+36693669+struct ec_params_set_cbi {36703670+ uint32_t tag; /* enum cbi_data_tag */36713671+ uint32_t flag; /* CBI_SET_* */36723672+ uint32_t size; /* Data size */36733673+ uint8_t data[]; /* For string and raw data */36743674+} __ec_align1;36753675+36763676+/*36773677+ * Information about resets of the AP by the EC and the EC's own uptime.36783678+ */36793679+#define EC_CMD_GET_UPTIME_INFO 0x012136803680+36813681+struct ec_response_uptime_info {36823682+ /*36833683+ * Number of milliseconds since the last EC boot. Sysjump resets36843684+ * typically do not restart the EC's time_since_boot epoch.36853685+ *36863686+ * WARNING: The EC's sense of time is much less accurate than the AP's36873687+ * sense of time, in both phase and frequency. This timebase is similar36883688+ * to CLOCK_MONOTONIC_RAW, but with 1% or more frequency error.36893689+ */36903690+ uint32_t time_since_ec_boot_ms;36913691+36923692+ /*36933693+ * Number of times the AP was reset by the EC since the last EC boot.36943694+ * Note that the AP may be held in reset by the EC during the initial36953695+ * boot sequence, such that the very first AP boot may count as more36963696+ * than one here.36973697+ */36983698+ uint32_t ap_resets_since_ec_boot;36993699+37003700+ /*37013701+ * The set of flags which describe the EC's most recent reset. See37023702+ * include/system.h RESET_FLAG_* for details.37033703+ */37043704+ uint32_t ec_reset_flags;37053705+37063706+ /* Empty log entries have both the cause and timestamp set to zero. */37073707+ struct ap_reset_log_entry {37083708+ /*37093709+ * See include/chipset.h: enum chipset_{reset,shutdown}_reason37103710+ * for details.37113711+ */37123712+ uint16_t reset_cause;37133713+37143714+ /* Reserved for protocol growth. */37153715+ uint16_t reserved;37163716+37173717+ /*37183718+ * The time of the reset's assertion, in milliseconds since the37193719+ * last EC boot, in the same epoch as time_since_ec_boot_ms.37203720+ * Set to zero if the log entry is empty.37213721+ */37223722+ uint32_t reset_time_ms;37233723+ } recent_ap_reset[4];37243724+} __ec_align4;37253725+37263726+/*37273727+ * Add entropy to the device secret (stored in the rollback region).37283728+ *37293729+ * Depending on the chip, the operation may take a long time (e.g. to erase37303730+ * flash), so the commands are asynchronous.37313731+ */37323732+#define EC_CMD_ADD_ENTROPY 0x012237333733+37343734+enum add_entropy_action {37353735+ /* Add entropy to the current secret. */37363736+ ADD_ENTROPY_ASYNC = 0,37373737+ /*37383738+ * Add entropy, and also make sure that the previous secret is erased.37393739+ * (this can be implemented by adding entropy multiple times until37403740+ * all rolback blocks have been overwritten).37413741+ */37423742+ ADD_ENTROPY_RESET_ASYNC = 1,37433743+ /* Read back result from the previous operation. */37443744+ ADD_ENTROPY_GET_RESULT = 2,37453745+};37463746+37473747+struct ec_params_rollback_add_entropy {37483748+ uint8_t action;37493749+} __ec_align1;37503750+37513751+/*37523752+ * Perform a single read of a given ADC channel.37533753+ */37543754+#define EC_CMD_ADC_READ 0x012337553755+37563756+struct ec_params_adc_read {37573757+ uint8_t adc_channel;37583758+} __ec_align1;37593759+37603760+struct ec_response_adc_read {37613761+ int32_t adc_value;37623762+} __ec_align4;37633763+37643764+/*37653765+ * Read back rollback info37663766+ */37673767+#define EC_CMD_ROLLBACK_INFO 0x012437683768+37693769+struct ec_response_rollback_info {37703770+ int32_t id; /* Incrementing number to indicate which region to use. */37713771+ int32_t rollback_min_version;37723772+ int32_t rw_rollback_version;37733773+} __ec_align4;37743774+37753775+37763776+/* Issue AP reset */37773777+#define EC_CMD_AP_RESET 0x012537783778+37793779+/*****************************************************************************/37803780+/* The command range 0x200-0x2FF is reserved for Rotor. */37813781+37823782+/*****************************************************************************/37833783+/*37843784+ * Reserve a range of host commands for the CR51 firmware.37853785+ */37863786+#define EC_CMD_CR51_BASE 0x030037873787+#define EC_CMD_CR51_LAST 0x03FF37883788+37893789+/*****************************************************************************/37903790+/* Fingerprint MCU commands: range 0x0400-0x040x */37913791+37923792+/* Fingerprint SPI sensor passthru command: prototyping ONLY */37933793+#define EC_CMD_FP_PASSTHRU 0x040037943794+37953795+#define EC_FP_FLAG_NOT_COMPLETE 0x137963796+37973797+struct ec_params_fp_passthru {37983798+ uint16_t len; /* Number of bytes to write then read */37993799+ uint16_t flags; /* EC_FP_FLAG_xxx */38003800+ uint8_t data[]; /* Data to send */38013801+} __ec_align2;38023802+38033803+/* Configure the Fingerprint MCU behavior */38043804+#define EC_CMD_FP_MODE 0x040238053805+38063806+/* Put the sensor in its lowest power mode */38073807+#define FP_MODE_DEEPSLEEP BIT(0)38083808+/* Wait to see a finger on the sensor */38093809+#define FP_MODE_FINGER_DOWN BIT(1)38103810+/* Poll until the finger has left the sensor */38113811+#define FP_MODE_FINGER_UP BIT(2)38123812+/* Capture the current finger image */38133813+#define FP_MODE_CAPTURE BIT(3)38143814+/* Finger enrollment session on-going */38153815+#define FP_MODE_ENROLL_SESSION BIT(4)38163816+/* Enroll the current finger image */38173817+#define FP_MODE_ENROLL_IMAGE BIT(5)38183818+/* Try to match the current finger image */38193819+#define FP_MODE_MATCH BIT(6)38203820+/* Reset and re-initialize the sensor. */38213821+#define FP_MODE_RESET_SENSOR BIT(7)38223822+/* special value: don't change anything just read back current mode */38233823+#define FP_MODE_DONT_CHANGE BIT(31)38243824+38253825+#define FP_VALID_MODES (FP_MODE_DEEPSLEEP | \38263826+ FP_MODE_FINGER_DOWN | \38273827+ FP_MODE_FINGER_UP | \38283828+ FP_MODE_CAPTURE | \38293829+ FP_MODE_ENROLL_SESSION | \38303830+ FP_MODE_ENROLL_IMAGE | \38313831+ FP_MODE_MATCH | \38323832+ FP_MODE_RESET_SENSOR | \38333833+ FP_MODE_DONT_CHANGE)38343834+38353835+/* Capture types defined in bits [30..28] */38363836+#define FP_MODE_CAPTURE_TYPE_SHIFT 2838373837+#define FP_MODE_CAPTURE_TYPE_MASK (0x7 << FP_MODE_CAPTURE_TYPE_SHIFT)38383838+/*38393839+ * This enum must remain ordered, if you add new values you must ensure that38403840+ * FP_CAPTURE_TYPE_MAX is still the last one.38413841+ */38423842+enum fp_capture_type {38433843+ /* Full blown vendor-defined capture (produces 'frame_size' bytes) */38443844+ FP_CAPTURE_VENDOR_FORMAT = 0,38453845+ /* Simple raw image capture (produces width x height x bpp bits) */38463846+ FP_CAPTURE_SIMPLE_IMAGE = 1,38473847+ /* Self test pattern (e.g. checkerboard) */38483848+ FP_CAPTURE_PATTERN0 = 2,38493849+ /* Self test pattern (e.g. inverted checkerboard) */38503850+ FP_CAPTURE_PATTERN1 = 3,38513851+ /* Capture for Quality test with fixed contrast */38523852+ FP_CAPTURE_QUALITY_TEST = 4,38533853+ /* Capture for pixel reset value test */38543854+ FP_CAPTURE_RESET_TEST = 5,38553855+ FP_CAPTURE_TYPE_MAX,38563856+};38573857+/* Extracts the capture type from the sensor 'mode' word */38583858+#define FP_CAPTURE_TYPE(mode) (((mode) & FP_MODE_CAPTURE_TYPE_MASK) \38593859+ >> FP_MODE_CAPTURE_TYPE_SHIFT)38603860+38613861+struct ec_params_fp_mode {38623862+ uint32_t mode; /* as defined by FP_MODE_ constants */38633863+} __ec_align4;38643864+38653865+struct ec_response_fp_mode {38663866+ uint32_t mode; /* as defined by FP_MODE_ constants */38673867+} __ec_align4;38683868+38693869+/* Retrieve Fingerprint sensor information */38703870+#define EC_CMD_FP_INFO 0x040338713871+38723872+/* Number of dead pixels detected on the last maintenance */38733873+#define FP_ERROR_DEAD_PIXELS(errors) ((errors) & 0x3FF)38743874+/* Unknown number of dead pixels detected on the last maintenance */38753875+#define FP_ERROR_DEAD_PIXELS_UNKNOWN (0x3FF)38763876+/* No interrupt from the sensor */38773877+#define FP_ERROR_NO_IRQ BIT(12)38783878+/* SPI communication error */38793879+#define FP_ERROR_SPI_COMM BIT(13)38803880+/* Invalid sensor Hardware ID */38813881+#define FP_ERROR_BAD_HWID BIT(14)38823882+/* Sensor initialization failed */38833883+#define FP_ERROR_INIT_FAIL BIT(15)38843884+38853885+struct ec_response_fp_info_v0 {38863886+ /* Sensor identification */38873887+ uint32_t vendor_id;38883888+ uint32_t product_id;38893889+ uint32_t model_id;38903890+ uint32_t version;38913891+ /* Image frame characteristics */38923892+ uint32_t frame_size;38933893+ uint32_t pixel_format; /* using V4L2_PIX_FMT_ */38943894+ uint16_t width;38953895+ uint16_t height;38963896+ uint16_t bpp;38973897+ uint16_t errors; /* see FP_ERROR_ flags above */38983898+} __ec_align4;38993899+39003900+struct ec_response_fp_info {39013901+ /* Sensor identification */39023902+ uint32_t vendor_id;39033903+ uint32_t product_id;39043904+ uint32_t model_id;39053905+ uint32_t version;39063906+ /* Image frame characteristics */39073907+ uint32_t frame_size;39083908+ uint32_t pixel_format; /* using V4L2_PIX_FMT_ */39093909+ uint16_t width;39103910+ uint16_t height;39113911+ uint16_t bpp;39123912+ uint16_t errors; /* see FP_ERROR_ flags above */39133913+ /* Template/finger current information */39143914+ uint32_t template_size; /* max template size in bytes */39153915+ uint16_t template_max; /* maximum number of fingers/templates */39163916+ uint16_t template_valid; /* number of valid fingers/templates */39173917+ uint32_t template_dirty; /* bitmap of templates with MCU side changes */39183918+ uint32_t template_version; /* version of the template format */39193919+} __ec_align4;39203920+39213921+/* Get the last captured finger frame or a template content */39223922+#define EC_CMD_FP_FRAME 0x040439233923+39243924+/* constants defining the 'offset' field which also contains the frame index */39253925+#define FP_FRAME_INDEX_SHIFT 2839263926+/* Frame buffer where the captured image is stored */39273927+#define FP_FRAME_INDEX_RAW_IMAGE 039283928+/* First frame buffer holding a template */39293929+#define FP_FRAME_INDEX_TEMPLATE 139303930+#define FP_FRAME_GET_BUFFER_INDEX(offset) ((offset) >> FP_FRAME_INDEX_SHIFT)39313931+#define FP_FRAME_OFFSET_MASK 0x0FFFFFFF39323932+39333933+/* Version of the format of the encrypted templates. */39343934+#define FP_TEMPLATE_FORMAT_VERSION 339353935+39363936+/* Constants for encryption parameters */39373937+#define FP_CONTEXT_NONCE_BYTES 1239383938+#define FP_CONTEXT_USERID_WORDS (32 / sizeof(uint32_t))39393939+#define FP_CONTEXT_TAG_BYTES 1639403940+#define FP_CONTEXT_SALT_BYTES 1639413941+#define FP_CONTEXT_TPM_BYTES 3239423942+39433943+struct ec_fp_template_encryption_metadata {39443944+ /*39453945+ * Version of the structure format (N=3).39463946+ */39473947+ uint16_t struct_version;39483948+ /* Reserved bytes, set to 0. */39493949+ uint16_t reserved;39503950+ /*39513951+ * The salt is *only* ever used for key derivation. The nonce is unique,39523952+ * a different one is used for every message.39533953+ */39543954+ uint8_t nonce[FP_CONTEXT_NONCE_BYTES];39553955+ uint8_t salt[FP_CONTEXT_SALT_BYTES];39563956+ uint8_t tag[FP_CONTEXT_TAG_BYTES];39573957+};39583958+39593959+struct ec_params_fp_frame {39603960+ /*39613961+ * The offset contains the template index or FP_FRAME_INDEX_RAW_IMAGE39623962+ * in the high nibble, and the real offset within the frame in39633963+ * FP_FRAME_OFFSET_MASK.39643964+ */39653965+ uint32_t offset;39663966+ uint32_t size;39673967+} __ec_align4;39683968+39693969+/* Load a template into the MCU */39703970+#define EC_CMD_FP_TEMPLATE 0x040539713971+39723972+/* Flag in the 'size' field indicating that the full template has been sent */39733973+#define FP_TEMPLATE_COMMIT 0x8000000039743974+39753975+struct ec_params_fp_template {39763976+ uint32_t offset;39773977+ uint32_t size;39783978+ uint8_t data[];39793979+} __ec_align4;39803980+39813981+/* Clear the current fingerprint user context and set a new one */39823982+#define EC_CMD_FP_CONTEXT 0x040639833983+39843984+struct ec_params_fp_context {39853985+ uint32_t userid[FP_CONTEXT_USERID_WORDS];39863986+} __ec_align4;39873987+39883988+#define EC_CMD_FP_STATS 0x040739893989+39903990+#define FPSTATS_CAPTURE_INV BIT(0)39913991+#define FPSTATS_MATCHING_INV BIT(1)39923992+39933993+struct ec_response_fp_stats {39943994+ uint32_t capture_time_us;39953995+ uint32_t matching_time_us;39963996+ uint32_t overall_time_us;39973997+ struct {39983998+ uint32_t lo;39993999+ uint32_t hi;40004000+ } overall_t0;40014001+ uint8_t timestamps_invalid;40024002+ int8_t template_matched;40034003+} __ec_align2;40044004+40054005+#define EC_CMD_FP_SEED 0x040840064006+struct ec_params_fp_seed {40074007+ /*40084008+ * Version of the structure format (N=3).40094009+ */40104010+ uint16_t struct_version;40114011+ /* Reserved bytes, set to 0. */40124012+ uint16_t reserved;40134013+ /* Seed from the TPM. */40144014+ uint8_t seed[FP_CONTEXT_TPM_BYTES];40154015+} __ec_align4;40164016+40174017+/*****************************************************************************/40184018+/* Touchpad MCU commands: range 0x0500-0x05FF */40194019+40204020+/* Perform touchpad self test */40214021+#define EC_CMD_TP_SELF_TEST 0x050040224022+40234023+/* Get number of frame types, and the size of each type */40244024+#define EC_CMD_TP_FRAME_INFO 0x050140254025+40264026+struct ec_response_tp_frame_info {40274027+ uint32_t n_frames;40284028+ uint32_t frame_sizes[0];40294029+} __ec_align4;40304030+40314031+/* Create a snapshot of current frame readings */40324032+#define EC_CMD_TP_FRAME_SNAPSHOT 0x050240334033+40344034+/* Read the frame */40354035+#define EC_CMD_TP_FRAME_GET 0x050340364036+40374037+struct ec_params_tp_frame_get {40384038+ uint32_t frame_index;40394039+ uint32_t offset;40404040+ uint32_t size;40414041+} __ec_align4;40424042+40434043+/*****************************************************************************/40444044+/* EC-EC communication commands: range 0x0600-0x06FF */40454045+40464046+#define EC_COMM_TEXT_MAX 840474047+40484048+/*40494049+ * Get battery static information, i.e. information that never changes, or40504050+ * very infrequently.40514051+ */40524052+#define EC_CMD_BATTERY_GET_STATIC 0x060040534053+40544054+/**40554055+ * struct ec_params_battery_static_info - Battery static info parameters40564056+ * @index: Battery index.40574057+ */40584058+struct ec_params_battery_static_info {40594059+ uint8_t index;40604060+} __ec_align_size1;40614061+40624062+/**40634063+ * struct ec_response_battery_static_info - Battery static info response40644064+ * @design_capacity: Battery Design Capacity (mAh)40654065+ * @design_voltage: Battery Design Voltage (mV)40664066+ * @manufacturer: Battery Manufacturer String40674067+ * @model: Battery Model Number String40684068+ * @serial: Battery Serial Number String40694069+ * @type: Battery Type String40704070+ * @cycle_count: Battery Cycle Count40714071+ */40724072+struct ec_response_battery_static_info {40734073+ uint16_t design_capacity;40744074+ uint16_t design_voltage;40754075+ char manufacturer[EC_COMM_TEXT_MAX];40764076+ char model[EC_COMM_TEXT_MAX];40774077+ char serial[EC_COMM_TEXT_MAX];40784078+ char type[EC_COMM_TEXT_MAX];40794079+ /* TODO(crbug.com/795991): Consider moving to dynamic structure. */40804080+ uint32_t cycle_count;40814081+} __ec_align4;40824082+40834083+/*40844084+ * Get battery dynamic information, i.e. information that is likely to change40854085+ * every time it is read.40864086+ */40874087+#define EC_CMD_BATTERY_GET_DYNAMIC 0x060140884088+40894089+/**40904090+ * struct ec_params_battery_dynamic_info - Battery dynamic info parameters40914091+ * @index: Battery index.40924092+ */40934093+struct ec_params_battery_dynamic_info {40944094+ uint8_t index;40954095+} __ec_align_size1;40964096+40974097+/**40984098+ * struct ec_response_battery_dynamic_info - Battery dynamic info response40994099+ * @actual_voltage: Battery voltage (mV)41004100+ * @actual_current: Battery current (mA); negative=discharging41014101+ * @remaining_capacity: Remaining capacity (mAh)41024102+ * @full_capacity: Capacity (mAh, might change occasionally)41034103+ * @flags: Flags, see EC_BATT_FLAG_*41044104+ * @desired_voltage: Charging voltage desired by battery (mV)41054105+ * @desired_current: Charging current desired by battery (mA)41064106+ */41074107+struct ec_response_battery_dynamic_info {41084108+ int16_t actual_voltage;41094109+ int16_t actual_current;41104110+ int16_t remaining_capacity;41114111+ int16_t full_capacity;41124112+ int16_t flags;41134113+ int16_t desired_voltage;41144114+ int16_t desired_current;41154115+} __ec_align2;41164116+41174117+/*41184118+ * Control charger chip. Used to control charger chip on the slave.41194119+ */41204120+#define EC_CMD_CHARGER_CONTROL 0x060241214121+41224122+/**41234123+ * struct ec_params_charger_control - Charger control parameters41244124+ * @max_current: Charger current (mA). Positive to allow base to draw up to41254125+ * max_current and (possibly) charge battery, negative to request current41264126+ * from base (OTG).41274127+ * @otg_voltage: Voltage (mV) to use in OTG mode, ignored if max_current is41284128+ * >= 0.41294129+ * @allow_charging: Allow base battery charging (only makes sense if41304130+ * max_current > 0).41314131+ */41324132+struct ec_params_charger_control {41334133+ int16_t max_current;41344134+ uint16_t otg_voltage;41354135+ uint8_t allow_charging;41364136+} __ec_align_size1;41374137+41384138+/*****************************************************************************/41394139+/*41404140+ * Reserve a range of host commands for board-specific, experimental, or41414141+ * special purpose features. These can be (re)used without updating this file.41424142+ *41434143+ * CAUTION: Don't go nuts with this. Shipping products should document ALL41444144+ * their EC commands for easier development, testing, debugging, and support.41454145+ *41464146+ * All commands MUST be #defined to be 4-digit UPPER CASE hex values41474147+ * (e.g., 0x00AB, not 0xab) for CONFIG_HOSTCMD_SECTION_SORTED to work.41484148+ *41494149+ * In your experimental code, you may want to do something like this:41504150+ *41514151+ * #define EC_CMD_MAGIC_FOO 0x000041524152+ * #define EC_CMD_MAGIC_BAR 0x000141534153+ * #define EC_CMD_MAGIC_HEY 0x000241544154+ *41554155+ * DECLARE_PRIVATE_HOST_COMMAND(EC_CMD_MAGIC_FOO, magic_foo_handler,41564156+ * EC_VER_MASK(0);41574157+ *41584158+ * DECLARE_PRIVATE_HOST_COMMAND(EC_CMD_MAGIC_BAR, magic_bar_handler,41594159+ * EC_VER_MASK(0);41604160+ *41614161+ * DECLARE_PRIVATE_HOST_COMMAND(EC_CMD_MAGIC_HEY, magic_hey_handler,41624162+ * EC_VER_MASK(0);41634163+ */41644164+#define EC_CMD_BOARD_SPECIFIC_BASE 0x3E0041654165+#define EC_CMD_BOARD_SPECIFIC_LAST 0x3FFF41664166+41674167+/*41684168+ * Given the private host command offset, calculate the true private host41694169+ * command value.41704170+ */41714171+#define EC_PRIVATE_HOST_COMMAND_VALUE(command) \41724172+ (EC_CMD_BOARD_SPECIFIC_BASE + (command))5009417350104174/*****************************************************************************/50114175/*···57073545#define EC_HOST_PARAM_SIZE EC_PROTO2_MAX_PARAM_SIZE57083546#define EC_LPC_ADDR_OLD_PARAM EC_HOST_CMD_REGION157093547#define EC_OLD_PARAM_SIZE EC_HOST_CMD_REGION_SIZE35483548+35493549+5710355057113551#endif /* __CROS_EC_COMMANDS_H */