Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5b5513b8 authored by Eddie James's avatar Eddie James Committed by Guenter Roeck
Browse files

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: default avatarEddie James <eajames@linux.ibm.com>
[groeck: Fix up SPDX license identifier]
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent c0c9872a
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1293,6 +1293,8 @@ config SENSORS_NSA320
	  This driver can also be built as a module. If so, the module
	  will be called nsa320-hwmon.

source "drivers/hwmon/occ/Kconfig"

config SENSORS_PCF8591
	tristate "Philips PCF8591 ADC/DAC"
	depends on I2C
+1 −0
Original line number Diff line number Diff line
@@ -178,6 +178,7 @@ obj-$(CONFIG_SENSORS_WM831X) += wm831x-hwmon.o
obj-$(CONFIG_SENSORS_WM8350)	+= wm8350-hwmon.o
obj-$(CONFIG_SENSORS_XGENE)	+= xgene-hwmon.o

obj-$(CONFIG_SENSORS_OCC)	+= occ/
obj-$(CONFIG_PMBUS)		+= pmbus/

ccflags-$(CONFIG_HWMON_DEBUG_CHIP) := -DDEBUG
+31 −0
Original line number Diff line number Diff line
#
# On-Chip Controller configuration
#

config SENSORS_OCC_P8_I2C
	tristate "POWER8 OCC through I2C"
	depends on I2C
	select SENSORS_OCC
	help
	 This option enables support for monitoring sensors provided by the
	 On-Chip Controller (OCC) on a POWER8 processor. Communications with
	 the OCC are established through I2C bus.

	 This driver can also be built as a module. If so, the module will be
	 called occ-p8-hwmon.

config SENSORS_OCC_P9_SBE
	tristate "POWER9 OCC through SBE"
	depends on FSI_OCC
	select SENSORS_OCC
	help
	 This option enables support for monitoring sensors provided by the
	 On-Chip Controller (OCC) on a POWER9 processor. Communications with
	 the OCC are established through SBE fifo on an FSI bus.

	 This driver can also be built as a module. If so, the module will be
	 called occ-p9-hwmon.

config SENSORS_OCC
	bool "POWER On-Chip Controller"
	depends on SENSORS_OCC_P8_I2C || SENSORS_OCC_P9_SBE
+5 −0
Original line number Diff line number Diff line
occ-p8-hwmon-objs := common.o p8_i2c.o
occ-p9-hwmon-objs := common.o p9_sbe.o

obj-$(CONFIG_SENSORS_OCC_P8_I2C) += occ-p8-hwmon.o
obj-$(CONFIG_SENSORS_OCC_P9_SBE) += occ-p9-hwmon.o
+40 −0
Original line number Diff line number Diff line
// 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;
}
Loading