samsung-dsim.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright (C) 2022 Amarula Solutions(India)
  4. * Author: Jagan Teki <jagan@amarulasolutions.com>
  5. */
  6. #ifndef __SAMSUNG_DSIM__
  7. #define __SAMSUNG_DSIM__
  8. #include <linux/gpio/consumer.h>
  9. #include <linux/regulator/consumer.h>
  10. #include <drm/drm_atomic_helper.h>
  11. #include <drm/drm_bridge.h>
  12. #include <drm/drm_mipi_dsi.h>
  13. #include <drm/drm_of.h>
  14. struct platform_device;
  15. struct samsung_dsim;
  16. #define DSIM_STATE_ENABLED BIT(0)
  17. #define DSIM_STATE_INITIALIZED BIT(1)
  18. #define DSIM_STATE_CMD_LPM BIT(2)
  19. #define DSIM_STATE_VIDOUT_AVAILABLE BIT(3)
  20. enum samsung_dsim_type {
  21. DSIM_TYPE_EXYNOS3250,
  22. DSIM_TYPE_EXYNOS4210,
  23. DSIM_TYPE_EXYNOS5410,
  24. DSIM_TYPE_EXYNOS5422,
  25. DSIM_TYPE_EXYNOS5433,
  26. DSIM_TYPE_EXYNOS7870,
  27. DSIM_TYPE_IMX8MM,
  28. DSIM_TYPE_IMX8MP,
  29. DSIM_TYPE_COUNT,
  30. };
  31. #define samsung_dsim_hw_is_exynos(hw) \
  32. ((hw) >= DSIM_TYPE_EXYNOS3250 && (hw) <= DSIM_TYPE_EXYNOS5433)
  33. struct samsung_dsim_transfer {
  34. struct list_head list;
  35. struct completion completed;
  36. int result;
  37. struct mipi_dsi_packet packet;
  38. u16 flags;
  39. u16 tx_done;
  40. u8 *rx_payload;
  41. u16 rx_len;
  42. u16 rx_done;
  43. };
  44. struct samsung_dsim_driver_data {
  45. const unsigned int *reg_ofs;
  46. unsigned int plltmr_reg;
  47. unsigned int has_legacy_status_reg:1;
  48. unsigned int has_freqband:1;
  49. unsigned int has_clklane_stop:1;
  50. unsigned int has_broken_fifoctrl_emptyhdr:1;
  51. unsigned int has_sfrctrl:1;
  52. struct clk_bulk_data *clk_data;
  53. unsigned int num_clks;
  54. unsigned int min_freq;
  55. unsigned int max_freq;
  56. unsigned int wait_for_hdr_fifo;
  57. unsigned int wait_for_reset;
  58. unsigned int num_bits_resol;
  59. unsigned int video_mode_bit;
  60. unsigned int pll_stable_bit;
  61. unsigned int esc_clken_bit;
  62. unsigned int byte_clken_bit;
  63. unsigned int tx_req_hsclk_bit;
  64. unsigned int lane_esc_clk_bit;
  65. unsigned int lane_esc_data_offset;
  66. unsigned int pll_p_offset;
  67. unsigned int pll_m_offset;
  68. unsigned int pll_s_offset;
  69. unsigned int main_vsa_offset;
  70. const unsigned int *reg_values;
  71. unsigned int pll_fin_min;
  72. unsigned int pll_fin_max;
  73. u16 m_min;
  74. u16 m_max;
  75. };
  76. struct samsung_dsim_host_ops {
  77. int (*register_host)(struct samsung_dsim *dsim);
  78. void (*unregister_host)(struct samsung_dsim *dsim);
  79. int (*attach)(struct samsung_dsim *dsim, struct mipi_dsi_device *device);
  80. void (*detach)(struct samsung_dsim *dsim, struct mipi_dsi_device *device);
  81. irqreturn_t (*te_irq_handler)(struct samsung_dsim *dsim);
  82. };
  83. struct samsung_dsim_plat_data {
  84. enum samsung_dsim_type hw_type;
  85. const struct samsung_dsim_host_ops *host_ops;
  86. };
  87. struct samsung_dsim {
  88. struct mipi_dsi_host dsi_host;
  89. struct drm_bridge bridge;
  90. struct device *dev;
  91. struct drm_display_mode mode;
  92. void __iomem *reg_base;
  93. struct phy *phy;
  94. struct clk *pll_clk;
  95. struct regulator_bulk_data supplies[2];
  96. int irq;
  97. struct gpio_desc *te_gpio;
  98. u32 pll_clk_rate;
  99. u32 burst_clk_rate;
  100. u32 hs_clock;
  101. u32 esc_clk_rate;
  102. u32 lanes;
  103. u32 mode_flags;
  104. u32 format;
  105. bool swap_dn_dp_clk;
  106. bool swap_dn_dp_data;
  107. int state;
  108. struct drm_property *brightness;
  109. struct completion completed;
  110. spinlock_t transfer_lock; /* protects transfer_list */
  111. struct list_head transfer_list;
  112. const struct samsung_dsim_driver_data *driver_data;
  113. const struct samsung_dsim_plat_data *plat_data;
  114. void *priv;
  115. };
  116. extern int samsung_dsim_probe(struct platform_device *pdev);
  117. extern void samsung_dsim_remove(struct platform_device *pdev);
  118. extern const struct dev_pm_ops samsung_dsim_pm_ops;
  119. #endif /* __SAMSUNG_DSIM__ */