xref: /OK3568_Linux_fs/kernel/include/linux/scpi_protocol.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-only */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * SCPI Message Protocol driver header
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Copyright (C) 2014 ARM Ltd.
6*4882a593Smuzhiyun  */
7*4882a593Smuzhiyun 
8*4882a593Smuzhiyun #ifndef _LINUX_SCPI_PROTOCOL_H
9*4882a593Smuzhiyun #define _LINUX_SCPI_PROTOCOL_H
10*4882a593Smuzhiyun 
11*4882a593Smuzhiyun #include <linux/types.h>
12*4882a593Smuzhiyun 
13*4882a593Smuzhiyun struct scpi_opp {
14*4882a593Smuzhiyun 	u32 freq;
15*4882a593Smuzhiyun 	u32 m_volt;
16*4882a593Smuzhiyun } __packed;
17*4882a593Smuzhiyun 
18*4882a593Smuzhiyun struct scpi_dvfs_info {
19*4882a593Smuzhiyun 	unsigned int count;
20*4882a593Smuzhiyun 	unsigned int latency; /* in nanoseconds */
21*4882a593Smuzhiyun 	struct scpi_opp *opps;
22*4882a593Smuzhiyun };
23*4882a593Smuzhiyun 
24*4882a593Smuzhiyun enum scpi_sensor_class {
25*4882a593Smuzhiyun 	TEMPERATURE,
26*4882a593Smuzhiyun 	VOLTAGE,
27*4882a593Smuzhiyun 	CURRENT,
28*4882a593Smuzhiyun 	POWER,
29*4882a593Smuzhiyun 	ENERGY,
30*4882a593Smuzhiyun };
31*4882a593Smuzhiyun 
32*4882a593Smuzhiyun struct scpi_sensor_info {
33*4882a593Smuzhiyun 	u16 sensor_id;
34*4882a593Smuzhiyun 	u8 class;
35*4882a593Smuzhiyun 	u8 trigger_type;
36*4882a593Smuzhiyun 	char name[20];
37*4882a593Smuzhiyun } __packed;
38*4882a593Smuzhiyun 
39*4882a593Smuzhiyun /**
40*4882a593Smuzhiyun  * struct scpi_ops - represents the various operations provided
41*4882a593Smuzhiyun  *	by SCP through SCPI message protocol
42*4882a593Smuzhiyun  * @get_version: returns the major and minor revision on the SCPI
43*4882a593Smuzhiyun  *	message protocol
44*4882a593Smuzhiyun  * @clk_get_range: gets clock range limit(min - max in Hz)
45*4882a593Smuzhiyun  * @clk_get_val: gets clock value(in Hz)
46*4882a593Smuzhiyun  * @clk_set_val: sets the clock value, setting to 0 will disable the
47*4882a593Smuzhiyun  *	clock (if supported)
48*4882a593Smuzhiyun  * @dvfs_get_idx: gets the Operating Point of the given power domain.
49*4882a593Smuzhiyun  *	OPP is an index to the list return by @dvfs_get_info
50*4882a593Smuzhiyun  * @dvfs_set_idx: sets the Operating Point of the given power domain.
51*4882a593Smuzhiyun  *	OPP is an index to the list return by @dvfs_get_info
52*4882a593Smuzhiyun  * @dvfs_get_info: returns the DVFS capabilities of the given power
53*4882a593Smuzhiyun  *	domain. It includes the OPP list and the latency information
54*4882a593Smuzhiyun  */
55*4882a593Smuzhiyun struct scpi_ops {
56*4882a593Smuzhiyun 	u32 (*get_version)(void);
57*4882a593Smuzhiyun 	int (*clk_get_range)(u16, unsigned long *, unsigned long *);
58*4882a593Smuzhiyun 	unsigned long (*clk_get_val)(u16);
59*4882a593Smuzhiyun 	int (*clk_set_val)(u16, unsigned long);
60*4882a593Smuzhiyun 	int (*dvfs_get_idx)(u8);
61*4882a593Smuzhiyun 	int (*dvfs_set_idx)(u8, u8);
62*4882a593Smuzhiyun 	struct scpi_dvfs_info *(*dvfs_get_info)(u8);
63*4882a593Smuzhiyun 	int (*device_domain_id)(struct device *);
64*4882a593Smuzhiyun 	int (*get_transition_latency)(struct device *);
65*4882a593Smuzhiyun 	int (*add_opps_to_device)(struct device *);
66*4882a593Smuzhiyun 	int (*sensor_get_capability)(u16 *sensors);
67*4882a593Smuzhiyun 	int (*sensor_get_info)(u16 sensor_id, struct scpi_sensor_info *);
68*4882a593Smuzhiyun 	int (*sensor_get_value)(u16, u64 *);
69*4882a593Smuzhiyun 	int (*device_get_power_state)(u16);
70*4882a593Smuzhiyun 	int (*device_set_power_state)(u16, u8);
71*4882a593Smuzhiyun };
72*4882a593Smuzhiyun 
73*4882a593Smuzhiyun #if IS_REACHABLE(CONFIG_ARM_SCPI_PROTOCOL)
74*4882a593Smuzhiyun struct scpi_ops *get_scpi_ops(void);
75*4882a593Smuzhiyun #else
get_scpi_ops(void)76*4882a593Smuzhiyun static inline struct scpi_ops *get_scpi_ops(void) { return NULL; }
77*4882a593Smuzhiyun #endif
78*4882a593Smuzhiyun 
79*4882a593Smuzhiyun #endif /* _LINUX_SCPI_PROTOCOL_H */
80