Re: [RFC Patch 1/3] USB: add descriptors from USB Power Delivery spec
Hello. On 3/10/2016 1:32 PM, Oliver Neukum wrote: Adding the descriptors of chapter 9.2 of the Power Delivery spec. Signed-off-by: Oliver Neukum--- include/uapi/linux/usb/ch9.h | 94 1 file changed, 94 insertions(+) diff --git a/include/uapi/linux/usb/ch9.h b/include/uapi/linux/usb/ch9.h index 252ac16..c9f2bc2 100644 --- a/include/uapi/linux/usb/ch9.h +++ b/include/uapi/linux/usb/ch9.h @@ -913,6 +913,100 @@ struct usb_ssp_cap_descriptor { } __attribute__((packed)); /* + * USB Power Delivery Capability Descriptor: + * Defines capabilities for PD + */ +#define USB_PD_POWER_DELIVERY_CAPABILITY (0x06) /* Defines the various PD Capabilities of this device */ +#define USB_PD_BATTERY_INFO_CAPABILITY (0x07) /* Provides information on each battery supported by the device */ +#define USB_PD_PD_CONSUMER_PORT_CAPABILITY (0x08) /* The Consumer characteristics of a Port on the device */ +#define USB_PD_PD_PROVIDER_PORT_CAPABILITY (0x09) /* The provider characteristics of a Port on the device */ Parens not needed. + +struct usb_pd_cap_descriptor { + __u8 bLength; + __u8 bDescriptorType; + __u8 bDevCapabilityType; /* set to USB_PD_POWER_DELIVERY_CAPABILITY */ + __u8 bReserved; + __le32 bmAttributes; +#define uSB_PD_CAP_BATTERY_CHARGING( 1 << 1 ) /* supports Battery Charging specification */ +#define uSB_PD_CAP_USB_PD ( 1 << 2 ) /* supports USB Power Delivery specification */ +#define uSB_PD_CAP_PROVIDER( 1 << 3 ) /* can provide power */ +#define uSB_PD_CAP_CONSUMER( 1 << 4 ) /* can consume power */ +#define uSB_PD_CAP_CHARGING_POLICY ( 1 << 5 ) /* supports CHARGING_POLICY feature */ +#define uSB_PD_CAP_TYPE_C_CURRENT ( 1 << 6 ) /* supports power capabilities defined in the USB Type-C Specification */ + +#define uSB_PD_CAP_PWR_AC ( 1 << 8 ) +#define uSB_PD_CAP_PWR_BAT ( 1 << 9 ) +#define uSB_PD_CAP_PWR_USE_V_BUS ( 1 << 14 ) Remove spaces after ( and before ) please. [...] +struct usb_pd_cap_consumer_port_descriptor { + __u8 bLength; + __u8 bDescriptorType; + __u8 bDevCapabilityType; + __u8 bReserved; + __u8 bmCapabilities; +/* port will oerate under: */ +#define uSB_PD_CAP_CONSUMER_BC ( 1 << 0 ) /* BC */ +#define uSB_PD_CAP_CONSUMER_PD ( 1 << 1 ) /* PD */ +#define uSB_PD_CAP_CONSUMER_TYPE_C ( 1 << 2 ) /* USB Type-C Current */ Likewise. + __le16 wMinVoltage; /* in 50mV units */ + __le16 wMaxVoltage; /* in 50mV units */ + __u16 wReserved; + __le32 dwMaxOperatingPower; /* in 10 mW - operating at steady state */ + __le32 dwMaxPeakPower; /* in 10mW units - operating at peak power */ + __le32 dwMaxPeakPowerTime; /* in 100ms units - duration of peak */ +#define uSB_PD_CAP_CONSUMER_UNKNOWN_PEAK_POWER_TIME 0x +} __attribute__((packed)); + +struct usb_pd_cap_provider_port_descriptor { + __u8 bLength; + __u8 bDescriptorType; + __u8 bDevCapabilityType; + __u8 bReserved1; + __u8 bmCapabilities; +/* port will oerate under: */ +#define uSB_PD_CAP_PROVIDER_BC ( 1 << 0 ) /* BC */ +#define uSB_PD_CAP_PROVIDER_PD ( 1 << 1 ) /* PD */ +#define uSB_PD_CAP_PROVIDER_TYPE_C ( 1 << 2 ) /* USB Type-C Current */ Likewise. [...] MBR, Sergei -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC Patch 1/3] USB: add descriptors from USB Power Delivery spec
Hi, On Thu, Mar 10, 2016 at 12:45 PM, Felipe Balbiwrote: > > Hi, > > Oliver Neukum writes: >> [ text/plain ] >> Adding the descriptors of chapter 9.2 of the Power Delivery spec. >> >> Signed-off-by: Oliver Neukum >> --- >> include/uapi/linux/usb/ch9.h | 94 >> >> 1 file changed, 94 insertions(+) >> >> diff --git a/include/uapi/linux/usb/ch9.h b/include/uapi/linux/usb/ch9.h >> index 252ac16..c9f2bc2 100644 >> --- a/include/uapi/linux/usb/ch9.h >> +++ b/include/uapi/linux/usb/ch9.h >> @@ -913,6 +913,100 @@ struct usb_ssp_cap_descriptor { >> } __attribute__((packed)); >> >> /* >> + * USB Power Delivery Capability Descriptor: >> + * Defines capabilities for PD >> + */ >> +#define USB_PD_POWER_DELIVERY_CAPABILITY (0x06) /* Defines the various >> PD Capabilities of this device */ >> +#define USB_PD_BATTERY_INFO_CAPABILITY (0x07) /* Provides >> information on each battery supported by the device */ >> +#define USB_PD_PD_CONSUMER_PORT_CAPABILITY (0x08) /* The Consumer >> characteristics of a Port on the device */ >> +#define USB_PD_PD_PROVIDER_PORT_CAPABILITY (0x09) /* The provider >> characteristics of a Port on the device */ > > any chance you can avoid the extra long lines ? > >> +struct usb_pd_cap_descriptor { >> + __u8 bLength; >> + __u8 bDescriptorType; >> + __u8 bDevCapabilityType; /* set to USB_PD_POWER_DELIVERY_CAPABILITY */ >> + __u8 bReserved; >> + __le32 bmAttributes; >> +#define uSB_PD_CAP_BATTERY_CHARGING ( 1 << 1 ) /* supports Battery >> Charging specification */ >> +#define uSB_PD_CAP_USB_PD( 1 << 2 ) /* supports USB Power >> Delivery specification */ >> +#define uSB_PD_CAP_PROVIDER ( 1 << 3 ) /* can provide power */ >> +#define uSB_PD_CAP_CONSUMER ( 1 << 4 ) /* can consume power */ >> +#define uSB_PD_CAP_CHARGING_POLICY ( 1 << 5 ) /* supports CHARGING_POLICY >> feature */ >> +#define uSB_PD_CAP_TYPE_C_CURRENT( 1 << 6 ) /* supports power >> capabilities defined in the USB Type-C Specification */ >> + >> +#define uSB_PD_CAP_PWR_AC( 1 << 8 ) >> +#define uSB_PD_CAP_PWR_BAT ( 1 << 9 ) >> +#define uSB_PD_CAP_PWR_USE_V_BUS ( 1 << 14 ) > > why the extra spaces inside () ? Also it's not clear why these macro start with lowercase letter (e.g. why uSB_XXX instead of USB_XXX), looks like a typo. > > -- > balbi -- Best regards, Ruslan -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC Patch 1/3] USB: add descriptors from USB Power Delivery spec
Hi, Oliver Neukumwrites: > [ text/plain ] > Adding the descriptors of chapter 9.2 of the Power Delivery spec. > > Signed-off-by: Oliver Neukum > --- > include/uapi/linux/usb/ch9.h | 94 > > 1 file changed, 94 insertions(+) > > diff --git a/include/uapi/linux/usb/ch9.h b/include/uapi/linux/usb/ch9.h > index 252ac16..c9f2bc2 100644 > --- a/include/uapi/linux/usb/ch9.h > +++ b/include/uapi/linux/usb/ch9.h > @@ -913,6 +913,100 @@ struct usb_ssp_cap_descriptor { > } __attribute__((packed)); > > /* > + * USB Power Delivery Capability Descriptor: > + * Defines capabilities for PD > + */ > +#define USB_PD_POWER_DELIVERY_CAPABILITY (0x06) /* Defines the various > PD Capabilities of this device */ > +#define USB_PD_BATTERY_INFO_CAPABILITY (0x07) /* Provides > information on each battery supported by the device */ > +#define USB_PD_PD_CONSUMER_PORT_CAPABILITY (0x08) /* The Consumer > characteristics of a Port on the device */ > +#define USB_PD_PD_PROVIDER_PORT_CAPABILITY (0x09) /* The provider > characteristics of a Port on the device */ any chance you can avoid the extra long lines ? > +struct usb_pd_cap_descriptor { > + __u8 bLength; > + __u8 bDescriptorType; > + __u8 bDevCapabilityType; /* set to USB_PD_POWER_DELIVERY_CAPABILITY */ > + __u8 bReserved; > + __le32 bmAttributes; > +#define uSB_PD_CAP_BATTERY_CHARGING ( 1 << 1 ) /* supports Battery Charging > specification */ > +#define uSB_PD_CAP_USB_PD( 1 << 2 ) /* supports USB Power > Delivery specification */ > +#define uSB_PD_CAP_PROVIDER ( 1 << 3 ) /* can provide power */ > +#define uSB_PD_CAP_CONSUMER ( 1 << 4 ) /* can consume power */ > +#define uSB_PD_CAP_CHARGING_POLICY ( 1 << 5 ) /* supports CHARGING_POLICY > feature */ > +#define uSB_PD_CAP_TYPE_C_CURRENT( 1 << 6 ) /* supports power > capabilities defined in the USB Type-C Specification */ > + > +#define uSB_PD_CAP_PWR_AC( 1 << 8 ) > +#define uSB_PD_CAP_PWR_BAT ( 1 << 9 ) > +#define uSB_PD_CAP_PWR_USE_V_BUS ( 1 << 14 ) why the extra spaces inside () ? -- balbi signature.asc Description: PGP signature
[RFC Patch 1/3] 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--- include/uapi/linux/usb/ch9.h | 94 1 file changed, 94 insertions(+) diff --git a/include/uapi/linux/usb/ch9.h b/include/uapi/linux/usb/ch9.h index 252ac16..c9f2bc2 100644 --- a/include/uapi/linux/usb/ch9.h +++ b/include/uapi/linux/usb/ch9.h @@ -913,6 +913,100 @@ struct usb_ssp_cap_descriptor { } __attribute__((packed)); /* + * USB Power Delivery Capability Descriptor: + * Defines capabilities for PD + */ +#define USB_PD_POWER_DELIVERY_CAPABILITY (0x06) /* Defines the various PD Capabilities of this device */ +#define USB_PD_BATTERY_INFO_CAPABILITY (0x07) /* Provides information on each battery supported by the device */ +#define USB_PD_PD_CONSUMER_PORT_CAPABILITY (0x08) /* The Consumer characteristics of a Port on the device */ +#define USB_PD_PD_PROVIDER_PORT_CAPABILITY (0x09) /* The provider characteristics of a Port on the device */ + +struct usb_pd_cap_descriptor { + __u8 bLength; + __u8 bDescriptorType; + __u8 bDevCapabilityType; /* set to USB_PD_POWER_DELIVERY_CAPABILITY */ + __u8 bReserved; + __le32 bmAttributes; +#define uSB_PD_CAP_BATTERY_CHARGING( 1 << 1 ) /* supports Battery Charging specification */ +#define uSB_PD_CAP_USB_PD ( 1 << 2 ) /* supports USB Power Delivery specification */ +#define uSB_PD_CAP_PROVIDER( 1 << 3 ) /* can provide power */ +#define uSB_PD_CAP_CONSUMER( 1 << 4 ) /* can consume power */ +#define uSB_PD_CAP_CHARGING_POLICY ( 1 << 5 ) /* supports CHARGING_POLICY feature */ +#define uSB_PD_CAP_TYPE_C_CURRENT ( 1 << 6 ) /* supports power capabilities defined in the USB Type-C Specification */ + +#define uSB_PD_CAP_PWR_AC ( 1 << 8 ) +#define uSB_PD_CAP_PWR_BAT ( 1 << 9 ) +#define uSB_PD_CAP_PWR_USE_V_BUS ( 1 << 14 ) + + __le16 bmProviderPorts; /* Bit zero refers to the UFP of the device */ + __le16 bmConsumerPorts; + __le16 bcdBCVersion; + __le16 bcdPDVersion; + __le16 bcdUSBTypeCVersion; +} __attribute__((packed)); + +struct usb_pd_cap_battery_info_descriptor { + __u8 bLength; + __u8 bDescriptorType; + __u8 bDevCapabilityType; + /* Index of string descriptor shall contain the user friendly name for this battery */ + __u8 iBattery; + /* Index of string descriptor shall contain the Serial Number String for this battery */ + __u8 iSerial; + __u8 iManufacturer; + __u8 bBatteryId; /* uniquely identifies this battery in status Messages */ + __u8 bReserved; + /* +* Shall contain the Battery Charge value above which this +* battery is considered to be fully charged but not necessarily +* “topped off.” +*/ + __le32 dwChargedThreshold; /* in mWh */ + /* +* Shall contain the minimum charge level of this battery such +* that above this threshold, a device can be assured of being +* able to power up successfully (see Battery Charging 1.2). +*/ + __le32 dwWeakThreshold; /* in mWh */ + __le32 dwBatteryDesignCapacity; /* in mWh */ + __le32 dwBatteryLastFullchargeCapacity; /* in mWh */ +} __attribute__((packed)); + +struct usb_pd_cap_consumer_port_descriptor { + __u8 bLength; + __u8 bDescriptorType; + __u8 bDevCapabilityType; + __u8 bReserved; + __u8 bmCapabilities; +/* port will oerate under: */ +#define uSB_PD_CAP_CONSUMER_BC ( 1 << 0 ) /* BC */ +#define uSB_PD_CAP_CONSUMER_PD ( 1 << 1 ) /* PD */ +#define uSB_PD_CAP_CONSUMER_TYPE_C ( 1 << 2 ) /* USB Type-C Current */ + __le16 wMinVoltage; /* in 50mV units */ + __le16 wMaxVoltage; /* in 50mV units */ + __u16 wReserved; + __le32 dwMaxOperatingPower; /* in 10 mW - operating at steady state */ + __le32 dwMaxPeakPower; /* in 10mW units - operating at peak power */ + __le32 dwMaxPeakPowerTime; /* in 100ms units - duration of peak */ +#define uSB_PD_CAP_CONSUMER_UNKNOWN_PEAK_POWER_TIME 0x +} __attribute__((packed)); + +struct usb_pd_cap_provider_port_descriptor { + __u8 bLength; + __u8 bDescriptorType; + __u8 bDevCapabilityType; + __u8 bReserved1; + __u8 bmCapabilities; +/* port will oerate under: */ +#define uSB_PD_CAP_PROVIDER_BC ( 1 << 0 ) /* BC */ +#define uSB_PD_CAP_PROVIDER_PD ( 1 << 1 ) /* PD */ +#define uSB_PD_CAP_PROVIDER_TYPE_C ( 1 << 2 ) /* USB Type-C Current */ + __u8 bNumOfPDObjects; + __u8 bReserved2; + __le32 wPowerDataObject[]; +} __attribute__((packed)); + +/* * Precision time measurement capability descriptor: advertised by devices and * hubs that support PTM */ -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message