fsp-sensor: rework device tree for sensors

The current code in OPAL exposing the FSP sensors in the device tree
is very SPCN-centric which makes it difficult to add new sensors
fitting with the ibmpowernv Linux driver. This patch proposes some
improvements on the way the device tree is created.

The logic behind the node creation is preserved. The DMA sensor buffer
is parsed, looping on the PRS command modifiers and entries while
nodes are being created under the "ibm,opal/sensors/" directory. The
code now splits the creation under separate routines, one for each
modifier, and use the same old pattern for names :

	<resource class name>#<index>-attribute/

Each resource node is compatible with :

	"ibm,opal-sensor-<resource classname>"

There is a mapping to be done between the attributes of a same
resource and the PRS command used to collect them. This adds some
complexity in the code when creating the node and when building a
request for the FSP.

For instance, the status of a FSP sensor which 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, there is no other choice than to use the DATA
modifier. 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 only keep bits[1-2] to reflect the fault status to Linux.

Another significant change is that the power consumption is now
reported for each power supply and not as a whole like before. A Tuleta
can have up to four distinct power supplies so it seems an interesting
resource to report independently.

Currently, we handle the "power-supply", "cooling-fan" and "amb-temp"
resource classes. More exist in the specs but they have not showed up
on the Tuleta I used.

Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
1 file changed