26 #include <linux/kernel.h>
27 #include <linux/module.h>
29 #include <linux/slab.h>
73 static int sh7760fb_blank(
int blank,
struct fb_info *
info)
97 return wait_for_lps(par, lps);
100 static int sh7760_setcolreg (
u_int regno,
111 red >>= 16 - info->
var.red.length;
112 green >>= 16 - info->
var.green.length;
113 blue >>= 16 - info->
var.blue.length;
114 transp >>= 16 - info->
var.transp.length;
116 palette[regno] = (red << info->
var.red.offset) |
117 (green << info->
var.green.offset) |
118 (blue << info->
var.blue.offset) |
119 (transp << info->
var.transp.offset);
124 static int sh7760fb_get_color_info(
struct device *
dev,
156 dev_dbg(dev,
"unsupported LDDFR bit depth.\n");
176 ret = sh7760fb_get_color_info(info->
dev, par->
pd->lddfr, &bpp,
NULL);
199 static int sh7760fb_set_par(
struct fb_info *info)
203 unsigned long sbase, dstn_off, ldsarl, stride;
204 unsigned short hsynp, hsynw, htcn, hdcn;
205 unsigned short vsynp, vsynw, vtln, vdln;
206 unsigned short lddfr, ldmtr;
209 par->
rot = par->
pd->rotate;
212 if (par->
rot && (vm->
xres > 320)) {
213 dev_dbg(info->
dev,
"rotation disabled due to display size\n");
228 ret = sh7760fb_get_color_info(info->
dev, par->
pd->lddfr, &bpp, &gray);
232 dev_dbg(info->
dev,
"%dx%d %dbpp %s (orientation %s)\n", hdcn,
233 vdln, bpp, gray ?
"grayscale" :
"color",
234 par->
rot ?
"rotated" :
"normal");
236 #ifdef CONFIG_CPU_LITTLE_ENDIAN
237 lddfr = par->
pd->lddfr | (1 << 8);
239 lddfr = par->
pd->lddfr & ~(1 << 8);
242 ldmtr = par->
pd->ldmtr;
260 iowrite16(((htcn >> 3) - 1) | (((hdcn >> 3) - 1) << 8),
266 iowrite16(((hsynp >> 3) - 1) | (((hsynw >> 3) - 1) << 12),
271 stride = (par->
rot) ? vtln : hdcn;
273 stride *= (bpp + 7) >> 3;
286 unsigned long bit = 1 << 31;
300 sbase += (hdcn - 1) * stride;
312 dev_dbg(info->
dev,
" ***** DSTN untested! *****\n");
316 dstn_off *= hdcn >> 1;
318 dstn_off *= vdln >> 1;
320 ldsarl = sbase + dstn_off;
326 info->
fix.line_length = stride;
328 sh7760fb_check_var(&info->
var, info);
332 dev_dbg(info->
dev,
"hdcn : %6d htcn : %6d\n", hdcn, htcn);
333 dev_dbg(info->
dev,
"hsynw : %6d hsynp : %6d\n", hsynw, hsynp);
334 dev_dbg(info->
dev,
"vdln : %6d vtln : %6d\n", vdln, vtln);
335 dev_dbg(info->
dev,
"vsynw : %6d vsynp : %6d\n", vsynw, vsynp);
336 dev_dbg(info->
dev,
"clksrc: %6d clkdiv: %6d\n",
337 (par->
pd->ldickr >> 12) & 3, par->
pd->ldickr & 0x1f);
338 dev_dbg(info->
dev,
"ldpmmr: 0x%04x ldpspr: 0x%04x\n", par->
pd->ldpmmr,
340 dev_dbg(info->
dev,
"ldmtr : 0x%04x lddfr : 0x%04x\n", ldmtr, lddfr);
342 dev_dbg(info->
dev,
"ldsaru: 0x%08lx ldsarl: 0x%08lx\n", sbase, ldsarl);
347 static struct fb_ops sh7760fb_ops = {
349 .fb_blank = sh7760fb_blank,
350 .fb_check_var = sh7760fb_check_var,
351 .fb_setcolreg = sh7760_setcolreg,
352 .fb_set_par = sh7760fb_set_par,
358 static void sh7760fb_free_mem(
struct fb_info *info)
376 static int sh7760fb_alloc_mem(
struct fb_info *info)
387 ret = sh7760fb_get_color_info(info->
dev, par->
pd->lddfr, &bpp,
NULL);
396 vram = info->
var.xres * info->
var.yres;
397 if (info->
var.grayscale) {
406 if ((vram < 1) || (vram > 1024 * 2048)) {
407 dev_dbg(info->
dev,
"too much VRAM required. Check settings\n");
420 sh7760fb_free_mem(info);
421 dev_err(info->
dev,
"kernel gave me memory at 0x%08lx, which is"
422 "unusable for the LCDC\n", (
unsigned long)par->
fbdma);
454 par->
pd = pdev->
dev.platform_data;
456 dev_dbg(info->
dev,
"no display setup data!\n");
462 resource_size(res), pdev->
name);
480 "sh7760-lcdc", &par->
vsync);
490 ret = sh7760fb_alloc_mem(info);
492 dev_dbg(info->
dev,
"framebuffer memory allocation failed!\n");
499 info->
var.red.offset = 11;
500 info->
var.red.length = 5;
501 info->
var.red.msb_right = 0;
503 info->
var.green.offset = 5;
504 info->
var.green.length = 6;
505 info->
var.green.msb_right = 0;
507 info->
var.blue.offset = 0;
508 info->
var.blue.length = 5;
509 info->
var.blue.msb_right = 0;
511 info->
var.transp.offset = 0;
512 info->
var.transp.length = 0;
513 info->
var.transp.msb_right = 0;
521 info->
fbops = &sh7760fb_ops;
525 dev_dbg(info->
dev,
"Unable to allocate cmap memory\n");
534 platform_set_drvdata(pdev, info);
538 (
unsigned long)par->
fbdma,
548 sh7760fb_free_mem(info);
562 struct fb_info *info = platform_get_drvdata(dev);
568 sh7760fb_free_mem(info);
574 platform_set_drvdata(dev,
NULL);
581 .name =
"sh7760-lcdc",
584 .probe = sh7760fb_probe,