Ever wondered where those "setting incorrect section attributes for
[coreboot.git] / src / southbridge / intel / i82801db / i82801db_ehci.c
1 /*
2  * This file is part of the LinuxBIOS project.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
17  */
18
19 #include <console/console.h>
20 #include <device/device.h>
21 #include <device/pci.h>
22 #include <device/pci_ids.h>
23 #include <device/pci_ops.h>
24 #include "i82801db.h"
25
26 static void ehci_init(struct device *dev)
27 {
28         uint32_t cmd;
29
30         printk_debug("EHCI: Setting up controller.. ");
31         cmd = pci_read_config32(dev, PCI_COMMAND);
32         pci_write_config32(dev, PCI_COMMAND, 
33                 cmd | PCI_COMMAND_MASTER);
34
35         printk_debug("done.\n");
36 }
37
38 static void ehci_set_subsystem(device_t dev, unsigned vendor, unsigned device)
39 {
40         uint8_t access_cntl;
41         access_cntl = pci_read_config8(dev, 0x80);
42         /* Enable writes to protected registers */
43         pci_write_config8(dev, 0x80, access_cntl | 1);
44         /* Write the subsystem vendor and device id */
45         pci_write_config32(dev, PCI_SUBSYSTEM_VENDOR_ID, 
46                 ((device & 0xffff) << 16) | (vendor & 0xffff));
47         /* Restore protection */
48         pci_write_config8(dev, 0x80, access_cntl);
49 }
50
51 static struct pci_operations lops_pci = {
52         .set_subsystem = &ehci_set_subsystem,
53 };
54 static struct device_operations ehci_ops  = {
55         .read_resources   = pci_dev_read_resources,
56         .set_resources    = pci_dev_set_resources,
57         .enable_resources = pci_dev_enable_resources,
58         .init             = ehci_init,
59         .scan_bus         = 0,
60         .enable           = i82801db_enable,
61         .ops_pci          = &lops_pci,
62 };
63
64 static const struct pci_driver ehci_driver __pci_driver = {
65         .ops    = &ehci_ops,
66         .vendor = PCI_VENDOR_ID_INTEL,
67         .device = PCI_DEVICE_ID_INTEL_82801DB_EHCI,
68 };