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 */ |
Angel Pons | c803f65 | 2020-06-07 22:09:01 +0200 | [diff] [blame] | 23 | pci_or_config32(dev, 0x44, 1); |
Duncan Laurie | 645b376 | 2013-02-12 14:00:47 -0800 | [diff] [blame] | 24 | |
Nicolas Reinecke | 0b29a7b | 2015-03-29 17:51:11 +0200 | [diff] [blame] | 25 | pci_write_config32(dev, XUSB2PRM, config->xhci_switchable_ports); |
| 26 | pci_write_config32(dev, USB3PRM, config->superspeed_capable_ports); |
Vladimir Serbinenko | b26156e | 2015-01-31 17:45:50 +0100 | [diff] [blame] | 27 | |
Duncan Laurie | 645b376 | 2013-02-12 14:00:47 -0800 | [diff] [blame] | 28 | /* 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 Durbin | aa090cb | 2017-09-13 16:01:52 -0600 | [diff] [blame] | 39 | static const char *xhci_acpi_name(const struct device *dev) |
Patrick Rudolph | 604f698 | 2017-06-07 09:46:52 +0200 | [diff] [blame] | 40 | { |
| 41 | return "XHC"; |
| 42 | } |
| 43 | |
Duncan Laurie | 645b376 | 2013-02-12 14:00:47 -0800 | [diff] [blame] | 44 | static 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 Pons | 1fc0edd | 2020-05-31 00:03:28 +0200 | [diff] [blame] | 49 | .ops_pci = &pci_dev_ops_pci, |
Patrick Rudolph | 604f698 | 2017-06-07 09:46:52 +0200 | [diff] [blame] | 50 | .acpi_name = xhci_acpi_name, |
Duncan Laurie | 645b376 | 2013-02-12 14:00:47 -0800 | [diff] [blame] | 51 | }; |
| 52 | |
| 53 | static const unsigned short pci_device_ids[] = { 0x1e31, 0 }; |
| 54 | |
| 55 | static const struct pci_driver pch_usb_xhci __pci_driver = { |
| 56 | .ops = &usb_xhci_ops, |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 57 | .vendor = PCI_VID_INTEL, |
Duncan Laurie | 645b376 | 2013-02-12 14:00:47 -0800 | [diff] [blame] | 58 | .devices = pci_device_ids, |
| 59 | }; |