rcar_du_drv.h (4008B)
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 <drm/drm_device.h> 17 18#include "rcar_cmm.h" 19#include "rcar_du_crtc.h" 20#include "rcar_du_group.h" 21#include "rcar_du_vsp.h" 22 23struct clk; 24struct device; 25struct drm_bridge; 26struct drm_property; 27struct rcar_du_device; 28 29#define RCAR_DU_FEATURE_CRTC_IRQ BIT(0) /* Per-CRTC IRQ */ 30#define RCAR_DU_FEATURE_CRTC_CLOCK BIT(1) /* Per-CRTC clock */ 31#define RCAR_DU_FEATURE_VSP1_SOURCE BIT(2) /* Has inputs from VSP1 */ 32#define RCAR_DU_FEATURE_INTERLACED BIT(3) /* HW supports interlaced */ 33#define RCAR_DU_FEATURE_TVM_SYNC BIT(4) /* Has TV switch/sync modes */ 34 35#define RCAR_DU_QUIRK_ALIGN_128B BIT(0) /* Align pitches to 128 bytes */ 36 37enum rcar_du_output { 38 RCAR_DU_OUTPUT_DPAD0, 39 RCAR_DU_OUTPUT_DPAD1, 40 RCAR_DU_OUTPUT_DSI0, 41 RCAR_DU_OUTPUT_DSI1, 42 RCAR_DU_OUTPUT_HDMI0, 43 RCAR_DU_OUTPUT_HDMI1, 44 RCAR_DU_OUTPUT_LVDS0, 45 RCAR_DU_OUTPUT_LVDS1, 46 RCAR_DU_OUTPUT_TCON, 47 RCAR_DU_OUTPUT_MAX, 48}; 49 50/* 51 * struct rcar_du_output_routing - Output routing specification 52 * @possible_crtcs: bitmask of possible CRTCs for the output 53 * @port: device tree port number corresponding to this output route 54 * 55 * The DU has 5 possible outputs (DPAD0/1, LVDS0/1, TCON). Output routing data 56 * specify the valid SoC outputs, which CRTCs can drive the output, and the type 57 * of in-SoC encoder for the output. 58 */ 59struct rcar_du_output_routing { 60 unsigned int possible_crtcs; 61 unsigned int port; 62}; 63 64/* 65 * struct rcar_du_device_info - DU model-specific information 66 * @gen: device generation (2 or 3) 67 * @features: device features (RCAR_DU_FEATURE_*) 68 * @quirks: device quirks (RCAR_DU_QUIRK_*) 69 * @channels_mask: bit mask of available DU channels 70 * @routes: array of CRTC to output routes, indexed by output (RCAR_DU_OUTPUT_*) 71 * @num_lvds: number of internal LVDS encoders 72 * @dpll_mask: bit mask of DU channels equipped with a DPLL 73 * @dsi_clk_mask: bitmask of channels that can use the DSI clock as dot clock 74 * @lvds_clk_mask: bitmask of channels that can use the LVDS clock as dot clock 75 */ 76struct rcar_du_device_info { 77 unsigned int gen; 78 unsigned int features; 79 unsigned int quirks; 80 unsigned int channels_mask; 81 struct rcar_du_output_routing routes[RCAR_DU_OUTPUT_MAX]; 82 unsigned int num_lvds; 83 unsigned int dpll_mask; 84 unsigned int dsi_clk_mask; 85 unsigned int lvds_clk_mask; 86}; 87 88#define RCAR_DU_MAX_CRTCS 4 89#define RCAR_DU_MAX_GROUPS DIV_ROUND_UP(RCAR_DU_MAX_CRTCS, 2) 90#define RCAR_DU_MAX_VSPS 4 91#define RCAR_DU_MAX_LVDS 2 92 93struct rcar_du_device { 94 struct device *dev; 95 const struct rcar_du_device_info *info; 96 97 void __iomem *mmio; 98 99 struct drm_device ddev; 100 101 struct rcar_du_crtc crtcs[RCAR_DU_MAX_CRTCS]; 102 unsigned int num_crtcs; 103 104 struct rcar_du_group groups[RCAR_DU_MAX_GROUPS]; 105 struct platform_device *cmms[RCAR_DU_MAX_CRTCS]; 106 struct rcar_du_vsp vsps[RCAR_DU_MAX_VSPS]; 107 struct drm_bridge *lvds[RCAR_DU_MAX_LVDS]; 108 109 struct { 110 struct drm_property *colorkey; 111 } props; 112 113 unsigned int dpad0_source; 114 unsigned int dpad1_source; 115 unsigned int vspd1_sink; 116}; 117 118static inline struct rcar_du_device *to_rcar_du_device(struct drm_device *dev) 119{ 120 return container_of(dev, struct rcar_du_device, ddev); 121} 122 123static inline bool rcar_du_has(struct rcar_du_device *rcdu, 124 unsigned int feature) 125{ 126 return rcdu->info->features & feature; 127} 128 129static inline bool rcar_du_needs(struct rcar_du_device *rcdu, 130 unsigned int quirk) 131{ 132 return rcdu->info->quirks & quirk; 133} 134 135static inline u32 rcar_du_read(struct rcar_du_device *rcdu, u32 reg) 136{ 137 return ioread32(rcdu->mmio + reg); 138} 139 140static inline void rcar_du_write(struct rcar_du_device *rcdu, u32 reg, u32 data) 141{ 142 iowrite32(data, rcdu->mmio + reg); 143} 144 145const char *rcar_du_output_name(enum rcar_du_output output); 146 147#endif /* __RCAR_DU_DRV_H__ */