Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
DIOT Zynq Ultrascale-based System Board
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
9
Issues
9
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Projects
DIOT Zynq Ultrascale-based System Board
Commits
e6b0d163
Commit
e6b0d163
authored
Dec 10, 2021
by
Adam Wujek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sw/petalinux/diot_util: add support for fantray
Signed-off-by:
Adam Wujek
<
dev_public@wujek.eu
>
parent
1ef8ecfe
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
91 additions
and
23 deletions
+91
-23
diot_util_sensors.c
...eta-user/recipes-apps/diot-util/files/diot_util_sensors.c
+91
-23
No files found.
sw/petalinux/project-spec/meta-user/recipes-apps/diot-util/files/diot_util_sensors.c
View file @
e6b0d163
...
...
@@ -85,9 +85,7 @@ static struct hw_sensor hw_sensors_temp_list[] = {
DECLARE_DIOT_SENSOR
(
"PSU1"
,
"D57500520-i2c-"
PSU_I2C
"-18"
,
"PSU1 Temp2"
),
DECLARE_DIOT_SENSOR
(
"PSU2"
,
"D57500520-i2c-"
PSU_I2C
"-19"
,
"PSU2 Temp1"
),
DECLARE_DIOT_SENSOR
(
"PSU2"
,
"D57500520-i2c-"
PSU_I2C
"-19"
,
"PSU2 Temp2"
),
DECLARE_DIOT_SENSOR
(
"FAN"
,
"fan-i2c-"
PSU_I2C
"-??"
,
"FAN Temp1"
),
/* TODO: fix FAN's i2c address */
DECLARE_DIOT_SENSOR
(
"FAN"
,
"fan-i2c-"
PSU_I2C
"-??"
,
"FAN Temp2"
),
/* TODO: fix FAN's i2c address */
DECLARE_DIOT_SENSOR
(
"FAN"
,
"fan-i2c-"
PSU_I2C
"-??"
,
"FAN Temp3"
),
/* TODO: fix FAN's i2c address */
DECLARE_DIOT_SENSOR
(
"FANTRAY"
,
"monimod-i2c-"
PSU_I2C
"-12"
,
"FANTRAY Temp"
),
DECLARE_DIOT_SENSOR
(
NULL
,
NULL
,
NULL
)
};
...
...
@@ -133,12 +131,21 @@ static struct hw_sensor hw_sensors_vcp_list[] = {
DECLARE_DIOT_SENSOR
(
"PSU2"
,
"D57500520-i2c-"
PSU_I2C
"-19"
,
"PSU2 12V Voltage"
),
DECLARE_DIOT_SENSOR
(
"PSU2"
,
"D57500520-i2c-"
PSU_I2C
"-19"
,
"PSU2 12V Current"
),
DECLARE_DIOT_SENSOR
(
"PSU2"
,
"D57500520-i2c-"
PSU_I2C
"-19"
,
"PSU2 12V Power"
),
DECLARE_DIOT_SENSOR
(
"FAN"
,
"fan-i2c-"
PSU_I2C
"-??"
,
"FAN Voltage"
),
/* TODO: fix FAN's i2c address */
DECLARE_DIOT_SENSOR
(
"FAN"
,
"fan-i2c-"
PSU_I2C
"-??"
,
"FAN Current"
),
/* TODO: fix FAN's i2c address */
DECLARE_DIOT_SENSOR
(
"FAN"
,
"fan-i2c-"
PSU_I2C
"-??"
,
"FAN Power"
),
/* TODO: fix FAN's i2c address */
DECLARE_DIOT_SENSOR
(
NULL
,
NULL
,
NULL
)
};
/* List of Fan sensors */
static
struct
hw_sensor
hw_sensors_monimod_list
[]
=
{
DECLARE_DIOT_SENSOR
(
"FANTRAY"
,
"monimod-i2c-3-12"
,
"FANTRAY 12V Voltage"
),
DECLARE_DIOT_SENSOR
(
"FANTRAY"
,
"monimod-i2c-3-12"
,
"FANTRAY 5V Voltage"
),
DECLARE_DIOT_SENSOR
(
"FANTRAY"
,
"monimod-i2c-3-12"
,
"FAN1 Current"
),
DECLARE_DIOT_SENSOR
(
"FANTRAY"
,
"monimod-i2c-3-12"
,
"FAN2 Current"
),
DECLARE_DIOT_SENSOR
(
"FANTRAY"
,
"monimod-i2c-3-12"
,
"FAN3 Current"
),
DECLARE_DIOT_SENSOR
(
"FANTRAY"
,
"monimod-i2c-3-12"
,
"FAN1 RPM Slots S+P1-4"
),
DECLARE_DIOT_SENSOR
(
"FANTRAY"
,
"monimod-i2c-3-12"
,
"FAN2 RPM Slots P5-8"
),
DECLARE_DIOT_SENSOR
(
"FANTRAY"
,
"monimod-i2c-3-12"
,
"FAN3 RPM Power Supp"
),
DECLARE_DIOT_SENSOR
(
NULL
,
NULL
,
NULL
)
};
struct
sensor_short
{
char
*
short_name
;
...
...
@@ -188,12 +195,21 @@ static struct sensor_short temp_sensors_irps2_list[] = {
};
static
struct
sensor_short
temp_sensors_monimod_list
[]
=
{
DECLARE_SENSOR_SHORT
(
"FAN"
,
"FAN Temp1"
),
DECLARE_SENSOR_SHORT
(
"FAN"
,
"FAN Temp2"
),
DECLARE_SENSOR_SHORT
(
"FAN"
,
"FAN Temp3"
),
DECLARE_SENSOR_SHORT
(
"FANTRAY"
,
"FANTRAY Temp"
),
DECLARE_SENSOR_SHORT
(
NULL
,
NULL
),
};
static
struct
sensor_short
sensors_monimod_list
[]
=
{
DECLARE_SENSOR_SHORT
(
"FANTRAY"
,
"FANTRAY 12V Voltage"
),
DECLARE_SENSOR_SHORT
(
"FANTRAY"
,
"FANTRAY 5V Voltage"
),
DECLARE_SENSOR_SHORT
(
"FANTRAY"
,
"FAN1 Current"
),
DECLARE_SENSOR_SHORT
(
"FANTRAY"
,
"FAN2 Current"
),
DECLARE_SENSOR_SHORT
(
"FANTRAY"
,
"FAN3 Current"
),
DECLARE_SENSOR_SHORT
(
"FANTRAY"
,
"FAN1 RPM Slots S+P1-4"
),
DECLARE_SENSOR_SHORT
(
"FANTRAY"
,
"FAN2 RPM Slots P5-8"
),
DECLARE_SENSOR_SHORT
(
"FANTRAY"
,
"FAN3 RPM Power Supp"
),
DECLARE_SENSOR_SHORT
(
NULL
,
NULL
),
};
struct
short_vcp
{
/* vcp = Voltage, Current, Power */
char
*
short_name
;
...
...
@@ -240,11 +256,6 @@ static struct short_vcp psu2_entries[] = {
DECLARE_SHORT_VCP
(
NULL
,
NULL
,
NULL
,
NULL
),
};
static
struct
short_vcp
monimod_entries
[]
=
{
DECLARE_SHORT_VCP
(
"FAN"
,
"FAN Voltage"
,
"FAN Current"
,
"FAN Power"
),
DECLARE_SHORT_VCP
(
NULL
,
NULL
,
NULL
,
NULL
),
};
struct
sensor_alarms
{
sensors_subfeature_type
alarm_type
;
char
*
alarm_msg
;
...
...
@@ -553,12 +564,12 @@ void read_all_sensors(void)
/* 3. Read FAN sensors once more */
read_sensors
(
temp_sensors_monimod_list
,
hw_sensors_temp_list
);
read_sensors
_vcp
(
monimod_entries
,
hw_sensors_vcp
_list
);
read_sensors
(
sensors_monimod_list
,
hw_sensors_monimod
_list
);
/* number of Temperature sensors */
expected_errors
=
ARRAY_SIZE
(
temp_sensors_monimod_list
)
-
1
;
/* number of
VCP
sensors */
expected_errors
+=
(
ARRAY_SIZE
(
monimod_entries
)
-
1
)
*
3
;
/* number of
other
sensors */
expected_errors
+=
ARRAY_SIZE
(
sensors_monimod_list
)
-
1
;
if
(
diot_error_buff_n_errors
()
==
expected_errors
)
{
diot_error_clear
();
...
...
@@ -793,7 +804,7 @@ static void print_short_temp(void)
printf
(
"%6s |"
,
"IRPS2"
);
printf
(
"%6s |"
,
"PSU1"
);
printf
(
"%6s |"
,
"PSU2"
);
printf
(
"%6s |"
,
"FAN"
);
printf
(
"%6s |"
,
"FAN
TR
"
);
printf
(
"
\n
"
);
/* Print line */
...
...
@@ -822,7 +833,7 @@ static void print_short_temp(void)
static
void
print_irps_short
(
void
)
{
printf
(
"Voltage/Current/Power read
ing
s:
\n
"
);
printf
(
"Voltage/Current/Power read
out
s:
\n
"
);
printf
(
"---------------+----------------+----------------+----------------+
\n
"
);
printf
(
"IRPS1 | Voltage (V) | Current (A) | Power (W) |
\n
"
);
printf
(
" | read | status | read | status | read | status |
\n
"
);
...
...
@@ -834,16 +845,71 @@ static void print_irps_short(void)
printf
(
"---------------+-------+--------+-------+--------+-------+--------+
\n
"
);
print_short_vcp
(
irps2_entries
,
hw_sensors_vcp_list
);
printf
(
"---------------+----------------+----------------+----------------+
\n
"
);
printf
(
"PSU
/FAN
| Voltage (V) | Current (A) | Power (W) |
\n
"
);
printf
(
"PSU
| Voltage (V) | Current (A) | Power (W) |
\n
"
);
printf
(
" | read | status | read | status | read | status |
\n
"
);
printf
(
"---------------+-------+--------+-------+--------+-------+--------+
\n
"
);
print_short_vcp
(
psu1_entries
,
hw_sensors_vcp_list
);
print_short_vcp
(
psu2_entries
,
hw_sensors_vcp_list
);
print_short_vcp
(
monimod_entries
,
hw_sensors_vcp_list
);
printf
(
"---------------+-------+--------+-------+--------+-------+--------+
\n
"
);
printf
(
"
\n
"
);
}
static
void
print_fan_values
(
char
*
sensor_name_to_print
,
struct
hw_sensor
*
hw_sensors_list
,
int
field_width
,
int
precision_width
)
{
struct
hw_sensor
*
sensor_p
;
sensor_p
=
find_hw_sensor
(
sensor_name_to_print
,
hw_sensors_list
);
if
(
sensor_p
)
{
if
(
isnan
(
sensor_p
->
read_val
))
printf
(
"%*s |"
,
field_width
,
"N/A"
);
else
printf
(
"%s%*.*f%s |"
,
sensor_p
->
alarm
?
COLOR_RED
:
""
,
field_width
,
precision_width
,
sensor_p
->
read_val
,
sensor_p
->
alarm
?
COLOR_OFF
:
""
);
}
else
{
diot_error_add
(
"BUG: sensor %s not on the sensors list!
\n
"
,
sensor_name_to_print
);
printf
(
"%s%*s%s |"
,
COLOR_RED
,
field_width
,
"ERROR"
,
COLOR_OFF
);
}
}
static
void
print_fantray_short
(
void
)
{
printf
(
"Fantray readouts:
\n
"
);
printf
(
"-----------+-------------+
\n
"
);
printf
(
"Power rail | Voltage (V) |
\n
"
);
printf
(
"-----------+-------------+
\n
"
);
printf
(
"%10s |"
,
"12V"
);
print_fan_values
(
"FANTRAY 12V Voltage"
,
hw_sensors_monimod_list
,
12
,
2
);
printf
(
"
\n
"
);
printf
(
"%10s |"
,
"5V"
);
print_fan_values
(
"FANTRAY 5V Voltage"
,
hw_sensors_monimod_list
,
12
,
2
);
printf
(
"
\n
"
);
printf
(
"-----------+-------------+
\n
"
);
printf
(
"--------------------+-------+-------------+
\n
"
);
printf
(
"FAN | RPM | Current (A) |
\n
"
);
printf
(
"--------------------+-------+-------------+
\n
"
);
printf
(
"%-19s |"
,
"FAN1 Slots S, P1-4"
);
print_fan_values
(
"FAN1 RPM Slots S+P1-4"
,
hw_sensors_monimod_list
,
6
,
0
);
print_fan_values
(
"FAN1 Current"
,
hw_sensors_monimod_list
,
12
,
2
);
printf
(
"
\n
"
);
printf
(
"%-19s |"
,
"FAN2 RPM Slots P5-8"
);
print_fan_values
(
"FAN2 RPM Slots P5-8"
,
hw_sensors_monimod_list
,
6
,
0
);
print_fan_values
(
"FAN2 Current"
,
hw_sensors_monimod_list
,
12
,
2
);
printf
(
"
\n
"
);
printf
(
"%-19s |"
,
"FAN3 RPM Power Supp"
);
print_fan_values
(
"FAN3 RPM Power Supp"
,
hw_sensors_monimod_list
,
6
,
0
);
print_fan_values
(
"FAN3 Current"
,
hw_sensors_monimod_list
,
12
,
2
);
printf
(
"
\n
"
);
printf
(
"--------------------+-------+-------------+
\n
"
);
printf
(
"
\n
"
);
}
int
cmd_sensors
(
char
*
params
)
{
diot_error_clear
();
...
...
@@ -859,6 +925,7 @@ int cmd_sensors(char *params)
/* Print sensors */
print_short_temp
();
print_irps_short
();
print_fantray_short
();
sensors_cleanup
();
diot_error_print
();
...
...
@@ -1229,12 +1296,11 @@ static void print_expert_irps(void)
printf
(
"IRPS2 | Voltage (V) | Current (A) | Power (W) |
\n
"
);
printf
(
"---------------+-------------------------------------------+-------------------------------------------+-------------------------------------------+
\n
"
);
print_expert_vcp
(
irps2_entries
,
hw_sensors_vcp_list
);
printf
(
"PSU
/FAN
| Voltage (V) | Current (A) | Power (W) |
\n
"
);
printf
(
"PSU
| Voltage (V) | Current (A) | Power (W) |
\n
"
);
printf
(
"---------------+-------------------------------------------+-------------------------------------------+-------------------------------------------+
\n
"
);
print_expert_vcp
(
psu1_entries
,
hw_sensors_vcp_list
);
print_expert_vcp
(
psu2_entries
,
hw_sensors_vcp_list
);
print_expert_vcp
(
monimod_entries
,
hw_sensors_vcp_list
);
printf
(
"
\n
"
);
}
...
...
@@ -1255,6 +1321,8 @@ int cmd_sensors_expert(char *params)
print_expert_temp
();
printf
(
"
\n
"
);
print_expert_irps
();
printf
(
"
\n
"
);
print_fantray_short
();
sensors_cleanup
();
diot_error_print
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment