memory.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* include/asm-arm/arch-lh7a40x/memory.h
  2. *
  3. * Copyright (C) 2004 Coastal Environmental Systems
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * version 2 as published by the Free Software Foundation.
  8. *
  9. *
  10. * Refer to <file:Documentation/arm/Sharp-LH/SDRAM> for more information.
  11. *
  12. */
  13. #ifndef __ASM_ARCH_MEMORY_H
  14. #define __ASM_ARCH_MEMORY_H
  15. /*
  16. * Physical DRAM offset.
  17. */
  18. #define PHYS_OFFSET UL(0xc0000000)
  19. /*
  20. * Virtual view <-> DMA view memory address translations
  21. * virt_to_bus: Used to translate the virtual address to an
  22. * address suitable to be passed to set_dma_addr
  23. * bus_to_virt: Used to convert an address for DMA operations
  24. * to an address that the kernel can use.
  25. */
  26. #define __virt_to_bus(x) __virt_to_phys(x)
  27. #define __bus_to_virt(x) __phys_to_virt(x)
  28. #ifdef CONFIG_DISCONTIGMEM
  29. /*
  30. * Given a kernel address, find the home node of the underlying memory.
  31. */
  32. # ifdef CONFIG_LH7A40X_ONE_BANK_PER_NODE
  33. # define KVADDR_TO_NID(addr) \
  34. ( ((((unsigned long) (addr) - PAGE_OFFSET) >> 24) & 1)\
  35. | ((((unsigned long) (addr) - PAGE_OFFSET) >> 25) & ~1))
  36. # else /* 2 banks per node */
  37. # define KVADDR_TO_NID(addr) \
  38. (((unsigned long) (addr) - PAGE_OFFSET) >> 26)
  39. # endif
  40. /*
  41. * Given a page frame number, convert it to a node id.
  42. */
  43. # ifdef CONFIG_LH7A40X_ONE_BANK_PER_NODE
  44. # define PFN_TO_NID(pfn) \
  45. (((((pfn) - PHYS_PFN_OFFSET) >> (24 - PAGE_SHIFT)) & 1)\
  46. | ((((pfn) - PHYS_PFN_OFFSET) >> (25 - PAGE_SHIFT)) & ~1))
  47. # else /* 2 banks per node */
  48. # define PFN_TO_NID(pfn) \
  49. (((pfn) - PHYS_PFN_OFFSET) >> (26 - PAGE_SHIFT))
  50. #endif
  51. /*
  52. * Given a kaddr, LOCAL_MEM_MAP finds the owning node of the memory
  53. * and returns the index corresponding to the appropriate page in the
  54. * node's mem_map.
  55. */
  56. # ifdef CONFIG_LH7A40X_ONE_BANK_PER_NODE
  57. # define LOCAL_MAP_NR(addr) \
  58. (((unsigned long)(addr) & 0x003fffff) >> PAGE_SHIFT)
  59. # else /* 2 banks per node */
  60. # define LOCAL_MAP_NR(addr) \
  61. (((unsigned long)(addr) & 0x01ffffff) >> PAGE_SHIFT)
  62. # endif
  63. #endif
  64. #endif