blob: db925e0df0f623482a095313109e3810416bf7ae [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 */
23 reg32 = pci_read_config32(dev, 0x44);
24 reg32 |= 1;
25 pci_write_config32(dev, 0x44, reg32);
26
Nicolas Reinecke0b29a7b2015-03-29 17:51:11 +020027 pci_write_config32(dev, XUSB2PRM, config->xhci_switchable_ports);
28 pci_write_config32(dev, USB3PRM, config->superspeed_capable_ports);
Vladimir Serbinenkob26156e2015-01-31 17:45:50 +010029
Duncan Laurie645b3762013-02-12 14:00:47 -080030 /* Enable clock gating */
31 reg32 = pci_read_config32(dev, 0x40);
32 reg32 &= ~((1 << 20) | (1 << 21));
33 reg32 |= (1 << 19) | (1 << 18) | (1 << 17);
34 reg32 |= (1 << 10) | (1 << 9) | (1 << 8);
35 reg32 |= (1 << 31); /* lock */
36 pci_write_config32(dev, 0x40, reg32);
37
38 printk(BIOS_DEBUG, "done.\n");
39}
40
Aaron Durbinaa090cb2017-09-13 16:01:52 -060041static const char *xhci_acpi_name(const struct device *dev)
Patrick Rudolph604f6982017-06-07 09:46:52 +020042{
43 return "XHC";
44}
45
Duncan Laurie645b3762013-02-12 14:00:47 -080046static struct pci_operations xhci_pci_ops = {
Subrata Banik4a0f0712019-03-20 14:29:47 +053047 .set_subsystem = pci_dev_set_subsystem,
Duncan Laurie645b3762013-02-12 14:00:47 -080048};
49
50static struct device_operations usb_xhci_ops = {
51 .read_resources = pci_dev_read_resources,
52 .set_resources = pci_dev_set_resources,
53 .enable_resources = pci_dev_enable_resources,
54 .init = usb_xhci_init,
Duncan Laurie645b3762013-02-12 14:00:47 -080055 .ops_pci = &xhci_pci_ops,
Patrick Rudolph604f6982017-06-07 09:46:52 +020056 .acpi_name = xhci_acpi_name,
Duncan Laurie645b3762013-02-12 14:00:47 -080057};
58
59static const unsigned short pci_device_ids[] = { 0x1e31, 0 };
60
61static const struct pci_driver pch_usb_xhci __pci_driver = {
62 .ops = &usb_xhci_ops,
63 .vendor = PCI_VENDOR_ID_INTEL,
64 .devices = pci_device_ids,
65};