From b4d864de11bb0177b764976ee8e82fa67688314c Mon Sep 17 00:00:00 2001 From: Cherrence Sarip Date: Thu, 28 Nov 2024 14:37:53 +0800 Subject: [PATCH 1/3] dt-bindings: trivial-devices: add lt7170 Add Analog Devices LT7170, LT7170-1, LT7171, and LT7171-1 Single- or Dual-Phase Step-Down Silent Switcher. Signed-off-by: Cherrence Sarip --- Documentation/devicetree/bindings/trivial-devices.yaml | 8 ++++++++ MAINTAINERS | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Documentation/devicetree/bindings/trivial-devices.yaml index 430a814f64a567..182ac86bb6de62 100644 --- a/Documentation/devicetree/bindings/trivial-devices.yaml +++ b/Documentation/devicetree/bindings/trivial-devices.yaml @@ -43,6 +43,14 @@ properties: - adi,adp5585-02 # Analog Devices ADP5589 Keypad Decoder and I/O Expansion - adi,adp5589 + # Analog Devices LT7170 20A, 16V Single- or Dual-Phase Step-Down Silent Switcher + - adi,lt7170 + # Analog Devices LT7170-1 20A, 16V Single- or Dual-Phase Step-Down Silent Switcher + - adi,lt7170-1 + # Analog Devices LT7171 20A, 16V PolyPhase Step-Down Silent Switcher + - adi,lt7171 + # Analog Devices LT7171-1 20A, 16V PolyPhase Step-Down Silent Switcher + - adi,lt7171-1 # Analog Devices LT7182S Dual Channel 6A, 20V PolyPhase Step-Down Silent Switcher - adi,lt7182s # AMS iAQ-Core VOC Sensor diff --git a/MAINTAINERS b/MAINTAINERS index 5c649553dc015d..9c92bb2f917933 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -12549,6 +12549,11 @@ L: linux-scsi@vger.kernel.org S: Maintained F: drivers/scsi/sym53c8xx_2/ +LT7170 HARDWARE MONITOR DRIVER +M: Cherrence Sarip +L: linux-hwmon@vger.kernel.org +S: Supported + LTC1660 DAC DRIVER M: Marcus Folkesson L: linux-iio@vger.kernel.org From d14448b34782b6be7a5d55f9faf2be9bf60837fb Mon Sep 17 00:00:00 2001 From: Cherrence Sarip Date: Thu, 28 Nov 2024 16:24:49 +0800 Subject: [PATCH 2/3] hwmon: pmbus: add driver for lt7170, lt7170-1, lt7171, and lt7171-1 LT7170 20A, 16V Single- or Dual-Phase Step-Down Silent Switcher with PMBus Interface LT7170-1 20A, 16V Single- or Dual-Phase Step-Down Silent Switcher with PMBus Interface LT7171 20A, 16V PolyPhase Step-Down Silent Switcher with PMBus Interface LT7171-1 20A, 16V PolyPhase Step-Down Silent Switcher with PMBus Interface Signed-off-by: Cherrence Sarip --- Documentation/hwmon/index.rst | 1 + Documentation/hwmon/lt7170.rst | 110 +++++++++++++++++++++++ MAINTAINERS | 2 + drivers/hwmon/pmbus/Kconfig | 9 ++ drivers/hwmon/pmbus/Makefile | 1 + drivers/hwmon/pmbus/lt7170.c | 154 +++++++++++++++++++++++++++++++++ 6 files changed, 277 insertions(+) create mode 100644 Documentation/hwmon/lt7170.rst create mode 100644 drivers/hwmon/pmbus/lt7170.c diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst index 0ec96abe3f7d21..72fc8ff6e83cfe 100644 --- a/Documentation/hwmon/index.rst +++ b/Documentation/hwmon/index.rst @@ -115,6 +115,7 @@ Hardware Monitoring Kernel Drivers lm95234 lm95245 lochnagar + lt7170 lt7182s ltc2992 ltc2945 diff --git a/Documentation/hwmon/lt7170.rst b/Documentation/hwmon/lt7170.rst new file mode 100644 index 00000000000000..7d28f9825f0fb9 --- /dev/null +++ b/Documentation/hwmon/lt7170.rst @@ -0,0 +1,110 @@ +.. SPDX-License-Identifier: GPL-2.0 + +Kernel driver lt7170 +===================== + +Supported chips: + + * Analog Devices LT7170 + + Prefix: 'lt7170' + + Addresses scanned: I2C 0x4F + + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/lt7170-lt7170-1.pdf + + * Analog Devices LT7170-1 + + Prefix: 'lt7170-1' + + Addresses scanned: I2C 0x4F + + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/lt7170-lt7170-1.pdf + + * Analog Devices LT7171 + + Prefix: 'lt7171' + + Addresses scanned: I2C 0x41 + + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/lt7170-lt7170-1.pdf + + * Analog Devices LT7171-1 + + Prefix: 'lt7171-1' + + Addresses scanned: I2C 0x41 + + Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/lt7170-lt7170-1.pdf + + +Authors: + - Cherrence Sarip + + +Description +----------- + +The LT7170 is a family of silent switcher step-down regulators with +digital power system management support. LT7170 +features telemetry monitoring of input/output voltage, output current, +and temperature over PMBus. + +The driver is a client driver to the core PMBus driver. Please see +Documentation/hwmon/pmbus.rst for details on PMBus client drivers. + +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. Please see +Documentation/hwmon/pmbus.rst for details. + +Sysfs Attributes +---------------- + +======================= =========================== +curr1_label "iout1" +curr1_input Measured output current +curr1_highest Highest measured output current +curr1_max Maximum output current +curr1_max_alarm Output current high alarm + +in1_label "vin" +in1_input Measured input voltage +in1_highest Highest measured input voltage +in1_min Minimum input voltage +in1_min_alarm Input voltage low alarm +in1_rated_min Rated minimum input voltage +in1_rated_max Rated maximum input voltage +in1_reset_history Write to reset history for all attributes + +in2_label "vout1" +in2_input Measured output voltage +in2_highest Highest measured output voltage +in2_lcrit Critical minimum output voltage +in2_lcrit_alarm Output voltage critical low alarm +in2_min Minimum output voltage +in2_max_alarm Output voltage low alarm +in2_max Maximum output voltage +in2_max_alarm Output voltage high alarm +in2_crit Critical maximum output voltage +in2_crit_alarm Output voltage critical high alarm +in2_rated_min Rated minimum output voltage +in2_rated_max Rated maximum output voltage + +temp1_input Measured temperature +temp1_highest Highest measured temperature +temp1_crit Critical high temperature +temp1_crit_alarm Chip temperature critical high alarm +temp1_max Maximum temperature +temp1_max_alarm Chip temperature high alarm +======================= =========================== + + diff --git a/MAINTAINERS b/MAINTAINERS index 9c92bb2f917933..3321a43698a19b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -12553,6 +12553,8 @@ LT7170 HARDWARE MONITOR DRIVER M: Cherrence Sarip L: linux-hwmon@vger.kernel.org S: Supported +F: Documentation/hwmon/lt7170.rst +F: drivers/hwmon/pmbus/lt7170.c LTC1660 DAC DRIVER M: Marcus Folkesson diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig index 4b175c14addcce..8c5833199ce406 100644 --- a/drivers/hwmon/pmbus/Kconfig +++ b/drivers/hwmon/pmbus/Kconfig @@ -200,6 +200,15 @@ config SENSORS_LM25066_REGULATOR If you say yes here you get regulator support for National Semiconductor LM25066, LM5064, and LM5066. +config SENSORS_LT7170 + tristate "Analog Devices LT7170, LT7170-1, LT7171, LT7171-1" + help + If you say yes here you get hardware monitoring support for Analog + Devices LT7170, LT7170-1, LT7171 and LT7171-1. + + This driver can also be built as a module. If so, the module will + be called lt7170. + config SENSORS_LT7182S tristate "Analog Devices LT7182S" help diff --git a/drivers/hwmon/pmbus/Makefile b/drivers/hwmon/pmbus/Makefile index 65afceb75b3646..79f31edfd75e06 100644 --- a/drivers/hwmon/pmbus/Makefile +++ b/drivers/hwmon/pmbus/Makefile @@ -22,6 +22,7 @@ obj-$(CONFIG_SENSORS_IR38064) += ir38064.o obj-$(CONFIG_SENSORS_IRPS5401) += irps5401.o obj-$(CONFIG_SENSORS_ISL68137) += isl68137.o obj-$(CONFIG_SENSORS_LM25066) += lm25066.o +obj-$(CONFIG_SENSORS_LT7170) += lt7170.o obj-$(CONFIG_SENSORS_LT7182S) += lt7182s.o obj-$(CONFIG_SENSORS_LTC2978) += ltc2978.o obj-$(CONFIG_SENSORS_LTC3815) += ltc3815.o diff --git a/drivers/hwmon/pmbus/lt7170.c b/drivers/hwmon/pmbus/lt7170.c new file mode 100644 index 00000000000000..a317dd06a51d16 --- /dev/null +++ b/drivers/hwmon/pmbus/lt7170.c @@ -0,0 +1,154 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Hardware monitoring driver for Analog Devices LT7170 + * + * Copyright (C) 2024 Analog Devices, Inc. + */ +#include +#include +#include +#include +#include +#include +#include +#include "pmbus.h" + +#define LT7170_NUM_PAGES 1 + +#define MFR_READ_EXTVCC 0xcd +#define MFR_READ_ITH 0xce +#define MFR_CONFIG_ALL_LT7170 0xd1 +#define MFR_IOUT_PEAK 0xd7 +#define MFR_ADC_CONTROL_LT7170 0xd8 + +#define MFR_DEBUG_TELEMETRY BIT(0) + +#define MFR_VOUT_PEAK 0xdd +#define MFR_VIN_PEAK 0xde +#define MFR_TEMPERATURE_1_PEAK 0xdf +#define MFR_CLEAR_PEAKS 0xe3 + +static int lt7170_read_word_data(struct i2c_client *client, int page, int phase, int reg) +{ + int ret; + + switch (reg) { + case PMBUS_VIRT_READ_VMON: + if (page == 0) + ret = pmbus_read_word_data(client, page, phase, MFR_READ_ITH); + else + ret = pmbus_read_word_data(client, 0, phase, MFR_READ_EXTVCC); + break; + case PMBUS_VIRT_READ_IOUT_MAX: + ret = pmbus_read_word_data(client, page, phase, MFR_IOUT_PEAK); + break; + case PMBUS_VIRT_READ_VOUT_MAX: + ret = pmbus_read_word_data(client, page, phase, MFR_VOUT_PEAK); + break; + case PMBUS_VIRT_READ_VIN_MAX: + ret = pmbus_read_word_data(client, page, phase, MFR_VIN_PEAK); + break; + case PMBUS_VIRT_READ_TEMP_MAX: + ret = pmbus_read_word_data(client, page, phase, MFR_TEMPERATURE_1_PEAK); + break; + case PMBUS_VIRT_RESET_VIN_HISTORY: + ret = (page == 0) ? 0 : -ENODATA; + break; + default: + ret = -ENODATA; + break; + } + return ret; +} + +static int lt7170_write_word_data(struct i2c_client *client, int page, int reg, u16 word) +{ + int ret; + + switch (reg) { + case PMBUS_VIRT_RESET_VIN_HISTORY: + ret = pmbus_write_byte(client, 0, MFR_CLEAR_PEAKS); + break; + default: + ret = -ENODATA; + break; + } + return ret; +} + +static struct pmbus_driver_info lt7170_info = { + .pages = LT7170_NUM_PAGES, + .format[PSC_VOLTAGE_IN] = ieee754, + .format[PSC_VOLTAGE_OUT] = ieee754, + .format[PSC_CURRENT_OUT] = ieee754, + .format[PSC_TEMPERATURE] = ieee754, + .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | + PMBUS_HAVE_IOUT | PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_VOUT | + PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_STATUS_INPUT | + PMBUS_HAVE_STATUS_TEMP, + .read_word_data = lt7170_read_word_data, + .write_word_data = lt7170_write_word_data, +}; + +static int lt7170_probe(struct i2c_client *client) +{ + struct device *dev = &client->dev; + struct pmbus_driver_info *info; + int ret; + + if (!i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_BYTE_DATA | + I2C_FUNC_SMBUS_READ_WORD_DATA | + I2C_FUNC_SMBUS_READ_BLOCK_DATA)) + return -ENODEV; + + info = devm_kmemdup(dev, <7170_info, + sizeof(struct pmbus_driver_info), GFP_KERNEL); + if (!info) + return -ENOMEM; + + /* Enable VMON output if configured */ + ret = i2c_smbus_read_byte_data(client, MFR_ADC_CONTROL_LT7170); + if (ret < 0) + return ret; + if (ret & MFR_DEBUG_TELEMETRY) { + info->pages = 1; + info->func[0] |= PMBUS_HAVE_VMON; + } + + return pmbus_do_probe(client, <7170_info); +} + +static const struct i2c_device_id lt7170_id[] = { + {"lt7170", 0}, + {"lt7170-1", 0}, + {"lt7171", 0}, + {"lt7171-1", 0}, + {} +}; +MODULE_DEVICE_TABLE(i2c, lt7170_id); + +static const struct of_device_id lt7170_of_match[] = { + { .compatible = "adi,lt7170" }, + { .compatible = "adi,lt7170-1" }, + { .compatible = "adi,lt7171" }, + { .compatible = "adi,lt7171-1" }, + {} +}; +MODULE_DEVICE_TABLE(of, lt7170_of_match); + +static struct i2c_driver lt7170_driver = { + .driver = { + .name = "lt7170", + .of_match_table = of_match_ptr(lt7170_of_match), + }, + .probe = lt7170_probe, + .id_table = lt7170_id, +}; + +module_i2c_driver(lt7170_driver); + +MODULE_AUTHOR("Cherrence Sarip "); +MODULE_DESCRIPTION("PMBus driver for Analog Devices LT7170"); +MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(PMBUS); From 1ebf9338e3fcf1d9238a90e0258f897190d6dce2 Mon Sep 17 00:00:00 2001 From: Cherrence Sarip Date: Thu, 28 Nov 2024 16:41:09 +0800 Subject: [PATCH 3/3] hwmon: Kconfig.adi: imply lt7170 Add entries for the LT7170 driver. Signed-off-by: Cherrence Sarip --- drivers/hwmon/Kconfig.adi | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/hwmon/Kconfig.adi b/drivers/hwmon/Kconfig.adi index db613969acc86c..4e461154fa03ce 100644 --- a/drivers/hwmon/Kconfig.adi +++ b/drivers/hwmon/Kconfig.adi @@ -26,6 +26,7 @@ config HWMON_ALL_ADI_DRIVERS imply SENSORS_ADT7462 imply SENSORS_ADT7470 imply SENSORS_ADT7475 + imply SENSORS_LT7170 imply SENSORS_LTC2945 imply SENSORS_LTC2947_I2C imply SENSORS_LTC2947_SPI