Merge tag 'io_uring-5.11-2021-01-16' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / gpu / drm / rcar-du / rcar_du_drv.h
blob61504c54e2ecf249ca81525ff3116b740b2cfb37
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3 * rcar_du_drv.h -- R-Car Display Unit DRM driver
5 * Copyright (C) 2013-2015 Renesas Electronics Corporation
7 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
8 */
10 #ifndef __RCAR_DU_DRV_H__
11 #define __RCAR_DU_DRV_H__
13 #include <linux/kernel.h>
14 #include <linux/wait.h>
16 #include "rcar_cmm.h"
17 #include "rcar_du_crtc.h"
18 #include "rcar_du_group.h"
19 #include "rcar_du_vsp.h"
21 struct clk;
22 struct device;
23 struct drm_device;
24 struct drm_property;
25 struct rcar_du_device;
26 struct rcar_du_encoder;
28 #define RCAR_DU_FEATURE_CRTC_IRQ_CLOCK BIT(0) /* Per-CRTC IRQ and clock */
29 #define RCAR_DU_FEATURE_VSP1_SOURCE BIT(1) /* Has inputs from VSP1 */
30 #define RCAR_DU_FEATURE_INTERLACED BIT(2) /* HW supports interlaced */
31 #define RCAR_DU_FEATURE_TVM_SYNC BIT(3) /* Has TV switch/sync modes */
33 #define RCAR_DU_QUIRK_ALIGN_128B BIT(0) /* Align pitches to 128 bytes */
36 * struct rcar_du_output_routing - Output routing specification
37 * @possible_crtcs: bitmask of possible CRTCs for the output
38 * @port: device tree port number corresponding to this output route
40 * The DU has 5 possible outputs (DPAD0/1, LVDS0/1, TCON). Output routing data
41 * specify the valid SoC outputs, which CRTCs can drive the output, and the type
42 * of in-SoC encoder for the output.
44 struct rcar_du_output_routing {
45 unsigned int possible_crtcs;
46 unsigned int port;
50 * struct rcar_du_device_info - DU model-specific information
51 * @gen: device generation (2 or 3)
52 * @features: device features (RCAR_DU_FEATURE_*)
53 * @quirks: device quirks (RCAR_DU_QUIRK_*)
54 * @channels_mask: bit mask of available DU channels
55 * @routes: array of CRTC to output routes, indexed by output (RCAR_DU_OUTPUT_*)
56 * @num_lvds: number of internal LVDS encoders
57 * @dpll_mask: bit mask of DU channels equipped with a DPLL
58 * @lvds_clk_mask: bitmask of channels that can use the LVDS clock as dot clock
60 struct rcar_du_device_info {
61 unsigned int gen;
62 unsigned int features;
63 unsigned int quirks;
64 unsigned int channels_mask;
65 struct rcar_du_output_routing routes[RCAR_DU_OUTPUT_MAX];
66 unsigned int num_lvds;
67 unsigned int dpll_mask;
68 unsigned int lvds_clk_mask;
71 #define RCAR_DU_MAX_CRTCS 4
72 #define RCAR_DU_MAX_GROUPS DIV_ROUND_UP(RCAR_DU_MAX_CRTCS, 2)
73 #define RCAR_DU_MAX_VSPS 4
75 struct rcar_du_device {
76 struct device *dev;
77 const struct rcar_du_device_info *info;
79 void __iomem *mmio;
81 struct drm_device *ddev;
83 struct rcar_du_crtc crtcs[RCAR_DU_MAX_CRTCS];
84 unsigned int num_crtcs;
86 struct rcar_du_encoder *encoders[RCAR_DU_OUTPUT_MAX];
88 struct rcar_du_group groups[RCAR_DU_MAX_GROUPS];
89 struct platform_device *cmms[RCAR_DU_MAX_CRTCS];
90 struct rcar_du_vsp vsps[RCAR_DU_MAX_VSPS];
92 struct {
93 struct drm_property *colorkey;
94 } props;
96 unsigned int dpad0_source;
97 unsigned int dpad1_source;
98 unsigned int vspd1_sink;
101 static inline bool rcar_du_has(struct rcar_du_device *rcdu,
102 unsigned int feature)
104 return rcdu->info->features & feature;
107 static inline bool rcar_du_needs(struct rcar_du_device *rcdu,
108 unsigned int quirk)
110 return rcdu->info->quirks & quirk;
113 static inline u32 rcar_du_read(struct rcar_du_device *rcdu, u32 reg)
115 return ioread32(rcdu->mmio + reg);
118 static inline void rcar_du_write(struct rcar_du_device *rcdu, u32 reg, u32 data)
120 iowrite32(data, rcdu->mmio + reg);
123 #endif /* __RCAR_DU_DRV_H__ */