aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2019-06-03 14:33:57 -0400
committerLee Jones <lee.jones@linaro.org>2019-06-10 04:15:08 -0400
commitda038d6ee7a4e791eba6b1954a6c49f4f2856786 (patch)
treea8d08af8509bf38dccdad244ec37b64a12b3716a /include/linux
parent6f9d485ca4c5d3ac223a1e49f604192be12e0676 (diff)
mfd: cros_ec: Add API for Fingerprint support
Add API for fingerprint sensor presented by embedded controller. 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.h228
1 files changed, 228 insertions, 0 deletions
diff --git a/include/linux/mfd/cros_ec_commands.h b/include/linux/mfd/cros_ec_commands.h
index 1d0311df44d3..4a9ac3861bdd 100644
--- a/include/linux/mfd/cros_ec_commands.h
+++ b/include/linux/mfd/cros_ec_commands.h
@@ -5044,6 +5044,234 @@ struct ec_response_pd_chip_info_v1 {
5044} __ec_align2; 5044} __ec_align2;
5045 5045
5046/*****************************************************************************/ 5046/*****************************************************************************/
5047/* Fingerprint MCU commands: range 0x0400-0x040x */
5048
5049/* Fingerprint SPI sensor passthru command: prototyping ONLY */
5050#define EC_CMD_FP_PASSTHRU 0x0400
5051
5052#define EC_FP_FLAG_NOT_COMPLETE 0x1
5053
5054struct ec_params_fp_passthru {
5055 uint16_t len; /* Number of bytes to write then read */
5056 uint16_t flags; /* EC_FP_FLAG_xxx */
5057 uint8_t data[]; /* Data to send */
5058} __ec_align2;
5059
5060/* Configure the Fingerprint MCU behavior */
5061#define EC_CMD_FP_MODE 0x0402
5062
5063/* Put the sensor in its lowest power mode */
5064#define FP_MODE_DEEPSLEEP BIT(0)
5065/* Wait to see a finger on the sensor */
5066#define FP_MODE_FINGER_DOWN BIT(1)
5067/* Poll until the finger has left the sensor */
5068#define FP_MODE_FINGER_UP BIT(2)
5069/* Capture the current finger image */
5070#define FP_MODE_CAPTURE BIT(3)
5071/* Finger enrollment session on-going */
5072#define FP_MODE_ENROLL_SESSION BIT(4)
5073/* Enroll the current finger image */
5074#define FP_MODE_ENROLL_IMAGE BIT(5)
5075/* Try to match the current finger image */
5076#define FP_MODE_MATCH BIT(6)
5077/* Reset and re-initialize the sensor. */
5078#define FP_MODE_RESET_SENSOR BIT(7)
5079/* special value: don't change anything just read back current mode */
5080#define FP_MODE_DONT_CHANGE BIT(31)
5081
5082#define FP_VALID_MODES (FP_MODE_DEEPSLEEP | \
5083 FP_MODE_FINGER_DOWN | \
5084 FP_MODE_FINGER_UP | \
5085 FP_MODE_CAPTURE | \
5086 FP_MODE_ENROLL_SESSION | \
5087 FP_MODE_ENROLL_IMAGE | \
5088 FP_MODE_MATCH | \
5089 FP_MODE_RESET_SENSOR | \
5090 FP_MODE_DONT_CHANGE)
5091
5092/* Capture types defined in bits [30..28] */
5093#define FP_MODE_CAPTURE_TYPE_SHIFT 28
5094#define FP_MODE_CAPTURE_TYPE_MASK (0x7 << FP_MODE_CAPTURE_TYPE_SHIFT)
5095/*
5096 * This enum must remain ordered, if you add new values you must ensure that
5097 * FP_CAPTURE_TYPE_MAX is still the last one.
5098 */
5099enum fp_capture_type {
5100 /* Full blown vendor-defined capture (produces 'frame_size' bytes) */
5101 FP_CAPTURE_VENDOR_FORMAT = 0,
5102 /* Simple raw image capture (produces width x height x bpp bits) */
5103 FP_CAPTURE_SIMPLE_IMAGE = 1,
5104 /* Self test pattern (e.g. checkerboard) */
5105 FP_CAPTURE_PATTERN0 = 2,
5106 /* Self test pattern (e.g. inverted checkerboard) */
5107 FP_CAPTURE_PATTERN1 = 3,
5108 /* Capture for Quality test with fixed contrast */
5109 FP_CAPTURE_QUALITY_TEST = 4,
5110 /* Capture for pixel reset value test */
5111 FP_CAPTURE_RESET_TEST = 5,
5112 FP_CAPTURE_TYPE_MAX,
5113};
5114/* Extracts the capture type from the sensor 'mode' word */
5115#define FP_CAPTURE_TYPE(mode) (((mode) & FP_MODE_CAPTURE_TYPE_MASK) \
5116 >> FP_MODE_CAPTURE_TYPE_SHIFT)
5117
5118struct ec_params_fp_mode {
5119 uint32_t mode; /* as defined by FP_MODE_ constants */
5120} __ec_align4;
5121
5122struct ec_response_fp_mode {
5123 uint32_t mode; /* as defined by FP_MODE_ constants */
5124} __ec_align4;
5125
5126/* Retrieve Fingerprint sensor information */
5127#define EC_CMD_FP_INFO 0x0403
5128
5129/* Number of dead pixels detected on the last maintenance */
5130#define FP_ERROR_DEAD_PIXELS(errors) ((errors) & 0x3FF)
5131/* Unknown number of dead pixels detected on the last maintenance */
5132#define FP_ERROR_DEAD_PIXELS_UNKNOWN (0x3FF)
5133/* No interrupt from the sensor */
5134#define FP_ERROR_NO_IRQ BIT(12)
5135/* SPI communication error */
5136#define FP_ERROR_SPI_COMM BIT(13)
5137/* Invalid sensor Hardware ID */
5138#define FP_ERROR_BAD_HWID BIT(14)
5139/* Sensor initialization failed */
5140#define FP_ERROR_INIT_FAIL BIT(15)
5141
5142struct ec_response_fp_info_v0 {
5143 /* Sensor identification */
5144 uint32_t vendor_id;
5145 uint32_t product_id;
5146 uint32_t model_id;
5147 uint32_t version;
5148 /* Image frame characteristics */
5149 uint32_t frame_size;
5150 uint32_t pixel_format; /* using V4L2_PIX_FMT_ */
5151 uint16_t width;
5152 uint16_t height;
5153 uint16_t bpp;
5154 uint16_t errors; /* see FP_ERROR_ flags above */
5155} __ec_align4;
5156
5157struct ec_response_fp_info {
5158 /* Sensor identification */
5159 uint32_t vendor_id;
5160 uint32_t product_id;
5161 uint32_t model_id;
5162 uint32_t version;
5163 /* Image frame characteristics */
5164 uint32_t frame_size;
5165 uint32_t pixel_format; /* using V4L2_PIX_FMT_ */
5166 uint16_t width;
5167 uint16_t height;
5168 uint16_t bpp;
5169 uint16_t errors; /* see FP_ERROR_ flags above */
5170 /* Template/finger current information */
5171 uint32_t template_size; /* max template size in bytes */
5172 uint16_t template_max; /* maximum number of fingers/templates */
5173 uint16_t template_valid; /* number of valid fingers/templates */
5174 uint32_t template_dirty; /* bitmap of templates with MCU side changes */
5175 uint32_t template_version; /* version of the template format */
5176} __ec_align4;
5177
5178/* Get the last captured finger frame or a template content */
5179#define EC_CMD_FP_FRAME 0x0404
5180
5181/* constants defining the 'offset' field which also contains the frame index */
5182#define FP_FRAME_INDEX_SHIFT 28
5183/* Frame buffer where the captured image is stored */
5184#define FP_FRAME_INDEX_RAW_IMAGE 0
5185/* First frame buffer holding a template */
5186#define FP_FRAME_INDEX_TEMPLATE 1
5187#define FP_FRAME_GET_BUFFER_INDEX(offset) ((offset) >> FP_FRAME_INDEX_SHIFT)
5188#define FP_FRAME_OFFSET_MASK 0x0FFFFFFF
5189
5190/* Version of the format of the encrypted templates. */
5191#define FP_TEMPLATE_FORMAT_VERSION 3
5192
5193/* Constants for encryption parameters */
5194#define FP_CONTEXT_NONCE_BYTES 12
5195#define FP_CONTEXT_USERID_WORDS (32 / sizeof(uint32_t))
5196#define FP_CONTEXT_TAG_BYTES 16
5197#define FP_CONTEXT_SALT_BYTES 16
5198#define FP_CONTEXT_TPM_BYTES 32
5199
5200struct ec_fp_template_encryption_metadata {
5201 /*
5202 * Version of the structure format (N=3).
5203 */
5204 uint16_t struct_version;
5205 /* Reserved bytes, set to 0. */
5206 uint16_t reserved;
5207 /*
5208 * The salt is *only* ever used for key derivation. The nonce is unique,
5209 * a different one is used for every message.
5210 */
5211 uint8_t nonce[FP_CONTEXT_NONCE_BYTES];
5212 uint8_t salt[FP_CONTEXT_SALT_BYTES];
5213 uint8_t tag[FP_CONTEXT_TAG_BYTES];
5214};
5215
5216struct ec_params_fp_frame {
5217 /*
5218 * The offset contains the template index or FP_FRAME_INDEX_RAW_IMAGE
5219 * in the high nibble, and the real offset within the frame in
5220 * FP_FRAME_OFFSET_MASK.
5221 */
5222 uint32_t offset;
5223 uint32_t size;
5224} __ec_align4;
5225
5226/* Load a template into the MCU */
5227#define EC_CMD_FP_TEMPLATE 0x0405
5228
5229/* Flag in the 'size' field indicating that the full template has been sent */
5230#define FP_TEMPLATE_COMMIT 0x80000000
5231
5232struct ec_params_fp_template {
5233 uint32_t offset;
5234 uint32_t size;
5235 uint8_t data[];
5236} __ec_align4;
5237
5238/* Clear the current fingerprint user context and set a new one */
5239#define EC_CMD_FP_CONTEXT 0x0406
5240
5241struct ec_params_fp_context {
5242 uint32_t userid[FP_CONTEXT_USERID_WORDS];
5243} __ec_align4;
5244
5245#define EC_CMD_FP_STATS 0x0407
5246
5247#define FPSTATS_CAPTURE_INV BIT(0)
5248#define FPSTATS_MATCHING_INV BIT(1)
5249
5250struct ec_response_fp_stats {
5251 uint32_t capture_time_us;
5252 uint32_t matching_time_us;
5253 uint32_t overall_time_us;
5254 struct {
5255 uint32_t lo;
5256 uint32_t hi;
5257 } overall_t0;
5258 uint8_t timestamps_invalid;
5259 int8_t template_matched;
5260} __ec_align2;
5261
5262#define EC_CMD_FP_SEED 0x0408
5263struct ec_params_fp_seed {
5264 /*
5265 * Version of the structure format (N=3).
5266 */
5267 uint16_t struct_version;
5268 /* Reserved bytes, set to 0. */
5269 uint16_t reserved;
5270 /* Seed from the TPM. */
5271 uint8_t seed[FP_CONTEXT_TPM_BYTES];
5272} __ec_align4;
5273
5274/*****************************************************************************/
5047/* Touchpad MCU commands: range 0x0500-0x05FF */ 5275/* Touchpad MCU commands: range 0x0500-0x05FF */
5048 5276
5049/* Perform touchpad self test */ 5277/* Perform touchpad self test */