[RFC PATCH linux v6 9/9] wip: hwmon: occ: Add sketch of the hwmon implementation for the P9 OCC

Andrew Jeffery andrew at aj.id.au
Tue Dec 13 14:32:19 AEDT 2016


On Tue, 2016-11-29 at 17:04 -0600, eajames.ibm at gmail.com wrote:
> > From: "Edward A. James" <eajames at us.ibm.com>
> 

We shouldn't include this patch until it is actually useful. I
purposefully crippled it so I could get it to compile, mainly as a
demonstration of how the architecture would work for the P9 case.

Andrew

> Signed-off-by: Edward A. James <eajames at us.ibm.com>
> ---
>  drivers/hwmon/occ/Kconfig      |  9 ++++
>  drivers/hwmon/occ/Makefile     |  1 +
>  drivers/hwmon/occ/occ_p9_fsi.c | 93 ++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 103 insertions(+)
>  create mode 100644 drivers/hwmon/occ/occ_p9_fsi.c
> 
> diff --git a/drivers/hwmon/occ/Kconfig b/drivers/hwmon/occ/Kconfig
> index e690001..7e95876 100644
> --- a/drivers/hwmon/occ/Kconfig
> +++ b/drivers/hwmon/occ/Kconfig
> @@ -26,4 +26,13 @@ config SENSORS_PPC_OCC_P8_I2C
> >  	 This driver can also be built as a module. If so, the module will be
> >  	 called occ-p8-i2c.
>  
> +config SENSORS_PPC_OCC_P9_FSI
> > +	tristate "POWER9 OCC hwmon support"
> > +	help
> > +	  Provide a hwmon sysfs interface for the POWER9 On-Chip Controller,
> > +	  exposing temperature, frequency and power measurements.
> +
> > +	  This driver can also be built as a module. If so, the module will be
> > +	  called occ-p9-fsi.
> +
>  endif
> diff --git a/drivers/hwmon/occ/Makefile b/drivers/hwmon/occ/Makefile
> index 05a84e9..77e47e1 100644
> --- a/drivers/hwmon/occ/Makefile
> +++ b/drivers/hwmon/occ/Makefile
> @@ -1,2 +1,3 @@
>  obj-$(CONFIG_SENSORS_PPC_OCC) += occ.o occ_sysfs.o
>  obj-$(CONFIG_SENSORS_PPC_OCC_P8_I2C) += occ_scom_i2c.o occ_p8.o occ_p8_i2c.o
> +obj-$(CONFIG_SENSORS_PPC_OCC_P9_FSI) += occ_p9.o occ_p9_fsi.o
> diff --git a/drivers/hwmon/occ/occ_p9_fsi.c b/drivers/hwmon/occ/occ_p9_fsi.c
> new file mode 100644
> index 0000000..2f651d1
> --- /dev/null
> +++ b/drivers/hwmon/occ/occ_p9_fsi.c
> @@ -0,0 +1,93 @@
> +/*
> + * occ_p9_fsi.c - hwmon OCC driver
> + *
> + * Copyright 2016 IBM Corp.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#include <linux/err.h>
> +#include <linux/module.h>
> +#include <linux/init.h>
> +#include <linux/slab.h>
> +#include <linux/err.h>
> +#include <linux/of.h>
> +#include <linux/kernel.h>
> +#include <linux/device.h>
> +
> +#include "scom.h"
> +#include "occ_p9.h"
> +#include "occ_sysfs.h"
> +
> > +#define OCC_I2C_NAME	"occ-p9-fsi"
> +
> +static char *caps_sensor_names[] = {
> > +	"curr_powercap",
> > +	"curr_powerreading",
> > +	"norm_powercap",
> > +	"max_powercap",
> > +	"min_powercap",
> > +	"user_powerlimit"
> +};
> +
> +int p9_fsi_getscom(void *bus, u32 address, u8 *data, size_t offset)
> +{
> > +	return -SCOM_READ_ERROR;
> +}
> +
> +int p9_fsi_putscom(void *bus, u32 address, u32 data0, u32 data1)
> +{
> > +	return -SCOM_WRITE_ERROR;
> +}
> +
> +static struct occ_bus_ops p9_bus_ops = {
> > +	.getscom = p9_fsi_getscom,
> > +	.putscom = p9_fsi_putscom,
> +};
> +
> +static struct occ_sysfs_config p9_sysfs_config = {
> > +	.num_caps_fields = ARRAY_SIZE(caps_sensor_names),
> > +	.caps_names = caps_sensor_names,
> +};
> +
> +int occ_p9_probe(struct device *dev, void *client)
> +{
> > +	struct occ *occ;
> > +	struct occ_sysfs *hwmon;
> +
> > +	occ = occ_p9_start(dev, client, p9_bus_ops);
> > +	if (IS_ERR(occ))
> > +		return PTR_ERR(occ);
> +
> > +	hwmon = occ_sysfs_start(dev, occ, &p9_sysfs_config);
> > +	if (IS_ERR(hwmon))
> > +		return PTR_ERR(hwmon);
> +
> > +	return 0;
> +}
> +
> +int occ_p9_remove(void)
> +{
> > +	struct occ *occ = NULL;
> +
> > +	return occ_p9_stop(occ);
> +}
> +
> +/* used by device table */
> +static const struct of_device_id occ_of_match[] = {
> > +	{ .compatible = "ibm,occ-p9-fsi" },
> > +	{}
> +};
> +MODULE_DEVICE_TABLE(of, occ_of_match);
> +
> > +MODULE_AUTHOR("Eddie James <eajames at us.ibm.com>");
> +MODULE_DESCRIPTION("BMC P9 OCC hwmon driver");
> +MODULE_LICENSE("GPL");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: This is a digitally signed message part
URL: <http://lists.ozlabs.org/pipermail/openbmc/attachments/20161213/1383ff07/attachment.sig>


More information about the openbmc mailing list