Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * Copyright (c) 2015-2016, Linaro Limited
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) #ifndef TEE_PRIVATE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) #define TEE_PRIVATE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) #include <linux/cdev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <linux/completion.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/kref.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/mutex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)  * struct tee_shm_pool - shared memory pool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)  * @private_mgr:	pool manager for shared memory only between kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)  *			and secure world
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)  * @dma_buf_mgr:	pool manager for shared memory exported to user space
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) struct tee_shm_pool {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 	struct tee_shm_pool_mgr *private_mgr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 	struct tee_shm_pool_mgr *dma_buf_mgr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #define TEE_DEVICE_FLAG_REGISTERED	0x1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define TEE_MAX_DEV_NAME_LEN		32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)  * struct tee_device - TEE Device representation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)  * @name:	name of device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)  * @desc:	description of device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)  * @id:		unique id of device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)  * @flags:	represented by TEE_DEVICE_FLAG_REGISTERED above
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)  * @dev:	embedded basic device structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)  * @cdev:	embedded cdev
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)  * @num_users:	number of active users of this device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)  * @c_no_user:	completion used when unregistering the device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)  * @mutex:	mutex protecting @num_users and @idr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)  * @idr:	register of user space shared memory objects allocated or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)  *		registered on this device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)  * @pool:	shared memory pool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) struct tee_device {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	char name[TEE_MAX_DEV_NAME_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	const struct tee_desc *desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 	int id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 	unsigned int flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 	struct device dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 	struct cdev cdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	size_t num_users;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 	struct completion c_no_users;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 	struct mutex mutex;	/* protects num_users and idr */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 	struct idr idr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 	struct tee_shm_pool *pool;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) int tee_shm_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) int tee_shm_get_fd(struct tee_shm *shm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) bool tee_device_get(struct tee_device *teedev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) void tee_device_put(struct tee_device *teedev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) void teedev_ctx_get(struct tee_context *ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) void teedev_ctx_put(struct tee_context *ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) #endif /*TEE_PRIVATE_H*/