diff options
| -rw-r--r-- | drivers/mfd/cros_ec_dev.h | 13 | ||||
| -rw-r--r-- | drivers/platform/chrome/chromeos_tbmc.c | 2 | ||||
| -rw-r--r-- | drivers/platform/chrome/cros_ec_lpc.c | 18 | ||||
| -rw-r--r-- | drivers/platform/chrome/cros_ec_lpc_mec.c | 3 | ||||
| -rw-r--r-- | drivers/platform/chrome/cros_ec_lpc_mec.h (renamed from include/linux/mfd/cros_ec_lpc_mec.h) | 6 | ||||
| -rw-r--r-- | drivers/platform/chrome/cros_ec_lpc_reg.c | 3 | ||||
| -rw-r--r-- | drivers/platform/chrome/cros_ec_lpc_reg.h (renamed from include/linux/mfd/cros_ec_lpc_reg.h) | 6 | ||||
| -rw-r--r-- | include/linux/mfd/cros_ec.h | 214 | ||||
| -rw-r--r-- | include/linux/mfd/cros_ec_commands.h | 295 |
9 files changed, 337 insertions, 223 deletions
diff --git a/drivers/mfd/cros_ec_dev.h b/drivers/mfd/cros_ec_dev.h index 45e9453608c5..978d836a0248 100644 --- a/drivers/mfd/cros_ec_dev.h +++ b/drivers/mfd/cros_ec_dev.h | |||
| @@ -26,12 +26,13 @@ | |||
| 26 | 26 | ||
| 27 | #define CROS_EC_DEV_VERSION "1.0.0" | 27 | #define CROS_EC_DEV_VERSION "1.0.0" |
| 28 | 28 | ||
| 29 | /* | 29 | /** |
| 30 | * @offset: within EC_LPC_ADDR_MEMMAP region | 30 | * struct cros_ec_readmem - Struct used to read mapped memory. |
| 31 | * @bytes: number of bytes to read. zero means "read a string" (including '\0') | 31 | * @offset: Within EC_LPC_ADDR_MEMMAP region. |
| 32 | * (at most only EC_MEMMAP_SIZE bytes can be read) | 32 | * @bytes: Number of bytes to read. Zero means "read a string" (including '\0') |
| 33 | * @buffer: where to store the result | 33 | * At most only EC_MEMMAP_SIZE bytes can be read. |
| 34 | * ioctl returns the number of bytes read, negative on error | 34 | * @buffer: Where to store the result. The ioctl returns the number of bytes |
| 35 | * read or negative on error. | ||
| 35 | */ | 36 | */ |
| 36 | struct cros_ec_readmem { | 37 | struct cros_ec_readmem { |
| 37 | uint32_t offset; | 38 | uint32_t offset; |
diff --git a/drivers/platform/chrome/chromeos_tbmc.c b/drivers/platform/chrome/chromeos_tbmc.c index 1e81f8144c0d..ce259ec9f990 100644 --- a/drivers/platform/chrome/chromeos_tbmc.c +++ b/drivers/platform/chrome/chromeos_tbmc.c | |||
| @@ -99,7 +99,7 @@ static const struct acpi_device_id chromeos_tbmc_acpi_device_ids[] = { | |||
| 99 | }; | 99 | }; |
| 100 | MODULE_DEVICE_TABLE(acpi, chromeos_tbmc_acpi_device_ids); | 100 | MODULE_DEVICE_TABLE(acpi, chromeos_tbmc_acpi_device_ids); |
| 101 | 101 | ||
| 102 | static const SIMPLE_DEV_PM_OPS(chromeos_tbmc_pm_ops, NULL, | 102 | static SIMPLE_DEV_PM_OPS(chromeos_tbmc_pm_ops, NULL, |
| 103 | chromeos_tbmc_resume); | 103 | chromeos_tbmc_resume); |
| 104 | 104 | ||
| 105 | static struct acpi_driver chromeos_tbmc_driver = { | 105 | static struct acpi_driver chromeos_tbmc_driver = { |
diff --git a/drivers/platform/chrome/cros_ec_lpc.c b/drivers/platform/chrome/cros_ec_lpc.c index 31c8b8c49e45..e1b75775cd4a 100644 --- a/drivers/platform/chrome/cros_ec_lpc.c +++ b/drivers/platform/chrome/cros_ec_lpc.c | |||
| @@ -25,14 +25,16 @@ | |||
| 25 | #include <linux/dmi.h> | 25 | #include <linux/dmi.h> |
| 26 | #include <linux/delay.h> | 26 | #include <linux/delay.h> |
| 27 | #include <linux/io.h> | 27 | #include <linux/io.h> |
| 28 | #include <linux/interrupt.h> | ||
| 28 | #include <linux/mfd/cros_ec.h> | 29 | #include <linux/mfd/cros_ec.h> |
| 29 | #include <linux/mfd/cros_ec_commands.h> | 30 | #include <linux/mfd/cros_ec_commands.h> |
| 30 | #include <linux/mfd/cros_ec_lpc_reg.h> | ||
| 31 | #include <linux/module.h> | 31 | #include <linux/module.h> |
| 32 | #include <linux/platform_device.h> | 32 | #include <linux/platform_device.h> |
| 33 | #include <linux/printk.h> | 33 | #include <linux/printk.h> |
| 34 | #include <linux/suspend.h> | 34 | #include <linux/suspend.h> |
| 35 | 35 | ||
| 36 | #include "cros_ec_lpc_reg.h" | ||
| 37 | |||
| 36 | #define DRV_NAME "cros_ec_lpcs" | 38 | #define DRV_NAME "cros_ec_lpcs" |
| 37 | #define ACPI_DRV_NAME "GOOG0004" | 39 | #define ACPI_DRV_NAME "GOOG0004" |
| 38 | 40 | ||
| @@ -248,7 +250,7 @@ static int cros_ec_lpc_probe(struct platform_device *pdev) | |||
| 248 | acpi_status status; | 250 | acpi_status status; |
| 249 | struct cros_ec_device *ec_dev; | 251 | struct cros_ec_device *ec_dev; |
| 250 | u8 buf[2]; | 252 | u8 buf[2]; |
| 251 | int ret; | 253 | int irq, ret; |
| 252 | 254 | ||
| 253 | if (!devm_request_region(dev, EC_LPC_ADDR_MEMMAP, EC_MEMMAP_SIZE, | 255 | if (!devm_request_region(dev, EC_LPC_ADDR_MEMMAP, EC_MEMMAP_SIZE, |
| 254 | dev_name(dev))) { | 256 | dev_name(dev))) { |
| @@ -287,6 +289,18 @@ static int cros_ec_lpc_probe(struct platform_device *pdev) | |||
| 287 | sizeof(struct ec_response_get_protocol_info); | 289 | sizeof(struct ec_response_get_protocol_info); |
| 288 | ec_dev->dout_size = sizeof(struct ec_host_request); | 290 | ec_dev->dout_size = sizeof(struct ec_host_request); |
| 289 | 291 | ||
| 292 | /* | ||
| 293 | * Some boards do not have an IRQ allotted for cros_ec_lpc, | ||
| 294 | * which makes ENXIO an expected (and safe) scenario. | ||
| 295 | */ | ||
| 296 | irq = platform_get_irq(pdev, 0); | ||
| 297 | if (irq > 0) | ||
| 298 | ec_dev->irq = irq; | ||
| 299 | else if (irq != -ENXIO) { | ||
| 300 | dev_err(dev, "couldn't retrieve IRQ number (%d)\n", irq); | ||
| 301 | return irq; | ||
| 302 | } | ||
| 303 | |||
| 290 | ret = cros_ec_register(ec_dev); | 304 | ret = cros_ec_register(ec_dev); |
| 291 | if (ret) { | 305 | if (ret) { |
| 292 | dev_err(dev, "couldn't register ec_dev (%d)\n", ret); | 306 | dev_err(dev, "couldn't register ec_dev (%d)\n", ret); |
diff --git a/drivers/platform/chrome/cros_ec_lpc_mec.c b/drivers/platform/chrome/cros_ec_lpc_mec.c index 2eda2c2fc210..c4edfa83e493 100644 --- a/drivers/platform/chrome/cros_ec_lpc_mec.c +++ b/drivers/platform/chrome/cros_ec_lpc_mec.c | |||
| @@ -24,10 +24,11 @@ | |||
| 24 | #include <linux/delay.h> | 24 | #include <linux/delay.h> |
| 25 | #include <linux/io.h> | 25 | #include <linux/io.h> |
| 26 | #include <linux/mfd/cros_ec_commands.h> | 26 | #include <linux/mfd/cros_ec_commands.h> |
| 27 | #include <linux/mfd/cros_ec_lpc_mec.h> | ||
| 28 | #include <linux/mutex.h> | 27 | #include <linux/mutex.h> |
| 29 | #include <linux/types.h> | 28 | #include <linux/types.h> |
| 30 | 29 | ||
| 30 | #include "cros_ec_lpc_mec.h" | ||
| 31 | |||
| 31 | /* | 32 | /* |
| 32 | * This mutex must be held while accessing the EMI unit. We can't rely on the | 33 | * This mutex must be held while accessing the EMI unit. We can't rely on the |
| 33 | * EC mutex because memmap data may be accessed without it being held. | 34 | * EC mutex because memmap data may be accessed without it being held. |
diff --git a/include/linux/mfd/cros_ec_lpc_mec.h b/drivers/platform/chrome/cros_ec_lpc_mec.h index 176496ddc66c..105068c0e919 100644 --- a/include/linux/mfd/cros_ec_lpc_mec.h +++ b/drivers/platform/chrome/cros_ec_lpc_mec.h | |||
| @@ -21,8 +21,8 @@ | |||
| 21 | * expensive. | 21 | * expensive. |
| 22 | */ | 22 | */ |
| 23 | 23 | ||
| 24 | #ifndef __LINUX_MFD_CROS_EC_MEC_H | 24 | #ifndef __CROS_EC_LPC_MEC_H |
| 25 | #define __LINUX_MFD_CROS_EC_MEC_H | 25 | #define __CROS_EC_LPC_MEC_H |
| 26 | 26 | ||
| 27 | #include <linux/mfd/cros_ec_commands.h> | 27 | #include <linux/mfd/cros_ec_commands.h> |
| 28 | 28 | ||
| @@ -87,4 +87,4 @@ void cros_ec_lpc_mec_destroy(void); | |||
| 87 | u8 cros_ec_lpc_io_bytes_mec(enum cros_ec_lpc_mec_io_type io_type, | 87 | u8 cros_ec_lpc_io_bytes_mec(enum cros_ec_lpc_mec_io_type io_type, |
| 88 | unsigned int offset, unsigned int length, u8 *buf); | 88 | unsigned int offset, unsigned int length, u8 *buf); |
| 89 | 89 | ||
| 90 | #endif /* __LINUX_MFD_CROS_EC_MEC_H */ | 90 | #endif /* __CROS_EC_LPC_MEC_H */ |
diff --git a/drivers/platform/chrome/cros_ec_lpc_reg.c b/drivers/platform/chrome/cros_ec_lpc_reg.c index dcc7a3e30604..fc23d535c404 100644 --- a/drivers/platform/chrome/cros_ec_lpc_reg.c +++ b/drivers/platform/chrome/cros_ec_lpc_reg.c | |||
| @@ -24,7 +24,8 @@ | |||
| 24 | #include <linux/io.h> | 24 | #include <linux/io.h> |
| 25 | #include <linux/mfd/cros_ec.h> | 25 | #include <linux/mfd/cros_ec.h> |
| 26 | #include <linux/mfd/cros_ec_commands.h> | 26 | #include <linux/mfd/cros_ec_commands.h> |
| 27 | #include <linux/mfd/cros_ec_lpc_mec.h> | 27 | |
| 28 | #include "cros_ec_lpc_mec.h" | ||
| 28 | 29 | ||
| 29 | static u8 lpc_read_bytes(unsigned int offset, unsigned int length, u8 *dest) | 30 | static u8 lpc_read_bytes(unsigned int offset, unsigned int length, u8 *dest) |
| 30 | { | 31 | { |
diff --git a/include/linux/mfd/cros_ec_lpc_reg.h b/drivers/platform/chrome/cros_ec_lpc_reg.h index 5560bef63c2b..1c12c38b306a 100644 --- a/include/linux/mfd/cros_ec_lpc_reg.h +++ b/drivers/platform/chrome/cros_ec_lpc_reg.h | |||
| @@ -21,8 +21,8 @@ | |||
| 21 | * expensive. | 21 | * expensive. |
| 22 | */ | 22 | */ |
| 23 | 23 | ||
| 24 | #ifndef __LINUX_MFD_CROS_EC_REG_H | 24 | #ifndef __CROS_EC_LPC_REG_H |
| 25 | #define __LINUX_MFD_CROS_EC_REG_H | 25 | #define __CROS_EC_LPC_REG_H |
| 26 | 26 | ||
| 27 | /** | 27 | /** |
| 28 | * cros_ec_lpc_read_bytes - Read bytes from a given LPC-mapped address. | 28 | * cros_ec_lpc_read_bytes - Read bytes from a given LPC-mapped address. |
| @@ -58,4 +58,4 @@ void cros_ec_lpc_reg_init(void); | |||
| 58 | */ | 58 | */ |
| 59 | void cros_ec_lpc_reg_destroy(void); | 59 | void cros_ec_lpc_reg_destroy(void); |
| 60 | 60 | ||
| 61 | #endif /* __LINUX_MFD_CROS_EC_REG_H */ | 61 | #endif /* __CROS_EC_LPC_REG_H */ |
diff --git a/include/linux/mfd/cros_ec.h b/include/linux/mfd/cros_ec.h index 20949dde35cd..e44e3ec8a9c7 100644 --- a/include/linux/mfd/cros_ec.h +++ b/include/linux/mfd/cros_ec.h | |||
| @@ -36,7 +36,7 @@ | |||
| 36 | * I2C requires 1 additional byte for requests. | 36 | * I2C requires 1 additional byte for requests. |
| 37 | * I2C requires 2 additional bytes for responses. | 37 | * I2C requires 2 additional bytes for responses. |
| 38 | * SPI requires up to 32 additional bytes for responses. | 38 | * SPI requires up to 32 additional bytes for responses. |
| 39 | * */ | 39 | */ |
| 40 | #define EC_PROTO_VERSION_UNKNOWN 0 | 40 | #define EC_PROTO_VERSION_UNKNOWN 0 |
| 41 | #define EC_MAX_REQUEST_OVERHEAD 1 | 41 | #define EC_MAX_REQUEST_OVERHEAD 1 |
| 42 | #define EC_MAX_RESPONSE_OVERHEAD 32 | 42 | #define EC_MAX_RESPONSE_OVERHEAD 32 |
| @@ -58,13 +58,14 @@ enum { | |||
| 58 | EC_MAX_MSG_BYTES = 64 * 1024, | 58 | EC_MAX_MSG_BYTES = 64 * 1024, |
| 59 | }; | 59 | }; |
| 60 | 60 | ||
| 61 | /* | 61 | /** |
| 62 | * @version: Command version number (often 0) | 62 | * struct cros_ec_command - Information about a ChromeOS EC command. |
| 63 | * @command: Command to send (EC_CMD_...) | 63 | * @version: Command version number (often 0). |
| 64 | * @outsize: Outgoing length in bytes | 64 | * @command: Command to send (EC_CMD_...). |
| 65 | * @insize: Max number of bytes to accept from EC | 65 | * @outsize: Outgoing length in bytes. |
| 66 | * @result: EC's response to the command (separate from communication failure) | 66 | * @insize: Max number of bytes to accept from the EC. |
| 67 | * @data: Where to put the incoming data from EC and outgoing data to EC | 67 | * @result: EC's response to the command (separate from communication failure). |
| 68 | * @data: Where to put the incoming data from EC and outgoing data to EC. | ||
| 68 | */ | 69 | */ |
| 69 | struct cros_ec_command { | 70 | struct cros_ec_command { |
| 70 | uint32_t version; | 71 | uint32_t version; |
| @@ -76,48 +77,55 @@ struct cros_ec_command { | |||
| 76 | }; | 77 | }; |
| 77 | 78 | ||
| 78 | /** | 79 | /** |
| 79 | * struct cros_ec_device - Information about a ChromeOS EC device | 80 | * struct cros_ec_device - Information about a ChromeOS EC device. |
| 80 | * | 81 | * @phys_name: Name of physical comms layer (e.g. 'i2c-4'). |
| 81 | * @phys_name: name of physical comms layer (e.g. 'i2c-4') | ||
| 82 | * @dev: Device pointer for physical comms device | 82 | * @dev: Device pointer for physical comms device |
| 83 | * @was_wake_device: true if this device was set to wake the system from | 83 | * @was_wake_device: True if this device was set to wake the system from |
| 84 | * sleep at the last suspend | 84 | * sleep at the last suspend. |
| 85 | * @cmd_readmem: direct read of the EC memory-mapped region, if supported | 85 | * @cros_class: The class structure for this device. |
| 86 | * @offset is within EC_LPC_ADDR_MEMMAP region. | 86 | * @cmd_readmem: Direct read of the EC memory-mapped region, if supported. |
| 87 | * @bytes: number of bytes to read. zero means "read a string" (including | 87 | * @offset: Is within EC_LPC_ADDR_MEMMAP region. |
| 88 | * the trailing '\0'). At most only EC_MEMMAP_SIZE bytes can be read. | 88 | * @bytes: Number of bytes to read. zero means "read a string" (including |
| 89 | * Caller must ensure that the buffer is large enough for the result when | 89 | * the trailing '\0'). At most only EC_MEMMAP_SIZE bytes can be |
| 90 | * reading a string. | 90 | * read. Caller must ensure that the buffer is large enough for the |
| 91 | * | 91 | * result when reading a string. |
| 92 | * @priv: Private data | 92 | * @max_request: Max size of message requested. |
| 93 | * @irq: Interrupt to use | 93 | * @max_response: Max size of message response. |
| 94 | * @id: Device id | 94 | * @max_passthru: Max sice of passthru message. |
| 95 | * @din: input buffer (for data from EC) | 95 | * @proto_version: The protocol version used for this device. |
| 96 | * @dout: output buffer (for data to EC) | 96 | * @priv: Private data. |
| 97 | * \note | 97 | * @irq: Interrupt to use. |
| 98 | * These two buffers will always be dword-aligned and include enough | 98 | * @id: Device id. |
| 99 | * space for up to 7 word-alignment bytes also, so we can ensure that | 99 | * @din: Input buffer (for data from EC). This buffer will always be |
| 100 | * the body of the message is always dword-aligned (64-bit). | 100 | * dword-aligned and include enough space for up to 7 word-alignment |
| 101 | * We use this alignment to keep ARM and x86 happy. Probably word | 101 | * bytes also, so we can ensure that the body of the message is always |
| 102 | * alignment would be OK, there might be a small performance advantage | 102 | * dword-aligned (64-bit). We use this alignment to keep ARM and x86 |
| 103 | * to using dword. | 103 | * happy. Probably word alignment would be OK, there might be a small |
| 104 | * @din_size: size of din buffer to allocate (zero to use static din) | 104 | * performance advantage to using dword. |
| 105 | * @dout_size: size of dout buffer to allocate (zero to use static dout) | 105 | * @dout: Output buffer (for data to EC). This buffer will always be |
| 106 | * @wake_enabled: true if this device can wake the system from sleep | 106 | * dword-aligned and include enough space for up to 7 word-alignment |
| 107 | * @suspended: true if this device had been suspended | 107 | * bytes also, so we can ensure that the body of the message is always |
| 108 | * @cmd_xfer: send command to EC and get response | 108 | * dword-aligned (64-bit). We use this alignment to keep ARM and x86 |
| 109 | * Returns the number of bytes received if the communication succeeded, but | 109 | * happy. Probably word alignment would be OK, there might be a small |
| 110 | * that doesn't mean the EC was happy with the command. The caller | 110 | * performance advantage to using dword. |
| 111 | * should check msg.result for the EC's result code. | 111 | * @din_size: Size of din buffer to allocate (zero to use static din). |
| 112 | * @pkt_xfer: send packet to EC and get response | 112 | * @dout_size: Size of dout buffer to allocate (zero to use static dout). |
| 113 | * @lock: one transaction at a time | 113 | * @wake_enabled: True if this device can wake the system from sleep. |
| 114 | * @mkbp_event_supported: true if this EC supports the MKBP event protocol. | 114 | * @suspended: True if this device had been suspended. |
| 115 | * @event_notifier: interrupt event notifier for transport devices. | 115 | * @cmd_xfer: Send command to EC and get response. |
| 116 | * @event_data: raw payload transferred with the MKBP event. | 116 | * Returns the number of bytes received if the communication |
| 117 | * @event_size: size in bytes of the event data. | 117 | * succeeded, but that doesn't mean the EC was happy with the |
| 118 | * command. The caller should check msg.result for the EC's result | ||
| 119 | * code. | ||
| 120 | * @pkt_xfer: Send packet to EC and get response. | ||
| 121 | * @lock: One transaction at a time. | ||
| 122 | * @mkbp_event_supported: True if this EC supports the MKBP event protocol. | ||
| 123 | * @event_notifier: Interrupt event notifier for transport devices. | ||
| 124 | * @event_data: Raw payload transferred with the MKBP event. | ||
| 125 | * @event_size: Size in bytes of the event data. | ||
| 126 | * @host_event_wake_mask: Mask of host events that cause wake from suspend. | ||
| 118 | */ | 127 | */ |
| 119 | struct cros_ec_device { | 128 | struct cros_ec_device { |
| 120 | |||
| 121 | /* These are used by other drivers that want to talk to the EC */ | 129 | /* These are used by other drivers that want to talk to the EC */ |
| 122 | const char *phys_name; | 130 | const char *phys_name; |
| 123 | struct device *dev; | 131 | struct device *dev; |
| @@ -153,20 +161,19 @@ struct cros_ec_device { | |||
| 153 | }; | 161 | }; |
| 154 | 162 | ||
| 155 | /** | 163 | /** |
| 156 | * struct cros_ec_sensor_platform - ChromeOS EC sensor platform information | 164 | * struct cros_ec_sensor_platform - ChromeOS EC sensor platform information. |
| 157 | * | ||
| 158 | * @sensor_num: Id of the sensor, as reported by the EC. | 165 | * @sensor_num: Id of the sensor, as reported by the EC. |
| 159 | */ | 166 | */ |
| 160 | struct cros_ec_sensor_platform { | 167 | struct cros_ec_sensor_platform { |
| 161 | u8 sensor_num; | 168 | u8 sensor_num; |
| 162 | }; | 169 | }; |
| 163 | 170 | ||
| 164 | /* struct cros_ec_platform - ChromeOS EC platform information | 171 | /** |
| 165 | * | 172 | * struct cros_ec_platform - ChromeOS EC platform information. |
| 166 | * @ec_name: name of EC device (e.g. 'cros-ec', 'cros-pd', ...) | 173 | * @ec_name: Name of EC device (e.g. 'cros-ec', 'cros-pd', ...) |
| 167 | * used in /dev/ and sysfs. | 174 | * used in /dev/ and sysfs. |
| 168 | * @cmd_offset: offset to apply for each command. Set when | 175 | * @cmd_offset: Offset to apply for each command. Set when |
| 169 | * registering a devicde behind another one. | 176 | * registering a device behind another one. |
| 170 | */ | 177 | */ |
| 171 | struct cros_ec_platform { | 178 | struct cros_ec_platform { |
| 172 | const char *ec_name; | 179 | const char *ec_name; |
| @@ -175,16 +182,16 @@ struct cros_ec_platform { | |||
| 175 | 182 | ||
| 176 | struct cros_ec_debugfs; | 183 | struct cros_ec_debugfs; |
| 177 | 184 | ||
| 178 | /* | 185 | /** |
| 179 | * struct cros_ec_dev - ChromeOS EC device entry point | 186 | * struct cros_ec_dev - ChromeOS EC device entry point. |
| 180 | * | 187 | * @class_dev: Device structure used in sysfs. |
| 181 | * @class_dev: Device structure used in sysfs | 188 | * @cdev: Character device structure in /dev. |
| 182 | * @cdev: Character device structure in /dev | 189 | * @ec_dev: cros_ec_device structure to talk to the physical device. |
| 183 | * @ec_dev: cros_ec_device structure to talk to the physical device | 190 | * @dev: Pointer to the platform device. |
| 184 | * @dev: pointer to the platform device | 191 | * @debug_info: cros_ec_debugfs structure for debugging information. |
| 185 | * @debug_info: cros_ec_debugfs structure for debugging information | 192 | * @has_kb_wake_angle: True if at least 2 accelerometer are connected to the EC. |
| 186 | * @has_kb_wake_angle: true if at least 2 accelerometer are connected to the EC. | 193 | * @cmd_offset: Offset to apply for each command. |
| 187 | * @cmd_offset: offset to apply for each command. | 194 | * @features: Features supported by the EC. |
| 188 | */ | 195 | */ |
| 189 | struct cros_ec_dev { | 196 | struct cros_ec_dev { |
| 190 | struct device class_dev; | 197 | struct device class_dev; |
| @@ -200,124 +207,129 @@ struct cros_ec_dev { | |||
| 200 | #define to_cros_ec_dev(dev) container_of(dev, struct cros_ec_dev, class_dev) | 207 | #define to_cros_ec_dev(dev) container_of(dev, struct cros_ec_dev, class_dev) |
| 201 | 208 | ||
| 202 | /** | 209 | /** |
| 203 | * cros_ec_suspend - Handle a suspend operation for the ChromeOS EC device | 210 | * cros_ec_suspend() - Handle a suspend operation for the ChromeOS EC device. |
| 211 | * @ec_dev: Device to suspend. | ||
| 204 | * | 212 | * |
| 205 | * This can be called by drivers to handle a suspend event. | 213 | * This can be called by drivers to handle a suspend event. |
| 206 | * | 214 | * |
| 207 | * ec_dev: Device to suspend | 215 | * Return: 0 on success or negative error code. |
| 208 | * @return 0 if ok, -ve on error | ||
| 209 | */ | 216 | */ |
| 210 | int cros_ec_suspend(struct cros_ec_device *ec_dev); | 217 | int cros_ec_suspend(struct cros_ec_device *ec_dev); |
| 211 | 218 | ||
| 212 | /** | 219 | /** |
| 213 | * cros_ec_resume - Handle a resume operation for the ChromeOS EC device | 220 | * cros_ec_resume() - Handle a resume operation for the ChromeOS EC device. |
| 221 | * @ec_dev: Device to resume. | ||
| 214 | * | 222 | * |
| 215 | * This can be called by drivers to handle a resume event. | 223 | * This can be called by drivers to handle a resume event. |
| 216 | * | 224 | * |
| 217 | * @ec_dev: Device to resume | 225 | * Return: 0 on success or negative error code. |
| 218 | * @return 0 if ok, -ve on error | ||
| 219 | */ | 226 | */ |
| 220 | int cros_ec_resume(struct cros_ec_device *ec_dev); | 227 | int cros_ec_resume(struct cros_ec_device *ec_dev); |
| 221 | 228 | ||
| 222 | /** | 229 | /** |
| 223 | * cros_ec_prepare_tx - Prepare an outgoing message in the output buffer | 230 | * cros_ec_prepare_tx() - Prepare an outgoing message in the output buffer. |
| 231 | * @ec_dev: Device to register. | ||
| 232 | * @msg: Message to write. | ||
| 224 | * | 233 | * |
| 225 | * This is intended to be used by all ChromeOS EC drivers, but at present | 234 | * This is intended to be used by all ChromeOS EC drivers, but at present |
| 226 | * only SPI uses it. Once LPC uses the same protocol it can start using it. | 235 | * only SPI uses it. Once LPC uses the same protocol it can start using it. |
| 227 | * I2C could use it now, with a refactor of the existing code. | 236 | * I2C could use it now, with a refactor of the existing code. |
| 228 | * | 237 | * |
| 229 | * @ec_dev: Device to register | 238 | * Return: 0 on success or negative error code. |
| 230 | * @msg: Message to write | ||
| 231 | */ | 239 | */ |
| 232 | int cros_ec_prepare_tx(struct cros_ec_device *ec_dev, | 240 | int cros_ec_prepare_tx(struct cros_ec_device *ec_dev, |
| 233 | struct cros_ec_command *msg); | 241 | struct cros_ec_command *msg); |
| 234 | 242 | ||
| 235 | /** | 243 | /** |
| 236 | * cros_ec_check_result - Check ec_msg->result | 244 | * cros_ec_check_result() - Check ec_msg->result. |
| 245 | * @ec_dev: EC device. | ||
| 246 | * @msg: Message to check. | ||
| 237 | * | 247 | * |
| 238 | * This is used by ChromeOS EC drivers to check the ec_msg->result for | 248 | * This is used by ChromeOS EC drivers to check the ec_msg->result for |
| 239 | * errors and to warn about them. | 249 | * errors and to warn about them. |
| 240 | * | 250 | * |
| 241 | * @ec_dev: EC device | 251 | * Return: 0 on success or negative error code. |
| 242 | * @msg: Message to check | ||
| 243 | */ | 252 | */ |
| 244 | int cros_ec_check_result(struct cros_ec_device *ec_dev, | 253 | int cros_ec_check_result(struct cros_ec_device *ec_dev, |
| 245 | struct cros_ec_command *msg); | 254 | struct cros_ec_command *msg); |
| 246 | 255 | ||
| 247 | /** | 256 | /** |
| 248 | * cros_ec_cmd_xfer - Send a command to the ChromeOS EC | 257 | * cros_ec_cmd_xfer() - Send a command to the ChromeOS EC. |
| 258 | * @ec_dev: EC device. | ||
| 259 | * @msg: Message to write. | ||
| 249 | * | 260 | * |
| 250 | * Call this to send a command to the ChromeOS EC. This should be used | 261 | * Call this to send a command to the ChromeOS EC. This should be used |
| 251 | * instead of calling the EC's cmd_xfer() callback directly. | 262 | * instead of calling the EC's cmd_xfer() callback directly. |
| 252 | * | 263 | * |
| 253 | * @ec_dev: EC device | 264 | * Return: 0 on success or negative error code. |
| 254 | * @msg: Message to write | ||
| 255 | */ | 265 | */ |
| 256 | int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev, | 266 | int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev, |
| 257 | struct cros_ec_command *msg); | 267 | struct cros_ec_command *msg); |
| 258 | 268 | ||
| 259 | /** | 269 | /** |
| 260 | * cros_ec_cmd_xfer_status - Send a command to the ChromeOS EC | 270 | * cros_ec_cmd_xfer_status() - Send a command to the ChromeOS EC. |
| 271 | * @ec_dev: EC device. | ||
| 272 | * @msg: Message to write. | ||
| 261 | * | 273 | * |
| 262 | * This function is identical to cros_ec_cmd_xfer, except it returns success | 274 | * This function is identical to cros_ec_cmd_xfer, except it returns success |
| 263 | * status only if both the command was transmitted successfully and the EC | 275 | * status only if both the command was transmitted successfully and the EC |
| 264 | * replied with success status. It's not necessary to check msg->result when | 276 | * replied with success status. It's not necessary to check msg->result when |
| 265 | * using this function. | 277 | * using this function. |
| 266 | * | 278 | * |
| 267 | * @ec_dev: EC device | 279 | * Return: The number of bytes transferred on success or negative error code. |
| 268 | * @msg: Message to write | ||
| 269 | * @return: Num. of bytes transferred on success, <0 on failure | ||
| 270 | */ | 280 | */ |
| 271 | int cros_ec_cmd_xfer_status(struct cros_ec_device *ec_dev, | 281 | int cros_ec_cmd_xfer_status(struct cros_ec_device *ec_dev, |
| 272 | struct cros_ec_command *msg); | 282 | struct cros_ec_command *msg); |
| 273 | 283 | ||
| 274 | /** | 284 | /** |
| 275 | * cros_ec_remove - Remove a ChromeOS EC | 285 | * cros_ec_remove() - Remove a ChromeOS EC. |
| 286 | * @ec_dev: Device to register. | ||
| 276 | * | 287 | * |
| 277 | * Call this to deregister a ChromeOS EC, then clean up any private data. | 288 | * Call this to deregister a ChromeOS EC, then clean up any private data. |
| 278 | * | 289 | * |
| 279 | * @ec_dev: Device to register | 290 | * Return: 0 on success or negative error code. |
| 280 | * @return 0 if ok, -ve on error | ||
| 281 | */ | 291 | */ |
| 282 | int cros_ec_remove(struct cros_ec_device *ec_dev); | 292 | int cros_ec_remove(struct cros_ec_device *ec_dev); |
| 283 | 293 | ||
| 284 | /** | 294 | /** |
| 285 | * cros_ec_register - Register a new ChromeOS EC, using the provided info | 295 | * cros_ec_register() - Register a new ChromeOS EC, using the provided info. |
| 296 | * @ec_dev: Device to register. | ||
| 286 | * | 297 | * |
| 287 | * Before calling this, allocate a pointer to a new device and then fill | 298 | * Before calling this, allocate a pointer to a new device and then fill |
| 288 | * in all the fields up to the --private-- marker. | 299 | * in all the fields up to the --private-- marker. |
| 289 | * | 300 | * |
| 290 | * @ec_dev: Device to register | 301 | * Return: 0 on success or negative error code. |
| 291 | * @return 0 if ok, -ve on error | ||
| 292 | */ | 302 | */ |
| 293 | int cros_ec_register(struct cros_ec_device *ec_dev); | 303 | int cros_ec_register(struct cros_ec_device *ec_dev); |
| 294 | 304 | ||
| 295 | /** | 305 | /** |
| 296 | * cros_ec_query_all - Query the protocol version supported by the ChromeOS EC | 306 | * cros_ec_query_all() - Query the protocol version supported by the |
| 307 | * ChromeOS EC. | ||
| 308 | * @ec_dev: Device to register. | ||
| 297 | * | 309 | * |
| 298 | * @ec_dev: Device to register | 310 | * Return: 0 on success or negative error code. |
| 299 | * @return 0 if ok, -ve on error | ||
| 300 | */ | 311 | */ |
| 301 | int cros_ec_query_all(struct cros_ec_device *ec_dev); | 312 | int cros_ec_query_all(struct cros_ec_device *ec_dev); |
| 302 | 313 | ||
| 303 | /** | 314 | /** |
| 304 | * cros_ec_get_next_event - Fetch next event from the ChromeOS EC | 315 | * cros_ec_get_next_event() - Fetch next event from the ChromeOS EC. |
| 305 | * | 316 | * @ec_dev: Device to fetch event from. |
| 306 | * @ec_dev: Device to fetch event from | ||
| 307 | * @wake_event: Pointer to a bool set to true upon return if the event might be | 317 | * @wake_event: Pointer to a bool set to true upon return if the event might be |
| 308 | * treated as a wake event. Ignored if null. | 318 | * treated as a wake event. Ignored if null. |
| 309 | * | 319 | * |
| 310 | * Returns: 0 on success, Linux error number on failure | 320 | * Return: 0 on success or negative error code. |
| 311 | */ | 321 | */ |
| 312 | int cros_ec_get_next_event(struct cros_ec_device *ec_dev, bool *wake_event); | 322 | int cros_ec_get_next_event(struct cros_ec_device *ec_dev, bool *wake_event); |
| 313 | 323 | ||
| 314 | /** | 324 | /** |
| 315 | * cros_ec_get_host_event - Return a mask of event set by the EC. | 325 | * cros_ec_get_host_event() - Return a mask of event set by the ChromeOS EC. |
| 326 | * @ec_dev: Device to fetch event from. | ||
| 316 | * | 327 | * |
| 317 | * When MKBP is supported, when the EC raises an interrupt, | 328 | * When MKBP is supported, when the EC raises an interrupt, we collect the |
| 318 | * We collect the events raised and call the functions in the ec notifier. | 329 | * events raised and call the functions in the ec notifier. This function |
| 330 | * is a helper to know which events are raised. | ||
| 319 | * | 331 | * |
| 320 | * This function is a helper to know which events are raised. | 332 | * Return: 0 on success or negative error code. |
| 321 | */ | 333 | */ |
| 322 | u32 cros_ec_get_host_event(struct cros_ec_device *ec_dev); | 334 | u32 cros_ec_get_host_event(struct cros_ec_device *ec_dev); |
| 323 | 335 | ||
diff --git a/include/linux/mfd/cros_ec_commands.h b/include/linux/mfd/cros_ec_commands.h index 5fd0e429f472..9a9631f0559e 100644 --- a/include/linux/mfd/cros_ec_commands.h +++ b/include/linux/mfd/cros_ec_commands.h | |||
| @@ -306,15 +306,18 @@ enum host_event_code { | |||
| 306 | /* Host event mask */ | 306 | /* Host event mask */ |
| 307 | #define EC_HOST_EVENT_MASK(event_code) (1UL << ((event_code) - 1)) | 307 | #define EC_HOST_EVENT_MASK(event_code) (1UL << ((event_code) - 1)) |
| 308 | 308 | ||
| 309 | /* Arguments at EC_LPC_ADDR_HOST_ARGS */ | 309 | /** |
| 310 | * struct ec_lpc_host_args - Arguments at EC_LPC_ADDR_HOST_ARGS | ||
| 311 | * @flags: The host argument flags. | ||
| 312 | * @command_version: Command version. | ||
| 313 | * @data_size: The length of data. | ||
| 314 | * @checksum: Checksum; sum of command + flags + command_version + data_size + | ||
| 315 | * all params/response data bytes. | ||
| 316 | */ | ||
| 310 | struct ec_lpc_host_args { | 317 | struct ec_lpc_host_args { |
| 311 | uint8_t flags; | 318 | uint8_t flags; |
| 312 | uint8_t command_version; | 319 | uint8_t command_version; |
| 313 | uint8_t data_size; | 320 | uint8_t data_size; |
| 314 | /* | ||
| 315 | * Checksum; sum of command + flags + command_version + data_size + | ||
| 316 | * all params/response data bytes. | ||
| 317 | */ | ||
| 318 | uint8_t checksum; | 321 | uint8_t checksum; |
| 319 | } __packed; | 322 | } __packed; |
| 320 | 323 | ||
| @@ -468,54 +471,43 @@ struct ec_lpc_host_args { | |||
| 468 | 471 | ||
| 469 | #define EC_HOST_REQUEST_VERSION 3 | 472 | #define EC_HOST_REQUEST_VERSION 3 |
| 470 | 473 | ||
| 471 | /* Version 3 request from host */ | 474 | /** |
| 475 | * struct ec_host_request - Version 3 request from host. | ||
| 476 | * @struct_version: Should be 3. The EC will return EC_RES_INVALID_HEADER if it | ||
| 477 | * receives a header with a version it doesn't know how to | ||
| 478 | * parse. | ||
| 479 | * @checksum: Checksum of request and data; sum of all bytes including checksum | ||
| 480 | * should total to 0. | ||
| 481 | * @command: Command to send (EC_CMD_...) | ||
| 482 | * @command_version: Command version. | ||
| 483 | * @reserved: Unused byte in current protocol version; set to 0. | ||
| 484 | * @data_len: Length of data which follows this header. | ||
| 485 | */ | ||
| 472 | struct ec_host_request { | 486 | struct ec_host_request { |
| 473 | /* Struct version (=3) | ||
| 474 | * | ||
| 475 | * EC will return EC_RES_INVALID_HEADER if it receives a header with a | ||
| 476 | * version it doesn't know how to parse. | ||
| 477 | */ | ||
| 478 | uint8_t struct_version; | 487 | uint8_t struct_version; |
| 479 | |||
| 480 | /* | ||
| 481 | * Checksum of request and data; sum of all bytes including checksum | ||
| 482 | * should total to 0. | ||
| 483 | */ | ||
| 484 | uint8_t checksum; | 488 | uint8_t checksum; |
| 485 | |||
| 486 | /* Command code */ | ||
| 487 | uint16_t command; | 489 | uint16_t command; |
| 488 | |||
| 489 | /* Command version */ | ||
| 490 | uint8_t command_version; | 490 | uint8_t command_version; |
| 491 | |||
| 492 | /* Unused byte in current protocol version; set to 0 */ | ||
| 493 | uint8_t reserved; | 491 | uint8_t reserved; |
| 494 | |||
| 495 | /* Length of data which follows this header */ | ||
| 496 | uint16_t data_len; | 492 | uint16_t data_len; |
| 497 | } __packed; | 493 | } __packed; |
| 498 | 494 | ||
| 499 | #define EC_HOST_RESPONSE_VERSION 3 | 495 | #define EC_HOST_RESPONSE_VERSION 3 |
| 500 | 496 | ||
| 501 | /* Version 3 response from EC */ | 497 | /** |
| 498 | * struct ec_host_response - Version 3 response from EC. | ||
| 499 | * @struct_version: Struct version (=3). | ||
| 500 | * @checksum: Checksum of response and data; sum of all bytes including | ||
| 501 | * checksum should total to 0. | ||
| 502 | * @result: EC's response to the command (separate from communication failure) | ||
| 503 | * @data_len: Length of data which follows this header. | ||
| 504 | * @reserved: Unused bytes in current protocol version; set to 0. | ||
| 505 | */ | ||
| 502 | struct ec_host_response { | 506 | struct ec_host_response { |
| 503 | /* Struct version (=3) */ | ||
| 504 | uint8_t struct_version; | 507 | uint8_t struct_version; |
| 505 | |||
| 506 | /* | ||
| 507 | * Checksum of response and data; sum of all bytes including checksum | ||
| 508 | * should total to 0. | ||
| 509 | */ | ||
| 510 | uint8_t checksum; | 508 | uint8_t checksum; |
| 511 | |||
| 512 | /* Result code (EC_RES_*) */ | ||
| 513 | uint16_t result; | 509 | uint16_t result; |
| 514 | |||
| 515 | /* Length of data which follows this header */ | ||
| 516 | uint16_t data_len; | 510 | uint16_t data_len; |
| 517 | |||
| 518 | /* Unused bytes in current protocol version; set to 0 */ | ||
| 519 | uint16_t reserved; | 511 | uint16_t reserved; |
| 520 | } __packed; | 512 | } __packed; |
| 521 | 513 | ||
| @@ -540,6 +532,10 @@ struct ec_host_response { | |||
| 540 | */ | 532 | */ |
| 541 | #define EC_CMD_PROTO_VERSION 0x00 | 533 | #define EC_CMD_PROTO_VERSION 0x00 |
| 542 | 534 | ||
| 535 | /** | ||
| 536 | * struct ec_response_proto_version - Response to the proto version command. | ||
| 537 | * @version: The protocol version. | ||
| 538 | */ | ||
| 543 | struct ec_response_proto_version { | 539 | struct ec_response_proto_version { |
| 544 | uint32_t version; | 540 | uint32_t version; |
| 545 | } __packed; | 541 | } __packed; |
| @@ -550,12 +546,20 @@ struct ec_response_proto_version { | |||
| 550 | */ | 546 | */ |
| 551 | #define EC_CMD_HELLO 0x01 | 547 | #define EC_CMD_HELLO 0x01 |
| 552 | 548 | ||
| 549 | /** | ||
| 550 | * struct ec_params_hello - Parameters to the hello command. | ||
| 551 | * @in_data: Pass anything here. | ||
| 552 | */ | ||
| 553 | struct ec_params_hello { | 553 | struct ec_params_hello { |
| 554 | uint32_t in_data; /* Pass anything here */ | 554 | uint32_t in_data; |
| 555 | } __packed; | 555 | } __packed; |
| 556 | 556 | ||
| 557 | /** | ||
| 558 | * struct ec_response_hello - Response to the hello command. | ||
| 559 | * @out_data: Output will be in_data + 0x01020304. | ||
| 560 | */ | ||
| 557 | struct ec_response_hello { | 561 | struct ec_response_hello { |
| 558 | uint32_t out_data; /* Output will be in_data + 0x01020304 */ | 562 | uint32_t out_data; |
| 559 | } __packed; | 563 | } __packed; |
| 560 | 564 | ||
| 561 | /* Get version number */ | 565 | /* Get version number */ |
| @@ -567,22 +571,37 @@ enum ec_current_image { | |||
| 567 | EC_IMAGE_RW | 571 | EC_IMAGE_RW |
| 568 | }; | 572 | }; |
| 569 | 573 | ||
| 574 | /** | ||
| 575 | * struct ec_response_get_version - Response to the get version command. | ||
| 576 | * @version_string_ro: Null-terminated RO firmware version string. | ||
| 577 | * @version_string_rw: Null-terminated RW firmware version string. | ||
| 578 | * @reserved: Unused bytes; was previously RW-B firmware version string. | ||
| 579 | * @current_image: One of ec_current_image. | ||
| 580 | */ | ||
| 570 | struct ec_response_get_version { | 581 | struct ec_response_get_version { |
| 571 | /* Null-terminated version strings for RO, RW */ | ||
| 572 | char version_string_ro[32]; | 582 | char version_string_ro[32]; |
| 573 | char version_string_rw[32]; | 583 | char version_string_rw[32]; |
| 574 | char reserved[32]; /* Was previously RW-B string */ | 584 | char reserved[32]; |
| 575 | uint32_t current_image; /* One of ec_current_image */ | 585 | uint32_t current_image; |
| 576 | } __packed; | 586 | } __packed; |
| 577 | 587 | ||
| 578 | /* Read test */ | 588 | /* Read test */ |
| 579 | #define EC_CMD_READ_TEST 0x03 | 589 | #define EC_CMD_READ_TEST 0x03 |
| 580 | 590 | ||
| 591 | /** | ||
| 592 | * struct ec_params_read_test - Parameters for the read test command. | ||
| 593 | * @offset: Starting value for read buffer. | ||
| 594 | * @size: Size to read in bytes. | ||
| 595 | */ | ||
| 581 | struct ec_params_read_test { | 596 | struct ec_params_read_test { |
| 582 | uint32_t offset; /* Starting value for read buffer */ | 597 | uint32_t offset; |
| 583 | uint32_t size; /* Size to read in bytes */ | 598 | uint32_t size; |
| 584 | } __packed; | 599 | } __packed; |
| 585 | 600 | ||
| 601 | /** | ||
| 602 | * struct ec_response_read_test - Response to the read test command. | ||
| 603 | * @data: Data returned by the read test command. | ||
| 604 | */ | ||
| 586 | struct ec_response_read_test { | 605 | struct ec_response_read_test { |
| 587 | uint32_t data[32]; | 606 | uint32_t data[32]; |
| 588 | } __packed; | 607 | } __packed; |
| @@ -597,18 +616,27 @@ struct ec_response_read_test { | |||
| 597 | /* Get chip info */ | 616 | /* Get chip info */ |
| 598 | #define EC_CMD_GET_CHIP_INFO 0x05 | 617 | #define EC_CMD_GET_CHIP_INFO 0x05 |
| 599 | 618 | ||
| 619 | /** | ||
| 620 | * struct ec_response_get_chip_info - Response to the get chip info command. | ||
| 621 | * @vendor: Null-terminated string for chip vendor. | ||
| 622 | * @name: Null-terminated string for chip name. | ||
| 623 | * @revision: Null-terminated string for chip mask version. | ||
| 624 | */ | ||
| 600 | struct ec_response_get_chip_info { | 625 | struct ec_response_get_chip_info { |
| 601 | /* Null-terminated strings */ | ||
| 602 | char vendor[32]; | 626 | char vendor[32]; |
| 603 | char name[32]; | 627 | char name[32]; |
| 604 | char revision[32]; /* Mask version */ | 628 | char revision[32]; |
| 605 | } __packed; | 629 | } __packed; |
| 606 | 630 | ||
| 607 | /* Get board HW version */ | 631 | /* Get board HW version */ |
| 608 | #define EC_CMD_GET_BOARD_VERSION 0x06 | 632 | #define EC_CMD_GET_BOARD_VERSION 0x06 |
| 609 | 633 | ||
| 634 | /** | ||
| 635 | * struct ec_response_board_version - Response to the board version command. | ||
| 636 | * @board_version: A monotonously incrementing number. | ||
| 637 | */ | ||
| 610 | struct ec_response_board_version { | 638 | struct ec_response_board_version { |
| 611 | uint16_t board_version; /* A monotonously incrementing number. */ | 639 | uint16_t board_version; |
| 612 | } __packed; | 640 | } __packed; |
| 613 | 641 | ||
| 614 | /* | 642 | /* |
| @@ -621,27 +649,42 @@ struct ec_response_board_version { | |||
| 621 | */ | 649 | */ |
| 622 | #define EC_CMD_READ_MEMMAP 0x07 | 650 | #define EC_CMD_READ_MEMMAP 0x07 |
| 623 | 651 | ||
| 652 | /** | ||
| 653 | * struct ec_params_read_memmap - Parameters for the read memory map command. | ||
| 654 | * @offset: Offset in memmap (EC_MEMMAP_*). | ||
| 655 | * @size: Size to read in bytes. | ||
| 656 | */ | ||
| 624 | struct ec_params_read_memmap { | 657 | struct ec_params_read_memmap { |
| 625 | uint8_t offset; /* Offset in memmap (EC_MEMMAP_*) */ | 658 | uint8_t offset; |
| 626 | uint8_t size; /* Size to read in bytes */ | 659 | uint8_t size; |
| 627 | } __packed; | 660 | } __packed; |
| 628 | 661 | ||
| 629 | /* Read versions supported for a command */ | 662 | /* Read versions supported for a command */ |
| 630 | #define EC_CMD_GET_CMD_VERSIONS 0x08 | 663 | #define EC_CMD_GET_CMD_VERSIONS 0x08 |
| 631 | 664 | ||
| 665 | /** | ||
| 666 | * struct ec_params_get_cmd_versions - Parameters for the get command versions. | ||
| 667 | * @cmd: Command to check. | ||
| 668 | */ | ||
| 632 | struct ec_params_get_cmd_versions { | 669 | struct ec_params_get_cmd_versions { |
| 633 | uint8_t cmd; /* Command to check */ | 670 | uint8_t cmd; |
| 634 | } __packed; | 671 | } __packed; |
| 635 | 672 | ||
| 673 | /** | ||
| 674 | * struct ec_params_get_cmd_versions_v1 - Parameters for the get command | ||
| 675 | * versions (v1) | ||
| 676 | * @cmd: Command to check. | ||
| 677 | */ | ||
| 636 | struct ec_params_get_cmd_versions_v1 { | 678 | struct ec_params_get_cmd_versions_v1 { |
| 637 | uint16_t cmd; /* Command to check */ | 679 | uint16_t cmd; |
| 638 | } __packed; | 680 | } __packed; |
| 639 | 681 | ||
| 682 | /** | ||
| 683 | * struct ec_response_get_cmd_version - Response to the get command versions. | ||
| 684 | * @version_mask: Mask of supported versions; use EC_VER_MASK() to compare with | ||
| 685 | * a desired version. | ||
| 686 | */ | ||
| 640 | struct ec_response_get_cmd_versions { | 687 | struct ec_response_get_cmd_versions { |
| 641 | /* | ||
| 642 | * Mask of supported versions; use EC_VER_MASK() to compare with a | ||
| 643 | * desired version. | ||
| 644 | */ | ||
| 645 | uint32_t version_mask; | 688 | uint32_t version_mask; |
| 646 | } __packed; | 689 | } __packed; |
| 647 | 690 | ||
| @@ -659,6 +702,11 @@ enum ec_comms_status { | |||
| 659 | EC_COMMS_STATUS_PROCESSING = 1 << 0, /* Processing cmd */ | 702 | EC_COMMS_STATUS_PROCESSING = 1 << 0, /* Processing cmd */ |
| 660 | }; | 703 | }; |
| 661 | 704 | ||
| 705 | /** | ||
| 706 | * struct ec_response_get_comms_status - Response to the get comms status | ||
| 707 | * command. | ||
| 708 | * @flags: Mask of enum ec_comms_status. | ||
| 709 | */ | ||
| 662 | struct ec_response_get_comms_status { | 710 | struct ec_response_get_comms_status { |
| 663 | uint32_t flags; /* Mask of enum ec_comms_status */ | 711 | uint32_t flags; /* Mask of enum ec_comms_status */ |
| 664 | } __packed; | 712 | } __packed; |
| @@ -685,19 +733,19 @@ struct ec_response_test_protocol { | |||
| 685 | /* EC_RES_IN_PROGRESS may be returned if a command is slow */ | 733 | /* EC_RES_IN_PROGRESS may be returned if a command is slow */ |
| 686 | #define EC_PROTOCOL_INFO_IN_PROGRESS_SUPPORTED (1 << 0) | 734 | #define EC_PROTOCOL_INFO_IN_PROGRESS_SUPPORTED (1 << 0) |
| 687 | 735 | ||
| 736 | /** | ||
| 737 | * struct ec_response_get_protocol_info - Response to the get protocol info. | ||
| 738 | * @protocol_versions: Bitmask of protocol versions supported (1 << n means | ||
| 739 | * version n). | ||
| 740 | * @max_request_packet_size: Maximum request packet size in bytes. | ||
| 741 | * @max_response_packet_size: Maximum response packet size in bytes. | ||
| 742 | * @flags: see EC_PROTOCOL_INFO_* | ||
| 743 | */ | ||
| 688 | struct ec_response_get_protocol_info { | 744 | struct ec_response_get_protocol_info { |
| 689 | /* Fields which exist if at least protocol version 3 supported */ | 745 | /* Fields which exist if at least protocol version 3 supported */ |
| 690 | |||
| 691 | /* Bitmask of protocol versions supported (1 << n means version n)*/ | ||
| 692 | uint32_t protocol_versions; | 746 | uint32_t protocol_versions; |
| 693 | |||
| 694 | /* Maximum request packet size, in bytes */ | ||
| 695 | uint16_t max_request_packet_size; | 747 | uint16_t max_request_packet_size; |
| 696 | |||
| 697 | /* Maximum response packet size, in bytes */ | ||
| 698 | uint16_t max_response_packet_size; | 748 | uint16_t max_response_packet_size; |
| 699 | |||
| 700 | /* Flags; see EC_PROTOCOL_INFO_* */ | ||
| 701 | uint32_t flags; | 749 | uint32_t flags; |
| 702 | } __packed; | 750 | } __packed; |
| 703 | 751 | ||
| @@ -708,8 +756,10 @@ struct ec_response_get_protocol_info { | |||
| 708 | /* The upper byte of .flags tells what to do (nothing means "get") */ | 756 | /* The upper byte of .flags tells what to do (nothing means "get") */ |
| 709 | #define EC_GSV_SET 0x80000000 | 757 | #define EC_GSV_SET 0x80000000 |
| 710 | 758 | ||
| 711 | /* The lower three bytes of .flags identifies the parameter, if that has | 759 | /* |
| 712 | meaning for an individual command. */ | 760 | * The lower three bytes of .flags identifies the parameter, if that has |
| 761 | * meaning for an individual command. | ||
| 762 | */ | ||
| 713 | #define EC_GSV_PARAM_MASK 0x00ffffff | 763 | #define EC_GSV_PARAM_MASK 0x00ffffff |
| 714 | 764 | ||
| 715 | struct ec_params_get_set_value { | 765 | struct ec_params_get_set_value { |
| @@ -810,6 +860,7 @@ enum ec_feature_code { | |||
| 810 | 860 | ||
| 811 | #define EC_FEATURE_MASK_0(event_code) (1UL << (event_code % 32)) | 861 | #define EC_FEATURE_MASK_0(event_code) (1UL << (event_code % 32)) |
| 812 | #define EC_FEATURE_MASK_1(event_code) (1UL << (event_code - 32)) | 862 | #define EC_FEATURE_MASK_1(event_code) (1UL << (event_code - 32)) |
| 863 | |||
| 813 | struct ec_response_get_features { | 864 | struct ec_response_get_features { |
| 814 | uint32_t flags[2]; | 865 | uint32_t flags[2]; |
| 815 | } __packed; | 866 | } __packed; |
| @@ -820,24 +871,22 @@ struct ec_response_get_features { | |||
| 820 | /* Get flash info */ | 871 | /* Get flash info */ |
| 821 | #define EC_CMD_FLASH_INFO 0x10 | 872 | #define EC_CMD_FLASH_INFO 0x10 |
| 822 | 873 | ||
| 823 | /* Version 0 returns these fields */ | 874 | /** |
| 875 | * struct ec_response_flash_info - Response to the flash info command. | ||
| 876 | * @flash_size: Usable flash size in bytes. | ||
| 877 | * @write_block_size: Write block size. Write offset and size must be a | ||
| 878 | * multiple of this. | ||
| 879 | * @erase_block_size: Erase block size. Erase offset and size must be a | ||
| 880 | * multiple of this. | ||
| 881 | * @protect_block_size: Protection block size. Protection offset and size | ||
| 882 | * must be a multiple of this. | ||
| 883 | * | ||
| 884 | * Version 0 returns these fields. | ||
| 885 | */ | ||
| 824 | struct ec_response_flash_info { | 886 | struct ec_response_flash_info { |
| 825 | /* Usable flash size, in bytes */ | ||
| 826 | uint32_t flash_size; | 887 | uint32_t flash_size; |
| 827 | /* | ||
| 828 | * Write block size. Write offset and size must be a multiple | ||
| 829 | * of this. | ||
| 830 | */ | ||
| 831 | uint32_t write_block_size; | 888 | uint32_t write_block_size; |
| 832 | /* | ||
| 833 | * Erase block size. Erase offset and size must be a multiple | ||
| 834 | * of this. | ||
| 835 | */ | ||
| 836 | uint32_t erase_block_size; | 889 | uint32_t erase_block_size; |
| 837 | /* | ||
| 838 | * Protection block size. Protection offset and size must be a | ||
| 839 | * multiple of this. | ||
| 840 | */ | ||
| 841 | uint32_t protect_block_size; | 890 | uint32_t protect_block_size; |
| 842 | } __packed; | 891 | } __packed; |
| 843 | 892 | ||
| @@ -845,7 +894,22 @@ struct ec_response_flash_info { | |||
| 845 | /* EC flash erases bits to 0 instead of 1 */ | 894 | /* EC flash erases bits to 0 instead of 1 */ |
| 846 | #define EC_FLASH_INFO_ERASE_TO_0 (1 << 0) | 895 | #define EC_FLASH_INFO_ERASE_TO_0 (1 << 0) |
| 847 | 896 | ||
| 848 | /* | 897 | /** |
| 898 | * struct ec_response_flash_info_1 - Response to the flash info v1 command. | ||
| 899 | * @flash_size: Usable flash size in bytes. | ||
| 900 | * @write_block_size: Write block size. Write offset and size must be a | ||
| 901 | * multiple of this. | ||
| 902 | * @erase_block_size: Erase block size. Erase offset and size must be a | ||
| 903 | * multiple of this. | ||
| 904 | * @protect_block_size: Protection block size. Protection offset and size | ||
| 905 | * must be a multiple of this. | ||
| 906 | * @write_ideal_size: Ideal write size in bytes. Writes will be fastest if | ||
| 907 | * size is exactly this and offset is a multiple of this. | ||
| 908 | * For example, an EC may have a write buffer which can do | ||
| 909 | * half-page operations if data is aligned, and a slower | ||
| 910 | * word-at-a-time write mode. | ||
| 911 | * @flags: Flags; see EC_FLASH_INFO_* | ||
| 912 | * | ||
| 849 | * Version 1 returns the same initial fields as version 0, with additional | 913 | * Version 1 returns the same initial fields as version 0, with additional |
| 850 | * fields following. | 914 | * fields following. |
| 851 | * | 915 | * |
| @@ -860,15 +924,7 @@ struct ec_response_flash_info_1 { | |||
| 860 | uint32_t protect_block_size; | 924 | uint32_t protect_block_size; |
| 861 | 925 | ||
| 862 | /* Version 1 adds these fields: */ | 926 | /* Version 1 adds these fields: */ |
| 863 | /* | ||
| 864 | * Ideal write size in bytes. Writes will be fastest if size is | ||
| 865 | * exactly this and offset is a multiple of this. For example, an EC | ||
| 866 | * may have a write buffer which can do half-page operations if data is | ||
| 867 | * aligned, and a slower word-at-a-time write mode. | ||
| 868 | */ | ||
| 869 | uint32_t write_ideal_size; | 927 | uint32_t write_ideal_size; |
| 870 | |||
| 871 | /* Flags; see EC_FLASH_INFO_* */ | ||
| 872 | uint32_t flags; | 928 | uint32_t flags; |
| 873 | } __packed; | 929 | } __packed; |
| 874 | 930 | ||
| @@ -879,9 +935,14 @@ struct ec_response_flash_info_1 { | |||
| 879 | */ | 935 | */ |
| 880 | #define EC_CMD_FLASH_READ 0x11 | 936 | #define EC_CMD_FLASH_READ 0x11 |
| 881 | 937 | ||
| 938 | /** | ||
| 939 | * struct ec_params_flash_read - Parameters for the flash read command. | ||
| 940 | * @offset: Byte offset to read. | ||
| 941 | * @size: Size to read in bytes. | ||
| 942 | */ | ||
| 882 | struct ec_params_flash_read { | 943 | struct ec_params_flash_read { |
| 883 | uint32_t offset; /* Byte offset to read */ | 944 | uint32_t offset; |
| 884 | uint32_t size; /* Size to read in bytes */ | 945 | uint32_t size; |
| 885 | } __packed; | 946 | } __packed; |
| 886 | 947 | ||
| 887 | /* Write flash */ | 948 | /* Write flash */ |
| @@ -891,18 +952,28 @@ struct ec_params_flash_read { | |||
| 891 | /* Version 0 of the flash command supported only 64 bytes of data */ | 952 | /* Version 0 of the flash command supported only 64 bytes of data */ |
| 892 | #define EC_FLASH_WRITE_VER0_SIZE 64 | 953 | #define EC_FLASH_WRITE_VER0_SIZE 64 |
| 893 | 954 | ||
| 955 | /** | ||
| 956 | * struct ec_params_flash_write - Parameters for the flash write command. | ||
| 957 | * @offset: Byte offset to write. | ||
| 958 | * @size: Size to write in bytes. | ||
| 959 | */ | ||
| 894 | struct ec_params_flash_write { | 960 | struct ec_params_flash_write { |
| 895 | uint32_t offset; /* Byte offset to write */ | 961 | uint32_t offset; |
| 896 | uint32_t size; /* Size to write in bytes */ | 962 | uint32_t size; |
| 897 | /* Followed by data to write */ | 963 | /* Followed by data to write */ |
| 898 | } __packed; | 964 | } __packed; |
| 899 | 965 | ||
| 900 | /* Erase flash */ | 966 | /* Erase flash */ |
| 901 | #define EC_CMD_FLASH_ERASE 0x13 | 967 | #define EC_CMD_FLASH_ERASE 0x13 |
| 902 | 968 | ||
| 969 | /** | ||
| 970 | * struct ec_params_flash_erase - Parameters for the flash erase command. | ||
| 971 | * @offset: Byte offset to erase. | ||
| 972 | * @size: Size to erase in bytes. | ||
| 973 | */ | ||
| 903 | struct ec_params_flash_erase { | 974 | struct ec_params_flash_erase { |
| 904 | uint32_t offset; /* Byte offset to erase */ | 975 | uint32_t offset; |
| 905 | uint32_t size; /* Size to erase in bytes */ | 976 | uint32_t size; |
| 906 | } __packed; | 977 | } __packed; |
| 907 | 978 | ||
| 908 | /* | 979 | /* |
| @@ -941,21 +1012,28 @@ struct ec_params_flash_erase { | |||
| 941 | /* Entile flash code protected when the EC boots */ | 1012 | /* Entile flash code protected when the EC boots */ |
| 942 | #define EC_FLASH_PROTECT_ALL_AT_BOOT (1 << 6) | 1013 | #define EC_FLASH_PROTECT_ALL_AT_BOOT (1 << 6) |
| 943 | 1014 | ||
| 1015 | /** | ||
| 1016 | * struct ec_params_flash_protect - Parameters for the flash protect command. | ||
| 1017 | * @mask: Bits in flags to apply. | ||
| 1018 | * @flags: New flags to apply. | ||
| 1019 | */ | ||
| 944 | struct ec_params_flash_protect { | 1020 | struct ec_params_flash_protect { |
| 945 | uint32_t mask; /* Bits in flags to apply */ | 1021 | uint32_t mask; |
| 946 | uint32_t flags; /* New flags to apply */ | 1022 | uint32_t flags; |
| 947 | } __packed; | 1023 | } __packed; |
| 948 | 1024 | ||
| 1025 | /** | ||
| 1026 | * struct ec_response_flash_protect - Response to the flash protect command. | ||
| 1027 | * @flags: Current value of flash protect flags. | ||
| 1028 | * @valid_flags: Flags which are valid on this platform. This allows the | ||
| 1029 | * caller to distinguish between flags which aren't set vs. flags | ||
| 1030 | * which can't be set on this platform. | ||
| 1031 | * @writable_flags: Flags which can be changed given the current protection | ||
| 1032 | * state. | ||
| 1033 | */ | ||
| 949 | struct ec_response_flash_protect { | 1034 | struct ec_response_flash_protect { |
| 950 | /* Current value of flash protect flags */ | ||
| 951 | uint32_t flags; | 1035 | uint32_t flags; |
| 952 | /* | ||
| 953 | * Flags which are valid on this platform. This allows the caller | ||
| 954 | * to distinguish between flags which aren't set vs. flags which can't | ||
| 955 | * be set on this platform. | ||
| 956 | */ | ||
| 957 | uint32_t valid_flags; | 1036 | uint32_t valid_flags; |
| 958 | /* Flags which can be changed given the current protection state */ | ||
| 959 | uint32_t writable_flags; | 1037 | uint32_t writable_flags; |
| 960 | } __packed; | 1038 | } __packed; |
| 961 | 1039 | ||
| @@ -982,8 +1060,13 @@ enum ec_flash_region { | |||
| 982 | EC_FLASH_REGION_COUNT, | 1060 | EC_FLASH_REGION_COUNT, |
| 983 | }; | 1061 | }; |
| 984 | 1062 | ||
| 1063 | /** | ||
| 1064 | * struct ec_params_flash_region_info - Parameters for the flash region info | ||
| 1065 | * command. | ||
| 1066 | * @region: Flash region; see EC_FLASH_REGION_* | ||
| 1067 | */ | ||
| 985 | struct ec_params_flash_region_info { | 1068 | struct ec_params_flash_region_info { |
| 986 | uint32_t region; /* enum ec_flash_region */ | 1069 | uint32_t region; |
| 987 | } __packed; | 1070 | } __packed; |
| 988 | 1071 | ||
| 989 | struct ec_response_flash_region_info { | 1072 | struct ec_response_flash_region_info { |
| @@ -1094,7 +1177,9 @@ struct rgb_s { | |||
| 1094 | }; | 1177 | }; |
| 1095 | 1178 | ||
| 1096 | #define LB_BATTERY_LEVELS 4 | 1179 | #define LB_BATTERY_LEVELS 4 |
| 1097 | /* List of tweakable parameters. NOTE: It's __packed so it can be sent in a | 1180 | |
| 1181 | /* | ||
| 1182 | * List of tweakable parameters. NOTE: It's __packed so it can be sent in a | ||
| 1098 | * host command, but the alignment is the same regardless. Keep it that way. | 1183 | * host command, but the alignment is the same regardless. Keep it that way. |
| 1099 | */ | 1184 | */ |
| 1100 | struct lightbar_params_v0 { | 1185 | struct lightbar_params_v0 { |
