Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fbdev: amba-clcd: Delete the old CLCD driver

We have managed to ascertain that all users of the old FBDEV
code that are out of tree are now gone.

The new DRM driver can be found in drivers/gpu/drm/pl111/.

The remaining out of tree user was the ARM FVP emulation
platform, running Android. Thanks to changes in Android
versions 13 and 14, Android can now use the DRM driver when
being emulated under FVP. Some final patches are being put
in place to make it fully featured.

This is essentially a revert of the partial revert in
commit 112c35237c72 ("Partially revert "video: fbdev: amba-clcd: Retire elder CLCD driver"")

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Helge Deller <deller@gmx.de>

authored by

Linus Walleij and committed by
Helge Deller
dee56ccb d9f25b59

-1385
-5
MAINTAINERS
··· 1684 1684 F: drivers/amba/ 1685 1685 F: include/linux/amba/bus.h 1686 1686 1687 - ARM PRIMECELL CLCD PL110 DRIVER 1688 - M: Russell King <linux@armlinux.org.uk> 1689 - S: Odd Fixes 1690 - F: drivers/video/fbdev/amba-clcd.* 1691 - 1692 1687 ARM PRIMECELL KMI PL050 DRIVER 1693 1688 M: Russell King <linux@armlinux.org.uk> 1694 1689 S: Odd Fixes
-18
drivers/video/fbdev/Kconfig
··· 116 116 help 117 117 Support the Permedia2 FIFO disconnect feature. 118 118 119 - config FB_ARMCLCD 120 - tristate "ARM PrimeCell PL110 support" 121 - depends on ARM || ARM64 || COMPILE_TEST 122 - depends on FB && ARM_AMBA && HAS_IOMEM 123 - select FB_IOMEM_HELPERS 124 - select FB_MODE_HELPERS if OF 125 - select VIDEOMODE_HELPERS if OF 126 - select BACKLIGHT_CLASS_DEVICE if OF 127 - help 128 - This framebuffer device driver is for the ARM PrimeCell PL110 129 - Colour LCD controller. ARM PrimeCells provide the building 130 - blocks for System on a Chip devices. 131 - 132 - If you want to compile this as a module (=code which can be 133 - inserted into and removed from the running kernel), say M 134 - here and read <file:Documentation/kbuild/modules.rst>. The module 135 - will be called amba-clcd. 136 - 137 119 config FB_ACORN 138 120 bool "Acorn VIDC support" 139 121 depends on (FB = y) && ARM && ARCH_ACORN
-1
drivers/video/fbdev/Makefile
··· 74 74 obj-$(CONFIG_FB_ATMEL) += atmel_lcdfb.o 75 75 obj-$(CONFIG_FB_PVR2) += pvr2fb.o 76 76 obj-$(CONFIG_FB_VOODOO1) += sstfb.o 77 - obj-$(CONFIG_FB_ARMCLCD) += amba-clcd.o 78 77 obj-$(CONFIG_FB_GOLDFISH) += goldfishfb.o 79 78 obj-$(CONFIG_FB_68328) += 68328fb.o 80 79 obj-$(CONFIG_FB_GBE) += gbefb.o
-984
drivers/video/fbdev/amba-clcd.c
··· 1 - /* 2 - * linux/drivers/video/amba-clcd.c 3 - * 4 - * Copyright (C) 2001 ARM Limited, by David A Rusling 5 - * Updated to 2.5, Deep Blue Solutions Ltd. 6 - * 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 9 - * for more details. 10 - * 11 - * ARM PrimeCell PL110 Color LCD Controller 12 - */ 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> 19 - #include <linux/fb.h> 20 - #include <linux/init.h> 21 - #include <linux/ioport.h> 22 - #include <linux/list.h> 23 - #include <linux/mm.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> 32 - 33 - #define to_clcd(info) container_of(info, struct clcd_fb, fb) 34 - 35 - /* This is limited to 16 characters when displayed by X startup */ 36 - static const char *clcd_name = "CLCD FB"; 37 - 38 - static inline void clcdfb_set_start(struct clcd_fb *fb) 39 - { 40 - unsigned long ustart = fb->fb.fix.smem_start; 41 - unsigned long lstart; 42 - 43 - ustart += fb->fb.var.yoffset * fb->fb.fix.line_length; 44 - lstart = ustart + fb->fb.var.yres * fb->fb.fix.line_length / 2; 45 - 46 - writel(ustart, fb->regs + CLCD_UBAS); 47 - writel(lstart, fb->regs + CLCD_LBAS); 48 - } 49 - 50 - static void clcdfb_disable(struct clcd_fb *fb) 51 - { 52 - u32 val; 53 - 54 - if (fb->board->disable) 55 - fb->board->disable(fb); 56 - 57 - if (fb->panel->backlight) { 58 - fb->panel->backlight->props.power = FB_BLANK_POWERDOWN; 59 - backlight_update_status(fb->panel->backlight); 60 - } 61 - 62 - val = readl(fb->regs + fb->off_cntl); 63 - if (val & CNTL_LCDPWR) { 64 - val &= ~CNTL_LCDPWR; 65 - writel(val, fb->regs + fb->off_cntl); 66 - 67 - msleep(20); 68 - } 69 - if (val & CNTL_LCDEN) { 70 - val &= ~CNTL_LCDEN; 71 - writel(val, fb->regs + fb->off_cntl); 72 - } 73 - 74 - /* 75 - * Disable CLCD clock source. 76 - */ 77 - if (fb->clk_enabled) { 78 - fb->clk_enabled = false; 79 - clk_disable(fb->clk); 80 - } 81 - } 82 - 83 - static void clcdfb_enable(struct clcd_fb *fb, u32 cntl) 84 - { 85 - /* 86 - * Enable the CLCD clock source. 87 - */ 88 - if (!fb->clk_enabled) { 89 - fb->clk_enabled = true; 90 - clk_enable(fb->clk); 91 - } 92 - 93 - /* 94 - * Bring up by first enabling.. 95 - */ 96 - cntl |= CNTL_LCDEN; 97 - writel(cntl, fb->regs + fb->off_cntl); 98 - 99 - msleep(20); 100 - 101 - /* 102 - * and now apply power. 103 - */ 104 - cntl |= CNTL_LCDPWR; 105 - writel(cntl, fb->regs + fb->off_cntl); 106 - 107 - /* 108 - * Turn on backlight 109 - */ 110 - if (fb->panel->backlight) { 111 - fb->panel->backlight->props.power = FB_BLANK_UNBLANK; 112 - backlight_update_status(fb->panel->backlight); 113 - } 114 - 115 - /* 116 - * finally, enable the interface. 117 - */ 118 - if (fb->board->enable) 119 - fb->board->enable(fb); 120 - } 121 - 122 - static int 123 - clcdfb_set_bitfields(struct clcd_fb *fb, struct fb_var_screeninfo *var) 124 - { 125 - u32 caps; 126 - int ret = 0; 127 - 128 - if (fb->panel->caps && fb->board->caps) 129 - caps = fb->panel->caps & fb->board->caps; 130 - else { 131 - /* Old way of specifying what can be used */ 132 - caps = fb->panel->cntl & CNTL_BGR ? 133 - CLCD_CAP_BGR : CLCD_CAP_RGB; 134 - /* But mask out 444 modes as they weren't supported */ 135 - caps &= ~CLCD_CAP_444; 136 - } 137 - 138 - /* Only TFT panels can do RGB888/BGR888 */ 139 - if (!(fb->panel->cntl & CNTL_LCDTFT)) 140 - caps &= ~CLCD_CAP_888; 141 - 142 - memset(&var->transp, 0, sizeof(var->transp)); 143 - 144 - var->red.msb_right = 0; 145 - var->green.msb_right = 0; 146 - var->blue.msb_right = 0; 147 - 148 - switch (var->bits_per_pixel) { 149 - case 1: 150 - case 2: 151 - case 4: 152 - case 8: 153 - /* If we can't do 5551, reject */ 154 - caps &= CLCD_CAP_5551; 155 - if (!caps) { 156 - ret = -EINVAL; 157 - break; 158 - } 159 - 160 - var->red.length = var->bits_per_pixel; 161 - var->red.offset = 0; 162 - var->green.length = var->bits_per_pixel; 163 - var->green.offset = 0; 164 - var->blue.length = var->bits_per_pixel; 165 - var->blue.offset = 0; 166 - break; 167 - 168 - case 16: 169 - /* If we can't do 444, 5551 or 565, reject */ 170 - if (!(caps & (CLCD_CAP_444 | CLCD_CAP_5551 | CLCD_CAP_565))) { 171 - ret = -EINVAL; 172 - break; 173 - } 174 - 175 - /* 176 - * Green length can be 4, 5 or 6 depending whether 177 - * we're operating in 444, 5551 or 565 mode. 178 - */ 179 - if (var->green.length == 4 && caps & CLCD_CAP_444) 180 - caps &= CLCD_CAP_444; 181 - if (var->green.length == 5 && caps & CLCD_CAP_5551) 182 - caps &= CLCD_CAP_5551; 183 - else if (var->green.length == 6 && caps & CLCD_CAP_565) 184 - caps &= CLCD_CAP_565; 185 - else { 186 - /* 187 - * PL110 officially only supports RGB555, 188 - * but may be wired up to allow RGB565. 189 - */ 190 - if (caps & CLCD_CAP_565) { 191 - var->green.length = 6; 192 - caps &= CLCD_CAP_565; 193 - } else if (caps & CLCD_CAP_5551) { 194 - var->green.length = 5; 195 - caps &= CLCD_CAP_5551; 196 - } else { 197 - var->green.length = 4; 198 - caps &= CLCD_CAP_444; 199 - } 200 - } 201 - 202 - if (var->green.length >= 5) { 203 - var->red.length = 5; 204 - var->blue.length = 5; 205 - } else { 206 - var->red.length = 4; 207 - var->blue.length = 4; 208 - } 209 - break; 210 - case 32: 211 - /* If we can't do 888, reject */ 212 - caps &= CLCD_CAP_888; 213 - if (!caps) { 214 - ret = -EINVAL; 215 - break; 216 - } 217 - 218 - var->red.length = 8; 219 - var->green.length = 8; 220 - var->blue.length = 8; 221 - break; 222 - default: 223 - ret = -EINVAL; 224 - break; 225 - } 226 - 227 - /* 228 - * >= 16bpp displays have separate colour component bitfields 229 - * encoded in the pixel data. Calculate their position from 230 - * the bitfield length defined above. 231 - */ 232 - if (ret == 0 && var->bits_per_pixel >= 16) { 233 - bool bgr, rgb; 234 - 235 - bgr = caps & CLCD_CAP_BGR && var->blue.offset == 0; 236 - rgb = caps & CLCD_CAP_RGB && var->red.offset == 0; 237 - 238 - if (!bgr && !rgb) 239 - /* 240 - * The requested format was not possible, try just 241 - * our capabilities. One of BGR or RGB must be 242 - * supported. 243 - */ 244 - bgr = caps & CLCD_CAP_BGR; 245 - 246 - if (bgr) { 247 - var->blue.offset = 0; 248 - var->green.offset = var->blue.offset + var->blue.length; 249 - var->red.offset = var->green.offset + var->green.length; 250 - } else { 251 - var->red.offset = 0; 252 - var->green.offset = var->red.offset + var->red.length; 253 - var->blue.offset = var->green.offset + var->green.length; 254 - } 255 - } 256 - 257 - return ret; 258 - } 259 - 260 - static int clcdfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) 261 - { 262 - struct clcd_fb *fb = to_clcd(info); 263 - int ret = -EINVAL; 264 - 265 - if (fb->board->check) 266 - ret = fb->board->check(fb, var); 267 - 268 - if (ret == 0 && 269 - var->xres_virtual * var->bits_per_pixel / 8 * 270 - var->yres_virtual > fb->fb.fix.smem_len) 271 - ret = -EINVAL; 272 - 273 - if (ret == 0) 274 - ret = clcdfb_set_bitfields(fb, var); 275 - 276 - return ret; 277 - } 278 - 279 - static int clcdfb_set_par(struct fb_info *info) 280 - { 281 - struct clcd_fb *fb = to_clcd(info); 282 - struct clcd_regs regs; 283 - 284 - fb->fb.fix.line_length = fb->fb.var.xres_virtual * 285 - fb->fb.var.bits_per_pixel / 8; 286 - 287 - if (fb->fb.var.bits_per_pixel <= 8) 288 - fb->fb.fix.visual = FB_VISUAL_PSEUDOCOLOR; 289 - else 290 - fb->fb.fix.visual = FB_VISUAL_TRUECOLOR; 291 - 292 - fb->board->decode(fb, &regs); 293 - 294 - clcdfb_disable(fb); 295 - 296 - writel(regs.tim0, fb->regs + CLCD_TIM0); 297 - writel(regs.tim1, fb->regs + CLCD_TIM1); 298 - writel(regs.tim2, fb->regs + CLCD_TIM2); 299 - writel(regs.tim3, fb->regs + CLCD_TIM3); 300 - 301 - clcdfb_set_start(fb); 302 - 303 - clk_set_rate(fb->clk, (1000000000 / regs.pixclock) * 1000); 304 - 305 - fb->clcd_cntl = regs.cntl; 306 - 307 - clcdfb_enable(fb, regs.cntl); 308 - 309 - #ifdef DEBUG 310 - printk(KERN_INFO 311 - "CLCD: Registers set to\n" 312 - " %08x %08x %08x %08x\n" 313 - " %08x %08x %08x %08x\n", 314 - readl(fb->regs + CLCD_TIM0), readl(fb->regs + CLCD_TIM1), 315 - readl(fb->regs + CLCD_TIM2), readl(fb->regs + CLCD_TIM3), 316 - readl(fb->regs + CLCD_UBAS), readl(fb->regs + CLCD_LBAS), 317 - readl(fb->regs + fb->off_ienb), readl(fb->regs + fb->off_cntl)); 318 - #endif 319 - 320 - return 0; 321 - } 322 - 323 - static inline u32 convert_bitfield(int val, struct fb_bitfield *bf) 324 - { 325 - unsigned int mask = (1 << bf->length) - 1; 326 - 327 - return (val >> (16 - bf->length) & mask) << bf->offset; 328 - } 329 - 330 - /* 331 - * Set a single color register. The values supplied have a 16 bit 332 - * magnitude. Return != 0 for invalid regno. 333 - */ 334 - static int 335 - clcdfb_setcolreg(unsigned int regno, unsigned int red, unsigned int green, 336 - unsigned int blue, unsigned int transp, struct fb_info *info) 337 - { 338 - struct clcd_fb *fb = to_clcd(info); 339 - 340 - if (regno < 16) 341 - fb->cmap[regno] = convert_bitfield(transp, &fb->fb.var.transp) | 342 - convert_bitfield(blue, &fb->fb.var.blue) | 343 - convert_bitfield(green, &fb->fb.var.green) | 344 - convert_bitfield(red, &fb->fb.var.red); 345 - 346 - if (fb->fb.fix.visual == FB_VISUAL_PSEUDOCOLOR && regno < 256) { 347 - int hw_reg = CLCD_PALETTE + ((regno * 2) & ~3); 348 - u32 val, mask, newval; 349 - 350 - newval = (red >> 11) & 0x001f; 351 - newval |= (green >> 6) & 0x03e0; 352 - newval |= (blue >> 1) & 0x7c00; 353 - 354 - /* 355 - * 3.2.11: if we're configured for big endian 356 - * byte order, the palette entries are swapped. 357 - */ 358 - if (fb->clcd_cntl & CNTL_BEBO) 359 - regno ^= 1; 360 - 361 - if (regno & 1) { 362 - newval <<= 16; 363 - mask = 0x0000ffff; 364 - } else { 365 - mask = 0xffff0000; 366 - } 367 - 368 - val = readl(fb->regs + hw_reg) & mask; 369 - writel(val | newval, fb->regs + hw_reg); 370 - } 371 - 372 - return regno > 255; 373 - } 374 - 375 - /* 376 - * Blank the screen if blank_mode != 0, else unblank. If blank == NULL 377 - * then the caller blanks by setting the CLUT (Color Look Up Table) to all 378 - * black. Return 0 if blanking succeeded, != 0 if un-/blanking failed due 379 - * to e.g. a video mode which doesn't support it. Implements VESA suspend 380 - * and powerdown modes on hardware that supports disabling hsync/vsync: 381 - * blank_mode == 2: suspend vsync 382 - * blank_mode == 3: suspend hsync 383 - * blank_mode == 4: powerdown 384 - */ 385 - static int clcdfb_blank(int blank_mode, struct fb_info *info) 386 - { 387 - struct clcd_fb *fb = to_clcd(info); 388 - 389 - if (blank_mode != 0) { 390 - clcdfb_disable(fb); 391 - } else { 392 - clcdfb_enable(fb, fb->clcd_cntl); 393 - } 394 - return 0; 395 - } 396 - 397 - static int clcdfb_mmap(struct fb_info *info, 398 - struct vm_area_struct *vma) 399 - { 400 - struct clcd_fb *fb = to_clcd(info); 401 - unsigned long len, off = vma->vm_pgoff << PAGE_SHIFT; 402 - int ret = -EINVAL; 403 - 404 - len = info->fix.smem_len; 405 - 406 - if (off <= len && vma->vm_end - vma->vm_start <= len - off && 407 - fb->board->mmap) 408 - ret = fb->board->mmap(fb, vma); 409 - 410 - return ret; 411 - } 412 - 413 - static const struct fb_ops clcdfb_ops = { 414 - .owner = THIS_MODULE, 415 - __FB_DEFAULT_IOMEM_OPS_RDWR, 416 - .fb_check_var = clcdfb_check_var, 417 - .fb_set_par = clcdfb_set_par, 418 - .fb_setcolreg = clcdfb_setcolreg, 419 - .fb_blank = clcdfb_blank, 420 - __FB_DEFAULT_IOMEM_OPS_DRAW, 421 - .fb_mmap = clcdfb_mmap, 422 - }; 423 - 424 - static int clcdfb_register(struct clcd_fb *fb) 425 - { 426 - int ret; 427 - 428 - /* 429 - * ARM PL111 always has IENB at 0x1c; it's only PL110 430 - * which is reversed on some platforms. 431 - */ 432 - if (amba_manf(fb->dev) == 0x41 && amba_part(fb->dev) == 0x111) { 433 - fb->off_ienb = CLCD_PL111_IENB; 434 - fb->off_cntl = CLCD_PL111_CNTL; 435 - } else { 436 - fb->off_ienb = CLCD_PL110_IENB; 437 - fb->off_cntl = CLCD_PL110_CNTL; 438 - } 439 - 440 - fb->clk = clk_get(&fb->dev->dev, NULL); 441 - if (IS_ERR(fb->clk)) { 442 - ret = PTR_ERR(fb->clk); 443 - goto out; 444 - } 445 - 446 - ret = clk_prepare(fb->clk); 447 - if (ret) 448 - goto free_clk; 449 - 450 - fb->fb.device = &fb->dev->dev; 451 - 452 - fb->fb.fix.mmio_start = fb->dev->res.start; 453 - fb->fb.fix.mmio_len = resource_size(&fb->dev->res); 454 - 455 - fb->regs = ioremap(fb->fb.fix.mmio_start, fb->fb.fix.mmio_len); 456 - if (!fb->regs) { 457 - printk(KERN_ERR "CLCD: unable to remap registers\n"); 458 - ret = -ENOMEM; 459 - goto clk_unprep; 460 - } 461 - 462 - fb->fb.fbops = &clcdfb_ops; 463 - fb->fb.pseudo_palette = fb->cmap; 464 - 465 - strncpy(fb->fb.fix.id, clcd_name, sizeof(fb->fb.fix.id)); 466 - fb->fb.fix.type = FB_TYPE_PACKED_PIXELS; 467 - fb->fb.fix.type_aux = 0; 468 - fb->fb.fix.xpanstep = 0; 469 - fb->fb.fix.ypanstep = 0; 470 - fb->fb.fix.ywrapstep = 0; 471 - fb->fb.fix.accel = FB_ACCEL_NONE; 472 - 473 - fb->fb.var.xres = fb->panel->mode.xres; 474 - fb->fb.var.yres = fb->panel->mode.yres; 475 - fb->fb.var.xres_virtual = fb->panel->mode.xres; 476 - fb->fb.var.yres_virtual = fb->panel->mode.yres; 477 - fb->fb.var.bits_per_pixel = fb->panel->bpp; 478 - fb->fb.var.grayscale = fb->panel->grayscale; 479 - fb->fb.var.pixclock = fb->panel->mode.pixclock; 480 - fb->fb.var.left_margin = fb->panel->mode.left_margin; 481 - fb->fb.var.right_margin = fb->panel->mode.right_margin; 482 - fb->fb.var.upper_margin = fb->panel->mode.upper_margin; 483 - fb->fb.var.lower_margin = fb->panel->mode.lower_margin; 484 - fb->fb.var.hsync_len = fb->panel->mode.hsync_len; 485 - fb->fb.var.vsync_len = fb->panel->mode.vsync_len; 486 - fb->fb.var.sync = fb->panel->mode.sync; 487 - fb->fb.var.vmode = fb->panel->mode.vmode; 488 - fb->fb.var.activate = FB_ACTIVATE_NOW; 489 - fb->fb.var.nonstd = 0; 490 - fb->fb.var.height = fb->panel->height; 491 - fb->fb.var.width = fb->panel->width; 492 - fb->fb.var.accel_flags = 0; 493 - 494 - fb->fb.monspecs.hfmin = 0; 495 - fb->fb.monspecs.hfmax = 100000; 496 - fb->fb.monspecs.vfmin = 0; 497 - fb->fb.monspecs.vfmax = 400; 498 - fb->fb.monspecs.dclkmin = 1000000; 499 - fb->fb.monspecs.dclkmax = 100000000; 500 - 501 - /* 502 - * Make sure that the bitfields are set appropriately. 503 - */ 504 - clcdfb_set_bitfields(fb, &fb->fb.var); 505 - 506 - /* 507 - * Allocate colourmap. 508 - */ 509 - ret = fb_alloc_cmap(&fb->fb.cmap, 256, 0); 510 - if (ret) 511 - goto unmap; 512 - 513 - /* 514 - * Ensure interrupts are disabled. 515 - */ 516 - writel(0, fb->regs + fb->off_ienb); 517 - 518 - fb_set_var(&fb->fb, &fb->fb.var); 519 - 520 - dev_info(&fb->dev->dev, "%s hardware, %s display\n", 521 - fb->board->name, fb->panel->mode.name); 522 - 523 - ret = register_framebuffer(&fb->fb); 524 - if (ret == 0) 525 - goto out; 526 - 527 - printk(KERN_ERR "CLCD: cannot register framebuffer (%d)\n", ret); 528 - 529 - fb_dealloc_cmap(&fb->fb.cmap); 530 - unmap: 531 - iounmap(fb->regs); 532 - clk_unprep: 533 - clk_unprepare(fb->clk); 534 - free_clk: 535 - clk_put(fb->clk); 536 - out: 537 - return ret; 538 - } 539 - 540 - #ifdef CONFIG_OF 541 - static int clcdfb_of_get_dpi_panel_mode(struct device_node *node, 542 - struct clcd_panel *clcd_panel) 543 - { 544 - int err; 545 - struct display_timing timing; 546 - struct videomode video; 547 - 548 - err = of_get_display_timing(node, "panel-timing", &timing); 549 - if (err) { 550 - pr_err("%pOF: problems parsing panel-timing (%d)\n", node, err); 551 - return err; 552 - } 553 - 554 - videomode_from_timing(&timing, &video); 555 - 556 - err = fb_videomode_from_videomode(&video, &clcd_panel->mode); 557 - if (err) 558 - return err; 559 - 560 - /* Set up some inversion flags */ 561 - if (timing.flags & DISPLAY_FLAGS_PIXDATA_NEGEDGE) 562 - clcd_panel->tim2 |= TIM2_IPC; 563 - else if (!(timing.flags & DISPLAY_FLAGS_PIXDATA_POSEDGE)) 564 - /* 565 - * To preserve backwards compatibility, the IPC (inverted 566 - * pixel clock) flag needs to be set on any display that 567 - * doesn't explicitly specify that the pixel clock is 568 - * active on the negative or positive edge. 569 - */ 570 - clcd_panel->tim2 |= TIM2_IPC; 571 - 572 - if (timing.flags & DISPLAY_FLAGS_HSYNC_LOW) 573 - clcd_panel->tim2 |= TIM2_IHS; 574 - 575 - if (timing.flags & DISPLAY_FLAGS_VSYNC_LOW) 576 - clcd_panel->tim2 |= TIM2_IVS; 577 - 578 - if (timing.flags & DISPLAY_FLAGS_DE_LOW) 579 - clcd_panel->tim2 |= TIM2_IOE; 580 - 581 - return 0; 582 - } 583 - 584 - static int clcdfb_snprintf_mode(char *buf, int size, struct fb_videomode *mode) 585 - { 586 - return snprintf(buf, size, "%ux%u@%u", mode->xres, mode->yres, 587 - mode->refresh); 588 - } 589 - 590 - static int clcdfb_of_get_backlight(struct device *dev, 591 - struct clcd_panel *clcd_panel) 592 - { 593 - struct backlight_device *backlight; 594 - 595 - /* Look up the optional backlight device */ 596 - backlight = devm_of_find_backlight(dev); 597 - if (IS_ERR(backlight)) 598 - return PTR_ERR(backlight); 599 - 600 - clcd_panel->backlight = backlight; 601 - return 0; 602 - } 603 - 604 - static int clcdfb_of_get_mode(struct device *dev, struct device_node *panel, 605 - struct clcd_panel *clcd_panel) 606 - { 607 - int err; 608 - struct fb_videomode *mode; 609 - char *name; 610 - int len; 611 - 612 - /* Only directly connected DPI panels supported for now */ 613 - if (of_device_is_compatible(panel, "panel-dpi")) 614 - err = clcdfb_of_get_dpi_panel_mode(panel, clcd_panel); 615 - else 616 - err = -ENOENT; 617 - if (err) 618 - return err; 619 - mode = &clcd_panel->mode; 620 - 621 - len = clcdfb_snprintf_mode(NULL, 0, mode); 622 - name = devm_kzalloc(dev, len + 1, GFP_KERNEL); 623 - if (!name) 624 - return -ENOMEM; 625 - 626 - clcdfb_snprintf_mode(name, len + 1, mode); 627 - mode->name = name; 628 - 629 - return 0; 630 - } 631 - 632 - static int clcdfb_of_init_tft_panel(struct clcd_fb *fb, u32 r0, u32 g0, u32 b0) 633 - { 634 - static struct { 635 - unsigned int part; 636 - u32 r0, g0, b0; 637 - u32 caps; 638 - } panels[] = { 639 - { 0x110, 1, 7, 13, CLCD_CAP_5551 }, 640 - { 0x110, 0, 8, 16, CLCD_CAP_888 }, 641 - { 0x110, 16, 8, 0, CLCD_CAP_888 }, 642 - { 0x111, 4, 14, 20, CLCD_CAP_444 }, 643 - { 0x111, 3, 11, 19, CLCD_CAP_444 | CLCD_CAP_5551 }, 644 - { 0x111, 3, 10, 19, CLCD_CAP_444 | CLCD_CAP_5551 | 645 - CLCD_CAP_565 }, 646 - { 0x111, 0, 8, 16, CLCD_CAP_444 | CLCD_CAP_5551 | 647 - CLCD_CAP_565 | CLCD_CAP_888 }, 648 - }; 649 - int i; 650 - 651 - /* Bypass pixel clock divider */ 652 - fb->panel->tim2 |= TIM2_BCD; 653 - 654 - /* TFT display, vert. comp. interrupt at the start of the back porch */ 655 - fb->panel->cntl |= CNTL_LCDTFT | CNTL_LCDVCOMP(1); 656 - 657 - fb->panel->caps = 0; 658 - 659 - /* Match the setup with known variants */ 660 - for (i = 0; i < ARRAY_SIZE(panels) && !fb->panel->caps; i++) { 661 - if (amba_part(fb->dev) != panels[i].part) 662 - continue; 663 - if (g0 != panels[i].g0) 664 - continue; 665 - if (r0 == panels[i].r0 && b0 == panels[i].b0) 666 - fb->panel->caps = panels[i].caps; 667 - } 668 - 669 - /* 670 - * If we actually physically connected the R lines to B and 671 - * vice versa 672 - */ 673 - if (r0 != 0 && b0 == 0) 674 - fb->panel->bgr_connection = true; 675 - 676 - return fb->panel->caps ? 0 : -EINVAL; 677 - } 678 - 679 - static int clcdfb_of_init_display(struct clcd_fb *fb) 680 - { 681 - struct device_node *endpoint, *panel; 682 - int err; 683 - unsigned int bpp; 684 - u32 max_bandwidth; 685 - u32 tft_r0b0g0[3]; 686 - 687 - fb->panel = devm_kzalloc(&fb->dev->dev, sizeof(*fb->panel), GFP_KERNEL); 688 - if (!fb->panel) 689 - return -ENOMEM; 690 - 691 - /* 692 - * Fetch the panel endpoint. 693 - */ 694 - endpoint = of_graph_get_next_endpoint(fb->dev->dev.of_node, NULL); 695 - if (!endpoint) 696 - return -ENODEV; 697 - 698 - panel = of_graph_get_remote_port_parent(endpoint); 699 - if (!panel) { 700 - err = -ENODEV; 701 - goto out_endpoint_put; 702 - } 703 - 704 - err = clcdfb_of_get_backlight(&fb->dev->dev, fb->panel); 705 - if (err) 706 - goto out_panel_put; 707 - 708 - err = clcdfb_of_get_mode(&fb->dev->dev, panel, fb->panel); 709 - if (err) 710 - goto out_panel_put; 711 - 712 - err = of_property_read_u32(fb->dev->dev.of_node, "max-memory-bandwidth", 713 - &max_bandwidth); 714 - if (!err) { 715 - /* 716 - * max_bandwidth is in bytes per second and pixclock in 717 - * pico-seconds, so the maximum allowed bits per pixel is 718 - * 8 * max_bandwidth / (PICOS2KHZ(pixclock) * 1000) 719 - * Rearrange this calculation to avoid overflow and then ensure 720 - * result is a valid format. 721 - */ 722 - bpp = max_bandwidth / (1000 / 8) 723 - / PICOS2KHZ(fb->panel->mode.pixclock); 724 - bpp = rounddown_pow_of_two(bpp); 725 - if (bpp > 32) 726 - bpp = 32; 727 - } else 728 - bpp = 32; 729 - fb->panel->bpp = bpp; 730 - 731 - #ifdef CONFIG_CPU_BIG_ENDIAN 732 - fb->panel->cntl |= CNTL_BEBO; 733 - #endif 734 - fb->panel->width = -1; 735 - fb->panel->height = -1; 736 - 737 - if (of_property_read_u32_array(endpoint, 738 - "arm,pl11x,tft-r0g0b0-pads", 739 - tft_r0b0g0, ARRAY_SIZE(tft_r0b0g0)) != 0) { 740 - err = -ENOENT; 741 - goto out_panel_put; 742 - } 743 - 744 - of_node_put(panel); 745 - of_node_put(endpoint); 746 - 747 - return clcdfb_of_init_tft_panel(fb, tft_r0b0g0[0], 748 - tft_r0b0g0[1], tft_r0b0g0[2]); 749 - out_panel_put: 750 - of_node_put(panel); 751 - out_endpoint_put: 752 - of_node_put(endpoint); 753 - return err; 754 - } 755 - 756 - static int clcdfb_of_vram_setup(struct clcd_fb *fb) 757 - { 758 - int err; 759 - struct device_node *memory; 760 - u64 size; 761 - 762 - err = clcdfb_of_init_display(fb); 763 - if (err) 764 - return err; 765 - 766 - memory = of_parse_phandle(fb->dev->dev.of_node, "memory-region", 0); 767 - if (!memory) 768 - return -ENODEV; 769 - 770 - fb->fb.screen_base = of_iomap(memory, 0); 771 - if (!fb->fb.screen_base) { 772 - of_node_put(memory); 773 - return -ENOMEM; 774 - } 775 - 776 - fb->fb.fix.smem_start = of_translate_address(memory, 777 - of_get_address(memory, 0, &size, NULL)); 778 - fb->fb.fix.smem_len = size; 779 - of_node_put(memory); 780 - 781 - return 0; 782 - } 783 - 784 - static int clcdfb_of_vram_mmap(struct clcd_fb *fb, struct vm_area_struct *vma) 785 - { 786 - unsigned long off, user_size, kernel_size; 787 - 788 - 789 - off = vma->vm_pgoff << PAGE_SHIFT; 790 - user_size = vma->vm_end - vma->vm_start; 791 - kernel_size = fb->fb.fix.smem_len; 792 - 793 - if (off >= kernel_size || user_size > (kernel_size - off)) 794 - return -ENXIO; 795 - 796 - return remap_pfn_range(vma, vma->vm_start, 797 - __phys_to_pfn(fb->fb.fix.smem_start) + vma->vm_pgoff, 798 - user_size, 799 - pgprot_writecombine(vma->vm_page_prot)); 800 - } 801 - 802 - static void clcdfb_of_vram_remove(struct clcd_fb *fb) 803 - { 804 - iounmap(fb->fb.screen_base); 805 - } 806 - 807 - static int clcdfb_of_dma_setup(struct clcd_fb *fb) 808 - { 809 - unsigned long framesize; 810 - dma_addr_t dma; 811 - int err; 812 - 813 - err = clcdfb_of_init_display(fb); 814 - if (err) 815 - return err; 816 - 817 - framesize = PAGE_ALIGN(fb->panel->mode.xres * fb->panel->mode.yres * 818 - fb->panel->bpp / 8); 819 - fb->fb.screen_base = dma_alloc_coherent(&fb->dev->dev, framesize, 820 - &dma, GFP_KERNEL); 821 - if (!fb->fb.screen_base) 822 - return -ENOMEM; 823 - 824 - fb->fb.fix.smem_start = dma; 825 - fb->fb.fix.smem_len = framesize; 826 - 827 - return 0; 828 - } 829 - 830 - static int clcdfb_of_dma_mmap(struct clcd_fb *fb, struct vm_area_struct *vma) 831 - { 832 - return dma_mmap_wc(&fb->dev->dev, vma, fb->fb.screen_base, 833 - fb->fb.fix.smem_start, fb->fb.fix.smem_len); 834 - } 835 - 836 - static void clcdfb_of_dma_remove(struct clcd_fb *fb) 837 - { 838 - dma_free_coherent(&fb->dev->dev, fb->fb.fix.smem_len, 839 - fb->fb.screen_base, fb->fb.fix.smem_start); 840 - } 841 - 842 - static struct clcd_board *clcdfb_of_get_board(struct amba_device *dev) 843 - { 844 - struct clcd_board *board = devm_kzalloc(&dev->dev, sizeof(*board), 845 - GFP_KERNEL); 846 - struct device_node *node = dev->dev.of_node; 847 - 848 - if (!board) 849 - return NULL; 850 - 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_property_present(node, "memory-region")) { 856 - board->setup = clcdfb_of_vram_setup; 857 - board->mmap = clcdfb_of_vram_mmap; 858 - board->remove = clcdfb_of_vram_remove; 859 - } else { 860 - board->setup = clcdfb_of_dma_setup; 861 - board->mmap = clcdfb_of_dma_mmap; 862 - board->remove = clcdfb_of_dma_remove; 863 - } 864 - 865 - return board; 866 - } 867 - #else 868 - static struct clcd_board *clcdfb_of_get_board(struct amba_device *dev) 869 - { 870 - return NULL; 871 - } 872 - #endif 873 - 874 - static int clcdfb_probe(struct amba_device *dev, const struct amba_id *id) 875 - { 876 - struct clcd_board *board = dev_get_platdata(&dev->dev); 877 - struct clcd_fb *fb; 878 - int ret; 879 - 880 - if (!board) 881 - board = clcdfb_of_get_board(dev); 882 - 883 - if (!board) 884 - return -EINVAL; 885 - 886 - ret = dma_set_mask_and_coherent(&dev->dev, DMA_BIT_MASK(32)); 887 - if (ret) 888 - goto out; 889 - 890 - ret = amba_request_regions(dev, NULL); 891 - if (ret) { 892 - printk(KERN_ERR "CLCD: unable to reserve regs region\n"); 893 - goto out; 894 - } 895 - 896 - fb = kzalloc(sizeof(*fb), GFP_KERNEL); 897 - if (!fb) { 898 - ret = -ENOMEM; 899 - goto free_region; 900 - } 901 - 902 - fb->dev = dev; 903 - fb->board = board; 904 - 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); 908 - 909 - ret = fb->board->setup(fb); 910 - if (ret) 911 - goto free_fb; 912 - 913 - ret = clcdfb_register(fb); 914 - if (ret == 0) { 915 - amba_set_drvdata(dev, fb); 916 - goto out; 917 - } 918 - 919 - fb->board->remove(fb); 920 - free_fb: 921 - kfree(fb); 922 - free_region: 923 - amba_release_regions(dev); 924 - out: 925 - return ret; 926 - } 927 - 928 - static void clcdfb_remove(struct amba_device *dev) 929 - { 930 - struct clcd_fb *fb = amba_get_drvdata(dev); 931 - 932 - clcdfb_disable(fb); 933 - unregister_framebuffer(&fb->fb); 934 - if (fb->fb.cmap.len) 935 - fb_dealloc_cmap(&fb->fb.cmap); 936 - iounmap(fb->regs); 937 - clk_unprepare(fb->clk); 938 - clk_put(fb->clk); 939 - 940 - fb->board->remove(fb); 941 - 942 - kfree(fb); 943 - 944 - amba_release_regions(dev); 945 - } 946 - 947 - static const struct amba_id clcdfb_id_table[] = { 948 - { 949 - .id = 0x00041110, 950 - .mask = 0x000ffffe, 951 - }, 952 - { 0, 0 }, 953 - }; 954 - 955 - MODULE_DEVICE_TABLE(amba, clcdfb_id_table); 956 - 957 - static struct amba_driver clcd_driver = { 958 - .drv = { 959 - .name = "clcd-pl11x", 960 - }, 961 - .probe = clcdfb_probe, 962 - .remove = clcdfb_remove, 963 - .id_table = clcdfb_id_table, 964 - }; 965 - 966 - static int __init amba_clcdfb_init(void) 967 - { 968 - if (fb_get_options("ambafb", NULL)) 969 - return -ENODEV; 970 - 971 - return amba_driver_register(&clcd_driver); 972 - } 973 - 974 - module_init(amba_clcdfb_init); 975 - 976 - static void __exit amba_clcdfb_exit(void) 977 - { 978 - amba_driver_unregister(&clcd_driver); 979 - } 980 - 981 - module_exit(amba_clcdfb_exit); 982 - 983 - MODULE_DESCRIPTION("ARM PrimeCell PL110 CLCD core driver"); 984 - MODULE_LICENSE("GPL");
-87
include/linux/amba/clcd-regs.h
··· 1 - /* 2 - * David A Rusling 3 - * 4 - * Copyright (C) 2001 ARM Limited 5 - * 6 - * This file is subject to the terms and conditions of the GNU General Public 7 - * License. See the file COPYING in the main directory of this archive 8 - * for more details. 9 - */ 10 - 11 - #ifndef AMBA_CLCD_REGS_H 12 - #define AMBA_CLCD_REGS_H 13 - 14 - /* 15 - * CLCD Controller Internal Register addresses 16 - */ 17 - #define CLCD_TIM0 0x00000000 18 - #define CLCD_TIM1 0x00000004 19 - #define CLCD_TIM2 0x00000008 20 - #define CLCD_TIM3 0x0000000c 21 - #define CLCD_UBAS 0x00000010 22 - #define CLCD_LBAS 0x00000014 23 - 24 - #define CLCD_PL110_IENB 0x00000018 25 - #define CLCD_PL110_CNTL 0x0000001c 26 - #define CLCD_PL110_STAT 0x00000020 27 - #define CLCD_PL110_INTR 0x00000024 28 - #define CLCD_PL110_UCUR 0x00000028 29 - #define CLCD_PL110_LCUR 0x0000002C 30 - 31 - #define CLCD_PL111_CNTL 0x00000018 32 - #define CLCD_PL111_IENB 0x0000001c 33 - #define CLCD_PL111_RIS 0x00000020 34 - #define CLCD_PL111_MIS 0x00000024 35 - #define CLCD_PL111_ICR 0x00000028 36 - #define CLCD_PL111_UCUR 0x0000002c 37 - #define CLCD_PL111_LCUR 0x00000030 38 - 39 - #define CLCD_PALL 0x00000200 40 - #define CLCD_PALETTE 0x00000200 41 - 42 - #define TIM2_PCD_LO_MASK GENMASK(4, 0) 43 - #define TIM2_PCD_LO_BITS 5 44 - #define TIM2_CLKSEL (1 << 5) 45 - #define TIM2_ACB_MASK GENMASK(10, 6) 46 - #define TIM2_IVS (1 << 11) 47 - #define TIM2_IHS (1 << 12) 48 - #define TIM2_IPC (1 << 13) 49 - #define TIM2_IOE (1 << 14) 50 - #define TIM2_BCD (1 << 26) 51 - #define TIM2_PCD_HI_MASK GENMASK(31, 27) 52 - #define TIM2_PCD_HI_BITS 5 53 - #define TIM2_PCD_HI_SHIFT 27 54 - 55 - #define CNTL_LCDEN (1 << 0) 56 - #define CNTL_LCDBPP1 (0 << 1) 57 - #define CNTL_LCDBPP2 (1 << 1) 58 - #define CNTL_LCDBPP4 (2 << 1) 59 - #define CNTL_LCDBPP8 (3 << 1) 60 - #define CNTL_LCDBPP16 (4 << 1) 61 - #define CNTL_LCDBPP16_565 (6 << 1) 62 - #define CNTL_LCDBPP16_444 (7 << 1) 63 - #define CNTL_LCDBPP24 (5 << 1) 64 - #define CNTL_LCDBW (1 << 4) 65 - #define CNTL_LCDTFT (1 << 5) 66 - #define CNTL_LCDMONO8 (1 << 6) 67 - #define CNTL_LCDDUAL (1 << 7) 68 - #define CNTL_BGR (1 << 8) 69 - #define CNTL_BEBO (1 << 9) 70 - #define CNTL_BEPO (1 << 10) 71 - #define CNTL_LCDPWR (1 << 11) 72 - #define CNTL_LCDVCOMP(x) ((x) << 12) 73 - #define CNTL_LDMAFIFOTIME (1 << 15) 74 - #define CNTL_WATERMARK (1 << 16) 75 - 76 - /* ST Microelectronics variant bits */ 77 - #define CNTL_ST_1XBPP_444 0x0 78 - #define CNTL_ST_1XBPP_5551 (1 << 17) 79 - #define CNTL_ST_1XBPP_565 (1 << 18) 80 - #define CNTL_ST_CDWID_12 0x0 81 - #define CNTL_ST_CDWID_16 (1 << 19) 82 - #define CNTL_ST_CDWID_18 (1 << 20) 83 - #define CNTL_ST_CDWID_24 ((1 << 19)|(1 << 20)) 84 - #define CNTL_ST_CEAEN (1 << 21) 85 - #define CNTL_ST_LCDBPP24_PACKED (6 << 1) 86 - 87 - #endif /* AMBA_CLCD_REGS_H */
-290
include/linux/amba/clcd.h
··· 1 - /* 2 - * linux/include/asm-arm/hardware/amba_clcd.h -- Integrator LCD panel. 3 - * 4 - * David A Rusling 5 - * 6 - * Copyright (C) 2001 ARM Limited 7 - * 8 - * This file is subject to the terms and conditions of the GNU General Public 9 - * License. See the file COPYING in the main directory of this archive 10 - * for more details. 11 - */ 12 - #include <linux/fb.h> 13 - #include <linux/amba/clcd-regs.h> 14 - 15 - enum { 16 - /* individual formats */ 17 - CLCD_CAP_RGB444 = (1 << 0), 18 - CLCD_CAP_RGB5551 = (1 << 1), 19 - CLCD_CAP_RGB565 = (1 << 2), 20 - CLCD_CAP_RGB888 = (1 << 3), 21 - CLCD_CAP_BGR444 = (1 << 4), 22 - CLCD_CAP_BGR5551 = (1 << 5), 23 - CLCD_CAP_BGR565 = (1 << 6), 24 - CLCD_CAP_BGR888 = (1 << 7), 25 - 26 - /* connection layouts */ 27 - CLCD_CAP_444 = CLCD_CAP_RGB444 | CLCD_CAP_BGR444, 28 - CLCD_CAP_5551 = CLCD_CAP_RGB5551 | CLCD_CAP_BGR5551, 29 - CLCD_CAP_565 = CLCD_CAP_RGB565 | CLCD_CAP_BGR565, 30 - CLCD_CAP_888 = CLCD_CAP_RGB888 | CLCD_CAP_BGR888, 31 - 32 - /* red/blue ordering */ 33 - CLCD_CAP_RGB = CLCD_CAP_RGB444 | CLCD_CAP_RGB5551 | 34 - CLCD_CAP_RGB565 | CLCD_CAP_RGB888, 35 - CLCD_CAP_BGR = CLCD_CAP_BGR444 | CLCD_CAP_BGR5551 | 36 - CLCD_CAP_BGR565 | CLCD_CAP_BGR888, 37 - 38 - CLCD_CAP_ALL = CLCD_CAP_BGR | CLCD_CAP_RGB, 39 - }; 40 - 41 - struct backlight_device; 42 - 43 - struct clcd_panel { 44 - struct fb_videomode mode; 45 - signed short width; /* width in mm */ 46 - signed short height; /* height in mm */ 47 - u32 tim2; 48 - u32 tim3; 49 - u32 cntl; 50 - u32 caps; 51 - unsigned int bpp:8, 52 - fixedtimings:1, 53 - grayscale:1; 54 - unsigned int connector; 55 - struct backlight_device *backlight; 56 - /* 57 - * If the B/R lines are switched between the CLCD 58 - * and the panel we need to know this and not try to 59 - * compensate with the BGR bit in the control register. 60 - */ 61 - bool bgr_connection; 62 - }; 63 - 64 - struct clcd_regs { 65 - u32 tim0; 66 - u32 tim1; 67 - u32 tim2; 68 - u32 tim3; 69 - u32 cntl; 70 - unsigned long pixclock; 71 - }; 72 - 73 - struct clcd_fb; 74 - 75 - /* 76 - * the board-type specific routines 77 - */ 78 - struct clcd_board { 79 - const char *name; 80 - 81 - /* 82 - * Optional. Hardware capability flags. 83 - */ 84 - u32 caps; 85 - 86 - /* 87 - * Optional. Check whether the var structure is acceptable 88 - * for this display. 89 - */ 90 - int (*check)(struct clcd_fb *fb, struct fb_var_screeninfo *var); 91 - 92 - /* 93 - * Compulsory. Decode fb->fb.var into regs->*. In the case of 94 - * fixed timing, set regs->* to the register values required. 95 - */ 96 - void (*decode)(struct clcd_fb *fb, struct clcd_regs *regs); 97 - 98 - /* 99 - * Optional. Disable any extra display hardware. 100 - */ 101 - void (*disable)(struct clcd_fb *); 102 - 103 - /* 104 - * Optional. Enable any extra display hardware. 105 - */ 106 - void (*enable)(struct clcd_fb *); 107 - 108 - /* 109 - * Setup platform specific parts of CLCD driver 110 - */ 111 - int (*setup)(struct clcd_fb *); 112 - 113 - /* 114 - * mmap the framebuffer memory 115 - */ 116 - int (*mmap)(struct clcd_fb *, struct vm_area_struct *); 117 - 118 - /* 119 - * Remove platform specific parts of CLCD driver 120 - */ 121 - void (*remove)(struct clcd_fb *); 122 - }; 123 - 124 - struct amba_device; 125 - struct clk; 126 - 127 - /* this data structure describes each frame buffer device we find */ 128 - struct clcd_fb { 129 - struct fb_info fb; 130 - struct amba_device *dev; 131 - struct clk *clk; 132 - struct clcd_panel *panel; 133 - struct clcd_board *board; 134 - void *board_data; 135 - void __iomem *regs; 136 - u16 off_ienb; 137 - u16 off_cntl; 138 - u32 clcd_cntl; 139 - u32 cmap[16]; 140 - bool clk_enabled; 141 - }; 142 - 143 - static inline void clcdfb_decode(struct clcd_fb *fb, struct clcd_regs *regs) 144 - { 145 - struct fb_var_screeninfo *var = &fb->fb.var; 146 - u32 val, cpl; 147 - 148 - /* 149 - * Program the CLCD controller registers and start the CLCD 150 - */ 151 - val = ((var->xres / 16) - 1) << 2; 152 - val |= (var->hsync_len - 1) << 8; 153 - val |= (var->right_margin - 1) << 16; 154 - val |= (var->left_margin - 1) << 24; 155 - regs->tim0 = val; 156 - 157 - val = var->yres; 158 - if (fb->panel->cntl & CNTL_LCDDUAL) 159 - val /= 2; 160 - val -= 1; 161 - val |= (var->vsync_len - 1) << 10; 162 - val |= var->lower_margin << 16; 163 - val |= var->upper_margin << 24; 164 - regs->tim1 = val; 165 - 166 - val = fb->panel->tim2; 167 - val |= var->sync & FB_SYNC_HOR_HIGH_ACT ? 0 : TIM2_IHS; 168 - val |= var->sync & FB_SYNC_VERT_HIGH_ACT ? 0 : TIM2_IVS; 169 - 170 - cpl = var->xres_virtual; 171 - if (fb->panel->cntl & CNTL_LCDTFT) /* TFT */ 172 - /* / 1 */; 173 - else if (!var->grayscale) /* STN color */ 174 - cpl = cpl * 8 / 3; 175 - else if (fb->panel->cntl & CNTL_LCDMONO8) /* STN monochrome, 8bit */ 176 - cpl /= 8; 177 - else /* STN monochrome, 4bit */ 178 - cpl /= 4; 179 - 180 - regs->tim2 = val | ((cpl - 1) << 16); 181 - 182 - regs->tim3 = fb->panel->tim3; 183 - 184 - val = fb->panel->cntl; 185 - if (var->grayscale) 186 - val |= CNTL_LCDBW; 187 - 188 - if (fb->panel->caps && fb->board->caps && var->bits_per_pixel >= 16) { 189 - /* 190 - * if board and panel supply capabilities, we can support 191 - * changing BGR/RGB depending on supplied parameters. Here 192 - * we switch to what the framebuffer is providing if need 193 - * be, so if the framebuffer is BGR but the display connection 194 - * is RGB (first case) we switch it around. Vice versa mutatis 195 - * mutandis if the framebuffer is RGB but the display connection 196 - * is BGR, we flip it around. 197 - */ 198 - if (var->red.offset == 0) 199 - val &= ~CNTL_BGR; 200 - else 201 - val |= CNTL_BGR; 202 - if (fb->panel->bgr_connection) 203 - val ^= CNTL_BGR; 204 - } 205 - 206 - switch (var->bits_per_pixel) { 207 - case 1: 208 - val |= CNTL_LCDBPP1; 209 - break; 210 - case 2: 211 - val |= CNTL_LCDBPP2; 212 - break; 213 - case 4: 214 - val |= CNTL_LCDBPP4; 215 - break; 216 - case 8: 217 - val |= CNTL_LCDBPP8; 218 - break; 219 - case 16: 220 - /* 221 - * PL110 cannot choose between 5551 and 565 modes in its 222 - * control register. It is possible to use 565 with 223 - * custom external wiring. 224 - */ 225 - if (amba_part(fb->dev) == 0x110 || 226 - var->green.length == 5) 227 - val |= CNTL_LCDBPP16; 228 - else if (var->green.length == 6) 229 - val |= CNTL_LCDBPP16_565; 230 - else 231 - val |= CNTL_LCDBPP16_444; 232 - break; 233 - case 32: 234 - val |= CNTL_LCDBPP24; 235 - break; 236 - } 237 - 238 - regs->cntl = val; 239 - regs->pixclock = var->pixclock; 240 - } 241 - 242 - static inline int clcdfb_check(struct clcd_fb *fb, struct fb_var_screeninfo *var) 243 - { 244 - var->xres_virtual = var->xres = (var->xres + 15) & ~15; 245 - var->yres_virtual = var->yres = (var->yres + 1) & ~1; 246 - 247 - #define CHECK(e,l,h) (var->e < l || var->e > h) 248 - if (CHECK(right_margin, (5+1), 256) || /* back porch */ 249 - CHECK(left_margin, (5+1), 256) || /* front porch */ 250 - CHECK(hsync_len, (5+1), 256) || 251 - var->xres > 4096 || 252 - var->lower_margin > 255 || /* back porch */ 253 - var->upper_margin > 255 || /* front porch */ 254 - var->vsync_len > 32 || 255 - var->yres > 1024) 256 - return -EINVAL; 257 - #undef CHECK 258 - 259 - /* single panel mode: PCD = max(PCD, 1) */ 260 - /* dual panel mode: PCD = max(PCD, 5) */ 261 - 262 - /* 263 - * You can't change the grayscale setting, and 264 - * we can only do non-interlaced video. 265 - */ 266 - if (var->grayscale != fb->fb.var.grayscale || 267 - (var->vmode & FB_VMODE_MASK) != FB_VMODE_NONINTERLACED) 268 - return -EINVAL; 269 - 270 - #define CHECK(e) (var->e != fb->fb.var.e) 271 - if (fb->panel->fixedtimings && 272 - (CHECK(xres) || 273 - CHECK(yres) || 274 - CHECK(bits_per_pixel) || 275 - CHECK(pixclock) || 276 - CHECK(left_margin) || 277 - CHECK(right_margin) || 278 - CHECK(upper_margin) || 279 - CHECK(lower_margin) || 280 - CHECK(hsync_len) || 281 - CHECK(vsync_len) || 282 - CHECK(sync))) 283 - return -EINVAL; 284 - #undef CHECK 285 - 286 - var->nonstd = 0; 287 - var->accel_flags = 0; 288 - 289 - return 0; 290 - }