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