Skip to content

Commit e10f9a4

Browse files
oneukumgregkh
authored andcommitted
USB: add descriptors from USB Power Delivery spec
Adding the descriptors of chapter 9.2 of the Power Delivery spec. Signed-off-by: Oliver Neukum <oneukum@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c3b46c7 commit e10f9a4

1 file changed

Lines changed: 98 additions & 0 deletions

File tree

  • include/uapi/linux/usb

‎include/uapi/linux/usb/ch9.h‎

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,104 @@ struct usb_ssp_cap_descriptor {
913913
#define USB_SSP_SUBLINK_SPEED_LSM (0xff << 16) /* Lanespeed mantissa */
914914
} __attribute__((packed));
915915

916+
/*
917+
* USB Power Delivery Capability Descriptor:
918+
* Defines capabilities for PD
919+
*/
920+
/* Defines the various PD Capabilities of this device */
921+
#define USB_PD_POWER_DELIVERY_CAPABILITY 0x06
922+
/* Provides information on each battery supported by the device */
923+
#define USB_PD_BATTERY_INFO_CAPABILITY 0x07
924+
/* The Consumer characteristics of a Port on the device */
925+
#define USB_PD_PD_CONSUMER_PORT_CAPABILITY 0x08
926+
/* The provider characteristics of a Port on the device */
927+
#define USB_PD_PD_PROVIDER_PORT_CAPABILITY 0x09
928+
929+
struct usb_pd_cap_descriptor {
930+
__u8 bLength;
931+
__u8 bDescriptorType;
932+
__u8 bDevCapabilityType; /* set to USB_PD_POWER_DELIVERY_CAPABILITY */
933+
__u8 bReserved;
934+
__le32 bmAttributes;
935+
#define USB_PD_CAP_BATTERY_CHARGING (1 << 1) /* supports Battery Charging specification */
936+
#define USB_PD_CAP_USB_PD (1 << 2) /* supports USB Power Delivery specification */
937+
#define USB_PD_CAP_PROVIDER (1 << 3) /* can provide power */
938+
#define USB_PD_CAP_CONSUMER (1 << 4) /* can consume power */
939+
#define USB_PD_CAP_CHARGING_POLICY (1 << 5) /* supports CHARGING_POLICY feature */
940+
#define USB_PD_CAP_TYPE_C_CURRENT (1 << 6) /* supports power capabilities defined in the USB Type-C Specification */
941+
942+
#define USB_PD_CAP_PWR_AC (1 << 8)
943+
#define USB_PD_CAP_PWR_BAT (1 << 9)
944+
#define USB_PD_CAP_PWR_USE_V_BUS (1 << 14)
945+
946+
__le16 bmProviderPorts; /* Bit zero refers to the UFP of the device */
947+
__le16 bmConsumerPorts;
948+
__le16 bcdBCVersion;
949+
__le16 bcdPDVersion;
950+
__le16 bcdUSBTypeCVersion;
951+
} __attribute__((packed));
952+
953+
struct usb_pd_cap_battery_info_descriptor {
954+
__u8 bLength;
955+
__u8 bDescriptorType;
956+
__u8 bDevCapabilityType;
957+
/* Index of string descriptor shall contain the user friendly name for this battery */
958+
__u8 iBattery;
959+
/* Index of string descriptor shall contain the Serial Number String for this battery */
960+
__u8 iSerial;
961+
__u8 iManufacturer;
962+
__u8 bBatteryId; /* uniquely identifies this battery in status Messages */
963+
__u8 bReserved;
964+
/*
965+
* Shall contain the Battery Charge value above which this
966+
* battery is considered to be fully charged but not necessarily
967+
* “topped off.”
968+
*/
969+
__le32 dwChargedThreshold; /* in mWh */
970+
/*
971+
* Shall contain the minimum charge level of this battery such
972+
* that above this threshold, a device can be assured of being
973+
* able to power up successfully (see Battery Charging 1.2).
974+
*/
975+
__le32 dwWeakThreshold; /* in mWh */
976+
__le32 dwBatteryDesignCapacity; /* in mWh */
977+
__le32 dwBatteryLastFullchargeCapacity; /* in mWh */
978+
} __attribute__((packed));
979+
980+
struct usb_pd_cap_consumer_port_descriptor {
981+
__u8 bLength;
982+
__u8 bDescriptorType;
983+
__u8 bDevCapabilityType;
984+
__u8 bReserved;
985+
__u8 bmCapabilities;
986+
/* port will oerate under: */
987+
#define USB_PD_CAP_CONSUMER_BC (1 << 0) /* BC */
988+
#define USB_PD_CAP_CONSUMER_PD (1 << 1) /* PD */
989+
#define USB_PD_CAP_CONSUMER_TYPE_C (1 << 2) /* USB Type-C Current */
990+
__le16 wMinVoltage; /* in 50mV units */
991+
__le16 wMaxVoltage; /* in 50mV units */
992+
__u16 wReserved;
993+
__le32 dwMaxOperatingPower; /* in 10 mW - operating at steady state */
994+
__le32 dwMaxPeakPower; /* in 10mW units - operating at peak power */
995+
__le32 dwMaxPeakPowerTime; /* in 100ms units - duration of peak */
996+
#define USB_PD_CAP_CONSUMER_UNKNOWN_PEAK_POWER_TIME 0xffff
997+
} __attribute__((packed));
998+
999+
struct usb_pd_cap_provider_port_descriptor {
1000+
__u8 bLength;
1001+
__u8 bDescriptorType;
1002+
__u8 bDevCapabilityType;
1003+
__u8 bReserved1;
1004+
__u8 bmCapabilities;
1005+
/* port will oerate under: */
1006+
#define USB_PD_CAP_PROVIDER_BC (1 << 0) /* BC */
1007+
#define USB_PD_CAP_PROVIDER_PD (1 << 1) /* PD */
1008+
#define USB_PD_CAP_PROVIDER_TYPE_C (1 << 2) /* USB Type-C Current */
1009+
__u8 bNumOfPDObjects;
1010+
__u8 bReserved2;
1011+
__le32 wPowerDataObject[];
1012+
} __attribute__((packed));
1013+
9161014
/*
9171015
* Precision time measurement capability descriptor: advertised by devices and
9181016
* hubs that support PTM

0 commit comments

Comments
 (0)