2 * This file is part of the coreboot project.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
15 #include <console/console.h>
16 #include <device/device.h>
17 #include <device/pci.h>
18 #include <device/pci_ids.h>
19 #include <device/pci_ops.h>
20 #include <device/pci_ehci.h>
22 #include <soc/pci_devs.h>
23 #include <soc/southbridge.h>
24 #include <amdblocks/acpimmio.h>
26 static void set_usb_over_current(struct device
*dev
)
28 uint16_t map
= USB_OC_DISABLE_ALL
;
30 if (dev
->path
.pci
.devfn
== XHCI_DEVFN
) {
31 if (mainboard_get_xhci_oc_map(&map
) == 0) {
32 xhci_pm_write32(XHCI_PM_INDIRECT_INDEX
,
33 XHCI_OVER_CURRENT_CONTROL
);
34 xhci_pm_write16(XHCI_PM_INDIRECT_DATA
, map
);
38 if (dev
->path
.pci
.devfn
== EHCI1_DEVFN
) {
39 if (mainboard_get_ehci_oc_map(&map
) == 0)
40 pci_write_config16(dev
, EHCI_OVER_CURRENT_CONTROL
, map
);
44 int __weak
mainboard_get_xhci_oc_map(uint16_t *map
)
46 printk(BIOS_DEBUG
, "WEAK: %s/%s called\n", __FILE__
, __func__
);
50 int __weak
mainboard_get_ehci_oc_map(uint16_t *map
)
52 printk(BIOS_DEBUG
, "WEAK: %s/%s called\n", __FILE__
, __func__
);
56 static struct pci_operations lops_pci
= {
57 .set_subsystem
= pci_dev_set_subsystem
,
60 static struct device_operations usb_ops
= {
61 .read_resources
= pci_ehci_read_resources
,
62 .set_resources
= pci_dev_set_resources
,
63 .enable_resources
= pci_dev_enable_resources
,
64 .init
= set_usb_over_current
,
65 .scan_bus
= scan_static_bus
,
66 .acpi_name
= soc_acpi_name
,
70 static const unsigned short pci_device_ids
[] = {
71 PCI_DEVICE_ID_AMD_SB900_USB_18_0
,
72 PCI_DEVICE_ID_AMD_SB900_USB_18_2
,
73 PCI_DEVICE_ID_AMD_SB900_USB_20_5
,
74 PCI_DEVICE_ID_AMD_CZ_USB_0
,
75 PCI_DEVICE_ID_AMD_CZ_USB_1
,
76 PCI_DEVICE_ID_AMD_CZ_USB3_0
,
80 static const struct pci_driver usb_0_driver __pci_driver
= {
82 .vendor
= PCI_VENDOR_ID_AMD
,
83 .devices
= pci_device_ids
,