#
5e203df4 |
|
14-Mar-2017 |
Mike Voydanoff <voydanoff@google.com> |
[usb] Add beginnings of USB peripheral mode support This change adds three new DDK protocols for USB peripheral support: - MX_PROTOCOL_USB_DCI The DCI stands for "device controller interface". This protocol is implemented by drivers for the actual USB controller hardware. It is analogous to the MX_PROTOCOL_USB_HCI protocol for the host controller drivers. - MX_PROTOCOL_USB_DEVICE This is the protocol for the "usb-device" driver, which is the platform independent layer to the USB peripheral stack. This protocol provides ioctls for configuring how the USB peripheral controller appears to the host. It supports ioctls for setting the USB device, configuration and string descriptors that the host sees. The "usb-device" driver creates devmgr devices with protocol MX_PROTOCOL_USB_FUNCTION for each interface in the configuration descriptor. - MX_PROTOCOL_USB_FUNCTION This protocol is what various USB function drivers will bind to. A USB function driver implements a specific piece of functionality corresponding to a USB interface. For example, a USB HID function driver would allow the Magenta device to appear as a HID device to the USB host it is connected to. This change also adds: - The "usb-device" driver, which binds to MX_PROTOCOL_USB_DCI and creates child devices with protocol MX_PROTOCOL_USB_FUNCTION based on the USB configuration descriptor set via ioctl_usb_device_set_config_desc() - The "usb-function-test" driver. This driver doesn't do anything yet, but it implements the MX_PROTOCOL_USB_FUNCTION protocol and will be flushed out to do loop back testing for USB peripheral mode. - The "usb-virtual-bus" driver. This driver creates a virtual USB host controller and device controller and proxies USB transactions between the two sides. This allows testing of the USB peripheral stack on devices without actual USB peripheral controller hardware. - The "usbctl" command line tool. This can be used to enable or disable the USB virtual bus, simulate device connect and disconnect events on the virtual bus, and also initialize the USB device driver to use the "usb-function-test" function. To try this out, run: usbctl virtual enable usbctl device init-test usbctl virtual connect After that you should see a device corresponding to the usb-function-test function in the lsusb output. So far only USB control requests have been tested. There is plumbing in place for transfers on other endpoint types, but this hasn't been tested yet. Change-Id: I302c37246bb887060c3e7f4baa58da1f825e388b
|