blob: 3c31db49f09930c138bb41f63e4b73ad4d71220b [file] [log] [blame]
Angel Pons4b429832020-04-02 23:48:50 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Kyösti Mälkki03eb8a82016-06-14 14:49:07 -05002
3#include <device/device.h>
4#include <device/pci.h>
5#include <device/pci_ids.h>
Kyösti Mälkki03eb8a82016-06-14 14:49:07 -05006#include <lib.h>
7
8static void iommu_read_resources(struct device *dev)
9{
10 struct resource *res;
11
12 /* Get the normal pci resources of this device */
13 pci_dev_read_resources(dev);
14
Felix Heldddf137f2022-02-04 19:27:48 +010015 /* IOMMU MMIO registers */
Kyösti Mälkki03eb8a82016-06-14 14:49:07 -050016 res = new_resource(dev, 0x44);
17 res->size = 512 * 1024;
18 res->align = log2(res->size);
19 res->gran = log2(res->size);
20 res->limit = 0xffffffff; /* 4G */
21 res->flags = IORESOURCE_MEM;
22}
23
Kyösti Mälkki03eb8a82016-06-14 14:49:07 -050024static struct device_operations iommu_ops = {
25 .read_resources = iommu_read_resources,
Felix Helda4d033a2022-02-04 19:14:50 +010026 .set_resources = pci_dev_set_resources,
Kyösti Mälkki03eb8a82016-06-14 14:49:07 -050027 .enable_resources = pci_dev_enable_resources,
Angel Pons1fc0edd2020-05-31 00:03:28 +020028 .ops_pci = &pci_dev_ops_pci,
Kyösti Mälkki03eb8a82016-06-14 14:49:07 -050029};
30
31static const struct pci_driver iommu_driver __pci_driver = {
32 .ops = &iommu_ops,
Felix Singer43b7f412022-03-07 04:34:52 +010033 .vendor = PCI_VID_AMD,
34 .device = PCI_DID_AMD_16H_MODEL_303F_NB_IOMMU,
Kyösti Mälkki03eb8a82016-06-14 14:49:07 -050035};