xref: /linux-6.15/include/linux/scpi_protocol.h (revision 8cb7cf56)
1 /*
2  * SCPI Message Protocol driver header
3  *
4  * Copyright (C) 2014 ARM Ltd.
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms and conditions of the GNU General Public License,
8  * version 2, as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along with
16  * this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 #include <linux/types.h>
19 
20 struct scpi_opp {
21 	u32 freq;
22 	u32 m_volt;
23 } __packed;
24 
25 struct scpi_dvfs_info {
26 	unsigned int count;
27 	unsigned int latency; /* in nanoseconds */
28 	struct scpi_opp *opps;
29 };
30 
31 /**
32  * struct scpi_ops - represents the various operations provided
33  *	by SCP through SCPI message protocol
34  * @get_version: returns the major and minor revision on the SCPI
35  *	message protocol
36  * @clk_get_range: gets clock range limit(min - max in Hz)
37  * @clk_get_val: gets clock value(in Hz)
38  * @clk_set_val: sets the clock value, setting to 0 will disable the
39  *	clock (if supported)
40  * @dvfs_get_idx: gets the Operating Point of the given power domain.
41  *	OPP is an index to the list return by @dvfs_get_info
42  * @dvfs_set_idx: sets the Operating Point of the given power domain.
43  *	OPP is an index to the list return by @dvfs_get_info
44  * @dvfs_get_info: returns the DVFS capabilities of the given power
45  *	domain. It includes the OPP list and the latency information
46  */
47 struct scpi_ops {
48 	u32 (*get_version)(void);
49 	int (*clk_get_range)(u16, unsigned long *, unsigned long *);
50 	unsigned long (*clk_get_val)(u16);
51 	int (*clk_set_val)(u16, unsigned long);
52 	int (*dvfs_get_idx)(u8);
53 	int (*dvfs_set_idx)(u8, u8);
54 	struct scpi_dvfs_info *(*dvfs_get_info)(u8);
55 };
56 
57 #if IS_ENABLED(CONFIG_ARM_SCPI_PROTOCOL)
58 struct scpi_ops *get_scpi_ops(void);
59 #else
60 static inline struct scpi_ops *get_scpi_ops(void) { return NULL; }
61 #endif
62