dsi_pll.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. * Copyright (c) 2012-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_PLL_H__
  14. #define __DSI_PLL_H__
  15. #include <linux/clk.h>
  16. #include <linux/clk-provider.h>
  17. #include "dsi.h"
  18. #define NUM_DSI_CLOCKS_MAX 6
  19. #define MAX_DSI_PLL_EN_SEQS 10
  20. struct msm_dsi_pll {
  21. enum msm_dsi_phy_type type;
  22. struct clk_hw clk_hw;
  23. bool pll_on;
  24. bool state_saved;
  25. unsigned long min_rate;
  26. unsigned long max_rate;
  27. u32 en_seq_cnt;
  28. int (*enable_seqs[MAX_DSI_PLL_EN_SEQS])(struct msm_dsi_pll *pll);
  29. void (*disable_seq)(struct msm_dsi_pll *pll);
  30. int (*get_provider)(struct msm_dsi_pll *pll,
  31. struct clk **byte_clk_provider,
  32. struct clk **pixel_clk_provider);
  33. void (*destroy)(struct msm_dsi_pll *pll);
  34. void (*save_state)(struct msm_dsi_pll *pll);
  35. int (*restore_state)(struct msm_dsi_pll *pll);
  36. int (*set_usecase)(struct msm_dsi_pll *pll,
  37. enum msm_dsi_phy_usecase uc);
  38. };
  39. #define hw_clk_to_pll(x) container_of(x, struct msm_dsi_pll, clk_hw)
  40. static inline void pll_write(void __iomem *reg, u32 data)
  41. {
  42. msm_writel(data, reg);
  43. }
  44. static inline u32 pll_read(const void __iomem *reg)
  45. {
  46. return msm_readl(reg);
  47. }
  48. static inline void pll_write_udelay(void __iomem *reg, u32 data, u32 delay_us)
  49. {
  50. pll_write(reg, data);
  51. udelay(delay_us);
  52. }
  53. static inline void pll_write_ndelay(void __iomem *reg, u32 data, u32 delay_ns)
  54. {
  55. pll_write((reg), data);
  56. ndelay(delay_ns);
  57. }
  58. /*
  59. * DSI PLL Helper functions
  60. */
  61. /* clock callbacks */
  62. long msm_dsi_pll_helper_clk_round_rate(struct clk_hw *hw,
  63. unsigned long rate, unsigned long *parent_rate);
  64. int msm_dsi_pll_helper_clk_prepare(struct clk_hw *hw);
  65. void msm_dsi_pll_helper_clk_unprepare(struct clk_hw *hw);
  66. /* misc */
  67. void msm_dsi_pll_helper_unregister_clks(struct platform_device *pdev,
  68. struct clk **clks, u32 num_clks);
  69. /*
  70. * Initialization for Each PLL Type
  71. */
  72. #ifdef CONFIG_DRM_MSM_DSI_28NM_PHY
  73. struct msm_dsi_pll *msm_dsi_pll_28nm_init(struct platform_device *pdev,
  74. enum msm_dsi_phy_type type, int id);
  75. #else
  76. static inline struct msm_dsi_pll *msm_dsi_pll_28nm_init(
  77. struct platform_device *pdev, enum msm_dsi_phy_type type, int id)
  78. {
  79. return ERR_PTR(-ENODEV);
  80. }
  81. #endif
  82. #ifdef CONFIG_DRM_MSM_DSI_28NM_8960_PHY
  83. struct msm_dsi_pll *msm_dsi_pll_28nm_8960_init(struct platform_device *pdev,
  84. int id);
  85. #else
  86. static inline struct msm_dsi_pll *msm_dsi_pll_28nm_8960_init(
  87. struct platform_device *pdev, int id)
  88. {
  89. return ERR_PTR(-ENODEV);
  90. }
  91. #endif
  92. #ifdef CONFIG_DRM_MSM_DSI_14NM_PHY
  93. struct msm_dsi_pll *msm_dsi_pll_14nm_init(struct platform_device *pdev, int id);
  94. #else
  95. static inline struct msm_dsi_pll *
  96. msm_dsi_pll_14nm_init(struct platform_device *pdev, int id)
  97. {
  98. return ERR_PTR(-ENODEV);
  99. }
  100. #endif
  101. #ifdef CONFIG_DRM_MSM_DSI_10NM_PHY
  102. struct msm_dsi_pll *msm_dsi_pll_10nm_init(struct platform_device *pdev, int id);
  103. #else
  104. static inline struct msm_dsi_pll *
  105. msm_dsi_pll_10nm_init(struct platform_device *pdev, int id)
  106. {
  107. return ERR_PTR(-ENODEV);
  108. }
  109. #endif
  110. #endif /* __DSI_PLL_H__ */