hwmon: Add On-Chip Controller (OCC) hwmon driver
The OCC is a device embedded on a POWER processor that collects and aggregates sensor data from the processor and system. The OCC can provide the raw sensor data as well as perform thermal and power management on the system. This driver provides a hwmon interface to the OCC from a service processor (e.g. a BMC). The driver supports both POWER8 and POWER9 OCCs. Communications with the POWER8 OCC are established over standard I2C bus. The driver communicates with the POWER9 OCC through the FSI-based OCC driver, which handles the lower-level communication details. This patch lays out the structure of the OCC hwmon driver. There are two platform drivers, one each for P8 and P9 OCCs. These are probed through the I2C tree and the FSI-based OCC driver, respectively. The patch also defines the first common structures and methods between the two OCC versions. Signed-off-by: Eddie James <eajames@linux.ibm.com> [groeck: Fix up SPDX license identifier] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:

committed by
Guenter Roeck

parent
c0c9872a8b
commit
5b5513b880
40
drivers/hwmon/occ/common.c
Normal file
40
drivers/hwmon/occ/common.c
Normal file
@@ -0,0 +1,40 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
#include <linux/device.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
static int occ_poll(struct occ *occ)
|
||||
{
|
||||
u16 checksum = occ->poll_cmd_data + 1;
|
||||
u8 cmd[8];
|
||||
|
||||
/* big endian */
|
||||
cmd[0] = 0; /* sequence number */
|
||||
cmd[1] = 0; /* cmd type */
|
||||
cmd[2] = 0; /* data length msb */
|
||||
cmd[3] = 1; /* data length lsb */
|
||||
cmd[4] = occ->poll_cmd_data; /* data */
|
||||
cmd[5] = checksum >> 8; /* checksum msb */
|
||||
cmd[6] = checksum & 0xFF; /* checksum lsb */
|
||||
cmd[7] = 0;
|
||||
|
||||
return occ->send_cmd(occ, cmd);
|
||||
}
|
||||
|
||||
int occ_setup(struct occ *occ, const char *name)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = occ_poll(occ);
|
||||
if (rc == -ESHUTDOWN) {
|
||||
dev_info(occ->bus_dev, "host is not ready\n");
|
||||
return rc;
|
||||
} else if (rc < 0) {
|
||||
dev_err(occ->bus_dev, "failed to get OCC poll response: %d\n",
|
||||
rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user