1 /*
2  * Copyright (c) 2024, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef __SMMU_V3_DRV_H__
8 #define __SMMU_V3_DRV_H__
9 
10 #include <stdint.h>
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 /**
17  * \brief SMMU error enumeration types
18  */
19 enum smmu_error_t {
20     /* No Error */
21     SMMU_ERR_NONE,
22     /* Invalid parameter */
23     SMMU_ERR_INVALID_PARAM,
24     /* Error accessing smmu */
25     SMMU_ERR_ACCESS,
26     /* General error with driver */
27     SMMU_ERR_GENERAL,
28     /* Timeout waiting for smmu */
29     SMMU_ERR_TIMEOUT,
30 };
31 
32 /**
33  * \brief SMMU device structure
34  */
35 struct smmu_dev_t {
36     /* Base address of the SMMU */
37     const uintptr_t smmu_base;
38     /* Approximate number of cycles to wait for ack from SMMU  */
39     const uint64_t ack_timeout;
40 };
41 
42 #define SMMU_DEFAULT_ACK_TIMEOUT 1000UL
43 
44 /**
45  * \brief Enable granule protection checks (GPC)
46  *
47  * \param[in] dev                SMMU device struct \ref smmu_dev_t
48  *
49  * \return Returns error code as specified in \ref smmu_error_t
50  */
51 enum smmu_error_t smmu_gpc_enable(struct smmu_dev_t *dev);
52 
53 /**
54  * \brief Disable granule protection checks (GPC)
55  *
56  * \param[in] dev                SMMU device struct \ref smmu_dev_t
57  *
58  * \return Returns error code as specified in \ref smmu_error_t
59  */
60 enum smmu_error_t smmu_gpc_disable(struct smmu_dev_t *dev);
61 
62 /**
63  * \brief Enable smmu and client accesses
64  *
65  * \param[in] dev                SMMU device struct \ref smmu_dev_t
66  *
67  * \return Returns error code as specified in \ref smmu_error_t
68  */
69 enum smmu_error_t smmu_access_enable(struct smmu_dev_t *dev);
70 
71 /**
72  * \brief Disable smmu and client accesses
73  *
74  * \param[in] dev                SMMU device struct \ref smmu_dev_t
75  *
76  * \return Returns error code as specified in \ref smmu_error_t
77  */
78 enum smmu_error_t smmu_access_disable(struct smmu_dev_t *dev);
79 
80 #ifdef __cplusplus
81 }
82 #endif
83 #endif /* __SMMU_V3_DRV_H__ */
84