dsi_pll.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. };
  37. #define hw_clk_to_pll(x) container_of(x, struct msm_dsi_pll, clk_hw)
  38. static inline void pll_write(void __iomem *reg, u32 data)
  39. {
  40. msm_writel(data, reg);
  41. }
  42. static inline u32 pll_read(const void __iomem *reg)
  43. {
  44. return msm_readl(reg);
  45. }
  46. static inline void pll_write_udelay(void __iomem *reg, u32 data, u32 delay_us)
  47. {
  48. pll_write(reg, data);
  49. udelay(delay_us);
  50. }
  51. static inline void pll_write_ndelay(void __iomem *reg, u32 data, u32 delay_ns)
  52. {
  53. pll_write((reg), data);
  54. ndelay(delay_ns);
  55. }
  56. /*
  57. * DSI PLL Helper functions
  58. */
  59. /* clock callbacks */
  60. long msm_dsi_pll_helper_clk_round_rate(struct clk_hw *hw,
  61. unsigned long rate, unsigned long *parent_rate);
  62. int msm_dsi_pll_helper_clk_prepare(struct clk_hw *hw);
  63. void msm_dsi_pll_helper_clk_unprepare(struct clk_hw *hw);
  64. /* misc */
  65. void msm_dsi_pll_helper_unregister_clks(struct platform_device *pdev,
  66. struct clk **clks, u32 num_clks);
  67. /*
  68. * Initialization for Each PLL Type
  69. */
  70. #ifdef CONFIG_DRM_MSM_DSI_28NM_PHY
  71. struct msm_dsi_pll *msm_dsi_pll_28nm_init(struct platform_device *pdev,
  72. enum msm_dsi_phy_type type, int id);
  73. #else
  74. static inline struct msm_dsi_pll *msm_dsi_pll_28nm_init(
  75. struct platform_device *pdev, enum msm_dsi_phy_type type, int id)
  76. {
  77. return ERR_PTR(-ENODEV);
  78. }
  79. #endif
  80. #ifdef CONFIG_DRM_MSM_DSI_28NM_8960_PHY
  81. struct msm_dsi_pll *msm_dsi_pll_28nm_8960_init(struct platform_device *pdev,
  82. int id);
  83. #else
  84. static inline struct msm_dsi_pll *msm_dsi_pll_28nm_8960_init(
  85. struct platform_device *pdev, int id)
  86. {
  87. return ERR_PTR(-ENODEV);
  88. }
  89. #endif
  90. #endif /* __DSI_PLL_H__ */