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

MIPS: Alchemy: au1100fb: use clk framework

Use the clock framework to en/disable the clock to the au1100
framebuffer device.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
Cc: Linux-MIPS <linux-mips@linux-mips.org>
Patchwork: https://patchwork.linux-mips.org/patch/7474/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

Manuel Lauss and committed by
Ralf Baechle
6b1889c1 9178af9a

+37 -14
+14
arch/mips/alchemy/devboards/db1000.c
··· 19 19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 20 */ 21 21 22 + #include <linux/clk.h> 22 23 #include <linux/dma-mapping.h> 23 24 #include <linux/gpio.h> 24 25 #include <linux/init.h> ··· 497 496 int board = BCSR_WHOAMI_BOARD(bcsr_read(BCSR_WHOAMI)); 498 497 int c0, c1, d0, d1, s0, s1, flashsize = 32, twosocks = 1; 499 498 unsigned long pfc; 499 + struct clk *c, *p; 500 500 501 501 if (board == BCSR_WHOAMI_DB1500) { 502 502 c0 = AU1500_GPIO2_INT; ··· 526 524 527 525 spi_register_board_info(db1100_spi_info, 528 526 ARRAY_SIZE(db1100_spi_info)); 527 + 528 + /* link LCD clock to AUXPLL */ 529 + p = clk_get(NULL, "auxpll_clk"); 530 + c = clk_get(NULL, "lcd_intclk"); 531 + if (!IS_ERR(c) && !IS_ERR(p)) { 532 + clk_set_parent(c, p); 533 + clk_set_rate(c, clk_get_rate(p)); 534 + } 535 + if (!IS_ERR(c)) 536 + clk_put(c); 537 + if (!IS_ERR(p)) 538 + clk_put(p); 529 539 530 540 platform_add_devices(db1100_devs, ARRAY_SIZE(db1100_devs)); 531 541 platform_device_register(&db1100_spi_dev);
+22 -14
drivers/video/fbdev/au1100fb.c
··· 41 41 * with this program; if not, write to the Free Software Foundation, Inc., 42 42 * 675 Mass Ave, Cambridge, MA 02139, USA. 43 43 */ 44 + #include <linux/clk.h> 44 45 #include <linux/module.h> 45 46 #include <linux/kernel.h> 46 47 #include <linux/errno.h> ··· 435 434 struct au1100fb_device *fbdev = NULL; 436 435 struct resource *regs_res; 437 436 unsigned long page; 438 - u32 sys_clksrc; 437 + struct clk *c; 439 438 440 439 /* Allocate new device private */ 441 440 fbdev = devm_kzalloc(&dev->dev, sizeof(struct au1100fb_device), ··· 474 473 print_dbg("Register memory map at %p", fbdev->regs); 475 474 print_dbg("phys=0x%08x, size=%d", fbdev->regs_phys, fbdev->regs_len); 476 475 476 + c = clk_get(NULL, "lcd_intclk"); 477 + if (!IS_ERR(c)) { 478 + fbdev->lcdclk = c; 479 + clk_set_rate(c, 48000000); 480 + clk_prepare_enable(c); 481 + } 482 + 477 483 /* Allocate the framebuffer to the maximum screen size * nbr of video buffers */ 478 484 fbdev->fb_len = fbdev->panel->xres * fbdev->panel->yres * 479 485 (fbdev->panel->bpp >> 3) * AU1100FB_NBR_VIDEO_BUFFERS; ··· 513 505 514 506 print_dbg("Framebuffer memory map at %p", fbdev->fb_mem); 515 507 print_dbg("phys=0x%08x, size=%dK", fbdev->fb_phys, fbdev->fb_len / 1024); 516 - 517 - /* Setup LCD clock to AUX (48 MHz) */ 518 - sys_clksrc = alchemy_rdsys(AU1000_SYS_CLKSRC); 519 - sys_clksrc &= ~(SYS_CS_ML_MASK | SYS_CS_DL | SYS_CS_CL); 520 - alchemy_wrsys((sys_clksrc | (1 << SYS_CS_ML_BIT)), AU1000_SYS_CLKSRC); 521 508 522 509 /* load the panel info into the var struct */ 523 510 au1100fb_var.bits_per_pixel = fbdev->panel->bpp; ··· 550 547 return 0; 551 548 552 549 failed: 550 + if (fbdev->lcdclk) { 551 + clk_disable_unprepare(fbdev->lcdclk); 552 + clk_put(fbdev->lcdclk); 553 + } 553 554 if (fbdev->fb_mem) { 554 555 dma_free_noncoherent(&dev->dev, fbdev->fb_len, fbdev->fb_mem, 555 556 fbdev->fb_phys); ··· 584 577 585 578 fb_dealloc_cmap(&fbdev->info.cmap); 586 579 580 + if (fbdev->lcdclk) { 581 + clk_disable_unprepare(fbdev->lcdclk); 582 + clk_put(fbdev->lcdclk); 583 + } 584 + 587 585 return 0; 588 586 } 589 587 590 588 #ifdef CONFIG_PM 591 - static u32 sys_clksrc; 592 589 static struct au1100fb_regs fbregs; 593 590 594 591 int au1100fb_drv_suspend(struct platform_device *dev, pm_message_t state) ··· 602 591 if (!fbdev) 603 592 return 0; 604 593 605 - /* Save the clock source state */ 606 - sys_clksrc = alchemy_rdsys(AU1000_SYS_CLKSRC); 607 - 608 594 /* Blank the LCD */ 609 595 au1100fb_fb_blank(VESA_POWERDOWN, &fbdev->info); 610 596 611 - /* Stop LCD clocking */ 612 - alchemy_wrsys(sys_clksrc & ~SYS_CS_ML_MASK, AU1000_SYS_CLKSRC); 597 + if (fbdev->lcdclk) 598 + clk_disable(fbdev->lcdclk); 613 599 614 600 memcpy(&fbregs, fbdev->regs, sizeof(struct au1100fb_regs)); 615 601 ··· 622 614 623 615 memcpy(fbdev->regs, &fbregs, sizeof(struct au1100fb_regs)); 624 616 625 - /* Restart LCD clocking */ 626 - alchemy_wrsys(sys_clksrc, AU1000_SYS_CLKSRC); 617 + if (fbdev->lcdclk) 618 + clk_enable(fbdev->lcdclk); 627 619 628 620 /* Unblank the LCD */ 629 621 au1100fb_fb_blank(VESA_NO_BLANKING, &fbdev->info);
+1
drivers/video/fbdev/au1100fb.h
··· 109 109 size_t fb_len; 110 110 dma_addr_t fb_phys; 111 111 int panel_idx; 112 + struct clk *lcdclk; 112 113 }; 113 114 114 115 /********************************************************************/