memory.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. #include <linux/kernel.h>
  2. #include <linux/init.h>
  3. #include <mach/am_regs.h>
  4. #include "common-data.h"
  5. #include <asm/page.h>
  6. #define PHYS_MEM_START (0x80000000)
  7. #define PHYS_MEM_SIZE (256*SZ_1M)
  8. #define PHYS_MEM_END (PHYS_MEM_START + PHYS_MEM_SIZE -1 )
  9. /******** Reserved memory setting ************************/
  10. #define RESERVED_MEM_START (0x80000000+64*SZ_1M) /*start at the second 64M*/
  11. /******** CODEC memory setting ************************/
  12. // Codec need 16M for 1080p decode
  13. // 4M for sd decode;
  14. #define ALIGN_MSK ((SZ_1M)-1)
  15. #define U_ALIGN(x) ((x+ALIGN_MSK)&(~ALIGN_MSK))
  16. #define D_ALIGN(x) ((x)&(~ALIGN_MSK))
  17. /******** AUDIODSP memory setting ************************/
  18. #define AUDIODSP_ADDR_START U_ALIGN(RESERVED_MEM_START) /*audiodsp memstart*/
  19. #define AUDIODSP_ADDR_END (AUDIODSP_ADDR_START+SZ_1M-1) /*audiodsp memend*/
  20. /******** Frame buffer memory configuration ***********/
  21. #define OSD_480_PIX (640*480)
  22. #define OSD_576_PIX (768*576)
  23. #define OSD_720_PIX (1280*720)
  24. #define OSD_1080_PIX (1920*1080)
  25. #define OSD_PANEL_PIX (800*480)
  26. #define B16BpP (2)
  27. #define B32BpP (4)
  28. #define DOUBLE_BUFFER (2)
  29. #define OSD1_MAX_MEM U_ALIGN(OSD_1080_PIX*B32BpP*DOUBLE_BUFFER)
  30. #define OSD2_MAX_MEM U_ALIGN(32*32*B32BpP)
  31. /******** Reserved memory configuration ***************/
  32. #define OSD1_ADDR_START U_ALIGN(AUDIODSP_ADDR_END )
  33. #define OSD1_ADDR_END (OSD1_ADDR_START+OSD1_MAX_MEM - 1)
  34. #define OSD2_ADDR_START U_ALIGN(OSD1_ADDR_END)
  35. #define OSD2_ADDR_END (OSD2_ADDR_START +OSD2_MAX_MEM -1)
  36. #if defined(CONFIG_AM_VDEC_H264)
  37. #define CODEC_MEM_SIZE U_ALIGN(32*SZ_1M)
  38. #else
  39. #define CODEC_MEM_SIZE U_ALIGN(16*SZ_1M)
  40. #endif
  41. #define CODEC_ADDR_START U_ALIGN(OSD2_ADDR_END)
  42. #define CODEC_ADDR_END (CODEC_ADDR_START+CODEC_MEM_SIZE-1)
  43. /********VDIN memory configuration ***************/
  44. #define VDIN_ADDR_START U_ALIGN(OSD2_ADDR_END)
  45. #define VDIN_ADDR_END (VDIN_ADDR_START +CODEC_MEM_SIZE -1)
  46. #if defined(CONFIG_AM_DEINTERLACE_SD_ONLY)
  47. #define DI_MEM_SIZE (SZ_1M*3)
  48. #else
  49. #define DI_MEM_SIZE (SZ_1M*15)
  50. #endif
  51. #define DI_ADDR_START U_ALIGN(CODEC_ADDR_END)
  52. #define DI_ADDR_END (DI_ADDR_START+DI_MEM_SIZE-1)
  53. #define STREAMBUF_MEM_SIZE (SZ_1M*7)
  54. #define STREAMBUF_ADDR_START U_ALIGN(DI_ADDR_END)
  55. #define STREAMBUF_ADDR_END (STREAMBUF_ADDR_START+STREAMBUF_MEM_SIZE-1)
  56. #define RESERVED_MEM_END (STREAMBUF_ADDR_END)
  57. /***********************************************************************
  58. * IO Mapping
  59. **********************************************************************/
  60. static __initdata struct map_desc meson_io_desc[] = {
  61. {
  62. .virtual = IO_CBUS_BASE,
  63. .pfn = __phys_to_pfn(IO_CBUS_PHY_BASE),
  64. .length = SZ_2M,
  65. .type = MT_DEVICE,
  66. } , {
  67. .virtual = IO_AXI_BUS_BASE,
  68. .pfn = __phys_to_pfn(IO_AXI_BUS_PHY_BASE),
  69. .length = SZ_1M,
  70. .type = MT_DEVICE,
  71. } , {
  72. .virtual = IO_PL310_BASE,
  73. .pfn = __phys_to_pfn(IO_PL310_PHY_BASE),
  74. .length = SZ_4K,
  75. .type = MT_DEVICE,
  76. } , {
  77. .virtual = IO_PERIPH_BASE,
  78. .pfn = __phys_to_pfn(IO_PERIPH_PHY_BASE),
  79. .length = SZ_4K,
  80. .type = MT_DEVICE,
  81. } , {
  82. .virtual = IO_APB_BUS_BASE,
  83. .pfn = __phys_to_pfn(IO_APB_BUS_PHY_BASE),
  84. .length = SZ_512K,
  85. .type = MT_DEVICE,
  86. } , {
  87. .virtual = IO_AOBUS_BASE,
  88. .pfn = __phys_to_pfn(IO_AOBUS_PHY_BASE),
  89. .length = SZ_1M,
  90. .type = MT_DEVICE,
  91. } , {
  92. .virtual = IO_AHB_BUS_BASE,
  93. .pfn = __phys_to_pfn(IO_AHB_BUS_PHY_BASE),
  94. .length = SZ_16M,
  95. .type = MT_DEVICE,
  96. } , {
  97. .virtual = IO_APB2_BUS_BASE,
  98. .pfn = __phys_to_pfn(IO_APB2_BUS_PHY_BASE),
  99. .length = SZ_512K,
  100. .type = MT_DEVICE,
  101. }, {
  102. .virtual = PAGE_ALIGN(__phys_to_virt(RESERVED_MEM_START)),
  103. .pfn = __phys_to_pfn(RESERVED_MEM_START),
  104. .length = RESERVED_MEM_END - RESERVED_MEM_START + 1,
  105. .type = MT_DEVICE,
  106. }
  107. };
  108. void __init meson_map_io(void)
  109. {
  110. iotable_init(meson_io_desc, ARRAY_SIZE(meson_io_desc));
  111. }
  112. void __init meson_fixup(struct machine_desc *mach, struct tag *tag, char **cmdline, struct meminfo *m)
  113. {
  114. struct membank *pbank;
  115. m->nr_banks = 0;
  116. pbank = &m->bank[m->nr_banks];
  117. pbank->start = PAGE_ALIGN(PHYS_MEM_START);
  118. pbank->size = SZ_64M & PAGE_MASK;
  119. m->nr_banks++;
  120. pbank = &m->bank[m->nr_banks];
  121. pbank->start = PAGE_ALIGN(RESERVED_MEM_END + 1);
  122. pbank->size = (PHYS_MEM_END - RESERVED_MEM_END) & PAGE_MASK;
  123. m->nr_banks++;
  124. }