2 * Copyright 2008 Freescale Semiconductor, Inc. All Rights Reserved.
4 * Freescale DIU Frame Buffer device driver
6 * Authors: Hongjun Chen <hong-jun.chen@freescale.com>
7 * Paul Widmer <paul.widmer@freescale.com>
8 * Srikanth Srinivasan <srikanth.srinivasan@freescale.com>
9 * York Sun <yorksun@freescale.com>
11 * Based on imxfb.c Copyright (C) 2004 S.Hauer, Pengutronix
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the
15 * Free Software Foundation; either version 2 of the License, or (at your
16 * option) any later version.
20 #include <linux/module.h>
21 #include <linux/kernel.h>
22 #include <linux/errno.h>
23 #include <linux/string.h>
24 #include <linux/slab.h>
26 #include <linux/init.h>
27 #include <linux/dma-mapping.h>
28 #include <linux/platform_device.h>
29 #include <linux/interrupt.h>
30 #include <linux/clk.h>
31 #include <linux/uaccess.h>
32 #include <linux/vmalloc.h>
33 #include <linux/spinlock.h>
35 #include <sysdev/fsl_soc.h>
36 #include <linux/fsl-diu-fb.h>
39 #define NUM_AOIS 5 /* 1 for plane 0, 2 for planes 1 & 2 each */
41 /* HW cursor parameters */
44 /* INT_STATUS/INT_MASK field descriptions */
45 #define INT_VSYNC 0x01 /* Vsync interrupt */
46 #define INT_VSYNC_WB 0x02 /* Vsync interrupt for write back operation */
47 #define INT_UNDRUN 0x04 /* Under run exception interrupt */
48 #define INT_PARERR 0x08 /* Display parameters error interrupt */
49 #define INT_LS_BF_VS 0x10 /* Lines before vsync. interrupt */
52 * List of supported video modes
54 * The first entry is the default video mode. The remain entries are in
55 * order if increasing resolution and frequency. The 320x240-60 mode is
56 * the initial AOI for the second and third planes.
58 static struct fb_videomode __devinitdata fsl_diu_mode_db[] = {
70 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
71 .vmode = FB_VMODE_NONINTERLACED
84 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
85 .vmode = FB_VMODE_NONINTERLACED
98 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
99 .vmode = FB_VMODE_NONINTERLACED
112 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
113 .vmode = FB_VMODE_NONINTERLACED
126 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
127 .vmode = FB_VMODE_NONINTERLACED
140 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
141 .vmode = FB_VMODE_NONINTERLACED
154 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
155 .vmode = FB_VMODE_NONINTERLACED
168 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
169 .vmode = FB_VMODE_NONINTERLACED
182 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
183 .vmode = FB_VMODE_NONINTERLACED
196 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
197 .vmode = FB_VMODE_NONINTERLACED
210 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
211 .vmode = FB_VMODE_NONINTERLACED
224 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
225 .vmode = FB_VMODE_NONINTERLACED
238 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
239 .vmode = FB_VMODE_NONINTERLACED
252 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
253 .vmode = FB_VMODE_NONINTERLACED
266 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
267 .vmode = FB_VMODE_NONINTERLACED
280 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
281 .vmode = FB_VMODE_NONINTERLACED
294 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
295 .vmode = FB_VMODE_NONINTERLACED
308 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
309 .vmode = FB_VMODE_NONINTERLACED
313 static char *fb_mode;
314 static unsigned long default_bpp = 32;
315 static enum fsl_diu_monitor_port monitor_port;
316 static char *monitor_string;
318 #if defined(CONFIG_NOT_COHERENT_CACHE)
319 static u8 *coherence_data;
320 static size_t coherence_data_size;
321 static unsigned int d_cache_line_size;
324 static DEFINE_SPINLOCK(diu_lock);
327 PLANE0 = 0, /* Plane 0, only one AOI that fills the screen */
328 PLANE1_AOI0, /* Plane 1, first AOI */
329 PLANE1_AOI1, /* Plane 1, second AOI */
330 PLANE2_AOI0, /* Plane 2, first AOI */
331 PLANE2_AOI1, /* Plane 2, second AOI */
335 enum mfb_index index;
338 unsigned long pseudo_palette[16];
341 unsigned char g_alpha;
343 int x_aoi_d; /* aoi display x offset to physical screen */
344 int y_aoi_d; /* aoi display y offset to physical screen */
345 struct fsl_diu_data *parent;
350 * struct fsl_diu_data - per-DIU data structure
351 * @dma_addr: DMA address of this structure
352 * @fsl_diu_info: fb_info objects, one per AOI
353 * @dev_attr: sysfs structure
355 * @monitor_port: the monitor port this DIU is connected to
356 * @diu_reg: pointer to the DIU hardware registers
357 * @reg_lock: spinlock for register access
358 * @dummy_aoi: video buffer for the 4x4 32-bit dummy AOI
359 * dummy_ad: DIU Area Descriptor for the dummy AOI
360 * @ad[]: Area Descriptors for each real AOI
361 * @gamma: gamma color table
362 * @cursor: hardware cursor data
364 * This data structure must be allocated with 32-byte alignment, so that the
365 * internal fields can be aligned properly.
367 struct fsl_diu_data {
369 struct fb_info fsl_diu_info[NUM_AOIS];
370 struct mfb_info mfb[NUM_AOIS];
371 struct device_attribute dev_attr;
373 enum fsl_diu_monitor_port monitor_port;
374 struct diu __iomem *diu_reg;
376 u8 dummy_aoi[4 * 4 * 4];
377 struct diu_ad dummy_ad __aligned(8);
378 struct diu_ad ad[NUM_AOIS] __aligned(8);
379 u8 gamma[256 * 3] __aligned(32);
380 u8 cursor[MAX_CURS * MAX_CURS * 2] __aligned(32);
383 /* Determine the DMA address of a member of the fsl_diu_data structure */
384 #define DMA_ADDR(p, f) ((p)->dma_addr + offsetof(struct fsl_diu_data, f))
386 static struct mfb_info mfb_template[] = {
396 .index = PLANE1_AOI0,
405 .index = PLANE1_AOI1,
414 .index = PLANE2_AOI0,
423 .index = PLANE2_AOI1,
434 * fsl_diu_name_to_port - convert a port name to a monitor port enum
436 * Takes the name of a monitor port ("dvi", "lvds", or "dlvds") and returns
437 * the enum fsl_diu_monitor_port that corresponds to that string.
439 * For compatibility with older versions, a number ("0", "1", or "2") is also
442 * If the string is unknown, DVI is assumed.
444 * If the particular port is not supported by the platform, another port
445 * (platform-specific) is chosen instead.
447 static enum fsl_diu_monitor_port fsl_diu_name_to_port(const char *s)
449 enum fsl_diu_monitor_port port = FSL_DIU_PORT_DVI;
453 if (!strict_strtoul(s, 10, &val) && (val <= 2))
454 port = (enum fsl_diu_monitor_port) val;
455 else if (strncmp(s, "lvds", 4) == 0)
456 port = FSL_DIU_PORT_LVDS;
457 else if (strncmp(s, "dlvds", 5) == 0)
458 port = FSL_DIU_PORT_DLVDS;
461 return diu_ops.valid_monitor_port(port);
465 * fsl_diu_alloc - allocate memory for the DIU
466 * @size: number of bytes to allocate
467 * @param: returned physical address of memory
469 * This function allocates a physically-contiguous block of memory.
471 static void *fsl_diu_alloc(size_t size, phys_addr_t *phys)
475 virt = alloc_pages_exact(size, GFP_DMA | __GFP_ZERO);
477 *phys = virt_to_phys(virt);
483 * fsl_diu_free - release DIU memory
484 * @virt: pointer returned by fsl_diu_alloc()
485 * @size: number of bytes allocated by fsl_diu_alloc()
487 * This function releases memory allocated by fsl_diu_alloc().
489 static void fsl_diu_free(void *virt, size_t size)
492 free_pages_exact(virt, size);
496 * Workaround for failed writing desc register of planes.
497 * Needed with MPC5121 DIU rev 2.0 silicon.
499 void wr_reg_wa(u32 *reg, u32 val)
503 } while (in_be32(reg) != val);
506 static void fsl_diu_enable_panel(struct fb_info *info)
508 struct mfb_info *pmfbi, *cmfbi, *mfbi = info->par;
509 struct diu_ad *ad = mfbi->ad;
510 struct fsl_diu_data *data = mfbi->parent;
511 struct diu __iomem *hw = data->diu_reg;
513 switch (mfbi->index) {
515 if (hw->desc[0] != ad->paddr)
516 wr_reg_wa(&hw->desc[0], ad->paddr);
519 cmfbi = &data->mfb[2];
520 if (hw->desc[1] != ad->paddr) { /* AOI0 closed */
521 if (cmfbi->count > 0) /* AOI1 open */
523 cpu_to_le32(cmfbi->ad->paddr);
526 wr_reg_wa(&hw->desc[1], ad->paddr);
530 cmfbi = &data->mfb[4];
531 if (hw->desc[2] != ad->paddr) { /* AOI0 closed */
532 if (cmfbi->count > 0) /* AOI1 open */
534 cpu_to_le32(cmfbi->ad->paddr);
537 wr_reg_wa(&hw->desc[2], ad->paddr);
541 pmfbi = &data->mfb[1];
543 if (hw->desc[1] == data->dummy_ad.paddr)
544 wr_reg_wa(&hw->desc[1], ad->paddr);
546 pmfbi->ad->next_ad = cpu_to_le32(ad->paddr);
549 pmfbi = &data->mfb[3];
551 if (hw->desc[2] == data->dummy_ad.paddr)
552 wr_reg_wa(&hw->desc[2], ad->paddr);
553 else /* AOI0 was open */
554 pmfbi->ad->next_ad = cpu_to_le32(ad->paddr);
559 static void fsl_diu_disable_panel(struct fb_info *info)
561 struct mfb_info *pmfbi, *cmfbi, *mfbi = info->par;
562 struct diu_ad *ad = mfbi->ad;
563 struct fsl_diu_data *data = mfbi->parent;
564 struct diu __iomem *hw = data->diu_reg;
566 switch (mfbi->index) {
568 if (hw->desc[0] != data->dummy_ad.paddr)
569 wr_reg_wa(&hw->desc[0], data->dummy_ad.paddr);
572 cmfbi = &data->mfb[2];
573 if (cmfbi->count > 0) /* AOI1 is open */
574 wr_reg_wa(&hw->desc[1], cmfbi->ad->paddr);
575 /* move AOI1 to the first */
576 else /* AOI1 was closed */
577 wr_reg_wa(&hw->desc[1], data->dummy_ad.paddr);
581 cmfbi = &data->mfb[4];
582 if (cmfbi->count > 0) /* AOI1 is open */
583 wr_reg_wa(&hw->desc[2], cmfbi->ad->paddr);
584 /* move AOI1 to the first */
585 else /* AOI1 was closed */
586 wr_reg_wa(&hw->desc[2], data->dummy_ad.paddr);
590 pmfbi = &data->mfb[1];
591 if (hw->desc[1] != ad->paddr) {
592 /* AOI1 is not the first in the chain */
593 if (pmfbi->count > 0)
594 /* AOI0 is open, must be the first */
595 pmfbi->ad->next_ad = 0;
596 } else /* AOI1 is the first in the chain */
597 wr_reg_wa(&hw->desc[1], data->dummy_ad.paddr);
601 pmfbi = &data->mfb[3];
602 if (hw->desc[2] != ad->paddr) {
603 /* AOI1 is not the first in the chain */
604 if (pmfbi->count > 0)
605 /* AOI0 is open, must be the first */
606 pmfbi->ad->next_ad = 0;
607 } else /* AOI1 is the first in the chain */
608 wr_reg_wa(&hw->desc[2], data->dummy_ad.paddr);
614 static void enable_lcdc(struct fb_info *info)
616 struct mfb_info *mfbi = info->par;
617 struct fsl_diu_data *data = mfbi->parent;
618 struct diu __iomem *hw = data->diu_reg;
620 out_be32(&hw->diu_mode, MFB_MODE1);
623 static void disable_lcdc(struct fb_info *info)
625 struct mfb_info *mfbi = info->par;
626 struct fsl_diu_data *data = mfbi->parent;
627 struct diu __iomem *hw = data->diu_reg;
629 out_be32(&hw->diu_mode, 0);
632 static void adjust_aoi_size_position(struct fb_var_screeninfo *var,
633 struct fb_info *info)
635 struct mfb_info *lower_aoi_mfbi, *upper_aoi_mfbi, *mfbi = info->par;
636 struct fsl_diu_data *data = mfbi->parent;
637 int available_height, upper_aoi_bottom;
638 enum mfb_index index = mfbi->index;
639 int lower_aoi_is_open, upper_aoi_is_open;
640 __u32 base_plane_width, base_plane_height, upper_aoi_height;
642 base_plane_width = data->fsl_diu_info[0].var.xres;
643 base_plane_height = data->fsl_diu_info[0].var.yres;
645 if (mfbi->x_aoi_d < 0)
647 if (mfbi->y_aoi_d < 0)
651 if (mfbi->x_aoi_d != 0)
653 if (mfbi->y_aoi_d != 0)
658 lower_aoi_mfbi = data->fsl_diu_info[index+1].par;
659 lower_aoi_is_open = lower_aoi_mfbi->count > 0 ? 1 : 0;
660 if (var->xres > base_plane_width)
661 var->xres = base_plane_width;
662 if ((mfbi->x_aoi_d + var->xres) > base_plane_width)
663 mfbi->x_aoi_d = base_plane_width - var->xres;
665 if (lower_aoi_is_open)
666 available_height = lower_aoi_mfbi->y_aoi_d;
668 available_height = base_plane_height;
669 if (var->yres > available_height)
670 var->yres = available_height;
671 if ((mfbi->y_aoi_d + var->yres) > available_height)
672 mfbi->y_aoi_d = available_height - var->yres;
676 upper_aoi_mfbi = data->fsl_diu_info[index-1].par;
677 upper_aoi_height = data->fsl_diu_info[index-1].var.yres;
678 upper_aoi_bottom = upper_aoi_mfbi->y_aoi_d + upper_aoi_height;
679 upper_aoi_is_open = upper_aoi_mfbi->count > 0 ? 1 : 0;
680 if (var->xres > base_plane_width)
681 var->xres = base_plane_width;
682 if ((mfbi->x_aoi_d + var->xres) > base_plane_width)
683 mfbi->x_aoi_d = base_plane_width - var->xres;
684 if (mfbi->y_aoi_d < 0)
686 if (upper_aoi_is_open) {
687 if (mfbi->y_aoi_d < upper_aoi_bottom)
688 mfbi->y_aoi_d = upper_aoi_bottom;
689 available_height = base_plane_height
692 available_height = base_plane_height;
693 if (var->yres > available_height)
694 var->yres = available_height;
695 if ((mfbi->y_aoi_d + var->yres) > base_plane_height)
696 mfbi->y_aoi_d = base_plane_height - var->yres;
701 * Checks to see if the hardware supports the state requested by var passed
702 * in. This function does not alter the hardware state! If the var passed in
703 * is slightly off by what the hardware can support then we alter the var
704 * PASSED in to what we can do. If the hardware doesn't support mode change
705 * a -EINVAL will be returned by the upper layers.
707 static int fsl_diu_check_var(struct fb_var_screeninfo *var,
708 struct fb_info *info)
710 if (var->xres_virtual < var->xres)
711 var->xres_virtual = var->xres;
712 if (var->yres_virtual < var->yres)
713 var->yres_virtual = var->yres;
715 if (var->xoffset < 0)
718 if (var->yoffset < 0)
721 if (var->xoffset + info->var.xres > info->var.xres_virtual)
722 var->xoffset = info->var.xres_virtual - info->var.xres;
724 if (var->yoffset + info->var.yres > info->var.yres_virtual)
725 var->yoffset = info->var.yres_virtual - info->var.yres;
727 if ((var->bits_per_pixel != 32) && (var->bits_per_pixel != 24) &&
728 (var->bits_per_pixel != 16))
729 var->bits_per_pixel = default_bpp;
731 switch (var->bits_per_pixel) {
734 var->red.offset = 11;
735 var->red.msb_right = 0;
737 var->green.length = 6;
738 var->green.offset = 5;
739 var->green.msb_right = 0;
741 var->blue.length = 5;
742 var->blue.offset = 0;
743 var->blue.msb_right = 0;
745 var->transp.length = 0;
746 var->transp.offset = 0;
747 var->transp.msb_right = 0;
752 var->red.msb_right = 0;
754 var->green.length = 8;
755 var->green.offset = 8;
756 var->green.msb_right = 0;
758 var->blue.length = 8;
759 var->blue.offset = 16;
760 var->blue.msb_right = 0;
762 var->transp.length = 0;
763 var->transp.offset = 0;
764 var->transp.msb_right = 0;
768 var->red.offset = 16;
769 var->red.msb_right = 0;
771 var->green.length = 8;
772 var->green.offset = 8;
773 var->green.msb_right = 0;
775 var->blue.length = 8;
776 var->blue.offset = 0;
777 var->blue.msb_right = 0;
779 var->transp.length = 8;
780 var->transp.offset = 24;
781 var->transp.msb_right = 0;
790 /* Copy nonstd field to/from sync for fbset usage */
791 var->sync |= var->nonstd;
792 var->nonstd |= var->sync;
794 adjust_aoi_size_position(var, info);
798 static void set_fix(struct fb_info *info)
800 struct fb_fix_screeninfo *fix = &info->fix;
801 struct fb_var_screeninfo *var = &info->var;
802 struct mfb_info *mfbi = info->par;
804 strncpy(fix->id, mfbi->id, sizeof(fix->id));
805 fix->line_length = var->xres_virtual * var->bits_per_pixel / 8;
806 fix->type = FB_TYPE_PACKED_PIXELS;
807 fix->accel = FB_ACCEL_NONE;
808 fix->visual = FB_VISUAL_TRUECOLOR;
813 static void update_lcdc(struct fb_info *info)
815 struct fb_var_screeninfo *var = &info->var;
816 struct mfb_info *mfbi = info->par;
817 struct fsl_diu_data *data = mfbi->parent;
818 struct diu __iomem *hw;
820 u8 *gamma_table_base;
826 diu_ops.set_monitor_port(data->monitor_port);
827 gamma_table_base = data->gamma;
829 /* Prep for DIU init - gamma table, cursor table */
831 for (i = 0; i <= 2; i++)
832 for (j = 0; j <= 255; j++)
833 *gamma_table_base++ = j;
835 if (diu_ops.set_gamma_table)
836 diu_ops.set_gamma_table(data->monitor_port, data->gamma);
840 /* Program DIU registers */
842 out_be32(&hw->gamma, DMA_ADDR(data, gamma));
843 out_be32(&hw->cursor, DMA_ADDR(data, cursor));
845 out_be32(&hw->bgnd, 0x007F7F7F); /* BGND */
846 out_be32(&hw->bgnd_wb, 0); /* BGND_WB */
847 out_be32(&hw->disp_size, (var->yres << 16 | var->xres));
849 out_be32(&hw->wb_size, 0); /* WB SIZE */
850 out_be32(&hw->wb_mem_addr, 0); /* WB MEM ADDR */
852 /* Horizontal and vertical configuration register */
853 temp = var->left_margin << 22 | /* BP_H */
854 var->hsync_len << 11 | /* PW_H */
855 var->right_margin; /* FP_H */
857 out_be32(&hw->hsyn_para, temp);
859 temp = var->upper_margin << 22 | /* BP_V */
860 var->vsync_len << 11 | /* PW_V */
861 var->lower_margin; /* FP_V */
863 out_be32(&hw->vsyn_para, temp);
865 diu_ops.set_pixel_clock(var->pixclock);
867 out_be32(&hw->syn_pol, 0); /* SYNC SIGNALS POLARITY */
868 out_be32(&hw->thresholds, 0x00037800); /* The Thresholds */
869 out_be32(&hw->int_status, 0); /* INTERRUPT STATUS */
870 out_be32(&hw->plut, 0x01F5F666);
876 static int map_video_memory(struct fb_info *info)
879 u32 smem_len = info->fix.line_length * info->var.yres_virtual;
881 info->screen_base = fsl_diu_alloc(smem_len, &phys);
882 if (info->screen_base == NULL) {
883 dev_err(info->dev, "unable to allocate fb memory\n");
886 mutex_lock(&info->mm_lock);
887 info->fix.smem_start = (unsigned long) phys;
888 info->fix.smem_len = smem_len;
889 mutex_unlock(&info->mm_lock);
890 info->screen_size = info->fix.smem_len;
895 static void unmap_video_memory(struct fb_info *info)
897 fsl_diu_free(info->screen_base, info->fix.smem_len);
898 mutex_lock(&info->mm_lock);
899 info->screen_base = NULL;
900 info->fix.smem_start = 0;
901 info->fix.smem_len = 0;
902 mutex_unlock(&info->mm_lock);
906 * Using the fb_var_screeninfo in fb_info we set the aoi of this
907 * particular framebuffer. It is a light version of fsl_diu_set_par.
909 static int fsl_diu_set_aoi(struct fb_info *info)
911 struct fb_var_screeninfo *var = &info->var;
912 struct mfb_info *mfbi = info->par;
913 struct diu_ad *ad = mfbi->ad;
915 /* AOI should not be greater than display size */
916 ad->offset_xyi = cpu_to_le32((var->yoffset << 16) | var->xoffset);
917 ad->offset_xyd = cpu_to_le32((mfbi->y_aoi_d << 16) | mfbi->x_aoi_d);
922 * fsl_diu_get_pixel_format: return the pixel format for a given color depth
924 * The pixel format is a 32-bit value that determine which bits in each
925 * pixel are to be used for each color. This is the default function used
926 * if the platform does not define its own version.
928 static u32 fsl_diu_get_pixel_format(unsigned int bits_per_pixel)
930 #define PF_BYTE_F 0x10000000
931 #define PF_ALPHA_C_MASK 0x0E000000
932 #define PF_ALPHA_C_SHIFT 25
933 #define PF_BLUE_C_MASK 0x01800000
934 #define PF_BLUE_C_SHIFT 23
935 #define PF_GREEN_C_MASK 0x00600000
936 #define PF_GREEN_C_SHIFT 21
937 #define PF_RED_C_MASK 0x00180000
938 #define PF_RED_C_SHIFT 19
939 #define PF_PALETTE 0x00040000
940 #define PF_PIXEL_S_MASK 0x00030000
941 #define PF_PIXEL_S_SHIFT 16
942 #define PF_COMP_3_MASK 0x0000F000
943 #define PF_COMP_3_SHIFT 12
944 #define PF_COMP_2_MASK 0x00000F00
945 #define PF_COMP_2_SHIFT 8
946 #define PF_COMP_1_MASK 0x000000F0
947 #define PF_COMP_1_SHIFT 4
948 #define PF_COMP_0_MASK 0x0000000F
949 #define PF_COMP_0_SHIFT 0
951 #define MAKE_PF(alpha, red, blue, green, size, c0, c1, c2, c3) \
952 cpu_to_le32(PF_BYTE_F | (alpha << PF_ALPHA_C_SHIFT) | \
953 (blue << PF_BLUE_C_SHIFT) | (green << PF_GREEN_C_SHIFT) | \
954 (red << PF_RED_C_SHIFT) | (c3 << PF_COMP_3_SHIFT) | \
955 (c2 << PF_COMP_2_SHIFT) | (c1 << PF_COMP_1_SHIFT) | \
956 (c0 << PF_COMP_0_SHIFT) | (size << PF_PIXEL_S_SHIFT))
958 switch (bits_per_pixel) {
961 return MAKE_PF(3, 2, 0, 1, 3, 8, 8, 8, 8);
964 return MAKE_PF(4, 0, 1, 2, 2, 0, 8, 8, 8);
967 return MAKE_PF(4, 2, 1, 0, 1, 5, 6, 5, 0);
969 pr_err("fsl-diu: unsupported color depth %u\n", bits_per_pixel);
975 * Using the fb_var_screeninfo in fb_info we set the resolution of this
976 * particular framebuffer. This function alters the fb_fix_screeninfo stored
977 * in fb_info. It does not alter var in fb_info since we are using that
978 * data. This means we depend on the data in var inside fb_info to be
979 * supported by the hardware. fsl_diu_check_var is always called before
980 * fsl_diu_set_par to ensure this.
982 static int fsl_diu_set_par(struct fb_info *info)
985 struct fb_var_screeninfo *var = &info->var;
986 struct mfb_info *mfbi = info->par;
987 struct fsl_diu_data *data = mfbi->parent;
988 struct diu_ad *ad = mfbi->ad;
989 struct diu __iomem *hw;
994 mfbi->cursor_reset = 1;
996 len = info->var.yres_virtual * info->fix.line_length;
997 /* Alloc & dealloc each time resolution/bpp change */
998 if (len != info->fix.smem_len) {
999 if (info->fix.smem_start)
1000 unmap_video_memory(info);
1002 /* Memory allocation for framebuffer */
1003 if (map_video_memory(info)) {
1004 dev_err(info->dev, "unable to allocate fb memory 1\n");
1009 if (diu_ops.get_pixel_format)
1010 ad->pix_fmt = diu_ops.get_pixel_format(data->monitor_port,
1011 var->bits_per_pixel);
1013 ad->pix_fmt = fsl_diu_get_pixel_format(var->bits_per_pixel);
1015 ad->addr = cpu_to_le32(info->fix.smem_start);
1016 ad->src_size_g_alpha = cpu_to_le32((var->yres_virtual << 12) |
1017 var->xres_virtual) | mfbi->g_alpha;
1018 /* AOI should not be greater than display size */
1019 ad->aoi_size = cpu_to_le32((var->yres << 16) | var->xres);
1020 ad->offset_xyi = cpu_to_le32((var->yoffset << 16) | var->xoffset);
1021 ad->offset_xyd = cpu_to_le32((mfbi->y_aoi_d << 16) | mfbi->x_aoi_d);
1023 /* Disable chroma keying function */
1032 if (mfbi->index == PLANE0)
1037 static inline __u32 CNVT_TOHW(__u32 val, __u32 width)
1039 return ((val << width) + 0x7FFF - val) >> 16;
1043 * Set a single color register. The values supplied have a 16 bit magnitude
1044 * which needs to be scaled in this function for the hardware. Things to take
1045 * into consideration are how many color registers, if any, are supported with
1046 * the current color visual. With truecolor mode no color palettes are
1047 * supported. Here a pseudo palette is created which we store the value in
1048 * pseudo_palette in struct fb_info. For pseudocolor mode we have a limited
1051 static int fsl_diu_setcolreg(unsigned int regno, unsigned int red,
1052 unsigned int green, unsigned int blue,
1053 unsigned int transp, struct fb_info *info)
1058 * If greyscale is true, then we convert the RGB value
1059 * to greyscale no matter what visual we are using.
1061 if (info->var.grayscale)
1062 red = green = blue = (19595 * red + 38470 * green +
1064 switch (info->fix.visual) {
1065 case FB_VISUAL_TRUECOLOR:
1067 * 16-bit True Colour. We encode the RGB value
1068 * according to the RGB bitfield information.
1071 u32 *pal = info->pseudo_palette;
1074 red = CNVT_TOHW(red, info->var.red.length);
1075 green = CNVT_TOHW(green, info->var.green.length);
1076 blue = CNVT_TOHW(blue, info->var.blue.length);
1077 transp = CNVT_TOHW(transp, info->var.transp.length);
1079 v = (red << info->var.red.offset) |
1080 (green << info->var.green.offset) |
1081 (blue << info->var.blue.offset) |
1082 (transp << info->var.transp.offset);
1094 * Pan (or wrap, depending on the `vmode' field) the display using the
1095 * 'xoffset' and 'yoffset' fields of the 'var' structure. If the values
1096 * don't fit, return -EINVAL.
1098 static int fsl_diu_pan_display(struct fb_var_screeninfo *var,
1099 struct fb_info *info)
1101 if ((info->var.xoffset == var->xoffset) &&
1102 (info->var.yoffset == var->yoffset))
1103 return 0; /* No change, do nothing */
1105 if (var->xoffset < 0 || var->yoffset < 0
1106 || var->xoffset + info->var.xres > info->var.xres_virtual
1107 || var->yoffset + info->var.yres > info->var.yres_virtual)
1110 info->var.xoffset = var->xoffset;
1111 info->var.yoffset = var->yoffset;
1113 if (var->vmode & FB_VMODE_YWRAP)
1114 info->var.vmode |= FB_VMODE_YWRAP;
1116 info->var.vmode &= ~FB_VMODE_YWRAP;
1118 fsl_diu_set_aoi(info);
1123 static int fsl_diu_ioctl(struct fb_info *info, unsigned int cmd,
1126 struct mfb_info *mfbi = info->par;
1127 struct diu_ad *ad = mfbi->ad;
1128 struct mfb_chroma_key ck;
1129 unsigned char global_alpha;
1130 struct aoi_display_offset aoi_d;
1132 void __user *buf = (void __user *)arg;
1137 case MFB_SET_PIXFMT_OLD:
1139 "MFB_SET_PIXFMT value of 0x%08x is deprecated.\n",
1140 MFB_SET_PIXFMT_OLD);
1141 case MFB_SET_PIXFMT:
1142 if (copy_from_user(&pix_fmt, buf, sizeof(pix_fmt)))
1144 ad->pix_fmt = pix_fmt;
1146 case MFB_GET_PIXFMT_OLD:
1148 "MFB_GET_PIXFMT value of 0x%08x is deprecated.\n",
1149 MFB_GET_PIXFMT_OLD);
1150 case MFB_GET_PIXFMT:
1151 pix_fmt = ad->pix_fmt;
1152 if (copy_to_user(buf, &pix_fmt, sizeof(pix_fmt)))
1156 if (copy_from_user(&aoi_d, buf, sizeof(aoi_d)))
1158 mfbi->x_aoi_d = aoi_d.x_aoi_d;
1159 mfbi->y_aoi_d = aoi_d.y_aoi_d;
1160 fsl_diu_check_var(&info->var, info);
1161 fsl_diu_set_aoi(info);
1164 aoi_d.x_aoi_d = mfbi->x_aoi_d;
1165 aoi_d.y_aoi_d = mfbi->y_aoi_d;
1166 if (copy_to_user(buf, &aoi_d, sizeof(aoi_d)))
1170 global_alpha = mfbi->g_alpha;
1171 if (copy_to_user(buf, &global_alpha, sizeof(global_alpha)))
1175 /* set panel information */
1176 if (copy_from_user(&global_alpha, buf, sizeof(global_alpha)))
1178 ad->src_size_g_alpha = (ad->src_size_g_alpha & (~0xff)) |
1179 (global_alpha & 0xff);
1180 mfbi->g_alpha = global_alpha;
1182 case MFB_SET_CHROMA_KEY:
1183 /* set panel winformation */
1184 if (copy_from_user(&ck, buf, sizeof(ck)))
1188 (ck.red_max < ck.red_min ||
1189 ck.green_max < ck.green_min ||
1190 ck.blue_max < ck.blue_min))
1201 ad->ckmax_r = ck.red_max;
1202 ad->ckmax_g = ck.green_max;
1203 ad->ckmax_b = ck.blue_max;
1204 ad->ckmin_r = ck.red_min;
1205 ad->ckmin_g = ck.green_min;
1206 ad->ckmin_b = ck.blue_min;
1210 dev_err(info->dev, "unknown ioctl command (0x%08X)\n", cmd);
1211 return -ENOIOCTLCMD;
1217 /* turn on fb if count == 1
1219 static int fsl_diu_open(struct fb_info *info, int user)
1221 struct mfb_info *mfbi = info->par;
1224 /* free boot splash memory on first /dev/fb0 open */
1225 if ((mfbi->index == PLANE0) && diu_ops.release_bootmem)
1226 diu_ops.release_bootmem();
1228 spin_lock(&diu_lock);
1230 if (mfbi->count == 1) {
1231 fsl_diu_check_var(&info->var, info);
1232 res = fsl_diu_set_par(info);
1236 fsl_diu_enable_panel(info);
1239 spin_unlock(&diu_lock);
1243 /* turn off fb if count == 0
1245 static int fsl_diu_release(struct fb_info *info, int user)
1247 struct mfb_info *mfbi = info->par;
1250 spin_lock(&diu_lock);
1252 if (mfbi->count == 0)
1253 fsl_diu_disable_panel(info);
1255 spin_unlock(&diu_lock);
1259 static struct fb_ops fsl_diu_ops = {
1260 .owner = THIS_MODULE,
1261 .fb_check_var = fsl_diu_check_var,
1262 .fb_set_par = fsl_diu_set_par,
1263 .fb_setcolreg = fsl_diu_setcolreg,
1264 .fb_pan_display = fsl_diu_pan_display,
1265 .fb_fillrect = cfb_fillrect,
1266 .fb_copyarea = cfb_copyarea,
1267 .fb_imageblit = cfb_imageblit,
1268 .fb_ioctl = fsl_diu_ioctl,
1269 .fb_open = fsl_diu_open,
1270 .fb_release = fsl_diu_release,
1273 static int __devinit install_fb(struct fb_info *info)
1276 struct mfb_info *mfbi = info->par;
1277 const char *aoi_mode, *init_aoi_mode = "320x240";
1278 struct fb_videomode *db = fsl_diu_mode_db;
1279 unsigned int dbsize = ARRAY_SIZE(fsl_diu_mode_db);
1280 int has_default_mode = 1;
1282 info->var.activate = FB_ACTIVATE_NOW;
1283 info->fbops = &fsl_diu_ops;
1284 info->flags = FBINFO_DEFAULT | FBINFO_VIRTFB | FBINFO_PARTIAL_PAN_OK |
1286 info->pseudo_palette = mfbi->pseudo_palette;
1288 rc = fb_alloc_cmap(&info->cmap, 16, 0);
1292 if (mfbi->index == PLANE0) {
1293 if (mfbi->edid_data) {
1294 /* Now build modedb from EDID */
1295 fb_edid_to_monspecs(mfbi->edid_data, &info->monspecs);
1296 fb_videomode_to_modelist(info->monspecs.modedb,
1297 info->monspecs.modedb_len,
1299 db = info->monspecs.modedb;
1300 dbsize = info->monspecs.modedb_len;
1304 aoi_mode = init_aoi_mode;
1306 rc = fb_find_mode(&info->var, info, aoi_mode, db, dbsize, NULL,
1310 * For plane 0 we continue and look into
1311 * driver's internal modedb.
1313 if ((mfbi->index == PLANE0) && mfbi->edid_data)
1314 has_default_mode = 0;
1319 if (!has_default_mode) {
1320 rc = fb_find_mode(&info->var, info, aoi_mode, fsl_diu_mode_db,
1321 ARRAY_SIZE(fsl_diu_mode_db), NULL, default_bpp);
1323 has_default_mode = 1;
1326 /* Still not found, use preferred mode from database if any */
1327 if (!has_default_mode && info->monspecs.modedb) {
1328 struct fb_monspecs *specs = &info->monspecs;
1329 struct fb_videomode *modedb = &specs->modedb[0];
1332 * Get preferred timing. If not found,
1333 * first mode in database will be used.
1335 if (specs->misc & FB_MISC_1ST_DETAIL) {
1338 for (i = 0; i < specs->modedb_len; i++) {
1339 if (specs->modedb[i].flag & FB_MODE_IS_FIRST) {
1340 modedb = &specs->modedb[i];
1346 info->var.bits_per_pixel = default_bpp;
1347 fb_videomode_to_var(&info->var, modedb);
1350 if (fsl_diu_check_var(&info->var, info)) {
1351 dev_err(info->dev, "fsl_diu_check_var failed\n");
1352 unmap_video_memory(info);
1353 fb_dealloc_cmap(&info->cmap);
1357 if (register_framebuffer(info) < 0) {
1358 dev_err(info->dev, "register_framebuffer failed\n");
1359 unmap_video_memory(info);
1360 fb_dealloc_cmap(&info->cmap);
1364 mfbi->registered = 1;
1365 dev_info(info->dev, "%s registered successfully\n", mfbi->id);
1370 static void uninstall_fb(struct fb_info *info)
1372 struct mfb_info *mfbi = info->par;
1374 if (!mfbi->registered)
1377 if (mfbi->index == PLANE0)
1378 kfree(mfbi->edid_data);
1380 unregister_framebuffer(info);
1381 unmap_video_memory(info);
1383 fb_dealloc_cmap(&info->cmap);
1385 mfbi->registered = 0;
1388 static irqreturn_t fsl_diu_isr(int irq, void *dev_id)
1390 struct diu __iomem *hw = dev_id;
1391 unsigned int status = in_be32(&hw->int_status);
1394 /* This is the workaround for underrun */
1395 if (status & INT_UNDRUN) {
1396 out_be32(&hw->diu_mode, 0);
1398 out_be32(&hw->diu_mode, 1);
1400 #if defined(CONFIG_NOT_COHERENT_CACHE)
1401 else if (status & INT_VSYNC) {
1404 for (i = 0; i < coherence_data_size;
1405 i += d_cache_line_size)
1406 __asm__ __volatile__ (
1408 ::[input]"r"(&coherence_data[i]));
1416 static int request_irq_local(struct fsl_diu_data *data)
1418 struct diu __iomem *hw = data->diu_reg;
1422 /* Read to clear the status */
1423 in_be32(&hw->int_status);
1425 ret = request_irq(data->irq, fsl_diu_isr, 0, "fsl-diu-fb", hw);
1427 ints = INT_PARERR | INT_LS_BF_VS;
1428 #if !defined(CONFIG_NOT_COHERENT_CACHE)
1432 /* Read to clear the status */
1433 in_be32(&hw->int_status);
1434 out_be32(&hw->int_mask, ints);
1440 static void free_irq_local(struct fsl_diu_data *data)
1442 struct diu __iomem *hw = data->diu_reg;
1444 /* Disable all LCDC interrupt */
1445 out_be32(&hw->int_mask, 0x1f);
1447 free_irq(data->irq, NULL);
1452 * Power management hooks. Note that we won't be called from IRQ context,
1453 * unlike the blank functions above, so we may sleep.
1455 static int fsl_diu_suspend(struct platform_device *ofdev, pm_message_t state)
1457 struct fsl_diu_data *data;
1459 data = dev_get_drvdata(&ofdev->dev);
1460 disable_lcdc(data->fsl_diu_info[0]);
1465 static int fsl_diu_resume(struct platform_device *ofdev)
1467 struct fsl_diu_data *data;
1469 data = dev_get_drvdata(&ofdev->dev);
1470 enable_lcdc(data->fsl_diu_info[0]);
1476 #define fsl_diu_suspend NULL
1477 #define fsl_diu_resume NULL
1478 #endif /* CONFIG_PM */
1480 static ssize_t store_monitor(struct device *device,
1481 struct device_attribute *attr, const char *buf, size_t count)
1483 enum fsl_diu_monitor_port old_monitor_port;
1484 struct fsl_diu_data *data =
1485 container_of(attr, struct fsl_diu_data, dev_attr);
1487 old_monitor_port = data->monitor_port;
1488 data->monitor_port = fsl_diu_name_to_port(buf);
1490 if (old_monitor_port != data->monitor_port) {
1491 /* All AOIs need adjust pixel format
1492 * fsl_diu_set_par only change the pixsel format here
1493 * unlikely to fail. */
1496 for (i=0; i < NUM_AOIS; i++)
1497 fsl_diu_set_par(&data->fsl_diu_info[i]);
1502 static ssize_t show_monitor(struct device *device,
1503 struct device_attribute *attr, char *buf)
1505 struct fsl_diu_data *data =
1506 container_of(attr, struct fsl_diu_data, dev_attr);
1508 switch (data->monitor_port) {
1509 case FSL_DIU_PORT_DVI:
1510 return sprintf(buf, "DVI\n");
1511 case FSL_DIU_PORT_LVDS:
1512 return sprintf(buf, "Single-link LVDS\n");
1513 case FSL_DIU_PORT_DLVDS:
1514 return sprintf(buf, "Dual-link LVDS\n");
1520 static int __devinit fsl_diu_probe(struct platform_device *pdev)
1522 struct device_node *np = pdev->dev.of_node;
1523 struct mfb_info *mfbi;
1524 struct fsl_diu_data *data;
1526 dma_addr_t dma_addr; /* DMA addr of fsl_diu_data struct */
1530 data = dma_alloc_coherent(&pdev->dev, sizeof(struct fsl_diu_data),
1531 &dma_addr, GFP_DMA | __GFP_ZERO);
1534 data->dma_addr = dma_addr;
1537 * dma_alloc_coherent() uses a page allocator, so the address is
1538 * always page-aligned. We need the memory to be 32-byte aligned,
1539 * so that's good. However, if one day the allocator changes, we
1540 * need to catch that. It's not worth the effort to handle unaligned
1541 * alloctions now because it's highly unlikely to ever be a problem.
1543 if ((unsigned long)data & 31) {
1544 dev_err(&pdev->dev, "misaligned allocation");
1549 spin_lock_init(&data->reg_lock);
1551 for (i = 0; i < NUM_AOIS; i++) {
1552 struct fb_info *info = &data->fsl_diu_info[i];
1554 info->device = &pdev->dev;
1555 info->par = &data->mfb[i];
1558 * We store the physical address of the AD in the reserved
1559 * 'paddr' field of the AD itself.
1561 data->ad[i].paddr = DMA_ADDR(data, ad[i]);
1563 info->fix.smem_start = 0;
1565 /* Initialize the AOI data structure */
1567 memcpy(mfbi, &mfb_template[i], sizeof(struct mfb_info));
1568 mfbi->parent = data;
1569 mfbi->ad = &data->ad[i];
1571 if (mfbi->index == PLANE0) {
1576 prop = of_get_property(np, "edid", &len);
1577 if (prop && len == EDID_LENGTH)
1578 mfbi->edid_data = kmemdup(prop, EDID_LENGTH,
1583 data->diu_reg = of_iomap(np, 0);
1584 if (!data->diu_reg) {
1585 dev_err(&pdev->dev, "cannot map DIU registers\n");
1590 diu_mode = in_be32(&data->diu_reg->diu_mode);
1591 if (diu_mode == MFB_MODE0)
1592 out_be32(&data->diu_reg->diu_mode, 0); /* disable DIU */
1594 /* Get the IRQ of the DIU */
1595 data->irq = irq_of_parse_and_map(np, 0);
1598 dev_err(&pdev->dev, "could not get DIU IRQ\n");
1602 data->monitor_port = monitor_port;
1604 /* Initialize the dummy Area Descriptor */
1605 data->dummy_ad.addr = cpu_to_le32(DMA_ADDR(data, dummy_aoi));
1606 data->dummy_ad.pix_fmt = 0x88882317;
1607 data->dummy_ad.src_size_g_alpha = cpu_to_le32((4 << 12) | 4);
1608 data->dummy_ad.aoi_size = cpu_to_le32((4 << 16) | 2);
1609 data->dummy_ad.offset_xyi = 0;
1610 data->dummy_ad.offset_xyd = 0;
1611 data->dummy_ad.next_ad = 0;
1612 data->dummy_ad.paddr = DMA_ADDR(data, dummy_ad);
1615 * Let DIU display splash screen if it was pre-initialized
1616 * by the bootloader, set dummy area descriptor otherwise.
1618 if (diu_mode == MFB_MODE0)
1619 out_be32(&data->diu_reg->desc[0], data->dummy_ad.paddr);
1621 out_be32(&data->diu_reg->desc[1], data->dummy_ad.paddr);
1622 out_be32(&data->diu_reg->desc[2], data->dummy_ad.paddr);
1624 for (i = 0; i < NUM_AOIS; i++) {
1625 ret = install_fb(&data->fsl_diu_info[i]);
1627 dev_err(&pdev->dev, "could not register fb %d\n", i);
1632 if (request_irq_local(data)) {
1633 dev_err(&pdev->dev, "could not claim irq\n");
1637 sysfs_attr_init(&data->dev_attr.attr);
1638 data->dev_attr.attr.name = "monitor";
1639 data->dev_attr.attr.mode = S_IRUGO|S_IWUSR;
1640 data->dev_attr.show = show_monitor;
1641 data->dev_attr.store = store_monitor;
1642 ret = device_create_file(&pdev->dev, &data->dev_attr);
1644 dev_err(&pdev->dev, "could not create sysfs file %s\n",
1645 data->dev_attr.attr.name);
1648 dev_set_drvdata(&pdev->dev, data);
1652 for (i = 0; i < NUM_AOIS; i++)
1653 uninstall_fb(&data->fsl_diu_info[i]);
1655 iounmap(data->diu_reg);
1657 dma_free_coherent(&pdev->dev, sizeof(struct fsl_diu_data), data,
1663 static int fsl_diu_remove(struct platform_device *pdev)
1665 struct fsl_diu_data *data;
1668 data = dev_get_drvdata(&pdev->dev);
1669 disable_lcdc(&data->fsl_diu_info[0]);
1670 free_irq_local(data);
1672 for (i = 0; i < NUM_AOIS; i++)
1673 uninstall_fb(&data->fsl_diu_info[i]);
1675 iounmap(data->diu_reg);
1677 dma_free_coherent(&pdev->dev, sizeof(struct fsl_diu_data), data,
1684 static int __init fsl_diu_setup(char *options)
1689 if (!options || !*options)
1692 while ((opt = strsep(&options, ",")) != NULL) {
1695 if (!strncmp(opt, "monitor=", 8)) {
1696 monitor_port = fsl_diu_name_to_port(opt + 8);
1697 } else if (!strncmp(opt, "bpp=", 4)) {
1698 if (!strict_strtoul(opt + 4, 10, &val))
1708 static struct of_device_id fsl_diu_match[] = {
1709 #ifdef CONFIG_PPC_MPC512x
1711 .compatible = "fsl,mpc5121-diu",
1715 .compatible = "fsl,diu",
1719 MODULE_DEVICE_TABLE(of, fsl_diu_match);
1721 static struct platform_driver fsl_diu_driver = {
1723 .name = "fsl-diu-fb",
1724 .owner = THIS_MODULE,
1725 .of_match_table = fsl_diu_match,
1727 .probe = fsl_diu_probe,
1728 .remove = fsl_diu_remove,
1729 .suspend = fsl_diu_suspend,
1730 .resume = fsl_diu_resume,
1733 static int __init fsl_diu_init(void)
1735 #ifdef CONFIG_NOT_COHERENT_CACHE
1736 struct device_node *np;
1744 * For kernel boot options (in 'video=xxxfb:<options>' format)
1746 if (fb_get_options("fslfb", &option))
1748 fsl_diu_setup(option);
1750 monitor_port = fsl_diu_name_to_port(monitor_string);
1752 pr_info("Freescale Display Interface Unit (DIU) framebuffer driver\n");
1754 #ifdef CONFIG_NOT_COHERENT_CACHE
1755 np = of_find_node_by_type(NULL, "cpu");
1757 pr_err("fsl-diu-fb: can't find 'cpu' device node\n");
1761 prop = of_get_property(np, "d-cache-size", NULL);
1763 pr_err("fsl-diu-fb: missing 'd-cache-size' property' "
1770 * Freescale PLRU requires 13/8 times the cache size to do a proper
1771 * displacement flush
1773 coherence_data_size = be32_to_cpup(prop) * 13;
1774 coherence_data_size /= 8;
1776 prop = of_get_property(np, "d-cache-line-size", NULL);
1778 pr_err("fsl-diu-fb: missing 'd-cache-line-size' property' "
1783 d_cache_line_size = be32_to_cpup(prop);
1786 coherence_data = vmalloc(coherence_data_size);
1787 if (!coherence_data)
1791 ret = platform_driver_register(&fsl_diu_driver);
1793 pr_err("fsl-diu-fb: failed to register platform driver\n");
1794 #if defined(CONFIG_NOT_COHERENT_CACHE)
1795 vfree(coherence_data);
1801 static void __exit fsl_diu_exit(void)
1803 platform_driver_unregister(&fsl_diu_driver);
1804 #if defined(CONFIG_NOT_COHERENT_CACHE)
1805 vfree(coherence_data);
1809 module_init(fsl_diu_init);
1810 module_exit(fsl_diu_exit);
1812 MODULE_AUTHOR("York Sun <yorksun@freescale.com>");
1813 MODULE_DESCRIPTION("Freescale DIU framebuffer driver");
1814 MODULE_LICENSE("GPL");
1816 module_param_named(mode, fb_mode, charp, 0);
1817 MODULE_PARM_DESC(mode,
1818 "Specify resolution as \"<xres>x<yres>[-<bpp>][@<refresh>]\" ");
1819 module_param_named(bpp, default_bpp, ulong, 0);
1820 MODULE_PARM_DESC(bpp, "Specify bit-per-pixel if not specified in 'mode'");
1821 module_param_named(monitor, monitor_string, charp, 0);
1822 MODULE_PARM_DESC(monitor, "Specify the monitor port "
1823 "(\"dvi\", \"lvds\", or \"dlvds\") if supported by the platform");