Skip to content

drivers: power: ltm4700: Add support for LTM4700 dual-channel PMBus regulator#3111

Open
cjones-adi wants to merge 6 commits into
analogdevicesinc:mainfrom
cjones-adi:staging/ltm4700
Open

drivers: power: ltm4700: Add support for LTM4700 dual-channel PMBus regulator#3111
cjones-adi wants to merge 6 commits into
analogdevicesinc:mainfrom
cjones-adi:staging/ltm4700

Conversation

@cjones-adi

Copy link
Copy Markdown
Contributor

Pull Request Description

Add comprehensive support for the LTM4700 dual-channel 50A/100A μModule regulator with complete IIO subsystem integration, multi-example project build, and unit testing.

Driver Features

  • PMBus 1.3 compliant I2C interface (default address 0x5A)
  • Dual-channel power monitoring and control (VIN, IIN, PIN, VOUT, IOUT, POUT per channel)
  • Temperature monitoring
  • Switching frequency monitoring
  • LINEAR11/LINEAR16 data format conversion
  • Device identification and verification (LTM4700 special ID check)
  • CRC-8 support for reliable PMBus communication
  • Operation control (ON/OFF per channel or both)

Files Changed

  • Drivers: 4 files (ltm4700.h/c, iio_ltm4700.h/c)
  • Project: 13 files (complete multi-platform structure)
  • Tests: 4 files (comprehensive unit tests)
  • Documentation: 4 files (driver/project README + Sphinx)

PR Type

  • Bug fix (change that fixes an issue)
  • New feature (change that adds new functionality)
  • Breaking change (has dependencies in other repos or will cause CI to fail)

PR Checklist

  • I have followed the Coding style guidelines
  • I have complied with the Submission Checklist
  • I have performed a self-review of the changes
  • I have commented my code, at least hard-to-understand parts
  • I have build all projects affected by the changes in this PR
  • I have tested in hardware affected projects, at the relevant boards
  • I have signed off all commits from this PR
  • I have updated the documentation (wiki pages, ReadMe etc), if applies

Comment thread drivers/power/ltm4700/ltm4700.c Outdated
return -EINVAL;

return ltm4700_send_byte(dev, 0, LTM4700_MFR_CLEAR_PEAKS);
} No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing new line at end, check all files

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in V2

if (ret)
goto exit;

ret = ltm4700_set_operation(dev, LTM4700_CHAN_ALL,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in ltm4700_init num of channels is set to
LTM4700_CHAN_ALL is 0xFF
won't it return invalid in ltm4700_set_operation because of
if (channel >= dev->num_channels)
return -EINVAL;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in V2

Comment thread drivers/power/ltm4700/ltm4700.c Outdated

ret = no_os_gpio_remove(dev->alert_desc);
if (ret)
return ret;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should still attempt to remove i2c to prevent partial clean ups

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in V2

Comment thread drivers/power/ltm4700/ltm4700.h Outdated
#define LTM4700_LIN11_EXPONENT_MSK NO_OS_GENMASK(15,11)
#define LTM4700_LIN11_EXPONENT(x) ((int16_t)(x) >> 11)
#define LTM4700_LIN11_MANTISSA(x) (((int16_t)((x & LTM4700_LIN11_MANTISSA_MSK) << 5)) >> 5)
#define LTM4700_LIN16_EXPONENT -12

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe enclose negative values in ()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in V2

@cjones-adi
cjones-adi force-pushed the staging/ltm4700 branch 2 times, most recently from 20b4639 to 10ebcb5 Compare June 1, 2026 09:18
@cjones-adi

Copy link
Copy Markdown
Contributor Author

V2:

  • Fix bug in sscanf parsing
  • Fix bug in all channel filter in set operation (and set page)
  • Add i2c clean up
  • Add newline at the end of file for affected files
  • Add parenthesis on negative #define values

@liviutomoiaga

Copy link
Copy Markdown
Contributor

Xilinx build fails due to missing authorization. By default, PRs from forks cannot access repository secrets.

FYI @cjones-adi

Comment thread drivers/power/ltm4700/ltm4700.h Outdated
* @param tr - Transition rate in µV/ms
* @return 0 in case of success, negative error code otherwise
*/
int ltm4700_vout_tr(struct ltm4700_dev *dev, uint8_t channel, int tr);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems to be redundant.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in V3

Comment thread projects/ltm4700/builds.json Outdated
@@ -0,0 +1,10 @@
{
"maxim": {
"basic_example_max32665": {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the project documentation references only max32655. what platform was actually used?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

max32665 is the one. addressed in V3

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed back to max32655 in V4

$(PLATFORM_DRIVERS)/../common/maxim_dma.c \
$(PLATFORM_DRIVERS)/maxim_i2c.c \
$(PLATFORM_DRIVERS)/maxim_uart.c \
$(PLATFORM_DRIVERS)/maxim_uart_stdio.c No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing newline at eof. check all occurences in all files.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in V3

Comment thread drivers/power/ltm4700/README.rst Outdated
struct ltm4700_init_param init_param = {
.i2c_init = &i2c_init_param,
.crc_en = false,
.id = ID_LTM4700

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this member is non-existent.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in V3

Comment thread drivers/power/ltm4700/ltm4700.h Outdated
struct no_os_gpio_init_param **run_params;
struct no_os_gpio_init_param **fault_params;

bool external_clk_en;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't seem to be used.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in V3

@cjones-adi
cjones-adi force-pushed the staging/ltm4700 branch 3 times, most recently from 63dfde6 to 17892f4 Compare June 17, 2026 07:06
@cjones-adi

Copy link
Copy Markdown
Contributor Author

V3

  • Remove unused external_clk_en member from ltm4700_init_param
  • Remove redundant ltm4700_vout_tr function declaration
  • Fix driver README example code
  • Fix platform inconsistency in project documentation
  • Add missing newlines at end of files

else
mantissa = uval << (-exp);

return (uint16_t)mantissa;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When value overflows truncated value may give garbage values. Better to clamp

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in V4

Comment thread drivers/power/ltm4700/ltm4700.c Outdated
else
val = mantissa >> (-exp);

return val;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same clamp issue

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in V4

Comment thread drivers/power/ltm4700/ltm4700.c Outdated
if (exponent >= 0)
val = mantissa << exponent;
else
val = mantissa >> (-exponent);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same issue with overflow

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in V4

goto error_dev;

if (init_param->crc_en) {
no_os_crc8_populate_msb(ltm4700_crc_table, LTM4700_CRC_POLYNOMIAL);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

crc table is in init but seems to not be used

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in V4

ptr++;
}

if (sscanf(ptr, "%d.%d", &int_part, &frac_part) == 2) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if fractional part has leading zeros like 3.05
.05 will just be parsed as 5 this in turn will give a wrong value

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in V4

Comment thread drivers/power/ltm4700/iio_ltm4700.c Outdated

#define LTM4700_IIO_REG_CHAN(reg, chan) (reg | (chan << 8))
#define LTM4700_IIO_REG(x) (x & 0xFF)
#define LTM4700_IIO_CHAN(x) ((x >> 8) & 0xFF)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these macros used?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in V4 (stale debug codes)

return -EINVAL;

if (ltm4700_cmd_is_paged(cmd)) {
int ret = ltm4700_set_page(dev, page);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent with coding style should be declared at the top

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in V4

return -EINVAL;

if (ltm4700_cmd_is_paged(cmd)) {
int ret = ltm4700_set_page(dev, page);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent with coding style should be declared at the top

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in V4

return -EINVAL;

if (ltm4700_cmd_is_paged(cmd)) {
int ret = ltm4700_set_page(dev, page);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent with coding style should be declared at the top

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in V4

@buha

buha commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

please migrate to the cmake/kconfig build system

@buha

buha commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

/AzurePipelines run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 2 pipeline(s).

Add comprehensive PMBus driver for LTM4700 dual-channel regulator.
Includes support for dual-channel monitoring, and complete LINEAR
format conversion.

Key features:
- PMBus 1.3 compliant I2C interface (400kHz)
- Dual-channel 50A per channel or single 100A operation
- LINEAR11/LINEAR16 data format support
- Comprehensive status monitoring
- Complete telemetry reading (VIN, IIN, VOUT, IOUT, temperatures)
- Peak value tracking and management
- NVM operations for configuration storage

Signed-off-by: Carlos Jones Jr <carlosjr.jones@analog.com>
Add comprehensive Industrial I/O (IIO) framework integration for LTM4700
dual-channel regulator with real-time telemetry and control interface.

Key features:
- 13 IIO channels covering all telemetry (VIN, IIN, VOUT0/1, IOUT0/1, etc.)
- Real-time voltage/current/power/temperature monitoring
- Write support for VOUT control and operation mode
- Peak value management and fault clearing
- Engineering unit conversion (mV, mA, m°C, mW)
- Multi-channel configuration support
- Complete Linux IIO subsystem compliance

IIO Channels:
- Input: VIN, IIN, PIN, IC temperature
- Output: VOUT0/1, IOUT0/1, POUT0/1, external temperatures
- Control: Operation mode, voltage commands, margins
- Frequency: Per-channel switching frequency monitoring

Signed-off-by: Carlos Jones Jr <carlosjr.jones@analog.com>
Add comprehensive driver documentation covering device features,
PMBus command interface, IIO integration, and usage examples.

Documentation includes:
- Device overview
- Key features and specifications
- PMBus communication interface details
- Data format descriptions (LINEAR11/LINEAR16)
- Complete API usage examples
- IIO framework integration guide
- Design considerations and best practices
- Build configuration instructions

The documentation provides complete guidance for driver integration
and application development with the LTM4700 regulator.

Signed-off-by: Carlos Jones Jr <carlosjr.jones@analog.com>
Add comprehensive project structure for LTM4700 dual-channel regulator
with support for both basic telemetry monitoring and IIO integration.
Includes platform-specific configuration for Maxim MAX32655 with proper
I2C, UART, and GPIO setup for PMBus communication at 400kHz.

Signed-off-by: Carlos Jones Jr <carlosjr.jones@analog.com>
Add comprehensive project documentation covering hardware setup,
build instructions, examples usage, and troubleshooting guide.
Includes detailed configuration options for both basic telemetry
and IIO integration examples with performance characteristics
and platform-specific setup instructions.

Signed-off-by: Carlos Jones Jr <carlosjr.jones@analog.com>
Add comprehensive unit test suite for LTM4700 dual-channel regulator
driver using Ceedling/Unity/CMock framework. Includes core driver tests
for initialization, PMBus communication, LINEAR format conversion,
voltage/current/temperature reading, and IIO integration tests.

Test coverage includes:
- Device initialization
- PMBus read/write operations with I2C mocking
- LINEAR11/LINEAR16 format conversion validation
- Multi-channel operation and page selection
- IIO channel mapping and attribute handling
- Error handling and parameter validation
- Support functions for test data generation

Targets 80%+ code coverage with automated testing framework.

Signed-off-by: Carlos Jones Jr <carlosjr.jones@analog.com>
@cjones-adi

Copy link
Copy Markdown
Contributor Author

V4:

  • Migrate build system to cmake/kconfig
  • Handle overflows in data conversion
  • Address CRC and scannf issue
  • Clean up unused macros
  • Fix code style issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants