Lines Matching +full:cros +full:- +full:ec +full:- +full:spi +full:- +full:pre +full:- +full:delay
2 * Use of this source code is governed by a BSD-style license that can be
6 /* Host communication command constants for Chrome EC */
18 * - CMD is the command code. (defined by EC_CMD_ constants)
19 * - ERR is the error code. (defined by EC_RES_ constants)
20 * - Px is the optional payload.
23 * - S is the checksum which is the sum of all payload bytes.
59 /* The actual block is 0x800-0x8ff, but some BIOSes think it's 0x880-0x8ff
65 /* EC command register bit functions */
67 #define EC_LPC_CMDR_PENDING (1 << 1) /* Write pending to EC */
68 #define EC_LPC_CMDR_BUSY (1 << 2) /* EC is busy processing a command */
79 #define EC_MEMMAP_TEMP_SENSOR 0x00 /* Temp sensors 0x00 - 0x0f */
80 #define EC_MEMMAP_FAN 0x10 /* Fan speeds 0x10 - 0x17 */
81 #define EC_MEMMAP_TEMP_SENSOR_B 0x18 /* More temp sensors 0x18 - 0x1f */
83 #define EC_MEMMAP_ID_VERSION 0x22 /* Version of data in 0x20 - 0x2f */
84 #define EC_MEMMAP_THERMAL_VERSION 0x23 /* Version of data in 0x00 - 0x1f */
85 #define EC_MEMMAP_BATTERY_VERSION 0x24 /* Version of data in 0x40 - 0x7f */
86 #define EC_MEMMAP_SWITCHES_VERSION 0x25 /* Version of data in 0x30 - 0x33 */
87 #define EC_MEMMAP_EVENTS_VERSION 0x26 /* Version of data in 0x34 - 0x3f */
89 /* Unused 0x28 - 0x2f */
91 /* Unused 0x31 - 0x33 */
93 /* Reserve 0x38 - 0x3f for additional host event-related stuff */
109 /* Unused 0x84 - 0x8f */
112 #define EC_MEMMAP_ACC_DATA 0x92 /* Accelerometers data 0x92 - 0x9f */
114 /* 0x94 - 0x99: 1st Accelerometer */
115 /* 0x9a - 0x9f: 2nd Accelerometer */
116 #define EC_MEMMAP_GYRO_DATA 0xa0 /* Gyroscope data 0xa0 - 0xa5 */
117 /* Unused 0xa6 - 0xdf */
121 * limitations of the ACPI protocol. Do not place data in the range 0xe0 - 0xfe
147 * reporting a temperature range of 200K to 454K = -73C to 181C.
161 #define EC_TEMP_SENSOR_DEFAULT (296 - EC_TEMP_SENSOR_OFFSET)
208 * This reads from ACPI memory space on the EC (EC_ACPI_MEM_*).
212 * - Write EC_CMD_ACPI_READ to EC_LPC_ADDR_ACPI_CMD
213 * - Wait for EC_LPC_CMDR_PENDING bit to clear
214 * - Write address to EC_LPC_ADDR_ACPI_DATA
215 * - Wait for EC_LPC_CMDR_DATA bit to set
216 * - Read value from EC_LPC_ADDR_ACPI_DATA
223 * This reads from ACPI memory space on the EC (EC_ACPI_MEM_*).
227 * - Write EC_CMD_ACPI_WRITE to EC_LPC_ADDR_ACPI_CMD
228 * - Wait for EC_LPC_CMDR_PENDING bit to clear
229 * - Write address to EC_LPC_ADDR_ACPI_DATA
230 * - Wait for EC_LPC_CMDR_PENDING bit to clear
231 * - Write value to EC_LPC_ADDR_ACPI_DATA
238 * This enables burst mode on the EC to allow the host to issue several
239 * commands back-to-back. While in this mode, writes to mapped multi-byte
247 * This disables burst mode on the EC and stops preventing EC writes to mapped
248 * multi-byte data.
255 * This clears the lowest-order bit in the currently pending host events, and
256 * sets the result code to the 1-based index of the bit (event 0x00000001 = 1,
266 * Test location; writing value here updates test compliment byte to (0xff -
273 /* Keyboard backlight brightness percent (0 - 100) */
275 /* DPTF Target Fan Duty (0-100, 0xff for auto/none) */
279 * DPTF temp thresholds. Any of the EC's temp sensors can have up to two
283 * as the memory-mapped sensors. The COMMIT register applies those settings.
308 * write 2 to [0x05] -- select temp sensor 2
309 * write 0x7b to [0x06] -- C_TO_K(50) - EC_TEMP_SENSOR_OFFSET
310 * write 0x2 to [0x07] -- enable threshold 0 with this value
311 * write 0x85 to [0x06] -- C_TO_K(60) - EC_TEMP_SENSOR_OFFSET
312 * write 0x3 to [0x07] -- enable threshold 1 with this value
315 * write 2 to [0x05] -- select temp sensor 2
316 * write 0x1 to [0x07] -- disable threshold 1
335 * ACPI addresses 0x20 - 0xff map to EC_MEMMAP offset 0x00 - 0xdf. This data
336 * is read-only from the AP. Added in EC_ACPI_MEM_VERSION 2.
347 * is pre-processed to handle constants but the ASL compiler is unable to
365 * Attributes for EC request and response packets. Just defining __packed
367 * 32-bit aligned, as it should be for all buffers.
374 * the parent structure. This is particularly important if the sub-structure
378 * Also be very careful using __packed - particularly when nesting non-packed
385 * "__packed" - generates inefficient code; all sub-structs must also be packed
387 * "struct [^_]" - all structs should be annotated, except for structs that are
402 * Packed structure which must be under-aligned, because its size is not a
403 * 4-byte multiple. This is sub-optimal because it forces byte-wise access
404 * of all multi-byte fields in it, even though they are themselves aligned.
412 * Packed structure which must be under-aligned, because its offset inside a
413 * parent structure is not a 4-byte multiple.
433 * byte-wise reads.
447 /* EC has written a byte in the data register and host hasn't read it yet */
449 /* Host has written a command/data byte and the EC hasn't read it yet */
451 /* EC is processing a command */
453 /* Last write to EC was a command, not data */
455 /* EC is in burst mode */
465 * EC is busy. This covers both the EC processing a command, and the host has
466 * written a new command but the EC hasn't picked it up yet.
471 /* Host command response codes (16-bit). Note that response codes should be
495 * Host event codes. Note these are 1-based, not 0-based, because ACPI query
496 * EC command uses code 0 to mean "no event pending". We explicitly specify
511 /* Event generated by a device attached to the EC */
517 * EC has finished initializing the host interface. The host can check
519 * determine when the EC is ready to accept subsequent commands.
546 /* EC encountered a panic, triggering a reset */
552 /* EC RTC event occurred */
558 /* EC desires to change state of host-controlled USB mux */
578 * not initialized on the EC, or improperly configured on the host.
583 #define EC_HOST_EVENT_MASK(event_code) (1ULL << ((event_code) - 1))
602 * If EC gets a command and this flag is not set, this is an old-style command.
604 * unknown length. EC must respond with an old-style response (that is,
609 * Args are from EC. Data area at EC_LPC_ADDR_HOST_PARAM contains response.
611 * If EC responds to a command and this flag is not set, this is an old-style
612 * response. Command version is 0 and response data from EC is at
619 * Byte codes returned by EC over SPI interface.
621 * These can be used by the AP to debug the EC interface, and to determine
622 * when the EC is not in a state where it will ever get around to responding
625 * Example of sequence of bytes read from EC for a current good transfer:
626 * 1. - - AP asserts chip select (CS#)
627 * 2. EC_SPI_OLD_READY - AP sends first byte(s) of request
628 * 3. - - EC starts handling CS# interrupt
629 * 4. EC_SPI_RECEIVING - AP sends remaining byte(s) of request
630 * 5. EC_SPI_PROCESSING - EC starts processing request; AP is clocking in
632 * 6. - - EC finishes processing and sets up response
633 * 7. EC_SPI_FRAME_START - AP reads frame byte
634 * 8. (response packet) - AP reads response packet
635 * 9. EC_SPI_PAST_END - Any additional bytes read by AP
636 * 10 - - AP deasserts chip select
637 * 11 - - EC processes CS# interrupt and sets up DMA for
647 * Then the EC found an error in the request, or was not ready for the request
649 * because the EC is unable to tell when the AP is done sending its request.
653 * Framing byte which precedes a response packet from the EC. After sending a
665 * EC is ready to receive, and has ignored the byte sent by the AP. EC expects
672 * EC has started receiving the request from the AP, but hasn't started
677 /* EC has received the entire request from the AP and is processing it. */
681 * EC received bad data from the AP, such as a packet header with an invalid
682 * length. EC will ignore all data until chip select deasserts.
687 * EC received data from the AP before it was ready. That is, the AP asserted
688 * chip select and started clocking data before the EC was ready to receive it.
689 * EC will ignore all data until chip select deasserts.
694 * EC was ready to receive a request from the AP. EC has treated the byte sent
695 * by the AP as part of a request packet, or (for old-style ECs) is processing
703 * Protocol version 2 for I2C and SPI send a request this way:
709 * N+3 8-bit checksum of bytes 0..N+2
716 * M+2 8-bit checksum of bytes 0..M+1
741 * 3+ structs are being used. Usage is bus-dependent.
751 * EC will return EC_RES_INVALID_HEADER if it receives a header with a
777 /* Version 3 response from EC */
802 * Each command is an 16-bit command value. Commands which take params or
806 * communication protocols (I2C, SPI) may add length or checksum headers, but
807 * those are implementation-dependent and not defined here.
809 * All commands MUST be #defined to be 4-digit UPPER CASE hex values
817 * Get protocol version, used to deal with non-backward compatible protocol
827 * Hello. This is a simple command to test the EC is responsive to
850 /* Null-terminated version strings for RO, RW */
853 char reserved[32]; /* Was previously RW-B string */
872 * Response is null-terminated string.
880 /* Null-terminated strings */
894 * Read memory-mapped data.
896 * This is an alternate interface to memory-mapped data for bus protocols
897 * which don't support direct-mapped memory - I2C, SPI, etc.
928 * Check EC communications status (busy). This is needed on i2c/spi but not
929 * on lpc since it has its own out-of-band busy indicator.
948 /* Tell the EC what to send back to us. */
1020 * EC are present.
1038 * The host goes through the EC to access these sensors.
1039 * In addition, the EC may provide composite sensors, like lid angle.
1042 /* The keyboard is controlled by the EC */
1044 /* The AP can use part of the EC flash as persistent storage. */
1046 /* The EC monitors BIOS port 80h, and can return POST codes. */
1059 /* The EC exposes GPIO commands to control/monitor connected devices. */
1061 /* The EC can send i2c messages to downstream devices. */
1072 /* EC can detect when the host hangs. */
1076 /* Another Cros EC device is present downstream of this one */
1086 /* EC decides on USB-C SS mux state, muxes configured by host */
1088 /* EC has RTC feature that can be controlled by host commands */
1096 /* EC has device events support */
1098 /* EC supports the unified wake masks for LPC/eSPI systems */
1103 #define EC_FEATURE_MASK_1(event_code) (1UL << (event_code - 32))
1109 /* Get the board's SKU ID from EC */
1148 /* EC flash erases bits to 0 instead of 1 */
1163 * if they did we'd define the version 0 structure as a sub-structure of this
1169 * The EC returns the number of banks describing the flash memory.
1182 * exactly this and offset is a multiple of this. For example, an EC
1183 * may have a write buffer which can do half-page operations if data is
1184 * aligned, and a slower word-at-a-time write mode.
1202 /* Size in power of 2 of each sector (8 --> 256 bytes) */
1215 /* Total flash in the EC. */
1219 /* Maximum size to use to send data to write to the EC. */
1221 /* Number of banks present in the EC. */
1277 * ERASE_GET_RESULT command may timeout on EC where flash access is not
1311 /* RO flash code protected when the EC boots */
1314 * RO flash code protected now. If this bit is set, at-boot status cannot
1322 /* Error - at least one bank of flash is stuck locked, and cannot be unlocked */
1325 * Error - flash protection is in inconsistent state. At least one bank of
1327 * re-requesting the desired flags, or by a hard reset if that fails.
1330 /* Entire flash code protected when the EC boots */
1332 /* RW flash code protected when the EC boots */
1336 /* Rollback information flash region protected when the EC boots */
1360 * Note: commands 0x14 - 0x19 version 0 were old commands to get/set flash
1369 /* Region which holds read-only EC image */
1371 /* Region which holds active rewritable EC image */
1374 * Region which should be write-protected in the factory (a superset of
1414 /* Get SPI flash information */
1465 /* OBSOLETE - Use EC_CMD_PWM_SET_DUTY */
1474 /* OBSOLETE - Use EC_CMD_PWM_SET_DUTY */
1500 /* All types, indexed by board-specific enum pwm_channel */
1512 uint8_t index; /* Type-specific index, or 0 if unique */
1519 uint8_t index; /* Type-specific index, or 0 if unique */
1567 uint8_t battery_threshold[LB_BATTERY_LEVELS - 1];
1574 struct rgb_s color[8]; /* 0-3 are Google colors */
1594 /* Tap-for-battery params */
1613 uint8_t battery_threshold[LB_BATTERY_LEVELS - 1];
1619 /* s5: single color pulse on inhibited power-up */
1623 struct rgb_s color[8]; /* 0-3 are Google colors */
1654 /* Tap-for-battery params */
1679 uint8_t battery_threshold[LB_BATTERY_LEVELS - 1];
1687 /* s5: single color pulse on inhibited power-up */
1691 struct rgb_s color[8]; /* 0-3 are Google colors */
1840 * May be on power button or on C-panel.
1929 EC_VBOOT_HASH_TYPE_SHA256 = 0, /* SHA-256 */
1940 * If one of these is specified, the EC will automatically update offset and
1949 * Motion sense commands. We'll make separate structs for sub-commands with
1970 * EC Rate command is a setter/getter command for the EC sampling rate
1972 * It is per sensor, the EC run sample task at the minimum of all
1976 * For sensor with hardware FIFO, EC_RATE is used as the maximal delay
1989 * a specified motion sensor in +/-G's or +/- deg/s.
1998 * un-calibrated value, hence the wake angle isn't exact.
2067 /* Number of motionsense sub-commands. */
2110 /* Each sensor is up to 3-axis. */
2159 /* Module flag masks used for the dump sub-command. */
2162 /* Sensor flag masks used for the dump sub-command. */
2176 * send any other value, the EC will interpret it as data to set and will
2179 #define EC_MOTION_SENSE_NO_VALUE -1
2211 * of sensors controlled by the EC.
2240 /* Rounding flag, true for round-up, false for down. */
2255 * the calibration information in the EC.
2286 * EC may return less or 0 if none available.
2329 /* Number of sensors managed directly by the EC */
2491 /* Real-time clock */
2612 /* Version 0 - set */
2619 /* Version 0 - get */
2643 * Note that this structure is a sub-structure of
2652 /* Version 1 - get config for one sensor. */
2658 /* Version 1 - set config for one sensor.
2659 * Use read-modify-write for best results! */
2684 * and how many params it requires. That way we can change the EC code without
2741 /* MKBP - Matrix KeyBoard Protocol */
2842 * Note that this is used as a sub-structure of
2853 * minimum post-scan relax time. Once we finish a scan we check
2858 /* delay between setting up output and waiting for it to settle */
2887 * Indicates this scan was processed by the EC. Due to timing, some
2948 /* The state of the non-matrixed buttons have changed. */
3036 * Note: host commands 0x80 - 0x87 are reserved to avoid conflict with ACPI
3072 * Unified host event programming interface - Should be used by newer versions
3078 /* Action requested by host - one of enum ec_host_event_action. */
3082 * Mask type that the host requested the action on - one of
3179 * Flags to leave enabled in S3, if they're on at the S0->S3
3180 * transition. (Other flags will be disabled by the S0->S3
3199 /* GPIO commands. Only available on EC if write protect has been disabled. */
3257 * CAUTION: These commands are deprecated, and are not supported anymore in EC
3267 uint16_t addr; /* 8-bit address (7-bit shifted << 1) */
3282 uint16_t addr; /* 8-bit address (7-bit shifted << 1) */
3322 * Response is null-terminated string. Empty string, if there is no more
3462 /* Start of AP S3->S0 transition (booting or resuming from suspend) */
3473 /* Stop on end of AP S0->S3 transition (suspending or shutting down) */
3506 * This is the single catch-all host command to exchange data regarding the
3520 * Known param numbers are defined here. Ranges are reserved for board-specific
3527 CS_PARAM_CHG_STATUS, /* charger-specific status */
3528 CS_PARAM_CHG_OPTION, /* charger-specific options */
3617 /* Set the delay before going into hibernation. */
3631 * state. This value is reset if the EC transitions out of G3.
3636 * The current time remaining in seconds until the EC should hibernate.
3637 * This value is also reset if the EC transitions out of G3.
3642 * The current time in seconds that the EC should wait in G3 before
3648 /* Inform the EC when entering a sleep state */
3693 /* Smart battery pass-through */
3695 /* Get / Set 16-bit smart battery registers */
3730 * Get or set vendor-specific parameters in the battery. Implementations may
3815 * Default mode is VBOOT_MODE_NORMAL if EC did not receive this command.
3831 * certain addresses (board-specific).
3854 * necessarily reboot the EC. Rename to "image" or something similar?
3863 /* (command 3 was jump to RW-B) */
3864 EC_REBOOT_COLD = 4, /* Cold-reboot */
3866 EC_REBOOT_HIBERNATE = 6, /* Hibernate EC */
3881 * Get information on last EC panic.
3883 * Returns variable-length platform-dependent panic information. See panic.h
3899 * This command will work even when the EC LPC interface is busy, because the
3900 * reboot command is processed at interrupt level. Note that when the EC
3903 * Use EC_CMD_REBOOT_EC to reboot the EC more politely.
3910 * Returns EC_RES_UNAVAILABLE if there is no response available - for example,
3918 * than this means that we are talking to an old EC which doesn't support
3924 * The old EC interface must not use commands 0xdc or higher.
3935 /* EC to PD MCU exchange status command */
3946 /* Status of EC being sent to PD */
3950 uint8_t status; /* EC status */
3955 /* Status of PD being sent back to EC */
3984 /* Set USB type-C port role and muxes */
4098 /* Write USB-PD device FW */
4116 /* Write USB-PD Accessory RW_HASH table entry */
4118 /* RW hash is first 20 bytes of SHA-256 of RW section */
4129 /* Read USB-PD Accessory info */
4136 /* Read USB-PD Device discovery info */
4139 uint16_t vid; /* USB-IF VID */
4140 uint16_t pid; /* USB-IF PID */
4149 OVERRIDE_DONT_CHARGE = -2,
4150 OVERRIDE_OFF = -1,
4165 uint16_t data; /* type-defined data payload */
4247 /* Get/Set USB-PD Alternate mode info */
4285 /* Control USB-PD chip */
4289 PD_SUSPEND = 0, /* Suspend the PD chip (EC: stop talking to PD) */
4290 PD_RESUME, /* Resume the PD chip (EC: start talking to PD) */
4300 /* Get info about USB-C SS muxes */
4304 uint8_t port; /* USB-C port number */
4314 uint8_t flags; /* USB_PD_MUX_*-encoded USB mux state */
4320 uint8_t port; /* USB-C port number */
4361 * Retrieve info from Cros Board Info store. Response is based on the data
4367 * Write info into Cros Board Info on EEPROM. Write fails if the board has
4368 * hardware write-protect enabled.
4395 * NO_SYNC: Makes EC update data in RAM but skip writing to EEPROM. It's
4411 /* The command range 0x200-0x2FF is reserved for Rotor. */
4421 /* Fingerprint MCU commands: range 0x0400-0x040x */
4423 /* Fingerprint SPI sensor passthru command: prototyping ONLY */
4491 /* Get the last captured finger frame: TODO: will be AES-encrypted */
4500 /* Touchpad MCU commands: range 0x0500-0x05FF */
4527 * Reserve a range of host commands for board-specific, experimental, or
4531 * their EC commands for easier development, testing, debugging, and support.
4533 * All commands MUST be #defined to be 4-digit UPPER CASE hex values
4565 * Some platforms have sub-processors chained to each other. For example.
4567 * AP <--> EC <--> PD MCU
4571 * command; other device mapping is board-specific.
4573 * When a device receives a command to be passed to a sub-processor, it passes
4574 * it on with the device number set back to 0. This allows the sub-processor
4579 * AP sends command 0x4002 to the EC
4580 * EC sends command 0x0002 to the PD MCU
4581 * EC forwards PD MCU response back to the AP
4584 /* Offset and max command number for sub-device n */