1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright (c) 2015-2019, Arm Limited and Contributors. All rights reserved.
4  * Copyright (c) 2019, Linaro Limited
5  */
6 #ifndef SCMI_MSG_RESET_DOMAIN_H
7 #define SCMI_MSG_RESET_DOMAIN_H
8 
9 #include <compiler.h>
10 #include <stdbool.h>
11 #include <stdint.h>
12 #include <types_ext.h>
13 #include <util.h>
14 
15 #include "common.h"
16 
17 #define SCMI_PROTOCOL_VERSION_RESET_DOMAIN	0x10000
18 
19 #define SCMI_RESET_STATE_ARCH			BIT(31)
20 #define SCMI_RESET_STATE_IMPL			0
21 
22 /*
23  * Identifiers of the SCMI Reset Domain Management Protocol commands
24  */
25 enum scmi_reset_domain_command_id {
26 	SCMI_RESET_DOMAIN_ATTRIBUTES = 0x03,
27 	SCMI_RESET_DOMAIN_REQUEST = 0x04,
28 	SCMI_RESET_DOMAIN_NOTIFY = 0x05,
29 };
30 
31 /*
32  * Identifiers of the SCMI Reset Domain Management Protocol responses
33  */
34 enum scmi_reset_domain_response_id {
35 	SCMI_RESET_ISSUED = 0x00,
36 	SCMI_RESET_COMPLETE = 0x04,
37 };
38 
39 /*
40  * PROTOCOL_ATTRIBUTES
41  */
42 
43 #define SCMI_RESET_DOMAIN_COUNT_MASK		GENMASK_32(15, 0)
44 
45 struct scmi_reset_domain_protocol_attributes_p2a {
46 	int32_t status;
47 	uint32_t attributes;
48 };
49 
50 /* Value for scmi_reset_domain_attributes_p2a:flags */
51 #define SCMI_RESET_DOMAIN_ATTR_ASYNC		BIT(31)
52 #define SCMI_RESET_DOMAIN_ATTR_NOTIF		BIT(30)
53 
54 /* Value for scmi_reset_domain_attributes_p2a:latency */
55 #define SCMI_RESET_DOMAIN_ATTR_UNK_LAT		0x7fffffff
56 #define SCMI_RESET_DOMAIN_ATTR_MAX_LAT		0x7ffffffe
57 
58 /* Macro for scmi_reset_domain_attributes_p2a:name */
59 #define SCMI_RESET_DOMAIN_ATTR_NAME_SZ		16
60 
61 struct scmi_reset_domain_attributes_a2p {
62 	uint32_t domain_id;
63 };
64 
65 struct scmi_reset_domain_attributes_p2a {
66 	int32_t status;
67 	uint32_t flags;
68 	uint32_t latency;
69 	char name[SCMI_RESET_DOMAIN_ATTR_NAME_SZ];
70 };
71 
72 /*
73  * RESET
74  */
75 
76 /* Values for scmi_reset_domain_request_a2p:flags */
77 #define SCMI_RESET_DOMAIN_ASYNC			BIT(2)
78 #define SCMI_RESET_DOMAIN_EXPLICIT		BIT(1)
79 #define SCMI_RESET_DOMAIN_AUTO			BIT(0)
80 
81 struct scmi_reset_domain_request_a2p {
82 	uint32_t domain_id;
83 	uint32_t flags;
84 	uint32_t reset_state;
85 };
86 
87 struct scmi_reset_domain_request_p2a {
88 	int32_t status;
89 };
90 
91 /*
92  * RESET_NOTIFY
93  */
94 
95 /* Values for scmi_reset_notify_p2a:flags */
96 #define SCMI_RESET_DOMAIN_DO_NOTIFY		BIT(0)
97 
98 struct scmi_reset_domain_notify_a2p {
99 	uint32_t domain_id;
100 	uint32_t notify_enable;
101 };
102 
103 struct scmi_reset_domain_notify_p2a {
104 	int32_t status;
105 };
106 
107 /*
108  * RESET_COMPLETE
109  */
110 
111 struct scmi_reset_domain_complete_p2a {
112 	int32_t status;
113 	uint32_t domain_id;
114 };
115 
116 /*
117  * RESET_ISSUED
118  */
119 
120 struct scmi_reset_domain_issued_p2a {
121 	uint32_t domain_id;
122 	uint32_t reset_state;
123 };
124 
125 #ifdef CFG_SCMI_MSG_RESET_DOMAIN
126 /*
127  * scmi_msg_get_rd_handler - Return a handler for a reset domain message
128  * @msg - message to process
129  * Return a function handler for the message or NULL
130  */
131 scmi_msg_handler_t scmi_msg_get_rd_handler(struct scmi_msg *msg);
132 #else
133 static inline
scmi_msg_get_rd_handler(struct scmi_msg * msg __unused)134 scmi_msg_handler_t scmi_msg_get_rd_handler(struct scmi_msg *msg __unused)
135 {
136 	return NULL;
137 }
138 #endif
139 #endif /* SCMI_MSG_RESET_DOMAIN_H */
140