Merge tag 'v3.12'
[platform/adaptation/renesas_rcar/renesas_kernel.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 Renesas 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 #include <linux/platform_data/rcar-du.h>
19
20 #include "rcar_du_crtc.h"
21 #include "rcar_du_group.h"
22
23 struct clk;
24 struct device;
25 struct drm_device;
26 struct drm_fbdev_cma;
27 struct rcar_du_device;
28 struct rcar_du_lvdsenc;
29
30 #define RCAR_DU_FEATURE_CRTC_IRQ_CLOCK  (1 << 0)        /* Per-CRTC IRQ and clock */
31 #define RCAR_DU_FEATURE_ALIGN_128B      (1 << 1)        /* Align pitches to 128 bytes */
32 #define RCAR_DU_FEATURE_DEFR8           (1 << 2)        /* Has DEFR8 register */
33
34 /*
35  * struct rcar_du_output_routing - Output routing specification
36  * @possible_crtcs: bitmask of possible CRTCs for the output
37  * @encoder_type: DRM type of the internal encoder associated with the output
38  *
39  * The DU has 5 possible outputs (DPAD0/1, LVDS0/1, TCON). Output routing data
40  * specify the valid SoC outputs, which CRTCs can drive the output, and the type
41  * of in-SoC encoder for the output.
42  */
43 struct rcar_du_output_routing {
44         unsigned int possible_crtcs;
45         unsigned int encoder_type;
46 };
47
48 /*
49  * struct rcar_du_device_info - DU model-specific information
50  * @features: device features (RCAR_DU_FEATURE_*)
51  * @num_crtcs: total number of CRTCs
52  * @routes: array of CRTC to output routes, indexed by output (RCAR_DU_OUTPUT_*)
53  * @num_lvds: number of internal LVDS encoders
54  */
55 struct rcar_du_device_info {
56         unsigned int features;
57         unsigned int num_crtcs;
58         struct rcar_du_output_routing routes[RCAR_DU_OUTPUT_MAX];
59         unsigned int num_lvds;
60 };
61
62 struct rcar_du_device {
63         struct device *dev;
64         const struct rcar_du_platform_data *pdata;
65         const struct rcar_du_device_info *info;
66
67         void __iomem *mmio;
68
69         struct drm_device *ddev;
70         struct drm_fbdev_cma *fbdev;
71
72         struct rcar_du_crtc crtcs[3];
73         unsigned int num_crtcs;
74
75         struct rcar_du_group groups[2];
76
77         unsigned int dpad0_source;
78         struct rcar_du_lvdsenc *lvds[2];
79 };
80
81 static inline bool rcar_du_has(struct rcar_du_device *rcdu,
82                                unsigned int feature)
83 {
84         return rcdu->info->features & feature;
85 }
86
87 static inline u32 rcar_du_read(struct rcar_du_device *rcdu, u32 reg)
88 {
89         return ioread32(rcdu->mmio + reg);
90 }
91
92 static inline void rcar_du_write(struct rcar_du_device *rcdu, u32 reg, u32 data)
93 {
94         iowrite32(data, rcdu->mmio + reg);
95 }
96
97 #endif /* __RCAR_DU_DRV_H__ */