mangle-port.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2003, 2004 Ralf Baechle
  7. */
  8. #ifndef __ASM_MACH_GENERIC_MANGLE_PORT_H
  9. #define __ASM_MACH_GENERIC_MANGLE_PORT_H
  10. #include <asm/byteorder.h>
  11. #ifdef __BIG_ENDIAN
  12. static inline bool __should_swizzle_bits(volatile void *a)
  13. {
  14. extern const bool octeon_should_swizzle_table[];
  15. unsigned long did = ((unsigned long)a >> 40) & 0xff;
  16. return octeon_should_swizzle_table[did];
  17. }
  18. # define __swizzle_addr_b(port) (port)
  19. # define __swizzle_addr_w(port) (port)
  20. # define __swizzle_addr_l(port) (port)
  21. # define __swizzle_addr_q(port) (port)
  22. #else /* __LITTLE_ENDIAN */
  23. #define __should_swizzle_bits(a) false
  24. static inline bool __should_swizzle_addr(unsigned long p)
  25. {
  26. /* boot bus? */
  27. return ((p >> 40) & 0xff) == 0;
  28. }
  29. # define __swizzle_addr_b(port) \
  30. (__should_swizzle_addr(port) ? (port) ^ 7 : (port))
  31. # define __swizzle_addr_w(port) \
  32. (__should_swizzle_addr(port) ? (port) ^ 6 : (port))
  33. # define __swizzle_addr_l(port) \
  34. (__should_swizzle_addr(port) ? (port) ^ 4 : (port))
  35. # define __swizzle_addr_q(port) (port)
  36. #endif /* __BIG_ENDIAN */
  37. # define ioswabb(a, x) (x)
  38. # define __mem_ioswabb(a, x) (x)
  39. # define ioswabw(a, x) (__should_swizzle_bits(a) ? le16_to_cpu(x) : x)
  40. # define __mem_ioswabw(a, x) (x)
  41. # define ioswabl(a, x) (__should_swizzle_bits(a) ? le32_to_cpu(x) : x)
  42. # define __mem_ioswabl(a, x) (x)
  43. # define ioswabq(a, x) (__should_swizzle_bits(a) ? le64_to_cpu(x) : x)
  44. # define __mem_ioswabq(a, x) (x)
  45. #endif /* __ASM_MACH_GENERIC_MANGLE_PORT_H */