blob: 5607b16ae4a008730398c5ac6e3e235404f54c72 [file] [log] [blame]
Angel Pons182dbde2020-04-02 23:49:05 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Duncan Laurie645b3762013-02-12 14:00:47 -08002
3#include <console/console.h>
4#include <device/device.h>
5#include <device/pci.h>
6#include <device/pci_ids.h>
7#include "pch.h"
Kyösti Mälkkie2227a22014-02-05 13:02:55 +02008#include <device/pci_ehci.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02009#include <device/pci_ops.h>
Kyösti Mälkki12b121c2019-08-18 16:33:39 +030010#include "chip.h"
Duncan Laurie645b3762013-02-12 14:00:47 -080011
12static void usb_xhci_init(struct device *dev)
13{
14 u32 reg32;
Vladimir Serbinenkob26156e2015-01-31 17:45:50 +010015 struct southbridge_intel_bd82x6x_config *config = dev->chip_info;
Duncan Laurie645b3762013-02-12 14:00:47 -080016
17 printk(BIOS_DEBUG, "XHCI: Setting up controller.. ");
18
Nicolas Reinecke59aef5c2015-04-16 23:25:00 +020019 if (config->xhci_overcurrent_mapping)
20 pci_write_config32(dev, XOCM, config->xhci_overcurrent_mapping);
21
Duncan Laurie645b3762013-02-12 14:00:47 -080022 /* lock overcurrent map */
Angel Ponsc803f652020-06-07 22:09:01 +020023 pci_or_config32(dev, 0x44, 1);
Duncan Laurie645b3762013-02-12 14:00:47 -080024
Nicolas Reinecke0b29a7b2015-03-29 17:51:11 +020025 pci_write_config32(dev, XUSB2PRM, config->xhci_switchable_ports);
26 pci_write_config32(dev, USB3PRM, config->superspeed_capable_ports);
Vladimir Serbinenkob26156e2015-01-31 17:45:50 +010027
Duncan Laurie645b3762013-02-12 14:00:47 -080028 /* Enable clock gating */
29 reg32 = pci_read_config32(dev, 0x40);
30 reg32 &= ~((1 << 20) | (1 << 21));
31 reg32 |= (1 << 19) | (1 << 18) | (1 << 17);
32 reg32 |= (1 << 10) | (1 << 9) | (1 << 8);
33 reg32 |= (1 << 31); /* lock */
34 pci_write_config32(dev, 0x40, reg32);
35
36 printk(BIOS_DEBUG, "done.\n");
37}
38
Aaron Durbinaa090cb2017-09-13 16:01:52 -060039static const char *xhci_acpi_name(const struct device *dev)
Patrick Rudolph604f6982017-06-07 09:46:52 +020040{
41 return "XHC";
42}
43
Duncan Laurie645b3762013-02-12 14:00:47 -080044static struct device_operations usb_xhci_ops = {
45 .read_resources = pci_dev_read_resources,
46 .set_resources = pci_dev_set_resources,
47 .enable_resources = pci_dev_enable_resources,
48 .init = usb_xhci_init,
Angel Pons1fc0edd2020-05-31 00:03:28 +020049 .ops_pci = &pci_dev_ops_pci,
Patrick Rudolph604f6982017-06-07 09:46:52 +020050 .acpi_name = xhci_acpi_name,
Duncan Laurie645b3762013-02-12 14:00:47 -080051};
52
53static const unsigned short pci_device_ids[] = { 0x1e31, 0 };
54
55static const struct pci_driver pch_usb_xhci __pci_driver = {
56 .ops = &usb_xhci_ops,
Felix Singer43b7f412022-03-07 04:34:52 +010057 .vendor = PCI_VID_INTEL,
Duncan Laurie645b3762013-02-12 14:00:47 -080058 .devices = pci_device_ids,
59};