2 * (c) Copyright 2006 Hewlett-Packard Development Company, L.P.
3 * Bjorn Helgaas <bjorn.helgaas@hp.com>
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.
10 #include <linux/compiler.h>
11 #include <linux/module.h>
12 #include <linux/efi.h>
14 #include <asm/meminit.h>
16 static inline void __iomem
*
17 __ioremap (unsigned long offset
, unsigned long size
)
19 return (void __iomem
*) (__IA64_UNCACHED_OFFSET
| offset
);
23 ioremap (unsigned long offset
, unsigned long size
)
26 unsigned long gran_base
, gran_size
;
29 * For things in kern_memmap, we must use the same attribute
30 * as the rest of the kernel. For more details, see
31 * Documentation/ia64/aliasing.txt.
33 attr
= kern_mem_attribute(offset
, size
);
34 if (attr
& EFI_MEMORY_WB
)
35 return (void __iomem
*) phys_to_virt(offset
);
36 else if (attr
& EFI_MEMORY_UC
)
37 return __ioremap(offset
, size
);
40 * Some chipsets don't support UC access to memory. If
41 * WB is supported for the whole granule, we prefer that.
43 gran_base
= GRANULEROUNDDOWN(offset
);
44 gran_size
= GRANULEROUNDUP(offset
+ size
) - gran_base
;
45 if (efi_mem_attribute(gran_base
, gran_size
) & EFI_MEMORY_WB
)
46 return (void __iomem
*) phys_to_virt(offset
);
48 return __ioremap(offset
, size
);
50 EXPORT_SYMBOL(ioremap
);
53 ioremap_nocache (unsigned long offset
, unsigned long size
)
55 if (kern_mem_attribute(offset
, size
) & EFI_MEMORY_WB
)
58 return __ioremap(offset
, size
);
60 EXPORT_SYMBOL(ioremap_nocache
);