Lines Matching +full:dc +full:- +full:id

1 // SPDX-License-Identifier: GPL-2.0-only
7 * Author: Jean-Jacques Hiblot <jjhiblot@traphandler.com>
8 * Author: Boris BREZILLON <boris.brezillon@free-electrons.com>
14 #include <linux/mfd/atmel-hlcdc.h>
38 .id = 0,
68 .id = 0,
84 .id = 1,
100 .name = "high-end-overlay",
103 .id = 2,
125 .id = 3,
161 .id = 0,
177 .id = 1,
196 .id = 2,
212 .name = "high-end-overlay",
215 .id = 3,
241 .id = 4,
279 .id = 0,
295 .id = 1,
314 .id = 2,
330 .name = "high-end-overlay",
333 .id = 3,
374 .id = 0,
390 .id = 1,
409 .id = 2,
425 .name = "high-end-overlay",
428 .id = 3,
467 .compatible = "atmel,at91sam9n12-hlcdc",
471 .compatible = "atmel,at91sam9x5-hlcdc",
475 .compatible = "atmel,sama5d2-hlcdc",
479 .compatible = "atmel,sama5d3-hlcdc",
483 .compatible = "atmel,sama5d4-hlcdc",
487 .compatible = "microchip,sam9x60-hlcdc",
495 atmel_hlcdc_dc_mode_valid(struct atmel_hlcdc_dc *dc, in atmel_hlcdc_dc_mode_valid() argument
498 int vfront_porch = mode->vsync_start - mode->vdisplay; in atmel_hlcdc_dc_mode_valid()
499 int vback_porch = mode->vtotal - mode->vsync_end; in atmel_hlcdc_dc_mode_valid()
500 int vsync_len = mode->vsync_end - mode->vsync_start; in atmel_hlcdc_dc_mode_valid()
501 int hfront_porch = mode->hsync_start - mode->hdisplay; in atmel_hlcdc_dc_mode_valid()
502 int hback_porch = mode->htotal - mode->hsync_end; in atmel_hlcdc_dc_mode_valid()
503 int hsync_len = mode->hsync_end - mode->hsync_start; in atmel_hlcdc_dc_mode_valid()
505 if (hsync_len > dc->desc->max_spw + 1 || hsync_len < 1) in atmel_hlcdc_dc_mode_valid()
508 if (vsync_len > dc->desc->max_spw + 1 || vsync_len < 1) in atmel_hlcdc_dc_mode_valid()
511 if (hfront_porch > dc->desc->max_hpw + 1 || hfront_porch < 1 || in atmel_hlcdc_dc_mode_valid()
512 hback_porch > dc->desc->max_hpw + 1 || hback_porch < 1 || in atmel_hlcdc_dc_mode_valid()
513 mode->hdisplay < 1) in atmel_hlcdc_dc_mode_valid()
516 if (vfront_porch > dc->desc->max_vpw + 1 || vfront_porch < 1 || in atmel_hlcdc_dc_mode_valid()
517 vback_porch > dc->desc->max_vpw || vback_porch < 0 || in atmel_hlcdc_dc_mode_valid()
518 mode->vdisplay < 1) in atmel_hlcdc_dc_mode_valid()
529 if (layer->desc->type == ATMEL_HLCDC_BASE_LAYER || in atmel_hlcdc_layer_irq()
530 layer->desc->type == ATMEL_HLCDC_OVERLAY_LAYER || in atmel_hlcdc_layer_irq()
531 layer->desc->type == ATMEL_HLCDC_CURSOR_LAYER) in atmel_hlcdc_layer_irq()
538 struct atmel_hlcdc_dc *dc = dev->dev_private; in atmel_hlcdc_dc_irq_handler() local
543 regmap_read(dc->hlcdc->regmap, ATMEL_HLCDC_IMR, &imr); in atmel_hlcdc_dc_irq_handler()
544 regmap_read(dc->hlcdc->regmap, ATMEL_HLCDC_ISR, &isr); in atmel_hlcdc_dc_irq_handler()
550 atmel_hlcdc_crtc_irq(dc->crtc); in atmel_hlcdc_dc_irq_handler()
554 atmel_hlcdc_layer_irq(dc->layers[i]); in atmel_hlcdc_dc_irq_handler()
562 struct atmel_hlcdc_dc *dc = dev->dev_private; in atmel_hlcdc_dc_irq_postinstall() local
568 if (dc->layers[i]) in atmel_hlcdc_dc_irq_postinstall()
572 regmap_write(dc->hlcdc->regmap, ATMEL_HLCDC_IER, cfg); in atmel_hlcdc_dc_irq_postinstall()
577 struct atmel_hlcdc_dc *dc = dev->dev_private; in atmel_hlcdc_dc_irq_disable() local
580 regmap_write(dc->hlcdc->regmap, ATMEL_HLCDC_IDR, 0xffffffff); in atmel_hlcdc_dc_irq_disable()
581 regmap_read(dc->hlcdc->regmap, ATMEL_HLCDC_ISR, &isr); in atmel_hlcdc_dc_irq_disable()
590 ret = devm_request_irq(dev->dev, irq, atmel_hlcdc_dc_irq_handler, 0, in atmel_hlcdc_dc_irq_install()
591 dev->driver->name, dev); in atmel_hlcdc_dc_irq_install()
613 struct atmel_hlcdc_dc *dc = dev->dev_private; in atmel_hlcdc_dc_modeset_init() local
620 dev_err(dev->dev, "failed to create HLCDC outputs: %d\n", ret); in atmel_hlcdc_dc_modeset_init()
626 dev_err(dev->dev, "failed to create planes: %d\n", ret); in atmel_hlcdc_dc_modeset_init()
632 dev_err(dev->dev, "failed to create crtc\n"); in atmel_hlcdc_dc_modeset_init()
636 dev->mode_config.min_width = dc->desc->min_width; in atmel_hlcdc_dc_modeset_init()
637 dev->mode_config.min_height = dc->desc->min_height; in atmel_hlcdc_dc_modeset_init()
638 dev->mode_config.max_width = dc->desc->max_width; in atmel_hlcdc_dc_modeset_init()
639 dev->mode_config.max_height = dc->desc->max_height; in atmel_hlcdc_dc_modeset_init()
640 dev->mode_config.funcs = &mode_config_funcs; in atmel_hlcdc_dc_modeset_init()
641 dev->mode_config.async_page_flip = true; in atmel_hlcdc_dc_modeset_init()
648 struct platform_device *pdev = to_platform_device(dev->dev); in atmel_hlcdc_dc_load()
650 struct atmel_hlcdc_dc *dc; in atmel_hlcdc_dc_load() local
653 match = of_match_node(atmel_hlcdc_of_match, dev->dev->parent->of_node); in atmel_hlcdc_dc_load()
655 dev_err(&pdev->dev, "invalid compatible string\n"); in atmel_hlcdc_dc_load()
656 return -ENODEV; in atmel_hlcdc_dc_load()
659 if (!match->data) { in atmel_hlcdc_dc_load()
660 dev_err(&pdev->dev, "invalid hlcdc description\n"); in atmel_hlcdc_dc_load()
661 return -EINVAL; in atmel_hlcdc_dc_load()
664 dc = devm_kzalloc(dev->dev, sizeof(*dc), GFP_KERNEL); in atmel_hlcdc_dc_load()
665 if (!dc) in atmel_hlcdc_dc_load()
666 return -ENOMEM; in atmel_hlcdc_dc_load()
668 dc->desc = match->data; in atmel_hlcdc_dc_load()
669 dc->hlcdc = dev_get_drvdata(dev->dev->parent); in atmel_hlcdc_dc_load()
670 dev->dev_private = dc; in atmel_hlcdc_dc_load()
672 ret = clk_prepare_enable(dc->hlcdc->periph_clk); in atmel_hlcdc_dc_load()
674 dev_err(dev->dev, "failed to enable periph_clk\n"); in atmel_hlcdc_dc_load()
678 pm_runtime_enable(dev->dev); in atmel_hlcdc_dc_load()
682 dev_err(dev->dev, "failed to initialize vblank\n"); in atmel_hlcdc_dc_load()
688 dev_err(dev->dev, "failed to initialize mode setting\n"); in atmel_hlcdc_dc_load()
694 pm_runtime_get_sync(dev->dev); in atmel_hlcdc_dc_load()
695 ret = atmel_hlcdc_dc_irq_install(dev, dc->hlcdc->irq); in atmel_hlcdc_dc_load()
696 pm_runtime_put_sync(dev->dev); in atmel_hlcdc_dc_load()
698 dev_err(dev->dev, "failed to install IRQ handler\n"); in atmel_hlcdc_dc_load()
709 pm_runtime_disable(dev->dev); in atmel_hlcdc_dc_load()
710 clk_disable_unprepare(dc->hlcdc->periph_clk); in atmel_hlcdc_dc_load()
717 struct atmel_hlcdc_dc *dc = dev->dev_private; in atmel_hlcdc_dc_unload() local
723 pm_runtime_get_sync(dev->dev); in atmel_hlcdc_dc_unload()
725 pm_runtime_put_sync(dev->dev); in atmel_hlcdc_dc_unload()
727 dev->dev_private = NULL; in atmel_hlcdc_dc_unload()
729 pm_runtime_disable(dev->dev); in atmel_hlcdc_dc_unload()
730 clk_disable_unprepare(dc->hlcdc->periph_clk); in atmel_hlcdc_dc_unload()
739 .name = "atmel-hlcdc",
751 ddev = drm_dev_alloc(&atmel_hlcdc_dc_driver, &pdev->dev); in atmel_hlcdc_dc_drm_probe()
788 struct atmel_hlcdc_dc *dc = drm_dev->dev_private; in atmel_hlcdc_dc_drm_suspend() local
789 struct regmap *regmap = dc->hlcdc->regmap; in atmel_hlcdc_dc_drm_suspend()
796 dc->suspend.state = state; in atmel_hlcdc_dc_drm_suspend()
798 regmap_read(regmap, ATMEL_HLCDC_IMR, &dc->suspend.imr); in atmel_hlcdc_dc_drm_suspend()
799 regmap_write(regmap, ATMEL_HLCDC_IDR, dc->suspend.imr); in atmel_hlcdc_dc_drm_suspend()
800 clk_disable_unprepare(dc->hlcdc->periph_clk); in atmel_hlcdc_dc_drm_suspend()
808 struct atmel_hlcdc_dc *dc = drm_dev->dev_private; in atmel_hlcdc_dc_drm_resume() local
810 clk_prepare_enable(dc->hlcdc->periph_clk); in atmel_hlcdc_dc_drm_resume()
811 regmap_write(dc->hlcdc->regmap, ATMEL_HLCDC_IER, dc->suspend.imr); in atmel_hlcdc_dc_drm_resume()
813 return drm_atomic_helper_resume(drm_dev, dc->suspend.state); in atmel_hlcdc_dc_drm_resume()
821 { .compatible = "atmel,hlcdc-display-controller" },
829 .name = "atmel-hlcdc-display-controller",
836 MODULE_AUTHOR("Jean-Jacques Hiblot <jjhiblot@traphandler.com>");
837 MODULE_AUTHOR("Boris Brezillon <boris.brezillon@free-electrons.com>");
840 MODULE_ALIAS("platform:atmel-hlcdc-dc");