io.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * arch/arm/mach-tegra/include/mach/io.h
  3. *
  4. * Copyright (C) 2010 Google, Inc.
  5. *
  6. * Author:
  7. * Colin Cross <ccross@google.com>
  8. * Erik Gilling <konkers@google.com>
  9. *
  10. * This software is licensed under the terms of the GNU General Public
  11. * License version 2, as published by the Free Software Foundation, and
  12. * may be copied, distributed, and modified under those terms.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. */
  20. #ifndef __MACH_TEGRA_IO_H
  21. #define __MACH_TEGRA_IO_H
  22. #define IO_SPACE_LIMIT 0xffffffff
  23. /* On TEGRA, many peripherals are very closely packed in
  24. * two 256MB io windows (that actually only use about 64KB
  25. * at the start of each).
  26. *
  27. * We will just map the first 1MB of each window (to minimize
  28. * pt entries needed) and provide a macro to transform physical
  29. * io addresses to an appropriate void __iomem *.
  30. *
  31. */
  32. #define IO_CPU_PHYS 0x50040000
  33. #define IO_CPU_VIRT 0xFE000000
  34. #define IO_CPU_SIZE SZ_16K
  35. #define IO_PPSB_PHYS 0x60000000
  36. #define IO_PPSB_VIRT 0xFE200000
  37. #define IO_PPSB_SIZE SZ_1M
  38. #define IO_APB_PHYS 0x70000000
  39. #define IO_APB_VIRT 0xFE300000
  40. #define IO_APB_SIZE SZ_1M
  41. #define IO_TO_VIRT_BETWEEN(p, st, sz) ((p) >= (st) && (p) < ((st) + (sz)))
  42. #define IO_TO_VIRT_XLATE(p, pst, vst) (((p) - (pst) + (vst)))
  43. #define IO_TO_VIRT(n) ( \
  44. IO_TO_VIRT_BETWEEN((n), IO_PPSB_PHYS, IO_PPSB_SIZE) ? \
  45. IO_TO_VIRT_XLATE((n), IO_PPSB_PHYS, IO_PPSB_VIRT) : \
  46. IO_TO_VIRT_BETWEEN((n), IO_APB_PHYS, IO_APB_SIZE) ? \
  47. IO_TO_VIRT_XLATE((n), IO_APB_PHYS, IO_APB_VIRT) : \
  48. IO_TO_VIRT_BETWEEN((n), IO_CPU_PHYS, IO_CPU_SIZE) ? \
  49. IO_TO_VIRT_XLATE((n), IO_CPU_PHYS, IO_CPU_VIRT) : \
  50. 0)
  51. #ifndef __ASSEMBLER__
  52. #define __arch_ioremap(p, s, t) tegra_ioremap(p, s, t)
  53. #define __arch_iounmap(v) tegra_iounmap(v)
  54. void __iomem *tegra_ioremap(unsigned long phys, size_t size, unsigned int type);
  55. void tegra_iounmap(volatile void __iomem *addr);
  56. #define IO_ADDRESS(n) ((void __iomem *) IO_TO_VIRT(n))
  57. static inline void __iomem *__io(unsigned long addr)
  58. {
  59. return (void __iomem *)addr;
  60. }
  61. #define __io(a) __io(a)
  62. #define __mem_pci(a) (a)
  63. #endif
  64. #endif