2 * OMAP2 display controller support
4 * Copyright (C) 2005 Nokia Corporation
5 * Author: Imre Deak <imre.deak@nokia.com>
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 #include <linux/kernel.h>
22 #include <linux/dma-mapping.h>
24 #include <linux/vmalloc.h>
25 #include <linux/clk.h>
27 #include <linux/platform_device.h>
28 #include <linux/slab.h>
30 #include <plat/sram.h>
31 #include <plat/board.h>
36 #define MODULE_NAME "dispc"
38 #define DSS_BASE 0x48050000
39 #define DSS_SYSCONFIG 0x0010
41 #define DISPC_BASE 0x48050400
44 #define DISPC_REVISION 0x0000
45 #define DISPC_SYSCONFIG 0x0010
46 #define DISPC_SYSSTATUS 0x0014
47 #define DISPC_IRQSTATUS 0x0018
48 #define DISPC_IRQENABLE 0x001C
49 #define DISPC_CONTROL 0x0040
50 #define DISPC_CONFIG 0x0044
51 #define DISPC_CAPABLE 0x0048
52 #define DISPC_DEFAULT_COLOR0 0x004C
53 #define DISPC_DEFAULT_COLOR1 0x0050
54 #define DISPC_TRANS_COLOR0 0x0054
55 #define DISPC_TRANS_COLOR1 0x0058
56 #define DISPC_LINE_STATUS 0x005C
57 #define DISPC_LINE_NUMBER 0x0060
58 #define DISPC_TIMING_H 0x0064
59 #define DISPC_TIMING_V 0x0068
60 #define DISPC_POL_FREQ 0x006C
61 #define DISPC_DIVISOR 0x0070
62 #define DISPC_SIZE_DIG 0x0078
63 #define DISPC_SIZE_LCD 0x007C
65 #define DISPC_DATA_CYCLE1 0x01D4
66 #define DISPC_DATA_CYCLE2 0x01D8
67 #define DISPC_DATA_CYCLE3 0x01DC
70 #define DISPC_GFX_BA0 0x0080
71 #define DISPC_GFX_BA1 0x0084
72 #define DISPC_GFX_POSITION 0x0088
73 #define DISPC_GFX_SIZE 0x008C
74 #define DISPC_GFX_ATTRIBUTES 0x00A0
75 #define DISPC_GFX_FIFO_THRESHOLD 0x00A4
76 #define DISPC_GFX_FIFO_SIZE_STATUS 0x00A8
77 #define DISPC_GFX_ROW_INC 0x00AC
78 #define DISPC_GFX_PIXEL_INC 0x00B0
79 #define DISPC_GFX_WINDOW_SKIP 0x00B4
80 #define DISPC_GFX_TABLE_BA 0x00B8
82 /* DISPC Video plane 1/2 */
83 #define DISPC_VID1_BASE 0x00BC
84 #define DISPC_VID2_BASE 0x014C
86 /* Offsets into DISPC_VID1/2_BASE */
87 #define DISPC_VID_BA0 0x0000
88 #define DISPC_VID_BA1 0x0004
89 #define DISPC_VID_POSITION 0x0008
90 #define DISPC_VID_SIZE 0x000C
91 #define DISPC_VID_ATTRIBUTES 0x0010
92 #define DISPC_VID_FIFO_THRESHOLD 0x0014
93 #define DISPC_VID_FIFO_SIZE_STATUS 0x0018
94 #define DISPC_VID_ROW_INC 0x001C
95 #define DISPC_VID_PIXEL_INC 0x0020
96 #define DISPC_VID_FIR 0x0024
97 #define DISPC_VID_PICTURE_SIZE 0x0028
98 #define DISPC_VID_ACCU0 0x002C
99 #define DISPC_VID_ACCU1 0x0030
101 /* 8 elements in 8 byte increments */
102 #define DISPC_VID_FIR_COEF_H0 0x0034
103 /* 8 elements in 8 byte increments */
104 #define DISPC_VID_FIR_COEF_HV0 0x0038
105 /* 5 elements in 4 byte increments */
106 #define DISPC_VID_CONV_COEF0 0x0074
108 #define DISPC_IRQ_FRAMEMASK 0x0001
109 #define DISPC_IRQ_VSYNC 0x0002
110 #define DISPC_IRQ_EVSYNC_EVEN 0x0004
111 #define DISPC_IRQ_EVSYNC_ODD 0x0008
112 #define DISPC_IRQ_ACBIAS_COUNT_STAT 0x0010
113 #define DISPC_IRQ_PROG_LINE_NUM 0x0020
114 #define DISPC_IRQ_GFX_FIFO_UNDERFLOW 0x0040
115 #define DISPC_IRQ_GFX_END_WIN 0x0080
116 #define DISPC_IRQ_PAL_GAMMA_MASK 0x0100
117 #define DISPC_IRQ_OCP_ERR 0x0200
118 #define DISPC_IRQ_VID1_FIFO_UNDERFLOW 0x0400
119 #define DISPC_IRQ_VID1_END_WIN 0x0800
120 #define DISPC_IRQ_VID2_FIFO_UNDERFLOW 0x1000
121 #define DISPC_IRQ_VID2_END_WIN 0x2000
122 #define DISPC_IRQ_SYNC_LOST 0x4000
124 #define DISPC_IRQ_MASK_ALL 0x7fff
126 #define DISPC_IRQ_MASK_ERROR (DISPC_IRQ_GFX_FIFO_UNDERFLOW | \
127 DISPC_IRQ_VID1_FIFO_UNDERFLOW | \
128 DISPC_IRQ_VID2_FIFO_UNDERFLOW | \
131 #define RFBI_CONTROL 0x48050040
133 #define MAX_PALETTE_SIZE (256 * 16)
135 #define FLD_MASK(pos, len) (((1 << len) - 1) << pos)
137 #define MOD_REG_FLD(reg, mask, val) \
138 dispc_write_reg((reg), (dispc_read_reg(reg) & ~(mask)) | (val));
140 #define OMAP2_SRAM_START 0x40200000
141 /* Maximum size, in reality this is smaller if SRAM is partially locked. */
142 #define OMAP2_SRAM_SIZE 0xa0000 /* 640k */
144 /* We support the SDRAM / SRAM types. See OMAPFB_PLANE_MEMTYPE_* in omapfb.h */
145 #define DISPC_MEMTYPE_NUM 2
147 #define RESMAP_SIZE(_page_cnt) \
148 ((_page_cnt + (sizeof(unsigned long) * 8) - 1) / 8)
149 #define RESMAP_PTR(_res_map, _page_nr) \
150 (((_res_map)->map) + (_page_nr) / (sizeof(unsigned long) * 8))
151 #define RESMAP_MASK(_page_nr) \
152 (1 << ((_page_nr) & (sizeof(unsigned long) * 8 - 1)))
160 #define MAX_IRQ_HANDLERS 4
165 struct omapfb_mem_desc mem_desc
;
166 struct resmap
*res_map
[DISPC_MEMTYPE_NUM
];
167 atomic_t map_count
[OMAPFB_PLANE_NUM
];
169 dma_addr_t palette_paddr
;
176 void (*callback
)(void *);
178 } irq_handlers
[MAX_IRQ_HANDLERS
];
179 struct completion frame_done
;
181 int fir_hinc
[OMAPFB_PLANE_NUM
];
182 int fir_vinc
[OMAPFB_PLANE_NUM
];
184 struct clk
*dss_ick
, *dss1_fck
;
185 struct clk
*dss_54m_fck
;
187 enum omapfb_update_mode update_mode
;
188 struct omapfb_device
*fbdev
;
190 struct omapfb_color_key color_key
;
193 static void enable_lcd_clocks(int enable
);
195 static void inline dispc_write_reg(int idx
, u32 val
)
197 __raw_writel(val
, dispc
.base
+ idx
);
200 static u32
inline dispc_read_reg(int idx
)
202 u32 l
= __raw_readl(dispc
.base
+ idx
);
206 /* Select RFBI or bypass mode */
207 static void enable_rfbi_mode(int enable
)
209 void __iomem
*rfbi_control
;
212 l
= dispc_read_reg(DISPC_CONTROL
);
213 /* Enable RFBI, GPIO0/1 */
214 l
&= ~((1 << 11) | (1 << 15) | (1 << 16));
215 l
|= enable
? (1 << 11) : 0;
216 /* RFBI En: GPIO0/1=10 RFBI Dis: GPIO0/1=11 */
218 l
|= enable
? 0 : (1 << 16);
219 dispc_write_reg(DISPC_CONTROL
, l
);
221 /* Set bypass mode in RFBI module */
222 rfbi_control
= ioremap(RFBI_CONTROL
, SZ_1K
);
224 pr_err("Unable to ioremap rfbi_control\n");
227 l
= __raw_readl(rfbi_control
);
228 l
|= enable
? 0 : (1 << 1);
229 __raw_writel(l
, rfbi_control
);
230 iounmap(rfbi_control
);
233 static void set_lcd_data_lines(int data_lines
)
238 switch (data_lines
) {
255 l
= dispc_read_reg(DISPC_CONTROL
);
258 dispc_write_reg(DISPC_CONTROL
, l
);
261 static void set_load_mode(int mode
)
263 BUG_ON(mode
& ~(DISPC_LOAD_CLUT_ONLY
| DISPC_LOAD_FRAME_ONLY
|
264 DISPC_LOAD_CLUT_ONCE_FRAME
));
265 MOD_REG_FLD(DISPC_CONFIG
, 0x03 << 1, mode
<< 1);
268 void omap_dispc_set_lcd_size(int x
, int y
)
270 BUG_ON((x
> (1 << 11)) || (y
> (1 << 11)));
271 enable_lcd_clocks(1);
272 MOD_REG_FLD(DISPC_SIZE_LCD
, FLD_MASK(16, 11) | FLD_MASK(0, 11),
273 ((y
- 1) << 16) | (x
- 1));
274 enable_lcd_clocks(0);
276 EXPORT_SYMBOL(omap_dispc_set_lcd_size
);
278 void omap_dispc_set_digit_size(int x
, int y
)
280 BUG_ON((x
> (1 << 11)) || (y
> (1 << 11)));
281 enable_lcd_clocks(1);
282 MOD_REG_FLD(DISPC_SIZE_DIG
, FLD_MASK(16, 11) | FLD_MASK(0, 11),
283 ((y
- 1) << 16) | (x
- 1));
284 enable_lcd_clocks(0);
286 EXPORT_SYMBOL(omap_dispc_set_digit_size
);
288 static void setup_plane_fifo(int plane
, int ext_mode
)
290 const u32 ftrs_reg
[] = { DISPC_GFX_FIFO_THRESHOLD
,
291 DISPC_VID1_BASE
+ DISPC_VID_FIFO_THRESHOLD
,
292 DISPC_VID2_BASE
+ DISPC_VID_FIFO_THRESHOLD
};
293 const u32 fsz_reg
[] = { DISPC_GFX_FIFO_SIZE_STATUS
,
294 DISPC_VID1_BASE
+ DISPC_VID_FIFO_SIZE_STATUS
,
295 DISPC_VID2_BASE
+ DISPC_VID_FIFO_SIZE_STATUS
};
301 l
= dispc_read_reg(fsz_reg
[plane
]);
302 l
&= FLD_MASK(0, 11);
310 MOD_REG_FLD(ftrs_reg
[plane
], FLD_MASK(16, 12) | FLD_MASK(0, 12),
314 void omap_dispc_enable_lcd_out(int enable
)
316 enable_lcd_clocks(1);
317 MOD_REG_FLD(DISPC_CONTROL
, 1, enable
? 1 : 0);
318 enable_lcd_clocks(0);
320 EXPORT_SYMBOL(omap_dispc_enable_lcd_out
);
322 void omap_dispc_enable_digit_out(int enable
)
324 enable_lcd_clocks(1);
325 MOD_REG_FLD(DISPC_CONTROL
, 1 << 1, enable
? 1 << 1 : 0);
326 enable_lcd_clocks(0);
328 EXPORT_SYMBOL(omap_dispc_enable_digit_out
);
330 static inline int _setup_plane(int plane
, int channel_out
,
331 u32 paddr
, int screen_width
,
332 int pos_x
, int pos_y
, int width
, int height
,
335 const u32 at_reg
[] = { DISPC_GFX_ATTRIBUTES
,
336 DISPC_VID1_BASE
+ DISPC_VID_ATTRIBUTES
,
337 DISPC_VID2_BASE
+ DISPC_VID_ATTRIBUTES
};
338 const u32 ba_reg
[] = { DISPC_GFX_BA0
, DISPC_VID1_BASE
+ DISPC_VID_BA0
,
339 DISPC_VID2_BASE
+ DISPC_VID_BA0
};
340 const u32 ps_reg
[] = { DISPC_GFX_POSITION
,
341 DISPC_VID1_BASE
+ DISPC_VID_POSITION
,
342 DISPC_VID2_BASE
+ DISPC_VID_POSITION
};
343 const u32 sz_reg
[] = { DISPC_GFX_SIZE
,
344 DISPC_VID1_BASE
+ DISPC_VID_PICTURE_SIZE
,
345 DISPC_VID2_BASE
+ DISPC_VID_PICTURE_SIZE
};
346 const u32 ri_reg
[] = { DISPC_GFX_ROW_INC
,
347 DISPC_VID1_BASE
+ DISPC_VID_ROW_INC
,
348 DISPC_VID2_BASE
+ DISPC_VID_ROW_INC
};
349 const u32 vs_reg
[] = { 0, DISPC_VID1_BASE
+ DISPC_VID_SIZE
,
350 DISPC_VID2_BASE
+ DISPC_VID_SIZE
};
352 int chout_shift
, burst_shift
;
361 dev_dbg(dispc
.fbdev
->dev
, "plane %d channel %d paddr %#08x scr_width %d"
362 " pos_x %d pos_y %d width %d height %d color_mode %d\n",
363 plane
, channel_out
, paddr
, screen_width
, pos_x
, pos_y
,
364 width
, height
, color_mode
);
369 case OMAPFB_PLANE_GFX
:
373 case OMAPFB_PLANE_VID1
:
374 case OMAPFB_PLANE_VID2
:
383 switch (channel_out
) {
384 case OMAPFB_CHANNEL_OUT_LCD
:
387 case OMAPFB_CHANNEL_OUT_DIGIT
:
395 switch (color_mode
) {
396 case OMAPFB_COLOR_RGB565
:
397 color_code
= DISPC_RGB_16_BPP
;
400 case OMAPFB_COLOR_YUV422
:
403 color_code
= DISPC_UYVY_422
;
407 case OMAPFB_COLOR_YUY422
:
410 color_code
= DISPC_YUV2_422
;
418 l
= dispc_read_reg(at_reg
[plane
]);
421 l
|= color_code
<< 1;
425 l
&= ~(0x03 << burst_shift
);
426 l
|= DISPC_BURST_8x32
<< burst_shift
;
428 l
&= ~(1 << chout_shift
);
429 l
|= chout_val
<< chout_shift
;
431 dispc_write_reg(at_reg
[plane
], l
);
433 dispc_write_reg(ba_reg
[plane
], paddr
);
434 MOD_REG_FLD(ps_reg
[plane
],
435 FLD_MASK(16, 11) | FLD_MASK(0, 11), (pos_y
<< 16) | pos_x
);
437 MOD_REG_FLD(sz_reg
[plane
], FLD_MASK(16, 11) | FLD_MASK(0, 11),
438 ((height
- 1) << 16) | (width
- 1));
441 /* Set video size if set_scale hasn't set it */
442 if (!dispc
.fir_vinc
[plane
])
443 MOD_REG_FLD(vs_reg
[plane
],
444 FLD_MASK(16, 11), (height
- 1) << 16);
445 if (!dispc
.fir_hinc
[plane
])
446 MOD_REG_FLD(vs_reg
[plane
],
447 FLD_MASK(0, 11), width
- 1);
450 dispc_write_reg(ri_reg
[plane
], (screen_width
- width
) * bpp
/ 8 + 1);
452 return height
* screen_width
* bpp
/ 8;
455 static int omap_dispc_setup_plane(int plane
, int channel_out
,
456 unsigned long offset
,
458 int pos_x
, int pos_y
, int width
, int height
,
464 if ((unsigned)plane
> dispc
.mem_desc
.region_cnt
)
466 paddr
= dispc
.mem_desc
.region
[plane
].paddr
+ offset
;
467 enable_lcd_clocks(1);
468 r
= _setup_plane(plane
, channel_out
, paddr
,
470 pos_x
, pos_y
, width
, height
, color_mode
);
471 enable_lcd_clocks(0);
475 static void write_firh_reg(int plane
, int reg
, u32 value
)
480 base
= DISPC_VID1_BASE
+ DISPC_VID_FIR_COEF_H0
;
482 base
= DISPC_VID2_BASE
+ DISPC_VID_FIR_COEF_H0
;
483 dispc_write_reg(base
+ reg
* 8, value
);
486 static void write_firhv_reg(int plane
, int reg
, u32 value
)
491 base
= DISPC_VID1_BASE
+ DISPC_VID_FIR_COEF_HV0
;
493 base
= DISPC_VID2_BASE
+ DISPC_VID_FIR_COEF_HV0
;
494 dispc_write_reg(base
+ reg
* 8, value
);
497 static void set_upsampling_coef_table(int plane
)
499 const u32 coef
[][2] = {
500 { 0x00800000, 0x00800000 },
501 { 0x0D7CF800, 0x037B02FF },
502 { 0x1E70F5FF, 0x0C6F05FE },
503 { 0x335FF5FE, 0x205907FB },
504 { 0xF74949F7, 0x00404000 },
505 { 0xF55F33FB, 0x075920FE },
506 { 0xF5701EFE, 0x056F0CFF },
507 { 0xF87C0DFF, 0x027B0300 },
511 for (i
= 0; i
< 8; i
++) {
512 write_firh_reg(plane
, i
, coef
[i
][0]);
513 write_firhv_reg(plane
, i
, coef
[i
][1]);
517 static int omap_dispc_set_scale(int plane
,
518 int orig_width
, int orig_height
,
519 int out_width
, int out_height
)
521 const u32 at_reg
[] = { 0, DISPC_VID1_BASE
+ DISPC_VID_ATTRIBUTES
,
522 DISPC_VID2_BASE
+ DISPC_VID_ATTRIBUTES
};
523 const u32 vs_reg
[] = { 0, DISPC_VID1_BASE
+ DISPC_VID_SIZE
,
524 DISPC_VID2_BASE
+ DISPC_VID_SIZE
};
525 const u32 fir_reg
[] = { 0, DISPC_VID1_BASE
+ DISPC_VID_FIR
,
526 DISPC_VID2_BASE
+ DISPC_VID_FIR
};
532 if ((unsigned)plane
> OMAPFB_PLANE_NUM
)
535 if (plane
== OMAPFB_PLANE_GFX
&&
536 (out_width
!= orig_width
|| out_height
!= orig_height
))
539 enable_lcd_clocks(1);
540 if (orig_width
< out_width
) {
543 * Currently you can only scale both dimensions in one way.
545 if (orig_height
> out_height
||
546 orig_width
* 8 < out_width
||
547 orig_height
* 8 < out_height
) {
548 enable_lcd_clocks(0);
551 set_upsampling_coef_table(plane
);
552 } else if (orig_width
> out_width
) {
553 /* Downsampling not yet supported
556 enable_lcd_clocks(0);
559 if (!orig_width
|| orig_width
== out_width
)
562 fir_hinc
= 1024 * orig_width
/ out_width
;
563 if (!orig_height
|| orig_height
== out_height
)
566 fir_vinc
= 1024 * orig_height
/ out_height
;
567 dispc
.fir_hinc
[plane
] = fir_hinc
;
568 dispc
.fir_vinc
[plane
] = fir_vinc
;
570 MOD_REG_FLD(fir_reg
[plane
],
571 FLD_MASK(16, 12) | FLD_MASK(0, 12),
572 ((fir_vinc
& 4095) << 16) |
575 dev_dbg(dispc
.fbdev
->dev
, "out_width %d out_height %d orig_width %d "
576 "orig_height %d fir_hinc %d fir_vinc %d\n",
577 out_width
, out_height
, orig_width
, orig_height
,
580 MOD_REG_FLD(vs_reg
[plane
],
581 FLD_MASK(16, 11) | FLD_MASK(0, 11),
582 ((out_height
- 1) << 16) | (out_width
- 1));
584 l
= dispc_read_reg(at_reg
[plane
]);
586 l
|= fir_hinc
? (1 << 5) : 0;
587 l
|= fir_vinc
? (1 << 6) : 0;
588 dispc_write_reg(at_reg
[plane
], l
);
590 enable_lcd_clocks(0);
594 static int omap_dispc_enable_plane(int plane
, int enable
)
596 const u32 at_reg
[] = { DISPC_GFX_ATTRIBUTES
,
597 DISPC_VID1_BASE
+ DISPC_VID_ATTRIBUTES
,
598 DISPC_VID2_BASE
+ DISPC_VID_ATTRIBUTES
};
599 if ((unsigned int)plane
> dispc
.mem_desc
.region_cnt
)
602 enable_lcd_clocks(1);
603 MOD_REG_FLD(at_reg
[plane
], 1, enable
? 1 : 0);
604 enable_lcd_clocks(0);
609 static int omap_dispc_set_color_key(struct omapfb_color_key
*ck
)
614 switch (ck
->channel_out
) {
615 case OMAPFB_CHANNEL_OUT_LCD
:
616 df_reg
= DISPC_DEFAULT_COLOR0
;
617 tr_reg
= DISPC_TRANS_COLOR0
;
620 case OMAPFB_CHANNEL_OUT_DIGIT
:
621 df_reg
= DISPC_DEFAULT_COLOR1
;
622 tr_reg
= DISPC_TRANS_COLOR1
;
628 switch (ck
->key_type
) {
629 case OMAPFB_COLOR_KEY_DISABLED
:
632 case OMAPFB_COLOR_KEY_GFX_DST
:
635 case OMAPFB_COLOR_KEY_VID_SRC
:
641 enable_lcd_clocks(1);
642 MOD_REG_FLD(DISPC_CONFIG
, FLD_MASK(shift
, 2), val
<< shift
);
645 dispc_write_reg(tr_reg
, ck
->trans_key
);
646 dispc_write_reg(df_reg
, ck
->background
);
647 enable_lcd_clocks(0);
649 dispc
.color_key
= *ck
;
654 static int omap_dispc_get_color_key(struct omapfb_color_key
*ck
)
656 *ck
= dispc
.color_key
;
660 static void load_palette(void)
664 static int omap_dispc_set_update_mode(enum omapfb_update_mode mode
)
668 if (mode
!= dispc
.update_mode
) {
670 case OMAPFB_AUTO_UPDATE
:
671 case OMAPFB_MANUAL_UPDATE
:
672 enable_lcd_clocks(1);
673 omap_dispc_enable_lcd_out(1);
674 dispc
.update_mode
= mode
;
676 case OMAPFB_UPDATE_DISABLED
:
677 init_completion(&dispc
.frame_done
);
678 omap_dispc_enable_lcd_out(0);
679 if (!wait_for_completion_timeout(&dispc
.frame_done
,
680 msecs_to_jiffies(500))) {
681 dev_err(dispc
.fbdev
->dev
,
682 "timeout waiting for FRAME DONE\n");
684 dispc
.update_mode
= mode
;
685 enable_lcd_clocks(0);
695 static void omap_dispc_get_caps(int plane
, struct omapfb_caps
*caps
)
697 caps
->ctrl
|= OMAPFB_CAPS_PLANE_RELOCATE_MEM
;
699 caps
->ctrl
|= OMAPFB_CAPS_PLANE_SCALE
;
700 caps
->plane_color
|= (1 << OMAPFB_COLOR_RGB565
) |
701 (1 << OMAPFB_COLOR_YUV422
) |
702 (1 << OMAPFB_COLOR_YUY422
);
704 caps
->plane_color
|= (1 << OMAPFB_COLOR_CLUT_8BPP
) |
705 (1 << OMAPFB_COLOR_CLUT_4BPP
) |
706 (1 << OMAPFB_COLOR_CLUT_2BPP
) |
707 (1 << OMAPFB_COLOR_CLUT_1BPP
) |
708 (1 << OMAPFB_COLOR_RGB444
);
711 static enum omapfb_update_mode
omap_dispc_get_update_mode(void)
713 return dispc
.update_mode
;
716 static void setup_color_conv_coef(void)
718 u32 mask
= FLD_MASK(16, 11) | FLD_MASK(0, 11);
719 int cf1_reg
= DISPC_VID1_BASE
+ DISPC_VID_CONV_COEF0
;
720 int cf2_reg
= DISPC_VID2_BASE
+ DISPC_VID_CONV_COEF0
;
721 int at1_reg
= DISPC_VID1_BASE
+ DISPC_VID_ATTRIBUTES
;
722 int at2_reg
= DISPC_VID2_BASE
+ DISPC_VID_ATTRIBUTES
;
723 const struct color_conv_coef
{
724 int ry
, rcr
, rcb
, gy
, gcr
, gcb
, by
, bcr
, bcb
;
727 298, 409, 0, 298, -208, -100, 298, 0, 517, 0,
729 const struct color_conv_coef
*ct
;
730 #define CVAL(x, y) (((x & 2047) << 16) | (y & 2047))
734 MOD_REG_FLD(cf1_reg
, mask
, CVAL(ct
->rcr
, ct
->ry
));
735 MOD_REG_FLD(cf1_reg
+ 4, mask
, CVAL(ct
->gy
, ct
->rcb
));
736 MOD_REG_FLD(cf1_reg
+ 8, mask
, CVAL(ct
->gcb
, ct
->gcr
));
737 MOD_REG_FLD(cf1_reg
+ 12, mask
, CVAL(ct
->bcr
, ct
->by
));
738 MOD_REG_FLD(cf1_reg
+ 16, mask
, CVAL(0, ct
->bcb
));
740 MOD_REG_FLD(cf2_reg
, mask
, CVAL(ct
->rcr
, ct
->ry
));
741 MOD_REG_FLD(cf2_reg
+ 4, mask
, CVAL(ct
->gy
, ct
->rcb
));
742 MOD_REG_FLD(cf2_reg
+ 8, mask
, CVAL(ct
->gcb
, ct
->gcr
));
743 MOD_REG_FLD(cf2_reg
+ 12, mask
, CVAL(ct
->bcr
, ct
->by
));
744 MOD_REG_FLD(cf2_reg
+ 16, mask
, CVAL(0, ct
->bcb
));
747 MOD_REG_FLD(at1_reg
, (1 << 11), ct
->full_range
);
748 MOD_REG_FLD(at2_reg
, (1 << 11), ct
->full_range
);
751 static void calc_ck_div(int is_tft
, int pck
, int *lck_div
, int *pck_div
)
753 unsigned long fck
, lck
;
757 fck
= clk_get_rate(dispc
.dss1_fck
);
759 *pck_div
= (lck
+ pck
- 1) / pck
;
761 *pck_div
= max(2, *pck_div
);
763 *pck_div
= max(3, *pck_div
);
764 if (*pck_div
> 255) {
766 lck
= pck
* *pck_div
;
767 *lck_div
= fck
/ lck
;
768 BUG_ON(*lck_div
< 1);
769 if (*lck_div
> 255) {
771 dev_warn(dispc
.fbdev
->dev
, "pixclock %d kHz too low.\n",
777 static void set_lcd_tft_mode(int enable
)
782 MOD_REG_FLD(DISPC_CONTROL
, mask
, enable
? mask
: 0);
785 static void set_lcd_timings(void)
788 int lck_div
, pck_div
;
789 struct lcd_panel
*panel
= dispc
.fbdev
->panel
;
790 int is_tft
= panel
->config
& OMAP_LCDC_PANEL_TFT
;
793 l
= dispc_read_reg(DISPC_TIMING_H
);
794 l
&= ~(FLD_MASK(0, 6) | FLD_MASK(8, 8) | FLD_MASK(20, 8));
795 l
|= ( max(1, (min(64, panel
->hsw
))) - 1 ) << 0;
796 l
|= ( max(1, (min(256, panel
->hfp
))) - 1 ) << 8;
797 l
|= ( max(1, (min(256, panel
->hbp
))) - 1 ) << 20;
798 dispc_write_reg(DISPC_TIMING_H
, l
);
800 l
= dispc_read_reg(DISPC_TIMING_V
);
801 l
&= ~(FLD_MASK(0, 6) | FLD_MASK(8, 8) | FLD_MASK(20, 8));
802 l
|= ( max(1, (min(64, panel
->vsw
))) - 1 ) << 0;
803 l
|= ( max(0, (min(255, panel
->vfp
))) - 0 ) << 8;
804 l
|= ( max(0, (min(255, panel
->vbp
))) - 0 ) << 20;
805 dispc_write_reg(DISPC_TIMING_V
, l
);
807 l
= dispc_read_reg(DISPC_POL_FREQ
);
808 l
&= ~FLD_MASK(12, 6);
809 l
|= (panel
->config
& OMAP_LCDC_SIGNAL_MASK
) << 12;
810 l
|= panel
->acb
& 0xff;
811 dispc_write_reg(DISPC_POL_FREQ
, l
);
813 calc_ck_div(is_tft
, panel
->pixel_clock
* 1000, &lck_div
, &pck_div
);
815 l
= dispc_read_reg(DISPC_DIVISOR
);
816 l
&= ~(FLD_MASK(16, 8) | FLD_MASK(0, 8));
817 l
|= (lck_div
<< 16) | (pck_div
<< 0);
818 dispc_write_reg(DISPC_DIVISOR
, l
);
820 /* update panel info with the exact clock */
821 fck
= clk_get_rate(dispc
.dss1_fck
);
822 panel
->pixel_clock
= fck
/ lck_div
/ pck_div
/ 1000;
825 static void recalc_irq_mask(void)
828 unsigned long irq_mask
= DISPC_IRQ_MASK_ERROR
;
830 for (i
= 0; i
< MAX_IRQ_HANDLERS
; i
++) {
831 if (!dispc
.irq_handlers
[i
].callback
)
834 irq_mask
|= dispc
.irq_handlers
[i
].irq_mask
;
837 enable_lcd_clocks(1);
838 MOD_REG_FLD(DISPC_IRQENABLE
, 0x7fff, irq_mask
);
839 enable_lcd_clocks(0);
842 int omap_dispc_request_irq(unsigned long irq_mask
, void (*callback
)(void *data
),
847 BUG_ON(callback
== NULL
);
849 for (i
= 0; i
< MAX_IRQ_HANDLERS
; i
++) {
850 if (dispc
.irq_handlers
[i
].callback
)
853 dispc
.irq_handlers
[i
].irq_mask
= irq_mask
;
854 dispc
.irq_handlers
[i
].callback
= callback
;
855 dispc
.irq_handlers
[i
].data
= data
;
863 EXPORT_SYMBOL(omap_dispc_request_irq
);
865 void omap_dispc_free_irq(unsigned long irq_mask
, void (*callback
)(void *data
),
870 for (i
= 0; i
< MAX_IRQ_HANDLERS
; i
++) {
871 if (dispc
.irq_handlers
[i
].callback
== callback
&&
872 dispc
.irq_handlers
[i
].data
== data
) {
873 dispc
.irq_handlers
[i
].irq_mask
= 0;
874 dispc
.irq_handlers
[i
].callback
= NULL
;
875 dispc
.irq_handlers
[i
].data
= NULL
;
883 EXPORT_SYMBOL(omap_dispc_free_irq
);
885 static irqreturn_t
omap_dispc_irq_handler(int irq
, void *dev
)
890 enable_lcd_clocks(1);
892 stat
= dispc_read_reg(DISPC_IRQSTATUS
);
893 if (stat
& DISPC_IRQ_FRAMEMASK
)
894 complete(&dispc
.frame_done
);
896 if (stat
& DISPC_IRQ_MASK_ERROR
) {
897 if (printk_ratelimit()) {
898 dev_err(dispc
.fbdev
->dev
, "irq error status %04x\n",
903 for (i
= 0; i
< MAX_IRQ_HANDLERS
; i
++) {
904 if (unlikely(dispc
.irq_handlers
[i
].callback
&&
905 (stat
& dispc
.irq_handlers
[i
].irq_mask
)))
906 dispc
.irq_handlers
[i
].callback(
907 dispc
.irq_handlers
[i
].data
);
910 dispc_write_reg(DISPC_IRQSTATUS
, stat
);
912 enable_lcd_clocks(0);
917 static int get_dss_clocks(void)
919 dispc
.dss_ick
= clk_get(&dispc
.fbdev
->dssdev
->dev
, "ick");
920 if (IS_ERR(dispc
.dss_ick
)) {
921 dev_err(dispc
.fbdev
->dev
, "can't get ick\n");
922 return PTR_ERR(dispc
.dss_ick
);
925 dispc
.dss1_fck
= clk_get(&dispc
.fbdev
->dssdev
->dev
, "fck");
926 if (IS_ERR(dispc
.dss1_fck
)) {
927 dev_err(dispc
.fbdev
->dev
, "can't get dss1_fck\n");
928 clk_put(dispc
.dss_ick
);
929 return PTR_ERR(dispc
.dss1_fck
);
932 dispc
.dss_54m_fck
= clk_get(&dispc
.fbdev
->dssdev
->dev
, "tv_clk");
933 if (IS_ERR(dispc
.dss_54m_fck
)) {
934 dev_err(dispc
.fbdev
->dev
, "can't get tv_fck\n");
935 clk_put(dispc
.dss_ick
);
936 clk_put(dispc
.dss1_fck
);
937 return PTR_ERR(dispc
.dss_54m_fck
);
943 static void put_dss_clocks(void)
945 clk_put(dispc
.dss_54m_fck
);
946 clk_put(dispc
.dss1_fck
);
947 clk_put(dispc
.dss_ick
);
950 static void enable_lcd_clocks(int enable
)
953 clk_enable(dispc
.dss_ick
);
954 clk_enable(dispc
.dss1_fck
);
956 clk_disable(dispc
.dss1_fck
);
957 clk_disable(dispc
.dss_ick
);
961 static void enable_digit_clocks(int enable
)
964 clk_enable(dispc
.dss_54m_fck
);
966 clk_disable(dispc
.dss_54m_fck
);
969 static void omap_dispc_suspend(void)
971 if (dispc
.update_mode
== OMAPFB_AUTO_UPDATE
) {
972 init_completion(&dispc
.frame_done
);
973 omap_dispc_enable_lcd_out(0);
974 if (!wait_for_completion_timeout(&dispc
.frame_done
,
975 msecs_to_jiffies(500))) {
976 dev_err(dispc
.fbdev
->dev
,
977 "timeout waiting for FRAME DONE\n");
979 enable_lcd_clocks(0);
983 static void omap_dispc_resume(void)
985 if (dispc
.update_mode
== OMAPFB_AUTO_UPDATE
) {
986 enable_lcd_clocks(1);
987 if (!dispc
.ext_mode
) {
991 omap_dispc_enable_lcd_out(1);
996 static int omap_dispc_update_window(struct fb_info
*fbi
,
997 struct omapfb_update_window
*win
,
998 void (*complete_callback
)(void *arg
),
999 void *complete_callback_data
)
1001 return dispc
.update_mode
== OMAPFB_UPDATE_DISABLED
? -ENODEV
: 0;
1004 static int mmap_kern(struct omapfb_mem_region
*region
)
1006 struct vm_struct
*kvma
;
1007 struct vm_area_struct vma
;
1009 unsigned long vaddr
;
1011 kvma
= get_vm_area(region
->size
, VM_IOREMAP
);
1013 dev_err(dispc
.fbdev
->dev
, "can't get kernel vm area\n");
1016 vma
.vm_mm
= &init_mm
;
1018 vaddr
= (unsigned long)kvma
->addr
;
1020 pgprot
= pgprot_writecombine(pgprot_kernel
);
1021 vma
.vm_start
= vaddr
;
1022 vma
.vm_end
= vaddr
+ region
->size
;
1023 if (io_remap_pfn_range(&vma
, vaddr
, region
->paddr
>> PAGE_SHIFT
,
1024 region
->size
, pgprot
) < 0) {
1025 dev_err(dispc
.fbdev
->dev
, "kernel mmap for FBMEM failed\n");
1028 region
->vaddr
= (void *)vaddr
;
1033 static void mmap_user_open(struct vm_area_struct
*vma
)
1035 int plane
= (int)vma
->vm_private_data
;
1037 atomic_inc(&dispc
.map_count
[plane
]);
1040 static void mmap_user_close(struct vm_area_struct
*vma
)
1042 int plane
= (int)vma
->vm_private_data
;
1044 atomic_dec(&dispc
.map_count
[plane
]);
1047 static const struct vm_operations_struct mmap_user_ops
= {
1048 .open
= mmap_user_open
,
1049 .close
= mmap_user_close
,
1052 static int omap_dispc_mmap_user(struct fb_info
*info
,
1053 struct vm_area_struct
*vma
)
1055 struct omapfb_plane_struct
*plane
= info
->par
;
1057 unsigned long start
;
1060 if (vma
->vm_end
- vma
->vm_start
== 0)
1062 if (vma
->vm_pgoff
> (~0UL >> PAGE_SHIFT
))
1064 off
= vma
->vm_pgoff
<< PAGE_SHIFT
;
1066 start
= info
->fix
.smem_start
;
1067 len
= info
->fix
.smem_len
;
1070 if ((vma
->vm_end
- vma
->vm_start
+ off
) > len
)
1073 vma
->vm_pgoff
= off
>> PAGE_SHIFT
;
1074 vma
->vm_flags
|= VM_IO
| VM_RESERVED
;
1075 vma
->vm_page_prot
= pgprot_writecombine(vma
->vm_page_prot
);
1076 vma
->vm_ops
= &mmap_user_ops
;
1077 vma
->vm_private_data
= (void *)plane
->idx
;
1078 if (io_remap_pfn_range(vma
, vma
->vm_start
, off
>> PAGE_SHIFT
,
1079 vma
->vm_end
- vma
->vm_start
, vma
->vm_page_prot
))
1081 /* vm_ops.open won't be called for mmap itself. */
1082 atomic_inc(&dispc
.map_count
[plane
->idx
]);
1086 static void unmap_kern(struct omapfb_mem_region
*region
)
1088 vunmap(region
->vaddr
);
1091 static int alloc_palette_ram(void)
1093 dispc
.palette_vaddr
= dma_alloc_writecombine(dispc
.fbdev
->dev
,
1094 MAX_PALETTE_SIZE
, &dispc
.palette_paddr
, GFP_KERNEL
);
1095 if (dispc
.palette_vaddr
== NULL
) {
1096 dev_err(dispc
.fbdev
->dev
, "failed to alloc palette memory\n");
1103 static void free_palette_ram(void)
1105 dma_free_writecombine(dispc
.fbdev
->dev
, MAX_PALETTE_SIZE
,
1106 dispc
.palette_vaddr
, dispc
.palette_paddr
);
1109 static int alloc_fbmem(struct omapfb_mem_region
*region
)
1111 region
->vaddr
= dma_alloc_writecombine(dispc
.fbdev
->dev
,
1112 region
->size
, ®ion
->paddr
, GFP_KERNEL
);
1114 if (region
->vaddr
== NULL
) {
1115 dev_err(dispc
.fbdev
->dev
, "unable to allocate FB DMA memory\n");
1122 static void free_fbmem(struct omapfb_mem_region
*region
)
1124 dma_free_writecombine(dispc
.fbdev
->dev
, region
->size
,
1125 region
->vaddr
, region
->paddr
);
1128 static struct resmap
*init_resmap(unsigned long start
, size_t size
)
1131 struct resmap
*res_map
;
1133 page_cnt
= PAGE_ALIGN(size
) / PAGE_SIZE
;
1135 kzalloc(sizeof(struct resmap
) + RESMAP_SIZE(page_cnt
), GFP_KERNEL
);
1136 if (res_map
== NULL
)
1138 res_map
->start
= start
;
1139 res_map
->page_cnt
= page_cnt
;
1140 res_map
->map
= (unsigned long *)(res_map
+ 1);
1144 static void cleanup_resmap(struct resmap
*res_map
)
1149 static inline int resmap_mem_type(unsigned long start
)
1151 if (start
>= OMAP2_SRAM_START
&&
1152 start
< OMAP2_SRAM_START
+ OMAP2_SRAM_SIZE
)
1153 return OMAPFB_MEMTYPE_SRAM
;
1155 return OMAPFB_MEMTYPE_SDRAM
;
1158 static inline int resmap_page_reserved(struct resmap
*res_map
, unsigned page_nr
)
1160 return *RESMAP_PTR(res_map
, page_nr
) & RESMAP_MASK(page_nr
) ? 1 : 0;
1163 static inline void resmap_reserve_page(struct resmap
*res_map
, unsigned page_nr
)
1165 BUG_ON(resmap_page_reserved(res_map
, page_nr
));
1166 *RESMAP_PTR(res_map
, page_nr
) |= RESMAP_MASK(page_nr
);
1169 static inline void resmap_free_page(struct resmap
*res_map
, unsigned page_nr
)
1171 BUG_ON(!resmap_page_reserved(res_map
, page_nr
));
1172 *RESMAP_PTR(res_map
, page_nr
) &= ~RESMAP_MASK(page_nr
);
1175 static void resmap_reserve_region(unsigned long start
, size_t size
)
1178 struct resmap
*res_map
;
1179 unsigned start_page
;
1184 mtype
= resmap_mem_type(start
);
1185 res_map
= dispc
.res_map
[mtype
];
1186 dev_dbg(dispc
.fbdev
->dev
, "reserve mem type %d start %08lx size %d\n",
1187 mtype
, start
, size
);
1188 start_page
= (start
- res_map
->start
) / PAGE_SIZE
;
1189 end_page
= start_page
+ PAGE_ALIGN(size
) / PAGE_SIZE
;
1190 for (i
= start_page
; i
< end_page
; i
++)
1191 resmap_reserve_page(res_map
, i
);
1194 static void resmap_free_region(unsigned long start
, size_t size
)
1196 struct resmap
*res_map
;
1197 unsigned start_page
;
1202 mtype
= resmap_mem_type(start
);
1203 res_map
= dispc
.res_map
[mtype
];
1204 dev_dbg(dispc
.fbdev
->dev
, "free mem type %d start %08lx size %d\n",
1205 mtype
, start
, size
);
1206 start_page
= (start
- res_map
->start
) / PAGE_SIZE
;
1207 end_page
= start_page
+ PAGE_ALIGN(size
) / PAGE_SIZE
;
1208 for (i
= start_page
; i
< end_page
; i
++)
1209 resmap_free_page(res_map
, i
);
1212 static unsigned long resmap_alloc_region(int mtype
, size_t size
)
1216 unsigned start_page
;
1217 unsigned long start
;
1218 struct resmap
*res_map
= dispc
.res_map
[mtype
];
1220 BUG_ON(mtype
>= DISPC_MEMTYPE_NUM
|| res_map
== NULL
|| !size
);
1222 size
= PAGE_ALIGN(size
) / PAGE_SIZE
;
1225 for (i
= 0; i
< res_map
->page_cnt
; i
++) {
1226 if (resmap_page_reserved(res_map
, i
)) {
1229 } else if (++total
== size
)
1235 start
= res_map
->start
+ start_page
* PAGE_SIZE
;
1236 resmap_reserve_region(start
, size
* PAGE_SIZE
);
1241 /* Note that this will only work for user mappings, we don't deal with
1242 * kernel mappings here, so fbcon will keep using the old region.
1244 static int omap_dispc_setup_mem(int plane
, size_t size
, int mem_type
,
1245 unsigned long *paddr
)
1247 struct omapfb_mem_region
*rg
;
1248 unsigned long new_addr
= 0;
1250 if ((unsigned)plane
> dispc
.mem_desc
.region_cnt
)
1252 if (mem_type
>= DISPC_MEMTYPE_NUM
)
1254 if (dispc
.res_map
[mem_type
] == NULL
)
1256 rg
= &dispc
.mem_desc
.region
[plane
];
1257 if (size
== rg
->size
&& mem_type
== rg
->type
)
1259 if (atomic_read(&dispc
.map_count
[plane
]))
1262 resmap_free_region(rg
->paddr
, rg
->size
);
1264 new_addr
= resmap_alloc_region(mem_type
, size
);
1266 /* Reallocate old region. */
1267 resmap_reserve_region(rg
->paddr
, rg
->size
);
1271 rg
->paddr
= new_addr
;
1273 rg
->type
= mem_type
;
1280 static int setup_fbmem(struct omapfb_mem_desc
*req_md
)
1282 struct omapfb_mem_region
*rg
;
1285 unsigned long mem_start
[DISPC_MEMTYPE_NUM
];
1286 unsigned long mem_end
[DISPC_MEMTYPE_NUM
];
1288 if (!req_md
->region_cnt
) {
1289 dev_err(dispc
.fbdev
->dev
, "no memory regions defined\n");
1293 rg
= &req_md
->region
[0];
1294 memset(mem_start
, 0xff, sizeof(mem_start
));
1295 memset(mem_end
, 0, sizeof(mem_end
));
1297 for (i
= 0; i
< req_md
->region_cnt
; i
++, rg
++) {
1301 if (rg
->vaddr
== NULL
) {
1303 if ((r
= mmap_kern(rg
)) < 0)
1307 if (rg
->type
!= OMAPFB_MEMTYPE_SDRAM
) {
1308 dev_err(dispc
.fbdev
->dev
,
1309 "unsupported memory type\n");
1312 rg
->alloc
= rg
->map
= 1;
1313 if ((r
= alloc_fbmem(rg
)) < 0)
1318 if (rg
->paddr
< mem_start
[mtype
])
1319 mem_start
[mtype
] = rg
->paddr
;
1320 if (rg
->paddr
+ rg
->size
> mem_end
[mtype
])
1321 mem_end
[mtype
] = rg
->paddr
+ rg
->size
;
1324 for (i
= 0; i
< DISPC_MEMTYPE_NUM
; i
++) {
1325 unsigned long start
;
1327 if (mem_end
[i
] == 0)
1329 start
= mem_start
[i
];
1330 size
= mem_end
[i
] - start
;
1331 dispc
.res_map
[i
] = init_resmap(start
, size
);
1333 if (dispc
.res_map
[i
] == NULL
)
1335 /* Initial state is that everything is reserved. This
1336 * includes possible holes as well, which will never be
1339 resmap_reserve_region(start
, size
);
1342 dispc
.mem_desc
= *req_md
;
1346 for (i
= 0; i
< DISPC_MEMTYPE_NUM
; i
++) {
1347 if (dispc
.res_map
[i
] != NULL
)
1348 cleanup_resmap(dispc
.res_map
[i
]);
1353 static void cleanup_fbmem(void)
1355 struct omapfb_mem_region
*rg
;
1358 for (i
= 0; i
< DISPC_MEMTYPE_NUM
; i
++) {
1359 if (dispc
.res_map
[i
] != NULL
)
1360 cleanup_resmap(dispc
.res_map
[i
]);
1362 rg
= &dispc
.mem_desc
.region
[0];
1363 for (i
= 0; i
< dispc
.mem_desc
.region_cnt
; i
++, rg
++) {
1373 static int omap_dispc_init(struct omapfb_device
*fbdev
, int ext_mode
,
1374 struct omapfb_mem_desc
*req_vram
)
1378 struct lcd_panel
*panel
= fbdev
->panel
;
1379 void __iomem
*ram_fw_base
;
1384 memset(&dispc
, 0, sizeof(dispc
));
1386 dispc
.base
= ioremap(DISPC_BASE
, SZ_1K
);
1388 dev_err(fbdev
->dev
, "can't ioremap DISPC\n");
1392 dispc
.fbdev
= fbdev
;
1393 dispc
.ext_mode
= ext_mode
;
1395 init_completion(&dispc
.frame_done
);
1397 if ((r
= get_dss_clocks()) < 0)
1400 enable_lcd_clocks(1);
1402 #ifdef CONFIG_FB_OMAP_BOOTLOADER_INIT
1403 l
= dispc_read_reg(DISPC_CONTROL
);
1406 pr_info("omapfb: skipping hardware initialization\n");
1412 /* Reset monitoring works only w/ the 54M clk */
1413 enable_digit_clocks(1);
1416 MOD_REG_FLD(DISPC_SYSCONFIG
, 1 << 1, 1 << 1);
1418 while (!(dispc_read_reg(DISPC_SYSSTATUS
) & 1)) {
1420 dev_err(dispc
.fbdev
->dev
, "soft reset failed\n");
1422 enable_digit_clocks(0);
1427 enable_digit_clocks(0);
1430 /* Enable smart standby/idle, autoidle and wakeup */
1431 l
= dispc_read_reg(DISPC_SYSCONFIG
);
1432 l
&= ~((3 << 12) | (3 << 3));
1433 l
|= (2 << 12) | (2 << 3) | (1 << 2) | (1 << 0);
1434 dispc_write_reg(DISPC_SYSCONFIG
, l
);
1435 omap_writel(1 << 0, DSS_BASE
+ DSS_SYSCONFIG
);
1437 /* Set functional clock autogating */
1438 l
= dispc_read_reg(DISPC_CONFIG
);
1440 dispc_write_reg(DISPC_CONFIG
, l
);
1442 l
= dispc_read_reg(DISPC_IRQSTATUS
);
1443 dispc_write_reg(DISPC_IRQSTATUS
, l
);
1447 if ((r
= request_irq(INT_24XX_DSS_IRQ
, omap_dispc_irq_handler
,
1448 0, MODULE_NAME
, fbdev
)) < 0) {
1449 dev_err(dispc
.fbdev
->dev
, "can't get DSS IRQ\n");
1453 /* L3 firewall setting: enable access to OCM RAM */
1454 ram_fw_base
= ioremap(0x68005000, SZ_1K
);
1456 dev_err(dispc
.fbdev
->dev
, "Cannot ioremap to enable OCM RAM\n");
1459 __raw_writel(0x402000b0, ram_fw_base
+ 0xa0);
1460 iounmap(ram_fw_base
);
1462 if ((r
= alloc_palette_ram()) < 0)
1465 if ((r
= setup_fbmem(req_vram
)) < 0)
1469 for (i
= 0; i
< dispc
.mem_desc
.region_cnt
; i
++) {
1470 memset(dispc
.mem_desc
.region
[i
].vaddr
, 0,
1471 dispc
.mem_desc
.region
[i
].size
);
1474 /* Set logic clock to fck, pixel clock to fck/2 for now */
1475 MOD_REG_FLD(DISPC_DIVISOR
, FLD_MASK(16, 8), 1 << 16);
1476 MOD_REG_FLD(DISPC_DIVISOR
, FLD_MASK(0, 8), 2 << 0);
1478 setup_plane_fifo(0, ext_mode
);
1479 setup_plane_fifo(1, ext_mode
);
1480 setup_plane_fifo(2, ext_mode
);
1482 setup_color_conv_coef();
1484 set_lcd_tft_mode(panel
->config
& OMAP_LCDC_PANEL_TFT
);
1485 set_load_mode(DISPC_LOAD_FRAME_ONLY
);
1488 set_lcd_data_lines(panel
->data_lines
);
1489 omap_dispc_set_lcd_size(panel
->x_res
, panel
->y_res
);
1492 set_lcd_data_lines(panel
->bpp
);
1493 enable_rfbi_mode(ext_mode
);
1496 l
= dispc_read_reg(DISPC_REVISION
);
1497 pr_info("omapfb: DISPC version %d.%d initialized\n",
1498 l
>> 4 & 0x0f, l
& 0x0f);
1499 enable_lcd_clocks(0);
1505 free_irq(INT_24XX_DSS_IRQ
, fbdev
);
1507 enable_lcd_clocks(0);
1510 iounmap(dispc
.base
);
1514 static void omap_dispc_cleanup(void)
1518 omap_dispc_set_update_mode(OMAPFB_UPDATE_DISABLED
);
1519 /* This will also disable clocks that are on */
1520 for (i
= 0; i
< dispc
.mem_desc
.region_cnt
; i
++)
1521 omap_dispc_enable_plane(i
, 0);
1524 free_irq(INT_24XX_DSS_IRQ
, dispc
.fbdev
);
1526 iounmap(dispc
.base
);
1529 const struct lcd_ctrl omap2_int_ctrl
= {
1531 .init
= omap_dispc_init
,
1532 .cleanup
= omap_dispc_cleanup
,
1533 .get_caps
= omap_dispc_get_caps
,
1534 .set_update_mode
= omap_dispc_set_update_mode
,
1535 .get_update_mode
= omap_dispc_get_update_mode
,
1536 .update_window
= omap_dispc_update_window
,
1537 .suspend
= omap_dispc_suspend
,
1538 .resume
= omap_dispc_resume
,
1539 .setup_plane
= omap_dispc_setup_plane
,
1540 .setup_mem
= omap_dispc_setup_mem
,
1541 .set_scale
= omap_dispc_set_scale
,
1542 .enable_plane
= omap_dispc_enable_plane
,
1543 .set_color_key
= omap_dispc_set_color_key
,
1544 .get_color_key
= omap_dispc_get_color_key
,
1545 .mmap
= omap_dispc_mmap_user
,