2023-04-12 05:24:56

by Lakshmi Yadlapati

[permalink] [raw]
Subject: [PATCH v6 0/5] hwmon: (pmbus/acbel-fsg032) Add Acbel power supply

Adding new acbel,fsg032 driver and documentation updates.

Changes since V5:
Add symlink from manufacturer serial number to ccin since ccin is not
available in acbel-fsg032 power supply driver.

Lakshmi Yadlapati (5):
dt-bindings: vendor-prefixes: Add prefix for acbel
dt-bindings: trivial-devices: Add acbel,fsg032
hwmon: (pmbus/acbel-fsg032) Add Acbel power supply
docs: hwmon: Add documentaion for acbel-fsg032 PSU
ARM: dts: aspeed: p10bmc: Change power supply info

.../devicetree/bindings/trivial-devices.yaml | 2 +
.../devicetree/bindings/vendor-prefixes.yaml | 2 +
Documentation/hwmon/acbel-fsg032.rst | 80 ++++++++++++++++
Documentation/hwmon/index.rst | 1 +
arch/arm/boot/dts/aspeed-bmc-ibm-bonnell.dts | 12 +--
drivers/hwmon/pmbus/Kconfig | 9 ++
drivers/hwmon/pmbus/Makefile | 1 +
drivers/hwmon/pmbus/acbel-fsg032.c | 95 +++++++++++++++++++
8 files changed, 196 insertions(+), 6 deletions(-)
create mode 100644 Documentation/hwmon/acbel-fsg032.rst
create mode 100644 drivers/hwmon/pmbus/acbel-fsg032.c

--
2.37.2


2023-04-12 05:25:10

by Lakshmi Yadlapati

[permalink] [raw]
Subject: [PATCH v6 1/5] dt-bindings: vendor-prefixes: Add prefix for acbel

Add a vendor prefix entry for acbel (https://www.acbel.com)

Signed-off-by: Lakshmi Yadlapati <[email protected]>
Acked-by: Krzysztof Kozlowski <[email protected]>
---
Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Documentation/devicetree/bindings/vendor-prefixes.yaml
index ed64e06ecca4..9dbb8f69be65 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.yaml
+++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml
@@ -37,6 +37,8 @@ patternProperties:
description: Abracon Corporation
"^abt,.*":
description: ShenZhen Asia Better Technology Ltd.
+ "^acbel,.*":
+ description: Acbel Polytech Inc.
"^acer,.*":
description: Acer Inc.
"^acme,.*":
--
2.37.2

2023-04-12 05:25:51

by Lakshmi Yadlapati

[permalink] [raw]
Subject: [PATCH v6 3/5] hwmon: (pmbus/acbel-fsg032) Add Acbel power supply

Add the driver to support ACBEL FSG032 power supply.

Change-Id: Ief984325fe3fa0ed042e1d00e34ff579b45e1c81
Signed-off-by: Lakshmi Yadlapati <[email protected]>
---
drivers/hwmon/pmbus/Kconfig | 9 +++
drivers/hwmon/pmbus/Makefile | 1 +
drivers/hwmon/pmbus/acbel-fsg032.c | 95 ++++++++++++++++++++++++++++++
3 files changed, 105 insertions(+)
create mode 100644 drivers/hwmon/pmbus/acbel-fsg032.c

diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig
index 59d9a7430499..270b6336b76d 100644
--- a/drivers/hwmon/pmbus/Kconfig
+++ b/drivers/hwmon/pmbus/Kconfig
@@ -27,6 +27,15 @@ config SENSORS_PMBUS
This driver can also be built as a module. If so, the module will
be called pmbus.

+config SENSORS_ACBEL_FSG032
+ tristate "ACBEL FSG032 Power Supply"
+ help
+ If you say yes here you get hardware monitoring support for the ACBEL
+ FSG032 Power Supply.
+
+ This driver can also be built as a module. If so, the module will
+ be called acbel-fsg032.
+
config SENSORS_ADM1266
tristate "Analog Devices ADM1266 Sequencer"
select CRC8
diff --git a/drivers/hwmon/pmbus/Makefile b/drivers/hwmon/pmbus/Makefile
index 3ae019916267..84ee960a6c2d 100644
--- a/drivers/hwmon/pmbus/Makefile
+++ b/drivers/hwmon/pmbus/Makefile
@@ -5,6 +5,7 @@

obj-$(CONFIG_PMBUS) += pmbus_core.o
obj-$(CONFIG_SENSORS_PMBUS) += pmbus.o
+obj-$(CONFIG_SENSORS_ACBEL_FSG032) += acbel-fsg032.o
obj-$(CONFIG_SENSORS_ADM1266) += adm1266.o
obj-$(CONFIG_SENSORS_ADM1275) += adm1275.o
obj-$(CONFIG_SENSORS_BEL_PFE) += bel-pfe.o
diff --git a/drivers/hwmon/pmbus/acbel-fsg032.c b/drivers/hwmon/pmbus/acbel-fsg032.c
new file mode 100644
index 000000000000..f160f45c7ac5
--- /dev/null
+++ b/drivers/hwmon/pmbus/acbel-fsg032.c
@@ -0,0 +1,95 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright 2023 IBM Corp.
+ */
+
+#include <linux/debugfs.h>
+#include <linux/device.h>
+#include <linux/fs.h>
+#include <linux/i2c.h>
+#include <linux/module.h>
+#include <linux/pmbus.h>
+#include <linux/hwmon-sysfs.h>
+#include "pmbus.h"
+
+static const struct i2c_device_id acbel_fsg032_id[] = {
+ { "acbel_fsg032" },
+ {}
+};
+
+static struct pmbus_driver_info acbel_fsg032_info = {
+ .pages = 1,
+ .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_IIN | PMBUS_HAVE_PIN |
+ PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT | PMBUS_HAVE_POUT |
+ PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2 | PMBUS_HAVE_TEMP3 |
+ PMBUS_HAVE_FAN12 | PMBUS_HAVE_STATUS_VOUT |
+ PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_STATUS_TEMP |
+ PMBUS_HAVE_STATUS_INPUT | PMBUS_HAVE_STATUS_FAN12,
+};
+
+static int acbel_fsg032_probe(struct i2c_client *client)
+{
+ u8 buf[I2C_SMBUS_BLOCK_MAX + 1];
+ struct device *dev = &client->dev;
+ struct dentry *debugfs;
+ int rc;
+
+ rc = i2c_smbus_read_block_data(client, PMBUS_MFR_ID, buf);
+ if (rc < 0) {
+ dev_err(dev, "Failed to read PMBUS_MFR_ID\n");
+ return rc;
+ }
+ if (strncmp(buf, "ACBEL", 5)) {
+ buf[rc] = '\0';
+ dev_err(dev, "Manufacturer '%s' not supported\n", buf);
+ return -ENODEV;
+ }
+
+ rc = i2c_smbus_read_block_data(client, PMBUS_MFR_MODEL, buf);
+ if (rc < 0) {
+ dev_err(dev, "Failed to read PMBUS_MFR_MODEL\n");
+ return rc;
+ }
+
+ if (strncmp(buf, "FSG032", 6)) {
+ buf[rc] = '\0';
+ dev_err(dev, "Model '%s' not supported\n", buf);
+ return -ENODEV;
+ }
+
+ rc = pmbus_do_probe(client, &acbel_fsg032_info);
+ if (rc)
+ return rc;
+
+ debugfs = pmbus_get_debugfs_dir(client);
+ if (!debugfs)
+ return rc;
+
+ /* ccin is not available, create a symlink from the
+ * mfr_serial to ccin as required by hwmon */
+ debugfs_create_symlink("ccin", debugfs, "mfr_serial");
+
+ return 0;
+}
+
+static const struct of_device_id acbel_fsg032_of_match[] = {
+ { .compatible = "acbel,fsg032" },
+ {}
+};
+MODULE_DEVICE_TABLE(of, acbel_fsg032_of_match);
+
+static struct i2c_driver acbel_fsg032_driver = {
+ .driver = {
+ .name = "acbel-fsg032",
+ .of_match_table = acbel_fsg032_of_match,
+ },
+ .probe_new = acbel_fsg032_probe,
+ .id_table = acbel_fsg032_id,
+};
+
+module_i2c_driver(acbel_fsg032_driver);
+
+MODULE_AUTHOR("Lakshmi Yadlapati");
+MODULE_DESCRIPTION("PMBus driver for AcBel Power System power supplies");
+MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS(PMBUS);
--
2.37.2

2023-04-12 15:33:09

by Guenter Roeck

[permalink] [raw]
Subject: Re: [PATCH v6 0/5] hwmon: (pmbus/acbel-fsg032) Add Acbel power supply

On Wed, Apr 12, 2023 at 12:23:00AM -0500, Lakshmi Yadlapati wrote:
> Adding new acbel,fsg032 driver and documentation updates.
>
> Changes since V5:
> Add symlink from manufacturer serial number to ccin since ccin is not
> available in acbel-fsg032 power supply driver.

Sorry, I fail to understand this change, and I am not inclined
to accept it. There is no "as required by hwmon".

Guenter

>
> Lakshmi Yadlapati (5):
> dt-bindings: vendor-prefixes: Add prefix for acbel
> dt-bindings: trivial-devices: Add acbel,fsg032
> hwmon: (pmbus/acbel-fsg032) Add Acbel power supply
> docs: hwmon: Add documentaion for acbel-fsg032 PSU
> ARM: dts: aspeed: p10bmc: Change power supply info
>
> .../devicetree/bindings/trivial-devices.yaml | 2 +
> .../devicetree/bindings/vendor-prefixes.yaml | 2 +
> Documentation/hwmon/acbel-fsg032.rst | 80 ++++++++++++++++
> Documentation/hwmon/index.rst | 1 +
> arch/arm/boot/dts/aspeed-bmc-ibm-bonnell.dts | 12 +--
> drivers/hwmon/pmbus/Kconfig | 9 ++
> drivers/hwmon/pmbus/Makefile | 1 +
> drivers/hwmon/pmbus/acbel-fsg032.c | 95 +++++++++++++++++++
> 8 files changed, 196 insertions(+), 6 deletions(-)
> create mode 100644 Documentation/hwmon/acbel-fsg032.rst
> create mode 100644 drivers/hwmon/pmbus/acbel-fsg032.c
>
> --
> 2.37.2
>

2023-04-12 15:35:08

by Guenter Roeck

[permalink] [raw]
Subject: Re: [PATCH v6 3/5] hwmon: (pmbus/acbel-fsg032) Add Acbel power supply

On Wed, Apr 12, 2023 at 12:23:03AM -0500, Lakshmi Yadlapati wrote:
> Add the driver to support ACBEL FSG032 power supply.
>
> Change-Id: Ief984325fe3fa0ed042e1d00e34ff579b45e1c81
> Signed-off-by: Lakshmi Yadlapati <[email protected]>
> ---
> drivers/hwmon/pmbus/Kconfig | 9 +++
> drivers/hwmon/pmbus/Makefile | 1 +
> drivers/hwmon/pmbus/acbel-fsg032.c | 95 ++++++++++++++++++++++++++++++
> 3 files changed, 105 insertions(+)
> create mode 100644 drivers/hwmon/pmbus/acbel-fsg032.c
>
> diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig
> index 59d9a7430499..270b6336b76d 100644
> --- a/drivers/hwmon/pmbus/Kconfig
> +++ b/drivers/hwmon/pmbus/Kconfig
> @@ -27,6 +27,15 @@ config SENSORS_PMBUS
> This driver can also be built as a module. If so, the module will
> be called pmbus.
>
> +config SENSORS_ACBEL_FSG032
> + tristate "ACBEL FSG032 Power Supply"
> + help
> + If you say yes here you get hardware monitoring support for the ACBEL
> + FSG032 Power Supply.
> +
> + This driver can also be built as a module. If so, the module will
> + be called acbel-fsg032.
> +
> config SENSORS_ADM1266
> tristate "Analog Devices ADM1266 Sequencer"
> select CRC8
> diff --git a/drivers/hwmon/pmbus/Makefile b/drivers/hwmon/pmbus/Makefile
> index 3ae019916267..84ee960a6c2d 100644
> --- a/drivers/hwmon/pmbus/Makefile
> +++ b/drivers/hwmon/pmbus/Makefile
> @@ -5,6 +5,7 @@
>
> obj-$(CONFIG_PMBUS) += pmbus_core.o
> obj-$(CONFIG_SENSORS_PMBUS) += pmbus.o
> +obj-$(CONFIG_SENSORS_ACBEL_FSG032) += acbel-fsg032.o
> obj-$(CONFIG_SENSORS_ADM1266) += adm1266.o
> obj-$(CONFIG_SENSORS_ADM1275) += adm1275.o
> obj-$(CONFIG_SENSORS_BEL_PFE) += bel-pfe.o
> diff --git a/drivers/hwmon/pmbus/acbel-fsg032.c b/drivers/hwmon/pmbus/acbel-fsg032.c
> new file mode 100644
> index 000000000000..f160f45c7ac5
> --- /dev/null
> +++ b/drivers/hwmon/pmbus/acbel-fsg032.c
> @@ -0,0 +1,95 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright 2023 IBM Corp.
> + */
> +
> +#include <linux/debugfs.h>
> +#include <linux/device.h>
> +#include <linux/fs.h>
> +#include <linux/i2c.h>
> +#include <linux/module.h>
> +#include <linux/pmbus.h>
> +#include <linux/hwmon-sysfs.h>
> +#include "pmbus.h"
> +
> +static const struct i2c_device_id acbel_fsg032_id[] = {
> + { "acbel_fsg032" },
> + {}
> +};
> +
> +static struct pmbus_driver_info acbel_fsg032_info = {
> + .pages = 1,
> + .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_IIN | PMBUS_HAVE_PIN |
> + PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT | PMBUS_HAVE_POUT |
> + PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2 | PMBUS_HAVE_TEMP3 |
> + PMBUS_HAVE_FAN12 | PMBUS_HAVE_STATUS_VOUT |
> + PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_STATUS_TEMP |
> + PMBUS_HAVE_STATUS_INPUT | PMBUS_HAVE_STATUS_FAN12,
> +};
> +
> +static int acbel_fsg032_probe(struct i2c_client *client)
> +{
> + u8 buf[I2C_SMBUS_BLOCK_MAX + 1];
> + struct device *dev = &client->dev;
> + struct dentry *debugfs;
> + int rc;
> +
> + rc = i2c_smbus_read_block_data(client, PMBUS_MFR_ID, buf);
> + if (rc < 0) {
> + dev_err(dev, "Failed to read PMBUS_MFR_ID\n");
> + return rc;
> + }
> + if (strncmp(buf, "ACBEL", 5)) {
> + buf[rc] = '\0';
> + dev_err(dev, "Manufacturer '%s' not supported\n", buf);
> + return -ENODEV;
> + }
> +
> + rc = i2c_smbus_read_block_data(client, PMBUS_MFR_MODEL, buf);
> + if (rc < 0) {
> + dev_err(dev, "Failed to read PMBUS_MFR_MODEL\n");
> + return rc;
> + }
> +
> + if (strncmp(buf, "FSG032", 6)) {
> + buf[rc] = '\0';
> + dev_err(dev, "Model '%s' not supported\n", buf);
> + return -ENODEV;
> + }
> +
> + rc = pmbus_do_probe(client, &acbel_fsg032_info);
> + if (rc)
> + return rc;
> +
> + debugfs = pmbus_get_debugfs_dir(client);
> + if (!debugfs)
> + return rc;
> +
> + /* ccin is not available, create a symlink from the
> + * mfr_serial to ccin as required by hwmon */

There is no such hwmon requirement (hwmon neither knows nor
cares about "ccin"), and this is not a valid multi-line comment.
Please drop this change.

If some userspace code is looking for a debugfs file named "ccin",
change it to read "mfr_serial" instead of "ccin" if "ccin" is
not available. Hacking a kernel driver to meet some arbitrary
userspace requirement is not acceptable.

Thanks,
Guenter

> + debugfs_create_symlink("ccin", debugfs, "mfr_serial");
> +
> + return 0;
> +}
> +
> +static const struct of_device_id acbel_fsg032_of_match[] = {
> + { .compatible = "acbel,fsg032" },
> + {}
> +};
> +MODULE_DEVICE_TABLE(of, acbel_fsg032_of_match);
> +
> +static struct i2c_driver acbel_fsg032_driver = {
> + .driver = {
> + .name = "acbel-fsg032",
> + .of_match_table = acbel_fsg032_of_match,
> + },
> + .probe_new = acbel_fsg032_probe,
> + .id_table = acbel_fsg032_id,
> +};
> +
> +module_i2c_driver(acbel_fsg032_driver);
> +
> +MODULE_AUTHOR("Lakshmi Yadlapati");
> +MODULE_DESCRIPTION("PMBus driver for AcBel Power System power supplies");
> +MODULE_LICENSE("GPL");
> +MODULE_IMPORT_NS(PMBUS);
> --
> 2.37.2
>