smiapp-pll.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. #ifndef SMIAPP_PLL_H
  19. #define SMIAPP_PLL_H
  20. /* CSI-2 or CCP-2 */
  21. #define SMIAPP_PLL_BUS_TYPE_CSI2 0x00
  22. #define SMIAPP_PLL_BUS_TYPE_PARALLEL 0x01
  23. /* op pix clock is for all lanes in total normally */
  24. #define SMIAPP_PLL_FLAG_OP_PIX_CLOCK_PER_LANE (1 << 0)
  25. #define SMIAPP_PLL_FLAG_NO_OP_CLOCKS (1 << 1)
  26. struct smiapp_pll_branch {
  27. uint16_t sys_clk_div;
  28. uint16_t pix_clk_div;
  29. uint32_t sys_clk_freq_hz;
  30. uint32_t pix_clk_freq_hz;
  31. };
  32. struct smiapp_pll {
  33. /* input values */
  34. uint8_t bus_type;
  35. union {
  36. struct {
  37. uint8_t lanes;
  38. } csi2;
  39. struct {
  40. uint8_t bus_width;
  41. } parallel;
  42. };
  43. unsigned long flags;
  44. uint8_t binning_horizontal;
  45. uint8_t binning_vertical;
  46. uint8_t scale_m;
  47. uint8_t scale_n;
  48. uint8_t bits_per_pixel;
  49. uint32_t link_freq;
  50. uint32_t ext_clk_freq_hz;
  51. /* output values */
  52. uint16_t pre_pll_clk_div;
  53. uint16_t pll_multiplier;
  54. uint32_t pll_ip_clk_freq_hz;
  55. uint32_t pll_op_clk_freq_hz;
  56. struct smiapp_pll_branch vt;
  57. struct smiapp_pll_branch op;
  58. uint32_t pixel_rate_csi;
  59. uint32_t pixel_rate_pixel_array;
  60. };
  61. struct smiapp_pll_branch_limits {
  62. uint16_t min_sys_clk_div;
  63. uint16_t max_sys_clk_div;
  64. uint32_t min_sys_clk_freq_hz;
  65. uint32_t max_sys_clk_freq_hz;
  66. uint16_t min_pix_clk_div;
  67. uint16_t max_pix_clk_div;
  68. uint32_t min_pix_clk_freq_hz;
  69. uint32_t max_pix_clk_freq_hz;
  70. };
  71. struct smiapp_pll_limits {
  72. /* Strict PLL limits */
  73. uint32_t min_ext_clk_freq_hz;
  74. uint32_t max_ext_clk_freq_hz;
  75. uint16_t min_pre_pll_clk_div;
  76. uint16_t max_pre_pll_clk_div;
  77. uint32_t min_pll_ip_freq_hz;
  78. uint32_t max_pll_ip_freq_hz;
  79. uint16_t min_pll_multiplier;
  80. uint16_t max_pll_multiplier;
  81. uint32_t min_pll_op_freq_hz;
  82. uint32_t max_pll_op_freq_hz;
  83. struct smiapp_pll_branch_limits vt;
  84. struct smiapp_pll_branch_limits op;
  85. /* Other relevant limits */
  86. uint32_t min_line_length_pck_bin;
  87. uint32_t min_line_length_pck;
  88. };
  89. struct device;
  90. int smiapp_pll_calculate(struct device *dev,
  91. const struct smiapp_pll_limits *limits,
  92. struct smiapp_pll *pll);
  93. #endif /* SMIAPP_PLL_H */