diff options
author | Eddie James <eajames@linux.vnet.ibm.com> | 2018-11-08 15:05:25 -0600 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2018-12-16 15:13:08 -0800 |
commit | 88be37c07c1524102aed5736094cfacf24407b46 (patch) | |
tree | bd8e64a1e06307ef79cc4ef34c04134fd5f514b1 /drivers/hwmon/occ/p9_sbe.c | |
parent | 5b5513b8800291226a8fa63fd22a14cc235b313e (diff) |
hwmon (occ): Add command transport method for P8 and P9
For the P8 OCC, add the procedure to send a command to the OCC over I2C
bus. This involves writing the OCC command registers with serial
communication operations (SCOMs) interpreted by the I2C slave. For the
P9 OCC, add a procedure to use the OCC in-kernel API to send a command
to the OCC through the SBE.
Signed-off-by: Eddie James <eajames@linux.ibm.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/occ/p9_sbe.c')
-rw-r--r-- | drivers/hwmon/occ/p9_sbe.c | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/drivers/hwmon/occ/p9_sbe.c b/drivers/hwmon/occ/p9_sbe.c index c2fa34e30544..0ed5e22143ae 100644 --- a/drivers/hwmon/occ/p9_sbe.c +++ b/drivers/hwmon/occ/p9_sbe.c @@ -2,6 +2,7 @@ #include <linux/device.h> #include <linux/errno.h> +#include <linux/fsi-occ.h> #include <linux/module.h> #include <linux/platform_device.h> @@ -16,7 +17,42 @@ struct p9_sbe_occ { static int p9_sbe_occ_send_cmd(struct occ *occ, u8 *cmd) { - return -EOPNOTSUPP; + struct occ_response *resp = &occ->resp; + struct p9_sbe_occ *ctx = to_p9_sbe_occ(occ); + size_t resp_len = sizeof(*resp); + int rc; + + rc = fsi_occ_submit(ctx->sbe, cmd, 8, resp, &resp_len); + if (rc < 0) + return rc; + + switch (resp->return_status) { + case OCC_RESP_CMD_IN_PRG: + rc = -ETIMEDOUT; + break; + case OCC_RESP_SUCCESS: + rc = 0; + break; + case OCC_RESP_CMD_INVAL: + case OCC_RESP_CMD_LEN_INVAL: + case OCC_RESP_DATA_INVAL: + case OCC_RESP_CHKSUM_ERR: + rc = -EINVAL; + break; + case OCC_RESP_INT_ERR: + case OCC_RESP_BAD_STATE: + case OCC_RESP_CRIT_EXCEPT: + case OCC_RESP_CRIT_INIT: + case OCC_RESP_CRIT_WATCHDOG: + case OCC_RESP_CRIT_OCB: + case OCC_RESP_CRIT_HW: + rc = -EREMOTEIO; + break; + default: + rc = -EPROTO; + } + + return rc; } static int p9_sbe_occ_probe(struct platform_device *pdev) |