Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add driver for LT717x #2658

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Documentation/devicetree/bindings/trivial-devices.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Documentation/hwmon/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ Hardware Monitoring Kernel Drivers
lm95234
lm95245
lochnagar
lt7170
lt7182s
ltc2992
ltc2945
Expand Down
110 changes: 110 additions & 0 deletions Documentation/hwmon/lt7170.rst
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>


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
======================= ===========================


7 changes: 7 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -12549,6 +12549,13 @@ L: [email protected]
S: Maintained
F: drivers/scsi/sym53c8xx_2/

LT7170 HARDWARE MONITOR DRIVER
M: Cherrence Sarip <[email protected]>
L: [email protected]
S: Supported
F: Documentation/hwmon/lt7170.rst
F: drivers/hwmon/pmbus/lt7170.c

LTC1660 DAC DRIVER
M: Marcus Folkesson <[email protected]>
L: [email protected]
Expand Down
1 change: 1 addition & 0 deletions drivers/hwmon/Kconfig.adi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions drivers/hwmon/pmbus/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions drivers/hwmon/pmbus/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
154 changes: 154 additions & 0 deletions drivers/hwmon/pmbus/lt7170.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Hardware monitoring driver for Analog Devices LT7170
*
* 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"

#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, &lt7170_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, &lt7170_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 <[email protected]>");
MODULE_DESCRIPTION("PMBus driver for Analog Devices LT7170");
MODULE_LICENSE("GPL");
MODULE_IMPORT_NS(PMBUS);
Loading