Skip to content

Commit 7f9f825

Browse files
committed
PMBus and MFR: new 11 commands
Add a substantial set of PMBus feature commands, aligned with Flex BMR (BMR685/BMR456/BMR480) docs. Include some long helps and some notes (see TODO). 1) capability - capability get - capability check --need-pec on|off --min-speed 100|400 --need-alert on|off [--strict] Decodes: PEC support, max bus speed (100/400 kHz), SMBALERT# presence, and reserved low bits. 2) interleave - interleave get - interleave set [--set 0xNN] [--phases 1..16 --index 0..15]` Upper nibble = phases-1, lower nibble = phase index. 3) hrr - hrr get - hrr set [--pec on|off] [--hrr on|off] [--dls linear|nonlinear] [--artdlc on|off] [--dbv on|off]` - hrr set --raw 0xNN Bits: bit7=PEC require, bit6=HRR, bit5=DLS slope, bit3=ART/DLC, bit2=DBV. Includes hrr help with detailed descriptions and examples. TODO: apply the same for other commands. 4) vin - vin get [--exp5 N] [--raw] - vin set [--on V] [--off V] [--exp5 N] | [--on-raw 0xNNNN] [--off-raw 0xNNNN] 5) pgood - pgood get [--exp5 N] [--raw] - pgood set [--on V] [--off V] [--exp5 N] | [--on-raw 0xNNNN] [--off-raw 0xNNNN] 6) freq - freq get - freq set --raw 0xNNNN 7) salert - salert get - salert set --raw 0xNN 8) addr-offset - addr-offset get - addr-offset set --raw 0xNN 9) ramp-data Returns a hex blob (TODO: no vendor decode). 10) status-data Returns a hex blob (concise status history snapshot). 11) write-protect - write-protect get - write-protect set [--none|--ctrl|--nvm|--all] | --raw 0xNN Typical values: 0x00, 0x40, 0x80, 0xFF. - No behavior changes for the existing commands. - PEC: Enabling via hrr will require the host stack to send SMBus PEC or communication will fail; see comments from hrr help.
1 parent 81db338 commit 7f9f825

27 files changed

+1749
-3
lines changed

README.md

Lines changed: 243 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,230 @@ bmr ... vout set --set-all 0.90 --margin-pct 5
351351

352352
Then use `operation set --margin high|low` during validation.
353353

354+
## capability — PMBus CAPABILITY (0x19) decode & checks
355+
356+
```bash
357+
bmr ... capability get
358+
bmr ... capability check --need-pec on|off --min-speed 100|400 --need-alert on|off [--strict]
359+
```
360+
361+
### What it does
362+
363+
Decodes `PMBUS_CAPABILITY` into `pec_supported`, `max_bus_speed` (100/400 kHz),
364+
`smblalert_supported`, and reserved bits. `check` compares against requirements
365+
and returns `{checks:{...}, mismatches:[...]}`.
366+
367+
### Use case
368+
369+
Guard-rail in bring-up scripts to assert 400 kHz + PEC + ALERT:
370+
371+
```bash
372+
bmr ... capability check --need-pec on --min-speed 400 --need-alert on --strict
373+
```
374+
375+
## interleave — Phase count & index (INTERLEAVE 0x37)
376+
377+
```bash
378+
bmr ... interleave get
379+
bmr ... interleave set [--set 0xNN] [--phases 1..16 --index 0..15]
380+
```
381+
382+
### What it does
383+
384+
Reads/writes the `INTERLEAVE` byte (upper nibble = phases-1, lower nibble =
385+
phase index). Some devices may ignore or restrict settings.
386+
387+
### Use case
388+
389+
Set a 2-phase configuration on phase index 0:
390+
391+
```bash
392+
bmr ... interleave set --phases 2 --index 0
393+
```
394+
395+
## hrr — MFR_SPECIAL_OPTIONS (0xE0) bit control
396+
397+
```bash
398+
bmr ... hrr get
399+
bmr ... hrr set [--pec on|off] [--hrr on|off] [--dls linear|nonlinear] \
400+
[--artdlc on|off] [--dbv on|off]
401+
bmr ... hrr set --raw 0xNN
402+
```
403+
404+
### What it does
405+
406+
Controls `MFR_SPECIAL_OPTIONS` bits such as **PEC require**, **HRR**, **DLS** slope,
407+
**ART/DLC**, **DBV**. Writes only the requested bits or the raw byte.
408+
409+
### Use case
410+
411+
Enable HRR and non-linear droop:
412+
413+
```bash
414+
bmr ... hrr set --hrr on --dls nonlinear
415+
```
416+
417+
> If you turn **PEC on**, your SMBus stack must send PEC.
418+
419+
## vin — VIN_ON/OFF thresholds
420+
421+
```bash
422+
bmr ... vin get [--exp5 N] [--raw]
423+
bmr ... vin set [--on V] [--off V] [--exp5 N] \
424+
| [--on-raw 0xNNNN] [--off-raw 0xNNNN]
425+
```
426+
427+
### What it does
428+
429+
Programs `VIN_ON (0x35)` and `VIN_OFF (0x36)` using LIN-16u (`--exp5`) or raw
430+
words. Use raw if exponent is unknown.
431+
432+
### Use case
433+
434+
Require VIN ≥ 7.5 V to start, stop below 6.8 V:
435+
436+
```bash
437+
bmr ... vin set --on 7.5 --off 6.8 --exp5 -13
438+
```
439+
440+
## pgood — POWER_GOOD window
441+
442+
```bash
443+
bmr ... pgood get [--exp5 N] [--raw]
444+
bmr ... pgood set [--on V] [--off V] [--exp5 N] \
445+
| [--on-raw 0xNNNN] [--off-raw 0xNNNN]
446+
```
447+
448+
### What it does
449+
450+
Controls `POWER_GOOD_ON (0x5E)` / `POWER_GOOD_OFF (0x5F)` (LIN-16u or raw).
451+
452+
### Use case
453+
454+
Ensure PG asserts when VOUT ≥ 96% and de-asserts ≤ 90%:
455+
456+
```bash
457+
bmr ... pgood set --on 0.96 --off 0.90 --exp5 -13
458+
```
459+
460+
## freq — Switching frequency setpoint
461+
462+
```bash
463+
bmr ... freq get
464+
bmr ... freq set --raw 0xNNNN
465+
```
466+
467+
### What it does
468+
469+
Reads/writes the device’s frequency setpoint register (word). Register code and
470+
range are device-specific; use raw word.
471+
472+
### Use case
473+
474+
Bump frequency by a small step for EMI validation:
475+
476+
```bash
477+
bmr ... freq set --raw 0x012C
478+
```
479+
480+
## salert — SMBALERT# mask (0x1B)
481+
482+
```bash
483+
bmr ... salert get
484+
bmr ... salert set --raw 0xNN
485+
```
486+
487+
### What it does
488+
489+
Reads/writes `SMBALERT_MASK` if implemented by the device. Useful to silence
490+
non-critical categories.
491+
492+
### Use case
493+
494+
Mask temperature warnings from ALERT while keeping faults:
495+
496+
```bash
497+
bmr ... salert set --raw 0xXX # choose per device map
498+
```
499+
500+
## addr-offset — Address offset helper
501+
502+
```bash
503+
bmr ... addr-offset get
504+
bmr ... addr-offset set --raw 0xNN
505+
```
506+
507+
### What it does
508+
509+
Reads/writes `MFR_OFFSET_ADDRESS` (if present) to apply a board-level offset to
510+
the base address.
511+
512+
### Use case
513+
514+
Shift module to `0x5A + 1`:
515+
516+
```bash
517+
bmr ... addr-offset set --raw 0x01
518+
```
519+
520+
## ramp-data — Vendor ramp capture (0xDB)
521+
522+
```bash
523+
bmr ... ramp-data
524+
```
525+
526+
### What it does
527+
528+
Reads `MFR_GET_RAMP_DATA` and returns a hex blob. Format is vendor-specific.
529+
530+
### Use case
531+
532+
Capture ramp profile for offline analysis:
533+
534+
```bash
535+
bmr ... ramp-data
536+
```
537+
538+
## status-data — Vendor status dump (0xDF)
539+
540+
```bash
541+
bmr ... status-data
542+
```
543+
544+
### What it does
545+
546+
Reads `MFR_GET_STATUS_DATA` (vendor snapshot of status bytes) as hex.
547+
548+
### Use case
549+
550+
Fetch condensed status history:
551+
552+
```bash
553+
bmr ... status-data
554+
```
555+
556+
## write-protect — WRITE_PROTECT (0x10)
557+
558+
```bash
559+
bmr ... write-protect get
560+
bmr ... write-protect set [--none|--ctrl|--nvm|--all] | --raw 0xNN
561+
```
562+
563+
### What it does
564+
565+
Controls write protection policy. Typical values: `0x00` (none), `0x40` (control-only),
566+
`0x80` (NVM), `0xFF` (all). Exact semantics can vary per device.
567+
568+
### Use case
569+
570+
Lock NVM while allowing live control:
571+
572+
```bash
573+
bmr ... write-protect set --ctrl
574+
```
575+
576+
---
577+
354578
## Notes & best practices
355579

356580
* **Linear formats**: The tool reads `VOUT_MODE` to scale VOUT and uses
@@ -377,8 +601,13 @@ bmr --bus /dev/i2c-1 --addr 0x40 status
377601
bmr --bus /dev/i2c-1 --addr 0x40 id
378602
bmr --bus /dev/i2c-1 --addr 0x40 fwdata
379603

604+
# Capability & checks
605+
bmr --bus /dev/i2c-1 --addr 0x40 capability get
606+
bmr --bus /dev/i2c-1 --addr 0x40 capability check --need-pec on --min-speed 400 --need-alert on --strict
607+
380608
# Snapshot debug
381609
bmr --bus /dev/i2c-1 --addr 0x40 snapshot --cycle 0 --decode
610+
bmr --bus /dev/i2c-1 --addr 0x40 status-data
382611

383612
# PG/Multi-Pin config
384613
bmr --bus /dev/i2c-1 --addr 0x40 mfr-multi-pin set --pg highz --pg-enable 1
@@ -390,7 +619,19 @@ bmr --bus /dev/i2c-1 --addr 0x40 operation set --on --margin normal
390619
# Timing and sequencing
391620
bmr --bus /dev/i2c-1 --addr 0x40 timing set --profile sequenced --ton-delay 250 --ton-rise 100 --toff-fall 40
392621

393-
# Voltage and margins
622+
# Voltage, margins, thresholds
394623
bmr --bus /dev/i2c-1 --addr 0x40 vout set --set-all 1.00 --margin-pct 5
395-
bmr --bus /dev/i2c-1 --addr 0x40 operation set --margin high
624+
bmr --bus /dev/i2c-1 --addr 0x40 vin set --on 7.5 --off 6.8 --exp5 -13
625+
bmr --bus /dev/i2c-1 --addr 0x40 pgood set --on 0.96 --off 0.90 --exp5 -13
626+
627+
# HRR & options
628+
bmr --bus /dev/i2c-1 --addr 0x40 hrr set --hrr on --dls nonlinear
629+
630+
# Frequency & interleave
631+
bmr --bus /dev/i2c-1 --addr 0x40 freq set --raw 0x012C
632+
bmr --bus /dev/i2c-1 --addr 0x40 interleave set --phases 2 --index 0
633+
634+
# Alerts & protection
635+
bmr --bus /dev/i2c-1 --addr 0x40 salert get
636+
bmr --bus /dev/i2c-1 --addr 0x40 write-protect set --ctrl
396637
```

src/TODO

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* use getopt_long() for each subcommand
2+
* move hex/sprintf to util json
3+
* add a usage_long() for some complex commands

0 commit comments

Comments
 (0)