blob: afbf8037d8db8015a8bc1f570135d0656de070af [file] [log] [blame]
Thomas Gleixner9952f692019-05-28 10:10:04 -07001/* SPDX-License-Identifier: GPL-2.0-only */
Sudeep Holla8cb7cf52015-03-30 10:59:52 +01002/*
3 * SCPI Message Protocol driver header
4 *
5 * Copyright (C) 2014 ARM Ltd.
Sudeep Holla8cb7cf52015-03-30 10:59:52 +01006 */
Sudeep Holla23818b32020-04-03 18:10:18 +01007
8#ifndef _LINUX_SCPI_PROTOCOL_H
9#define _LINUX_SCPI_PROTOCOL_H
10
Sudeep Holla8cb7cf52015-03-30 10:59:52 +010011#include <linux/types.h>
12
13struct scpi_opp {
14 u32 freq;
15 u32 m_volt;
16} __packed;
17
18struct scpi_dvfs_info {
19 unsigned int count;
20 unsigned int latency; /* in nanoseconds */
21 struct scpi_opp *opps;
22};
23
Punit Agrawal38a1bdc2015-06-19 15:31:46 +010024enum scpi_sensor_class {
25 TEMPERATURE,
26 VOLTAGE,
27 CURRENT,
28 POWER,
Sudeep Hollafb3b07e2016-01-25 10:53:38 +000029 ENERGY,
Punit Agrawal38a1bdc2015-06-19 15:31:46 +010030};
31
32struct scpi_sensor_info {
33 u16 sensor_id;
34 u8 class;
35 u8 trigger_type;
36 char name[20];
37} __packed;
38
Sudeep Holla8cb7cf52015-03-30 10:59:52 +010039/**
40 * struct scpi_ops - represents the various operations provided
41 * by SCP through SCPI message protocol
42 * @get_version: returns the major and minor revision on the SCPI
43 * message protocol
44 * @clk_get_range: gets clock range limit(min - max in Hz)
45 * @clk_get_val: gets clock value(in Hz)
46 * @clk_set_val: sets the clock value, setting to 0 will disable the
47 * clock (if supported)
48 * @dvfs_get_idx: gets the Operating Point of the given power domain.
49 * OPP is an index to the list return by @dvfs_get_info
50 * @dvfs_set_idx: sets the Operating Point of the given power domain.
51 * OPP is an index to the list return by @dvfs_get_info
52 * @dvfs_get_info: returns the DVFS capabilities of the given power
53 * domain. It includes the OPP list and the latency information
54 */
55struct scpi_ops {
56 u32 (*get_version)(void);
57 int (*clk_get_range)(u16, unsigned long *, unsigned long *);
58 unsigned long (*clk_get_val)(u16);
59 int (*clk_set_val)(u16, unsigned long);
60 int (*dvfs_get_idx)(u8);
61 int (*dvfs_set_idx)(u8, u8);
62 struct scpi_dvfs_info *(*dvfs_get_info)(u8);
Sudeep Holla45ca7df2017-04-27 15:08:51 +010063 int (*device_domain_id)(struct device *);
64 int (*get_transition_latency)(struct device *);
65 int (*add_opps_to_device)(struct device *);
Punit Agrawal38a1bdc2015-06-19 15:31:46 +010066 int (*sensor_get_capability)(u16 *sensors);
67 int (*sensor_get_info)(u16 sensor_id, struct scpi_sensor_info *);
Sudeep Holla2e874152016-01-14 17:58:02 +000068 int (*sensor_get_value)(u16, u64 *);
Sudeep Holla37a441d2016-04-20 14:05:14 +010069 int (*device_get_power_state)(u16);
70 int (*device_set_power_state)(u16, u8);
Sudeep Holla8cb7cf52015-03-30 10:59:52 +010071};
72
Arnd Bergmann851df3d2015-11-16 22:34:58 +010073#if IS_REACHABLE(CONFIG_ARM_SCPI_PROTOCOL)
Sudeep Holla8cb7cf52015-03-30 10:59:52 +010074struct scpi_ops *get_scpi_ops(void);
75#else
76static inline struct scpi_ops *get_scpi_ops(void) { return NULL; }
77#endif
Sudeep Holla23818b32020-04-03 18:10:18 +010078
79#endif /* _LINUX_SCPI_PROTOCOL_H */