Duncan Laurie | 645b376 | 2013-02-12 14:00:47 -0800 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright 2013 Google Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License as |
| 8 | * published by the Free Software Foundation; version 2 of |
| 9 | * the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | */ |
| 20 | |
| 21 | #include <console/console.h> |
| 22 | #include <device/device.h> |
| 23 | #include <device/pci.h> |
| 24 | #include <device/pci_ids.h> |
| 25 | #include "pch.h" |
Kyösti Mälkki | e2227a2 | 2014-02-05 13:02:55 +0200 | [diff] [blame] | 26 | #include <device/pci_ehci.h> |
Duncan Laurie | 645b376 | 2013-02-12 14:00:47 -0800 | [diff] [blame] | 27 | #include <arch/io.h> |
| 28 | |
| 29 | static void usb_xhci_init(struct device *dev) |
| 30 | { |
| 31 | u32 reg32; |
Vladimir Serbinenko | b26156e | 2015-01-31 17:45:50 +0100 | [diff] [blame] | 32 | struct southbridge_intel_bd82x6x_config *config = dev->chip_info; |
Duncan Laurie | 645b376 | 2013-02-12 14:00:47 -0800 | [diff] [blame] | 33 | |
| 34 | printk(BIOS_DEBUG, "XHCI: Setting up controller.. "); |
| 35 | |
| 36 | /* lock overcurrent map */ |
| 37 | reg32 = pci_read_config32(dev, 0x44); |
| 38 | reg32 |= 1; |
| 39 | pci_write_config32(dev, 0x44, reg32); |
| 40 | |
Nicolas Reinecke | 0b29a7b | 2015-03-29 17:51:11 +0200 | [diff] [blame] | 41 | pci_write_config32(dev, XUSB2PRM, config->xhci_switchable_ports); |
| 42 | pci_write_config32(dev, USB3PRM, config->superspeed_capable_ports); |
Vladimir Serbinenko | b26156e | 2015-01-31 17:45:50 +0100 | [diff] [blame] | 43 | |
Duncan Laurie | 645b376 | 2013-02-12 14:00:47 -0800 | [diff] [blame] | 44 | /* Enable clock gating */ |
| 45 | reg32 = pci_read_config32(dev, 0x40); |
| 46 | reg32 &= ~((1 << 20) | (1 << 21)); |
| 47 | reg32 |= (1 << 19) | (1 << 18) | (1 << 17); |
| 48 | reg32 |= (1 << 10) | (1 << 9) | (1 << 8); |
| 49 | reg32 |= (1 << 31); /* lock */ |
| 50 | pci_write_config32(dev, 0x40, reg32); |
| 51 | |
| 52 | printk(BIOS_DEBUG, "done.\n"); |
| 53 | } |
| 54 | |
| 55 | static void xhci_set_subsystem(device_t dev, unsigned vendor, unsigned device) |
| 56 | { |
| 57 | if (!vendor || !device) { |
| 58 | pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID, |
| 59 | pci_read_config32(dev, PCI_VENDOR_ID)); |
| 60 | } else { |
| 61 | pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID, |
| 62 | ((device & 0xffff) << 16) | (vendor & 0xffff)); |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | static struct pci_operations xhci_pci_ops = { |
| 67 | .set_subsystem = xhci_set_subsystem, |
| 68 | }; |
| 69 | |
| 70 | static struct device_operations usb_xhci_ops = { |
| 71 | .read_resources = pci_dev_read_resources, |
| 72 | .set_resources = pci_dev_set_resources, |
| 73 | .enable_resources = pci_dev_enable_resources, |
| 74 | .init = usb_xhci_init, |
| 75 | .scan_bus = 0, |
| 76 | .ops_pci = &xhci_pci_ops, |
| 77 | }; |
| 78 | |
| 79 | static const unsigned short pci_device_ids[] = { 0x1e31, 0 }; |
| 80 | |
| 81 | static const struct pci_driver pch_usb_xhci __pci_driver = { |
| 82 | .ops = &usb_xhci_ops, |
| 83 | .vendor = PCI_VENDOR_ID_INTEL, |
| 84 | .devices = pci_device_ids, |
| 85 | }; |