History log of /fuchsia/zircon/system/dev/usb/usb-bus/usb-bus.c
Revision Date Author Comments
# 1be83d34 12-Sep-2018 Mike Voydanoff <voydanoff@google.com>

[dev][usb-bus] Refactor usb-bus driver

Previously the usb-bus driver not only managed all USB devices for a USB controller
but also managed creating devmgr devices for each interface on each device.
Now the usb-bus driver only creates devmgr devices for each USB device.
The functionality of creating devmgr devices for USB interfaces is handled by
a new driver called usb-composite, which binds to the devices created by the
usb-bus driver.

We add a new protocol ZX_PROTOCOL_USB_DEVICE to represent a USB device
(the existing ZX_PROTOCOL_USB protocol is used to represent a USB interface).
For now ZX_PROTOCOL_USB_DEVICE and ZX_PROTOCOL_USB both share the same protocol
interface (defined in ddk/protocol/usb.h), but this protocol will be refactored
in an upcoming CL.

The combination of the new usb-bus and usb-composite drivers implement
the same functionality as the old usb-bus driver, so no changes are needed
for existing USB drivers. However drivers have the option of binding directly
to the ZX_PROTOCOL_USB_DEVICE protocol in cases where the driver needs full control
of the USB device. For example, a USB device might have several interfaces that
all need to be accessed by the same driver. In this case, we do not want the
usb-composite driver to create devices for each interface.
To avoid this, the driver can bind to the ZX_PROTOCOL_USB_DEVICE device provided
by the usb-bus driver instead of the usb-composite driver.
The usb-composite driver is marked as a fallback driver to allow that to happen.

Drivers that bind directly to usb-bus with the ZX_PROTOCOL_USB_DEVICE protocol
must do some additional work that is usually handled by usb-composite.
In particular, they must call usb_enable_endpoint() to enable the endpoints
they are using.

In addition to the above, there are some changes to the ioctl interface for USB.
/dev/class/usb-device now contains files for all the USB devices created by the
usb-bus driver. Tools like lsusb should now use this directory instead of
/dev/class/usb.

The devices representing USB interfaces no longer support ioctl. To support that change,
some calls to device_ioctl() have been replaced with protocol calls.
IOCTL_USB_GET_CURRENT_FRAME is replaced by a new usb_get_current_frame() function in the USB protocol.

To help test this new functionality, the usb-hub driver now binds to ZX_PROTOCOL_USB_DEVICE
rather than ZX_PROTOCOL_USB. This means the usb-hub driver binds directly to usb-bus,
with no usb-composite support in between.

TEST: USB on NUC and VIM2 is working as expected. Tested keyboards, USB 2.0 and 3.0 hubs,
mass storage and USB audio.

Change-Id: Ib9f5aa09f8c0ae7ae2e7378f6996181fce5afb11


# 411ba40b 30-May-2018 Mike Voydanoff <voydanoff@google.com>

[dev][usb-bus] Fix race condition when enumerating USB hubs

This showed up with kernel.smp.maxcpus=1
The problem was due to a reference to the hub's usb_device_t
being accessed via bus_set_hub_interface() before it is set,
resulting in a null pointer error.

ZX-2195 #done

Change-Id: Ib98f4af20372278f552ae21609977edeec150631


# 7837c25b 19-Apr-2018 Ruchira Ravoori <ravoorir@rodete-desktop-imager.corp.google.com>

[zircon][xhci] Initialize TT fields for all the low/full speed devices

The transaction translator fields should be set for all the low/full
speed devices. Currently our code only sets it if the parent is a high
speed hub and does not pass on the TT fields to children of a full speed
or a low speed hub which is connected to a high speed hub. Without this,
the xhc generates errors for the SET_ADDRESS command and the device does
not initialize properly. This changeset does the following:
1. Passes on the TT fields as required.
2. Add a sleep between Address Device and Get Descriptor commands.
Without this, the Get Descriptor command fails on Razer Megalogon headset.
3. Provides error handling for legacy devices that might expect Get
Descriptor request before SET_ADDRESS request.
ZX-1933 #done ZX-1975 #done

Change-Id: I80045a2569ba108f697034dd8c85229a8960bea9


# 58e1f3cc 13-Mar-2018 Mike Voydanoff <voydanoff@google.com>

[ddk][usb] Add support for allocating USB requests to the USB protocol

We will transition to this so we can use the USB controller's BTI in USB requests.

Change-Id: I61a04f57713c55134b005f9ee632561c48baa7ec


# 2e0fc961 05-Nov-2017 Mike Voydanoff <voydanoff@google.com>

[ddk] Remove driver bind() cookie and unbind() callback

Also removed "owner" and "owner_cookie" from internal zx_device_t struct

Adjusted intel-hda audio drivers to create devices to hold driver context
rather than using the driver bind cookie.

Change-Id: I0eca7f6fa3b155be71843291812e7aa9fea5bf55


# f4b2ff04 23-Oct-2017 Brian Swetland <swetland@google.com>

[ddk] rename dprintf() to zxlogf() to avoid conflicts

dprintf is still defined by ddk/debug.h but with a deprecation warning

Change-Id: I00b34803571c468007e069c1da6a292feba2bc3c


# db019e05 18-Sep-2017 Mike Voydanoff <voydanoff@google.com>

[dev][usb-bus] Fix bugs in driver unbind path

Change-Id: Icd0c4d7b03faeb19393d0f476d6cd74c2edf8d94


# dacc1d80 12-Sep-2017 Mike Voydanoff <voydanoff@google.com>

[dev] Rename "mxdev" to "zxdev" in ddktl and various drivers.

Change-Id: I000e42c26d9f8379de40447690694a35f6be93e2


# f3e2126c 12-Sep-2017 Roland McGrath <mcgrathr@google.com>

[zx] Magenta -> Zircon

The Great Renaming is here!

Change-Id: I3229bdeb2a3d0e40fb4db6fec8ca7d971fbffb94


# c1f5c118 07-Sep-2017 Mike Voydanoff <voydanoff@google.com>

[dev][usb-bus] Switch to new DDK dprintf() logging calls

Change-Id: Ia8d967dcea84935467f9950f637963ff534de1d1


# ea7d000d 26-Jul-2017 Mike Voydanoff <voydanoff@google.com>

[dev][usb-bus] Fix device leak in usb_bus_unbind()

Change-Id: I2fbf4b8179a48e7ba3a56cf0cdc8e4d1ed74c3f2


# 1206bd9b 11-Jul-2017 Mike Voydanoff <voydanoff@google.com>

[dev][usb] Add separate interface for notifying bus when devices are added and removed

Change-Id: I500fe5113d3c54016c539f979446f2d7388aeb94


# 11b5375a 05-Jul-2017 Mike Voydanoff <voydanoff@google.com>

[ddk][usb] Add inline wrappers for USB protocol ops

Change-Id: I925b09dd4d8cbd4dae88b0c4bd9246105a1b4de8


# 71856d57 14-Jun-2017 Brian Swetland <swetland@google.com>

[usb][usb-bus] add get_device_id to usb protocol

This makes usb_interface_get_device_id() safer, because it will not return
random junk if passed a non-usb-interface mx_device_t, and makes the usb
stack no longer depend on internal fields of mx_device_t (ctx).

Change-Id: I3d1fcccfe58524eff9de4eb7715aff6978e4cd39


# 4f5f5b8a 14-Jun-2017 Brian Swetland <swetland@google.com>

[ddk][usb-bus] new protocol support (5 of n)

Migrate MX_PROTOCOL_USB_BUS to new style.

Change-Id: I8f6e4cf4ca7a139c5ddce203e94a3f7d6444b98b


# 053dab5a 14-Jun-2017 Brian Swetland <swetland@google.com>

[ddk][usb-hci] new protocol support (4 of n)

Migrate PROTOCOL_USB_HCI providers and consumers.

Change-Id: I73e25b1caccf5c75d46006facb2b5163d9398077


# b2d14526 09-Jun-2017 Tim Kilbourn <tkilbourn@google.com>

[dev][usb] Use new magenta error names

Change-Id: Ie4901fe957ee96cf7c7d425a948c1b66a0d3a0f3


# 0bc8d058 07-Jun-2017 Brian Swetland <swetland@google.com>

[udev][usb-bus] rename udev/usb-bus to dev/usb/usb-bus

Change-Id: I972a5821eadc4d9d859b8f30998e151c0d0d85e0