blob: 1ff4cfbbc9f21f488e47bac572b5b55ea27d3d8d [file] [log] [blame]
Kyösti Mälkki03eb8a82016-06-14 14:49:07 -05001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2013 Rudolf Marek <r.marek@assembler.cz>
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
16#include <device/device.h>
17#include <device/pci.h>
18#include <device/pci_ids.h>
19#include <device/pci_ops.h>
20#include <lib.h>
21
22static void iommu_read_resources(struct device *dev)
23{
24 struct resource *res;
25
26 /* Get the normal pci resources of this device */
27 pci_dev_read_resources(dev);
28
29 /* Add an extra subtractive resource for both memory and I/O. */
30 res = new_resource(dev, 0x44);
31 res->size = 512 * 1024;
32 res->align = log2(res->size);
33 res->gran = log2(res->size);
34 res->limit = 0xffffffff; /* 4G */
35 res->flags = IORESOURCE_MEM;
36}
37
38static void iommu_set_resources(struct device *dev)
39{
40 pci_dev_set_resources(dev);
41}
42
43static struct pci_operations lops_pci = {
44 .set_subsystem = pci_dev_set_subsystem,
45};
46
47static struct device_operations iommu_ops = {
48 .read_resources = iommu_read_resources,
49 .set_resources = iommu_set_resources,
50 .enable_resources = pci_dev_enable_resources,
51 .init = 0,
52 .scan_bus = 0,
53 .ops_pci = &lops_pci,
54};
55
56static const struct pci_driver iommu_driver __pci_driver = {
57 .ops = &iommu_ops,
58 .vendor = PCI_VENDOR_ID_AMD,
59 .device = PCI_DEVICE_ID_AMD_16H_MODEL_303F_NB_IOMMU,
60};