xref: /linux/drivers/gpu/drm/pl111/pl111_drm.h (revision 1ac731c529cd4d6adbce134754b51ff7d822b145)
1e559355aSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
2bed41005STom Cooksey /*
3bed41005STom Cooksey  *
4bed41005STom Cooksey  * (C) COPYRIGHT 2012-2013 ARM Limited. All rights reserved.
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 
13bed41005STom Cooksey #ifndef _PL111_DRM_H_
14bed41005STom Cooksey #define _PL111_DRM_H_
15bed41005STom Cooksey 
16032838f9SEric Anholt #include <linux/clk-provider.h>
17ad86ebe7SLinus Walleij #include <linux/interrupt.h>
18bed41005STom Cooksey 
1909a56fbeSSam Ravnborg #include <drm/drm_bridge.h>
2009a56fbeSSam Ravnborg #include <drm/drm_connector.h>
2109a56fbeSSam Ravnborg #include <drm/drm_encoder.h>
2209a56fbeSSam Ravnborg #include <drm/drm_gem.h>
2309a56fbeSSam Ravnborg #include <drm/drm_panel.h>
2409a56fbeSSam Ravnborg #include <drm/drm_simple_kms_helper.h>
2509a56fbeSSam Ravnborg 
267e4e589dSLinus Walleij /*
277e4e589dSLinus Walleij  * CLCD Controller Internal Register addresses
287e4e589dSLinus Walleij  */
297e4e589dSLinus Walleij #define CLCD_TIM0		0x00000000
307e4e589dSLinus Walleij #define CLCD_TIM1		0x00000004
317e4e589dSLinus Walleij #define CLCD_TIM2		0x00000008
327e4e589dSLinus Walleij #define CLCD_TIM3		0x0000000c
337e4e589dSLinus Walleij #define CLCD_UBAS		0x00000010
347e4e589dSLinus Walleij #define CLCD_LBAS		0x00000014
357e4e589dSLinus Walleij 
367e4e589dSLinus Walleij #define CLCD_PL110_IENB		0x00000018
377e4e589dSLinus Walleij #define CLCD_PL110_CNTL		0x0000001c
387e4e589dSLinus Walleij #define CLCD_PL110_STAT		0x00000020
397e4e589dSLinus Walleij #define CLCD_PL110_INTR		0x00000024
407e4e589dSLinus Walleij #define CLCD_PL110_UCUR		0x00000028
417e4e589dSLinus Walleij #define CLCD_PL110_LCUR		0x0000002C
427e4e589dSLinus Walleij 
437e4e589dSLinus Walleij #define CLCD_PL111_CNTL		0x00000018
447e4e589dSLinus Walleij #define CLCD_PL111_IENB		0x0000001c
457e4e589dSLinus Walleij #define CLCD_PL111_RIS		0x00000020
467e4e589dSLinus Walleij #define CLCD_PL111_MIS		0x00000024
477e4e589dSLinus Walleij #define CLCD_PL111_ICR		0x00000028
487e4e589dSLinus Walleij #define CLCD_PL111_UCUR		0x0000002c
497e4e589dSLinus Walleij #define CLCD_PL111_LCUR		0x00000030
507e4e589dSLinus Walleij 
517e4e589dSLinus Walleij #define CLCD_PALL		0x00000200
527e4e589dSLinus Walleij #define CLCD_PALETTE		0x00000200
537e4e589dSLinus Walleij 
547e4e589dSLinus Walleij #define TIM2_PCD_LO_MASK	GENMASK(4, 0)
557e4e589dSLinus Walleij #define TIM2_PCD_LO_BITS	5
567e4e589dSLinus Walleij #define TIM2_CLKSEL		(1 << 5)
577e4e589dSLinus Walleij #define TIM2_ACB_MASK		GENMASK(10, 6)
587e4e589dSLinus Walleij #define TIM2_IVS		(1 << 11)
597e4e589dSLinus Walleij #define TIM2_IHS		(1 << 12)
607e4e589dSLinus Walleij #define TIM2_IPC		(1 << 13)
617e4e589dSLinus Walleij #define TIM2_IOE		(1 << 14)
627e4e589dSLinus Walleij #define TIM2_BCD		(1 << 26)
637e4e589dSLinus Walleij #define TIM2_PCD_HI_MASK	GENMASK(31, 27)
647e4e589dSLinus Walleij #define TIM2_PCD_HI_BITS	5
657e4e589dSLinus Walleij #define TIM2_PCD_HI_SHIFT	27
667e4e589dSLinus Walleij 
677e4e589dSLinus Walleij #define CNTL_LCDEN		(1 << 0)
687e4e589dSLinus Walleij #define CNTL_LCDBPP1		(0 << 1)
697e4e589dSLinus Walleij #define CNTL_LCDBPP2		(1 << 1)
707e4e589dSLinus Walleij #define CNTL_LCDBPP4		(2 << 1)
717e4e589dSLinus Walleij #define CNTL_LCDBPP8		(3 << 1)
727e4e589dSLinus Walleij #define CNTL_LCDBPP16		(4 << 1)
737e4e589dSLinus Walleij #define CNTL_LCDBPP16_565	(6 << 1)
747e4e589dSLinus Walleij #define CNTL_LCDBPP16_444	(7 << 1)
757e4e589dSLinus Walleij #define CNTL_LCDBPP24		(5 << 1)
767e4e589dSLinus Walleij #define CNTL_LCDBW		(1 << 4)
777e4e589dSLinus Walleij #define CNTL_LCDTFT		(1 << 5)
787e4e589dSLinus Walleij #define CNTL_LCDMONO8		(1 << 6)
797e4e589dSLinus Walleij #define CNTL_LCDDUAL		(1 << 7)
807e4e589dSLinus Walleij #define CNTL_BGR		(1 << 8)
817e4e589dSLinus Walleij #define CNTL_BEBO		(1 << 9)
827e4e589dSLinus Walleij #define CNTL_BEPO		(1 << 10)
837e4e589dSLinus Walleij #define CNTL_LCDPWR		(1 << 11)
847e4e589dSLinus Walleij #define CNTL_LCDVCOMP(x)	((x) << 12)
857e4e589dSLinus Walleij #define CNTL_LDMAFIFOTIME	(1 << 15)
867e4e589dSLinus Walleij #define CNTL_WATERMARK		(1 << 16)
877e4e589dSLinus Walleij 
887e4e589dSLinus Walleij /* ST Microelectronics variant bits */
897e4e589dSLinus Walleij #define CNTL_ST_1XBPP_444	0x0
907e4e589dSLinus Walleij #define CNTL_ST_1XBPP_5551	(1 << 17)
917e4e589dSLinus Walleij #define CNTL_ST_1XBPP_565	(1 << 18)
927e4e589dSLinus Walleij #define CNTL_ST_CDWID_12	0x0
937e4e589dSLinus Walleij #define CNTL_ST_CDWID_16	(1 << 19)
947e4e589dSLinus Walleij #define CNTL_ST_CDWID_18	(1 << 20)
957e4e589dSLinus Walleij #define CNTL_ST_CDWID_24	((1 << 19) | (1 << 20))
967e4e589dSLinus Walleij #define CNTL_ST_CEAEN		(1 << 21)
977e4e589dSLinus Walleij #define CNTL_ST_LCDBPP24_PACKED	(6 << 1)
987e4e589dSLinus Walleij 
99bed41005STom Cooksey #define CLCD_IRQ_NEXTBASE_UPDATE BIT(2)
100bed41005STom Cooksey 
101141518d2SEric Anholt struct drm_minor;
102141518d2SEric Anholt 
103fa83306cSLinus Walleij /**
104fa83306cSLinus Walleij  * struct pl111_variant_data - encodes IP differences
105fa83306cSLinus Walleij  * @name: the name of this variant
106fa83306cSLinus Walleij  * @is_pl110: this is the early PL110 variant
107e08015e7SLinus Walleij  * @is_lcdc: this is the ST Microelectronics Nomadik LCDC variant
1083d95f76aSLinus Walleij  * @external_bgr: this is the Versatile Pl110 variant with external
1093d95f76aSLinus Walleij  *	BGR/RGB routing
110eedd6033SLinus Walleij  * @broken_clockdivider: the clock divider is broken and we need to
111eedd6033SLinus Walleij  *	use the supplied clock directly
11208e32112SLinus Walleij  * @broken_vblank: the vblank IRQ is broken on this variant
113e08015e7SLinus Walleij  * @st_bitmux_control: this variant is using the ST Micro bitmux
114e08015e7SLinus Walleij  *	extensions to the control register
115fa83306cSLinus Walleij  * @formats: array of supported pixel formats on this variant
116fa83306cSLinus Walleij  * @nformats: the length of the array of supported pixel formats
117*14080973SLinus Walleij  * @fb_depth: desired depth per pixel on the default framebuffer
118fa83306cSLinus Walleij  */
119fa83306cSLinus Walleij struct pl111_variant_data {
120fa83306cSLinus Walleij 	const char *name;
121fa83306cSLinus Walleij 	bool is_pl110;
122e08015e7SLinus Walleij 	bool is_lcdc;
1233d95f76aSLinus Walleij 	bool external_bgr;
124eedd6033SLinus Walleij 	bool broken_clockdivider;
12508e32112SLinus Walleij 	bool broken_vblank;
126e08015e7SLinus Walleij 	bool st_bitmux_control;
127fa83306cSLinus Walleij 	const u32 *formats;
128fa83306cSLinus Walleij 	unsigned int nformats;
129*14080973SLinus Walleij 	unsigned int fb_depth;
130fa83306cSLinus Walleij };
131fa83306cSLinus Walleij 
132bed41005STom Cooksey struct pl111_drm_dev_private {
133bed41005STom Cooksey 	struct drm_device *drm;
134bed41005STom Cooksey 
135001485d5SLinus Walleij 	struct drm_connector *connector;
136001485d5SLinus Walleij 	struct drm_panel *panel;
137001485d5SLinus Walleij 	struct drm_bridge *bridge;
138bed41005STom Cooksey 	struct drm_simple_display_pipe pipe;
139bed41005STom Cooksey 
140bed41005STom Cooksey 	void *regs;
141df99dd92SLinus Walleij 	u32 memory_bw;
142fa83306cSLinus Walleij 	u32 ienb;
143fa83306cSLinus Walleij 	u32 ctrl;
144032838f9SEric Anholt 	/* The pixel clock (a reference to our clock divider off of CLCDCLK). */
145bed41005STom Cooksey 	struct clk *clk;
146032838f9SEric Anholt 	/* pl111's internal clock divider. */
147032838f9SEric Anholt 	struct clk_hw clk_div;
148032838f9SEric Anholt 	/* Lock to sync access to CLCD_TIM2 between the common clock
149032838f9SEric Anholt 	 * subsystem and pl111_display_enable().
150032838f9SEric Anholt 	 */
151032838f9SEric Anholt 	spinlock_t tim2_lock;
152fa83306cSLinus Walleij 	const struct pl111_variant_data *variant;
153ad86ebe7SLinus Walleij 	void (*variant_display_enable) (struct drm_device *drm, u32 format);
154ad86ebe7SLinus Walleij 	void (*variant_display_disable) (struct drm_device *drm);
15557450671SLinus Walleij 	bool use_device_memory;
156bed41005STom Cooksey };
157bed41005STom Cooksey 
158bed41005STom Cooksey int pl111_display_init(struct drm_device *dev);
159bed41005STom Cooksey irqreturn_t pl111_irq(int irq, void *data);
1607ce84471SWambui Karuga void pl111_debugfs_init(struct drm_minor *minor);
161bed41005STom Cooksey 
162bed41005STom Cooksey #endif /* _PL111_DRM_H_ */
163