2 * linux/drivers/video/amba-clcd.c
4 * Copyright (C) 2001 ARM Limited, by David A Rusling
5 * Updated to 2.5, Deep Blue Solutions Ltd.
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file COPYING in the main directory of this archive
11 * ARM PrimeCell PL110 Color LCD Controller
13 #include <linux/amba/bus.h>
14 #include <linux/amba/clcd.h>
15 #include <linux/backlight.h>
16 #include <linux/clk.h>
17 #include <linux/delay.h>
18 #include <linux/dma-mapping.h>
20 #include <linux/init.h>
21 #include <linux/ioport.h>
22 #include <linux/list.h>
24 #include <linux/module.h>
25 #include <linux/of_address.h>
26 #include <linux/of_graph.h>
27 #include <linux/slab.h>
28 #include <linux/string.h>
29 #include <video/display_timing.h>
30 #include <video/of_display_timing.h>
31 #include <video/videomode.h>
33 #define to_clcd(info) container_of(info, struct clcd_fb, fb)
35 /* This is limited to 16 characters when displayed by X startup */
36 static const char *clcd_name = "CLCD FB";
39 * Unfortunately, the enable/disable functions may be called either from
40 * process or IRQ context, and we _need_ to delay. This is _not_ good.
42 static inline void clcdfb_sleep(unsigned int ms)
51 static inline void clcdfb_set_start(struct clcd_fb *fb)
53 unsigned long ustart = fb->fb.fix.smem_start;
56 ustart += fb->fb.var.yoffset * fb->fb.fix.line_length;
57 lstart = ustart + fb->fb.var.yres * fb->fb.fix.line_length / 2;
59 writel(ustart, fb->regs + CLCD_UBAS);
60 writel(lstart, fb->regs + CLCD_LBAS);
63 static void clcdfb_disable(struct clcd_fb *fb)
67 if (fb->board->disable)
68 fb->board->disable(fb);
70 if (fb->panel->backlight) {
71 fb->panel->backlight->props.power = FB_BLANK_POWERDOWN;
72 backlight_update_status(fb->panel->backlight);
75 val = readl(fb->regs + fb->off_cntl);
76 if (val & CNTL_LCDPWR) {
78 writel(val, fb->regs + fb->off_cntl);
82 if (val & CNTL_LCDEN) {
84 writel(val, fb->regs + fb->off_cntl);
88 * Disable CLCD clock source.
90 if (fb->clk_enabled) {
91 fb->clk_enabled = false;
96 static void clcdfb_enable(struct clcd_fb *fb, u32 cntl)
99 * Enable the CLCD clock source.
101 if (!fb->clk_enabled) {
102 fb->clk_enabled = true;
107 * Bring up by first enabling..
110 writel(cntl, fb->regs + fb->off_cntl);
115 * and now apply power.
118 writel(cntl, fb->regs + fb->off_cntl);
123 if (fb->panel->backlight) {
124 fb->panel->backlight->props.power = FB_BLANK_UNBLANK;
125 backlight_update_status(fb->panel->backlight);
129 * finally, enable the interface.
131 if (fb->board->enable)
132 fb->board->enable(fb);
136 clcdfb_set_bitfields(struct clcd_fb *fb, struct fb_var_screeninfo *var)
141 if (fb->panel->caps && fb->board->caps)
142 caps = fb->panel->caps & fb->board->caps;
144 /* Old way of specifying what can be used */
145 caps = fb->panel->cntl & CNTL_BGR ?
146 CLCD_CAP_BGR : CLCD_CAP_RGB;
147 /* But mask out 444 modes as they weren't supported */
148 caps &= ~CLCD_CAP_444;
151 /* Only TFT panels can do RGB888/BGR888 */
152 if (!(fb->panel->cntl & CNTL_LCDTFT))
153 caps &= ~CLCD_CAP_888;
155 memset(&var->transp, 0, sizeof(var->transp));
157 var->red.msb_right = 0;
158 var->green.msb_right = 0;
159 var->blue.msb_right = 0;
161 switch (var->bits_per_pixel) {
166 /* If we can't do 5551, reject */
167 caps &= CLCD_CAP_5551;
173 var->red.length = var->bits_per_pixel;
175 var->green.length = var->bits_per_pixel;
176 var->green.offset = 0;
177 var->blue.length = var->bits_per_pixel;
178 var->blue.offset = 0;
182 /* If we can't do 444, 5551 or 565, reject */
183 if (!(caps & (CLCD_CAP_444 | CLCD_CAP_5551 | CLCD_CAP_565))) {
189 * Green length can be 4, 5 or 6 depending whether
190 * we're operating in 444, 5551 or 565 mode.
192 if (var->green.length == 4 && caps & CLCD_CAP_444)
193 caps &= CLCD_CAP_444;
194 if (var->green.length == 5 && caps & CLCD_CAP_5551)
195 caps &= CLCD_CAP_5551;
196 else if (var->green.length == 6 && caps & CLCD_CAP_565)
197 caps &= CLCD_CAP_565;
200 * PL110 officially only supports RGB555,
201 * but may be wired up to allow RGB565.
203 if (caps & CLCD_CAP_565) {
204 var->green.length = 6;
205 caps &= CLCD_CAP_565;
206 } else if (caps & CLCD_CAP_5551) {
207 var->green.length = 5;
208 caps &= CLCD_CAP_5551;
210 var->green.length = 4;
211 caps &= CLCD_CAP_444;
215 if (var->green.length >= 5) {
217 var->blue.length = 5;
220 var->blue.length = 4;
224 /* If we can't do 888, reject */
225 caps &= CLCD_CAP_888;
232 var->green.length = 8;
233 var->blue.length = 8;
241 * >= 16bpp displays have separate colour component bitfields
242 * encoded in the pixel data. Calculate their position from
243 * the bitfield length defined above.
245 if (ret == 0 && var->bits_per_pixel >= 16) {
248 bgr = caps & CLCD_CAP_BGR && var->blue.offset == 0;
249 rgb = caps & CLCD_CAP_RGB && var->red.offset == 0;
253 * The requested format was not possible, try just
254 * our capabilities. One of BGR or RGB must be
257 bgr = caps & CLCD_CAP_BGR;
260 var->blue.offset = 0;
261 var->green.offset = var->blue.offset + var->blue.length;
262 var->red.offset = var->green.offset + var->green.length;
265 var->green.offset = var->red.offset + var->red.length;
266 var->blue.offset = var->green.offset + var->green.length;
273 static int clcdfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
275 struct clcd_fb *fb = to_clcd(info);
278 if (fb->board->check)
279 ret = fb->board->check(fb, var);
282 var->xres_virtual * var->bits_per_pixel / 8 *
283 var->yres_virtual > fb->fb.fix.smem_len)
287 ret = clcdfb_set_bitfields(fb, var);
292 static int clcdfb_set_par(struct fb_info *info)
294 struct clcd_fb *fb = to_clcd(info);
295 struct clcd_regs regs;
297 fb->fb.fix.line_length = fb->fb.var.xres_virtual *
298 fb->fb.var.bits_per_pixel / 8;
300 if (fb->fb.var.bits_per_pixel <= 8)
301 fb->fb.fix.visual = FB_VISUAL_PSEUDOCOLOR;
303 fb->fb.fix.visual = FB_VISUAL_TRUECOLOR;
305 fb->board->decode(fb, ®s);
309 writel(regs.tim0, fb->regs + CLCD_TIM0);
310 writel(regs.tim1, fb->regs + CLCD_TIM1);
311 writel(regs.tim2, fb->regs + CLCD_TIM2);
312 writel(regs.tim3, fb->regs + CLCD_TIM3);
314 clcdfb_set_start(fb);
316 clk_set_rate(fb->clk, (1000000000 / regs.pixclock) * 1000);
318 fb->clcd_cntl = regs.cntl;
320 clcdfb_enable(fb, regs.cntl);
324 "CLCD: Registers set to\n"
325 " %08x %08x %08x %08x\n"
326 " %08x %08x %08x %08x\n",
327 readl(fb->regs + CLCD_TIM0), readl(fb->regs + CLCD_TIM1),
328 readl(fb->regs + CLCD_TIM2), readl(fb->regs + CLCD_TIM3),
329 readl(fb->regs + CLCD_UBAS), readl(fb->regs + CLCD_LBAS),
330 readl(fb->regs + fb->off_ienb), readl(fb->regs + fb->off_cntl));
336 static inline u32 convert_bitfield(int val, struct fb_bitfield *bf)
338 unsigned int mask = (1 << bf->length) - 1;
340 return (val >> (16 - bf->length) & mask) << bf->offset;
344 * Set a single color register. The values supplied have a 16 bit
345 * magnitude. Return != 0 for invalid regno.
348 clcdfb_setcolreg(unsigned int regno, unsigned int red, unsigned int green,
349 unsigned int blue, unsigned int transp, struct fb_info *info)
351 struct clcd_fb *fb = to_clcd(info);
354 fb->cmap[regno] = convert_bitfield(transp, &fb->fb.var.transp) |
355 convert_bitfield(blue, &fb->fb.var.blue) |
356 convert_bitfield(green, &fb->fb.var.green) |
357 convert_bitfield(red, &fb->fb.var.red);
359 if (fb->fb.fix.visual == FB_VISUAL_PSEUDOCOLOR && regno < 256) {
360 int hw_reg = CLCD_PALETTE + ((regno * 2) & ~3);
361 u32 val, mask, newval;
363 newval = (red >> 11) & 0x001f;
364 newval |= (green >> 6) & 0x03e0;
365 newval |= (blue >> 1) & 0x7c00;
368 * 3.2.11: if we're configured for big endian
369 * byte order, the palette entries are swapped.
371 if (fb->clcd_cntl & CNTL_BEBO)
381 val = readl(fb->regs + hw_reg) & mask;
382 writel(val | newval, fb->regs + hw_reg);
389 * Blank the screen if blank_mode != 0, else unblank. If blank == NULL
390 * then the caller blanks by setting the CLUT (Color Look Up Table) to all
391 * black. Return 0 if blanking succeeded, != 0 if un-/blanking failed due
392 * to e.g. a video mode which doesn't support it. Implements VESA suspend
393 * and powerdown modes on hardware that supports disabling hsync/vsync:
394 * blank_mode == 2: suspend vsync
395 * blank_mode == 3: suspend hsync
396 * blank_mode == 4: powerdown
398 static int clcdfb_blank(int blank_mode, struct fb_info *info)
400 struct clcd_fb *fb = to_clcd(info);
402 if (blank_mode != 0) {
405 clcdfb_enable(fb, fb->clcd_cntl);
410 static int clcdfb_mmap(struct fb_info *info,
411 struct vm_area_struct *vma)
413 struct clcd_fb *fb = to_clcd(info);
414 unsigned long len, off = vma->vm_pgoff << PAGE_SHIFT;
417 len = info->fix.smem_len;
419 if (off <= len && vma->vm_end - vma->vm_start <= len - off &&
421 ret = fb->board->mmap(fb, vma);
426 static const struct fb_ops clcdfb_ops = {
427 .owner = THIS_MODULE,
428 .fb_check_var = clcdfb_check_var,
429 .fb_set_par = clcdfb_set_par,
430 .fb_setcolreg = clcdfb_setcolreg,
431 .fb_blank = clcdfb_blank,
432 .fb_fillrect = cfb_fillrect,
433 .fb_copyarea = cfb_copyarea,
434 .fb_imageblit = cfb_imageblit,
435 .fb_mmap = clcdfb_mmap,
438 static int clcdfb_register(struct clcd_fb *fb)
443 * ARM PL111 always has IENB at 0x1c; it's only PL110
444 * which is reversed on some platforms.
446 if (amba_manf(fb->dev) == 0x41 && amba_part(fb->dev) == 0x111) {
447 fb->off_ienb = CLCD_PL111_IENB;
448 fb->off_cntl = CLCD_PL111_CNTL;
450 fb->off_ienb = CLCD_PL110_IENB;
451 fb->off_cntl = CLCD_PL110_CNTL;
454 fb->clk = clk_get(&fb->dev->dev, NULL);
455 if (IS_ERR(fb->clk)) {
456 ret = PTR_ERR(fb->clk);
460 ret = clk_prepare(fb->clk);
464 fb->fb.device = &fb->dev->dev;
466 fb->fb.fix.mmio_start = fb->dev->res.start;
467 fb->fb.fix.mmio_len = resource_size(&fb->dev->res);
469 fb->regs = ioremap(fb->fb.fix.mmio_start, fb->fb.fix.mmio_len);
471 printk(KERN_ERR "CLCD: unable to remap registers\n");
476 fb->fb.fbops = &clcdfb_ops;
477 fb->fb.flags = FBINFO_FLAG_DEFAULT;
478 fb->fb.pseudo_palette = fb->cmap;
480 strncpy(fb->fb.fix.id, clcd_name, sizeof(fb->fb.fix.id));
481 fb->fb.fix.type = FB_TYPE_PACKED_PIXELS;
482 fb->fb.fix.type_aux = 0;
483 fb->fb.fix.xpanstep = 0;
484 fb->fb.fix.ypanstep = 0;
485 fb->fb.fix.ywrapstep = 0;
486 fb->fb.fix.accel = FB_ACCEL_NONE;
488 fb->fb.var.xres = fb->panel->mode.xres;
489 fb->fb.var.yres = fb->panel->mode.yres;
490 fb->fb.var.xres_virtual = fb->panel->mode.xres;
491 fb->fb.var.yres_virtual = fb->panel->mode.yres;
492 fb->fb.var.bits_per_pixel = fb->panel->bpp;
493 fb->fb.var.grayscale = fb->panel->grayscale;
494 fb->fb.var.pixclock = fb->panel->mode.pixclock;
495 fb->fb.var.left_margin = fb->panel->mode.left_margin;
496 fb->fb.var.right_margin = fb->panel->mode.right_margin;
497 fb->fb.var.upper_margin = fb->panel->mode.upper_margin;
498 fb->fb.var.lower_margin = fb->panel->mode.lower_margin;
499 fb->fb.var.hsync_len = fb->panel->mode.hsync_len;
500 fb->fb.var.vsync_len = fb->panel->mode.vsync_len;
501 fb->fb.var.sync = fb->panel->mode.sync;
502 fb->fb.var.vmode = fb->panel->mode.vmode;
503 fb->fb.var.activate = FB_ACTIVATE_NOW;
504 fb->fb.var.nonstd = 0;
505 fb->fb.var.height = fb->panel->height;
506 fb->fb.var.width = fb->panel->width;
507 fb->fb.var.accel_flags = 0;
509 fb->fb.monspecs.hfmin = 0;
510 fb->fb.monspecs.hfmax = 100000;
511 fb->fb.monspecs.vfmin = 0;
512 fb->fb.monspecs.vfmax = 400;
513 fb->fb.monspecs.dclkmin = 1000000;
514 fb->fb.monspecs.dclkmax = 100000000;
517 * Make sure that the bitfields are set appropriately.
519 clcdfb_set_bitfields(fb, &fb->fb.var);
522 * Allocate colourmap.
524 ret = fb_alloc_cmap(&fb->fb.cmap, 256, 0);
529 * Ensure interrupts are disabled.
531 writel(0, fb->regs + fb->off_ienb);
533 fb_set_var(&fb->fb, &fb->fb.var);
535 dev_info(&fb->dev->dev, "%s hardware, %s display\n",
536 fb->board->name, fb->panel->mode.name);
538 ret = register_framebuffer(&fb->fb);
542 printk(KERN_ERR "CLCD: cannot register framebuffer (%d)\n", ret);
544 fb_dealloc_cmap(&fb->fb.cmap);
548 clk_unprepare(fb->clk);
556 static int clcdfb_of_get_dpi_panel_mode(struct device_node *node,
557 struct clcd_panel *clcd_panel)
560 struct display_timing timing;
561 struct videomode video;
563 err = of_get_display_timing(node, "panel-timing", &timing);
565 pr_err("%pOF: problems parsing panel-timing (%d)\n", node, err);
569 videomode_from_timing(&timing, &video);
571 err = fb_videomode_from_videomode(&video, &clcd_panel->mode);
575 /* Set up some inversion flags */
576 if (timing.flags & DISPLAY_FLAGS_PIXDATA_NEGEDGE)
577 clcd_panel->tim2 |= TIM2_IPC;
578 else if (!(timing.flags & DISPLAY_FLAGS_PIXDATA_POSEDGE))
580 * To preserve backwards compatibility, the IPC (inverted
581 * pixel clock) flag needs to be set on any display that
582 * doesn't explicitly specify that the pixel clock is
583 * active on the negative or positive edge.
585 clcd_panel->tim2 |= TIM2_IPC;
587 if (timing.flags & DISPLAY_FLAGS_HSYNC_LOW)
588 clcd_panel->tim2 |= TIM2_IHS;
590 if (timing.flags & DISPLAY_FLAGS_VSYNC_LOW)
591 clcd_panel->tim2 |= TIM2_IVS;
593 if (timing.flags & DISPLAY_FLAGS_DE_LOW)
594 clcd_panel->tim2 |= TIM2_IOE;
599 static int clcdfb_snprintf_mode(char *buf, int size, struct fb_videomode *mode)
601 return snprintf(buf, size, "%ux%u@%u", mode->xres, mode->yres,
605 static int clcdfb_of_get_backlight(struct device *dev,
606 struct clcd_panel *clcd_panel)
608 struct backlight_device *backlight;
610 /* Look up the optional backlight device */
611 backlight = devm_of_find_backlight(dev);
612 if (IS_ERR(backlight))
613 return PTR_ERR(backlight);
615 clcd_panel->backlight = backlight;
619 static int clcdfb_of_get_mode(struct device *dev, struct device_node *panel,
620 struct clcd_panel *clcd_panel)
623 struct fb_videomode *mode;
627 /* Only directly connected DPI panels supported for now */
628 if (of_device_is_compatible(panel, "panel-dpi"))
629 err = clcdfb_of_get_dpi_panel_mode(panel, clcd_panel);
634 mode = &clcd_panel->mode;
636 len = clcdfb_snprintf_mode(NULL, 0, mode);
637 name = devm_kzalloc(dev, len + 1, GFP_KERNEL);
641 clcdfb_snprintf_mode(name, len + 1, mode);
647 static int clcdfb_of_init_tft_panel(struct clcd_fb *fb, u32 r0, u32 g0, u32 b0)
654 { 0x110, 1, 7, 13, CLCD_CAP_5551 },
655 { 0x110, 0, 8, 16, CLCD_CAP_888 },
656 { 0x110, 16, 8, 0, CLCD_CAP_888 },
657 { 0x111, 4, 14, 20, CLCD_CAP_444 },
658 { 0x111, 3, 11, 19, CLCD_CAP_444 | CLCD_CAP_5551 },
659 { 0x111, 3, 10, 19, CLCD_CAP_444 | CLCD_CAP_5551 |
661 { 0x111, 0, 8, 16, CLCD_CAP_444 | CLCD_CAP_5551 |
662 CLCD_CAP_565 | CLCD_CAP_888 },
666 /* Bypass pixel clock divider */
667 fb->panel->tim2 |= TIM2_BCD;
669 /* TFT display, vert. comp. interrupt at the start of the back porch */
670 fb->panel->cntl |= CNTL_LCDTFT | CNTL_LCDVCOMP(1);
674 /* Match the setup with known variants */
675 for (i = 0; i < ARRAY_SIZE(panels) && !fb->panel->caps; i++) {
676 if (amba_part(fb->dev) != panels[i].part)
678 if (g0 != panels[i].g0)
680 if (r0 == panels[i].r0 && b0 == panels[i].b0)
681 fb->panel->caps = panels[i].caps;
685 * If we actually physically connected the R lines to B and
688 if (r0 != 0 && b0 == 0)
689 fb->panel->bgr_connection = true;
691 return fb->panel->caps ? 0 : -EINVAL;
694 static int clcdfb_of_init_display(struct clcd_fb *fb)
696 struct device_node *endpoint, *panel;
702 fb->panel = devm_kzalloc(&fb->dev->dev, sizeof(*fb->panel), GFP_KERNEL);
707 * Fetch the panel endpoint.
709 endpoint = of_graph_get_next_endpoint(fb->dev->dev.of_node, NULL);
713 panel = of_graph_get_remote_port_parent(endpoint);
717 err = clcdfb_of_get_backlight(&fb->dev->dev, fb->panel);
721 err = clcdfb_of_get_mode(&fb->dev->dev, panel, fb->panel);
725 err = of_property_read_u32(fb->dev->dev.of_node, "max-memory-bandwidth",
729 * max_bandwidth is in bytes per second and pixclock in
730 * pico-seconds, so the maximum allowed bits per pixel is
731 * 8 * max_bandwidth / (PICOS2KHZ(pixclock) * 1000)
732 * Rearrange this calculation to avoid overflow and then ensure
733 * result is a valid format.
735 bpp = max_bandwidth / (1000 / 8)
736 / PICOS2KHZ(fb->panel->mode.pixclock);
737 bpp = rounddown_pow_of_two(bpp);
742 fb->panel->bpp = bpp;
744 #ifdef CONFIG_CPU_BIG_ENDIAN
745 fb->panel->cntl |= CNTL_BEBO;
747 fb->panel->width = -1;
748 fb->panel->height = -1;
750 if (of_property_read_u32_array(endpoint,
751 "arm,pl11x,tft-r0g0b0-pads",
752 tft_r0b0g0, ARRAY_SIZE(tft_r0b0g0)) != 0)
755 return clcdfb_of_init_tft_panel(fb, tft_r0b0g0[0],
756 tft_r0b0g0[1], tft_r0b0g0[2]);
759 static int clcdfb_of_vram_setup(struct clcd_fb *fb)
762 struct device_node *memory;
765 err = clcdfb_of_init_display(fb);
769 memory = of_parse_phandle(fb->dev->dev.of_node, "memory-region", 0);
773 fb->fb.screen_base = of_iomap(memory, 0);
774 if (!fb->fb.screen_base)
777 fb->fb.fix.smem_start = of_translate_address(memory,
778 of_get_address(memory, 0, &size, NULL));
779 fb->fb.fix.smem_len = size;
784 static int clcdfb_of_vram_mmap(struct clcd_fb *fb, struct vm_area_struct *vma)
786 unsigned long off, user_size, kernel_size;
789 off = vma->vm_pgoff << PAGE_SHIFT;
790 user_size = vma->vm_end - vma->vm_start;
791 kernel_size = fb->fb.fix.smem_len;
793 if (off >= kernel_size || user_size > (kernel_size - off))
796 return remap_pfn_range(vma, vma->vm_start,
797 __phys_to_pfn(fb->fb.fix.smem_start) + vma->vm_pgoff,
799 pgprot_writecombine(vma->vm_page_prot));
802 static void clcdfb_of_vram_remove(struct clcd_fb *fb)
804 iounmap(fb->fb.screen_base);
807 static int clcdfb_of_dma_setup(struct clcd_fb *fb)
809 unsigned long framesize;
813 err = clcdfb_of_init_display(fb);
817 framesize = PAGE_ALIGN(fb->panel->mode.xres * fb->panel->mode.yres *
819 fb->fb.screen_base = dma_alloc_coherent(&fb->dev->dev, framesize,
821 if (!fb->fb.screen_base)
824 fb->fb.fix.smem_start = dma;
825 fb->fb.fix.smem_len = framesize;
830 static int clcdfb_of_dma_mmap(struct clcd_fb *fb, struct vm_area_struct *vma)
832 return dma_mmap_wc(&fb->dev->dev, vma, fb->fb.screen_base,
833 fb->fb.fix.smem_start, fb->fb.fix.smem_len);
836 static void clcdfb_of_dma_remove(struct clcd_fb *fb)
838 dma_free_coherent(&fb->dev->dev, fb->fb.fix.smem_len,
839 fb->fb.screen_base, fb->fb.fix.smem_start);
842 static struct clcd_board *clcdfb_of_get_board(struct amba_device *dev)
844 struct clcd_board *board = devm_kzalloc(&dev->dev, sizeof(*board),
846 struct device_node *node = dev->dev.of_node;
851 board->name = of_node_full_name(node);
852 board->caps = CLCD_CAP_ALL;
853 board->check = clcdfb_check;
854 board->decode = clcdfb_decode;
855 if (of_find_property(node, "memory-region", NULL)) {
856 board->setup = clcdfb_of_vram_setup;
857 board->mmap = clcdfb_of_vram_mmap;
858 board->remove = clcdfb_of_vram_remove;
860 board->setup = clcdfb_of_dma_setup;
861 board->mmap = clcdfb_of_dma_mmap;
862 board->remove = clcdfb_of_dma_remove;
868 static struct clcd_board *clcdfb_of_get_board(struct amba_device *dev)
874 static int clcdfb_probe(struct amba_device *dev, const struct amba_id *id)
876 struct clcd_board *board = dev_get_platdata(&dev->dev);
881 board = clcdfb_of_get_board(dev);
886 ret = dma_set_mask_and_coherent(&dev->dev, DMA_BIT_MASK(32));
890 ret = amba_request_regions(dev, NULL);
892 printk(KERN_ERR "CLCD: unable to reserve regs region\n");
896 fb = kzalloc(sizeof(*fb), GFP_KERNEL);
905 dev_info(&fb->dev->dev, "PL%03x designer %02x rev%u at 0x%08llx\n",
906 amba_part(dev), amba_manf(dev), amba_rev(dev),
907 (unsigned long long)dev->res.start);
909 ret = fb->board->setup(fb);
913 ret = clcdfb_register(fb);
915 amba_set_drvdata(dev, fb);
919 fb->board->remove(fb);
923 amba_release_regions(dev);
928 static int clcdfb_remove(struct amba_device *dev)
930 struct clcd_fb *fb = amba_get_drvdata(dev);
933 unregister_framebuffer(&fb->fb);
935 fb_dealloc_cmap(&fb->fb.cmap);
937 clk_unprepare(fb->clk);
940 fb->board->remove(fb);
944 amba_release_regions(dev);
949 static const struct amba_id clcdfb_id_table[] = {
957 MODULE_DEVICE_TABLE(amba, clcdfb_id_table);
959 static struct amba_driver clcd_driver = {
961 .name = "clcd-pl11x",
963 .probe = clcdfb_probe,
964 .remove = clcdfb_remove,
965 .id_table = clcdfb_id_table,
968 static int __init amba_clcdfb_init(void)
970 if (fb_get_options("ambafb", NULL))
973 return amba_driver_register(&clcd_driver);
976 module_init(amba_clcdfb_init);
978 static void __exit amba_clcdfb_exit(void)
980 amba_driver_unregister(&clcd_driver);
983 module_exit(amba_clcdfb_exit);
985 MODULE_DESCRIPTION("ARM PrimeCell PL110 CLCD core driver");
986 MODULE_LICENSE("GPL");