Commit 287e5d6fcccfa38b953cebe307e1ddfd32363355

Authored by Grant Likely
Committed by Paul Mackerras
1 parent b4d6a7268f

[POWERPC] XilinxFB: Allow fixed framebuffer base address

Allow a fixed framebuffer address to be assigned to the framebuffer device
instead of allocating the framebuffer from the consistent memory pool.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: Paul Mackerras <paulus@samba.org>

Showing 2 changed files with 21 additions and 6 deletions Side-by-side Diff

drivers/video/xilinxfb.c
... ... @@ -117,6 +117,7 @@
117 117  
118 118 void *fb_virt; /* virt. address of the frame buffer */
119 119 dma_addr_t fb_phys; /* phys. address of the frame buffer */
  120 + int fb_alloced; /* Flag, was the fb memory alloced? */
120 121  
121 122 u32 reg_ctrl_default;
122 123  
... ... @@ -235,8 +236,15 @@
235 236 }
236 237  
237 238 /* Allocate the framebuffer memory */
238   - drvdata->fb_virt = dma_alloc_coherent(dev, PAGE_ALIGN(fbsize),
239   - &drvdata->fb_phys, GFP_KERNEL);
  239 + if (pdata->fb_phys) {
  240 + drvdata->fb_phys = pdata->fb_phys;
  241 + drvdata->fb_virt = ioremap(pdata->fb_phys, fbsize);
  242 + } else {
  243 + drvdata->fb_alloced = 1;
  244 + drvdata->fb_virt = dma_alloc_coherent(dev, PAGE_ALIGN(fbsize),
  245 + &drvdata->fb_phys, GFP_KERNEL);
  246 + }
  247 +
240 248 if (!drvdata->fb_virt) {
241 249 dev_err(dev, "Could not allocate frame buffer memory\n");
242 250 rc = -ENOMEM;
... ... @@ -300,8 +308,9 @@
300 308 fb_dealloc_cmap(&drvdata->info.cmap);
301 309  
302 310 err_cmap:
303   - dma_free_coherent(dev, PAGE_ALIGN(fbsize), drvdata->fb_virt,
304   - drvdata->fb_phys);
  311 + if (drvdata->fb_alloced)
  312 + dma_free_coherent(dev, PAGE_ALIGN(fbsize), drvdata->fb_virt,
  313 + drvdata->fb_phys);
305 314 /* Turn off the display */
306 315 xilinx_fb_out_be32(drvdata, REG_CTRL, 0);
307 316  
... ... @@ -330,8 +339,9 @@
330 339  
331 340 fb_dealloc_cmap(&drvdata->info.cmap);
332 341  
333   - dma_free_coherent(dev, PAGE_ALIGN(drvdata->info.fix.smem_len),
334   - drvdata->fb_virt, drvdata->fb_phys);
  342 + if (drvdata->fb_alloced)
  343 + dma_free_coherent(dev, PAGE_ALIGN(drvdata->info.fix.smem_len),
  344 + drvdata->fb_virt, drvdata->fb_phys);
335 345  
336 346 /* Turn off the display */
337 347 xilinx_fb_out_be32(drvdata, REG_CTRL, 0);
include/linux/xilinxfb.h
... ... @@ -20,6 +20,11 @@
20 20 u32 screen_width_mm;
21 21 u32 xres, yres; /* resolution of screen in pixels */
22 22 u32 xvirt, yvirt; /* resolution of memory buffer */
  23 +
  24 + /* Physical address of framebuffer memory; If non-zero, driver
  25 + * will use provided memory address instead of allocating one from
  26 + * the consistent pool. */
  27 + u32 fb_phys;
23 28 };
24 29  
25 30 #endif /* __XILINXFB_H__ */