Lines Matching +full:op +full:- +full:tee
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2018-2019 Linaro Ltd.
15 #define DRIVER_NAME "optee-rng"
20 * TA_CMD_GET_ENTROPY - Get Entropy from RNG
22 * param[0] (inout memref) - Entropy buffer memory reference
28 * TEE_SUCCESS - Invoke command success
29 * TEE_ERROR_BAD_PARAMETERS - Incorrect input param
30 * TEE_ERROR_NOT_SUPPORTED - Requested entropy size greater than size of pool
31 * TEE_ERROR_HEALTH_TEST_FAIL - Continuous health testing failed
36 * TA_CMD_GET_RNG_INFO - Get RNG information
38 * param[0] (out value) - value.a: RNG data-rate in bytes per second
45 * TEE_SUCCESS - Invoke command success
46 * TEE_ERROR_BAD_PARAMETERS - Incorrect input param
53 * struct optee_rng_private - OP-TEE Random Number Generator private data
54 * @dev: OP-TEE based RNG device.
55 * @ctx: OP-TEE context handler.
59 * @optee_rng: OP-TEE RNG driver structure.
87 inv_arg.session = pvt_data->session_id; in get_optee_rng_data()
92 param[0].u.memref.shm = pvt_data->entropy_shm_pool; in get_optee_rng_data()
96 ret = tee_client_invoke_func(pvt_data->ctx, &inv_arg, param); in get_optee_rng_data()
98 dev_err(pvt_data->dev, "TA_CMD_GET_ENTROPY invoke err: %x\n", in get_optee_rng_data()
103 rng_data = tee_shm_get_va(pvt_data->entropy_shm_pool, 0); in get_optee_rng_data()
105 dev_err(pvt_data->dev, "tee_shm_get_va failed\n"); in get_optee_rng_data()
126 rng_size = get_optee_rng_data(pvt_data, data, (max - read)); in optee_rng_read()
131 if (wait && pvt_data->data_rate) { in optee_rng_read()
132 if ((timeout-- == 0) || (read == max)) in optee_rng_read()
134 msleep((1000 * (max - read)) / pvt_data->data_rate); in optee_rng_read()
148 entropy_shm_pool = tee_shm_alloc_kernel_buf(pvt_data->ctx, in optee_rng_init()
151 dev_err(pvt_data->dev, "tee_shm_alloc_kernel_buf failed\n"); in optee_rng_init()
155 pvt_data->entropy_shm_pool = entropy_shm_pool; in optee_rng_init()
164 tee_shm_free(pvt_data->entropy_shm_pool); in optee_rng_cleanup()
197 return -EINVAL; in get_optee_rng_info()
208 if (ver->impl_id == TEE_IMPL_ID_OPTEE) in optee_ctx_match()
217 int ret = 0, err = -ENODEV; in optee_rng_probe()
222 /* Open context with TEE driver */ in optee_rng_probe()
226 return -ENODEV; in optee_rng_probe()
229 export_uuid(sess_arg.uuid, &rng_device->id.uuid); in optee_rng_probe()
237 err = -EINVAL; in optee_rng_probe()
278 MODULE_DEVICE_TABLE(tee, optee_rng_id_table);
305 MODULE_DESCRIPTION("OP-TEE based random number generator driver");