dsi_phy.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 (*enable)(struct msm_dsi_phy *phy, int src_pll_id,
  21. const unsigned long bit_rate, const unsigned long esc_rate);
  22. void (*disable)(struct msm_dsi_phy *phy);
  23. };
  24. struct msm_dsi_phy_cfg {
  25. enum msm_dsi_phy_type type;
  26. struct dsi_reg_config reg_cfg;
  27. struct msm_dsi_phy_ops ops;
  28. /*
  29. * Each cell {phy_id, pll_id} of the truth table indicates
  30. * if the source PLL selection bit should be set for each PHY.
  31. * Fill default H/W values in illegal cells, eg. cell {0, 1}.
  32. */
  33. bool src_pll_truthtable[DSI_MAX][DSI_MAX];
  34. };
  35. extern const struct msm_dsi_phy_cfg dsi_phy_28nm_hpm_cfgs;
  36. extern const struct msm_dsi_phy_cfg dsi_phy_28nm_lp_cfgs;
  37. extern const struct msm_dsi_phy_cfg dsi_phy_20nm_cfgs;
  38. struct msm_dsi_dphy_timing {
  39. u32 clk_pre;
  40. u32 clk_post;
  41. u32 clk_zero;
  42. u32 clk_trail;
  43. u32 clk_prepare;
  44. u32 hs_exit;
  45. u32 hs_zero;
  46. u32 hs_prepare;
  47. u32 hs_trail;
  48. u32 hs_rqst;
  49. u32 ta_go;
  50. u32 ta_sure;
  51. u32 ta_get;
  52. };
  53. struct msm_dsi_phy {
  54. struct platform_device *pdev;
  55. void __iomem *base;
  56. void __iomem *reg_base;
  57. int id;
  58. struct clk *ahb_clk;
  59. struct regulator_bulk_data supplies[DSI_DEV_REGULATOR_MAX];
  60. struct msm_dsi_dphy_timing timing;
  61. const struct msm_dsi_phy_cfg *cfg;
  62. bool regulator_ldo_mode;
  63. struct msm_dsi_pll *pll;
  64. };
  65. /*
  66. * PHY internal functions
  67. */
  68. int msm_dsi_dphy_timing_calc(struct msm_dsi_dphy_timing *timing,
  69. const unsigned long bit_rate, const unsigned long esc_rate);
  70. void msm_dsi_phy_set_src_pll(struct msm_dsi_phy *phy, int pll_id, u32 reg,
  71. u32 bit_mask);
  72. #endif /* __DSI_PHY_H__ */