smiapp-pll.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * drivers/media/i2c/smiapp-pll.h
  3. *
  4. * Generic driver for SMIA/SMIA++ compliant camera modules
  5. *
  6. * Copyright (C) 2012 Nokia Corporation
  7. * Contact: Sakari Ailus <sakari.ailus@iki.fi>
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * version 2 as published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  21. * 02110-1301 USA
  22. *
  23. */
  24. #ifndef SMIAPP_PLL_H
  25. #define SMIAPP_PLL_H
  26. #include <linux/device.h>
  27. /* CSI-2 or CCP-2 */
  28. #define SMIAPP_PLL_BUS_TYPE_CSI2 0x00
  29. #define SMIAPP_PLL_BUS_TYPE_PARALLEL 0x01
  30. /* op pix clock is for all lanes in total normally */
  31. #define SMIAPP_PLL_FLAG_OP_PIX_CLOCK_PER_LANE (1 << 0)
  32. #define SMIAPP_PLL_FLAG_NO_OP_CLOCKS (1 << 1)
  33. struct smiapp_pll {
  34. /* input values */
  35. uint8_t bus_type;
  36. union {
  37. struct {
  38. uint8_t lanes;
  39. } csi2;
  40. struct {
  41. uint8_t bus_width;
  42. } parallel;
  43. };
  44. uint8_t flags;
  45. uint8_t binning_horizontal;
  46. uint8_t binning_vertical;
  47. uint8_t scale_m;
  48. uint8_t scale_n;
  49. uint8_t bits_per_pixel;
  50. uint32_t link_freq;
  51. /* output values */
  52. uint16_t pre_pll_clk_div;
  53. uint16_t pll_multiplier;
  54. uint16_t op_sys_clk_div;
  55. uint16_t op_pix_clk_div;
  56. uint16_t vt_sys_clk_div;
  57. uint16_t vt_pix_clk_div;
  58. uint32_t ext_clk_freq_hz;
  59. uint32_t pll_ip_clk_freq_hz;
  60. uint32_t pll_op_clk_freq_hz;
  61. uint32_t op_sys_clk_freq_hz;
  62. uint32_t op_pix_clk_freq_hz;
  63. uint32_t vt_sys_clk_freq_hz;
  64. uint32_t vt_pix_clk_freq_hz;
  65. uint32_t pixel_rate_csi;
  66. };
  67. struct smiapp_pll_branch_limits {
  68. uint16_t min_sys_clk_div;
  69. uint16_t max_sys_clk_div;
  70. uint32_t min_sys_clk_freq_hz;
  71. uint32_t max_sys_clk_freq_hz;
  72. uint16_t min_pix_clk_div;
  73. uint16_t max_pix_clk_div;
  74. uint32_t min_pix_clk_freq_hz;
  75. uint32_t max_pix_clk_freq_hz;
  76. };
  77. struct smiapp_pll_limits {
  78. /* Strict PLL limits */
  79. uint32_t min_ext_clk_freq_hz;
  80. uint32_t max_ext_clk_freq_hz;
  81. uint16_t min_pre_pll_clk_div;
  82. uint16_t max_pre_pll_clk_div;
  83. uint32_t min_pll_ip_freq_hz;
  84. uint32_t max_pll_ip_freq_hz;
  85. uint16_t min_pll_multiplier;
  86. uint16_t max_pll_multiplier;
  87. uint32_t min_pll_op_freq_hz;
  88. uint32_t max_pll_op_freq_hz;
  89. struct smiapp_pll_branch_limits vt;
  90. struct smiapp_pll_branch_limits op;
  91. /* Other relevant limits */
  92. uint32_t min_line_length_pck_bin;
  93. uint32_t min_line_length_pck;
  94. };
  95. struct device;
  96. int smiapp_pll_calculate(struct device *dev,
  97. const struct smiapp_pll_limits *limits,
  98. struct smiapp_pll *pll);
  99. #endif /* SMIAPP_PLL_H */