pci: improve io address space allocation

This patch improves the io address space allocation.  It adds a check
that the region above 0xc000 which is traditionally used for pci io
is actually big enougth.  If it isn't it tries the larger window at
0x1000.  If that is to small too it errors out.

When creating guests with multiple pci-pci bridges (and devices with
io regions behind them) the 0xc000 -> 0xffff region quickly becomes
too small.

While being at it document the io address space layout used by
qemu/seabios.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
xhci: allocate scratch pad buffers

Untested.  Anyone who tried to get xhci run on real hardware
is welcome to test whenever this patch improves things.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
xhci: Use 64bit writes to ERDP register.

At least some real-world XHCI controllers expect a 64bit write to the
ERDP register.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
xhci: Fix incorrect direction setting on status transmissions.

The status part of a control message was likely to have an incorrect
direction set.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
xhci: Set the interval parameter on interrupt pipes.

Be sure to set the interval parameter when creating an interrupt based
pipe.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
xhci: Verify PAGESIZE register before initializing driver.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
xhci: Allocate and free the xhci inctx structure on each use.

The inctx struct isn't long lived, so it doesn't need to be allocated
in permanent memory.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
xhci: Move set_address code from xhci_control to xhci_alloc_pipe.

It's easier to run the set_address from xhci_alloc_pipe as there is
more information available there.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
xhci: Eliminate 'struct xhci_device'.

Eliminate the xhci_device struct by storing the slotid in usbdevice_s
and in xhci_pipe.  The remaining storage in that struct (xhci_devctx)
is available from xhci->devs.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
xhci: Support xhci controllers with 64 byte contexts.

At least some real-world controllers require 64 byte contexts.  Detect
this case and handle it appropriately.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
xhci: Allow the XHCI USB controller to be enabled for coreboot.

Initial tests look promising and at least two different real-world
chipsets show limited functionality with the support enabled.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
xhci: Don't use a dummy endpoint count in configure command.

At least some real-world controllers expect the endpoint count in the
inctx to be accurate, so set it to the pipe currently being activated.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
xhci: Report the "protocol defined" and PSIC bits of extended capabilities.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
xhci: Support USB hubs on xhci controllers.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add call32_params() helper function.

Add helper function for calling 32bit functions with more than just
one parameter.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add space between DTYPE_* definitions.

Avoid consective numbering on the DTYPE_* definitions.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
xhci: Run the XHCI driver entirely in 32bit mode.

Since the XHCI driver needs to jump into 32bit mode anyway, it is
simpler to just run all of the code in 32bit mode.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Remove pci_writel() and pci_readl() functions.

These functions are no longer used.  Going forward it's better to move
a driver to full 32bit mode then to use these functions.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
xhci: Check if scratch pad allocation fails.

Some boards ask for a large amount of ram for scratch pad usage, and
it is possible the allocation will fail.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Increase maximum size of permanent high memory area.

Some XHCI controllers can request a significant chunk of reserved
memory for scratch pad buffers.  (At least one controller Intel
Haswell based controller has been seen to request 64KiB.)  Unused
memory is returned after POST completes, so it should be okay to
increase the maximum permanent high memory zone from 64K to 256K.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>