rcar_du_drv.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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_ALIGN_128B (1 << 1) /* Align pitches to 128 bytes */
  27. #define RCAR_DU_FEATURE_DEFR8 (1 << 2) /* Has DEFR8 register */
  28. /*
  29. * struct rcar_du_output_routing - Output routing specification
  30. * @possible_crtcs: bitmask of possible CRTCs for the output
  31. * @encoder_type: DRM type of the internal encoder associated with the output
  32. *
  33. * The DU has 5 possible outputs (DPAD0/1, LVDS0/1, TCON). Output routing data
  34. * specify the valid SoC outputs, which CRTCs can drive the output, and the type
  35. * of in-SoC encoder for the output.
  36. */
  37. struct rcar_du_output_routing {
  38. unsigned int possible_crtcs;
  39. unsigned int encoder_type;
  40. };
  41. /*
  42. * struct rcar_du_device_info - DU model-specific information
  43. * @features: device features (RCAR_DU_FEATURE_*)
  44. * @num_crtcs: total number of CRTCs
  45. * @routes: array of CRTC to output routes, indexed by output (RCAR_DU_OUTPUT_*)
  46. * @num_lvds: number of internal LVDS encoders
  47. */
  48. struct rcar_du_device_info {
  49. unsigned int features;
  50. unsigned int num_crtcs;
  51. struct rcar_du_output_routing routes[RCAR_DU_OUTPUT_MAX];
  52. unsigned int num_lvds;
  53. };
  54. struct rcar_du_device {
  55. struct device *dev;
  56. const struct rcar_du_platform_data *pdata;
  57. const struct rcar_du_device_info *info;
  58. void __iomem *mmio;
  59. struct drm_device *ddev;
  60. struct drm_fbdev_cma *fbdev;
  61. struct rcar_du_crtc crtcs[3];
  62. unsigned int num_crtcs;
  63. struct rcar_du_group groups[2];
  64. unsigned int dpad0_source;
  65. struct rcar_du_lvdsenc *lvds[2];
  66. };
  67. static inline bool rcar_du_has(struct rcar_du_device *rcdu,
  68. unsigned int feature)
  69. {
  70. return rcdu->info->features & feature;
  71. }
  72. static inline u32 rcar_du_read(struct rcar_du_device *rcdu, u32 reg)
  73. {
  74. return ioread32(rcdu->mmio + reg);
  75. }
  76. static inline void rcar_du_write(struct rcar_du_device *rcdu, u32 reg, u32 data)
  77. {
  78. iowrite32(data, rcdu->mmio + reg);
  79. }
  80. #endif /* __RCAR_DU_DRV_H__ */