samsung-dsim.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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_IMX8MM,
  27. DSIM_TYPE_IMX8MP,
  28. DSIM_TYPE_COUNT,
  29. };
  30. #define samsung_dsim_hw_is_exynos(hw) \
  31. ((hw) >= DSIM_TYPE_EXYNOS3250 && (hw) <= DSIM_TYPE_EXYNOS5433)
  32. struct samsung_dsim_transfer {
  33. struct list_head list;
  34. struct completion completed;
  35. int result;
  36. struct mipi_dsi_packet packet;
  37. u16 flags;
  38. u16 tx_done;
  39. u8 *rx_payload;
  40. u16 rx_len;
  41. u16 rx_done;
  42. };
  43. struct samsung_dsim_driver_data {
  44. const unsigned int *reg_ofs;
  45. unsigned int plltmr_reg;
  46. unsigned int has_freqband:1;
  47. unsigned int has_clklane_stop:1;
  48. unsigned int has_broken_fifoctrl_emptyhdr:1;
  49. unsigned int num_clks;
  50. unsigned int min_freq;
  51. unsigned int max_freq;
  52. unsigned int wait_for_reset;
  53. unsigned int num_bits_resol;
  54. unsigned int pll_p_offset;
  55. const unsigned int *reg_values;
  56. unsigned int pll_fin_min;
  57. unsigned int pll_fin_max;
  58. u16 m_min;
  59. u16 m_max;
  60. };
  61. struct samsung_dsim_host_ops {
  62. int (*register_host)(struct samsung_dsim *dsim);
  63. void (*unregister_host)(struct samsung_dsim *dsim);
  64. int (*attach)(struct samsung_dsim *dsim, struct mipi_dsi_device *device);
  65. void (*detach)(struct samsung_dsim *dsim, struct mipi_dsi_device *device);
  66. irqreturn_t (*te_irq_handler)(struct samsung_dsim *dsim);
  67. };
  68. struct samsung_dsim_plat_data {
  69. enum samsung_dsim_type hw_type;
  70. const struct samsung_dsim_host_ops *host_ops;
  71. };
  72. struct samsung_dsim {
  73. struct mipi_dsi_host dsi_host;
  74. struct drm_bridge bridge;
  75. struct drm_bridge *out_bridge;
  76. struct device *dev;
  77. struct drm_display_mode mode;
  78. void __iomem *reg_base;
  79. struct phy *phy;
  80. struct clk **clks;
  81. struct clk *pll_clk;
  82. struct regulator_bulk_data supplies[2];
  83. int irq;
  84. struct gpio_desc *te_gpio;
  85. u32 pll_clk_rate;
  86. u32 burst_clk_rate;
  87. u32 hs_clock;
  88. u32 esc_clk_rate;
  89. u32 lanes;
  90. u32 mode_flags;
  91. u32 format;
  92. bool swap_dn_dp_clk;
  93. bool swap_dn_dp_data;
  94. int state;
  95. struct drm_property *brightness;
  96. struct completion completed;
  97. spinlock_t transfer_lock; /* protects transfer_list */
  98. struct list_head transfer_list;
  99. const struct samsung_dsim_driver_data *driver_data;
  100. const struct samsung_dsim_plat_data *plat_data;
  101. void *priv;
  102. };
  103. extern int samsung_dsim_probe(struct platform_device *pdev);
  104. extern void samsung_dsim_remove(struct platform_device *pdev);
  105. extern const struct dev_pm_ops samsung_dsim_pm_ops;
  106. #endif /* __SAMSUNG_DSIM__ */