Merge branch 'spi-4.20' into spi-4.21 for bcm stuff.
[linux-2.6-microblaze.git] / include / linux / tee_drv.h
index a2b3dfc..6cfe058 100644 (file)
@@ -453,6 +453,79 @@ static inline int tee_shm_get_id(struct tee_shm *shm)
  */
 struct tee_shm *tee_shm_get_from_id(struct tee_context *ctx, int id);
 
+/**
+ * tee_client_open_context() - Open a TEE context
+ * @start:     if not NULL, continue search after this context
+ * @match:     function to check TEE device
+ * @data:      data for match function
+ * @vers:      if not NULL, version data of TEE device of the context returned
+ *
+ * This function does an operation similar to open("/dev/teeX") in user space.
+ * A returned context must be released with tee_client_close_context().
+ *
+ * Returns a TEE context of the first TEE device matched by the match()
+ * callback or an ERR_PTR.
+ */
+struct tee_context *
+tee_client_open_context(struct tee_context *start,
+                       int (*match)(struct tee_ioctl_version_data *,
+                                    const void *),
+                       const void *data, struct tee_ioctl_version_data *vers);
+
+/**
+ * tee_client_close_context() - Close a TEE context
+ * @ctx:       TEE context to close
+ *
+ * Note that all sessions previously opened with this context will be
+ * closed when this function is called.
+ */
+void tee_client_close_context(struct tee_context *ctx);
+
+/**
+ * tee_client_get_version() - Query version of TEE
+ * @ctx:       TEE context to TEE to query
+ * @vers:      Pointer to version data
+ */
+void tee_client_get_version(struct tee_context *ctx,
+                           struct tee_ioctl_version_data *vers);
+
+/**
+ * tee_client_open_session() - Open a session to a Trusted Application
+ * @ctx:       TEE context
+ * @arg:       Open session arguments, see description of
+ *             struct tee_ioctl_open_session_arg
+ * @param:     Parameters passed to the Trusted Application
+ *
+ * Returns < 0 on error else see @arg->ret for result. If @arg->ret
+ * is TEEC_SUCCESS the session identifier is available in @arg->session.
+ */
+int tee_client_open_session(struct tee_context *ctx,
+                           struct tee_ioctl_open_session_arg *arg,
+                           struct tee_param *param);
+
+/**
+ * tee_client_close_session() - Close a session to a Trusted Application
+ * @ctx:       TEE Context
+ * @session:   Session id
+ *
+ * Return < 0 on error else 0, regardless the session will not be
+ * valid after this function has returned.
+ */
+int tee_client_close_session(struct tee_context *ctx, u32 session);
+
+/**
+ * tee_client_invoke_func() - Invoke a function in a Trusted Application
+ * @ctx:       TEE Context
+ * @arg:       Invoke arguments, see description of
+ *             struct tee_ioctl_invoke_arg
+ * @param:     Parameters passed to the Trusted Application
+ *
+ * Returns < 0 on error else see @arg->ret for result.
+ */
+int tee_client_invoke_func(struct tee_context *ctx,
+                          struct tee_ioctl_invoke_arg *arg,
+                          struct tee_param *param);
+
 static inline bool tee_param_is_memref(struct tee_param *param)
 {
        switch (param->attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) {