drivers/usbhost: Tell the host stack which controller a port belongs to.

struct usbhost_roothubport_s carries the number of the controller its port
belongs to, so a port can be named on a system with more than one.
Nothing set it.

Take the number from whoever brings the controller up rather than counting
registrations, which would agree with the name the driver reports only
while controllers are registered in the order they are named.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Justin Hammond <justin@dynam.ac>
This commit is contained in:
Justin Hammond 2026-08-08 14:39:09 +08:00 • committed by Xiang Xiao
parent ba7c7e1f77
commit ed046adeb4
3 changed files with 12 additions and 3 deletions

View file

@ -248,6 +248,7 @@ struct usbhost_xhci_s
/* xHCI parameters */
uint8_t no_ports; /* Number of USB Ports */
uint8_t bus; /* Which controller this is */
uint8_t no_slots; /* Maximum number of Device Slots (one per USB device) */
uint8_t no_scratch; /* Number of scratch buffers */
uint8_t no_erst; /* Event Ring Segment Table size */
@ -5830,6 +5831,7 @@ static inline int xhci_sw_initialize(FAR struct usbhost_xhci_s *priv)
rhport->ep0.epno = 0;
rhport->ep0.devaddr = 0;
nxsem_init(&rhport->ep0.iocsem, 0, 0);
rhport->hport.bus = priv->bus;
nxmutex_init(&rhport->ep0.lock);
/* Initialize the public port representation */
@ -5874,7 +5876,7 @@ static inline int xhci_sw_initialize(FAR struct usbhost_xhci_s *priv)
****************************************************************************/
FAR struct usbhost_connection_s *
xhci_initialize(FAR const char *name, uintptr_t base,
xhci_initialize(FAR const char *name, uint8_t bus, uintptr_t base,
FAR const struct xhci_bus_ops_s *ops, FAR void *arg)
{
FAR struct usbhost_conn_xhci_s *conn = NULL;
@ -5903,6 +5905,13 @@ xhci_initialize(FAR const char *name, uintptr_t base,
conn->priv = priv;
priv->name = name;
/* The bus is what the controller calls itself, so that a port reported
* through the generic host stack and a message from this driver name the
* same thing. Numbering them here instead would agree only by accident.
*/
priv->bus = bus;
priv->ops = ops;
priv->arg = arg;
priv->base = base;

View file

@ -213,7 +213,7 @@ static int pci_xhci_probe(FAR struct pci_device_s *dev)
goto errout;
}
pcix->conn = xhci_initialize("usb", base, &g_pci_xhci_ops, pcix);
pcix->conn = xhci_initialize("usb", 0, base, &g_pci_xhci_ops, pcix);
if (pcix->conn == NULL)
{
pcierr("xhci_initialize failed\n");

View file

@ -95,7 +95,7 @@ struct xhci_bus_ops_s
****************************************************************************/
FAR struct usbhost_connection_s *
xhci_initialize(FAR const char *name, uintptr_t base,
xhci_initialize(FAR const char *name, uint8_t bus, uintptr_t base,
FAR const struct xhci_bus_ops_s *ops, FAR void *arg);
/****************************************************************************