/* SPDX-License-Identifier: GPL-2.0 */ #include <linux/device.h> #include <linux/types.h> #include <linux/io.h> #include <linux/mm.h> #include <linux/ioremap.h> #ifndef arch_memremap_wb static void *arch_memremap_wb(resource_size_t offset, unsigned long size) { … } #endif #ifndef arch_memremap_can_ram_remap static bool arch_memremap_can_ram_remap(resource_size_t offset, size_t size, unsigned long flags) { return true; } #endif static void *try_ram_remap(resource_size_t offset, size_t size, unsigned long flags) { … } /** * memremap() - remap an iomem_resource as cacheable memory * @offset: iomem resource start address * @size: size of remap * @flags: any of MEMREMAP_WB, MEMREMAP_WT, MEMREMAP_WC, * MEMREMAP_ENC, MEMREMAP_DEC * * memremap() is "ioremap" for cases where it is known that the resource * being mapped does not have i/o side effects and the __iomem * annotation is not applicable. In the case of multiple flags, the different * mapping types will be attempted in the order listed below until one of * them succeeds. * * MEMREMAP_WB - matches the default mapping for System RAM on * the architecture. This is usually a read-allocate write-back cache. * Moreover, if MEMREMAP_WB is specified and the requested remap region is RAM * memremap() will bypass establishing a new mapping and instead return * a pointer into the direct map. * * MEMREMAP_WT - establish a mapping whereby writes either bypass the * cache or are written through to memory and never exist in a * cache-dirty state with respect to program visibility. Attempts to * map System RAM with this mapping type will fail. * * MEMREMAP_WC - establish a writecombine mapping, whereby writes may * be coalesced together (e.g. in the CPU's write buffers), but is otherwise * uncached. Attempts to map System RAM with this mapping type will fail. */ void *memremap(resource_size_t offset, size_t size, unsigned long flags) { … } EXPORT_SYMBOL(…); void memunmap(void *addr) { … } EXPORT_SYMBOL(…); static void devm_memremap_release(struct device *dev, void *res) { … } static int devm_memremap_match(struct device *dev, void *res, void *match_data) { … } void *devm_memremap(struct device *dev, resource_size_t offset, size_t size, unsigned long flags) { … } EXPORT_SYMBOL(…); void devm_memunmap(struct device *dev, void *addr) { … } EXPORT_SYMBOL(…);