1 /*
2  * Renesas SCP/MCP Software
3  * Copyright (c) 2020-2021, Renesas Electronics Corporation. All rights
4  * reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 
9 #include <system_mmap.h>
10 #include <config_sensor.h>
11 
12 #include <mod_reg_sensor.h>
13 #include <mod_sensor.h>
14 
15 #include <fwk_element.h>
16 #include <fwk_module.h>
17 #include <fwk_module_idx.h>
18 
19 #include <stddef.h>
20 
21 /*
22  * Register Sensor driver config
23  */
24 static struct mod_sensor_info info_soc_temperature = {
25     .type = MOD_SENSOR_TYPE_DEGREES_C,
26     .update_interval = 0,
27     .update_interval_multiplier = 0,
28     .unit_multiplier = -3,
29 };
30 
31 static const struct fwk_element reg_sensor_element_table[] = {
32     [REG_SENSOR_DEV_SOC_TEMP1] = {
33         .name = "thermal1",
34         .data = &((struct mod_reg_sensor_dev_config) {
35             .reg = (uintptr_t)(SENSOR_SOC_TEMP1),
36             .info = &info_soc_temperature,
37         }),
38     },
39     [REG_SENSOR_DEV_SOC_TEMP2] = {
40         .name = "thermal2",
41         .data = &((struct mod_reg_sensor_dev_config) {
42             .reg = (uintptr_t)(SENSOR_SOC_TEMP2),
43             .info = &info_soc_temperature,
44         }),
45     },
46     [REG_SENSOR_DEV_SOC_TEMP3] = {
47         .name = "thermal3",
48         .data = &((struct mod_reg_sensor_dev_config) {
49             .reg = (uintptr_t)(SENSOR_SOC_TEMP3),
50             .info = &info_soc_temperature,
51         }),
52     },
53     [REG_SENSOR_DEV_COUNT] = { 0 },
54 };
55 
get_reg_sensor_element_table(fwk_id_t id)56 static const struct fwk_element *get_reg_sensor_element_table(fwk_id_t id)
57 {
58     return reg_sensor_element_table;
59 }
60 
61 struct fwk_module_config config_rcar_reg_sensor = {
62     .elements = FWK_MODULE_DYNAMIC_ELEMENTS(get_reg_sensor_element_table),
63 };
64 
65 /*
66  * Sensor module config
67  */
68 static const struct fwk_element sensor_element_table[] = {
69     [R8A7795_SNSR_THERMAL1] = {
70         .name = "thermal1",
71         .data = &((const struct mod_sensor_dev_config) {
72             .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_REG_SENSOR,
73                                              REG_SENSOR_DEV_SOC_TEMP1),
74             .driver_api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_REG_SENSOR, 0),
75         }),
76     },
77     [R8A7795_SNSR_THERMAL2] = {
78         .name = "thermal2",
79         .data = &((const struct mod_sensor_dev_config) {
80             .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_REG_SENSOR,
81                                              REG_SENSOR_DEV_SOC_TEMP2),
82             .driver_api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_REG_SENSOR, 0),
83         }),
84     },
85     [R8A7795_SNSR_THERMAL3] = {
86         .name = "thermal3",
87         .data = &((const struct mod_sensor_dev_config) {
88             .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_REG_SENSOR,
89                                              REG_SENSOR_DEV_SOC_TEMP3),
90             .driver_api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_REG_SENSOR, 0),
91         }),
92     },
93     [R8A7795_SNSR_COUNT] = { 0 },
94 };
95 
get_sensor_element_table(fwk_id_t module_id)96 static const struct fwk_element *get_sensor_element_table(fwk_id_t module_id)
97 {
98     return sensor_element_table;
99 }
100 
101 struct fwk_module_config config_sensor = {
102     .elements = FWK_MODULE_DYNAMIC_ELEMENTS(get_sensor_element_table),
103     .data = NULL,
104 };
105