xref: /openbmc/linux/drivers/gpu/drm/pl111/pl111_drm.h (revision eedd6033)
1bed41005STom Cooksey /*
2bed41005STom Cooksey  *
3bed41005STom Cooksey  * (C) COPYRIGHT 2012-2013 ARM Limited. All rights reserved.
4bed41005STom Cooksey  *
5bed41005STom Cooksey  *
6bed41005STom Cooksey  * Parts of this file were based on sources as follows:
7bed41005STom Cooksey  *
8bed41005STom Cooksey  * Copyright (c) 2006-2008 Intel Corporation
9bed41005STom Cooksey  * Copyright (c) 2007 Dave Airlie <airlied@linux.ie>
10bed41005STom Cooksey  * Copyright (C) 2011 Texas Instruments
11bed41005STom Cooksey  *
12bed41005STom Cooksey  * This program is free software and is provided to you under the terms of the
13bed41005STom Cooksey  * GNU General Public License version 2 as published by the Free Software
14bed41005STom Cooksey  * Foundation, and any use by you of this program is subject to the terms of
15bed41005STom Cooksey  * such GNU licence.
16bed41005STom Cooksey  *
17bed41005STom Cooksey  */
18bed41005STom Cooksey 
19bed41005STom Cooksey #ifndef _PL111_DRM_H_
20bed41005STom Cooksey #define _PL111_DRM_H_
21bed41005STom Cooksey 
22bed41005STom Cooksey #include <drm/drm_gem.h>
23bed41005STom Cooksey #include <drm/drm_simple_kms_helper.h>
24001485d5SLinus Walleij #include <drm/drm_connector.h>
25001485d5SLinus Walleij #include <drm/drm_encoder.h>
26001485d5SLinus Walleij #include <drm/drm_panel.h>
27001485d5SLinus Walleij #include <drm/drm_bridge.h>
28032838f9SEric Anholt #include <linux/clk-provider.h>
29ad86ebe7SLinus Walleij #include <linux/interrupt.h>
30bed41005STom Cooksey 
31bed41005STom Cooksey #define CLCD_IRQ_NEXTBASE_UPDATE BIT(2)
32bed41005STom Cooksey 
33141518d2SEric Anholt struct drm_minor;
34141518d2SEric Anholt 
35fa83306cSLinus Walleij /**
36fa83306cSLinus Walleij  * struct pl111_variant_data - encodes IP differences
37fa83306cSLinus Walleij  * @name: the name of this variant
38fa83306cSLinus Walleij  * @is_pl110: this is the early PL110 variant
393d95f76aSLinus Walleij  * @external_bgr: this is the Versatile Pl110 variant with external
403d95f76aSLinus Walleij  *	BGR/RGB routing
41eedd6033SLinus Walleij  * @broken_clockdivider: the clock divider is broken and we need to
42eedd6033SLinus Walleij  *	use the supplied clock directly
43fa83306cSLinus Walleij  * @formats: array of supported pixel formats on this variant
44fa83306cSLinus Walleij  * @nformats: the length of the array of supported pixel formats
45fa83306cSLinus Walleij  */
46fa83306cSLinus Walleij struct pl111_variant_data {
47fa83306cSLinus Walleij 	const char *name;
48fa83306cSLinus Walleij 	bool is_pl110;
493d95f76aSLinus Walleij 	bool external_bgr;
50eedd6033SLinus Walleij 	bool broken_clockdivider;
51fa83306cSLinus Walleij 	const u32 *formats;
52fa83306cSLinus Walleij 	unsigned int nformats;
53fa83306cSLinus Walleij };
54fa83306cSLinus Walleij 
55bed41005STom Cooksey struct pl111_drm_dev_private {
56bed41005STom Cooksey 	struct drm_device *drm;
57bed41005STom Cooksey 
58001485d5SLinus Walleij 	struct drm_connector *connector;
59001485d5SLinus Walleij 	struct drm_panel *panel;
60001485d5SLinus Walleij 	struct drm_bridge *bridge;
61bed41005STom Cooksey 	struct drm_simple_display_pipe pipe;
62bed41005STom Cooksey 
63bed41005STom Cooksey 	void *regs;
64fa83306cSLinus Walleij 	u32 ienb;
65fa83306cSLinus Walleij 	u32 ctrl;
66032838f9SEric Anholt 	/* The pixel clock (a reference to our clock divider off of CLCDCLK). */
67bed41005STom Cooksey 	struct clk *clk;
68032838f9SEric Anholt 	/* pl111's internal clock divider. */
69032838f9SEric Anholt 	struct clk_hw clk_div;
70032838f9SEric Anholt 	/* Lock to sync access to CLCD_TIM2 between the common clock
71032838f9SEric Anholt 	 * subsystem and pl111_display_enable().
72032838f9SEric Anholt 	 */
73032838f9SEric Anholt 	spinlock_t tim2_lock;
74fa83306cSLinus Walleij 	const struct pl111_variant_data *variant;
75ad86ebe7SLinus Walleij 	void (*variant_display_enable) (struct drm_device *drm, u32 format);
76ad86ebe7SLinus Walleij 	void (*variant_display_disable) (struct drm_device *drm);
77bed41005STom Cooksey };
78bed41005STom Cooksey 
79bed41005STom Cooksey int pl111_display_init(struct drm_device *dev);
80bed41005STom Cooksey int pl111_enable_vblank(struct drm_device *drm, unsigned int crtc);
81bed41005STom Cooksey void pl111_disable_vblank(struct drm_device *drm, unsigned int crtc);
82bed41005STom Cooksey irqreturn_t pl111_irq(int irq, void *data);
83141518d2SEric Anholt int pl111_debugfs_init(struct drm_minor *minor);
84bed41005STom Cooksey 
85bed41005STom Cooksey #endif /* _PL111_DRM_H_ */
86