2 * SuperH Mobile LCDC Framebuffer
4 * Copyright (c) 2008 Magnus Damm
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/delay.h>
15 #include <linux/clk.h>
16 #include <linux/pm_runtime.h>
17 #include <linux/platform_device.h>
18 #include <linux/dma-mapping.h>
19 #include <linux/interrupt.h>
20 #include <linux/vmalloc.h>
21 #include <linux/ioctl.h>
22 #include <linux/slab.h>
23 #include <linux/console.h>
24 #include <linux/backlight.h>
25 #include <linux/gpio.h>
26 #include <video/sh_mobile_lcdc.h>
27 #include <asm/atomic.h>
29 #include "sh_mobile_lcdcfb.h"
31 #define SIDE_B_OFFSET 0x1000
32 #define MIRROR_OFFSET 0x2000
34 /* shared registers */
36 #define _LDDCKSTPR 0x414
39 #define _LDCNT1R 0x470
40 #define _LDCNT2R 0x474
41 #define _LDRCNTR 0x478
43 #define _LDDWD0R 0x800
48 /* shared registers and their order for context save/restore */
49 static int lcdc_shared_regs
[] = {
57 #define NR_SHARED_REGS ARRAY_SIZE(lcdc_shared_regs)
62 static unsigned long lcdc_offs_mainlcd
[NR_CH_REGS
] = {
81 static unsigned long lcdc_offs_sublcd
[NR_CH_REGS
] = {
99 #define START_LCDC 0x00000001
100 #define LCDC_RESET 0x00000100
101 #define DISPLAY_BEU 0x00000008
102 #define LCDC_ENABLE 0x00000001
103 #define LDINTR_FE 0x00000400
104 #define LDINTR_VSE 0x00000200
105 #define LDINTR_VEE 0x00000100
106 #define LDINTR_FS 0x00000004
107 #define LDINTR_VSS 0x00000002
108 #define LDINTR_VES 0x00000001
109 #define LDRCNTR_SRS 0x00020000
110 #define LDRCNTR_SRC 0x00010000
111 #define LDRCNTR_MRS 0x00000002
112 #define LDRCNTR_MRC 0x00000001
113 #define LDSR_MRS 0x00000100
115 static const struct fb_videomode default_720p
= {
130 .sync
= FB_SYNC_VERT_HIGH_ACT
| FB_SYNC_HOR_HIGH_ACT
,
133 struct sh_mobile_lcdc_priv
{
139 unsigned long lddckr
;
140 struct sh_mobile_lcdc_chan ch
[2];
141 struct notifier_block notifier
;
142 unsigned long saved_shared_regs
[NR_SHARED_REGS
];
144 int forced_bpp
; /* 2 channel LCDC must share bpp setting */
147 static bool banked(int reg_nr
)
166 static void lcdc_write_chan(struct sh_mobile_lcdc_chan
*chan
,
167 int reg_nr
, unsigned long data
)
169 iowrite32(data
, chan
->lcdc
->base
+ chan
->reg_offs
[reg_nr
]);
171 iowrite32(data
, chan
->lcdc
->base
+ chan
->reg_offs
[reg_nr
] +
175 static void lcdc_write_chan_mirror(struct sh_mobile_lcdc_chan
*chan
,
176 int reg_nr
, unsigned long data
)
178 iowrite32(data
, chan
->lcdc
->base
+ chan
->reg_offs
[reg_nr
] +
182 static unsigned long lcdc_read_chan(struct sh_mobile_lcdc_chan
*chan
,
185 return ioread32(chan
->lcdc
->base
+ chan
->reg_offs
[reg_nr
]);
188 static void lcdc_write(struct sh_mobile_lcdc_priv
*priv
,
189 unsigned long reg_offs
, unsigned long data
)
191 iowrite32(data
, priv
->base
+ reg_offs
);
194 static unsigned long lcdc_read(struct sh_mobile_lcdc_priv
*priv
,
195 unsigned long reg_offs
)
197 return ioread32(priv
->base
+ reg_offs
);
200 static void lcdc_wait_bit(struct sh_mobile_lcdc_priv
*priv
,
201 unsigned long reg_offs
,
202 unsigned long mask
, unsigned long until
)
204 while ((lcdc_read(priv
, reg_offs
) & mask
) != until
)
208 static int lcdc_chan_is_sublcd(struct sh_mobile_lcdc_chan
*chan
)
210 return chan
->cfg
.chan
== LCDC_CHAN_SUBLCD
;
213 static void lcdc_sys_write_index(void *handle
, unsigned long data
)
215 struct sh_mobile_lcdc_chan
*ch
= handle
;
217 lcdc_write(ch
->lcdc
, _LDDWD0R
, data
| 0x10000000);
218 lcdc_wait_bit(ch
->lcdc
, _LDSR
, 2, 0);
219 lcdc_write(ch
->lcdc
, _LDDWAR
, 1 | (lcdc_chan_is_sublcd(ch
) ? 2 : 0));
220 lcdc_wait_bit(ch
->lcdc
, _LDSR
, 2, 0);
223 static void lcdc_sys_write_data(void *handle
, unsigned long data
)
225 struct sh_mobile_lcdc_chan
*ch
= handle
;
227 lcdc_write(ch
->lcdc
, _LDDWD0R
, data
| 0x11000000);
228 lcdc_wait_bit(ch
->lcdc
, _LDSR
, 2, 0);
229 lcdc_write(ch
->lcdc
, _LDDWAR
, 1 | (lcdc_chan_is_sublcd(ch
) ? 2 : 0));
230 lcdc_wait_bit(ch
->lcdc
, _LDSR
, 2, 0);
233 static unsigned long lcdc_sys_read_data(void *handle
)
235 struct sh_mobile_lcdc_chan
*ch
= handle
;
237 lcdc_write(ch
->lcdc
, _LDDRDR
, 0x01000000);
238 lcdc_wait_bit(ch
->lcdc
, _LDSR
, 2, 0);
239 lcdc_write(ch
->lcdc
, _LDDRAR
, 1 | (lcdc_chan_is_sublcd(ch
) ? 2 : 0));
241 lcdc_wait_bit(ch
->lcdc
, _LDSR
, 2, 0);
243 return lcdc_read(ch
->lcdc
, _LDDRDR
) & 0x3ffff;
246 struct sh_mobile_lcdc_sys_bus_ops sh_mobile_lcdc_sys_bus_ops
= {
247 lcdc_sys_write_index
,
252 static void sh_mobile_lcdc_clk_on(struct sh_mobile_lcdc_priv
*priv
)
254 if (atomic_inc_and_test(&priv
->hw_usecnt
)) {
255 pm_runtime_get_sync(priv
->dev
);
257 clk_enable(priv
->dot_clk
);
261 static void sh_mobile_lcdc_clk_off(struct sh_mobile_lcdc_priv
*priv
)
263 if (atomic_sub_return(1, &priv
->hw_usecnt
) == -1) {
265 clk_disable(priv
->dot_clk
);
266 pm_runtime_put(priv
->dev
);
270 static int sh_mobile_lcdc_sginit(struct fb_info
*info
,
271 struct list_head
*pagelist
)
273 struct sh_mobile_lcdc_chan
*ch
= info
->par
;
274 unsigned int nr_pages_max
= info
->fix
.smem_len
>> PAGE_SHIFT
;
278 sg_init_table(ch
->sglist
, nr_pages_max
);
280 list_for_each_entry(page
, pagelist
, lru
)
281 sg_set_page(&ch
->sglist
[nr_pages
++], page
, PAGE_SIZE
, 0);
286 static void sh_mobile_lcdc_deferred_io(struct fb_info
*info
,
287 struct list_head
*pagelist
)
289 struct sh_mobile_lcdc_chan
*ch
= info
->par
;
290 struct sh_mobile_lcdc_board_cfg
*bcfg
= &ch
->cfg
.board_cfg
;
292 /* enable clocks before accessing hardware */
293 sh_mobile_lcdc_clk_on(ch
->lcdc
);
296 * It's possible to get here without anything on the pagelist via
297 * sh_mobile_lcdc_deferred_io_touch() or via a userspace fsync()
298 * invocation. In the former case, the acceleration routines are
299 * stepped in to when using the framebuffer console causing the
300 * workqueue to be scheduled without any dirty pages on the list.
302 * Despite this, a panel update is still needed given that the
303 * acceleration routines have their own methods for writing in
304 * that still need to be updated.
306 * The fsync() and empty pagelist case could be optimized for,
307 * but we don't bother, as any application exhibiting such
308 * behaviour is fundamentally broken anyways.
310 if (!list_empty(pagelist
)) {
311 unsigned int nr_pages
= sh_mobile_lcdc_sginit(info
, pagelist
);
313 /* trigger panel update */
314 dma_map_sg(info
->dev
, ch
->sglist
, nr_pages
, DMA_TO_DEVICE
);
315 if (bcfg
->start_transfer
)
316 bcfg
->start_transfer(bcfg
->board_data
, ch
,
317 &sh_mobile_lcdc_sys_bus_ops
);
318 lcdc_write_chan(ch
, LDSM2R
, 1);
319 dma_unmap_sg(info
->dev
, ch
->sglist
, nr_pages
, DMA_TO_DEVICE
);
321 if (bcfg
->start_transfer
)
322 bcfg
->start_transfer(bcfg
->board_data
, ch
,
323 &sh_mobile_lcdc_sys_bus_ops
);
324 lcdc_write_chan(ch
, LDSM2R
, 1);
328 static void sh_mobile_lcdc_deferred_io_touch(struct fb_info
*info
)
330 struct fb_deferred_io
*fbdefio
= info
->fbdefio
;
333 schedule_delayed_work(&info
->deferred_work
, fbdefio
->delay
);
336 static irqreturn_t
sh_mobile_lcdc_irq(int irq
, void *data
)
338 struct sh_mobile_lcdc_priv
*priv
= data
;
339 struct sh_mobile_lcdc_chan
*ch
;
341 unsigned long ldintr
;
345 /* acknowledge interrupt */
346 ldintr
= tmp
= lcdc_read(priv
, _LDINTR
);
348 * disable further VSYNC End IRQs, preserve all other enabled IRQs,
349 * write 0 to bits 0-6 to ack all triggered IRQs.
351 tmp
&= 0xffffff00 & ~LDINTR_VEE
;
352 lcdc_write(priv
, _LDINTR
, tmp
);
354 /* figure out if this interrupt is for main or sub lcd */
355 is_sub
= (lcdc_read(priv
, _LDSR
) & (1 << 10)) ? 1 : 0;
357 /* wake up channel and disable clocks */
358 for (k
= 0; k
< ARRAY_SIZE(priv
->ch
); k
++) {
365 if (ldintr
& LDINTR_FS
) {
366 if (is_sub
== lcdc_chan_is_sublcd(ch
)) {
368 wake_up(&ch
->frame_end_wait
);
370 sh_mobile_lcdc_clk_off(priv
);
375 if (ldintr
& LDINTR_VES
)
376 complete(&ch
->vsync_completion
);
382 static void sh_mobile_lcdc_start_stop(struct sh_mobile_lcdc_priv
*priv
,
385 unsigned long tmp
= lcdc_read(priv
, _LDCNT2R
);
388 /* start or stop the lcdc */
390 lcdc_write(priv
, _LDCNT2R
, tmp
| START_LCDC
);
392 lcdc_write(priv
, _LDCNT2R
, tmp
& ~START_LCDC
);
394 /* wait until power is applied/stopped on all channels */
395 for (k
= 0; k
< ARRAY_SIZE(priv
->ch
); k
++)
396 if (lcdc_read(priv
, _LDCNT2R
) & priv
->ch
[k
].enabled
)
398 tmp
= lcdc_read_chan(&priv
->ch
[k
], LDPMR
) & 3;
399 if (start
&& tmp
== 3)
401 if (!start
&& tmp
== 0)
407 lcdc_write(priv
, _LDDCKSTPR
, 1); /* stop dotclock */
410 static void sh_mobile_lcdc_geometry(struct sh_mobile_lcdc_chan
*ch
)
412 struct fb_var_screeninfo
*var
= &ch
->info
->var
, *display_var
= &ch
->display_var
;
413 unsigned long h_total
, hsync_pos
, display_h_total
;
416 tmp
= ch
->ldmt1r_value
;
417 tmp
|= (var
->sync
& FB_SYNC_VERT_HIGH_ACT
) ? 0 : 1 << 28;
418 tmp
|= (var
->sync
& FB_SYNC_HOR_HIGH_ACT
) ? 0 : 1 << 27;
419 tmp
|= (ch
->cfg
.flags
& LCDC_FLAGS_DWPOL
) ? 1 << 26 : 0;
420 tmp
|= (ch
->cfg
.flags
& LCDC_FLAGS_DIPOL
) ? 1 << 25 : 0;
421 tmp
|= (ch
->cfg
.flags
& LCDC_FLAGS_DAPOL
) ? 1 << 24 : 0;
422 tmp
|= (ch
->cfg
.flags
& LCDC_FLAGS_HSCNT
) ? 1 << 17 : 0;
423 tmp
|= (ch
->cfg
.flags
& LCDC_FLAGS_DWCNT
) ? 1 << 16 : 0;
424 lcdc_write_chan(ch
, LDMT1R
, tmp
);
427 lcdc_write_chan(ch
, LDMT2R
, ch
->cfg
.sys_bus_cfg
.ldmt2r
);
428 lcdc_write_chan(ch
, LDMT3R
, ch
->cfg
.sys_bus_cfg
.ldmt3r
);
430 /* horizontal configuration */
431 h_total
= display_var
->xres
+ display_var
->hsync_len
+
432 display_var
->left_margin
+ display_var
->right_margin
;
433 tmp
= h_total
/ 8; /* HTCN */
434 tmp
|= (min(display_var
->xres
, var
->xres
) / 8) << 16; /* HDCN */
435 lcdc_write_chan(ch
, LDHCNR
, tmp
);
437 hsync_pos
= display_var
->xres
+ display_var
->right_margin
;
438 tmp
= hsync_pos
/ 8; /* HSYNP */
439 tmp
|= (display_var
->hsync_len
/ 8) << 16; /* HSYNW */
440 lcdc_write_chan(ch
, LDHSYNR
, tmp
);
442 /* vertical configuration */
443 tmp
= display_var
->yres
+ display_var
->vsync_len
+
444 display_var
->upper_margin
+ display_var
->lower_margin
; /* VTLN */
445 tmp
|= min(display_var
->yres
, var
->yres
) << 16; /* VDLN */
446 lcdc_write_chan(ch
, LDVLNR
, tmp
);
448 tmp
= display_var
->yres
+ display_var
->lower_margin
; /* VSYNP */
449 tmp
|= display_var
->vsync_len
<< 16; /* VSYNW */
450 lcdc_write_chan(ch
, LDVSYNR
, tmp
);
452 /* Adjust horizontal synchronisation for HDMI */
453 display_h_total
= display_var
->xres
+ display_var
->hsync_len
+
454 display_var
->left_margin
+ display_var
->right_margin
;
455 tmp
= ((display_var
->xres
& 7) << 24) |
456 ((display_h_total
& 7) << 16) |
457 ((display_var
->hsync_len
& 7) << 8) |
459 lcdc_write_chan(ch
, LDHAJR
, tmp
);
462 static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv
*priv
)
464 struct sh_mobile_lcdc_chan
*ch
;
465 struct sh_mobile_lcdc_board_cfg
*board_cfg
;
471 /* enable clocks before accessing the hardware */
472 for (k
= 0; k
< ARRAY_SIZE(priv
->ch
); k
++) {
473 if (priv
->ch
[k
].enabled
) {
474 sh_mobile_lcdc_clk_on(priv
);
476 bpp
= priv
->ch
[k
].info
->var
.bits_per_pixel
;
481 lcdc_write(priv
, _LDCNT2R
, lcdc_read(priv
, _LDCNT2R
) | LCDC_RESET
);
482 lcdc_wait_bit(priv
, _LDCNT2R
, LCDC_RESET
, 0);
484 /* enable LCDC channels */
485 tmp
= lcdc_read(priv
, _LDCNT2R
);
486 tmp
|= priv
->ch
[0].enabled
;
487 tmp
|= priv
->ch
[1].enabled
;
488 lcdc_write(priv
, _LDCNT2R
, tmp
);
490 /* read data from external memory, avoid using the BEU for now */
491 lcdc_write(priv
, _LDCNT2R
, lcdc_read(priv
, _LDCNT2R
) & ~DISPLAY_BEU
);
493 /* stop the lcdc first */
494 sh_mobile_lcdc_start_stop(priv
, 0);
496 /* configure clocks */
498 for (k
= 0; k
< ARRAY_SIZE(priv
->ch
); k
++) {
501 if (!priv
->ch
[k
].enabled
)
504 m
= ch
->cfg
.clock_divider
;
510 tmp
|= m
<< (lcdc_chan_is_sublcd(ch
) ? 8 : 0);
512 /* FIXME: sh7724 can only use 42, 48, 54 and 60 for the divider denominator */
513 lcdc_write_chan(ch
, LDDCKPAT1R
, 0);
514 lcdc_write_chan(ch
, LDDCKPAT2R
, (1 << (m
/2)) - 1);
517 lcdc_write(priv
, _LDDCKR
, tmp
);
519 /* start dotclock again */
520 lcdc_write(priv
, _LDDCKSTPR
, 0);
521 lcdc_wait_bit(priv
, _LDDCKSTPR
, ~0, 0);
523 /* interrupts are disabled to begin with */
524 lcdc_write(priv
, _LDINTR
, 0);
526 for (k
= 0; k
< ARRAY_SIZE(priv
->ch
); k
++) {
532 sh_mobile_lcdc_geometry(ch
);
535 lcdc_write_chan(ch
, LDPMR
, 0);
537 board_cfg
= &ch
->cfg
.board_cfg
;
538 if (board_cfg
->setup_sys
)
539 ret
= board_cfg
->setup_sys(board_cfg
->board_data
, ch
,
540 &sh_mobile_lcdc_sys_bus_ops
);
545 /* word and long word swap */
548 lcdc_write(priv
, _LDDDSR
, lcdc_read(priv
, _LDDDSR
) | 6);
551 lcdc_write(priv
, _LDDDSR
, lcdc_read(priv
, _LDDDSR
) | 7);
554 lcdc_write(priv
, _LDDDSR
, lcdc_read(priv
, _LDDDSR
) | 4);
558 for (k
= 0; k
< ARRAY_SIZE(priv
->ch
); k
++) {
561 if (!priv
->ch
[k
].enabled
)
564 /* set bpp format in PKF[4:0] */
565 tmp
= lcdc_read_chan(ch
, LDDFR
);
567 switch (ch
->info
->var
.bits_per_pixel
) {
577 lcdc_write_chan(ch
, LDDFR
, tmp
);
579 /* point out our frame buffer */
580 lcdc_write_chan(ch
, LDSA1R
, ch
->info
->fix
.smem_start
);
583 lcdc_write_chan(ch
, LDMLSR
, ch
->info
->fix
.line_length
);
585 /* setup deferred io if SYS bus */
586 tmp
= ch
->cfg
.sys_bus_cfg
.deferred_io_msec
;
587 if (ch
->ldmt1r_value
& (1 << 12) && tmp
) {
588 ch
->defio
.deferred_io
= sh_mobile_lcdc_deferred_io
;
589 ch
->defio
.delay
= msecs_to_jiffies(tmp
);
590 ch
->info
->fbdefio
= &ch
->defio
;
591 fb_deferred_io_init(ch
->info
);
594 lcdc_write_chan(ch
, LDSM1R
, 1);
596 /* enable "Frame End Interrupt Enable" bit */
597 lcdc_write(priv
, _LDINTR
, LDINTR_FE
);
600 /* continuous read mode */
601 lcdc_write_chan(ch
, LDSM1R
, 0);
606 lcdc_write(priv
, _LDCNT1R
, LCDC_ENABLE
);
609 sh_mobile_lcdc_start_stop(priv
, 1);
612 /* tell the board code to enable the panel */
613 for (k
= 0; k
< ARRAY_SIZE(priv
->ch
); k
++) {
618 board_cfg
= &ch
->cfg
.board_cfg
;
619 if (try_module_get(board_cfg
->owner
) && board_cfg
->display_on
) {
620 board_cfg
->display_on(board_cfg
->board_data
, ch
->info
);
621 module_put(board_cfg
->owner
);
625 ch
->bl
->props
.power
= FB_BLANK_UNBLANK
;
626 backlight_update_status(ch
->bl
);
633 static void sh_mobile_lcdc_stop(struct sh_mobile_lcdc_priv
*priv
)
635 struct sh_mobile_lcdc_chan
*ch
;
636 struct sh_mobile_lcdc_board_cfg
*board_cfg
;
639 /* clean up deferred io and ask board code to disable panel */
640 for (k
= 0; k
< ARRAY_SIZE(priv
->ch
); k
++) {
646 * flush frame, and wait for frame end interrupt
647 * clean up deferred io and enable clock
649 if (ch
->info
&& ch
->info
->fbdefio
) {
651 schedule_delayed_work(&ch
->info
->deferred_work
, 0);
652 wait_event(ch
->frame_end_wait
, ch
->frame_end
);
653 fb_deferred_io_cleanup(ch
->info
);
654 ch
->info
->fbdefio
= NULL
;
655 sh_mobile_lcdc_clk_on(priv
);
659 ch
->bl
->props
.power
= FB_BLANK_POWERDOWN
;
660 backlight_update_status(ch
->bl
);
663 board_cfg
= &ch
->cfg
.board_cfg
;
664 if (try_module_get(board_cfg
->owner
) && board_cfg
->display_off
) {
665 board_cfg
->display_off(board_cfg
->board_data
);
666 module_put(board_cfg
->owner
);
672 sh_mobile_lcdc_start_stop(priv
, 0);
677 for (k
= 0; k
< ARRAY_SIZE(priv
->ch
); k
++)
678 if (priv
->ch
[k
].enabled
)
679 sh_mobile_lcdc_clk_off(priv
);
682 static int sh_mobile_lcdc_check_interface(struct sh_mobile_lcdc_chan
*ch
)
686 switch (ch
->cfg
.interface_type
) {
687 case RGB8
: ifm
= 0; miftyp
= 0; break;
688 case RGB9
: ifm
= 0; miftyp
= 4; break;
689 case RGB12A
: ifm
= 0; miftyp
= 5; break;
690 case RGB12B
: ifm
= 0; miftyp
= 6; break;
691 case RGB16
: ifm
= 0; miftyp
= 7; break;
692 case RGB18
: ifm
= 0; miftyp
= 10; break;
693 case RGB24
: ifm
= 0; miftyp
= 11; break;
694 case SYS8A
: ifm
= 1; miftyp
= 0; break;
695 case SYS8B
: ifm
= 1; miftyp
= 1; break;
696 case SYS8C
: ifm
= 1; miftyp
= 2; break;
697 case SYS8D
: ifm
= 1; miftyp
= 3; break;
698 case SYS9
: ifm
= 1; miftyp
= 4; break;
699 case SYS12
: ifm
= 1; miftyp
= 5; break;
700 case SYS16A
: ifm
= 1; miftyp
= 7; break;
701 case SYS16B
: ifm
= 1; miftyp
= 8; break;
702 case SYS16C
: ifm
= 1; miftyp
= 9; break;
703 case SYS18
: ifm
= 1; miftyp
= 10; break;
704 case SYS24
: ifm
= 1; miftyp
= 11; break;
708 /* SUBLCD only supports SYS interface */
709 if (lcdc_chan_is_sublcd(ch
)) {
716 ch
->ldmt1r_value
= (ifm
<< 12) | miftyp
;
722 static int sh_mobile_lcdc_setup_clocks(struct platform_device
*pdev
,
724 struct sh_mobile_lcdc_priv
*priv
)
729 switch (clock_source
) {
730 case LCDC_CLK_BUS
: str
= "bus_clk"; icksel
= 0; break;
731 case LCDC_CLK_PERIPHERAL
: str
= "peripheral_clk"; icksel
= 1; break;
732 case LCDC_CLK_EXTERNAL
: str
= NULL
; icksel
= 2; break;
737 priv
->lddckr
= icksel
<< 16;
740 priv
->dot_clk
= clk_get(&pdev
->dev
, str
);
741 if (IS_ERR(priv
->dot_clk
)) {
742 dev_err(&pdev
->dev
, "cannot get dot clock %s\n", str
);
743 return PTR_ERR(priv
->dot_clk
);
747 /* Runtime PM support involves two step for this driver:
748 * 1) Enable Runtime PM
749 * 2) Force Runtime PM Resume since hardware is accessed from probe()
751 priv
->dev
= &pdev
->dev
;
752 pm_runtime_enable(priv
->dev
);
753 pm_runtime_resume(priv
->dev
);
757 static int sh_mobile_lcdc_setcolreg(u_int regno
,
758 u_int red
, u_int green
, u_int blue
,
759 u_int transp
, struct fb_info
*info
)
761 u32
*palette
= info
->pseudo_palette
;
763 if (regno
>= PALETTE_NR
)
766 /* only FB_VISUAL_TRUECOLOR supported */
768 red
>>= 16 - info
->var
.red
.length
;
769 green
>>= 16 - info
->var
.green
.length
;
770 blue
>>= 16 - info
->var
.blue
.length
;
771 transp
>>= 16 - info
->var
.transp
.length
;
773 palette
[regno
] = (red
<< info
->var
.red
.offset
) |
774 (green
<< info
->var
.green
.offset
) |
775 (blue
<< info
->var
.blue
.offset
) |
776 (transp
<< info
->var
.transp
.offset
);
781 static struct fb_fix_screeninfo sh_mobile_lcdc_fix
= {
782 .id
= "SH Mobile LCDC",
783 .type
= FB_TYPE_PACKED_PIXELS
,
784 .visual
= FB_VISUAL_TRUECOLOR
,
785 .accel
= FB_ACCEL_NONE
,
791 static void sh_mobile_lcdc_fillrect(struct fb_info
*info
,
792 const struct fb_fillrect
*rect
)
794 sys_fillrect(info
, rect
);
795 sh_mobile_lcdc_deferred_io_touch(info
);
798 static void sh_mobile_lcdc_copyarea(struct fb_info
*info
,
799 const struct fb_copyarea
*area
)
801 sys_copyarea(info
, area
);
802 sh_mobile_lcdc_deferred_io_touch(info
);
805 static void sh_mobile_lcdc_imageblit(struct fb_info
*info
,
806 const struct fb_image
*image
)
808 sys_imageblit(info
, image
);
809 sh_mobile_lcdc_deferred_io_touch(info
);
812 static int sh_mobile_fb_pan_display(struct fb_var_screeninfo
*var
,
813 struct fb_info
*info
)
815 struct sh_mobile_lcdc_chan
*ch
= info
->par
;
816 struct sh_mobile_lcdc_priv
*priv
= ch
->lcdc
;
817 unsigned long ldrcntr
;
818 unsigned long new_pan_offset
;
820 new_pan_offset
= (var
->yoffset
* info
->fix
.line_length
) +
821 (var
->xoffset
* (info
->var
.bits_per_pixel
/ 8));
823 if (new_pan_offset
== ch
->pan_offset
)
824 return 0; /* No change, do nothing */
826 ldrcntr
= lcdc_read(priv
, _LDRCNTR
);
828 /* Set the source address for the next refresh */
829 lcdc_write_chan_mirror(ch
, LDSA1R
, ch
->dma_handle
+ new_pan_offset
);
830 if (lcdc_chan_is_sublcd(ch
))
831 lcdc_write(ch
->lcdc
, _LDRCNTR
, ldrcntr
^ LDRCNTR_SRS
);
833 lcdc_write(ch
->lcdc
, _LDRCNTR
, ldrcntr
^ LDRCNTR_MRS
);
835 ch
->pan_offset
= new_pan_offset
;
837 sh_mobile_lcdc_deferred_io_touch(info
);
842 static int sh_mobile_wait_for_vsync(struct fb_info
*info
)
844 struct sh_mobile_lcdc_chan
*ch
= info
->par
;
845 unsigned long ldintr
;
848 /* Enable VSync End interrupt */
849 ldintr
= lcdc_read(ch
->lcdc
, _LDINTR
);
850 ldintr
|= LDINTR_VEE
;
851 lcdc_write(ch
->lcdc
, _LDINTR
, ldintr
);
853 ret
= wait_for_completion_interruptible_timeout(&ch
->vsync_completion
,
854 msecs_to_jiffies(100));
861 static int sh_mobile_ioctl(struct fb_info
*info
, unsigned int cmd
,
867 case FBIO_WAITFORVSYNC
:
868 retval
= sh_mobile_wait_for_vsync(info
);
872 retval
= -ENOIOCTLCMD
;
878 static void sh_mobile_fb_reconfig(struct fb_info
*info
)
880 struct sh_mobile_lcdc_chan
*ch
= info
->par
;
881 struct fb_videomode mode1
, mode2
;
882 struct fb_event event
;
883 int evnt
= FB_EVENT_MODE_CHANGE_ALL
;
885 if (ch
->use_count
> 1 || (ch
->use_count
== 1 && !info
->fbcon_par
))
886 /* More framebuffer users are active */
889 fb_var_to_videomode(&mode1
, &ch
->display_var
);
890 fb_var_to_videomode(&mode2
, &info
->var
);
892 if (fb_mode_is_equal(&mode1
, &mode2
))
895 /* Display has been re-plugged, framebuffer is free now, reconfigure */
896 if (fb_set_var(info
, &ch
->display_var
) < 0)
897 /* Couldn't reconfigure, hopefully, can continue as before */
900 info
->fix
.line_length
= mode1
.xres
* (ch
->cfg
.bpp
/ 8);
903 * fb_set_var() calls the notifier change internally, only if
904 * FBINFO_MISC_USEREVENT flag is set. Since we do not want to fake a
905 * user event, we have to call the chain ourselves.
909 fb_notifier_call_chain(evnt
, &event
);
913 * Locking: both .fb_release() and .fb_open() are called with info->lock held if
914 * user == 1, or with console sem held, if user == 0.
916 static int sh_mobile_release(struct fb_info
*info
, int user
)
918 struct sh_mobile_lcdc_chan
*ch
= info
->par
;
920 mutex_lock(&ch
->open_lock
);
921 dev_dbg(info
->dev
, "%s(): %d users\n", __func__
, ch
->use_count
);
925 /* Nothing to reconfigure, when called from fbcon */
928 sh_mobile_fb_reconfig(info
);
932 mutex_unlock(&ch
->open_lock
);
937 static int sh_mobile_open(struct fb_info
*info
, int user
)
939 struct sh_mobile_lcdc_chan
*ch
= info
->par
;
941 mutex_lock(&ch
->open_lock
);
944 dev_dbg(info
->dev
, "%s(): %d users\n", __func__
, ch
->use_count
);
945 mutex_unlock(&ch
->open_lock
);
950 static int sh_mobile_check_var(struct fb_var_screeninfo
*var
, struct fb_info
*info
)
952 struct sh_mobile_lcdc_chan
*ch
= info
->par
;
953 struct sh_mobile_lcdc_priv
*p
= ch
->lcdc
;
955 if (var
->xres
> MAX_XRES
|| var
->yres
> MAX_YRES
||
956 var
->xres
* var
->yres
* (ch
->cfg
.bpp
/ 8) * 2 > info
->fix
.smem_len
) {
957 dev_warn(info
->dev
, "Invalid info: %u-%u-%u-%u x %u-%u-%u-%u @ %lukHz!\n",
958 var
->left_margin
, var
->xres
, var
->right_margin
, var
->hsync_len
,
959 var
->upper_margin
, var
->yres
, var
->lower_margin
, var
->vsync_len
,
960 PICOS2KHZ(var
->pixclock
));
964 /* only accept the forced_bpp for dual channel configurations */
965 if (p
->forced_bpp
&& p
->forced_bpp
!= var
->bits_per_pixel
)
968 switch (var
->bits_per_pixel
) {
969 case 16: /* PKF[4:0] = 00011 - RGB 565 */
970 case 24: /* PKF[4:0] = 01011 - RGB 888 */
971 case 32: /* PKF[4:0] = 00000 - RGBA 888 */
980 static struct fb_ops sh_mobile_lcdc_ops
= {
981 .owner
= THIS_MODULE
,
982 .fb_setcolreg
= sh_mobile_lcdc_setcolreg
,
983 .fb_read
= fb_sys_read
,
984 .fb_write
= fb_sys_write
,
985 .fb_fillrect
= sh_mobile_lcdc_fillrect
,
986 .fb_copyarea
= sh_mobile_lcdc_copyarea
,
987 .fb_imageblit
= sh_mobile_lcdc_imageblit
,
988 .fb_pan_display
= sh_mobile_fb_pan_display
,
989 .fb_ioctl
= sh_mobile_ioctl
,
990 .fb_open
= sh_mobile_open
,
991 .fb_release
= sh_mobile_release
,
992 .fb_check_var
= sh_mobile_check_var
,
995 static int sh_mobile_lcdc_update_bl(struct backlight_device
*bdev
)
997 struct sh_mobile_lcdc_chan
*ch
= bl_get_data(bdev
);
998 struct sh_mobile_lcdc_board_cfg
*cfg
= &ch
->cfg
.board_cfg
;
999 int brightness
= bdev
->props
.brightness
;
1001 if (bdev
->props
.power
!= FB_BLANK_UNBLANK
||
1002 bdev
->props
.state
& (BL_CORE_SUSPENDED
| BL_CORE_FBBLANK
))
1005 return cfg
->set_brightness(cfg
->board_data
, brightness
);
1008 static int sh_mobile_lcdc_get_brightness(struct backlight_device
*bdev
)
1010 struct sh_mobile_lcdc_chan
*ch
= bl_get_data(bdev
);
1011 struct sh_mobile_lcdc_board_cfg
*cfg
= &ch
->cfg
.board_cfg
;
1013 return cfg
->get_brightness(cfg
->board_data
);
1016 static int sh_mobile_lcdc_check_fb(struct backlight_device
*bdev
,
1017 struct fb_info
*info
)
1019 return (info
->bl_dev
== bdev
);
1022 static struct backlight_ops sh_mobile_lcdc_bl_ops
= {
1023 .options
= BL_CORE_SUSPENDRESUME
,
1024 .update_status
= sh_mobile_lcdc_update_bl
,
1025 .get_brightness
= sh_mobile_lcdc_get_brightness
,
1026 .check_fb
= sh_mobile_lcdc_check_fb
,
1029 static struct backlight_device
*sh_mobile_lcdc_bl_probe(struct device
*parent
,
1030 struct sh_mobile_lcdc_chan
*ch
)
1032 struct backlight_device
*bl
;
1034 bl
= backlight_device_register(ch
->cfg
.bl_info
.name
, parent
, ch
,
1035 &sh_mobile_lcdc_bl_ops
, NULL
);
1037 dev_err(parent
, "unable to register backlight device\n");
1041 bl
->props
.max_brightness
= ch
->cfg
.bl_info
.max_brightness
;
1042 bl
->props
.brightness
= bl
->props
.max_brightness
;
1043 backlight_update_status(bl
);
1048 static void sh_mobile_lcdc_bl_remove(struct backlight_device
*bdev
)
1050 backlight_device_unregister(bdev
);
1053 static int sh_mobile_lcdc_set_bpp(struct fb_var_screeninfo
*var
, int bpp
)
1056 case 16: /* PKF[4:0] = 00011 - RGB 565 */
1057 var
->red
.offset
= 11;
1058 var
->red
.length
= 5;
1059 var
->green
.offset
= 5;
1060 var
->green
.length
= 6;
1061 var
->blue
.offset
= 0;
1062 var
->blue
.length
= 5;
1063 var
->transp
.offset
= 0;
1064 var
->transp
.length
= 0;
1067 case 24: /* PKF[4:0] = 01011 - RGB 888 */
1068 var
->red
.offset
= 16;
1069 var
->red
.length
= 8;
1070 var
->green
.offset
= 8;
1071 var
->green
.length
= 8;
1072 var
->blue
.offset
= 0;
1073 var
->blue
.length
= 8;
1074 var
->transp
.offset
= 0;
1075 var
->transp
.length
= 0;
1078 case 32: /* PKF[4:0] = 00000 - RGBA 888 */
1079 var
->red
.offset
= 16;
1080 var
->red
.length
= 8;
1081 var
->green
.offset
= 8;
1082 var
->green
.length
= 8;
1083 var
->blue
.offset
= 0;
1084 var
->blue
.length
= 8;
1085 var
->transp
.offset
= 24;
1086 var
->transp
.length
= 8;
1091 var
->bits_per_pixel
= bpp
;
1092 var
->red
.msb_right
= 0;
1093 var
->green
.msb_right
= 0;
1094 var
->blue
.msb_right
= 0;
1095 var
->transp
.msb_right
= 0;
1099 static int sh_mobile_lcdc_suspend(struct device
*dev
)
1101 struct platform_device
*pdev
= to_platform_device(dev
);
1103 sh_mobile_lcdc_stop(platform_get_drvdata(pdev
));
1107 static int sh_mobile_lcdc_resume(struct device
*dev
)
1109 struct platform_device
*pdev
= to_platform_device(dev
);
1111 return sh_mobile_lcdc_start(platform_get_drvdata(pdev
));
1114 static int sh_mobile_lcdc_runtime_suspend(struct device
*dev
)
1116 struct platform_device
*pdev
= to_platform_device(dev
);
1117 struct sh_mobile_lcdc_priv
*p
= platform_get_drvdata(pdev
);
1118 struct sh_mobile_lcdc_chan
*ch
;
1121 /* save per-channel registers */
1122 for (k
= 0; k
< ARRAY_SIZE(p
->ch
); k
++) {
1126 for (n
= 0; n
< NR_CH_REGS
; n
++)
1127 ch
->saved_ch_regs
[n
] = lcdc_read_chan(ch
, n
);
1130 /* save shared registers */
1131 for (n
= 0; n
< NR_SHARED_REGS
; n
++)
1132 p
->saved_shared_regs
[n
] = lcdc_read(p
, lcdc_shared_regs
[n
]);
1134 /* turn off LCDC hardware */
1135 lcdc_write(p
, _LDCNT1R
, 0);
1139 static int sh_mobile_lcdc_runtime_resume(struct device
*dev
)
1141 struct platform_device
*pdev
= to_platform_device(dev
);
1142 struct sh_mobile_lcdc_priv
*p
= platform_get_drvdata(pdev
);
1143 struct sh_mobile_lcdc_chan
*ch
;
1146 /* restore per-channel registers */
1147 for (k
= 0; k
< ARRAY_SIZE(p
->ch
); k
++) {
1151 for (n
= 0; n
< NR_CH_REGS
; n
++)
1152 lcdc_write_chan(ch
, n
, ch
->saved_ch_regs
[n
]);
1155 /* restore shared registers */
1156 for (n
= 0; n
< NR_SHARED_REGS
; n
++)
1157 lcdc_write(p
, lcdc_shared_regs
[n
], p
->saved_shared_regs
[n
]);
1162 static const struct dev_pm_ops sh_mobile_lcdc_dev_pm_ops
= {
1163 .suspend
= sh_mobile_lcdc_suspend
,
1164 .resume
= sh_mobile_lcdc_resume
,
1165 .runtime_suspend
= sh_mobile_lcdc_runtime_suspend
,
1166 .runtime_resume
= sh_mobile_lcdc_runtime_resume
,
1169 /* locking: called with info->lock held */
1170 static int sh_mobile_lcdc_notify(struct notifier_block
*nb
,
1171 unsigned long action
, void *data
)
1173 struct fb_event
*event
= data
;
1174 struct fb_info
*info
= event
->info
;
1175 struct sh_mobile_lcdc_chan
*ch
= info
->par
;
1176 struct sh_mobile_lcdc_board_cfg
*board_cfg
= &ch
->cfg
.board_cfg
;
1179 if (&ch
->lcdc
->notifier
!= nb
)
1182 dev_dbg(info
->dev
, "%s(): action = %lu, data = %p\n",
1183 __func__
, action
, event
->data
);
1186 case FB_EVENT_SUSPEND
:
1187 if (try_module_get(board_cfg
->owner
) && board_cfg
->display_off
) {
1188 board_cfg
->display_off(board_cfg
->board_data
);
1189 module_put(board_cfg
->owner
);
1191 pm_runtime_put(info
->device
);
1192 sh_mobile_lcdc_stop(ch
->lcdc
);
1194 case FB_EVENT_RESUME
:
1195 mutex_lock(&ch
->open_lock
);
1196 sh_mobile_fb_reconfig(info
);
1197 mutex_unlock(&ch
->open_lock
);
1199 /* HDMI must be enabled before LCDC configuration */
1200 if (try_module_get(board_cfg
->owner
) && board_cfg
->display_on
) {
1201 board_cfg
->display_on(board_cfg
->board_data
, info
);
1202 module_put(board_cfg
->owner
);
1205 ret
= sh_mobile_lcdc_start(ch
->lcdc
);
1207 pm_runtime_get_sync(info
->device
);
1213 static int sh_mobile_lcdc_remove(struct platform_device
*pdev
);
1215 static int __devinit
sh_mobile_lcdc_probe(struct platform_device
*pdev
)
1217 struct fb_info
*info
;
1218 struct sh_mobile_lcdc_priv
*priv
;
1219 struct sh_mobile_lcdc_info
*pdata
= pdev
->dev
.platform_data
;
1220 struct resource
*res
;
1226 dev_err(&pdev
->dev
, "no platform data defined\n");
1230 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
1231 i
= platform_get_irq(pdev
, 0);
1232 if (!res
|| i
< 0) {
1233 dev_err(&pdev
->dev
, "cannot get platform resources\n");
1237 priv
= kzalloc(sizeof(*priv
), GFP_KERNEL
);
1239 dev_err(&pdev
->dev
, "cannot allocate device data\n");
1243 platform_set_drvdata(pdev
, priv
);
1245 error
= request_irq(i
, sh_mobile_lcdc_irq
, IRQF_DISABLED
,
1246 dev_name(&pdev
->dev
), priv
);
1248 dev_err(&pdev
->dev
, "unable to request irq\n");
1253 atomic_set(&priv
->hw_usecnt
, -1);
1256 for (i
= 0; i
< ARRAY_SIZE(pdata
->ch
); i
++) {
1257 struct sh_mobile_lcdc_chan
*ch
= priv
->ch
+ j
;
1260 memcpy(&ch
->cfg
, &pdata
->ch
[i
], sizeof(pdata
->ch
[i
]));
1262 error
= sh_mobile_lcdc_check_interface(ch
);
1264 dev_err(&pdev
->dev
, "unsupported interface type\n");
1267 init_waitqueue_head(&ch
->frame_end_wait
);
1268 init_completion(&ch
->vsync_completion
);
1271 /* probe the backlight is there is one defined */
1272 if (ch
->cfg
.bl_info
.max_brightness
)
1273 ch
->bl
= sh_mobile_lcdc_bl_probe(&pdev
->dev
, ch
);
1275 switch (pdata
->ch
[i
].chan
) {
1276 case LCDC_CHAN_MAINLCD
:
1277 ch
->enabled
= 1 << 1;
1278 ch
->reg_offs
= lcdc_offs_mainlcd
;
1281 case LCDC_CHAN_SUBLCD
:
1282 ch
->enabled
= 1 << 2;
1283 ch
->reg_offs
= lcdc_offs_sublcd
;
1290 dev_err(&pdev
->dev
, "no channels defined\n");
1295 /* for dual channel LCDC (MAIN + SUB) force shared bpp setting */
1297 priv
->forced_bpp
= pdata
->ch
[0].bpp
;
1299 priv
->base
= ioremap_nocache(res
->start
, resource_size(res
));
1303 error
= sh_mobile_lcdc_setup_clocks(pdev
, pdata
->clock_source
, priv
);
1305 dev_err(&pdev
->dev
, "unable to setup clocks\n");
1309 for (i
= 0; i
< j
; i
++) {
1310 struct fb_var_screeninfo
*var
;
1311 const struct fb_videomode
*lcd_cfg
, *max_cfg
= NULL
;
1312 struct sh_mobile_lcdc_chan
*ch
= priv
->ch
+ i
;
1313 struct sh_mobile_lcdc_chan_cfg
*cfg
= &ch
->cfg
;
1314 const struct fb_videomode
*mode
= cfg
->lcd_cfg
;
1315 unsigned long max_size
= 0;
1319 ch
->info
= framebuffer_alloc(0, &pdev
->dev
);
1321 dev_err(&pdev
->dev
, "unable to allocate fb_info\n");
1328 info
->fbops
= &sh_mobile_lcdc_ops
;
1331 mutex_init(&ch
->open_lock
);
1333 for (k
= 0, lcd_cfg
= mode
;
1334 k
< cfg
->num_cfg
&& lcd_cfg
;
1336 unsigned long size
= lcd_cfg
->yres
* lcd_cfg
->xres
;
1338 if (size
> max_size
) {
1345 max_size
= MAX_XRES
* MAX_YRES
;
1347 dev_dbg(&pdev
->dev
, "Found largest videomode %ux%u\n",
1348 max_cfg
->xres
, max_cfg
->yres
);
1350 info
->fix
= sh_mobile_lcdc_fix
;
1351 info
->fix
.smem_len
= max_size
* (cfg
->bpp
/ 8) * 2;
1354 mode
= &default_720p
;
1357 num_cfg
= cfg
->num_cfg
;
1360 fb_videomode_to_modelist(mode
, num_cfg
, &info
->modelist
);
1362 fb_videomode_to_var(var
, mode
);
1363 var
->width
= cfg
->lcd_size_cfg
.width
;
1364 var
->height
= cfg
->lcd_size_cfg
.height
;
1365 /* Default Y virtual resolution is 2x panel size */
1366 var
->yres_virtual
= var
->yres
* 2;
1367 var
->activate
= FB_ACTIVATE_NOW
;
1369 error
= sh_mobile_lcdc_set_bpp(var
, cfg
->bpp
);
1373 buf
= dma_alloc_coherent(&pdev
->dev
, info
->fix
.smem_len
,
1374 &ch
->dma_handle
, GFP_KERNEL
);
1376 dev_err(&pdev
->dev
, "unable to allocate buffer\n");
1381 info
->pseudo_palette
= &ch
->pseudo_palette
;
1382 info
->flags
= FBINFO_FLAG_DEFAULT
;
1384 error
= fb_alloc_cmap(&info
->cmap
, PALETTE_NR
, 0);
1386 dev_err(&pdev
->dev
, "unable to allocate cmap\n");
1387 dma_free_coherent(&pdev
->dev
, info
->fix
.smem_len
,
1388 buf
, ch
->dma_handle
);
1392 info
->fix
.smem_start
= ch
->dma_handle
;
1393 info
->fix
.line_length
= var
->xres
* (cfg
->bpp
/ 8);
1394 info
->screen_base
= buf
;
1395 info
->device
= &pdev
->dev
;
1396 ch
->display_var
= *var
;
1402 error
= sh_mobile_lcdc_start(priv
);
1404 dev_err(&pdev
->dev
, "unable to start hardware\n");
1408 for (i
= 0; i
< j
; i
++) {
1409 struct sh_mobile_lcdc_chan
*ch
= priv
->ch
+ i
;
1413 if (info
->fbdefio
) {
1414 ch
->sglist
= vmalloc(sizeof(struct scatterlist
) *
1415 info
->fix
.smem_len
>> PAGE_SHIFT
);
1417 dev_err(&pdev
->dev
, "cannot allocate sglist\n");
1422 info
->bl_dev
= ch
->bl
;
1424 error
= register_framebuffer(info
);
1429 "registered %s/%s as %dx%d %dbpp.\n",
1431 (ch
->cfg
.chan
== LCDC_CHAN_MAINLCD
) ?
1432 "mainlcd" : "sublcd",
1433 info
->var
.xres
, info
->var
.yres
,
1436 /* deferred io mode: disable clock to save power */
1437 if (info
->fbdefio
|| info
->state
== FBINFO_STATE_SUSPENDED
)
1438 sh_mobile_lcdc_clk_off(priv
);
1441 /* Failure ignored */
1442 priv
->notifier
.notifier_call
= sh_mobile_lcdc_notify
;
1443 fb_register_client(&priv
->notifier
);
1447 sh_mobile_lcdc_remove(pdev
);
1452 static int sh_mobile_lcdc_remove(struct platform_device
*pdev
)
1454 struct sh_mobile_lcdc_priv
*priv
= platform_get_drvdata(pdev
);
1455 struct fb_info
*info
;
1458 fb_unregister_client(&priv
->notifier
);
1460 for (i
= 0; i
< ARRAY_SIZE(priv
->ch
); i
++)
1461 if (priv
->ch
[i
].info
&& priv
->ch
[i
].info
->dev
)
1462 unregister_framebuffer(priv
->ch
[i
].info
);
1464 sh_mobile_lcdc_stop(priv
);
1466 for (i
= 0; i
< ARRAY_SIZE(priv
->ch
); i
++) {
1467 info
= priv
->ch
[i
].info
;
1469 if (!info
|| !info
->device
)
1472 if (priv
->ch
[i
].sglist
)
1473 vfree(priv
->ch
[i
].sglist
);
1475 if (info
->screen_base
)
1476 dma_free_coherent(&pdev
->dev
, info
->fix
.smem_len
,
1478 priv
->ch
[i
].dma_handle
);
1479 fb_dealloc_cmap(&info
->cmap
);
1480 framebuffer_release(info
);
1483 for (i
= 0; i
< ARRAY_SIZE(priv
->ch
); i
++) {
1485 sh_mobile_lcdc_bl_remove(priv
->ch
[i
].bl
);
1489 clk_put(priv
->dot_clk
);
1492 pm_runtime_disable(priv
->dev
);
1495 iounmap(priv
->base
);
1498 free_irq(priv
->irq
, priv
);
1503 static struct platform_driver sh_mobile_lcdc_driver
= {
1505 .name
= "sh_mobile_lcdc_fb",
1506 .owner
= THIS_MODULE
,
1507 .pm
= &sh_mobile_lcdc_dev_pm_ops
,
1509 .probe
= sh_mobile_lcdc_probe
,
1510 .remove
= sh_mobile_lcdc_remove
,
1513 static int __init
sh_mobile_lcdc_init(void)
1515 return platform_driver_register(&sh_mobile_lcdc_driver
);
1518 static void __exit
sh_mobile_lcdc_exit(void)
1520 platform_driver_unregister(&sh_mobile_lcdc_driver
);
1523 module_init(sh_mobile_lcdc_init
);
1524 module_exit(sh_mobile_lcdc_exit
);
1526 MODULE_DESCRIPTION("SuperH Mobile LCDC Framebuffer driver");
1527 MODULE_AUTHOR("Magnus Damm <damm@opensource.se>");
1528 MODULE_LICENSE("GPL v2");