Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[wrt350n-kernel.git] / drivers / video / bf54x-lq043fb.c
blob508497d93d7dd8c8c0b2e2be9eb9fec150ad9a47
1 /*
2 * File: drivers/video/bf54x-lq043.c
3 * Based on:
4 * Author: Michael Hennerich <hennerich@blackfin.uclinux.org>
6 * Created:
7 * Description: ADSP-BF54x Framebufer driver
10 * Modified:
11 <<<<<<< HEAD:drivers/video/bf54x-lq043fb.c
12 * Copyright 2004-2007 Analog Devices Inc.
13 =======
14 * Copyright 2007-2008 Analog Devices Inc.
15 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/video/bf54x-lq043fb.c
17 * Bugs: Enter bugs at http://blackfin.uclinux.org/
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation; either version 2 of the License, or
22 * (at your option) any later version.
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, see the file COPYING, or write
31 * to the Free Software Foundation, Inc.,
32 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
35 #include <linux/module.h>
36 #include <linux/kernel.h>
37 #include <linux/errno.h>
38 #include <linux/string.h>
39 #include <linux/mm.h>
40 #include <linux/tty.h>
41 #include <linux/slab.h>
42 #include <linux/delay.h>
43 #include <linux/fb.h>
44 #include <linux/ioport.h>
45 #include <linux/init.h>
46 #include <linux/types.h>
47 #include <linux/interrupt.h>
48 #include <linux/sched.h>
49 #include <linux/timer.h>
50 #include <linux/device.h>
51 #include <linux/backlight.h>
52 #include <linux/lcd.h>
53 #include <linux/spinlock.h>
54 #include <linux/dma-mapping.h>
55 #include <linux/platform_device.h>
57 #include <asm/blackfin.h>
58 #include <asm/irq.h>
59 #include <asm/dpmc.h>
60 #include <asm/dma-mapping.h>
61 #include <asm/dma.h>
62 #include <asm/gpio.h>
63 #include <asm/portmux.h>
65 #include <asm/mach/bf54x-lq043.h>
67 #define NO_BL_SUPPORT
69 #define DRIVER_NAME "bf54x-lq043"
70 static char driver_name[] = DRIVER_NAME;
72 #define BFIN_LCD_NBR_PALETTE_ENTRIES 256
74 #define EPPI0_18 {P_PPI0_CLK, P_PPI0_FS1, P_PPI0_FS2, P_PPI0_D0, P_PPI0_D1, P_PPI0_D2, P_PPI0_D3, \
75 P_PPI0_D4, P_PPI0_D5, P_PPI0_D6, P_PPI0_D7, P_PPI0_D8, P_PPI0_D9, P_PPI0_D10, \
76 P_PPI0_D11, P_PPI0_D12, P_PPI0_D13, P_PPI0_D14, P_PPI0_D15, P_PPI0_D16, P_PPI0_D17, 0}
78 #define EPPI0_24 {P_PPI0_D18, P_PPI0_D19, P_PPI0_D20, P_PPI0_D21, P_PPI0_D22, P_PPI0_D23, 0}
80 struct bfin_bf54xfb_info {
81 struct fb_info *fb;
82 struct device *dev;
84 struct bfin_bf54xfb_mach_info *mach_info;
86 unsigned char *fb_buffer; /* RGB Buffer */
88 dma_addr_t dma_handle;
89 int lq043_mmap;
90 int lq043_open_cnt;
91 int irq;
92 spinlock_t lock; /* lock */
95 static int nocursor;
96 module_param(nocursor, int, 0644);
97 MODULE_PARM_DESC(nocursor, "cursor enable/disable");
99 static int outp_rgb666;
100 module_param(outp_rgb666, int, 0);
101 MODULE_PARM_DESC(outp_rgb666, "Output 18-bit RGB666");
103 #define LCD_X_RES 480 /*Horizontal Resolution */
104 #define LCD_Y_RES 272 /* Vertical Resolution */
106 #define LCD_BPP 24 /* Bit Per Pixel */
107 #define DMA_BUS_SIZE 32
109 /* -- Horizontal synchronizing --
111 * Timing characteristics taken from the SHARP LQ043T1DG01 datasheet
112 * (LCY-W-06602A Page 9 of 22)
114 * Clock Frequency 1/Tc Min 7.83 Typ 9.00 Max 9.26 MHz
116 * Period TH - 525 - Clock
117 * Pulse width THp - 41 - Clock
118 * Horizontal period THd - 480 - Clock
119 * Back porch THb - 2 - Clock
120 * Front porch THf - 2 - Clock
122 * -- Vertical synchronizing --
123 * Period TV - 286 - Line
124 * Pulse width TVp - 10 - Line
125 * Vertical period TVd - 272 - Line
126 * Back porch TVb - 2 - Line
127 * Front porch TVf - 2 - Line
130 #define LCD_CLK (8*1000*1000) /* 8MHz */
132 /* # active data to transfer after Horizontal Delay clock */
133 #define EPPI_HCOUNT LCD_X_RES
135 /* # active lines to transfer after Vertical Delay clock */
136 #define EPPI_VCOUNT LCD_Y_RES
138 /* Samples per Line = 480 (active data) + 45 (padding) */
139 #define EPPI_LINE 525
141 /* Lines per Frame = 272 (active data) + 14 (padding) */
142 #define EPPI_FRAME 286
144 /* FS1 (Hsync) Width (Typical)*/
145 #define EPPI_FS1W_HBL 41
147 /* FS1 (Hsync) Period (Typical) */
148 #define EPPI_FS1P_AVPL EPPI_LINE
150 /* Horizontal Delay clock after assertion of Hsync (Typical) */
151 #define EPPI_HDELAY 43
153 /* FS2 (Vsync) Width = FS1 (Hsync) Period * 10 */
154 #define EPPI_FS2W_LVB (EPPI_LINE * 10)
156 /* FS2 (Vsync) Period = FS1 (Hsync) Period * Lines per Frame */
157 #define EPPI_FS2P_LAVF (EPPI_LINE * EPPI_FRAME)
159 /* Vertical Delay after assertion of Vsync (2 Lines) */
160 #define EPPI_VDELAY 12
162 #define EPPI_CLIP 0xFF00FF00
164 /* EPPI Control register configuration value for RGB out
165 * - EPPI as Output
166 * GP 2 frame sync mode,
167 * Internal Clock generation disabled, Internal FS generation enabled,
168 * Receives samples on EPPI_CLK raising edge, Transmits samples on EPPI_CLK falling edge,
169 * FS1 & FS2 are active high,
170 * DLEN = 6 (24 bits for RGB888 out) or 5 (18 bits for RGB666 out)
171 * DMA Unpacking disabled when RGB Formating is enabled, otherwise DMA unpacking enabled
172 * Swapping Enabled,
173 * One (DMA) Channel Mode,
174 * RGB Formatting Enabled for RGB666 output, disabled for RGB888 output
175 * Regular watermark - when FIFO is 100% full,
176 * Urgent watermark - when FIFO is 75% full
179 #define EPPI_CONTROL (0x20136E2E | SWAPEN)
181 static inline u16 get_eppi_clkdiv(u32 target_ppi_clk)
183 u32 sclk = get_sclk();
185 /* EPPI_CLK = (SCLK) / (2 * (EPPI_CLKDIV[15:0] + 1)) */
187 return (((sclk / target_ppi_clk) / 2) - 1);
190 static void config_ppi(struct bfin_bf54xfb_info *fbi)
193 u16 eppi_clkdiv = get_eppi_clkdiv(LCD_CLK);
195 bfin_write_EPPI0_FS1W_HBL(EPPI_FS1W_HBL);
196 bfin_write_EPPI0_FS1P_AVPL(EPPI_FS1P_AVPL);
197 bfin_write_EPPI0_FS2W_LVB(EPPI_FS2W_LVB);
198 bfin_write_EPPI0_FS2P_LAVF(EPPI_FS2P_LAVF);
199 bfin_write_EPPI0_CLIP(EPPI_CLIP);
201 bfin_write_EPPI0_FRAME(EPPI_FRAME);
202 bfin_write_EPPI0_LINE(EPPI_LINE);
204 bfin_write_EPPI0_HCOUNT(EPPI_HCOUNT);
205 bfin_write_EPPI0_HDELAY(EPPI_HDELAY);
206 bfin_write_EPPI0_VCOUNT(EPPI_VCOUNT);
207 bfin_write_EPPI0_VDELAY(EPPI_VDELAY);
209 bfin_write_EPPI0_CLKDIV(eppi_clkdiv);
212 * DLEN = 6 (24 bits for RGB888 out) or 5 (18 bits for RGB666 out)
213 * RGB Formatting Enabled for RGB666 output, disabled for RGB888 output
215 if (outp_rgb666)
216 bfin_write_EPPI0_CONTROL((EPPI_CONTROL & ~DLENGTH) | DLEN_18 |
217 RGB_FMT_EN);
218 else
219 bfin_write_EPPI0_CONTROL(((EPPI_CONTROL & ~DLENGTH) | DLEN_24) &
220 ~RGB_FMT_EN);
225 static int config_dma(struct bfin_bf54xfb_info *fbi)
228 set_dma_config(CH_EPPI0,
229 set_bfin_dma_config(DIR_READ, DMA_FLOW_AUTO,
230 INTR_DISABLE, DIMENSION_2D,
231 DATA_SIZE_32,
232 DMA_NOSYNC_KEEP_DMA_BUF));
233 set_dma_x_count(CH_EPPI0, (LCD_X_RES * LCD_BPP) / DMA_BUS_SIZE);
234 set_dma_x_modify(CH_EPPI0, DMA_BUS_SIZE / 8);
235 set_dma_y_count(CH_EPPI0, LCD_Y_RES);
236 set_dma_y_modify(CH_EPPI0, DMA_BUS_SIZE / 8);
237 set_dma_start_addr(CH_EPPI0, (unsigned long)fbi->fb_buffer);
239 return 0;
242 static int request_ports(struct bfin_bf54xfb_info *fbi)
245 u16 eppi_req_18[] = EPPI0_18;
246 u16 disp = fbi->mach_info->disp;
248 <<<<<<< HEAD:drivers/video/bf54x-lq043fb.c
249 if (gpio_request(disp, NULL)) {
250 =======
251 if (gpio_request(disp, DRIVER_NAME)) {
252 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/video/bf54x-lq043fb.c
253 printk(KERN_ERR "Requesting GPIO %d faild\n", disp);
254 return -EFAULT;
257 if (peripheral_request_list(eppi_req_18, DRIVER_NAME)) {
258 printk(KERN_ERR "Requesting Peripherals faild\n");
259 gpio_free(disp);
260 return -EFAULT;
263 if (!outp_rgb666) {
265 u16 eppi_req_24[] = EPPI0_24;
267 if (peripheral_request_list(eppi_req_24, DRIVER_NAME)) {
268 printk(KERN_ERR "Requesting Peripherals faild\n");
269 peripheral_free_list(eppi_req_18);
270 gpio_free(disp);
271 return -EFAULT;
275 gpio_direction_output(disp, 1);
277 return 0;
280 static void free_ports(struct bfin_bf54xfb_info *fbi)
283 u16 eppi_req_18[] = EPPI0_18;
285 gpio_free(fbi->mach_info->disp);
287 peripheral_free_list(eppi_req_18);
289 if (!outp_rgb666) {
290 u16 eppi_req_24[] = EPPI0_24;
291 peripheral_free_list(eppi_req_24);
295 static int bfin_bf54x_fb_open(struct fb_info *info, int user)
297 struct bfin_bf54xfb_info *fbi = info->par;
299 spin_lock(&fbi->lock);
300 fbi->lq043_open_cnt++;
302 if (fbi->lq043_open_cnt <= 1) {
304 bfin_write_EPPI0_CONTROL(0);
305 SSYNC();
307 config_dma(fbi);
308 config_ppi(fbi);
310 /* start dma */
311 enable_dma(CH_EPPI0);
312 bfin_write_EPPI0_CONTROL(bfin_read_EPPI0_CONTROL() | EPPI_EN);
315 spin_unlock(&fbi->lock);
317 return 0;
320 static int bfin_bf54x_fb_release(struct fb_info *info, int user)
322 struct bfin_bf54xfb_info *fbi = info->par;
324 spin_lock(&fbi->lock);
326 fbi->lq043_open_cnt--;
327 fbi->lq043_mmap = 0;
329 if (fbi->lq043_open_cnt <= 0) {
331 bfin_write_EPPI0_CONTROL(0);
332 SSYNC();
333 disable_dma(CH_EPPI0);
334 memset(fbi->fb_buffer, 0, info->fix.smem_len);
337 spin_unlock(&fbi->lock);
339 return 0;
342 static int bfin_bf54x_fb_check_var(struct fb_var_screeninfo *var,
343 struct fb_info *info)
346 if (var->bits_per_pixel != LCD_BPP) {
347 pr_debug("%s: depth not supported: %u BPP\n", __FUNCTION__,
348 var->bits_per_pixel);
349 return -EINVAL;
352 if (info->var.xres != var->xres || info->var.yres != var->yres ||
353 info->var.xres_virtual != var->xres_virtual ||
354 info->var.yres_virtual != var->yres_virtual) {
355 pr_debug("%s: Resolution not supported: X%u x Y%u \n",
356 __FUNCTION__, var->xres, var->yres);
357 return -EINVAL;
361 * Memory limit
364 if ((info->fix.line_length * var->yres_virtual) > info->fix.smem_len) {
365 pr_debug("%s: Memory Limit requested yres_virtual = %u\n",
366 __FUNCTION__, var->yres_virtual);
367 return -ENOMEM;
370 return 0;
373 static int bfin_bf54x_fb_mmap(struct fb_info *info, struct vm_area_struct *vma)
376 struct bfin_bf54xfb_info *fbi = info->par;
378 if (fbi->lq043_mmap)
379 return -1;
381 spin_lock(&fbi->lock);
382 fbi->lq043_mmap = 1;
383 spin_unlock(&fbi->lock);
385 vma->vm_start = (unsigned long)(fbi->fb_buffer);
387 vma->vm_end = vma->vm_start + info->fix.smem_len;
388 /* For those who don't understand how mmap works, go read
389 * Documentation/nommu-mmap.txt.
390 * For those that do, you will know that the VM_MAYSHARE flag
391 * must be set in the vma->vm_flags structure on noMMU
392 * Other flags can be set, and are documented in
393 * include/linux/mm.h
395 vma->vm_flags |= VM_MAYSHARE;
397 return 0;
400 int bfin_bf54x_fb_cursor(struct fb_info *info, struct fb_cursor *cursor)
402 if (nocursor)
403 return 0;
404 else
405 return -EINVAL; /* just to force soft_cursor() call */
408 static int bfin_bf54x_fb_setcolreg(u_int regno, u_int red, u_int green,
409 u_int blue, u_int transp,
410 struct fb_info *info)
412 if (regno >= BFIN_LCD_NBR_PALETTE_ENTRIES)
413 return -EINVAL;
415 if (info->var.grayscale) {
416 /* grayscale = 0.30*R + 0.59*G + 0.11*B */
417 red = green = blue = (red * 77 + green * 151 + blue * 28) >> 8;
420 if (info->fix.visual == FB_VISUAL_TRUECOLOR) {
422 u32 value;
423 /* Place color in the pseudopalette */
424 if (regno > 16)
425 return -EINVAL;
427 red >>= (16 - info->var.red.length);
428 green >>= (16 - info->var.green.length);
429 blue >>= (16 - info->var.blue.length);
431 value = (red << info->var.red.offset) |
432 (green << info->var.green.offset) |
433 (blue << info->var.blue.offset);
434 value &= 0xFFFFFF;
436 ((u32 *) (info->pseudo_palette))[regno] = value;
440 return 0;
443 static struct fb_ops bfin_bf54x_fb_ops = {
444 .owner = THIS_MODULE,
445 .fb_open = bfin_bf54x_fb_open,
446 .fb_release = bfin_bf54x_fb_release,
447 .fb_check_var = bfin_bf54x_fb_check_var,
448 .fb_fillrect = cfb_fillrect,
449 .fb_copyarea = cfb_copyarea,
450 .fb_imageblit = cfb_imageblit,
451 .fb_mmap = bfin_bf54x_fb_mmap,
452 .fb_cursor = bfin_bf54x_fb_cursor,
453 .fb_setcolreg = bfin_bf54x_fb_setcolreg,
456 #ifndef NO_BL_SUPPORT
457 static int bl_get_brightness(struct backlight_device *bd)
459 return 0;
462 static struct backlight_ops bfin_lq043fb_bl_ops = {
463 .get_brightness = bl_get_brightness,
466 static struct backlight_device *bl_dev;
468 static int bfin_lcd_get_power(struct lcd_device *dev)
470 return 0;
473 static int bfin_lcd_set_power(struct lcd_device *dev, int power)
475 return 0;
478 static int bfin_lcd_get_contrast(struct lcd_device *dev)
480 return 0;
483 static int bfin_lcd_set_contrast(struct lcd_device *dev, int contrast)
486 return 0;
489 static int bfin_lcd_check_fb(struct fb_info *fi)
491 if (!fi || (fi == &bfin_bf54x_fb))
492 return 1;
493 return 0;
496 static struct lcd_ops bfin_lcd_ops = {
497 .get_power = bfin_lcd_get_power,
498 .set_power = bfin_lcd_set_power,
499 .get_contrast = bfin_lcd_get_contrast,
500 .set_contrast = bfin_lcd_set_contrast,
501 .check_fb = bfin_lcd_check_fb,
504 static struct lcd_device *lcd_dev;
505 #endif
507 static irqreturn_t bfin_bf54x_irq_error(int irq, void *dev_id)
509 /*struct bfin_bf54xfb_info *info = dev_id;*/
511 u16 status = bfin_read_EPPI0_STATUS();
513 bfin_write_EPPI0_STATUS(0xFFFF);
515 if (status) {
516 bfin_write_EPPI0_CONTROL(bfin_read_EPPI0_CONTROL() & ~EPPI_EN);
517 disable_dma(CH_EPPI0);
519 /* start dma */
520 enable_dma(CH_EPPI0);
521 bfin_write_EPPI0_CONTROL(bfin_read_EPPI0_CONTROL() | EPPI_EN);
522 bfin_write_EPPI0_STATUS(0xFFFF);
525 return IRQ_HANDLED;
528 static int __init bfin_bf54x_probe(struct platform_device *pdev)
530 struct bfin_bf54xfb_info *info;
531 struct fb_info *fbinfo;
532 int ret;
534 printk(KERN_INFO DRIVER_NAME ": FrameBuffer initializing...\n");
536 if (request_dma(CH_EPPI0, "CH_EPPI0") < 0) {
537 printk(KERN_ERR DRIVER_NAME
538 ": couldn't request CH_EPPI0 DMA\n");
539 ret = -EFAULT;
540 goto out1;
543 fbinfo =
544 framebuffer_alloc(sizeof(struct bfin_bf54xfb_info), &pdev->dev);
545 if (!fbinfo) {
546 ret = -ENOMEM;
547 goto out2;
550 info = fbinfo->par;
551 info->fb = fbinfo;
552 info->dev = &pdev->dev;
554 platform_set_drvdata(pdev, fbinfo);
556 strcpy(fbinfo->fix.id, driver_name);
558 info->mach_info = pdev->dev.platform_data;
560 if (info->mach_info == NULL) {
561 dev_err(&pdev->dev,
562 "no platform data for lcd, cannot attach\n");
563 ret = -EINVAL;
564 goto out3;
567 fbinfo->fix.type = FB_TYPE_PACKED_PIXELS;
568 fbinfo->fix.type_aux = 0;
569 fbinfo->fix.xpanstep = 0;
570 fbinfo->fix.ypanstep = 0;
571 fbinfo->fix.ywrapstep = 0;
572 fbinfo->fix.accel = FB_ACCEL_NONE;
573 fbinfo->fix.visual = FB_VISUAL_TRUECOLOR;
575 fbinfo->var.nonstd = 0;
576 fbinfo->var.activate = FB_ACTIVATE_NOW;
577 fbinfo->var.height = info->mach_info->height;
578 fbinfo->var.width = info->mach_info->width;
579 fbinfo->var.accel_flags = 0;
580 fbinfo->var.vmode = FB_VMODE_NONINTERLACED;
582 fbinfo->fbops = &bfin_bf54x_fb_ops;
583 fbinfo->flags = FBINFO_FLAG_DEFAULT;
585 fbinfo->var.xres = info->mach_info->xres.defval;
586 fbinfo->var.xres_virtual = info->mach_info->xres.defval;
587 fbinfo->var.yres = info->mach_info->yres.defval;
588 fbinfo->var.yres_virtual = info->mach_info->yres.defval;
589 fbinfo->var.bits_per_pixel = info->mach_info->bpp.defval;
591 fbinfo->var.upper_margin = 0;
592 fbinfo->var.lower_margin = 0;
593 fbinfo->var.vsync_len = 0;
595 fbinfo->var.left_margin = 0;
596 fbinfo->var.right_margin = 0;
597 fbinfo->var.hsync_len = 0;
599 fbinfo->var.red.offset = 16;
600 fbinfo->var.green.offset = 8;
601 fbinfo->var.blue.offset = 0;
602 fbinfo->var.transp.offset = 0;
603 fbinfo->var.red.length = 8;
604 fbinfo->var.green.length = 8;
605 fbinfo->var.blue.length = 8;
606 fbinfo->var.transp.length = 0;
607 fbinfo->fix.smem_len = info->mach_info->xres.max *
608 info->mach_info->yres.max * info->mach_info->bpp.max / 8;
610 fbinfo->fix.line_length = fbinfo->var.xres_virtual *
611 fbinfo->var.bits_per_pixel / 8;
613 info->fb_buffer =
614 dma_alloc_coherent(NULL, fbinfo->fix.smem_len, &info->dma_handle,
615 GFP_KERNEL);
617 if (NULL == info->fb_buffer) {
618 printk(KERN_ERR DRIVER_NAME
619 ": couldn't allocate dma buffer.\n");
620 ret = -ENOMEM;
621 goto out3;
624 memset(info->fb_buffer, 0, fbinfo->fix.smem_len);
626 fbinfo->screen_base = (void *)info->fb_buffer;
627 fbinfo->fix.smem_start = (int)info->fb_buffer;
629 fbinfo->fbops = &bfin_bf54x_fb_ops;
631 fbinfo->pseudo_palette = kmalloc(sizeof(u32) * 16, GFP_KERNEL);
632 if (!fbinfo->pseudo_palette) {
633 printk(KERN_ERR DRIVER_NAME
634 "Fail to allocate pseudo_palette\n");
636 ret = -ENOMEM;
637 goto out4;
640 memset(fbinfo->pseudo_palette, 0, sizeof(u32) * 16);
642 if (fb_alloc_cmap(&fbinfo->cmap, BFIN_LCD_NBR_PALETTE_ENTRIES, 0)
643 < 0) {
644 printk(KERN_ERR DRIVER_NAME
645 "Fail to allocate colormap (%d entries)\n",
646 BFIN_LCD_NBR_PALETTE_ENTRIES);
647 ret = -EFAULT;
648 goto out5;
651 if (request_ports(info)) {
652 printk(KERN_ERR DRIVER_NAME ": couldn't request gpio port.\n");
653 ret = -EFAULT;
654 goto out6;
657 info->irq = platform_get_irq(pdev, 0);
658 if (info->irq < 0) {
659 ret = -EINVAL;
660 goto out7;
663 if (request_irq(info->irq, (void *)bfin_bf54x_irq_error, IRQF_DISABLED,
664 "PPI ERROR", info) < 0) {
665 printk(KERN_ERR DRIVER_NAME
666 ": unable to request PPI ERROR IRQ\n");
667 ret = -EFAULT;
668 goto out7;
671 if (register_framebuffer(fbinfo) < 0) {
672 printk(KERN_ERR DRIVER_NAME
673 ": unable to register framebuffer.\n");
674 ret = -EINVAL;
675 goto out8;
677 #ifndef NO_BL_SUPPORT
678 bl_dev =
679 backlight_device_register("bf54x-bl", NULL, NULL,
680 &bfin_lq043fb_bl_ops);
681 bl_dev->props.max_brightness = 255;
683 <<<<<<< HEAD:drivers/video/bf54x-lq043fb.c
684 lcd_dev = lcd_device_register(DRIVER_NAME, NULL, &bfin_lcd_ops);
685 =======
686 lcd_dev = lcd_device_register(DRIVER_NAME, &pdev->dev, NULL, &bfin_lcd_ops);
687 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/video/bf54x-lq043fb.c
688 lcd_dev->props.max_contrast = 255, printk(KERN_INFO "Done.\n");
689 #endif
691 return 0;
693 out8:
694 free_irq(info->irq, info);
695 out7:
696 free_ports(info);
697 out6:
698 fb_dealloc_cmap(&fbinfo->cmap);
699 out5:
700 kfree(fbinfo->pseudo_palette);
701 out4:
702 dma_free_coherent(NULL, fbinfo->fix.smem_len, info->fb_buffer,
703 info->dma_handle);
704 out3:
705 framebuffer_release(fbinfo);
706 out2:
707 free_dma(CH_EPPI0);
708 out1:
709 platform_set_drvdata(pdev, NULL);
711 return ret;
714 static int bfin_bf54x_remove(struct platform_device *pdev)
717 struct fb_info *fbinfo = platform_get_drvdata(pdev);
718 struct bfin_bf54xfb_info *info = fbinfo->par;
720 free_dma(CH_EPPI0);
721 free_irq(info->irq, info);
723 if (info->fb_buffer != NULL)
724 dma_free_coherent(NULL, fbinfo->fix.smem_len, info->fb_buffer,
725 info->dma_handle);
727 kfree(fbinfo->pseudo_palette);
728 fb_dealloc_cmap(&fbinfo->cmap);
730 #ifndef NO_BL_SUPPORT
731 lcd_device_unregister(lcd_dev);
732 backlight_device_unregister(bl_dev);
733 #endif
735 unregister_framebuffer(fbinfo);
737 free_ports(info);
739 printk(KERN_INFO DRIVER_NAME ": Unregister LCD driver.\n");
741 return 0;
744 #ifdef CONFIG_PM
745 static int bfin_bf54x_suspend(struct platform_device *pdev, pm_message_t state)
747 struct fb_info *fbinfo = platform_get_drvdata(pdev);
748 struct bfin_bf54xfb_info *info = fbinfo->par;
750 bfin_write_EPPI0_CONTROL(bfin_read_EPPI0_CONTROL() & ~EPPI_EN);
751 disable_dma(CH_EPPI0);
752 bfin_write_EPPI0_STATUS(0xFFFF);
754 return 0;
757 static int bfin_bf54x_resume(struct platform_device *pdev)
759 struct fb_info *fbinfo = platform_get_drvdata(pdev);
760 struct bfin_bf54xfb_info *info = fbinfo->par;
762 enable_dma(CH_EPPI0);
763 bfin_write_EPPI0_CONTROL(bfin_read_EPPI0_CONTROL() | EPPI_EN);
765 return 0;
767 #else
768 #define bfin_bf54x_suspend NULL
769 #define bfin_bf54x_resume NULL
770 #endif
772 static struct platform_driver bfin_bf54x_driver = {
773 .probe = bfin_bf54x_probe,
774 .remove = bfin_bf54x_remove,
775 .suspend = bfin_bf54x_suspend,
776 .resume = bfin_bf54x_resume,
777 .driver = {
778 .name = DRIVER_NAME,
779 .owner = THIS_MODULE,
783 static int __devinit bfin_bf54x_driver_init(void)
785 return platform_driver_register(&bfin_bf54x_driver);
788 static void __exit bfin_bf54x_driver_cleanup(void)
790 platform_driver_unregister(&bfin_bf54x_driver);
793 MODULE_DESCRIPTION("Blackfin BF54x TFT LCD Driver");
794 MODULE_LICENSE("GPL");
796 module_init(bfin_bf54x_driver_init);
797 module_exit(bfin_bf54x_driver_cleanup);