2 * This file is part of the coreboot project.
4 * Copyright (C) 2008-2010 coresystems GmbH
5 * Copyright (C) 2009-2010 iWave Systems
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; version 2 of
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include <console/console.h>
23 #include <device/device.h>
24 #include <device/pci.h>
25 #include <device/pci_ids.h>
28 static void usb_ehci_init(struct device *dev)
32 printk(BIOS_DEBUG, "EHCI: Setting up controller.. ");
33 reg32 = pci_read_config32(dev, PCI_COMMAND);
34 reg32 |= PCI_COMMAND_MASTER;
35 pci_write_config32(dev, PCI_COMMAND, reg32);
36 /*Disable clock gating
37 reg32 = pci_read_config32(dev, 0xc0);
39 pci_write_config32(dev, 0xc0, reg32);*/
40 //pci_write_config32(dev, 0x3c, 0x17);
41 reg32 = pci_read_config32(dev, 0xFC);
43 pci_write_config32(dev, 0xFC, reg32);
45 reg32 = pci_read_config32(dev, 0x4);
46 printk(BIOS_DEBUG, "PCI_COMMAND %x.\n",reg32);
47 reg32 = pci_read_config32(dev, 0x20);
48 printk(BIOS_DEBUG, "PCI_BASE %x.\n",reg32);
49 reg32 = pci_read_config32(dev, 0xC0);
50 printk(BIOS_DEBUG, "PCI_FD %x.\n",reg32);
51 printk(BIOS_DEBUG, "done.\n");
54 static void usb_ehci_set_subsystem(device_t dev, unsigned vendor,
59 access_cntl = pci_read_config8(dev, 0x80);
61 /* Enable writes to protected registers. */
62 pci_write_config8(dev, 0x80, access_cntl | 1);
64 if (!vendor || !device) {
65 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
66 pci_read_config32(dev, PCI_VENDOR_ID));
68 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
69 ((device & 0xffff) << 16) | (vendor & 0xffff));
72 /* Restore protection. */
73 pci_write_config8(dev, 0x80, access_cntl);
76 static struct pci_operations lops_pci = {
77 .set_subsystem = &usb_ehci_set_subsystem,
80 static struct device_operations usb_ehci_ops = {
81 .read_resources = pci_dev_read_resources,
82 .set_resources = pci_dev_set_resources,
83 .enable_resources = pci_dev_enable_resources,
84 .init = usb_ehci_init,
89 static const struct pci_driver sch_usb_ehci __pci_driver = {
91 .vendor = PCI_VENDOR_ID_INTEL,