blob: 3e6ce6b341b0cc6acd40ba5b5bff9bcc87ed508f [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
36 /* lock overcurrent map */
37 reg32 = pci_read_config32(dev, 0x44);
38 reg32 |= 1;
39 pci_write_config32(dev, 0x44, reg32);
40
Nicolas Reinecke0b29a7b2015-03-29 17:51:11 +020041 pci_write_config32(dev, XUSB2PRM, config->xhci_switchable_ports);
42 pci_write_config32(dev, USB3PRM, config->superspeed_capable_ports);
Vladimir Serbinenkob26156e2015-01-31 17:45:50 +010043
Duncan Laurie645b3762013-02-12 14:00:47 -080044 /* 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
55static 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
66static struct pci_operations xhci_pci_ops = {
67 .set_subsystem = xhci_set_subsystem,
68};
69
70static 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
79static const unsigned short pci_device_ids[] = { 0x1e31, 0 };
80
81static 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};