drm: rcar-du: Define macros for the max number of groups, CRTCs and LVDS
[deliverable/linux.git] / drivers / gpu / drm / rcar-du / rcar_du_drv.h
1 /*
2 * rcar_du_drv.h -- R-Car Display Unit DRM driver
3 *
4 * Copyright (C) 2013-2014 Renesas Electronics Corporation
5 *
6 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 */
13
14 #ifndef __RCAR_DU_DRV_H__
15 #define __RCAR_DU_DRV_H__
16
17 #include <linux/kernel.h>
18
19 #include "rcar_du_crtc.h"
20 #include "rcar_du_group.h"
21
22 struct clk;
23 struct device;
24 struct drm_device;
25 struct drm_fbdev_cma;
26 struct rcar_du_device;
27 struct rcar_du_lvdsenc;
28
29 #define RCAR_DU_FEATURE_CRTC_IRQ_CLOCK (1 << 0) /* Per-CRTC IRQ and clock */
30 #define RCAR_DU_FEATURE_EXT_CTRL_REGS (1 << 1) /* Has extended control registers */
31
32 #define RCAR_DU_QUIRK_ALIGN_128B (1 << 0) /* Align pitches to 128 bytes */
33 #define RCAR_DU_QUIRK_LVDS_LANES (1 << 1) /* LVDS lanes 1 and 3 inverted */
34
35 /*
36 * struct rcar_du_output_routing - Output routing specification
37 * @possible_crtcs: bitmask of possible CRTCs for the output
38 * @encoder_type: DRM type of the internal encoder associated with the output
39 * @port: device tree port number corresponding to this output route
40 *
41 * The DU has 5 possible outputs (DPAD0/1, LVDS0/1, TCON). Output routing data
42 * specify the valid SoC outputs, which CRTCs can drive the output, and the type
43 * of in-SoC encoder for the output.
44 */
45 struct rcar_du_output_routing {
46 unsigned int possible_crtcs;
47 unsigned int encoder_type;
48 unsigned int port;
49 };
50
51 /*
52 * struct rcar_du_device_info - DU model-specific information
53 * @features: device features (RCAR_DU_FEATURE_*)
54 * @quirks: device quirks (RCAR_DU_QUIRK_*)
55 * @num_crtcs: total number of CRTCs
56 * @routes: array of CRTC to output routes, indexed by output (RCAR_DU_OUTPUT_*)
57 * @num_lvds: number of internal LVDS encoders
58 */
59 struct rcar_du_device_info {
60 unsigned int features;
61 unsigned int quirks;
62 unsigned int num_crtcs;
63 struct rcar_du_output_routing routes[RCAR_DU_OUTPUT_MAX];
64 unsigned int num_lvds;
65 };
66
67 #define RCAR_DU_MAX_CRTCS 3
68 #define RCAR_DU_MAX_GROUPS DIV_ROUND_UP(RCAR_DU_MAX_CRTCS, 2)
69 #define RCAR_DU_MAX_LVDS 2
70
71 struct rcar_du_device {
72 struct device *dev;
73 const struct rcar_du_device_info *info;
74
75 void __iomem *mmio;
76
77 struct drm_device *ddev;
78 struct drm_fbdev_cma *fbdev;
79
80 struct rcar_du_crtc crtcs[RCAR_DU_MAX_CRTCS];
81 unsigned int num_crtcs;
82
83 struct rcar_du_group groups[RCAR_DU_MAX_GROUPS];
84
85 unsigned int dpad0_source;
86 struct rcar_du_lvdsenc *lvds[RCAR_DU_MAX_LVDS];
87 };
88
89 static inline bool rcar_du_has(struct rcar_du_device *rcdu,
90 unsigned int feature)
91 {
92 return rcdu->info->features & feature;
93 }
94
95 static inline bool rcar_du_needs(struct rcar_du_device *rcdu,
96 unsigned int quirk)
97 {
98 return rcdu->info->quirks & quirk;
99 }
100
101 static inline u32 rcar_du_read(struct rcar_du_device *rcdu, u32 reg)
102 {
103 return ioread32(rcdu->mmio + reg);
104 }
105
106 static inline void rcar_du_write(struct rcar_du_device *rcdu, u32 reg, u32 data)
107 {
108 iowrite32(data, rcdu->mmio + reg);
109 }
110
111 #endif /* __RCAR_DU_DRV_H__ */
This page took 0.03417 seconds and 5 git commands to generate.