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