blob: e27c8e59c9634d2ad5824a935b7559b1f57568c1 [file] [log] [blame]
Duncan Lauriec88c54c2014-04-30 16:36:13 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2008-2009 coresystems GmbH
5 * Copyright (C) 2014 Google Inc.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of 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 <delay.h>
23#include <device/device.h>
24#include <device/pci.h>
25#include <device/pci_ids.h>
26#include <usbdebug.h>
27#include <arch/io.h>
28#include <broadwell/ehci.h>
29
30static void usb_ehci_set_subsystem(device_t dev, unsigned vendor, unsigned device)
31{
32 u8 access_cntl;
33
34 access_cntl = pci_read_config8(dev, 0x80);
35
36 /* Enable writes to protected registers. */
37 pci_write_config8(dev, 0x80, access_cntl | 1);
38
39 if (!vendor || !device) {
40 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
41 pci_read_config32(dev, PCI_VENDOR_ID));
42 } else {
43 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
44 ((device & 0xffff) << 16) | (vendor & 0xffff));
45 }
46
47 /* Restore protection. */
48 pci_write_config8(dev, 0x80, access_cntl);
49}
50
51static void usb_ehci_set_resources(struct device *dev)
52{
53#if CONFIG_USBDEBUG
54 struct resource *res;
55 u32 base;
56 u32 usb_debug;
57
58 usb_debug = get_ehci_debug();
59 set_ehci_debug(0);
60#endif
61 pci_dev_set_resources(dev);
62
63#if CONFIG_USBDEBUG
64 res = find_resource(dev, 0x10);
65 set_ehci_debug(usb_debug);
66 if (!res) return;
67 base = res->base;
68 set_ehci_base(base);
69 report_resource_stored(dev, res, "");
70#endif
71}
72
73static struct pci_operations ehci_ops_pci = {
74 .set_subsystem = &usb_ehci_set_subsystem,
75};
76
77static struct device_operations usb_ehci_ops = {
78 .read_resources = &pci_dev_read_resources,
79 .set_resources = &usb_ehci_set_resources,
80 .enable_resources = &pci_dev_enable_resources,
81 .ops_pci = &ehci_ops_pci,
82};
83
84static const unsigned short pci_device_ids[] = {
85 0x9c26, /* LynxPoint-LP */
86 0x9ca6, /* WildcatPoint */
87 0
88};
89
90static const struct pci_driver pch_usb_ehci __pci_driver = {
91 .ops = &usb_ehci_ops,
92 .vendor = PCI_VENDOR_ID_INTEL,
93 .devices = pci_device_ids,
94};