Loading...
1/*
2 * rcar_du_drv.h -- R-Car Display Unit DRM driver
3 *
4 * Copyright (C) 2013-2015 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#include <linux/wait.h>
19
20#include "rcar_du_crtc.h"
21#include "rcar_du_group.h"
22#include "rcar_du_vsp.h"
23
24struct clk;
25struct device;
26struct drm_device;
27struct drm_fbdev_cma;
28struct rcar_du_device;
29struct rcar_du_lvdsenc;
30
31#define RCAR_DU_FEATURE_CRTC_IRQ_CLOCK (1 << 0) /* Per-CRTC IRQ and clock */
32#define RCAR_DU_FEATURE_EXT_CTRL_REGS (1 << 1) /* Has extended control registers */
33#define RCAR_DU_FEATURE_VSP1_SOURCE (1 << 2) /* Has inputs from VSP1 */
34
35#define RCAR_DU_QUIRK_ALIGN_128B (1 << 0) /* Align pitches to 128 bytes */
36#define RCAR_DU_QUIRK_LVDS_LANES (1 << 1) /* LVDS lanes 1 and 3 inverted */
37
38/*
39 * struct rcar_du_output_routing - Output routing specification
40 * @possible_crtcs: bitmask of possible CRTCs for the output
41 * @encoder_type: DRM type of the internal encoder associated with the output
42 * @port: device tree port number corresponding to this output route
43 *
44 * The DU has 5 possible outputs (DPAD0/1, LVDS0/1, TCON). Output routing data
45 * specify the valid SoC outputs, which CRTCs can drive the output, and the type
46 * of in-SoC encoder for the output.
47 */
48struct rcar_du_output_routing {
49 unsigned int possible_crtcs;
50 unsigned int encoder_type;
51 unsigned int port;
52};
53
54/*
55 * struct rcar_du_device_info - DU model-specific information
56 * @gen: device generation (2 or 3)
57 * @features: device features (RCAR_DU_FEATURE_*)
58 * @quirks: device quirks (RCAR_DU_QUIRK_*)
59 * @num_crtcs: total number of CRTCs
60 * @routes: array of CRTC to output routes, indexed by output (RCAR_DU_OUTPUT_*)
61 * @num_lvds: number of internal LVDS encoders
62 */
63struct rcar_du_device_info {
64 unsigned int gen;
65 unsigned int features;
66 unsigned int quirks;
67 unsigned int num_crtcs;
68 struct rcar_du_output_routing routes[RCAR_DU_OUTPUT_MAX];
69 unsigned int num_lvds;
70};
71
72#define RCAR_DU_MAX_CRTCS 4
73#define RCAR_DU_MAX_GROUPS DIV_ROUND_UP(RCAR_DU_MAX_CRTCS, 2)
74#define RCAR_DU_MAX_LVDS 2
75#define RCAR_DU_MAX_VSPS 4
76
77struct rcar_du_device {
78 struct device *dev;
79 const struct rcar_du_device_info *info;
80
81 void __iomem *mmio;
82
83 struct drm_device *ddev;
84 struct drm_fbdev_cma *fbdev;
85
86 struct rcar_du_crtc crtcs[RCAR_DU_MAX_CRTCS];
87 unsigned int num_crtcs;
88
89 struct rcar_du_group groups[RCAR_DU_MAX_GROUPS];
90 struct rcar_du_vsp vsps[RCAR_DU_MAX_VSPS];
91
92 struct {
93 struct drm_property *alpha;
94 struct drm_property *colorkey;
95 struct drm_property *zpos;
96 } props;
97
98 unsigned int dpad0_source;
99 unsigned int vspd1_sink;
100
101 struct rcar_du_lvdsenc *lvds[RCAR_DU_MAX_LVDS];
102
103 struct {
104 wait_queue_head_t wait;
105 u32 pending;
106 } commit;
107};
108
109static inline bool rcar_du_has(struct rcar_du_device *rcdu,
110 unsigned int feature)
111{
112 return rcdu->info->features & feature;
113}
114
115static inline bool rcar_du_needs(struct rcar_du_device *rcdu,
116 unsigned int quirk)
117{
118 return rcdu->info->quirks & quirk;
119}
120
121static inline u32 rcar_du_read(struct rcar_du_device *rcdu, u32 reg)
122{
123 return ioread32(rcdu->mmio + reg);
124}
125
126static inline void rcar_du_write(struct rcar_du_device *rcdu, u32 reg, u32 data)
127{
128 iowrite32(data, rcdu->mmio + reg);
129}
130
131#endif /* __RCAR_DU_DRV_H__ */
1/* SPDX-License-Identifier: GPL-2.0+ */
2/*
3 * rcar_du_drv.h -- R-Car Display Unit DRM driver
4 *
5 * Copyright (C) 2013-2015 Renesas Electronics Corporation
6 *
7 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
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 "rcar_cmm.h"
17#include "rcar_du_crtc.h"
18#include "rcar_du_group.h"
19#include "rcar_du_vsp.h"
20
21struct clk;
22struct device;
23struct drm_device;
24struct drm_property;
25struct rcar_du_device;
26struct rcar_du_encoder;
27
28#define RCAR_DU_FEATURE_CRTC_IRQ_CLOCK BIT(0) /* Per-CRTC IRQ and clock */
29#define RCAR_DU_FEATURE_VSP1_SOURCE BIT(1) /* Has inputs from VSP1 */
30#define RCAR_DU_FEATURE_INTERLACED BIT(2) /* HW supports interlaced */
31#define RCAR_DU_FEATURE_TVM_SYNC BIT(3) /* Has TV switch/sync modes */
32
33#define RCAR_DU_QUIRK_ALIGN_128B BIT(0) /* Align pitches to 128 bytes */
34
35/*
36 * struct rcar_du_output_routing - Output routing specification
37 * @possible_crtcs: bitmask of possible CRTCs for the output
38 * @port: device tree port number corresponding to this output route
39 *
40 * The DU has 5 possible outputs (DPAD0/1, LVDS0/1, TCON). Output routing data
41 * specify the valid SoC outputs, which CRTCs can drive the output, and the type
42 * of in-SoC encoder for the output.
43 */
44struct rcar_du_output_routing {
45 unsigned int possible_crtcs;
46 unsigned int port;
47};
48
49/*
50 * struct rcar_du_device_info - DU model-specific information
51 * @gen: device generation (2 or 3)
52 * @features: device features (RCAR_DU_FEATURE_*)
53 * @quirks: device quirks (RCAR_DU_QUIRK_*)
54 * @channels_mask: bit mask of available DU channels
55 * @routes: array of CRTC to output routes, indexed by output (RCAR_DU_OUTPUT_*)
56 * @num_lvds: number of internal LVDS encoders
57 * @dpll_mask: bit mask of DU channels equipped with a DPLL
58 * @lvds_clk_mask: bitmask of channels that can use the LVDS clock as dot clock
59 */
60struct rcar_du_device_info {
61 unsigned int gen;
62 unsigned int features;
63 unsigned int quirks;
64 unsigned int channels_mask;
65 struct rcar_du_output_routing routes[RCAR_DU_OUTPUT_MAX];
66 unsigned int num_lvds;
67 unsigned int dpll_mask;
68 unsigned int lvds_clk_mask;
69};
70
71#define RCAR_DU_MAX_CRTCS 4
72#define RCAR_DU_MAX_GROUPS DIV_ROUND_UP(RCAR_DU_MAX_CRTCS, 2)
73#define RCAR_DU_MAX_VSPS 4
74
75struct rcar_du_device {
76 struct device *dev;
77 const struct rcar_du_device_info *info;
78
79 void __iomem *mmio;
80
81 struct drm_device *ddev;
82
83 struct rcar_du_crtc crtcs[RCAR_DU_MAX_CRTCS];
84 unsigned int num_crtcs;
85
86 struct rcar_du_encoder *encoders[RCAR_DU_OUTPUT_MAX];
87
88 struct rcar_du_group groups[RCAR_DU_MAX_GROUPS];
89 struct platform_device *cmms[RCAR_DU_MAX_CRTCS];
90 struct rcar_du_vsp vsps[RCAR_DU_MAX_VSPS];
91
92 struct {
93 struct drm_property *colorkey;
94 } props;
95
96 unsigned int dpad0_source;
97 unsigned int dpad1_source;
98 unsigned int vspd1_sink;
99};
100
101static inline bool rcar_du_has(struct rcar_du_device *rcdu,
102 unsigned int feature)
103{
104 return rcdu->info->features & feature;
105}
106
107static inline bool rcar_du_needs(struct rcar_du_device *rcdu,
108 unsigned int quirk)
109{
110 return rcdu->info->quirks & quirk;
111}
112
113static inline u32 rcar_du_read(struct rcar_du_device *rcdu, u32 reg)
114{
115 return ioread32(rcdu->mmio + reg);
116}
117
118static inline void rcar_du_write(struct rcar_du_device *rcdu, u32 reg, u32 data)
119{
120 iowrite32(data, rcdu->mmio + reg);
121}
122
123#endif /* __RCAR_DU_DRV_H__ */