usb: ehci: Properly set hub devnum and portnr with usb-1 hubs in the chain

For full / low speed devices we need to get the devnum and portnr of the tt,
so of the first upstream usb-2 hub, not of the parent device (which may be a
usb-1 hub).

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
usb: ehci: Add missing cache flush to destroy_int_queue

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
usb: ehci: poll_int_queue check real qtd, not the overlay

When we first start an int queue, the qh's overlay area is all zeros. This
gets filled by the hc with the actual qtd values as soon as it advances
the queue, but we may call poll_int_queue before then, in which case we
would think the transfer has completed as the hc has not yet copied the
qt_token to the overlay, so the active flag is not set.

This fixes this by checking the actual qtd token, rather then the overlay.
This also fixes a (theoretical) race where we see the completion in the
overlay and free and re-use the qtd before the hc has completed writing back
the overlay to the actual qtd.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
usb: Do not treat -ENODEV as an error for usb_kbd_deregister

ENODEV menas no usb keyboard was registered, threat this as a successful
usb_kbd_deregister.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
usb: kbd: On a "usb reset" call usb_kbd_deregister() before calling usb_stop()

We need to call usb_kbd_deregister() before calling usb_stop().

usbkbd's stdio_dev->priv points to the usb_device, and usb_kbd_testc
dereferences usb_device->privptr.

usb_stop zeros usb_device, leaving usb_device->privptr NULL, causing
bad things (tm) to happen once control returns to the main loop and
usb_kbd_testc gets called.

Calling usb_kbd_deregister() avoids this. Note that we do not allow
the "usb reset" to continue when the deregister fails. This will be fixed
in a later patch.

For the same reasons always fail "usb stop" if the usb_kbd_deregister() fails,
even in the force path. This can happen when CONFIG_SYS_STDIO_DEREGISTER is
not set.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
usb: kbd: Remove check for already being registered

We now always properly deregister the keyboard before calling
drv_usb_kbd_init(), so we can drop the check for already being registered.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
stdio: Add force parameter to stdio_deregister

In some cases we really want to move forward with a deregister, add a force
parameter to allow this, and replace the dev with a nulldev in this case.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
usb: kbd: Allow "usb reset" to continue when an usb kbd is used

Use the new force parameter to make the stdio_deregister succeed, replacing
stdin with a nulldev, and assume that the usb keyboard will come back after
the reset.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
usb: ehci: Move interrupt packet length check to create_int_queue

Preperation patch to use create_int_queue outside of ehci-hcd.c .

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
usb: ehci: Move cache invalidation to poll_int_queue

Preperation patch to use poll_int_queue outside of ehci-hcd.c .

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
usb: Make pollable int support available outside of ehci-hcd.c

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
usb: kbd: Remove unused usb_kbd_generic_poll function

This is not used anywhere, so lets remove it.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
usb: kbd: Cache pipe, interval and packetsize

Instead of looking them up every time we need them.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
usb: kbd: Add (optional) support for using interrupt packets for polling

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
usb: Remove unnecessary portnr lookup from usb_new_device

If the device has a parent, it is instantiated from usb_hub_port_connect_change
and the portnr is right there in dev->portnr, so there is no need for this
whole dance to look it up.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
usb: Do not power-cycle usb devices on init

Do as the Linux kernel does and power on any ports which are not yet one,
this is enough.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>