1
2
3
4
5
6
7
8
9
10#ifndef __RCAR_DU_DRV_H__
11#define __RCAR_DU_DRV_H__
12
13#include <linux/kernel.h>
14#include <linux/wait.h>
15
16#include <drm/drm_device.h>
17
18#include "rcar_cmm.h"
19#include "rcar_du_crtc.h"
20#include "rcar_du_group.h"
21#include "rcar_du_vsp.h"
22
23struct clk;
24struct device;
25struct drm_bridge;
26struct drm_property;
27struct rcar_du_device;
28
29#define RCAR_DU_FEATURE_CRTC_IRQ BIT(0)
30#define RCAR_DU_FEATURE_CRTC_CLOCK BIT(1)
31#define RCAR_DU_FEATURE_VSP1_SOURCE BIT(2)
32#define RCAR_DU_FEATURE_INTERLACED BIT(3)
33#define RCAR_DU_FEATURE_TVM_SYNC BIT(4)
34
35#define RCAR_DU_QUIRK_ALIGN_128B BIT(0)
36
37enum rcar_du_output {
38 RCAR_DU_OUTPUT_DPAD0,
39 RCAR_DU_OUTPUT_DPAD1,
40 RCAR_DU_OUTPUT_DSI0,
41 RCAR_DU_OUTPUT_DSI1,
42 RCAR_DU_OUTPUT_HDMI0,
43 RCAR_DU_OUTPUT_HDMI1,
44 RCAR_DU_OUTPUT_LVDS0,
45 RCAR_DU_OUTPUT_LVDS1,
46 RCAR_DU_OUTPUT_TCON,
47 RCAR_DU_OUTPUT_MAX,
48};
49
50
51
52
53
54
55
56
57
58
59struct rcar_du_output_routing {
60 unsigned int possible_crtcs;
61 unsigned int port;
62};
63
64
65
66
67
68
69
70
71
72
73
74
75
76struct rcar_du_device_info {
77 unsigned int gen;
78 unsigned int features;
79 unsigned int quirks;
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;
86};
87
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
92
93struct rcar_du_device {
94 struct device *dev;
95 const struct rcar_du_device_info *info;
96
97 void __iomem *mmio;
98
99 struct drm_device ddev;
100
101 struct rcar_du_crtc crtcs[RCAR_DU_MAX_CRTCS];
102 unsigned int num_crtcs;
103
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];
108
109 struct {
110 struct drm_property *colorkey;
111 } props;
112
113 unsigned int dpad0_source;
114 unsigned int dpad1_source;
115 unsigned int vspd1_sink;
116};
117
118static inline struct rcar_du_device *to_rcar_du_device(struct drm_device *dev)
119{
120 return container_of(dev, struct rcar_du_device, ddev);
121}
122
123static inline bool rcar_du_has(struct rcar_du_device *rcdu,
124 unsigned int feature)
125{
126 return rcdu->info->features & feature;
127}
128
129static inline bool rcar_du_needs(struct rcar_du_device *rcdu,
130 unsigned int quirk)
131{
132 return rcdu->info->quirks & quirk;
133}
134
135static inline u32 rcar_du_read(struct rcar_du_device *rcdu, u32 reg)
136{
137 return ioread32(rcdu->mmio + reg);
138}
139
140static inline void rcar_du_write(struct rcar_du_device *rcdu, u32 reg, u32 data)
141{
142 iowrite32(data, rcdu->mmio + reg);
143}
144
145const char *rcar_du_output_name(enum rcar_du_output output);
146
147#endif
148