4 * Sony digital demodulator driver for
5 * CXD2441ER - DVB-S/S2/T/T2/C/C2
6 * CXD2454ER - DVB-S/S2/T/T2/C/C2, ISDB-T/S
8 * Copyright 2012 Sony Corporation
9 * Copyright (C) 2014 NetUP Inc.
10 * Copyright (C) 2014 Sergey Kozlov <serjk@netup.ru>
11 * Copyright (C) 2014 Abylay Ospan <aospan@netup.ru>
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
24 #include <linux/module.h>
25 #include <linux/init.h>
26 #include <linux/string.h>
27 #include <linux/slab.h>
28 #include <linux/bitops.h>
29 #include <linux/math64.h>
30 #include <linux/log2.h>
31 #include <linux/dynamic_debug.h>
34 #include "dvb_frontend.h"
35 #include "cxd2841er.h"
36 #include "cxd2841er_priv.h"
38 #define MAX_WRITE_REGSIZE 16
40 enum cxd2841er_state {
48 struct cxd2841er_priv {
49 struct dvb_frontend frontend;
50 struct i2c_adapter *i2c;
53 const struct cxd2841er_config *config;
54 enum cxd2841er_state state;
56 enum cxd2841er_xtal xtal;
59 static const struct cxd2841er_cnr_data s_cn_data[] = {
60 { 0x033e, 0 }, { 0x0339, 100 }, { 0x0333, 200 },
61 { 0x032e, 300 }, { 0x0329, 400 }, { 0x0324, 500 },
62 { 0x031e, 600 }, { 0x0319, 700 }, { 0x0314, 800 },
63 { 0x030f, 900 }, { 0x030a, 1000 }, { 0x02ff, 1100 },
64 { 0x02f4, 1200 }, { 0x02e9, 1300 }, { 0x02de, 1400 },
65 { 0x02d4, 1500 }, { 0x02c9, 1600 }, { 0x02bf, 1700 },
66 { 0x02b5, 1800 }, { 0x02ab, 1900 }, { 0x02a1, 2000 },
67 { 0x029b, 2100 }, { 0x0295, 2200 }, { 0x0290, 2300 },
68 { 0x028a, 2400 }, { 0x0284, 2500 }, { 0x027f, 2600 },
69 { 0x0279, 2700 }, { 0x0274, 2800 }, { 0x026e, 2900 },
70 { 0x0269, 3000 }, { 0x0262, 3100 }, { 0x025c, 3200 },
71 { 0x0255, 3300 }, { 0x024f, 3400 }, { 0x0249, 3500 },
72 { 0x0242, 3600 }, { 0x023c, 3700 }, { 0x0236, 3800 },
73 { 0x0230, 3900 }, { 0x022a, 4000 }, { 0x0223, 4100 },
74 { 0x021c, 4200 }, { 0x0215, 4300 }, { 0x020e, 4400 },
75 { 0x0207, 4500 }, { 0x0201, 4600 }, { 0x01fa, 4700 },
76 { 0x01f4, 4800 }, { 0x01ed, 4900 }, { 0x01e7, 5000 },
77 { 0x01e0, 5100 }, { 0x01d9, 5200 }, { 0x01d2, 5300 },
78 { 0x01cb, 5400 }, { 0x01c4, 5500 }, { 0x01be, 5600 },
79 { 0x01b7, 5700 }, { 0x01b1, 5800 }, { 0x01aa, 5900 },
80 { 0x01a4, 6000 }, { 0x019d, 6100 }, { 0x0196, 6200 },
81 { 0x018f, 6300 }, { 0x0189, 6400 }, { 0x0182, 6500 },
82 { 0x017c, 6600 }, { 0x0175, 6700 }, { 0x016f, 6800 },
83 { 0x0169, 6900 }, { 0x0163, 7000 }, { 0x015c, 7100 },
84 { 0x0156, 7200 }, { 0x0150, 7300 }, { 0x014a, 7400 },
85 { 0x0144, 7500 }, { 0x013e, 7600 }, { 0x0138, 7700 },
86 { 0x0132, 7800 }, { 0x012d, 7900 }, { 0x0127, 8000 },
87 { 0x0121, 8100 }, { 0x011c, 8200 }, { 0x0116, 8300 },
88 { 0x0111, 8400 }, { 0x010b, 8500 }, { 0x0106, 8600 },
89 { 0x0101, 8700 }, { 0x00fc, 8800 }, { 0x00f7, 8900 },
90 { 0x00f2, 9000 }, { 0x00ee, 9100 }, { 0x00ea, 9200 },
91 { 0x00e6, 9300 }, { 0x00e2, 9400 }, { 0x00de, 9500 },
92 { 0x00da, 9600 }, { 0x00d7, 9700 }, { 0x00d3, 9800 },
93 { 0x00d0, 9900 }, { 0x00cc, 10000 }, { 0x00c7, 10100 },
94 { 0x00c3, 10200 }, { 0x00bf, 10300 }, { 0x00ba, 10400 },
95 { 0x00b6, 10500 }, { 0x00b2, 10600 }, { 0x00ae, 10700 },
96 { 0x00aa, 10800 }, { 0x00a7, 10900 }, { 0x00a3, 11000 },
97 { 0x009f, 11100 }, { 0x009c, 11200 }, { 0x0098, 11300 },
98 { 0x0094, 11400 }, { 0x0091, 11500 }, { 0x008e, 11600 },
99 { 0x008a, 11700 }, { 0x0087, 11800 }, { 0x0084, 11900 },
100 { 0x0081, 12000 }, { 0x007e, 12100 }, { 0x007b, 12200 },
101 { 0x0079, 12300 }, { 0x0076, 12400 }, { 0x0073, 12500 },
102 { 0x0071, 12600 }, { 0x006e, 12700 }, { 0x006c, 12800 },
103 { 0x0069, 12900 }, { 0x0067, 13000 }, { 0x0065, 13100 },
104 { 0x0062, 13200 }, { 0x0060, 13300 }, { 0x005e, 13400 },
105 { 0x005c, 13500 }, { 0x005a, 13600 }, { 0x0058, 13700 },
106 { 0x0056, 13800 }, { 0x0054, 13900 }, { 0x0052, 14000 },
107 { 0x0050, 14100 }, { 0x004e, 14200 }, { 0x004c, 14300 },
108 { 0x004b, 14400 }, { 0x0049, 14500 }, { 0x0047, 14600 },
109 { 0x0046, 14700 }, { 0x0044, 14800 }, { 0x0043, 14900 },
110 { 0x0041, 15000 }, { 0x003f, 15100 }, { 0x003e, 15200 },
111 { 0x003c, 15300 }, { 0x003b, 15400 }, { 0x003a, 15500 },
112 { 0x0037, 15700 }, { 0x0036, 15800 }, { 0x0034, 15900 },
113 { 0x0033, 16000 }, { 0x0032, 16100 }, { 0x0031, 16200 },
114 { 0x0030, 16300 }, { 0x002f, 16400 }, { 0x002e, 16500 },
115 { 0x002d, 16600 }, { 0x002c, 16700 }, { 0x002b, 16800 },
116 { 0x002a, 16900 }, { 0x0029, 17000 }, { 0x0028, 17100 },
117 { 0x0027, 17200 }, { 0x0026, 17300 }, { 0x0025, 17400 },
118 { 0x0024, 17500 }, { 0x0023, 17600 }, { 0x0022, 17800 },
119 { 0x0021, 17900 }, { 0x0020, 18000 }, { 0x001f, 18200 },
120 { 0x001e, 18300 }, { 0x001d, 18500 }, { 0x001c, 18700 },
121 { 0x001b, 18900 }, { 0x001a, 19000 }, { 0x0019, 19200 },
122 { 0x0018, 19300 }, { 0x0017, 19500 }, { 0x0016, 19700 },
123 { 0x0015, 19900 }, { 0x0014, 20000 },
126 static const struct cxd2841er_cnr_data s2_cn_data[] = {
127 { 0x05af, 0 }, { 0x0597, 100 }, { 0x057e, 200 },
128 { 0x0567, 300 }, { 0x0550, 400 }, { 0x0539, 500 },
129 { 0x0522, 600 }, { 0x050c, 700 }, { 0x04f6, 800 },
130 { 0x04e1, 900 }, { 0x04cc, 1000 }, { 0x04b6, 1100 },
131 { 0x04a1, 1200 }, { 0x048c, 1300 }, { 0x0477, 1400 },
132 { 0x0463, 1500 }, { 0x044f, 1600 }, { 0x043c, 1700 },
133 { 0x0428, 1800 }, { 0x0416, 1900 }, { 0x0403, 2000 },
134 { 0x03ef, 2100 }, { 0x03dc, 2200 }, { 0x03c9, 2300 },
135 { 0x03b6, 2400 }, { 0x03a4, 2500 }, { 0x0392, 2600 },
136 { 0x0381, 2700 }, { 0x036f, 2800 }, { 0x035f, 2900 },
137 { 0x034e, 3000 }, { 0x033d, 3100 }, { 0x032d, 3200 },
138 { 0x031d, 3300 }, { 0x030d, 3400 }, { 0x02fd, 3500 },
139 { 0x02ee, 3600 }, { 0x02df, 3700 }, { 0x02d0, 3800 },
140 { 0x02c2, 3900 }, { 0x02b4, 4000 }, { 0x02a6, 4100 },
141 { 0x0299, 4200 }, { 0x028c, 4300 }, { 0x027f, 4400 },
142 { 0x0272, 4500 }, { 0x0265, 4600 }, { 0x0259, 4700 },
143 { 0x024d, 4800 }, { 0x0241, 4900 }, { 0x0236, 5000 },
144 { 0x022b, 5100 }, { 0x0220, 5200 }, { 0x0215, 5300 },
145 { 0x020a, 5400 }, { 0x0200, 5500 }, { 0x01f6, 5600 },
146 { 0x01ec, 5700 }, { 0x01e2, 5800 }, { 0x01d8, 5900 },
147 { 0x01cf, 6000 }, { 0x01c6, 6100 }, { 0x01bc, 6200 },
148 { 0x01b3, 6300 }, { 0x01aa, 6400 }, { 0x01a2, 6500 },
149 { 0x0199, 6600 }, { 0x0191, 6700 }, { 0x0189, 6800 },
150 { 0x0181, 6900 }, { 0x0179, 7000 }, { 0x0171, 7100 },
151 { 0x0169, 7200 }, { 0x0161, 7300 }, { 0x015a, 7400 },
152 { 0x0153, 7500 }, { 0x014b, 7600 }, { 0x0144, 7700 },
153 { 0x013d, 7800 }, { 0x0137, 7900 }, { 0x0130, 8000 },
154 { 0x012a, 8100 }, { 0x0124, 8200 }, { 0x011e, 8300 },
155 { 0x0118, 8400 }, { 0x0112, 8500 }, { 0x010c, 8600 },
156 { 0x0107, 8700 }, { 0x0101, 8800 }, { 0x00fc, 8900 },
157 { 0x00f7, 9000 }, { 0x00f2, 9100 }, { 0x00ec, 9200 },
158 { 0x00e7, 9300 }, { 0x00e2, 9400 }, { 0x00dd, 9500 },
159 { 0x00d8, 9600 }, { 0x00d4, 9700 }, { 0x00cf, 9800 },
160 { 0x00ca, 9900 }, { 0x00c6, 10000 }, { 0x00c2, 10100 },
161 { 0x00be, 10200 }, { 0x00b9, 10300 }, { 0x00b5, 10400 },
162 { 0x00b1, 10500 }, { 0x00ae, 10600 }, { 0x00aa, 10700 },
163 { 0x00a6, 10800 }, { 0x00a3, 10900 }, { 0x009f, 11000 },
164 { 0x009b, 11100 }, { 0x0098, 11200 }, { 0x0095, 11300 },
165 { 0x0091, 11400 }, { 0x008e, 11500 }, { 0x008b, 11600 },
166 { 0x0088, 11700 }, { 0x0085, 11800 }, { 0x0082, 11900 },
167 { 0x007f, 12000 }, { 0x007c, 12100 }, { 0x007a, 12200 },
168 { 0x0077, 12300 }, { 0x0074, 12400 }, { 0x0072, 12500 },
169 { 0x006f, 12600 }, { 0x006d, 12700 }, { 0x006b, 12800 },
170 { 0x0068, 12900 }, { 0x0066, 13000 }, { 0x0064, 13100 },
171 { 0x0061, 13200 }, { 0x005f, 13300 }, { 0x005d, 13400 },
172 { 0x005b, 13500 }, { 0x0059, 13600 }, { 0x0057, 13700 },
173 { 0x0055, 13800 }, { 0x0053, 13900 }, { 0x0051, 14000 },
174 { 0x004f, 14100 }, { 0x004e, 14200 }, { 0x004c, 14300 },
175 { 0x004a, 14400 }, { 0x0049, 14500 }, { 0x0047, 14600 },
176 { 0x0045, 14700 }, { 0x0044, 14800 }, { 0x0042, 14900 },
177 { 0x0041, 15000 }, { 0x003f, 15100 }, { 0x003e, 15200 },
178 { 0x003c, 15300 }, { 0x003b, 15400 }, { 0x003a, 15500 },
179 { 0x0038, 15600 }, { 0x0037, 15700 }, { 0x0036, 15800 },
180 { 0x0034, 15900 }, { 0x0033, 16000 }, { 0x0032, 16100 },
181 { 0x0031, 16200 }, { 0x0030, 16300 }, { 0x002f, 16400 },
182 { 0x002e, 16500 }, { 0x002d, 16600 }, { 0x002c, 16700 },
183 { 0x002b, 16800 }, { 0x002a, 16900 }, { 0x0029, 17000 },
184 { 0x0028, 17100 }, { 0x0027, 17200 }, { 0x0026, 17300 },
185 { 0x0025, 17400 }, { 0x0024, 17500 }, { 0x0023, 17600 },
186 { 0x0022, 17800 }, { 0x0021, 17900 }, { 0x0020, 18000 },
187 { 0x001f, 18200 }, { 0x001e, 18300 }, { 0x001d, 18500 },
188 { 0x001c, 18700 }, { 0x001b, 18900 }, { 0x001a, 19000 },
189 { 0x0019, 19200 }, { 0x0018, 19300 }, { 0x0017, 19500 },
190 { 0x0016, 19700 }, { 0x0015, 19900 }, { 0x0014, 20000 },
193 #define MAKE_IFFREQ_CONFIG(iffreq) ((u32)(((iffreq)/41.0)*16777216.0 + 0.5))
194 #define MAKE_IFFREQ_CONFIG_XTAL(xtal, iffreq) ((xtal == SONY_XTAL_24000) ? \
195 (u32)(((iffreq)/48.0)*16777216.0 + 0.5) : \
196 (u32)(((iffreq)/41.0)*16777216.0 + 0.5))
198 static void cxd2841er_i2c_debug(struct cxd2841er_priv *priv,
199 u8 addr, u8 reg, u8 write,
200 const u8 *data, u32 len)
202 dev_dbg(&priv->i2c->dev,
203 "cxd2841er: I2C %s addr %02x reg 0x%02x size %d\n",
204 (write == 0 ? "read" : "write"), addr, reg, len);
205 print_hex_dump_bytes("cxd2841er: I2C data: ",
206 DUMP_PREFIX_OFFSET, data, len);
209 static int cxd2841er_write_regs(struct cxd2841er_priv *priv,
210 u8 addr, u8 reg, const u8 *data, u32 len)
213 u8 buf[MAX_WRITE_REGSIZE + 1];
214 u8 i2c_addr = (addr == I2C_SLVX ?
215 priv->i2c_addr_slvx : priv->i2c_addr_slvt);
216 struct i2c_msg msg[1] = {
225 if (len + 1 >= sizeof(buf)) {
226 dev_warn(&priv->i2c->dev, "wr reg=%04x: len=%d is too big!\n",
231 cxd2841er_i2c_debug(priv, i2c_addr, reg, 1, data, len);
233 memcpy(&buf[1], data, len);
235 ret = i2c_transfer(priv->i2c, msg, 1);
236 if (ret >= 0 && ret != 1)
239 dev_warn(&priv->i2c->dev,
240 "%s: i2c wr failed=%d addr=%02x reg=%02x len=%d\n",
241 KBUILD_MODNAME, ret, i2c_addr, reg, len);
247 static int cxd2841er_write_reg(struct cxd2841er_priv *priv,
248 u8 addr, u8 reg, u8 val)
250 return cxd2841er_write_regs(priv, addr, reg, &val, 1);
253 static int cxd2841er_read_regs(struct cxd2841er_priv *priv,
254 u8 addr, u8 reg, u8 *val, u32 len)
257 u8 i2c_addr = (addr == I2C_SLVX ?
258 priv->i2c_addr_slvx : priv->i2c_addr_slvt);
259 struct i2c_msg msg[2] = {
273 ret = i2c_transfer(priv->i2c, &msg[0], 1);
274 if (ret >= 0 && ret != 1)
277 dev_warn(&priv->i2c->dev,
278 "%s: i2c rw failed=%d addr=%02x reg=%02x\n",
279 KBUILD_MODNAME, ret, i2c_addr, reg);
282 ret = i2c_transfer(priv->i2c, &msg[1], 1);
283 if (ret >= 0 && ret != 1)
286 dev_warn(&priv->i2c->dev,
287 "%s: i2c rd failed=%d addr=%02x reg=%02x\n",
288 KBUILD_MODNAME, ret, i2c_addr, reg);
294 static int cxd2841er_read_reg(struct cxd2841er_priv *priv,
295 u8 addr, u8 reg, u8 *val)
297 return cxd2841er_read_regs(priv, addr, reg, val, 1);
300 static int cxd2841er_set_reg_bits(struct cxd2841er_priv *priv,
301 u8 addr, u8 reg, u8 data, u8 mask)
307 res = cxd2841er_read_reg(priv, addr, reg, &rdata);
310 data = ((data & mask) | (rdata & (mask ^ 0xFF)));
312 return cxd2841er_write_reg(priv, addr, reg, data);
315 static int cxd2841er_dvbs2_set_symbol_rate(struct cxd2841er_priv *priv,
319 u8 data[3] = {0, 0, 0};
321 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
323 * regValue = (symbolRateKSps * 2^14 / 1000) + 0.5
324 * = ((symbolRateKSps * 2^14) + 500) / 1000
325 * = ((symbolRateKSps * 16384) + 500) / 1000
327 reg_value = DIV_ROUND_CLOSEST(symbol_rate * 16384, 1000);
328 if ((reg_value == 0) || (reg_value > 0xFFFFF)) {
329 dev_err(&priv->i2c->dev,
330 "%s(): reg_value is out of range\n", __func__);
333 data[0] = (u8)((reg_value >> 16) & 0x0F);
334 data[1] = (u8)((reg_value >> 8) & 0xFF);
335 data[2] = (u8)(reg_value & 0xFF);
336 /* Set SLV-T Bank : 0xAE */
337 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0xae);
338 cxd2841er_write_regs(priv, I2C_SLVT, 0x20, data, 3);
342 static void cxd2841er_set_ts_clock_mode(struct cxd2841er_priv *priv,
345 static int cxd2841er_sleep_s_to_active_s(struct cxd2841er_priv *priv,
346 u8 system, u32 symbol_rate)
349 u8 data[4] = { 0, 0, 0, 0 };
351 if (priv->state != STATE_SLEEP_S) {
352 dev_err(&priv->i2c->dev, "%s(): invalid state %d\n",
353 __func__, (int)priv->state);
356 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
357 cxd2841er_set_ts_clock_mode(priv, SYS_DVBS);
359 if (system == SYS_DVBS) {
361 } else if (system == SYS_DVBS2) {
364 dev_err(&priv->i2c->dev, "%s(): invalid delsys %d\n",
368 /* Set SLV-X Bank : 0x00 */
369 cxd2841er_write_reg(priv, I2C_SLVX, 0x00, 0x00);
370 cxd2841er_write_reg(priv, I2C_SLVX, 0x17, data[0]);
373 /* Set SLV-T Bank : 0x00 */
374 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x00);
375 /* Enable S/S2 auto detection 1 */
376 cxd2841er_write_reg(priv, I2C_SLVT, 0x2d, data[0]);
377 /* Set SLV-T Bank : 0xAE */
378 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0xae);
379 /* Enable S/S2 auto detection 2 */
380 cxd2841er_write_reg(priv, I2C_SLVT, 0x30, data[0]);
381 /* Set SLV-T Bank : 0x00 */
382 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x00);
383 /* Enable demod clock */
384 cxd2841er_write_reg(priv, I2C_SLVT, 0x2c, 0x01);
385 /* Enable ADC clock */
386 cxd2841er_write_reg(priv, I2C_SLVT, 0x31, 0x01);
388 cxd2841er_write_reg(priv, I2C_SLVT, 0x63, 0x16);
390 cxd2841er_write_reg(priv, I2C_SLVT, 0x65, 0x3f);
391 /* Set SLV-X Bank : 0x00 */
392 cxd2841er_write_reg(priv, I2C_SLVX, 0x00, 0x00);
394 cxd2841er_write_reg(priv, I2C_SLVX, 0x18, 0x00);
395 /* Set SLV-T Bank : 0xA3 */
396 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0xa3);
397 cxd2841er_write_reg(priv, I2C_SLVT, 0xac, 0x00);
402 /* Set SLV-T Bank : 0xAB */
403 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0xab);
404 cxd2841er_write_regs(priv, I2C_SLVT, 0x98, data, 4);
409 cxd2841er_write_regs(priv, I2C_SLVT, 0xa8, data, 4);
412 cxd2841er_write_regs(priv, I2C_SLVT, 0xc3, data, 2);
413 /* Set demod parameter */
414 ret = cxd2841er_dvbs2_set_symbol_rate(priv, symbol_rate);
417 /* Set SLV-T Bank : 0x00 */
418 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x00);
419 /* disable Hi-Z setting 1 */
420 cxd2841er_write_reg(priv, I2C_SLVT, 0x80, 0x10);
421 /* disable Hi-Z setting 2 */
422 cxd2841er_write_reg(priv, I2C_SLVT, 0x81, 0x00);
423 priv->state = STATE_ACTIVE_S;
427 static int cxd2841er_sleep_tc_to_active_t_band(struct cxd2841er_priv *priv,
430 static int cxd2841er_sleep_tc_to_active_t2_band(struct cxd2841er_priv *priv,
433 static int cxd2841er_sleep_tc_to_active_c_band(struct cxd2841er_priv *priv,
436 static int cxd2841er_sleep_tc_to_active_i(struct cxd2841er_priv *priv,
439 static int cxd2841er_active_i_to_sleep_tc(struct cxd2841er_priv *priv);
441 static int cxd2841er_sleep_tc_to_shutdown(struct cxd2841er_priv *priv);
443 static int cxd2841er_shutdown_to_sleep_tc(struct cxd2841er_priv *priv);
445 static int cxd2841er_retune_active(struct cxd2841er_priv *priv,
446 struct dtv_frontend_properties *p)
448 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
449 if (priv->state != STATE_ACTIVE_S &&
450 priv->state != STATE_ACTIVE_TC) {
451 dev_dbg(&priv->i2c->dev, "%s(): invalid state %d\n",
452 __func__, priv->state);
455 /* Set SLV-T Bank : 0x00 */
456 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x00);
457 /* disable TS output */
458 cxd2841er_write_reg(priv, I2C_SLVT, 0xc3, 0x01);
459 if (priv->state == STATE_ACTIVE_S)
460 return cxd2841er_dvbs2_set_symbol_rate(
461 priv, p->symbol_rate / 1000);
462 else if (priv->state == STATE_ACTIVE_TC) {
463 switch (priv->system) {
465 return cxd2841er_sleep_tc_to_active_t_band(
466 priv, p->bandwidth_hz);
468 return cxd2841er_sleep_tc_to_active_t2_band(
469 priv, p->bandwidth_hz);
470 case SYS_DVBC_ANNEX_A:
471 return cxd2841er_sleep_tc_to_active_c_band(
472 priv, p->bandwidth_hz);
474 cxd2841er_active_i_to_sleep_tc(priv);
475 cxd2841er_sleep_tc_to_shutdown(priv);
476 cxd2841er_shutdown_to_sleep_tc(priv);
477 return cxd2841er_sleep_tc_to_active_i(
478 priv, p->bandwidth_hz);
481 dev_dbg(&priv->i2c->dev, "%s(): invalid delivery system %d\n",
482 __func__, priv->system);
486 static int cxd2841er_active_s_to_sleep_s(struct cxd2841er_priv *priv)
488 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
489 if (priv->state != STATE_ACTIVE_S) {
490 dev_err(&priv->i2c->dev, "%s(): invalid state %d\n",
491 __func__, priv->state);
494 /* Set SLV-T Bank : 0x00 */
495 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x00);
496 /* disable TS output */
497 cxd2841er_write_reg(priv, I2C_SLVT, 0xc3, 0x01);
498 /* enable Hi-Z setting 1 */
499 cxd2841er_write_reg(priv, I2C_SLVT, 0x80, 0x1f);
500 /* enable Hi-Z setting 2 */
501 cxd2841er_write_reg(priv, I2C_SLVT, 0x81, 0xff);
502 /* Set SLV-X Bank : 0x00 */
503 cxd2841er_write_reg(priv, I2C_SLVX, 0x00, 0x00);
505 cxd2841er_write_reg(priv, I2C_SLVX, 0x18, 0x01);
506 /* Set SLV-T Bank : 0x00 */
507 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x00);
508 /* disable ADC clock */
509 cxd2841er_write_reg(priv, I2C_SLVT, 0x31, 0x00);
511 cxd2841er_write_reg(priv, I2C_SLVT, 0x63, 0x16);
513 cxd2841er_write_reg(priv, I2C_SLVT, 0x65, 0x27);
515 cxd2841er_write_reg(priv, I2C_SLVT, 0x69, 0x06);
516 /* disable demod clock */
517 cxd2841er_write_reg(priv, I2C_SLVT, 0x2c, 0x00);
518 /* Set SLV-T Bank : 0xAE */
519 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0xae);
520 /* disable S/S2 auto detection1 */
521 cxd2841er_write_reg(priv, I2C_SLVT, 0x30, 0x00);
522 /* Set SLV-T Bank : 0x00 */
523 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x00);
524 /* disable S/S2 auto detection2 */
525 cxd2841er_write_reg(priv, I2C_SLVT, 0x2d, 0x00);
526 priv->state = STATE_SLEEP_S;
530 static int cxd2841er_sleep_s_to_shutdown(struct cxd2841er_priv *priv)
532 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
533 if (priv->state != STATE_SLEEP_S) {
534 dev_dbg(&priv->i2c->dev, "%s(): invalid demod state %d\n",
535 __func__, priv->state);
538 /* Set SLV-T Bank : 0x00 */
539 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x00);
541 cxd2841er_write_reg(priv, I2C_SLVT, 0x80, 0x3f);
543 cxd2841er_write_reg(priv, I2C_SLVT, 0x9c, 0x00);
544 /* Set SLV-X Bank : 0x00 */
545 cxd2841er_write_reg(priv, I2C_SLVX, 0x00, 0x00);
546 /* Disable oscillator */
547 cxd2841er_write_reg(priv, I2C_SLVX, 0x15, 0x01);
549 cxd2841er_write_reg(priv, I2C_SLVX, 0x17, 0x01);
550 priv->state = STATE_SHUTDOWN;
554 static int cxd2841er_sleep_tc_to_shutdown(struct cxd2841er_priv *priv)
556 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
557 if (priv->state != STATE_SLEEP_TC) {
558 dev_dbg(&priv->i2c->dev, "%s(): invalid demod state %d\n",
559 __func__, priv->state);
562 /* Set SLV-X Bank : 0x00 */
563 cxd2841er_write_reg(priv, I2C_SLVX, 0x00, 0x00);
564 /* Disable oscillator */
565 cxd2841er_write_reg(priv, I2C_SLVX, 0x15, 0x01);
567 cxd2841er_write_reg(priv, I2C_SLVX, 0x17, 0x01);
568 priv->state = STATE_SHUTDOWN;
572 static int cxd2841er_active_t_to_sleep_tc(struct cxd2841er_priv *priv)
574 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
575 if (priv->state != STATE_ACTIVE_TC) {
576 dev_err(&priv->i2c->dev, "%s(): invalid state %d\n",
577 __func__, priv->state);
580 /* Set SLV-T Bank : 0x00 */
581 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x00);
582 /* disable TS output */
583 cxd2841er_write_reg(priv, I2C_SLVT, 0xc3, 0x01);
584 /* enable Hi-Z setting 1 */
585 cxd2841er_write_reg(priv, I2C_SLVT, 0x80, 0x3f);
586 /* enable Hi-Z setting 2 */
587 cxd2841er_write_reg(priv, I2C_SLVT, 0x81, 0xff);
588 /* Set SLV-X Bank : 0x00 */
589 cxd2841er_write_reg(priv, I2C_SLVX, 0x00, 0x00);
591 cxd2841er_write_reg(priv, I2C_SLVX, 0x18, 0x01);
592 /* Set SLV-T Bank : 0x00 */
593 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x00);
595 cxd2841er_write_reg(priv, I2C_SLVT, 0x43, 0x0a);
597 cxd2841er_write_reg(priv, I2C_SLVT, 0x41, 0x0a);
598 /* Disable ADC clock */
599 cxd2841er_write_reg(priv, I2C_SLVT, 0x30, 0x00);
600 /* Disable RF level monitor */
601 cxd2841er_write_reg(priv, I2C_SLVT, 0x2f, 0x00);
602 /* Disable demod clock */
603 cxd2841er_write_reg(priv, I2C_SLVT, 0x2c, 0x00);
604 priv->state = STATE_SLEEP_TC;
608 static int cxd2841er_active_t2_to_sleep_tc(struct cxd2841er_priv *priv)
610 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
611 if (priv->state != STATE_ACTIVE_TC) {
612 dev_err(&priv->i2c->dev, "%s(): invalid state %d\n",
613 __func__, priv->state);
616 /* Set SLV-T Bank : 0x00 */
617 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x00);
618 /* disable TS output */
619 cxd2841er_write_reg(priv, I2C_SLVT, 0xc3, 0x01);
620 /* enable Hi-Z setting 1 */
621 cxd2841er_write_reg(priv, I2C_SLVT, 0x80, 0x3f);
622 /* enable Hi-Z setting 2 */
623 cxd2841er_write_reg(priv, I2C_SLVT, 0x81, 0xff);
624 /* Cancel DVB-T2 setting */
625 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x13);
626 cxd2841er_write_reg(priv, I2C_SLVT, 0x83, 0x40);
627 cxd2841er_write_reg(priv, I2C_SLVT, 0x86, 0x21);
628 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0x9e, 0x09, 0x0f);
629 cxd2841er_write_reg(priv, I2C_SLVT, 0x9f, 0xfb);
630 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x2a);
631 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0x38, 0x00, 0x0f);
632 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x2b);
633 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0x11, 0x00, 0x3f);
634 /* Set SLV-X Bank : 0x00 */
635 cxd2841er_write_reg(priv, I2C_SLVX, 0x00, 0x00);
637 cxd2841er_write_reg(priv, I2C_SLVX, 0x18, 0x01);
638 /* Set SLV-T Bank : 0x00 */
639 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x00);
641 cxd2841er_write_reg(priv, I2C_SLVT, 0x43, 0x0a);
643 cxd2841er_write_reg(priv, I2C_SLVT, 0x41, 0x0a);
644 /* Disable ADC clock */
645 cxd2841er_write_reg(priv, I2C_SLVT, 0x30, 0x00);
646 /* Disable RF level monitor */
647 cxd2841er_write_reg(priv, I2C_SLVT, 0x2f, 0x00);
648 /* Disable demod clock */
649 cxd2841er_write_reg(priv, I2C_SLVT, 0x2c, 0x00);
650 priv->state = STATE_SLEEP_TC;
654 static int cxd2841er_active_c_to_sleep_tc(struct cxd2841er_priv *priv)
656 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
657 if (priv->state != STATE_ACTIVE_TC) {
658 dev_err(&priv->i2c->dev, "%s(): invalid state %d\n",
659 __func__, priv->state);
662 /* Set SLV-T Bank : 0x00 */
663 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x00);
664 /* disable TS output */
665 cxd2841er_write_reg(priv, I2C_SLVT, 0xc3, 0x01);
666 /* enable Hi-Z setting 1 */
667 cxd2841er_write_reg(priv, I2C_SLVT, 0x80, 0x3f);
668 /* enable Hi-Z setting 2 */
669 cxd2841er_write_reg(priv, I2C_SLVT, 0x81, 0xff);
670 /* Cancel DVB-C setting */
671 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x11);
672 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xa3, 0x00, 0x1f);
673 /* Set SLV-X Bank : 0x00 */
674 cxd2841er_write_reg(priv, I2C_SLVX, 0x00, 0x00);
676 cxd2841er_write_reg(priv, I2C_SLVX, 0x18, 0x01);
677 /* Set SLV-T Bank : 0x00 */
678 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x00);
680 cxd2841er_write_reg(priv, I2C_SLVT, 0x43, 0x0a);
682 cxd2841er_write_reg(priv, I2C_SLVT, 0x41, 0x0a);
683 /* Disable ADC clock */
684 cxd2841er_write_reg(priv, I2C_SLVT, 0x30, 0x00);
685 /* Disable RF level monitor */
686 cxd2841er_write_reg(priv, I2C_SLVT, 0x2f, 0x00);
687 /* Disable demod clock */
688 cxd2841er_write_reg(priv, I2C_SLVT, 0x2c, 0x00);
689 priv->state = STATE_SLEEP_TC;
693 static int cxd2841er_active_i_to_sleep_tc(struct cxd2841er_priv *priv)
695 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
696 if (priv->state != STATE_ACTIVE_TC) {
697 dev_err(&priv->i2c->dev, "%s(): invalid state %d\n",
698 __func__, priv->state);
701 /* Set SLV-T Bank : 0x00 */
702 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x00);
703 /* disable TS output */
704 cxd2841er_write_reg(priv, I2C_SLVT, 0xc3, 0x01);
705 /* enable Hi-Z setting 1 */
706 cxd2841er_write_reg(priv, I2C_SLVT, 0x80, 0x3f);
707 /* enable Hi-Z setting 2 */
708 cxd2841er_write_reg(priv, I2C_SLVT, 0x81, 0xff);
710 /* TODO: Cancel demod parameter */
712 /* Set SLV-X Bank : 0x00 */
713 cxd2841er_write_reg(priv, I2C_SLVX, 0x00, 0x00);
715 cxd2841er_write_reg(priv, I2C_SLVX, 0x18, 0x01);
716 /* Set SLV-T Bank : 0x00 */
717 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x00);
719 cxd2841er_write_reg(priv, I2C_SLVT, 0x43, 0x0a);
721 cxd2841er_write_reg(priv, I2C_SLVT, 0x41, 0x0a);
722 /* Disable ADC clock */
723 cxd2841er_write_reg(priv, I2C_SLVT, 0x30, 0x00);
724 /* Disable RF level monitor */
725 cxd2841er_write_reg(priv, I2C_SLVT, 0x2f, 0x00);
726 /* Disable demod clock */
727 cxd2841er_write_reg(priv, I2C_SLVT, 0x2c, 0x00);
728 priv->state = STATE_SLEEP_TC;
732 static int cxd2841er_shutdown_to_sleep_s(struct cxd2841er_priv *priv)
734 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
735 if (priv->state != STATE_SHUTDOWN) {
736 dev_dbg(&priv->i2c->dev, "%s(): invalid demod state %d\n",
737 __func__, priv->state);
740 /* Set SLV-X Bank : 0x00 */
741 cxd2841er_write_reg(priv, I2C_SLVX, 0x00, 0x00);
742 /* Clear all demodulator registers */
743 cxd2841er_write_reg(priv, I2C_SLVX, 0x02, 0x00);
744 usleep_range(3000, 5000);
745 /* Set SLV-X Bank : 0x00 */
746 cxd2841er_write_reg(priv, I2C_SLVX, 0x00, 0x00);
747 /* Set demod SW reset */
748 cxd2841er_write_reg(priv, I2C_SLVX, 0x10, 0x01);
750 switch (priv->xtal) {
751 case SONY_XTAL_20500:
752 cxd2841er_write_reg(priv, I2C_SLVX, 0x14, 0x00);
754 case SONY_XTAL_24000:
755 /* Select demod frequency */
756 cxd2841er_write_reg(priv, I2C_SLVX, 0x12, 0x00);
757 cxd2841er_write_reg(priv, I2C_SLVX, 0x14, 0x03);
759 case SONY_XTAL_41000:
760 cxd2841er_write_reg(priv, I2C_SLVX, 0x14, 0x01);
763 dev_dbg(&priv->i2c->dev, "%s(): invalid demod xtal %d\n",
764 __func__, priv->xtal);
769 cxd2841er_write_reg(priv, I2C_SLVX, 0x17, 0x0a);
770 /* Clear demod SW reset */
771 cxd2841er_write_reg(priv, I2C_SLVX, 0x10, 0x00);
772 usleep_range(1000, 2000);
773 /* Set SLV-T Bank : 0x00 */
774 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x00);
776 cxd2841er_write_reg(priv, I2C_SLVT, 0x80, 0x1F);
778 cxd2841er_write_reg(priv, I2C_SLVT, 0x9C, 0x40);
780 cxd2841er_write_reg(priv, I2C_SLVT, 0x43, 0x0a);
781 cxd2841er_write_reg(priv, I2C_SLVT, 0x41, 0x0a);
783 cxd2841er_write_reg(priv, I2C_SLVT, 0x63, 0x16);
784 cxd2841er_write_reg(priv, I2C_SLVT, 0x65, 0x27);
785 cxd2841er_write_reg(priv, I2C_SLVT, 0x69, 0x06);
786 priv->state = STATE_SLEEP_S;
790 static int cxd2841er_shutdown_to_sleep_tc(struct cxd2841er_priv *priv)
792 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
793 if (priv->state != STATE_SHUTDOWN) {
794 dev_dbg(&priv->i2c->dev, "%s(): invalid demod state %d\n",
795 __func__, priv->state);
798 /* Set SLV-X Bank : 0x00 */
799 cxd2841er_write_reg(priv, I2C_SLVX, 0x00, 0x00);
800 /* Clear all demodulator registers */
801 cxd2841er_write_reg(priv, I2C_SLVX, 0x02, 0x00);
802 usleep_range(3000, 5000);
803 /* Set SLV-X Bank : 0x00 */
804 cxd2841er_write_reg(priv, I2C_SLVX, 0x00, 0x00);
805 /* Set demod SW reset */
806 cxd2841er_write_reg(priv, I2C_SLVX, 0x10, 0x01);
807 /* Set X'tal clock to 20.5Mhz */
808 cxd2841er_write_reg(priv, I2C_SLVX, 0x13, 0x00);
809 cxd2841er_write_reg(priv, I2C_SLVX, 0x14, 0x00);
810 /* Clear demod SW reset */
811 cxd2841er_write_reg(priv, I2C_SLVX, 0x10, 0x00);
812 usleep_range(1000, 2000);
813 /* Set SLV-T Bank : 0x00 */
814 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x00);
816 cxd2841er_write_reg(priv, I2C_SLVT, 0x43, 0x0a);
817 cxd2841er_write_reg(priv, I2C_SLVT, 0x41, 0x0a);
819 cxd2841er_write_reg(priv, I2C_SLVT, 0x63, 0x16);
820 cxd2841er_write_reg(priv, I2C_SLVT, 0x65, 0x27);
821 cxd2841er_write_reg(priv, I2C_SLVT, 0x69, 0x06);
822 priv->state = STATE_SLEEP_TC;
826 static int cxd2841er_tune_done(struct cxd2841er_priv *priv)
828 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
829 /* Set SLV-T Bank : 0x00 */
830 cxd2841er_write_reg(priv, I2C_SLVT, 0, 0);
832 cxd2841er_write_reg(priv, I2C_SLVT, 0xfe, 0x01);
833 /* Enable TS output */
834 cxd2841er_write_reg(priv, I2C_SLVT, 0xc3, 0x00);
838 /* Set TS parallel mode */
839 static void cxd2841er_set_ts_clock_mode(struct cxd2841er_priv *priv,
842 u8 serial_ts, ts_rate_ctrl_off, ts_in_off;
844 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
845 /* Set SLV-T Bank : 0x00 */
846 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x00);
847 cxd2841er_read_reg(priv, I2C_SLVT, 0xc4, &serial_ts);
848 cxd2841er_read_reg(priv, I2C_SLVT, 0xd3, &ts_rate_ctrl_off);
849 cxd2841er_read_reg(priv, I2C_SLVT, 0xde, &ts_in_off);
850 dev_dbg(&priv->i2c->dev, "%s(): ser_ts=0x%02x rate_ctrl_off=0x%02x in_off=0x%02x\n",
851 __func__, serial_ts, ts_rate_ctrl_off, ts_in_off);
854 * slave Bank Addr Bit default Name
855 * <SLV-T> 00h D9h [7:0] 8'h08 OTSCKPERIOD
857 cxd2841er_write_reg(priv, I2C_SLVT, 0xd9, 0x08);
859 * Disable TS IF Clock
860 * slave Bank Addr Bit default Name
861 * <SLV-T> 00h 32h [0] 1'b1 OREG_CK_TSIF_EN
863 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0x32, 0x00, 0x01);
865 * slave Bank Addr Bit default Name
866 * <SLV-T> 00h 33h [1:0] 2'b01 OREG_CKSEL_TSIF
868 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0x33, 0x00, 0x03);
871 * slave Bank Addr Bit default Name
872 * <SLV-T> 00h 32h [0] 1'b1 OREG_CK_TSIF_EN
874 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0x32, 0x01, 0x01);
876 if (system == SYS_DVBT) {
877 /* Enable parity period for DVB-T */
878 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x10);
879 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0x66, 0x01, 0x01);
880 } else if (system == SYS_DVBC_ANNEX_A) {
881 /* Enable parity period for DVB-C */
882 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x40);
883 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0x66, 0x01, 0x01);
887 static u8 cxd2841er_chip_id(struct cxd2841er_priv *priv)
891 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
892 if (cxd2841er_write_reg(priv, I2C_SLVT, 0, 0) == 0)
893 cxd2841er_read_reg(priv, I2C_SLVT, 0xfd, &chip_id);
894 else if (cxd2841er_write_reg(priv, I2C_SLVX, 0, 0) == 0)
895 cxd2841er_read_reg(priv, I2C_SLVX, 0xfd, &chip_id);
900 static int cxd2841er_read_status_s(struct dvb_frontend *fe,
901 enum fe_status *status)
904 struct cxd2841er_priv *priv = fe->demodulator_priv;
906 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
908 if (priv->state != STATE_ACTIVE_S) {
909 dev_err(&priv->i2c->dev, "%s(): invalid state %d\n",
910 __func__, priv->state);
913 /* Set SLV-T Bank : 0xA0 */
914 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0xa0);
916 * slave Bank Addr Bit Signal name
917 * <SLV-T> A0h 11h [2] ITSLOCK
919 cxd2841er_read_reg(priv, I2C_SLVT, 0x11, ®);
921 *status = FE_HAS_SIGNAL
927 dev_dbg(&priv->i2c->dev, "%s(): result 0x%x\n", __func__, *status);
931 static int cxd2841er_read_status_t_t2(struct cxd2841er_priv *priv,
932 u8 *sync, u8 *tslock, u8 *unlock)
936 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
937 if (priv->state != STATE_ACTIVE_TC)
939 if (priv->system == SYS_DVBT) {
940 /* Set SLV-T Bank : 0x10 */
941 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x10);
943 /* Set SLV-T Bank : 0x20 */
944 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x20);
946 cxd2841er_read_reg(priv, I2C_SLVT, 0x10, &data);
947 if ((data & 0x07) == 0x07) {
948 dev_dbg(&priv->i2c->dev,
949 "%s(): invalid hardware state detected\n", __func__);
954 *sync = ((data & 0x07) == 0x6 ? 1 : 0);
955 *tslock = ((data & 0x20) ? 1 : 0);
956 *unlock = ((data & 0x10) ? 1 : 0);
961 static int cxd2841er_read_status_c(struct cxd2841er_priv *priv, u8 *tslock)
965 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
966 if (priv->state != STATE_ACTIVE_TC)
968 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x40);
969 cxd2841er_read_reg(priv, I2C_SLVT, 0x88, &data);
970 if ((data & 0x01) == 0) {
973 cxd2841er_read_reg(priv, I2C_SLVT, 0x10, &data);
974 *tslock = ((data & 0x20) ? 1 : 0);
979 static int cxd2841er_read_status_i(struct cxd2841er_priv *priv,
980 u8 *sync, u8 *tslock, u8 *unlock)
984 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
985 if (priv->state != STATE_ACTIVE_TC)
987 /* Set SLV-T Bank : 0x60 */
988 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x60);
989 cxd2841er_read_reg(priv, I2C_SLVT, 0x10, &data);
990 dev_dbg(&priv->i2c->dev,
991 "%s(): lock=0x%x\n", __func__, data);
992 *sync = ((data & 0x02) ? 1 : 0);
993 *tslock = ((data & 0x01) ? 1 : 0);
994 *unlock = ((data & 0x10) ? 1 : 0);
998 static int cxd2841er_read_status_tc(struct dvb_frontend *fe,
999 enum fe_status *status)
1005 struct cxd2841er_priv *priv = fe->demodulator_priv;
1008 if (priv->state == STATE_ACTIVE_TC) {
1009 if (priv->system == SYS_DVBT || priv->system == SYS_DVBT2) {
1010 ret = cxd2841er_read_status_t_t2(
1011 priv, &sync, &tslock, &unlock);
1017 *status = FE_HAS_SIGNAL |
1022 *status |= FE_HAS_LOCK;
1023 } else if (priv->system == SYS_ISDBT) {
1024 ret = cxd2841er_read_status_i(
1025 priv, &sync, &tslock, &unlock);
1031 *status = FE_HAS_SIGNAL |
1036 *status |= FE_HAS_LOCK;
1037 } else if (priv->system == SYS_DVBC_ANNEX_A) {
1038 ret = cxd2841er_read_status_c(priv, &tslock);
1042 *status = FE_HAS_SIGNAL |
1050 dev_dbg(&priv->i2c->dev, "%s(): status 0x%x\n", __func__, *status);
1054 static int cxd2841er_get_carrier_offset_s_s2(struct cxd2841er_priv *priv,
1060 s32 temp_div, temp_q, temp_r;
1062 if (priv->state != STATE_ACTIVE_S) {
1063 dev_dbg(&priv->i2c->dev, "%s(): invalid state %d\n",
1064 __func__, priv->state);
1068 * Get High Sampling Rate mode
1069 * slave Bank Addr Bit Signal name
1070 * <SLV-T> A0h 10h [0] ITRL_LOCK
1072 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0xa0);
1073 cxd2841er_read_reg(priv, I2C_SLVT, 0x10, &data[0]);
1074 if (data[0] & 0x01) {
1076 * slave Bank Addr Bit Signal name
1077 * <SLV-T> A0h 50h [4] IHSMODE
1079 cxd2841er_read_reg(priv, I2C_SLVT, 0x50, &data[0]);
1080 is_hs_mode = (data[0] & 0x10 ? 1 : 0);
1082 dev_dbg(&priv->i2c->dev,
1083 "%s(): unable to detect sampling rate mode\n",
1088 * slave Bank Addr Bit Signal name
1089 * <SLV-T> A0h 45h [4:0] ICFRL_CTRLVAL[20:16]
1090 * <SLV-T> A0h 46h [7:0] ICFRL_CTRLVAL[15:8]
1091 * <SLV-T> A0h 47h [7:0] ICFRL_CTRLVAL[7:0]
1093 cxd2841er_read_regs(priv, I2C_SLVT, 0x45, data, 3);
1094 cfrl_ctrlval = sign_extend32((((u32)data[0] & 0x1F) << 16) |
1095 (((u32)data[1] & 0xFF) << 8) |
1096 ((u32)data[2] & 0xFF), 20);
1097 temp_div = (is_hs_mode ? 1048576 : 1572864);
1098 if (cfrl_ctrlval > 0) {
1099 temp_q = div_s64_rem(97375LL * cfrl_ctrlval,
1102 temp_q = div_s64_rem(-97375LL * cfrl_ctrlval,
1105 if (temp_r >= temp_div / 2)
1107 if (cfrl_ctrlval > 0)
1113 static int cxd2841er_get_carrier_offset_i(struct cxd2841er_priv *priv,
1114 u32 bandwidth, int *offset)
1118 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
1119 if (priv->state != STATE_ACTIVE_TC) {
1120 dev_dbg(&priv->i2c->dev, "%s(): invalid state %d\n",
1121 __func__, priv->state);
1124 if (priv->system != SYS_ISDBT) {
1125 dev_dbg(&priv->i2c->dev, "%s(): invalid delivery system %d\n",
1126 __func__, priv->system);
1129 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x60);
1130 cxd2841er_read_regs(priv, I2C_SLVT, 0x4c, data, sizeof(data));
1131 *offset = -1 * sign_extend32(
1132 ((u32)(data[0] & 0x1F) << 24) | ((u32)data[1] << 16) |
1133 ((u32)data[2] << 8) | (u32)data[3], 29);
1135 switch (bandwidth) {
1137 *offset = -1 * ((*offset) * 8/264);
1140 *offset = -1 * ((*offset) * 8/231);
1143 *offset = -1 * ((*offset) * 8/198);
1146 dev_dbg(&priv->i2c->dev, "%s(): invalid bandwidth %d\n",
1147 __func__, bandwidth);
1151 dev_dbg(&priv->i2c->dev, "%s(): bandwidth %d offset %d\n",
1152 __func__, bandwidth, *offset);
1157 static int cxd2841er_get_carrier_offset_t(struct cxd2841er_priv *priv,
1158 u32 bandwidth, int *offset)
1162 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
1163 if (priv->state != STATE_ACTIVE_TC) {
1164 dev_dbg(&priv->i2c->dev, "%s(): invalid state %d\n",
1165 __func__, priv->state);
1168 if (priv->system != SYS_DVBT) {
1169 dev_dbg(&priv->i2c->dev, "%s(): invalid delivery system %d\n",
1170 __func__, priv->system);
1173 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x10);
1174 cxd2841er_read_regs(priv, I2C_SLVT, 0x4c, data, sizeof(data));
1175 *offset = -1 * sign_extend32(
1176 ((u32)(data[0] & 0x1F) << 24) | ((u32)data[1] << 16) |
1177 ((u32)data[2] << 8) | (u32)data[3], 29);
1178 *offset *= (bandwidth / 1000000);
1183 static int cxd2841er_get_carrier_offset_t2(struct cxd2841er_priv *priv,
1184 u32 bandwidth, int *offset)
1188 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
1189 if (priv->state != STATE_ACTIVE_TC) {
1190 dev_dbg(&priv->i2c->dev, "%s(): invalid state %d\n",
1191 __func__, priv->state);
1194 if (priv->system != SYS_DVBT2) {
1195 dev_dbg(&priv->i2c->dev, "%s(): invalid delivery system %d\n",
1196 __func__, priv->system);
1199 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x20);
1200 cxd2841er_read_regs(priv, I2C_SLVT, 0x4c, data, sizeof(data));
1201 *offset = -1 * sign_extend32(
1202 ((u32)(data[0] & 0x0F) << 24) | ((u32)data[1] << 16) |
1203 ((u32)data[2] << 8) | (u32)data[3], 27);
1204 switch (bandwidth) {
1212 *offset *= (bandwidth / 1000000);
1216 dev_dbg(&priv->i2c->dev, "%s(): invalid bandwidth %d\n",
1217 __func__, bandwidth);
1223 static int cxd2841er_get_carrier_offset_c(struct cxd2841er_priv *priv,
1228 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
1229 if (priv->state != STATE_ACTIVE_TC) {
1230 dev_dbg(&priv->i2c->dev, "%s(): invalid state %d\n",
1231 __func__, priv->state);
1234 if (priv->system != SYS_DVBC_ANNEX_A) {
1235 dev_dbg(&priv->i2c->dev, "%s(): invalid delivery system %d\n",
1236 __func__, priv->system);
1239 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x40);
1240 cxd2841er_read_regs(priv, I2C_SLVT, 0x15, data, sizeof(data));
1241 *offset = div_s64(41000LL * sign_extend32((((u32)data[0] & 0x3f) << 8)
1242 | (u32)data[1], 13), 16384);
1246 static int cxd2841er_read_packet_errors_t(
1247 struct cxd2841er_priv *priv, u32 *penum)
1252 if (priv->state != STATE_ACTIVE_TC) {
1253 dev_dbg(&priv->i2c->dev, "%s(): invalid state %d\n",
1254 __func__, priv->state);
1257 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x10);
1258 cxd2841er_read_regs(priv, I2C_SLVT, 0xea, data, sizeof(data));
1260 *penum = ((u32)data[0] << 8) | (u32)data[1];
1264 static int cxd2841er_read_packet_errors_t2(
1265 struct cxd2841er_priv *priv, u32 *penum)
1270 if (priv->state != STATE_ACTIVE_TC) {
1271 dev_dbg(&priv->i2c->dev, "%s(): invalid state %d\n",
1272 __func__, priv->state);
1275 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x24);
1276 cxd2841er_read_regs(priv, I2C_SLVT, 0xfd, data, sizeof(data));
1278 *penum = ((u32)data[1] << 8) | (u32)data[2];
1282 static int cxd2841er_read_packet_errors_i(
1283 struct cxd2841er_priv *priv, u32 *penum)
1288 if (priv->state != STATE_ACTIVE_TC) {
1289 dev_dbg(&priv->i2c->dev, "%s(): invalid state %d\n",
1290 __func__, priv->state);
1293 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x60);
1294 cxd2841er_read_regs(priv, I2C_SLVT, 0xA1, data, 1);
1296 if (!(data[0] & 0x01))
1300 cxd2841er_read_regs(priv, I2C_SLVT, 0xA2, data, sizeof(data));
1301 *penum = ((u32)data[0] << 8) | (u32)data[1];
1304 cxd2841er_read_regs(priv, I2C_SLVT, 0xA4, data, sizeof(data));
1305 *penum += ((u32)data[0] << 8) | (u32)data[1];
1308 cxd2841er_read_regs(priv, I2C_SLVT, 0xA6, data, sizeof(data));
1309 *penum += ((u32)data[0] << 8) | (u32)data[1];
1314 static u32 cxd2841er_mon_read_ber_s(struct cxd2841er_priv *priv)
1317 u32 bit_error, bit_count;
1320 /* Set SLV-T Bank : 0xA0 */
1321 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0xa0);
1323 * slave Bank Addr Bit Signal name
1324 * <SLV-T> A0h 35h [0] IFVBER_VALID
1325 * <SLV-T> A0h 36h [5:0] IFVBER_BITERR[21:16]
1326 * <SLV-T> A0h 37h [7:0] IFVBER_BITERR[15:8]
1327 * <SLV-T> A0h 38h [7:0] IFVBER_BITERR[7:0]
1328 * <SLV-T> A0h 3Dh [5:0] IFVBER_BITNUM[21:16]
1329 * <SLV-T> A0h 3Eh [7:0] IFVBER_BITNUM[15:8]
1330 * <SLV-T> A0h 3Fh [7:0] IFVBER_BITNUM[7:0]
1332 cxd2841er_read_regs(priv, I2C_SLVT, 0x35, data, 11);
1333 if (data[0] & 0x01) {
1334 bit_error = ((u32)(data[1] & 0x3F) << 16) |
1335 ((u32)(data[2] & 0xFF) << 8) |
1336 (u32)(data[3] & 0xFF);
1337 bit_count = ((u32)(data[8] & 0x3F) << 16) |
1338 ((u32)(data[9] & 0xFF) << 8) |
1339 (u32)(data[10] & 0xFF);
1341 * BER = bitError / bitCount
1342 * = (bitError * 10^7) / bitCount
1343 * = ((bitError * 625 * 125 * 128) / bitCount
1345 if ((bit_count == 0) || (bit_error > bit_count)) {
1346 dev_dbg(&priv->i2c->dev,
1347 "%s(): invalid bit_error %d, bit_count %d\n",
1348 __func__, bit_error, bit_count);
1351 temp_q = div_u64_rem(10000000ULL * bit_error,
1352 bit_count, &temp_r);
1353 if (bit_count != 1 && temp_r >= bit_count / 2)
1357 dev_dbg(&priv->i2c->dev, "%s(): no data available\n", __func__);
1362 static u32 cxd2841er_mon_read_ber_s2(struct cxd2841er_priv *priv)
1365 u32 bit_error, period;
1369 /* Set SLV-T Bank : 0xB2 */
1370 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0xb2);
1372 * slave Bank Addr Bit Signal name
1373 * <SLV-T> B2h 30h [0] IFLBER_VALID
1374 * <SLV-T> B2h 31h [3:0] IFLBER_BITERR[27:24]
1375 * <SLV-T> B2h 32h [7:0] IFLBER_BITERR[23:16]
1376 * <SLV-T> B2h 33h [7:0] IFLBER_BITERR[15:8]
1377 * <SLV-T> B2h 34h [7:0] IFLBER_BITERR[7:0]
1379 cxd2841er_read_regs(priv, I2C_SLVT, 0x30, data, 5);
1380 if (data[0] & 0x01) {
1381 /* Bit error count */
1382 bit_error = ((u32)(data[1] & 0x0F) << 24) |
1383 ((u32)(data[2] & 0xFF) << 16) |
1384 ((u32)(data[3] & 0xFF) << 8) |
1385 (u32)(data[4] & 0xFF);
1387 /* Set SLV-T Bank : 0xA0 */
1388 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0xa0);
1389 cxd2841er_read_reg(priv, I2C_SLVT, 0x7a, data);
1390 /* Measurement period */
1391 period = (u32)(1 << (data[0] & 0x0F));
1393 dev_dbg(&priv->i2c->dev,
1394 "%s(): period is 0\n", __func__);
1397 if (bit_error > (period * 64800)) {
1398 dev_dbg(&priv->i2c->dev,
1399 "%s(): invalid bit_err 0x%x period 0x%x\n",
1400 __func__, bit_error, period);
1404 * BER = bitError / (period * 64800)
1405 * = (bitError * 10^7) / (period * 64800)
1406 * = (bitError * 10^5) / (period * 648)
1407 * = (bitError * 12500) / (period * 81)
1408 * = (bitError * 10) * 1250 / (period * 81)
1410 temp_q = div_u64_rem(12500ULL * bit_error,
1411 period * 81, &temp_r);
1412 if (temp_r >= period * 40)
1416 dev_dbg(&priv->i2c->dev,
1417 "%s(): no data available\n", __func__);
1422 static int cxd2841er_read_ber_t2(struct cxd2841er_priv *priv, u32 *ber)
1426 u32 bit_err, period_exp, n_ldpc;
1429 if (priv->state != STATE_ACTIVE_TC) {
1430 dev_dbg(&priv->i2c->dev,
1431 "%s(): invalid state %d\n", __func__, priv->state);
1434 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x20);
1435 cxd2841er_read_regs(priv, I2C_SLVT, 0x39, data, sizeof(data));
1436 if (!(data[0] & 0x10)) {
1437 dev_dbg(&priv->i2c->dev,
1438 "%s(): no valid BER data\n", __func__);
1441 bit_err = ((u32)(data[0] & 0x0f) << 24) |
1442 ((u32)data[1] << 16) |
1443 ((u32)data[2] << 8) |
1445 cxd2841er_read_reg(priv, I2C_SLVT, 0x6f, data);
1446 period_exp = data[0] & 0x0f;
1447 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x22);
1448 cxd2841er_read_reg(priv, I2C_SLVT, 0x5e, data);
1449 n_ldpc = ((data[0] & 0x03) == 0 ? 16200 : 64800);
1450 if (bit_err > ((1U << period_exp) * n_ldpc)) {
1451 dev_dbg(&priv->i2c->dev,
1452 "%s(): invalid BER value\n", __func__);
1455 if (period_exp >= 4) {
1456 div = (1U << (period_exp - 4)) * (n_ldpc / 200);
1457 q = div_u64_rem(3125ULL * bit_err, div, &r);
1459 div = (1U << period_exp) * (n_ldpc / 200);
1460 q = div_u64_rem(50000ULL * bit_err, div, &r);
1462 *ber = (r >= div / 2) ? q + 1 : q;
1466 static int cxd2841er_read_ber_t(struct cxd2841er_priv *priv, u32 *ber)
1470 u32 bit_err, period;
1473 if (priv->state != STATE_ACTIVE_TC) {
1474 dev_dbg(&priv->i2c->dev,
1475 "%s(): invalid state %d\n", __func__, priv->state);
1478 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x10);
1479 cxd2841er_read_reg(priv, I2C_SLVT, 0x39, data);
1480 if (!(data[0] & 0x01)) {
1481 dev_dbg(&priv->i2c->dev,
1482 "%s(): no valid BER data\n", __func__);
1485 cxd2841er_read_regs(priv, I2C_SLVT, 0x22, data, sizeof(data));
1486 bit_err = ((u32)data[0] << 8) | (u32)data[1];
1487 cxd2841er_read_reg(priv, I2C_SLVT, 0x6f, data);
1488 period = ((data[0] & 0x07) == 0) ? 256 : (4096 << (data[0] & 0x07));
1490 q = div_u64_rem(78125ULL * bit_err, div, &r);
1491 *ber = (r >= div / 2) ? q + 1 : q;
1495 static u32 cxd2841er_dvbs_read_snr(struct cxd2841er_priv *priv, u8 delsys)
1499 int min_index, max_index, index;
1500 static const struct cxd2841er_cnr_data *cn_data;
1502 /* Set SLV-T Bank : 0xA1 */
1503 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0xa1);
1505 * slave Bank Addr Bit Signal name
1506 * <SLV-T> A1h 10h [0] ICPM_QUICKRDY
1507 * <SLV-T> A1h 11h [4:0] ICPM_QUICKCNDT[12:8]
1508 * <SLV-T> A1h 12h [7:0] ICPM_QUICKCNDT[7:0]
1510 cxd2841er_read_regs(priv, I2C_SLVT, 0x10, data, 3);
1511 if (data[0] & 0x01) {
1512 value = ((u32)(data[1] & 0x1F) << 8) | (u32)(data[2] & 0xFF);
1514 if (delsys == SYS_DVBS) {
1515 cn_data = s_cn_data;
1516 max_index = sizeof(s_cn_data) /
1517 sizeof(s_cn_data[0]) - 1;
1519 cn_data = s2_cn_data;
1520 max_index = sizeof(s2_cn_data) /
1521 sizeof(s2_cn_data[0]) - 1;
1523 if (value >= cn_data[min_index].value) {
1524 res = cn_data[min_index].cnr_x1000;
1527 if (value <= cn_data[max_index].value) {
1528 res = cn_data[max_index].cnr_x1000;
1531 while ((max_index - min_index) > 1) {
1532 index = (max_index + min_index) / 2;
1533 if (value == cn_data[index].value) {
1534 res = cn_data[index].cnr_x1000;
1536 } else if (value > cn_data[index].value)
1540 if ((max_index - min_index) <= 1) {
1541 if (value == cn_data[max_index].value) {
1542 res = cn_data[max_index].cnr_x1000;
1545 res = cn_data[min_index].cnr_x1000;
1551 dev_dbg(&priv->i2c->dev,
1552 "%s(): no data available\n", __func__);
1558 static int cxd2841er_read_snr_t(struct cxd2841er_priv *priv, u32 *snr)
1564 if (priv->state != STATE_ACTIVE_TC) {
1565 dev_dbg(&priv->i2c->dev,
1566 "%s(): invalid state %d\n", __func__, priv->state);
1569 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x10);
1570 cxd2841er_read_regs(priv, I2C_SLVT, 0x28, data, sizeof(data));
1571 reg = ((u32)data[0] << 8) | (u32)data[1];
1573 dev_dbg(&priv->i2c->dev,
1574 "%s(): reg value out of range\n", __func__);
1579 *snr = 10000 * ((intlog10(reg) - intlog10(5350 - reg)) >> 24) + 28500;
1583 static int cxd2841er_read_snr_t2(struct cxd2841er_priv *priv, u32 *snr)
1589 if (priv->state != STATE_ACTIVE_TC) {
1590 dev_dbg(&priv->i2c->dev,
1591 "%s(): invalid state %d\n", __func__, priv->state);
1594 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x20);
1595 cxd2841er_read_regs(priv, I2C_SLVT, 0x28, data, sizeof(data));
1596 reg = ((u32)data[0] << 8) | (u32)data[1];
1598 dev_dbg(&priv->i2c->dev,
1599 "%s(): reg value out of range\n", __func__);
1604 *snr = 10000 * ((intlog10(reg) -
1605 intlog10(12600 - reg)) >> 24) + 32000;
1609 static int cxd2841er_read_snr_i(struct cxd2841er_priv *priv, u32 *snr)
1615 if (priv->state != STATE_ACTIVE_TC) {
1616 dev_dbg(&priv->i2c->dev,
1617 "%s(): invalid state %d\n", __func__,
1622 /* Freeze all registers */
1623 cxd2841er_write_reg(priv, I2C_SLVT, 0x01, 0x01);
1626 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x60);
1627 cxd2841er_read_regs(priv, I2C_SLVT, 0x28, data, sizeof(data));
1628 reg = ((u32)data[0] << 8) | (u32)data[1];
1630 dev_dbg(&priv->i2c->dev,
1631 "%s(): reg value out of range\n", __func__);
1636 *snr = 100 * intlog10(reg) - 9031;
1640 static u16 cxd2841er_read_agc_gain_t_t2(struct cxd2841er_priv *priv,
1645 cxd2841er_write_reg(
1646 priv, I2C_SLVT, 0x00, (delsys == SYS_DVBT ? 0x10 : 0x20));
1647 cxd2841er_read_regs(priv, I2C_SLVT, 0x26, data, 2);
1648 dev_dbg(&priv->i2c->dev,
1649 "%s(): AGC value=%u\n",
1650 __func__, (((u16)data[0] & 0x0F) << 8) |
1651 (u16)(data[1] & 0xFF));
1652 return ((((u16)data[0] & 0x0F) << 8) | (u16)(data[1] & 0xFF)) << 4;
1655 static u16 cxd2841er_read_agc_gain_i(struct cxd2841er_priv *priv,
1660 cxd2841er_write_reg(
1661 priv, I2C_SLVT, 0x00, 0x60);
1662 cxd2841er_read_regs(priv, I2C_SLVT, 0x26, data, 2);
1664 dev_dbg(&priv->i2c->dev,
1665 "%s(): AGC value=%u\n",
1666 __func__, (((u16)data[0] & 0x0F) << 8) |
1667 (u16)(data[1] & 0xFF));
1668 return ((((u16)data[0] & 0x0F) << 8) | (u16)(data[1] & 0xFF)) << 4;
1671 static u16 cxd2841er_read_agc_gain_s(struct cxd2841er_priv *priv)
1675 /* Set SLV-T Bank : 0xA0 */
1676 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0xa0);
1678 * slave Bank Addr Bit Signal name
1679 * <SLV-T> A0h 1Fh [4:0] IRFAGC_GAIN[12:8]
1680 * <SLV-T> A0h 20h [7:0] IRFAGC_GAIN[7:0]
1682 cxd2841er_read_regs(priv, I2C_SLVT, 0x1f, data, 2);
1683 return ((((u16)data[0] & 0x1F) << 8) | (u16)(data[1] & 0xFF)) << 3;
1686 static int cxd2841er_read_ber(struct dvb_frontend *fe, u32 *ber)
1688 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
1689 struct cxd2841er_priv *priv = fe->demodulator_priv;
1691 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
1693 switch (p->delivery_system) {
1695 *ber = cxd2841er_mon_read_ber_s(priv);
1698 *ber = cxd2841er_mon_read_ber_s2(priv);
1701 return cxd2841er_read_ber_t(priv, ber);
1703 return cxd2841er_read_ber_t2(priv, ber);
1711 static int cxd2841er_read_signal_strength(struct dvb_frontend *fe,
1714 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
1715 struct cxd2841er_priv *priv = fe->demodulator_priv;
1717 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
1718 switch (p->delivery_system) {
1721 *strength = 65535 - cxd2841er_read_agc_gain_t_t2(
1722 priv, p->delivery_system);
1725 *strength = 65535 - cxd2841er_read_agc_gain_i(
1726 priv, p->delivery_system);
1730 *strength = 65535 - cxd2841er_read_agc_gain_s(priv);
1739 static int cxd2841er_read_snr(struct dvb_frontend *fe, u16 *snr)
1742 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
1743 struct cxd2841er_priv *priv = fe->demodulator_priv;
1745 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
1746 switch (p->delivery_system) {
1748 cxd2841er_read_snr_t(priv, &tmp);
1751 cxd2841er_read_snr_t2(priv, &tmp);
1754 cxd2841er_read_snr_i(priv, &tmp);
1758 tmp = cxd2841er_dvbs_read_snr(priv, p->delivery_system);
1761 dev_dbg(&priv->i2c->dev, "%s(): unknown delivery system %d\n",
1762 __func__, p->delivery_system);
1765 *snr = tmp & 0xffff;
1769 static int cxd2841er_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
1771 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
1772 struct cxd2841er_priv *priv = fe->demodulator_priv;
1774 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
1775 switch (p->delivery_system) {
1777 cxd2841er_read_packet_errors_t(priv, ucblocks);
1780 cxd2841er_read_packet_errors_t2(priv, ucblocks);
1783 cxd2841er_read_packet_errors_i(priv, ucblocks);
1789 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
1793 static int cxd2841er_dvbt2_set_profile(
1794 struct cxd2841er_priv *priv, enum cxd2841er_dvbt2_profile_t profile)
1799 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
1801 case DVBT2_PROFILE_BASE:
1803 seq_not2d_time = 12;
1805 case DVBT2_PROFILE_LITE:
1807 seq_not2d_time = 40;
1809 case DVBT2_PROFILE_ANY:
1811 seq_not2d_time = 40;
1816 /* Set SLV-T Bank : 0x2E */
1817 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x2e);
1818 /* Set profile and tune mode */
1819 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0x10, tune_mode, 0x07);
1820 /* Set SLV-T Bank : 0x2B */
1821 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x2b);
1822 /* Set early unlock detection time */
1823 cxd2841er_write_reg(priv, I2C_SLVT, 0x9d, seq_not2d_time);
1827 static int cxd2841er_dvbt2_set_plp_config(struct cxd2841er_priv *priv,
1828 u8 is_auto, u8 plp_id)
1831 dev_dbg(&priv->i2c->dev,
1832 "%s() using auto PLP selection\n", __func__);
1834 dev_dbg(&priv->i2c->dev,
1835 "%s() using manual PLP selection, ID %d\n",
1838 /* Set SLV-T Bank : 0x23 */
1839 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x23);
1841 /* Manual PLP selection mode. Set the data PLP Id. */
1842 cxd2841er_write_reg(priv, I2C_SLVT, 0xaf, plp_id);
1844 /* Auto PLP select (Scanning mode = 0x00). Data PLP select = 0x01. */
1845 cxd2841er_write_reg(priv, I2C_SLVT, 0xad, (is_auto ? 0x00 : 0x01));
1849 static int cxd2841er_sleep_tc_to_active_t2_band(struct cxd2841er_priv *priv,
1858 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
1859 switch (bandwidth) {
1861 /* bank 0x20, reg 0x9f */
1867 /* bank 0x10, reg 0xa6 */
1882 iffreq = MAKE_IFFREQ_CONFIG(4.80);
1886 /* bank 0x20, reg 0x9f */
1892 /* bank 0x10, reg 0xa6 */
1907 iffreq = MAKE_IFFREQ_CONFIG(4.2);
1911 /* bank 0x20, reg 0x9f */
1917 /* bank 0x10, reg 0xa6 */
1932 iffreq = MAKE_IFFREQ_CONFIG(3.6);
1936 /* bank 0x20, reg 0x9f */
1942 /* bank 0x10, reg 0xa6 */
1957 iffreq = MAKE_IFFREQ_CONFIG(3.6);
1961 /* bank 0x20, reg 0x9f */
1967 /* bank 0x10, reg 0xa6 */
1982 iffreq = MAKE_IFFREQ_CONFIG(3.5);
1988 /* Set SLV-T Bank : 0x20 */
1989 cxd2841er_write_reg(priv, I2C_SLVX, 0x00, 0x20);
1990 cxd2841er_write_regs(priv, I2C_SLVT, 0x9f, b20_9f, sizeof(b20_9f));
1991 /* Set SLV-T Bank : 0x27 */
1992 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x27);
1993 cxd2841er_set_reg_bits(
1994 priv, I2C_SLVT, 0x7a,
1995 (bandwidth == 1712000 ? 0x03 : 0x00), 0x0f);
1996 /* Set SLV-T Bank : 0x10 */
1997 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x10);
1998 /* Group delay equaliser sett. for ASCOT2E */
1999 cxd2841er_write_regs(priv, I2C_SLVT, 0xa6, b10_a6, sizeof(b10_a6));
2000 /* <IF freq setting> */
2001 b10_b6[0] = (u8) ((iffreq >> 16) & 0xff);
2002 b10_b6[1] = (u8)((iffreq >> 8) & 0xff);
2003 b10_b6[2] = (u8)(iffreq & 0xff);
2004 cxd2841er_write_regs(priv, I2C_SLVT, 0xb6, b10_b6, sizeof(b10_b6));
2005 /* System bandwidth setting */
2006 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xd7, b10_d7, 0x07);
2010 static int cxd2841er_sleep_tc_to_active_t_band(
2011 struct cxd2841er_priv *priv, u32 bandwidth)
2013 u8 data[MAX_WRITE_REGSIZE];
2015 u8 nominalRate8bw[3][5] = {
2016 /* TRCG Nominal Rate [37:0] */
2017 {0x11, 0xF0, 0x00, 0x00, 0x00}, /* 20.5MHz XTal */
2018 {0x15, 0x00, 0x00, 0x00, 0x00}, /* 24MHz XTal */
2019 {0x11, 0xF0, 0x00, 0x00, 0x00} /* 41MHz XTal */
2021 u8 nominalRate7bw[3][5] = {
2022 /* TRCG Nominal Rate [37:0] */
2023 {0x14, 0x80, 0x00, 0x00, 0x00}, /* 20.5MHz XTal */
2024 {0x18, 0x00, 0x00, 0x00, 0x00}, /* 24MHz XTal */
2025 {0x14, 0x80, 0x00, 0x00, 0x00} /* 41MHz XTal */
2027 u8 nominalRate6bw[3][5] = {
2028 /* TRCG Nominal Rate [37:0] */
2029 {0x17, 0xEA, 0xAA, 0xAA, 0xAA}, /* 20.5MHz XTal */
2030 {0x1C, 0x00, 0x00, 0x00, 0x00}, /* 24MHz XTal */
2031 {0x17, 0xEA, 0xAA, 0xAA, 0xAA} /* 41MHz XTal */
2033 u8 nominalRate5bw[3][5] = {
2034 /* TRCG Nominal Rate [37:0] */
2035 {0x1C, 0xB3, 0x33, 0x33, 0x33}, /* 20.5MHz XTal */
2036 {0x21, 0x99, 0x99, 0x99, 0x99}, /* 24MHz XTal */
2037 {0x1C, 0xB3, 0x33, 0x33, 0x33} /* 41MHz XTal */
2040 u8 itbCoef8bw[3][14] = {
2041 {0x26, 0xAF, 0x06, 0xCD, 0x13, 0xBB, 0x28, 0xBA, 0x23, 0xA9,
2042 0x1F, 0xA8, 0x2C, 0xC8}, /* 20.5MHz XTal */
2043 {0x2F, 0xBA, 0x28, 0x9B, 0x28, 0x9D, 0x28, 0xA1, 0x29, 0xA5,
2044 0x2A, 0xAC, 0x29, 0xB5}, /* 24MHz XTal */
2045 {0x26, 0xAF, 0x06, 0xCD, 0x13, 0xBB, 0x28, 0xBA, 0x23, 0xA9,
2046 0x1F, 0xA8, 0x2C, 0xC8} /* 41MHz XTal */
2048 u8 itbCoef7bw[3][14] = {
2049 {0x2C, 0xBD, 0x02, 0xCF, 0x04, 0xF8, 0x23, 0xA6, 0x29, 0xB0,
2050 0x26, 0xA9, 0x21, 0xA5}, /* 20.5MHz XTal */
2051 {0x30, 0xB1, 0x29, 0x9A, 0x28, 0x9C, 0x28, 0xA0, 0x29, 0xA2,
2052 0x2B, 0xA6, 0x2B, 0xAD}, /* 24MHz XTal */
2053 {0x2C, 0xBD, 0x02, 0xCF, 0x04, 0xF8, 0x23, 0xA6, 0x29, 0xB0,
2054 0x26, 0xA9, 0x21, 0xA5} /* 41MHz XTal */
2056 u8 itbCoef6bw[3][14] = {
2057 {0x27, 0xA7, 0x28, 0xB3, 0x02, 0xF0, 0x01, 0xE8, 0x00, 0xCF,
2058 0x00, 0xE6, 0x23, 0xA4}, /* 20.5MHz XTal */
2059 {0x31, 0xA8, 0x29, 0x9B, 0x27, 0x9C, 0x28, 0x9E, 0x29, 0xA4,
2060 0x29, 0xA2, 0x29, 0xA8}, /* 24MHz XTal */
2061 {0x27, 0xA7, 0x28, 0xB3, 0x02, 0xF0, 0x01, 0xE8, 0x00, 0xCF,
2062 0x00, 0xE6, 0x23, 0xA4} /* 41MHz XTal */
2064 u8 itbCoef5bw[3][14] = {
2065 {0x27, 0xA7, 0x28, 0xB3, 0x02, 0xF0, 0x01, 0xE8, 0x00, 0xCF,
2066 0x00, 0xE6, 0x23, 0xA4}, /* 20.5MHz XTal */
2067 {0x31, 0xA8, 0x29, 0x9B, 0x27, 0x9C, 0x28, 0x9E, 0x29, 0xA4,
2068 0x29, 0xA2, 0x29, 0xA8}, /* 24MHz XTal */
2069 {0x27, 0xA7, 0x28, 0xB3, 0x02, 0xF0, 0x01, 0xE8, 0x00, 0xCF,
2070 0x00, 0xE6, 0x23, 0xA4} /* 41MHz XTal */
2073 /* Set SLV-T Bank : 0x13 */
2074 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x13);
2075 /* Echo performance optimization setting */
2078 cxd2841er_write_regs(priv, I2C_SLVT, 0x9C, data, 2);
2080 /* Set SLV-T Bank : 0x10 */
2081 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x10);
2083 switch (bandwidth) {
2085 /* <Timing Recovery setting> */
2086 cxd2841er_write_regs(priv, I2C_SLVT,
2087 0x9F, nominalRate8bw[priv->xtal], 5);
2088 /* Group delay equaliser settings for
2089 * ASCOT2D, ASCOT2E and ASCOT3 tuners
2091 cxd2841er_write_regs(priv, I2C_SLVT,
2092 0xA6, itbCoef8bw[priv->xtal], 14);
2093 /* <IF freq setting> */
2094 iffreq = MAKE_IFFREQ_CONFIG_XTAL(priv->xtal, 4.80);
2095 data[0] = (u8) ((iffreq >> 16) & 0xff);
2096 data[1] = (u8)((iffreq >> 8) & 0xff);
2097 data[2] = (u8)(iffreq & 0xff);
2098 cxd2841er_write_regs(priv, I2C_SLVT, 0xB6, data, 3);
2099 /* System bandwidth setting */
2100 cxd2841er_set_reg_bits(
2101 priv, I2C_SLVT, 0xD7, 0x00, 0x07);
2103 /* Demod core latency setting */
2104 if (priv->xtal == SONY_XTAL_24000) {
2111 cxd2841er_write_regs(priv, I2C_SLVT, 0xD9, data, 2);
2113 /* Notch filter setting */
2116 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x17);
2117 cxd2841er_write_regs(priv, I2C_SLVT, 0x38, data, 2);
2120 /* <Timing Recovery setting> */
2121 cxd2841er_write_regs(priv, I2C_SLVT,
2122 0x9F, nominalRate7bw[priv->xtal], 5);
2123 /* Group delay equaliser settings for
2124 * ASCOT2D, ASCOT2E and ASCOT3 tuners
2126 cxd2841er_write_regs(priv, I2C_SLVT,
2127 0xA6, itbCoef7bw[priv->xtal], 14);
2128 /* <IF freq setting> */
2129 iffreq = MAKE_IFFREQ_CONFIG_XTAL(priv->xtal, 4.20);
2130 data[0] = (u8) ((iffreq >> 16) & 0xff);
2131 data[1] = (u8)((iffreq >> 8) & 0xff);
2132 data[2] = (u8)(iffreq & 0xff);
2133 cxd2841er_write_regs(priv, I2C_SLVT, 0xB6, data, 3);
2134 /* System bandwidth setting */
2135 cxd2841er_set_reg_bits(
2136 priv, I2C_SLVT, 0xD7, 0x02, 0x07);
2138 /* Demod core latency setting */
2139 if (priv->xtal == SONY_XTAL_24000) {
2146 cxd2841er_write_regs(priv, I2C_SLVT, 0xD9, data, 2);
2148 /* Notch filter setting */
2151 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x17);
2152 cxd2841er_write_regs(priv, I2C_SLVT, 0x38, data, 2);
2155 /* <Timing Recovery setting> */
2156 cxd2841er_write_regs(priv, I2C_SLVT,
2157 0x9F, nominalRate6bw[priv->xtal], 5);
2158 /* Group delay equaliser settings for
2159 * ASCOT2D, ASCOT2E and ASCOT3 tuners
2161 cxd2841er_write_regs(priv, I2C_SLVT,
2162 0xA6, itbCoef6bw[priv->xtal], 14);
2163 /* <IF freq setting> */
2164 iffreq = MAKE_IFFREQ_CONFIG_XTAL(priv->xtal, 3.60);
2165 data[0] = (u8) ((iffreq >> 16) & 0xff);
2166 data[1] = (u8)((iffreq >> 8) & 0xff);
2167 data[2] = (u8)(iffreq & 0xff);
2168 cxd2841er_write_regs(priv, I2C_SLVT, 0xB6, data, 3);
2169 /* System bandwidth setting */
2170 cxd2841er_set_reg_bits(
2171 priv, I2C_SLVT, 0xD7, 0x04, 0x07);
2173 /* Demod core latency setting */
2174 if (priv->xtal == SONY_XTAL_24000) {
2181 cxd2841er_write_regs(priv, I2C_SLVT, 0xD9, data, 2);
2183 /* Notch filter setting */
2186 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x17);
2187 cxd2841er_write_regs(priv, I2C_SLVT, 0x38, data, 2);
2190 /* <Timing Recovery setting> */
2191 cxd2841er_write_regs(priv, I2C_SLVT,
2192 0x9F, nominalRate5bw[priv->xtal], 5);
2193 /* Group delay equaliser settings for
2194 * ASCOT2D, ASCOT2E and ASCOT3 tuners
2196 cxd2841er_write_regs(priv, I2C_SLVT,
2197 0xA6, itbCoef5bw[priv->xtal], 14);
2198 /* <IF freq setting> */
2199 iffreq = MAKE_IFFREQ_CONFIG_XTAL(priv->xtal, 3.60);
2200 data[0] = (u8) ((iffreq >> 16) & 0xff);
2201 data[1] = (u8)((iffreq >> 8) & 0xff);
2202 data[2] = (u8)(iffreq & 0xff);
2203 cxd2841er_write_regs(priv, I2C_SLVT, 0xB6, data, 3);
2204 /* System bandwidth setting */
2205 cxd2841er_set_reg_bits(
2206 priv, I2C_SLVT, 0xD7, 0x06, 0x07);
2208 /* Demod core latency setting */
2209 if (priv->xtal == SONY_XTAL_24000) {
2216 cxd2841er_write_regs(priv, I2C_SLVT, 0xD9, data, 2);
2218 /* Notch filter setting */
2221 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x17);
2222 cxd2841er_write_regs(priv, I2C_SLVT, 0x38, data, 2);
2229 static int cxd2841er_sleep_tc_to_active_i_band(
2230 struct cxd2841er_priv *priv, u32 bandwidth)
2235 /* TRCG Nominal Rate */
2236 u8 nominalRate8bw[3][5] = {
2237 {0x00, 0x00, 0x00, 0x00, 0x00}, /* 20.5MHz XTal */
2238 {0x11, 0xB8, 0x00, 0x00, 0x00}, /* 24MHz XTal */
2239 {0x00, 0x00, 0x00, 0x00, 0x00} /* 41MHz XTal */
2242 u8 nominalRate7bw[3][5] = {
2243 {0x00, 0x00, 0x00, 0x00, 0x00}, /* 20.5MHz XTal */
2244 {0x14, 0x40, 0x00, 0x00, 0x00}, /* 24MHz XTal */
2245 {0x00, 0x00, 0x00, 0x00, 0x00} /* 41MHz XTal */
2248 u8 nominalRate6bw[3][5] = {
2249 {0x14, 0x2E, 0x00, 0x00, 0x00}, /* 20.5MHz XTal */
2250 {0x17, 0xA0, 0x00, 0x00, 0x00}, /* 24MHz XTal */
2251 {0x14, 0x2E, 0x00, 0x00, 0x00} /* 41MHz XTal */
2254 u8 itbCoef8bw[3][14] = {
2255 {0x00}, /* 20.5MHz XTal */
2256 {0x2F, 0xBA, 0x28, 0x9B, 0x28, 0x9D, 0x28, 0xA1, 0x29,
2257 0xA5, 0x2A, 0xAC, 0x29, 0xB5}, /* 24MHz Xtal */
2258 {0x0}, /* 41MHz XTal */
2261 u8 itbCoef7bw[3][14] = {
2262 {0x00}, /* 20.5MHz XTal */
2263 {0x30, 0xB1, 0x29, 0x9A, 0x28, 0x9C, 0x28, 0xA0, 0x29,
2264 0xA2, 0x2B, 0xA6, 0x2B, 0xAD}, /* 24MHz Xtal */
2265 {0x00}, /* 41MHz XTal */
2268 u8 itbCoef6bw[3][14] = {
2269 {0x27, 0xA7, 0x28, 0xB3, 0x02, 0xF0, 0x01, 0xE8, 0x00,
2270 0xCF, 0x00, 0xE6, 0x23, 0xA4}, /* 20.5MHz XTal */
2271 {0x31, 0xA8, 0x29, 0x9B, 0x27, 0x9C, 0x28, 0x9E, 0x29,
2272 0xA4, 0x29, 0xA2, 0x29, 0xA8}, /* 24MHz Xtal */
2273 {0x27, 0xA7, 0x28, 0xB3, 0x02, 0xF0, 0x01, 0xE8, 0x00,
2274 0xCF, 0x00, 0xE6, 0x23, 0xA4}, /* 41MHz XTal */
2277 dev_dbg(&priv->i2c->dev, "%s() bandwidth=%u\n", __func__, bandwidth);
2278 /* Set SLV-T Bank : 0x10 */
2279 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x10);
2281 /* 20.5/41MHz Xtal support is not available
2282 * on ISDB-T 7MHzBW and 8MHzBW
2284 if (priv->xtal != SONY_XTAL_24000 && bandwidth > 6000000) {
2285 dev_err(&priv->i2c->dev,
2286 "%s(): bandwidth %d supported only for 24MHz xtal\n",
2287 __func__, bandwidth);
2291 switch (bandwidth) {
2293 /* TRCG Nominal Rate */
2294 cxd2841er_write_regs(priv, I2C_SLVT,
2295 0x9F, nominalRate8bw[priv->xtal], 5);
2296 /* Group delay equaliser settings for ASCOT tuners optimized */
2297 cxd2841er_write_regs(priv, I2C_SLVT,
2298 0xA6, itbCoef8bw[priv->xtal], 14);
2300 /* IF freq setting */
2301 iffreq = MAKE_IFFREQ_CONFIG_XTAL(priv->xtal, 4.75);
2302 data[0] = (u8) ((iffreq >> 16) & 0xff);
2303 data[1] = (u8)((iffreq >> 8) & 0xff);
2304 data[2] = (u8)(iffreq & 0xff);
2305 cxd2841er_write_regs(priv, I2C_SLVT, 0xB6, data, 3);
2307 /* System bandwidth setting */
2308 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xd7, 0x0, 0x7);
2310 /* Demod core latency setting */
2313 cxd2841er_write_regs(priv, I2C_SLVT, 0xD9, data, 2);
2315 /* Acquisition optimization setting */
2316 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x12);
2317 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0x71, 0x03, 0x07);
2318 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x15);
2319 cxd2841er_write_reg(priv, I2C_SLVT, 0xBE, 0x03);
2322 /* TRCG Nominal Rate */
2323 cxd2841er_write_regs(priv, I2C_SLVT,
2324 0x9F, nominalRate7bw[priv->xtal], 5);
2325 /* Group delay equaliser settings for ASCOT tuners optimized */
2326 cxd2841er_write_regs(priv, I2C_SLVT,
2327 0xA6, itbCoef7bw[priv->xtal], 14);
2329 /* IF freq setting */
2330 iffreq = MAKE_IFFREQ_CONFIG_XTAL(priv->xtal, 4.15);
2331 data[0] = (u8) ((iffreq >> 16) & 0xff);
2332 data[1] = (u8)((iffreq >> 8) & 0xff);
2333 data[2] = (u8)(iffreq & 0xff);
2334 cxd2841er_write_regs(priv, I2C_SLVT, 0xB6, data, 3);
2336 /* System bandwidth setting */
2337 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xd7, 0x02, 0x7);
2339 /* Demod core latency setting */
2342 cxd2841er_write_regs(priv, I2C_SLVT, 0xD9, data, 2);
2344 /* Acquisition optimization setting */
2345 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x12);
2346 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0x71, 0x03, 0x07);
2347 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x15);
2348 cxd2841er_write_reg(priv, I2C_SLVT, 0xBE, 0x02);
2351 /* TRCG Nominal Rate */
2352 cxd2841er_write_regs(priv, I2C_SLVT,
2353 0x9F, nominalRate6bw[priv->xtal], 5);
2354 /* Group delay equaliser settings for ASCOT tuners optimized */
2355 cxd2841er_write_regs(priv, I2C_SLVT,
2356 0xA6, itbCoef6bw[priv->xtal], 14);
2358 /* IF freq setting */
2359 iffreq = MAKE_IFFREQ_CONFIG_XTAL(priv->xtal, 3.55);
2360 data[0] = (u8) ((iffreq >> 16) & 0xff);
2361 data[1] = (u8)((iffreq >> 8) & 0xff);
2362 data[2] = (u8)(iffreq & 0xff);
2363 cxd2841er_write_regs(priv, I2C_SLVT, 0xB6, data, 3);
2365 /* System bandwidth setting */
2366 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xd7, 0x04, 0x7);
2368 /* Demod core latency setting */
2369 if (priv->xtal == SONY_XTAL_24000) {
2376 cxd2841er_write_regs(priv, I2C_SLVT, 0xD9, data, 2);
2378 /* Acquisition optimization setting */
2379 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x12);
2380 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0x71, 0x07, 0x07);
2381 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x15);
2382 cxd2841er_write_reg(priv, I2C_SLVT, 0xBE, 0x02);
2385 dev_dbg(&priv->i2c->dev, "%s(): invalid bandwidth %d\n",
2386 __func__, bandwidth);
2392 static int cxd2841er_sleep_tc_to_active_c_band(struct cxd2841er_priv *priv,
2395 u8 bw7_8mhz_b10_a6[] = {
2396 0x2D, 0xC7, 0x04, 0xF4, 0x07, 0xC5, 0x2A, 0xB8,
2397 0x27, 0x9E, 0x27, 0xA4, 0x29, 0xAB };
2398 u8 bw6mhz_b10_a6[] = {
2399 0x27, 0xA7, 0x28, 0xB3, 0x02, 0xF0, 0x01, 0xE8,
2400 0x00, 0xCF, 0x00, 0xE6, 0x23, 0xA4 };
2404 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
2405 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x10);
2406 switch (bandwidth) {
2409 cxd2841er_write_regs(
2410 priv, I2C_SLVT, 0xa6,
2411 bw7_8mhz_b10_a6, sizeof(bw7_8mhz_b10_a6));
2412 iffreq = MAKE_IFFREQ_CONFIG(4.9);
2415 cxd2841er_write_regs(
2416 priv, I2C_SLVT, 0xa6,
2417 bw6mhz_b10_a6, sizeof(bw6mhz_b10_a6));
2418 iffreq = MAKE_IFFREQ_CONFIG(3.7);
2421 dev_dbg(&priv->i2c->dev, "%s(): unsupported bandwidth %d\n",
2422 __func__, bandwidth);
2425 /* <IF freq setting> */
2426 b10_b6[0] = (u8) ((iffreq >> 16) & 0xff);
2427 b10_b6[1] = (u8)((iffreq >> 8) & 0xff);
2428 b10_b6[2] = (u8)(iffreq & 0xff);
2429 cxd2841er_write_regs(priv, I2C_SLVT, 0xb6, b10_b6, sizeof(b10_b6));
2430 /* Set SLV-T Bank : 0x11 */
2431 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x11);
2432 switch (bandwidth) {
2435 cxd2841er_set_reg_bits(
2436 priv, I2C_SLVT, 0xa3, 0x00, 0x1f);
2439 cxd2841er_set_reg_bits(
2440 priv, I2C_SLVT, 0xa3, 0x14, 0x1f);
2443 /* Set SLV-T Bank : 0x40 */
2444 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x40);
2445 switch (bandwidth) {
2447 cxd2841er_set_reg_bits(
2448 priv, I2C_SLVT, 0x26, 0x0b, 0x0f);
2449 cxd2841er_write_reg(priv, I2C_SLVT, 0x27, 0x3e);
2452 cxd2841er_set_reg_bits(
2453 priv, I2C_SLVT, 0x26, 0x09, 0x0f);
2454 cxd2841er_write_reg(priv, I2C_SLVT, 0x27, 0xd6);
2457 cxd2841er_set_reg_bits(
2458 priv, I2C_SLVT, 0x26, 0x08, 0x0f);
2459 cxd2841er_write_reg(priv, I2C_SLVT, 0x27, 0x6e);
2465 static int cxd2841er_sleep_tc_to_active_t(struct cxd2841er_priv *priv,
2468 u8 data[2] = { 0x09, 0x54 };
2469 u8 data24m[3] = {0xDC, 0x6C, 0x00};
2471 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
2472 cxd2841er_set_ts_clock_mode(priv, SYS_DVBT);
2473 /* Set SLV-X Bank : 0x00 */
2474 cxd2841er_write_reg(priv, I2C_SLVX, 0x00, 0x00);
2475 /* Set demod mode */
2476 cxd2841er_write_reg(priv, I2C_SLVX, 0x17, 0x01);
2477 /* Set SLV-T Bank : 0x00 */
2478 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x00);
2479 /* Enable demod clock */
2480 cxd2841er_write_reg(priv, I2C_SLVT, 0x2c, 0x01);
2481 /* Disable RF level monitor */
2482 cxd2841er_write_reg(priv, I2C_SLVT, 0x2f, 0x00);
2483 /* Enable ADC clock */
2484 cxd2841er_write_reg(priv, I2C_SLVT, 0x30, 0x00);
2486 cxd2841er_write_reg(priv, I2C_SLVT, 0x41, 0x1a);
2487 /* Enable ADC 2 & 3 */
2488 if (priv->xtal == SONY_XTAL_41000) {
2492 cxd2841er_write_regs(priv, I2C_SLVT, 0x43, data, 2);
2494 cxd2841er_write_reg(priv, I2C_SLVX, 0x18, 0x00);
2495 /* Set SLV-T Bank : 0x10 */
2496 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x10);
2497 /* IFAGC gain settings */
2498 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xd2, 0x0c, 0x1f);
2499 /* Set SLV-T Bank : 0x11 */
2500 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x11);
2501 /* BBAGC TARGET level setting */
2502 cxd2841er_write_reg(priv, I2C_SLVT, 0x6a, 0x50);
2503 /* Set SLV-T Bank : 0x10 */
2504 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x10);
2505 /* ASCOT setting ON */
2506 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xa5, 0x01, 0x01);
2507 /* Set SLV-T Bank : 0x18 */
2508 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x18);
2509 /* Pre-RS BER moniter setting */
2510 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0x36, 0x40, 0x07);
2511 /* FEC Auto Recovery setting */
2512 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0x30, 0x01, 0x01);
2513 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0x31, 0x01, 0x01);
2514 /* Set SLV-T Bank : 0x00 */
2515 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x00);
2517 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xce, 0x01, 0x01);
2518 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xcf, 0x01, 0x01);
2520 if (priv->xtal == SONY_XTAL_24000) {
2521 /* Set SLV-T Bank : 0x10 */
2522 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x10);
2523 cxd2841er_write_reg(priv, I2C_SLVT, 0xBF, 0x60);
2524 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x18);
2525 cxd2841er_write_regs(priv, I2C_SLVT, 0x24, data24m, 3);
2528 cxd2841er_sleep_tc_to_active_t_band(priv, bandwidth);
2529 /* Set SLV-T Bank : 0x00 */
2530 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x00);
2531 /* Disable HiZ Setting 1 */
2532 cxd2841er_write_reg(priv, I2C_SLVT, 0x80, 0x28);
2533 /* Disable HiZ Setting 2 */
2534 cxd2841er_write_reg(priv, I2C_SLVT, 0x81, 0x00);
2535 priv->state = STATE_ACTIVE_TC;
2539 static int cxd2841er_sleep_tc_to_active_t2(struct cxd2841er_priv *priv,
2542 u8 data[2] = { 0x09, 0x54 };
2544 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
2545 cxd2841er_set_ts_clock_mode(priv, SYS_DVBT2);
2546 /* Set SLV-X Bank : 0x00 */
2547 cxd2841er_write_reg(priv, I2C_SLVX, 0x00, 0x00);
2548 /* Set demod mode */
2549 cxd2841er_write_reg(priv, I2C_SLVX, 0x17, 0x02);
2550 /* Set SLV-T Bank : 0x00 */
2551 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x00);
2552 /* Enable demod clock */
2553 cxd2841er_write_reg(priv, I2C_SLVT, 0x2c, 0x01);
2554 /* Disable RF level monitor */
2555 cxd2841er_write_reg(priv, I2C_SLVT, 0x2f, 0x00);
2556 /* Enable ADC clock */
2557 cxd2841er_write_reg(priv, I2C_SLVT, 0x30, 0x00);
2559 cxd2841er_write_reg(priv, I2C_SLVT, 0x41, 0x1a);
2560 /* xtal freq 20.5MHz */
2561 cxd2841er_write_regs(priv, I2C_SLVT, 0x43, data, 2);
2563 cxd2841er_write_reg(priv, I2C_SLVX, 0x18, 0x00);
2564 /* Set SLV-T Bank : 0x10 */
2565 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x10);
2566 /* IFAGC gain settings */
2567 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xd2, 0x0c, 0x1f);
2568 /* Set SLV-T Bank : 0x11 */
2569 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x11);
2570 /* BBAGC TARGET level setting */
2571 cxd2841er_write_reg(priv, I2C_SLVT, 0x6a, 0x50);
2572 /* Set SLV-T Bank : 0x10 */
2573 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x10);
2574 /* ASCOT setting ON */
2575 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xa5, 0x01, 0x01);
2576 /* Set SLV-T Bank : 0x20 */
2577 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x20);
2578 /* Acquisition optimization setting */
2579 cxd2841er_write_reg(priv, I2C_SLVT, 0x8b, 0x3c);
2580 /* Set SLV-T Bank : 0x2b */
2581 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x2b);
2582 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0x76, 0x20, 0x70);
2583 /* Set SLV-T Bank : 0x00 */
2584 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x00);
2586 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xce, 0x01, 0x01);
2587 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xcf, 0x01, 0x01);
2588 /* DVB-T2 initial setting */
2589 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x13);
2590 cxd2841er_write_reg(priv, I2C_SLVT, 0x83, 0x10);
2591 cxd2841er_write_reg(priv, I2C_SLVT, 0x86, 0x34);
2592 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0x9e, 0x09, 0x0f);
2593 cxd2841er_write_reg(priv, I2C_SLVT, 0x9f, 0xd8);
2594 /* Set SLV-T Bank : 0x2a */
2595 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x2a);
2596 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0x38, 0x04, 0x0f);
2597 /* Set SLV-T Bank : 0x2b */
2598 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x2b);
2599 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0x11, 0x20, 0x3f);
2601 cxd2841er_sleep_tc_to_active_t2_band(priv, bandwidth);
2603 /* Set SLV-T Bank : 0x00 */
2604 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x00);
2605 /* Disable HiZ Setting 1 */
2606 cxd2841er_write_reg(priv, I2C_SLVT, 0x80, 0x28);
2607 /* Disable HiZ Setting 2 */
2608 cxd2841er_write_reg(priv, I2C_SLVT, 0x81, 0x00);
2609 priv->state = STATE_ACTIVE_TC;
2614 static int cxd2841er_sleep_tc_to_active_i(struct cxd2841er_priv *priv,
2617 u8 data[2] = { 0x09, 0x54 };
2618 u8 data24m[2] = {0x60, 0x00};
2619 u8 data24m2[3] = {0xB7, 0x1B, 0x00};
2621 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
2622 cxd2841er_set_ts_clock_mode(priv, SYS_DVBT);
2623 /* Set SLV-X Bank : 0x00 */
2624 cxd2841er_write_reg(priv, I2C_SLVX, 0x00, 0x00);
2625 /* Set demod mode */
2626 cxd2841er_write_reg(priv, I2C_SLVX, 0x17, 0x06);
2627 /* Set SLV-T Bank : 0x00 */
2628 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x00);
2629 /* Enable demod clock */
2630 cxd2841er_write_reg(priv, I2C_SLVT, 0x2c, 0x01);
2631 /* Enable RF level monitor */
2632 cxd2841er_write_reg(priv, I2C_SLVT, 0x2f, 0x01);
2633 cxd2841er_write_reg(priv, I2C_SLVT, 0x59, 0x01);
2634 /* Enable ADC clock */
2635 cxd2841er_write_reg(priv, I2C_SLVT, 0x30, 0x00);
2637 cxd2841er_write_reg(priv, I2C_SLVT, 0x41, 0x1a);
2638 /* xtal freq 20.5MHz or 24M */
2639 cxd2841er_write_regs(priv, I2C_SLVT, 0x43, data, 2);
2641 cxd2841er_write_reg(priv, I2C_SLVX, 0x18, 0x00);
2642 /* ASCOT setting ON */
2643 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xa5, 0x01, 0x01);
2644 /* FEC Auto Recovery setting */
2645 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0x30, 0x01, 0x01);
2646 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0x31, 0x00, 0x01);
2647 /* ISDB-T initial setting */
2648 /* Set SLV-T Bank : 0x00 */
2649 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x00);
2650 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xce, 0x00, 0x01);
2651 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xcf, 0x00, 0x01);
2652 /* Set SLV-T Bank : 0x10 */
2653 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x10);
2654 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0x69, 0x04, 0x07);
2655 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0x6B, 0x03, 0x07);
2656 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0x9D, 0x50, 0xFF);
2657 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xD3, 0x06, 0x1F);
2658 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xED, 0x00, 0x01);
2659 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xE2, 0xCE, 0x80);
2660 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xF2, 0x13, 0x10);
2661 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xDE, 0x2E, 0x3F);
2662 /* Set SLV-T Bank : 0x15 */
2663 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x15);
2664 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xDE, 0x02, 0x03);
2665 /* Set SLV-T Bank : 0x1E */
2666 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x1E);
2667 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0x73, 0x68, 0xFF);
2668 /* Set SLV-T Bank : 0x63 */
2669 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x63);
2670 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0x81, 0x00, 0x01);
2672 /* for xtal 24MHz */
2673 /* Set SLV-T Bank : 0x10 */
2674 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x10);
2675 cxd2841er_write_regs(priv, I2C_SLVT, 0xBF, data24m, 2);
2676 /* Set SLV-T Bank : 0x60 */
2677 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x60);
2678 cxd2841er_write_regs(priv, I2C_SLVT, 0xA8, data24m2, 3);
2680 cxd2841er_sleep_tc_to_active_i_band(priv, bandwidth);
2681 /* Set SLV-T Bank : 0x00 */
2682 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x00);
2683 /* Disable HiZ Setting 1 */
2684 cxd2841er_write_reg(priv, I2C_SLVT, 0x80, 0x28);
2685 /* Disable HiZ Setting 2 */
2686 cxd2841er_write_reg(priv, I2C_SLVT, 0x81, 0x00);
2687 priv->state = STATE_ACTIVE_TC;
2691 static int cxd2841er_sleep_tc_to_active_c(struct cxd2841er_priv *priv,
2694 u8 data[2] = { 0x09, 0x54 };
2696 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
2697 cxd2841er_set_ts_clock_mode(priv, SYS_DVBC_ANNEX_A);
2698 /* Set SLV-X Bank : 0x00 */
2699 cxd2841er_write_reg(priv, I2C_SLVX, 0x00, 0x00);
2700 /* Set demod mode */
2701 cxd2841er_write_reg(priv, I2C_SLVX, 0x17, 0x04);
2702 /* Set SLV-T Bank : 0x00 */
2703 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x00);
2704 /* Enable demod clock */
2705 cxd2841er_write_reg(priv, I2C_SLVT, 0x2c, 0x01);
2706 /* Disable RF level monitor */
2707 cxd2841er_write_reg(priv, I2C_SLVT, 0x2f, 0x00);
2708 /* Enable ADC clock */
2709 cxd2841er_write_reg(priv, I2C_SLVT, 0x30, 0x00);
2711 cxd2841er_write_reg(priv, I2C_SLVT, 0x41, 0x1a);
2712 /* xtal freq 20.5MHz */
2713 cxd2841er_write_regs(priv, I2C_SLVT, 0x43, data, 2);
2715 cxd2841er_write_reg(priv, I2C_SLVX, 0x18, 0x00);
2716 /* Set SLV-T Bank : 0x10 */
2717 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x10);
2718 /* IFAGC gain settings */
2719 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xd2, 0x09, 0x1f);
2720 /* Set SLV-T Bank : 0x11 */
2721 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x11);
2722 /* BBAGC TARGET level setting */
2723 cxd2841er_write_reg(priv, I2C_SLVT, 0x6a, 0x48);
2724 /* Set SLV-T Bank : 0x10 */
2725 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x10);
2726 /* ASCOT setting ON */
2727 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xa5, 0x01, 0x01);
2728 /* Set SLV-T Bank : 0x40 */
2729 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x40);
2731 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xc3, 0x00, 0x04);
2732 /* Set SLV-T Bank : 0x00 */
2733 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x00);
2735 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xce, 0x01, 0x01);
2736 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xcf, 0x01, 0x01);
2738 cxd2841er_sleep_tc_to_active_c_band(priv, 8000000);
2739 /* Set SLV-T Bank : 0x00 */
2740 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x00);
2741 /* Disable HiZ Setting 1 */
2742 cxd2841er_write_reg(priv, I2C_SLVT, 0x80, 0x28);
2743 /* Disable HiZ Setting 2 */
2744 cxd2841er_write_reg(priv, I2C_SLVT, 0x81, 0x00);
2745 priv->state = STATE_ACTIVE_TC;
2749 static int cxd2841er_get_frontend(struct dvb_frontend *fe,
2750 struct dtv_frontend_properties *p)
2752 enum fe_status status = 0;
2753 u16 strength = 0, snr = 0;
2754 u32 errors = 0, ber = 0;
2755 struct cxd2841er_priv *priv = fe->demodulator_priv;
2757 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
2758 if (priv->state == STATE_ACTIVE_S)
2759 cxd2841er_read_status_s(fe, &status);
2760 else if (priv->state == STATE_ACTIVE_TC)
2761 cxd2841er_read_status_tc(fe, &status);
2763 if (status & FE_HAS_LOCK) {
2764 cxd2841er_read_signal_strength(fe, &strength);
2765 p->strength.len = 1;
2766 p->strength.stat[0].scale = FE_SCALE_RELATIVE;
2767 p->strength.stat[0].uvalue = strength;
2768 cxd2841er_read_snr(fe, &snr);
2770 p->cnr.stat[0].scale = FE_SCALE_DECIBEL;
2771 p->cnr.stat[0].svalue = snr;
2772 cxd2841er_read_ucblocks(fe, &errors);
2773 p->block_error.len = 1;
2774 p->block_error.stat[0].scale = FE_SCALE_COUNTER;
2775 p->block_error.stat[0].uvalue = errors;
2776 cxd2841er_read_ber(fe, &ber);
2777 p->post_bit_error.len = 1;
2778 p->post_bit_error.stat[0].scale = FE_SCALE_COUNTER;
2779 p->post_bit_error.stat[0].uvalue = ber;
2781 p->strength.len = 1;
2782 p->strength.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
2784 p->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
2785 p->block_error.len = 1;
2786 p->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
2787 p->post_bit_error.len = 1;
2788 p->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
2793 static int cxd2841er_set_frontend_s(struct dvb_frontend *fe)
2795 int ret = 0, i, timeout, carr_offset;
2796 enum fe_status status;
2797 struct cxd2841er_priv *priv = fe->demodulator_priv;
2798 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
2799 u32 symbol_rate = p->symbol_rate/1000;
2801 dev_dbg(&priv->i2c->dev, "%s(): %s frequency=%d symbol_rate=%d xtal=%d\n",
2803 (p->delivery_system == SYS_DVBS ? "DVB-S" : "DVB-S2"),
2804 p->frequency, symbol_rate, priv->xtal);
2805 switch (priv->state) {
2807 ret = cxd2841er_sleep_s_to_active_s(
2808 priv, p->delivery_system, symbol_rate);
2810 case STATE_ACTIVE_S:
2811 ret = cxd2841er_retune_active(priv, p);
2814 dev_dbg(&priv->i2c->dev, "%s(): invalid state %d\n",
2815 __func__, priv->state);
2820 dev_dbg(&priv->i2c->dev, "%s(): tune failed\n", __func__);
2823 if (fe->ops.i2c_gate_ctrl)
2824 fe->ops.i2c_gate_ctrl(fe, 1);
2825 if (fe->ops.tuner_ops.set_params)
2826 fe->ops.tuner_ops.set_params(fe);
2827 if (fe->ops.i2c_gate_ctrl)
2828 fe->ops.i2c_gate_ctrl(fe, 0);
2829 cxd2841er_tune_done(priv);
2830 timeout = ((3000000 + (symbol_rate - 1)) / symbol_rate) + 150;
2831 for (i = 0; i < timeout / CXD2841ER_DVBS_POLLING_INVL; i++) {
2832 usleep_range(CXD2841ER_DVBS_POLLING_INVL*1000,
2833 (CXD2841ER_DVBS_POLLING_INVL + 2) * 1000);
2834 cxd2841er_read_status_s(fe, &status);
2835 if (status & FE_HAS_LOCK)
2838 if (status & FE_HAS_LOCK) {
2839 if (cxd2841er_get_carrier_offset_s_s2(
2840 priv, &carr_offset)) {
2844 dev_dbg(&priv->i2c->dev, "%s(): carrier_offset=%d\n",
2845 __func__, carr_offset);
2851 static int cxd2841er_set_frontend_tc(struct dvb_frontend *fe)
2853 int ret = 0, timeout;
2854 enum fe_status status;
2855 struct cxd2841er_priv *priv = fe->demodulator_priv;
2856 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
2858 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
2859 if (p->delivery_system == SYS_DVBT) {
2860 priv->system = SYS_DVBT;
2861 switch (priv->state) {
2862 case STATE_SLEEP_TC:
2863 ret = cxd2841er_sleep_tc_to_active_t(
2864 priv, p->bandwidth_hz);
2866 case STATE_ACTIVE_TC:
2867 ret = cxd2841er_retune_active(priv, p);
2870 dev_dbg(&priv->i2c->dev, "%s(): invalid state %d\n",
2871 __func__, priv->state);
2874 } else if (p->delivery_system == SYS_DVBT2) {
2875 priv->system = SYS_DVBT2;
2876 cxd2841er_dvbt2_set_plp_config(priv,
2877 (int)(p->stream_id > 255), p->stream_id);
2878 cxd2841er_dvbt2_set_profile(priv, DVBT2_PROFILE_BASE);
2879 switch (priv->state) {
2880 case STATE_SLEEP_TC:
2881 ret = cxd2841er_sleep_tc_to_active_t2(priv,
2884 case STATE_ACTIVE_TC:
2885 ret = cxd2841er_retune_active(priv, p);
2888 dev_dbg(&priv->i2c->dev, "%s(): invalid state %d\n",
2889 __func__, priv->state);
2892 } else if (p->delivery_system == SYS_ISDBT) {
2893 priv->system = SYS_ISDBT;
2894 switch (priv->state) {
2895 case STATE_SLEEP_TC:
2896 ret = cxd2841er_sleep_tc_to_active_i(
2897 priv, p->bandwidth_hz);
2899 case STATE_ACTIVE_TC:
2900 ret = cxd2841er_retune_active(priv, p);
2903 dev_dbg(&priv->i2c->dev, "%s(): invalid state %d\n",
2904 __func__, priv->state);
2907 } else if (p->delivery_system == SYS_DVBC_ANNEX_A ||
2908 p->delivery_system == SYS_DVBC_ANNEX_C) {
2909 priv->system = SYS_DVBC_ANNEX_A;
2910 switch (priv->state) {
2911 case STATE_SLEEP_TC:
2912 ret = cxd2841er_sleep_tc_to_active_c(
2913 priv, p->bandwidth_hz);
2915 case STATE_ACTIVE_TC:
2916 ret = cxd2841er_retune_active(priv, p);
2919 dev_dbg(&priv->i2c->dev, "%s(): invalid state %d\n",
2920 __func__, priv->state);
2924 dev_dbg(&priv->i2c->dev,
2925 "%s(): invalid delivery system %d\n",
2926 __func__, p->delivery_system);
2931 if (fe->ops.i2c_gate_ctrl)
2932 fe->ops.i2c_gate_ctrl(fe, 1);
2933 if (fe->ops.tuner_ops.set_params)
2934 fe->ops.tuner_ops.set_params(fe);
2935 if (fe->ops.i2c_gate_ctrl)
2936 fe->ops.i2c_gate_ctrl(fe, 0);
2937 cxd2841er_tune_done(priv);
2939 while (timeout > 0) {
2940 ret = cxd2841er_read_status_tc(fe, &status);
2943 if (status & FE_HAS_LOCK)
2949 dev_dbg(&priv->i2c->dev,
2950 "%s(): LOCK wait timeout\n", __func__);
2955 static int cxd2841er_tune_s(struct dvb_frontend *fe,
2957 unsigned int mode_flags,
2958 unsigned int *delay,
2959 enum fe_status *status)
2961 int ret, carrier_offset;
2962 struct cxd2841er_priv *priv = fe->demodulator_priv;
2963 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
2965 dev_dbg(&priv->i2c->dev, "%s() re_tune=%d\n", __func__, re_tune);
2967 ret = cxd2841er_set_frontend_s(fe);
2970 cxd2841er_read_status_s(fe, status);
2971 if (*status & FE_HAS_LOCK) {
2972 if (cxd2841er_get_carrier_offset_s_s2(
2973 priv, &carrier_offset))
2975 p->frequency += carrier_offset;
2976 ret = cxd2841er_set_frontend_s(fe);
2982 return cxd2841er_read_status_s(fe, status);
2985 static int cxd2841er_tune_tc(struct dvb_frontend *fe,
2987 unsigned int mode_flags,
2988 unsigned int *delay,
2989 enum fe_status *status)
2991 int ret, carrier_offset;
2992 struct cxd2841er_priv *priv = fe->demodulator_priv;
2993 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
2995 dev_dbg(&priv->i2c->dev, "%s(): re_tune %d\n", __func__, re_tune);
2997 ret = cxd2841er_set_frontend_tc(fe);
3000 cxd2841er_read_status_tc(fe, status);
3001 if (*status & FE_HAS_LOCK) {
3002 switch (priv->system) {
3004 ret = cxd2841er_get_carrier_offset_i(
3005 priv, p->bandwidth_hz,
3009 ret = cxd2841er_get_carrier_offset_t(
3010 priv, p->bandwidth_hz,
3014 ret = cxd2841er_get_carrier_offset_t2(
3015 priv, p->bandwidth_hz,
3018 case SYS_DVBC_ANNEX_A:
3019 ret = cxd2841er_get_carrier_offset_c(
3020 priv, &carrier_offset);
3023 dev_dbg(&priv->i2c->dev,
3024 "%s(): invalid delivery system %d\n",
3025 __func__, priv->system);
3030 dev_dbg(&priv->i2c->dev, "%s(): carrier offset %d\n",
3031 __func__, carrier_offset);
3032 p->frequency += carrier_offset;
3033 ret = cxd2841er_set_frontend_tc(fe);
3039 return cxd2841er_read_status_tc(fe, status);
3042 static int cxd2841er_sleep_s(struct dvb_frontend *fe)
3044 struct cxd2841er_priv *priv = fe->demodulator_priv;
3046 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
3047 cxd2841er_active_s_to_sleep_s(fe->demodulator_priv);
3048 cxd2841er_sleep_s_to_shutdown(fe->demodulator_priv);
3052 static int cxd2841er_sleep_tc(struct dvb_frontend *fe)
3054 struct cxd2841er_priv *priv = fe->demodulator_priv;
3056 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
3057 if (priv->state == STATE_ACTIVE_TC) {
3058 switch (priv->system) {
3060 cxd2841er_active_t_to_sleep_tc(priv);
3063 cxd2841er_active_t2_to_sleep_tc(priv);
3066 cxd2841er_active_i_to_sleep_tc(priv);
3068 case SYS_DVBC_ANNEX_A:
3069 cxd2841er_active_c_to_sleep_tc(priv);
3072 dev_warn(&priv->i2c->dev,
3073 "%s(): unknown delivery system %d\n",
3074 __func__, priv->system);
3077 if (priv->state != STATE_SLEEP_TC) {
3078 dev_err(&priv->i2c->dev, "%s(): invalid state %d\n",
3079 __func__, priv->state);
3082 cxd2841er_sleep_tc_to_shutdown(priv);
3086 static int cxd2841er_send_burst(struct dvb_frontend *fe,
3087 enum fe_sec_mini_cmd burst)
3090 struct cxd2841er_priv *priv = fe->demodulator_priv;
3092 dev_dbg(&priv->i2c->dev, "%s(): burst mode %s\n", __func__,
3093 (burst == SEC_MINI_A ? "A" : "B"));
3094 if (priv->state != STATE_SLEEP_S &&
3095 priv->state != STATE_ACTIVE_S) {
3096 dev_err(&priv->i2c->dev, "%s(): invalid demod state %d\n",
3097 __func__, priv->state);
3100 data = (burst == SEC_MINI_A ? 0 : 1);
3101 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0xbb);
3102 cxd2841er_write_reg(priv, I2C_SLVT, 0x34, 0x01);
3103 cxd2841er_write_reg(priv, I2C_SLVT, 0x35, data);
3107 static int cxd2841er_set_tone(struct dvb_frontend *fe,
3108 enum fe_sec_tone_mode tone)
3111 struct cxd2841er_priv *priv = fe->demodulator_priv;
3113 dev_dbg(&priv->i2c->dev, "%s(): tone %s\n", __func__,
3114 (tone == SEC_TONE_ON ? "On" : "Off"));
3115 if (priv->state != STATE_SLEEP_S &&
3116 priv->state != STATE_ACTIVE_S) {
3117 dev_err(&priv->i2c->dev, "%s(): invalid demod state %d\n",
3118 __func__, priv->state);
3121 data = (tone == SEC_TONE_ON ? 1 : 0);
3122 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0xbb);
3123 cxd2841er_write_reg(priv, I2C_SLVT, 0x36, data);
3127 static int cxd2841er_send_diseqc_msg(struct dvb_frontend *fe,
3128 struct dvb_diseqc_master_cmd *cmd)
3132 struct cxd2841er_priv *priv = fe->demodulator_priv;
3134 if (priv->state != STATE_SLEEP_S &&
3135 priv->state != STATE_ACTIVE_S) {
3136 dev_err(&priv->i2c->dev, "%s(): invalid demod state %d\n",
3137 __func__, priv->state);
3140 dev_dbg(&priv->i2c->dev,
3141 "%s(): cmd->len %d\n", __func__, cmd->msg_len);
3142 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0xbb);
3144 cxd2841er_write_reg(priv, I2C_SLVT, 0x33, 0x01);
3145 /* cmd1 length & data */
3146 cxd2841er_write_reg(priv, I2C_SLVT, 0x3d, cmd->msg_len);
3147 memset(data, 0, sizeof(data));
3148 for (i = 0; i < cmd->msg_len && i < sizeof(data); i++)
3149 data[i] = cmd->msg[i];
3150 cxd2841er_write_regs(priv, I2C_SLVT, 0x3e, data, sizeof(data));
3151 /* repeat count for cmd1 */
3152 cxd2841er_write_reg(priv, I2C_SLVT, 0x37, 1);
3153 /* repeat count for cmd2: always 0 */
3154 cxd2841er_write_reg(priv, I2C_SLVT, 0x38, 0);
3155 /* start transmit */
3156 cxd2841er_write_reg(priv, I2C_SLVT, 0x32, 0x01);
3157 /* wait for 1 sec timeout */
3158 for (i = 0; i < 50; i++) {
3159 cxd2841er_read_reg(priv, I2C_SLVT, 0x10, data);
3161 dev_dbg(&priv->i2c->dev,
3162 "%s(): DiSEqC cmd has been sent\n", __func__);
3167 dev_dbg(&priv->i2c->dev,
3168 "%s(): DiSEqC cmd transmit timeout\n", __func__);
3172 static void cxd2841er_release(struct dvb_frontend *fe)
3174 struct cxd2841er_priv *priv = fe->demodulator_priv;
3176 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
3180 static int cxd2841er_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
3182 struct cxd2841er_priv *priv = fe->demodulator_priv;
3184 dev_dbg(&priv->i2c->dev, "%s(): enable=%d\n", __func__, enable);
3185 cxd2841er_set_reg_bits(
3186 priv, I2C_SLVX, 0x8, (enable ? 0x01 : 0x00), 0x01);
3190 static enum dvbfe_algo cxd2841er_get_algo(struct dvb_frontend *fe)
3192 struct cxd2841er_priv *priv = fe->demodulator_priv;
3194 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
3195 return DVBFE_ALGO_HW;
3198 static int cxd2841er_init_s(struct dvb_frontend *fe)
3200 struct cxd2841er_priv *priv = fe->demodulator_priv;
3202 /* sanity. force demod to SHUTDOWN state */
3203 if (priv->state == STATE_SLEEP_S) {
3204 dev_dbg(&priv->i2c->dev, "%s() forcing sleep->shutdown\n",
3206 cxd2841er_sleep_s_to_shutdown(priv);
3207 } else if (priv->state == STATE_ACTIVE_S) {
3208 dev_dbg(&priv->i2c->dev, "%s() forcing active->sleep->shutdown\n",
3210 cxd2841er_active_s_to_sleep_s(priv);
3211 cxd2841er_sleep_s_to_shutdown(priv);
3214 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
3215 cxd2841er_shutdown_to_sleep_s(priv);
3216 /* SONY_DEMOD_CONFIG_SAT_IFAGCNEG set to 1 */
3217 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0xa0);
3218 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xb9, 0x01, 0x01);
3222 static int cxd2841er_init_tc(struct dvb_frontend *fe)
3224 struct cxd2841er_priv *priv = fe->demodulator_priv;
3226 dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
3227 cxd2841er_shutdown_to_sleep_tc(priv);
3228 /* SONY_DEMOD_CONFIG_IFAGCNEG = 1 */
3229 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x10);
3230 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xcb, 0x40, 0x40);
3231 /* SONY_DEMOD_CONFIG_IFAGC_ADC_FS = 0 */
3232 cxd2841er_write_reg(priv, I2C_SLVT, 0xcd, 0x50);
3233 /* SONY_DEMOD_CONFIG_PARALLEL_SEL = 1 */
3234 cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x00);
3235 cxd2841er_set_reg_bits(priv, I2C_SLVT, 0xc4, 0x00, 0x80);
3239 static struct dvb_frontend_ops cxd2841er_dvbs_s2_ops;
3240 static struct dvb_frontend_ops cxd2841er_dvbt_t2_ops;
3241 static struct dvb_frontend_ops cxd2841er_dvbc_ops;
3242 static struct dvb_frontend_ops cxd2841er_isdbt_ops;
3244 static struct dvb_frontend *cxd2841er_attach(struct cxd2841er_config *cfg,
3245 struct i2c_adapter *i2c,
3250 struct cxd2841er_priv *priv = NULL;
3252 /* allocate memory for the internal state */
3253 priv = kzalloc(sizeof(struct cxd2841er_priv), GFP_KERNEL);
3258 priv->i2c_addr_slvx = (cfg->i2c_addr + 4) >> 1;
3259 priv->i2c_addr_slvt = (cfg->i2c_addr) >> 1;
3260 priv->xtal = cfg->xtal;
3261 /* create dvb_frontend */
3264 memcpy(&priv->frontend.ops,
3265 &cxd2841er_dvbs_s2_ops,
3266 sizeof(struct dvb_frontend_ops));
3270 memcpy(&priv->frontend.ops,
3271 &cxd2841er_dvbt_t2_ops,
3272 sizeof(struct dvb_frontend_ops));
3276 memcpy(&priv->frontend.ops,
3277 &cxd2841er_isdbt_ops,
3278 sizeof(struct dvb_frontend_ops));
3281 case SYS_DVBC_ANNEX_A:
3282 memcpy(&priv->frontend.ops,
3283 &cxd2841er_dvbc_ops,
3284 sizeof(struct dvb_frontend_ops));
3291 priv->frontend.demodulator_priv = priv;
3292 dev_info(&priv->i2c->dev,
3293 "%s(): attaching CXD2841ER DVB-%s frontend\n",
3295 dev_info(&priv->i2c->dev,
3296 "%s(): I2C adapter %p SLVX addr %x SLVT addr %x\n",
3297 __func__, priv->i2c,
3298 priv->i2c_addr_slvx, priv->i2c_addr_slvt);
3299 chip_id = cxd2841er_chip_id(priv);
3300 if (chip_id != CXD2841ER_CHIP_ID && chip_id != CXD2854ER_CHIP_ID) {
3301 dev_err(&priv->i2c->dev, "%s(): invalid chip ID 0x%02x\n",
3303 priv->frontend.demodulator_priv = NULL;
3307 dev_info(&priv->i2c->dev, "%s(): chip ID 0x%02x OK.\n",
3309 return &priv->frontend;
3312 struct dvb_frontend *cxd2841er_attach_s(struct cxd2841er_config *cfg,
3313 struct i2c_adapter *i2c)
3315 return cxd2841er_attach(cfg, i2c, SYS_DVBS);
3317 EXPORT_SYMBOL(cxd2841er_attach_s);
3319 struct dvb_frontend *cxd2841er_attach_t(struct cxd2841er_config *cfg,
3320 struct i2c_adapter *i2c)
3322 return cxd2841er_attach(cfg, i2c, SYS_DVBT);
3324 EXPORT_SYMBOL(cxd2841er_attach_t);
3326 struct dvb_frontend *cxd2841er_attach_i(struct cxd2841er_config *cfg,
3327 struct i2c_adapter *i2c)
3329 return cxd2841er_attach(cfg, i2c, SYS_ISDBT);
3331 EXPORT_SYMBOL(cxd2841er_attach_i);
3333 struct dvb_frontend *cxd2841er_attach_c(struct cxd2841er_config *cfg,
3334 struct i2c_adapter *i2c)
3336 return cxd2841er_attach(cfg, i2c, SYS_DVBC_ANNEX_A);
3338 EXPORT_SYMBOL(cxd2841er_attach_c);
3340 static struct dvb_frontend_ops cxd2841er_dvbs_s2_ops = {
3341 .delsys = { SYS_DVBS, SYS_DVBS2 },
3343 .name = "Sony CXD2841ER DVB-S/S2 demodulator",
3344 .frequency_min = 500000,
3345 .frequency_max = 2500000,
3346 .frequency_stepsize = 0,
3347 .symbol_rate_min = 1000000,
3348 .symbol_rate_max = 45000000,
3349 .symbol_rate_tolerance = 500,
3350 .caps = FE_CAN_INVERSION_AUTO |
3354 .init = cxd2841er_init_s,
3355 .sleep = cxd2841er_sleep_s,
3356 .release = cxd2841er_release,
3357 .set_frontend = cxd2841er_set_frontend_s,
3358 .get_frontend = cxd2841er_get_frontend,
3359 .read_status = cxd2841er_read_status_s,
3360 .i2c_gate_ctrl = cxd2841er_i2c_gate_ctrl,
3361 .get_frontend_algo = cxd2841er_get_algo,
3362 .set_tone = cxd2841er_set_tone,
3363 .diseqc_send_burst = cxd2841er_send_burst,
3364 .diseqc_send_master_cmd = cxd2841er_send_diseqc_msg,
3365 .tune = cxd2841er_tune_s
3368 static struct dvb_frontend_ops cxd2841er_dvbt_t2_ops = {
3369 .delsys = { SYS_DVBT, SYS_DVBT2 },
3371 .name = "Sony CXD2841ER DVB-T/T2 demodulator",
3372 .caps = FE_CAN_FEC_1_2 |
3385 FE_CAN_TRANSMISSION_MODE_AUTO |
3386 FE_CAN_GUARD_INTERVAL_AUTO |
3387 FE_CAN_HIERARCHY_AUTO |
3389 FE_CAN_2G_MODULATION,
3390 .frequency_min = 42000000,
3391 .frequency_max = 1002000000
3393 .init = cxd2841er_init_tc,
3394 .sleep = cxd2841er_sleep_tc,
3395 .release = cxd2841er_release,
3396 .set_frontend = cxd2841er_set_frontend_tc,
3397 .get_frontend = cxd2841er_get_frontend,
3398 .read_status = cxd2841er_read_status_tc,
3399 .tune = cxd2841er_tune_tc,
3400 .i2c_gate_ctrl = cxd2841er_i2c_gate_ctrl,
3401 .get_frontend_algo = cxd2841er_get_algo
3404 static struct dvb_frontend_ops cxd2841er_isdbt_ops = {
3405 .delsys = { SYS_ISDBT },
3407 .name = "Sony CXD2854ER ISDBT demodulator",
3408 .caps = FE_CAN_FEC_1_2 |
3421 FE_CAN_TRANSMISSION_MODE_AUTO |
3422 FE_CAN_GUARD_INTERVAL_AUTO |
3423 FE_CAN_HIERARCHY_AUTO |
3425 FE_CAN_2G_MODULATION,
3426 .frequency_min = 42000000,
3427 .frequency_max = 1002000000
3429 .init = cxd2841er_init_tc,
3430 .sleep = cxd2841er_sleep_tc,
3431 .release = cxd2841er_release,
3432 .set_frontend = cxd2841er_set_frontend_tc,
3433 .get_frontend = cxd2841er_get_frontend,
3434 .read_status = cxd2841er_read_status_tc,
3435 .tune = cxd2841er_tune_tc,
3436 .i2c_gate_ctrl = cxd2841er_i2c_gate_ctrl,
3437 .get_frontend_algo = cxd2841er_get_algo
3440 static struct dvb_frontend_ops cxd2841er_dvbc_ops = {
3441 .delsys = { SYS_DVBC_ANNEX_A },
3443 .name = "Sony CXD2841ER DVB-C demodulator",
3444 .caps = FE_CAN_FEC_1_2 |
3456 FE_CAN_INVERSION_AUTO,
3457 .frequency_min = 42000000,
3458 .frequency_max = 1002000000
3460 .init = cxd2841er_init_tc,
3461 .sleep = cxd2841er_sleep_tc,
3462 .release = cxd2841er_release,
3463 .set_frontend = cxd2841er_set_frontend_tc,
3464 .get_frontend = cxd2841er_get_frontend,
3465 .read_status = cxd2841er_read_status_tc,
3466 .tune = cxd2841er_tune_tc,
3467 .i2c_gate_ctrl = cxd2841er_i2c_gate_ctrl,
3468 .get_frontend_algo = cxd2841er_get_algo,
3471 MODULE_DESCRIPTION("Sony CXD2841ER/CXD2854ER DVB-C/C2/T/T2/S/S2 demodulator driver");
3472 MODULE_AUTHOR("Sergey Kozlov <serjk@netup.ru>, Abylay Ospan <aospan@netup.ru>");
3473 MODULE_LICENSE("GPL");