1 /* 2 * Arm SCP/MCP Software 3 * Copyright (c) 2022, Arm Limited and Contributors. All rights reserved. 4 * 5 * SPDX-License-Identifier: BSD-3-Clause 6 */ 7 8 #ifdef BUILD_HAS_SCMI_SENSOR_V2 9 10 # include <internal/scmi_sensor.h> 11 12 # include <mod_scmi.h> 13 # include <mod_scmi_sensor.h> 14 # include <mod_sensor.h> 15 16 # include <fwk_assert.h> 17 # include <fwk_id.h> 18 # include <fwk_status.h> 19 20 # include <stdbool.h> 21 # include <stddef.h> 22 # include <stdint.h> 23 scmi_sensor_prop_set(struct mod_sensor_complete_info * info,struct scmi_sensor_desc * desc)24void scmi_sensor_prop_set( 25 struct mod_sensor_complete_info *info, 26 struct scmi_sensor_desc *desc) 27 { 28 if (info->hal_info.ext_attributes && !info->multi_axis.support) { 29 desc->sensor_power = info->hal_info.sensor_properties.sensor_power; 30 desc->sensor_resolution = info->hal_info.sensor_properties 31 .sensor_property_vals.axis_resolution; 32 desc->sensor_min_range_low = (int32_t)( 33 info->hal_info.sensor_properties.sensor_property_vals 34 .axis_min_range & 35 0xffffffff); 36 desc->sensor_min_range_high = (int32_t)( 37 info->hal_info.sensor_properties.sensor_property_vals 38 .axis_min_range >> 39 32); 40 desc->sensor_max_range_low = (int32_t)( 41 info->hal_info.sensor_properties.sensor_property_vals 42 .axis_max_range & 43 0xffffffff); 44 desc->sensor_min_range_high = (int32_t)( 45 info->hal_info.sensor_properties.sensor_property_vals 46 .axis_max_range >> 47 32); 48 } else { 49 /* Populate with the default values from the SCMI specification V3.0 */ 50 desc->sensor_power = SCMI_SENSOR_EXT_ATTR_POWER; 51 desc->sensor_resolution = SCMI_SENSOR_EXT_ATTR_RESOLUTION_VAL; 52 desc->sensor_min_range_low = SCMI_SENSOR_EXT_ATTR_MIN_RANGE_LOW; 53 desc->sensor_min_range_high = SCMI_SENSOR_EXT_ATTR_MIN_RANGE_HIGH; 54 desc->sensor_max_range_low = SCMI_SENSOR_EXT_ATTR_MAX_RANGE_LOW; 55 desc->sensor_max_range_high = SCMI_SENSOR_EXT_ATTR_MAX_RANGE_HIGH; 56 } 57 } 58 scmi_sensor_axis_prop_set(struct mod_sensor_axis_info * axis_values,struct scmi_sensor_axis_desc * desc)59void scmi_sensor_axis_prop_set( 60 struct mod_sensor_axis_info *axis_values, 61 struct scmi_sensor_axis_desc *desc) 62 { 63 if (axis_values->extended_attribs) { 64 desc->axis_resolution = 65 axis_values->multi_axis_properties.axis_resolution; 66 desc->axis_min_range_low = (int32_t)( 67 axis_values->multi_axis_properties.axis_min_range & 0xffffffff); 68 desc->axis_min_range_high = 69 (int32_t)(axis_values->multi_axis_properties.axis_min_range >> 32); 70 desc->axis_max_range_low = (int32_t)( 71 axis_values->multi_axis_properties.axis_max_range & 0xffffffff); 72 desc->axis_max_range_high = 73 (int32_t)(axis_values->multi_axis_properties.axis_max_range >> 32); 74 } else { 75 /* Populate with the default values from the SCMI specification V3.0 */ 76 desc->axis_resolution = SCMI_SENSOR_EXT_ATTR_RESOLUTION_VAL; 77 desc->axis_min_range_low = SCMI_SENSOR_EXT_ATTR_MIN_RANGE_LOW; 78 desc->axis_min_range_high = SCMI_SENSOR_EXT_ATTR_MIN_RANGE_HIGH; 79 desc->axis_max_range_low = SCMI_SENSOR_EXT_ATTR_MAX_RANGE_LOW; 80 desc->axis_max_range_high = SCMI_SENSOR_EXT_ATTR_MAX_RANGE_HIGH; 81 } 82 } 83 84 #endif 85