fc2580_priv.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * FCI FC2580 silicon tuner driver
  4. *
  5. * Copyright (C) 2012 Antti Palosaari <crope@iki.fi>
  6. */
  7. #ifndef FC2580_PRIV_H
  8. #define FC2580_PRIV_H
  9. #include "fc2580.h"
  10. #include <media/v4l2-ctrls.h>
  11. #include <media/v4l2-subdev.h>
  12. #include <linux/regmap.h>
  13. #include <linux/math64.h>
  14. struct fc2580_reg_val {
  15. u8 reg;
  16. u8 val;
  17. };
  18. static const struct fc2580_reg_val fc2580_init_reg_vals[] = {
  19. {0x00, 0x00},
  20. {0x12, 0x86},
  21. {0x14, 0x5c},
  22. {0x16, 0x3c},
  23. {0x1f, 0xd2},
  24. {0x09, 0xd7},
  25. {0x0b, 0xd5},
  26. {0x0c, 0x32},
  27. {0x0e, 0x43},
  28. {0x21, 0x0a},
  29. {0x22, 0x82},
  30. {0x45, 0x10},
  31. {0x4c, 0x00},
  32. {0x3f, 0x88},
  33. {0x02, 0x0e},
  34. {0x58, 0x14},
  35. };
  36. struct fc2580_pll {
  37. u32 freq;
  38. u8 div_out;
  39. u8 band;
  40. };
  41. static const struct fc2580_pll fc2580_pll_lut[] = {
  42. /* VCO min VCO max */
  43. { 400000000, 12, 0x80}, /* .......... 4800000000 */
  44. {1000000000, 4, 0x00}, /* 1600000000 4000000000 */
  45. {0xffffffff, 2, 0x40}, /* 2000000000 .......... */
  46. };
  47. struct fc2580_if_filter {
  48. u32 freq;
  49. u8 r36_val;
  50. u8 r39_val;
  51. };
  52. static const struct fc2580_if_filter fc2580_if_filter_lut[] = {
  53. { 6000000, 0x18, 0x00},
  54. { 7000000, 0x18, 0x80},
  55. { 8000000, 0x18, 0x80},
  56. {0xffffffff, 0x18, 0x80},
  57. };
  58. struct fc2580_freq_regs {
  59. u32 freq;
  60. u8 r25_val;
  61. u8 r27_val;
  62. u8 r28_val;
  63. u8 r29_val;
  64. u8 r2b_val;
  65. u8 r2c_val;
  66. u8 r2d_val;
  67. u8 r30_val;
  68. u8 r44_val;
  69. u8 r50_val;
  70. u8 r53_val;
  71. u8 r5f_val;
  72. u8 r61_val;
  73. u8 r62_val;
  74. u8 r63_val;
  75. u8 r67_val;
  76. u8 r68_val;
  77. u8 r69_val;
  78. u8 r6a_val;
  79. u8 r6b_val;
  80. u8 r6c_val;
  81. u8 r6d_val;
  82. u8 r6e_val;
  83. u8 r6f_val;
  84. };
  85. /* XXX: 0xff is used for don't-care! */
  86. static const struct fc2580_freq_regs fc2580_freq_regs_lut[] = {
  87. { 400000000,
  88. 0xff, 0x77, 0x33, 0x40, 0xff, 0xff, 0xff, 0x09, 0xff, 0x8c,
  89. 0x50, 0x0f, 0x07, 0x00, 0x15, 0x03, 0x05, 0x10, 0x12, 0x08,
  90. 0x0a, 0x78, 0x32, 0x54},
  91. { 538000000,
  92. 0xf0, 0x77, 0x53, 0x60, 0xff, 0xff, 0x9f, 0x09, 0xff, 0x8c,
  93. 0x50, 0x13, 0x07, 0x06, 0x15, 0x06, 0x08, 0x10, 0x12, 0x0b,
  94. 0x0c, 0x78, 0x32, 0x14},
  95. { 794000000,
  96. 0xf0, 0x77, 0x53, 0x60, 0xff, 0xff, 0x9f, 0x09, 0xff, 0x8c,
  97. 0x50, 0x15, 0x03, 0x03, 0x15, 0x03, 0x05, 0x0c, 0x0e, 0x0b,
  98. 0x0c, 0x78, 0x32, 0x14},
  99. {1000000000,
  100. 0xf0, 0x77, 0x53, 0x60, 0xff, 0xff, 0x8f, 0x09, 0xff, 0x8c,
  101. 0x50, 0x15, 0x07, 0x06, 0x15, 0x07, 0x09, 0x10, 0x12, 0x0b,
  102. 0x0c, 0x78, 0x32, 0x14},
  103. {0xffffffff,
  104. 0xff, 0xff, 0xff, 0xff, 0x70, 0x37, 0xe7, 0x09, 0x20, 0x8c,
  105. 0x50, 0x0f, 0x0f, 0x00, 0x13, 0x00, 0x02, 0x0c, 0x0e, 0x08,
  106. 0x0a, 0xa0, 0x50, 0x14},
  107. };
  108. struct fc2580_dev {
  109. u32 clk;
  110. struct i2c_client *client;
  111. struct regmap *regmap;
  112. struct v4l2_subdev subdev;
  113. bool active;
  114. unsigned int f_frequency;
  115. unsigned int f_bandwidth;
  116. /* Controls */
  117. struct v4l2_ctrl_handler hdl;
  118. struct v4l2_ctrl *bandwidth_auto;
  119. struct v4l2_ctrl *bandwidth;
  120. };
  121. #endif