1 /* 2 * Copyright (c) 2020-2021 Huawei Device Co., Ltd. 3 * 4 * HDF is dual licensed: you can use it either under the terms of 5 * the GPL, or the BSD license, at your option. 6 * See the LICENSE file in the root of this repository for complete details. 7 */ 8 9 #ifndef HDF_USB_PNP_MANAGE_H 10 #define HDF_USB_PNP_MANAGE_H 11 12 #include "hdf_base.h" 13 14 #define USB_PNP_NOTIFY_TEST_MODE false 15 #define USB_PNP_INFO_MAX_INTERFACES 32 16 17 enum UsbPnpNotifyServiceCmd { 18 USB_PNP_NOTIFY_ADD_INTERFACE, 19 USB_PNP_NOTIFY_REMOVE_INTERFACE, 20 USB_PNP_NOTIFY_REPORT_INTERFACE, 21 USB_PNP_NOTIFY_ADD_DEVICE, 22 USB_PNP_NOTIFY_REMOVE_DEVICE, 23 #if USB_PNP_NOTIFY_TEST_MODE == true 24 USB_PNP_NOTIFY_ADD_TEST, 25 USB_PNP_NOTIFY_REMOVE_TEST, 26 #endif 27 USB_PNP_DRIVER_REGISTER_DEVICE, 28 USB_PNP_DRIVER_UNREGISTER_DEVICE, 29 USB_PNP_DRIVER_GETDEVICES = 20, 30 USB_PNP_DRIVER_GADGET_ADD = 30, 31 USB_PNP_DRIVER_GADGET_REMOVE, 32 USB_PNP_DRIVER_PORT_HOST = 40, 33 USB_PNP_DRIVER_PORT_DEVICE, 34 USB_PNP_DRIVER_GET_GADGET_LINK_STATUS, 35 }; 36 37 enum UsbPnpNotifyRemoveType { 38 USB_PNP_NOTIFY_REMOVE_BUS_DEV_NUM, 39 USB_PNP_NOTIFY_REMOVE_INTERFACE_NUM, 40 }; 41 42 enum { 43 USB_PNP_NOTIFY_MATCH_VENDOR = 0x0001, 44 USB_PNP_NOTIFY_MATCH_PRODUCT = 0x0002, 45 USB_PNP_NOTIFY_MATCH_DEV_LOW = 0x0004, 46 USB_PNP_NOTIFY_MATCH_DEV_HIGH = 0x0008, 47 USB_PNP_NOTIFY_MATCH_DEV_CLASS = 0x0010, 48 USB_PNP_NOTIFY_MATCH_DEV_SUBCLASS = 0x0020, 49 USB_PNP_NOTIFY_MATCH_DEV_PROTOCOL = 0x0040, 50 USB_PNP_NOTIFY_MATCH_INT_CLASS = 0x0080, 51 USB_PNP_NOTIFY_MATCH_INT_SUBCLASS = 0x0100, 52 USB_PNP_NOTIFY_MATCH_INT_PROTOCOL = 0x0200, 53 USB_PNP_NOTIFY_MATCH_INT_NUMBER = 0x0400, 54 }; 55 56 struct UsbPnpNotifyServiceInfo { 57 uint32_t length; 58 59 int32_t devNum; 60 int32_t busNum; 61 62 int32_t interfaceLength; 63 uint8_t interfaceNumber[USB_PNP_INFO_MAX_INTERFACES]; 64 } __attribute__ ((packed)); 65 66 struct UsbPnpNotifyInterfaceInfo { 67 uint8_t interfaceClass; 68 uint8_t interfaceSubClass; 69 uint8_t interfaceProtocol; 70 71 uint8_t interfaceNumber; 72 }; 73 74 struct UsbPnpNotifyDeviceInfo { 75 uint16_t vendorId; 76 uint16_t productId; 77 78 uint16_t bcdDeviceLow; 79 uint16_t bcdDeviceHigh; 80 81 uint8_t deviceClass; 82 uint8_t deviceSubClass; 83 uint8_t deviceProtocol; 84 }; 85 86 struct UsbPnpNotifyMatchInfoTable { 87 uint64_t usbDevAddr; 88 int32_t devNum; 89 int32_t busNum; 90 91 struct UsbPnpNotifyDeviceInfo deviceInfo; 92 93 uint8_t removeType; 94 uint8_t numInfos; 95 96 struct UsbPnpNotifyInterfaceInfo interfaceInfo[USB_PNP_INFO_MAX_INTERFACES]; 97 }; 98 99 struct UsbPnpAddRemoveInfo { 100 int32_t devNum; 101 int32_t busNum; 102 uint8_t interfaceNumber; 103 uint8_t interfaceClass; 104 uint8_t interfaceSubClass; 105 uint8_t interfaceProtocol; 106 }; 107 108 #endif /* HDF_USB_PNP_MANAGE_H */ 109