1 /*
2  * Arm SCP/MCP Software
3  * Copyright (c) 2018-2021, Arm Limited and Contributors. All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  */
7 
8 #include "scp_system_mmap.h"
9 
10 #include <mod_reg_sensor.h>
11 #include <mod_sensor.h>
12 
13 #include <fwk_element.h>
14 #include <fwk_id.h>
15 #include <fwk_module.h>
16 #include <fwk_module_idx.h>
17 
18 #include <stdint.h>
19 
20 enum REG_SENSOR_DEVICES {
21     REG_SENSOR_DEV_SOC_TEMP,
22     REG_SENSOR_DEV_COUNT,
23 };
24 
25 /*
26  * Register Sensor driver config
27  */
28 static struct mod_sensor_info info_soc_temperature = {
29     .type = MOD_SENSOR_TYPE_DEGREES_C,
30     .update_interval = 0,
31     .update_interval_multiplier = 0,
32     .unit_multiplier = 0,
33 };
34 
35 static const struct fwk_element reg_sensor_element_table[] = {
36     [REG_SENSOR_DEV_SOC_TEMP] = {
37         .name = "Soc Temperature",
38         .data = &((struct mod_reg_sensor_dev_config) {
39             .reg = (uintptr_t)(SCP_SENSOR_SOC_TEMP),
40             .info = &info_soc_temperature,
41         }),
42     },
43     [REG_SENSOR_DEV_COUNT] = { 0 },
44 };
45 
get_reg_sensor_element_table(fwk_id_t id)46 static const struct fwk_element *get_reg_sensor_element_table(fwk_id_t id)
47 {
48     return reg_sensor_element_table;
49 }
50 
51 struct fwk_module_config config_reg_sensor = {
52     .elements = FWK_MODULE_DYNAMIC_ELEMENTS(get_reg_sensor_element_table),
53 };
54 
55 /*
56  * Sensor module config
57  */
58 static const struct fwk_element sensor_element_table[] = {
59     [0] = {
60         .name = "Soc Temperature",
61         .data = &((const struct mod_sensor_dev_config) {
62             .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_REG_SENSOR,
63                                              REG_SENSOR_DEV_SOC_TEMP),
64             .driver_api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_REG_SENSOR, 0),
65         }),
66     },
67     [1] = { 0 },
68 };
69 
get_sensor_element_table(fwk_id_t module_id)70 static const struct fwk_element *get_sensor_element_table(fwk_id_t module_id)
71 {
72     return sensor_element_table;
73 }
74 
75 const struct fwk_module_config config_sensor = {
76     .elements = FWK_MODULE_DYNAMIC_ELEMENTS(get_sensor_element_table),
77 };
78