Commit | Line | Data |
---|---|---|
4bf8e196 LP |
1 | /* |
2 | * rcar_du_drv.h -- R-Car Display Unit DRM driver | |
3 | * | |
36d50464 | 4 | * Copyright (C) 2013-2014 Renesas Electronics Corporation |
4bf8e196 LP |
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> | |
4bf8e196 LP |
18 | #include <linux/platform_data/rcar-du.h> |
19 | ||
20 | #include "rcar_du_crtc.h" | |
cb2025d2 | 21 | #include "rcar_du_group.h" |
4bf8e196 LP |
22 | |
23 | struct clk; | |
24 | struct device; | |
25 | struct drm_device; | |
3864c6f4 | 26 | struct drm_fbdev_cma; |
cb2025d2 | 27 | struct rcar_du_device; |
90374b5c | 28 | struct rcar_du_lvdsenc; |
4bf8e196 | 29 | |
f66ee304 | 30 | #define RCAR_DU_FEATURE_CRTC_IRQ_CLOCK (1 << 0) /* Per-CRTC IRQ and clock */ |
e8355e0d LP |
31 | #define RCAR_DU_FEATURE_DEFR8 (1 << 1) /* Has DEFR8 register */ |
32 | ||
33 | #define RCAR_DU_QUIRK_ALIGN_128B (1 << 0) /* Align pitches to 128 bytes */ | |
5cca30eb | 34 | #define RCAR_DU_QUIRK_LVDS_LANES (1 << 1) /* LVDS lanes 1 and 3 inverted */ |
f66ee304 | 35 | |
ef67a902 LP |
36 | /* |
37 | * struct rcar_du_output_routing - Output routing specification | |
38 | * @possible_crtcs: bitmask of possible CRTCs for the output | |
39 | * @encoder_type: DRM type of the internal encoder associated with the output | |
96c02691 | 40 | * @port: device tree port number corresponding to this output route |
ef67a902 LP |
41 | * |
42 | * The DU has 5 possible outputs (DPAD0/1, LVDS0/1, TCON). Output routing data | |
43 | * specify the valid SoC outputs, which CRTCs can drive the output, and the type | |
44 | * of in-SoC encoder for the output. | |
45 | */ | |
46 | struct rcar_du_output_routing { | |
47 | unsigned int possible_crtcs; | |
48 | unsigned int encoder_type; | |
96c02691 | 49 | unsigned int port; |
ef67a902 LP |
50 | }; |
51 | ||
481d342e LP |
52 | /* |
53 | * struct rcar_du_device_info - DU model-specific information | |
54 | * @features: device features (RCAR_DU_FEATURE_*) | |
e8355e0d | 55 | * @quirks: device quirks (RCAR_DU_QUIRK_*) |
a5f0ef59 | 56 | * @num_crtcs: total number of CRTCs |
ef67a902 | 57 | * @routes: array of CRTC to output routes, indexed by output (RCAR_DU_OUTPUT_*) |
90374b5c | 58 | * @num_lvds: number of internal LVDS encoders |
481d342e LP |
59 | */ |
60 | struct rcar_du_device_info { | |
61 | unsigned int features; | |
e8355e0d | 62 | unsigned int quirks; |
a5f0ef59 | 63 | unsigned int num_crtcs; |
ef67a902 | 64 | struct rcar_du_output_routing routes[RCAR_DU_OUTPUT_MAX]; |
90374b5c | 65 | unsigned int num_lvds; |
481d342e LP |
66 | }; |
67 | ||
4bf8e196 LP |
68 | struct rcar_du_device { |
69 | struct device *dev; | |
70 | const struct rcar_du_platform_data *pdata; | |
481d342e | 71 | const struct rcar_du_device_info *info; |
4bf8e196 LP |
72 | |
73 | void __iomem *mmio; | |
4bf8e196 LP |
74 | |
75 | struct drm_device *ddev; | |
3864c6f4 | 76 | struct drm_fbdev_cma *fbdev; |
4bf8e196 | 77 | |
a5f0ef59 | 78 | struct rcar_du_crtc crtcs[3]; |
4bf8e196 LP |
79 | unsigned int num_crtcs; |
80 | ||
a5f0ef59 | 81 | struct rcar_du_group groups[2]; |
7cbc05cb LP |
82 | |
83 | unsigned int dpad0_source; | |
90374b5c | 84 | struct rcar_du_lvdsenc *lvds[2]; |
4bf8e196 LP |
85 | }; |
86 | ||
481d342e LP |
87 | static inline bool rcar_du_has(struct rcar_du_device *rcdu, |
88 | unsigned int feature) | |
89 | { | |
90 | return rcdu->info->features & feature; | |
91 | } | |
92 | ||
e8355e0d LP |
93 | static inline bool rcar_du_needs(struct rcar_du_device *rcdu, |
94 | unsigned int quirk) | |
95 | { | |
96 | return rcdu->info->quirks & quirk; | |
97 | } | |
98 | ||
4bf8e196 LP |
99 | static inline u32 rcar_du_read(struct rcar_du_device *rcdu, u32 reg) |
100 | { | |
101 | return ioread32(rcdu->mmio + reg); | |
102 | } | |
103 | ||
104 | static inline void rcar_du_write(struct rcar_du_device *rcdu, u32 reg, u32 data) | |
105 | { | |
106 | iowrite32(data, rcdu->mmio + reg); | |
107 | } | |
108 | ||
109 | #endif /* __RCAR_DU_DRV_H__ */ |