io-kernel.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. * U-boot - io-kernel.h
  3. *
  4. * Copyright (c) 2005 blackfin.uclinux.org
  5. *
  6. * (C) Copyright 2000-2004
  7. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  8. *
  9. * See file CREDITS for list of people who contributed to this
  10. * project.
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License as
  14. * published by the Free Software Foundation; either version 2 of
  15. * the License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  25. * MA 02111-1307 USA
  26. */
  27. #ifndef _BLACKFIN_IO_H
  28. #define _BLACKFIN_IO_H
  29. #ifdef __KERNEL__
  30. #include <linux/config.h>
  31. /*
  32. * These are for ISA/PCI shared memory _only_ and should never be used
  33. * on any other type of memory, including Zorro memory. They are meant to
  34. * access the bus in the bus byte order which is little-endian!.
  35. *
  36. * readX/writeX() are used to access memory mapped devices. On some
  37. * architectures the memory mapped IO stuff needs to be accessed
  38. * differently. On the m68k architecture, we just read/write the
  39. * memory location directly.
  40. */
  41. /* ++roman: The assignments to temp. vars avoid that gcc sometimes generates
  42. * two accesses to memory, which may be undesireable for some devices.
  43. */
  44. #define readb(addr) ({ unsigned char __v = (*(volatile unsigned char *) (addr));asm("ssync;"); __v; })
  45. #define readw(addr) ({ unsigned short __v = (*(volatile unsigned short *) (addr)); asm("ssync;");__v; })
  46. #define readl(addr) ({ unsigned int __v = (*(volatile unsigned int *) (addr));asm("ssync;"); __v; })
  47. #define writeb(b,addr) (void)((*(volatile unsigned char *) (addr)) = (b))
  48. #define writew(b,addr) (void)((*(volatile unsigned short *) (addr)) = (b))
  49. #define writel(b,addr) (void)((*(volatile unsigned int *) (addr)) = (b))
  50. #define __raw_readb readb
  51. #define __raw_readw readw
  52. #define __raw_readl readl
  53. #define __raw_writeb writeb
  54. #define __raw_writew writew
  55. #define __raw_writel writel
  56. #define memset_io(a,b,c) memset((void *)(a),(b),(c))
  57. #define memcpy_fromio(a,b,c) memcpy((a),(void *)(b),(c))
  58. #define memcpy_toio(a,b,c) memcpy((void *)(a),(b),(c))
  59. #define inb(addr) cf_inb((volatile unsigned char*)(addr))
  60. #define inw(addr) readw(addr)
  61. #define inl(addr) readl(addr)
  62. #define outb(x,addr) cf_outb((unsigned char)(x), (volatile unsigned char*)(addr))
  63. #define outw(x,addr) ((void) writew(x,addr))
  64. #define outl(x,addr) ((void) writel(x,addr))
  65. #define inb_p(addr) inb(addr)
  66. #define inw_p(addr) inw(addr)
  67. #define inl_p(addr) inl(addr)
  68. #define outb_p(x,addr) outb(x,addr)
  69. #define outw_p(x,addr) outw(x,addr)
  70. #define outl_p(x,addr) outl(x,addr)
  71. #define insb(port, addr, count) memcpy((void*)addr, (void*)port, count)
  72. #define insw(port, addr, count) cf_insw((unsigned short*)addr, (unsigned short*)(port), (count))
  73. #define insl(port, addr, count) memcpy((void*)addr, (void*)port, (4*count))
  74. #define outsb(port, addr, count) memcpy((void*)port, (void*)addr, count)
  75. #define outsw(port,addr,count) cf_outsw((unsigned short*)(port), (unsigned short*)addr, (count))
  76. #define outsl(port, addr, count) memcpy((void*)port, (void*)addr, (4*count))
  77. #define IO_SPACE_LIMIT 0xffff
  78. /* Values for nocacheflag and cmode */
  79. #define IOMAP_FULL_CACHING 0
  80. #define IOMAP_NOCACHE_SER 1
  81. #define IOMAP_NOCACHE_NONSER 2
  82. #define IOMAP_WRITETHROUGH 3
  83. #ifndef __ASSEMBLY__
  84. extern void *__ioremap(unsigned long physaddr, unsigned long size,
  85. int cacheflag);
  86. extern void __iounmap(void *addr, unsigned long size);
  87. extern inline void *ioremap(unsigned long physaddr, unsigned long size)
  88. {
  89. return __ioremap(physaddr, size, IOMAP_NOCACHE_SER);
  90. }
  91. extern inline void *ioremap_nocache(unsigned long physaddr, unsigned long size)
  92. {
  93. return __ioremap(physaddr, size, IOMAP_NOCACHE_SER);
  94. }
  95. extern inline void *ioremap_writethrough(unsigned long physaddr,
  96. unsigned long size)
  97. {
  98. return __ioremap(physaddr, size, IOMAP_WRITETHROUGH);
  99. }
  100. extern inline void *ioremap_fullcache(unsigned long physaddr,
  101. unsigned long size)
  102. {
  103. return __ioremap(physaddr, size, IOMAP_FULL_CACHING);
  104. }
  105. extern void iounmap(void *addr);
  106. /* Nothing to do */
  107. extern void blkfin_inv_cache_all(void);
  108. #endif
  109. #define dma_cache_inv(_start,_size) do { blkfin_inv_cache_all();} while (0)
  110. #define dma_cache_wback(_start,_size) do { } while (0)
  111. #define dma_cache_wback_inv(_start,_size) do { blkfin_inv_cache_all();} while (0)
  112. /* Pages to physical address... */
  113. #define page_to_phys(page) ((page - mem_map) << PAGE_SHIFT)
  114. #define page_to_bus(page) ((page - mem_map) << PAGE_SHIFT)
  115. #define mm_ptov(vaddr) ((void *) (vaddr))
  116. #define mm_vtop(vaddr) ((unsigned long) (vaddr))
  117. #define phys_to_virt(vaddr) ((void *) (vaddr))
  118. #define virt_to_phys(vaddr) ((unsigned long) (vaddr))
  119. #define virt_to_bus virt_to_phys
  120. #define bus_to_virt phys_to_virt
  121. #endif
  122. #endif