ioremap.c 823 B

1234567891011121314151617181920212223242526272829303132333435
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * ioremap implementation.
  4. *
  5. * Copyright (C) 2015 Cadence Design Systems Inc.
  6. */
  7. #include <linux/io.h>
  8. #include <linux/pgtable.h>
  9. #include <asm/cacheflush.h>
  10. #include <asm/io.h>
  11. void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size,
  12. unsigned long prot)
  13. {
  14. unsigned long pfn = __phys_to_pfn((phys_addr));
  15. WARN_ON(pfn_valid(pfn));
  16. return generic_ioremap_prot(phys_addr, size, __pgprot(prot));
  17. }
  18. EXPORT_SYMBOL(ioremap_prot);
  19. void iounmap(volatile void __iomem *addr)
  20. {
  21. unsigned long va = (unsigned long) addr;
  22. if ((va >= XCHAL_KIO_CACHED_VADDR &&
  23. va - XCHAL_KIO_CACHED_VADDR < XCHAL_KIO_SIZE) ||
  24. (va >= XCHAL_KIO_BYPASS_VADDR &&
  25. va - XCHAL_KIO_BYPASS_VADDR < XCHAL_KIO_SIZE))
  26. return;
  27. generic_iounmap(addr);
  28. }
  29. EXPORT_SYMBOL(iounmap);