rcar_du_drv.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. #ifndef __RCAR_DU_DRV_H__
  10. #define __RCAR_DU_DRV_H__
  11. #include <linux/kernel.h>
  12. #include <linux/wait.h>
  13. #include "rcar_du_crtc.h"
  14. #include "rcar_du_group.h"
  15. #include "rcar_du_vsp.h"
  16. struct clk;
  17. struct device;
  18. struct drm_device;
  19. struct drm_fbdev_cma;
  20. struct rcar_du_device;
  21. #define RCAR_DU_FEATURE_CRTC_IRQ_CLOCK BIT(0) /* Per-CRTC IRQ and clock */
  22. #define RCAR_DU_FEATURE_EXT_CTRL_REGS BIT(1) /* Has extended control registers */
  23. #define RCAR_DU_FEATURE_VSP1_SOURCE BIT(2) /* Has inputs from VSP1 */
  24. #define RCAR_DU_FEATURE_INTERLACED BIT(3) /* HW supports interlaced */
  25. #define RCAR_DU_FEATURE_TVM_SYNC BIT(4) /* Has TV switch/sync modes */
  26. #define RCAR_DU_QUIRK_ALIGN_128B BIT(0) /* Align pitches to 128 bytes */
  27. /*
  28. * struct rcar_du_output_routing - Output routing specification
  29. * @possible_crtcs: bitmask of possible CRTCs for the output
  30. * @port: device tree port number corresponding to this output route
  31. *
  32. * The DU has 5 possible outputs (DPAD0/1, LVDS0/1, TCON). Output routing data
  33. * specify the valid SoC outputs, which CRTCs can drive the output, and the type
  34. * of in-SoC encoder for the output.
  35. */
  36. struct rcar_du_output_routing {
  37. unsigned int possible_crtcs;
  38. unsigned int port;
  39. };
  40. /*
  41. * struct rcar_du_device_info - DU model-specific information
  42. * @gen: device generation (2 or 3)
  43. * @features: device features (RCAR_DU_FEATURE_*)
  44. * @quirks: device quirks (RCAR_DU_QUIRK_*)
  45. * @channels_mask: bit mask of available DU channels
  46. * @routes: array of CRTC to output routes, indexed by output (RCAR_DU_OUTPUT_*)
  47. * @num_lvds: number of internal LVDS encoders
  48. * @dpll_mask: bit mask of DU channels equipped with a DPLL
  49. * @lvds_clk_mask: bitmask of channels that can use the LVDS clock as dot clock
  50. */
  51. struct rcar_du_device_info {
  52. unsigned int gen;
  53. unsigned int features;
  54. unsigned int quirks;
  55. unsigned int channels_mask;
  56. struct rcar_du_output_routing routes[RCAR_DU_OUTPUT_MAX];
  57. unsigned int num_lvds;
  58. unsigned int dpll_mask;
  59. unsigned int lvds_clk_mask;
  60. };
  61. #define RCAR_DU_MAX_CRTCS 4
  62. #define RCAR_DU_MAX_GROUPS DIV_ROUND_UP(RCAR_DU_MAX_CRTCS, 2)
  63. #define RCAR_DU_MAX_VSPS 4
  64. struct rcar_du_device {
  65. struct device *dev;
  66. const struct rcar_du_device_info *info;
  67. void __iomem *mmio;
  68. struct drm_device *ddev;
  69. struct drm_fbdev_cma *fbdev;
  70. struct drm_atomic_state *suspend_state;
  71. struct rcar_du_crtc crtcs[RCAR_DU_MAX_CRTCS];
  72. unsigned int num_crtcs;
  73. struct rcar_du_group groups[RCAR_DU_MAX_GROUPS];
  74. struct rcar_du_vsp vsps[RCAR_DU_MAX_VSPS];
  75. struct {
  76. struct drm_property *colorkey;
  77. } props;
  78. unsigned int dpad0_source;
  79. unsigned int vspd1_sink;
  80. };
  81. static inline bool rcar_du_has(struct rcar_du_device *rcdu,
  82. unsigned int feature)
  83. {
  84. return rcdu->info->features & feature;
  85. }
  86. static inline bool rcar_du_needs(struct rcar_du_device *rcdu,
  87. unsigned int quirk)
  88. {
  89. return rcdu->info->quirks & quirk;
  90. }
  91. static inline u32 rcar_du_read(struct rcar_du_device *rcdu, u32 reg)
  92. {
  93. return ioread32(rcdu->mmio + reg);
  94. }
  95. static inline void rcar_du_write(struct rcar_du_device *rcdu, u32 reg, u32 data)
  96. {
  97. iowrite32(data, rcdu->mmio + reg);
  98. }
  99. #endif /* __RCAR_DU_DRV_H__ */