Angel Pons | 182dbde | 2020-04-02 23:49:05 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Duncan Laurie | 645b376 | 2013-02-12 14:00:47 -0800 | [diff] [blame] | 2 | |
| 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älkki | e2227a2 | 2014-02-05 13:02:55 +0200 | [diff] [blame] | 8 | #include <device/pci_ehci.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 9 | #include <device/pci_ops.h> |
Kyösti Mälkki | 12b121c | 2019-08-18 16:33:39 +0300 | [diff] [blame] | 10 | #include "chip.h" |
Duncan Laurie | 645b376 | 2013-02-12 14:00:47 -0800 | [diff] [blame] | 11 | |
| 12 | static void usb_xhci_init(struct device *dev) |
| 13 | { |
| 14 | u32 reg32; |
Vladimir Serbinenko | b26156e | 2015-01-31 17:45:50 +0100 | [diff] [blame] | 15 | struct southbridge_intel_bd82x6x_config *config = dev->chip_info; |
Duncan Laurie | 645b376 | 2013-02-12 14:00:47 -0800 | [diff] [blame] | 16 | |
| 17 | printk(BIOS_DEBUG, "XHCI: Setting up controller.. "); |
| 18 | |
Nicolas Reinecke | 59aef5c | 2015-04-16 23:25:00 +0200 | [diff] [blame] | 19 | if (config->xhci_overcurrent_mapping) |
| 20 | pci_write_config32(dev, XOCM, config->xhci_overcurrent_mapping); |
| 21 | |
Duncan Laurie | 645b376 | 2013-02-12 14:00:47 -0800 | [diff] [blame] | 22 | /* lock overcurrent map */ |
| 23 | reg32 = pci_read_config32(dev, 0x44); |
| 24 | reg32 |= 1; |
| 25 | pci_write_config32(dev, 0x44, reg32); |
| 26 | |
Nicolas Reinecke | 0b29a7b | 2015-03-29 17:51:11 +0200 | [diff] [blame] | 27 | pci_write_config32(dev, XUSB2PRM, config->xhci_switchable_ports); |
| 28 | pci_write_config32(dev, USB3PRM, config->superspeed_capable_ports); |
Vladimir Serbinenko | b26156e | 2015-01-31 17:45:50 +0100 | [diff] [blame] | 29 | |
Duncan Laurie | 645b376 | 2013-02-12 14:00:47 -0800 | [diff] [blame] | 30 | /* 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 Durbin | aa090cb | 2017-09-13 16:01:52 -0600 | [diff] [blame] | 41 | static const char *xhci_acpi_name(const struct device *dev) |
Patrick Rudolph | 604f698 | 2017-06-07 09:46:52 +0200 | [diff] [blame] | 42 | { |
| 43 | return "XHC"; |
| 44 | } |
| 45 | |
Duncan Laurie | 645b376 | 2013-02-12 14:00:47 -0800 | [diff] [blame] | 46 | static struct device_operations usb_xhci_ops = { |
| 47 | .read_resources = pci_dev_read_resources, |
| 48 | .set_resources = pci_dev_set_resources, |
| 49 | .enable_resources = pci_dev_enable_resources, |
| 50 | .init = usb_xhci_init, |
Angel Pons | 1fc0edd | 2020-05-31 00:03:28 +0200 | [diff] [blame] | 51 | .ops_pci = &pci_dev_ops_pci, |
Patrick Rudolph | 604f698 | 2017-06-07 09:46:52 +0200 | [diff] [blame] | 52 | .acpi_name = xhci_acpi_name, |
Duncan Laurie | 645b376 | 2013-02-12 14:00:47 -0800 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | static const unsigned short pci_device_ids[] = { 0x1e31, 0 }; |
| 56 | |
| 57 | static const struct pci_driver pch_usb_xhci __pci_driver = { |
| 58 | .ops = &usb_xhci_ops, |
| 59 | .vendor = PCI_VENDOR_ID_INTEL, |
| 60 | .devices = pci_device_ids, |
| 61 | }; |