Lines Matching +full:sync +full:- +full:on +full:- +full:green +full:- +full:active

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright(C) 2005-2006 Chris Humbert
9 * Based on:
98 * This iomem area supports only 16-bit IO.
116 * This iomem area supports only 16-bit IO.
146 #define LCR_HSS 0x144 /* H-Sync Start */
147 #define LCR_HSE 0x146 /* H-Sync End */
151 #define LCR_VSS 0x154 /* V-Sync Start */
152 #define LCR_VSE 0x156 /* V-Sync End */
155 #define LCR_SP 0x164 /* Sync Polarity */
157 #define LCR_VIHSS 0x16a /* Video Interface H-Sync Start */
160 #define LCR_VIVSS 0x170 /* Video Interface V-Sync Start */
200 /*--------------------------------------------------------------------------*/
213 struct tmiofb_par *par = info->par; in tmiofb_irq()
214 unsigned int bbisc = tmio_ioread16(par->lcr + LCR_BBISC); in tmiofb_irq()
217 tmio_iowrite16(bbisc, par->lcr + LCR_BBISC); in tmiofb_irq()
222 * Switch back to IRQ-based sync of command FIFO in tmiofb_irq()
224 if (unlikely(par->use_polling && irq != -1)) { in tmiofb_irq()
226 par->use_polling = false; in tmiofb_irq()
230 wake_up(&par->wait_acc); in tmiofb_irq()
237 /*--------------------------------------------------------------------------*/
245 struct tmio_fb_data *data = dev_get_platdata(&dev->dev); in tmiofb_hw_stop()
247 struct tmiofb_par *par = info->par; in tmiofb_hw_stop()
249 tmio_iowrite16(0, par->ccr + CCR_UGCC); in tmiofb_hw_stop()
250 tmio_iowrite16(0, par->lcr + LCR_GM); in tmiofb_hw_stop()
251 data->lcd_set_power(dev, 0); in tmiofb_hw_stop()
252 tmio_iowrite16(0x0010, par->lcr + LCR_LCDCCRC); in tmiofb_hw_stop()
264 struct tmiofb_par *par = info->par; in tmiofb_hw_init()
265 const struct resource *nlcr = &cell->resources[0]; in tmiofb_hw_init()
266 const struct resource *vram = &cell->resources[2]; in tmiofb_hw_init()
270 return -EINVAL; in tmiofb_hw_init()
272 base = nlcr->start; in tmiofb_hw_init()
274 tmio_iowrite16(0x003a, par->ccr + CCR_UGCC); in tmiofb_hw_init()
275 tmio_iowrite16(0x003a, par->ccr + CCR_GCC); in tmiofb_hw_init()
276 tmio_iowrite16(0x3f00, par->ccr + CCR_USC); in tmiofb_hw_init()
280 tmio_iowrite16(0x0000, par->ccr + CCR_USC); in tmiofb_hw_init()
281 tmio_iowrite16(base >> 16, par->ccr + CCR_BASEH); in tmiofb_hw_init()
282 tmio_iowrite16(base, par->ccr + CCR_BASEL); in tmiofb_hw_init()
283 tmio_iowrite16(0x0002, par->ccr + CCR_CMD); /* base address enable */ in tmiofb_hw_init()
284 tmio_iowrite16(0x40a8, par->ccr + CCR_VRAMRTC); /* VRAMRC, VRAMTC */ in tmiofb_hw_init()
285 tmio_iowrite16(0x0018, par->ccr + CCR_VRAMSAC); /* VRAMSTS, VRAMAC */ in tmiofb_hw_init()
286 tmio_iowrite16(0x0002, par->ccr + CCR_VRAMBC); in tmiofb_hw_init()
288 tmio_iowrite16(0x000b, par->ccr + CCR_VRAMBC); in tmiofb_hw_init()
290 base = vram->start + info->screen_size; in tmiofb_hw_init()
291 tmio_iowrite16(base >> 16, par->lcr + LCR_CFSAH); in tmiofb_hw_init()
292 tmio_iowrite16(base, par->lcr + LCR_CFSAL); in tmiofb_hw_init()
293 tmio_iowrite16(TMIOFB_FIFO_SIZE - 1, par->lcr + LCR_CFS); in tmiofb_hw_init()
294 tmio_iowrite16(1, par->lcr + LCR_CFC); in tmiofb_hw_init()
295 tmio_iowrite16(1, par->lcr + LCR_BBIE); in tmiofb_hw_init()
296 tmio_iowrite16(0, par->lcr + LCR_CFWS); in tmiofb_hw_init()
306 struct tmio_fb_data *data = dev_get_platdata(&dev->dev); in tmiofb_hw_mode()
308 struct fb_videomode *mode = info->mode; in tmiofb_hw_mode()
309 struct tmiofb_par *par = info->par; in tmiofb_hw_mode()
312 tmio_iowrite16(0, par->lcr + LCR_GM); in tmiofb_hw_mode()
313 data->lcd_set_power(dev, 0); in tmiofb_hw_mode()
314 tmio_iowrite16(0x0010, par->lcr + LCR_LCDCCRC); in tmiofb_hw_mode()
315 data->lcd_mode(dev, mode); in tmiofb_hw_mode()
316 data->lcd_set_power(dev, 1); in tmiofb_hw_mode()
318 tmio_iowrite16(info->fix.line_length, par->lcr + LCR_VHPN); in tmiofb_hw_mode()
319 tmio_iowrite16(0, par->lcr + LCR_GDSAH); in tmiofb_hw_mode()
320 tmio_iowrite16(0, par->lcr + LCR_GDSAL); in tmiofb_hw_mode()
321 tmio_iowrite16(info->fix.line_length >> 16, par->lcr + LCR_VHPCH); in tmiofb_hw_mode()
322 tmio_iowrite16(info->fix.line_length, par->lcr + LCR_VHPCL); in tmiofb_hw_mode()
323 tmio_iowrite16(i = 0, par->lcr + LCR_HSS); in tmiofb_hw_mode()
324 tmio_iowrite16(i += mode->hsync_len, par->lcr + LCR_HSE); in tmiofb_hw_mode()
325 tmio_iowrite16(i += mode->left_margin, par->lcr + LCR_HDS); in tmiofb_hw_mode()
326 tmio_iowrite16(i += mode->xres + mode->right_margin, par->lcr + LCR_HT); in tmiofb_hw_mode()
327 tmio_iowrite16(mode->xres, par->lcr + LCR_HNP); in tmiofb_hw_mode()
328 tmio_iowrite16(i = 0, par->lcr + LCR_VSS); in tmiofb_hw_mode()
329 tmio_iowrite16(i += mode->vsync_len, par->lcr + LCR_VSE); in tmiofb_hw_mode()
330 tmio_iowrite16(i += mode->upper_margin, par->lcr + LCR_VDS); in tmiofb_hw_mode()
331 tmio_iowrite16(i += mode->yres, par->lcr + LCR_ILN); in tmiofb_hw_mode()
332 tmio_iowrite16(i += mode->lower_margin, par->lcr + LCR_VT); in tmiofb_hw_mode()
333 tmio_iowrite16(3, par->lcr + LCR_MISC); /* RGB565 mode */ in tmiofb_hw_mode()
334 tmio_iowrite16(1, par->lcr + LCR_GM); /* VRAM enable */ in tmiofb_hw_mode()
335 tmio_iowrite16(0x4007, par->lcr + LCR_LCDCC); in tmiofb_hw_mode()
336 tmio_iowrite16(3, par->lcr + LCR_SP); /* sync polarity */ in tmiofb_hw_mode()
338 tmio_iowrite16(0x0010, par->lcr + LCR_LCDCCRC); in tmiofb_hw_mode()
340 tmio_iowrite16(0x0014, par->lcr + LCR_LCDCCRC); /* STOP_CKP */ in tmiofb_hw_mode()
342 tmio_iowrite16(0x0015, par->lcr + LCR_LCDCCRC); /* STOP_CKP|SOFT_RESET*/ in tmiofb_hw_mode()
343 tmio_iowrite16(0xfffa, par->lcr + LCR_VCS); in tmiofb_hw_mode()
346 /*--------------------------------------------------------------------------*/
352 struct tmiofb_par *par = info->par; in tmiofb_acc_wait()
355 * So instead of relaying on irq to trigger the event, in tmiofb_acc_wait()
358 if (irqs_disabled() || par->use_polling) { in tmiofb_acc_wait()
360 while (tmio_ioread16(par->lcr + LCR_CCS) > ccs) { in tmiofb_acc_wait()
366 return -ETIMEDOUT; in tmiofb_acc_wait()
368 tmiofb_irq(-1, info); in tmiofb_acc_wait()
371 if (!wait_event_interruptible_timeout(par->wait_acc, in tmiofb_acc_wait()
372 tmio_ioread16(par->lcr + LCR_CCS) <= ccs, in tmiofb_acc_wait()
375 return -ETIMEDOUT; in tmiofb_acc_wait()
388 struct tmiofb_par *par = info->par; in tmiofb_acc_write()
391 ret = tmiofb_acc_wait(info, TMIOFB_FIFO_SIZE - count); in tmiofb_acc_write()
395 for (; count; count--, cmd++) { in tmiofb_acc_write()
396 tmio_iowrite16(*cmd >> 16, par->lcr + LCR_CMDH); in tmiofb_acc_write()
397 tmio_iowrite16(*cmd, par->lcr + LCR_CMDL); in tmiofb_acc_write()
409 struct tmiofb_par *par = fbi->par; in tmiofb_sync()
416 while (tmio_ioread16(par->lcr + LCR_BBES) & 2) { /* blit active */ in tmiofb_sync()
421 return -ETIMEDOUT; in tmiofb_sync()
432 TMIOFB_ACC_DSADR((rect->dy * fbi->mode->xres + rect->dx) * 2), in tmiofb_fillrect()
433 TMIOFB_ACC_DHPIX(rect->width - 1), in tmiofb_fillrect()
434 TMIOFB_ACC_DVPIX(rect->height - 1), in tmiofb_fillrect()
435 TMIOFB_ACC_FILL(rect->color), in tmiofb_fillrect()
439 if (fbi->state != FBINFO_STATE_RUNNING || in tmiofb_fillrect()
440 fbi->flags & FBINFO_HWACCEL_DISABLED) { in tmiofb_fillrect()
452 TMIOFB_ACC_DSADR((area->dy * fbi->mode->xres + area->dx) * 2), in tmiofb_copyarea()
453 TMIOFB_ACC_DHPIX(area->width - 1), in tmiofb_copyarea()
454 TMIOFB_ACC_DVPIX(area->height - 1), in tmiofb_copyarea()
455 TMIOFB_ACC_SSADR((area->sy * fbi->mode->xres + area->sx) * 2), in tmiofb_copyarea()
459 if (fbi->state != FBINFO_STATE_RUNNING || in tmiofb_copyarea()
460 fbi->flags & FBINFO_HWACCEL_DISABLED) { in tmiofb_copyarea()
474 .width = info->mode->xres, in tmiofb_clearscreen()
475 .height = info->mode->yres, in tmiofb_clearscreen()
480 info->fbops->fb_fillrect(info, &rect); in tmiofb_clearscreen()
485 struct tmiofb_par *par = fbi->par; in tmiofb_vblank()
486 struct fb_videomode *mode = fbi->mode; in tmiofb_vblank()
487 unsigned int vcount = tmio_ioread16(par->lcr + LCR_CDLN); in tmiofb_vblank()
488 unsigned int vds = mode->vsync_len + mode->upper_margin; in tmiofb_vblank()
490 vblank->vcount = vcount; in tmiofb_vblank()
491 vblank->flags = FB_VBLANK_HAVE_VBLANK | FB_VBLANK_HAVE_VCOUNT in tmiofb_vblank()
494 if (vcount < mode->vsync_len) in tmiofb_vblank()
495 vblank->flags |= FB_VBLANK_VSYNCING; in tmiofb_vblank()
497 if (vcount < vds || vcount > vds + mode->yres) in tmiofb_vblank()
498 vblank->flags |= FB_VBLANK_VBLANKING; in tmiofb_vblank()
514 return -EFAULT; in tmiofb_ioctl()
529 return -EFAULT; in tmiofb_ioctl()
531 return -EINVAL; in tmiofb_ioctl()
533 return -EFAULT; in tmiofb_ioctl()
540 return -ENOTTY; in tmiofb_ioctl()
543 /*--------------------------------------------------------------------------*/
552 struct tmio_fb_data *data = dev_get_platdata(info->device); in tmiofb_find_mode()
556 for (i = 0; i < data->num_modes; i++) { in tmiofb_find_mode()
557 struct fb_videomode *mode = data->modes + i; in tmiofb_find_mode()
559 if (mode->xres >= var->xres && mode->yres >= var->yres in tmiofb_find_mode()
560 && (!best || (mode->xres < best->xres in tmiofb_find_mode()
561 && mode->yres < best->yres))) in tmiofb_find_mode()
572 struct tmio_fb_data *data = dev_get_platdata(info->device); in tmiofb_check_var()
575 if (!mode || var->bits_per_pixel > 16) in tmiofb_check_var()
576 return -EINVAL; in tmiofb_check_var()
580 var->xres_virtual = mode->xres; in tmiofb_check_var()
581 var->yres_virtual = info->screen_size / (mode->xres * 2); in tmiofb_check_var()
583 if (var->yres_virtual < var->yres) in tmiofb_check_var()
584 return -EINVAL; in tmiofb_check_var()
586 var->xoffset = 0; in tmiofb_check_var()
587 var->yoffset = 0; in tmiofb_check_var()
588 var->bits_per_pixel = 16; in tmiofb_check_var()
589 var->grayscale = 0; in tmiofb_check_var()
590 var->red.offset = 11; in tmiofb_check_var()
591 var->red.length = 5; in tmiofb_check_var()
592 var->green.offset = 5; in tmiofb_check_var()
593 var->green.length = 6; in tmiofb_check_var()
594 var->blue.offset = 0; in tmiofb_check_var()
595 var->blue.length = 5; in tmiofb_check_var()
596 var->transp.offset = 0; in tmiofb_check_var()
597 var->transp.length = 0; in tmiofb_check_var()
598 var->nonstd = 0; in tmiofb_check_var()
599 var->height = data->height; /* mm */ in tmiofb_check_var()
600 var->width = data->width; /* mm */ in tmiofb_check_var()
601 var->rotate = 0; in tmiofb_check_var()
607 struct fb_var_screeninfo *var = &info->var; in tmiofb_set_par()
612 return -EINVAL; in tmiofb_set_par()
614 info->mode = mode; in tmiofb_set_par()
615 info->fix.line_length = info->mode->xres * in tmiofb_set_par()
616 var->bits_per_pixel / 8; in tmiofb_set_par()
618 tmiofb_hw_mode(to_platform_device(info->device)); in tmiofb_set_par()
623 static int tmiofb_setcolreg(unsigned regno, unsigned red, unsigned green, in tmiofb_setcolreg() argument
627 struct tmiofb_par *par = info->par; in tmiofb_setcolreg()
629 if (regno < ARRAY_SIZE(par->pseudo_palette)) { in tmiofb_setcolreg()
630 par->pseudo_palette[regno] = in tmiofb_setcolreg()
632 ((green & 0xfc00) >> 5) | in tmiofb_setcolreg()
637 return -EINVAL; in tmiofb_setcolreg()
668 /*--------------------------------------------------------------------------*/
673 struct tmio_fb_data *data = dev_get_platdata(&dev->dev); in tmiofb_probe()
686 dev_err(&dev->dev, "NULL platform data!\n"); in tmiofb_probe()
687 return -EINVAL; in tmiofb_probe()
690 dev_err(&dev->dev, "missing resources\n"); in tmiofb_probe()
691 return -EINVAL; in tmiofb_probe()
694 info = framebuffer_alloc(sizeof(struct tmiofb_par), &dev->dev); in tmiofb_probe()
697 return -ENOMEM; in tmiofb_probe()
699 par = info->par; in tmiofb_probe()
702 init_waitqueue_head(&par->wait_acc); in tmiofb_probe()
704 par->use_polling = true; in tmiofb_probe()
706 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_COPYAREA in tmiofb_probe()
709 info->flags = FBINFO_DEFAULT; in tmiofb_probe()
712 info->fbops = &tmiofb_ops; in tmiofb_probe()
714 strcpy(info->fix.id, "tmio-fb"); in tmiofb_probe()
715 info->fix.smem_start = vram->start; in tmiofb_probe()
716 info->fix.smem_len = resource_size(vram); in tmiofb_probe()
717 info->fix.type = FB_TYPE_PACKED_PIXELS; in tmiofb_probe()
718 info->fix.visual = FB_VISUAL_TRUECOLOR; in tmiofb_probe()
719 info->fix.mmio_start = lcr->start; in tmiofb_probe()
720 info->fix.mmio_len = resource_size(lcr); in tmiofb_probe()
721 info->fix.accel = FB_ACCEL_NONE; in tmiofb_probe()
722 info->screen_size = info->fix.smem_len - (4 * TMIOFB_FIFO_SIZE); in tmiofb_probe()
723 info->pseudo_palette = par->pseudo_palette; in tmiofb_probe()
725 par->ccr = ioremap(ccr->start, resource_size(ccr)); in tmiofb_probe()
726 if (!par->ccr) { in tmiofb_probe()
727 retval = -ENOMEM; in tmiofb_probe()
731 par->lcr = ioremap(info->fix.mmio_start, info->fix.mmio_len); in tmiofb_probe()
732 if (!par->lcr) { in tmiofb_probe()
733 retval = -ENOMEM; in tmiofb_probe()
737 info->screen_base = ioremap(info->fix.smem_start, info->fix.smem_len); in tmiofb_probe()
738 if (!info->screen_base) { in tmiofb_probe()
739 retval = -ENOMEM; in tmiofb_probe()
744 dev_name(&dev->dev), info); in tmiofb_probe()
751 retval = fb_find_mode(&info->var, info, mode_option, in tmiofb_probe()
752 data->modes, data->num_modes, in tmiofb_probe()
753 data->modes, 16); in tmiofb_probe()
755 retval = -EINVAL; in tmiofb_probe()
759 if (cell->enable) { in tmiofb_probe()
760 retval = cell->enable(dev); in tmiofb_probe()
769 fb_videomode_to_modelist(data->modes, data->num_modes, in tmiofb_probe()
770 &info->modelist); in tmiofb_probe()
776 fb_info(info, "%s frame buffer device\n", info->fix.id); in tmiofb_probe()
784 if (cell->disable) in tmiofb_probe()
785 cell->disable(dev); in tmiofb_probe()
790 iounmap(info->screen_base); in tmiofb_probe()
792 iounmap(par->lcr); in tmiofb_probe()
794 iounmap(par->ccr); in tmiofb_probe()
808 par = info->par; in tmiofb_remove()
813 if (cell->disable) in tmiofb_remove()
814 cell->disable(dev); in tmiofb_remove()
818 iounmap(info->screen_base); in tmiofb_remove()
819 iounmap(par->lcr); in tmiofb_remove()
820 iounmap(par->ccr); in tmiofb_remove()
832 struct tmiofb_par *par = info->par; in tmiofb_dump_regs()
836 tmio_ioread16(par->ccr + CCR_ ## n)); in tmiofb_dump_regs()
851 tmio_ioread16(par->lcr + LCR_ ## n)); in tmiofb_dump_regs()
928 struct tmiofb_par *par = info->par; in tmiofb_suspend()
937 if (info->fbops->fb_sync) in tmiofb_suspend()
938 info->fbops->fb_sync(info); in tmiofb_suspend()
947 par->use_polling = true; in tmiofb_suspend()
951 if (cell->suspend) in tmiofb_suspend()
952 retval = cell->suspend(dev); in tmiofb_suspend()
967 if (cell->resume) { in tmiofb_resume()
968 retval = cell->resume(dev); in tmiofb_resume()
973 tmiofb_irq(-1, info); in tmiofb_resume()
990 .driver.name = "tmio-fb",
998 /*--------------------------------------------------------------------------*/
1024 return -ENODEV; in tmiofb_init()