rcar_du_drv.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. * rcar_du_drv.h -- R-Car Display Unit DRM driver
  3. *
  4. * Copyright (C) 2013-2015 Renesas Electronics 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. #ifndef __RCAR_DU_DRV_H__
  14. #define __RCAR_DU_DRV_H__
  15. #include <linux/kernel.h>
  16. #include <linux/wait.h>
  17. #include "rcar_du_crtc.h"
  18. #include "rcar_du_group.h"
  19. #include "rcar_du_vsp.h"
  20. struct clk;
  21. struct device;
  22. struct drm_device;
  23. struct drm_fbdev_cma;
  24. struct rcar_du_device;
  25. struct rcar_du_lvdsenc;
  26. #define RCAR_DU_FEATURE_CRTC_IRQ_CLOCK (1 << 0) /* Per-CRTC IRQ and clock */
  27. #define RCAR_DU_FEATURE_EXT_CTRL_REGS (1 << 1) /* Has extended control registers */
  28. #define RCAR_DU_FEATURE_VSP1_SOURCE (1 << 2) /* Has inputs from VSP1 */
  29. #define RCAR_DU_QUIRK_ALIGN_128B (1 << 0) /* Align pitches to 128 bytes */
  30. #define RCAR_DU_QUIRK_LVDS_LANES (1 << 1) /* LVDS lanes 1 and 3 inverted */
  31. /*
  32. * struct rcar_du_output_routing - Output routing specification
  33. * @possible_crtcs: bitmask of possible CRTCs for the output
  34. * @encoder_type: DRM type of the internal encoder associated with the output
  35. * @port: device tree port number corresponding to this output route
  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. unsigned int port;
  45. };
  46. /*
  47. * struct rcar_du_device_info - DU model-specific information
  48. * @gen: device generation (2 or 3)
  49. * @features: device features (RCAR_DU_FEATURE_*)
  50. * @quirks: device quirks (RCAR_DU_QUIRK_*)
  51. * @num_crtcs: total number of CRTCs
  52. * @routes: array of CRTC to output routes, indexed by output (RCAR_DU_OUTPUT_*)
  53. * @num_lvds: number of internal LVDS encoders
  54. */
  55. struct rcar_du_device_info {
  56. unsigned int gen;
  57. unsigned int features;
  58. unsigned int quirks;
  59. unsigned int num_crtcs;
  60. struct rcar_du_output_routing routes[RCAR_DU_OUTPUT_MAX];
  61. unsigned int num_lvds;
  62. };
  63. #define RCAR_DU_MAX_CRTCS 4
  64. #define RCAR_DU_MAX_GROUPS DIV_ROUND_UP(RCAR_DU_MAX_CRTCS, 2)
  65. #define RCAR_DU_MAX_LVDS 2
  66. #define RCAR_DU_MAX_VSPS 4
  67. struct rcar_du_device {
  68. struct device *dev;
  69. const struct rcar_du_device_info *info;
  70. void __iomem *mmio;
  71. struct drm_device *ddev;
  72. struct drm_fbdev_cma *fbdev;
  73. struct rcar_du_crtc crtcs[RCAR_DU_MAX_CRTCS];
  74. unsigned int num_crtcs;
  75. struct rcar_du_group groups[RCAR_DU_MAX_GROUPS];
  76. struct rcar_du_vsp vsps[RCAR_DU_MAX_VSPS];
  77. struct {
  78. struct drm_property *alpha;
  79. struct drm_property *colorkey;
  80. } props;
  81. unsigned int dpad0_source;
  82. unsigned int vspd1_sink;
  83. struct rcar_du_lvdsenc *lvds[RCAR_DU_MAX_LVDS];
  84. struct {
  85. wait_queue_head_t wait;
  86. u32 pending;
  87. } commit;
  88. };
  89. static inline bool rcar_du_has(struct rcar_du_device *rcdu,
  90. unsigned int feature)
  91. {
  92. return rcdu->info->features & feature;
  93. }
  94. static inline bool rcar_du_needs(struct rcar_du_device *rcdu,
  95. unsigned int quirk)
  96. {
  97. return rcdu->info->quirks & quirk;
  98. }
  99. static inline u32 rcar_du_read(struct rcar_du_device *rcdu, u32 reg)
  100. {
  101. return ioread32(rcdu->mmio + reg);
  102. }
  103. static inline void rcar_du_write(struct rcar_du_device *rcdu, u32 reg, u32 data)
  104. {
  105. iowrite32(data, rcdu->mmio + reg);
  106. }
  107. #endif /* __RCAR_DU_DRV_H__ */