scpi_protocol.h 2.1 KB

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