xref: /linux/drivers/gpu/drm/mcde/mcde_drm.h (revision cdd38c5f1ce4398ec58fec95904b75824daab7b5)
15fc537bfSLinus Walleij /* SPDX-License-Identifier: GPL-2.0+ */
25fc537bfSLinus Walleij /*
35fc537bfSLinus Walleij  * Copyright (C) 2018 Linus Walleij <linus.walleij@linaro.org>
45fc537bfSLinus Walleij  * Parts of this file were based on the MCDE driver by Marcus Lorentzon
55fc537bfSLinus Walleij  * (C) ST-Ericsson SA 2013
65fc537bfSLinus Walleij  */
75fc537bfSLinus Walleij #include <drm/drm_simple_kms_helper.h>
85fc537bfSLinus Walleij 
95fc537bfSLinus Walleij #ifndef _MCDE_DRM_H_
105fc537bfSLinus Walleij #define _MCDE_DRM_H_
115fc537bfSLinus Walleij 
12c4842d4dSLinus Walleij /* Shared basic registers */
13c4842d4dSLinus Walleij #define MCDE_CR 0x00000000
14c4842d4dSLinus Walleij #define MCDE_CR_IFIFOEMPTYLINECOUNT_V422_SHIFT 0
15c4842d4dSLinus Walleij #define MCDE_CR_IFIFOEMPTYLINECOUNT_V422_MASK 0x0000003F
16c4842d4dSLinus Walleij #define MCDE_CR_IFIFOCTRLEN BIT(15)
17c4842d4dSLinus Walleij #define MCDE_CR_UFRECOVERY_MODE_V422 BIT(16)
18c4842d4dSLinus Walleij #define MCDE_CR_WRAP_MODE_V422_SHIFT BIT(17)
19c4842d4dSLinus Walleij #define MCDE_CR_AUTOCLKG_EN BIT(30)
20c4842d4dSLinus Walleij #define MCDE_CR_MCDEEN BIT(31)
21c4842d4dSLinus Walleij 
22c4842d4dSLinus Walleij #define MCDE_CONF0 0x00000004
23c4842d4dSLinus Walleij #define MCDE_CONF0_SYNCMUX0 BIT(0)
24c4842d4dSLinus Walleij #define MCDE_CONF0_SYNCMUX1 BIT(1)
25c4842d4dSLinus Walleij #define MCDE_CONF0_SYNCMUX2 BIT(2)
26c4842d4dSLinus Walleij #define MCDE_CONF0_SYNCMUX3 BIT(3)
27c4842d4dSLinus Walleij #define MCDE_CONF0_SYNCMUX4 BIT(4)
28c4842d4dSLinus Walleij #define MCDE_CONF0_SYNCMUX5 BIT(5)
29c4842d4dSLinus Walleij #define MCDE_CONF0_SYNCMUX6 BIT(6)
30c4842d4dSLinus Walleij #define MCDE_CONF0_SYNCMUX7 BIT(7)
31c4842d4dSLinus Walleij #define MCDE_CONF0_IFIFOCTRLWTRMRKLVL_SHIFT 12
32c4842d4dSLinus Walleij #define MCDE_CONF0_IFIFOCTRLWTRMRKLVL_MASK 0x00007000
33c4842d4dSLinus Walleij #define MCDE_CONF0_OUTMUX0_SHIFT 16
34c4842d4dSLinus Walleij #define MCDE_CONF0_OUTMUX0_MASK 0x00070000
35c4842d4dSLinus Walleij #define MCDE_CONF0_OUTMUX1_SHIFT 19
36c4842d4dSLinus Walleij #define MCDE_CONF0_OUTMUX1_MASK 0x00380000
37c4842d4dSLinus Walleij #define MCDE_CONF0_OUTMUX2_SHIFT 22
38c4842d4dSLinus Walleij #define MCDE_CONF0_OUTMUX2_MASK 0x01C00000
39c4842d4dSLinus Walleij #define MCDE_CONF0_OUTMUX3_SHIFT 25
40c4842d4dSLinus Walleij #define MCDE_CONF0_OUTMUX3_MASK 0x0E000000
41c4842d4dSLinus Walleij #define MCDE_CONF0_OUTMUX4_SHIFT 28
42c4842d4dSLinus Walleij #define MCDE_CONF0_OUTMUX4_MASK 0x70000000
43c4842d4dSLinus Walleij 
44c4842d4dSLinus Walleij #define MCDE_SSP 0x00000008
45c4842d4dSLinus Walleij #define MCDE_AIS 0x00000100
46c4842d4dSLinus Walleij #define MCDE_IMSCERR 0x00000110
47c4842d4dSLinus Walleij #define MCDE_RISERR 0x00000120
48c4842d4dSLinus Walleij #define MCDE_MISERR 0x00000130
49c4842d4dSLinus Walleij #define MCDE_SISERR 0x00000140
50c4842d4dSLinus Walleij 
51709c2773SLinus Walleij enum mcde_flow_mode {
52709c2773SLinus Walleij 	/* One-shot mode: flow stops after one frame */
53709c2773SLinus Walleij 	MCDE_COMMAND_ONESHOT_FLOW,
54709c2773SLinus Walleij 	/* Command mode with tearing effect (TE) IRQ sync */
55709c2773SLinus Walleij 	MCDE_COMMAND_TE_FLOW,
56709c2773SLinus Walleij 	/*
57709c2773SLinus Walleij 	 * Command mode with bus turn-around (BTA) and tearing effect
58709c2773SLinus Walleij 	 * (TE) IRQ sync.
59709c2773SLinus Walleij 	 */
60709c2773SLinus Walleij 	MCDE_COMMAND_BTA_TE_FLOW,
61709c2773SLinus Walleij 	/* Video mode with tearing effect (TE) sync IRQ */
62709c2773SLinus Walleij 	MCDE_VIDEO_TE_FLOW,
63709c2773SLinus Walleij 	/* Video mode with the formatter itself as sync source */
64709c2773SLinus Walleij 	MCDE_VIDEO_FORMATTER_FLOW,
65*d795fd32SLinus Walleij 	/* DPI video with the formatter itsels as sync source */
66*d795fd32SLinus Walleij 	MCDE_DPI_FORMATTER_FLOW,
67709c2773SLinus Walleij };
68709c2773SLinus Walleij 
695fc537bfSLinus Walleij struct mcde {
705fc537bfSLinus Walleij 	struct drm_device drm;
715fc537bfSLinus Walleij 	struct device *dev;
725fc537bfSLinus Walleij 	struct drm_panel *panel;
735fc537bfSLinus Walleij 	struct drm_bridge *bridge;
745fc537bfSLinus Walleij 	struct drm_connector *connector;
755fc537bfSLinus Walleij 	struct drm_simple_display_pipe pipe;
765fc537bfSLinus Walleij 	struct mipi_dsi_device *mdsi;
77*d795fd32SLinus Walleij 	bool dpi_output;
785fc537bfSLinus Walleij 	s16 stride;
79709c2773SLinus Walleij 	enum mcde_flow_mode flow_mode;
805fc537bfSLinus Walleij 	unsigned int flow_active;
815fc537bfSLinus Walleij 	spinlock_t flow_lock; /* Locks the channel flow control */
825fc537bfSLinus Walleij 
835fc537bfSLinus Walleij 	void __iomem *regs;
845fc537bfSLinus Walleij 
855fc537bfSLinus Walleij 	struct clk *mcde_clk;
865fc537bfSLinus Walleij 	struct clk *lcd_clk;
875fc537bfSLinus Walleij 	struct clk *hdmi_clk;
88*d795fd32SLinus Walleij 	/* Handles to the clock dividers for FIFO A and B */
89*d795fd32SLinus Walleij 	struct clk *fifoa_clk;
90*d795fd32SLinus Walleij 	struct clk *fifob_clk;
91*d795fd32SLinus Walleij 	/* Locks the MCDE FIFO control register A and B */
92*d795fd32SLinus Walleij 	spinlock_t fifo_crx1_lock;
935fc537bfSLinus Walleij 
945fc537bfSLinus Walleij 	struct regulator *epod;
955fc537bfSLinus Walleij 	struct regulator *vana;
965fc537bfSLinus Walleij };
975fc537bfSLinus Walleij 
98fd7ee85cSDaniel Vetter #define to_mcde(dev) container_of(dev, struct mcde, drm)
99fd7ee85cSDaniel Vetter 
mcde_flow_is_video(struct mcde * mcde)100709c2773SLinus Walleij static inline bool mcde_flow_is_video(struct mcde *mcde)
101709c2773SLinus Walleij {
102709c2773SLinus Walleij 	return (mcde->flow_mode == MCDE_VIDEO_TE_FLOW ||
103709c2773SLinus Walleij 		mcde->flow_mode == MCDE_VIDEO_FORMATTER_FLOW);
104709c2773SLinus Walleij }
105709c2773SLinus Walleij 
1065fc537bfSLinus Walleij bool mcde_dsi_irq(struct mipi_dsi_device *mdsi);
1075fc537bfSLinus Walleij void mcde_dsi_te_request(struct mipi_dsi_device *mdsi);
10842bac89aSLinus Walleij void mcde_dsi_enable(struct drm_bridge *bridge);
10942bac89aSLinus Walleij void mcde_dsi_disable(struct drm_bridge *bridge);
1105fc537bfSLinus Walleij extern struct platform_driver mcde_dsi_driver;
1115fc537bfSLinus Walleij 
1125fc537bfSLinus Walleij void mcde_display_irq(struct mcde *mcde);
1135fc537bfSLinus Walleij void mcde_display_disable_irqs(struct mcde *mcde);
1145fc537bfSLinus Walleij int mcde_display_init(struct drm_device *drm);
1155fc537bfSLinus Walleij 
116*d795fd32SLinus Walleij int mcde_init_clock_divider(struct mcde *mcde);
117*d795fd32SLinus Walleij 
1185fc537bfSLinus Walleij #endif /* _MCDE_DRM_H_ */
119