public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
* [Announce] lsucpd release 0.91 utility for USB Type-C
@ 2023-12-08  6:36 Douglas Gilbert
  2023-12-08  7:16 ` Greg KH
  2023-12-11 15:07 ` Alexander Stein
  0 siblings, 2 replies; 5+ messages in thread
From: Douglas Gilbert @ 2023-12-08  6:36 UTC (permalink / raw)
  To: linux-usb

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]

 > pd0: has NO source-capabilities
 >  pd0: sink-capabilities:
    >> 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:
   >> 1:fixed_supply; fixed: 0.00 Volts, 7.21 Amps (max)
 >  pd1: sink-capabilities:
    >> 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:
   >> 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]

 > 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'
 > 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 .


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Announce] lsucpd release 0.91 utility for USB Type-C
  2023-12-08  6:36 [Announce] lsucpd release 0.91 utility for USB Type-C Douglas Gilbert
@ 2023-12-08  7:16 ` Greg KH
  2023-12-08 21:14   ` Douglas Gilbert
  2023-12-11 15:07 ` Alexander Stein
  1 sibling, 1 reply; 5+ messages in thread
From: Greg KH @ 2023-12-08  7:16 UTC (permalink / raw)
  To: Douglas Gilbert; +Cc: linux-usb

On Fri, Dec 08, 2023 at 01:36:02AM -0500, Douglas Gilbert wrote:
> 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

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

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Announce] lsucpd release 0.91 utility for USB Type-C
  2023-12-08  7:16 ` Greg KH
@ 2023-12-08 21:14   ` Douglas Gilbert
  0 siblings, 0 replies; 5+ messages in thread
From: Douglas Gilbert @ 2023-12-08 21:14 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-usb

On 12/8/23 02:16, Greg KH wrote:
> On Fri, Dec 08, 2023 at 01:36:02AM -0500, Douglas Gilbert wrote:
>> 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
> 
> 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




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Announce] lsucpd release 0.91 utility for USB Type-C
  2023-12-08  6:36 [Announce] lsucpd release 0.91 utility for USB Type-C Douglas Gilbert
  2023-12-08  7:16 ` Greg KH
@ 2023-12-11 15:07 ` Alexander Stein
  2023-12-12  5:44   ` Douglas Gilbert
  1 sibling, 1 reply; 5+ messages in thread
From: Alexander Stein @ 2023-12-11 15:07 UTC (permalink / raw)
  To: linux-usb, dgilbert

Hi Douglas,

Am Freitag, 8. Dezember 2023, 07:36:02 CET schrieb 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

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

Thanks
Alexander

> 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]
> 
>  > pd0: has NO source-capabilities
>  > 
>  >  pd0: sink-capabilities:
>     >> 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:
>    >> 1:fixed_supply; fixed: 0.00 Volts, 7.21 Amps (max)
>  >  
>  >  pd1: sink-capabilities:
>     >> 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:
>    >> 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]
> 
>  > 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'
> 
>  > 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 .


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



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Announce] lsucpd release 0.91 utility for USB Type-C
  2023-12-11 15:07 ` Alexander Stein
@ 2023-12-12  5:44   ` Douglas Gilbert
  0 siblings, 0 replies; 5+ messages in thread
From: Douglas Gilbert @ 2023-12-12  5:44 UTC (permalink / raw)
  To: Alexander Stein, linux-usb

On 12/11/23 10:07, Alexander Stein wrote:
> Hi Douglas,
> 
> Am Freitag, 8. Dezember 2023, 07:36:02 CET schrieb 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
> 
> 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>


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-12-12  5:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-08  6:36 [Announce] lsucpd release 0.91 utility for USB Type-C Douglas Gilbert
2023-12-08  7:16 ` Greg KH
2023-12-08 21:14   ` Douglas Gilbert
2023-12-11 15:07 ` Alexander Stein
2023-12-12  5:44   ` Douglas Gilbert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox