mirror of
https://github.com/edk2-porting/linux-next.git
synced 2025-01-06 20:53:54 +08:00
5b5513b880
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>
62 lines
1.3 KiB
C
62 lines
1.3 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
#include <linux/device.h>
|
|
#include <linux/errno.h>
|
|
#include <linux/i2c.h>
|
|
#include <linux/module.h>
|
|
|
|
#include "common.h"
|
|
|
|
struct p8_i2c_occ {
|
|
struct occ occ;
|
|
struct i2c_client *client;
|
|
};
|
|
|
|
#define to_p8_i2c_occ(x) container_of((x), struct p8_i2c_occ, occ)
|
|
|
|
static int p8_i2c_occ_send_cmd(struct occ *occ, u8 *cmd)
|
|
{
|
|
return -EOPNOTSUPP;
|
|
}
|
|
|
|
static int p8_i2c_occ_probe(struct i2c_client *client,
|
|
const struct i2c_device_id *id)
|
|
{
|
|
struct occ *occ;
|
|
struct p8_i2c_occ *ctx = devm_kzalloc(&client->dev, sizeof(*ctx),
|
|
GFP_KERNEL);
|
|
if (!ctx)
|
|
return -ENOMEM;
|
|
|
|
ctx->client = client;
|
|
occ = &ctx->occ;
|
|
occ->bus_dev = &client->dev;
|
|
dev_set_drvdata(&client->dev, occ);
|
|
|
|
occ->poll_cmd_data = 0x10; /* P8 OCC poll data */
|
|
occ->send_cmd = p8_i2c_occ_send_cmd;
|
|
|
|
return occ_setup(occ, "p8_occ");
|
|
}
|
|
|
|
static const struct of_device_id p8_i2c_occ_of_match[] = {
|
|
{ .compatible = "ibm,p8-occ-hwmon" },
|
|
{}
|
|
};
|
|
MODULE_DEVICE_TABLE(of, p8_i2c_occ_of_match);
|
|
|
|
static struct i2c_driver p8_i2c_occ_driver = {
|
|
.class = I2C_CLASS_HWMON,
|
|
.driver = {
|
|
.name = "occ-hwmon",
|
|
.of_match_table = p8_i2c_occ_of_match,
|
|
},
|
|
.probe = p8_i2c_occ_probe,
|
|
};
|
|
|
|
module_i2c_driver(p8_i2c_occ_driver);
|
|
|
|
MODULE_AUTHOR("Eddie James <eajames@linux.ibm.com>");
|
|
MODULE_DESCRIPTION("BMC P8 OCC hwmon driver");
|
|
MODULE_LICENSE("GPL");
|