hwmon: (pmbus) Add driver for ADP1050
authorRadu Sabau <radu.sabau@analog.com>
Thu, 21 Mar 2024 14:21:43 +0000 (16:21 +0200)
committerGuenter Roeck <linux@roeck-us.net>
Sun, 28 Apr 2024 17:07:35 +0000 (10:07 -0700)
Add support for ADP1050 Digital Controller for Isolated Power Supplies
with PMBus interface Voltage, Current and Temperature Monitor.

The ADP1050 implements several features to enable a robust
system of parallel and redundant operation for customers who
require high availability. The device can measure voltage,
current and temperature that can be used in different
techniques to identify and safely shut down an erroneous
power supply in parallel operation mode.

Signed-off-by: Radu Sabau <radu.sabau@analog.com>
Link: https://lore.kernel.org/r/20240321142201.10330-2-radu.sabau@analog.com
[groeck: Fixed corrupted link in documentation]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Documentation/hwmon/adp1050.rst [new file with mode: 0644]
Documentation/hwmon/index.rst
drivers/hwmon/pmbus/Kconfig
drivers/hwmon/pmbus/Makefile
drivers/hwmon/pmbus/adp1050.c [new file with mode: 0644]

diff --git a/Documentation/hwmon/adp1050.rst b/Documentation/hwmon/adp1050.rst
new file mode 100644 (file)
index 0000000..8fa9370
--- /dev/null
@@ -0,0 +1,64 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+Kernel driver adp1050
+=====================
+
+Supported chips:
+
+  * Analog Devices ADP1050
+
+    Prefix: 'adp1050'
+
+    Addresses scanned: I2C 0x70 - 0x77
+
+    Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/ADP1050.pdf
+
+Authors:
+
+  - Radu Sabau <radu.sabau@analog.com>
+
+
+Description
+-----------
+
+This driver supprts hardware monitoring for Analog Devices ADP1050 Digital
+Controller for Isolated Power Supply with PMBus interface.
+
+The ADP1050 is an advanced digital controller with a PMBusā„¢
+interface targeting high density, high efficiency dc-to-dc power
+conversion used to monitor system temperatures, voltages and currents.
+Through the PMBus interface, the device can monitor input/output voltages,
+input current and temperature.
+
+Usage Notes
+-----------
+
+This driver does not auto-detect devices. You will have to instantiate
+the devices explicitly.
+Please see Documentation/i2c/instantiating-devices.rst for details.
+
+Platform data support
+---------------------
+
+The driver supports standard PMBus driver platform data.
+
+Sysfs Attributes
+----------------
+
+================= ========================================
+in1_label         "vin"
+in1_input         Measured input voltage
+in1_alarm        Input voltage alarm
+in2_label        "vout1"
+in2_input        Measured output voltage
+in2_crit         Critical maximum output voltage
+in2_crit_alarm    Output voltage high alarm
+in2_lcrit        Critical minimum output voltage
+in2_lcrit_alarm          Output voltage critical low alarm
+curr1_label      "iin"
+curr1_input      Measured input current.
+curr1_alarm      Input current alarm
+temp1_input       Measured temperature
+temp1_crit       Critical high temperature
+temp1_crit_alarm  Chip temperature critical high alarm
+================= ========================================
index 1ca7a4fe1f8f5764c998f7c7955fe0f2f8c70397..9a4fd576e6f628a8bf1026fa6fe6d864c98cd49a 100644 (file)
@@ -33,6 +33,7 @@ Hardware Monitoring Kernel Drivers
    adm1266
    adm1275
    adm9240
+   adp1050
    ads7828
    adt7410
    adt7411
index 557ae0c414b09ee8c3adb616320f9bd69fc1097b..38e794d83cc3dbf2c0d3b06875b85aa47786accc 100644 (file)
@@ -57,6 +57,16 @@ config SENSORS_ADM1275
          This driver can also be built as a module. If so, the module will
          be called adm1275.
 
+config SENSORS_ADP1050
+       tristate "Analog Devices ADP1050 digital controller for Power Supplies"
+       help
+         If you say yes here you get hardware monitoring support for Analog
+         Devices ADP1050 digital controller for isolated power supply with
+         PMBus interface.
+
+         This driver can also be built as a module. If so, the module will
+         be called adp1050.
+
 config SENSORS_BEL_PFE
        tristate "Bel PFE Compatible Power Supplies"
        help
index f14ecf03ad7790edbc3c30b2886d495b06144ae7..95a8dea5e5ed9db052fbf03382a2276b05e87e8b 100644 (file)
@@ -8,6 +8,7 @@ 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_ADP1050)  += adp1050.o
 obj-$(CONFIG_SENSORS_BEL_PFE)  += bel-pfe.o
 obj-$(CONFIG_SENSORS_BPA_RS600)        += bpa-rs600.o
 obj-$(CONFIG_SENSORS_DELTA_AHE50DC_FAN) += delta-ahe50dc-fan.o
diff --git a/drivers/hwmon/pmbus/adp1050.c b/drivers/hwmon/pmbus/adp1050.c
new file mode 100644 (file)
index 0000000..0a49bea
--- /dev/null
@@ -0,0 +1,58 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Hardware monitoring driver for Analog Devices ADP1050
+ *
+ * Copyright (C) 2024 Analog Devices, Inc.
+ */
+#include <linux/bits.h>
+#include <linux/err.h>
+#include <linux/i2c.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include "pmbus.h"
+
+static struct pmbus_driver_info adp1050_info = {
+       .pages = 1,
+       .format[PSC_VOLTAGE_IN] = linear,
+       .format[PSC_VOLTAGE_OUT] = linear,
+       .format[PSC_CURRENT_IN] = linear,
+       .format[PSC_TEMPERATURE] = linear,
+       .func[0] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
+               | PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT
+               | PMBUS_HAVE_IIN | PMBUS_HAVE_TEMP
+               | PMBUS_HAVE_STATUS_TEMP,
+};
+
+static int adp1050_probe(struct i2c_client *client)
+{
+       return pmbus_do_probe(client, &adp1050_info);
+}
+
+static const struct i2c_device_id adp1050_id[] = {
+       {"adp1050", 0},
+       {}
+};
+MODULE_DEVICE_TABLE(i2c, adp1050_id);
+
+static const struct of_device_id adp1050_of_match[] = {
+       { .compatible = "adi,adp1050"},
+       {}
+};
+MODULE_DEVICE_TABLE(of, adp1050_of_match);
+
+static struct i2c_driver adp1050_driver = {
+       .driver = {
+               .name = "adp1050",
+               .of_match_table = adp1050_of_match,
+       },
+       .probe = adp1050_probe,
+       .id_table = adp1050_id,
+};
+module_i2c_driver(adp1050_driver);
+
+MODULE_AUTHOR("Radu Sabau <radu.sabau@analog.com>");
+MODULE_DESCRIPTION("Analog Devices ADP1050 HWMON PMBus Driver");
+MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS(PMBUS);