rcar_du_drv.h 3.1 KB
Newer Older
1
/* SPDX-License-Identifier: GPL-2.0+ */
2 3 4
/*
 * rcar_du_drv.h  --  R-Car Display Unit DRM driver
 *
5
 * Copyright (C) 2013-2015 Renesas Electronics Corporation
6 7 8 9 10 11 12 13
 *
 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
 */

#ifndef __RCAR_DU_DRV_H__
#define __RCAR_DU_DRV_H__

#include <linux/kernel.h>
14
#include <linux/wait.h>
15 16

#include "rcar_du_crtc.h"
17
#include "rcar_du_group.h"
18
#include "rcar_du_vsp.h"
19 20 21 22

struct clk;
struct device;
struct drm_device;
23
struct drm_fbdev_cma;
24
struct rcar_du_device;
25

26 27 28
#define RCAR_DU_FEATURE_CRTC_IRQ_CLOCK	BIT(0)	/* Per-CRTC IRQ and clock */
#define RCAR_DU_FEATURE_EXT_CTRL_REGS	BIT(1)	/* Has extended control registers */
#define RCAR_DU_FEATURE_VSP1_SOURCE	BIT(2)	/* Has inputs from VSP1 */
29
#define RCAR_DU_FEATURE_INTERLACED	BIT(3)	/* HW supports interlaced */
30

31
#define RCAR_DU_QUIRK_ALIGN_128B	BIT(0)	/* Align pitches to 128 bytes */
32

33 34 35
/*
 * struct rcar_du_output_routing - Output routing specification
 * @possible_crtcs: bitmask of possible CRTCs for the output
L
Laurent Pinchart 已提交
36
 * @port: device tree port number corresponding to this output route
37 38 39 40 41 42 43
 *
 * The DU has 5 possible outputs (DPAD0/1, LVDS0/1, TCON). Output routing data
 * specify the valid SoC outputs, which CRTCs can drive the output, and the type
 * of in-SoC encoder for the output.
 */
struct rcar_du_output_routing {
	unsigned int possible_crtcs;
L
Laurent Pinchart 已提交
44
	unsigned int port;
45 46
};

47 48
/*
 * struct rcar_du_device_info - DU model-specific information
49
 * @gen: device generation (2 or 3)
50
 * @features: device features (RCAR_DU_FEATURE_*)
51
 * @quirks: device quirks (RCAR_DU_QUIRK_*)
52
 * @channels_mask: bit mask of available DU channels
53
 * @routes: array of CRTC to output routes, indexed by output (RCAR_DU_OUTPUT_*)
54
 * @num_lvds: number of internal LVDS encoders
55
 * @dpll_mask: bit mask of DU channels equipped with a DPLL
56 57
 */
struct rcar_du_device_info {
58
	unsigned int gen;
59
	unsigned int features;
60
	unsigned int quirks;
61
	unsigned int channels_mask;
62
	struct rcar_du_output_routing routes[RCAR_DU_OUTPUT_MAX];
63
	unsigned int num_lvds;
64
	unsigned int dpll_mask;
65 66
};

67
#define RCAR_DU_MAX_CRTCS		4
68
#define RCAR_DU_MAX_GROUPS		DIV_ROUND_UP(RCAR_DU_MAX_CRTCS, 2)
69
#define RCAR_DU_MAX_VSPS		4
70

71 72
struct rcar_du_device {
	struct device *dev;
73
	const struct rcar_du_device_info *info;
74 75 76 77

	void __iomem *mmio;

	struct drm_device *ddev;
78
	struct drm_fbdev_cma *fbdev;
79
	struct drm_atomic_state *suspend_state;
80

81
	struct rcar_du_crtc crtcs[RCAR_DU_MAX_CRTCS];
82 83
	unsigned int num_crtcs;

84
	struct rcar_du_group groups[RCAR_DU_MAX_GROUPS];
85
	struct rcar_du_vsp vsps[RCAR_DU_MAX_VSPS];
86

87 88 89 90
	struct {
		struct drm_property *colorkey;
	} props;

91
	unsigned int dpad0_source;
92
	unsigned int vspd1_sink;
93 94
};

95 96 97 98 99 100
static inline bool rcar_du_has(struct rcar_du_device *rcdu,
			       unsigned int feature)
{
	return rcdu->info->features & feature;
}

101 102 103 104 105 106
static inline bool rcar_du_needs(struct rcar_du_device *rcdu,
				 unsigned int quirk)
{
	return rcdu->info->quirks & quirk;
}

107 108 109 110 111 112 113 114 115 116 117
static inline u32 rcar_du_read(struct rcar_du_device *rcdu, u32 reg)
{
	return ioread32(rcdu->mmio + reg);
}

static inline void rcar_du_write(struct rcar_du_device *rcdu, u32 reg, u32 data)
{
	iowrite32(data, rcdu->mmio + reg);
}

#endif /* __RCAR_DU_DRV_H__ */