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 | * |
| 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 Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 18 | #include <linux/platform_data/rcar-du.h> |
| 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 | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 22 | |
| 23 | struct clk; |
| 24 | struct device; |
| 25 | struct drm_device; |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 26 | struct rcar_du_device; |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 27 | |
Laurent Pinchart | f66ee30 | 2013-06-14 14:15:01 +0200 | [diff] [blame] | 28 | #define RCAR_DU_FEATURE_CRTC_IRQ_CLOCK (1 << 0) /* Per-CRTC IRQ and clock */ |
Laurent Pinchart | 9e2d2de | 2013-06-14 20:52:52 +0200 | [diff] [blame] | 29 | #define RCAR_DU_FEATURE_ALIGN_128B (1 << 1) /* Align pitches to 128 bytes */ |
Laurent Pinchart | 38b62fb | 2013-06-15 02:40:57 +0200 | [diff] [blame] | 30 | #define RCAR_DU_FEATURE_DEFR8 (1 << 2) /* Has DEFR8 register */ |
Laurent Pinchart | f66ee30 | 2013-06-14 14:15:01 +0200 | [diff] [blame] | 31 | |
Laurent Pinchart | 481d342 | 2013-06-14 13:38:33 +0200 | [diff] [blame] | 32 | /* |
Laurent Pinchart | ef67a90 | 2013-06-17 03:13:11 +0200 | [diff] [blame] | 33 | * 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 | */ |
| 41 | struct rcar_du_output_routing { |
| 42 | unsigned int possible_crtcs; |
| 43 | unsigned int encoder_type; |
| 44 | }; |
| 45 | |
| 46 | /* |
Laurent Pinchart | 481d342 | 2013-06-14 13:38:33 +0200 | [diff] [blame] | 47 | * struct rcar_du_device_info - DU model-specific information |
| 48 | * @features: device features (RCAR_DU_FEATURE_*) |
Laurent Pinchart | a5f0ef5 | 2013-06-17 00:29:25 +0200 | [diff] [blame] | 49 | * @num_crtcs: total number of CRTCs |
Laurent Pinchart | ef67a90 | 2013-06-17 03:13:11 +0200 | [diff] [blame] | 50 | * @routes: array of CRTC to output routes, indexed by output (RCAR_DU_OUTPUT_*) |
Laurent Pinchart | 481d342 | 2013-06-14 13:38:33 +0200 | [diff] [blame] | 51 | */ |
| 52 | struct rcar_du_device_info { |
| 53 | unsigned int features; |
Laurent Pinchart | a5f0ef5 | 2013-06-17 00:29:25 +0200 | [diff] [blame] | 54 | unsigned int num_crtcs; |
Laurent Pinchart | ef67a90 | 2013-06-17 03:13:11 +0200 | [diff] [blame] | 55 | struct rcar_du_output_routing routes[RCAR_DU_OUTPUT_MAX]; |
Laurent Pinchart | 481d342 | 2013-06-14 13:38:33 +0200 | [diff] [blame] | 56 | }; |
| 57 | |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 58 | struct rcar_du_device { |
| 59 | struct device *dev; |
| 60 | const struct rcar_du_platform_data *pdata; |
Laurent Pinchart | 481d342 | 2013-06-14 13:38:33 +0200 | [diff] [blame] | 61 | const struct rcar_du_device_info *info; |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 62 | |
| 63 | void __iomem *mmio; |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 64 | |
| 65 | struct drm_device *ddev; |
| 66 | |
Laurent Pinchart | a5f0ef5 | 2013-06-17 00:29:25 +0200 | [diff] [blame] | 67 | struct rcar_du_crtc crtcs[3]; |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 68 | unsigned int num_crtcs; |
| 69 | |
Laurent Pinchart | a5f0ef5 | 2013-06-17 00:29:25 +0200 | [diff] [blame] | 70 | struct rcar_du_group groups[2]; |
Laurent Pinchart | 7cbc05c | 2013-06-17 03:20:08 +0200 | [diff] [blame^] | 71 | |
| 72 | unsigned int dpad0_source; |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 73 | }; |
| 74 | |
Laurent Pinchart | 481d342 | 2013-06-14 13:38:33 +0200 | [diff] [blame] | 75 | static inline bool rcar_du_has(struct rcar_du_device *rcdu, |
| 76 | unsigned int feature) |
| 77 | { |
| 78 | return rcdu->info->features & feature; |
| 79 | } |
| 80 | |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 81 | static inline u32 rcar_du_read(struct rcar_du_device *rcdu, u32 reg) |
| 82 | { |
| 83 | return ioread32(rcdu->mmio + reg); |
| 84 | } |
| 85 | |
| 86 | static 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__ */ |