1 /*
2  * Arm SCP/MCP Software
3  * Copyright (c) 2015-2021, Arm Limited and Contributors. All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  *
7  * Description:
8  *      System Control and Management Interface (SCMI) support.
9  */
10 
11 #ifndef INTERNAL_SCMI_POWER_H
12 #define INTERNAL_SCMI_POWER_H
13 
14 #include <stdint.h>
15 
16 /*!
17  * \addtogroup GroupModules Modules
18  * \{
19  */
20 
21 /*!
22  * \defgroup GroupSCMIPowerDomain SCMI Power Domain Management Protocol
23  * \{
24  */
25 
26 #define SCMI_PROTOCOL_VERSION_POWER_DOMAIN UINT32_C(0x20000)
27 
28 #define SCMI_PD_DEVICE_STATE_ID_OFF  0U
29 #define SCMI_PD_DEVICE_STATE_ID_ON   0U
30 #define SCMI_PD_DEVICE_STATE_ID      0U
31 #define SCMI_PD_DEVICE_STATE_ID_MASK 0xFFFFFFFU
32 #define SCMI_PD_DEVICE_STATE_TYPE    (1U << 30)
33 
34 /*!
35  * \brief SCMI Power Domain Protocol Notifications message ids.
36  */
37 enum scmi_pd_notification_id {
38     SCMI_POWER_STATE_CHANGED = 0x000,
39     SCMI_POWER_STATE_CHANGE_REQUESTED = 0x001,
40 };
41 
42 /*
43  * PROTOCOL_ATTRIBUTES
44  */
45 
46 struct scmi_pd_protocol_attributes_p2a {
47     int32_t status;
48     uint32_t attributes;
49     uint32_t statistics_address_low;
50     uint32_t statistics_address_high;
51     uint32_t statistics_len;
52 };
53 
54 /*
55  * POWER_DOMAIN_ATTRIBUTES
56  */
57 
58 struct scmi_pd_power_domain_attributes_a2p {
59     uint32_t domain_id;
60 };
61 
62 #define SCMI_PD_POWER_STATE_CHANGE_NOTIFICATIONS (1UL << 31)
63 #define SCMI_PD_POWER_STATE_SET_ASYNC            (1U << 30)
64 #define SCMI_PD_POWER_STATE_SET_SYNC             (1U << 29)
65 
66 struct scmi_pd_power_domain_attributes_p2a {
67     int32_t status;
68     uint32_t attributes;
69     uint8_t name[16];
70 };
71 
72 /*
73  * POWER_STATE_SET
74  */
75 
76 #define SCMI_PD_POWER_STATE_SET_ASYNC_FLAG_MASK  (1U << 0)
77 #define SCMI_PD_POWER_STATE_SET_FLAGS_MASK       (1U << 0)
78 #define SCMI_PD_POWER_STATE_SET_POWER_STATE_MASK UINT32_C(0x4FFFFFFF)
79 
80 struct scmi_pd_power_state_set_a2p {
81     uint32_t flags;
82     uint32_t domain_id;
83     uint32_t power_state;
84 };
85 
86 struct scmi_pd_power_state_set_p2a {
87     int32_t status;
88 };
89 
90 /*
91  * POWER_STATE_GET
92  */
93 
94 struct scmi_pd_power_state_get_a2p {
95     uint32_t domain_id;
96 };
97 
98 struct scmi_pd_power_state_get_p2a {
99     int32_t status;
100     uint32_t power_state;
101 };
102 
103 /*
104  * POWER_STATE_NOTIFY
105  */
106 #define SCMI_PD_NOTIFY_ENABLE_MASK UINT32_C(0x1)
107 
108 struct scmi_pd_power_state_notify_a2p {
109     uint32_t domain_id;
110     uint32_t notify_enable;
111 };
112 
113 struct scmi_pd_power_state_notify_p2a {
114     int32_t status;
115 };
116 
117 struct __attribute((packed)) scmi_pd_power_state_notification_message_p2a {
118     uint32_t agent_id;
119     uint32_t domain_id;
120     uint32_t power_state;
121 };
122 
123 /*!
124  * \}
125  */
126 
127 /*!
128  * \}
129  */
130 
131 #endif /* INTERNAL_SCMI_POWER_DOMAIN_H */
132