io.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * DaVinci IO address definitions
  3. *
  4. * Copied from include/asm/arm/arch-omap/io.h
  5. *
  6. * 2007 (c) MontaVista Software, Inc. This file is licensed under
  7. * the terms of the GNU General Public License version 2. This program
  8. * is licensed "as is" without any warranty of any kind, whether express
  9. * or implied.
  10. */
  11. #ifndef __ASM_ARCH_IO_H
  12. #define __ASM_ARCH_IO_H
  13. #define IO_SPACE_LIMIT 0xffffffff
  14. /*
  15. * ----------------------------------------------------------------------------
  16. * I/O mapping
  17. * ----------------------------------------------------------------------------
  18. */
  19. #define IO_PHYS 0x01c00000
  20. #define IO_OFFSET 0xfd000000 /* Virtual IO = 0xfec00000 */
  21. #define IO_SIZE 0x00400000
  22. #define IO_VIRT (IO_PHYS + IO_OFFSET)
  23. #define io_p2v(pa) ((pa) + IO_OFFSET)
  24. #define io_v2p(va) ((va) - IO_OFFSET)
  25. #define IO_ADDRESS(x) io_p2v(x)
  26. /*
  27. * We don't actually have real ISA nor PCI buses, but there is so many
  28. * drivers out there that might just work if we fake them...
  29. */
  30. #define PCIO_BASE 0
  31. #define __io(a) ((void __iomem *)(PCIO_BASE + (a)))
  32. #define __mem_pci(a) (a)
  33. #define __mem_isa(a) (a)
  34. #ifndef __ASSEMBLER__
  35. /*
  36. * Functions to access the DaVinci IO region
  37. *
  38. * NOTE: - Use davinci_read/write[bwl] for physical register addresses
  39. * - Use __raw_read/write[bwl]() for virtual register addresses
  40. * - Use IO_ADDRESS(phys_addr) to convert registers to virtual addresses
  41. * - DO NOT use hardcoded virtual addresses to allow changing the
  42. * IO address space again if needed
  43. */
  44. #define davinci_readb(a) (*(volatile unsigned char *)IO_ADDRESS(a))
  45. #define davinci_readw(a) (*(volatile unsigned short *)IO_ADDRESS(a))
  46. #define davinci_readl(a) (*(volatile unsigned int *)IO_ADDRESS(a))
  47. #define davinci_writeb(v,a) (*(volatile unsigned char *)IO_ADDRESS(a) = (v))
  48. #define davinci_writew(v,a) (*(volatile unsigned short *)IO_ADDRESS(a) = (v))
  49. #define davinci_writel(v,a) (*(volatile unsigned int *)IO_ADDRESS(a) = (v))
  50. /* 16 bit uses LDRH/STRH, base +/- offset_8 */
  51. typedef struct { volatile u16 offset[256]; } __regbase16;
  52. #define __REGV16(vaddr) ((__regbase16 *)((vaddr)&~0xff)) \
  53. ->offset[((vaddr)&0xff)>>1]
  54. #define __REG16(paddr) __REGV16(io_p2v(paddr))
  55. /* 8/32 bit uses LDR/STR, base +/- offset_12 */
  56. typedef struct { volatile u8 offset[4096]; } __regbase8;
  57. #define __REGV8(vaddr) ((__regbase8 *)((vaddr)&~4095)) \
  58. ->offset[((vaddr)&4095)>>0]
  59. #define __REG8(paddr) __REGV8(io_p2v(paddr))
  60. typedef struct { volatile u32 offset[4096]; } __regbase32;
  61. #define __REGV32(vaddr) ((__regbase32 *)((vaddr)&~4095)) \
  62. ->offset[((vaddr)&4095)>>2]
  63. #define __REG(paddr) __REGV32(io_p2v(paddr))
  64. #else
  65. #define __REG(x) (*((volatile unsigned long *)io_p2v(x)))
  66. #endif /* __ASSEMBLER__ */
  67. #endif /* __ASM_ARCH_IO_H */