1 | /* |
---|
2 | * (c) Copyright 2006 Hewlett-Packard Development Company, L.P. |
---|
3 | * Bjorn Helgaas <bjorn.helgaas@hp.com> |
---|
4 | * |
---|
5 | * This program is free software; you can redistribute it and/or modify |
---|
6 | * it under the terms of the GNU General Public License version 2 as |
---|
7 | * published by the Free Software Foundation. |
---|
8 | */ |
---|
9 | |
---|
10 | #include <linux/compiler.h> |
---|
11 | #include <linux/module.h> |
---|
12 | #include <linux/efi.h> |
---|
13 | #include <asm/io.h> |
---|
14 | #include <asm/meminit.h> |
---|
15 | |
---|
16 | static inline void __iomem * |
---|
17 | __ioremap (unsigned long offset, unsigned long size) |
---|
18 | { |
---|
19 | offset = HYPERVISOR_ioremap(offset, size); |
---|
20 | if (IS_ERR_VALUE(offset)) |
---|
21 | return (void __iomem*)offset; |
---|
22 | return (void __iomem *) (__IA64_UNCACHED_OFFSET | offset); |
---|
23 | } |
---|
24 | |
---|
25 | void __iomem * |
---|
26 | ioremap (unsigned long offset, unsigned long size) |
---|
27 | { |
---|
28 | u64 attr; |
---|
29 | unsigned long gran_base, gran_size; |
---|
30 | |
---|
31 | /* |
---|
32 | * For things in kern_memmap, we must use the same attribute |
---|
33 | * as the rest of the kernel. For more details, see |
---|
34 | * Documentation/ia64/aliasing.txt. |
---|
35 | */ |
---|
36 | attr = kern_mem_attribute(offset, size); |
---|
37 | if (attr & EFI_MEMORY_WB) |
---|
38 | return (void __iomem *) phys_to_virt(offset); |
---|
39 | else if (attr & EFI_MEMORY_UC) |
---|
40 | return __ioremap(offset, size); |
---|
41 | |
---|
42 | /* |
---|
43 | * Some chipsets don't support UC access to memory. If |
---|
44 | * WB is supported for the whole granule, we prefer that. |
---|
45 | */ |
---|
46 | gran_base = GRANULEROUNDDOWN(offset); |
---|
47 | gran_size = GRANULEROUNDUP(offset + size) - gran_base; |
---|
48 | if (efi_mem_attribute(gran_base, gran_size) & EFI_MEMORY_WB) |
---|
49 | return (void __iomem *) phys_to_virt(offset); |
---|
50 | |
---|
51 | return __ioremap(offset, size); |
---|
52 | } |
---|
53 | EXPORT_SYMBOL(ioremap); |
---|
54 | |
---|
55 | void __iomem * |
---|
56 | ioremap_nocache (unsigned long offset, unsigned long size) |
---|
57 | { |
---|
58 | if (kern_mem_attribute(offset, size) & EFI_MEMORY_WB) |
---|
59 | return NULL; |
---|
60 | |
---|
61 | return __ioremap(offset, size); |
---|
62 | } |
---|
63 | EXPORT_SYMBOL(ioremap_nocache); |
---|