dsi_phy.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * Copyright (c) 2015, The Linux Foundation. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 and
  6. * only version 2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #ifndef __DSI_PHY_H__
  14. #define __DSI_PHY_H__
  15. #include <linux/regulator/consumer.h>
  16. #include "dsi.h"
  17. #define dsi_phy_read(offset) msm_readl((offset))
  18. #define dsi_phy_write(offset, data) msm_writel((data), (offset))
  19. struct msm_dsi_phy_ops {
  20. int (*init) (struct msm_dsi_phy *phy);
  21. int (*enable)(struct msm_dsi_phy *phy, int src_pll_id,
  22. struct msm_dsi_phy_clk_request *clk_req);
  23. void (*disable)(struct msm_dsi_phy *phy);
  24. };
  25. struct msm_dsi_phy_cfg {
  26. enum msm_dsi_phy_type type;
  27. struct dsi_reg_config reg_cfg;
  28. struct msm_dsi_phy_ops ops;
  29. /*
  30. * Each cell {phy_id, pll_id} of the truth table indicates
  31. * if the source PLL selection bit should be set for each PHY.
  32. * Fill default H/W values in illegal cells, eg. cell {0, 1}.
  33. */
  34. bool src_pll_truthtable[DSI_MAX][DSI_MAX];
  35. const resource_size_t io_start[DSI_MAX];
  36. const int num_dsi_phy;
  37. };
  38. extern const struct msm_dsi_phy_cfg dsi_phy_28nm_hpm_cfgs;
  39. extern const struct msm_dsi_phy_cfg dsi_phy_28nm_lp_cfgs;
  40. extern const struct msm_dsi_phy_cfg dsi_phy_20nm_cfgs;
  41. extern const struct msm_dsi_phy_cfg dsi_phy_28nm_8960_cfgs;
  42. extern const struct msm_dsi_phy_cfg dsi_phy_14nm_cfgs;
  43. extern const struct msm_dsi_phy_cfg dsi_phy_10nm_cfgs;
  44. struct msm_dsi_dphy_timing {
  45. u32 clk_pre;
  46. u32 clk_post;
  47. u32 clk_zero;
  48. u32 clk_trail;
  49. u32 clk_prepare;
  50. u32 hs_exit;
  51. u32 hs_zero;
  52. u32 hs_prepare;
  53. u32 hs_trail;
  54. u32 hs_rqst;
  55. u32 ta_go;
  56. u32 ta_sure;
  57. u32 ta_get;
  58. struct msm_dsi_phy_shared_timings shared_timings;
  59. /* For PHY v2 only */
  60. u32 hs_rqst_ckln;
  61. u32 hs_prep_dly;
  62. u32 hs_prep_dly_ckln;
  63. u8 hs_halfbyte_en;
  64. u8 hs_halfbyte_en_ckln;
  65. };
  66. struct msm_dsi_phy {
  67. struct platform_device *pdev;
  68. void __iomem *base;
  69. void __iomem *reg_base;
  70. void __iomem *lane_base;
  71. int id;
  72. struct clk *ahb_clk;
  73. struct regulator_bulk_data supplies[DSI_DEV_REGULATOR_MAX];
  74. struct msm_dsi_dphy_timing timing;
  75. const struct msm_dsi_phy_cfg *cfg;
  76. enum msm_dsi_phy_usecase usecase;
  77. bool regulator_ldo_mode;
  78. struct msm_dsi_pll *pll;
  79. };
  80. /*
  81. * PHY internal functions
  82. */
  83. int msm_dsi_dphy_timing_calc(struct msm_dsi_dphy_timing *timing,
  84. struct msm_dsi_phy_clk_request *clk_req);
  85. int msm_dsi_dphy_timing_calc_v2(struct msm_dsi_dphy_timing *timing,
  86. struct msm_dsi_phy_clk_request *clk_req);
  87. int msm_dsi_dphy_timing_calc_v3(struct msm_dsi_dphy_timing *timing,
  88. struct msm_dsi_phy_clk_request *clk_req);
  89. void msm_dsi_phy_set_src_pll(struct msm_dsi_phy *phy, int pll_id, u32 reg,
  90. u32 bit_mask);
  91. int msm_dsi_phy_init_common(struct msm_dsi_phy *phy);
  92. #endif /* __DSI_PHY_H__ */