aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/xilinxfb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/video/xilinxfb.c')
-rw-r--r--drivers/video/xilinxfb.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/drivers/video/xilinxfb.c b/drivers/video/xilinxfb.c
index c6174125f52b..6ef99b2d13ca 100644
--- a/drivers/video/xilinxfb.c
+++ b/drivers/video/xilinxfb.c
@@ -117,6 +117,7 @@ struct xilinxfb_drvdata {
117 117
118 void *fb_virt; /* virt. address of the frame buffer */ 118 void *fb_virt; /* virt. address of the frame buffer */
119 dma_addr_t fb_phys; /* phys. address of the frame buffer */ 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 u32 reg_ctrl_default; 122 u32 reg_ctrl_default;
122 123
@@ -235,8 +236,15 @@ static int xilinxfb_assign(struct device *dev, unsigned long physaddr,
235 } 236 }
236 237
237 /* Allocate the framebuffer memory */ 238 /* Allocate the framebuffer memory */
238 drvdata->fb_virt = dma_alloc_coherent(dev, PAGE_ALIGN(fbsize), 239 if (pdata->fb_phys) {
239 &drvdata->fb_phys, GFP_KERNEL); 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 if (!drvdata->fb_virt) { 248 if (!drvdata->fb_virt) {
241 dev_err(dev, "Could not allocate frame buffer memory\n"); 249 dev_err(dev, "Could not allocate frame buffer memory\n");
242 rc = -ENOMEM; 250 rc = -ENOMEM;
@@ -300,8 +308,9 @@ err_regfb:
300 fb_dealloc_cmap(&drvdata->info.cmap); 308 fb_dealloc_cmap(&drvdata->info.cmap);
301 309
302err_cmap: 310err_cmap:
303 dma_free_coherent(dev, PAGE_ALIGN(fbsize), drvdata->fb_virt, 311 if (drvdata->fb_alloced)
304 drvdata->fb_phys); 312 dma_free_coherent(dev, PAGE_ALIGN(fbsize), drvdata->fb_virt,
313 drvdata->fb_phys);
305 /* Turn off the display */ 314 /* Turn off the display */
306 xilinx_fb_out_be32(drvdata, REG_CTRL, 0); 315 xilinx_fb_out_be32(drvdata, REG_CTRL, 0);
307 316
@@ -330,8 +339,9 @@ static int xilinxfb_release(struct device *dev)
330 339
331 fb_dealloc_cmap(&drvdata->info.cmap); 340 fb_dealloc_cmap(&drvdata->info.cmap);
332 341
333 dma_free_coherent(dev, PAGE_ALIGN(drvdata->info.fix.smem_len), 342 if (drvdata->fb_alloced)
334 drvdata->fb_virt, drvdata->fb_phys); 343 dma_free_coherent(dev, PAGE_ALIGN(drvdata->info.fix.smem_len),
344 drvdata->fb_virt, drvdata->fb_phys);
335 345
336 /* Turn off the display */ 346 /* Turn off the display */
337 xilinx_fb_out_be32(drvdata, REG_CTRL, 0); 347 xilinx_fb_out_be32(drvdata, REG_CTRL, 0);