Re: [PATCH v6 08/13] hwmon: add support for the sl28cpld hardware monitoring controller
On Sun, Jul 26, 2020 at 01:18:29AM +0200, Michael Walle wrote: > Add support for the hardware monitoring controller of the sl28cpld board > management controller. This driver is part of a multi-function device. FWIW, Reviewed-by: Andy Shevchenko > Signed-off-by: Michael Walle > Acked-by: Guenter Roeck > --- > Changes since v5: > - none > > Changes since v4: > - update copyright year > - remove #include , suggested by Andy. > - use PTR_ERR_OR_ZERO(), suggested by Andy. > - remove the platform device table > - don't use KBUID_MODNAME > > Changes since v3: > - see cover letter > > Documentation/hwmon/index.rst| 1 + > Documentation/hwmon/sl28cpld.rst | 36 > drivers/hwmon/Kconfig| 10 +++ > drivers/hwmon/Makefile | 1 + > drivers/hwmon/sl28cpld-hwmon.c | 142 +++ > 5 files changed, 190 insertions(+) > create mode 100644 Documentation/hwmon/sl28cpld.rst > create mode 100644 drivers/hwmon/sl28cpld-hwmon.c > > diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst > index 750d3a975d82..d90c43c82936 100644 > --- a/Documentation/hwmon/index.rst > +++ b/Documentation/hwmon/index.rst > @@ -154,6 +154,7 @@ Hardware Monitoring Kernel Drivers > sht3x > shtc1 > sis5595 > + sl28cpld > smm665 > smsc47b397 > smsc47m192 > diff --git a/Documentation/hwmon/sl28cpld.rst > b/Documentation/hwmon/sl28cpld.rst > new file mode 100644 > index ..7ed65f78250c > --- /dev/null > +++ b/Documentation/hwmon/sl28cpld.rst > @@ -0,0 +1,36 @@ > +.. SPDX-License-Identifier: GPL-2.0-only > + > +Kernel driver sl28cpld > +== > + > +Supported chips: > + > + * Kontron sl28cpld > + > + Prefix: 'sl28cpld' > + > + Datasheet: not available > + > +Authors: Michael Walle > + > +Description > +--- > + > +The sl28cpld is a board management controller which also exposes a hardware > +monitoring controller. At the moment this controller supports a single fan > +supervisor. In the future there might be other flavours and additional > +hardware monitoring might be supported. > + > +The fan supervisor has a 7 bit counter register and a counter period of 1 > +second. If the 7 bit counter overflows, the supervisor will automatically > +switch to x8 mode to support a wider input range at the loss of > +granularity. > + > +Sysfs entries > +- > + > +The following attributes are supported. > + > +=== > > +fan1_input Fan RPM. Assuming 2 pulses per revolution. > +=== > > diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig > index 8dc28b26916e..a02829ec7386 100644 > --- a/drivers/hwmon/Kconfig > +++ b/drivers/hwmon/Kconfig > @@ -1479,6 +1479,16 @@ config SENSORS_RASPBERRYPI_HWMON > This driver can also be built as a module. If so, the module > will be called raspberrypi-hwmon. > > +config SENSORS_SL28CPLD > + tristate "Kontron sl28cpld hardware monitoring driver" > + select MFD_SIMPLE_MFD_I2C > + help > + If you say yes here you get support for the fan supervisor of the > + sl28cpld board management controller. > + > + This driver can also be built as a module. If so, the module > + will be called sl28cpld-hwmon. > + > config SENSORS_SHT15 > tristate "Sensiron humidity and temperature sensors. SHT15 and compat." > depends on GPIOLIB || COMPILE_TEST > diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile > index a8f4b35b136b..dee8511f9348 100644 > --- a/drivers/hwmon/Makefile > +++ b/drivers/hwmon/Makefile > @@ -159,6 +159,7 @@ obj-$(CONFIG_SENSORS_S3C) += s3c-hwmon.o > obj-$(CONFIG_SENSORS_SCH56XX_COMMON)+= sch56xx-common.o > obj-$(CONFIG_SENSORS_SCH5627)+= sch5627.o > obj-$(CONFIG_SENSORS_SCH5636)+= sch5636.o > +obj-$(CONFIG_SENSORS_SL28CPLD) += sl28cpld-hwmon.o > obj-$(CONFIG_SENSORS_SHT15) += sht15.o > obj-$(CONFIG_SENSORS_SHT21) += sht21.o > obj-$(CONFIG_SENSORS_SHT3x) += sht3x.o > diff --git a/drivers/hwmon/sl28cpld-hwmon.c b/drivers/hwmon/sl28cpld-hwmon.c > new file mode 100644 > index ..e48f58ec5b9c > --- /dev/null > +++ b/drivers/hwmon/sl28cpld-hwmon.c > @@ -0,0 +1,142 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * sl28cpld hardware monitoring driver > + * > + * Copyright 2020 Kontron Europe GmbH > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#define FAN_INPUT0x00 > +#define FAN_SCALE_X8 BIT(7) > +#define FAN_VALUE_MASK GENMASK(6, 0) > + > +struct sl28cpld_hwmon { > + struct regmap *regmap; > + u32 offset; > +}; > + > +static umode_t sl28cpld_hwmon_is_visible(const void *data, > + enum hwmon_sensor_types type, > +
[PATCH v6 08/13] hwmon: add support for the sl28cpld hardware monitoring controller
Add support for the hardware monitoring controller of the sl28cpld board management controller. This driver is part of a multi-function device. Signed-off-by: Michael Walle Acked-by: Guenter Roeck --- Changes since v5: - none Changes since v4: - update copyright year - remove #include , suggested by Andy. - use PTR_ERR_OR_ZERO(), suggested by Andy. - remove the platform device table - don't use KBUID_MODNAME Changes since v3: - see cover letter Documentation/hwmon/index.rst| 1 + Documentation/hwmon/sl28cpld.rst | 36 drivers/hwmon/Kconfig| 10 +++ drivers/hwmon/Makefile | 1 + drivers/hwmon/sl28cpld-hwmon.c | 142 +++ 5 files changed, 190 insertions(+) create mode 100644 Documentation/hwmon/sl28cpld.rst create mode 100644 drivers/hwmon/sl28cpld-hwmon.c diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst index 750d3a975d82..d90c43c82936 100644 --- a/Documentation/hwmon/index.rst +++ b/Documentation/hwmon/index.rst @@ -154,6 +154,7 @@ Hardware Monitoring Kernel Drivers sht3x shtc1 sis5595 + sl28cpld smm665 smsc47b397 smsc47m192 diff --git a/Documentation/hwmon/sl28cpld.rst b/Documentation/hwmon/sl28cpld.rst new file mode 100644 index ..7ed65f78250c --- /dev/null +++ b/Documentation/hwmon/sl28cpld.rst @@ -0,0 +1,36 @@ +.. SPDX-License-Identifier: GPL-2.0-only + +Kernel driver sl28cpld +== + +Supported chips: + + * Kontron sl28cpld + + Prefix: 'sl28cpld' + + Datasheet: not available + +Authors: Michael Walle + +Description +--- + +The sl28cpld is a board management controller which also exposes a hardware +monitoring controller. At the moment this controller supports a single fan +supervisor. In the future there might be other flavours and additional +hardware monitoring might be supported. + +The fan supervisor has a 7 bit counter register and a counter period of 1 +second. If the 7 bit counter overflows, the supervisor will automatically +switch to x8 mode to support a wider input range at the loss of +granularity. + +Sysfs entries +- + +The following attributes are supported. + +=== +fan1_input Fan RPM. Assuming 2 pulses per revolution. +=== diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 8dc28b26916e..a02829ec7386 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -1479,6 +1479,16 @@ config SENSORS_RASPBERRYPI_HWMON This driver can also be built as a module. If so, the module will be called raspberrypi-hwmon. +config SENSORS_SL28CPLD + tristate "Kontron sl28cpld hardware monitoring driver" + select MFD_SIMPLE_MFD_I2C + help + If you say yes here you get support for the fan supervisor of the + sl28cpld board management controller. + + This driver can also be built as a module. If so, the module + will be called sl28cpld-hwmon. + config SENSORS_SHT15 tristate "Sensiron humidity and temperature sensors. SHT15 and compat." depends on GPIOLIB || COMPILE_TEST diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index a8f4b35b136b..dee8511f9348 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -159,6 +159,7 @@ obj-$(CONFIG_SENSORS_S3C) += s3c-hwmon.o obj-$(CONFIG_SENSORS_SCH56XX_COMMON)+= sch56xx-common.o obj-$(CONFIG_SENSORS_SCH5627) += sch5627.o obj-$(CONFIG_SENSORS_SCH5636) += sch5636.o +obj-$(CONFIG_SENSORS_SL28CPLD) += sl28cpld-hwmon.o obj-$(CONFIG_SENSORS_SHT15)+= sht15.o obj-$(CONFIG_SENSORS_SHT21)+= sht21.o obj-$(CONFIG_SENSORS_SHT3x)+= sht3x.o diff --git a/drivers/hwmon/sl28cpld-hwmon.c b/drivers/hwmon/sl28cpld-hwmon.c new file mode 100644 index ..e48f58ec5b9c --- /dev/null +++ b/drivers/hwmon/sl28cpld-hwmon.c @@ -0,0 +1,142 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * sl28cpld hardware monitoring driver + * + * Copyright 2020 Kontron Europe GmbH + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define FAN_INPUT 0x00 +#define FAN_SCALE_X8 BIT(7) +#define FAN_VALUE_MASK GENMASK(6, 0) + +struct sl28cpld_hwmon { + struct regmap *regmap; + u32 offset; +}; + +static umode_t sl28cpld_hwmon_is_visible(const void *data, +enum hwmon_sensor_types type, +u32 attr, int channel) +{ + return 0444; +} + +static int sl28cpld_hwmon_read(struct device *dev, + enum hwmon_sensor_types type, u32 attr, + int channel, long *input) +{ + struct sl28cpld_hwmon *hwmon = dev_get_drvdata(dev); + unsigned int value; + int ret; + +