1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <console/console.h>
4 #include <device/pci.h>
5 #include <soc/pch_pci_devs.h>
10 #define SYS_BUS_CFG2 0x44
12 static uint8_t *get_xhci_bar(void)
14 const struct resource
*res
;
15 res
= probe_resource(PCH_DEV_XHCI
, PCI_BASE_ADDRESS_0
);
17 printk(BIOS_ERR
, "XHCI BAR is not found\n");
20 return (void *)(uintptr_t)res
->base
;
23 void write_usb_oc_mapping(const struct usb_oc_mapping
*config
, uint8_t pins
)
25 uint8_t *mbar
= get_xhci_bar();
29 printk(BIOS_ERR
, "XHCI BAR is invalid, skip USB OC mapping configuration\n");
32 for (i
= 0; i
< pins
; i
++)
33 write32(mbar
+ config
[i
].pin
, config
[i
].port
);
36 void lock_oc_cfg(bool lock
)
38 uint32_t cfg
= pci_read_config32(PCH_DEV_XHCI
, SYS_BUS_CFG2
);
44 pci_write_config32(PCH_DEV_XHCI
, SYS_BUS_CFG2
, cfg
);