e1fb65f9db318090f6c10576d170ce92a17f6285
[coreboot.git] / src / drivers / oxford / oxpcie / oxpcie.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2011 Google Inc
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; version 2 of the License.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
18  */
19
20 #include <device/device.h>
21 #include <device/pci_def.h>
22 #include <device/pci.h>
23 #include <device/pci_ids.h>
24 #include <console/console.h>
25 #include <arch/io.h>
26 #include <uart8250.h>
27
28 static void oxford_oxpcie_enable(device_t dev)
29 {
30         printk(BIOS_DEBUG, "Initializing Oxford OXPCIe952\n");
31
32         struct resource *res = find_resource(dev, 0x10);
33         if (!res) {
34                 printk(BIOS_WARNING, "OXPCIe952: No UART resource found.\n");
35                 return;
36         }
37
38         printk(BIOS_DEBUG, "OXPCIe952: Class=%x Revision ID=%x\n",
39                         (read32(res->base) >> 8), (read32(res->base) & 0xff));
40         printk(BIOS_DEBUG, "OXPCIe952: %d UARTs detected.\n",
41                         (read32(res->base + 4) & 3));
42 }
43
44 static struct device_operations oxford_oxpcie_ops = {
45         .read_resources   = pci_dev_read_resources,
46         .set_resources    = pci_dev_set_resources,
47         .enable_resources = pci_dev_enable_resources,
48         .init             = oxford_oxpcie_enable,
49         .scan_bus         = 0,
50 };
51
52 static const struct pci_driver oxford_oxpcie_driver __pci_driver = {
53         .ops    = &oxford_oxpcie_ops,
54         .vendor = 0x1415,
55         .device = 0xc158,
56 };
57
58 static const struct pci_driver oxford_oxpcie_driver_2 __pci_driver = {
59         .ops    = &oxford_oxpcie_ops,
60         .vendor = 0x1415,
61         .device = 0xc11b,
62 };