blob: 639d640d3d9c42c50f20a0425cdd21359b47e665 [file] [log] [blame]
Duncan Laurie645b3762013-02-12 14:00:47 -08001/*
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älkkie2227a22014-02-05 13:02:55 +020026#include <device/pci_ehci.h>
Duncan Laurie645b3762013-02-12 14:00:47 -080027#include <arch/io.h>
28
29static void usb_xhci_init(struct device *dev)
30{
31 u32 reg32;
Vladimir Serbinenkob26156e2015-01-31 17:45:50 +010032 struct southbridge_intel_bd82x6x_config *config = dev->chip_info;
Duncan Laurie645b3762013-02-12 14:00:47 -080033
34 printk(BIOS_DEBUG, "XHCI: Setting up controller.. ");
35
Nicolas Reinecke59aef5c2015-04-16 23:25:00 +020036 if (config->xhci_overcurrent_mapping)
37 pci_write_config32(dev, XOCM, config->xhci_overcurrent_mapping);
38
Duncan Laurie645b3762013-02-12 14:00:47 -080039 /* lock overcurrent map */
40 reg32 = pci_read_config32(dev, 0x44);
41 reg32 |= 1;
42 pci_write_config32(dev, 0x44, reg32);
43
Nicolas Reinecke0b29a7b2015-03-29 17:51:11 +020044 pci_write_config32(dev, XUSB2PRM, config->xhci_switchable_ports);
45 pci_write_config32(dev, USB3PRM, config->superspeed_capable_ports);
Vladimir Serbinenkob26156e2015-01-31 17:45:50 +010046
Duncan Laurie645b3762013-02-12 14:00:47 -080047 /* Enable clock gating */
48 reg32 = pci_read_config32(dev, 0x40);
49 reg32 &= ~((1 << 20) | (1 << 21));
50 reg32 |= (1 << 19) | (1 << 18) | (1 << 17);
51 reg32 |= (1 << 10) | (1 << 9) | (1 << 8);
52 reg32 |= (1 << 31); /* lock */
53 pci_write_config32(dev, 0x40, reg32);
54
55 printk(BIOS_DEBUG, "done.\n");
56}
57
58static void xhci_set_subsystem(device_t dev, unsigned vendor, unsigned device)
59{
60 if (!vendor || !device) {
61 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
62 pci_read_config32(dev, PCI_VENDOR_ID));
63 } else {
64 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
65 ((device & 0xffff) << 16) | (vendor & 0xffff));
66 }
67}
68
69static struct pci_operations xhci_pci_ops = {
70 .set_subsystem = xhci_set_subsystem,
71};
72
73static struct device_operations usb_xhci_ops = {
74 .read_resources = pci_dev_read_resources,
75 .set_resources = pci_dev_set_resources,
76 .enable_resources = pci_dev_enable_resources,
77 .init = usb_xhci_init,
78 .scan_bus = 0,
79 .ops_pci = &xhci_pci_ops,
80};
81
82static const unsigned short pci_device_ids[] = { 0x1e31, 0 };
83
84static const struct pci_driver pch_usb_xhci __pci_driver = {
85 .ops = &usb_xhci_ops,
86 .vendor = PCI_VENDOR_ID_INTEL,
87 .devices = pci_device_ids,
88};