io.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* SPARC I/O definitions
  2. *
  3. * (C) Copyright 2007
  4. * Daniel Hellstrom, Gaisler Research, daniel@gaisler.com.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation; either version 2 of
  9. * the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  19. * MA 02111-1307 USA
  20. *
  21. */
  22. #ifndef _SPARC_IO_H
  23. #define _SPARC_IO_H
  24. /* Nothing to sync, total store ordering (TSO)... */
  25. #define sync()
  26. /* Forces a cache miss on read/load.
  27. * On some architectures we need to bypass the cache when reading
  28. * I/O registers so that we are not reading the same status word
  29. * over and over again resulting in a hang (until an IRQ if lucky)
  30. *
  31. */
  32. #ifndef CFG_HAS_NO_CACHE
  33. #define READ_BYTE(var) SPARC_NOCACHE_READ_BYTE((unsigned int)(var))
  34. #define READ_HWORD(var) SPARC_NOCACHE_READ_HWORD((unsigned int)(var))
  35. #define READ_WORD(var) SPARC_NOCACHE_READ((unsigned int)(var))
  36. #define READ_DWORD(var) SPARC_NOCACHE_READ_DWORD((unsigned int)(var))
  37. #else
  38. #define READ_BYTE(var) (var)
  39. #define READ_HWORD(var) (var)
  40. #define READ_WORD(var) (var)
  41. #define READ_DWORD(var) (var)
  42. #endif
  43. /*
  44. * Generic virtual read/write.
  45. */
  46. #define __arch_getb(a) (READ_BYTE(a))
  47. #define __arch_getw(a) (READ_HWORD(a))
  48. #define __arch_getl(a) (READ_WORD(a))
  49. #define __arch_getq(a) (READ_DWORD(a))
  50. #define __arch_putb(v,a) (*(volatile unsigned char *)(a) = (v))
  51. #define __arch_putw(v,a) (*(volatile unsigned short *)(a) = (v))
  52. #define __arch_putl(v,a) (*(volatile unsigned int *)(a) = (v))
  53. #define __raw_writeb(v,a) __arch_putb(v,a)
  54. #define __raw_writew(v,a) __arch_putw(v,a)
  55. #define __raw_writel(v,a) __arch_putl(v,a)
  56. #define __raw_readb(a) __arch_getb(a)
  57. #define __raw_readw(a) __arch_getw(a)
  58. #define __raw_readl(a) __arch_getl(a)
  59. #define __raw_readq(a) __arch_getq(a)
  60. /*
  61. * Given a physical address and a length, return a virtual address
  62. * that can be used to access the memory range with the caching
  63. * properties specified by "flags".
  64. */
  65. typedef unsigned long phys_addr_t;
  66. #define MAP_NOCACHE (0)
  67. #define MAP_WRCOMBINE (0)
  68. #define MAP_WRBACK (0)
  69. #define MAP_WRTHROUGH (0)
  70. static inline void *map_physmem(phys_addr_t paddr, unsigned long len,
  71. unsigned long flags)
  72. {
  73. return (void *)paddr;
  74. }
  75. /*
  76. * Take down a mapping set up by map_physmem().
  77. */
  78. static inline void unmap_physmem(void *vaddr, unsigned long flags)
  79. {
  80. }
  81. #endif