diff options
author | Joerg Roedel <joerg.roedel@amd.com> | 2008-06-26 15:27:44 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-06-27 04:12:10 -0400 |
commit | b2026aa2dce4454950ccd9c410790f310d65696a (patch) | |
tree | 1315db5d19a3c14f815d27b4dedbd1916e350d25 /arch/x86/kernel/amd_iommu_init.c | |
parent | 6c56747b46717b4c6a890b35e8518f4be961dc7e (diff) |
x86, AMD IOMMU: add functions for programming IOMMU MMIO space
This patch adds the functions required to programm the IOMMU with the MMIO
space.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Cc: iommu@lists.linux-foundation.org
Cc: bhavna.sarathy@amd.com
Cc: Sebastian.Biemueller@amd.com
Cc: robert.richter@amd.com
Cc: joro@8bytes.org
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/amd_iommu_init.c')
-rw-r--r-- | arch/x86/kernel/amd_iommu_init.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/arch/x86/kernel/amd_iommu_init.c b/arch/x86/kernel/amd_iommu_init.c index 3147e6991005..ffb8ac82e32f 100644 --- a/arch/x86/kernel/amd_iommu_init.c +++ b/arch/x86/kernel/amd_iommu_init.c | |||
@@ -117,6 +117,66 @@ static u32 dev_table_size; | |||
117 | static u32 alias_table_size; | 117 | static u32 alias_table_size; |
118 | static u32 rlookup_table_size; | 118 | static u32 rlookup_table_size; |
119 | 119 | ||
120 | static void __init iommu_set_exclusion_range(struct amd_iommu *iommu) | ||
121 | { | ||
122 | u64 start = iommu->exclusion_start & PAGE_MASK; | ||
123 | u64 limit = (start + iommu->exclusion_length) & PAGE_MASK; | ||
124 | u64 entry; | ||
125 | |||
126 | if (!iommu->exclusion_start) | ||
127 | return; | ||
128 | |||
129 | entry = start | MMIO_EXCL_ENABLE_MASK; | ||
130 | memcpy_toio(iommu->mmio_base + MMIO_EXCL_BASE_OFFSET, | ||
131 | &entry, sizeof(entry)); | ||
132 | |||
133 | entry = limit; | ||
134 | memcpy_toio(iommu->mmio_base + MMIO_EXCL_LIMIT_OFFSET, | ||
135 | &entry, sizeof(entry)); | ||
136 | } | ||
137 | |||
138 | static void __init iommu_set_device_table(struct amd_iommu *iommu) | ||
139 | { | ||
140 | u32 entry; | ||
141 | |||
142 | BUG_ON(iommu->mmio_base == NULL); | ||
143 | |||
144 | entry = virt_to_phys(amd_iommu_dev_table); | ||
145 | entry |= (dev_table_size >> 12) - 1; | ||
146 | memcpy_toio(iommu->mmio_base + MMIO_DEV_TABLE_OFFSET, | ||
147 | &entry, sizeof(entry)); | ||
148 | } | ||
149 | |||
150 | static void __init iommu_feature_enable(struct amd_iommu *iommu, u8 bit) | ||
151 | { | ||
152 | u32 ctrl; | ||
153 | |||
154 | ctrl = readl(iommu->mmio_base + MMIO_CONTROL_OFFSET); | ||
155 | ctrl |= (1 << bit); | ||
156 | writel(ctrl, iommu->mmio_base + MMIO_CONTROL_OFFSET); | ||
157 | } | ||
158 | |||
159 | static void __init iommu_feature_disable(struct amd_iommu *iommu, u8 bit) | ||
160 | { | ||
161 | u32 ctrl; | ||
162 | |||
163 | ctrl = (u64)readl(iommu->mmio_base + MMIO_CONTROL_OFFSET); | ||
164 | ctrl &= ~(1 << bit); | ||
165 | writel(ctrl, iommu->mmio_base + MMIO_CONTROL_OFFSET); | ||
166 | } | ||
167 | |||
168 | void __init iommu_enable(struct amd_iommu *iommu) | ||
169 | { | ||
170 | u32 ctrl; | ||
171 | |||
172 | printk(KERN_INFO "AMD IOMMU: Enabling IOMMU at "); | ||
173 | print_devid(iommu->devid, 0); | ||
174 | printk(" cap 0x%hx\n", iommu->cap_ptr); | ||
175 | |||
176 | iommu_feature_enable(iommu, CONTROL_IOMMU_EN); | ||
177 | ctrl = readl(iommu->mmio_base + MMIO_CONTROL_OFFSET); | ||
178 | } | ||
179 | |||
120 | static u8 * __init iommu_map_mmio_space(u64 address) | 180 | static u8 * __init iommu_map_mmio_space(u64 address) |
121 | { | 181 | { |
122 | u8 *ret; | 182 | u8 *ret; |