diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2017-07-11 12:55:47 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-07-11 12:55:47 -0400 |
| commit | a3ddacbae5abc0a5aabb1e75b655e8cd6dc83888 (patch) | |
| tree | 9b33fb1fdb67080e05b0603c5639bd7b6149b523 /include/linux/mfd | |
| parent | a0188177344c8efdb1467889a0ec148554869e15 (diff) | |
| parent | 3c778a7fcfaa4bb51aefb4f2c7364a5e2c4d0b66 (diff) | |
Merge tag 'chrome-platform-for-linus-4.13' of git://git.kernel.org/pub/scm/linux/kernel/git/bleung/chrome-platform
Pull chrome platform updates from Benson Leung:
"Changes in this pull request are around catching up cros_ec with the
internal chromeos-kernel versions of cros_ec, cros_ec_lpc, and
cros_ec_lightbar.
Also, switching maintainership from olof to bleung"
* tag 'chrome-platform-for-linus-4.13' of git://git.kernel.org/pub/scm/linux/kernel/git/bleung/chrome-platform:
platform/chrome : Add myself as Maintainer
platform/chrome: cros_ec_lightbar - hide unused PM functions
cros_ec: Don't signal wake event for non-wake host events
cros_ec: Fix deadlock when EC is not responsive at probe
cros_ec: Don't return error when checking command version
platform/chrome: cros_ec_lightbar - Avoid I2C xfer to EC during suspend
platform/chrome: cros_ec_lightbar - Add userspace lightbar control bit to EC
platform/chrome: cros_ec_lightbar - Control of suspend/resume lightbar sequence
platform/chrome: cros_ec_lightbar - Add lightbar program feature to sysfs
platform/chrome: cros_ec_lpc: Add MKBP events support over ACPI
platform/chrome: cros_ec_lpc: Add power management ops
platform/chrome: cros_ec_lpc: Add support for GOOG004 ACPI device
platform/chrome: cros_ec_lpc: Add support for mec1322 EC
platform/chrome: cros_ec_lpc: Add R/W helpers to LPC protocol variants
mfd: cros_ec: Add support for dumping panic information
cros_ec_debugfs: Pass proper struct sizes to cros_ec_cmd_xfer()
mfd: cros_ec: add debugfs, console log file
mfd: cros_ec: Add EC console read structures definitions
mfd: cros_ec: Add helper for event notifier.
Diffstat (limited to 'include/linux/mfd')
| -rw-r--r-- | include/linux/mfd/cros_ec.h | 19 | ||||
| -rw-r--r-- | include/linux/mfd/cros_ec_commands.h | 42 | ||||
| -rw-r--r-- | include/linux/mfd/cros_ec_lpc_mec.h | 90 | ||||
| -rw-r--r-- | include/linux/mfd/cros_ec_lpc_reg.h | 61 |
4 files changed, 208 insertions, 4 deletions
diff --git a/include/linux/mfd/cros_ec.h b/include/linux/mfd/cros_ec.h index 28baee63eaf6..4e887ba22635 100644 --- a/include/linux/mfd/cros_ec.h +++ b/include/linux/mfd/cros_ec.h | |||
| @@ -149,6 +149,7 @@ struct cros_ec_device { | |||
| 149 | 149 | ||
| 150 | struct ec_response_get_next_event event_data; | 150 | struct ec_response_get_next_event event_data; |
| 151 | int event_size; | 151 | int event_size; |
| 152 | u32 host_event_wake_mask; | ||
| 152 | }; | 153 | }; |
| 153 | 154 | ||
| 154 | /** | 155 | /** |
| @@ -172,6 +173,8 @@ struct cros_ec_platform { | |||
| 172 | u16 cmd_offset; | 173 | u16 cmd_offset; |
| 173 | }; | 174 | }; |
| 174 | 175 | ||
| 176 | struct cros_ec_debugfs; | ||
| 177 | |||
| 175 | /* | 178 | /* |
| 176 | * struct cros_ec_dev - ChromeOS EC device entry point | 179 | * struct cros_ec_dev - ChromeOS EC device entry point |
| 177 | * | 180 | * |
| @@ -179,6 +182,7 @@ struct cros_ec_platform { | |||
| 179 | * @cdev: Character device structure in /dev | 182 | * @cdev: Character device structure in /dev |
| 180 | * @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 |
| 181 | * @dev: pointer to the platform device | 184 | * @dev: pointer to the platform device |
| 185 | * @debug_info: cros_ec_debugfs structure for debugging information | ||
| 182 | * @cmd_offset: offset to apply for each command. | 186 | * @cmd_offset: offset to apply for each command. |
| 183 | */ | 187 | */ |
| 184 | struct cros_ec_dev { | 188 | struct cros_ec_dev { |
| @@ -186,6 +190,7 @@ struct cros_ec_dev { | |||
| 186 | struct cdev cdev; | 190 | struct cdev cdev; |
| 187 | struct cros_ec_device *ec_dev; | 191 | struct cros_ec_device *ec_dev; |
| 188 | struct device *dev; | 192 | struct device *dev; |
| 193 | struct cros_ec_debugfs *debug_info; | ||
| 189 | u16 cmd_offset; | 194 | u16 cmd_offset; |
| 190 | u32 features[2]; | 195 | u32 features[2]; |
| 191 | }; | 196 | }; |
| @@ -295,10 +300,22 @@ int cros_ec_query_all(struct cros_ec_device *ec_dev); | |||
| 295 | * cros_ec_get_next_event - Fetch next event from the ChromeOS EC | 300 | * cros_ec_get_next_event - Fetch next event from the ChromeOS EC |
| 296 | * | 301 | * |
| 297 | * @ec_dev: Device to fetch event from | 302 | * @ec_dev: Device to fetch event from |
| 303 | * @wake_event: Pointer to a bool set to true upon return if the event might be | ||
| 304 | * treated as a wake event. Ignored if null. | ||
| 298 | * | 305 | * |
| 299 | * Returns: 0 on success, Linux error number on failure | 306 | * Returns: 0 on success, Linux error number on failure |
| 300 | */ | 307 | */ |
| 301 | int cros_ec_get_next_event(struct cros_ec_device *ec_dev); | 308 | int cros_ec_get_next_event(struct cros_ec_device *ec_dev, bool *wake_event); |
| 309 | |||
| 310 | /** | ||
| 311 | * cros_ec_get_host_event - Return a mask of event set by the EC. | ||
| 312 | * | ||
| 313 | * When MKBP is supported, when the EC raises an interrupt, | ||
| 314 | * We collect the events raised and call the functions in the ec notifier. | ||
| 315 | * | ||
| 316 | * This function is a helper to know which events are raised. | ||
| 317 | */ | ||
| 318 | u32 cros_ec_get_host_event(struct cros_ec_device *ec_dev); | ||
| 302 | 319 | ||
| 303 | /* sysfs stuff */ | 320 | /* sysfs stuff */ |
| 304 | extern struct attribute_group cros_ec_attr_group; | 321 | extern struct attribute_group cros_ec_attr_group; |
diff --git a/include/linux/mfd/cros_ec_commands.h b/include/linux/mfd/cros_ec_commands.h index c93e7e0300ef..190c8f4afa02 100644 --- a/include/linux/mfd/cros_ec_commands.h +++ b/include/linux/mfd/cros_ec_commands.h | |||
| @@ -625,6 +625,10 @@ struct ec_params_get_cmd_versions { | |||
| 625 | uint8_t cmd; /* Command to check */ | 625 | uint8_t cmd; /* Command to check */ |
| 626 | } __packed; | 626 | } __packed; |
| 627 | 627 | ||
| 628 | struct ec_params_get_cmd_versions_v1 { | ||
| 629 | uint16_t cmd; /* Command to check */ | ||
| 630 | } __packed; | ||
| 631 | |||
| 628 | struct ec_response_get_cmd_versions { | 632 | struct ec_response_get_cmd_versions { |
| 629 | /* | 633 | /* |
| 630 | * Mask of supported versions; use EC_VER_MASK() to compare with a | 634 | * Mask of supported versions; use EC_VER_MASK() to compare with a |
| @@ -1158,13 +1162,20 @@ struct lightbar_params_v1 { | |||
| 1158 | struct rgb_s color[8]; /* 0-3 are Google colors */ | 1162 | struct rgb_s color[8]; /* 0-3 are Google colors */ |
| 1159 | } __packed; | 1163 | } __packed; |
| 1160 | 1164 | ||
| 1165 | /* Lightbar program */ | ||
| 1166 | #define EC_LB_PROG_LEN 192 | ||
| 1167 | struct lightbar_program { | ||
| 1168 | uint8_t size; | ||
| 1169 | uint8_t data[EC_LB_PROG_LEN]; | ||
| 1170 | }; | ||
| 1171 | |||
| 1161 | struct ec_params_lightbar { | 1172 | struct ec_params_lightbar { |
| 1162 | uint8_t cmd; /* Command (see enum lightbar_command) */ | 1173 | uint8_t cmd; /* Command (see enum lightbar_command) */ |
| 1163 | union { | 1174 | union { |
| 1164 | struct { | 1175 | struct { |
| 1165 | /* no args */ | 1176 | /* no args */ |
| 1166 | } dump, off, on, init, get_seq, get_params_v0, get_params_v1, | 1177 | } dump, off, on, init, get_seq, get_params_v0, get_params_v1, |
| 1167 | version, get_brightness, get_demo; | 1178 | version, get_brightness, get_demo, suspend, resume; |
| 1168 | 1179 | ||
| 1169 | struct { | 1180 | struct { |
| 1170 | uint8_t num; | 1181 | uint8_t num; |
| @@ -1182,8 +1193,13 @@ struct ec_params_lightbar { | |||
| 1182 | uint8_t led; | 1193 | uint8_t led; |
| 1183 | } get_rgb; | 1194 | } get_rgb; |
| 1184 | 1195 | ||
| 1196 | struct { | ||
| 1197 | uint8_t enable; | ||
| 1198 | } manual_suspend_ctrl; | ||
| 1199 | |||
| 1185 | struct lightbar_params_v0 set_params_v0; | 1200 | struct lightbar_params_v0 set_params_v0; |
| 1186 | struct lightbar_params_v1 set_params_v1; | 1201 | struct lightbar_params_v1 set_params_v1; |
| 1202 | struct lightbar_program set_program; | ||
| 1187 | }; | 1203 | }; |
| 1188 | } __packed; | 1204 | } __packed; |
| 1189 | 1205 | ||
| @@ -1216,7 +1232,8 @@ struct ec_response_lightbar { | |||
| 1216 | struct { | 1232 | struct { |
| 1217 | /* no return params */ | 1233 | /* no return params */ |
| 1218 | } off, on, init, set_brightness, seq, reg, set_rgb, | 1234 | } off, on, init, set_brightness, seq, reg, set_rgb, |
| 1219 | demo, set_params_v0, set_params_v1; | 1235 | demo, set_params_v0, set_params_v1, |
| 1236 | set_program, manual_suspend_ctrl, suspend, resume; | ||
| 1220 | }; | 1237 | }; |
| 1221 | } __packed; | 1238 | } __packed; |
| 1222 | 1239 | ||
| @@ -1240,6 +1257,10 @@ enum lightbar_command { | |||
| 1240 | LIGHTBAR_CMD_GET_DEMO = 15, | 1257 | LIGHTBAR_CMD_GET_DEMO = 15, |
| 1241 | LIGHTBAR_CMD_GET_PARAMS_V1 = 16, | 1258 | LIGHTBAR_CMD_GET_PARAMS_V1 = 16, |
| 1242 | LIGHTBAR_CMD_SET_PARAMS_V1 = 17, | 1259 | LIGHTBAR_CMD_SET_PARAMS_V1 = 17, |
| 1260 | LIGHTBAR_CMD_SET_PROGRAM = 18, | ||
| 1261 | LIGHTBAR_CMD_MANUAL_SUSPEND_CTRL = 19, | ||
| 1262 | LIGHTBAR_CMD_SUSPEND = 20, | ||
| 1263 | LIGHTBAR_CMD_RESUME = 21, | ||
| 1243 | LIGHTBAR_NUM_CMDS | 1264 | LIGHTBAR_NUM_CMDS |
| 1244 | }; | 1265 | }; |
| 1245 | 1266 | ||
| @@ -2285,13 +2306,28 @@ struct ec_params_charge_control { | |||
| 2285 | #define EC_CMD_CONSOLE_SNAPSHOT 0x97 | 2306 | #define EC_CMD_CONSOLE_SNAPSHOT 0x97 |
| 2286 | 2307 | ||
| 2287 | /* | 2308 | /* |
| 2288 | * Read next chunk of data from saved snapshot. | 2309 | * Read data from the saved snapshot. If the subcmd parameter is |
| 2310 | * CONSOLE_READ_NEXT, this will return data starting from the beginning of | ||
| 2311 | * the latest snapshot. If it is CONSOLE_READ_RECENT, it will start from the | ||
| 2312 | * end of the previous snapshot. | ||
| 2313 | * | ||
| 2314 | * The params are only looked at in version >= 1 of this command. Prior | ||
| 2315 | * versions will just default to CONSOLE_READ_NEXT behavior. | ||
| 2289 | * | 2316 | * |
| 2290 | * Response is null-terminated string. Empty string, if there is no more | 2317 | * Response is null-terminated string. Empty string, if there is no more |
| 2291 | * remaining output. | 2318 | * remaining output. |
| 2292 | */ | 2319 | */ |
| 2293 | #define EC_CMD_CONSOLE_READ 0x98 | 2320 | #define EC_CMD_CONSOLE_READ 0x98 |
| 2294 | 2321 | ||
| 2322 | enum ec_console_read_subcmd { | ||
| 2323 | CONSOLE_READ_NEXT = 0, | ||
| 2324 | CONSOLE_READ_RECENT | ||
| 2325 | }; | ||
| 2326 | |||
| 2327 | struct ec_params_console_read_v1 { | ||
| 2328 | uint8_t subcmd; /* enum ec_console_read_subcmd */ | ||
| 2329 | } __packed; | ||
| 2330 | |||
| 2295 | /*****************************************************************************/ | 2331 | /*****************************************************************************/ |
| 2296 | 2332 | ||
| 2297 | /* | 2333 | /* |
diff --git a/include/linux/mfd/cros_ec_lpc_mec.h b/include/linux/mfd/cros_ec_lpc_mec.h new file mode 100644 index 000000000000..176496ddc66c --- /dev/null +++ b/include/linux/mfd/cros_ec_lpc_mec.h | |||
| @@ -0,0 +1,90 @@ | |||
| 1 | /* | ||
| 2 | * cros_ec_lpc_mec - LPC variant I/O for Microchip EC | ||
| 3 | * | ||
| 4 | * Copyright (C) 2016 Google, Inc | ||
| 5 | * | ||
| 6 | * This software is licensed under the terms of the GNU General Public | ||
| 7 | * License version 2, as published by the Free Software Foundation, and | ||
| 8 | * may be copied, distributed, and modified under those terms. | ||
| 9 | * | ||
| 10 | * This program is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | * GNU General Public License for more details. | ||
| 14 | * | ||
| 15 | * This driver uses the Chrome OS EC byte-level message-based protocol for | ||
| 16 | * communicating the keyboard state (which keys are pressed) from a keyboard EC | ||
| 17 | * to the AP over some bus (such as i2c, lpc, spi). The EC does debouncing, | ||
| 18 | * but everything else (including deghosting) is done here. The main | ||
| 19 | * motivation for this is to keep the EC firmware as simple as possible, since | ||
| 20 | * it cannot be easily upgraded and EC flash/IRAM space is relatively | ||
| 21 | * expensive. | ||
| 22 | */ | ||
| 23 | |||
| 24 | #ifndef __LINUX_MFD_CROS_EC_MEC_H | ||
| 25 | #define __LINUX_MFD_CROS_EC_MEC_H | ||
| 26 | |||
| 27 | #include <linux/mfd/cros_ec_commands.h> | ||
| 28 | |||
| 29 | enum cros_ec_lpc_mec_emi_access_mode { | ||
| 30 | /* 8-bit access */ | ||
| 31 | ACCESS_TYPE_BYTE = 0x0, | ||
| 32 | /* 16-bit access */ | ||
| 33 | ACCESS_TYPE_WORD = 0x1, | ||
| 34 | /* 32-bit access */ | ||
| 35 | ACCESS_TYPE_LONG = 0x2, | ||
| 36 | /* | ||
| 37 | * 32-bit access, read or write of MEC_EMI_EC_DATA_B3 causes the | ||
| 38 | * EC data register to be incremented. | ||
| 39 | */ | ||
| 40 | ACCESS_TYPE_LONG_AUTO_INCREMENT = 0x3, | ||
| 41 | }; | ||
| 42 | |||
| 43 | enum cros_ec_lpc_mec_io_type { | ||
| 44 | MEC_IO_READ, | ||
| 45 | MEC_IO_WRITE, | ||
| 46 | }; | ||
| 47 | |||
| 48 | /* Access IO ranges 0x800 thru 0x9ff using EMI interface instead of LPC */ | ||
| 49 | #define MEC_EMI_RANGE_START EC_HOST_CMD_REGION0 | ||
| 50 | #define MEC_EMI_RANGE_END (EC_LPC_ADDR_MEMMAP + EC_MEMMAP_SIZE) | ||
| 51 | |||
| 52 | /* EMI registers are relative to base */ | ||
| 53 | #define MEC_EMI_BASE 0x800 | ||
| 54 | #define MEC_EMI_HOST_TO_EC (MEC_EMI_BASE + 0) | ||
| 55 | #define MEC_EMI_EC_TO_HOST (MEC_EMI_BASE + 1) | ||
| 56 | #define MEC_EMI_EC_ADDRESS_B0 (MEC_EMI_BASE + 2) | ||
| 57 | #define MEC_EMI_EC_ADDRESS_B1 (MEC_EMI_BASE + 3) | ||
| 58 | #define MEC_EMI_EC_DATA_B0 (MEC_EMI_BASE + 4) | ||
| 59 | #define MEC_EMI_EC_DATA_B1 (MEC_EMI_BASE + 5) | ||
| 60 | #define MEC_EMI_EC_DATA_B2 (MEC_EMI_BASE + 6) | ||
| 61 | #define MEC_EMI_EC_DATA_B3 (MEC_EMI_BASE + 7) | ||
| 62 | |||
| 63 | /* | ||
| 64 | * cros_ec_lpc_mec_init | ||
| 65 | * | ||
| 66 | * Initialize MEC I/O. | ||
| 67 | */ | ||
| 68 | void cros_ec_lpc_mec_init(void); | ||
| 69 | |||
| 70 | /* | ||
| 71 | * cros_ec_lpc_mec_destroy | ||
| 72 | * | ||
| 73 | * Cleanup MEC I/O. | ||
| 74 | */ | ||
| 75 | void cros_ec_lpc_mec_destroy(void); | ||
| 76 | |||
| 77 | /** | ||
| 78 | * cros_ec_lpc_io_bytes_mec - Read / write bytes to MEC EMI port | ||
| 79 | * | ||
| 80 | * @io_type: MEC_IO_READ or MEC_IO_WRITE, depending on request | ||
| 81 | * @offset: Base read / write address | ||
| 82 | * @length: Number of bytes to read / write | ||
| 83 | * @buf: Destination / source buffer | ||
| 84 | * | ||
| 85 | * @return 8-bit checksum of all bytes read / written | ||
| 86 | */ | ||
| 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); | ||
| 89 | |||
| 90 | #endif /* __LINUX_MFD_CROS_EC_MEC_H */ | ||
diff --git a/include/linux/mfd/cros_ec_lpc_reg.h b/include/linux/mfd/cros_ec_lpc_reg.h new file mode 100644 index 000000000000..5560bef63c2b --- /dev/null +++ b/include/linux/mfd/cros_ec_lpc_reg.h | |||
| @@ -0,0 +1,61 @@ | |||
| 1 | /* | ||
| 2 | * cros_ec_lpc_reg - LPC access to the Chrome OS Embedded Controller | ||
| 3 | * | ||
| 4 | * Copyright (C) 2016 Google, Inc | ||
| 5 | * | ||
| 6 | * This software is licensed under the terms of the GNU General Public | ||
| 7 | * License version 2, as published by the Free Software Foundation, and | ||
| 8 | * may be copied, distributed, and modified under those terms. | ||
| 9 | * | ||
| 10 | * This program is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | * GNU General Public License for more details. | ||
| 14 | * | ||
| 15 | * This driver uses the Chrome OS EC byte-level message-based protocol for | ||
| 16 | * communicating the keyboard state (which keys are pressed) from a keyboard EC | ||
| 17 | * to the AP over some bus (such as i2c, lpc, spi). The EC does debouncing, | ||
| 18 | * but everything else (including deghosting) is done here. The main | ||
| 19 | * motivation for this is to keep the EC firmware as simple as possible, since | ||
| 20 | * it cannot be easily upgraded and EC flash/IRAM space is relatively | ||
| 21 | * expensive. | ||
| 22 | */ | ||
| 23 | |||
| 24 | #ifndef __LINUX_MFD_CROS_EC_REG_H | ||
| 25 | #define __LINUX_MFD_CROS_EC_REG_H | ||
| 26 | |||
| 27 | /** | ||
| 28 | * cros_ec_lpc_read_bytes - Read bytes from a given LPC-mapped address. | ||
| 29 | * Returns 8-bit checksum of all bytes read. | ||
| 30 | * | ||
| 31 | * @offset: Base read address | ||
| 32 | * @length: Number of bytes to read | ||
| 33 | * @dest: Destination buffer | ||
| 34 | */ | ||
| 35 | u8 cros_ec_lpc_read_bytes(unsigned int offset, unsigned int length, u8 *dest); | ||
| 36 | |||
| 37 | /** | ||
| 38 | * cros_ec_lpc_write_bytes - Write bytes to a given LPC-mapped address. | ||
| 39 | * Returns 8-bit checksum of all bytes written. | ||
| 40 | * | ||
| 41 | * @offset: Base write address | ||
| 42 | * @length: Number of bytes to write | ||
| 43 | * @msg: Write data buffer | ||
| 44 | */ | ||
| 45 | u8 cros_ec_lpc_write_bytes(unsigned int offset, unsigned int length, u8 *msg); | ||
| 46 | |||
| 47 | /** | ||
| 48 | * cros_ec_lpc_reg_init | ||
| 49 | * | ||
| 50 | * Initialize register I/O. | ||
| 51 | */ | ||
| 52 | void cros_ec_lpc_reg_init(void); | ||
| 53 | |||
| 54 | /** | ||
| 55 | * cros_ec_lpc_reg_destroy | ||
| 56 | * | ||
| 57 | * Cleanup reg I/O. | ||
| 58 | */ | ||
| 59 | void cros_ec_lpc_reg_destroy(void); | ||
| 60 | |||
| 61 | #endif /* __LINUX_MFD_CROS_EC_REG_H */ | ||
