drivers/video: fsl-diu-fb: merge all allocated data into one block
[deliverable/linux.git] / drivers / video / fsl-diu-fb.c
CommitLineData
9b53a9e2
YS
1/*
2 * Copyright 2008 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * Freescale DIU Frame Buffer device driver
5 *
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>
10 *
11 * Based on imxfb.c Copyright (C) 2004 S.Hauer, Pengutronix
12 *
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.
17 *
18 */
19
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>
25#include <linux/fb.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>
b715f9f0 33#include <linux/spinlock.h>
9b53a9e2 34
9b53a9e2 35#include <sysdev/fsl_soc.h>
0814a979 36#include <linux/fsl-diu-fb.h>
8b856f04 37#include "edid.h"
9b53a9e2 38
ddd3d905 39#define NUM_AOIS 5 /* 1 for plane 0, 2 for planes 1 & 2 each */
b715f9f0
TT
40
41/* HW cursor parameters */
42#define MAX_CURS 32
43
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 */
50
9b53a9e2 51/*
63cf8df4
TT
52 * List of supported video modes
53 *
760af8f8
TT
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.
9b53a9e2 57 */
9b53a9e2
YS
58static struct fb_videomode __devinitdata fsl_diu_mode_db[] = {
59 {
9b53a9e2
YS
60 .refresh = 60,
61 .xres = 1024,
62 .yres = 768,
63 .pixclock = 15385,
64 .left_margin = 160,
65 .right_margin = 24,
66 .upper_margin = 29,
67 .lower_margin = 3,
68 .hsync_len = 136,
69 .vsync_len = 6,
70 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
71 .vmode = FB_VMODE_NONINTERLACED
72 },
73 {
760af8f8
TT
74 .refresh = 60,
75 .xres = 320,
76 .yres = 240,
77 .pixclock = 79440,
78 .left_margin = 16,
79 .right_margin = 16,
80 .upper_margin = 16,
81 .lower_margin = 5,
82 .hsync_len = 48,
83 .vsync_len = 1,
84 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
85 .vmode = FB_VMODE_NONINTERLACED
86 },
87 {
88 .refresh = 60,
89 .xres = 640,
90 .yres = 480,
91 .pixclock = 39722,
92 .left_margin = 48,
93 .right_margin = 16,
94 .upper_margin = 33,
95 .lower_margin = 10,
96 .hsync_len = 96,
97 .vsync_len = 2,
98 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
99 .vmode = FB_VMODE_NONINTERLACED
100 },
101 {
102 .refresh = 72,
103 .xres = 640,
104 .yres = 480,
105 .pixclock = 32052,
106 .left_margin = 128,
107 .right_margin = 24,
108 .upper_margin = 28,
109 .lower_margin = 9,
110 .hsync_len = 40,
111 .vsync_len = 3,
112 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
113 .vmode = FB_VMODE_NONINTERLACED
114 },
115 {
116 .refresh = 75,
117 .xres = 640,
118 .yres = 480,
119 .pixclock = 31747,
120 .left_margin = 120,
121 .right_margin = 16,
122 .upper_margin = 16,
123 .lower_margin = 1,
124 .hsync_len = 64,
125 .vsync_len = 3,
126 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
127 .vmode = FB_VMODE_NONINTERLACED
128 },
129 {
130 .refresh = 90,
131 .xres = 640,
132 .yres = 480,
133 .pixclock = 25057,
134 .left_margin = 120,
135 .right_margin = 32,
136 .upper_margin = 14,
137 .lower_margin = 25,
138 .hsync_len = 40,
139 .vsync_len = 14,
140 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
141 .vmode = FB_VMODE_NONINTERLACED
142 },
143 {
144 .refresh = 100,
145 .xres = 640,
146 .yres = 480,
147 .pixclock = 22272,
148 .left_margin = 48,
149 .right_margin = 32,
150 .upper_margin = 17,
151 .lower_margin = 22,
152 .hsync_len = 128,
153 .vsync_len = 12,
154 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
155 .vmode = FB_VMODE_NONINTERLACED
156 },
157 {
158 .refresh = 60,
159 .xres = 800,
160 .yres = 480,
161 .pixclock = 33805,
162 .left_margin = 96,
163 .right_margin = 24,
164 .upper_margin = 10,
165 .lower_margin = 3,
166 .hsync_len = 72,
167 .vsync_len = 7,
168 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
169 .vmode = FB_VMODE_NONINTERLACED
170 },
171 {
172 .refresh = 60,
173 .xres = 800,
174 .yres = 600,
175 .pixclock = 25000,
176 .left_margin = 88,
177 .right_margin = 40,
178 .upper_margin = 23,
179 .lower_margin = 1,
180 .hsync_len = 128,
181 .vsync_len = 4,
182 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
183 .vmode = FB_VMODE_NONINTERLACED
184 },
185 {
186 .refresh = 60,
187 .xres = 854,
188 .yres = 480,
189 .pixclock = 31518,
190 .left_margin = 104,
191 .right_margin = 16,
192 .upper_margin = 13,
193 .lower_margin = 1,
194 .hsync_len = 88,
195 .vsync_len = 3,
196 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
197 .vmode = FB_VMODE_NONINTERLACED
198 },
199 {
9b53a9e2
YS
200 .refresh = 70,
201 .xres = 1024,
202 .yres = 768,
203 .pixclock = 16886,
204 .left_margin = 3,
205 .right_margin = 3,
206 .upper_margin = 2,
207 .lower_margin = 2,
208 .hsync_len = 40,
209 .vsync_len = 18,
210 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
211 .vmode = FB_VMODE_NONINTERLACED
212 },
213 {
9b53a9e2
YS
214 .refresh = 75,
215 .xres = 1024,
216 .yres = 768,
217 .pixclock = 15009,
218 .left_margin = 3,
219 .right_margin = 3,
220 .upper_margin = 2,
221 .lower_margin = 2,
222 .hsync_len = 80,
223 .vsync_len = 32,
224 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
225 .vmode = FB_VMODE_NONINTERLACED
226 },
227 {
760af8f8
TT
228 .refresh = 60,
229 .xres = 1280,
230 .yres = 480,
231 .pixclock = 18939,
232 .left_margin = 353,
233 .right_margin = 47,
234 .upper_margin = 39,
235 .lower_margin = 4,
236 .hsync_len = 8,
237 .vsync_len = 2,
238 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
239 .vmode = FB_VMODE_NONINTERLACED
240 },
241 {
242 .refresh = 60,
243 .xres = 1280,
244 .yres = 720,
245 .pixclock = 13426,
246 .left_margin = 192,
247 .right_margin = 64,
248 .upper_margin = 22,
249 .lower_margin = 1,
250 .hsync_len = 136,
251 .vsync_len = 3,
252 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
253 .vmode = FB_VMODE_NONINTERLACED
254 },
255 {
9b53a9e2
YS
256 .refresh = 60,
257 .xres = 1280,
258 .yres = 1024,
259 .pixclock = 9375,
260 .left_margin = 38,
261 .right_margin = 128,
262 .upper_margin = 2,
263 .lower_margin = 7,
264 .hsync_len = 216,
265 .vsync_len = 37,
266 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
267 .vmode = FB_VMODE_NONINTERLACED
268 },
269 {
9b53a9e2
YS
270 .refresh = 70,
271 .xres = 1280,
272 .yres = 1024,
273 .pixclock = 9380,
274 .left_margin = 6,
275 .right_margin = 6,
276 .upper_margin = 4,
277 .lower_margin = 4,
278 .hsync_len = 60,
279 .vsync_len = 94,
280 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
281 .vmode = FB_VMODE_NONINTERLACED
282 },
283 {
9b53a9e2
YS
284 .refresh = 75,
285 .xres = 1280,
286 .yres = 1024,
287 .pixclock = 9380,
288 .left_margin = 6,
289 .right_margin = 6,
290 .upper_margin = 4,
291 .lower_margin = 4,
292 .hsync_len = 60,
293 .vsync_len = 15,
294 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
295 .vmode = FB_VMODE_NONINTERLACED
296 },
297 {
9b53a9e2 298 .refresh = 60,
760af8f8
TT
299 .xres = 1920,
300 .yres = 1080,
301 .pixclock = 5787,
302 .left_margin = 328,
303 .right_margin = 120,
304 .upper_margin = 34,
305 .lower_margin = 1,
306 .hsync_len = 208,
307 .vsync_len = 3,
9b53a9e2
YS
308 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
309 .vmode = FB_VMODE_NONINTERLACED
310 },
311};
312
760af8f8 313static char *fb_mode;
9b53a9e2 314static unsigned long default_bpp = 32;
7653aaab
TT
315static enum fsl_diu_monitor_port monitor_port;
316static char *monitor_string;
9b53a9e2
YS
317
318#if defined(CONFIG_NOT_COHERENT_CACHE)
319static u8 *coherence_data;
320static size_t coherence_data_size;
321static unsigned int d_cache_line_size;
322#endif
323
324static DEFINE_SPINLOCK(diu_lock);
325
2572df91
TT
326enum mfb_index {
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 */
332};
333
9b53a9e2 334struct mfb_info {
2572df91 335 enum mfb_index index;
9b53a9e2
YS
336 char *id;
337 int registered;
9b53a9e2
YS
338 unsigned long pseudo_palette[16];
339 struct diu_ad *ad;
340 int cursor_reset;
341 unsigned char g_alpha;
342 unsigned int count;
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;
8b856f04 346 u8 *edid_data;
9b53a9e2
YS
347};
348
ddd3d905
TT
349/**
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
354 * @irq: IRQ
355 * @fb_enabled: TRUE if the DIU is enabled, FALSE if not
356 * @monitor_port: the monitor port this DIU is connected to
357 * @diu_reg: pointer to the DIU hardware registers
358 * @reg_lock: spinlock for register access
359 * @dummy_aoi: video buffer for the 4x4 32-bit dummy AOI
360 * dummy_ad: DIU Area Descriptor for the dummy AOI
361 * @ad[]: Area Descriptors for each real AOI
362 * @gamma: gamma color table
363 * @cursor: hardware cursor data
364 *
365 * This data structure must be allocated with 32-byte alignment, so that the
366 * internal fields can be aligned properly.
367 */
368struct fsl_diu_data {
369 dma_addr_t dma_addr;
370 struct fb_info fsl_diu_info[NUM_AOIS];
371 struct mfb_info mfb[NUM_AOIS];
372 struct device_attribute dev_attr;
373 unsigned int irq;
374 int fb_enabled;
375 enum fsl_diu_monitor_port monitor_port;
376 struct diu __iomem *diu_reg;
377 spinlock_t reg_lock;
378 u8 dummy_aoi[4 * 4 * 4];
379 struct diu_ad dummy_ad __aligned(8);
380 struct diu_ad ad[NUM_AOIS] __aligned(8);
381 u8 gamma[256 * 3] __aligned(32);
382 u8 cursor[MAX_CURS * MAX_CURS * 2] __aligned(32);
383} __aligned(32);
384
385/* Determine the DMA address of a member of the fsl_diu_data structure */
386#define DMA_ADDR(p, f) ((p)->dma_addr + offsetof(struct fsl_diu_data, f))
9b53a9e2
YS
387
388static struct mfb_info mfb_template[] = {
2572df91
TT
389 {
390 .index = PLANE0,
4a85dc8b
TT
391 .id = "Panel0",
392 .registered = 0,
393 .count = 0,
394 .x_aoi_d = 0,
395 .y_aoi_d = 0,
9b53a9e2 396 },
2572df91
TT
397 {
398 .index = PLANE1_AOI0,
4a85dc8b
TT
399 .id = "Panel1 AOI0",
400 .registered = 0,
401 .g_alpha = 0xff,
402 .count = 0,
403 .x_aoi_d = 0,
404 .y_aoi_d = 0,
9b53a9e2 405 },
2572df91
TT
406 {
407 .index = PLANE1_AOI1,
4a85dc8b
TT
408 .id = "Panel1 AOI1",
409 .registered = 0,
410 .g_alpha = 0xff,
411 .count = 0,
412 .x_aoi_d = 0,
413 .y_aoi_d = 480,
9b53a9e2 414 },
2572df91
TT
415 {
416 .index = PLANE2_AOI0,
4a85dc8b
TT
417 .id = "Panel2 AOI0",
418 .registered = 0,
419 .g_alpha = 0xff,
420 .count = 0,
421 .x_aoi_d = 640,
422 .y_aoi_d = 0,
9b53a9e2 423 },
2572df91
TT
424 {
425 .index = PLANE2_AOI1,
4a85dc8b
TT
426 .id = "Panel2 AOI1",
427 .registered = 0,
428 .g_alpha = 0xff,
429 .count = 0,
430 .x_aoi_d = 640,
431 .y_aoi_d = 480,
9b53a9e2
YS
432 },
433};
434
7653aaab
TT
435/**
436 * fsl_diu_name_to_port - convert a port name to a monitor port enum
437 *
438 * Takes the name of a monitor port ("dvi", "lvds", or "dlvds") and returns
439 * the enum fsl_diu_monitor_port that corresponds to that string.
440 *
441 * For compatibility with older versions, a number ("0", "1", or "2") is also
442 * supported.
443 *
444 * If the string is unknown, DVI is assumed.
445 *
446 * If the particular port is not supported by the platform, another port
447 * (platform-specific) is chosen instead.
448 */
449static enum fsl_diu_monitor_port fsl_diu_name_to_port(const char *s)
450{
451 enum fsl_diu_monitor_port port = FSL_DIU_PORT_DVI;
452 unsigned long val;
453
454 if (s) {
455 if (!strict_strtoul(s, 10, &val) && (val <= 2))
456 port = (enum fsl_diu_monitor_port) val;
457 else if (strncmp(s, "lvds", 4) == 0)
458 port = FSL_DIU_PORT_LVDS;
459 else if (strncmp(s, "dlvds", 5) == 0)
460 port = FSL_DIU_PORT_DLVDS;
461 }
462
463 return diu_ops.valid_monitor_port(port);
464}
465
6b51d51a
TT
466/**
467 * fsl_diu_alloc - allocate memory for the DIU
468 * @size: number of bytes to allocate
469 * @param: returned physical address of memory
470 *
471 * This function allocates a physically-contiguous block of memory.
9b53a9e2 472 */
6b51d51a 473static void *fsl_diu_alloc(size_t size, phys_addr_t *phys)
9b53a9e2
YS
474{
475 void *virt;
476
6b51d51a 477 virt = alloc_pages_exact(size, GFP_DMA | __GFP_ZERO);
154152ae 478 if (virt)
9b53a9e2 479 *phys = virt_to_phys(virt);
9b53a9e2 480
9b53a9e2
YS
481 return virt;
482}
483
6b51d51a
TT
484/**
485 * fsl_diu_free - release DIU memory
486 * @virt: pointer returned by fsl_diu_alloc()
487 * @size: number of bytes allocated by fsl_diu_alloc()
488 *
489 * This function releases memory allocated by fsl_diu_alloc().
490 */
491static void fsl_diu_free(void *virt, size_t size)
9b53a9e2 492{
6b51d51a
TT
493 if (virt && size)
494 free_pages_exact(virt, size);
9b53a9e2
YS
495}
496
0d9dab39
AG
497/*
498 * Workaround for failed writing desc register of planes.
499 * Needed with MPC5121 DIU rev 2.0 silicon.
500 */
501void wr_reg_wa(u32 *reg, u32 val)
502{
503 do {
504 out_be32(reg, val);
505 } while (in_be32(reg) != val);
506}
507
7e47c211 508static void fsl_diu_enable_panel(struct fb_info *info)
9b53a9e2
YS
509{
510 struct mfb_info *pmfbi, *cmfbi, *mfbi = info->par;
9b53a9e2
YS
511 struct diu_ad *ad = mfbi->ad;
512 struct fsl_diu_data *machine_data = mfbi->parent;
3c755b7c 513 struct diu __iomem *hw = machine_data->diu_reg;
9b53a9e2 514
7e47c211
TT
515 switch (mfbi->index) {
516 case PLANE0:
517 if (hw->desc[0] != ad->paddr)
518 wr_reg_wa(&hw->desc[0], ad->paddr);
519 break;
520 case PLANE1_AOI0:
ddd3d905 521 cmfbi = &machine_data->mfb[2];
7e47c211
TT
522 if (hw->desc[1] != ad->paddr) { /* AOI0 closed */
523 if (cmfbi->count > 0) /* AOI1 open */
524 ad->next_ad =
525 cpu_to_le32(cmfbi->ad->paddr);
526 else
527 ad->next_ad = 0;
528 wr_reg_wa(&hw->desc[1], ad->paddr);
9b53a9e2 529 }
7e47c211
TT
530 break;
531 case PLANE2_AOI0:
ddd3d905 532 cmfbi = &machine_data->mfb[4];
7e47c211
TT
533 if (hw->desc[2] != ad->paddr) { /* AOI0 closed */
534 if (cmfbi->count > 0) /* AOI1 open */
535 ad->next_ad =
536 cpu_to_le32(cmfbi->ad->paddr);
537 else
538 ad->next_ad = 0;
539 wr_reg_wa(&hw->desc[2], ad->paddr);
540 }
541 break;
542 case PLANE1_AOI1:
ddd3d905 543 pmfbi = &machine_data->mfb[1];
7e47c211 544 ad->next_ad = 0;
ddd3d905 545 if (hw->desc[1] == machine_data->dummy_ad.paddr)
7e47c211
TT
546 wr_reg_wa(&hw->desc[1], ad->paddr);
547 else /* AOI0 open */
548 pmfbi->ad->next_ad = cpu_to_le32(ad->paddr);
549 break;
550 case PLANE2_AOI1:
ddd3d905 551 pmfbi = &machine_data->mfb[3];
7e47c211 552 ad->next_ad = 0;
ddd3d905 553 if (hw->desc[2] == machine_data->dummy_ad.paddr)
7e47c211
TT
554 wr_reg_wa(&hw->desc[2], ad->paddr);
555 else /* AOI0 was open */
556 pmfbi->ad->next_ad = cpu_to_le32(ad->paddr);
557 break;
558 }
9b53a9e2
YS
559}
560
2572df91 561static void fsl_diu_disable_panel(struct fb_info *info)
9b53a9e2
YS
562{
563 struct mfb_info *pmfbi, *cmfbi, *mfbi = info->par;
9b53a9e2
YS
564 struct diu_ad *ad = mfbi->ad;
565 struct fsl_diu_data *machine_data = mfbi->parent;
3c755b7c 566 struct diu __iomem *hw = machine_data->diu_reg;
9b53a9e2
YS
567
568 switch (mfbi->index) {
2572df91 569 case PLANE0:
ddd3d905
TT
570 if (hw->desc[0] != machine_data->dummy_ad.paddr)
571 wr_reg_wa(&hw->desc[0], machine_data->dummy_ad.paddr);
9b53a9e2 572 break;
2572df91 573 case PLANE1_AOI0:
ddd3d905 574 cmfbi = &machine_data->mfb[2];
9b53a9e2 575 if (cmfbi->count > 0) /* AOI1 is open */
0d9dab39 576 wr_reg_wa(&hw->desc[1], cmfbi->ad->paddr);
9b53a9e2
YS
577 /* move AOI1 to the first */
578 else /* AOI1 was closed */
ddd3d905 579 wr_reg_wa(&hw->desc[1], machine_data->dummy_ad.paddr);
9b53a9e2
YS
580 /* close AOI 0 */
581 break;
2572df91 582 case PLANE2_AOI0:
ddd3d905 583 cmfbi = &machine_data->mfb[4];
9b53a9e2 584 if (cmfbi->count > 0) /* AOI1 is open */
0d9dab39 585 wr_reg_wa(&hw->desc[2], cmfbi->ad->paddr);
9b53a9e2
YS
586 /* move AOI1 to the first */
587 else /* AOI1 was closed */
ddd3d905 588 wr_reg_wa(&hw->desc[2], machine_data->dummy_ad.paddr);
9b53a9e2
YS
589 /* close AOI 0 */
590 break;
2572df91 591 case PLANE1_AOI1:
ddd3d905 592 pmfbi = &machine_data->mfb[1];
9b53a9e2
YS
593 if (hw->desc[1] != ad->paddr) {
594 /* AOI1 is not the first in the chain */
595 if (pmfbi->count > 0)
596 /* AOI0 is open, must be the first */
597 pmfbi->ad->next_ad = 0;
598 } else /* AOI1 is the first in the chain */
ddd3d905 599 wr_reg_wa(&hw->desc[1], machine_data->dummy_ad.paddr);
9b53a9e2
YS
600 /* close AOI 1 */
601 break;
2572df91 602 case PLANE2_AOI1:
ddd3d905 603 pmfbi = &machine_data->mfb[3];
9b53a9e2
YS
604 if (hw->desc[2] != ad->paddr) {
605 /* AOI1 is not the first in the chain */
606 if (pmfbi->count > 0)
607 /* AOI0 is open, must be the first */
608 pmfbi->ad->next_ad = 0;
609 } else /* AOI1 is the first in the chain */
ddd3d905 610 wr_reg_wa(&hw->desc[2], machine_data->dummy_ad.paddr);
9b53a9e2
YS
611 /* close AOI 1 */
612 break;
9b53a9e2 613 }
9b53a9e2
YS
614}
615
616static void enable_lcdc(struct fb_info *info)
617{
9b53a9e2
YS
618 struct mfb_info *mfbi = info->par;
619 struct fsl_diu_data *machine_data = mfbi->parent;
3c755b7c 620 struct diu __iomem *hw = machine_data->diu_reg;
9b53a9e2
YS
621
622 if (!machine_data->fb_enabled) {
c4e5a023 623 out_be32(&hw->diu_mode, MFB_MODE1);
9b53a9e2
YS
624 machine_data->fb_enabled++;
625 }
626}
627
628static void disable_lcdc(struct fb_info *info)
629{
9b53a9e2
YS
630 struct mfb_info *mfbi = info->par;
631 struct fsl_diu_data *machine_data = mfbi->parent;
3c755b7c 632 struct diu __iomem *hw = machine_data->diu_reg;
9b53a9e2
YS
633
634 if (machine_data->fb_enabled) {
635 out_be32(&hw->diu_mode, 0);
636 machine_data->fb_enabled = 0;
637 }
638}
639
640static void adjust_aoi_size_position(struct fb_var_screeninfo *var,
641 struct fb_info *info)
642{
643 struct mfb_info *lower_aoi_mfbi, *upper_aoi_mfbi, *mfbi = info->par;
644 struct fsl_diu_data *machine_data = mfbi->parent;
2572df91
TT
645 int available_height, upper_aoi_bottom;
646 enum mfb_index index = mfbi->index;
9b53a9e2
YS
647 int lower_aoi_is_open, upper_aoi_is_open;
648 __u32 base_plane_width, base_plane_height, upper_aoi_height;
649
ddd3d905
TT
650 base_plane_width = machine_data->fsl_diu_info[0].var.xres;
651 base_plane_height = machine_data->fsl_diu_info[0].var.yres;
9b53a9e2 652
fdfaa483
YS
653 if (mfbi->x_aoi_d < 0)
654 mfbi->x_aoi_d = 0;
655 if (mfbi->y_aoi_d < 0)
656 mfbi->y_aoi_d = 0;
9b53a9e2 657 switch (index) {
2572df91 658 case PLANE0:
9b53a9e2
YS
659 if (mfbi->x_aoi_d != 0)
660 mfbi->x_aoi_d = 0;
661 if (mfbi->y_aoi_d != 0)
662 mfbi->y_aoi_d = 0;
663 break;
2572df91
TT
664 case PLANE1_AOI0:
665 case PLANE2_AOI0:
ddd3d905 666 lower_aoi_mfbi = machine_data->fsl_diu_info[index+1].par;
9b53a9e2
YS
667 lower_aoi_is_open = lower_aoi_mfbi->count > 0 ? 1 : 0;
668 if (var->xres > base_plane_width)
669 var->xres = base_plane_width;
670 if ((mfbi->x_aoi_d + var->xres) > base_plane_width)
671 mfbi->x_aoi_d = base_plane_width - var->xres;
672
673 if (lower_aoi_is_open)
674 available_height = lower_aoi_mfbi->y_aoi_d;
675 else
676 available_height = base_plane_height;
677 if (var->yres > available_height)
678 var->yres = available_height;
679 if ((mfbi->y_aoi_d + var->yres) > available_height)
680 mfbi->y_aoi_d = available_height - var->yres;
681 break;
2572df91
TT
682 case PLANE1_AOI1:
683 case PLANE2_AOI1:
ddd3d905 684 upper_aoi_mfbi = machine_data->fsl_diu_info[index-1].par;
9b53a9e2 685 upper_aoi_height =
ddd3d905 686 machine_data->fsl_diu_info[index-1].var.yres;
9b53a9e2
YS
687 upper_aoi_bottom = upper_aoi_mfbi->y_aoi_d + upper_aoi_height;
688 upper_aoi_is_open = upper_aoi_mfbi->count > 0 ? 1 : 0;
689 if (var->xres > base_plane_width)
690 var->xres = base_plane_width;
691 if ((mfbi->x_aoi_d + var->xres) > base_plane_width)
692 mfbi->x_aoi_d = base_plane_width - var->xres;
693 if (mfbi->y_aoi_d < 0)
694 mfbi->y_aoi_d = 0;
695 if (upper_aoi_is_open) {
696 if (mfbi->y_aoi_d < upper_aoi_bottom)
697 mfbi->y_aoi_d = upper_aoi_bottom;
698 available_height = base_plane_height
699 - upper_aoi_bottom;
700 } else
701 available_height = base_plane_height;
702 if (var->yres > available_height)
703 var->yres = available_height;
704 if ((mfbi->y_aoi_d + var->yres) > base_plane_height)
705 mfbi->y_aoi_d = base_plane_height - var->yres;
706 break;
707 }
708}
709/*
710 * Checks to see if the hardware supports the state requested by var passed
711 * in. This function does not alter the hardware state! If the var passed in
712 * is slightly off by what the hardware can support then we alter the var
713 * PASSED in to what we can do. If the hardware doesn't support mode change
714 * a -EINVAL will be returned by the upper layers.
715 */
716static int fsl_diu_check_var(struct fb_var_screeninfo *var,
717 struct fb_info *info)
718{
9b53a9e2
YS
719 if (var->xres_virtual < var->xres)
720 var->xres_virtual = var->xres;
721 if (var->yres_virtual < var->yres)
722 var->yres_virtual = var->yres;
723
724 if (var->xoffset < 0)
725 var->xoffset = 0;
726
727 if (var->yoffset < 0)
728 var->yoffset = 0;
729
730 if (var->xoffset + info->var.xres > info->var.xres_virtual)
731 var->xoffset = info->var.xres_virtual - info->var.xres;
732
733 if (var->yoffset + info->var.yres > info->var.yres_virtual)
734 var->yoffset = info->var.yres_virtual - info->var.yres;
735
736 if ((var->bits_per_pixel != 32) && (var->bits_per_pixel != 24) &&
737 (var->bits_per_pixel != 16))
738 var->bits_per_pixel = default_bpp;
739
740 switch (var->bits_per_pixel) {
741 case 16:
742 var->red.length = 5;
743 var->red.offset = 11;
744 var->red.msb_right = 0;
745
746 var->green.length = 6;
747 var->green.offset = 5;
748 var->green.msb_right = 0;
749
750 var->blue.length = 5;
751 var->blue.offset = 0;
752 var->blue.msb_right = 0;
753
754 var->transp.length = 0;
755 var->transp.offset = 0;
756 var->transp.msb_right = 0;
757 break;
758 case 24:
759 var->red.length = 8;
760 var->red.offset = 0;
761 var->red.msb_right = 0;
762
763 var->green.length = 8;
764 var->green.offset = 8;
765 var->green.msb_right = 0;
766
767 var->blue.length = 8;
768 var->blue.offset = 16;
769 var->blue.msb_right = 0;
770
771 var->transp.length = 0;
772 var->transp.offset = 0;
773 var->transp.msb_right = 0;
774 break;
775 case 32:
776 var->red.length = 8;
777 var->red.offset = 16;
778 var->red.msb_right = 0;
779
780 var->green.length = 8;
781 var->green.offset = 8;
782 var->green.msb_right = 0;
783
784 var->blue.length = 8;
785 var->blue.offset = 0;
786 var->blue.msb_right = 0;
787
788 var->transp.length = 8;
789 var->transp.offset = 24;
790 var->transp.msb_right = 0;
791
792 break;
793 }
9b53a9e2
YS
794
795 var->height = -1;
796 var->width = -1;
797 var->grayscale = 0;
798
799 /* Copy nonstd field to/from sync for fbset usage */
800 var->sync |= var->nonstd;
801 var->nonstd |= var->sync;
802
803 adjust_aoi_size_position(var, info);
804 return 0;
805}
806
807static void set_fix(struct fb_info *info)
808{
809 struct fb_fix_screeninfo *fix = &info->fix;
810 struct fb_var_screeninfo *var = &info->var;
811 struct mfb_info *mfbi = info->par;
812
ec02dd23 813 strncpy(fix->id, mfbi->id, sizeof(fix->id));
9b53a9e2
YS
814 fix->line_length = var->xres_virtual * var->bits_per_pixel / 8;
815 fix->type = FB_TYPE_PACKED_PIXELS;
816 fix->accel = FB_ACCEL_NONE;
817 fix->visual = FB_VISUAL_TRUECOLOR;
818 fix->xpanstep = 1;
819 fix->ypanstep = 1;
820}
821
822static void update_lcdc(struct fb_info *info)
823{
824 struct fb_var_screeninfo *var = &info->var;
825 struct mfb_info *mfbi = info->par;
826 struct fsl_diu_data *machine_data = mfbi->parent;
3c755b7c 827 struct diu __iomem *hw;
9b53a9e2 828 int i, j;
ddd3d905 829 u8 *gamma_table_base;
9b53a9e2
YS
830
831 u32 temp;
832
3c755b7c 833 hw = machine_data->diu_reg;
9b53a9e2 834
9b53a9e2 835 diu_ops.set_monitor_port(machine_data->monitor_port);
ddd3d905
TT
836 gamma_table_base = machine_data->gamma;
837
9b53a9e2
YS
838 /* Prep for DIU init - gamma table, cursor table */
839
840 for (i = 0; i <= 2; i++)
4a85dc8b
TT
841 for (j = 0; j <= 255; j++)
842 *gamma_table_base++ = j;
9b53a9e2 843
07a06214 844 diu_ops.set_gamma_table(machine_data->monitor_port,
ddd3d905 845 machine_data->gamma);
9b53a9e2 846
9b53a9e2
YS
847 disable_lcdc(info);
848
849 /* Program DIU registers */
850
ddd3d905
TT
851 out_be32(&hw->gamma, DMA_ADDR(machine_data, gamma));
852 out_be32(&hw->cursor, DMA_ADDR(machine_data, cursor));
9b53a9e2
YS
853
854 out_be32(&hw->bgnd, 0x007F7F7F); /* BGND */
855 out_be32(&hw->bgnd_wb, 0); /* BGND_WB */
856 out_be32(&hw->disp_size, (var->yres << 16 | var->xres));
857 /* DISP SIZE */
9b53a9e2
YS
858 out_be32(&hw->wb_size, 0); /* WB SIZE */
859 out_be32(&hw->wb_mem_addr, 0); /* WB MEM ADDR */
860
861 /* Horizontal and vertical configuration register */
862 temp = var->left_margin << 22 | /* BP_H */
863 var->hsync_len << 11 | /* PW_H */
864 var->right_margin; /* FP_H */
865
866 out_be32(&hw->hsyn_para, temp);
867
868 temp = var->upper_margin << 22 | /* BP_V */
869 var->vsync_len << 11 | /* PW_V */
870 var->lower_margin; /* FP_V */
871
872 out_be32(&hw->vsyn_para, temp);
873
9b53a9e2
YS
874 diu_ops.set_pixel_clock(var->pixclock);
875
876 out_be32(&hw->syn_pol, 0); /* SYNC SIGNALS POLARITY */
877 out_be32(&hw->thresholds, 0x00037800); /* The Thresholds */
878 out_be32(&hw->int_status, 0); /* INTERRUPT STATUS */
879 out_be32(&hw->plut, 0x01F5F666);
880
881 /* Enable the DIU */
882 enable_lcdc(info);
883}
884
885static int map_video_memory(struct fb_info *info)
886{
887 phys_addr_t phys;
537a1bf0 888 u32 smem_len = info->fix.line_length * info->var.yres_virtual;
9b53a9e2 889
537a1bf0 890 info->screen_base = fsl_diu_alloc(smem_len, &phys);
05946bce 891 if (info->screen_base == NULL) {
154152ae 892 dev_err(info->dev, "unable to allocate fb memory\n");
9b53a9e2
YS
893 return -ENOMEM;
894 }
537a1bf0 895 mutex_lock(&info->mm_lock);
9b53a9e2 896 info->fix.smem_start = (unsigned long) phys;
537a1bf0
KH
897 info->fix.smem_len = smem_len;
898 mutex_unlock(&info->mm_lock);
9b53a9e2
YS
899 info->screen_size = info->fix.smem_len;
900
9b53a9e2
YS
901 return 0;
902}
903
904static void unmap_video_memory(struct fb_info *info)
905{
906 fsl_diu_free(info->screen_base, info->fix.smem_len);
537a1bf0 907 mutex_lock(&info->mm_lock);
05946bce 908 info->screen_base = NULL;
9b53a9e2
YS
909 info->fix.smem_start = 0;
910 info->fix.smem_len = 0;
537a1bf0 911 mutex_unlock(&info->mm_lock);
9b53a9e2
YS
912}
913
ae5591e3
YS
914/*
915 * Using the fb_var_screeninfo in fb_info we set the aoi of this
916 * particular framebuffer. It is a light version of fsl_diu_set_par.
917 */
918static int fsl_diu_set_aoi(struct fb_info *info)
919{
920 struct fb_var_screeninfo *var = &info->var;
921 struct mfb_info *mfbi = info->par;
922 struct diu_ad *ad = mfbi->ad;
923
924 /* AOI should not be greater than display size */
925 ad->offset_xyi = cpu_to_le32((var->yoffset << 16) | var->xoffset);
926 ad->offset_xyd = cpu_to_le32((mfbi->y_aoi_d << 16) | mfbi->x_aoi_d);
927 return 0;
928}
929
9b53a9e2
YS
930/*
931 * Using the fb_var_screeninfo in fb_info we set the resolution of this
932 * particular framebuffer. This function alters the fb_fix_screeninfo stored
933 * in fb_info. It does not alter var in fb_info since we are using that
934 * data. This means we depend on the data in var inside fb_info to be
935 * supported by the hardware. fsl_diu_check_var is always called before
936 * fsl_diu_set_par to ensure this.
937 */
938static int fsl_diu_set_par(struct fb_info *info)
939{
940 unsigned long len;
941 struct fb_var_screeninfo *var = &info->var;
942 struct mfb_info *mfbi = info->par;
943 struct fsl_diu_data *machine_data = mfbi->parent;
944 struct diu_ad *ad = mfbi->ad;
3c755b7c 945 struct diu __iomem *hw;
9b53a9e2 946
3c755b7c 947 hw = machine_data->diu_reg;
9b53a9e2
YS
948
949 set_fix(info);
950 mfbi->cursor_reset = 1;
951
952 len = info->var.yres_virtual * info->fix.line_length;
953 /* Alloc & dealloc each time resolution/bpp change */
954 if (len != info->fix.smem_len) {
955 if (info->fix.smem_start)
956 unmap_video_memory(info);
9b53a9e2
YS
957
958 /* Memory allocation for framebuffer */
959 if (map_video_memory(info)) {
154152ae 960 dev_err(info->dev, "unable to allocate fb memory 1\n");
9b53a9e2
YS
961 return -ENOMEM;
962 }
963 }
964
7653aaab
TT
965 ad->pix_fmt = diu_ops.get_pixel_format(machine_data->monitor_port,
966 var->bits_per_pixel);
9b53a9e2 967 ad->addr = cpu_to_le32(info->fix.smem_start);
ae5591e3
YS
968 ad->src_size_g_alpha = cpu_to_le32((var->yres_virtual << 12) |
969 var->xres_virtual) | mfbi->g_alpha;
970 /* AOI should not be greater than display size */
9b53a9e2 971 ad->aoi_size = cpu_to_le32((var->yres << 16) | var->xres);
ae5591e3 972 ad->offset_xyi = cpu_to_le32((var->yoffset << 16) | var->xoffset);
9b53a9e2
YS
973 ad->offset_xyd = cpu_to_le32((mfbi->y_aoi_d << 16) | mfbi->x_aoi_d);
974
975 /* Disable chroma keying function */
976 ad->ckmax_r = 0;
977 ad->ckmax_g = 0;
978 ad->ckmax_b = 0;
979
980 ad->ckmin_r = 255;
981 ad->ckmin_g = 255;
982 ad->ckmin_b = 255;
983
2572df91 984 if (mfbi->index == PLANE0)
9b53a9e2
YS
985 update_lcdc(info);
986 return 0;
987}
988
989static inline __u32 CNVT_TOHW(__u32 val, __u32 width)
990{
4a85dc8b 991 return ((val << width) + 0x7FFF - val) >> 16;
9b53a9e2
YS
992}
993
994/*
995 * Set a single color register. The values supplied have a 16 bit magnitude
996 * which needs to be scaled in this function for the hardware. Things to take
997 * into consideration are how many color registers, if any, are supported with
998 * the current color visual. With truecolor mode no color palettes are
25985edc 999 * supported. Here a pseudo palette is created which we store the value in
9b53a9e2
YS
1000 * pseudo_palette in struct fb_info. For pseudocolor mode we have a limited
1001 * color palette.
1002 */
4a85dc8b
TT
1003static int fsl_diu_setcolreg(unsigned int regno, unsigned int red,
1004 unsigned int green, unsigned int blue,
1005 unsigned int transp, struct fb_info *info)
9b53a9e2
YS
1006{
1007 int ret = 1;
1008
1009 /*
1010 * If greyscale is true, then we convert the RGB value
1011 * to greyscale no matter what visual we are using.
1012 */
1013 if (info->var.grayscale)
1014 red = green = blue = (19595 * red + 38470 * green +
1015 7471 * blue) >> 16;
1016 switch (info->fix.visual) {
1017 case FB_VISUAL_TRUECOLOR:
1018 /*
1019 * 16-bit True Colour. We encode the RGB value
1020 * according to the RGB bitfield information.
1021 */
1022 if (regno < 16) {
1023 u32 *pal = info->pseudo_palette;
1024 u32 v;
1025
1026 red = CNVT_TOHW(red, info->var.red.length);
1027 green = CNVT_TOHW(green, info->var.green.length);
1028 blue = CNVT_TOHW(blue, info->var.blue.length);
1029 transp = CNVT_TOHW(transp, info->var.transp.length);
1030
1031 v = (red << info->var.red.offset) |
1032 (green << info->var.green.offset) |
1033 (blue << info->var.blue.offset) |
1034 (transp << info->var.transp.offset);
1035
1036 pal[regno] = v;
1037 ret = 0;
1038 }
1039 break;
9b53a9e2
YS
1040 }
1041
1042 return ret;
1043}
1044
1045/*
1046 * Pan (or wrap, depending on the `vmode' field) the display using the
1047 * 'xoffset' and 'yoffset' fields of the 'var' structure. If the values
1048 * don't fit, return -EINVAL.
1049 */
1050static int fsl_diu_pan_display(struct fb_var_screeninfo *var,
1051 struct fb_info *info)
1052{
1053 if ((info->var.xoffset == var->xoffset) &&
1054 (info->var.yoffset == var->yoffset))
1055 return 0; /* No change, do nothing */
1056
1057 if (var->xoffset < 0 || var->yoffset < 0
1058 || var->xoffset + info->var.xres > info->var.xres_virtual
1059 || var->yoffset + info->var.yres > info->var.yres_virtual)
1060 return -EINVAL;
1061
1062 info->var.xoffset = var->xoffset;
1063 info->var.yoffset = var->yoffset;
1064
1065 if (var->vmode & FB_VMODE_YWRAP)
1066 info->var.vmode |= FB_VMODE_YWRAP;
1067 else
1068 info->var.vmode &= ~FB_VMODE_YWRAP;
1069
ae5591e3
YS
1070 fsl_diu_set_aoi(info);
1071
9b53a9e2
YS
1072 return 0;
1073}
1074
9b53a9e2
YS
1075static int fsl_diu_ioctl(struct fb_info *info, unsigned int cmd,
1076 unsigned long arg)
1077{
1078 struct mfb_info *mfbi = info->par;
1079 struct diu_ad *ad = mfbi->ad;
1080 struct mfb_chroma_key ck;
1081 unsigned char global_alpha;
1082 struct aoi_display_offset aoi_d;
1083 __u32 pix_fmt;
1084 void __user *buf = (void __user *)arg;
1085
1086 if (!arg)
1087 return -EINVAL;
1088 switch (cmd) {
36b0b1d4
TT
1089 case MFB_SET_PIXFMT_OLD:
1090 dev_warn(info->dev,
1091 "MFB_SET_PIXFMT value of 0x%08x is deprecated.\n",
1092 MFB_SET_PIXFMT_OLD);
9b53a9e2
YS
1093 case MFB_SET_PIXFMT:
1094 if (copy_from_user(&pix_fmt, buf, sizeof(pix_fmt)))
1095 return -EFAULT;
1096 ad->pix_fmt = pix_fmt;
9b53a9e2 1097 break;
36b0b1d4
TT
1098 case MFB_GET_PIXFMT_OLD:
1099 dev_warn(info->dev,
1100 "MFB_GET_PIXFMT value of 0x%08x is deprecated.\n",
1101 MFB_GET_PIXFMT_OLD);
9b53a9e2
YS
1102 case MFB_GET_PIXFMT:
1103 pix_fmt = ad->pix_fmt;
1104 if (copy_to_user(buf, &pix_fmt, sizeof(pix_fmt)))
1105 return -EFAULT;
9b53a9e2
YS
1106 break;
1107 case MFB_SET_AOID:
1108 if (copy_from_user(&aoi_d, buf, sizeof(aoi_d)))
1109 return -EFAULT;
1110 mfbi->x_aoi_d = aoi_d.x_aoi_d;
1111 mfbi->y_aoi_d = aoi_d.y_aoi_d;
9b53a9e2 1112 fsl_diu_check_var(&info->var, info);
ae5591e3 1113 fsl_diu_set_aoi(info);
9b53a9e2
YS
1114 break;
1115 case MFB_GET_AOID:
1116 aoi_d.x_aoi_d = mfbi->x_aoi_d;
1117 aoi_d.y_aoi_d = mfbi->y_aoi_d;
1118 if (copy_to_user(buf, &aoi_d, sizeof(aoi_d)))
1119 return -EFAULT;
9b53a9e2
YS
1120 break;
1121 case MFB_GET_ALPHA:
1122 global_alpha = mfbi->g_alpha;
1123 if (copy_to_user(buf, &global_alpha, sizeof(global_alpha)))
1124 return -EFAULT;
9b53a9e2
YS
1125 break;
1126 case MFB_SET_ALPHA:
1127 /* set panel information */
1128 if (copy_from_user(&global_alpha, buf, sizeof(global_alpha)))
1129 return -EFAULT;
1130 ad->src_size_g_alpha = (ad->src_size_g_alpha & (~0xff)) |
1131 (global_alpha & 0xff);
1132 mfbi->g_alpha = global_alpha;
9b53a9e2
YS
1133 break;
1134 case MFB_SET_CHROMA_KEY:
1135 /* set panel winformation */
1136 if (copy_from_user(&ck, buf, sizeof(ck)))
1137 return -EFAULT;
1138
1139 if (ck.enable &&
1140 (ck.red_max < ck.red_min ||
1141 ck.green_max < ck.green_min ||
1142 ck.blue_max < ck.blue_min))
1143 return -EINVAL;
1144
1145 if (!ck.enable) {
1146 ad->ckmax_r = 0;
1147 ad->ckmax_g = 0;
1148 ad->ckmax_b = 0;
1149 ad->ckmin_r = 255;
1150 ad->ckmin_g = 255;
1151 ad->ckmin_b = 255;
1152 } else {
1153 ad->ckmax_r = ck.red_max;
1154 ad->ckmax_g = ck.green_max;
1155 ad->ckmax_b = ck.blue_max;
1156 ad->ckmin_r = ck.red_min;
1157 ad->ckmin_g = ck.green_min;
1158 ad->ckmin_b = ck.blue_min;
1159 }
9b53a9e2 1160 break;
9b53a9e2 1161 default:
154152ae 1162 dev_err(info->dev, "unknown ioctl command (0x%08X)\n", cmd);
9b53a9e2
YS
1163 return -ENOIOCTLCMD;
1164 }
1165
1166 return 0;
1167}
1168
1169/* turn on fb if count == 1
1170 */
1171static int fsl_diu_open(struct fb_info *info, int user)
1172{
1173 struct mfb_info *mfbi = info->par;
1174 int res = 0;
1175
4b5006ec 1176 /* free boot splash memory on first /dev/fb0 open */
2572df91 1177 if ((mfbi->index == PLANE0) && diu_ops.release_bootmem)
4b5006ec
AG
1178 diu_ops.release_bootmem();
1179
9b53a9e2
YS
1180 spin_lock(&diu_lock);
1181 mfbi->count++;
1182 if (mfbi->count == 1) {
9b53a9e2
YS
1183 fsl_diu_check_var(&info->var, info);
1184 res = fsl_diu_set_par(info);
1185 if (res < 0)
1186 mfbi->count--;
7e47c211
TT
1187 else
1188 fsl_diu_enable_panel(info);
9b53a9e2
YS
1189 }
1190
1191 spin_unlock(&diu_lock);
1192 return res;
1193}
1194
1195/* turn off fb if count == 0
1196 */
1197static int fsl_diu_release(struct fb_info *info, int user)
1198{
1199 struct mfb_info *mfbi = info->par;
1200 int res = 0;
1201
1202 spin_lock(&diu_lock);
1203 mfbi->count--;
2572df91
TT
1204 if (mfbi->count == 0)
1205 fsl_diu_disable_panel(info);
1206
9b53a9e2
YS
1207 spin_unlock(&diu_lock);
1208 return res;
1209}
1210
1211static struct fb_ops fsl_diu_ops = {
1212 .owner = THIS_MODULE,
1213 .fb_check_var = fsl_diu_check_var,
1214 .fb_set_par = fsl_diu_set_par,
1215 .fb_setcolreg = fsl_diu_setcolreg,
9b53a9e2
YS
1216 .fb_pan_display = fsl_diu_pan_display,
1217 .fb_fillrect = cfb_fillrect,
1218 .fb_copyarea = cfb_copyarea,
1219 .fb_imageblit = cfb_imageblit,
1220 .fb_ioctl = fsl_diu_ioctl,
1221 .fb_open = fsl_diu_open,
1222 .fb_release = fsl_diu_release,
1223};
1224
1225static int init_fbinfo(struct fb_info *info)
1226{
1227 struct mfb_info *mfbi = info->par;
1228
1229 info->device = NULL;
1230 info->var.activate = FB_ACTIVATE_NOW;
1231 info->fbops = &fsl_diu_ops;
1232 info->flags = FBINFO_FLAG_DEFAULT;
1233 info->pseudo_palette = &mfbi->pseudo_palette;
1234
1235 /* Allocate colormap */
1236 fb_alloc_cmap(&info->cmap, 16, 0);
1237 return 0;
1238}
1239
05946bce 1240static int __devinit install_fb(struct fb_info *info)
9b53a9e2
YS
1241{
1242 int rc;
1243 struct mfb_info *mfbi = info->par;
1244 const char *aoi_mode, *init_aoi_mode = "320x240";
8b856f04
AG
1245 struct fb_videomode *db = fsl_diu_mode_db;
1246 unsigned int dbsize = ARRAY_SIZE(fsl_diu_mode_db);
1247 int has_default_mode = 1;
9b53a9e2
YS
1248
1249 if (init_fbinfo(info))
1250 return -EINVAL;
1251
2572df91 1252 if (mfbi->index == PLANE0) {
8b856f04
AG
1253 if (mfbi->edid_data) {
1254 /* Now build modedb from EDID */
1255 fb_edid_to_monspecs(mfbi->edid_data, &info->monspecs);
1256 fb_videomode_to_modelist(info->monspecs.modedb,
1257 info->monspecs.modedb_len,
1258 &info->modelist);
1259 db = info->monspecs.modedb;
1260 dbsize = info->monspecs.modedb_len;
1261 }
9b53a9e2 1262 aoi_mode = fb_mode;
8b856f04 1263 } else {
9b53a9e2 1264 aoi_mode = init_aoi_mode;
8b856f04 1265 }
63cf8df4
TT
1266 rc = fb_find_mode(&info->var, info, aoi_mode, db, dbsize, NULL,
1267 default_bpp);
154152ae 1268 if (!rc) {
8b856f04
AG
1269 /*
1270 * For plane 0 we continue and look into
1271 * driver's internal modedb.
1272 */
2572df91 1273 if ((mfbi->index == PLANE0) && mfbi->edid_data)
8b856f04
AG
1274 has_default_mode = 0;
1275 else
1276 return -EINVAL;
9b53a9e2
YS
1277 }
1278
8b856f04
AG
1279 if (!has_default_mode) {
1280 rc = fb_find_mode(&info->var, info, aoi_mode, fsl_diu_mode_db,
63cf8df4
TT
1281 ARRAY_SIZE(fsl_diu_mode_db), NULL, default_bpp);
1282 if (rc)
8b856f04
AG
1283 has_default_mode = 1;
1284 }
1285
1286 /* Still not found, use preferred mode from database if any */
1287 if (!has_default_mode && info->monspecs.modedb) {
1288 struct fb_monspecs *specs = &info->monspecs;
1289 struct fb_videomode *modedb = &specs->modedb[0];
1290
1291 /*
1292 * Get preferred timing. If not found,
1293 * first mode in database will be used.
1294 */
1295 if (specs->misc & FB_MISC_1ST_DETAIL) {
1296 int i;
1297
1298 for (i = 0; i < specs->modedb_len; i++) {
1299 if (specs->modedb[i].flag & FB_MODE_IS_FIRST) {
1300 modedb = &specs->modedb[i];
1301 break;
1302 }
1303 }
1304 }
1305
1306 info->var.bits_per_pixel = default_bpp;
1307 fb_videomode_to_var(&info->var, modedb);
1308 }
1309
9b53a9e2 1310 if (fsl_diu_check_var(&info->var, info)) {
154152ae 1311 dev_err(info->dev, "fsl_diu_check_var failed\n");
589c7971 1312 unmap_video_memory(info);
9b53a9e2
YS
1313 fb_dealloc_cmap(&info->cmap);
1314 return -EINVAL;
1315 }
1316
9b53a9e2 1317 if (register_framebuffer(info) < 0) {
154152ae 1318 dev_err(info->dev, "register_framebuffer failed\n");
9b53a9e2
YS
1319 unmap_video_memory(info);
1320 fb_dealloc_cmap(&info->cmap);
1321 return -EINVAL;
1322 }
1323
1324 mfbi->registered = 1;
154152ae 1325 dev_info(info->dev, "%s registered successfully\n", mfbi->id);
9b53a9e2
YS
1326
1327 return 0;
1328}
1329
05946bce 1330static void uninstall_fb(struct fb_info *info)
9b53a9e2
YS
1331{
1332 struct mfb_info *mfbi = info->par;
1333
1334 if (!mfbi->registered)
1335 return;
1336
2572df91 1337 if (mfbi->index == PLANE0)
8b856f04
AG
1338 kfree(mfbi->edid_data);
1339
9b53a9e2
YS
1340 unregister_framebuffer(info);
1341 unmap_video_memory(info);
1342 if (&info->cmap)
1343 fb_dealloc_cmap(&info->cmap);
1344
1345 mfbi->registered = 0;
1346}
1347
1348static irqreturn_t fsl_diu_isr(int irq, void *dev_id)
1349{
3c755b7c 1350 struct diu __iomem *hw = dev_id;
9b53a9e2
YS
1351 unsigned int status = in_be32(&hw->int_status);
1352
1353 if (status) {
1354 /* This is the workaround for underrun */
1355 if (status & INT_UNDRUN) {
1356 out_be32(&hw->diu_mode, 0);
9b53a9e2
YS
1357 udelay(1);
1358 out_be32(&hw->diu_mode, 1);
1359 }
1360#if defined(CONFIG_NOT_COHERENT_CACHE)
1361 else if (status & INT_VSYNC) {
1362 unsigned int i;
4a85dc8b 1363
9b53a9e2
YS
1364 for (i = 0; i < coherence_data_size;
1365 i += d_cache_line_size)
1366 __asm__ __volatile__ (
1367 "dcbz 0, %[input]"
1368 ::[input]"r"(&coherence_data[i]));
1369 }
1370#endif
1371 return IRQ_HANDLED;
1372 }
1373 return IRQ_NONE;
1374}
1375
3c755b7c 1376static int request_irq_local(struct fsl_diu_data *machine_data)
9b53a9e2 1377{
3c755b7c 1378 struct diu __iomem *hw = machine_data->diu_reg;
bada04fc 1379 u32 ints;
9b53a9e2
YS
1380 int ret;
1381
9b53a9e2 1382 /* Read to clear the status */
bada04fc 1383 in_be32(&hw->int_status);
9b53a9e2 1384
3c755b7c 1385 ret = request_irq(machine_data->irq, fsl_diu_isr, 0, "fsl-diu-fb", hw);
154152ae 1386 if (!ret) {
9b53a9e2
YS
1387 ints = INT_PARERR | INT_LS_BF_VS;
1388#if !defined(CONFIG_NOT_COHERENT_CACHE)
1389 ints |= INT_VSYNC;
1390#endif
4a85dc8b 1391
9b53a9e2 1392 /* Read to clear the status */
bada04fc 1393 in_be32(&hw->int_status);
9b53a9e2
YS
1394 out_be32(&hw->int_mask, ints);
1395 }
4a85dc8b 1396
9b53a9e2
YS
1397 return ret;
1398}
1399
3c755b7c 1400static void free_irq_local(struct fsl_diu_data *machine_data)
9b53a9e2 1401{
3c755b7c 1402 struct diu __iomem *hw = machine_data->diu_reg;
9b53a9e2
YS
1403
1404 /* Disable all LCDC interrupt */
1405 out_be32(&hw->int_mask, 0x1f);
1406
3c755b7c 1407 free_irq(machine_data->irq, NULL);
9b53a9e2
YS
1408}
1409
1410#ifdef CONFIG_PM
1411/*
1412 * Power management hooks. Note that we won't be called from IRQ context,
1413 * unlike the blank functions above, so we may sleep.
1414 */
2dc11581 1415static int fsl_diu_suspend(struct platform_device *ofdev, pm_message_t state)
9b53a9e2
YS
1416{
1417 struct fsl_diu_data *machine_data;
1418
48948a3e 1419 machine_data = dev_get_drvdata(&ofdev->dev);
9b53a9e2
YS
1420 disable_lcdc(machine_data->fsl_diu_info[0]);
1421
1422 return 0;
1423}
1424
2dc11581 1425static int fsl_diu_resume(struct platform_device *ofdev)
9b53a9e2
YS
1426{
1427 struct fsl_diu_data *machine_data;
1428
48948a3e 1429 machine_data = dev_get_drvdata(&ofdev->dev);
9b53a9e2
YS
1430 enable_lcdc(machine_data->fsl_diu_info[0]);
1431
1432 return 0;
1433}
1434
1435#else
1436#define fsl_diu_suspend NULL
1437#define fsl_diu_resume NULL
1438#endif /* CONFIG_PM */
1439
9b53a9e2
YS
1440static ssize_t store_monitor(struct device *device,
1441 struct device_attribute *attr, const char *buf, size_t count)
1442{
7653aaab 1443 enum fsl_diu_monitor_port old_monitor_port;
9b53a9e2
YS
1444 struct fsl_diu_data *machine_data =
1445 container_of(attr, struct fsl_diu_data, dev_attr);
1446
9b53a9e2 1447 old_monitor_port = machine_data->monitor_port;
7653aaab 1448 machine_data->monitor_port = fsl_diu_name_to_port(buf);
9b53a9e2
YS
1449
1450 if (old_monitor_port != machine_data->monitor_port) {
1451 /* All AOIs need adjust pixel format
1452 * fsl_diu_set_par only change the pixsel format here
1453 * unlikely to fail. */
ddd3d905
TT
1454 unsigned int i;
1455
1456 for (i=0; i < NUM_AOIS; i++)
1457 fsl_diu_set_par(&machine_data->fsl_diu_info[i]);
9b53a9e2
YS
1458 }
1459 return count;
1460}
1461
1462static ssize_t show_monitor(struct device *device,
1463 struct device_attribute *attr, char *buf)
1464{
1465 struct fsl_diu_data *machine_data =
1466 container_of(attr, struct fsl_diu_data, dev_attr);
7653aaab
TT
1467
1468 switch (machine_data->monitor_port) {
1469 case FSL_DIU_PORT_DVI:
1470 return sprintf(buf, "DVI\n");
1471 case FSL_DIU_PORT_LVDS:
1472 return sprintf(buf, "Single-link LVDS\n");
1473 case FSL_DIU_PORT_DLVDS:
1474 return sprintf(buf, "Dual-link LVDS\n");
1475 }
1476
1477 return 0;
9b53a9e2
YS
1478}
1479
9e52ba61 1480static int __devinit fsl_diu_probe(struct platform_device *pdev)
9b53a9e2 1481{
9e52ba61 1482 struct device_node *np = pdev->dev.of_node;
9b53a9e2 1483 struct mfb_info *mfbi;
9b53a9e2 1484 struct fsl_diu_data *machine_data;
4b5006ec 1485 int diu_mode;
ddd3d905
TT
1486 dma_addr_t dma_addr; /* DMA addr of machine_data struct */
1487 unsigned int i;
1488 int ret;
9b53a9e2 1489
ddd3d905
TT
1490 machine_data = dma_alloc_coherent(&pdev->dev,
1491 sizeof(struct fsl_diu_data), &dma_addr, GFP_DMA | __GFP_ZERO);
9b53a9e2
YS
1492 if (!machine_data)
1493 return -ENOMEM;
ddd3d905
TT
1494 machine_data->dma_addr = dma_addr;
1495
1496 /*
1497 * dma_alloc_coherent() uses a page allocator, so the address is
1498 * always page-aligned. We need the memory to be 32-byte aligned,
1499 * so that's good. However, if one day the allocator changes, we
1500 * need to catch that. It's not worth the effort to handle unaligned
1501 * alloctions now because it's highly unlikely to ever be a problem.
1502 */
1503 if ((unsigned long)machine_data & 31) {
1504 dev_err(&pdev->dev, "misaligned allocation");
1505 ret = -ENOMEM;
1506 goto error;
1507 }
9b53a9e2 1508
3c755b7c
TT
1509 spin_lock_init(&machine_data->reg_lock);
1510
ddd3d905
TT
1511 for (i = 0; i < NUM_AOIS; i++) {
1512 struct fb_info *info = &machine_data->fsl_diu_info[i];
1513
1514 info->device = &pdev->dev;
1515 info->par = &machine_data->mfb[i];
1516
1517 /*
1518 * We store the physical address of the AD in the reserved
1519 * 'paddr' field of the AD itself.
1520 */
1521 machine_data->ad[i].paddr = DMA_ADDR(machine_data, ad[i]);
1522
1523 info->fix.smem_start = 0;
1524
1525 /* Initialize the AOI data structure */
1526 mfbi = info->par;
9b53a9e2
YS
1527 memcpy(mfbi, &mfb_template[i], sizeof(struct mfb_info));
1528 mfbi->parent = machine_data;
ddd3d905 1529 mfbi->ad = &machine_data->ad[i];
8b856f04 1530
2572df91 1531 if (mfbi->index == PLANE0) {
8b856f04
AG
1532 const u8 *prop;
1533 int len;
1534
1535 /* Get EDID */
1536 prop = of_get_property(np, "edid", &len);
1537 if (prop && len == EDID_LENGTH)
1538 mfbi->edid_data = kmemdup(prop, EDID_LENGTH,
1539 GFP_KERNEL);
1540 }
9b53a9e2
YS
1541 }
1542
3c755b7c
TT
1543 machine_data->diu_reg = of_iomap(np, 0);
1544 if (!machine_data->diu_reg) {
9e52ba61 1545 dev_err(&pdev->dev, "cannot map DIU registers\n");
9b53a9e2 1546 ret = -EFAULT;
ddd3d905 1547 goto error;
9b53a9e2
YS
1548 }
1549
3c755b7c 1550 diu_mode = in_be32(&machine_data->diu_reg->diu_mode);
c4e5a023 1551 if (diu_mode == MFB_MODE0)
3c755b7c 1552 out_be32(&machine_data->diu_reg->diu_mode, 0); /* disable DIU */
9b53a9e2
YS
1553
1554 /* Get the IRQ of the DIU */
1555 machine_data->irq = irq_of_parse_and_map(np, 0);
1556
1557 if (!machine_data->irq) {
9e52ba61 1558 dev_err(&pdev->dev, "could not get DIU IRQ\n");
9b53a9e2
YS
1559 ret = -EINVAL;
1560 goto error;
1561 }
1562 machine_data->monitor_port = monitor_port;
1563
ddd3d905
TT
1564 /* Initialize the dummy Area Descriptor */
1565 machine_data->dummy_ad.addr =
1566 cpu_to_le32(DMA_ADDR(machine_data, dummy_aoi));
1567 machine_data->dummy_ad.pix_fmt = 0x88882317;
1568 machine_data->dummy_ad.src_size_g_alpha = cpu_to_le32((4 << 12) | 4);
1569 machine_data->dummy_ad.aoi_size = cpu_to_le32((4 << 16) | 2);
1570 machine_data->dummy_ad.offset_xyi = 0;
1571 machine_data->dummy_ad.offset_xyd = 0;
1572 machine_data->dummy_ad.next_ad = 0;
1573 machine_data->dummy_ad.paddr = DMA_ADDR(machine_data, dummy_ad);
9b53a9e2 1574
4b5006ec
AG
1575 /*
1576 * Let DIU display splash screen if it was pre-initialized
1577 * by the bootloader, set dummy area descriptor otherwise.
1578 */
c4e5a023 1579 if (diu_mode == MFB_MODE0)
3c755b7c 1580 out_be32(&machine_data->diu_reg->desc[0],
ddd3d905
TT
1581 machine_data->dummy_ad.paddr);
1582
1583 out_be32(&machine_data->diu_reg->desc[1], machine_data->dummy_ad.paddr);
1584 out_be32(&machine_data->diu_reg->desc[2], machine_data->dummy_ad.paddr);
1585
1586 for (i = 0; i < NUM_AOIS; i++) {
1587 ret = install_fb(&machine_data->fsl_diu_info[i]);
9b53a9e2 1588 if (ret) {
9e52ba61 1589 dev_err(&pdev->dev, "could not register fb %d\n", i);
9b53a9e2
YS
1590 goto error;
1591 }
1592 }
1593
3c755b7c 1594 if (request_irq_local(machine_data)) {
9e52ba61 1595 dev_err(&pdev->dev, "could not claim irq\n");
9b53a9e2
YS
1596 goto error;
1597 }
1598
12765517 1599 sysfs_attr_init(&machine_data->dev_attr.attr);
9b53a9e2
YS
1600 machine_data->dev_attr.attr.name = "monitor";
1601 machine_data->dev_attr.attr.mode = S_IRUGO|S_IWUSR;
1602 machine_data->dev_attr.show = show_monitor;
1603 machine_data->dev_attr.store = store_monitor;
ddd3d905
TT
1604 ret = device_create_file(&pdev->dev, &machine_data->dev_attr);
1605 if (ret) {
9e52ba61 1606 dev_err(&pdev->dev, "could not create sysfs file %s\n",
9b53a9e2
YS
1607 machine_data->dev_attr.attr.name);
1608 }
1609
9e52ba61 1610 dev_set_drvdata(&pdev->dev, machine_data);
9b53a9e2
YS
1611 return 0;
1612
1613error:
ddd3d905
TT
1614 for (i = 0; i < NUM_AOIS; i++)
1615 uninstall_fb(&machine_data->fsl_diu_info[i]);
1616
3c755b7c 1617 iounmap(machine_data->diu_reg);
9b53a9e2 1618
ddd3d905
TT
1619 dma_free_coherent(&pdev->dev, sizeof(struct fsl_diu_data),
1620 machine_data, machine_data->dma_addr);
9b53a9e2
YS
1621
1622 return ret;
1623}
1624
9e52ba61 1625static int fsl_diu_remove(struct platform_device *pdev)
9b53a9e2
YS
1626{
1627 struct fsl_diu_data *machine_data;
1628 int i;
1629
9e52ba61 1630 machine_data = dev_get_drvdata(&pdev->dev);
ddd3d905 1631 disable_lcdc(&machine_data->fsl_diu_info[0]);
3c755b7c 1632 free_irq_local(machine_data);
ddd3d905
TT
1633
1634 for (i = 0; i < NUM_AOIS; i++)
1635 uninstall_fb(&machine_data->fsl_diu_info[i]);
1636
3c755b7c 1637 iounmap(machine_data->diu_reg);
ddd3d905
TT
1638
1639 dma_free_coherent(&pdev->dev, sizeof(struct fsl_diu_data),
1640 machine_data, machine_data->dma_addr);
9b53a9e2
YS
1641
1642 return 0;
1643}
1644
1645#ifndef MODULE
1646static int __init fsl_diu_setup(char *options)
1647{
1648 char *opt;
1649 unsigned long val;
1650
1651 if (!options || !*options)
1652 return 0;
1653
1654 while ((opt = strsep(&options, ",")) != NULL) {
1655 if (!*opt)
1656 continue;
1657 if (!strncmp(opt, "monitor=", 8)) {
7653aaab 1658 monitor_port = fsl_diu_name_to_port(opt + 8);
9b53a9e2
YS
1659 } else if (!strncmp(opt, "bpp=", 4)) {
1660 if (!strict_strtoul(opt + 4, 10, &val))
1661 default_bpp = val;
1662 } else
1663 fb_mode = opt;
1664 }
1665
1666 return 0;
1667}
1668#endif
1669
1670static struct of_device_id fsl_diu_match[] = {
d24720a4
AG
1671#ifdef CONFIG_PPC_MPC512x
1672 {
1673 .compatible = "fsl,mpc5121-diu",
1674 },
1675#endif
9b53a9e2
YS
1676 {
1677 .compatible = "fsl,diu",
1678 },
1679 {}
1680};
1681MODULE_DEVICE_TABLE(of, fsl_diu_match);
1682
28541d0f 1683static struct platform_driver fsl_diu_driver = {
4018294b 1684 .driver = {
f8c6bf6a 1685 .name = "fsl-diu-fb",
4018294b
GL
1686 .owner = THIS_MODULE,
1687 .of_match_table = fsl_diu_match,
1688 },
9b53a9e2
YS
1689 .probe = fsl_diu_probe,
1690 .remove = fsl_diu_remove,
1691 .suspend = fsl_diu_suspend,
1692 .resume = fsl_diu_resume,
1693};
1694
1695static int __init fsl_diu_init(void)
1696{
1697#ifdef CONFIG_NOT_COHERENT_CACHE
1698 struct device_node *np;
1699 const u32 *prop;
1700#endif
1701 int ret;
1702#ifndef MODULE
1703 char *option;
1704
1705 /*
1706 * For kernel boot options (in 'video=xxxfb:<options>' format)
1707 */
1708 if (fb_get_options("fslfb", &option))
1709 return -ENODEV;
1710 fsl_diu_setup(option);
7653aaab
TT
1711#else
1712 monitor_port = fsl_diu_name_to_port(monitor_string);
9b53a9e2 1713#endif
154152ae 1714 pr_info("Freescale Display Interface Unit (DIU) framebuffer driver\n");
9b53a9e2
YS
1715
1716#ifdef CONFIG_NOT_COHERENT_CACHE
1717 np = of_find_node_by_type(NULL, "cpu");
1718 if (!np) {
154152ae 1719 pr_err("fsl-diu-fb: can't find 'cpu' device node\n");
9b53a9e2
YS
1720 return -ENODEV;
1721 }
1722
1723 prop = of_get_property(np, "d-cache-size", NULL);
5394ba0f 1724 if (prop == NULL) {
154152ae
TT
1725 pr_err("fsl-diu-fb: missing 'd-cache-size' property' "
1726 "in 'cpu' node\n");
5394ba0f 1727 of_node_put(np);
9b53a9e2 1728 return -ENODEV;
5394ba0f 1729 }
9b53a9e2 1730
4a85dc8b
TT
1731 /*
1732 * Freescale PLRU requires 13/8 times the cache size to do a proper
1733 * displacement flush
9b53a9e2 1734 */
9e52ba61 1735 coherence_data_size = be32_to_cpup(prop) * 13;
9b53a9e2
YS
1736 coherence_data_size /= 8;
1737
1738 prop = of_get_property(np, "d-cache-line-size", NULL);
5394ba0f 1739 if (prop == NULL) {
154152ae
TT
1740 pr_err("fsl-diu-fb: missing 'd-cache-line-size' property' "
1741 "in 'cpu' node\n");
5394ba0f 1742 of_node_put(np);
9b53a9e2 1743 return -ENODEV;
5394ba0f 1744 }
9e52ba61 1745 d_cache_line_size = be32_to_cpup(prop);
9b53a9e2
YS
1746
1747 of_node_put(np);
1748 coherence_data = vmalloc(coherence_data_size);
1749 if (!coherence_data)
1750 return -ENOMEM;
1751#endif
4a85dc8b 1752
28541d0f 1753 ret = platform_driver_register(&fsl_diu_driver);
9b53a9e2 1754 if (ret) {
154152ae 1755 pr_err("fsl-diu-fb: failed to register platform driver\n");
9b53a9e2
YS
1756#if defined(CONFIG_NOT_COHERENT_CACHE)
1757 vfree(coherence_data);
1758#endif
9b53a9e2
YS
1759 }
1760 return ret;
1761}
1762
1763static void __exit fsl_diu_exit(void)
1764{
28541d0f 1765 platform_driver_unregister(&fsl_diu_driver);
9b53a9e2
YS
1766#if defined(CONFIG_NOT_COHERENT_CACHE)
1767 vfree(coherence_data);
1768#endif
1769}
1770
1771module_init(fsl_diu_init);
1772module_exit(fsl_diu_exit);
1773
1774MODULE_AUTHOR("York Sun <yorksun@freescale.com>");
1775MODULE_DESCRIPTION("Freescale DIU framebuffer driver");
1776MODULE_LICENSE("GPL");
1777
1778module_param_named(mode, fb_mode, charp, 0);
1779MODULE_PARM_DESC(mode,
1780 "Specify resolution as \"<xres>x<yres>[-<bpp>][@<refresh>]\" ");
1781module_param_named(bpp, default_bpp, ulong, 0);
154152ae 1782MODULE_PARM_DESC(bpp, "Specify bit-per-pixel if not specified in 'mode'");
7653aaab
TT
1783module_param_named(monitor, monitor_string, charp, 0);
1784MODULE_PARM_DESC(monitor, "Specify the monitor port "
1785 "(\"dvi\", \"lvds\", or \"dlvds\") if supported by the platform");
9b53a9e2 1786
This page took 0.386634 seconds and 5 git commands to generate.