2 * OMAP1 internal LCD controller
4 * Copyright (C) 2004 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/module.h>
22 #include <linux/device.h>
23 #include <linux/interrupt.h>
24 #include <linux/spinlock.h>
25 #include <linux/err.h>
28 #include <linux/dma-mapping.h>
29 #include <linux/vmalloc.h>
30 #include <linux/clk.h>
32 #include <asm/arch/dma.h>
33 #include <asm/arch/omapfb.h>
35 #include <asm/mach-types.h>
37 #define MODULE_NAME "lcdc"
39 #define OMAP_LCDC_BASE 0xfffec000
40 #define OMAP_LCDC_SIZE 256
41 #define OMAP_LCDC_IRQ INT_LCD_CTRL
43 #define OMAP_LCDC_CONTROL (OMAP_LCDC_BASE + 0x00)
44 #define OMAP_LCDC_TIMING0 (OMAP_LCDC_BASE + 0x04)
45 #define OMAP_LCDC_TIMING1 (OMAP_LCDC_BASE + 0x08)
46 #define OMAP_LCDC_TIMING2 (OMAP_LCDC_BASE + 0x0c)
47 #define OMAP_LCDC_STATUS (OMAP_LCDC_BASE + 0x10)
48 #define OMAP_LCDC_SUBPANEL (OMAP_LCDC_BASE + 0x14)
49 #define OMAP_LCDC_LINE_INT (OMAP_LCDC_BASE + 0x18)
50 #define OMAP_LCDC_DISPLAY_STATUS (OMAP_LCDC_BASE + 0x1c)
52 #define OMAP_LCDC_STAT_DONE (1 << 0)
53 #define OMAP_LCDC_STAT_VSYNC (1 << 1)
54 #define OMAP_LCDC_STAT_SYNC_LOST (1 << 2)
55 #define OMAP_LCDC_STAT_ABC (1 << 3)
56 #define OMAP_LCDC_STAT_LINE_INT (1 << 4)
57 #define OMAP_LCDC_STAT_FUF (1 << 5)
58 #define OMAP_LCDC_STAT_LOADED_PALETTE (1 << 6)
60 #define OMAP_LCDC_CTRL_LCD_EN (1 << 0)
61 #define OMAP_LCDC_CTRL_LCD_TFT (1 << 7)
62 #define OMAP_LCDC_CTRL_LINE_IRQ_CLR_SEL (1 << 10)
64 #define OMAP_LCDC_IRQ_VSYNC (1 << 2)
65 #define OMAP_LCDC_IRQ_DONE (1 << 3)
66 #define OMAP_LCDC_IRQ_LOADED_PALETTE (1 << 4)
67 #define OMAP_LCDC_IRQ_LINE_NIRQ (1 << 5)
68 #define OMAP_LCDC_IRQ_LINE (1 << 6)
69 #define OMAP_LCDC_IRQ_MASK (((1 << 5) - 1) << 2)
71 #define MAX_PALETTE_SIZE PAGE_SIZE
74 OMAP_LCDC_LOAD_PALETTE
,
76 OMAP_LCDC_LOAD_PALETTE_AND_FRAME
79 static struct omap_lcd_controller
{
80 enum omapfb_update_mode update_mode
;
83 unsigned long frame_offset
;
88 enum omapfb_color_format color_mode
;
91 dma_addr_t palette_phys
;
95 unsigned int irq_mask
;
96 struct completion last_frame_complete
;
97 struct completion palette_load_complete
;
99 struct omapfb_device
*fbdev
;
101 void (*dma_callback
)(void *data
);
102 void *dma_callback_data
;
105 dma_addr_t vram_phys
;
107 unsigned long vram_size
;
110 static void inline enable_irqs(int mask
)
112 lcdc
.irq_mask
|= mask
;
115 static void inline disable_irqs(int mask
)
117 lcdc
.irq_mask
&= ~mask
;
120 static void set_load_mode(enum lcdc_load_mode mode
)
124 l
= omap_readl(OMAP_LCDC_CONTROL
);
127 case OMAP_LCDC_LOAD_PALETTE
:
130 case OMAP_LCDC_LOAD_FRAME
:
133 case OMAP_LCDC_LOAD_PALETTE_AND_FRAME
:
138 omap_writel(l
, OMAP_LCDC_CONTROL
);
141 static void enable_controller(void)
145 l
= omap_readl(OMAP_LCDC_CONTROL
);
146 l
|= OMAP_LCDC_CTRL_LCD_EN
;
147 l
&= ~OMAP_LCDC_IRQ_MASK
;
148 l
|= lcdc
.irq_mask
| OMAP_LCDC_IRQ_DONE
; /* enabled IRQs */
149 omap_writel(l
, OMAP_LCDC_CONTROL
);
152 static void disable_controller_async(void)
157 l
= omap_readl(OMAP_LCDC_CONTROL
);
158 mask
= OMAP_LCDC_CTRL_LCD_EN
| OMAP_LCDC_IRQ_MASK
;
160 * Preserve the DONE mask, since we still want to get the
161 * final DONE irq. It will be disabled in the IRQ handler.
163 mask
&= ~OMAP_LCDC_IRQ_DONE
;
165 omap_writel(l
, OMAP_LCDC_CONTROL
);
168 static void disable_controller(void)
170 init_completion(&lcdc
.last_frame_complete
);
171 disable_controller_async();
172 if (!wait_for_completion_timeout(&lcdc
.last_frame_complete
,
173 msecs_to_jiffies(500)))
174 dev_err(lcdc
.fbdev
->dev
, "timeout waiting for FRAME DONE\n");
177 static void reset_controller(u32 status
)
179 static unsigned long reset_count
;
180 static unsigned long last_jiffies
;
182 disable_controller_async();
184 if (reset_count
== 1 || time_after(jiffies
, last_jiffies
+ HZ
)) {
185 dev_err(lcdc
.fbdev
->dev
,
186 "resetting (status %#010x,reset count %lu)\n",
187 status
, reset_count
);
188 last_jiffies
= jiffies
;
190 if (reset_count
< 100) {
194 dev_err(lcdc
.fbdev
->dev
,
195 "too many reset attempts, giving up.\n");
200 * Configure the LCD DMA according to the current mode specified by parameters
201 * in lcdc.fbdev and fbdev->var.
203 static void setup_lcd_dma(void)
205 static const int dma_elem_type
[] = {
207 OMAP_DMA_DATA_TYPE_S8
,
208 OMAP_DMA_DATA_TYPE_S16
,
210 OMAP_DMA_DATA_TYPE_S32
,
212 struct omapfb_plane_struct
*plane
= lcdc
.fbdev
->fb_info
[0]->par
;
213 struct fb_var_screeninfo
*var
= &lcdc
.fbdev
->fb_info
[0]->var
;
215 int esize
, xelem
, yelem
;
217 src
= lcdc
.vram_phys
+ lcdc
.frame_offset
;
219 switch (var
->rotate
) {
221 if (plane
->info
.mirror
|| (src
& 3) ||
222 lcdc
.color_mode
== OMAPFB_COLOR_YUV420
||
227 xelem
= lcdc
.xres
* lcdc
.bpp
/ 8 / esize
;
233 if (cpu_is_omap15xx()) {
237 xelem
= lcdc
.yres
* lcdc
.bpp
/ 16;
245 dev_dbg(lcdc
.fbdev
->dev
,
246 "setup_dma: src %#010lx esize %d xelem %d yelem %d\n",
247 src
, esize
, xelem
, yelem
);
249 omap_set_lcd_dma_b1(src
, xelem
, yelem
, dma_elem_type
[esize
]);
250 if (!cpu_is_omap15xx()) {
254 * YUV support is only for external mode when we have the
255 * YUV window embedded in a 16bpp frame buffer.
257 if (lcdc
.color_mode
== OMAPFB_COLOR_YUV420
)
259 /* Set virtual xres elem size */
260 omap_set_lcd_dma_b1_vxres(
261 lcdc
.screen_width
* bpp
/ 8 / esize
);
262 /* Setup transformations */
263 omap_set_lcd_dma_b1_rotation(var
->rotate
);
264 omap_set_lcd_dma_b1_mirror(plane
->info
.mirror
);
266 omap_setup_lcd_dma();
269 static irqreturn_t
lcdc_irq_handler(int irq
, void *dev_id
)
273 status
= omap_readl(OMAP_LCDC_STATUS
);
275 if (status
& (OMAP_LCDC_STAT_FUF
| OMAP_LCDC_STAT_SYNC_LOST
))
276 reset_controller(status
);
278 if (status
& OMAP_LCDC_STAT_DONE
) {
282 * Disable IRQ_DONE. The status bit will be cleared
283 * only when the controller is reenabled and we don't
284 * want to get more interrupts.
286 l
= omap_readl(OMAP_LCDC_CONTROL
);
287 l
&= ~OMAP_LCDC_IRQ_DONE
;
288 omap_writel(l
, OMAP_LCDC_CONTROL
);
289 complete(&lcdc
.last_frame_complete
);
291 if (status
& OMAP_LCDC_STAT_LOADED_PALETTE
) {
292 disable_controller_async();
293 complete(&lcdc
.palette_load_complete
);
298 * Clear these interrupt status bits.
299 * Sync_lost, FUF bits were cleared by disabling the LCD controller
300 * LOADED_PALETTE can be cleared this way only in palette only
301 * load mode. In other load modes it's cleared by disabling the
304 status
&= ~(OMAP_LCDC_STAT_VSYNC
|
305 OMAP_LCDC_STAT_LOADED_PALETTE
|
307 OMAP_LCDC_STAT_LINE_INT
);
308 omap_writel(status
, OMAP_LCDC_STATUS
);
313 * Change to a new video mode. We defer this to a later time to avoid any
314 * flicker and not to mess up the current LCD DMA context. For this we disable
315 * the LCD controler, which will generate a DONE irq after the last frame has
316 * been transferred. Then it'll be safe to reconfigure both the LCD controller
317 * as well as the LCD DMA.
319 static int omap_lcdc_setup_plane(int plane
, int channel_out
,
320 unsigned long offset
, int screen_width
,
321 int pos_x
, int pos_y
, int width
, int height
,
324 struct fb_var_screeninfo
*var
= &lcdc
.fbdev
->fb_info
[0]->var
;
325 struct lcd_panel
*panel
= lcdc
.fbdev
->panel
;
328 if (var
->rotate
== 0) {
329 rot_x
= panel
->x_res
;
330 rot_y
= panel
->y_res
;
332 rot_x
= panel
->y_res
;
333 rot_y
= panel
->x_res
;
335 if (plane
!= 0 || channel_out
!= 0 || pos_x
!= 0 || pos_y
!= 0 ||
336 width
> rot_x
|| height
> rot_y
) {
338 dev_dbg(lcdc
.fbdev
->dev
,
339 "invalid plane params plane %d pos_x %d pos_y %d "
340 "w %d h %d\n", plane
, pos_x
, pos_y
, width
, height
);
345 lcdc
.frame_offset
= offset
;
348 lcdc
.screen_width
= screen_width
;
349 lcdc
.color_mode
= color_mode
;
351 switch (color_mode
) {
352 case OMAPFB_COLOR_CLUT_8BPP
:
354 lcdc
.palette_code
= 0x3000;
355 lcdc
.palette_size
= 512;
357 case OMAPFB_COLOR_RGB565
:
359 lcdc
.palette_code
= 0x4000;
360 lcdc
.palette_size
= 32;
362 case OMAPFB_COLOR_RGB444
:
364 lcdc
.palette_code
= 0x4000;
365 lcdc
.palette_size
= 32;
367 case OMAPFB_COLOR_YUV420
:
373 case OMAPFB_COLOR_YUV422
:
380 /* FIXME: other BPPs.
381 * bpp1: code 0, size 256
382 * bpp2: code 0x1000 size 256
383 * bpp4: code 0x2000 size 256
384 * bpp12: code 0x4000 size 32
386 dev_dbg(lcdc
.fbdev
->dev
, "invalid color mode %d\n", color_mode
);
396 if (lcdc
.update_mode
== OMAPFB_AUTO_UPDATE
) {
397 disable_controller();
406 static int omap_lcdc_enable_plane(int plane
, int enable
)
408 dev_dbg(lcdc
.fbdev
->dev
,
409 "plane %d enable %d update_mode %d ext_mode %d\n",
410 plane
, enable
, lcdc
.update_mode
, lcdc
.ext_mode
);
411 if (plane
!= OMAPFB_PLANE_GFX
)
418 * Configure the LCD DMA for a palette load operation and do the palette
419 * downloading synchronously. We don't use the frame+palette load mode of
420 * the controller, since the palette can always be downloaded seperately.
422 static void load_palette(void)
426 palette
= (u16
*)lcdc
.palette_virt
;
428 *(u16
*)palette
&= 0x0fff;
429 *(u16
*)palette
|= lcdc
.palette_code
;
431 omap_set_lcd_dma_b1(lcdc
.palette_phys
,
432 lcdc
.palette_size
/ 4 + 1, 1, OMAP_DMA_DATA_TYPE_S32
);
434 omap_set_lcd_dma_single_transfer(1);
435 omap_setup_lcd_dma();
437 init_completion(&lcdc
.palette_load_complete
);
438 enable_irqs(OMAP_LCDC_IRQ_LOADED_PALETTE
);
439 set_load_mode(OMAP_LCDC_LOAD_PALETTE
);
441 if (!wait_for_completion_timeout(&lcdc
.palette_load_complete
,
442 msecs_to_jiffies(500)))
443 dev_err(lcdc
.fbdev
->dev
, "timeout waiting for FRAME DONE\n");
444 /* The controller gets disabled in the irq handler */
445 disable_irqs(OMAP_LCDC_IRQ_LOADED_PALETTE
);
448 omap_set_lcd_dma_single_transfer(lcdc
.ext_mode
);
451 /* Used only in internal controller mode */
452 static int omap_lcdc_setcolreg(u_int regno
, u16 red
, u16 green
, u16 blue
,
453 u16 transp
, int update_hw_pal
)
457 if (lcdc
.color_mode
!= OMAPFB_COLOR_CLUT_8BPP
|| regno
> 255)
460 palette
= (u16
*)lcdc
.palette_virt
;
462 palette
[regno
] &= ~0x0fff;
463 palette
[regno
] |= ((red
>> 12) << 8) | ((green
>> 12) << 4 ) |
467 disable_controller();
471 set_load_mode(OMAP_LCDC_LOAD_FRAME
);
478 static void calc_ck_div(int is_tft
, int pck
, int *pck_div
)
483 lck
= clk_get_rate(lcdc
.lcd_ck
);
484 *pck_div
= (lck
+ pck
- 1) / pck
;
486 *pck_div
= max(2, *pck_div
);
488 *pck_div
= max(3, *pck_div
);
489 if (*pck_div
> 255) {
490 /* FIXME: try to adjust logic clock divider as well */
492 dev_warn(lcdc
.fbdev
->dev
, "pixclock %d kHz too low.\n",
497 static void inline setup_regs(void)
500 struct lcd_panel
*panel
= lcdc
.fbdev
->panel
;
501 int is_tft
= panel
->config
& OMAP_LCDC_PANEL_TFT
;
505 l
= omap_readl(OMAP_LCDC_CONTROL
);
506 l
&= ~OMAP_LCDC_CTRL_LCD_TFT
;
507 l
|= is_tft
? OMAP_LCDC_CTRL_LCD_TFT
: 0;
508 #ifdef CONFIG_MACH_OMAP_PALMTE
509 /* FIXME:if (machine_is_omap_palmte()) { */
510 /* PalmTE uses alternate TFT setting in 8BPP mode */
511 l
|= (is_tft
&& panel
->bpp
== 8) ? 0x810000 : 0;
514 omap_writel(l
, OMAP_LCDC_CONTROL
);
516 l
= omap_readl(OMAP_LCDC_TIMING2
);
517 l
&= ~(((1 << 6) - 1) << 20);
518 l
|= (panel
->config
& OMAP_LCDC_SIGNAL_MASK
) << 20;
519 omap_writel(l
, OMAP_LCDC_TIMING2
);
521 l
= panel
->x_res
- 1;
522 l
|= (panel
->hsw
- 1) << 10;
523 l
|= (panel
->hfp
- 1) << 16;
524 l
|= (panel
->hbp
- 1) << 24;
525 omap_writel(l
, OMAP_LCDC_TIMING0
);
527 l
= panel
->y_res
- 1;
528 l
|= (panel
->vsw
- 1) << 10;
529 l
|= panel
->vfp
<< 16;
530 l
|= panel
->vbp
<< 24;
531 omap_writel(l
, OMAP_LCDC_TIMING1
);
533 l
= omap_readl(OMAP_LCDC_TIMING2
);
536 lck
= clk_get_rate(lcdc
.lcd_ck
);
539 calc_ck_div(is_tft
, panel
->pixel_clock
* 1000, &pcd
);
541 dev_warn(lcdc
.fbdev
->dev
,
542 "Pixel clock divider value is obsolete.\n"
543 "Try to set pixel_clock to %lu and pcd to 0 "
544 "in drivers/video/omap/lcd_%s.c and submit a patch.\n",
545 lck
/ panel
->pcd
/ 1000, panel
->name
);
550 l
|= panel
->acb
<< 8;
551 omap_writel(l
, OMAP_LCDC_TIMING2
);
553 /* update panel info with the exact clock */
554 panel
->pixel_clock
= lck
/ pcd
/ 1000;
558 * Configure the LCD controller, download the color palette and start a looped
559 * DMA transfer of the frame image data. Called only in internal
562 static int omap_lcdc_set_update_mode(enum omapfb_update_mode mode
)
566 if (mode
!= lcdc
.update_mode
) {
568 case OMAPFB_AUTO_UPDATE
:
572 /* Setup and start LCD DMA */
575 set_load_mode(OMAP_LCDC_LOAD_FRAME
);
576 enable_irqs(OMAP_LCDC_IRQ_DONE
);
577 /* This will start the actual DMA transfer */
579 lcdc
.update_mode
= mode
;
581 case OMAPFB_UPDATE_DISABLED
:
582 disable_controller();
584 lcdc
.update_mode
= mode
;
594 static enum omapfb_update_mode
omap_lcdc_get_update_mode(void)
596 return lcdc
.update_mode
;
599 /* PM code called only in internal controller mode */
600 static void omap_lcdc_suspend(void)
602 if (lcdc
.update_mode
== OMAPFB_AUTO_UPDATE
) {
603 disable_controller();
608 static void omap_lcdc_resume(void)
610 if (lcdc
.update_mode
== OMAPFB_AUTO_UPDATE
) {
614 set_load_mode(OMAP_LCDC_LOAD_FRAME
);
615 enable_irqs(OMAP_LCDC_IRQ_DONE
);
620 static void omap_lcdc_get_caps(int plane
, struct omapfb_caps
*caps
)
625 int omap_lcdc_set_dma_callback(void (*callback
)(void *data
), void *data
)
627 BUG_ON(callback
== NULL
);
629 if (lcdc
.dma_callback
)
632 lcdc
.dma_callback
= callback
;
633 lcdc
.dma_callback_data
= data
;
637 EXPORT_SYMBOL(omap_lcdc_set_dma_callback
);
639 void omap_lcdc_free_dma_callback(void)
641 lcdc
.dma_callback
= NULL
;
643 EXPORT_SYMBOL(omap_lcdc_free_dma_callback
);
645 static void lcdc_dma_handler(u16 status
, void *data
)
647 if (lcdc
.dma_callback
)
648 lcdc
.dma_callback(lcdc
.dma_callback_data
);
651 static int mmap_kern(void)
653 struct vm_struct
*kvma
;
654 struct vm_area_struct vma
;
658 kvma
= get_vm_area(lcdc
.vram_size
, VM_IOREMAP
);
660 dev_err(lcdc
.fbdev
->dev
, "can't get kernel vm area\n");
663 vma
.vm_mm
= &init_mm
;
665 vaddr
= (unsigned long)kvma
->addr
;
666 vma
.vm_start
= vaddr
;
667 vma
.vm_end
= vaddr
+ lcdc
.vram_size
;
669 pgprot
= pgprot_writecombine(pgprot_kernel
);
670 if (io_remap_pfn_range(&vma
, vaddr
,
671 lcdc
.vram_phys
>> PAGE_SHIFT
,
672 lcdc
.vram_size
, pgprot
) < 0) {
673 dev_err(lcdc
.fbdev
->dev
, "kernel mmap for FB memory failed\n");
677 lcdc
.vram_virt
= (void *)vaddr
;
682 static void unmap_kern(void)
684 vunmap(lcdc
.vram_virt
);
687 static int alloc_palette_ram(void)
689 lcdc
.palette_virt
= dma_alloc_writecombine(lcdc
.fbdev
->dev
,
690 MAX_PALETTE_SIZE
, &lcdc
.palette_phys
, GFP_KERNEL
);
691 if (lcdc
.palette_virt
== NULL
) {
692 dev_err(lcdc
.fbdev
->dev
, "failed to alloc palette memory\n");
695 memset(lcdc
.palette_virt
, 0, MAX_PALETTE_SIZE
);
700 static void free_palette_ram(void)
702 dma_free_writecombine(lcdc
.fbdev
->dev
, MAX_PALETTE_SIZE
,
703 lcdc
.palette_virt
, lcdc
.palette_phys
);
706 static int alloc_fbmem(struct omapfb_mem_region
*region
)
710 struct lcd_panel
*panel
= lcdc
.fbdev
->panel
;
715 frame_size
= PAGE_ALIGN(panel
->x_res
* bpp
/ 8 * panel
->y_res
);
716 if (region
->size
> frame_size
)
717 frame_size
= region
->size
;
718 lcdc
.vram_size
= frame_size
;
719 lcdc
.vram_virt
= dma_alloc_writecombine(lcdc
.fbdev
->dev
,
720 lcdc
.vram_size
, &lcdc
.vram_phys
, GFP_KERNEL
);
721 if (lcdc
.vram_virt
== NULL
) {
722 dev_err(lcdc
.fbdev
->dev
, "unable to allocate FB DMA memory\n");
725 region
->size
= frame_size
;
726 region
->paddr
= lcdc
.vram_phys
;
727 region
->vaddr
= lcdc
.vram_virt
;
730 memset(lcdc
.vram_virt
, 0, lcdc
.vram_size
);
735 static void free_fbmem(void)
737 dma_free_writecombine(lcdc
.fbdev
->dev
, lcdc
.vram_size
,
738 lcdc
.vram_virt
, lcdc
.vram_phys
);
741 static int setup_fbmem(struct omapfb_mem_desc
*req_md
)
745 if (!req_md
->region_cnt
) {
746 dev_err(lcdc
.fbdev
->dev
, "no memory regions defined\n");
750 if (req_md
->region_cnt
> 1) {
751 dev_err(lcdc
.fbdev
->dev
, "only one plane is supported\n");
752 req_md
->region_cnt
= 1;
755 if (req_md
->region
[0].paddr
== 0) {
756 lcdc
.fbmem_allocated
= 1;
757 if ((r
= alloc_fbmem(&req_md
->region
[0])) < 0)
762 lcdc
.vram_phys
= req_md
->region
[0].paddr
;
763 lcdc
.vram_size
= req_md
->region
[0].size
;
765 if ((r
= mmap_kern()) < 0)
768 dev_dbg(lcdc
.fbdev
->dev
, "vram at %08x size %08lx mapped to 0x%p\n",
769 lcdc
.vram_phys
, lcdc
.vram_size
, lcdc
.vram_virt
);
774 static void cleanup_fbmem(void)
776 if (lcdc
.fbmem_allocated
)
782 static int omap_lcdc_init(struct omapfb_device
*fbdev
, int ext_mode
,
783 struct omapfb_mem_desc
*req_vram
)
793 lcdc
.ext_mode
= ext_mode
;
796 omap_writel(l
, OMAP_LCDC_CONTROL
);
799 * According to errata some platforms have a clock rate limitiation
801 lcdc
.lcd_ck
= clk_get(NULL
, "lcd_ck");
802 if (IS_ERR(lcdc
.lcd_ck
)) {
803 dev_err(fbdev
->dev
, "unable to access LCD clock\n");
804 r
= PTR_ERR(lcdc
.lcd_ck
);
808 tc_ck
= clk_get(NULL
, "tc_ck");
810 dev_err(fbdev
->dev
, "unable to access TC clock\n");
815 rate
= clk_get_rate(tc_ck
);
818 if (machine_is_ams_delta())
820 if (machine_is_omap_h3())
822 r
= clk_set_rate(lcdc
.lcd_ck
, rate
);
824 dev_err(fbdev
->dev
, "failed to adjust LCD rate\n");
827 clk_enable(lcdc
.lcd_ck
);
829 r
= request_irq(OMAP_LCDC_IRQ
, lcdc_irq_handler
, 0, MODULE_NAME
, fbdev
);
831 dev_err(fbdev
->dev
, "unable to get IRQ\n");
835 r
= omap_request_lcd_dma(lcdc_dma_handler
, NULL
);
837 dev_err(fbdev
->dev
, "unable to get LCD DMA\n");
841 omap_set_lcd_dma_single_transfer(ext_mode
);
842 omap_set_lcd_dma_ext_controller(ext_mode
);
845 if ((r
= alloc_palette_ram()) < 0)
848 if ((r
= setup_fbmem(req_vram
)) < 0)
851 pr_info("omapfb: LCDC initialized\n");
860 free_irq(OMAP_LCDC_IRQ
, lcdc
.fbdev
);
862 clk_disable(lcdc
.lcd_ck
);
864 clk_put(lcdc
.lcd_ck
);
869 static void omap_lcdc_cleanup(void)
875 free_irq(OMAP_LCDC_IRQ
, lcdc
.fbdev
);
876 clk_disable(lcdc
.lcd_ck
);
877 clk_put(lcdc
.lcd_ck
);
880 const struct lcd_ctrl omap1_int_ctrl
= {
882 .init
= omap_lcdc_init
,
883 .cleanup
= omap_lcdc_cleanup
,
884 .get_caps
= omap_lcdc_get_caps
,
885 .set_update_mode
= omap_lcdc_set_update_mode
,
886 .get_update_mode
= omap_lcdc_get_update_mode
,
887 .update_window
= NULL
,
888 .suspend
= omap_lcdc_suspend
,
889 .resume
= omap_lcdc_resume
,
890 .setup_plane
= omap_lcdc_setup_plane
,
891 .enable_plane
= omap_lcdc_enable_plane
,
892 .setcolreg
= omap_lcdc_setcolreg
,