Lines Matching +full:dma +full:- +full:byte +full:- +full:en

1 // SPDX-License-Identifier: GPL-2.0
5 * (c) 2006-2008 MSC Vertriebsges.m.b.H.,
11 * Thanks to Siegfried Schaefer <s.schaefer at schaefer-edv.de>
19 #include <linux/dma-mapping.h>
56 /* wait_for_lps - wait until power supply has reached a certain state. */
60 while (--i && ((ioread16(par->base + LDPMMR) & 3) != val)) in wait_for_lps()
64 return -ETIMEDOUT; in wait_for_lps()
69 /* en/disable the LCDC */
72 struct sh7760fb_par *par = info->par; in sh7760fb_blank()
73 struct sh7760fb_platdata *pd = par->pd; in sh7760fb_blank()
74 unsigned short cntr = ioread16(par->base + LDCNTR); in sh7760fb_blank()
75 unsigned short intr = ioread16(par->base + LDINTR); in sh7760fb_blank()
88 if (pd->blank) in sh7760fb_blank()
89 pd->blank(blank); in sh7760fb_blank()
91 iowrite16(intr, par->base + LDINTR); in sh7760fb_blank()
92 iowrite16(cntr, par->base + LDCNTR); in sh7760fb_blank()
101 u32 *palette = info->pseudo_palette; in sh7760_setcolreg()
104 return -EINVAL; in sh7760_setcolreg()
108 red >>= 16 - info->var.red.length; in sh7760_setcolreg()
109 green >>= 16 - info->var.green.length; in sh7760_setcolreg()
110 blue >>= 16 - info->var.blue.length; in sh7760_setcolreg()
111 transp >>= 16 - info->var.transp.length; in sh7760_setcolreg()
113 palette[regno] = (red << info->var.red.offset) | in sh7760_setcolreg()
114 (green << info->var.green.offset) | in sh7760_setcolreg()
115 (blue << info->var.blue.offset) | in sh7760_setcolreg()
116 (transp << info->var.transp.offset); in sh7760_setcolreg()
156 return -EINVAL; in sh7760fb_get_color_info()
170 struct fb_fix_screeninfo *fix = &info->fix; in sh7760fb_check_var()
171 struct sh7760fb_par *par = info->par; in sh7760fb_check_var()
175 ret = sh7760fb_get_color_info(info, par->pd->lddfr, &bpp, NULL); in sh7760fb_check_var()
179 var->bits_per_pixel = bpp; in sh7760fb_check_var()
181 if ((var->grayscale) && (var->bits_per_pixel == 1)) in sh7760fb_check_var()
182 fix->visual = FB_VISUAL_MONO10; in sh7760fb_check_var()
183 else if (var->bits_per_pixel >= 15) in sh7760fb_check_var()
184 fix->visual = FB_VISUAL_TRUECOLOR; in sh7760fb_check_var()
186 fix->visual = FB_VISUAL_PSEUDOCOLOR; in sh7760fb_check_var()
193 * sh7760fb_set_par - set videomode.
200 struct sh7760fb_par *par = info->par; in sh7760fb_set_par()
201 struct fb_videomode *vm = par->pd->def_mode; in sh7760fb_set_par()
208 par->rot = par->pd->rotate; in sh7760fb_set_par()
211 if (par->rot && (vm->xres > 320)) { in sh7760fb_set_par()
213 par->rot = 0; in sh7760fb_set_par()
217 hsynp = vm->right_margin + vm->xres; in sh7760fb_set_par()
218 hsynw = vm->hsync_len; in sh7760fb_set_par()
219 htcn = vm->left_margin + hsynp + hsynw; in sh7760fb_set_par()
220 hdcn = vm->xres; in sh7760fb_set_par()
221 vsynp = vm->lower_margin + vm->yres; in sh7760fb_set_par()
222 vsynw = vm->vsync_len; in sh7760fb_set_par()
223 vtln = vm->upper_margin + vsynp + vsynw; in sh7760fb_set_par()
224 vdln = vm->yres; in sh7760fb_set_par()
227 ret = sh7760fb_get_color_info(info, par->pd->lddfr, &bpp, &gray); in sh7760fb_set_par()
233 par->rot ? "rotated" : "normal"); in sh7760fb_set_par()
236 lddfr = par->pd->lddfr | (1 << 8); in sh7760fb_set_par()
238 lddfr = par->pd->lddfr & ~(1 << 8); in sh7760fb_set_par()
241 ldmtr = par->pd->ldmtr; in sh7760fb_set_par()
243 if (!(vm->sync & FB_SYNC_HOR_HIGH_ACT)) in sh7760fb_set_par()
245 if (!(vm->sync & FB_SYNC_VERT_HIGH_ACT)) in sh7760fb_set_par()
251 iowrite16(par->pd->ldickr, par->base + LDICKR); /* pixclock */ in sh7760fb_set_par()
252 iowrite16(ldmtr, par->base + LDMTR); /* polarities */ in sh7760fb_set_par()
253 iowrite16(lddfr, par->base + LDDFR); /* color/depth */ in sh7760fb_set_par()
254 iowrite16((par->rot ? 1 << 13 : 0), par->base + LDSMR); /* rotate */ in sh7760fb_set_par()
255 iowrite16(par->pd->ldpmmr, par->base + LDPMMR); /* Power Management */ in sh7760fb_set_par()
256 iowrite16(par->pd->ldpspr, par->base + LDPSPR); /* Power Supply Ctrl */ in sh7760fb_set_par()
259 iowrite16(((htcn >> 3) - 1) | (((hdcn >> 3) - 1) << 8), in sh7760fb_set_par()
260 par->base + LDHCNR); in sh7760fb_set_par()
261 iowrite16(vdln - 1, par->base + LDVDLNR); in sh7760fb_set_par()
262 iowrite16(vtln - 1, par->base + LDVTLNR); in sh7760fb_set_par()
264 iowrite16((vsynp - 1) | ((vsynw - 1) << 12), par->base + LDVSYNR); in sh7760fb_set_par()
265 iowrite16(((hsynp >> 3) - 1) | (((hsynw >> 3) - 1) << 12), in sh7760fb_set_par()
266 par->base + LDHSYNR); in sh7760fb_set_par()
268 iowrite16(par->pd->ldaclnr, par->base + LDACLNR); in sh7760fb_set_par()
270 stride = (par->rot) ? vtln : hdcn; in sh7760fb_set_par()
284 if (par->rot) { in sh7760fb_set_par()
292 stride = bit << 1; /* not P-o-2, round up */ in sh7760fb_set_par()
294 iowrite16(stride, par->base + LDLAOR); in sh7760fb_set_par()
297 sbase = (unsigned long)par->fbdma; in sh7760fb_set_par()
298 if (par->rot) in sh7760fb_set_par()
299 sbase += (hdcn - 1) * stride; in sh7760fb_set_par()
301 iowrite32(sbase, par->base + LDSARU); in sh7760fb_set_par()
314 if (par->rot) in sh7760fb_set_par()
323 iowrite32(ldsarl, par->base + LDSARL); /* mem for lower half of DSTN */ in sh7760fb_set_par()
325 info->fix.line_length = stride; in sh7760fb_set_par()
327 sh7760fb_check_var(&info->var, info); in sh7760fb_set_par()
336 (par->pd->ldickr >> 12) & 3, par->pd->ldickr & 0x1f); in sh7760fb_set_par()
337 fb_dbg(info, "ldpmmr: 0x%04x ldpspr: 0x%04x\n", par->pd->ldpmmr, in sh7760fb_set_par()
338 par->pd->ldpspr); in sh7760fb_set_par()
357 struct sh7760fb_par *par = info->par; in sh7760fb_free_mem()
359 if (!info->screen_base) in sh7760fb_free_mem()
362 dma_free_coherent(info->device, info->screen_size, in sh7760fb_free_mem()
363 info->screen_base, par->fbdma); in sh7760fb_free_mem()
365 par->fbdma = 0; in sh7760fb_free_mem()
366 info->screen_base = NULL; in sh7760fb_free_mem()
367 info->screen_size = 0; in sh7760fb_free_mem()
371 * (dictated by the DMA engine) and contiguous, at a 512 byte boundary.
375 struct sh7760fb_par *par = info->par; in sh7760fb_alloc_mem()
380 if (info->screen_base) in sh7760fb_alloc_mem()
384 ret = sh7760fb_get_color_info(info, par->pd->lddfr, &bpp, NULL); in sh7760fb_alloc_mem()
390 /* min VRAM: xres_min = 16, yres_min = 1, bpp = 1: 2byte -> 1 page in sh7760fb_alloc_mem()
393 vram = info->var.xres * info->var.yres; in sh7760fb_alloc_mem()
394 if (info->var.grayscale) { in sh7760fb_alloc_mem()
405 return -ENODEV; in sh7760fb_alloc_mem()
411 fbmem = dma_alloc_coherent(info->device, vram, &par->fbdma, GFP_KERNEL); in sh7760fb_alloc_mem()
413 return -ENOMEM; in sh7760fb_alloc_mem()
415 if ((par->fbdma & SH7760FB_DMA_MASK) != SH7760FB_DMA_MASK) { in sh7760fb_alloc_mem()
416 dma_free_coherent(info->device, vram, fbmem, par->fbdma); in sh7760fb_alloc_mem()
417 dev_err(info->device, "kernel gave me memory at 0x%08lx, which is" in sh7760fb_alloc_mem()
418 "unusable for the LCDC\n", (unsigned long)par->fbdma); in sh7760fb_alloc_mem()
419 return -ENOMEM; in sh7760fb_alloc_mem()
422 info->screen_base = fbmem; in sh7760fb_alloc_mem()
423 info->screen_size = vram; in sh7760fb_alloc_mem()
424 info->fix.smem_start = (unsigned long)info->screen_base; in sh7760fb_alloc_mem()
425 info->fix.smem_len = info->screen_size; in sh7760fb_alloc_mem()
439 dev_err(&pdev->dev, "invalid resource\n"); in sh7760fb_probe()
440 return -EINVAL; in sh7760fb_probe()
443 info = framebuffer_alloc(sizeof(struct sh7760fb_par), &pdev->dev); in sh7760fb_probe()
445 return -ENOMEM; in sh7760fb_probe()
447 par = info->par; in sh7760fb_probe()
448 par->dev = pdev; in sh7760fb_probe()
450 par->pd = pdev->dev.platform_data; in sh7760fb_probe()
451 if (!par->pd) { in sh7760fb_probe()
452 dev_dbg(&pdev->dev, "no display setup data!\n"); in sh7760fb_probe()
453 ret = -ENODEV; in sh7760fb_probe()
457 par->ioarea = request_mem_region(res->start, in sh7760fb_probe()
458 resource_size(res), pdev->name); in sh7760fb_probe()
459 if (!par->ioarea) { in sh7760fb_probe()
460 dev_err(&pdev->dev, "mmio area busy\n"); in sh7760fb_probe()
461 ret = -EBUSY; in sh7760fb_probe()
465 par->base = ioremap(res->start, resource_size(res)); in sh7760fb_probe()
466 if (!par->base) { in sh7760fb_probe()
467 dev_err(&pdev->dev, "cannot remap\n"); in sh7760fb_probe()
468 ret = -ENODEV; in sh7760fb_probe()
472 iowrite16(0, par->base + LDINTR); /* disable vsync irq */ in sh7760fb_probe()
473 par->irq = platform_get_irq(pdev, 0); in sh7760fb_probe()
474 if (par->irq >= 0) { in sh7760fb_probe()
475 ret = request_irq(par->irq, sh7760fb_irq, 0, in sh7760fb_probe()
476 "sh7760-lcdc", &par->vsync); in sh7760fb_probe()
478 dev_err(&pdev->dev, "cannot grab IRQ\n"); in sh7760fb_probe()
479 par->irq = -ENXIO; in sh7760fb_probe()
481 disable_irq_nosync(par->irq); in sh7760fb_probe()
484 fb_videomode_to_var(&info->var, par->pd->def_mode); in sh7760fb_probe()
488 dev_dbg(info->device, "framebuffer memory allocation failed!\n"); in sh7760fb_probe()
492 info->pseudo_palette = par->pseudo_palette; in sh7760fb_probe()
495 info->var.red.offset = 11; in sh7760fb_probe()
496 info->var.red.length = 5; in sh7760fb_probe()
497 info->var.red.msb_right = 0; in sh7760fb_probe()
499 info->var.green.offset = 5; in sh7760fb_probe()
500 info->var.green.length = 6; in sh7760fb_probe()
501 info->var.green.msb_right = 0; in sh7760fb_probe()
503 info->var.blue.offset = 0; in sh7760fb_probe()
504 info->var.blue.length = 5; in sh7760fb_probe()
505 info->var.blue.msb_right = 0; in sh7760fb_probe()
507 info->var.transp.offset = 0; in sh7760fb_probe()
508 info->var.transp.length = 0; in sh7760fb_probe()
509 info->var.transp.msb_right = 0; in sh7760fb_probe()
511 strcpy(info->fix.id, "sh7760-lcdc"); in sh7760fb_probe()
516 iowrite16(LDCNTR_DON2, par->base + LDCNTR); in sh7760fb_probe()
517 info->fbops = &sh7760fb_ops; in sh7760fb_probe()
519 ret = fb_alloc_cmap(&info->cmap, 256, 0); in sh7760fb_probe()
521 dev_dbg(&pdev->dev, "Unable to allocate cmap memory\n"); in sh7760fb_probe()
527 dev_dbg(&pdev->dev, "cannot register fb!\n"); in sh7760fb_probe()
532 printk(KERN_INFO "%s: memory at phys 0x%08lx-0x%08lx, size %ld KiB\n", in sh7760fb_probe()
533 pdev->name, in sh7760fb_probe()
534 (unsigned long)par->fbdma, in sh7760fb_probe()
535 (unsigned long)(par->fbdma + info->screen_size - 1), in sh7760fb_probe()
536 info->screen_size >> 10); in sh7760fb_probe()
542 fb_dealloc_cmap(&info->cmap); in sh7760fb_probe()
546 if (par->irq >= 0) in sh7760fb_probe()
547 free_irq(par->irq, &par->vsync); in sh7760fb_probe()
548 iounmap(par->base); in sh7760fb_probe()
550 release_mem_region(res->start, resource_size(res)); in sh7760fb_probe()
559 struct sh7760fb_par *par = info->par; in sh7760fb_remove()
563 fb_dealloc_cmap(&info->cmap); in sh7760fb_remove()
565 if (par->irq >= 0) in sh7760fb_remove()
566 free_irq(par->irq, &par->vsync); in sh7760fb_remove()
567 iounmap(par->base); in sh7760fb_remove()
568 release_mem_region(par->ioarea->start, resource_size(par->ioarea)); in sh7760fb_remove()
574 .name = "sh7760-lcdc",