blob: 924f5e08f0602eca404c9edd446d490a5099733d [file] [log] [blame]
Laurent Pinchart4bf8e192013-06-19 13:54:11 +02001/*
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>
Laurent Pinchart4bf8e192013-06-19 13:54:11 +020018#include <linux/platform_data/rcar-du.h>
19
20#include "rcar_du_crtc.h"
Laurent Pinchartcb2025d2013-06-16 21:01:02 +020021#include "rcar_du_group.h"
Laurent Pinchart4bf8e192013-06-19 13:54:11 +020022
23struct clk;
24struct device;
25struct drm_device;
Laurent Pinchartcb2025d2013-06-16 21:01:02 +020026struct rcar_du_device;
Laurent Pinchart4bf8e192013-06-19 13:54:11 +020027
Laurent Pinchartf66ee302013-06-14 14:15:01 +020028#define RCAR_DU_FEATURE_CRTC_IRQ_CLOCK (1 << 0) /* Per-CRTC IRQ and clock */
Laurent Pinchart9e2d2de2013-06-14 20:52:52 +020029#define RCAR_DU_FEATURE_ALIGN_128B (1 << 1) /* Align pitches to 128 bytes */
Laurent Pinchart38b62fb2013-06-15 02:40:57 +020030#define RCAR_DU_FEATURE_DEFR8 (1 << 2) /* Has DEFR8 register */
Laurent Pinchartf66ee302013-06-14 14:15:01 +020031
Laurent Pinchart481d3422013-06-14 13:38:33 +020032/*
Laurent Pinchartef67a902013-06-17 03:13:11 +020033 * struct rcar_du_output_routing - Output routing specification
34 * @possible_crtcs: bitmask of possible CRTCs for the output
35 * @encoder_type: DRM type of the internal encoder associated with the output
36 *
37 * The DU has 5 possible outputs (DPAD0/1, LVDS0/1, TCON). Output routing data
38 * specify the valid SoC outputs, which CRTCs can drive the output, and the type
39 * of in-SoC encoder for the output.
40 */
41struct rcar_du_output_routing {
42 unsigned int possible_crtcs;
43 unsigned int encoder_type;
44};
45
46/*
Laurent Pinchart481d3422013-06-14 13:38:33 +020047 * struct rcar_du_device_info - DU model-specific information
48 * @features: device features (RCAR_DU_FEATURE_*)
Laurent Pincharta5f0ef52013-06-17 00:29:25 +020049 * @num_crtcs: total number of CRTCs
Laurent Pinchartef67a902013-06-17 03:13:11 +020050 * @routes: array of CRTC to output routes, indexed by output (RCAR_DU_OUTPUT_*)
Laurent Pinchart481d3422013-06-14 13:38:33 +020051 */
52struct rcar_du_device_info {
53 unsigned int features;
Laurent Pincharta5f0ef52013-06-17 00:29:25 +020054 unsigned int num_crtcs;
Laurent Pinchartef67a902013-06-17 03:13:11 +020055 struct rcar_du_output_routing routes[RCAR_DU_OUTPUT_MAX];
Laurent Pinchart481d3422013-06-14 13:38:33 +020056};
57
Laurent Pinchart4bf8e192013-06-19 13:54:11 +020058struct rcar_du_device {
59 struct device *dev;
60 const struct rcar_du_platform_data *pdata;
Laurent Pinchart481d3422013-06-14 13:38:33 +020061 const struct rcar_du_device_info *info;
Laurent Pinchart4bf8e192013-06-19 13:54:11 +020062
63 void __iomem *mmio;
Laurent Pinchart4bf8e192013-06-19 13:54:11 +020064
65 struct drm_device *ddev;
66
Laurent Pincharta5f0ef52013-06-17 00:29:25 +020067 struct rcar_du_crtc crtcs[3];
Laurent Pinchart4bf8e192013-06-19 13:54:11 +020068 unsigned int num_crtcs;
69
Laurent Pincharta5f0ef52013-06-17 00:29:25 +020070 struct rcar_du_group groups[2];
Laurent Pinchart7cbc05c2013-06-17 03:20:08 +020071
72 unsigned int dpad0_source;
Laurent Pinchart4bf8e192013-06-19 13:54:11 +020073};
74
Laurent Pinchart481d3422013-06-14 13:38:33 +020075static inline bool rcar_du_has(struct rcar_du_device *rcdu,
76 unsigned int feature)
77{
78 return rcdu->info->features & feature;
79}
80
Laurent Pinchart4bf8e192013-06-19 13:54:11 +020081static inline u32 rcar_du_read(struct rcar_du_device *rcdu, u32 reg)
82{
83 return ioread32(rcdu->mmio + reg);
84}
85
86static inline void rcar_du_write(struct rcar_du_device *rcdu, u32 reg, u32 data)
87{
88 iowrite32(data, rcdu->mmio + reg);
89}
90
91#endif /* __RCAR_DU_DRV_H__ */