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