xref: /freebsd/sys/dev/firmware/arm/scmi_clk.h (revision 8a271827e7b5d5310e06df1f9f49ba0ef9efd263)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2022 Ruslan Bukin <br@bsdpad.com>
5  *
6  * This work was supported by Innovate UK project 105694, "Digital Security
7  * by Design (DSbD) Technology Platform Prototype".
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  *
30  * $FreeBSD$
31  */
32 
33 #ifndef	_ARM64_SCMI_SCMI_CLK_H_
34 #define	_ARM64_SCMI_SCMI_CLK_H_
35 
36 /*
37  * SCMI Clock Protocol
38  */
39 
40 struct scmi_clk_protocol_attrs_out {
41 	int32_t status;
42 	uint32_t attributes;
43 #define	CLK_ATTRS_NCLOCKS_S		0
44 #define	CLK_ATTRS_NCLOCKS_M		(0xffff << CLK_ATTRS_NCLOCKS_S)
45 };
46 
47 struct scmi_clk_attrs_in {
48 	uint32_t clock_id;
49 };
50 
51 struct scmi_clk_attrs_out {
52 	int32_t status;
53 	uint32_t attributes;
54 #define	CLK_ATTRS_RATE_CHANGE_NOTIFY_SUPP	(1 << 31)
55 #define	CLK_ATTRS_RATE_REQ_CHANGE_NOTIFY_SUPP	(1 << 30)
56 #define	CLK_ATTRS_EXT_CLK_NAME			(1 << 29)
57 #define	CLK_ATTRS_ENABLED			(1 << 0)
58 	uint8_t clock_name[16];		/* only if attrs bit 29 unset */
59 	uint32_t clock_enable_delay;	/* worst case */
60 };
61 
62 struct scmi_clk_name_get_in {
63 	uint32_t clock_id;
64 };
65 
66 struct scmi_clk_name_get_out {
67 	int32_t status;
68 	uint32_t flags;
69 	uint8_t name[64];
70 };
71 
72 enum scmi_clock_message_id {
73 	SCMI_CLOCK_ATTRIBUTES = 0x3,
74 	SCMI_CLOCK_RATE_SET = 0x5,
75 	SCMI_CLOCK_RATE_GET = 0x6,
76 	SCMI_CLOCK_CONFIG_SET = 0x7,
77 	SCMI_CLOCK_NAME_GET = 0x8,
78 };
79 
80 #define SCMI_CLK_RATE_ASYNC_NOTIFY	(1 << 0)
81 #define SCMI_CLK_RATE_ASYNC_NORESP	(1 << 0 | 1 << 1)
82 #define SCMI_CLK_RATE_ROUND_DOWN	0
83 #define SCMI_CLK_RATE_ROUND_UP		(1 << 2)
84 #define SCMI_CLK_RATE_ROUND_CLOSEST	(1 << 3)
85 
86 struct scmi_clk_state_in {
87 	uint32_t clock_id;
88 	uint32_t attributes;
89 };
90 
91 struct scmi_clk_state_out {
92 	int32_t status;
93 };
94 
95 struct scmi_clk_rate_get_in {
96 	uint32_t clock_id;
97 };
98 
99 struct scmi_clk_rate_get_out {
100 	int32_t status;
101 	uint32_t rate_lsb;
102 	uint32_t rate_msb;
103 };
104 
105 struct scmi_clk_rate_set_in {
106 	uint32_t flags;
107 	uint32_t clock_id;
108 	uint32_t rate_lsb;
109 	uint32_t rate_msb;
110 };
111 
112 struct scmi_clk_rate_set_out {
113 	int32_t status;
114 };
115 
116 #endif /* !_ARM64_SCMI_SCMI_CLK_H_ */
117