1 /* SPDX-License-Identifier: GPL-2.0+ */
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)
10 #ifndef __RCAR_DU_DRV_H__
11 #define __RCAR_DU_DRV_H__
13 #include <linux/kernel.h>
14 #include <linux/wait.h>
16 #include <drm/drm_device.h>
19 #include "rcar_du_crtc.h"
20 #include "rcar_du_group.h"
21 #include "rcar_du_vsp.h"
27 struct rcar_du_device;
29 #define RCAR_DU_FEATURE_CRTC_IRQ BIT(0) /* Per-CRTC IRQ */
30 #define RCAR_DU_FEATURE_CRTC_CLOCK BIT(1) /* Per-CRTC clock */
31 #define RCAR_DU_FEATURE_VSP1_SOURCE BIT(2) /* Has inputs from VSP1 */
32 #define RCAR_DU_FEATURE_INTERLACED BIT(3) /* HW supports interlaced */
33 #define RCAR_DU_FEATURE_TVM_SYNC BIT(4) /* Has TV switch/sync modes */
35 #define RCAR_DU_QUIRK_ALIGN_128B BIT(0) /* Align pitches to 128 bytes */
51 * struct rcar_du_output_routing - Output routing specification
52 * @possible_crtcs: bitmask of possible CRTCs for the output
53 * @port: device tree port number corresponding to this output route
55 * The DU has 5 possible outputs (DPAD0/1, LVDS0/1, TCON). Output routing data
56 * specify the valid SoC outputs, which CRTCs can drive the output, and the type
57 * of in-SoC encoder for the output.
59 struct rcar_du_output_routing {
60 unsigned int possible_crtcs;
65 * struct rcar_du_device_info - DU model-specific information
66 * @gen: device generation (2 or 3)
67 * @features: device features (RCAR_DU_FEATURE_*)
68 * @quirks: device quirks (RCAR_DU_QUIRK_*)
69 * @channels_mask: bit mask of available DU channels
70 * @routes: array of CRTC to output routes, indexed by output (RCAR_DU_OUTPUT_*)
71 * @num_lvds: number of internal LVDS encoders
72 * @dpll_mask: bit mask of DU channels equipped with a DPLL
73 * @dsi_clk_mask: bitmask of channels that can use the DSI clock as dot clock
74 * @lvds_clk_mask: bitmask of channels that can use the LVDS clock as dot clock
76 struct rcar_du_device_info {
78 unsigned int features;
80 unsigned int channels_mask;
81 struct rcar_du_output_routing routes[RCAR_DU_OUTPUT_MAX];
82 unsigned int num_lvds;
83 unsigned int dpll_mask;
84 unsigned int dsi_clk_mask;
85 unsigned int lvds_clk_mask;
88 #define RCAR_DU_MAX_CRTCS 4
89 #define RCAR_DU_MAX_GROUPS DIV_ROUND_UP(RCAR_DU_MAX_CRTCS, 2)
90 #define RCAR_DU_MAX_VSPS 4
91 #define RCAR_DU_MAX_LVDS 2
93 struct rcar_du_device {
95 const struct rcar_du_device_info *info;
99 struct drm_device ddev;
101 struct rcar_du_crtc crtcs[RCAR_DU_MAX_CRTCS];
102 unsigned int num_crtcs;
104 struct rcar_du_group groups[RCAR_DU_MAX_GROUPS];
105 struct platform_device *cmms[RCAR_DU_MAX_CRTCS];
106 struct rcar_du_vsp vsps[RCAR_DU_MAX_VSPS];
107 struct drm_bridge *lvds[RCAR_DU_MAX_LVDS];
110 struct drm_property *colorkey;
113 unsigned int dpad0_source;
114 unsigned int dpad1_source;
115 unsigned int vspd1_sink;
118 static inline struct rcar_du_device *to_rcar_du_device(struct drm_device *dev)
120 return container_of(dev, struct rcar_du_device, ddev);
123 static inline bool rcar_du_has(struct rcar_du_device *rcdu,
124 unsigned int feature)
126 return rcdu->info->features & feature;
129 static inline bool rcar_du_needs(struct rcar_du_device *rcdu,
132 return rcdu->info->quirks & quirk;
135 static inline u32 rcar_du_read(struct rcar_du_device *rcdu, u32 reg)
137 return ioread32(rcdu->mmio + reg);
140 static inline void rcar_du_write(struct rcar_du_device *rcdu, u32 reg, u32 data)
142 iowrite32(data, rcdu->mmio + reg);
145 const char *rcar_du_output_name(enum rcar_du_output output);
147 #endif /* __RCAR_DU_DRV_H__ */