tilcdc_drv.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. /* Defaulting to pixel clock defined on AM335x */
  34. #define TILCDC_DEFAULT_MAX_PIXELCLOCK 126000
  35. /* Defaulting to max width as defined on AM335x */
  36. #define TILCDC_DEFAULT_MAX_WIDTH 2048
  37. /*
  38. * This may need some tweaking, but want to allow at least 1280x1024@60
  39. * with optimized DDR & EMIF settings tweaked 1920x1080@24 appears to
  40. * be supportable
  41. */
  42. #define TILCDC_DEFAULT_MAX_BANDWIDTH (1280*1024*60)
  43. struct tilcdc_drm_private {
  44. void __iomem *mmio;
  45. struct clk *clk; /* functional clock */
  46. int rev; /* IP revision */
  47. /* don't attempt resolutions w/ higher W * H * Hz: */
  48. uint32_t max_bandwidth;
  49. /*
  50. * Pixel Clock will be restricted to some value as
  51. * defined in the device datasheet measured in KHz
  52. */
  53. uint32_t max_pixelclock;
  54. /*
  55. * Max allowable width is limited on a per device basis
  56. * measured in pixels
  57. */
  58. uint32_t max_width;
  59. /* register contents saved across suspend/resume: */
  60. u32 *saved_register;
  61. int saved_dpms_state;
  62. bool ctx_valid;
  63. #ifdef CONFIG_CPU_FREQ
  64. struct notifier_block freq_transition;
  65. unsigned int lcd_fck_rate;
  66. #endif
  67. struct workqueue_struct *wq;
  68. struct drm_fbdev_cma *fbdev;
  69. struct drm_crtc *crtc;
  70. unsigned int num_encoders;
  71. struct drm_encoder *encoders[8];
  72. unsigned int num_connectors;
  73. struct drm_connector *connectors[8];
  74. const struct drm_connector_helper_funcs *connector_funcs[8];
  75. bool is_componentized;
  76. };
  77. /* Sub-module for display. Since we don't know at compile time what panels
  78. * or display adapter(s) might be present (for ex, off chip dvi/tfp410,
  79. * hdmi encoder, various lcd panels), the connector/encoder(s) are split into
  80. * separate drivers. If they are probed and found to be present, they
  81. * register themselves with tilcdc_register_module().
  82. */
  83. struct tilcdc_module;
  84. struct tilcdc_module_ops {
  85. /* create appropriate encoders/connectors: */
  86. int (*modeset_init)(struct tilcdc_module *mod, struct drm_device *dev);
  87. #ifdef CONFIG_DEBUG_FS
  88. /* create debugfs nodes (can be NULL): */
  89. int (*debugfs_init)(struct tilcdc_module *mod, struct drm_minor *minor);
  90. /* cleanup debugfs nodes (can be NULL): */
  91. void (*debugfs_cleanup)(struct tilcdc_module *mod, struct drm_minor *minor);
  92. #endif
  93. };
  94. struct tilcdc_module {
  95. const char *name;
  96. struct list_head list;
  97. const struct tilcdc_module_ops *funcs;
  98. unsigned int preferred_bpp;
  99. };
  100. void tilcdc_module_init(struct tilcdc_module *mod, const char *name,
  101. const struct tilcdc_module_ops *funcs);
  102. void tilcdc_module_cleanup(struct tilcdc_module *mod);
  103. /* Panel config that needs to be set in the crtc, but is not coming from
  104. * the mode timings. The display module is expected to call
  105. * tilcdc_crtc_set_panel_info() to set this during modeset.
  106. */
  107. struct tilcdc_panel_info {
  108. /* AC Bias Pin Frequency */
  109. uint32_t ac_bias;
  110. /* AC Bias Pin Transitions per Interrupt */
  111. uint32_t ac_bias_intrpt;
  112. /* DMA burst size */
  113. uint32_t dma_burst_sz;
  114. /* Bits per pixel */
  115. uint32_t bpp;
  116. /* FIFO DMA Request Delay */
  117. uint32_t fdd;
  118. /* TFT Alternative Signal Mapping (Only for active) */
  119. bool tft_alt_mode;
  120. /* Invert pixel clock */
  121. bool invert_pxl_clk;
  122. /* Horizontal and Vertical Sync Edge: 0=rising 1=falling */
  123. uint32_t sync_edge;
  124. /* Horizontal and Vertical Sync: Control: 0=ignore */
  125. uint32_t sync_ctrl;
  126. /* Raster Data Order Select: 1=Most-to-least 0=Least-to-most */
  127. uint32_t raster_order;
  128. /* DMA FIFO threshold */
  129. uint32_t fifo_th;
  130. };
  131. #define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)
  132. struct drm_crtc *tilcdc_crtc_create(struct drm_device *dev);
  133. irqreturn_t tilcdc_crtc_irq(struct drm_crtc *crtc);
  134. void tilcdc_crtc_update_clk(struct drm_crtc *crtc);
  135. void tilcdc_crtc_set_panel_info(struct drm_crtc *crtc,
  136. const struct tilcdc_panel_info *info);
  137. void tilcdc_crtc_set_simulate_vesa_sync(struct drm_crtc *crtc,
  138. bool simulate_vesa_sync);
  139. int tilcdc_crtc_mode_valid(struct drm_crtc *crtc, struct drm_display_mode *mode);
  140. int tilcdc_crtc_max_width(struct drm_crtc *crtc);
  141. void tilcdc_crtc_dpms(struct drm_crtc *crtc, int mode);
  142. int tilcdc_crtc_current_dpms_state(struct drm_crtc *crtc);
  143. int tilcdc_crtc_page_flip(struct drm_crtc *crtc,
  144. struct drm_framebuffer *fb,
  145. struct drm_pending_vblank_event *event,
  146. uint32_t page_flip_flags);
  147. int tilcdc_plane_init(struct drm_device *dev, struct drm_plane *plane);
  148. #endif /* __TILCDC_DRV_H__ */