tilcdc_drv.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2012 Texas Instruments
  4. * Author: Rob Clark <robdclark@gmail.com>
  5. */
  6. #ifndef __TILCDC_DRV_H__
  7. #define __TILCDC_DRV_H__
  8. #include <linux/cpufreq.h>
  9. #include <linux/irqreturn.h>
  10. #include <drm/drm_print.h>
  11. struct clk;
  12. struct workqueue_struct;
  13. struct drm_connector;
  14. struct drm_connector_helper_funcs;
  15. struct drm_crtc;
  16. struct drm_device;
  17. struct drm_display_mode;
  18. struct drm_encoder;
  19. struct drm_framebuffer;
  20. struct drm_minor;
  21. struct drm_pending_vblank_event;
  22. struct drm_plane;
  23. /* Defaulting to pixel clock defined on AM335x */
  24. #define TILCDC_DEFAULT_MAX_PIXELCLOCK 126000
  25. /* Maximum display width for LCDC V1 */
  26. #define TILCDC_DEFAULT_MAX_WIDTH_V1 1024
  27. /* ... and for LCDC V2 found on AM335x: */
  28. #define TILCDC_DEFAULT_MAX_WIDTH_V2 2048
  29. /*
  30. * This may need some tweaking, but want to allow at least 1280x1024@60
  31. * with optimized DDR & EMIF settings tweaked 1920x1080@24 appears to
  32. * be supportable
  33. */
  34. #define TILCDC_DEFAULT_MAX_BANDWIDTH (1280*1024*60)
  35. struct tilcdc_drm_private {
  36. void __iomem *mmio;
  37. struct clk *clk; /* functional clock */
  38. int rev; /* IP revision */
  39. unsigned int irq;
  40. /* don't attempt resolutions w/ higher W * H * Hz: */
  41. uint32_t max_bandwidth;
  42. /*
  43. * Pixel Clock will be restricted to some value as
  44. * defined in the device datasheet measured in KHz
  45. */
  46. uint32_t max_pixelclock;
  47. /*
  48. * Max allowable width is limited on a per device basis
  49. * measured in pixels
  50. */
  51. uint32_t max_width;
  52. /* Supported pixel formats */
  53. const uint32_t *pixelformats;
  54. uint32_t num_pixelformats;
  55. #ifdef CONFIG_CPU_FREQ
  56. struct notifier_block freq_transition;
  57. #endif
  58. struct workqueue_struct *wq;
  59. struct drm_crtc *crtc;
  60. unsigned int num_encoders;
  61. struct drm_encoder *encoders[8];
  62. unsigned int num_connectors;
  63. struct drm_connector *connectors[8];
  64. struct drm_encoder *external_encoder;
  65. struct drm_connector *external_connector;
  66. bool is_registered;
  67. bool is_componentized;
  68. bool irq_enabled;
  69. };
  70. /* Sub-module for display. Since we don't know at compile time what panels
  71. * or display adapter(s) might be present (for ex, off chip dvi/tfp410,
  72. * hdmi encoder, various lcd panels), the connector/encoder(s) are split into
  73. * separate drivers. If they are probed and found to be present, they
  74. * register themselves with tilcdc_register_module().
  75. */
  76. struct tilcdc_module;
  77. struct tilcdc_module_ops {
  78. /* create appropriate encoders/connectors: */
  79. int (*modeset_init)(struct tilcdc_module *mod, struct drm_device *dev);
  80. #ifdef CONFIG_DEBUG_FS
  81. /* create debugfs nodes (can be NULL): */
  82. int (*debugfs_init)(struct tilcdc_module *mod, struct drm_minor *minor);
  83. #endif
  84. };
  85. struct tilcdc_module {
  86. const char *name;
  87. struct list_head list;
  88. const struct tilcdc_module_ops *funcs;
  89. };
  90. void tilcdc_module_init(struct tilcdc_module *mod, const char *name,
  91. const struct tilcdc_module_ops *funcs);
  92. void tilcdc_module_cleanup(struct tilcdc_module *mod);
  93. /* Panel config that needs to be set in the crtc, but is not coming from
  94. * the mode timings. The display module is expected to call
  95. * tilcdc_crtc_set_panel_info() to set this during modeset.
  96. */
  97. struct tilcdc_panel_info {
  98. /* AC Bias Pin Frequency */
  99. uint32_t ac_bias;
  100. /* AC Bias Pin Transitions per Interrupt */
  101. uint32_t ac_bias_intrpt;
  102. /* DMA burst size */
  103. uint32_t dma_burst_sz;
  104. /* Bits per pixel */
  105. uint32_t bpp;
  106. /* FIFO DMA Request Delay */
  107. uint32_t fdd;
  108. /* TFT Alternative Signal Mapping (Only for active) */
  109. bool tft_alt_mode;
  110. /* Invert pixel clock */
  111. bool invert_pxl_clk;
  112. /* Horizontal and Vertical Sync Edge: 0=rising 1=falling */
  113. uint32_t sync_edge;
  114. /* Horizontal and Vertical Sync: Control: 0=ignore */
  115. uint32_t sync_ctrl;
  116. /* Raster Data Order Select: 1=Most-to-least 0=Least-to-most */
  117. uint32_t raster_order;
  118. /* DMA FIFO threshold */
  119. uint32_t fifo_th;
  120. };
  121. #define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)
  122. int tilcdc_crtc_create(struct drm_device *dev);
  123. irqreturn_t tilcdc_crtc_irq(struct drm_crtc *crtc);
  124. void tilcdc_crtc_update_clk(struct drm_crtc *crtc);
  125. void tilcdc_crtc_set_panel_info(struct drm_crtc *crtc,
  126. const struct tilcdc_panel_info *info);
  127. void tilcdc_crtc_set_simulate_vesa_sync(struct drm_crtc *crtc,
  128. bool simulate_vesa_sync);
  129. void tilcdc_crtc_shutdown(struct drm_crtc *crtc);
  130. int tilcdc_crtc_update_fb(struct drm_crtc *crtc,
  131. struct drm_framebuffer *fb,
  132. struct drm_pending_vblank_event *event);
  133. int tilcdc_plane_init(struct drm_device *dev, struct drm_plane *plane);
  134. #endif /* __TILCDC_DRV_H__ */