rcar_du_drv.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. #ifndef __RCAR_DU_DRV_H__
  14. #define __RCAR_DU_DRV_H__
  15. #include <linux/kernel.h>
  16. #include <linux/platform_data/rcar-du.h>
  17. #include "rcar_du_crtc.h"
  18. #include "rcar_du_group.h"
  19. struct clk;
  20. struct device;
  21. struct drm_device;
  22. struct drm_fbdev_cma;
  23. struct rcar_du_device;
  24. struct rcar_du_lvdsenc;
  25. #define RCAR_DU_FEATURE_CRTC_IRQ_CLOCK (1 << 0) /* Per-CRTC IRQ and clock */
  26. #define RCAR_DU_FEATURE_DEFR8 (1 << 1) /* Has DEFR8 register */
  27. #define RCAR_DU_QUIRK_ALIGN_128B (1 << 0) /* Align pitches to 128 bytes */
  28. #define RCAR_DU_QUIRK_LVDS_LANES (1 << 1) /* LVDS lanes 1 and 3 inverted */
  29. /*
  30. * struct rcar_du_output_routing - Output routing specification
  31. * @possible_crtcs: bitmask of possible CRTCs for the output
  32. * @encoder_type: DRM type of the internal encoder associated with the output
  33. *
  34. * The DU has 5 possible outputs (DPAD0/1, LVDS0/1, TCON). Output routing data
  35. * specify the valid SoC outputs, which CRTCs can drive the output, and the type
  36. * of in-SoC encoder for the output.
  37. */
  38. struct rcar_du_output_routing {
  39. unsigned int possible_crtcs;
  40. unsigned int encoder_type;
  41. };
  42. /*
  43. * struct rcar_du_device_info - DU model-specific information
  44. * @features: device features (RCAR_DU_FEATURE_*)
  45. * @quirks: device quirks (RCAR_DU_QUIRK_*)
  46. * @num_crtcs: total number of CRTCs
  47. * @routes: array of CRTC to output routes, indexed by output (RCAR_DU_OUTPUT_*)
  48. * @num_lvds: number of internal LVDS encoders
  49. */
  50. struct rcar_du_device_info {
  51. unsigned int features;
  52. unsigned int quirks;
  53. unsigned int num_crtcs;
  54. struct rcar_du_output_routing routes[RCAR_DU_OUTPUT_MAX];
  55. unsigned int num_lvds;
  56. };
  57. struct rcar_du_device {
  58. struct device *dev;
  59. const struct rcar_du_platform_data *pdata;
  60. const struct rcar_du_device_info *info;
  61. void __iomem *mmio;
  62. struct drm_device *ddev;
  63. struct drm_fbdev_cma *fbdev;
  64. struct rcar_du_crtc crtcs[3];
  65. unsigned int num_crtcs;
  66. struct rcar_du_group groups[2];
  67. unsigned int dpad0_source;
  68. struct rcar_du_lvdsenc *lvds[2];
  69. };
  70. static inline bool rcar_du_has(struct rcar_du_device *rcdu,
  71. unsigned int feature)
  72. {
  73. return rcdu->info->features & feature;
  74. }
  75. static inline bool rcar_du_needs(struct rcar_du_device *rcdu,
  76. unsigned int quirk)
  77. {
  78. return rcdu->info->quirks & quirk;
  79. }
  80. static inline u32 rcar_du_read(struct rcar_du_device *rcdu, u32 reg)
  81. {
  82. return ioread32(rcdu->mmio + reg);
  83. }
  84. static inline void rcar_du_write(struct rcar_du_device *rcdu, u32 reg, u32 data)
  85. {
  86. iowrite32(data, rcdu->mmio + reg);
  87. }
  88. #endif /* __RCAR_DU_DRV_H__ */