memory.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* arch/arm/mach-lh7a40x/include/mach/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. #ifdef CONFIG_DISCONTIGMEM
  20. /*
  21. * Given a kernel address, find the home node of the underlying memory.
  22. */
  23. # ifdef CONFIG_LH7A40X_ONE_BANK_PER_NODE
  24. # define KVADDR_TO_NID(addr) \
  25. ( ((((unsigned long) (addr) - PAGE_OFFSET) >> 24) & 1)\
  26. | ((((unsigned long) (addr) - PAGE_OFFSET) >> 25) & ~1))
  27. # else /* 2 banks per node */
  28. # define KVADDR_TO_NID(addr) \
  29. (((unsigned long) (addr) - PAGE_OFFSET) >> 26)
  30. # endif
  31. /*
  32. * Given a page frame number, convert it to a node id.
  33. */
  34. # ifdef CONFIG_LH7A40X_ONE_BANK_PER_NODE
  35. # define PFN_TO_NID(pfn) \
  36. (((((pfn) - PHYS_PFN_OFFSET) >> (24 - PAGE_SHIFT)) & 1)\
  37. | ((((pfn) - PHYS_PFN_OFFSET) >> (25 - PAGE_SHIFT)) & ~1))
  38. # else /* 2 banks per node */
  39. # define PFN_TO_NID(pfn) \
  40. (((pfn) - PHYS_PFN_OFFSET) >> (26 - PAGE_SHIFT))
  41. #endif
  42. /*
  43. * Given a kaddr, LOCAL_MEM_MAP finds the owning node of the memory
  44. * and returns the index corresponding to the appropriate page in the
  45. * node's mem_map.
  46. */
  47. # ifdef CONFIG_LH7A40X_ONE_BANK_PER_NODE
  48. # define LOCAL_MAP_NR(addr) \
  49. (((unsigned long)(addr) & 0x003fffff) >> PAGE_SHIFT)
  50. # else /* 2 banks per node */
  51. # define LOCAL_MAP_NR(addr) \
  52. (((unsigned long)(addr) & 0x01ffffff) >> PAGE_SHIFT)
  53. # endif
  54. #endif
  55. /*
  56. * Sparsemem version of the above
  57. */
  58. #define MAX_PHYSMEM_BITS 32
  59. #define SECTION_SIZE_BITS 24
  60. #endif