~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/firmware/qcom/qcom_qseecom.h

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0-or-later */
  2 /*
  3  * Driver for Qualcomm Secure Execution Environment (SEE) interface (QSEECOM).
  4  * Responsible for setting up and managing QSEECOM client devices.
  5  *
  6  * Copyright (C) 2023 Maximilian Luz <luzmaximilian@gmail.com>
  7  */
  8 
  9 #ifndef __QCOM_QSEECOM_H
 10 #define __QCOM_QSEECOM_H
 11 
 12 #include <linux/auxiliary_bus.h>
 13 #include <linux/dma-mapping.h>
 14 #include <linux/types.h>
 15 
 16 #include <linux/firmware/qcom/qcom_scm.h>
 17 
 18 /**
 19  * struct qseecom_client - QSEECOM client device.
 20  * @aux_dev: Underlying auxiliary device.
 21  * @app_id: ID of the loaded application.
 22  */
 23 struct qseecom_client {
 24         struct auxiliary_device aux_dev;
 25         u32 app_id;
 26 };
 27 
 28 /**
 29  * qseecom_scm_dev() - Get the SCM device associated with the QSEECOM client.
 30  * @client: The QSEECOM client device.
 31  *
 32  * Returns the SCM device under which the provided QSEECOM client device
 33  * operates. This function is intended to be used for DMA allocations.
 34  */
 35 static inline struct device *qseecom_scm_dev(struct qseecom_client *client)
 36 {
 37         return client->aux_dev.dev.parent->parent;
 38 }
 39 
 40 /**
 41  * qseecom_dma_alloc() - Allocate DMA memory for a QSEECOM client.
 42  * @client:     The QSEECOM client to allocate the memory for.
 43  * @size:       The number of bytes to allocate.
 44  * @dma_handle: Pointer to where the DMA address should be stored.
 45  * @gfp:        Allocation flags.
 46  *
 47  * Wrapper function for dma_alloc_coherent(), allocating DMA memory usable for
 48  * TZ/QSEECOM communication. Refer to dma_alloc_coherent() for details.
 49  */
 50 static inline void *qseecom_dma_alloc(struct qseecom_client *client, size_t size,
 51                                       dma_addr_t *dma_handle, gfp_t gfp)
 52 {
 53         return dma_alloc_coherent(qseecom_scm_dev(client), size, dma_handle, gfp);
 54 }
 55 
 56 /**
 57  * dma_free_coherent() - Free QSEECOM DMA memory.
 58  * @client:     The QSEECOM client for which the memory has been allocated.
 59  * @size:       The number of bytes allocated.
 60  * @cpu_addr:   Virtual memory address to free.
 61  * @dma_handle: DMA memory address to free.
 62  *
 63  * Wrapper function for dma_free_coherent(), freeing memory previously
 64  * allocated with qseecom_dma_alloc(). Refer to dma_free_coherent() for
 65  * details.
 66  */
 67 static inline void qseecom_dma_free(struct qseecom_client *client, size_t size,
 68                                     void *cpu_addr, dma_addr_t dma_handle)
 69 {
 70         return dma_free_coherent(qseecom_scm_dev(client), size, cpu_addr, dma_handle);
 71 }
 72 
 73 /**
 74  * qcom_qseecom_app_send() - Send to and receive data from a given QSEE app.
 75  * @client:   The QSEECOM client associated with the target app.
 76  * @req:      Request buffer sent to the app (must be TZ memory).
 77  * @req_size: Size of the request buffer.
 78  * @rsp:      Response buffer, written to by the app (must be TZ memory).
 79  * @rsp_size: Size of the response buffer.
 80  *
 81  * Sends a request to the QSEE app associated with the given client and read
 82  * back its response. The caller must provide two DMA memory regions, one for
 83  * the request and one for the response, and fill out the @req region with the
 84  * respective (app-specific) request data. The QSEE app reads this and returns
 85  * its response in the @rsp region.
 86  *
 87  * Note: This is a convenience wrapper around qcom_scm_qseecom_app_send().
 88  * Clients should prefer to use this wrapper.
 89  *
 90  * Return: Zero on success, nonzero on failure.
 91  */
 92 static inline int qcom_qseecom_app_send(struct qseecom_client *client,
 93                                         void *req, size_t req_size,
 94                                         void *rsp, size_t rsp_size)
 95 {
 96         return qcom_scm_qseecom_app_send(client->app_id, req, req_size, rsp, rsp_size);
 97 }
 98 
 99 #endif /* __QCOM_QSEECOM_H */
100 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php