Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * SCPI Message Protocol driver header
0004  *
0005  * Copyright (C) 2014 ARM Ltd.
0006  */
0007 
0008 #ifndef _LINUX_SCPI_PROTOCOL_H
0009 #define _LINUX_SCPI_PROTOCOL_H
0010 
0011 #include <linux/types.h>
0012 
0013 struct scpi_opp {
0014     u32 freq;
0015     u32 m_volt;
0016 } __packed;
0017 
0018 struct scpi_dvfs_info {
0019     unsigned int count;
0020     unsigned int latency; /* in nanoseconds */
0021     struct scpi_opp *opps;
0022 };
0023 
0024 enum scpi_sensor_class {
0025     TEMPERATURE,
0026     VOLTAGE,
0027     CURRENT,
0028     POWER,
0029     ENERGY,
0030 };
0031 
0032 struct scpi_sensor_info {
0033     u16 sensor_id;
0034     u8 class;
0035     u8 trigger_type;
0036     char name[20];
0037 } __packed;
0038 
0039 /**
0040  * struct scpi_ops - represents the various operations provided
0041  *  by SCP through SCPI message protocol
0042  * @get_version: returns the major and minor revision on the SCPI
0043  *  message protocol
0044  * @clk_get_range: gets clock range limit(min - max in Hz)
0045  * @clk_get_val: gets clock value(in Hz)
0046  * @clk_set_val: sets the clock value, setting to 0 will disable the
0047  *  clock (if supported)
0048  * @dvfs_get_idx: gets the Operating Point of the given power domain.
0049  *  OPP is an index to the list return by @dvfs_get_info
0050  * @dvfs_set_idx: sets the Operating Point of the given power domain.
0051  *  OPP is an index to the list return by @dvfs_get_info
0052  * @dvfs_get_info: returns the DVFS capabilities of the given power
0053  *  domain. It includes the OPP list and the latency information
0054  * @device_domain_id: gets the scpi domain id for a given device
0055  * @get_transition_latency: gets the DVFS transition latency for a given device
0056  * @add_opps_to_device: adds all the OPPs for a given device
0057  * @sensor_get_capability: get the list of capabilities for the sensors
0058  * @sensor_get_info: get the information of the specified sensor
0059  * @sensor_get_value: gets the current value of the sensor
0060  * @device_get_power_state: gets the power state of a power domain
0061  * @device_set_power_state: sets the power state of a power domain
0062  */
0063 struct scpi_ops {
0064     u32 (*get_version)(void);
0065     int (*clk_get_range)(u16, unsigned long *, unsigned long *);
0066     unsigned long (*clk_get_val)(u16);
0067     int (*clk_set_val)(u16, unsigned long);
0068     int (*dvfs_get_idx)(u8);
0069     int (*dvfs_set_idx)(u8, u8);
0070     struct scpi_dvfs_info *(*dvfs_get_info)(u8);
0071     int (*device_domain_id)(struct device *);
0072     int (*get_transition_latency)(struct device *);
0073     int (*add_opps_to_device)(struct device *);
0074     int (*sensor_get_capability)(u16 *sensors);
0075     int (*sensor_get_info)(u16 sensor_id, struct scpi_sensor_info *);
0076     int (*sensor_get_value)(u16, u64 *);
0077     int (*device_get_power_state)(u16);
0078     int (*device_set_power_state)(u16, u8);
0079 };
0080 
0081 #if IS_REACHABLE(CONFIG_ARM_SCPI_PROTOCOL)
0082 struct scpi_ops *get_scpi_ops(void);
0083 #else
0084 static inline struct scpi_ops *get_scpi_ops(void) { return NULL; }
0085 #endif
0086 
0087 #endif /* _LINUX_SCPI_PROTOCOL_H */