kmb_drv.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /* SPDX-License-Identifier: GPL-2.0-only
  2. *
  3. * Copyright © 2018-2020 Intel Corporation
  4. */
  5. #ifndef __KMB_DRV_H__
  6. #define __KMB_DRV_H__
  7. #include <drm/drm_device.h>
  8. #include "kmb_plane.h"
  9. #include "kmb_regs.h"
  10. #define KMB_MAX_WIDTH 1920 /*Max width in pixels */
  11. #define KMB_MAX_HEIGHT 1080 /*Max height in pixels */
  12. #define KMB_MIN_WIDTH 1920 /*Max width in pixels */
  13. #define KMB_MIN_HEIGHT 1080 /*Max height in pixels */
  14. #define DRIVER_DATE "20210223"
  15. #define DRIVER_MAJOR 1
  16. #define DRIVER_MINOR 1
  17. /* Platform definitions */
  18. #define KMB_CRTC_MIN_VFP 4
  19. #define KMB_CRTC_MAX_WIDTH 1920 /* max width in pixels */
  20. #define KMB_CRTC_MAX_HEIGHT 1080 /* max height in pixels */
  21. #define KMB_CRTC_MIN_WIDTH 1920
  22. #define KMB_CRTC_MIN_HEIGHT 1080
  23. #define KMB_FB_MAX_WIDTH 1920
  24. #define KMB_FB_MAX_HEIGHT 1080
  25. #define KMB_FB_MIN_WIDTH 1
  26. #define KMB_FB_MIN_HEIGHT 1
  27. #define KMB_MIN_VREFRESH 59 /*vertical refresh in Hz */
  28. #define KMB_MAX_VREFRESH 60 /*vertical refresh in Hz */
  29. #define KMB_LCD_DEFAULT_CLK 200000000
  30. #define KMB_SYS_CLK_MHZ 500
  31. #define ICAM_MMIO 0x3b100000
  32. #define ICAM_LCD_OFFSET 0x1080
  33. #define ICAM_MMIO_SIZE 0x2000
  34. struct kmb_dsi;
  35. struct kmb_clock {
  36. struct clk *clk_lcd;
  37. struct clk *clk_pll0;
  38. };
  39. struct kmb_drm_private {
  40. struct drm_device drm;
  41. struct kmb_dsi *kmb_dsi;
  42. void __iomem *lcd_mmio;
  43. struct kmb_clock kmb_clk;
  44. struct drm_crtc crtc;
  45. struct kmb_plane *plane;
  46. struct drm_atomic_state *state;
  47. spinlock_t irq_lock;
  48. int irq_lcd;
  49. int sys_clk_mhz;
  50. struct disp_cfg init_disp_cfg[KMB_MAX_PLANES];
  51. struct layer_status plane_status[KMB_MAX_PLANES];
  52. int kmb_under_flow;
  53. int kmb_flush_done;
  54. int layer_no;
  55. };
  56. static inline struct kmb_drm_private *to_kmb(const struct drm_device *dev)
  57. {
  58. return container_of(dev, struct kmb_drm_private, drm);
  59. }
  60. static inline struct kmb_drm_private *crtc_to_kmb_priv(const struct drm_crtc *x)
  61. {
  62. return container_of(x, struct kmb_drm_private, crtc);
  63. }
  64. static inline void kmb_write_lcd(struct kmb_drm_private *dev_p,
  65. unsigned int reg, u32 value)
  66. {
  67. writel(value, (dev_p->lcd_mmio + reg));
  68. }
  69. static inline u32 kmb_read_lcd(struct kmb_drm_private *dev_p, unsigned int reg)
  70. {
  71. return readl(dev_p->lcd_mmio + reg);
  72. }
  73. static inline void kmb_set_bitmask_lcd(struct kmb_drm_private *dev_p,
  74. unsigned int reg, u32 mask)
  75. {
  76. u32 reg_val = kmb_read_lcd(dev_p, reg);
  77. kmb_write_lcd(dev_p, reg, (reg_val | mask));
  78. }
  79. static inline void kmb_clr_bitmask_lcd(struct kmb_drm_private *dev_p,
  80. unsigned int reg, u32 mask)
  81. {
  82. u32 reg_val = kmb_read_lcd(dev_p, reg);
  83. kmb_write_lcd(dev_p, reg, (reg_val & (~mask)));
  84. }
  85. int kmb_setup_crtc(struct drm_device *dev);
  86. void kmb_set_scanout(struct kmb_drm_private *lcd);
  87. #endif /* __KMB_DRV_H__ */