Add constants for fast path resume copying
[coreboot.git] / src / southbridge / intel / sch / usb_ehci.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2008-2010 coresystems GmbH
5  * Copyright (C) 2009-2010 iWave Systems
6  *
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
10  * the License.
11  *
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.
16  *
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
20  */
21
22 #include <console/console.h>
23 #include <device/device.h>
24 #include <device/pci.h>
25 #include <device/pci_ids.h>
26 #include <arch/io.h>
27
28 static void usb_ehci_init(struct device *dev)
29 {
30         u32 reg32;
31
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);
38         reg32 |= (1 << 2);
39         pci_write_config32(dev, 0xc0, reg32);*/
40         //pci_write_config32(dev, 0x3c, 0x17);
41         reg32 = pci_read_config32(dev, 0xFC);
42         reg32 |= (1 << 28);
43         pci_write_config32(dev, 0xFC, reg32);
44
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");
52 }
53
54 static void usb_ehci_set_subsystem(device_t dev, unsigned vendor,
55                                    unsigned device)
56 {
57         u8 access_cntl;
58
59         access_cntl = pci_read_config8(dev, 0x80);
60
61         /* Enable writes to protected registers. */
62         pci_write_config8(dev, 0x80, access_cntl | 1);
63
64         if (!vendor || !device) {
65                 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
66                                 pci_read_config32(dev, PCI_VENDOR_ID));
67         } else {
68                 pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID,
69                                 ((device & 0xffff) << 16) | (vendor & 0xffff));
70         }
71
72         /* Restore protection. */
73         pci_write_config8(dev, 0x80, access_cntl);
74 }
75
76 static struct pci_operations lops_pci = {
77         .set_subsystem = &usb_ehci_set_subsystem,
78 };
79
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,
85         .scan_bus               = 0,
86         .ops_pci                = &lops_pci,
87 };
88
89 static const struct pci_driver sch_usb_ehci __pci_driver = {
90         .ops    = &usb_ehci_ops,
91         .vendor = PCI_VENDOR_ID_INTEL,
92         .device = 0x8117,
93 };