scpi_protocol.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * SCPI Message Protocol driver header
  3. *
  4. * Copyright (C) 2014 ARM Ltd.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms and conditions of the GNU General Public License,
  8. * version 2, as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along with
  16. * this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include <linux/types.h>
  19. struct scpi_opp {
  20. u32 freq;
  21. u32 m_volt;
  22. } __packed;
  23. struct scpi_dvfs_info {
  24. unsigned int count;
  25. unsigned int latency; /* in nanoseconds */
  26. struct scpi_opp *opps;
  27. };
  28. enum scpi_sensor_class {
  29. TEMPERATURE,
  30. VOLTAGE,
  31. CURRENT,
  32. POWER,
  33. };
  34. struct scpi_sensor_info {
  35. u16 sensor_id;
  36. u8 class;
  37. u8 trigger_type;
  38. char name[20];
  39. } __packed;
  40. /**
  41. * struct scpi_ops - represents the various operations provided
  42. * by SCP through SCPI message protocol
  43. * @get_version: returns the major and minor revision on the SCPI
  44. * message protocol
  45. * @clk_get_range: gets clock range limit(min - max in Hz)
  46. * @clk_get_val: gets clock value(in Hz)
  47. * @clk_set_val: sets the clock value, setting to 0 will disable the
  48. * clock (if supported)
  49. * @dvfs_get_idx: gets the Operating Point of the given power domain.
  50. * OPP is an index to the list return by @dvfs_get_info
  51. * @dvfs_set_idx: sets the Operating Point of the given power domain.
  52. * OPP is an index to the list return by @dvfs_get_info
  53. * @dvfs_get_info: returns the DVFS capabilities of the given power
  54. * domain. It includes the OPP list and the latency information
  55. */
  56. struct scpi_ops {
  57. u32 (*get_version)(void);
  58. int (*clk_get_range)(u16, unsigned long *, unsigned long *);
  59. unsigned long (*clk_get_val)(u16);
  60. int (*clk_set_val)(u16, unsigned long);
  61. int (*dvfs_get_idx)(u8);
  62. int (*dvfs_set_idx)(u8, u8);
  63. struct scpi_dvfs_info *(*dvfs_get_info)(u8);
  64. int (*sensor_get_capability)(u16 *sensors);
  65. int (*sensor_get_info)(u16 sensor_id, struct scpi_sensor_info *);
  66. int (*sensor_get_value)(u16, u32 *);
  67. };
  68. #if IS_ENABLED(CONFIG_ARM_SCPI_PROTOCOL)
  69. struct scpi_ops *get_scpi_ops(void);
  70. #else
  71. static inline struct scpi_ops *get_scpi_ops(void) { return NULL; }
  72. #endif