• Home
  • Raw
  • Download

Lines Matching full:fb

19 #include <linux/fb.h>
36 #define to_clcd(info) container_of(info, struct clcd_fb, fb)
39 static const char *clcd_name = "CLCD FB";
54 static inline void clcdfb_set_start(struct clcd_fb *fb) in clcdfb_set_start() argument
56 unsigned long ustart = fb->fb.fix.smem_start; in clcdfb_set_start()
59 ustart += fb->fb.var.yoffset * fb->fb.fix.line_length; in clcdfb_set_start()
60 lstart = ustart + fb->fb.var.yres * fb->fb.fix.line_length / 2; in clcdfb_set_start()
62 writel(ustart, fb->regs + CLCD_UBAS); in clcdfb_set_start()
63 writel(lstart, fb->regs + CLCD_LBAS); in clcdfb_set_start()
66 static void clcdfb_disable(struct clcd_fb *fb) in clcdfb_disable() argument
70 if (fb->board->disable) in clcdfb_disable()
71 fb->board->disable(fb); in clcdfb_disable()
73 if (fb->panel->backlight) { in clcdfb_disable()
74 fb->panel->backlight->props.power = FB_BLANK_POWERDOWN; in clcdfb_disable()
75 backlight_update_status(fb->panel->backlight); in clcdfb_disable()
78 val = readl(fb->regs + fb->off_cntl); in clcdfb_disable()
81 writel(val, fb->regs + fb->off_cntl); in clcdfb_disable()
87 writel(val, fb->regs + fb->off_cntl); in clcdfb_disable()
93 if (fb->clk_enabled) { in clcdfb_disable()
94 fb->clk_enabled = false; in clcdfb_disable()
95 clk_disable(fb->clk); in clcdfb_disable()
99 static void clcdfb_enable(struct clcd_fb *fb, u32 cntl) in clcdfb_enable() argument
104 if (!fb->clk_enabled) { in clcdfb_enable()
105 fb->clk_enabled = true; in clcdfb_enable()
106 clk_enable(fb->clk); in clcdfb_enable()
113 writel(cntl, fb->regs + fb->off_cntl); in clcdfb_enable()
121 writel(cntl, fb->regs + fb->off_cntl); in clcdfb_enable()
126 if (fb->panel->backlight) { in clcdfb_enable()
127 fb->panel->backlight->props.power = FB_BLANK_UNBLANK; in clcdfb_enable()
128 backlight_update_status(fb->panel->backlight); in clcdfb_enable()
134 if (fb->board->enable) in clcdfb_enable()
135 fb->board->enable(fb); in clcdfb_enable()
139 clcdfb_set_bitfields(struct clcd_fb *fb, struct fb_var_screeninfo *var) in clcdfb_set_bitfields() argument
144 if (fb->panel->caps && fb->board->caps) in clcdfb_set_bitfields()
145 caps = fb->panel->caps & fb->board->caps; in clcdfb_set_bitfields()
148 caps = fb->panel->cntl & CNTL_BGR ? in clcdfb_set_bitfields()
155 if (!(fb->panel->cntl & CNTL_LCDTFT)) in clcdfb_set_bitfields()
227 if (fb->vendor->packed_24_bit_pixels) { in clcdfb_set_bitfields()
287 struct clcd_fb *fb = to_clcd(info); in clcdfb_check_var() local
290 if (fb->board->check) in clcdfb_check_var()
291 ret = fb->board->check(fb, var); in clcdfb_check_var()
295 var->yres_virtual > fb->fb.fix.smem_len) in clcdfb_check_var()
299 ret = clcdfb_set_bitfields(fb, var); in clcdfb_check_var()
306 struct clcd_fb *fb = to_clcd(info); in clcdfb_set_par() local
309 fb->fb.fix.line_length = fb->fb.var.xres_virtual * in clcdfb_set_par()
310 fb->fb.var.bits_per_pixel / 8; in clcdfb_set_par()
312 if (fb->fb.var.bits_per_pixel <= 8) in clcdfb_set_par()
313 fb->fb.fix.visual = FB_VISUAL_PSEUDOCOLOR; in clcdfb_set_par()
315 fb->fb.fix.visual = FB_VISUAL_TRUECOLOR; in clcdfb_set_par()
317 fb->board->decode(fb, &regs); in clcdfb_set_par()
319 clcdfb_disable(fb); in clcdfb_set_par()
322 if (fb->vendor->clock_timregs && !fb->clk_enabled) { in clcdfb_set_par()
323 fb->clk_enabled = true; in clcdfb_set_par()
324 clk_enable(fb->clk); in clcdfb_set_par()
327 writel(regs.tim0, fb->regs + CLCD_TIM0); in clcdfb_set_par()
328 writel(regs.tim1, fb->regs + CLCD_TIM1); in clcdfb_set_par()
329 writel(regs.tim2, fb->regs + CLCD_TIM2); in clcdfb_set_par()
330 writel(regs.tim3, fb->regs + CLCD_TIM3); in clcdfb_set_par()
332 clcdfb_set_start(fb); in clcdfb_set_par()
334 clk_set_rate(fb->clk, (1000000000 / regs.pixclock) * 1000); in clcdfb_set_par()
336 fb->clcd_cntl = regs.cntl; in clcdfb_set_par()
338 clcdfb_enable(fb, regs.cntl); in clcdfb_set_par()
345 readl(fb->regs + CLCD_TIM0), readl(fb->regs + CLCD_TIM1), in clcdfb_set_par()
346 readl(fb->regs + CLCD_TIM2), readl(fb->regs + CLCD_TIM3), in clcdfb_set_par()
347 readl(fb->regs + CLCD_UBAS), readl(fb->regs + CLCD_LBAS), in clcdfb_set_par()
348 readl(fb->regs + fb->off_ienb), readl(fb->regs + fb->off_cntl)); in clcdfb_set_par()
369 struct clcd_fb *fb = to_clcd(info); in clcdfb_setcolreg() local
372 fb->cmap[regno] = convert_bitfield(transp, &fb->fb.var.transp) | in clcdfb_setcolreg()
373 convert_bitfield(blue, &fb->fb.var.blue) | in clcdfb_setcolreg()
374 convert_bitfield(green, &fb->fb.var.green) | in clcdfb_setcolreg()
375 convert_bitfield(red, &fb->fb.var.red); in clcdfb_setcolreg()
377 if (fb->fb.fix.visual == FB_VISUAL_PSEUDOCOLOR && regno < 256) { in clcdfb_setcolreg()
389 if (fb->clcd_cntl & CNTL_BEBO) in clcdfb_setcolreg()
399 val = readl(fb->regs + hw_reg) & mask; in clcdfb_setcolreg()
400 writel(val | newval, fb->regs + hw_reg); in clcdfb_setcolreg()
418 struct clcd_fb *fb = to_clcd(info); in clcdfb_blank() local
421 clcdfb_disable(fb); in clcdfb_blank()
423 clcdfb_enable(fb, fb->clcd_cntl); in clcdfb_blank()
431 struct clcd_fb *fb = to_clcd(info); in clcdfb_mmap() local
438 fb->board->mmap) in clcdfb_mmap()
439 ret = fb->board->mmap(fb, vma); in clcdfb_mmap()
456 static int clcdfb_register(struct clcd_fb *fb) in clcdfb_register() argument
464 if (amba_manf(fb->dev) == 0x41 && amba_part(fb->dev) == 0x111) { in clcdfb_register()
465 fb->off_ienb = CLCD_PL111_IENB; in clcdfb_register()
466 fb->off_cntl = CLCD_PL111_CNTL; in clcdfb_register()
470 fb->off_ienb = CLCD_PL111_IENB; in clcdfb_register()
471 fb->off_cntl = CLCD_PL111_CNTL; in clcdfb_register()
473 fb->off_ienb = CLCD_PL110_IENB; in clcdfb_register()
474 fb->off_cntl = CLCD_PL110_CNTL; in clcdfb_register()
478 fb->clk = clk_get(&fb->dev->dev, NULL); in clcdfb_register()
479 if (IS_ERR(fb->clk)) { in clcdfb_register()
480 ret = PTR_ERR(fb->clk); in clcdfb_register()
484 ret = clk_prepare(fb->clk); in clcdfb_register()
488 fb->fb.device = &fb->dev->dev; in clcdfb_register()
490 fb->fb.fix.mmio_start = fb->dev->res.start; in clcdfb_register()
491 fb->fb.fix.mmio_len = resource_size(&fb->dev->res); in clcdfb_register()
493 fb->regs = ioremap(fb->fb.fix.mmio_start, fb->fb.fix.mmio_len); in clcdfb_register()
494 if (!fb->regs) { in clcdfb_register()
500 fb->fb.fbops = &clcdfb_ops; in clcdfb_register()
501 fb->fb.flags = FBINFO_FLAG_DEFAULT; in clcdfb_register()
502 fb->fb.pseudo_palette = fb->cmap; in clcdfb_register()
504 strncpy(fb->fb.fix.id, clcd_name, sizeof(fb->fb.fix.id)); in clcdfb_register()
505 fb->fb.fix.type = FB_TYPE_PACKED_PIXELS; in clcdfb_register()
506 fb->fb.fix.type_aux = 0; in clcdfb_register()
507 fb->fb.fix.xpanstep = 0; in clcdfb_register()
508 fb->fb.fix.ypanstep = 0; in clcdfb_register()
509 fb->fb.fix.ywrapstep = 0; in clcdfb_register()
510 fb->fb.fix.accel = FB_ACCEL_NONE; in clcdfb_register()
512 fb->fb.var.xres = fb->panel->mode.xres; in clcdfb_register()
513 fb->fb.var.yres = fb->panel->mode.yres; in clcdfb_register()
514 fb->fb.var.xres_virtual = fb->panel->mode.xres; in clcdfb_register()
515 fb->fb.var.yres_virtual = fb->panel->mode.yres; in clcdfb_register()
516 fb->fb.var.bits_per_pixel = fb->panel->bpp; in clcdfb_register()
517 fb->fb.var.grayscale = fb->panel->grayscale; in clcdfb_register()
518 fb->fb.var.pixclock = fb->panel->mode.pixclock; in clcdfb_register()
519 fb->fb.var.left_margin = fb->panel->mode.left_margin; in clcdfb_register()
520 fb->fb.var.right_margin = fb->panel->mode.right_margin; in clcdfb_register()
521 fb->fb.var.upper_margin = fb->panel->mode.upper_margin; in clcdfb_register()
522 fb->fb.var.lower_margin = fb->panel->mode.lower_margin; in clcdfb_register()
523 fb->fb.var.hsync_len = fb->panel->mode.hsync_len; in clcdfb_register()
524 fb->fb.var.vsync_len = fb->panel->mode.vsync_len; in clcdfb_register()
525 fb->fb.var.sync = fb->panel->mode.sync; in clcdfb_register()
526 fb->fb.var.vmode = fb->panel->mode.vmode; in clcdfb_register()
527 fb->fb.var.activate = FB_ACTIVATE_NOW; in clcdfb_register()
528 fb->fb.var.nonstd = 0; in clcdfb_register()
529 fb->fb.var.height = fb->panel->height; in clcdfb_register()
530 fb->fb.var.width = fb->panel->width; in clcdfb_register()
531 fb->fb.var.accel_flags = 0; in clcdfb_register()
533 fb->fb.monspecs.hfmin = 0; in clcdfb_register()
534 fb->fb.monspecs.hfmax = 100000; in clcdfb_register()
535 fb->fb.monspecs.vfmin = 0; in clcdfb_register()
536 fb->fb.monspecs.vfmax = 400; in clcdfb_register()
537 fb->fb.monspecs.dclkmin = 1000000; in clcdfb_register()
538 fb->fb.monspecs.dclkmax = 100000000; in clcdfb_register()
543 clcdfb_set_bitfields(fb, &fb->fb.var); in clcdfb_register()
548 ret = fb_alloc_cmap(&fb->fb.cmap, 256, 0); in clcdfb_register()
555 writel(0, fb->regs + fb->off_ienb); in clcdfb_register()
557 fb_set_var(&fb->fb, &fb->fb.var); in clcdfb_register()
559 dev_info(&fb->dev->dev, "%s hardware, %s display\n", in clcdfb_register()
560 fb->board->name, fb->panel->mode.name); in clcdfb_register()
562 ret = register_framebuffer(&fb->fb); in clcdfb_register()
568 fb_dealloc_cmap(&fb->fb.cmap); in clcdfb_register()
570 iounmap(fb->regs); in clcdfb_register()
572 clk_unprepare(fb->clk); in clcdfb_register()
574 clk_put(fb->clk); in clcdfb_register()
672 static int clcdfb_of_init_tft_panel(struct clcd_fb *fb, u32 r0, u32 g0, u32 b0) in clcdfb_of_init_tft_panel() argument
692 fb->panel->tim2 |= TIM2_BCD; in clcdfb_of_init_tft_panel()
695 fb->panel->cntl |= CNTL_LCDTFT | CNTL_LCDVCOMP(1); in clcdfb_of_init_tft_panel()
697 fb->panel->caps = 0; in clcdfb_of_init_tft_panel()
700 for (i = 0; i < ARRAY_SIZE(panels) && !fb->panel->caps; i++) { in clcdfb_of_init_tft_panel()
701 if (amba_part(fb->dev) != panels[i].part) in clcdfb_of_init_tft_panel()
706 fb->panel->caps = panels[i].caps; in clcdfb_of_init_tft_panel()
714 fb->panel->bgr_connection = true; in clcdfb_of_init_tft_panel()
716 if (fb->panel->caps && fb->vendor->st_bitmux_control) { in clcdfb_of_init_tft_panel()
728 if (fb->panel->caps & CLCD_CAP_888) { in clcdfb_of_init_tft_panel()
730 } else if (fb->panel->caps & CLCD_CAP_565) { in clcdfb_of_init_tft_panel()
732 fb->panel->cntl |= CNTL_ST_1XBPP_565; in clcdfb_of_init_tft_panel()
733 } else if (fb->panel->caps & CLCD_CAP_5551) { in clcdfb_of_init_tft_panel()
735 fb->panel->cntl |= CNTL_ST_1XBPP_5551; in clcdfb_of_init_tft_panel()
736 } else if (fb->panel->caps & CLCD_CAP_444) { in clcdfb_of_init_tft_panel()
738 fb->panel->cntl |= CNTL_ST_1XBPP_444; in clcdfb_of_init_tft_panel()
743 fb->panel->cntl |= CNTL_ST_CDWID_24; in clcdfb_of_init_tft_panel()
745 fb->panel->cntl |= CNTL_ST_CDWID_18; in clcdfb_of_init_tft_panel()
747 fb->panel->cntl |= CNTL_ST_CDWID_16; in clcdfb_of_init_tft_panel()
749 fb->panel->cntl |= CNTL_ST_CDWID_12; in clcdfb_of_init_tft_panel()
752 return fb->panel->caps ? 0 : -EINVAL; in clcdfb_of_init_tft_panel()
755 static int clcdfb_of_init_display(struct clcd_fb *fb) in clcdfb_of_init_display() argument
763 fb->panel = devm_kzalloc(&fb->dev->dev, sizeof(*fb->panel), GFP_KERNEL); in clcdfb_of_init_display()
764 if (!fb->panel) in clcdfb_of_init_display()
770 endpoint = of_graph_get_next_endpoint(fb->dev->dev.of_node, NULL); in clcdfb_of_init_display()
778 if (fb->vendor->init_panel) { in clcdfb_of_init_display()
779 err = fb->vendor->init_panel(fb, panel); in clcdfb_of_init_display()
784 err = clcdfb_of_get_backlight(panel, fb->panel); in clcdfb_of_init_display()
788 err = clcdfb_of_get_mode(&fb->dev->dev, panel, fb->panel); in clcdfb_of_init_display()
792 err = of_property_read_u32(fb->dev->dev.of_node, "max-memory-bandwidth", in clcdfb_of_init_display()
803 / PICOS2KHZ(fb->panel->mode.pixclock); in clcdfb_of_init_display()
809 fb->panel->bpp = bpp; in clcdfb_of_init_display()
812 fb->panel->cntl |= CNTL_BEBO; in clcdfb_of_init_display()
814 fb->panel->width = -1; in clcdfb_of_init_display()
815 fb->panel->height = -1; in clcdfb_of_init_display()
822 return clcdfb_of_init_tft_panel(fb, tft_r0b0g0[0], in clcdfb_of_init_display()
826 static int clcdfb_of_vram_setup(struct clcd_fb *fb) in clcdfb_of_vram_setup() argument
832 err = clcdfb_of_init_display(fb); in clcdfb_of_vram_setup()
836 memory = of_parse_phandle(fb->dev->dev.of_node, "memory-region", 0); in clcdfb_of_vram_setup()
840 fb->fb.screen_base = of_iomap(memory, 0); in clcdfb_of_vram_setup()
841 if (!fb->fb.screen_base) in clcdfb_of_vram_setup()
844 fb->fb.fix.smem_start = of_translate_address(memory, in clcdfb_of_vram_setup()
846 fb->fb.fix.smem_len = size; in clcdfb_of_vram_setup()
851 static int clcdfb_of_vram_mmap(struct clcd_fb *fb, struct vm_area_struct *vma) in clcdfb_of_vram_mmap() argument
858 kernel_size = fb->fb.fix.smem_len; in clcdfb_of_vram_mmap()
864 __phys_to_pfn(fb->fb.fix.smem_start) + vma->vm_pgoff, in clcdfb_of_vram_mmap()
869 static void clcdfb_of_vram_remove(struct clcd_fb *fb) in clcdfb_of_vram_remove() argument
871 iounmap(fb->fb.screen_base); in clcdfb_of_vram_remove()
874 static int clcdfb_of_dma_setup(struct clcd_fb *fb) in clcdfb_of_dma_setup() argument
880 err = clcdfb_of_init_display(fb); in clcdfb_of_dma_setup()
884 framesize = PAGE_ALIGN(fb->panel->mode.xres * fb->panel->mode.yres * in clcdfb_of_dma_setup()
885 fb->panel->bpp / 8); in clcdfb_of_dma_setup()
886 fb->fb.screen_base = dma_alloc_coherent(&fb->dev->dev, framesize, in clcdfb_of_dma_setup()
888 if (!fb->fb.screen_base) in clcdfb_of_dma_setup()
891 fb->fb.fix.smem_start = dma; in clcdfb_of_dma_setup()
892 fb->fb.fix.smem_len = framesize; in clcdfb_of_dma_setup()
897 static int clcdfb_of_dma_mmap(struct clcd_fb *fb, struct vm_area_struct *vma) in clcdfb_of_dma_mmap() argument
899 return dma_mmap_wc(&fb->dev->dev, vma, fb->fb.screen_base, in clcdfb_of_dma_mmap()
900 fb->fb.fix.smem_start, fb->fb.fix.smem_len); in clcdfb_of_dma_mmap()
903 static void clcdfb_of_dma_remove(struct clcd_fb *fb) in clcdfb_of_dma_remove() argument
905 dma_free_coherent(&fb->dev->dev, fb->fb.fix.smem_len, in clcdfb_of_dma_remove()
906 fb->fb.screen_base, fb->fb.fix.smem_start); in clcdfb_of_dma_remove()
945 struct clcd_fb *fb; in clcdfb_probe() local
970 fb = kzalloc(sizeof(*fb), GFP_KERNEL); in clcdfb_probe()
971 if (!fb) { in clcdfb_probe()
976 fb->dev = dev; in clcdfb_probe()
977 fb->vendor = vendor; in clcdfb_probe()
978 fb->board = board; in clcdfb_probe()
980 dev_info(&fb->dev->dev, "PL%03x designer %02x rev%u at 0x%08llx\n", in clcdfb_probe()
984 ret = fb->board->setup(fb); in clcdfb_probe()
988 ret = clcdfb_register(fb); in clcdfb_probe()
990 amba_set_drvdata(dev, fb); in clcdfb_probe()
994 fb->board->remove(fb); in clcdfb_probe()
996 kfree(fb); in clcdfb_probe()
1005 struct clcd_fb *fb = amba_get_drvdata(dev); in clcdfb_remove() local
1007 clcdfb_disable(fb); in clcdfb_remove()
1008 unregister_framebuffer(&fb->fb); in clcdfb_remove()
1009 if (fb->fb.cmap.len) in clcdfb_remove()
1010 fb_dealloc_cmap(&fb->fb.cmap); in clcdfb_remove()
1011 iounmap(fb->regs); in clcdfb_remove()
1012 clk_unprepare(fb->clk); in clcdfb_remove()
1013 clk_put(fb->clk); in clcdfb_remove()
1015 fb->board->remove(fb); in clcdfb_remove()
1017 kfree(fb); in clcdfb_remove()