Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 1 | /* |
| 2 | * rcar_du_drv.h -- R-Car Display Unit DRM driver |
| 3 | * |
Laurent Pinchart | 2427b30 | 2015-09-07 17:34:26 +0300 | [diff] [blame] | 4 | * Copyright (C) 2013-2015 Renesas Electronics Corporation |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 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 Pinchart | 8d3f9b2 | 2015-02-23 01:02:15 +0200 | [diff] [blame] | 18 | #include <linux/wait.h> |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 19 | |
| 20 | #include "rcar_du_crtc.h" |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 21 | #include "rcar_du_group.h" |
Laurent Pinchart | 6d62ef3 | 2015-09-07 17:14:58 +0300 | [diff] [blame] | 22 | #include "rcar_du_vsp.h" |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 23 | |
| 24 | struct clk; |
| 25 | struct device; |
| 26 | struct drm_device; |
Laurent Pinchart | 3864c6f | 2013-03-14 22:45:22 +0100 | [diff] [blame] | 27 | struct drm_fbdev_cma; |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 28 | struct rcar_du_device; |
Laurent Pinchart | 90374b5 | 2013-06-17 13:48:27 +0200 | [diff] [blame] | 29 | struct rcar_du_lvdsenc; |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 30 | |
Laurent Pinchart | f66ee30 | 2013-06-14 14:15:01 +0200 | [diff] [blame] | 31 | #define RCAR_DU_FEATURE_CRTC_IRQ_CLOCK (1 << 0) /* Per-CRTC IRQ and clock */ |
Laurent Pinchart | 0c1c877 | 2014-12-09 00:21:12 +0200 | [diff] [blame] | 32 | #define RCAR_DU_FEATURE_EXT_CTRL_REGS (1 << 1) /* Has extended control registers */ |
Laurent Pinchart | 6d62ef3 | 2015-09-07 17:14:58 +0300 | [diff] [blame] | 33 | #define RCAR_DU_FEATURE_VSP1_SOURCE (1 << 2) /* Has inputs from VSP1 */ |
Laurent Pinchart | e8355e0 | 2013-11-13 13:33:45 +0100 | [diff] [blame] | 34 | |
| 35 | #define RCAR_DU_QUIRK_ALIGN_128B (1 << 0) /* Align pitches to 128 bytes */ |
Laurent Pinchart | 5cca30e | 2013-11-13 13:35:15 +0100 | [diff] [blame] | 36 | #define RCAR_DU_QUIRK_LVDS_LANES (1 << 1) /* LVDS lanes 1 and 3 inverted */ |
Laurent Pinchart | f66ee30 | 2013-06-14 14:15:01 +0200 | [diff] [blame] | 37 | |
Laurent Pinchart | 481d342 | 2013-06-14 13:38:33 +0200 | [diff] [blame] | 38 | /* |
Laurent Pinchart | ef67a90 | 2013-06-17 03:13:11 +0200 | [diff] [blame] | 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 |
Laurent Pinchart | 96c0269 | 2014-01-21 15:57:26 +0100 | [diff] [blame] | 42 | * @port: device tree port number corresponding to this output route |
Laurent Pinchart | ef67a90 | 2013-06-17 03:13:11 +0200 | [diff] [blame] | 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 | */ |
| 48 | struct rcar_du_output_routing { |
| 49 | unsigned int possible_crtcs; |
| 50 | unsigned int encoder_type; |
Laurent Pinchart | 96c0269 | 2014-01-21 15:57:26 +0100 | [diff] [blame] | 51 | unsigned int port; |
Laurent Pinchart | ef67a90 | 2013-06-17 03:13:11 +0200 | [diff] [blame] | 52 | }; |
| 53 | |
| 54 | /* |
Laurent Pinchart | 481d342 | 2013-06-14 13:38:33 +0200 | [diff] [blame] | 55 | * struct rcar_du_device_info - DU model-specific information |
Laurent Pinchart | 2427b30 | 2015-09-07 17:34:26 +0300 | [diff] [blame] | 56 | * @gen: device generation (2 or 3) |
Laurent Pinchart | 481d342 | 2013-06-14 13:38:33 +0200 | [diff] [blame] | 57 | * @features: device features (RCAR_DU_FEATURE_*) |
Laurent Pinchart | e8355e0 | 2013-11-13 13:33:45 +0100 | [diff] [blame] | 58 | * @quirks: device quirks (RCAR_DU_QUIRK_*) |
Laurent Pinchart | a5f0ef5 | 2013-06-17 00:29:25 +0200 | [diff] [blame] | 59 | * @num_crtcs: total number of CRTCs |
Laurent Pinchart | ef67a90 | 2013-06-17 03:13:11 +0200 | [diff] [blame] | 60 | * @routes: array of CRTC to output routes, indexed by output (RCAR_DU_OUTPUT_*) |
Laurent Pinchart | 90374b5 | 2013-06-17 13:48:27 +0200 | [diff] [blame] | 61 | * @num_lvds: number of internal LVDS encoders |
Laurent Pinchart | 481d342 | 2013-06-14 13:38:33 +0200 | [diff] [blame] | 62 | */ |
| 63 | struct rcar_du_device_info { |
Laurent Pinchart | 2427b30 | 2015-09-07 17:34:26 +0300 | [diff] [blame] | 64 | unsigned int gen; |
Laurent Pinchart | 481d342 | 2013-06-14 13:38:33 +0200 | [diff] [blame] | 65 | unsigned int features; |
Laurent Pinchart | e8355e0 | 2013-11-13 13:33:45 +0100 | [diff] [blame] | 66 | unsigned int quirks; |
Laurent Pinchart | a5f0ef5 | 2013-06-17 00:29:25 +0200 | [diff] [blame] | 67 | unsigned int num_crtcs; |
Laurent Pinchart | ef67a90 | 2013-06-17 03:13:11 +0200 | [diff] [blame] | 68 | struct rcar_du_output_routing routes[RCAR_DU_OUTPUT_MAX]; |
Laurent Pinchart | 90374b5 | 2013-06-17 13:48:27 +0200 | [diff] [blame] | 69 | unsigned int num_lvds; |
Laurent Pinchart | 481d342 | 2013-06-14 13:38:33 +0200 | [diff] [blame] | 70 | }; |
| 71 | |
Koji Matsuoka | 6a8c49f | 2015-09-04 19:49:05 +0900 | [diff] [blame] | 72 | #define RCAR_DU_MAX_CRTCS 4 |
Laurent Pinchart | a64b9c7 | 2015-02-25 18:21:12 +0200 | [diff] [blame] | 73 | #define RCAR_DU_MAX_GROUPS DIV_ROUND_UP(RCAR_DU_MAX_CRTCS, 2) |
| 74 | #define RCAR_DU_MAX_LVDS 2 |
Laurent Pinchart | 6d62ef3 | 2015-09-07 17:14:58 +0300 | [diff] [blame] | 75 | #define RCAR_DU_MAX_VSPS 4 |
Laurent Pinchart | a64b9c7 | 2015-02-25 18:21:12 +0200 | [diff] [blame] | 76 | |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 77 | struct rcar_du_device { |
| 78 | struct device *dev; |
Laurent Pinchart | 481d342 | 2013-06-14 13:38:33 +0200 | [diff] [blame] | 79 | const struct rcar_du_device_info *info; |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 80 | |
| 81 | void __iomem *mmio; |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 82 | |
| 83 | struct drm_device *ddev; |
Laurent Pinchart | 3864c6f | 2013-03-14 22:45:22 +0100 | [diff] [blame] | 84 | struct drm_fbdev_cma *fbdev; |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 85 | |
Laurent Pinchart | a64b9c7 | 2015-02-25 18:21:12 +0200 | [diff] [blame] | 86 | struct rcar_du_crtc crtcs[RCAR_DU_MAX_CRTCS]; |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 87 | unsigned int num_crtcs; |
| 88 | |
Laurent Pinchart | a64b9c7 | 2015-02-25 18:21:12 +0200 | [diff] [blame] | 89 | struct rcar_du_group groups[RCAR_DU_MAX_GROUPS]; |
Laurent Pinchart | 6d62ef3 | 2015-09-07 17:14:58 +0300 | [diff] [blame] | 90 | struct rcar_du_vsp vsps[RCAR_DU_MAX_VSPS]; |
Laurent Pinchart | 7cbc05c | 2013-06-17 03:20:08 +0200 | [diff] [blame] | 91 | |
Laurent Pinchart | 9f6aee9 | 2015-04-28 23:59:29 +0300 | [diff] [blame] | 92 | struct { |
| 93 | struct drm_property *alpha; |
| 94 | struct drm_property *colorkey; |
| 95 | struct drm_property *zpos; |
| 96 | } props; |
| 97 | |
Laurent Pinchart | 7cbc05c | 2013-06-17 03:20:08 +0200 | [diff] [blame] | 98 | unsigned int dpad0_source; |
Laurent Pinchart | 34a04f2 | 2013-06-21 17:54:50 +0200 | [diff] [blame] | 99 | unsigned int vspd1_sink; |
| 100 | |
Laurent Pinchart | a64b9c7 | 2015-02-25 18:21:12 +0200 | [diff] [blame] | 101 | struct rcar_du_lvdsenc *lvds[RCAR_DU_MAX_LVDS]; |
Laurent Pinchart | 8d3f9b2 | 2015-02-23 01:02:15 +0200 | [diff] [blame] | 102 | |
| 103 | struct { |
| 104 | wait_queue_head_t wait; |
| 105 | u32 pending; |
| 106 | } commit; |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 107 | }; |
| 108 | |
Laurent Pinchart | 481d342 | 2013-06-14 13:38:33 +0200 | [diff] [blame] | 109 | static inline bool rcar_du_has(struct rcar_du_device *rcdu, |
| 110 | unsigned int feature) |
| 111 | { |
| 112 | return rcdu->info->features & feature; |
| 113 | } |
| 114 | |
Laurent Pinchart | e8355e0 | 2013-11-13 13:33:45 +0100 | [diff] [blame] | 115 | static inline bool rcar_du_needs(struct rcar_du_device *rcdu, |
| 116 | unsigned int quirk) |
| 117 | { |
| 118 | return rcdu->info->quirks & quirk; |
| 119 | } |
| 120 | |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 121 | static inline u32 rcar_du_read(struct rcar_du_device *rcdu, u32 reg) |
| 122 | { |
| 123 | return ioread32(rcdu->mmio + reg); |
| 124 | } |
| 125 | |
| 126 | static 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__ */ |