Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xhci: export two xhci_hub functions for xhci-pci module usage

some Intel Alder Lake xHC hosts on ChromeOS platforms need special
workarounds touching port registers at xHC pci host hibernate.

Export xhci_port_state_to_neutral() and xhci_find_slot_id_by_port()
so they can be called from xhci-pci.c and thus the xhci-pci module.

Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://lore.kernel.org/r/20221130091944.2171610-4-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Mathias Nyman and committed by
Greg Kroah-Hartman
705c333a fed70b61

+18 -4
+18 -4
drivers/usb/host/xhci-hub.c
··· 426 426 */ 427 427 #define XHCI_PORT_RZ ((1<<2) | (1<<24) | (0xf<<28)) 428 428 429 - /* 429 + /** 430 + * xhci_port_state_to_neutral() - Clean up read portsc value back into writeable 431 + * @state: u32 port value read from portsc register to be cleanup up 432 + * 430 433 * Given a port state, this function returns a value that would result in the 431 434 * port being in the same state, if the value was written to the port status 432 435 * control register. 433 436 * Save Read Only (RO) bits and save read/write bits where 434 437 * writing a 0 clears the bit and writing a 1 sets the bit (RWS). 435 438 * For all other types (RW1S, RW1CS, RW, and RZ), writing a '0' has no effect. 439 + * 440 + * Return: u32 value that can be written back to portsc register without 441 + * changing port state. 436 442 */ 443 + 437 444 u32 xhci_port_state_to_neutral(u32 state) 438 445 { 439 446 /* Save read-only status and port state */ 440 447 return (state & XHCI_PORT_RO) | (state & XHCI_PORT_RWS); 441 448 } 449 + EXPORT_SYMBOL_GPL(xhci_port_state_to_neutral); 442 450 443 - /* 444 - * find slot id based on port number. 445 - * @port: The one-based port number from one of the two split roothubs. 451 + /** 452 + * xhci_find_slot_id_by_port() - Find slot id of a usb device on a roothub port 453 + * @hcd: pointer to hcd of the roothub 454 + * @xhci: pointer to xhci structure 455 + * @port: one-based port number of the port in this roothub. 456 + * 457 + * Return: Slot id of the usb device connected to the root port, 0 if not found 446 458 */ 459 + 447 460 int xhci_find_slot_id_by_port(struct usb_hcd *hcd, struct xhci_hcd *xhci, 448 461 u16 port) 449 462 { ··· 478 465 479 466 return slot_id; 480 467 } 468 + EXPORT_SYMBOL_GPL(xhci_find_slot_id_by_port); 481 469 482 470 /* 483 471 * Stop device