tilcdc_drv.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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 *disp_clk; /* display dpll */
  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. /* register contents saved across suspend/resume: */
  61. u32 saved_register[12];
  62. #ifdef CONFIG_CPU_FREQ
  63. struct notifier_block freq_transition;
  64. unsigned int lcd_fck_rate;
  65. #endif
  66. struct workqueue_struct *wq;
  67. struct drm_fbdev_cma *fbdev;
  68. struct drm_crtc *crtc;
  69. unsigned int num_encoders;
  70. struct drm_encoder *encoders[8];
  71. unsigned int num_connectors;
  72. struct drm_connector *connectors[8];
  73. const struct drm_connector_helper_funcs *connector_funcs[8];
  74. bool is_componentized;
  75. };
  76. /* Sub-module for display. Since we don't know at compile time what panels
  77. * or display adapter(s) might be present (for ex, off chip dvi/tfp410,
  78. * hdmi encoder, various lcd panels), the connector/encoder(s) are split into
  79. * separate drivers. If they are probed and found to be present, they
  80. * register themselves with tilcdc_register_module().
  81. */
  82. struct tilcdc_module;
  83. struct tilcdc_module_ops {
  84. /* create appropriate encoders/connectors: */
  85. int (*modeset_init)(struct tilcdc_module *mod, struct drm_device *dev);
  86. #ifdef CONFIG_DEBUG_FS
  87. /* create debugfs nodes (can be NULL): */
  88. int (*debugfs_init)(struct tilcdc_module *mod, struct drm_minor *minor);
  89. /* cleanup debugfs nodes (can be NULL): */
  90. void (*debugfs_cleanup)(struct tilcdc_module *mod, struct drm_minor *minor);
  91. #endif
  92. };
  93. struct tilcdc_module {
  94. const char *name;
  95. struct list_head list;
  96. const struct tilcdc_module_ops *funcs;
  97. unsigned int preferred_bpp;
  98. };
  99. void tilcdc_module_init(struct tilcdc_module *mod, const char *name,
  100. const struct tilcdc_module_ops *funcs);
  101. void tilcdc_module_cleanup(struct tilcdc_module *mod);
  102. /* Panel config that needs to be set in the crtc, but is not coming from
  103. * the mode timings. The display module is expected to call
  104. * tilcdc_crtc_set_panel_info() to set this during modeset.
  105. */
  106. struct tilcdc_panel_info {
  107. /* AC Bias Pin Frequency */
  108. uint32_t ac_bias;
  109. /* AC Bias Pin Transitions per Interrupt */
  110. uint32_t ac_bias_intrpt;
  111. /* DMA burst size */
  112. uint32_t dma_burst_sz;
  113. /* Bits per pixel */
  114. uint32_t bpp;
  115. /* FIFO DMA Request Delay */
  116. uint32_t fdd;
  117. /* TFT Alternative Signal Mapping (Only for active) */
  118. bool tft_alt_mode;
  119. /* Invert pixel clock */
  120. bool invert_pxl_clk;
  121. /* Horizontal and Vertical Sync Edge: 0=rising 1=falling */
  122. uint32_t sync_edge;
  123. /* Horizontal and Vertical Sync: Control: 0=ignore */
  124. uint32_t sync_ctrl;
  125. /* Raster Data Order Select: 1=Most-to-least 0=Least-to-most */
  126. uint32_t raster_order;
  127. /* DMA FIFO threshold */
  128. uint32_t fifo_th;
  129. };
  130. #define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)
  131. struct drm_crtc *tilcdc_crtc_create(struct drm_device *dev);
  132. void tilcdc_crtc_cancel_page_flip(struct drm_crtc *crtc, struct drm_file *file);
  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. #endif /* __TILCDC_DRV_H__ */