Lines Matching refs:jzfb
117 struct jzfb { struct
181 static unsigned int jzfb_num_ctrl_pins(struct jzfb *jzfb) in jzfb_num_ctrl_pins() argument
185 switch (jzfb->pdata->lcd_type) { in jzfb_num_ctrl_pins()
207 static unsigned int jzfb_num_data_pins(struct jzfb *jzfb) in jzfb_num_data_pins() argument
211 switch (jzfb->pdata->lcd_type) { in jzfb_num_data_pins()
224 if (jzfb->pdata->bpp == 18) in jzfb_num_data_pins()
261 static int jzfb_get_controller_bpp(struct jzfb *jzfb) in jzfb_get_controller_bpp() argument
263 switch (jzfb->pdata->bpp) { in jzfb_get_controller_bpp()
270 return jzfb->pdata->bpp; in jzfb_get_controller_bpp()
274 static struct fb_videomode *jzfb_get_mode(struct jzfb *jzfb, in jzfb_get_mode() argument
278 struct fb_videomode *mode = jzfb->pdata->modes; in jzfb_get_mode()
280 for (i = 0; i < jzfb->pdata->num_modes; ++i, ++mode) { in jzfb_get_mode()
290 struct jzfb *jzfb = fb->par; in jzfb_check_var() local
293 if (var->bits_per_pixel != jzfb_get_controller_bpp(jzfb) && in jzfb_check_var()
294 var->bits_per_pixel != jzfb->pdata->bpp) in jzfb_check_var()
297 mode = jzfb_get_mode(jzfb, var); in jzfb_check_var()
303 switch (jzfb->pdata->bpp) { in jzfb_check_var()
352 struct jzfb *jzfb = info->par; in jzfb_set_par() local
353 struct jz4740_fb_platform_data *pdata = jzfb->pdata; in jzfb_set_par()
363 mode = jzfb_get_mode(jzfb, var); in jzfb_set_par()
438 mutex_lock(&jzfb->lock); in jzfb_set_par()
439 if (!jzfb->is_enabled) in jzfb_set_par()
440 clk_enable(jzfb->ldclk); in jzfb_set_par()
448 writel(pdata->special_tft_config.spl, jzfb->base + JZ_REG_LCD_SPL); in jzfb_set_par()
449 writel(pdata->special_tft_config.cls, jzfb->base + JZ_REG_LCD_CLS); in jzfb_set_par()
450 writel(pdata->special_tft_config.ps, jzfb->base + JZ_REG_LCD_PS); in jzfb_set_par()
451 writel(pdata->special_tft_config.ps, jzfb->base + JZ_REG_LCD_REV); in jzfb_set_par()
461 writel(mode->hsync_len, jzfb->base + JZ_REG_LCD_HSYNC); in jzfb_set_par()
462 writel(mode->vsync_len, jzfb->base + JZ_REG_LCD_VSYNC); in jzfb_set_par()
464 writel((ht << 16) | vt, jzfb->base + JZ_REG_LCD_VAT); in jzfb_set_par()
466 writel((hds << 16) | hde, jzfb->base + JZ_REG_LCD_DAH); in jzfb_set_par()
467 writel((vds << 16) | vde, jzfb->base + JZ_REG_LCD_DAV); in jzfb_set_par()
469 writel(cfg, jzfb->base + JZ_REG_LCD_CFG); in jzfb_set_par()
471 writel(ctrl, jzfb->base + JZ_REG_LCD_CTRL); in jzfb_set_par()
473 if (!jzfb->is_enabled) in jzfb_set_par()
474 clk_disable_unprepare(jzfb->ldclk); in jzfb_set_par()
476 mutex_unlock(&jzfb->lock); in jzfb_set_par()
478 clk_set_rate(jzfb->lpclk, rate); in jzfb_set_par()
479 clk_set_rate(jzfb->ldclk, rate * 3); in jzfb_set_par()
484 static void jzfb_enable(struct jzfb *jzfb) in jzfb_enable() argument
488 clk_prepare_enable(jzfb->ldclk); in jzfb_enable()
490 jz_gpio_bulk_resume(jz_lcd_ctrl_pins, jzfb_num_ctrl_pins(jzfb)); in jzfb_enable()
491 jz_gpio_bulk_resume(jz_lcd_data_pins, jzfb_num_data_pins(jzfb)); in jzfb_enable()
493 writel(0, jzfb->base + JZ_REG_LCD_STATE); in jzfb_enable()
495 writel(jzfb->framedesc->next, jzfb->base + JZ_REG_LCD_DA0); in jzfb_enable()
497 ctrl = readl(jzfb->base + JZ_REG_LCD_CTRL); in jzfb_enable()
500 writel(ctrl, jzfb->base + JZ_REG_LCD_CTRL); in jzfb_enable()
503 static void jzfb_disable(struct jzfb *jzfb) in jzfb_disable() argument
507 ctrl = readl(jzfb->base + JZ_REG_LCD_CTRL); in jzfb_disable()
509 writel(ctrl, jzfb->base + JZ_REG_LCD_CTRL); in jzfb_disable()
511 ctrl = readl(jzfb->base + JZ_REG_LCD_STATE); in jzfb_disable()
514 jz_gpio_bulk_suspend(jz_lcd_ctrl_pins, jzfb_num_ctrl_pins(jzfb)); in jzfb_disable()
515 jz_gpio_bulk_suspend(jz_lcd_data_pins, jzfb_num_data_pins(jzfb)); in jzfb_disable()
517 clk_disable_unprepare(jzfb->ldclk); in jzfb_disable()
522 struct jzfb *jzfb = info->par; in jzfb_blank() local
526 mutex_lock(&jzfb->lock); in jzfb_blank()
527 if (jzfb->is_enabled) { in jzfb_blank()
528 mutex_unlock(&jzfb->lock); in jzfb_blank()
532 jzfb_enable(jzfb); in jzfb_blank()
533 jzfb->is_enabled = 1; in jzfb_blank()
535 mutex_unlock(&jzfb->lock); in jzfb_blank()
538 mutex_lock(&jzfb->lock); in jzfb_blank()
539 if (!jzfb->is_enabled) { in jzfb_blank()
540 mutex_unlock(&jzfb->lock); in jzfb_blank()
544 jzfb_disable(jzfb); in jzfb_blank()
545 jzfb->is_enabled = 0; in jzfb_blank()
547 mutex_unlock(&jzfb->lock); in jzfb_blank()
554 static int jzfb_alloc_devmem(struct jzfb *jzfb) in jzfb_alloc_devmem() argument
557 struct fb_videomode *mode = jzfb->pdata->modes; in jzfb_alloc_devmem()
561 for (i = 0; i < jzfb->pdata->num_modes; ++mode, ++i) { in jzfb_alloc_devmem()
566 max_videosize *= jzfb_get_controller_bpp(jzfb) >> 3; in jzfb_alloc_devmem()
568 jzfb->framedesc = dma_alloc_coherent(&jzfb->pdev->dev, in jzfb_alloc_devmem()
569 sizeof(*jzfb->framedesc), in jzfb_alloc_devmem()
570 &jzfb->framedesc_phys, GFP_KERNEL); in jzfb_alloc_devmem()
572 if (!jzfb->framedesc) in jzfb_alloc_devmem()
575 jzfb->vidmem_size = PAGE_ALIGN(max_videosize); in jzfb_alloc_devmem()
576 jzfb->vidmem = dma_alloc_coherent(&jzfb->pdev->dev, in jzfb_alloc_devmem()
577 jzfb->vidmem_size, in jzfb_alloc_devmem()
578 &jzfb->vidmem_phys, GFP_KERNEL); in jzfb_alloc_devmem()
580 if (!jzfb->vidmem) in jzfb_alloc_devmem()
583 for (page = jzfb->vidmem; in jzfb_alloc_devmem()
584 page < jzfb->vidmem + PAGE_ALIGN(jzfb->vidmem_size); in jzfb_alloc_devmem()
589 jzfb->framedesc->next = jzfb->framedesc_phys; in jzfb_alloc_devmem()
590 jzfb->framedesc->addr = jzfb->vidmem_phys; in jzfb_alloc_devmem()
591 jzfb->framedesc->id = 0xdeafbead; in jzfb_alloc_devmem()
592 jzfb->framedesc->cmd = 0; in jzfb_alloc_devmem()
593 jzfb->framedesc->cmd |= max_videosize / 4; in jzfb_alloc_devmem()
598 dma_free_coherent(&jzfb->pdev->dev, sizeof(*jzfb->framedesc), in jzfb_alloc_devmem()
599 jzfb->framedesc, jzfb->framedesc_phys); in jzfb_alloc_devmem()
603 static void jzfb_free_devmem(struct jzfb *jzfb) in jzfb_free_devmem() argument
605 dma_free_coherent(&jzfb->pdev->dev, jzfb->vidmem_size, in jzfb_free_devmem()
606 jzfb->vidmem, jzfb->vidmem_phys); in jzfb_free_devmem()
607 dma_free_coherent(&jzfb->pdev->dev, sizeof(*jzfb->framedesc), in jzfb_free_devmem()
608 jzfb->framedesc, jzfb->framedesc_phys); in jzfb_free_devmem()
625 struct jzfb *jzfb; in jzfb_probe() local
635 fb = framebuffer_alloc(sizeof(struct jzfb), &pdev->dev); in jzfb_probe()
644 jzfb = fb->par; in jzfb_probe()
645 jzfb->pdev = pdev; in jzfb_probe()
646 jzfb->pdata = pdata; in jzfb_probe()
648 jzfb->ldclk = devm_clk_get(&pdev->dev, "lcd"); in jzfb_probe()
649 if (IS_ERR(jzfb->ldclk)) { in jzfb_probe()
650 ret = PTR_ERR(jzfb->ldclk); in jzfb_probe()
655 jzfb->lpclk = devm_clk_get(&pdev->dev, "lcd_pclk"); in jzfb_probe()
656 if (IS_ERR(jzfb->lpclk)) { in jzfb_probe()
657 ret = PTR_ERR(jzfb->lpclk); in jzfb_probe()
663 jzfb->base = devm_ioremap_resource(&pdev->dev, mem); in jzfb_probe()
664 if (IS_ERR(jzfb->base)) { in jzfb_probe()
665 ret = PTR_ERR(jzfb->base); in jzfb_probe()
669 platform_set_drvdata(pdev, jzfb); in jzfb_probe()
671 mutex_init(&jzfb->lock); in jzfb_probe()
679 ret = jzfb_alloc_devmem(jzfb); in jzfb_probe()
689 fb->fix.smem_start = jzfb->vidmem_phys; in jzfb_probe()
691 fb->screen_base = jzfb->vidmem; in jzfb_probe()
692 fb->pseudo_palette = jzfb->pseudo_palette; in jzfb_probe()
696 clk_prepare_enable(jzfb->ldclk); in jzfb_probe()
697 jzfb->is_enabled = 1; in jzfb_probe()
699 writel(jzfb->framedesc->next, jzfb->base + JZ_REG_LCD_DA0); in jzfb_probe()
704 jz_gpio_bulk_request(jz_lcd_ctrl_pins, jzfb_num_ctrl_pins(jzfb)); in jzfb_probe()
705 jz_gpio_bulk_request(jz_lcd_data_pins, jzfb_num_data_pins(jzfb)); in jzfb_probe()
713 jzfb->fb = fb; in jzfb_probe()
718 jz_gpio_bulk_free(jz_lcd_ctrl_pins, jzfb_num_ctrl_pins(jzfb)); in jzfb_probe()
719 jz_gpio_bulk_free(jz_lcd_data_pins, jzfb_num_data_pins(jzfb)); in jzfb_probe()
722 jzfb_free_devmem(jzfb); in jzfb_probe()
730 struct jzfb *jzfb = platform_get_drvdata(pdev); in jzfb_remove() local
732 jzfb_blank(FB_BLANK_POWERDOWN, jzfb->fb); in jzfb_remove()
734 jz_gpio_bulk_free(jz_lcd_ctrl_pins, jzfb_num_ctrl_pins(jzfb)); in jzfb_remove()
735 jz_gpio_bulk_free(jz_lcd_data_pins, jzfb_num_data_pins(jzfb)); in jzfb_remove()
737 fb_dealloc_cmap(&jzfb->fb->cmap); in jzfb_remove()
738 jzfb_free_devmem(jzfb); in jzfb_remove()
740 framebuffer_release(jzfb->fb); in jzfb_remove()
749 struct jzfb *jzfb = dev_get_drvdata(dev); in jzfb_suspend() local
752 fb_set_suspend(jzfb->fb, 1); in jzfb_suspend()
755 mutex_lock(&jzfb->lock); in jzfb_suspend()
756 if (jzfb->is_enabled) in jzfb_suspend()
757 jzfb_disable(jzfb); in jzfb_suspend()
758 mutex_unlock(&jzfb->lock); in jzfb_suspend()
765 struct jzfb *jzfb = dev_get_drvdata(dev); in jzfb_resume() local
766 clk_prepare_enable(jzfb->ldclk); in jzfb_resume()
768 mutex_lock(&jzfb->lock); in jzfb_resume()
769 if (jzfb->is_enabled) in jzfb_resume()
770 jzfb_enable(jzfb); in jzfb_resume()
771 mutex_unlock(&jzfb->lock); in jzfb_resume()
774 fb_set_suspend(jzfb->fb, 0); in jzfb_resume()