| 1 |
|
| 2 |
|
| 3 |
#include <device/device.h> |
| 4 |
#include <device/pci.h> |
| 5 |
#include <console/console.h> |
| 6 |
#include <console/uart.h> |
| 7 |
#include <device/mmio.h> |
| 8 |
#include <device/pci_ops.h> |
| 9 |
|
| 10 |
static void oxford_oxpcie_enable(struct device *dev) |
| 11 |
{ |
| 12 |
printk(BIOS_DEBUG, "Initializing Oxford OXPCIe952\n"); |
| 13 |
|
| 14 |
struct resource *res = probe_resource(dev, PCI_BASE_ADDRESS_0); |
| 15 |
if (!res) { |
| 16 |
printk(BIOS_WARNING, "OXPCIe952: No UART resource found.\n"); |
| 17 |
return; |
| 18 |
} |
| 19 |
void *bar0 = res2mmio(res, 0, 0); |
| 20 |
|
| 21 |
printk(BIOS_DEBUG, "OXPCIe952: Class=%x Revision ID=%x\n", |
| 22 |
(read32(bar0) >> 8), (read32(bar0) & 0xff)); |
| 23 |
printk(BIOS_DEBUG, "OXPCIe952: %d UARTs detected.\n", |
| 24 |
(read32(bar0 + 4) & 3)); |
| 25 |
printk(BIOS_DEBUG, "OXPCIe952: UART BAR: 0x%x\n", (u32)res->base); |
| 26 |
} |
| 27 |
|
| 28 |
static void oxford_oxpcie_set_resources(struct device *dev) |
| 29 |
{ |
| 30 |
pci_dev_set_resources(dev); |
| 31 |
|
| 32 |
|
| 33 |
u32 mmio_base = pci_read_config32(dev, PCI_BASE_ADDRESS_0); |
| 34 |
oxford_remap(mmio_base & ~0xf); |
| 35 |
} |
| 36 |
|
| 37 |
static struct device_operations oxford_oxpcie_ops = { |
| 38 |
.read_resources = pci_dev_read_resources, |
| 39 |
.set_resources = oxford_oxpcie_set_resources, |
| 40 |
.enable_resources = pci_dev_enable_resources, |
| 41 |
.init = oxford_oxpcie_enable, |
| 42 |
}; |
| 43 |
|
| 44 |
static const struct pci_driver oxford_oxpcie_driver __pci_driver = { |
| 45 |
.ops = &oxford_oxpcie_ops, |
| 46 |
.vendor = 0x1415, |
| 47 |
.device = 0xc158, |
| 48 |
}; |
| 49 |
|
| 50 |
static const struct pci_driver oxford_oxpcie_driver_2 __pci_driver = { |
| 51 |
.ops = &oxford_oxpcie_ops, |
| 52 |
.vendor = 0x1415, |
| 53 |
.device = 0xc11b, |
| 54 |
}; |