io.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * (C) Copyright 2011, Julius Baxter <julius@opencores.org>
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of
  7. * the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  17. * MA 02111-1307 USA
  18. */
  19. #ifndef __ASM_OPENRISC_IO_H
  20. #define __ASM_OPENRISC_IO_H
  21. /*
  22. * Given a physical address and a length, return a virtual address
  23. * that can be used to access the memory range with the caching
  24. * properties specified by "flags".
  25. */
  26. #define MAP_NOCACHE (0)
  27. #define MAP_WRCOMBINE (0)
  28. #define MAP_WRBACK (0)
  29. #define MAP_WRTHROUGH (0)
  30. static inline void *
  31. map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags)
  32. {
  33. return (void *)paddr;
  34. }
  35. /*
  36. * Take down a mapping set up by map_physmem().
  37. */
  38. static inline void unmap_physmem(void *vaddr, unsigned long flags)
  39. {
  40. }
  41. /*
  42. * Change virtual addresses to physical addresses
  43. */
  44. static inline phys_addr_t virt_to_phys(void *vaddr)
  45. {
  46. return (phys_addr_t)(vaddr);
  47. }
  48. /*
  49. * readX/writeX() are used to access memory mapped devices. On some
  50. * architectures the memory mapped IO stuff needs to be accessed
  51. * differently. On the openrisc architecture, we just read/write the
  52. * memory location directly.
  53. */
  54. #define readb(addr) (*(volatile unsigned char *) (addr))
  55. #define readw(addr) (*(volatile unsigned short *) (addr))
  56. #define readl(addr) (*(volatile unsigned int *) (addr))
  57. #define __raw_readb readb
  58. #define __raw_readw readw
  59. #define __raw_readl readl
  60. #define writeb(b, addr) ((*(volatile unsigned char *) (addr)) = (b))
  61. #define writew(b, addr) ((*(volatile unsigned short *) (addr)) = (b))
  62. #define writel(b, addr) ((*(volatile unsigned int *) (addr)) = (b))
  63. #define __raw_writeb writeb
  64. #define __raw_writew writew
  65. #define __raw_writel writel
  66. #define memset_io(a, b, c) memset((void *)(a), (b), (c))
  67. #define memcpy_fromio(a, b, c) memcpy((a), (void *)(b), (c))
  68. #define memcpy_toio(a, b, c) memcpy((void *)(a), (b), (c))
  69. /*
  70. * Again, OpenRISC does not require mem IO specific function.
  71. */
  72. #define IO_BASE 0x0
  73. #define IO_SPACE_LIMIT 0xffffffff
  74. #define inb(port) readb((port + IO_BASE))
  75. #define outb(value, port) writeb((value), (port + IO_BASE))
  76. #define inb_p(port) inb((port))
  77. #define outb_p(value, port) outb((value), (port))
  78. /*
  79. * Convert a physical pointer to a virtual kernel pointer for /dev/mem
  80. * access
  81. */
  82. #define xlate_dev_mem_ptr(p) __va(p)
  83. /*
  84. * Convert a virtual cached pointer to an uncached pointer
  85. */
  86. #define xlate_dev_kmem_ptr(p) p
  87. #define ioread8(addr) readb(addr)
  88. #define ioread16(addr) readw(addr)
  89. #define ioread32(addr) readl(addr)
  90. #define iowrite8(v, addr) writeb((v), (addr))
  91. #define iowrite16(v, addr) writew((v), (addr))
  92. #define iowrite32(v, addr) writel((v), (addr))
  93. #endif