[Skiboot] [PATCH v2 06/13] fsp-sensor: add a status property
Cédric Le Goater
clg at fr.ibm.com
Sat Feb 21 01:27:29 AEDT 2015
This patch adds a new status property for the sensors available
on a Power system.
The status of a FSP sensor can be returned by one or more PRS
command modifiers. For power supply and fans, we choose the PRS
modifier (and not DATA) to return the AC_FAULTED bit. For the
ambient temperature, we have no choice, the DATA modifier needs
to be used.
We leave the decoding to the responsibility of the OS driver. This
is a change from the current implementation which should not add
too much complexity in the driver. The status bits being :
PRS PARAM/DATA
Modifier Modifier
0x0010 ON SUPPORTED
0x0008 ON
0x0004 AC FAULTED EM ALERT
0x0002 FAULTED FAULTED
0x0001 PRESENT PRESENT
we will expect Linux to only use bits[1-3] to reflect the status as
a *_alarm or *_fault attribute. bits [4-5] can be discarded.
For the core temperature sensors, we change the trip bits layout to
be the same but, as they are always set, we brutaly assign the value
to nil for the moment until we know why.
Signed-off-by: Cédric Le Goater <clg at fr.ibm.com>
---
Changes since RFC :
- added DTS status
hw/dts.c | 24 +++++++++++++++++++++-
hw/fsp/fsp-sensor.c | 55 +++++++++++++++++++++++++++++++++++++++++----------
2 files changed, 68 insertions(+), 11 deletions(-)
diff --git a/hw/dts.c b/hw/dts.c
index a58703cf28de..434f0add9efa 100644
--- a/hw/dts.c
+++ b/hw/dts.c
@@ -114,6 +114,12 @@ static int dts_read_core_temp(uint32_t pir, struct dts *dts)
prlog(PR_TRACE, "DTS: Chip %x Core %x temp:%dC trip:%x\n",
chip_id, core, dts->temp, dts->trip);
+
+ /*
+ * FIXME: The trip bits are always set ?! Just discard
+ * them for the moment until we understand why.
+ */
+ dts->trip = 0;
return 0;
}
@@ -160,7 +166,18 @@ int64_t dts_sensor_read(uint32_t sensor_hndl, uint32_t *sensor_data)
if (attr == SENSOR_DTS_ATTR_TEMP_MAX)
*sensor_data = dts.temp;
else if (attr == SENSOR_DTS_ATTR_TEMP_TRIP)
- *sensor_data = dts.trip;
+ /*
+ * shift left the trip bits and add a 'present' bit to
+ * fit the common layout for status. The meaning is
+ * slighty different but testing against 0x6 should
+ * raise an alarm
+ *
+ * fatal 11 1
+ * critical 10 1
+ * warning 01 1
+ * no trip 00 1
+ */
+ *sensor_data = (dts.trip << 1) | 0x1;
return 0;
}
@@ -194,6 +211,11 @@ bool dts_sensor_create_nodes(struct dt_node *sensors)
dt_add_property_string(node, "compatible",
"ibm,opal-sensor");
dt_add_property_cells(node, "sensor-data", handler);
+
+ handler = sensor_make_handler(sensor_class,
+ c->pir, SENSOR_DTS_ATTR_TEMP_TRIP);
+ dt_add_property_cells(node, "sensor-status", handler);
+
}
}
diff --git a/hw/fsp/fsp-sensor.c b/hw/fsp/fsp-sensor.c
index 3dab8803dc75..a44a42bb82bd 100644
--- a/hw/fsp/fsp-sensor.c
+++ b/hw/fsp/fsp-sensor.c
@@ -79,6 +79,7 @@ enum sensor_state {
enum spcn_attr {
/* mod 0x01, 0x02 */
+ SENSOR_STATUS,
SENSOR_PRESENT,
SENSOR_FAULTED,
SENSOR_AC_FAULTED,
@@ -119,6 +120,7 @@ struct spcn_mod {
};
static struct spcn_mod_attr prs_status_attrs[] = {
+ {"status", SENSOR_STATUS},
{"present", SENSOR_PRESENT},
{"faulted", SENSOR_FAULTED},
{"ac-faulted", SENSOR_AC_FAULTED},
@@ -282,6 +284,9 @@ static void fsp_sensor_process_data(struct opal_sensor_data *attr)
sensor_mod_data[1] == attr->rid) {
switch (attr->spcn_attr) {
/* modifier 0x01, 0x02 */
+ case SENSOR_STATUS:
+ sensor_data = sensor_mod_data[3];
+ break;
case SENSOR_PRESENT:
prlog(PR_TRACE,"Not exported to device tree\n");
break;
@@ -499,16 +504,19 @@ static inline bool sensor_frc_is_valid(uint16_t frc)
* its data. The routine below provides the mapping between the
* attribute and the PRS command modifier to use.
*
- * resource | data | thrs |
- * ----------------+--------+--------+
- * power_supply | POWER | |
- * ----------------+--------+--------+
- * amb-temp | DATA | |
- * | | PARAM |
- * ----------------+--------+--------+
- * fan | DATA | |
- * | | PARAM |
- * | | |
+ * resource | data | thrs | status |
+ * ----------------+--------+--------+-----------+
+ * power_supply | POWER | | |
+ * | | | PRS |
+ * ----------------+--------+--------+-----------+
+ * amb-temp | DATA | | DATA |
+ * | | PARAM | PARAM (*) |
+ * ----------------+--------+--------+-----------+
+ * fan | DATA | | DATA (*) |
+ * | | PARAM | PARAM (*) |
+ * | | | PRS |
+ *
+ * (*) don't use the attribute given by this command modifier
*/
static int64_t parse_sensor_id(uint32_t handler, struct opal_sensor_data *attr)
{
@@ -534,6 +542,21 @@ static int64_t parse_sensor_id(uint32_t handler, struct opal_sensor_data *attr)
case SENSOR_THRS:
mod = SPCN_MOD_SENSOR_PARAM_FIRST;
break;
+
+ case SENSOR_STATUS:
+ switch (attr->frc) {
+ case SENSOR_FRC_AMB_TEMP:
+ mod = SPCN_MOD_SENSOR_DATA_FIRST;
+ break;
+ case SENSOR_FRC_POWER_SUPPLY:
+ case SENSOR_FRC_COOLING_FAN:
+ mod = SPCN_MOD_PRS_STATUS_FIRST;
+ break;
+ default:
+ return OPAL_PARAMETER;
+ }
+ break;
+
default:
return OPAL_PARAMETER;
}
@@ -655,6 +678,8 @@ static int add_sensor_prs(struct dt_node *sensors, struct sensor_prs *prs)
if (!node)
return -1;
+ dt_add_property_cells(node, "sensor-status",
+ sensor_handler(prs->header, SENSOR_STATUS));
return 0;
}
@@ -669,6 +694,8 @@ static int add_sensor_param(struct dt_node *sensors, struct sensor_param *param)
dt_add_property_string(node, "ibm,loc-code", param->location);
dt_add_property_cells(node, "sensor-threshold",
sensor_handler(param->header, SENSOR_THRS));
+ /* don't use the status coming from the response of the
+ * SENSOR_PARAM subcommand */
return 0;
}
@@ -683,6 +710,14 @@ static int add_sensor_data(struct dt_node *sensors,
dt_add_property_cells(node, "sensor-data",
sensor_handler(data->header, SENSOR_DATA));
+
+ /* Let's make sure we are not adding a duplicate device node.
+ * Some resource, like fans, get their status attribute from
+ * three different commands ...
+ */
+ if (data->header.frc == SENSOR_FRC_AMB_TEMP)
+ dt_add_property_cells(node, "sensor-status",
+ sensor_handler(data->header, SENSOR_STATUS));
return 0;
}
--
1.7.10.4
More information about the Skiboot
mailing list