tilcdc_drv.h 5.2 KB

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