drm: rp1: VEC and DPI drivers: Fix bug #5901
[platform/kernel/linux-rpi.git] / drivers / gpu / drm / rp1 / rp1-dpi / rp1_dpi.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * DRM Driver for DSI output on Raspberry Pi RP1
4  *
5  * Copyright (c) 2023 Raspberry Pi Limited.
6  */
7
8 #include <linux/types.h>
9 #include <linux/io.h>
10 #include <linux/clk.h>
11 #include <drm/drm_device.h>
12 #include <drm/drm_simple_kms_helper.h>
13
14 #define MODULE_NAME "drm-rp1-dpi"
15 #define DRIVER_NAME "drm-rp1-dpi"
16
17 /* ---------------------------------------------------------------------- */
18
19 #define RP1DPI_HW_BLOCK_DPI   0
20 #define RP1DPI_HW_BLOCK_CFG   1
21 #define RP1DPI_NUM_HW_BLOCKS  2
22
23 #define RP1DPI_CLK_DPI      0
24 #define RP1DPI_CLK_PLLDIV   1
25 #define RP1DPI_CLK_PLLCORE  2
26 #define RP1DPI_NUM_CLOCKS   3
27
28 /* ---------------------------------------------------------------------- */
29
30 struct rp1_dpi {
31         /* DRM base and platform device pointer */
32         struct drm_device drm;
33         struct platform_device *pdev;
34
35         /* Framework and helper objects */
36         struct drm_simple_display_pipe pipe;
37         struct drm_connector connector;
38
39         /* Clocks: Video PLL, its primary divider, and DPI clock. */
40         struct clk *clocks[RP1DPI_NUM_CLOCKS];
41
42         /* Block (DPI, VOCFG) base addresses, and current state */
43         void __iomem *hw_base[RP1DPI_NUM_HW_BLOCKS];
44         u32 cur_fmt;
45         u32 bus_fmt;
46         bool de_inv, clk_inv;
47         bool dpi_running, pipe_enabled;
48         struct completion finished;
49 };
50
51 /* ---------------------------------------------------------------------- */
52 /* Functions to control the DPI/DMA block                                 */
53
54 void rp1dpi_hw_setup(struct rp1_dpi *dpi,
55                      u32 in_format,
56                      u32 bus_format,
57                      bool de_inv,
58                      struct drm_display_mode const *mode);
59 void rp1dpi_hw_update(struct rp1_dpi *dpi, dma_addr_t addr, u32 offset, u32 stride);
60 void rp1dpi_hw_stop(struct rp1_dpi *dpi);
61 int rp1dpi_hw_busy(struct rp1_dpi *dpi);
62 irqreturn_t rp1dpi_hw_isr(int irq, void *dev);
63 void rp1dpi_hw_vblank_ctrl(struct rp1_dpi *dpi, int enable);
64
65 /* ---------------------------------------------------------------------- */
66 /* Functions to control the VIDEO OUT CFG block and check RP1 platform    */
67
68 void rp1dpi_vidout_setup(struct rp1_dpi *dpi, bool drive_negedge);
69 void rp1dpi_vidout_poweroff(struct rp1_dpi *dpi);