aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/video')
-rw-r--r--drivers/video/fbdev/omap/lcdc.c67
1 files changed, 2 insertions, 65 deletions
diff --git a/drivers/video/fbdev/omap/lcdc.c b/drivers/video/fbdev/omap/lcdc.c
index b52f62595f65..6efa2591eaa8 100644
--- a/drivers/video/fbdev/omap/lcdc.c
+++ b/drivers/video/fbdev/omap/lcdc.c
@@ -74,7 +74,6 @@ static struct omap_lcd_controller {
74 void (*dma_callback)(void *data); 74 void (*dma_callback)(void *data);
75 void *dma_callback_data; 75 void *dma_callback_data;
76 76
77 int fbmem_allocated;
78 dma_addr_t vram_phys; 77 dma_addr_t vram_phys;
79 void *vram_virt; 78 void *vram_virt;
80 unsigned long vram_size; 79 unsigned long vram_size;
@@ -611,42 +610,6 @@ static void lcdc_dma_handler(u16 status, void *data)
611 lcdc.dma_callback(lcdc.dma_callback_data); 610 lcdc.dma_callback(lcdc.dma_callback_data);
612} 611}
613 612
614static int mmap_kern(void)
615{
616 struct vm_struct *kvma;
617 struct vm_area_struct vma;
618 pgprot_t pgprot;
619 unsigned long vaddr;
620
621 kvma = get_vm_area(lcdc.vram_size, VM_IOREMAP);
622 if (kvma == NULL) {
623 dev_err(lcdc.fbdev->dev, "can't get kernel vm area\n");
624 return -ENOMEM;
625 }
626 vma.vm_mm = &init_mm;
627
628 vaddr = (unsigned long)kvma->addr;
629 vma.vm_start = vaddr;
630 vma.vm_end = vaddr + lcdc.vram_size;
631
632 pgprot = pgprot_writecombine(pgprot_kernel);
633 if (io_remap_pfn_range(&vma, vaddr,
634 lcdc.vram_phys >> PAGE_SHIFT,
635 lcdc.vram_size, pgprot) < 0) {
636 dev_err(lcdc.fbdev->dev, "kernel mmap for FB memory failed\n");
637 return -EAGAIN;
638 }
639
640 lcdc.vram_virt = (void *)vaddr;
641
642 return 0;
643}
644
645static void unmap_kern(void)
646{
647 vunmap(lcdc.vram_virt);
648}
649
650static int alloc_palette_ram(void) 613static int alloc_palette_ram(void)
651{ 614{
652 lcdc.palette_virt = dma_alloc_writecombine(lcdc.fbdev->dev, 615 lcdc.palette_virt = dma_alloc_writecombine(lcdc.fbdev->dev,
@@ -703,8 +666,6 @@ static void free_fbmem(void)
703 666
704static int setup_fbmem(struct omapfb_mem_desc *req_md) 667static int setup_fbmem(struct omapfb_mem_desc *req_md)
705{ 668{
706 int r;
707
708 if (!req_md->region_cnt) { 669 if (!req_md->region_cnt) {
709 dev_err(lcdc.fbdev->dev, "no memory regions defined\n"); 670 dev_err(lcdc.fbdev->dev, "no memory regions defined\n");
710 return -EINVAL; 671 return -EINVAL;
@@ -715,31 +676,7 @@ static int setup_fbmem(struct omapfb_mem_desc *req_md)
715 req_md->region_cnt = 1; 676 req_md->region_cnt = 1;
716 } 677 }
717 678
718 if (req_md->region[0].paddr == 0) { 679 return alloc_fbmem(&req_md->region[0]);
719 lcdc.fbmem_allocated = 1;
720 if ((r = alloc_fbmem(&req_md->region[0])) < 0)
721 return r;
722 return 0;
723 }
724
725 lcdc.vram_phys = req_md->region[0].paddr;
726 lcdc.vram_size = req_md->region[0].size;
727
728 if ((r = mmap_kern()) < 0)
729 return r;
730
731 dev_dbg(lcdc.fbdev->dev, "vram at %08x size %08lx mapped to 0x%p\n",
732 lcdc.vram_phys, lcdc.vram_size, lcdc.vram_virt);
733
734 return 0;
735}
736
737static void cleanup_fbmem(void)
738{
739 if (lcdc.fbmem_allocated)
740 free_fbmem();
741 else
742 unmap_kern();
743} 680}
744 681
745static int omap_lcdc_init(struct omapfb_device *fbdev, int ext_mode, 682static int omap_lcdc_init(struct omapfb_device *fbdev, int ext_mode,
@@ -833,7 +770,7 @@ static void omap_lcdc_cleanup(void)
833{ 770{
834 if (!lcdc.ext_mode) 771 if (!lcdc.ext_mode)
835 free_palette_ram(); 772 free_palette_ram();
836 cleanup_fbmem(); 773 free_fbmem();
837 omap_free_lcd_dma(); 774 omap_free_lcd_dma();
838 free_irq(OMAP_LCDC_IRQ, lcdc.fbdev); 775 free_irq(OMAP_LCDC_IRQ, lcdc.fbdev);
839 clk_disable(lcdc.lcd_ck); 776 clk_disable(lcdc.lcd_ck);