io.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /* SPARC I/O definitions
  2. *
  3. * (C) Copyright 2007, 2015
  4. * Daniel Hellstrom, Cobham Gaisler, daniel@gaisler.com.
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #ifndef _SPARC_IO_H
  9. #define _SPARC_IO_H
  10. /* Nothing to sync, total store ordering (TSO)... */
  11. #define sync()
  12. /*
  13. * Generic virtual read/write.
  14. */
  15. #ifndef CONFIG_SYS_HAS_NO_CACHE
  16. /* Forces a cache miss on read/load.
  17. * On some architectures we need to bypass the cache when reading
  18. * I/O registers so that we are not reading the same status word
  19. * over and over again resulting in a hang (until an IRQ if lucky)
  20. */
  21. #define __arch_getb(a) SPARC_NOCACHE_READ_BYTE((unsigned int)(a))
  22. #define __arch_getw(a) SPARC_NOCACHE_READ_HWORD((unsigned int)(a))
  23. #define __arch_getl(a) SPARC_NOCACHE_READ((unsigned int)(a))
  24. #define __arch_getq(a) SPARC_NOCACHE_READ_DWORD((unsigned int)(a))
  25. #else
  26. #define __arch_getb(a) (*(volatile unsigned char *)(a))
  27. #define __arch_getw(a) (*(volatile unsigned short *)(a))
  28. #define __arch_getl(a) (*(volatile unsigned int *)(a))
  29. #define __arch_getq(a) (*(volatile unsigned long long *)(a))
  30. #endif /* CONFIG_SYS_HAS_NO_CACHE */
  31. #define __arch_putb(v, a) (*(volatile unsigned char *)(a) = (v))
  32. #define __arch_putw(v, a) (*(volatile unsigned short *)(a) = (v))
  33. #define __arch_putl(v, a) (*(volatile unsigned int *)(a) = (v))
  34. #define __arch_putq(v, a) (*(volatile unsigned long long *)(a) = (v))
  35. #define __raw_writeb(v, a) __arch_putb(v, a)
  36. #define __raw_writew(v, a) __arch_putw(v, a)
  37. #define __raw_writel(v, a) __arch_putl(v, a)
  38. #define __raw_writeq(v, a) __arch_putq(v, a)
  39. #define __raw_readb(a) __arch_getb(a)
  40. #define __raw_readw(a) __arch_getw(a)
  41. #define __raw_readl(a) __arch_getl(a)
  42. #define __raw_readq(a) __arch_getq(a)
  43. #define writeb __raw_writeb
  44. #define writew __raw_writew
  45. #define writel __raw_writel
  46. #define writeq __raw_writeq
  47. #define readb __raw_readb
  48. #define readw __raw_readw
  49. #define readl __raw_readl
  50. #define readq __raw_readq
  51. /*
  52. * Given a physical address and a length, return a virtual address
  53. * that can be used to access the memory range with the caching
  54. * properties specified by "flags".
  55. */
  56. #define MAP_NOCACHE (0)
  57. #define MAP_WRCOMBINE (0)
  58. #define MAP_WRBACK (0)
  59. #define MAP_WRTHROUGH (0)
  60. static inline void *map_physmem(phys_addr_t paddr, unsigned long len,
  61. unsigned long flags)
  62. {
  63. return (void *)paddr;
  64. }
  65. /*
  66. * Take down a mapping set up by map_physmem().
  67. */
  68. static inline void unmap_physmem(void *vaddr, unsigned long flags)
  69. {
  70. }
  71. static inline phys_addr_t virt_to_phys(void * vaddr)
  72. {
  73. return (phys_addr_t)(vaddr);
  74. }
  75. #endif