blob: 03e16f5e836897e1b4a7651e7c3697e98e3c6124 [file] [log] [blame]
Jacky Bai4d93d1d2020-07-02 14:39:58 +08001/*
2 * Copyright 2021-2024 NXP
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef IMX8_SCMI_H
8#define IMX8_SCMI_H
9
10#include <stdint.h>
11
12#define SCMI_SHMEM_CHANNEL_ERROR BIT_32(1)
13#define SCMI_SHMEM_CHANNEL_FREE BIT_32(0)
14
15#define SCMI_SHMEM_FLAG_INTR_ENABLED BIT_32(0)
16
17enum scmi_std_protocol {
18 SCMI_PROTOCOL_BASE = 0x10,
19 SCMI_PROTOCOL_POWER_DOMAIN = 0x11,
20 SCMI_PROTOCOL_SYS_POWER = 0x12,
21 SCMI_PROTOCOL_PERF_DOMAIN = 0x13,
22 SCMI_PROTOCOL_CLK = 0x14,
23 SCMI_PROTOCOL_SENSOR = 0x15,
24 SCMI_PROTOCOL_RESET_DOMAIN = 0x16,
25};
26
27#define MSG_ID(m) ((m) & 0xff)
28#define MSG_TYPE(m) (((m) >> 8) & 0x3)
29#define MSG_PRO_ID(m) (((m) >> 10) & 0xff)
30#define MSG_TOKEN(m) (((m) >> 18) & 0x3ff)
31
32enum {
33 SCMI_POWER_DOMAIN_PROTOCOL = 0x11,
34 SCMI_SYS_PWR_DOMAIN_PROTOCOL = 0x12,
35 SCMI_PER_DOMAIN_PROTOCOL = 0x13,
36 SCMI_CLK_DOMAIN_PROTOCOL = 0x14,
37 SCMI_SENSOR_PROTOCOL = 0x15,
38};
39
40#define PROTOCOL_VERSION 0
41#define PROTOCOL_ATTRIBUTES 1
42#define PROTOCOL_MESSAGE_ATTRIBUTES 2
43#define BASE_DISCOVER_VENDOR 3
44#define BASE_DISCOVER_SUB_VENDOR 4
45#define BASE_DISCOVER_IMPLEMENTATION_VERSION 5
46#define BASE_DISCOVER_LIST_PROTOCOLS 6
47#define BASE_DISCOVER_AGENT 7
48#define BASE_NOTIFY_ERRORS 8
49#define BASE_SET_DEVICE_PERMISSIONS 9
50#define BASE_SET_PROTOCOL_PERMISSIONS 0xA
51#define BASE_RESET_AGENT_CONFIGURATION 0xB
52
53enum {
54 SCMI_RET_SUCCESS = 0,
55 SCMI_RET_NOT_SUPPORTED = -1,
56 SCMI_RET_INVALID_PARAMETERS = -2,
57 SCMI_RET_DENIED = -3,
58 SCMI_RET_NOT_FOUND = -4,
59 SCMI_RET_OUT_OF_RANGE = -5,
60 SCMI_RET_BUSY = -6,
61 SCMI_RET_COMMS_ERROR = -7,
62 SCMI_RET_GENERIC_ERROR = -8,
63 SCMI_RET_HARDWARE_ERROR = -9,
64 SCMI_RET_PROTOCOL_ERROR = -10,
65};
66
67#define POWER_DOMAIN_ATTRIBUTES 3
68#define POWER_DOMAIN_SUPPORT_NOTIFICATION BIT(31)
69#define POWER_DOMAIN_SUPPORT_ASYNCHRONOUS BIT(30)
70#define POWER_DOMAIN_SUPPORT_SYNCHRONOUS BIT(29)
71
72#define POWER_STATE_SET 4
73#define POWER_STATE_GET 5
74#define POWER_STATE_NOTIFY 6
75#define POWER_STATE_CHANGE_REQUESTED_NOTIFY 7
76
77int scmi_power_domain_handler(uint32_t msg_id, void *shmem);
78
79#define PERFORMANCE_DOMAIN_ATTRIBUTES 3
80#define PERFORMANCE_DESCRIBE_LEVELS 4
81#define PERFORMANCE_LIMITS_SET 5
82#define PERFORMANCE_LIMITS_GET 6
83#define PERFORMANCE_LEVEL_SET 7
84#define PERFORMANCE_LEVEL_GET 8
85#define PERFORMANCE_NOTIFY_LIMITS 9
86#define PERFORMANCE_NOTIFY_LEVEL 0xA
87#define PERFORMANCE_DESCRIBE_FAST_CHANNEL 0xB
88
89int scmi_perf_domain_handler(uint32_t msg_id, void *shmem);
90
91#define SENSOR_DESCRIPTION_GET 0x003
92#define SENSOR_CONFIG_SET 0x004
93#define SENSOR_TRIP_POINT_SET 0x005
94#define SENSOR_READING_GET 0x006
95
96int scmi_sensor_handler(uint32_t msg_id, void *shmem);
97
98#define SMC_SHMEM_BASE 0x2201f000
99
100#endif /* IMX8_SCMI_H */