blob: ecb004711acf70bab8024239e24b45063e2f079e [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 */
7#include <linux/types.h>
8
9struct scpi_opp {
10 u32 freq;
11 u32 m_volt;
12} __packed;
13
14struct scpi_dvfs_info {
15 unsigned int count;
16 unsigned int latency; /* in nanoseconds */
17 struct scpi_opp *opps;
18};
19
Punit Agrawal38a1bdc2015-06-19 15:31:46 +010020enum scpi_sensor_class {
21 TEMPERATURE,
22 VOLTAGE,
23 CURRENT,
24 POWER,
Sudeep Hollafb3b07e2016-01-25 10:53:38 +000025 ENERGY,
Punit Agrawal38a1bdc2015-06-19 15:31:46 +010026};
27
28struct scpi_sensor_info {
29 u16 sensor_id;
30 u8 class;
31 u8 trigger_type;
32 char name[20];
33} __packed;
34
Sudeep Holla8cb7cf52015-03-30 10:59:52 +010035/**
36 * struct scpi_ops - represents the various operations provided
37 * by SCP through SCPI message protocol
38 * @get_version: returns the major and minor revision on the SCPI
39 * message protocol
40 * @clk_get_range: gets clock range limit(min - max in Hz)
41 * @clk_get_val: gets clock value(in Hz)
42 * @clk_set_val: sets the clock value, setting to 0 will disable the
43 * clock (if supported)
44 * @dvfs_get_idx: gets the Operating Point of the given power domain.
45 * OPP is an index to the list return by @dvfs_get_info
46 * @dvfs_set_idx: sets the Operating Point of the given power domain.
47 * OPP is an index to the list return by @dvfs_get_info
48 * @dvfs_get_info: returns the DVFS capabilities of the given power
49 * domain. It includes the OPP list and the latency information
50 */
51struct scpi_ops {
52 u32 (*get_version)(void);
53 int (*clk_get_range)(u16, unsigned long *, unsigned long *);
54 unsigned long (*clk_get_val)(u16);
55 int (*clk_set_val)(u16, unsigned long);
56 int (*dvfs_get_idx)(u8);
57 int (*dvfs_set_idx)(u8, u8);
58 struct scpi_dvfs_info *(*dvfs_get_info)(u8);
Sudeep Holla45ca7df2017-04-27 15:08:51 +010059 int (*device_domain_id)(struct device *);
60 int (*get_transition_latency)(struct device *);
61 int (*add_opps_to_device)(struct device *);
Punit Agrawal38a1bdc2015-06-19 15:31:46 +010062 int (*sensor_get_capability)(u16 *sensors);
63 int (*sensor_get_info)(u16 sensor_id, struct scpi_sensor_info *);
Sudeep Holla2e874152016-01-14 17:58:02 +000064 int (*sensor_get_value)(u16, u64 *);
Sudeep Holla37a441d2016-04-20 14:05:14 +010065 int (*device_get_power_state)(u16);
66 int (*device_set_power_state)(u16, u8);
Sudeep Holla8cb7cf52015-03-30 10:59:52 +010067};
68
Arnd Bergmann851df3d2015-11-16 22:34:58 +010069#if IS_REACHABLE(CONFIG_ARM_SCPI_PROTOCOL)
Sudeep Holla8cb7cf52015-03-30 10:59:52 +010070struct scpi_ops *get_scpi_ops(void);
71#else
72static inline struct scpi_ops *get_scpi_ops(void) { return NULL; }
73#endif