1 /*
2 * Arm SCP/MCP Software
3 * Copyright (c) 2022, Linaro Limited and Contributors. All rights reserved.
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7
8 #include <fwk_module.h>
9 #include <fwk_module_idx.h>
10 #include <mod_scmi_sensor.h>
11 #include <mod_sensor.h>
12 #include <mod_reg_sensor.h>
13 #include "config_reg_sensor.h"
14
15 uint64_t soc_temp[3] = {25000, 25000, 25000};
16 uint64_t ddr_temp[1] = {25000};
17 /*
18 * Register Sensor driver config
19 */
20 static struct mod_sensor_info info_soc_temperature = {
21 .type = MOD_SENSOR_TYPE_DEGREES_C,
22 .update_interval = 0,
23 .update_interval_multiplier = 0,
24 .unit_multiplier = -3,
25 };
26
27 static const struct fwk_element reg_sensor_element_table[] = {
28 [SENSOR_DEV_SOC_TEMP] = {
29 .name = "Soc Temperature",
30 .data = &((struct mod_reg_sensor_dev_config) {
31 .reg = (uintptr_t)(soc_temp),
32 .info = &info_soc_temperature,
33 }),
34 },
35 [SENSOR_DEV_DDR_TEMP] = {
36 .name = "DDR Temperature",
37 .data = &((struct mod_reg_sensor_dev_config) {
38 .reg = (uintptr_t)(ddr_temp),
39 .info = &info_soc_temperature,
40 }),
41 },
42 [SENSOR_DEV_COUNT] = { 0 },
43 };
44
get_reg_sensor_element_table(fwk_id_t id)45 static const struct fwk_element *get_reg_sensor_element_table(fwk_id_t id)
46 {
47 return reg_sensor_element_table;
48 }
49
50 struct fwk_module_config config_reg_sensor = {
51 .elements = FWK_MODULE_DYNAMIC_ELEMENTS(get_reg_sensor_element_table),
52 };
53
54 /*
55 * Sensor module config
56 */
57 static const struct fwk_element sensor_element_table[] = {
58 [0] = {
59 .name = "Soc Temperature",
60 .data = &((const struct mod_sensor_dev_config) {
61 .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_REG_SENSOR,
62 SENSOR_DEV_SOC_TEMP),
63 .driver_api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_REG_SENSOR, 0),
64 .trip_point = {
65 .count = 2,
66 }
67 }),
68 },
69 [1] = {
70 .name = "DDR Temperature",
71 .data = &((const struct mod_sensor_dev_config) {
72 .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_REG_SENSOR,
73 SENSOR_DEV_DDR_TEMP),
74 .driver_api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_REG_SENSOR, 0),
75 .trip_point = {
76 .count = 2,
77 }
78 }),
79 },
80 [2] = { 0 },
81 };
82
get_sensor_element_table(fwk_id_t module_id)83 static const struct fwk_element *get_sensor_element_table(fwk_id_t module_id)
84 {
85 return sensor_element_table;
86 }
87 static const struct mod_sensor_config sensor_config = {
88 #ifdef BUILD_HAS_SCMI_NOTIFICATIONS
89 .notification_id = FWK_ID_MODULE_INIT(FWK_MODULE_IDX_SCMI_SENSOR),
90 .trip_point_api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_SCMI_SENSOR,
91 SCMI_SENSOR_API_IDX_TRIP_POINT),
92 #else
93 .notification_id = FWK_ID_NONE_INIT
94 #endif
95 };
96
97 struct fwk_module_config config_sensor = {
98 .elements = FWK_MODULE_DYNAMIC_ELEMENTS(get_sensor_element_table),
99 .data = &sensor_config,
100 };
101