1 /* SPDX-License-Identifier: GPL-2.0-only */
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>
10 static void oxford_oxpcie_enable(struct device
*dev
)
12 printk(BIOS_DEBUG
, "Initializing Oxford OXPCIe952\n");
14 struct resource
*res
= probe_resource(dev
, PCI_BASE_ADDRESS_0
);
16 printk(BIOS_WARNING
, "OXPCIe952: No UART resource found.\n");
19 void *bar0
= res2mmio(res
, 0, 0);
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
);
28 static void oxford_oxpcie_set_resources(struct device
*dev
)
30 pci_dev_set_resources(dev
);
32 /* Re-initialize OXPCIe base address after set_resources */
33 u32 mmio_base
= pci_read_config32(dev
, PCI_BASE_ADDRESS_0
);
34 oxford_remap(mmio_base
& ~0xf);
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
,
44 static const struct pci_driver oxford_oxpcie_driver __pci_driver
= {
45 .ops
= &oxford_oxpcie_ops
,
50 static const struct pci_driver oxford_oxpcie_driver_2 __pci_driver
= {
51 .ops
= &oxford_oxpcie_ops
,