sensor.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /* SPDX-License-Identifier: BSD-3-Clause */
  2. /*
  3. * Copyright 2023-2024 NXP
  4. */
  5. #ifndef SCMI_MSG_SENSOR_H
  6. #define SCMI_MSG_SENSOR_H
  7. #include <stdint.h>
  8. #include <lib/utils_def.h>
  9. #define SCMI_PROTOCOL_VERSION_SENSOR 0x20000U
  10. /*
  11. * Identifiers of the SCMI SENSOR Protocol commands
  12. */
  13. enum scmi_sensor_command_id {
  14. SCMI_SENSOR_DESCRIPTION_GET = 0x003,
  15. SCMI_SENSOR_TRIP_POINT_NOTIFY = 0x004,
  16. SCMI_SENSOR_TRIP_POINT_CONFIG = 0x005,
  17. SCMI_SENSOR_READING_GET = 0x006,
  18. SCMI_SENSOR_AXIS_DESCRIPTION_GET = 0x007,
  19. SCMI_SENSOR_LIST_UPDATE_INTERVALS = 0x008,
  20. SCMI_SENSOR_CONFIG_GET = 0x009,
  21. SCMI_SENSOR_CONFIG_SET = 0x00A,
  22. SCMI_SENSOR_CONTINUOUS_UPDATE_NOTIFY = 0x00B,
  23. SCMI_SENSOR_MAX = 0x00C,
  24. };
  25. /* Protocol attributes */
  26. struct scmi_protocol_attributes_p2a_sensor {
  27. int32_t status;
  28. int16_t num_sensors;
  29. uint8_t max_reqs;
  30. uint8_t res;
  31. uint32_t sensor_reg_low;
  32. uint32_t sensor_reg_high;
  33. uint32_t sensor_reg_len;
  34. };
  35. #define SCMI_SENSOR_NAME_LENGTH_MAX 16U
  36. struct scmi_sensor_desc {
  37. uint32_t id;
  38. uint32_t attr_low;
  39. uint32_t attr_high;
  40. uint8_t name[SCMI_SENSOR_NAME_LENGTH_MAX];
  41. uint32_t power;
  42. uint32_t resolution;
  43. int32_t min_range_low;
  44. int32_t min_range_high;
  45. int32_t max_range_low;
  46. int32_t max_range_high;
  47. };
  48. struct scmi_sensor_description_get_a2p {
  49. uint32_t desc_index;
  50. };
  51. struct scmi_sensor_description_get_p2a {
  52. int32_t status;
  53. uint32_t num_sensor_flags;
  54. };
  55. struct scmi_sensor_config_get_a2p {
  56. uint32_t sensor_id;
  57. };
  58. struct scmi_sensor_config_get_p2a {
  59. int32_t status;
  60. uint32_t sensor_config;
  61. };
  62. /*
  63. * Sensor Reading Get
  64. */
  65. struct scmi_sensor_reading_get_a2p {
  66. uint32_t sensor_id;
  67. uint32_t flags;
  68. };
  69. struct scmi_sensor_val {
  70. uint32_t value_low;
  71. uint32_t value_high;
  72. uint32_t timestap_low;
  73. uint32_t timestap_high;
  74. };
  75. struct scmi_sensor_reading_get_p2a {
  76. int32_t status;
  77. struct scmi_sensor_val val;
  78. };
  79. typedef struct {
  80. uint16_t (*sensor_count)(unsigned int agent_id);
  81. uint8_t (*sensor_max_request)(unsigned int agent_id);
  82. uint32_t (*get_sensor_req)(unsigned int agent_id, unsigned int *addr);
  83. int32_t (*sensor_reading_get)(uint32_t agent_id, uint16_t sensor_id,
  84. uint32_t *val);
  85. uint32_t (*sensor_description_get)(unsigned int agent_id, uint16_t sensor_id,
  86. struct scmi_sensor_desc *desc);
  87. uint32_t (*sensor_update_interval)(uint32_t agent_id, uint16_t sensor_id);
  88. uint32_t (*sensor_state)(uint32_t agent_id, uint16_t sensor_id);
  89. uint16_t (*sensor_timestamped)(uint32_t agent_id, uint16_t sensor_id);
  90. } plat_scmi_sensor_ops_t;
  91. #define REGISTER_SCMI_SENSOR_OPS(_sensor_count, _sensor_max_request, \
  92. _get_sensor_req, _sensor_reading_get, \
  93. _sensor_description_get, _sensor_update_interval, \
  94. _sensor_state, _sensor_timestamped) \
  95. const plat_scmi_sensor_ops_t sensor_ops = { \
  96. .sensor_count = _sensor_count, \
  97. .sensor_max_request = _sensor_max_request, \
  98. .get_sensor_req = _get_sensor_req, \
  99. .sensor_reading_get = _sensor_reading_get, \
  100. .sensor_description_get = _sensor_description_get, \
  101. .sensor_update_interval = _sensor_update_interval, \
  102. .sensor_state = _sensor_state, \
  103. .sensor_timestamped = _sensor_timestamped, \
  104. }
  105. extern const plat_scmi_sensor_ops_t sensor_ops;
  106. #endif /* SCMI_MSG_SENSOR_H */