aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/omap2/vram.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/video/omap2/vram.c')
-rw-r--r--drivers/video/omap2/vram.c99
1 files changed, 5 insertions, 94 deletions
diff --git a/drivers/video/omap2/vram.c b/drivers/video/omap2/vram.c
index 9441e2eb3dee..87e421e25afe 100644
--- a/drivers/video/omap2/vram.c
+++ b/drivers/video/omap2/vram.c
@@ -33,7 +33,6 @@
33 33
34#include <asm/setup.h> 34#include <asm/setup.h>
35 35
36#include <plat/sram.h>
37#include <plat/vram.h> 36#include <plat/vram.h>
38#include <plat/dma.h> 37#include <plat/dma.h>
39 38
@@ -43,10 +42,6 @@
43#define DBG(format, ...) 42#define DBG(format, ...)
44#endif 43#endif
45 44
46#define OMAP2_SRAM_START 0x40200000
47/* Maximum size, in reality this is smaller if SRAM is partially locked. */
48#define OMAP2_SRAM_SIZE 0xa0000 /* 640k */
49
50/* postponed regions are used to temporarily store region information at boot 45/* postponed regions are used to temporarily store region information at boot
51 * time when we cannot yet allocate the region list */ 46 * time when we cannot yet allocate the region list */
52#define MAX_POSTPONED_REGIONS 10 47#define MAX_POSTPONED_REGIONS 10
@@ -74,15 +69,6 @@ struct vram_region {
74static DEFINE_MUTEX(region_mutex); 69static DEFINE_MUTEX(region_mutex);
75static LIST_HEAD(region_list); 70static LIST_HEAD(region_list);
76 71
77static inline int region_mem_type(unsigned long paddr)
78{
79 if (paddr >= OMAP2_SRAM_START &&
80 paddr < OMAP2_SRAM_START + OMAP2_SRAM_SIZE)
81 return OMAP_VRAM_MEMTYPE_SRAM;
82 else
83 return OMAP_VRAM_MEMTYPE_SDRAM;
84}
85
86static struct vram_region *omap_vram_create_region(unsigned long paddr, 72static struct vram_region *omap_vram_create_region(unsigned long paddr,
87 unsigned pages) 73 unsigned pages)
88{ 74{
@@ -212,9 +198,6 @@ static int _omap_vram_reserve(unsigned long paddr, unsigned pages)
212 198
213 DBG("checking region %lx %d\n", rm->paddr, rm->pages); 199 DBG("checking region %lx %d\n", rm->paddr, rm->pages);
214 200
215 if (region_mem_type(rm->paddr) != region_mem_type(paddr))
216 continue;
217
218 start = rm->paddr; 201 start = rm->paddr;
219 end = start + (rm->pages << PAGE_SHIFT) - 1; 202 end = start + (rm->pages << PAGE_SHIFT) - 1;
220 if (start > paddr || end < paddr + size - 1) 203 if (start > paddr || end < paddr + size - 1)
@@ -320,7 +303,7 @@ err:
320 return r; 303 return r;
321} 304}
322 305
323static int _omap_vram_alloc(int mtype, unsigned pages, unsigned long *paddr) 306static int _omap_vram_alloc(unsigned pages, unsigned long *paddr)
324{ 307{
325 struct vram_region *rm; 308 struct vram_region *rm;
326 struct vram_alloc *alloc; 309 struct vram_alloc *alloc;
@@ -330,9 +313,6 @@ static int _omap_vram_alloc(int mtype, unsigned pages, unsigned long *paddr)
330 313
331 DBG("checking region %lx %d\n", rm->paddr, rm->pages); 314 DBG("checking region %lx %d\n", rm->paddr, rm->pages);
332 315
333 if (region_mem_type(rm->paddr) != mtype)
334 continue;
335
336 start = rm->paddr; 316 start = rm->paddr;
337 317
338 list_for_each_entry(alloc, &rm->alloc_list, list) { 318 list_for_each_entry(alloc, &rm->alloc_list, list) {
@@ -365,21 +345,21 @@ found:
365 return -ENOMEM; 345 return -ENOMEM;
366} 346}
367 347
368int omap_vram_alloc(int mtype, size_t size, unsigned long *paddr) 348int omap_vram_alloc(size_t size, unsigned long *paddr)
369{ 349{
370 unsigned pages; 350 unsigned pages;
371 int r; 351 int r;
372 352
373 BUG_ON(mtype > OMAP_VRAM_MEMTYPE_MAX || !size); 353 BUG_ON(!size);
374 354
375 DBG("alloc mem type %d size %d\n", mtype, size); 355 DBG("alloc mem size %d\n", size);
376 356
377 size = PAGE_ALIGN(size); 357 size = PAGE_ALIGN(size);
378 pages = size >> PAGE_SHIFT; 358 pages = size >> PAGE_SHIFT;
379 359
380 mutex_lock(&region_mutex); 360 mutex_lock(&region_mutex);
381 361
382 r = _omap_vram_alloc(mtype, pages, paddr); 362 r = _omap_vram_alloc(pages, paddr);
383 363
384 mutex_unlock(&region_mutex); 364 mutex_unlock(&region_mutex);
385 365
@@ -501,10 +481,6 @@ arch_initcall(omap_vram_init);
501/* boottime vram alloc stuff */ 481/* boottime vram alloc stuff */
502 482
503/* set from board file */ 483/* set from board file */
504static u32 omap_vram_sram_start __initdata;
505static u32 omap_vram_sram_size __initdata;
506
507/* set from board file */
508static u32 omap_vram_sdram_start __initdata; 484static u32 omap_vram_sdram_start __initdata;
509static u32 omap_vram_sdram_size __initdata; 485static u32 omap_vram_sdram_size __initdata;
510 486
@@ -587,73 +563,8 @@ void __init omap_vram_reserve_sdram_memblock(void)
587 pr_info("Reserving %u bytes SDRAM for VRAM\n", size); 563 pr_info("Reserving %u bytes SDRAM for VRAM\n", size);
588} 564}
589 565
590/*
591 * Called at sram init time, before anything is pushed to the SRAM stack.
592 * Because of the stack scheme, we will allocate everything from the
593 * start of the lowest address region to the end of SRAM. This will also
594 * include padding for page alignment and possible holes between regions.
595 *
596 * As opposed to the SDRAM case, we'll also do any dynamic allocations at
597 * this point, since the driver built as a module would have problem with
598 * freeing / reallocating the regions.
599 */
600unsigned long __init omap_vram_reserve_sram(unsigned long sram_pstart,
601 unsigned long sram_vstart,
602 unsigned long sram_size,
603 unsigned long pstart_avail,
604 unsigned long size_avail)
605{
606 unsigned long pend_avail;
607 unsigned long reserved;
608 u32 paddr;
609 u32 size;
610
611 paddr = omap_vram_sram_start;
612 size = omap_vram_sram_size;
613
614 if (!size)
615 return 0;
616
617 reserved = 0;
618 pend_avail = pstart_avail + size_avail;
619
620 if (!paddr) {
621 /* Dynamic allocation */
622 if ((size_avail & PAGE_MASK) < size) {
623 pr_err("Not enough SRAM for VRAM\n");
624 return 0;
625 }
626 size_avail = (size_avail - size) & PAGE_MASK;
627 paddr = pstart_avail + size_avail;
628 }
629
630 if (paddr < sram_pstart ||
631 paddr + size > sram_pstart + sram_size) {
632 pr_err("Illegal SRAM region for VRAM\n");
633 return 0;
634 }
635
636 /* Reserve everything above the start of the region. */
637 if (pend_avail - paddr > reserved)
638 reserved = pend_avail - paddr;
639 size_avail = pend_avail - reserved - pstart_avail;
640
641 omap_vram_add_region(paddr, size);
642
643 if (reserved)
644 pr_info("Reserving %lu bytes SRAM for VRAM\n", reserved);
645
646 return reserved;
647}
648
649void __init omap_vram_set_sdram_vram(u32 size, u32 start) 566void __init omap_vram_set_sdram_vram(u32 size, u32 start)
650{ 567{
651 omap_vram_sdram_start = start; 568 omap_vram_sdram_start = start;
652 omap_vram_sdram_size = size; 569 omap_vram_sdram_size = size;
653} 570}
654
655void __init omap_vram_set_sram_vram(u32 size, u32 start)
656{
657 omap_vram_sram_start = start;
658 omap_vram_sram_size = size;
659}