dsi_phy.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2015, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef __DSI_PHY_H__
  6. #define __DSI_PHY_H__
  7. #include <linux/clk-provider.h>
  8. #include <linux/delay.h>
  9. #include <linux/regulator/consumer.h>
  10. #include "dsi.h"
  11. struct msm_dsi_phy_ops {
  12. int (*pll_init)(struct msm_dsi_phy *phy);
  13. int (*enable)(struct msm_dsi_phy *phy,
  14. struct msm_dsi_phy_clk_request *clk_req);
  15. void (*disable)(struct msm_dsi_phy *phy);
  16. void (*save_pll_state)(struct msm_dsi_phy *phy);
  17. int (*restore_pll_state)(struct msm_dsi_phy *phy);
  18. bool (*set_continuous_clock)(struct msm_dsi_phy *phy, bool enable);
  19. int (*parse_dt_properties)(struct msm_dsi_phy *phy);
  20. };
  21. struct msm_dsi_phy_cfg {
  22. const struct regulator_bulk_data *regulator_data;
  23. int num_regulators;
  24. struct msm_dsi_phy_ops ops;
  25. unsigned long min_pll_rate;
  26. unsigned long max_pll_rate;
  27. const resource_size_t io_start[DSI_MAX];
  28. const int num_dsi_phy;
  29. const int quirks;
  30. bool has_phy_regulator;
  31. bool has_phy_lane;
  32. };
  33. extern const struct msm_dsi_phy_cfg dsi_phy_28nm_hpm_cfgs;
  34. extern const struct msm_dsi_phy_cfg dsi_phy_28nm_hpm_famb_cfgs;
  35. extern const struct msm_dsi_phy_cfg dsi_phy_28nm_lp_cfgs;
  36. extern const struct msm_dsi_phy_cfg dsi_phy_28nm_8226_cfgs;
  37. extern const struct msm_dsi_phy_cfg dsi_phy_28nm_8937_cfgs;
  38. extern const struct msm_dsi_phy_cfg dsi_phy_28nm_8960_cfgs;
  39. extern const struct msm_dsi_phy_cfg dsi_phy_20nm_cfgs;
  40. extern const struct msm_dsi_phy_cfg dsi_phy_14nm_cfgs;
  41. extern const struct msm_dsi_phy_cfg dsi_phy_14nm_660_cfgs;
  42. extern const struct msm_dsi_phy_cfg dsi_phy_14nm_2290_cfgs;
  43. extern const struct msm_dsi_phy_cfg dsi_phy_14nm_8953_cfgs;
  44. extern const struct msm_dsi_phy_cfg dsi_phy_10nm_cfgs;
  45. extern const struct msm_dsi_phy_cfg dsi_phy_10nm_8998_cfgs;
  46. extern const struct msm_dsi_phy_cfg dsi_phy_7nm_cfgs;
  47. extern const struct msm_dsi_phy_cfg dsi_phy_7nm_6375_cfgs;
  48. extern const struct msm_dsi_phy_cfg dsi_phy_7nm_8150_cfgs;
  49. extern const struct msm_dsi_phy_cfg dsi_phy_7nm_7280_cfgs;
  50. extern const struct msm_dsi_phy_cfg dsi_phy_5nm_8350_cfgs;
  51. extern const struct msm_dsi_phy_cfg dsi_phy_5nm_8450_cfgs;
  52. extern const struct msm_dsi_phy_cfg dsi_phy_4nm_8550_cfgs;
  53. extern const struct msm_dsi_phy_cfg dsi_phy_4nm_8650_cfgs;
  54. struct msm_dsi_dphy_timing {
  55. u32 clk_zero;
  56. u32 clk_trail;
  57. u32 clk_prepare;
  58. u32 hs_exit;
  59. u32 hs_zero;
  60. u32 hs_prepare;
  61. u32 hs_trail;
  62. u32 hs_rqst;
  63. u32 ta_go;
  64. u32 ta_sure;
  65. u32 ta_get;
  66. struct msm_dsi_phy_shared_timings shared_timings;
  67. /* For PHY v2 only */
  68. u32 hs_rqst_ckln;
  69. u32 hs_prep_dly;
  70. u32 hs_prep_dly_ckln;
  71. u8 hs_halfbyte_en;
  72. u8 hs_halfbyte_en_ckln;
  73. };
  74. #define DSI_BYTE_PLL_CLK 0
  75. #define DSI_PIXEL_PLL_CLK 1
  76. #define NUM_PROVIDED_CLKS 2
  77. #define DSI_LANE_MAX 5
  78. struct msm_dsi_phy {
  79. struct platform_device *pdev;
  80. void __iomem *base;
  81. void __iomem *pll_base;
  82. void __iomem *reg_base;
  83. void __iomem *lane_base;
  84. phys_addr_t base_size;
  85. phys_addr_t pll_size;
  86. phys_addr_t reg_size;
  87. phys_addr_t lane_size;
  88. int id;
  89. struct clk *ahb_clk;
  90. struct regulator_bulk_data *supplies;
  91. struct msm_dsi_dphy_timing timing;
  92. const struct msm_dsi_phy_cfg *cfg;
  93. void *tuning_cfg;
  94. enum msm_dsi_phy_usecase usecase;
  95. bool regulator_ldo_mode;
  96. bool cphy_mode;
  97. struct clk_hw *vco_hw;
  98. bool pll_on;
  99. struct clk_hw_onecell_data *provided_clocks;
  100. bool state_saved;
  101. };
  102. /*
  103. * PHY internal functions
  104. */
  105. int msm_dsi_dphy_timing_calc(struct msm_dsi_dphy_timing *timing,
  106. struct msm_dsi_phy_clk_request *clk_req);
  107. int msm_dsi_dphy_timing_calc_v2(struct msm_dsi_dphy_timing *timing,
  108. struct msm_dsi_phy_clk_request *clk_req);
  109. int msm_dsi_dphy_timing_calc_v3(struct msm_dsi_dphy_timing *timing,
  110. struct msm_dsi_phy_clk_request *clk_req);
  111. int msm_dsi_dphy_timing_calc_v4(struct msm_dsi_dphy_timing *timing,
  112. struct msm_dsi_phy_clk_request *clk_req);
  113. int msm_dsi_cphy_timing_calc_v4(struct msm_dsi_dphy_timing *timing,
  114. struct msm_dsi_phy_clk_request *clk_req);
  115. #endif /* __DSI_PHY_H__ */