33#include <stdlib.h>
44#include "sensor.h"
55#include "plat_def.h"
6+ #include <logging/log.h>
67#ifdef ENABLE_APML
78#include "apml.h"
89
10+ LOG_MODULE_REGISTER (dev_apml_mailbox );
11+
912typedef struct _dimm_temp_priv_data {
1013 float ts0_temp ;
1114} dimm_temp_priv_data ;
1215
1316void apml_read_fail_cb (apml_msg * msg )
1417{
1518 if ((msg == NULL ) || (msg -> ptr_arg == NULL )) {
19+ LOG_DBG ("msg passed in as NULL" );
1620 return ;
1721 }
1822 sensor_cfg * cfg = (sensor_cfg * )msg -> ptr_arg ;
@@ -22,13 +26,14 @@ void apml_read_fail_cb(apml_msg *msg)
2226void cpu_power_write (apml_msg * msg )
2327{
2428 if ((msg == NULL ) || (msg -> ptr_arg == NULL )) {
29+ LOG_DBG ("msg passed in as NULL" );
2530 return ;
2631 }
2732 sensor_cfg * cfg = (sensor_cfg * )msg -> ptr_arg ;
2833 mailbox_RdData * rddata = (mailbox_RdData * )msg -> RdData ;
2934 if (rddata -> error_code != SBRMI_MAILBOX_NO_ERR ) {
30- printf ( "[%s] Read cpu power failed, sensor number 0x%x, error code %d\n" , __func__ ,
31- cfg -> num , rddata -> error_code );
35+ LOG_ERR ( " Read cpu power failed, sensor number 0x%x, error code %d\n" , cfg -> num ,
36+ rddata -> error_code );
3237 cfg -> cache_status = SENSOR_UNSPECIFIED_ERROR ;
3338 return ;
3439 }
@@ -45,13 +50,14 @@ void cpu_power_write(apml_msg *msg)
4550void dimm_pwr_write (apml_msg * msg )
4651{
4752 if ((msg == NULL ) || (msg -> ptr_arg == NULL )) {
53+ LOG_DBG ("msg passed in as NULL" );
4854 return ;
4955 }
5056 sensor_cfg * cfg = (sensor_cfg * )msg -> ptr_arg ;
5157 mailbox_RdData * rddata = (mailbox_RdData * )msg -> RdData ;
5258 if (rddata -> error_code != SBRMI_MAILBOX_NO_ERR ) {
53- printf ( "[%s] Read dimm power failed, sensor number 0x%x, error code %d\n" , __func__ ,
54- cfg -> num , rddata -> error_code );
59+ LOG_ERR ( " Read dimm power failed, sensor number 0x%x, error code %d\n" , cfg -> num ,
60+ rddata -> error_code );
5561 cfg -> cache_status = SENSOR_UNSPECIFIED_ERROR ;
5662 return ;
5763 }
@@ -66,14 +72,15 @@ void dimm_pwr_write(apml_msg *msg)
6672void dimm_temp_write (apml_msg * msg )
6773{
6874 if ((msg == NULL ) || (msg -> ptr_arg == NULL )) {
75+ LOG_DBG ("msg passed in as NULL" );
6976 return ;
7077 }
7178 sensor_cfg * cfg = (sensor_cfg * )msg -> ptr_arg ;
7279 mailbox_RdData * rddata = (mailbox_RdData * )msg -> RdData ;
7380
7481 if (rddata -> error_code != SBRMI_MAILBOX_NO_ERR ) {
75- printf ( "[%s] Read dimm temperature failed, sensor number 0x%x, error code %d\n" ,
76- __func__ , cfg -> num , rddata -> error_code );
82+ LOG_ERR ( " Read dimm temperature failed, sensor number 0x%x, error code %d\n" ,
83+ cfg -> num , rddata -> error_code );
7784 cfg -> cache_status = SENSOR_UNSPECIFIED_ERROR ;
7885 return ;
7986 }
@@ -83,7 +90,7 @@ void dimm_temp_write(apml_msg *msg)
8390 if (is_ts1 ) {
8491 float * TS0_temp = & (((dimm_temp_priv_data * )(cfg -> priv_data ))-> ts0_temp );
8592 if (TS0_temp == NULL ) {
86- printf ( "[%s] TS0_temp is NULL!\n", __func__ );
93+ LOG_DBG ( " TS0_temp is NULL!\n" );
8794 cfg -> cache_status = SENSOR_UNSPECIFIED_ERROR ;
8895 return ;
8996 }
@@ -101,20 +108,21 @@ void dimm_temp_write(apml_msg *msg)
101108 if (cfg -> priv_data ) {
102109 float * TS0_temp = & (((dimm_temp_priv_data * )(cfg -> priv_data ))-> ts0_temp );
103110 if (TS0_temp == NULL ) {
104- printf ( "[%s] TS0_temp is NULL!\n", __func__ );
111+ LOG_DBG ( " TS0_temp is NULL!\n" );
105112 cfg -> cache_status = SENSOR_UNSPECIFIED_ERROR ;
106113 return ;
107114 }
108115 * TS0_temp = temp ;
109116 } else {
110- printf ( "[%s] private data is NULL!\n", __func__ );
117+ LOG_ERR ( "Private data is NULL!\n" );
111118 }
112119 }
113120}
114121
115122uint8_t apml_mailbox_read (uint8_t sensor_num , int * reading )
116123{
117124 if (reading == NULL || (sensor_num > SENSOR_NUM_MAX )) {
125+ LOG_DBG ("msg passed in as NULL" );
118126 return SENSOR_UNSPECIFIED_ERROR ;
119127 }
120128
@@ -164,14 +172,15 @@ uint8_t apml_mailbox_read(uint8_t sensor_num, int *reading)
164172uint8_t apml_mailbox_init (uint8_t sensor_num )
165173{
166174 if (sensor_num > SENSOR_NUM_MAX ) {
175+ LOG_DBG ("msg passed in as NULL" );
167176 return SENSOR_INIT_UNSPECIFIED_ERROR ;
168177 }
169178 sensor_cfg * cfg = & sensor_config [sensor_config_index_map [sensor_num ]];
170179
171180 if (cfg -> offset == SBRMI_MAILBOX_GET_DIMM_TEMP ) {
172181 cfg -> priv_data = malloc (sizeof (dimm_temp_priv_data ));
173182 if (cfg -> priv_data == NULL ) {
174- printf ( "[%s] Allocate private data failed.\n", __func__ );
183+ LOG_DBG ( " Allocate private data failed.\n" );
175184 return SENSOR_INIT_UNSPECIFIED_ERROR ;
176185 }
177186 }
0 commit comments