1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <console/console.h>
4 #include <device/device.h>
5 #include <device/pci.h>
6 #include <device/pci_ids.h>
7 #include <device/pci_ops.h>
8 #include <device/pci_ehci.h>
10 #include <soc/pci_devs.h>
11 #include <soc/southbridge.h>
12 #include <amdblocks/acpimmio.h>
14 static void set_usb_over_current(struct device
*dev
)
16 uint16_t map
= USB_OC_DISABLE_ALL
;
18 if (dev
->path
.pci
.devfn
== XHCI_DEVFN
) {
19 if (mainboard_get_xhci_oc_map(&map
) == 0) {
20 xhci_pm_write32(XHCI_PM_INDIRECT_INDEX
,
21 XHCI_OVER_CURRENT_CONTROL
);
22 xhci_pm_write16(XHCI_PM_INDIRECT_DATA
, map
);
26 if (dev
->path
.pci
.devfn
== EHCI1_DEVFN
) {
27 if (mainboard_get_ehci_oc_map(&map
) == 0)
28 pci_write_config16(dev
, EHCI_OVER_CURRENT_CONTROL
, map
);
32 int __weak
mainboard_get_xhci_oc_map(uint16_t *map
)
34 printk(BIOS_DEBUG
, "WEAK: %s/%s called\n", __FILE__
, __func__
);
38 int __weak
mainboard_get_ehci_oc_map(uint16_t *map
)
40 printk(BIOS_DEBUG
, "WEAK: %s/%s called\n", __FILE__
, __func__
);
44 struct device_operations stoneyridge_usb_ops
= {
45 .read_resources
= pci_ehci_read_resources
,
46 .set_resources
= pci_dev_set_resources
,
47 .enable_resources
= pci_dev_enable_resources
,
48 .init
= set_usb_over_current
,
49 .scan_bus
= scan_static_bus
,
50 .acpi_name
= soc_acpi_name
,
51 .ops_pci
= &pci_dev_ops_pci
,