blob: 9212d5802d51263cb40a627927df2996b53ca323 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001/* SPDX-License-Identifier: GPL-2.0+ */
2/*
3 * Copyright (c) 2018 Linaro Limited
4 */
5
6#ifndef __OPTEE_PRIVATE_H
7#define __OPTEE_PRIVATE_H
8
9#include <tee.h>
10
11/**
12 * struct optee_private - OP-TEE driver private data
13 * @rpmb_mmc: mmc device for the RPMB partition
14 * @rpmb_dev_id: mmc device id matching @rpmb_mmc
15 * @rpmb_original_part: the previosly active partition on the mmc device,
16 * used to restore active the partition when the RPMB
17 * accesses are finished
18 */
19struct optee_private {
20 struct mmc *rpmb_mmc;
21 int rpmb_dev_id;
22 int rpmb_original_part;
23};
24
25struct optee_msg_arg;
26
27void optee_suppl_cmd(struct tee_device *dev, struct tee_shm *shm_arg,
28 void **page_list);
29
30#ifdef CONFIG_SUPPORT_EMMC_RPMB
31/**
32 * optee_suppl_cmd_rpmb() - route RPMB frames to mmc
33 * @dev: device with the selected RPMB partition
34 * @arg: OP-TEE message holding the frames to transmit to the mmc
35 * and space for the response frames.
36 *
37 * Routes signed (MACed) RPMB frames from OP-TEE Secure OS to MMC and vice
38 * versa to manipulate the RPMB partition.
39 */
40void optee_suppl_cmd_rpmb(struct tee_device *dev, struct optee_msg_arg *arg);
41
42/**
43 * optee_suppl_rpmb_release() - release mmc device
44 * @dev: mmc device
45 *
46 * Releases the mmc device and restores the previously selected partition.
47 */
48void optee_suppl_rpmb_release(struct tee_device *dev);
49#else
50static inline void optee_suppl_cmd_rpmb(struct tee_device *dev,
51 struct optee_msg_arg *arg)
52{
53 printf("OPTEE_MSG_RPC_CMD_RPMB not implemented\n");
54 arg->ret = TEE_ERROR_NOT_IMPLEMENTED;
55}
56
57static inline void optee_suppl_rpmb_release(struct tee_device *dev)
58{
59}
60#endif
61
62#ifdef CONFIG_DM_I2C
63/**
64 * optee_suppl_cmd_i2c_transfer() - route I2C requests to an I2C chip
65 * @arg: OP-TEE message (layout specified in optee_msg.h) defining the
66 * transfer mode (read/write), adapter, chip and control flags.
67 *
68 * Handles OP-TEE requests to transfer data to the I2C chip on the I2C adapter.
69 */
70void optee_suppl_cmd_i2c_transfer(struct optee_msg_arg *arg);
71#else
72static inline void optee_suppl_cmd_i2c_transfer(struct optee_msg_arg *arg)
73{
74 printf("OPTEE_MSG_RPC_CMD_I2C_TRANSFER not implemented\n");
75 arg->ret = TEE_ERROR_NOT_IMPLEMENTED;
76}
77#endif
78
79void *optee_alloc_and_init_page_list(void *buf, ulong len, u64 *phys_buf_ptr);
80
81#endif /* __OPTEE_PRIVATE_H */