USB Type-C, how is the direction of power delivery controlled?

In Linux you can control the direction of power on a given port by writing "source" or "sink" to the appropriate sysfs control, eg.:

# echo source >/sys/class/typec/port0/power_role
# cat /sys/class/typec/port0/power_role
[source] sink

The term in bracket indicates how is power currently flowing. See the kernel documentation see: https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-typec

Of course all of this works only if the device connected to the USB Type-C port supports Power Delivery. So it won't work with a typical Type-C power adapter or most Type-C portable batteries as they rarely support PD as of 2019.


USB type C connected together, then how is it decided which charges which?

This is all convoluted beyond comprehension so far. Type-C connector carries two roles

  1. data communication
  2. power delivery.

These are nearly independent functions. The entire functionality depends on whether

  1. both ports are USB hosts
  2. both ports are USB devices
  3. one port is Dual-role-Data and another is not
  4. one port is Dual-role-power

...

n. both ports are DRD and DRP,

I lost all permutations here. The UCSI is an attempt by Microsoft to tame this vast permutivity into API standard. For major ideas, see this presentation, and many more publications on "UCSI interface".

Tags:

Linux

Usb