also rename the config option.
[coreboot.git] / src / southbridge / nvidia / mcp55 / mcp55_usb2.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2004 Tyan Computer
5  * Written by Yinghai Lu <yhlu@tyan.com> for Tyan Computer.
6  * Copyright (C) 2006,2007 AMD
7  * Written by Yinghai Lu <yinghai.lu@amd.com> for AMD.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
22  */
23
24 #include <console/console.h>
25 #include <device/device.h>
26 #include <device/pci.h>
27 #include <device/pci_ids.h>
28 #include <device/pci_ops.h>
29 #include "mcp55.h"
30 #if CONFIG_USBDEBUG
31 #include <usbdebug.h>
32 #endif
33
34 extern struct ehci_debug_info dbg_info;
35
36 static void usb2_init(struct device *dev)
37 {
38         uint32_t dword;
39         dword = pci_read_config32(dev, 0xf8);
40         dword |= 40;
41         pci_write_config32(dev, 0xf8, dword);
42 }
43
44 static void usb2_set_resources(struct device *dev)
45 {
46 #if CONFIG_USBDEBUG
47         struct resource *res;
48         unsigned base;
49         unsigned old_debug;
50
51         old_debug = get_ehci_debug();
52         set_ehci_debug(0);
53 #endif
54         pci_dev_set_resources(dev);
55
56 #if CONFIG_USBDEBUG
57         res = find_resource(dev, 0x10);
58         set_ehci_debug(old_debug);
59         if (!res) return;
60         base = res->base;
61         set_ehci_base(base);
62         report_resource_stored(dev, res, "");
63 #endif
64
65 }
66
67 static void lpci_set_subsystem(device_t dev, unsigned vendor, unsigned device)
68 {
69         pci_write_config32(dev, 0x40,
70                 ((device & 0xffff) << 16) | (vendor & 0xffff));
71 }
72 static struct pci_operations lops_pci = {
73         .set_subsystem  = lpci_set_subsystem,
74 };
75
76 static struct device_operations usb2_ops  = {
77         .read_resources = pci_dev_read_resources,
78         .set_resources  = usb2_set_resources,
79         .enable_resources       = pci_dev_enable_resources,
80         .init           = usb2_init,
81 //      .enable         = mcp55_enable,
82         .scan_bus       = 0,
83         .ops_pci        = &lops_pci,
84 };
85
86 static const struct pci_driver usb2_driver __pci_driver = {
87         .ops    = &usb2_ops,
88         .vendor = PCI_VENDOR_ID_NVIDIA,
89         .device = PCI_DEVICE_ID_NVIDIA_MCP55_USB2,
90 };