Skip to contentSkip to conversation

lsucpd release 0.91 utility for USB Type-C

Announce Douglas Gilbert 3 participants 5 messages Dec 8, 2023 – Dec 12, 2023 USB

lore
Share & tools
lore
#0 lore raw

lsucpd is a command line utility for listing USB Type-C ports, partners and any associated PD objects. It is essentially data-mining the /sys/class/typec and /sys/class/usb_power_delivery directories. So lsucpd performs no magic and root permissions are not required.

lsucpd was originally announced in this post on 28 August 2023:
https://marc.info/?l=linux-usb&m=169325926403279&w=2
That code has been tagged as 'r0.89'. There is also a 'r0.90' tag but it was not announced. This release is tagged as 'r0.91'. The code is available at this git mirror at:
https://github.com/doug-gilbert/lsucpd

Changelog since 0.89 [20230827] [svn: r9]
- add the first stage of JSON support
- add --pdo-snk= and --pdo-src= options to decode PDOs
- add --rdo= option to decode RDOs
- make preparations for PD revision 3.2

The last one is a bit optimistic as the kernel PD stack can't yet handle the additions in PD 3.1 (e.g. fixed 28, 36 and 48 Volts, plus AVS from 15 to 48 Volts). Recently PD 3.1 dropped all support for 3.3 to < 5 Volts. PD 3.2 splits AVS (Adjustable Voltage Supply) into SPR (Standard Power Range [<= 21 Volts]) and EPR (Extended ...) variants. SPR AVS is the new one going from 9 to 20 Volts. What is the difference between AVS and PPS (Programmable PS)? Answer: PPS does current limiting, AVS doesn't ***.

Note: USB TypeC/PD standards have been in place for almost 10 years and now almost all new mobile devices use TypeC/PD . However visibility of TypeC/PD to host operating systems is relatively new and immature. Previously mobile devices handled TypeC/PD in their BIOS or Embedded Controllers and left the host OS "in the dark".
Please keep this in mind if reporting issues.

Here is a debian binary package built on Ubuntu 23.10 :

    https://doug-gilbert.github.io/p/lsucpd_0.91-0.1_amd64.deb

Here is a rpm built on Fedora 39 :

    https://doug-gilbert.github.io/p/lsucpd-0.91-1.x86_64.rpm

Doug Gilbert

*** "current limiting" as defined by PPS. AVS (and PPS) still does
OCP (Over Current Protection) but that is pretty brutal (i.e. the source removes power for a few hundred milliseconds to let the sink cool off)

Examples from a Thinkpad X13 Gen 3, U 23.10 lk 6.7.0-rc1
[port0-partner: is an alternate mode DP dongle,
port1-partner: is a PD power adapter (source)]

$ lsucpd
 port0 [pd0]  ====>>  partner [pd3]
 port1 [pd1]  <<====  partner [pd2]
$ lsucpd -c
 port0 [pd0]  ====>>  partner [pd3]
 port1 [pd1]  <<====  partner [pd2]
Quoted 12 lines

pd0: has NO source-capabilities
pd0: sink-capabilities:

Quoted 3 lines

1:fixed_supply; fixed: 5.00 Volts, 3.00 Amps (op) 2:variable_supply; variable: 5.00 to 20.00 Volts, 3.25 Amps (op) 3:battery; battery: 5.00 to 20.00 Volts, 65.00 Watts (op)

pd1: source-capabilities:

Quoted 1 line

1:fixed_supply; fixed: 0.00 Volts, 7.21 Amps (max)

pd1: sink-capabilities:

Quoted 3 lines

1:fixed_supply; fixed: 5.00 Volts, 3.00 Amps (op) 2:variable_supply; variable: 5.00 to 20.00 Volts, 3.25 Amps (op) 3:battery; battery: 5.00 to 20.00 Volts, 65.00 Watts (op)

pd2: source-capabilities:

Quoted 8 lines
Quoted 5 lines

1:fixed_supply; fixed: 5.00 Volts, 3.00 Amps (max) 2:fixed_supply; fixed: 9.00 Volts, 3.00 Amps (max) 3:fixed_supply; fixed: 12.00 Volts, 3.00 Amps (max) 4:fixed_supply; fixed: 15.00 Volts, 3.00 Amps (max) 5:fixed_supply; fixed: 20.00 Volts, 3.00 Amps (max)

pd2: has NO sink-capabilities
pd3: has NO source-capabilities
pd3: has NO sink-capabilities

$ lsucpd -ll
 port0 [pd0]  ====>>  partner [pd3]
 port1 [pd1]  <<====  partner [pd2]
Quoted 1 line

port0 [pd0]:

      data_role='[host] device'
      power_operation_mode='usb_power_delivery'
      power_role='[source] sink'
      preferred_role=''
      supported_accessory_modes='none'
      usb_power_delivery_revision='2.0'
      usb_typec_revision='1.0'
      vconn_source='no'
      waiting_for_supplier='0'
   port0-partner  [pd3]:
      accessory_mode='none'
      number_of_alternate_modes='1'
      supports_usb_power_delivery='yes'
      usb_power_delivery_revision='0.0'
      Alternate mode: /sys/class/typec/port0-partner/port0-partner.0
        active='yes'
        description='DisplayPort'
        mode='1'
        svid='ff01'
        vdo='0x00001085'
Quoted 1 line

port1 [pd1]:

      data_role='host [device]'
      power_operation_mode='usb_power_delivery'
      power_role='source [sink]'
      preferred_role=''
      supported_accessory_modes='none'
      usb_power_delivery_revision='2.0'
      usb_typec_revision='1.0'
      vconn_source='no'
      waiting_for_supplier='0'
   port1-partner  [pd2]:
      accessory_mode='none'
      supports_usb_power_delivery='yes'
      usb_power_delivery_revision='0.0'

Note: not all that output is believable (e.g. '0.00 Volts, 7.21 Amps (max)') so some common sense is required interpreting the output from lsucpd .

maintainer
#1 lore raw
Quoted 12 lines · Douglas Gilbert

lsucpd is a command line utility for listing USB Type-C ports, partners and any associated PD objects. It is essentially data-mining the /sys/class/typec and /sys/class/usb_power_delivery directories. So lsucpd performs no magic and root permissions are not required.

lsucpd was originally announced in this post on 28 August 2023:
https://marc.info/?l=linux-usb&m=169325926403279&w=2
That code has been tagged as 'r0.89'. There is also a 'r0.90' tag but it was not announced. This release is tagged as 'r0.91'. The code is available at this git mirror at:
https://github.com/doug-gilbert/lsucpd

Quoted 5 lines

Changelog since 0.89 [20230827] [svn: r9]
- add the first stage of JSON support
- add --pdo-snk= and --pdo-src= options to decode PDOs
- add --rdo= option to decode RDOs
- make preparations for PD revision 3.2

Nice! Any thoughts about adding this functionality to the usbutils package to make it all in one place?

thanks,

greg k-h

#2 lore raw
Quoted 13 lines · Greg KH
Quoted 12 lines · Douglas Gilbert

lsucpd is a command line utility for listing USB Type-C ports, partners and any associated PD objects. It is essentially data-mining the /sys/class/typec and /sys/class/usb_power_delivery directories. So lsucpd performs no magic and root permissions are not required.

lsucpd was originally announced in this post on 28 August 2023:

   https://marc.info/?l=linux-usb&m=169325926403279&w=2

That code has been tagged as 'r0.89'. There is also a 'r0.90' tag but it was not announced. This release is tagged as 'r0.91'. The code is available at this git mirror at:
https://github.com/doug-gilbert/lsucpd

Quoted 8 lines
Quoted 5 lines

Changelog since 0.89 [20230827] [svn: r9]
- add the first stage of JSON support
- add --pdo-snk= and --pdo-src= options to decode PDOs
- add --rdo= option to decode RDOs
- make preparations for PD revision 3.2

Nice! Any thoughts about adding this functionality to the usbutils package to make it all in one place?

Well that should be a medium term goal. However currently the environment in which lsucpd works is far from ideal.

The main problem is the dubious nature of some of the information provided (via UCSI_ACPI in my case). For my Thinkpad X13 Gen3 either Intel or Lenovo have screwed up but since that design is 18 months old my guess is those companies won't do anything about it, only fixing serious security issues. Maybe they will fix UCSI_ACPI properly in future models. Some other recent laptops I have tested (less than 12 months old) don't support UCSI_ACPI at all. Also the design of /sys/class/power_supply isn't a good fit for USB PD. Not sure how that could be solved. Heikki sounded off about design issues in:
https://marc.info/?l=linux-usb&m=169278141600478&w=2
Maybe USB PD needs its own power_supply class or at least a class that is higher level than class/typec and class/usb-power_delivery.

A secondary problem is that I chose to implement lsucpd in C++20 and later found out that g++ and clang were bending the truth when they said they supported C++20. std::print is one area of non-compliance. Hopefully this will improve in time for the next LTS cycle of major distributions.

Doug Gilbert

#3 lore raw
In reply to Douglas Gilbert

Hi Douglas,

Am Freitag, 8. Dezember 2023, 07:36:02 CET schrieb Douglas Gilbert:

Quoted 11 lines

lsucpd is a command line utility for listing USB Type-C ports, partners and any associated PD objects. It is essentially data-mining the /sys/class/typec and /sys/class/usb_power_delivery directories. So lsucpd performs no magic and root permissions are not required.

lsucpd was originally announced in this post on 28 August 2023:

   https://marc.info/?l=linux-usb&m=169325926403279&w=2

That code has been tagged as 'r0.89'. There is also a 'r0.90' tag but it was not announced. This release is tagged as 'r0.91'. The code is available at this git mirror at:
https://github.com/doug-gilbert/lsucpd

What is the actual license? There is LICENSE (BSP-2-Clause) and COPYING (GPL-2.0-or-later).

Thanks
Alexander

Quoted 121 lines

Changelog since 0.89 [20230827] [svn: r9]
- add the first stage of JSON support
- add --pdo-snk= and --pdo-src= options to decode PDOs
- add --rdo= option to decode RDOs
- make preparations for PD revision 3.2

The last one is a bit optimistic as the kernel PD stack can't yet handle the additions in PD 3.1 (e.g. fixed 28, 36 and 48 Volts, plus AVS from 15 to 48 Volts). Recently PD 3.1 dropped all support for 3.3 to < 5 Volts. PD 3.2 splits AVS (Adjustable Voltage Supply) into SPR (Standard Power Range [<= 21 Volts]) and EPR (Extended ...) variants. SPR AVS is the new one going from 9 to 20 Volts. What is the difference between AVS and PPS (Programmable PS)? Answer: PPS does current limiting, AVS doesn't ***.

Note: USB TypeC/PD standards have been in place for almost 10 years and now almost all new mobile devices use TypeC/PD . However visibility of TypeC/PD to host operating systems is relatively new and immature. Previously mobile devices handled TypeC/PD in their BIOS or Embedded Controllers and left the host OS "in the dark".
Please keep this in mind if reporting issues.

Here is a debian binary package built on Ubuntu 23.10 :

     https://doug-gilbert.github.io/p/lsucpd_0.91-0.1_amd64.deb

Here is a rpm built on Fedora 39 :

     https://doug-gilbert.github.io/p/lsucpd-0.91-1.x86_64.rpm

Doug Gilbert

*** "current limiting" as defined by PPS. AVS (and PPS) still does
OCP (Over Current Protection) but that is pretty brutal (i.e. the source removes power for a few hundred milliseconds to let the sink cool off)

Examples from a Thinkpad X13 Gen 3, U 23.10 lk 6.7.0-rc1
[port0-partner: is an alternate mode DP dongle,
port1-partner: is a PD power adapter (source)]

$ lsucpd
  port0 [pd0]  ====>>  partner [pd3]
  port1 [pd1]  <<====  partner [pd2]
$ lsucpd -c
  port0 [pd0]  ====>>  partner [pd3]
  port1 [pd1]  <<====  partner [pd2]
Quoted 22 lines

pd0: has NO source-capabilities

pd0: sink-capabilities:

Quoted 3 lines

1:fixed_supply; fixed: 5.00 Volts, 3.00 Amps (op) 2:variable_supply; variable: 5.00 to 20.00 Volts, 3.25 Amps (op) 3:battery; battery: 5.00 to 20.00 Volts, 65.00 Watts (op)

pd1: source-capabilities:

Quoted 1 line

1:fixed_supply; fixed: 0.00 Volts, 7.21 Amps (max)

pd1: sink-capabilities:

Quoted 3 lines

1:fixed_supply; fixed: 5.00 Volts, 3.00 Amps (op) 2:variable_supply; variable: 5.00 to 20.00 Volts, 3.25 Amps (op) 3:battery; battery: 5.00 to 20.00 Volts, 65.00 Watts (op)

pd2: source-capabilities:

Quoted 5 lines

1:fixed_supply; fixed: 5.00 Volts, 3.00 Amps (max) 2:fixed_supply; fixed: 9.00 Volts, 3.00 Amps (max) 3:fixed_supply; fixed: 12.00 Volts, 3.00 Amps (max) 4:fixed_supply; fixed: 15.00 Volts, 3.00 Amps (max) 5:fixed_supply; fixed: 20.00 Volts, 3.00 Amps (max)

Quoted 5 lines

pd2: has NO sink-capabilities

pd3: has NO source-capabilities

pd3: has NO sink-capabilities

$ lsucpd -ll
  port0 [pd0]  ====>>  partner [pd3]
  port1 [pd1]  <<====  partner [pd2]
Quoted 1 line

port0 [pd0]:

       data_role='[host] device'
       power_operation_mode='usb_power_delivery'
       power_role='[source] sink'
       preferred_role=''
       supported_accessory_modes='none'
       usb_power_delivery_revision='2.0'
       usb_typec_revision='1.0'
       vconn_source='no'
       waiting_for_supplier='0'
    port0-partner  [pd3]:
       accessory_mode='none'
       number_of_alternate_modes='1'
       supports_usb_power_delivery='yes'
       usb_power_delivery_revision='0.0'
       Alternate mode: /sys/class/typec/port0-partner/port0-partner.0
         active='yes'
         description='DisplayPort'
         mode='1'
         svid='ff01'
         vdo='0x00001085'
Quoted 1 line

port1 [pd1]:

       data_role='host [device]'
       power_operation_mode='usb_power_delivery'
       power_role='source [sink]'
       preferred_role=''
       supported_accessory_modes='none'
       usb_power_delivery_revision='2.0'
       usb_typec_revision='1.0'
       vconn_source='no'
       waiting_for_supplier='0'
    port1-partner  [pd2]:
       accessory_mode='none'
       supports_usb_power_delivery='yes'
       usb_power_delivery_revision='0.0'

Note: not all that output is believable (e.g. '0.00 Volts, 7.21 Amps (max)') so some common sense is required interpreting the output from lsucpd .

Signature · 4 lines
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
http://www.tq-group.com/
#4 lore raw
Quoted 15 lines · Alexander Stein

Hi Douglas,

Am Freitag, 8. Dezember 2023, 07:36:02 CET schrieb Douglas Gilbert:

Quoted 11 lines

lsucpd is a command line utility for listing USB Type-C ports, partners and any associated PD objects. It is essentially data-mining the /sys/class/typec and /sys/class/usb_power_delivery directories. So lsucpd performs no magic and root permissions are not required.

lsucpd was originally announced in this post on 28 August 2023:

    https://marc.info/?l=linux-usb&m=169325926403279&w=2

That code has been tagged as 'r0.89'. There is also a 'r0.90' tag but it was not announced. This release is tagged as 'r0.91'. The code is available at this git mirror at:
https://github.com/doug-gilbert/lsucpd

Quoted 2 lines

What is the actual license? There is LICENSE (BSP-2-Clause) and COPYING (GPL-2.0-or-later).

Yes, it was a mess. There are license entries all over the place (e.g. source files, manpages, rpm spec files and debian/copyright). My intention was to have a BSP-2-Clause license.

Put up new commit on github to align as many locations as I could find to BSP-2-Clause license.

Thanks for pointing out the inconsistency, cleaned up some of my other packages that had a similar issue.

Doug Gilbert

<snip>