blob: 2a423d3a2a8eb8fe80436b6b2100fef8a39ad9f1 [file] [log] [blame]
Michael Hennerich99eeed47a2008-03-10 11:44:04 -07001/*
2 * File: drivers/video/bfin-t350mcqb-fb.c
3 * Based on:
4 * Author: Michael Hennerich <hennerich@blackfin.uclinux.org>
5 *
6 * Created:
7 * Description: Blackfin LCD Framebufer driver
8 *
9 *
10 * Modified:
11 * Copyright 2004-2007 Analog Devices Inc.
12 *
13 * Bugs: Enter bugs at http://blackfin.uclinux.org/
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, see the file COPYING, or write
27 * to the Free Software Foundation, Inc.,
28 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 */
30
31#include <linux/module.h>
32#include <linux/kernel.h>
33#include <linux/errno.h>
34#include <linux/string.h>
35#include <linux/fb.h>
36#include <linux/init.h>
37#include <linux/types.h>
38#include <linux/interrupt.h>
39#include <linux/device.h>
40#include <linux/backlight.h>
41#include <linux/lcd.h>
42#include <linux/dma-mapping.h>
43#include <linux/platform_device.h>
44
45#include <asm/blackfin.h>
46#include <asm/irq.h>
47#include <asm/dma-mapping.h>
48#include <asm/dma.h>
49#include <asm/portmux.h>
50#include <asm/gptimers.h>
51
52#define NO_BL_SUPPORT
53
54#define LCD_X_RES 320 /* Horizontal Resolution */
55#define LCD_Y_RES 240 /* Vertical Resolution */
56#define LCD_BPP 24 /* Bit Per Pixel */
57
58#define DMA_BUS_SIZE 16
59#define LCD_CLK (12*1000*1000) /* 12MHz */
60
61#define CLOCKS_PER_PIX 3
62
63 /*
64 * HS and VS timing parameters (all in number of PPI clk ticks)
65 */
66
67#define U_LINE 1 /* Blanking Lines */
68
69#define H_ACTPIX (LCD_X_RES * CLOCKS_PER_PIX) /* active horizontal pixel */
70#define H_PERIOD (408 * CLOCKS_PER_PIX) /* HS period */
71#define H_PULSE 90 /* HS pulse width */
72#define H_START 204 /* first valid pixel */
73
74#define V_LINES (LCD_Y_RES + U_LINE) /* total vertical lines */
75#define V_PULSE (3 * H_PERIOD) /* VS pulse width (1-5 H_PERIODs) */
76#define V_PERIOD (H_PERIOD * V_LINES) /* VS period */
77
78#define ACTIVE_VIDEO_MEM_OFFSET (U_LINE * H_ACTPIX)
79
80#define BFIN_LCD_NBR_PALETTE_ENTRIES 256
81
82#define DRIVER_NAME "bfin-t350mcqb"
83static char driver_name[] = DRIVER_NAME;
84
85struct bfin_t350mcqbfb_info {
86 struct fb_info *fb;
87 struct device *dev;
88 unsigned char *fb_buffer; /* RGB Buffer */
89 dma_addr_t dma_handle;
90 int lq043_mmap;
91 int lq043_open_cnt;
92 int irq;
93 spinlock_t lock; /* lock */
Bryan Wu7ef98612008-03-28 14:16:05 -070094 u32 pseudo_pal[16];
Michael Hennerich99eeed47a2008-03-10 11:44:04 -070095};
96
97static int nocursor;
98module_param(nocursor, int, 0644);
99MODULE_PARM_DESC(nocursor, "cursor enable/disable");
100
101#define PPI_TX_MODE 0x2
102#define PPI_XFER_TYPE_11 0xC
103#define PPI_PORT_CFG_01 0x10
104#define PPI_PACK_EN 0x80
105#define PPI_POLS_1 0x8000
106
107static void bfin_t350mcqb_config_ppi(struct bfin_t350mcqbfb_info *fbi)
108{
109 bfin_write_PPI_DELAY(H_START);
110 bfin_write_PPI_COUNT(H_ACTPIX-1);
111 bfin_write_PPI_FRAME(V_LINES);
112
113 bfin_write_PPI_CONTROL(PPI_TX_MODE | /* output mode , PORT_DIR */
114 PPI_XFER_TYPE_11 | /* sync mode XFR_TYPE */
115 PPI_PORT_CFG_01 | /* two frame sync PORT_CFG */
116 PPI_PACK_EN | /* packing enabled PACK_EN */
117 PPI_POLS_1); /* faling edge syncs POLS */
118}
119
120static inline void bfin_t350mcqb_disable_ppi(void)
121{
122 bfin_write_PPI_CONTROL(bfin_read_PPI_CONTROL() & ~PORT_EN);
123}
124
125static inline void bfin_t350mcqb_enable_ppi(void)
126{
127 bfin_write_PPI_CONTROL(bfin_read_PPI_CONTROL() | PORT_EN);
128}
129
130static void bfin_t350mcqb_start_timers(void)
131{
132 unsigned long flags;
133
134 local_irq_save(flags);
135 enable_gptimers(TIMER1bit);
136 enable_gptimers(TIMER0bit);
137 local_irq_restore(flags);
138}
139
140static void bfin_t350mcqb_stop_timers(void)
141{
142 disable_gptimers(TIMER0bit | TIMER1bit);
143
144 set_gptimer_status(0, TIMER_STATUS_TRUN0 | TIMER_STATUS_TRUN1 |
145 TIMER_STATUS_TIMIL0 | TIMER_STATUS_TIMIL1 |
146 TIMER_STATUS_TOVF0 | TIMER_STATUS_TOVF1);
147
148}
149
150static void bfin_t350mcqb_init_timers(void)
151{
152
153 bfin_t350mcqb_stop_timers();
154
155 set_gptimer_period(TIMER0_id, H_PERIOD);
156 set_gptimer_pwidth(TIMER0_id, H_PULSE);
157 set_gptimer_config(TIMER0_id, TIMER_MODE_PWM | TIMER_PERIOD_CNT |
158 TIMER_TIN_SEL | TIMER_CLK_SEL|
159 TIMER_EMU_RUN);
160
161 set_gptimer_period(TIMER1_id, V_PERIOD);
162 set_gptimer_pwidth(TIMER1_id, V_PULSE);
163 set_gptimer_config(TIMER1_id, TIMER_MODE_PWM | TIMER_PERIOD_CNT |
164 TIMER_TIN_SEL | TIMER_CLK_SEL |
165 TIMER_EMU_RUN);
166
167}
168
169static void bfin_t350mcqb_config_dma(struct bfin_t350mcqbfb_info *fbi)
170{
171
172 set_dma_config(CH_PPI,
173 set_bfin_dma_config(DIR_READ, DMA_FLOW_AUTO,
174 INTR_DISABLE, DIMENSION_2D,
175 DATA_SIZE_16,
176 DMA_NOSYNC_KEEP_DMA_BUF));
177 set_dma_x_count(CH_PPI, (LCD_X_RES * LCD_BPP) / DMA_BUS_SIZE);
178 set_dma_x_modify(CH_PPI, DMA_BUS_SIZE / 8);
179 set_dma_y_count(CH_PPI, V_LINES);
180
181 set_dma_y_modify(CH_PPI, DMA_BUS_SIZE / 8);
182 set_dma_start_addr(CH_PPI, (unsigned long)fbi->fb_buffer);
183
184}
185
Bryan Wu7ef98612008-03-28 14:16:05 -0700186static u16 ppi0_req_8[] = {P_PPI0_CLK, P_PPI0_FS1, P_PPI0_FS2,
Michael Hennerich99eeed47a2008-03-10 11:44:04 -0700187 P_PPI0_D0, P_PPI0_D1, P_PPI0_D2,
188 P_PPI0_D3, P_PPI0_D4, P_PPI0_D5,
189 P_PPI0_D6, P_PPI0_D7, 0};
190
Bryan Wu7ef98612008-03-28 14:16:05 -0700191static int bfin_t350mcqb_request_ports(int action)
192{
Michael Hennerich99eeed47a2008-03-10 11:44:04 -0700193 if (action) {
194 if (peripheral_request_list(ppi0_req_8, DRIVER_NAME)) {
195 printk(KERN_ERR "Requesting Peripherals faild\n");
196 return -EFAULT;
197 }
198 } else
199 peripheral_free_list(ppi0_req_8);
200
201 return 0;
202}
203
204static int bfin_t350mcqb_fb_open(struct fb_info *info, int user)
205{
206 struct bfin_t350mcqbfb_info *fbi = info->par;
207
208 spin_lock(&fbi->lock);
209 fbi->lq043_open_cnt++;
210
211 if (fbi->lq043_open_cnt <= 1) {
212
213 bfin_t350mcqb_disable_ppi();
214 SSYNC();
215
216 bfin_t350mcqb_config_dma(fbi);
217 bfin_t350mcqb_config_ppi(fbi);
218 bfin_t350mcqb_init_timers();
219
220 /* start dma */
221 enable_dma(CH_PPI);
222 bfin_t350mcqb_enable_ppi();
223 bfin_t350mcqb_start_timers();
224 }
225
226 spin_unlock(&fbi->lock);
227
228 return 0;
229}
230
231static int bfin_t350mcqb_fb_release(struct fb_info *info, int user)
232{
233 struct bfin_t350mcqbfb_info *fbi = info->par;
234
235 spin_lock(&fbi->lock);
236
237 fbi->lq043_open_cnt--;
238 fbi->lq043_mmap = 0;
239
240 if (fbi->lq043_open_cnt <= 0) {
241 bfin_t350mcqb_disable_ppi();
242 SSYNC();
243 disable_dma(CH_PPI);
244 bfin_t350mcqb_stop_timers();
245 memset(fbi->fb_buffer, 0, info->fix.smem_len);
246 }
247
248 spin_unlock(&fbi->lock);
249
250 return 0;
251}
252
253static int bfin_t350mcqb_fb_check_var(struct fb_var_screeninfo *var,
254 struct fb_info *info)
255{
256
Michael Hennerichb46578e2009-01-15 13:50:46 -0800257 switch (var->bits_per_pixel) {
258 case 24:/* TRUECOLOUR, 16m */
259 var->red.offset = 0;
260 var->green.offset = 8;
261 var->blue.offset = 16;
262 var->red.length = var->green.length = var->blue.length = 8;
263 var->transp.offset = 0;
264 var->transp.length = 0;
265 var->transp.msb_right = 0;
266 var->red.msb_right = 0;
267 var->green.msb_right = 0;
268 var->blue.msb_right = 0;
269 break;
270 default:
Harvey Harrison729f77b2009-01-06 14:42:30 -0800271 pr_debug("%s: depth not supported: %u BPP\n", __func__,
Michael Hennerich99eeed47a2008-03-10 11:44:04 -0700272 var->bits_per_pixel);
273 return -EINVAL;
274 }
275
276 if (info->var.xres != var->xres || info->var.yres != var->yres ||
277 info->var.xres_virtual != var->xres_virtual ||
278 info->var.yres_virtual != var->yres_virtual) {
279 pr_debug("%s: Resolution not supported: X%u x Y%u \n",
Harvey Harrison729f77b2009-01-06 14:42:30 -0800280 __func__, var->xres, var->yres);
Michael Hennerich99eeed47a2008-03-10 11:44:04 -0700281 return -EINVAL;
282 }
283
284 /*
285 * Memory limit
286 */
287
288 if ((info->fix.line_length * var->yres_virtual) > info->fix.smem_len) {
289 pr_debug("%s: Memory Limit requested yres_virtual = %u\n",
Harvey Harrison729f77b2009-01-06 14:42:30 -0800290 __func__, var->yres_virtual);
Michael Hennerich99eeed47a2008-03-10 11:44:04 -0700291 return -ENOMEM;
292 }
293
294 return 0;
295}
296
297static int bfin_t350mcqb_fb_mmap(struct fb_info *info, struct vm_area_struct *vma)
298{
299 struct bfin_t350mcqbfb_info *fbi = info->par;
300
301 if (fbi->lq043_mmap)
302 return -1;
303
304 spin_lock(&fbi->lock);
305 fbi->lq043_mmap = 1;
306 spin_unlock(&fbi->lock);
307
308 vma->vm_start = (unsigned long)(fbi->fb_buffer + ACTIVE_VIDEO_MEM_OFFSET);
309
310 vma->vm_end = vma->vm_start + info->fix.smem_len;
311 /* For those who don't understand how mmap works, go read
312 * Documentation/nommu-mmap.txt.
313 * For those that do, you will know that the VM_MAYSHARE flag
314 * must be set in the vma->vm_flags structure on noMMU
315 * Other flags can be set, and are documented in
316 * include/linux/mm.h
317 */
Michael Hennerich363df392008-03-28 14:16:06 -0700318 vma->vm_flags |= VM_MAYSHARE | VM_SHARED;
Michael Hennerich99eeed47a2008-03-10 11:44:04 -0700319
320 return 0;
321}
322
323int bfin_t350mcqb_fb_cursor(struct fb_info *info, struct fb_cursor *cursor)
324{
325 if (nocursor)
326 return 0;
327 else
328 return -EINVAL; /* just to force soft_cursor() call */
329}
330
331static int bfin_t350mcqb_fb_setcolreg(u_int regno, u_int red, u_int green,
332 u_int blue, u_int transp,
333 struct fb_info *info)
334{
335 if (regno >= BFIN_LCD_NBR_PALETTE_ENTRIES)
336 return -EINVAL;
337
338 if (info->var.grayscale) {
339 /* grayscale = 0.30*R + 0.59*G + 0.11*B */
340 red = green = blue = (red * 77 + green * 151 + blue * 28) >> 8;
341 }
342
343 if (info->fix.visual == FB_VISUAL_TRUECOLOR) {
344
345 u32 value;
346 /* Place color in the pseudopalette */
347 if (regno > 16)
348 return -EINVAL;
349
350 red >>= (16 - info->var.red.length);
351 green >>= (16 - info->var.green.length);
352 blue >>= (16 - info->var.blue.length);
353
354 value = (red << info->var.red.offset) |
355 (green << info->var.green.offset) |
356 (blue << info->var.blue.offset);
357 value &= 0xFFFFFF;
358
359 ((u32 *) (info->pseudo_palette))[regno] = value;
360
361 }
362
363 return 0;
364}
365
366static struct fb_ops bfin_t350mcqb_fb_ops = {
367 .owner = THIS_MODULE,
368 .fb_open = bfin_t350mcqb_fb_open,
369 .fb_release = bfin_t350mcqb_fb_release,
370 .fb_check_var = bfin_t350mcqb_fb_check_var,
371 .fb_fillrect = cfb_fillrect,
372 .fb_copyarea = cfb_copyarea,
373 .fb_imageblit = cfb_imageblit,
374 .fb_mmap = bfin_t350mcqb_fb_mmap,
375 .fb_cursor = bfin_t350mcqb_fb_cursor,
376 .fb_setcolreg = bfin_t350mcqb_fb_setcolreg,
377};
378
379#ifndef NO_BL_SUPPORT
380static int bl_get_brightness(struct backlight_device *bd)
381{
382 return 0;
383}
384
385static struct backlight_ops bfin_lq043fb_bl_ops = {
386 .get_brightness = bl_get_brightness,
387};
388
389static struct backlight_device *bl_dev;
390
391static int bfin_lcd_get_power(struct lcd_device *dev)
392{
393 return 0;
394}
395
396static int bfin_lcd_set_power(struct lcd_device *dev, int power)
397{
398 return 0;
399}
400
401static int bfin_lcd_get_contrast(struct lcd_device *dev)
402{
403 return 0;
404}
405
406static int bfin_lcd_set_contrast(struct lcd_device *dev, int contrast)
407{
408
409 return 0;
410}
411
Ben Dooks0c531362008-07-23 21:31:38 -0700412static int bfin_lcd_check_fb(struct lcd_device *dev, struct fb_info *fi)
Michael Hennerich99eeed47a2008-03-10 11:44:04 -0700413{
414 if (!fi || (fi == &bfin_t350mcqb_fb))
415 return 1;
416 return 0;
417}
418
419static struct lcd_ops bfin_lcd_ops = {
420 .get_power = bfin_lcd_get_power,
421 .set_power = bfin_lcd_set_power,
422 .get_contrast = bfin_lcd_get_contrast,
423 .set_contrast = bfin_lcd_set_contrast,
424 .check_fb = bfin_lcd_check_fb,
425};
426
427static struct lcd_device *lcd_dev;
428#endif
429
430static irqreturn_t bfin_t350mcqb_irq_error(int irq, void *dev_id)
431{
432 /*struct bfin_t350mcqbfb_info *info = (struct bfin_t350mcqbfb_info *)dev_id;*/
433
434 u16 status = bfin_read_PPI_STATUS();
435 bfin_write_PPI_STATUS(0xFFFF);
436
437 if (status) {
438 bfin_t350mcqb_disable_ppi();
439 disable_dma(CH_PPI);
440
441 /* start dma */
442 enable_dma(CH_PPI);
443 bfin_t350mcqb_enable_ppi();
444 bfin_write_PPI_STATUS(0xFFFF);
445 }
446
447 return IRQ_HANDLED;
448}
449
450static int __init bfin_t350mcqb_probe(struct platform_device *pdev)
451{
452 struct bfin_t350mcqbfb_info *info;
453 struct fb_info *fbinfo;
454 int ret;
455
456 printk(KERN_INFO DRIVER_NAME ": %dx%d %d-bit RGB FrameBuffer initializing...\n",
457 LCD_X_RES, LCD_Y_RES, LCD_BPP);
458
459 if (request_dma(CH_PPI, "CH_PPI") < 0) {
460 printk(KERN_ERR DRIVER_NAME
461 ": couldn't request CH_PPI DMA\n");
462 ret = -EFAULT;
463 goto out1;
464 }
465
466 fbinfo =
467 framebuffer_alloc(sizeof(struct bfin_t350mcqbfb_info), &pdev->dev);
468 if (!fbinfo) {
469 ret = -ENOMEM;
470 goto out2;
471 }
472
473 info = fbinfo->par;
474 info->fb = fbinfo;
475 info->dev = &pdev->dev;
476
477 platform_set_drvdata(pdev, fbinfo);
478
479 strcpy(fbinfo->fix.id, driver_name);
480
481 fbinfo->fix.type = FB_TYPE_PACKED_PIXELS;
482 fbinfo->fix.type_aux = 0;
483 fbinfo->fix.xpanstep = 0;
484 fbinfo->fix.ypanstep = 0;
485 fbinfo->fix.ywrapstep = 0;
486 fbinfo->fix.accel = FB_ACCEL_NONE;
487 fbinfo->fix.visual = FB_VISUAL_TRUECOLOR;
488
489 fbinfo->var.nonstd = 0;
490 fbinfo->var.activate = FB_ACTIVATE_NOW;
491 fbinfo->var.height = -1;
492 fbinfo->var.width = -1;
493 fbinfo->var.accel_flags = 0;
494 fbinfo->var.vmode = FB_VMODE_NONINTERLACED;
495
496 fbinfo->var.xres = LCD_X_RES;
497 fbinfo->var.xres_virtual = LCD_X_RES;
498 fbinfo->var.yres = LCD_Y_RES;
499 fbinfo->var.yres_virtual = LCD_Y_RES;
500 fbinfo->var.bits_per_pixel = LCD_BPP;
501
502 fbinfo->var.red.offset = 0;
503 fbinfo->var.green.offset = 8;
504 fbinfo->var.blue.offset = 16;
505 fbinfo->var.transp.offset = 0;
506 fbinfo->var.red.length = 8;
507 fbinfo->var.green.length = 8;
508 fbinfo->var.blue.length = 8;
509 fbinfo->var.transp.length = 0;
510 fbinfo->fix.smem_len = LCD_X_RES * LCD_Y_RES * LCD_BPP / 8;
511
512 fbinfo->fix.line_length = fbinfo->var.xres_virtual *
513 fbinfo->var.bits_per_pixel / 8;
514
515
516 fbinfo->fbops = &bfin_t350mcqb_fb_ops;
517 fbinfo->flags = FBINFO_FLAG_DEFAULT;
518
519 info->fb_buffer =
520 dma_alloc_coherent(NULL, fbinfo->fix.smem_len, &info->dma_handle,
521 GFP_KERNEL);
522
523 if (NULL == info->fb_buffer) {
524 printk(KERN_ERR DRIVER_NAME
525 ": couldn't allocate dma buffer.\n");
526 ret = -ENOMEM;
527 goto out3;
528 }
529
530 memset(info->fb_buffer, 0, fbinfo->fix.smem_len);
531
532 fbinfo->screen_base = (void *)info->fb_buffer + ACTIVE_VIDEO_MEM_OFFSET;
533 fbinfo->fix.smem_start = (int)info->fb_buffer + ACTIVE_VIDEO_MEM_OFFSET;
534
535 fbinfo->fbops = &bfin_t350mcqb_fb_ops;
536
Bryan Wu7ef98612008-03-28 14:16:05 -0700537 fbinfo->pseudo_palette = &info->pseudo_pal;
Michael Hennerich99eeed47a2008-03-10 11:44:04 -0700538
539 if (fb_alloc_cmap(&fbinfo->cmap, BFIN_LCD_NBR_PALETTE_ENTRIES, 0)
540 < 0) {
541 printk(KERN_ERR DRIVER_NAME
542 "Fail to allocate colormap (%d entries)\n",
543 BFIN_LCD_NBR_PALETTE_ENTRIES);
544 ret = -EFAULT;
Bryan Wu7ef98612008-03-28 14:16:05 -0700545 goto out4;
Michael Hennerich99eeed47a2008-03-10 11:44:04 -0700546 }
547
548 if (bfin_t350mcqb_request_ports(1)) {
549 printk(KERN_ERR DRIVER_NAME ": couldn't request gpio port.\n");
550 ret = -EFAULT;
551 goto out6;
552 }
553
554 info->irq = platform_get_irq(pdev, 0);
555 if (info->irq < 0) {
556 ret = -EINVAL;
557 goto out7;
558 }
559
Bryan Wu7ef98612008-03-28 14:16:05 -0700560 ret = request_irq(info->irq, bfin_t350mcqb_irq_error, IRQF_DISABLED,
561 "PPI ERROR", info);
562 if (ret < 0) {
Michael Hennerich99eeed47a2008-03-10 11:44:04 -0700563 printk(KERN_ERR DRIVER_NAME
564 ": unable to request PPI ERROR IRQ\n");
Michael Hennerich99eeed47a2008-03-10 11:44:04 -0700565 goto out7;
566 }
567
568 if (register_framebuffer(fbinfo) < 0) {
569 printk(KERN_ERR DRIVER_NAME
570 ": unable to register framebuffer.\n");
571 ret = -EINVAL;
572 goto out8;
573 }
574#ifndef NO_BL_SUPPORT
575 bl_dev =
576 backlight_device_register("bf52x-bl", NULL, NULL,
577 &bfin_lq043fb_bl_ops);
578 bl_dev->props.max_brightness = 255;
579
580 lcd_dev = lcd_device_register(DRIVER_NAME, NULL, &bfin_lcd_ops);
581 lcd_dev->props.max_contrast = 255, printk(KERN_INFO "Done.\n");
582#endif
583
584 return 0;
585
586out8:
587 free_irq(info->irq, info);
588out7:
589 bfin_t350mcqb_request_ports(0);
590out6:
591 fb_dealloc_cmap(&fbinfo->cmap);
Michael Hennerich99eeed47a2008-03-10 11:44:04 -0700592out4:
593 dma_free_coherent(NULL, fbinfo->fix.smem_len, info->fb_buffer,
594 info->dma_handle);
595out3:
596 framebuffer_release(fbinfo);
597out2:
598 free_dma(CH_PPI);
599out1:
600 platform_set_drvdata(pdev, NULL);
601
602 return ret;
603}
604
605static int bfin_t350mcqb_remove(struct platform_device *pdev)
606{
607
608 struct fb_info *fbinfo = platform_get_drvdata(pdev);
609 struct bfin_t350mcqbfb_info *info = fbinfo->par;
610
Bryan Wu7ef98612008-03-28 14:16:05 -0700611 unregister_framebuffer(fbinfo);
612
Michael Hennerich99eeed47a2008-03-10 11:44:04 -0700613 free_dma(CH_PPI);
614 free_irq(info->irq, info);
615
616 if (info->fb_buffer != NULL)
617 dma_free_coherent(NULL, fbinfo->fix.smem_len, info->fb_buffer,
618 info->dma_handle);
619
Michael Hennerich99eeed47a2008-03-10 11:44:04 -0700620 fb_dealloc_cmap(&fbinfo->cmap);
621
622#ifndef NO_BL_SUPPORT
623 lcd_device_unregister(lcd_dev);
624 backlight_device_unregister(bl_dev);
625#endif
626
Michael Hennerich99eeed47a2008-03-10 11:44:04 -0700627 bfin_t350mcqb_request_ports(0);
628
Bryan Wu7ef98612008-03-28 14:16:05 -0700629 platform_set_drvdata(pdev, NULL);
630 framebuffer_release(fbinfo);
631
Michael Hennerich99eeed47a2008-03-10 11:44:04 -0700632 printk(KERN_INFO DRIVER_NAME ": Unregister LCD driver.\n");
633
634 return 0;
635}
636
637#ifdef CONFIG_PM
638static int bfin_t350mcqb_suspend(struct platform_device *pdev, pm_message_t state)
639{
640 struct fb_info *fbinfo = platform_get_drvdata(pdev);
641 struct bfin_t350mcqbfb_info *info = fbinfo->par;
642
643 bfin_t350mcqb_disable_ppi();
644 disable_dma(CH_PPI);
645 bfin_write_PPI_STATUS(0xFFFF);
646
647 return 0;
648}
649
650static int bfin_t350mcqb_resume(struct platform_device *pdev)
651{
652 struct fb_info *fbinfo = platform_get_drvdata(pdev);
653 struct bfin_t350mcqbfb_info *info = fbinfo->par;
654
655 enable_dma(CH_PPI);
656 bfin_t350mcqb_enable_ppi();
657
658 return 0;
659}
660#else
661#define bfin_t350mcqb_suspend NULL
662#define bfin_t350mcqb_resume NULL
663#endif
664
665static struct platform_driver bfin_t350mcqb_driver = {
666 .probe = bfin_t350mcqb_probe,
667 .remove = bfin_t350mcqb_remove,
668 .suspend = bfin_t350mcqb_suspend,
669 .resume = bfin_t350mcqb_resume,
670 .driver = {
671 .name = DRIVER_NAME,
672 .owner = THIS_MODULE,
673 },
674};
675
676static int __devinit bfin_t350mcqb_driver_init(void)
677{
678 return platform_driver_register(&bfin_t350mcqb_driver);
679}
680
681static void __exit bfin_t350mcqb_driver_cleanup(void)
682{
683 platform_driver_unregister(&bfin_t350mcqb_driver);
684}
685
686MODULE_DESCRIPTION("Blackfin TFT LCD Driver");
687MODULE_LICENSE("GPL");
688
689module_init(bfin_t350mcqb_driver_init);
690module_exit(bfin_t350mcqb_driver_cleanup);