xref: /optee_os/core/drivers/scmi-msg/reset_domain.h (revision 60c96f68b2cc9ea028b2a32c8110f67795a5df09)
156a1f10eSEtienne Carriere /* SPDX-License-Identifier: BSD-2-Clause */
256a1f10eSEtienne Carriere /*
356a1f10eSEtienne Carriere  * Copyright (c) 2015-2019, Arm Limited and Contributors. All rights reserved.
456a1f10eSEtienne Carriere  * Copyright (c) 2019, Linaro Limited
556a1f10eSEtienne Carriere  */
656a1f10eSEtienne Carriere #ifndef SCMI_MSG_RESET_DOMAIN_H
756a1f10eSEtienne Carriere #define SCMI_MSG_RESET_DOMAIN_H
856a1f10eSEtienne Carriere 
956a1f10eSEtienne Carriere #include <compiler.h>
1056a1f10eSEtienne Carriere #include <stdbool.h>
1156a1f10eSEtienne Carriere #include <stdint.h>
1256a1f10eSEtienne Carriere #include <types_ext.h>
1356a1f10eSEtienne Carriere #include <util.h>
1456a1f10eSEtienne Carriere 
15*60c96f68SEtienne Carriere #include "common.h"
16*60c96f68SEtienne Carriere 
1756a1f10eSEtienne Carriere #define SCMI_PROTOCOL_VERSION_RESET_DOMAIN	0x10000
1856a1f10eSEtienne Carriere 
1956a1f10eSEtienne Carriere #define SCMI_RESET_STATE_ARCH			BIT(31)
2056a1f10eSEtienne Carriere #define SCMI_RESET_STATE_IMPL			0
2156a1f10eSEtienne Carriere 
2256a1f10eSEtienne Carriere /*
2356a1f10eSEtienne Carriere  * Identifiers of the SCMI Reset Domain Management Protocol commands
2456a1f10eSEtienne Carriere  */
2556a1f10eSEtienne Carriere enum scmi_reset_domain_command_id {
2656a1f10eSEtienne Carriere 	SCMI_RESET_DOMAIN_ATTRIBUTES = 0x03,
2756a1f10eSEtienne Carriere 	SCMI_RESET_DOMAIN_REQUEST = 0x04,
2856a1f10eSEtienne Carriere 	SCMI_RESET_DOMAIN_NOTIFY = 0x05,
2956a1f10eSEtienne Carriere };
3056a1f10eSEtienne Carriere 
3156a1f10eSEtienne Carriere /*
3256a1f10eSEtienne Carriere  * Identifiers of the SCMI Reset Domain Management Protocol responses
3356a1f10eSEtienne Carriere  */
3456a1f10eSEtienne Carriere enum scmi_reset_domain_response_id {
3556a1f10eSEtienne Carriere 	SCMI_RESET_ISSUED = 0x00,
3656a1f10eSEtienne Carriere 	SCMI_RESET_COMPLETE = 0x04,
3756a1f10eSEtienne Carriere };
3856a1f10eSEtienne Carriere 
3956a1f10eSEtienne Carriere /*
4056a1f10eSEtienne Carriere  * PROTOCOL_ATTRIBUTES
4156a1f10eSEtienne Carriere  */
4256a1f10eSEtienne Carriere 
4356a1f10eSEtienne Carriere #define SCMI_RESET_DOMAIN_COUNT_MASK		GENMASK_32(15, 0)
4456a1f10eSEtienne Carriere 
4556a1f10eSEtienne Carriere struct scmi_reset_domain_protocol_attributes_p2a {
4656a1f10eSEtienne Carriere 	int32_t status;
4756a1f10eSEtienne Carriere 	uint32_t attributes;
4856a1f10eSEtienne Carriere };
4956a1f10eSEtienne Carriere 
5056a1f10eSEtienne Carriere /* Value for scmi_reset_domain_attributes_p2a:flags */
5156a1f10eSEtienne Carriere #define SCMI_RESET_DOMAIN_ATTR_ASYNC		BIT(31)
5256a1f10eSEtienne Carriere #define SCMI_RESET_DOMAIN_ATTR_NOTIF		BIT(30)
5356a1f10eSEtienne Carriere 
5456a1f10eSEtienne Carriere /* Value for scmi_reset_domain_attributes_p2a:latency */
5556a1f10eSEtienne Carriere #define SCMI_RESET_DOMAIN_ATTR_UNK_LAT		0x7fffffff
5656a1f10eSEtienne Carriere #define SCMI_RESET_DOMAIN_ATTR_MAX_LAT		0x7ffffffe
5756a1f10eSEtienne Carriere 
5856a1f10eSEtienne Carriere /* Macro for scmi_reset_domain_attributes_p2a:name */
5956a1f10eSEtienne Carriere #define SCMI_RESET_DOMAIN_ATTR_NAME_SZ		16
6056a1f10eSEtienne Carriere 
6156a1f10eSEtienne Carriere struct scmi_reset_domain_attributes_a2p {
6256a1f10eSEtienne Carriere 	uint32_t domain_id;
6356a1f10eSEtienne Carriere };
6456a1f10eSEtienne Carriere 
6556a1f10eSEtienne Carriere struct scmi_reset_domain_attributes_p2a {
6656a1f10eSEtienne Carriere 	int32_t status;
6756a1f10eSEtienne Carriere 	uint32_t flags;
6856a1f10eSEtienne Carriere 	uint32_t latency;
6956a1f10eSEtienne Carriere 	char name[SCMI_RESET_DOMAIN_ATTR_NAME_SZ];
7056a1f10eSEtienne Carriere };
7156a1f10eSEtienne Carriere 
7256a1f10eSEtienne Carriere /*
7356a1f10eSEtienne Carriere  * RESET
7456a1f10eSEtienne Carriere  */
7556a1f10eSEtienne Carriere 
7656a1f10eSEtienne Carriere /* Values for scmi_reset_domain_request_a2p:flags */
7756a1f10eSEtienne Carriere #define SCMI_RESET_DOMAIN_ASYNC			BIT(2)
7856a1f10eSEtienne Carriere #define SCMI_RESET_DOMAIN_EXPLICIT		BIT(1)
7956a1f10eSEtienne Carriere #define SCMI_RESET_DOMAIN_AUTO			BIT(0)
8056a1f10eSEtienne Carriere 
8156a1f10eSEtienne Carriere struct scmi_reset_domain_request_a2p {
8256a1f10eSEtienne Carriere 	uint32_t domain_id;
8356a1f10eSEtienne Carriere 	uint32_t flags;
8456a1f10eSEtienne Carriere 	uint32_t reset_state;
8556a1f10eSEtienne Carriere };
8656a1f10eSEtienne Carriere 
8756a1f10eSEtienne Carriere struct scmi_reset_domain_request_p2a {
8856a1f10eSEtienne Carriere 	int32_t status;
8956a1f10eSEtienne Carriere };
9056a1f10eSEtienne Carriere 
9156a1f10eSEtienne Carriere /*
9256a1f10eSEtienne Carriere  * RESET_NOTIFY
9356a1f10eSEtienne Carriere  */
9456a1f10eSEtienne Carriere 
9556a1f10eSEtienne Carriere /* Values for scmi_reset_notify_p2a:flags */
9656a1f10eSEtienne Carriere #define SCMI_RESET_DOMAIN_DO_NOTIFY		BIT(0)
9756a1f10eSEtienne Carriere 
9856a1f10eSEtienne Carriere struct scmi_reset_domain_notify_a2p {
9956a1f10eSEtienne Carriere 	uint32_t domain_id;
10056a1f10eSEtienne Carriere 	uint32_t notify_enable;
10156a1f10eSEtienne Carriere };
10256a1f10eSEtienne Carriere 
10356a1f10eSEtienne Carriere struct scmi_reset_domain_notify_p2a {
10456a1f10eSEtienne Carriere 	int32_t status;
10556a1f10eSEtienne Carriere };
10656a1f10eSEtienne Carriere 
10756a1f10eSEtienne Carriere /*
10856a1f10eSEtienne Carriere  * RESET_COMPLETE
10956a1f10eSEtienne Carriere  */
11056a1f10eSEtienne Carriere 
11156a1f10eSEtienne Carriere struct scmi_reset_domain_complete_p2a {
11256a1f10eSEtienne Carriere 	int32_t status;
11356a1f10eSEtienne Carriere 	uint32_t domain_id;
11456a1f10eSEtienne Carriere };
11556a1f10eSEtienne Carriere 
11656a1f10eSEtienne Carriere /*
11756a1f10eSEtienne Carriere  * RESET_ISSUED
11856a1f10eSEtienne Carriere  */
11956a1f10eSEtienne Carriere 
12056a1f10eSEtienne Carriere struct scmi_reset_domain_issued_p2a {
12156a1f10eSEtienne Carriere 	uint32_t domain_id;
12256a1f10eSEtienne Carriere 	uint32_t reset_state;
12356a1f10eSEtienne Carriere };
12456a1f10eSEtienne Carriere 
125*60c96f68SEtienne Carriere #ifdef CFG_SCMI_MSG_RESET_DOMAIN
126*60c96f68SEtienne Carriere /*
127*60c96f68SEtienne Carriere  * scmi_msg_get_rd_handler - Return a handler for a reset domain message
128*60c96f68SEtienne Carriere  * @msg - message to process
129*60c96f68SEtienne Carriere  * Return a function handler for the message or NULL
130*60c96f68SEtienne Carriere  */
131*60c96f68SEtienne Carriere scmi_msg_handler_t scmi_msg_get_rd_handler(struct scmi_msg *msg);
132*60c96f68SEtienne Carriere #else
133*60c96f68SEtienne Carriere static inline
scmi_msg_get_rd_handler(struct scmi_msg * msg __unused)134*60c96f68SEtienne Carriere scmi_msg_handler_t scmi_msg_get_rd_handler(struct scmi_msg *msg __unused)
135*60c96f68SEtienne Carriere {
136*60c96f68SEtienne Carriere 	return NULL;
137*60c96f68SEtienne Carriere }
138*60c96f68SEtienne Carriere #endif
13956a1f10eSEtienne Carriere #endif /* SCMI_MSG_RESET_DOMAIN_H */
140