diff options
| author | Gwendal Grignou <gwendal@chromium.org> | 2019-06-03 14:33:46 -0400 |
|---|---|---|
| committer | Lee Jones <lee.jones@linaro.org> | 2019-06-10 04:15:08 -0400 |
| commit | a517bb4bb8c15e6f427496b9bb7eba89f0b96bbb (patch) | |
| tree | 6356cc18f29d43b2366e50095c7216a70e4179d7 /include/linux | |
| parent | 2908c4ed296ee2107c03503328eb951d5bc58211 (diff) | |
mfd: cros_ec: Complete MEMS sensor API
Add new command for batched mode, add support for more sensors.
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Acked-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Acked-by: Benson Leung <bleung@chromium.org>
Reviewed-by: Fabien Lahoudere <fabien.lahoudere@collabora.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/mfd/cros_ec_commands.h | 464 |
1 files changed, 406 insertions, 58 deletions
diff --git a/include/linux/mfd/cros_ec_commands.h b/include/linux/mfd/cros_ec_commands.h index 40a8069a58e8..701b03cfa445 100644 --- a/include/linux/mfd/cros_ec_commands.h +++ b/include/linux/mfd/cros_ec_commands.h | |||
| @@ -2191,7 +2191,13 @@ enum motionsense_command { | |||
| 2191 | 2191 | ||
| 2192 | /* | 2192 | /* |
| 2193 | * EC Rate command is a setter/getter command for the EC sampling rate | 2193 | * EC Rate command is a setter/getter command for the EC sampling rate |
| 2194 | * of all motion sensors in milliseconds. | 2194 | * in milliseconds. |
| 2195 | * It is per sensor, the EC run sample task at the minimum of all | ||
| 2196 | * sensors EC_RATE. | ||
| 2197 | * For sensors without hardware FIFO, EC_RATE should be equals to 1/ODR | ||
| 2198 | * to collect all the sensor samples. | ||
| 2199 | * For sensor with hardware FIFO, EC_RATE is used as the maximal delay | ||
| 2200 | * to process of all motion sensors in milliseconds. | ||
| 2195 | */ | 2201 | */ |
| 2196 | MOTIONSENSE_CMD_EC_RATE = 2, | 2202 | MOTIONSENSE_CMD_EC_RATE = 2, |
| 2197 | 2203 | ||
| @@ -2222,32 +2228,76 @@ enum motionsense_command { | |||
| 2222 | MOTIONSENSE_CMD_DATA = 6, | 2228 | MOTIONSENSE_CMD_DATA = 6, |
| 2223 | 2229 | ||
| 2224 | /* | 2230 | /* |
| 2225 | * Perform low level calibration.. On sensors that support it, ask to | 2231 | * Return sensor fifo info. |
| 2226 | * do offset calibration. | 2232 | */ |
| 2233 | MOTIONSENSE_CMD_FIFO_INFO = 7, | ||
| 2234 | |||
| 2235 | /* | ||
| 2236 | * Insert a flush element in the fifo and return sensor fifo info. | ||
| 2237 | * The host can use that element to synchronize its operation. | ||
| 2238 | */ | ||
| 2239 | MOTIONSENSE_CMD_FIFO_FLUSH = 8, | ||
| 2240 | |||
| 2241 | /* | ||
| 2242 | * Return a portion of the fifo. | ||
| 2243 | */ | ||
| 2244 | MOTIONSENSE_CMD_FIFO_READ = 9, | ||
| 2245 | |||
| 2246 | /* | ||
| 2247 | * Perform low level calibration. | ||
| 2248 | * On sensors that support it, ask to do offset calibration. | ||
| 2227 | */ | 2249 | */ |
| 2228 | MOTIONSENSE_CMD_PERFORM_CALIB = 10, | 2250 | MOTIONSENSE_CMD_PERFORM_CALIB = 10, |
| 2229 | 2251 | ||
| 2230 | /* | 2252 | /* |
| 2231 | * Sensor Offset command is a setter/getter command for the offset used | 2253 | * Sensor Offset command is a setter/getter command for the offset |
| 2232 | * for calibration. The offsets can be calculated by the host, or via | 2254 | * used for calibration. |
| 2255 | * The offsets can be calculated by the host, or via | ||
| 2233 | * PERFORM_CALIB command. | 2256 | * PERFORM_CALIB command. |
| 2234 | */ | 2257 | */ |
| 2235 | MOTIONSENSE_CMD_SENSOR_OFFSET = 11, | 2258 | MOTIONSENSE_CMD_SENSOR_OFFSET = 11, |
| 2236 | 2259 | ||
| 2237 | /* Number of motionsense sub-commands. */ | 2260 | /* |
| 2238 | MOTIONSENSE_NUM_CMDS | 2261 | * List available activities for a MOTION sensor. |
| 2239 | }; | 2262 | * Indicates if they are enabled or disabled. |
| 2263 | */ | ||
| 2264 | MOTIONSENSE_CMD_LIST_ACTIVITIES = 12, | ||
| 2265 | |||
| 2266 | /* | ||
| 2267 | * Activity management | ||
| 2268 | * Enable/Disable activity recognition. | ||
| 2269 | */ | ||
| 2270 | MOTIONSENSE_CMD_SET_ACTIVITY = 13, | ||
| 2271 | |||
| 2272 | /* | ||
| 2273 | * Lid Angle | ||
| 2274 | */ | ||
| 2275 | MOTIONSENSE_CMD_LID_ANGLE = 14, | ||
| 2276 | |||
| 2277 | /* | ||
| 2278 | * Allow the FIFO to trigger interrupt via MKBP events. | ||
| 2279 | * By default the FIFO does not send interrupt to process the FIFO | ||
| 2280 | * until the AP is ready or it is coming from a wakeup sensor. | ||
| 2281 | */ | ||
| 2282 | MOTIONSENSE_CMD_FIFO_INT_ENABLE = 15, | ||
| 2283 | |||
| 2284 | /* | ||
| 2285 | * Spoof the readings of the sensors. The spoofed readings can be set | ||
| 2286 | * to arbitrary values, or will lock to the last read actual values. | ||
| 2287 | */ | ||
| 2288 | MOTIONSENSE_CMD_SPOOF = 16, | ||
| 2240 | 2289 | ||
| 2241 | enum motionsensor_id { | 2290 | /* Set lid angle for tablet mode detection. */ |
| 2242 | EC_MOTION_SENSOR_ACCEL_BASE = 0, | 2291 | MOTIONSENSE_CMD_TABLET_MODE_LID_ANGLE = 17, |
| 2243 | EC_MOTION_SENSOR_ACCEL_LID = 1, | ||
| 2244 | EC_MOTION_SENSOR_GYRO = 2, | ||
| 2245 | 2292 | ||
| 2246 | /* | 2293 | /* |
| 2247 | * Note, if more sensors are added and this count changes, the padding | 2294 | * Sensor Scale command is a setter/getter command for the calibration |
| 2248 | * in ec_response_motion_sense dump command must be modified. | 2295 | * scale. |
| 2249 | */ | 2296 | */ |
| 2250 | EC_MOTION_SENSOR_COUNT = 3 | 2297 | MOTIONSENSE_CMD_SENSOR_SCALE = 18, |
| 2298 | |||
| 2299 | /* Number of motionsense sub-commands. */ | ||
| 2300 | MOTIONSENSE_NUM_CMDS | ||
| 2251 | }; | 2301 | }; |
| 2252 | 2302 | ||
| 2253 | /* List of motion sensor types. */ | 2303 | /* List of motion sensor types. */ |
| @@ -2259,6 +2309,7 @@ enum motionsensor_type { | |||
| 2259 | MOTIONSENSE_TYPE_LIGHT = 4, | 2309 | MOTIONSENSE_TYPE_LIGHT = 4, |
| 2260 | MOTIONSENSE_TYPE_ACTIVITY = 5, | 2310 | MOTIONSENSE_TYPE_ACTIVITY = 5, |
| 2261 | MOTIONSENSE_TYPE_BARO = 6, | 2311 | MOTIONSENSE_TYPE_BARO = 6, |
| 2312 | MOTIONSENSE_TYPE_SYNC = 7, | ||
| 2262 | MOTIONSENSE_TYPE_MAX, | 2313 | MOTIONSENSE_TYPE_MAX, |
| 2263 | }; | 2314 | }; |
| 2264 | 2315 | ||
| @@ -2266,36 +2317,48 @@ enum motionsensor_type { | |||
| 2266 | enum motionsensor_location { | 2317 | enum motionsensor_location { |
| 2267 | MOTIONSENSE_LOC_BASE = 0, | 2318 | MOTIONSENSE_LOC_BASE = 0, |
| 2268 | MOTIONSENSE_LOC_LID = 1, | 2319 | MOTIONSENSE_LOC_LID = 1, |
| 2320 | MOTIONSENSE_LOC_CAMERA = 2, | ||
| 2269 | MOTIONSENSE_LOC_MAX, | 2321 | MOTIONSENSE_LOC_MAX, |
| 2270 | }; | 2322 | }; |
| 2271 | 2323 | ||
| 2272 | /* List of motion sensor chips. */ | 2324 | /* List of motion sensor chips. */ |
| 2273 | enum motionsensor_chip { | 2325 | enum motionsensor_chip { |
| 2274 | MOTIONSENSE_CHIP_KXCJ9 = 0, | 2326 | MOTIONSENSE_CHIP_KXCJ9 = 0, |
| 2327 | MOTIONSENSE_CHIP_LSM6DS0 = 1, | ||
| 2328 | MOTIONSENSE_CHIP_BMI160 = 2, | ||
| 2329 | MOTIONSENSE_CHIP_SI1141 = 3, | ||
| 2330 | MOTIONSENSE_CHIP_SI1142 = 4, | ||
| 2331 | MOTIONSENSE_CHIP_SI1143 = 5, | ||
| 2332 | MOTIONSENSE_CHIP_KX022 = 6, | ||
| 2333 | MOTIONSENSE_CHIP_L3GD20H = 7, | ||
| 2334 | MOTIONSENSE_CHIP_BMA255 = 8, | ||
| 2335 | MOTIONSENSE_CHIP_BMP280 = 9, | ||
| 2336 | MOTIONSENSE_CHIP_OPT3001 = 10, | ||
| 2337 | MOTIONSENSE_CHIP_BH1730 = 11, | ||
| 2338 | MOTIONSENSE_CHIP_GPIO = 12, | ||
| 2339 | MOTIONSENSE_CHIP_LIS2DH = 13, | ||
| 2340 | MOTIONSENSE_CHIP_LSM6DSM = 14, | ||
| 2341 | MOTIONSENSE_CHIP_LIS2DE = 15, | ||
| 2342 | MOTIONSENSE_CHIP_LIS2MDL = 16, | ||
| 2343 | MOTIONSENSE_CHIP_LSM6DS3 = 17, | ||
| 2344 | MOTIONSENSE_CHIP_LSM6DSO = 18, | ||
| 2345 | MOTIONSENSE_CHIP_LNG2DM = 19, | ||
| 2346 | MOTIONSENSE_CHIP_MAX, | ||
| 2275 | }; | 2347 | }; |
| 2276 | 2348 | ||
| 2277 | /* Module flag masks used for the dump sub-command. */ | 2349 | /* List of orientation positions */ |
| 2278 | #define MOTIONSENSE_MODULE_FLAG_ACTIVE (1<<0) | 2350 | enum motionsensor_orientation { |
| 2279 | 2351 | MOTIONSENSE_ORIENTATION_LANDSCAPE = 0, | |
| 2280 | /* Sensor flag masks used for the dump sub-command. */ | 2352 | MOTIONSENSE_ORIENTATION_PORTRAIT = 1, |
| 2281 | #define MOTIONSENSE_SENSOR_FLAG_PRESENT (1<<0) | 2353 | MOTIONSENSE_ORIENTATION_UPSIDE_DOWN_PORTRAIT = 2, |
| 2282 | 2354 | MOTIONSENSE_ORIENTATION_UPSIDE_DOWN_LANDSCAPE = 3, | |
| 2283 | /* | 2355 | MOTIONSENSE_ORIENTATION_UNKNOWN = 4, |
| 2284 | * Send this value for the data element to only perform a read. If you | 2356 | }; |
| 2285 | * send any other value, the EC will interpret it as data to set and will | ||
| 2286 | * return the actual value set. | ||
| 2287 | */ | ||
| 2288 | #define EC_MOTION_SENSE_NO_VALUE -1 | ||
| 2289 | |||
| 2290 | #define EC_MOTION_SENSE_INVALID_CALIB_TEMP 0x8000 | ||
| 2291 | |||
| 2292 | /* Set Calibration information */ | ||
| 2293 | #define MOTION_SENSE_SET_OFFSET 1 | ||
| 2294 | 2357 | ||
| 2295 | struct ec_response_motion_sensor_data { | 2358 | struct ec_response_motion_sensor_data { |
| 2296 | /* Flags for each sensor. */ | 2359 | /* Flags for each sensor. */ |
| 2297 | uint8_t flags; | 2360 | uint8_t flags; |
| 2298 | /* Sensor number the data comes from */ | 2361 | /* Sensor number the data comes from. */ |
| 2299 | uint8_t sensor_num; | 2362 | uint8_t sensor_num; |
| 2300 | /* Each sensor is up to 3-axis. */ | 2363 | /* Each sensor is up to 3-axis. */ |
| 2301 | union { | 2364 | union { |
| @@ -2312,22 +2375,138 @@ struct ec_response_motion_sensor_data { | |||
| 2312 | }; | 2375 | }; |
| 2313 | } __ec_todo_packed; | 2376 | } __ec_todo_packed; |
| 2314 | 2377 | ||
| 2378 | /* Note: used in ec_response_get_next_data */ | ||
| 2379 | struct ec_response_motion_sense_fifo_info { | ||
| 2380 | /* Size of the fifo */ | ||
| 2381 | uint16_t size; | ||
| 2382 | /* Amount of space used in the fifo */ | ||
| 2383 | uint16_t count; | ||
| 2384 | /* Timestamp recorded in us. | ||
| 2385 | * aka accurate timestamp when host event was triggered. | ||
| 2386 | */ | ||
| 2387 | uint32_t timestamp; | ||
| 2388 | /* Total amount of vector lost */ | ||
| 2389 | uint16_t total_lost; | ||
| 2390 | /* Lost events since the last fifo_info, per sensors */ | ||
| 2391 | uint16_t lost[0]; | ||
| 2392 | } __ec_todo_packed; | ||
| 2393 | |||
| 2394 | struct ec_response_motion_sense_fifo_data { | ||
| 2395 | uint32_t number_data; | ||
| 2396 | struct ec_response_motion_sensor_data data[0]; | ||
| 2397 | } __ec_todo_packed; | ||
| 2398 | |||
| 2399 | /* List supported activity recognition */ | ||
| 2400 | enum motionsensor_activity { | ||
| 2401 | MOTIONSENSE_ACTIVITY_RESERVED = 0, | ||
| 2402 | MOTIONSENSE_ACTIVITY_SIG_MOTION = 1, | ||
| 2403 | MOTIONSENSE_ACTIVITY_DOUBLE_TAP = 2, | ||
| 2404 | MOTIONSENSE_ACTIVITY_ORIENTATION = 3, | ||
| 2405 | }; | ||
| 2406 | |||
| 2407 | struct ec_motion_sense_activity { | ||
| 2408 | uint8_t sensor_num; | ||
| 2409 | uint8_t activity; /* one of enum motionsensor_activity */ | ||
| 2410 | uint8_t enable; /* 1: enable, 0: disable */ | ||
| 2411 | uint8_t reserved; | ||
| 2412 | uint16_t parameters[3]; /* activity dependent parameters */ | ||
| 2413 | } __ec_todo_unpacked; | ||
| 2414 | |||
| 2415 | /* Module flag masks used for the dump sub-command. */ | ||
| 2416 | #define MOTIONSENSE_MODULE_FLAG_ACTIVE BIT(0) | ||
| 2417 | |||
| 2418 | /* Sensor flag masks used for the dump sub-command. */ | ||
| 2419 | #define MOTIONSENSE_SENSOR_FLAG_PRESENT BIT(0) | ||
| 2420 | |||
| 2421 | /* | ||
| 2422 | * Flush entry for synchronization. | ||
| 2423 | * data contains time stamp | ||
| 2424 | */ | ||
| 2425 | #define MOTIONSENSE_SENSOR_FLAG_FLUSH BIT(0) | ||
| 2426 | #define MOTIONSENSE_SENSOR_FLAG_TIMESTAMP BIT(1) | ||
| 2427 | #define MOTIONSENSE_SENSOR_FLAG_WAKEUP BIT(2) | ||
| 2428 | #define MOTIONSENSE_SENSOR_FLAG_TABLET_MODE BIT(3) | ||
| 2429 | #define MOTIONSENSE_SENSOR_FLAG_ODR BIT(4) | ||
| 2430 | |||
| 2431 | /* | ||
| 2432 | * Send this value for the data element to only perform a read. If you | ||
| 2433 | * send any other value, the EC will interpret it as data to set and will | ||
| 2434 | * return the actual value set. | ||
| 2435 | */ | ||
| 2436 | #define EC_MOTION_SENSE_NO_VALUE -1 | ||
| 2437 | |||
| 2438 | #define EC_MOTION_SENSE_INVALID_CALIB_TEMP 0x8000 | ||
| 2439 | |||
| 2440 | /* MOTIONSENSE_CMD_SENSOR_OFFSET subcommand flag */ | ||
| 2441 | /* Set Calibration information */ | ||
| 2442 | #define MOTION_SENSE_SET_OFFSET BIT(0) | ||
| 2443 | |||
| 2444 | /* Default Scale value, factor 1. */ | ||
| 2445 | #define MOTION_SENSE_DEFAULT_SCALE BIT(15) | ||
| 2446 | |||
| 2447 | #define LID_ANGLE_UNRELIABLE 500 | ||
| 2448 | |||
| 2449 | enum motionsense_spoof_mode { | ||
| 2450 | /* Disable spoof mode. */ | ||
| 2451 | MOTIONSENSE_SPOOF_MODE_DISABLE = 0, | ||
| 2452 | |||
| 2453 | /* Enable spoof mode, but use provided component values. */ | ||
| 2454 | MOTIONSENSE_SPOOF_MODE_CUSTOM, | ||
| 2455 | |||
| 2456 | /* Enable spoof mode, but use the current sensor values. */ | ||
| 2457 | MOTIONSENSE_SPOOF_MODE_LOCK_CURRENT, | ||
| 2458 | |||
| 2459 | /* Query the current spoof mode status for the sensor. */ | ||
| 2460 | MOTIONSENSE_SPOOF_MODE_QUERY, | ||
| 2461 | }; | ||
| 2462 | |||
| 2315 | struct ec_params_motion_sense { | 2463 | struct ec_params_motion_sense { |
| 2316 | uint8_t cmd; | 2464 | uint8_t cmd; |
| 2317 | union { | 2465 | union { |
| 2318 | /* Used for MOTIONSENSE_CMD_DUMP. */ | 2466 | /* Used for MOTIONSENSE_CMD_DUMP. */ |
| 2319 | struct __ec_todo_unpacked { | 2467 | struct __ec_todo_unpacked { |
| 2320 | /* no args */ | 2468 | /* |
| 2469 | * Maximal number of sensor the host is expecting. | ||
| 2470 | * 0 means the host is only interested in the number | ||
| 2471 | * of sensors controlled by the EC. | ||
| 2472 | */ | ||
| 2473 | uint8_t max_sensor_count; | ||
| 2321 | } dump; | 2474 | } dump; |
| 2322 | 2475 | ||
| 2323 | /* | 2476 | /* |
| 2324 | * Used for MOTIONSENSE_CMD_EC_RATE and | 2477 | * Used for MOTIONSENSE_CMD_KB_WAKE_ANGLE. |
| 2325 | * MOTIONSENSE_CMD_KB_WAKE_ANGLE. | ||
| 2326 | */ | 2478 | */ |
| 2327 | struct __ec_todo_unpacked { | 2479 | struct __ec_todo_unpacked { |
| 2328 | /* Data to set or EC_MOTION_SENSE_NO_VALUE to read. */ | 2480 | /* Data to set or EC_MOTION_SENSE_NO_VALUE to read. |
| 2481 | * kb_wake_angle: angle to wakup AP. | ||
| 2482 | */ | ||
| 2329 | int16_t data; | 2483 | int16_t data; |
| 2330 | } ec_rate, kb_wake_angle; | 2484 | } kb_wake_angle; |
| 2485 | |||
| 2486 | /* | ||
| 2487 | * Used for MOTIONSENSE_CMD_INFO, MOTIONSENSE_CMD_DATA | ||
| 2488 | * and MOTIONSENSE_CMD_PERFORM_CALIB. | ||
| 2489 | */ | ||
| 2490 | struct __ec_todo_unpacked { | ||
| 2491 | uint8_t sensor_num; | ||
| 2492 | } info, info_3, data, fifo_flush, perform_calib, | ||
| 2493 | list_activities; | ||
| 2494 | |||
| 2495 | /* | ||
| 2496 | * Used for MOTIONSENSE_CMD_EC_RATE, MOTIONSENSE_CMD_SENSOR_ODR | ||
| 2497 | * and MOTIONSENSE_CMD_SENSOR_RANGE. | ||
| 2498 | */ | ||
| 2499 | struct __ec_todo_unpacked { | ||
| 2500 | uint8_t sensor_num; | ||
| 2501 | |||
| 2502 | /* Rounding flag, true for round-up, false for down. */ | ||
| 2503 | uint8_t roundup; | ||
| 2504 | |||
| 2505 | uint16_t reserved; | ||
| 2506 | |||
| 2507 | /* Data to set or EC_MOTION_SENSE_NO_VALUE to read. */ | ||
| 2508 | int32_t data; | ||
| 2509 | } ec_rate, sensor_odr, sensor_range; | ||
| 2331 | 2510 | ||
| 2332 | /* Used for MOTIONSENSE_CMD_SENSOR_OFFSET */ | 2511 | /* Used for MOTIONSENSE_CMD_SENSOR_OFFSET */ |
| 2333 | struct __ec_todo_packed { | 2512 | struct __ec_todo_packed { |
| @@ -2358,33 +2537,99 @@ struct ec_params_motion_sense { | |||
| 2358 | int16_t offset[3]; | 2537 | int16_t offset[3]; |
| 2359 | } sensor_offset; | 2538 | } sensor_offset; |
| 2360 | 2539 | ||
| 2361 | /* Used for MOTIONSENSE_CMD_INFO. */ | 2540 | /* Used for MOTIONSENSE_CMD_SENSOR_SCALE */ |
| 2362 | struct __ec_todo_packed { | 2541 | struct __ec_todo_packed { |
| 2363 | uint8_t sensor_num; | 2542 | uint8_t sensor_num; |
| 2364 | } info; | ||
| 2365 | 2543 | ||
| 2366 | /* | 2544 | /* |
| 2367 | * Used for MOTIONSENSE_CMD_SENSOR_ODR and | 2545 | * bit 0: If set (MOTION_SENSE_SET_OFFSET), set |
| 2368 | * MOTIONSENSE_CMD_SENSOR_RANGE. | 2546 | * the calibration information in the EC. |
| 2369 | */ | 2547 | * If unset, just retrieve calibration information. |
| 2370 | struct { | 2548 | */ |
| 2371 | /* Should be element of enum motionsensor_id. */ | 2549 | uint16_t flags; |
| 2372 | uint8_t sensor_num; | ||
| 2373 | 2550 | ||
| 2374 | /* Rounding flag, true for round-up, false for down. */ | 2551 | /* |
| 2375 | uint8_t roundup; | 2552 | * Temperature at calibration, in units of 0.01 C |
| 2553 | * 0x8000: invalid / unknown. | ||
| 2554 | * 0x0: 0C | ||
| 2555 | * 0x7fff: +327.67C | ||
| 2556 | */ | ||
| 2557 | int16_t temp; | ||
| 2376 | 2558 | ||
| 2377 | uint16_t reserved; | 2559 | /* |
| 2560 | * Scale for calibration: | ||
| 2561 | * By default scale is 1, it is encoded on 16bits: | ||
| 2562 | * 1 = BIT(15) | ||
| 2563 | * ~2 = 0xFFFF | ||
| 2564 | * ~0 = 0. | ||
| 2565 | */ | ||
| 2566 | uint16_t scale[3]; | ||
| 2567 | } sensor_scale; | ||
| 2378 | 2568 | ||
| 2379 | /* Data to set or EC_MOTION_SENSE_NO_VALUE to read. */ | 2569 | |
| 2380 | int32_t data; | 2570 | /* Used for MOTIONSENSE_CMD_FIFO_INFO */ |
| 2381 | } sensor_odr, sensor_range; | 2571 | /* (no params) */ |
| 2572 | |||
| 2573 | /* Used for MOTIONSENSE_CMD_FIFO_READ */ | ||
| 2574 | struct __ec_todo_unpacked { | ||
| 2575 | /* | ||
| 2576 | * Number of expected vector to return. | ||
| 2577 | * EC may return less or 0 if none available. | ||
| 2578 | */ | ||
| 2579 | uint32_t max_data_vector; | ||
| 2580 | } fifo_read; | ||
| 2581 | |||
| 2582 | struct ec_motion_sense_activity set_activity; | ||
| 2583 | |||
| 2584 | /* Used for MOTIONSENSE_CMD_LID_ANGLE */ | ||
| 2585 | /* (no params) */ | ||
| 2586 | |||
| 2587 | /* Used for MOTIONSENSE_CMD_FIFO_INT_ENABLE */ | ||
| 2588 | struct __ec_todo_unpacked { | ||
| 2589 | /* | ||
| 2590 | * 1: enable, 0 disable fifo, | ||
| 2591 | * EC_MOTION_SENSE_NO_VALUE return value. | ||
| 2592 | */ | ||
| 2593 | int8_t enable; | ||
| 2594 | } fifo_int_enable; | ||
| 2595 | |||
| 2596 | /* Used for MOTIONSENSE_CMD_SPOOF */ | ||
| 2597 | struct __ec_todo_packed { | ||
| 2598 | uint8_t sensor_id; | ||
| 2599 | |||
| 2600 | /* See enum motionsense_spoof_mode. */ | ||
| 2601 | uint8_t spoof_enable; | ||
| 2602 | |||
| 2603 | /* Ignored, used for alignment. */ | ||
| 2604 | uint8_t reserved; | ||
| 2605 | |||
| 2606 | /* Individual component values to spoof. */ | ||
| 2607 | int16_t components[3]; | ||
| 2608 | } spoof; | ||
| 2609 | |||
| 2610 | /* Used for MOTIONSENSE_CMD_TABLET_MODE_LID_ANGLE. */ | ||
| 2611 | struct __ec_todo_unpacked { | ||
| 2612 | /* | ||
| 2613 | * Lid angle threshold for switching between tablet and | ||
| 2614 | * clamshell mode. | ||
| 2615 | */ | ||
| 2616 | int16_t lid_angle; | ||
| 2617 | |||
| 2618 | /* | ||
| 2619 | * Hysteresis degree to prevent fluctuations between | ||
| 2620 | * clamshell and tablet mode if lid angle keeps | ||
| 2621 | * changing around the threshold. Lid motion driver will | ||
| 2622 | * use lid_angle + hys_degree to trigger tablet mode and | ||
| 2623 | * lid_angle - hys_degree to trigger clamshell mode. | ||
| 2624 | */ | ||
| 2625 | int16_t hys_degree; | ||
| 2626 | } tablet_mode_threshold; | ||
| 2382 | }; | 2627 | }; |
| 2383 | } __ec_todo_packed; | 2628 | } __ec_todo_packed; |
| 2384 | 2629 | ||
| 2385 | struct ec_response_motion_sense { | 2630 | struct ec_response_motion_sense { |
| 2386 | union { | 2631 | union { |
| 2387 | /* Used for MOTIONSENSE_CMD_DUMP. */ | 2632 | /* Used for MOTIONSENSE_CMD_DUMP */ |
| 2388 | struct __ec_todo_unpacked { | 2633 | struct __ec_todo_unpacked { |
| 2389 | /* Flags representing the motion sensor module. */ | 2634 | /* Flags representing the motion sensor module. */ |
| 2390 | uint8_t module_flags; | 2635 | uint8_t module_flags; |
| @@ -2411,28 +2656,119 @@ struct ec_response_motion_sense { | |||
| 2411 | uint8_t chip; | 2656 | uint8_t chip; |
| 2412 | } info; | 2657 | } info; |
| 2413 | 2658 | ||
| 2659 | /* Used for MOTIONSENSE_CMD_INFO version 3 */ | ||
| 2660 | struct __ec_todo_unpacked { | ||
| 2661 | /* Should be element of enum motionsensor_type. */ | ||
| 2662 | uint8_t type; | ||
| 2663 | |||
| 2664 | /* Should be element of enum motionsensor_location. */ | ||
| 2665 | uint8_t location; | ||
| 2666 | |||
| 2667 | /* Should be element of enum motionsensor_chip. */ | ||
| 2668 | uint8_t chip; | ||
| 2669 | |||
| 2670 | /* Minimum sensor sampling frequency */ | ||
| 2671 | uint32_t min_frequency; | ||
| 2672 | |||
| 2673 | /* Maximum sensor sampling frequency */ | ||
| 2674 | uint32_t max_frequency; | ||
| 2675 | |||
| 2676 | /* Max number of sensor events that could be in fifo */ | ||
| 2677 | uint32_t fifo_max_event_count; | ||
| 2678 | } info_3; | ||
| 2679 | |||
| 2414 | /* Used for MOTIONSENSE_CMD_DATA */ | 2680 | /* Used for MOTIONSENSE_CMD_DATA */ |
| 2415 | struct ec_response_motion_sensor_data data; | 2681 | struct ec_response_motion_sensor_data data; |
| 2416 | 2682 | ||
| 2417 | /* | 2683 | /* |
| 2418 | * Used for MOTIONSENSE_CMD_EC_RATE, MOTIONSENSE_CMD_SENSOR_ODR, | 2684 | * Used for MOTIONSENSE_CMD_EC_RATE, MOTIONSENSE_CMD_SENSOR_ODR, |
| 2419 | * MOTIONSENSE_CMD_SENSOR_RANGE, and | 2685 | * MOTIONSENSE_CMD_SENSOR_RANGE, |
| 2420 | * MOTIONSENSE_CMD_KB_WAKE_ANGLE. | 2686 | * MOTIONSENSE_CMD_KB_WAKE_ANGLE, |
| 2687 | * MOTIONSENSE_CMD_FIFO_INT_ENABLE and | ||
| 2688 | * MOTIONSENSE_CMD_SPOOF. | ||
| 2421 | */ | 2689 | */ |
| 2422 | struct __ec_todo_unpacked { | 2690 | struct __ec_todo_unpacked { |
| 2423 | /* Current value of the parameter queried. */ | 2691 | /* Current value of the parameter queried. */ |
| 2424 | int32_t ret; | 2692 | int32_t ret; |
| 2425 | } ec_rate, sensor_odr, sensor_range, kb_wake_angle; | 2693 | } ec_rate, sensor_odr, sensor_range, kb_wake_angle, |
| 2694 | fifo_int_enable, spoof; | ||
| 2426 | 2695 | ||
| 2427 | /* Used for MOTIONSENSE_CMD_SENSOR_OFFSET */ | 2696 | /* |
| 2697 | * Used for MOTIONSENSE_CMD_SENSOR_OFFSET, | ||
| 2698 | * PERFORM_CALIB. | ||
| 2699 | */ | ||
| 2428 | struct __ec_todo_unpacked { | 2700 | struct __ec_todo_unpacked { |
| 2429 | int16_t temp; | 2701 | int16_t temp; |
| 2430 | int16_t offset[3]; | 2702 | int16_t offset[3]; |
| 2431 | } sensor_offset, perform_calib; | 2703 | } sensor_offset, perform_calib; |
| 2704 | |||
| 2705 | /* Used for MOTIONSENSE_CMD_SENSOR_SCALE */ | ||
| 2706 | struct __ec_todo_unpacked { | ||
| 2707 | int16_t temp; | ||
| 2708 | uint16_t scale[3]; | ||
| 2709 | } sensor_scale; | ||
| 2710 | |||
| 2711 | struct ec_response_motion_sense_fifo_info fifo_info, fifo_flush; | ||
| 2712 | |||
| 2713 | struct ec_response_motion_sense_fifo_data fifo_read; | ||
| 2714 | |||
| 2715 | struct __ec_todo_packed { | ||
| 2716 | uint16_t reserved; | ||
| 2717 | uint32_t enabled; | ||
| 2718 | uint32_t disabled; | ||
| 2719 | } list_activities; | ||
| 2720 | |||
| 2721 | /* No params for set activity */ | ||
| 2722 | |||
| 2723 | /* Used for MOTIONSENSE_CMD_LID_ANGLE */ | ||
| 2724 | struct __ec_todo_unpacked { | ||
| 2725 | /* | ||
| 2726 | * Angle between 0 and 360 degree if available, | ||
| 2727 | * LID_ANGLE_UNRELIABLE otherwise. | ||
| 2728 | */ | ||
| 2729 | uint16_t value; | ||
| 2730 | } lid_angle; | ||
| 2731 | |||
| 2732 | /* Used for MOTIONSENSE_CMD_TABLET_MODE_LID_ANGLE. */ | ||
| 2733 | struct __ec_todo_unpacked { | ||
| 2734 | /* | ||
| 2735 | * Lid angle threshold for switching between tablet and | ||
| 2736 | * clamshell mode. | ||
| 2737 | */ | ||
| 2738 | uint16_t lid_angle; | ||
| 2739 | |||
| 2740 | /* Hysteresis degree. */ | ||
| 2741 | uint16_t hys_degree; | ||
| 2742 | } tablet_mode_threshold; | ||
| 2743 | |||
| 2432 | }; | 2744 | }; |
| 2433 | } __ec_todo_packed; | 2745 | } __ec_todo_packed; |
| 2434 | 2746 | ||
| 2435 | /*****************************************************************************/ | 2747 | /*****************************************************************************/ |
| 2748 | /* Force lid open command */ | ||
| 2749 | |||
| 2750 | /* Make lid event always open */ | ||
| 2751 | #define EC_CMD_FORCE_LID_OPEN 0x002C | ||
| 2752 | |||
| 2753 | struct ec_params_force_lid_open { | ||
| 2754 | uint8_t enabled; | ||
| 2755 | } __ec_align1; | ||
| 2756 | |||
| 2757 | /*****************************************************************************/ | ||
| 2758 | /* Configure the behavior of the power button */ | ||
| 2759 | #define EC_CMD_CONFIG_POWER_BUTTON 0x002D | ||
| 2760 | |||
| 2761 | enum ec_config_power_button_flags { | ||
| 2762 | /* Enable/Disable power button pulses for x86 devices */ | ||
| 2763 | EC_POWER_BUTTON_ENABLE_PULSE = BIT(0), | ||
| 2764 | }; | ||
| 2765 | |||
| 2766 | struct ec_params_config_power_button { | ||
| 2767 | /* See enum ec_config_power_button_flags */ | ||
| 2768 | uint8_t flags; | ||
| 2769 | } __ec_align1; | ||
| 2770 | |||
| 2771 | /*****************************************************************************/ | ||
| 2436 | /* USB charging control commands */ | 2772 | /* USB charging control commands */ |
| 2437 | 2773 | ||
| 2438 | /* Set USB port charging mode */ | 2774 | /* Set USB port charging mode */ |
| @@ -2888,6 +3224,12 @@ union __ec_align_offset1 ec_response_get_next_data { | |||
| 2888 | /* Unaligned */ | 3224 | /* Unaligned */ |
| 2889 | uint32_t host_event; | 3225 | uint32_t host_event; |
| 2890 | 3226 | ||
| 3227 | struct __ec_todo_unpacked { | ||
| 3228 | /* For aligning the fifo_info */ | ||
| 3229 | uint8_t reserved[3]; | ||
| 3230 | struct ec_response_motion_sense_fifo_info info; | ||
| 3231 | } sensor_fifo; | ||
| 3232 | |||
| 2891 | uint32_t buttons; | 3233 | uint32_t buttons; |
| 2892 | uint32_t switches; | 3234 | uint32_t switches; |
| 2893 | uint32_t sysrq; | 3235 | uint32_t sysrq; |
| @@ -2896,6 +3238,12 @@ union __ec_align_offset1 ec_response_get_next_data { | |||
| 2896 | union __ec_align_offset1 ec_response_get_next_data_v1 { | 3238 | union __ec_align_offset1 ec_response_get_next_data_v1 { |
| 2897 | uint8_t key_matrix[16]; | 3239 | uint8_t key_matrix[16]; |
| 2898 | uint32_t host_event; | 3240 | uint32_t host_event; |
| 3241 | struct __ec_todo_unpacked { | ||
| 3242 | /* For aligning the fifo_info */ | ||
| 3243 | uint8_t reserved[3]; | ||
| 3244 | struct ec_response_motion_sense_fifo_info info; | ||
| 3245 | } sensor_fifo; | ||
| 3246 | |||
| 2899 | uint32_t buttons; | 3247 | uint32_t buttons; |
| 2900 | uint32_t switches; | 3248 | uint32_t switches; |
| 2901 | uint32_t sysrq; | 3249 | uint32_t sysrq; |
