diff options
-rw-r--r-- | core/sensor.c | 4 | ||||
-rw-r--r-- | doc/device-tree/ibm,opal/sensors.rst | 9 | ||||
-rw-r--r-- | hw/dts.c | 6 | ||||
-rw-r--r-- | hw/fsp/fsp-sensor.c | 2 | ||||
-rw-r--r-- | include/sensor.h | 34 |
5 files changed, 34 insertions, 21 deletions
diff --git a/core/sensor.c b/core/sensor.c index 59845c3..cc5341c 100644 --- a/core/sensor.c +++ b/core/sensor.c @@ -26,8 +26,10 @@ struct dt_node *sensor_node; static int64_t opal_sensor_read(uint32_t sensor_hndl, int token, uint32_t *sensor_data) { - if (sensor_is_dts(sensor_hndl)) + switch (sensor_get_family(sensor_hndl)) { + case SENSOR_DTS: return dts_sensor_read(sensor_hndl, sensor_data); + } if (platform.sensor_read) return platform.sensor_read(sensor_hndl, token, sensor_data); diff --git a/doc/device-tree/ibm,opal/sensors.rst b/doc/device-tree/ibm,opal/sensors.rst index cd30ffc..c29b88f 100644 --- a/doc/device-tree/ibm,opal/sensors.rst +++ b/doc/device-tree/ibm,opal/sensors.rst @@ -24,9 +24,12 @@ Each node has a minimum set of properties describing the sensor : OPAL_SENSOR_READ call to be used by Linux to get the value of a sensor attribute. A sensor handler has the following encoding : :: - | Attr. | Res. | Resource | - | Number | Class | Id | - |--------|--------|----------------| + | Attr. |Fam|Res. | Resource | + | Number |ily|Class| Id | + |--------|---|-----|----------------| + + The sensor family (FSP, DTS, etc) is used to dispatch the call to + the appriopriate skiboot component. - a "sensor-status" property giving the state of the sensor. The status bits have the slightly meanings depending on the resource @@ -290,7 +290,7 @@ int64_t dts_sensor_read(uint32_t sensor_hndl, uint32_t *sensor_data) memset(&dts, 0, sizeof(struct dts)); - switch (sensor_get_frc(sensor_hndl) & ~SENSOR_DTS) { + switch (sensor_get_frc(sensor_hndl)) { case SENSOR_DTS_CORE_TEMP: rc = dts_read_core_temp(rid, &dts); break; @@ -326,11 +326,11 @@ int64_t dts_sensor_read(uint32_t sensor_hndl, uint32_t *sensor_data) (((chip_id) & 0x3ff) | ((dimm_id) << 10)) #define core_handler(core_id, attr_id) \ - sensor_make_handler(SENSOR_DTS_CORE_TEMP | SENSOR_DTS, \ + sensor_make_handler(SENSOR_DTS, SENSOR_DTS_CORE_TEMP, \ core_id, attr_id) #define cen_handler(cen_id, attr_id) \ - sensor_make_handler(SENSOR_DTS_MEM_TEMP|SENSOR_DTS, \ + sensor_make_handler(SENSOR_DTS, SENSOR_DTS_MEM_TEMP, \ centaur_make_id(chip_id, 0), attr_id) bool dts_sensor_create_nodes(struct dt_node *sensors) diff --git a/hw/fsp/fsp-sensor.c b/hw/fsp/fsp-sensor.c index 51ee872..0fa3115 100644 --- a/hw/fsp/fsp-sensor.c +++ b/hw/fsp/fsp-sensor.c @@ -617,7 +617,7 @@ static struct dt_node *sensor_get_node(struct dt_node *sensors, } #define sensor_handler(header, attr_num) \ - sensor_make_handler((header).frc, (header).rid, attr_num) + sensor_make_handler(SENSOR_FSP, (header).frc, (header).rid, attr_num) static int add_sensor_prs(struct dt_node *sensors, struct sensor_prs *prs) { diff --git a/include/sensor.h b/include/sensor.h index c37102e..7eb3fa5 100644 --- a/include/sensor.h +++ b/include/sensor.h @@ -22,18 +22,24 @@ * its resource class (temperature, fans ...), a resource identifier * and an attribute number (data, status, ...) : * - * Res. - * | Attr. | Class | Resource Id | - * |--------|--------|----------------| - * + * Res. + * | Attr. |Fam Class| Resource Id | + * |--------|---|-----|----------------| * + * The last 3bits of the resource class are used to hold the family + * number. That leaves 32 differents resource classes. This is enough + * for the FSP as it uses 15. + */ + +/* * Helper routines to build or use the sensor handler. */ -#define sensor_make_handler(sensor_class, sensor_rid, sensor_attr) \ - (((sensor_attr) << 24) | ((sensor_class) & 0xff) << 16 | \ - ((sensor_rid) & 0xffff)) +#define sensor_make_handler(family, class, rid, attr) \ + (((attr) << 24) | ((family) & 0x7) << 21 | ((class) & 0x1f) << 16 | \ + ((rid) & 0xffff)) -#define sensor_get_frc(handler) (((handler) >> 16) & 0xff) +#define sensor_get_family(handler) (((handler) >> 21) & 0x7) +#define sensor_get_frc(handler) (((handler) >> 16) & 0x1f) #define sensor_get_rid(handler) ((handler) & 0xffff) #define sensor_get_attr(handler) ((handler) >> 24) @@ -41,12 +47,14 @@ * Sensor families * * This identifier is used to dispatch calls to OPAL_SENSOR_READ to - * the appropriate component. FSP is the initial family. + * the appropriate component. FSP is the initial family and you can + * have up to eight, as we are hijacking the last 3bits of the + * resource class. */ -#define SENSOR_FSP 0x0 -#define SENSOR_DTS 0x80 - -#define sensor_is_dts(handler) (sensor_get_frc(handler) & SENSOR_DTS) +enum { + SENSOR_FSP = 0, + SENSOR_DTS = 7, +}; /* * root node of all sensors : /ibm,opal/sensors |