Marc Jones | bc94aea | 2018-09-26 09:57:08 -0600 | [diff] [blame^] | 1 | /* |
| 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 | |
| 22 | static 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 | |
| 38 | static struct pci_operations lops_pci = { |
| 39 | .set_subsystem = pci_dev_set_subsystem, |
| 40 | }; |
| 41 | |
| 42 | static struct device_operations iommu_ops = { |
| 43 | .read_resources = iommu_read_resources, |
| 44 | .set_resources = pci_dev_set_resources, |
| 45 | .enable_resources = pci_dev_enable_resources, |
| 46 | .init = 0, |
| 47 | .scan_bus = 0, |
| 48 | .ops_pci = &lops_pci, |
| 49 | }; |
| 50 | |
| 51 | static const struct pci_driver iommu_driver __pci_driver = { |
| 52 | .ops = &iommu_ops, |
| 53 | .vendor = PCI_VENDOR_ID_AMD, |
| 54 | .device = PCI_DEVICE_ID_AMD_15H_MODEL_707F_NB_IOMMU, |
| 55 | }; |