ioremap.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * This program is free software; you can redistribute it and/or
  3. * modify it under the terms of the GNU General Public License
  4. * as published by the Free Software Foundation; either version
  5. * 2 of the License, or (at your option) any later version.
  6. *
  7. * Portions Copyright (C) Cisco Systems, Inc.
  8. */
  9. #ifndef __ASM_MACH_POWERTV_IOREMAP_H
  10. #define __ASM_MACH_POWERTV_IOREMAP_H
  11. #include <linux/types.h>
  12. #define LOW_MEM_BOUNDARY_PHYS 0x20000000
  13. #define LOW_MEM_BOUNDARY_MASK (~(LOW_MEM_BOUNDARY_PHYS - 1))
  14. /*
  15. * The bus addresses are different than the physical addresses that
  16. * the processor sees by an offset. This offset varies by ASIC
  17. * version. Define a variable to hold the offset and some macros to
  18. * make the conversion simpler. */
  19. extern unsigned long phys_to_bus_offset;
  20. #ifdef CONFIG_HIGHMEM
  21. #define MEM_GAP_PHYS 0x60000000
  22. /*
  23. * TODO: We will use the hard code for conversion between physical and
  24. * bus until the bootloader releases their device tree to us.
  25. */
  26. #define phys_to_bus(x) (((x) < LOW_MEM_BOUNDARY_PHYS) ? \
  27. ((x) + phys_to_bus_offset) : (x))
  28. #define bus_to_phys(x) (((x) < MEM_GAP_PHYS_ADDR) ? \
  29. ((x) - phys_to_bus_offset) : (x))
  30. #else
  31. #define phys_to_bus(x) ((x) + phys_to_bus_offset)
  32. #define bus_to_phys(x) ((x) - phys_to_bus_offset)
  33. #endif
  34. /*
  35. * Determine whether the address we are given is for an ASIC device
  36. * Params: addr Address to check
  37. * Returns: Zero if the address is not for ASIC devices, non-zero
  38. * if it is.
  39. */
  40. static inline int asic_is_device_addr(phys_t addr)
  41. {
  42. return !((phys_t)addr & (phys_t) LOW_MEM_BOUNDARY_MASK);
  43. }
  44. /*
  45. * Determine whether the address we are given is external RAM mappable
  46. * into KSEG1.
  47. * Params: addr Address to check
  48. * Returns: Zero if the address is not for external RAM and
  49. */
  50. static inline int asic_is_lowmem_ram_addr(phys_t addr)
  51. {
  52. /*
  53. * The RAM always starts at the following address in the processor's
  54. * physical address space
  55. */
  56. static const phys_t phys_ram_base = 0x10000000;
  57. phys_t bus_ram_base;
  58. bus_ram_base = phys_to_bus_offset + phys_ram_base;
  59. return addr >= bus_ram_base &&
  60. addr < (bus_ram_base + (LOW_MEM_BOUNDARY_PHYS - phys_ram_base));
  61. }
  62. /*
  63. * Allow physical addresses to be fixed up to help peripherals located
  64. * outside the low 32-bit range -- generic pass-through version.
  65. */
  66. static inline phys_t fixup_bigphys_addr(phys_t phys_addr, phys_t size)
  67. {
  68. return phys_addr;
  69. }
  70. static inline void __iomem *plat_ioremap(phys_t offset, unsigned long size,
  71. unsigned long flags)
  72. {
  73. return NULL;
  74. }
  75. static inline int plat_iounmap(const volatile void __iomem *addr)
  76. {
  77. return 0;
  78. }
  79. #endif /* __ASM_MACH_POWERTV_IOREMAP_H */