summaryrefslogtreecommitdiff
path: root/src/southbridge
diff options
context:
space:
mode:
authorAngel Pons <th3fanbus@gmail.com>2021-03-03 17:30:52 +0100
committerPatrick Georgi <pgeorgi@google.com>2021-03-05 10:58:17 +0000
commit418190cbbaa6fed426078f31e16f68fb956da45c (patch)
tree426c8e007a806b8edab82dd67018c86e028cb19e /src/southbridge
parentb9338ba502b9749c2a301a19731d44fb62e31ca1 (diff)
downloadcoreboot-418190cbbaa6fed426078f31e16f68fb956da45c.tar.xz
sb/intel/lynxpoint: Refactor `usb_xhci_port_count_usb3`
Change the function parameters to avoid preprocessor usage. Change-Id: Iec43e057ed2a629e702e0f484ff7f19fe8a0311b Signed-off-by: Angel Pons <th3fanbus@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/51236 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Diffstat (limited to 'src/southbridge')
-rw-r--r--src/southbridge/intel/lynxpoint/usb_xhci.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/southbridge/intel/lynxpoint/usb_xhci.c b/src/southbridge/intel/lynxpoint/usb_xhci.c
index d4611a77db..ce851a3009 100644
--- a/src/southbridge/intel/lynxpoint/usb_xhci.c
+++ b/src/southbridge/intel/lynxpoint/usb_xhci.c
@@ -28,18 +28,19 @@ static u8 *usb_xhci_mem_base(struct device *dev)
return (u8 *)(mem_base & ~0xf);
}
-#ifdef __SIMPLE_DEVICE__
-static int usb_xhci_port_count_usb3(pci_devfn_t dev)
-#else
-static int usb_xhci_port_count_usb3(struct device *dev)
-#endif
+static int usb_xhci_port_count_usb3(u8 *mem_base)
{
+ if (!mem_base) {
+ /* Do not proceed if BAR is invalid */
+ return 0;
+ }
+
if (pch_is_lp()) {
/* LynxPoint-LP has 4 SS ports */
return 4;
}
- /* LynxPoint-H can have 0, 2, 4, or 6 SS ports */
- u8 *mem_base = usb_xhci_mem_base(dev);
+
+ /* LynxPoint-H can have 0, 2, 4, or 6 SS ports */
u32 fus = read32(mem_base + XHCI_USB3FUS);
fus >>= XHCI_USB3FUS_SS_SHIFT;
fus &= XHCI_USB3FUS_SS_MASK;
@@ -87,10 +88,10 @@ static void usb_xhci_reset_usb3(struct device *dev, int all)
{
u32 status, port_disabled;
int timeout, port;
- int port_count = usb_xhci_port_count_usb3(dev);
u8 *mem_base = usb_xhci_mem_base(dev);
+ int port_count = usb_xhci_port_count_usb3(mem_base);
- if (!mem_base || !port_count)
+ if (!port_count)
return;
/* Get mask of disabled ports */