blob: 7719f16c1d01abf332ca1694fb412761d26e2589 [file] [log] [blame]
Patrick Georgie72a8a32012-11-06 11:05:09 +01001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2008-2009 coresystems GmbH
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.
Patrick Georgie72a8a32012-11-06 11:05:09 +010015 */
16
17#include <console/console.h>
18#include <device/device.h>
19#include <device/pci.h>
20#include <device/pci_ids.h>
21#include "i82801ix.h"
Kyösti Mälkkie2227a22014-02-05 13:02:55 +020022#include <device/pci_ehci.h>
Patrick Georgie72a8a32012-11-06 11:05:09 +010023
24static void usb_ehci_init(struct device *dev)
25{
26 u32 reg32;
27
28 printk(BIOS_DEBUG, "EHCI: Setting up controller.. ");
29 reg32 = pci_read_config32(dev, PCI_COMMAND);
30 reg32 |= PCI_COMMAND_MASTER;
31 pci_write_config32(dev, PCI_COMMAND, reg32);
32
33 printk(BIOS_DEBUG, "done.\n");
34}
35
36static void usb_ehci_set_subsystem(device_t dev, unsigned vendor, unsigned device)
37{
38 u8 access_cntl;
39
40 access_cntl = pci_read_config8(dev, 0x80);
41
42 /* Enable writes to protected registers. */
43 pci_write_config8(dev, 0x80, access_cntl | 1);
44
45 if (!vendor || !device) {
46 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
47 pci_read_config32(dev, PCI_VENDOR_ID));
48 } else {
49 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
50 ((device & 0xffff) << 16) | (vendor & 0xffff));
51 }
52
53 /* Restore protection. */
54 pci_write_config8(dev, 0x80, access_cntl);
55}
56
Patrick Georgie72a8a32012-11-06 11:05:09 +010057static const unsigned short pci_device_ids[] = {
58 0x293a,
59 0x293c,
60 0
61};
62
63static struct pci_operations lops_pci = {
64 .set_subsystem = &usb_ehci_set_subsystem,
65};
66
67static struct device_operations usb_ehci_ops = {
Kyösti Mälkkifb387df2013-06-07 22:16:52 +030068 .read_resources = pci_ehci_read_resources,
69 .set_resources = pci_dev_set_resources,
Patrick Georgie72a8a32012-11-06 11:05:09 +010070 .enable_resources = pci_dev_enable_resources,
71 .init = usb_ehci_init,
72 .scan_bus = 0,
73 .ops_pci = &lops_pci,
74};
75
76static const struct pci_driver pch_usb_ehci1 __pci_driver = {
77 .ops = &usb_ehci_ops,
78 .vendor = PCI_VENDOR_ID_INTEL,
79 .devices = pci_device_ids,
80};