1 // SPDX-License-Identifier: GPL-2.0-only
3 * drxk_hard: DRX-K DVB-C/T demodulator driver
5 * Copyright (C) 2010-2011 Digital Devices GmbH
8 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
10 #include <linux/kernel.h>
11 #include <linux/module.h>
12 #include <linux/moduleparam.h>
13 #include <linux/init.h>
14 #include <linux/delay.h>
15 #include <linux/firmware.h>
16 #include <linux/i2c.h>
17 #include <linux/hardirq.h>
18 #include <asm/div64.h>
20 #include <media/dvb_frontend.h>
22 #include "drxk_hard.h"
23 #include <media/dvb_math.h>
25 static int power_down_dvbt(struct drxk_state
*state
, bool set_power_mode
);
26 static int power_down_qam(struct drxk_state
*state
);
27 static int set_dvbt_standard(struct drxk_state
*state
,
28 enum operation_mode o_mode
);
29 static int set_qam_standard(struct drxk_state
*state
,
30 enum operation_mode o_mode
);
31 static int set_qam(struct drxk_state
*state
, u16 intermediate_freqk_hz
,
32 s32 tuner_freq_offset
);
33 static int set_dvbt_standard(struct drxk_state
*state
,
34 enum operation_mode o_mode
);
35 static int dvbt_start(struct drxk_state
*state
);
36 static int set_dvbt(struct drxk_state
*state
, u16 intermediate_freqk_hz
,
37 s32 tuner_freq_offset
);
38 static int get_qam_lock_status(struct drxk_state
*state
, u32
*p_lock_status
);
39 static int get_dvbt_lock_status(struct drxk_state
*state
, u32
*p_lock_status
);
40 static int switch_antenna_to_qam(struct drxk_state
*state
);
41 static int switch_antenna_to_dvbt(struct drxk_state
*state
);
43 static bool is_dvbt(struct drxk_state
*state
)
45 return state
->m_operation_mode
== OM_DVBT
;
48 static bool is_qam(struct drxk_state
*state
)
50 return state
->m_operation_mode
== OM_QAM_ITU_A
||
51 state
->m_operation_mode
== OM_QAM_ITU_B
||
52 state
->m_operation_mode
== OM_QAM_ITU_C
;
57 #define DRXDAP_FASI_SHORT_FORMAT(addr) (((addr) & 0xFC30FF80) == 0)
58 #define DRXDAP_FASI_LONG_FORMAT(addr) (((addr) & 0xFC30FF80) != 0)
60 #define DEFAULT_MER_83 165
61 #define DEFAULT_MER_93 250
63 #ifndef DRXK_MPEG_SERIAL_OUTPUT_PIN_DRIVE_STRENGTH
64 #define DRXK_MPEG_SERIAL_OUTPUT_PIN_DRIVE_STRENGTH (0x02)
67 #ifndef DRXK_MPEG_PARALLEL_OUTPUT_PIN_DRIVE_STRENGTH
68 #define DRXK_MPEG_PARALLEL_OUTPUT_PIN_DRIVE_STRENGTH (0x03)
71 #define DEFAULT_DRXK_MPEG_LOCK_TIMEOUT 700
72 #define DEFAULT_DRXK_DEMOD_LOCK_TIMEOUT 500
74 #ifndef DRXK_KI_RAGC_ATV
75 #define DRXK_KI_RAGC_ATV 4
77 #ifndef DRXK_KI_IAGC_ATV
78 #define DRXK_KI_IAGC_ATV 6
80 #ifndef DRXK_KI_DAGC_ATV
81 #define DRXK_KI_DAGC_ATV 7
84 #ifndef DRXK_KI_RAGC_QAM
85 #define DRXK_KI_RAGC_QAM 3
87 #ifndef DRXK_KI_IAGC_QAM
88 #define DRXK_KI_IAGC_QAM 4
90 #ifndef DRXK_KI_DAGC_QAM
91 #define DRXK_KI_DAGC_QAM 7
93 #ifndef DRXK_KI_RAGC_DVBT
94 #define DRXK_KI_RAGC_DVBT (IsA1WithPatchCode(state) ? 3 : 2)
96 #ifndef DRXK_KI_IAGC_DVBT
97 #define DRXK_KI_IAGC_DVBT (IsA1WithPatchCode(state) ? 4 : 2)
99 #ifndef DRXK_KI_DAGC_DVBT
100 #define DRXK_KI_DAGC_DVBT (IsA1WithPatchCode(state) ? 10 : 7)
103 #ifndef DRXK_AGC_DAC_OFFSET
104 #define DRXK_AGC_DAC_OFFSET (0x800)
107 #ifndef DRXK_BANDWIDTH_8MHZ_IN_HZ
108 #define DRXK_BANDWIDTH_8MHZ_IN_HZ (0x8B8249L)
111 #ifndef DRXK_BANDWIDTH_7MHZ_IN_HZ
112 #define DRXK_BANDWIDTH_7MHZ_IN_HZ (0x7A1200L)
115 #ifndef DRXK_BANDWIDTH_6MHZ_IN_HZ
116 #define DRXK_BANDWIDTH_6MHZ_IN_HZ (0x68A1B6L)
119 #ifndef DRXK_QAM_SYMBOLRATE_MAX
120 #define DRXK_QAM_SYMBOLRATE_MAX (7233000)
123 #define DRXK_BL_ROM_OFFSET_TAPS_DVBT 56
124 #define DRXK_BL_ROM_OFFSET_TAPS_ITU_A 64
125 #define DRXK_BL_ROM_OFFSET_TAPS_ITU_C 0x5FE0
126 #define DRXK_BL_ROM_OFFSET_TAPS_BG 24
127 #define DRXK_BL_ROM_OFFSET_TAPS_DKILLP 32
128 #define DRXK_BL_ROM_OFFSET_TAPS_NTSC 40
129 #define DRXK_BL_ROM_OFFSET_TAPS_FM 48
130 #define DRXK_BL_ROM_OFFSET_UCODE 0
132 #define DRXK_BLC_TIMEOUT 100
134 #define DRXK_BLCC_NR_ELEMENTS_TAPS 2
135 #define DRXK_BLCC_NR_ELEMENTS_UCODE 6
137 #define DRXK_BLDC_NR_ELEMENTS_TAPS 28
139 #ifndef DRXK_OFDM_NE_NOTCH_WIDTH
140 #define DRXK_OFDM_NE_NOTCH_WIDTH (4)
143 #define DRXK_QAM_SL_SIG_POWER_QAM16 (40960)
144 #define DRXK_QAM_SL_SIG_POWER_QAM32 (20480)
145 #define DRXK_QAM_SL_SIG_POWER_QAM64 (43008)
146 #define DRXK_QAM_SL_SIG_POWER_QAM128 (20992)
147 #define DRXK_QAM_SL_SIG_POWER_QAM256 (43520)
149 static unsigned int debug
;
150 module_param(debug
, int, 0644);
151 MODULE_PARM_DESC(debug
, "enable debug messages");
153 #define dprintk(level, fmt, arg...) do { \
154 if (debug >= level) \
155 printk(KERN_DEBUG KBUILD_MODNAME ": %s " fmt, __func__, ##arg); \
159 static inline u32
MulDiv32(u32 a
, u32 b
, u32 c
)
163 tmp64
= (u64
) a
* (u64
) b
;
169 static inline u32
Frac28a(u32 a
, u32 c
)
175 R0
= (a
% c
) << 4; /* 32-28 == 4 shifts possible at max */
177 * integer part, only the 4 least significant
178 * bits will be visible in the result
181 /* division using radix 16, 7 nibbles in the result */
182 for (i
= 0; i
< 7; i
++) {
183 Q1
= (Q1
<< 4) | (R0
/ c
);
193 static inline u32
log10times100(u32 value
)
195 return (100L * intlog10(value
)) >> 24;
198 /***************************************************************************/
199 /* I2C **********************************************************************/
200 /***************************************************************************/
202 static int drxk_i2c_lock(struct drxk_state
*state
)
204 i2c_lock_bus(state
->i2c
, I2C_LOCK_SEGMENT
);
205 state
->drxk_i2c_exclusive_lock
= true;
210 static void drxk_i2c_unlock(struct drxk_state
*state
)
212 if (!state
->drxk_i2c_exclusive_lock
)
215 i2c_unlock_bus(state
->i2c
, I2C_LOCK_SEGMENT
);
216 state
->drxk_i2c_exclusive_lock
= false;
219 static int drxk_i2c_transfer(struct drxk_state
*state
, struct i2c_msg
*msgs
,
222 if (state
->drxk_i2c_exclusive_lock
)
223 return __i2c_transfer(state
->i2c
, msgs
, len
);
225 return i2c_transfer(state
->i2c
, msgs
, len
);
228 static int i2c_read1(struct drxk_state
*state
, u8 adr
, u8
*val
)
230 struct i2c_msg msgs
[1] = { {.addr
= adr
, .flags
= I2C_M_RD
,
231 .buf
= val
, .len
= 1}
234 return drxk_i2c_transfer(state
, msgs
, 1);
237 static int i2c_write(struct drxk_state
*state
, u8 adr
, u8
*data
, int len
)
240 struct i2c_msg msg
= {
241 .addr
= adr
, .flags
= 0, .buf
= data
, .len
= len
};
246 for (i
= 0; i
< len
; i
++)
247 pr_cont(" %02x", data
[i
]);
250 status
= drxk_i2c_transfer(state
, &msg
, 1);
251 if (status
>= 0 && status
!= 1)
255 pr_err("i2c write error at addr 0x%02x\n", adr
);
260 static int i2c_read(struct drxk_state
*state
,
261 u8 adr
, u8
*msg
, int len
, u8
*answ
, int alen
)
264 struct i2c_msg msgs
[2] = {
265 {.addr
= adr
, .flags
= 0,
266 .buf
= msg
, .len
= len
},
267 {.addr
= adr
, .flags
= I2C_M_RD
,
268 .buf
= answ
, .len
= alen
}
271 status
= drxk_i2c_transfer(state
, msgs
, 2);
274 pr_cont(": ERROR!\n");
278 pr_err("i2c read error at addr 0x%02x\n", adr
);
283 dprintk(2, ": read from");
284 for (i
= 0; i
< len
; i
++)
285 pr_cont(" %02x", msg
[i
]);
286 pr_cont(", value = ");
287 for (i
= 0; i
< alen
; i
++)
288 pr_cont(" %02x", answ
[i
]);
294 static int read16_flags(struct drxk_state
*state
, u32 reg
, u16
*data
, u8 flags
)
297 u8 adr
= state
->demod_address
, mm1
[4], mm2
[2], len
;
299 if (state
->single_master
)
302 if (DRXDAP_FASI_LONG_FORMAT(reg
) || (flags
!= 0)) {
303 mm1
[0] = (((reg
<< 1) & 0xFF) | 0x01);
304 mm1
[1] = ((reg
>> 16) & 0xFF);
305 mm1
[2] = ((reg
>> 24) & 0xFF) | flags
;
306 mm1
[3] = ((reg
>> 7) & 0xFF);
309 mm1
[0] = ((reg
<< 1) & 0xFF);
310 mm1
[1] = (((reg
>> 16) & 0x0F) | ((reg
>> 18) & 0xF0));
313 dprintk(2, "(0x%08x, 0x%02x)\n", reg
, flags
);
314 status
= i2c_read(state
, adr
, mm1
, len
, mm2
, 2);
318 *data
= mm2
[0] | (mm2
[1] << 8);
323 static int read16(struct drxk_state
*state
, u32 reg
, u16
*data
)
325 return read16_flags(state
, reg
, data
, 0);
328 static int read32_flags(struct drxk_state
*state
, u32 reg
, u32
*data
, u8 flags
)
331 u8 adr
= state
->demod_address
, mm1
[4], mm2
[4], len
;
333 if (state
->single_master
)
336 if (DRXDAP_FASI_LONG_FORMAT(reg
) || (flags
!= 0)) {
337 mm1
[0] = (((reg
<< 1) & 0xFF) | 0x01);
338 mm1
[1] = ((reg
>> 16) & 0xFF);
339 mm1
[2] = ((reg
>> 24) & 0xFF) | flags
;
340 mm1
[3] = ((reg
>> 7) & 0xFF);
343 mm1
[0] = ((reg
<< 1) & 0xFF);
344 mm1
[1] = (((reg
>> 16) & 0x0F) | ((reg
>> 18) & 0xF0));
347 dprintk(2, "(0x%08x, 0x%02x)\n", reg
, flags
);
348 status
= i2c_read(state
, adr
, mm1
, len
, mm2
, 4);
352 *data
= mm2
[0] | (mm2
[1] << 8) |
353 (mm2
[2] << 16) | (mm2
[3] << 24);
358 static int read32(struct drxk_state
*state
, u32 reg
, u32
*data
)
360 return read32_flags(state
, reg
, data
, 0);
363 static int write16_flags(struct drxk_state
*state
, u32 reg
, u16 data
, u8 flags
)
365 u8 adr
= state
->demod_address
, mm
[6], len
;
367 if (state
->single_master
)
369 if (DRXDAP_FASI_LONG_FORMAT(reg
) || (flags
!= 0)) {
370 mm
[0] = (((reg
<< 1) & 0xFF) | 0x01);
371 mm
[1] = ((reg
>> 16) & 0xFF);
372 mm
[2] = ((reg
>> 24) & 0xFF) | flags
;
373 mm
[3] = ((reg
>> 7) & 0xFF);
376 mm
[0] = ((reg
<< 1) & 0xFF);
377 mm
[1] = (((reg
>> 16) & 0x0F) | ((reg
>> 18) & 0xF0));
380 mm
[len
] = data
& 0xff;
381 mm
[len
+ 1] = (data
>> 8) & 0xff;
383 dprintk(2, "(0x%08x, 0x%04x, 0x%02x)\n", reg
, data
, flags
);
384 return i2c_write(state
, adr
, mm
, len
+ 2);
387 static int write16(struct drxk_state
*state
, u32 reg
, u16 data
)
389 return write16_flags(state
, reg
, data
, 0);
392 static int write32_flags(struct drxk_state
*state
, u32 reg
, u32 data
, u8 flags
)
394 u8 adr
= state
->demod_address
, mm
[8], len
;
396 if (state
->single_master
)
398 if (DRXDAP_FASI_LONG_FORMAT(reg
) || (flags
!= 0)) {
399 mm
[0] = (((reg
<< 1) & 0xFF) | 0x01);
400 mm
[1] = ((reg
>> 16) & 0xFF);
401 mm
[2] = ((reg
>> 24) & 0xFF) | flags
;
402 mm
[3] = ((reg
>> 7) & 0xFF);
405 mm
[0] = ((reg
<< 1) & 0xFF);
406 mm
[1] = (((reg
>> 16) & 0x0F) | ((reg
>> 18) & 0xF0));
409 mm
[len
] = data
& 0xff;
410 mm
[len
+ 1] = (data
>> 8) & 0xff;
411 mm
[len
+ 2] = (data
>> 16) & 0xff;
412 mm
[len
+ 3] = (data
>> 24) & 0xff;
413 dprintk(2, "(0x%08x, 0x%08x, 0x%02x)\n", reg
, data
, flags
);
415 return i2c_write(state
, adr
, mm
, len
+ 4);
418 static int write32(struct drxk_state
*state
, u32 reg
, u32 data
)
420 return write32_flags(state
, reg
, data
, 0);
423 static int write_block(struct drxk_state
*state
, u32 address
,
424 const int block_size
, const u8 p_block
[])
426 int status
= 0, blk_size
= block_size
;
429 if (state
->single_master
)
432 while (blk_size
> 0) {
433 int chunk
= blk_size
> state
->m_chunk_size
?
434 state
->m_chunk_size
: blk_size
;
435 u8
*adr_buf
= &state
->chunk
[0];
438 if (DRXDAP_FASI_LONG_FORMAT(address
) || (flags
!= 0)) {
439 adr_buf
[0] = (((address
<< 1) & 0xFF) | 0x01);
440 adr_buf
[1] = ((address
>> 16) & 0xFF);
441 adr_buf
[2] = ((address
>> 24) & 0xFF);
442 adr_buf
[3] = ((address
>> 7) & 0xFF);
445 if (chunk
== state
->m_chunk_size
)
448 adr_buf
[0] = ((address
<< 1) & 0xFF);
449 adr_buf
[1] = (((address
>> 16) & 0x0F) |
450 ((address
>> 18) & 0xF0));
453 memcpy(&state
->chunk
[adr_length
], p_block
, chunk
);
454 dprintk(2, "(0x%08x, 0x%02x)\n", address
, flags
);
458 for (i
= 0; i
< chunk
; i
++)
459 pr_cont(" %02x", p_block
[i
]);
462 status
= i2c_write(state
, state
->demod_address
,
463 &state
->chunk
[0], chunk
+ adr_length
);
465 pr_err("%s: i2c write error at addr 0x%02x\n",
470 address
+= (chunk
>> 1);
476 #ifndef DRXK_MAX_RETRIES_POWERUP
477 #define DRXK_MAX_RETRIES_POWERUP 20
480 static int power_up_device(struct drxk_state
*state
)
488 status
= i2c_read1(state
, state
->demod_address
, &data
);
492 status
= i2c_write(state
, state
->demod_address
,
494 usleep_range(10000, 11000);
498 status
= i2c_read1(state
, state
->demod_address
,
500 } while (status
< 0 &&
501 (retry_count
< DRXK_MAX_RETRIES_POWERUP
));
502 if (status
< 0 && retry_count
>= DRXK_MAX_RETRIES_POWERUP
)
506 /* Make sure all clk domains are active */
507 status
= write16(state
, SIO_CC_PWD_MODE__A
, SIO_CC_PWD_MODE_LEVEL_NONE
);
510 status
= write16(state
, SIO_CC_UPDATE__A
, SIO_CC_UPDATE_KEY
);
513 /* Enable pll lock tests */
514 status
= write16(state
, SIO_CC_PLL_LOCK__A
, 1);
518 state
->m_current_power_mode
= DRX_POWER_UP
;
522 pr_err("Error %d on %s\n", status
, __func__
);
528 static int init_state(struct drxk_state
*state
)
531 * FIXME: most (all?) of the values below should be moved into
532 * struct drxk_config, as they are probably board-specific
534 u32 ul_vsb_if_agc_mode
= DRXK_AGC_CTRL_AUTO
;
535 u32 ul_vsb_if_agc_output_level
= 0;
536 u32 ul_vsb_if_agc_min_level
= 0;
537 u32 ul_vsb_if_agc_max_level
= 0x7FFF;
538 u32 ul_vsb_if_agc_speed
= 3;
540 u32 ul_vsb_rf_agc_mode
= DRXK_AGC_CTRL_AUTO
;
541 u32 ul_vsb_rf_agc_output_level
= 0;
542 u32 ul_vsb_rf_agc_min_level
= 0;
543 u32 ul_vsb_rf_agc_max_level
= 0x7FFF;
544 u32 ul_vsb_rf_agc_speed
= 3;
545 u32 ul_vsb_rf_agc_top
= 9500;
546 u32 ul_vsb_rf_agc_cut_off_current
= 4000;
548 u32 ul_atv_if_agc_mode
= DRXK_AGC_CTRL_AUTO
;
549 u32 ul_atv_if_agc_output_level
= 0;
550 u32 ul_atv_if_agc_min_level
= 0;
551 u32 ul_atv_if_agc_max_level
= 0;
552 u32 ul_atv_if_agc_speed
= 3;
554 u32 ul_atv_rf_agc_mode
= DRXK_AGC_CTRL_OFF
;
555 u32 ul_atv_rf_agc_output_level
= 0;
556 u32 ul_atv_rf_agc_min_level
= 0;
557 u32 ul_atv_rf_agc_max_level
= 0;
558 u32 ul_atv_rf_agc_top
= 9500;
559 u32 ul_atv_rf_agc_cut_off_current
= 4000;
560 u32 ul_atv_rf_agc_speed
= 3;
562 u32 ulQual83
= DEFAULT_MER_83
;
563 u32 ulQual93
= DEFAULT_MER_93
;
565 u32 ul_mpeg_lock_time_out
= DEFAULT_DRXK_MPEG_LOCK_TIMEOUT
;
566 u32 ul_demod_lock_time_out
= DEFAULT_DRXK_DEMOD_LOCK_TIMEOUT
;
568 /* io_pad_cfg register (8 bit reg.) MSB bit is 1 (default value) */
569 /* io_pad_cfg_mode output mode is drive always */
570 /* io_pad_cfg_drive is set to power 2 (23 mA) */
571 u32 ul_gpio_cfg
= 0x0113;
572 u32 ul_invert_ts_clock
= 0;
573 u32 ul_ts_data_strength
= DRXK_MPEG_SERIAL_OUTPUT_PIN_DRIVE_STRENGTH
;
574 u32 ul_dvbt_bitrate
= 50000000;
575 u32 ul_dvbc_bitrate
= DRXK_QAM_SYMBOLRATE_MAX
* 8;
577 u32 ul_insert_rs_byte
= 0;
579 u32 ul_rf_mirror
= 1;
580 u32 ul_power_down
= 0;
584 state
->m_has_lna
= false;
585 state
->m_has_dvbt
= false;
586 state
->m_has_dvbc
= false;
587 state
->m_has_atv
= false;
588 state
->m_has_oob
= false;
589 state
->m_has_audio
= false;
591 if (!state
->m_chunk_size
)
592 state
->m_chunk_size
= 124;
594 state
->m_osc_clock_freq
= 0;
595 state
->m_smart_ant_inverted
= false;
596 state
->m_b_p_down_open_bridge
= false;
598 /* real system clock frequency in kHz */
599 state
->m_sys_clock_freq
= 151875;
600 /* Timing div, 250ns/Psys */
601 /* Timing div, = (delay (nano seconds) * sysclk (kHz))/ 1000 */
602 state
->m_hi_cfg_timing_div
= ((state
->m_sys_clock_freq
/ 1000) *
603 HI_I2C_DELAY
) / 1000;
605 if (state
->m_hi_cfg_timing_div
> SIO_HI_RA_RAM_PAR_2_CFG_DIV__M
)
606 state
->m_hi_cfg_timing_div
= SIO_HI_RA_RAM_PAR_2_CFG_DIV__M
;
607 state
->m_hi_cfg_wake_up_key
= (state
->demod_address
<< 1);
608 /* port/bridge/power down ctrl */
609 state
->m_hi_cfg_ctrl
= SIO_HI_RA_RAM_PAR_5_CFG_SLV0_SLAVE
;
611 state
->m_b_power_down
= (ul_power_down
!= 0);
613 state
->m_drxk_a3_patch_code
= false;
615 /* Init AGC and PGA parameters */
617 state
->m_vsb_if_agc_cfg
.ctrl_mode
= ul_vsb_if_agc_mode
;
618 state
->m_vsb_if_agc_cfg
.output_level
= ul_vsb_if_agc_output_level
;
619 state
->m_vsb_if_agc_cfg
.min_output_level
= ul_vsb_if_agc_min_level
;
620 state
->m_vsb_if_agc_cfg
.max_output_level
= ul_vsb_if_agc_max_level
;
621 state
->m_vsb_if_agc_cfg
.speed
= ul_vsb_if_agc_speed
;
622 state
->m_vsb_pga_cfg
= 140;
625 state
->m_vsb_rf_agc_cfg
.ctrl_mode
= ul_vsb_rf_agc_mode
;
626 state
->m_vsb_rf_agc_cfg
.output_level
= ul_vsb_rf_agc_output_level
;
627 state
->m_vsb_rf_agc_cfg
.min_output_level
= ul_vsb_rf_agc_min_level
;
628 state
->m_vsb_rf_agc_cfg
.max_output_level
= ul_vsb_rf_agc_max_level
;
629 state
->m_vsb_rf_agc_cfg
.speed
= ul_vsb_rf_agc_speed
;
630 state
->m_vsb_rf_agc_cfg
.top
= ul_vsb_rf_agc_top
;
631 state
->m_vsb_rf_agc_cfg
.cut_off_current
= ul_vsb_rf_agc_cut_off_current
;
632 state
->m_vsb_pre_saw_cfg
.reference
= 0x07;
633 state
->m_vsb_pre_saw_cfg
.use_pre_saw
= true;
635 state
->m_Quality83percent
= DEFAULT_MER_83
;
636 state
->m_Quality93percent
= DEFAULT_MER_93
;
637 if (ulQual93
<= 500 && ulQual83
< ulQual93
) {
638 state
->m_Quality83percent
= ulQual83
;
639 state
->m_Quality93percent
= ulQual93
;
643 state
->m_atv_if_agc_cfg
.ctrl_mode
= ul_atv_if_agc_mode
;
644 state
->m_atv_if_agc_cfg
.output_level
= ul_atv_if_agc_output_level
;
645 state
->m_atv_if_agc_cfg
.min_output_level
= ul_atv_if_agc_min_level
;
646 state
->m_atv_if_agc_cfg
.max_output_level
= ul_atv_if_agc_max_level
;
647 state
->m_atv_if_agc_cfg
.speed
= ul_atv_if_agc_speed
;
650 state
->m_atv_rf_agc_cfg
.ctrl_mode
= ul_atv_rf_agc_mode
;
651 state
->m_atv_rf_agc_cfg
.output_level
= ul_atv_rf_agc_output_level
;
652 state
->m_atv_rf_agc_cfg
.min_output_level
= ul_atv_rf_agc_min_level
;
653 state
->m_atv_rf_agc_cfg
.max_output_level
= ul_atv_rf_agc_max_level
;
654 state
->m_atv_rf_agc_cfg
.speed
= ul_atv_rf_agc_speed
;
655 state
->m_atv_rf_agc_cfg
.top
= ul_atv_rf_agc_top
;
656 state
->m_atv_rf_agc_cfg
.cut_off_current
= ul_atv_rf_agc_cut_off_current
;
657 state
->m_atv_pre_saw_cfg
.reference
= 0x04;
658 state
->m_atv_pre_saw_cfg
.use_pre_saw
= true;
662 state
->m_dvbt_rf_agc_cfg
.ctrl_mode
= DRXK_AGC_CTRL_OFF
;
663 state
->m_dvbt_rf_agc_cfg
.output_level
= 0;
664 state
->m_dvbt_rf_agc_cfg
.min_output_level
= 0;
665 state
->m_dvbt_rf_agc_cfg
.max_output_level
= 0xFFFF;
666 state
->m_dvbt_rf_agc_cfg
.top
= 0x2100;
667 state
->m_dvbt_rf_agc_cfg
.cut_off_current
= 4000;
668 state
->m_dvbt_rf_agc_cfg
.speed
= 1;
672 state
->m_dvbt_if_agc_cfg
.ctrl_mode
= DRXK_AGC_CTRL_AUTO
;
673 state
->m_dvbt_if_agc_cfg
.output_level
= 0;
674 state
->m_dvbt_if_agc_cfg
.min_output_level
= 0;
675 state
->m_dvbt_if_agc_cfg
.max_output_level
= 9000;
676 state
->m_dvbt_if_agc_cfg
.top
= 13424;
677 state
->m_dvbt_if_agc_cfg
.cut_off_current
= 0;
678 state
->m_dvbt_if_agc_cfg
.speed
= 3;
679 state
->m_dvbt_if_agc_cfg
.fast_clip_ctrl_delay
= 30;
680 state
->m_dvbt_if_agc_cfg
.ingain_tgt_max
= 30000;
681 /* state->m_dvbtPgaCfg = 140; */
683 state
->m_dvbt_pre_saw_cfg
.reference
= 4;
684 state
->m_dvbt_pre_saw_cfg
.use_pre_saw
= false;
687 state
->m_qam_rf_agc_cfg
.ctrl_mode
= DRXK_AGC_CTRL_OFF
;
688 state
->m_qam_rf_agc_cfg
.output_level
= 0;
689 state
->m_qam_rf_agc_cfg
.min_output_level
= 6023;
690 state
->m_qam_rf_agc_cfg
.max_output_level
= 27000;
691 state
->m_qam_rf_agc_cfg
.top
= 0x2380;
692 state
->m_qam_rf_agc_cfg
.cut_off_current
= 4000;
693 state
->m_qam_rf_agc_cfg
.speed
= 3;
696 state
->m_qam_if_agc_cfg
.ctrl_mode
= DRXK_AGC_CTRL_AUTO
;
697 state
->m_qam_if_agc_cfg
.output_level
= 0;
698 state
->m_qam_if_agc_cfg
.min_output_level
= 0;
699 state
->m_qam_if_agc_cfg
.max_output_level
= 9000;
700 state
->m_qam_if_agc_cfg
.top
= 0x0511;
701 state
->m_qam_if_agc_cfg
.cut_off_current
= 0;
702 state
->m_qam_if_agc_cfg
.speed
= 3;
703 state
->m_qam_if_agc_cfg
.ingain_tgt_max
= 5119;
704 state
->m_qam_if_agc_cfg
.fast_clip_ctrl_delay
= 50;
706 state
->m_qam_pga_cfg
= 140;
707 state
->m_qam_pre_saw_cfg
.reference
= 4;
708 state
->m_qam_pre_saw_cfg
.use_pre_saw
= false;
710 state
->m_operation_mode
= OM_NONE
;
711 state
->m_drxk_state
= DRXK_UNINITIALIZED
;
713 /* MPEG output configuration */
714 state
->m_enable_mpeg_output
= true; /* If TRUE; enable MPEG output */
715 state
->m_insert_rs_byte
= false; /* If TRUE; insert RS byte */
716 state
->m_invert_data
= false; /* If TRUE; invert DATA signals */
717 state
->m_invert_err
= false; /* If TRUE; invert ERR signal */
718 state
->m_invert_str
= false; /* If TRUE; invert STR signals */
719 state
->m_invert_val
= false; /* If TRUE; invert VAL signals */
720 state
->m_invert_clk
= (ul_invert_ts_clock
!= 0); /* If TRUE; invert CLK signals */
722 /* If TRUE; static MPEG clockrate will be used;
723 otherwise clockrate will adapt to the bitrate of the TS */
725 state
->m_dvbt_bitrate
= ul_dvbt_bitrate
;
726 state
->m_dvbc_bitrate
= ul_dvbc_bitrate
;
728 state
->m_ts_data_strength
= (ul_ts_data_strength
& 0x07);
730 /* Maximum bitrate in b/s in case static clockrate is selected */
731 state
->m_mpeg_ts_static_bitrate
= 19392658;
732 state
->m_disable_te_ihandling
= false;
734 if (ul_insert_rs_byte
)
735 state
->m_insert_rs_byte
= true;
737 state
->m_mpeg_lock_time_out
= DEFAULT_DRXK_MPEG_LOCK_TIMEOUT
;
738 if (ul_mpeg_lock_time_out
< 10000)
739 state
->m_mpeg_lock_time_out
= ul_mpeg_lock_time_out
;
740 state
->m_demod_lock_time_out
= DEFAULT_DRXK_DEMOD_LOCK_TIMEOUT
;
741 if (ul_demod_lock_time_out
< 10000)
742 state
->m_demod_lock_time_out
= ul_demod_lock_time_out
;
745 state
->m_constellation
= DRX_CONSTELLATION_AUTO
;
746 state
->m_qam_interleave_mode
= DRXK_QAM_I12_J17
;
747 state
->m_fec_rs_plen
= 204 * 8; /* fecRsPlen annex A */
748 state
->m_fec_rs_prescale
= 1;
750 state
->m_sqi_speed
= DRXK_DVBT_SQI_SPEED_MEDIUM
;
751 state
->m_agcfast_clip_ctrl_delay
= 0;
753 state
->m_gpio_cfg
= ul_gpio_cfg
;
755 state
->m_b_power_down
= false;
756 state
->m_current_power_mode
= DRX_POWER_DOWN
;
758 state
->m_rfmirror
= (ul_rf_mirror
== 0);
759 state
->m_if_agc_pol
= false;
763 static int drxx_open(struct drxk_state
*state
)
771 /* stop lock indicator process */
772 status
= write16(state
, SCU_RAM_GPIO__A
,
773 SCU_RAM_GPIO_HW_LOCK_IND_DISABLE
);
776 /* Check device id */
777 status
= read16(state
, SIO_TOP_COMM_KEY__A
, &key
);
780 status
= write16(state
, SIO_TOP_COMM_KEY__A
, SIO_TOP_COMM_KEY_KEY
);
783 status
= read32(state
, SIO_TOP_JTAGID_LO__A
, &jtag
);
786 status
= read16(state
, SIO_PDR_UIO_IN_HI__A
, &bid
);
789 status
= write16(state
, SIO_TOP_COMM_KEY__A
, key
);
792 pr_err("Error %d on %s\n", status
, __func__
);
796 static int get_device_capabilities(struct drxk_state
*state
)
798 u16 sio_pdr_ohw_cfg
= 0;
799 u32 sio_top_jtagid_lo
= 0;
801 const char *spin
= "";
806 /* stop lock indicator process */
807 status
= write16(state
, SCU_RAM_GPIO__A
,
808 SCU_RAM_GPIO_HW_LOCK_IND_DISABLE
);
811 status
= write16(state
, SIO_TOP_COMM_KEY__A
, SIO_TOP_COMM_KEY_KEY
);
814 status
= read16(state
, SIO_PDR_OHW_CFG__A
, &sio_pdr_ohw_cfg
);
817 status
= write16(state
, SIO_TOP_COMM_KEY__A
, 0x0000);
821 switch ((sio_pdr_ohw_cfg
& SIO_PDR_OHW_CFG_FREF_SEL__M
)) {
823 /* ignore (bypass ?) */
827 state
->m_osc_clock_freq
= 27000;
831 state
->m_osc_clock_freq
= 20250;
835 state
->m_osc_clock_freq
= 20250;
838 pr_err("Clock Frequency is unknown\n");
842 Determine device capabilities
845 status
= read32(state
, SIO_TOP_JTAGID_LO__A
, &sio_top_jtagid_lo
);
849 pr_info("status = 0x%08x\n", sio_top_jtagid_lo
);
852 switch ((sio_top_jtagid_lo
>> 29) & 0xF) {
854 state
->m_device_spin
= DRXK_SPIN_A1
;
858 state
->m_device_spin
= DRXK_SPIN_A2
;
862 state
->m_device_spin
= DRXK_SPIN_A3
;
866 state
->m_device_spin
= DRXK_SPIN_UNKNOWN
;
868 pr_err("Spin %d unknown\n", (sio_top_jtagid_lo
>> 29) & 0xF);
871 switch ((sio_top_jtagid_lo
>> 12) & 0xFF) {
873 /* typeId = DRX3913K_TYPE_ID */
874 state
->m_has_lna
= false;
875 state
->m_has_oob
= false;
876 state
->m_has_atv
= false;
877 state
->m_has_audio
= false;
878 state
->m_has_dvbt
= true;
879 state
->m_has_dvbc
= true;
880 state
->m_has_sawsw
= true;
881 state
->m_has_gpio2
= false;
882 state
->m_has_gpio1
= false;
883 state
->m_has_irqn
= false;
886 /* typeId = DRX3915K_TYPE_ID */
887 state
->m_has_lna
= false;
888 state
->m_has_oob
= false;
889 state
->m_has_atv
= true;
890 state
->m_has_audio
= false;
891 state
->m_has_dvbt
= true;
892 state
->m_has_dvbc
= false;
893 state
->m_has_sawsw
= true;
894 state
->m_has_gpio2
= true;
895 state
->m_has_gpio1
= true;
896 state
->m_has_irqn
= false;
899 /* typeId = DRX3916K_TYPE_ID */
900 state
->m_has_lna
= false;
901 state
->m_has_oob
= false;
902 state
->m_has_atv
= true;
903 state
->m_has_audio
= false;
904 state
->m_has_dvbt
= true;
905 state
->m_has_dvbc
= false;
906 state
->m_has_sawsw
= true;
907 state
->m_has_gpio2
= true;
908 state
->m_has_gpio1
= true;
909 state
->m_has_irqn
= false;
912 /* typeId = DRX3918K_TYPE_ID */
913 state
->m_has_lna
= false;
914 state
->m_has_oob
= false;
915 state
->m_has_atv
= true;
916 state
->m_has_audio
= true;
917 state
->m_has_dvbt
= true;
918 state
->m_has_dvbc
= false;
919 state
->m_has_sawsw
= true;
920 state
->m_has_gpio2
= true;
921 state
->m_has_gpio1
= true;
922 state
->m_has_irqn
= false;
925 /* typeId = DRX3921K_TYPE_ID */
926 state
->m_has_lna
= false;
927 state
->m_has_oob
= false;
928 state
->m_has_atv
= true;
929 state
->m_has_audio
= true;
930 state
->m_has_dvbt
= true;
931 state
->m_has_dvbc
= true;
932 state
->m_has_sawsw
= true;
933 state
->m_has_gpio2
= true;
934 state
->m_has_gpio1
= true;
935 state
->m_has_irqn
= false;
938 /* typeId = DRX3923K_TYPE_ID */
939 state
->m_has_lna
= false;
940 state
->m_has_oob
= false;
941 state
->m_has_atv
= true;
942 state
->m_has_audio
= true;
943 state
->m_has_dvbt
= true;
944 state
->m_has_dvbc
= true;
945 state
->m_has_sawsw
= true;
946 state
->m_has_gpio2
= true;
947 state
->m_has_gpio1
= true;
948 state
->m_has_irqn
= false;
951 /* typeId = DRX3925K_TYPE_ID */
952 state
->m_has_lna
= false;
953 state
->m_has_oob
= false;
954 state
->m_has_atv
= true;
955 state
->m_has_audio
= true;
956 state
->m_has_dvbt
= true;
957 state
->m_has_dvbc
= true;
958 state
->m_has_sawsw
= true;
959 state
->m_has_gpio2
= true;
960 state
->m_has_gpio1
= true;
961 state
->m_has_irqn
= false;
964 /* typeId = DRX3926K_TYPE_ID */
965 state
->m_has_lna
= false;
966 state
->m_has_oob
= false;
967 state
->m_has_atv
= true;
968 state
->m_has_audio
= false;
969 state
->m_has_dvbt
= true;
970 state
->m_has_dvbc
= true;
971 state
->m_has_sawsw
= true;
972 state
->m_has_gpio2
= true;
973 state
->m_has_gpio1
= true;
974 state
->m_has_irqn
= false;
977 pr_err("DeviceID 0x%02x not supported\n",
978 ((sio_top_jtagid_lo
>> 12) & 0xFF));
983 pr_info("detected a drx-39%02xk, spin %s, xtal %d.%03d MHz\n",
984 ((sio_top_jtagid_lo
>> 12) & 0xFF), spin
,
985 state
->m_osc_clock_freq
/ 1000,
986 state
->m_osc_clock_freq
% 1000);
990 pr_err("Error %d on %s\n", status
, __func__
);
996 static int hi_command(struct drxk_state
*state
, u16 cmd
, u16
*p_result
)
1004 status
= write16(state
, SIO_HI_RA_RAM_CMD__A
, cmd
);
1007 if (cmd
== SIO_HI_RA_RAM_CMD_RESET
)
1008 usleep_range(1000, 2000);
1011 (bool) ((cmd
== SIO_HI_RA_RAM_CMD_CONFIG
) &&
1012 ((state
->m_hi_cfg_ctrl
) &
1013 SIO_HI_RA_RAM_PAR_5_CFG_SLEEP__M
) ==
1014 SIO_HI_RA_RAM_PAR_5_CFG_SLEEP_ZZZ
);
1015 if (!powerdown_cmd
) {
1016 /* Wait until command rdy */
1017 u32 retry_count
= 0;
1021 usleep_range(1000, 2000);
1023 status
= read16(state
, SIO_HI_RA_RAM_CMD__A
,
1025 } while ((status
< 0) && (retry_count
< DRXK_MAX_RETRIES
)
1026 && (wait_cmd
!= 0));
1029 status
= read16(state
, SIO_HI_RA_RAM_RES__A
, p_result
);
1033 pr_err("Error %d on %s\n", status
, __func__
);
1038 static int hi_cfg_command(struct drxk_state
*state
)
1044 mutex_lock(&state
->mutex
);
1046 status
= write16(state
, SIO_HI_RA_RAM_PAR_6__A
,
1047 state
->m_hi_cfg_timeout
);
1050 status
= write16(state
, SIO_HI_RA_RAM_PAR_5__A
,
1051 state
->m_hi_cfg_ctrl
);
1054 status
= write16(state
, SIO_HI_RA_RAM_PAR_4__A
,
1055 state
->m_hi_cfg_wake_up_key
);
1058 status
= write16(state
, SIO_HI_RA_RAM_PAR_3__A
,
1059 state
->m_hi_cfg_bridge_delay
);
1062 status
= write16(state
, SIO_HI_RA_RAM_PAR_2__A
,
1063 state
->m_hi_cfg_timing_div
);
1066 status
= write16(state
, SIO_HI_RA_RAM_PAR_1__A
,
1067 SIO_HI_RA_RAM_PAR_1_PAR1_SEC_KEY
);
1070 status
= hi_command(state
, SIO_HI_RA_RAM_CMD_CONFIG
, NULL
);
1074 state
->m_hi_cfg_ctrl
&= ~SIO_HI_RA_RAM_PAR_5_CFG_SLEEP_ZZZ
;
1076 mutex_unlock(&state
->mutex
);
1078 pr_err("Error %d on %s\n", status
, __func__
);
1082 static int init_hi(struct drxk_state
*state
)
1086 state
->m_hi_cfg_wake_up_key
= (state
->demod_address
<< 1);
1087 state
->m_hi_cfg_timeout
= 0x96FF;
1088 /* port/bridge/power down ctrl */
1089 state
->m_hi_cfg_ctrl
= SIO_HI_RA_RAM_PAR_5_CFG_SLV0_SLAVE
;
1091 return hi_cfg_command(state
);
1094 static int mpegts_configure_pins(struct drxk_state
*state
, bool mpeg_enable
)
1097 u16 sio_pdr_mclk_cfg
= 0;
1098 u16 sio_pdr_mdx_cfg
= 0;
1101 dprintk(1, ": mpeg %s, %s mode\n",
1102 mpeg_enable
? "enable" : "disable",
1103 state
->m_enable_parallel
? "parallel" : "serial");
1105 /* stop lock indicator process */
1106 status
= write16(state
, SCU_RAM_GPIO__A
,
1107 SCU_RAM_GPIO_HW_LOCK_IND_DISABLE
);
1111 /* MPEG TS pad configuration */
1112 status
= write16(state
, SIO_TOP_COMM_KEY__A
, SIO_TOP_COMM_KEY_KEY
);
1117 /* Set MPEG TS pads to inputmode */
1118 status
= write16(state
, SIO_PDR_MSTRT_CFG__A
, 0x0000);
1121 status
= write16(state
, SIO_PDR_MERR_CFG__A
, 0x0000);
1124 status
= write16(state
, SIO_PDR_MCLK_CFG__A
, 0x0000);
1127 status
= write16(state
, SIO_PDR_MVAL_CFG__A
, 0x0000);
1130 status
= write16(state
, SIO_PDR_MD0_CFG__A
, 0x0000);
1133 status
= write16(state
, SIO_PDR_MD1_CFG__A
, 0x0000);
1136 status
= write16(state
, SIO_PDR_MD2_CFG__A
, 0x0000);
1139 status
= write16(state
, SIO_PDR_MD3_CFG__A
, 0x0000);
1142 status
= write16(state
, SIO_PDR_MD4_CFG__A
, 0x0000);
1145 status
= write16(state
, SIO_PDR_MD5_CFG__A
, 0x0000);
1148 status
= write16(state
, SIO_PDR_MD6_CFG__A
, 0x0000);
1151 status
= write16(state
, SIO_PDR_MD7_CFG__A
, 0x0000);
1155 /* Enable MPEG output */
1157 ((state
->m_ts_data_strength
<<
1158 SIO_PDR_MD0_CFG_DRIVE__B
) | 0x0003);
1159 sio_pdr_mclk_cfg
= ((state
->m_ts_clockk_strength
<<
1160 SIO_PDR_MCLK_CFG_DRIVE__B
) |
1163 status
= write16(state
, SIO_PDR_MSTRT_CFG__A
, sio_pdr_mdx_cfg
);
1167 if (state
->enable_merr_cfg
)
1168 err_cfg
= sio_pdr_mdx_cfg
;
1170 status
= write16(state
, SIO_PDR_MERR_CFG__A
, err_cfg
);
1173 status
= write16(state
, SIO_PDR_MVAL_CFG__A
, err_cfg
);
1177 if (state
->m_enable_parallel
) {
1178 /* parallel -> enable MD1 to MD7 */
1179 status
= write16(state
, SIO_PDR_MD1_CFG__A
,
1183 status
= write16(state
, SIO_PDR_MD2_CFG__A
,
1187 status
= write16(state
, SIO_PDR_MD3_CFG__A
,
1191 status
= write16(state
, SIO_PDR_MD4_CFG__A
,
1195 status
= write16(state
, SIO_PDR_MD5_CFG__A
,
1199 status
= write16(state
, SIO_PDR_MD6_CFG__A
,
1203 status
= write16(state
, SIO_PDR_MD7_CFG__A
,
1208 sio_pdr_mdx_cfg
= ((state
->m_ts_data_strength
<<
1209 SIO_PDR_MD0_CFG_DRIVE__B
)
1211 /* serial -> disable MD1 to MD7 */
1212 status
= write16(state
, SIO_PDR_MD1_CFG__A
, 0x0000);
1215 status
= write16(state
, SIO_PDR_MD2_CFG__A
, 0x0000);
1218 status
= write16(state
, SIO_PDR_MD3_CFG__A
, 0x0000);
1221 status
= write16(state
, SIO_PDR_MD4_CFG__A
, 0x0000);
1224 status
= write16(state
, SIO_PDR_MD5_CFG__A
, 0x0000);
1227 status
= write16(state
, SIO_PDR_MD6_CFG__A
, 0x0000);
1230 status
= write16(state
, SIO_PDR_MD7_CFG__A
, 0x0000);
1234 status
= write16(state
, SIO_PDR_MCLK_CFG__A
, sio_pdr_mclk_cfg
);
1237 status
= write16(state
, SIO_PDR_MD0_CFG__A
, sio_pdr_mdx_cfg
);
1241 /* Enable MB output over MPEG pads and ctl input */
1242 status
= write16(state
, SIO_PDR_MON_CFG__A
, 0x0000);
1245 /* Write nomagic word to enable pdr reg write */
1246 status
= write16(state
, SIO_TOP_COMM_KEY__A
, 0x0000);
1249 pr_err("Error %d on %s\n", status
, __func__
);
1253 static int mpegts_disable(struct drxk_state
*state
)
1257 return mpegts_configure_pins(state
, false);
1260 static int bl_chain_cmd(struct drxk_state
*state
,
1261 u16 rom_offset
, u16 nr_of_elements
, u32 time_out
)
1268 mutex_lock(&state
->mutex
);
1269 status
= write16(state
, SIO_BL_MODE__A
, SIO_BL_MODE_CHAIN
);
1272 status
= write16(state
, SIO_BL_CHAIN_ADDR__A
, rom_offset
);
1275 status
= write16(state
, SIO_BL_CHAIN_LEN__A
, nr_of_elements
);
1278 status
= write16(state
, SIO_BL_ENABLE__A
, SIO_BL_ENABLE_ON
);
1282 end
= jiffies
+ msecs_to_jiffies(time_out
);
1284 usleep_range(1000, 2000);
1285 status
= read16(state
, SIO_BL_STATUS__A
, &bl_status
);
1288 } while ((bl_status
== 0x1) &&
1289 ((time_is_after_jiffies(end
))));
1291 if (bl_status
== 0x1) {
1292 pr_err("SIO not ready\n");
1298 pr_err("Error %d on %s\n", status
, __func__
);
1300 mutex_unlock(&state
->mutex
);
1305 static int download_microcode(struct drxk_state
*state
,
1306 const u8 p_mc_image
[], u32 length
)
1308 const u8
*p_src
= p_mc_image
;
1318 /* down the drain (we don't care about MAGIC_WORD) */
1320 /* For future reference */
1321 drain
= (p_src
[0] << 8) | p_src
[1];
1323 p_src
+= sizeof(u16
);
1324 offset
+= sizeof(u16
);
1325 n_blocks
= (p_src
[0] << 8) | p_src
[1];
1326 p_src
+= sizeof(u16
);
1327 offset
+= sizeof(u16
);
1329 for (i
= 0; i
< n_blocks
; i
+= 1) {
1330 address
= (p_src
[0] << 24) | (p_src
[1] << 16) |
1331 (p_src
[2] << 8) | p_src
[3];
1332 p_src
+= sizeof(u32
);
1333 offset
+= sizeof(u32
);
1335 block_size
= ((p_src
[0] << 8) | p_src
[1]) * sizeof(u16
);
1336 p_src
+= sizeof(u16
);
1337 offset
+= sizeof(u16
);
1340 /* For future reference */
1341 flags
= (p_src
[0] << 8) | p_src
[1];
1343 p_src
+= sizeof(u16
);
1344 offset
+= sizeof(u16
);
1347 /* For future reference */
1348 block_crc
= (p_src
[0] << 8) | p_src
[1];
1350 p_src
+= sizeof(u16
);
1351 offset
+= sizeof(u16
);
1353 if (offset
+ block_size
> length
) {
1354 pr_err("Firmware is corrupted.\n");
1358 status
= write_block(state
, address
, block_size
, p_src
);
1360 pr_err("Error %d while loading firmware\n", status
);
1363 p_src
+= block_size
;
1364 offset
+= block_size
;
1369 static int dvbt_enable_ofdm_token_ring(struct drxk_state
*state
, bool enable
)
1373 u16 desired_ctrl
= SIO_OFDM_SH_OFDM_RING_ENABLE_ON
;
1374 u16 desired_status
= SIO_OFDM_SH_OFDM_RING_STATUS_ENABLED
;
1380 desired_ctrl
= SIO_OFDM_SH_OFDM_RING_ENABLE_OFF
;
1381 desired_status
= SIO_OFDM_SH_OFDM_RING_STATUS_DOWN
;
1384 status
= read16(state
, SIO_OFDM_SH_OFDM_RING_STATUS__A
, &data
);
1385 if (status
>= 0 && data
== desired_status
) {
1386 /* tokenring already has correct status */
1389 /* Disable/enable dvbt tokenring bridge */
1390 status
= write16(state
, SIO_OFDM_SH_OFDM_RING_ENABLE__A
, desired_ctrl
);
1392 end
= jiffies
+ msecs_to_jiffies(DRXK_OFDM_TR_SHUTDOWN_TIMEOUT
);
1394 status
= read16(state
, SIO_OFDM_SH_OFDM_RING_STATUS__A
, &data
);
1395 if ((status
>= 0 && data
== desired_status
)
1396 || time_is_after_jiffies(end
))
1398 usleep_range(1000, 2000);
1400 if (data
!= desired_status
) {
1401 pr_err("SIO not ready\n");
1407 static int mpegts_stop(struct drxk_state
*state
)
1410 u16 fec_oc_snc_mode
= 0;
1411 u16 fec_oc_ipr_mode
= 0;
1415 /* Graceful shutdown (byte boundaries) */
1416 status
= read16(state
, FEC_OC_SNC_MODE__A
, &fec_oc_snc_mode
);
1419 fec_oc_snc_mode
|= FEC_OC_SNC_MODE_SHUTDOWN__M
;
1420 status
= write16(state
, FEC_OC_SNC_MODE__A
, fec_oc_snc_mode
);
1424 /* Suppress MCLK during absence of data */
1425 status
= read16(state
, FEC_OC_IPR_MODE__A
, &fec_oc_ipr_mode
);
1428 fec_oc_ipr_mode
|= FEC_OC_IPR_MODE_MCLK_DIS_DAT_ABS__M
;
1429 status
= write16(state
, FEC_OC_IPR_MODE__A
, fec_oc_ipr_mode
);
1433 pr_err("Error %d on %s\n", status
, __func__
);
1438 static int scu_command(struct drxk_state
*state
,
1439 u16 cmd
, u8 parameter_len
,
1440 u16
*parameter
, u8 result_len
, u16
*result
)
1442 #if (SCU_RAM_PARAM_0__A - SCU_RAM_PARAM_15__A) != 15
1443 #error DRXK register mapping no longer compatible with this routine!
1446 int status
= -EINVAL
;
1455 if ((cmd
== 0) || ((parameter_len
> 0) && (parameter
== NULL
)) ||
1456 ((result_len
> 0) && (result
== NULL
))) {
1457 pr_err("Error %d on %s\n", status
, __func__
);
1461 mutex_lock(&state
->mutex
);
1463 /* assume that the command register is ready
1464 since it is checked afterwards */
1466 for (ii
= parameter_len
- 1; ii
>= 0; ii
-= 1) {
1467 buffer
[cnt
++] = (parameter
[ii
] & 0xFF);
1468 buffer
[cnt
++] = ((parameter
[ii
] >> 8) & 0xFF);
1471 buffer
[cnt
++] = (cmd
& 0xFF);
1472 buffer
[cnt
++] = ((cmd
>> 8) & 0xFF);
1474 write_block(state
, SCU_RAM_PARAM_0__A
-
1475 (parameter_len
- 1), cnt
, buffer
);
1476 /* Wait until SCU has processed command */
1477 end
= jiffies
+ msecs_to_jiffies(DRXK_MAX_WAITTIME
);
1479 usleep_range(1000, 2000);
1480 status
= read16(state
, SCU_RAM_COMMAND__A
, &cur_cmd
);
1483 } while (!(cur_cmd
== DRX_SCU_READY
) && (time_is_after_jiffies(end
)));
1484 if (cur_cmd
!= DRX_SCU_READY
) {
1485 pr_err("SCU not ready\n");
1490 if ((result_len
> 0) && (result
!= NULL
)) {
1494 for (ii
= result_len
- 1; ii
>= 0; ii
-= 1) {
1495 status
= read16(state
, SCU_RAM_PARAM_0__A
- ii
,
1501 /* Check if an error was reported by SCU */
1502 err
= (s16
)result
[0];
1506 /* check for the known error codes */
1508 case SCU_RESULT_UNKCMD
:
1509 p
= "SCU_RESULT_UNKCMD";
1511 case SCU_RESULT_UNKSTD
:
1512 p
= "SCU_RESULT_UNKSTD";
1514 case SCU_RESULT_SIZE
:
1515 p
= "SCU_RESULT_SIZE";
1517 case SCU_RESULT_INVPAR
:
1518 p
= "SCU_RESULT_INVPAR";
1520 default: /* Other negative values are errors */
1521 sprintf(errname
, "ERROR: %d\n", err
);
1524 pr_err("%s while sending cmd 0x%04x with params:", p
, cmd
);
1525 print_hex_dump_bytes("drxk: ", DUMP_PREFIX_NONE
, buffer
, cnt
);
1532 pr_err("Error %d on %s\n", status
, __func__
);
1534 mutex_unlock(&state
->mutex
);
1538 static int set_iqm_af(struct drxk_state
*state
, bool active
)
1546 status
= read16(state
, IQM_AF_STDBY__A
, &data
);
1551 data
|= (IQM_AF_STDBY_STDBY_ADC_STANDBY
1552 | IQM_AF_STDBY_STDBY_AMP_STANDBY
1553 | IQM_AF_STDBY_STDBY_PD_STANDBY
1554 | IQM_AF_STDBY_STDBY_TAGC_IF_STANDBY
1555 | IQM_AF_STDBY_STDBY_TAGC_RF_STANDBY
);
1557 data
&= ((~IQM_AF_STDBY_STDBY_ADC_STANDBY
)
1558 & (~IQM_AF_STDBY_STDBY_AMP_STANDBY
)
1559 & (~IQM_AF_STDBY_STDBY_PD_STANDBY
)
1560 & (~IQM_AF_STDBY_STDBY_TAGC_IF_STANDBY
)
1561 & (~IQM_AF_STDBY_STDBY_TAGC_RF_STANDBY
)
1564 status
= write16(state
, IQM_AF_STDBY__A
, data
);
1568 pr_err("Error %d on %s\n", status
, __func__
);
1572 static int ctrl_power_mode(struct drxk_state
*state
, enum drx_power_mode
*mode
)
1575 u16 sio_cc_pwd_mode
= 0;
1579 /* Check arguments */
1585 sio_cc_pwd_mode
= SIO_CC_PWD_MODE_LEVEL_NONE
;
1587 case DRXK_POWER_DOWN_OFDM
:
1588 sio_cc_pwd_mode
= SIO_CC_PWD_MODE_LEVEL_OFDM
;
1590 case DRXK_POWER_DOWN_CORE
:
1591 sio_cc_pwd_mode
= SIO_CC_PWD_MODE_LEVEL_CLOCK
;
1593 case DRXK_POWER_DOWN_PLL
:
1594 sio_cc_pwd_mode
= SIO_CC_PWD_MODE_LEVEL_PLL
;
1596 case DRX_POWER_DOWN
:
1597 sio_cc_pwd_mode
= SIO_CC_PWD_MODE_LEVEL_OSC
;
1600 /* Unknow sleep mode */
1604 /* If already in requested power mode, do nothing */
1605 if (state
->m_current_power_mode
== *mode
)
1608 /* For next steps make sure to start from DRX_POWER_UP mode */
1609 if (state
->m_current_power_mode
!= DRX_POWER_UP
) {
1610 status
= power_up_device(state
);
1613 status
= dvbt_enable_ofdm_token_ring(state
, true);
1618 if (*mode
== DRX_POWER_UP
) {
1619 /* Restore analog & pin configuration */
1621 /* Power down to requested mode */
1622 /* Backup some register settings */
1623 /* Set pins with possible pull-ups connected
1624 to them in input mode */
1625 /* Analog power down */
1626 /* ADC power down */
1627 /* Power down device */
1628 /* stop all comm_exec */
1629 /* Stop and power down previous standard */
1630 switch (state
->m_operation_mode
) {
1632 status
= mpegts_stop(state
);
1635 status
= power_down_dvbt(state
, false);
1641 status
= mpegts_stop(state
);
1644 status
= power_down_qam(state
);
1651 status
= dvbt_enable_ofdm_token_ring(state
, false);
1654 status
= write16(state
, SIO_CC_PWD_MODE__A
, sio_cc_pwd_mode
);
1657 status
= write16(state
, SIO_CC_UPDATE__A
, SIO_CC_UPDATE_KEY
);
1661 if (*mode
!= DRXK_POWER_DOWN_OFDM
) {
1662 state
->m_hi_cfg_ctrl
|=
1663 SIO_HI_RA_RAM_PAR_5_CFG_SLEEP_ZZZ
;
1664 status
= hi_cfg_command(state
);
1669 state
->m_current_power_mode
= *mode
;
1673 pr_err("Error %d on %s\n", status
, __func__
);
1678 static int power_down_dvbt(struct drxk_state
*state
, bool set_power_mode
)
1680 enum drx_power_mode power_mode
= DRXK_POWER_DOWN_OFDM
;
1687 status
= read16(state
, SCU_COMM_EXEC__A
, &data
);
1690 if (data
== SCU_COMM_EXEC_ACTIVE
) {
1691 /* Send OFDM stop command */
1692 status
= scu_command(state
,
1693 SCU_RAM_COMMAND_STANDARD_OFDM
1694 | SCU_RAM_COMMAND_CMD_DEMOD_STOP
,
1695 0, NULL
, 1, &cmd_result
);
1698 /* Send OFDM reset command */
1699 status
= scu_command(state
,
1700 SCU_RAM_COMMAND_STANDARD_OFDM
1701 | SCU_RAM_COMMAND_CMD_DEMOD_RESET
,
1702 0, NULL
, 1, &cmd_result
);
1707 /* Reset datapath for OFDM, processors first */
1708 status
= write16(state
, OFDM_SC_COMM_EXEC__A
, OFDM_SC_COMM_EXEC_STOP
);
1711 status
= write16(state
, OFDM_LC_COMM_EXEC__A
, OFDM_LC_COMM_EXEC_STOP
);
1714 status
= write16(state
, IQM_COMM_EXEC__A
, IQM_COMM_EXEC_B_STOP
);
1719 status
= set_iqm_af(state
, false);
1723 /* powerdown to OFDM mode */
1724 if (set_power_mode
) {
1725 status
= ctrl_power_mode(state
, &power_mode
);
1731 pr_err("Error %d on %s\n", status
, __func__
);
1735 static int setoperation_mode(struct drxk_state
*state
,
1736 enum operation_mode o_mode
)
1742 Stop and power down previous standard
1743 TODO investigate total power down instead of partial
1744 power down depending on "previous" standard.
1747 /* disable HW lock indicator */
1748 status
= write16(state
, SCU_RAM_GPIO__A
,
1749 SCU_RAM_GPIO_HW_LOCK_IND_DISABLE
);
1753 /* Device is already at the required mode */
1754 if (state
->m_operation_mode
== o_mode
)
1757 switch (state
->m_operation_mode
) {
1758 /* OM_NONE was added for start up */
1762 status
= mpegts_stop(state
);
1765 status
= power_down_dvbt(state
, true);
1768 state
->m_operation_mode
= OM_NONE
;
1770 case OM_QAM_ITU_A
: /* fallthrough */
1772 status
= mpegts_stop(state
);
1775 status
= power_down_qam(state
);
1778 state
->m_operation_mode
= OM_NONE
;
1787 Power up new standard
1791 dprintk(1, ": DVB-T\n");
1792 state
->m_operation_mode
= o_mode
;
1793 status
= set_dvbt_standard(state
, o_mode
);
1797 case OM_QAM_ITU_A
: /* fallthrough */
1799 dprintk(1, ": DVB-C Annex %c\n",
1800 (state
->m_operation_mode
== OM_QAM_ITU_A
) ? 'A' : 'C');
1801 state
->m_operation_mode
= o_mode
;
1802 status
= set_qam_standard(state
, o_mode
);
1812 pr_err("Error %d on %s\n", status
, __func__
);
1816 static int start(struct drxk_state
*state
, s32 offset_freq
,
1817 s32 intermediate_frequency
)
1819 int status
= -EINVAL
;
1822 s32 offsetk_hz
= offset_freq
/ 1000;
1825 if (state
->m_drxk_state
!= DRXK_STOPPED
&&
1826 state
->m_drxk_state
!= DRXK_DTV_STARTED
)
1829 state
->m_b_mirror_freq_spect
= (state
->props
.inversion
== INVERSION_ON
);
1831 if (intermediate_frequency
< 0) {
1832 state
->m_b_mirror_freq_spect
= !state
->m_b_mirror_freq_spect
;
1833 intermediate_frequency
= -intermediate_frequency
;
1836 switch (state
->m_operation_mode
) {
1839 i_freqk_hz
= (intermediate_frequency
/ 1000);
1840 status
= set_qam(state
, i_freqk_hz
, offsetk_hz
);
1843 state
->m_drxk_state
= DRXK_DTV_STARTED
;
1846 i_freqk_hz
= (intermediate_frequency
/ 1000);
1847 status
= mpegts_stop(state
);
1850 status
= set_dvbt(state
, i_freqk_hz
, offsetk_hz
);
1853 status
= dvbt_start(state
);
1856 state
->m_drxk_state
= DRXK_DTV_STARTED
;
1863 pr_err("Error %d on %s\n", status
, __func__
);
1867 static int shut_down(struct drxk_state
*state
)
1875 static int get_lock_status(struct drxk_state
*state
, u32
*p_lock_status
)
1877 int status
= -EINVAL
;
1881 if (p_lock_status
== NULL
)
1884 *p_lock_status
= NOT_LOCKED
;
1886 /* define the SCU command code */
1887 switch (state
->m_operation_mode
) {
1891 status
= get_qam_lock_status(state
, p_lock_status
);
1894 status
= get_dvbt_lock_status(state
, p_lock_status
);
1897 pr_debug("Unsupported operation mode %d in %s\n",
1898 state
->m_operation_mode
, __func__
);
1903 pr_err("Error %d on %s\n", status
, __func__
);
1907 static int mpegts_start(struct drxk_state
*state
)
1911 u16 fec_oc_snc_mode
= 0;
1913 /* Allow OC to sync again */
1914 status
= read16(state
, FEC_OC_SNC_MODE__A
, &fec_oc_snc_mode
);
1917 fec_oc_snc_mode
&= ~FEC_OC_SNC_MODE_SHUTDOWN__M
;
1918 status
= write16(state
, FEC_OC_SNC_MODE__A
, fec_oc_snc_mode
);
1921 status
= write16(state
, FEC_OC_SNC_UNLOCK__A
, 1);
1924 pr_err("Error %d on %s\n", status
, __func__
);
1928 static int mpegts_dto_init(struct drxk_state
*state
)
1934 /* Rate integration settings */
1935 status
= write16(state
, FEC_OC_RCN_CTL_STEP_LO__A
, 0x0000);
1938 status
= write16(state
, FEC_OC_RCN_CTL_STEP_HI__A
, 0x000C);
1941 status
= write16(state
, FEC_OC_RCN_GAIN__A
, 0x000A);
1944 status
= write16(state
, FEC_OC_AVR_PARM_A__A
, 0x0008);
1947 status
= write16(state
, FEC_OC_AVR_PARM_B__A
, 0x0006);
1950 status
= write16(state
, FEC_OC_TMD_HI_MARGIN__A
, 0x0680);
1953 status
= write16(state
, FEC_OC_TMD_LO_MARGIN__A
, 0x0080);
1956 status
= write16(state
, FEC_OC_TMD_COUNT__A
, 0x03F4);
1960 /* Additional configuration */
1961 status
= write16(state
, FEC_OC_OCR_INVERT__A
, 0);
1964 status
= write16(state
, FEC_OC_SNC_LWM__A
, 2);
1967 status
= write16(state
, FEC_OC_SNC_HWM__A
, 12);
1970 pr_err("Error %d on %s\n", status
, __func__
);
1975 static int mpegts_dto_setup(struct drxk_state
*state
,
1976 enum operation_mode o_mode
)
1980 u16 fec_oc_reg_mode
= 0; /* FEC_OC_MODE register value */
1981 u16 fec_oc_reg_ipr_mode
= 0; /* FEC_OC_IPR_MODE register value */
1982 u16 fec_oc_dto_mode
= 0; /* FEC_OC_IPR_INVERT register value */
1983 u16 fec_oc_fct_mode
= 0; /* FEC_OC_IPR_INVERT register value */
1984 u16 fec_oc_dto_period
= 2; /* FEC_OC_IPR_INVERT register value */
1985 u16 fec_oc_dto_burst_len
= 188; /* FEC_OC_IPR_INVERT register value */
1986 u32 fec_oc_rcn_ctl_rate
= 0; /* FEC_OC_IPR_INVERT register value */
1987 u16 fec_oc_tmd_mode
= 0;
1988 u16 fec_oc_tmd_int_upd_rate
= 0;
1989 u32 max_bit_rate
= 0;
1990 bool static_clk
= false;
1994 /* Check insertion of the Reed-Solomon parity bytes */
1995 status
= read16(state
, FEC_OC_MODE__A
, &fec_oc_reg_mode
);
1998 status
= read16(state
, FEC_OC_IPR_MODE__A
, &fec_oc_reg_ipr_mode
);
2001 fec_oc_reg_mode
&= (~FEC_OC_MODE_PARITY__M
);
2002 fec_oc_reg_ipr_mode
&= (~FEC_OC_IPR_MODE_MVAL_DIS_PAR__M
);
2003 if (state
->m_insert_rs_byte
) {
2004 /* enable parity symbol forward */
2005 fec_oc_reg_mode
|= FEC_OC_MODE_PARITY__M
;
2006 /* MVAL disable during parity bytes */
2007 fec_oc_reg_ipr_mode
|= FEC_OC_IPR_MODE_MVAL_DIS_PAR__M
;
2008 /* TS burst length to 204 */
2009 fec_oc_dto_burst_len
= 204;
2012 /* Check serial or parallel output */
2013 fec_oc_reg_ipr_mode
&= (~(FEC_OC_IPR_MODE_SERIAL__M
));
2014 if (!state
->m_enable_parallel
) {
2015 /* MPEG data output is serial -> set ipr_mode[0] */
2016 fec_oc_reg_ipr_mode
|= FEC_OC_IPR_MODE_SERIAL__M
;
2021 max_bit_rate
= state
->m_dvbt_bitrate
;
2022 fec_oc_tmd_mode
= 3;
2023 fec_oc_rcn_ctl_rate
= 0xC00000;
2024 static_clk
= state
->m_dvbt_static_clk
;
2026 case OM_QAM_ITU_A
: /* fallthrough */
2028 fec_oc_tmd_mode
= 0x0004;
2029 fec_oc_rcn_ctl_rate
= 0xD2B4EE; /* good for >63 Mb/s */
2030 max_bit_rate
= state
->m_dvbc_bitrate
;
2031 static_clk
= state
->m_dvbc_static_clk
;
2035 } /* switch (standard) */
2039 /* Configure DTO's */
2043 /* Rational DTO for MCLK source (static MCLK rate),
2044 Dynamic DTO for optimal grouping
2045 (avoid intra-packet gaps),
2046 DTO offset enable to sync TS burst with MSTRT */
2047 fec_oc_dto_mode
= (FEC_OC_DTO_MODE_DYNAMIC__M
|
2048 FEC_OC_DTO_MODE_OFFSET_ENABLE__M
);
2049 fec_oc_fct_mode
= (FEC_OC_FCT_MODE_RAT_ENA__M
|
2050 FEC_OC_FCT_MODE_VIRT_ENA__M
);
2052 /* Check user defined bitrate */
2053 bit_rate
= max_bit_rate
;
2054 if (bit_rate
> 75900000UL) { /* max is 75.9 Mb/s */
2055 bit_rate
= 75900000UL;
2057 /* Rational DTO period:
2058 dto_period = (Fsys / bitrate) - 2
2060 result should be floored,
2061 to make sure >= requested bitrate
2063 fec_oc_dto_period
= (u16
) (((state
->m_sys_clock_freq
)
2064 * 1000) / bit_rate
);
2065 if (fec_oc_dto_period
<= 2)
2066 fec_oc_dto_period
= 0;
2068 fec_oc_dto_period
-= 2;
2069 fec_oc_tmd_int_upd_rate
= 8;
2071 /* (commonAttr->static_clk == false) => dynamic mode */
2072 fec_oc_dto_mode
= FEC_OC_DTO_MODE_DYNAMIC__M
;
2073 fec_oc_fct_mode
= FEC_OC_FCT_MODE__PRE
;
2074 fec_oc_tmd_int_upd_rate
= 5;
2077 /* Write appropriate registers with requested configuration */
2078 status
= write16(state
, FEC_OC_DTO_BURST_LEN__A
, fec_oc_dto_burst_len
);
2081 status
= write16(state
, FEC_OC_DTO_PERIOD__A
, fec_oc_dto_period
);
2084 status
= write16(state
, FEC_OC_DTO_MODE__A
, fec_oc_dto_mode
);
2087 status
= write16(state
, FEC_OC_FCT_MODE__A
, fec_oc_fct_mode
);
2090 status
= write16(state
, FEC_OC_MODE__A
, fec_oc_reg_mode
);
2093 status
= write16(state
, FEC_OC_IPR_MODE__A
, fec_oc_reg_ipr_mode
);
2097 /* Rate integration settings */
2098 status
= write32(state
, FEC_OC_RCN_CTL_RATE_LO__A
, fec_oc_rcn_ctl_rate
);
2101 status
= write16(state
, FEC_OC_TMD_INT_UPD_RATE__A
,
2102 fec_oc_tmd_int_upd_rate
);
2105 status
= write16(state
, FEC_OC_TMD_MODE__A
, fec_oc_tmd_mode
);
2108 pr_err("Error %d on %s\n", status
, __func__
);
2112 static int mpegts_configure_polarity(struct drxk_state
*state
)
2114 u16 fec_oc_reg_ipr_invert
= 0;
2116 /* Data mask for the output data byte */
2117 u16 invert_data_mask
=
2118 FEC_OC_IPR_INVERT_MD7__M
| FEC_OC_IPR_INVERT_MD6__M
|
2119 FEC_OC_IPR_INVERT_MD5__M
| FEC_OC_IPR_INVERT_MD4__M
|
2120 FEC_OC_IPR_INVERT_MD3__M
| FEC_OC_IPR_INVERT_MD2__M
|
2121 FEC_OC_IPR_INVERT_MD1__M
| FEC_OC_IPR_INVERT_MD0__M
;
2125 /* Control selective inversion of output bits */
2126 fec_oc_reg_ipr_invert
&= (~(invert_data_mask
));
2127 if (state
->m_invert_data
)
2128 fec_oc_reg_ipr_invert
|= invert_data_mask
;
2129 fec_oc_reg_ipr_invert
&= (~(FEC_OC_IPR_INVERT_MERR__M
));
2130 if (state
->m_invert_err
)
2131 fec_oc_reg_ipr_invert
|= FEC_OC_IPR_INVERT_MERR__M
;
2132 fec_oc_reg_ipr_invert
&= (~(FEC_OC_IPR_INVERT_MSTRT__M
));
2133 if (state
->m_invert_str
)
2134 fec_oc_reg_ipr_invert
|= FEC_OC_IPR_INVERT_MSTRT__M
;
2135 fec_oc_reg_ipr_invert
&= (~(FEC_OC_IPR_INVERT_MVAL__M
));
2136 if (state
->m_invert_val
)
2137 fec_oc_reg_ipr_invert
|= FEC_OC_IPR_INVERT_MVAL__M
;
2138 fec_oc_reg_ipr_invert
&= (~(FEC_OC_IPR_INVERT_MCLK__M
));
2139 if (state
->m_invert_clk
)
2140 fec_oc_reg_ipr_invert
|= FEC_OC_IPR_INVERT_MCLK__M
;
2142 return write16(state
, FEC_OC_IPR_INVERT__A
, fec_oc_reg_ipr_invert
);
2145 #define SCU_RAM_AGC_KI_INV_RF_POL__M 0x4000
2147 static int set_agc_rf(struct drxk_state
*state
,
2148 struct s_cfg_agc
*p_agc_cfg
, bool is_dtv
)
2150 int status
= -EINVAL
;
2152 struct s_cfg_agc
*p_if_agc_settings
;
2156 if (p_agc_cfg
== NULL
)
2159 switch (p_agc_cfg
->ctrl_mode
) {
2160 case DRXK_AGC_CTRL_AUTO
:
2161 /* Enable RF AGC DAC */
2162 status
= read16(state
, IQM_AF_STDBY__A
, &data
);
2165 data
&= ~IQM_AF_STDBY_STDBY_TAGC_RF_STANDBY
;
2166 status
= write16(state
, IQM_AF_STDBY__A
, data
);
2169 status
= read16(state
, SCU_RAM_AGC_CONFIG__A
, &data
);
2173 /* Enable SCU RF AGC loop */
2174 data
&= ~SCU_RAM_AGC_CONFIG_DISABLE_RF_AGC__M
;
2177 if (state
->m_rf_agc_pol
)
2178 data
|= SCU_RAM_AGC_CONFIG_INV_RF_POL__M
;
2180 data
&= ~SCU_RAM_AGC_CONFIG_INV_RF_POL__M
;
2181 status
= write16(state
, SCU_RAM_AGC_CONFIG__A
, data
);
2185 /* Set speed (using complementary reduction value) */
2186 status
= read16(state
, SCU_RAM_AGC_KI_RED__A
, &data
);
2190 data
&= ~SCU_RAM_AGC_KI_RED_RAGC_RED__M
;
2191 data
|= (~(p_agc_cfg
->speed
<<
2192 SCU_RAM_AGC_KI_RED_RAGC_RED__B
)
2193 & SCU_RAM_AGC_KI_RED_RAGC_RED__M
);
2195 status
= write16(state
, SCU_RAM_AGC_KI_RED__A
, data
);
2200 p_if_agc_settings
= &state
->m_dvbt_if_agc_cfg
;
2201 else if (is_qam(state
))
2202 p_if_agc_settings
= &state
->m_qam_if_agc_cfg
;
2204 p_if_agc_settings
= &state
->m_atv_if_agc_cfg
;
2205 if (p_if_agc_settings
== NULL
) {
2210 /* Set TOP, only if IF-AGC is in AUTO mode */
2211 if (p_if_agc_settings
->ctrl_mode
== DRXK_AGC_CTRL_AUTO
) {
2212 status
= write16(state
,
2213 SCU_RAM_AGC_IF_IACCU_HI_TGT_MAX__A
,
2219 /* Cut-Off current */
2220 status
= write16(state
, SCU_RAM_AGC_RF_IACCU_HI_CO__A
,
2221 p_agc_cfg
->cut_off_current
);
2225 /* Max. output level */
2226 status
= write16(state
, SCU_RAM_AGC_RF_MAX__A
,
2227 p_agc_cfg
->max_output_level
);
2233 case DRXK_AGC_CTRL_USER
:
2234 /* Enable RF AGC DAC */
2235 status
= read16(state
, IQM_AF_STDBY__A
, &data
);
2238 data
&= ~IQM_AF_STDBY_STDBY_TAGC_RF_STANDBY
;
2239 status
= write16(state
, IQM_AF_STDBY__A
, data
);
2243 /* Disable SCU RF AGC loop */
2244 status
= read16(state
, SCU_RAM_AGC_CONFIG__A
, &data
);
2247 data
|= SCU_RAM_AGC_CONFIG_DISABLE_RF_AGC__M
;
2248 if (state
->m_rf_agc_pol
)
2249 data
|= SCU_RAM_AGC_CONFIG_INV_RF_POL__M
;
2251 data
&= ~SCU_RAM_AGC_CONFIG_INV_RF_POL__M
;
2252 status
= write16(state
, SCU_RAM_AGC_CONFIG__A
, data
);
2256 /* SCU c.o.c. to 0, enabling full control range */
2257 status
= write16(state
, SCU_RAM_AGC_RF_IACCU_HI_CO__A
, 0);
2261 /* Write value to output pin */
2262 status
= write16(state
, SCU_RAM_AGC_RF_IACCU_HI__A
,
2263 p_agc_cfg
->output_level
);
2268 case DRXK_AGC_CTRL_OFF
:
2269 /* Disable RF AGC DAC */
2270 status
= read16(state
, IQM_AF_STDBY__A
, &data
);
2273 data
|= IQM_AF_STDBY_STDBY_TAGC_RF_STANDBY
;
2274 status
= write16(state
, IQM_AF_STDBY__A
, data
);
2278 /* Disable SCU RF AGC loop */
2279 status
= read16(state
, SCU_RAM_AGC_CONFIG__A
, &data
);
2282 data
|= SCU_RAM_AGC_CONFIG_DISABLE_RF_AGC__M
;
2283 status
= write16(state
, SCU_RAM_AGC_CONFIG__A
, data
);
2294 pr_err("Error %d on %s\n", status
, __func__
);
2298 #define SCU_RAM_AGC_KI_INV_IF_POL__M 0x2000
2300 static int set_agc_if(struct drxk_state
*state
,
2301 struct s_cfg_agc
*p_agc_cfg
, bool is_dtv
)
2305 struct s_cfg_agc
*p_rf_agc_settings
;
2309 switch (p_agc_cfg
->ctrl_mode
) {
2310 case DRXK_AGC_CTRL_AUTO
:
2312 /* Enable IF AGC DAC */
2313 status
= read16(state
, IQM_AF_STDBY__A
, &data
);
2316 data
&= ~IQM_AF_STDBY_STDBY_TAGC_IF_STANDBY
;
2317 status
= write16(state
, IQM_AF_STDBY__A
, data
);
2321 status
= read16(state
, SCU_RAM_AGC_CONFIG__A
, &data
);
2325 /* Enable SCU IF AGC loop */
2326 data
&= ~SCU_RAM_AGC_CONFIG_DISABLE_IF_AGC__M
;
2329 if (state
->m_if_agc_pol
)
2330 data
|= SCU_RAM_AGC_CONFIG_INV_IF_POL__M
;
2332 data
&= ~SCU_RAM_AGC_CONFIG_INV_IF_POL__M
;
2333 status
= write16(state
, SCU_RAM_AGC_CONFIG__A
, data
);
2337 /* Set speed (using complementary reduction value) */
2338 status
= read16(state
, SCU_RAM_AGC_KI_RED__A
, &data
);
2341 data
&= ~SCU_RAM_AGC_KI_RED_IAGC_RED__M
;
2342 data
|= (~(p_agc_cfg
->speed
<<
2343 SCU_RAM_AGC_KI_RED_IAGC_RED__B
)
2344 & SCU_RAM_AGC_KI_RED_IAGC_RED__M
);
2346 status
= write16(state
, SCU_RAM_AGC_KI_RED__A
, data
);
2351 p_rf_agc_settings
= &state
->m_qam_rf_agc_cfg
;
2353 p_rf_agc_settings
= &state
->m_atv_rf_agc_cfg
;
2354 if (p_rf_agc_settings
== NULL
)
2357 status
= write16(state
, SCU_RAM_AGC_IF_IACCU_HI_TGT_MAX__A
,
2358 p_rf_agc_settings
->top
);
2363 case DRXK_AGC_CTRL_USER
:
2365 /* Enable IF AGC DAC */
2366 status
= read16(state
, IQM_AF_STDBY__A
, &data
);
2369 data
&= ~IQM_AF_STDBY_STDBY_TAGC_IF_STANDBY
;
2370 status
= write16(state
, IQM_AF_STDBY__A
, data
);
2374 status
= read16(state
, SCU_RAM_AGC_CONFIG__A
, &data
);
2378 /* Disable SCU IF AGC loop */
2379 data
|= SCU_RAM_AGC_CONFIG_DISABLE_IF_AGC__M
;
2382 if (state
->m_if_agc_pol
)
2383 data
|= SCU_RAM_AGC_CONFIG_INV_IF_POL__M
;
2385 data
&= ~SCU_RAM_AGC_CONFIG_INV_IF_POL__M
;
2386 status
= write16(state
, SCU_RAM_AGC_CONFIG__A
, data
);
2390 /* Write value to output pin */
2391 status
= write16(state
, SCU_RAM_AGC_IF_IACCU_HI_TGT_MAX__A
,
2392 p_agc_cfg
->output_level
);
2397 case DRXK_AGC_CTRL_OFF
:
2399 /* Disable If AGC DAC */
2400 status
= read16(state
, IQM_AF_STDBY__A
, &data
);
2403 data
|= IQM_AF_STDBY_STDBY_TAGC_IF_STANDBY
;
2404 status
= write16(state
, IQM_AF_STDBY__A
, data
);
2408 /* Disable SCU IF AGC loop */
2409 status
= read16(state
, SCU_RAM_AGC_CONFIG__A
, &data
);
2412 data
|= SCU_RAM_AGC_CONFIG_DISABLE_IF_AGC__M
;
2413 status
= write16(state
, SCU_RAM_AGC_CONFIG__A
, data
);
2417 } /* switch (agcSettingsIf->ctrl_mode) */
2419 /* always set the top to support
2420 configurations without if-loop */
2421 status
= write16(state
, SCU_RAM_AGC_INGAIN_TGT_MIN__A
, p_agc_cfg
->top
);
2424 pr_err("Error %d on %s\n", status
, __func__
);
2428 static int get_qam_signal_to_noise(struct drxk_state
*state
,
2429 s32
*p_signal_to_noise
)
2432 u16 qam_sl_err_power
= 0; /* accum. error between
2433 raw and sliced symbols */
2434 u32 qam_sl_sig_power
= 0; /* used for MER, depends of
2436 u32 qam_sl_mer
= 0; /* QAM MER */
2440 /* MER calculation */
2442 /* get the register value needed for MER */
2443 status
= read16(state
, QAM_SL_ERR_POWER__A
, &qam_sl_err_power
);
2445 pr_err("Error %d on %s\n", status
, __func__
);
2449 switch (state
->props
.modulation
) {
2451 qam_sl_sig_power
= DRXK_QAM_SL_SIG_POWER_QAM16
<< 2;
2454 qam_sl_sig_power
= DRXK_QAM_SL_SIG_POWER_QAM32
<< 2;
2457 qam_sl_sig_power
= DRXK_QAM_SL_SIG_POWER_QAM64
<< 2;
2460 qam_sl_sig_power
= DRXK_QAM_SL_SIG_POWER_QAM128
<< 2;
2464 qam_sl_sig_power
= DRXK_QAM_SL_SIG_POWER_QAM256
<< 2;
2468 if (qam_sl_err_power
> 0) {
2469 qam_sl_mer
= log10times100(qam_sl_sig_power
) -
2470 log10times100((u32
) qam_sl_err_power
);
2472 *p_signal_to_noise
= qam_sl_mer
;
2477 static int get_dvbt_signal_to_noise(struct drxk_state
*state
,
2478 s32
*p_signal_to_noise
)
2482 u32 eq_reg_td_sqr_err_i
= 0;
2483 u32 eq_reg_td_sqr_err_q
= 0;
2484 u16 eq_reg_td_sqr_err_exp
= 0;
2485 u16 eq_reg_td_tps_pwr_ofs
= 0;
2486 u16 eq_reg_td_req_smb_cnt
= 0;
2493 u16 transmission_params
= 0;
2497 status
= read16(state
, OFDM_EQ_TOP_TD_TPS_PWR_OFS__A
,
2498 &eq_reg_td_tps_pwr_ofs
);
2501 status
= read16(state
, OFDM_EQ_TOP_TD_REQ_SMB_CNT__A
,
2502 &eq_reg_td_req_smb_cnt
);
2505 status
= read16(state
, OFDM_EQ_TOP_TD_SQR_ERR_EXP__A
,
2506 &eq_reg_td_sqr_err_exp
);
2509 status
= read16(state
, OFDM_EQ_TOP_TD_SQR_ERR_I__A
,
2513 /* Extend SQR_ERR_I operational range */
2514 eq_reg_td_sqr_err_i
= (u32
) reg_data
;
2515 if ((eq_reg_td_sqr_err_exp
> 11) &&
2516 (eq_reg_td_sqr_err_i
< 0x00000FFFUL
)) {
2517 eq_reg_td_sqr_err_i
+= 0x00010000UL
;
2519 status
= read16(state
, OFDM_EQ_TOP_TD_SQR_ERR_Q__A
, ®_data
);
2522 /* Extend SQR_ERR_Q operational range */
2523 eq_reg_td_sqr_err_q
= (u32
) reg_data
;
2524 if ((eq_reg_td_sqr_err_exp
> 11) &&
2525 (eq_reg_td_sqr_err_q
< 0x00000FFFUL
))
2526 eq_reg_td_sqr_err_q
+= 0x00010000UL
;
2528 status
= read16(state
, OFDM_SC_RA_RAM_OP_PARAM__A
,
2529 &transmission_params
);
2533 /* Check input data for MER */
2535 /* MER calculation (in 0.1 dB) without math.h */
2536 if ((eq_reg_td_tps_pwr_ofs
== 0) || (eq_reg_td_req_smb_cnt
== 0))
2538 else if ((eq_reg_td_sqr_err_i
+ eq_reg_td_sqr_err_q
) == 0) {
2539 /* No error at all, this must be the HW reset value
2540 * Apparently no first measurement yet
2544 sqr_err_iq
= (eq_reg_td_sqr_err_i
+ eq_reg_td_sqr_err_q
) <<
2545 eq_reg_td_sqr_err_exp
;
2546 if ((transmission_params
&
2547 OFDM_SC_RA_RAM_OP_PARAM_MODE__M
)
2548 == OFDM_SC_RA_RAM_OP_PARAM_MODE_2K
)
2553 /* IMER = 100 * log10 (x)
2554 where x = (eq_reg_td_tps_pwr_ofs^2 *
2555 eq_reg_td_req_smb_cnt * tps_cnt)/sqr_err_iq
2558 where a = 100 * log10 (eq_reg_td_tps_pwr_ofs^2)
2559 b = 100 * log10 (eq_reg_td_req_smb_cnt * tps_cnt)
2560 c = 100 * log10 (sqr_err_iq)
2563 /* log(x) x = 9bits * 9bits->18 bits */
2564 a
= log10times100(eq_reg_td_tps_pwr_ofs
*
2565 eq_reg_td_tps_pwr_ofs
);
2566 /* log(x) x = 16bits * 7bits->23 bits */
2567 b
= log10times100(eq_reg_td_req_smb_cnt
* tps_cnt
);
2568 /* log(x) x = (16bits + 16bits) << 15 ->32 bits */
2569 c
= log10times100(sqr_err_iq
);
2573 *p_signal_to_noise
= i_mer
;
2577 pr_err("Error %d on %s\n", status
, __func__
);
2581 static int get_signal_to_noise(struct drxk_state
*state
, s32
*p_signal_to_noise
)
2585 *p_signal_to_noise
= 0;
2586 switch (state
->m_operation_mode
) {
2588 return get_dvbt_signal_to_noise(state
, p_signal_to_noise
);
2591 return get_qam_signal_to_noise(state
, p_signal_to_noise
);
2599 static int get_dvbt_quality(struct drxk_state
*state
, s32
*p_quality
)
2601 /* SNR Values for quasi errorfree reception rom Nordig 2.2 */
2606 static s32 QE_SN
[] = {
2612 108, /* 16-QAM 1/2 */
2613 131, /* 16-QAM 2/3 */
2614 146, /* 16-QAM 3/4 */
2615 156, /* 16-QAM 5/6 */
2616 160, /* 16-QAM 7/8 */
2617 165, /* 64-QAM 1/2 */
2618 187, /* 64-QAM 2/3 */
2619 202, /* 64-QAM 3/4 */
2620 216, /* 64-QAM 5/6 */
2621 225, /* 64-QAM 7/8 */
2627 s32 signal_to_noise
= 0;
2628 u16 constellation
= 0;
2630 u32 signal_to_noise_rel
;
2633 status
= get_dvbt_signal_to_noise(state
, &signal_to_noise
);
2636 status
= read16(state
, OFDM_EQ_TOP_TD_TPS_CONST__A
,
2640 constellation
&= OFDM_EQ_TOP_TD_TPS_CONST__M
;
2642 status
= read16(state
, OFDM_EQ_TOP_TD_TPS_CODE_HP__A
,
2646 code_rate
&= OFDM_EQ_TOP_TD_TPS_CODE_HP__M
;
2648 if (constellation
> OFDM_EQ_TOP_TD_TPS_CONST_64QAM
||
2649 code_rate
> OFDM_EQ_TOP_TD_TPS_CODE_LP_7_8
)
2651 signal_to_noise_rel
= signal_to_noise
-
2652 QE_SN
[constellation
* 5 + code_rate
];
2655 if (signal_to_noise_rel
< -70)
2657 else if (signal_to_noise_rel
< 30)
2658 *p_quality
= ((signal_to_noise_rel
+ 70) *
2661 *p_quality
= ber_quality
;
2666 static int get_dvbc_quality(struct drxk_state
*state
, s32
*p_quality
)
2674 u32 signal_to_noise
= 0;
2675 u32 ber_quality
= 100;
2676 u32 signal_to_noise_rel
= 0;
2678 status
= get_qam_signal_to_noise(state
, &signal_to_noise
);
2682 switch (state
->props
.modulation
) {
2684 signal_to_noise_rel
= signal_to_noise
- 200;
2687 signal_to_noise_rel
= signal_to_noise
- 230;
2688 break; /* Not in NorDig */
2690 signal_to_noise_rel
= signal_to_noise
- 260;
2693 signal_to_noise_rel
= signal_to_noise
- 290;
2697 signal_to_noise_rel
= signal_to_noise
- 320;
2701 if (signal_to_noise_rel
< -70)
2703 else if (signal_to_noise_rel
< 30)
2704 *p_quality
= ((signal_to_noise_rel
+ 70) *
2707 *p_quality
= ber_quality
;
2713 static int get_quality(struct drxk_state
*state
, s32
*p_quality
)
2717 switch (state
->m_operation_mode
) {
2719 return get_dvbt_quality(state
, p_quality
);
2721 return get_dvbc_quality(state
, p_quality
);
2730 /* Free data ram in SIO HI */
2731 #define SIO_HI_RA_RAM_USR_BEGIN__A 0x420040
2732 #define SIO_HI_RA_RAM_USR_END__A 0x420060
2734 #define DRXK_HI_ATOMIC_BUF_START (SIO_HI_RA_RAM_USR_BEGIN__A)
2735 #define DRXK_HI_ATOMIC_BUF_END (SIO_HI_RA_RAM_USR_BEGIN__A + 7)
2736 #define DRXK_HI_ATOMIC_READ SIO_HI_RA_RAM_PAR_3_ACP_RW_READ
2737 #define DRXK_HI_ATOMIC_WRITE SIO_HI_RA_RAM_PAR_3_ACP_RW_WRITE
2739 #define DRXDAP_FASI_ADDR2BLOCK(addr) (((addr) >> 22) & 0x3F)
2740 #define DRXDAP_FASI_ADDR2BANK(addr) (((addr) >> 16) & 0x3F)
2741 #define DRXDAP_FASI_ADDR2OFFSET(addr) ((addr) & 0x7FFF)
2743 static int ConfigureI2CBridge(struct drxk_state
*state
, bool b_enable_bridge
)
2745 int status
= -EINVAL
;
2749 if (state
->m_drxk_state
== DRXK_UNINITIALIZED
)
2751 if (state
->m_drxk_state
== DRXK_POWERED_DOWN
)
2754 if (state
->no_i2c_bridge
)
2757 status
= write16(state
, SIO_HI_RA_RAM_PAR_1__A
,
2758 SIO_HI_RA_RAM_PAR_1_PAR1_SEC_KEY
);
2761 if (b_enable_bridge
) {
2762 status
= write16(state
, SIO_HI_RA_RAM_PAR_2__A
,
2763 SIO_HI_RA_RAM_PAR_2_BRD_CFG_CLOSED
);
2767 status
= write16(state
, SIO_HI_RA_RAM_PAR_2__A
,
2768 SIO_HI_RA_RAM_PAR_2_BRD_CFG_OPEN
);
2773 status
= hi_command(state
, SIO_HI_RA_RAM_CMD_BRDCTRL
, NULL
);
2777 pr_err("Error %d on %s\n", status
, __func__
);
2781 static int set_pre_saw(struct drxk_state
*state
,
2782 struct s_cfg_pre_saw
*p_pre_saw_cfg
)
2784 int status
= -EINVAL
;
2788 if ((p_pre_saw_cfg
== NULL
)
2789 || (p_pre_saw_cfg
->reference
> IQM_AF_PDREF__M
))
2792 status
= write16(state
, IQM_AF_PDREF__A
, p_pre_saw_cfg
->reference
);
2795 pr_err("Error %d on %s\n", status
, __func__
);
2799 static int bl_direct_cmd(struct drxk_state
*state
, u32 target_addr
,
2800 u16 rom_offset
, u16 nr_of_elements
, u32 time_out
)
2803 u16 offset
= (u16
) ((target_addr
>> 0) & 0x00FFFF);
2804 u16 blockbank
= (u16
) ((target_addr
>> 16) & 0x000FFF);
2810 mutex_lock(&state
->mutex
);
2811 status
= write16(state
, SIO_BL_MODE__A
, SIO_BL_MODE_DIRECT
);
2814 status
= write16(state
, SIO_BL_TGT_HDR__A
, blockbank
);
2817 status
= write16(state
, SIO_BL_TGT_ADDR__A
, offset
);
2820 status
= write16(state
, SIO_BL_SRC_ADDR__A
, rom_offset
);
2823 status
= write16(state
, SIO_BL_SRC_LEN__A
, nr_of_elements
);
2826 status
= write16(state
, SIO_BL_ENABLE__A
, SIO_BL_ENABLE_ON
);
2830 end
= jiffies
+ msecs_to_jiffies(time_out
);
2832 status
= read16(state
, SIO_BL_STATUS__A
, &bl_status
);
2835 } while ((bl_status
== 0x1) && time_is_after_jiffies(end
));
2836 if (bl_status
== 0x1) {
2837 pr_err("SIO not ready\n");
2843 pr_err("Error %d on %s\n", status
, __func__
);
2845 mutex_unlock(&state
->mutex
);
2850 static int adc_sync_measurement(struct drxk_state
*state
, u16
*count
)
2857 /* start measurement */
2858 status
= write16(state
, IQM_AF_COMM_EXEC__A
, IQM_AF_COMM_EXEC_ACTIVE
);
2861 status
= write16(state
, IQM_AF_START_LOCK__A
, 1);
2866 status
= read16(state
, IQM_AF_PHASE0__A
, &data
);
2870 *count
= *count
+ 1;
2871 status
= read16(state
, IQM_AF_PHASE1__A
, &data
);
2875 *count
= *count
+ 1;
2876 status
= read16(state
, IQM_AF_PHASE2__A
, &data
);
2880 *count
= *count
+ 1;
2884 pr_err("Error %d on %s\n", status
, __func__
);
2888 static int adc_synchronization(struct drxk_state
*state
)
2895 status
= adc_sync_measurement(state
, &count
);
2900 /* Try sampling on a different edge */
2903 status
= read16(state
, IQM_AF_CLKNEG__A
, &clk_neg
);
2906 if ((clk_neg
& IQM_AF_CLKNEG_CLKNEGDATA__M
) ==
2907 IQM_AF_CLKNEG_CLKNEGDATA_CLK_ADC_DATA_POS
) {
2908 clk_neg
&= (~(IQM_AF_CLKNEG_CLKNEGDATA__M
));
2910 IQM_AF_CLKNEG_CLKNEGDATA_CLK_ADC_DATA_NEG
;
2912 clk_neg
&= (~(IQM_AF_CLKNEG_CLKNEGDATA__M
));
2914 IQM_AF_CLKNEG_CLKNEGDATA_CLK_ADC_DATA_POS
;
2916 status
= write16(state
, IQM_AF_CLKNEG__A
, clk_neg
);
2919 status
= adc_sync_measurement(state
, &count
);
2928 pr_err("Error %d on %s\n", status
, __func__
);
2932 static int set_frequency_shifter(struct drxk_state
*state
,
2933 u16 intermediate_freqk_hz
,
2934 s32 tuner_freq_offset
, bool is_dtv
)
2936 bool select_pos_image
= false;
2937 u32 rf_freq_residual
= tuner_freq_offset
;
2938 u32 fm_frequency_shift
= 0;
2939 bool tuner_mirror
= !state
->m_b_mirror_freq_spect
;
2944 u32 sampling_frequency
= (u32
) (state
->m_sys_clock_freq
/ 3);
2945 u32 frequency_shift
;
2946 bool image_to_select
;
2951 Program frequency shifter
2952 No need to account for mirroring on RF
2955 if ((state
->m_operation_mode
== OM_QAM_ITU_A
) ||
2956 (state
->m_operation_mode
== OM_QAM_ITU_C
) ||
2957 (state
->m_operation_mode
== OM_DVBT
))
2958 select_pos_image
= true;
2960 select_pos_image
= false;
2963 /* tuner doesn't mirror */
2964 if_freq_actual
= intermediate_freqk_hz
+
2965 rf_freq_residual
+ fm_frequency_shift
;
2968 if_freq_actual
= intermediate_freqk_hz
-
2969 rf_freq_residual
- fm_frequency_shift
;
2970 if (if_freq_actual
> sampling_frequency
/ 2) {
2972 adc_freq
= sampling_frequency
- if_freq_actual
;
2975 /* adc doesn't mirror */
2976 adc_freq
= if_freq_actual
;
2980 frequency_shift
= adc_freq
;
2981 image_to_select
= state
->m_rfmirror
^ tuner_mirror
^
2982 adc_flip
^ select_pos_image
;
2983 state
->m_iqm_fs_rate_ofs
=
2984 Frac28a((frequency_shift
), sampling_frequency
);
2986 if (image_to_select
)
2987 state
->m_iqm_fs_rate_ofs
= ~state
->m_iqm_fs_rate_ofs
+ 1;
2989 /* Program frequency shifter with tuner offset compensation */
2990 /* frequency_shift += tuner_freq_offset; TODO */
2991 status
= write32(state
, IQM_FS_RATE_OFS_LO__A
,
2992 state
->m_iqm_fs_rate_ofs
);
2994 pr_err("Error %d on %s\n", status
, __func__
);
2998 static int init_agc(struct drxk_state
*state
, bool is_dtv
)
3001 u16 ingain_tgt_min
= 0;
3002 u16 ingain_tgt_max
= 0;
3004 u16 clp_sum_min
= 0;
3006 u16 sns_sum_min
= 0;
3007 u16 sns_sum_max
= 0;
3008 u16 clp_sum_max
= 0;
3010 u16 ki_innergain_min
= 0;
3011 u16 if_iaccu_hi_tgt
= 0;
3012 u16 if_iaccu_hi_tgt_min
= 0;
3013 u16 if_iaccu_hi_tgt_max
= 0;
3015 u16 fast_clp_ctrl_delay
= 0;
3016 u16 clp_ctrl_mode
= 0;
3021 /* Common settings */
3023 if_iaccu_hi_tgt_min
= 2047;
3027 /* AGCInit() not available for DVBT; init done in microcode */
3028 if (!is_qam(state
)) {
3029 pr_err("%s: mode %d is not DVB-C\n",
3030 __func__
, state
->m_operation_mode
);
3034 /* FIXME: Analog TV AGC require different settings */
3036 /* Standard specific settings */
3038 clp_dir_to
= (u16
) -9;
3041 sns_dir_to
= (u16
) -9;
3042 ki_innergain_min
= (u16
) -1030;
3043 if_iaccu_hi_tgt_max
= 0x2380;
3044 if_iaccu_hi_tgt
= 0x2380;
3045 ingain_tgt_min
= 0x0511;
3046 ingain_tgt
= 0x0511;
3047 ingain_tgt_max
= 5119;
3048 fast_clp_ctrl_delay
= state
->m_qam_if_agc_cfg
.fast_clip_ctrl_delay
;
3050 status
= write16(state
, SCU_RAM_AGC_FAST_CLP_CTRL_DELAY__A
,
3051 fast_clp_ctrl_delay
);
3055 status
= write16(state
, SCU_RAM_AGC_CLP_CTRL_MODE__A
, clp_ctrl_mode
);
3058 status
= write16(state
, SCU_RAM_AGC_INGAIN_TGT__A
, ingain_tgt
);
3061 status
= write16(state
, SCU_RAM_AGC_INGAIN_TGT_MIN__A
, ingain_tgt_min
);
3064 status
= write16(state
, SCU_RAM_AGC_INGAIN_TGT_MAX__A
, ingain_tgt_max
);
3067 status
= write16(state
, SCU_RAM_AGC_IF_IACCU_HI_TGT_MIN__A
,
3068 if_iaccu_hi_tgt_min
);
3071 status
= write16(state
, SCU_RAM_AGC_IF_IACCU_HI_TGT_MAX__A
,
3072 if_iaccu_hi_tgt_max
);
3075 status
= write16(state
, SCU_RAM_AGC_IF_IACCU_HI__A
, 0);
3078 status
= write16(state
, SCU_RAM_AGC_IF_IACCU_LO__A
, 0);
3081 status
= write16(state
, SCU_RAM_AGC_RF_IACCU_HI__A
, 0);
3084 status
= write16(state
, SCU_RAM_AGC_RF_IACCU_LO__A
, 0);
3087 status
= write16(state
, SCU_RAM_AGC_CLP_SUM_MAX__A
, clp_sum_max
);
3090 status
= write16(state
, SCU_RAM_AGC_SNS_SUM_MAX__A
, sns_sum_max
);
3094 status
= write16(state
, SCU_RAM_AGC_KI_INNERGAIN_MIN__A
,
3098 status
= write16(state
, SCU_RAM_AGC_IF_IACCU_HI_TGT__A
,
3102 status
= write16(state
, SCU_RAM_AGC_CLP_CYCLEN__A
, clp_cyclen
);
3106 status
= write16(state
, SCU_RAM_AGC_RF_SNS_DEV_MAX__A
, 1023);
3109 status
= write16(state
, SCU_RAM_AGC_RF_SNS_DEV_MIN__A
, (u16
) -1023);
3112 status
= write16(state
, SCU_RAM_AGC_FAST_SNS_CTRL_DELAY__A
, 50);
3116 status
= write16(state
, SCU_RAM_AGC_KI_MAXMINGAIN_TH__A
, 20);
3119 status
= write16(state
, SCU_RAM_AGC_CLP_SUM_MIN__A
, clp_sum_min
);
3122 status
= write16(state
, SCU_RAM_AGC_SNS_SUM_MIN__A
, sns_sum_min
);
3125 status
= write16(state
, SCU_RAM_AGC_CLP_DIR_TO__A
, clp_dir_to
);
3128 status
= write16(state
, SCU_RAM_AGC_SNS_DIR_TO__A
, sns_dir_to
);
3131 status
= write16(state
, SCU_RAM_AGC_KI_MINGAIN__A
, 0x7fff);
3134 status
= write16(state
, SCU_RAM_AGC_KI_MAXGAIN__A
, 0x0);
3137 status
= write16(state
, SCU_RAM_AGC_KI_MIN__A
, 0x0117);
3140 status
= write16(state
, SCU_RAM_AGC_KI_MAX__A
, 0x0657);
3143 status
= write16(state
, SCU_RAM_AGC_CLP_SUM__A
, 0);
3146 status
= write16(state
, SCU_RAM_AGC_CLP_CYCCNT__A
, 0);
3149 status
= write16(state
, SCU_RAM_AGC_CLP_DIR_WD__A
, 0);
3152 status
= write16(state
, SCU_RAM_AGC_CLP_DIR_STP__A
, 1);
3155 status
= write16(state
, SCU_RAM_AGC_SNS_SUM__A
, 0);
3158 status
= write16(state
, SCU_RAM_AGC_SNS_CYCCNT__A
, 0);
3161 status
= write16(state
, SCU_RAM_AGC_SNS_DIR_WD__A
, 0);
3164 status
= write16(state
, SCU_RAM_AGC_SNS_DIR_STP__A
, 1);
3167 status
= write16(state
, SCU_RAM_AGC_SNS_CYCLEN__A
, 500);
3170 status
= write16(state
, SCU_RAM_AGC_KI_CYCLEN__A
, 500);
3174 /* Initialize inner-loop KI gain factors */
3175 status
= read16(state
, SCU_RAM_AGC_KI__A
, &data
);
3180 data
&= ~SCU_RAM_AGC_KI_RF__M
;
3181 data
|= (DRXK_KI_RAGC_QAM
<< SCU_RAM_AGC_KI_RF__B
);
3182 data
&= ~SCU_RAM_AGC_KI_IF__M
;
3183 data
|= (DRXK_KI_IAGC_QAM
<< SCU_RAM_AGC_KI_IF__B
);
3185 status
= write16(state
, SCU_RAM_AGC_KI__A
, data
);
3188 pr_err("Error %d on %s\n", status
, __func__
);
3192 static int dvbtqam_get_acc_pkt_err(struct drxk_state
*state
, u16
*packet_err
)
3197 if (packet_err
== NULL
)
3198 status
= write16(state
, SCU_RAM_FEC_ACCUM_PKT_FAILURES__A
, 0);
3200 status
= read16(state
, SCU_RAM_FEC_ACCUM_PKT_FAILURES__A
,
3203 pr_err("Error %d on %s\n", status
, __func__
);
3207 static int dvbt_sc_command(struct drxk_state
*state
,
3208 u16 cmd
, u16 subcmd
,
3209 u16 param0
, u16 param1
, u16 param2
,
3210 u16 param3
, u16 param4
)
3219 status
= read16(state
, OFDM_SC_COMM_EXEC__A
, &sc_exec
);
3221 /* SC is not running */
3227 /* Wait until sc is ready to receive command */
3230 usleep_range(1000, 2000);
3231 status
= read16(state
, OFDM_SC_RA_RAM_CMD__A
, &cur_cmd
);
3233 } while ((cur_cmd
!= 0) && (retry_cnt
< DRXK_MAX_RETRIES
));
3234 if (retry_cnt
>= DRXK_MAX_RETRIES
&& (status
< 0))
3237 /* Write sub-command */
3239 /* All commands using sub-cmd */
3240 case OFDM_SC_RA_RAM_CMD_PROC_START
:
3241 case OFDM_SC_RA_RAM_CMD_SET_PREF_PARAM
:
3242 case OFDM_SC_RA_RAM_CMD_PROGRAM_PARAM
:
3243 status
= write16(state
, OFDM_SC_RA_RAM_CMD_ADDR__A
, subcmd
);
3252 /* Write needed parameters and the command */
3255 /* All commands using 5 parameters */
3256 /* All commands using 4 parameters */
3257 /* All commands using 3 parameters */
3258 /* All commands using 2 parameters */
3259 case OFDM_SC_RA_RAM_CMD_PROC_START
:
3260 case OFDM_SC_RA_RAM_CMD_SET_PREF_PARAM
:
3261 case OFDM_SC_RA_RAM_CMD_PROGRAM_PARAM
:
3262 status
|= write16(state
, OFDM_SC_RA_RAM_PARAM1__A
, param1
);
3263 /* fall through - All commands using 1 parameters */
3264 case OFDM_SC_RA_RAM_CMD_SET_ECHO_TIMING
:
3265 case OFDM_SC_RA_RAM_CMD_USER_IO
:
3266 status
|= write16(state
, OFDM_SC_RA_RAM_PARAM0__A
, param0
);
3267 /* fall through - All commands using 0 parameters */
3268 case OFDM_SC_RA_RAM_CMD_GET_OP_PARAM
:
3269 case OFDM_SC_RA_RAM_CMD_NULL
:
3271 status
|= write16(state
, OFDM_SC_RA_RAM_CMD__A
, cmd
);
3274 /* Unknown command */
3280 /* Wait until sc is ready processing command */
3283 usleep_range(1000, 2000);
3284 status
= read16(state
, OFDM_SC_RA_RAM_CMD__A
, &cur_cmd
);
3286 } while ((cur_cmd
!= 0) && (retry_cnt
< DRXK_MAX_RETRIES
));
3287 if (retry_cnt
>= DRXK_MAX_RETRIES
&& (status
< 0))
3290 /* Check for illegal cmd */
3291 status
= read16(state
, OFDM_SC_RA_RAM_CMD_ADDR__A
, &err_code
);
3292 if (err_code
== 0xFFFF) {
3293 /* illegal command */
3299 /* Retrieve results parameters from SC */
3301 /* All commands yielding 5 results */
3302 /* All commands yielding 4 results */
3303 /* All commands yielding 3 results */
3304 /* All commands yielding 2 results */
3305 /* All commands yielding 1 result */
3306 case OFDM_SC_RA_RAM_CMD_USER_IO
:
3307 case OFDM_SC_RA_RAM_CMD_GET_OP_PARAM
:
3308 status
= read16(state
, OFDM_SC_RA_RAM_PARAM0__A
, &(param0
));
3309 /* All commands yielding 0 results */
3310 case OFDM_SC_RA_RAM_CMD_SET_ECHO_TIMING
:
3311 case OFDM_SC_RA_RAM_CMD_SET_TIMER
:
3312 case OFDM_SC_RA_RAM_CMD_PROC_START
:
3313 case OFDM_SC_RA_RAM_CMD_SET_PREF_PARAM
:
3314 case OFDM_SC_RA_RAM_CMD_PROGRAM_PARAM
:
3315 case OFDM_SC_RA_RAM_CMD_NULL
:
3318 /* Unknown command */
3321 } /* switch (cmd->cmd) */
3324 pr_err("Error %d on %s\n", status
, __func__
);
3328 static int power_up_dvbt(struct drxk_state
*state
)
3330 enum drx_power_mode power_mode
= DRX_POWER_UP
;
3334 status
= ctrl_power_mode(state
, &power_mode
);
3336 pr_err("Error %d on %s\n", status
, __func__
);
3340 static int dvbt_ctrl_set_inc_enable(struct drxk_state
*state
, bool *enabled
)
3346 status
= write16(state
, IQM_CF_BYPASSDET__A
, 0);
3348 status
= write16(state
, IQM_CF_BYPASSDET__A
, 1);
3350 pr_err("Error %d on %s\n", status
, __func__
);
3354 #define DEFAULT_FR_THRES_8K 4000
3355 static int dvbt_ctrl_set_fr_enable(struct drxk_state
*state
, bool *enabled
)
3362 /* write mask to 1 */
3363 status
= write16(state
, OFDM_SC_RA_RAM_FR_THRES_8K__A
,
3364 DEFAULT_FR_THRES_8K
);
3366 /* write mask to 0 */
3367 status
= write16(state
, OFDM_SC_RA_RAM_FR_THRES_8K__A
, 0);
3370 pr_err("Error %d on %s\n", status
, __func__
);
3375 static int dvbt_ctrl_set_echo_threshold(struct drxk_state
*state
,
3376 struct drxk_cfg_dvbt_echo_thres_t
*echo_thres
)
3382 status
= read16(state
, OFDM_SC_RA_RAM_ECHO_THRES__A
, &data
);
3386 switch (echo_thres
->fft_mode
) {
3387 case DRX_FFTMODE_2K
:
3388 data
&= ~OFDM_SC_RA_RAM_ECHO_THRES_2K__M
;
3389 data
|= ((echo_thres
->threshold
<<
3390 OFDM_SC_RA_RAM_ECHO_THRES_2K__B
)
3391 & (OFDM_SC_RA_RAM_ECHO_THRES_2K__M
));
3393 case DRX_FFTMODE_8K
:
3394 data
&= ~OFDM_SC_RA_RAM_ECHO_THRES_8K__M
;
3395 data
|= ((echo_thres
->threshold
<<
3396 OFDM_SC_RA_RAM_ECHO_THRES_8K__B
)
3397 & (OFDM_SC_RA_RAM_ECHO_THRES_8K__M
));
3403 status
= write16(state
, OFDM_SC_RA_RAM_ECHO_THRES__A
, data
);
3406 pr_err("Error %d on %s\n", status
, __func__
);
3410 static int dvbt_ctrl_set_sqi_speed(struct drxk_state
*state
,
3411 enum drxk_cfg_dvbt_sqi_speed
*speed
)
3413 int status
= -EINVAL
;
3418 case DRXK_DVBT_SQI_SPEED_FAST
:
3419 case DRXK_DVBT_SQI_SPEED_MEDIUM
:
3420 case DRXK_DVBT_SQI_SPEED_SLOW
:
3425 status
= write16(state
, SCU_RAM_FEC_PRE_RS_BER_FILTER_SH__A
,
3429 pr_err("Error %d on %s\n", status
, __func__
);
3433 /*============================================================================*/
3436 * \brief Activate DVBT specific presets
3437 * \param demod instance of demodulator.
3438 * \return DRXStatus_t.
3440 * Called in DVBTSetStandard
3443 static int dvbt_activate_presets(struct drxk_state
*state
)
3446 bool setincenable
= false;
3447 bool setfrenable
= true;
3449 struct drxk_cfg_dvbt_echo_thres_t echo_thres2k
= { 0, DRX_FFTMODE_2K
};
3450 struct drxk_cfg_dvbt_echo_thres_t echo_thres8k
= { 0, DRX_FFTMODE_8K
};
3453 status
= dvbt_ctrl_set_inc_enable(state
, &setincenable
);
3456 status
= dvbt_ctrl_set_fr_enable(state
, &setfrenable
);
3459 status
= dvbt_ctrl_set_echo_threshold(state
, &echo_thres2k
);
3462 status
= dvbt_ctrl_set_echo_threshold(state
, &echo_thres8k
);
3465 status
= write16(state
, SCU_RAM_AGC_INGAIN_TGT_MAX__A
,
3466 state
->m_dvbt_if_agc_cfg
.ingain_tgt_max
);
3469 pr_err("Error %d on %s\n", status
, __func__
);
3473 /*============================================================================*/
3476 * \brief Initialize channelswitch-independent settings for DVBT.
3477 * \param demod instance of demodulator.
3478 * \return DRXStatus_t.
3480 * For ROM code channel filter taps are loaded from the bootloader. For microcode
3481 * the DVB-T taps from the drxk_filters.h are used.
3483 static int set_dvbt_standard(struct drxk_state
*state
,
3484 enum operation_mode o_mode
)
3492 power_up_dvbt(state
);
3493 /* added antenna switch */
3494 switch_antenna_to_dvbt(state
);
3495 /* send OFDM reset command */
3496 status
= scu_command(state
,
3497 SCU_RAM_COMMAND_STANDARD_OFDM
3498 | SCU_RAM_COMMAND_CMD_DEMOD_RESET
,
3499 0, NULL
, 1, &cmd_result
);
3503 /* send OFDM setenv command */
3504 status
= scu_command(state
, SCU_RAM_COMMAND_STANDARD_OFDM
3505 | SCU_RAM_COMMAND_CMD_DEMOD_SET_ENV
,
3506 0, NULL
, 1, &cmd_result
);
3510 /* reset datapath for OFDM, processors first */
3511 status
= write16(state
, OFDM_SC_COMM_EXEC__A
, OFDM_SC_COMM_EXEC_STOP
);
3514 status
= write16(state
, OFDM_LC_COMM_EXEC__A
, OFDM_LC_COMM_EXEC_STOP
);
3517 status
= write16(state
, IQM_COMM_EXEC__A
, IQM_COMM_EXEC_B_STOP
);
3522 /* synchronize on ofdstate->m_festart */
3523 status
= write16(state
, IQM_AF_UPD_SEL__A
, 1);
3526 /* window size for clipping ADC detection */
3527 status
= write16(state
, IQM_AF_CLP_LEN__A
, 0);
3530 /* window size for for sense pre-SAW detection */
3531 status
= write16(state
, IQM_AF_SNS_LEN__A
, 0);
3534 /* sense threshold for sense pre-SAW detection */
3535 status
= write16(state
, IQM_AF_AMUX__A
, IQM_AF_AMUX_SIGNAL2ADC
);
3538 status
= set_iqm_af(state
, true);
3542 status
= write16(state
, IQM_AF_AGC_RF__A
, 0);
3546 /* Impulse noise cruncher setup */
3547 status
= write16(state
, IQM_AF_INC_LCT__A
, 0); /* crunch in IQM_CF */
3550 status
= write16(state
, IQM_CF_DET_LCT__A
, 0); /* detect in IQM_CF */
3553 status
= write16(state
, IQM_CF_WND_LEN__A
, 3); /* peak detector window length */
3557 status
= write16(state
, IQM_RC_STRETCH__A
, 16);
3560 status
= write16(state
, IQM_CF_OUT_ENA__A
, 0x4); /* enable output 2 */
3563 status
= write16(state
, IQM_CF_DS_ENA__A
, 0x4); /* decimate output 2 */
3566 status
= write16(state
, IQM_CF_SCALE__A
, 1600);
3569 status
= write16(state
, IQM_CF_SCALE_SH__A
, 0);
3573 /* virtual clipping threshold for clipping ADC detection */
3574 status
= write16(state
, IQM_AF_CLP_TH__A
, 448);
3577 status
= write16(state
, IQM_CF_DATATH__A
, 495); /* crunching threshold */
3581 status
= bl_chain_cmd(state
, DRXK_BL_ROM_OFFSET_TAPS_DVBT
,
3582 DRXK_BLCC_NR_ELEMENTS_TAPS
, DRXK_BLC_TIMEOUT
);
3586 status
= write16(state
, IQM_CF_PKDTH__A
, 2); /* peak detector threshold */
3589 status
= write16(state
, IQM_CF_POW_MEAS_LEN__A
, 2);
3592 /* enable power measurement interrupt */
3593 status
= write16(state
, IQM_CF_COMM_INT_MSK__A
, 1);
3596 status
= write16(state
, IQM_COMM_EXEC__A
, IQM_COMM_EXEC_B_ACTIVE
);
3600 /* IQM will not be reset from here, sync ADC and update/init AGC */
3601 status
= adc_synchronization(state
);
3604 status
= set_pre_saw(state
, &state
->m_dvbt_pre_saw_cfg
);
3608 /* Halt SCU to enable safe non-atomic accesses */
3609 status
= write16(state
, SCU_COMM_EXEC__A
, SCU_COMM_EXEC_HOLD
);
3613 status
= set_agc_rf(state
, &state
->m_dvbt_rf_agc_cfg
, true);
3616 status
= set_agc_if(state
, &state
->m_dvbt_if_agc_cfg
, true);
3620 /* Set Noise Estimation notch width and enable DC fix */
3621 status
= read16(state
, OFDM_SC_RA_RAM_CONFIG__A
, &data
);
3624 data
|= OFDM_SC_RA_RAM_CONFIG_NE_FIX_ENABLE__M
;
3625 status
= write16(state
, OFDM_SC_RA_RAM_CONFIG__A
, data
);
3629 /* Activate SCU to enable SCU commands */
3630 status
= write16(state
, SCU_COMM_EXEC__A
, SCU_COMM_EXEC_ACTIVE
);
3634 if (!state
->m_drxk_a3_rom_code
) {
3635 /* AGCInit() is not done for DVBT, so set agcfast_clip_ctrl_delay */
3636 status
= write16(state
, SCU_RAM_AGC_FAST_CLP_CTRL_DELAY__A
,
3637 state
->m_dvbt_if_agc_cfg
.fast_clip_ctrl_delay
);
3643 #ifdef COMPILE_FOR_NONRT
3644 status
= write16(state
, OFDM_SC_RA_RAM_BE_OPT_DELAY__A
, 1);
3647 status
= write16(state
, OFDM_SC_RA_RAM_BE_OPT_INIT_DELAY__A
, 2);
3653 status
= write16(state
, FEC_DI_INPUT_CTL__A
, 1); /* OFDM input */
3658 #ifdef COMPILE_FOR_NONRT
3659 status
= write16(state
, FEC_RS_MEASUREMENT_PERIOD__A
, 0x400);
3663 status
= write16(state
, FEC_RS_MEASUREMENT_PERIOD__A
, 0x1000);
3667 status
= write16(state
, FEC_RS_MEASUREMENT_PRESCALE__A
, 0x0001);
3671 /* Setup MPEG bus */
3672 status
= mpegts_dto_setup(state
, OM_DVBT
);
3675 /* Set DVBT Presets */
3676 status
= dvbt_activate_presets(state
);
3682 pr_err("Error %d on %s\n", status
, __func__
);
3686 /*============================================================================*/
3688 * \brief start dvbt demodulating for channel.
3689 * \param demod instance of demodulator.
3690 * \return DRXStatus_t.
3692 static int dvbt_start(struct drxk_state
*state
)
3696 /* drxk_ofdm_sc_cmd_t scCmd; */
3699 /* start correct processes to get in lock */
3700 /* DRXK: OFDM_SC_RA_RAM_PROC_LOCKTRACK is no longer in mapfile! */
3701 param1
= OFDM_SC_RA_RAM_LOCKTRACK_MIN
;
3702 status
= dvbt_sc_command(state
, OFDM_SC_RA_RAM_CMD_PROC_START
, 0,
3703 OFDM_SC_RA_RAM_SW_EVENT_RUN_NMASK__M
, param1
,
3708 status
= mpegts_start(state
);
3711 status
= write16(state
, FEC_COMM_EXEC__A
, FEC_COMM_EXEC_ACTIVE
);
3716 pr_err("Error %d on %s\n", status
, __func__
);
3721 /*============================================================================*/
3724 * \brief Set up dvbt demodulator for channel.
3725 * \param demod instance of demodulator.
3726 * \return DRXStatus_t.
3727 * // original DVBTSetChannel()
3729 static int set_dvbt(struct drxk_state
*state
, u16 intermediate_freqk_hz
,
3730 s32 tuner_freq_offset
)
3733 u16 transmission_params
= 0;
3734 u16 operation_mode
= 0;
3735 u32 iqm_rc_rate_ofs
= 0;
3740 dprintk(1, "IF =%d, TFO = %d\n",
3741 intermediate_freqk_hz
, tuner_freq_offset
);
3743 status
= scu_command(state
, SCU_RAM_COMMAND_STANDARD_OFDM
3744 | SCU_RAM_COMMAND_CMD_DEMOD_STOP
,
3745 0, NULL
, 1, &cmd_result
);
3749 /* Halt SCU to enable safe non-atomic accesses */
3750 status
= write16(state
, SCU_COMM_EXEC__A
, SCU_COMM_EXEC_HOLD
);
3754 /* Stop processors */
3755 status
= write16(state
, OFDM_SC_COMM_EXEC__A
, OFDM_SC_COMM_EXEC_STOP
);
3758 status
= write16(state
, OFDM_LC_COMM_EXEC__A
, OFDM_LC_COMM_EXEC_STOP
);
3762 /* Mandatory fix, always stop CP, required to set spl offset back to
3763 hardware default (is set to 0 by ucode during pilot detection */
3764 status
= write16(state
, OFDM_CP_COMM_EXEC__A
, OFDM_CP_COMM_EXEC_STOP
);
3768 /*== Write channel settings to device ================================*/
3771 switch (state
->props
.transmission_mode
) {
3772 case TRANSMISSION_MODE_AUTO
:
3774 operation_mode
|= OFDM_SC_RA_RAM_OP_AUTO_MODE__M
;
3775 /* fall through - try first guess DRX_FFTMODE_8K */
3776 case TRANSMISSION_MODE_8K
:
3777 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_MODE_8K
;
3779 case TRANSMISSION_MODE_2K
:
3780 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_MODE_2K
;
3785 switch (state
->props
.guard_interval
) {
3787 case GUARD_INTERVAL_AUTO
:
3788 operation_mode
|= OFDM_SC_RA_RAM_OP_AUTO_GUARD__M
;
3789 /* fall through - try first guess DRX_GUARD_1DIV4 */
3790 case GUARD_INTERVAL_1_4
:
3791 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_GUARD_4
;
3793 case GUARD_INTERVAL_1_32
:
3794 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_GUARD_32
;
3796 case GUARD_INTERVAL_1_16
:
3797 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_GUARD_16
;
3799 case GUARD_INTERVAL_1_8
:
3800 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_GUARD_8
;
3805 switch (state
->props
.hierarchy
) {
3806 case HIERARCHY_AUTO
:
3807 case HIERARCHY_NONE
:
3809 operation_mode
|= OFDM_SC_RA_RAM_OP_AUTO_HIER__M
;
3810 /* try first guess SC_RA_RAM_OP_PARAM_HIER_NO */
3811 /* transmission_params |= OFDM_SC_RA_RAM_OP_PARAM_HIER_NO; */
3814 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_HIER_A1
;
3817 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_HIER_A2
;
3820 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_HIER_A4
;
3826 switch (state
->props
.modulation
) {
3829 operation_mode
|= OFDM_SC_RA_RAM_OP_AUTO_CONST__M
;
3830 /* fall through - try first guess DRX_CONSTELLATION_QAM64 */
3832 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_CONST_QAM64
;
3835 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_CONST_QPSK
;
3838 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_CONST_QAM16
;
3842 /* No hierarchical channels support in BDA */
3843 /* Priority (only for hierarchical channels) */
3844 switch (channel
->priority
) {
3845 case DRX_PRIORITY_LOW
:
3846 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_PRIO_LO
;
3847 WR16(dev_addr
, OFDM_EC_SB_PRIOR__A
,
3848 OFDM_EC_SB_PRIOR_LO
);
3850 case DRX_PRIORITY_HIGH
:
3851 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_PRIO_HI
;
3852 WR16(dev_addr
, OFDM_EC_SB_PRIOR__A
,
3853 OFDM_EC_SB_PRIOR_HI
));
3855 case DRX_PRIORITY_UNKNOWN
: /* fall through */
3861 /* Set Priority high */
3862 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_PRIO_HI
;
3863 status
= write16(state
, OFDM_EC_SB_PRIOR__A
, OFDM_EC_SB_PRIOR_HI
);
3869 switch (state
->props
.code_rate_HP
) {
3872 operation_mode
|= OFDM_SC_RA_RAM_OP_AUTO_RATE__M
;
3873 /* fall through - try first guess DRX_CODERATE_2DIV3 */
3875 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_RATE_2_3
;
3878 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_RATE_1_2
;
3881 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_RATE_3_4
;
3884 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_RATE_5_6
;
3887 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_RATE_7_8
;
3892 * SAW filter selection: normally not necessary, but if wanted
3893 * the application can select a SAW filter via the driver by
3897 /* First determine real bandwidth (Hz) */
3898 /* Also set delay for impulse noise cruncher */
3900 * Also set parameters for EC_OC fix, note EC_OC_REG_TMD_HIL_MAR is
3901 * changed by SC for fix for some 8K,1/8 guard but is restored by
3902 * InitEC and ResetEC functions
3904 switch (state
->props
.bandwidth_hz
) {
3906 state
->props
.bandwidth_hz
= 8000000;
3909 bandwidth
= DRXK_BANDWIDTH_8MHZ_IN_HZ
;
3910 status
= write16(state
, OFDM_SC_RA_RAM_SRMM_FIX_FACT_8K__A
,
3914 /* cochannel protection for PAL 8 MHz */
3915 status
= write16(state
, OFDM_SC_RA_RAM_NI_INIT_8K_PER_LEFT__A
,
3919 status
= write16(state
, OFDM_SC_RA_RAM_NI_INIT_8K_PER_RIGHT__A
,
3923 status
= write16(state
, OFDM_SC_RA_RAM_NI_INIT_2K_PER_LEFT__A
,
3927 status
= write16(state
, OFDM_SC_RA_RAM_NI_INIT_2K_PER_RIGHT__A
,
3933 bandwidth
= DRXK_BANDWIDTH_7MHZ_IN_HZ
;
3934 status
= write16(state
, OFDM_SC_RA_RAM_SRMM_FIX_FACT_8K__A
,
3938 /* cochannel protection for PAL 7 MHz */
3939 status
= write16(state
, OFDM_SC_RA_RAM_NI_INIT_8K_PER_LEFT__A
,
3943 status
= write16(state
, OFDM_SC_RA_RAM_NI_INIT_8K_PER_RIGHT__A
,
3947 status
= write16(state
, OFDM_SC_RA_RAM_NI_INIT_2K_PER_LEFT__A
,
3951 status
= write16(state
, OFDM_SC_RA_RAM_NI_INIT_2K_PER_RIGHT__A
,
3957 bandwidth
= DRXK_BANDWIDTH_6MHZ_IN_HZ
;
3958 status
= write16(state
, OFDM_SC_RA_RAM_SRMM_FIX_FACT_8K__A
,
3962 /* cochannel protection for NTSC 6 MHz */
3963 status
= write16(state
, OFDM_SC_RA_RAM_NI_INIT_8K_PER_LEFT__A
,
3967 status
= write16(state
, OFDM_SC_RA_RAM_NI_INIT_8K_PER_RIGHT__A
,
3971 status
= write16(state
, OFDM_SC_RA_RAM_NI_INIT_2K_PER_LEFT__A
,
3975 status
= write16(state
, OFDM_SC_RA_RAM_NI_INIT_2K_PER_RIGHT__A
,
3985 if (iqm_rc_rate_ofs
== 0) {
3986 /* Now compute IQM_RC_RATE_OFS
3987 (((SysFreq/BandWidth)/2)/2) -1) * 2^23)
3989 ((SysFreq / BandWidth) * (2^21)) - (2^23)
3991 /* (SysFreq / BandWidth) * (2^28) */
3993 * assert (MAX(sysClk)/MIN(bandwidth) < 16)
3994 * => assert(MAX(sysClk) < 16*MIN(bandwidth))
3995 * => assert(109714272 > 48000000) = true
3996 * so Frac 28 can be used
3998 iqm_rc_rate_ofs
= Frac28a((u32
)
3999 ((state
->m_sys_clock_freq
*
4000 1000) / 3), bandwidth
);
4001 /* (SysFreq / BandWidth) * (2^21), rounding before truncating */
4002 if ((iqm_rc_rate_ofs
& 0x7fL
) >= 0x40)
4003 iqm_rc_rate_ofs
+= 0x80L
;
4004 iqm_rc_rate_ofs
= iqm_rc_rate_ofs
>> 7;
4005 /* ((SysFreq / BandWidth) * (2^21)) - (2^23) */
4006 iqm_rc_rate_ofs
= iqm_rc_rate_ofs
- (1 << 23);
4010 ((((u32
) IQM_RC_RATE_OFS_HI__M
) <<
4011 IQM_RC_RATE_OFS_LO__W
) | IQM_RC_RATE_OFS_LO__M
);
4012 status
= write32(state
, IQM_RC_RATE_OFS_LO__A
, iqm_rc_rate_ofs
);
4016 /* Bandwidth setting done */
4019 status
= dvbt_set_frequency_shift(demod
, channel
, tuner_offset
);
4023 status
= set_frequency_shifter(state
, intermediate_freqk_hz
,
4024 tuner_freq_offset
, true);
4028 /*== start SC, write channel settings to SC ==========================*/
4030 /* Activate SCU to enable SCU commands */
4031 status
= write16(state
, SCU_COMM_EXEC__A
, SCU_COMM_EXEC_ACTIVE
);
4035 /* Enable SC after setting all other parameters */
4036 status
= write16(state
, OFDM_SC_COMM_STATE__A
, 0);
4039 status
= write16(state
, OFDM_SC_COMM_EXEC__A
, 1);
4044 status
= scu_command(state
, SCU_RAM_COMMAND_STANDARD_OFDM
4045 | SCU_RAM_COMMAND_CMD_DEMOD_START
,
4046 0, NULL
, 1, &cmd_result
);
4050 /* Write SC parameter registers, set all AUTO flags in operation mode */
4051 param1
= (OFDM_SC_RA_RAM_OP_AUTO_MODE__M
|
4052 OFDM_SC_RA_RAM_OP_AUTO_GUARD__M
|
4053 OFDM_SC_RA_RAM_OP_AUTO_CONST__M
|
4054 OFDM_SC_RA_RAM_OP_AUTO_HIER__M
|
4055 OFDM_SC_RA_RAM_OP_AUTO_RATE__M
);
4056 status
= dvbt_sc_command(state
, OFDM_SC_RA_RAM_CMD_SET_PREF_PARAM
,
4057 0, transmission_params
, param1
, 0, 0, 0);
4061 if (!state
->m_drxk_a3_rom_code
)
4062 status
= dvbt_ctrl_set_sqi_speed(state
, &state
->m_sqi_speed
);
4065 pr_err("Error %d on %s\n", status
, __func__
);
4071 /*============================================================================*/
4074 * \brief Retrieve lock status .
4075 * \param demod Pointer to demodulator instance.
4076 * \param lockStat Pointer to lock status structure.
4077 * \return DRXStatus_t.
4080 static int get_dvbt_lock_status(struct drxk_state
*state
, u32
*p_lock_status
)
4083 const u16 mpeg_lock_mask
= (OFDM_SC_RA_RAM_LOCK_MPEG__M
|
4084 OFDM_SC_RA_RAM_LOCK_FEC__M
);
4085 const u16 fec_lock_mask
= (OFDM_SC_RA_RAM_LOCK_FEC__M
);
4086 const u16 demod_lock_mask
= OFDM_SC_RA_RAM_LOCK_DEMOD__M
;
4088 u16 sc_ra_ram_lock
= 0;
4089 u16 sc_comm_exec
= 0;
4093 *p_lock_status
= NOT_LOCKED
;
4095 /* Check if SC is running */
4096 status
= read16(state
, OFDM_SC_COMM_EXEC__A
, &sc_comm_exec
);
4099 if (sc_comm_exec
== OFDM_SC_COMM_EXEC_STOP
)
4102 status
= read16(state
, OFDM_SC_RA_RAM_LOCK__A
, &sc_ra_ram_lock
);
4106 if ((sc_ra_ram_lock
& mpeg_lock_mask
) == mpeg_lock_mask
)
4107 *p_lock_status
= MPEG_LOCK
;
4108 else if ((sc_ra_ram_lock
& fec_lock_mask
) == fec_lock_mask
)
4109 *p_lock_status
= FEC_LOCK
;
4110 else if ((sc_ra_ram_lock
& demod_lock_mask
) == demod_lock_mask
)
4111 *p_lock_status
= DEMOD_LOCK
;
4112 else if (sc_ra_ram_lock
& OFDM_SC_RA_RAM_LOCK_NODVBT__M
)
4113 *p_lock_status
= NEVER_LOCK
;
4116 pr_err("Error %d on %s\n", status
, __func__
);
4121 static int power_up_qam(struct drxk_state
*state
)
4123 enum drx_power_mode power_mode
= DRXK_POWER_DOWN_OFDM
;
4127 status
= ctrl_power_mode(state
, &power_mode
);
4129 pr_err("Error %d on %s\n", status
, __func__
);
4135 /* Power Down QAM */
4136 static int power_down_qam(struct drxk_state
*state
)
4143 status
= read16(state
, SCU_COMM_EXEC__A
, &data
);
4146 if (data
== SCU_COMM_EXEC_ACTIVE
) {
4151 /* stop all comstate->m_exec */
4152 status
= write16(state
, QAM_COMM_EXEC__A
, QAM_COMM_EXEC_STOP
);
4155 status
= scu_command(state
, SCU_RAM_COMMAND_STANDARD_QAM
4156 | SCU_RAM_COMMAND_CMD_DEMOD_STOP
,
4157 0, NULL
, 1, &cmd_result
);
4162 status
= set_iqm_af(state
, false);
4166 pr_err("Error %d on %s\n", status
, __func__
);
4171 /*============================================================================*/
4174 * \brief Setup of the QAM Measurement intervals for signal quality
4175 * \param demod instance of demod.
4176 * \param modulation current modulation.
4177 * \return DRXStatus_t.
4180 * Take into account that for certain settings the errorcounters can overflow.
4181 * The implementation does not check this.
4184 static int set_qam_measurement(struct drxk_state
*state
,
4185 enum e_drxk_constellation modulation
,
4188 u32 fec_bits_desired
= 0; /* BER accounting period */
4189 u32 fec_rs_period_total
= 0; /* Total period */
4190 u16 fec_rs_prescale
= 0; /* ReedSolomon Measurement Prescale */
4191 u16 fec_rs_period
= 0; /* Value for corresponding I2C register */
4196 fec_rs_prescale
= 1;
4197 /* fec_bits_desired = symbol_rate [kHz] *
4203 switch (modulation
) {
4204 case DRX_CONSTELLATION_QAM16
:
4205 fec_bits_desired
= 4 * symbol_rate
;
4207 case DRX_CONSTELLATION_QAM32
:
4208 fec_bits_desired
= 5 * symbol_rate
;
4210 case DRX_CONSTELLATION_QAM64
:
4211 fec_bits_desired
= 6 * symbol_rate
;
4213 case DRX_CONSTELLATION_QAM128
:
4214 fec_bits_desired
= 7 * symbol_rate
;
4216 case DRX_CONSTELLATION_QAM256
:
4217 fec_bits_desired
= 8 * symbol_rate
;
4225 fec_bits_desired
/= 1000; /* symbol_rate [Hz] -> symbol_rate [kHz] */
4226 fec_bits_desired
*= 500; /* meas. period [ms] */
4228 /* Annex A/C: bits/RsPeriod = 204 * 8 = 1632 */
4229 /* fec_rs_period_total = fec_bits_desired / 1632 */
4230 fec_rs_period_total
= (fec_bits_desired
/ 1632UL) + 1; /* roughly ceil */
4232 /* fec_rs_period_total = fec_rs_prescale * fec_rs_period */
4233 fec_rs_prescale
= 1 + (u16
) (fec_rs_period_total
>> 16);
4234 if (fec_rs_prescale
== 0) {
4235 /* Divide by zero (though impossible) */
4241 ((u16
) fec_rs_period_total
+
4242 (fec_rs_prescale
>> 1)) / fec_rs_prescale
;
4244 /* write corresponding registers */
4245 status
= write16(state
, FEC_RS_MEASUREMENT_PERIOD__A
, fec_rs_period
);
4248 status
= write16(state
, FEC_RS_MEASUREMENT_PRESCALE__A
,
4252 status
= write16(state
, FEC_OC_SNC_FAIL_PERIOD__A
, fec_rs_period
);
4255 pr_err("Error %d on %s\n", status
, __func__
);
4259 static int set_qam16(struct drxk_state
*state
)
4264 /* QAM Equalizer Setup */
4266 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD0__A
, 13517);
4269 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD1__A
, 13517);
4272 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD2__A
, 13517);
4275 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD3__A
, 13517);
4278 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD4__A
, 13517);
4281 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD5__A
, 13517);
4284 /* Decision Feedback Equalizer */
4285 status
= write16(state
, QAM_DQ_QUAL_FUN0__A
, 2);
4288 status
= write16(state
, QAM_DQ_QUAL_FUN1__A
, 2);
4291 status
= write16(state
, QAM_DQ_QUAL_FUN2__A
, 2);
4294 status
= write16(state
, QAM_DQ_QUAL_FUN3__A
, 2);
4297 status
= write16(state
, QAM_DQ_QUAL_FUN4__A
, 2);
4300 status
= write16(state
, QAM_DQ_QUAL_FUN5__A
, 0);
4304 status
= write16(state
, QAM_SY_SYNC_HWM__A
, 5);
4307 status
= write16(state
, QAM_SY_SYNC_AWM__A
, 4);
4310 status
= write16(state
, QAM_SY_SYNC_LWM__A
, 3);
4314 /* QAM Slicer Settings */
4315 status
= write16(state
, SCU_RAM_QAM_SL_SIG_POWER__A
,
4316 DRXK_QAM_SL_SIG_POWER_QAM16
);
4320 /* QAM Loop Controller Coeficients */
4321 status
= write16(state
, SCU_RAM_QAM_LC_CA_FINE__A
, 15);
4324 status
= write16(state
, SCU_RAM_QAM_LC_CA_COARSE__A
, 40);
4327 status
= write16(state
, SCU_RAM_QAM_LC_EP_FINE__A
, 12);
4330 status
= write16(state
, SCU_RAM_QAM_LC_EP_MEDIUM__A
, 24);
4333 status
= write16(state
, SCU_RAM_QAM_LC_EP_COARSE__A
, 24);
4336 status
= write16(state
, SCU_RAM_QAM_LC_EI_FINE__A
, 12);
4339 status
= write16(state
, SCU_RAM_QAM_LC_EI_MEDIUM__A
, 16);
4342 status
= write16(state
, SCU_RAM_QAM_LC_EI_COARSE__A
, 16);
4346 status
= write16(state
, SCU_RAM_QAM_LC_CP_FINE__A
, 5);
4349 status
= write16(state
, SCU_RAM_QAM_LC_CP_MEDIUM__A
, 20);
4352 status
= write16(state
, SCU_RAM_QAM_LC_CP_COARSE__A
, 80);
4355 status
= write16(state
, SCU_RAM_QAM_LC_CI_FINE__A
, 5);
4358 status
= write16(state
, SCU_RAM_QAM_LC_CI_MEDIUM__A
, 20);
4361 status
= write16(state
, SCU_RAM_QAM_LC_CI_COARSE__A
, 50);
4364 status
= write16(state
, SCU_RAM_QAM_LC_CF_FINE__A
, 16);
4367 status
= write16(state
, SCU_RAM_QAM_LC_CF_MEDIUM__A
, 16);
4370 status
= write16(state
, SCU_RAM_QAM_LC_CF_COARSE__A
, 32);
4373 status
= write16(state
, SCU_RAM_QAM_LC_CF1_FINE__A
, 5);
4376 status
= write16(state
, SCU_RAM_QAM_LC_CF1_MEDIUM__A
, 10);
4379 status
= write16(state
, SCU_RAM_QAM_LC_CF1_COARSE__A
, 10);
4384 /* QAM State Machine (FSM) Thresholds */
4386 status
= write16(state
, SCU_RAM_QAM_FSM_RTH__A
, 140);
4389 status
= write16(state
, SCU_RAM_QAM_FSM_FTH__A
, 50);
4392 status
= write16(state
, SCU_RAM_QAM_FSM_CTH__A
, 95);
4395 status
= write16(state
, SCU_RAM_QAM_FSM_PTH__A
, 120);
4398 status
= write16(state
, SCU_RAM_QAM_FSM_QTH__A
, 230);
4401 status
= write16(state
, SCU_RAM_QAM_FSM_MTH__A
, 105);
4405 status
= write16(state
, SCU_RAM_QAM_FSM_RATE_LIM__A
, 40);
4408 status
= write16(state
, SCU_RAM_QAM_FSM_COUNT_LIM__A
, 4);
4411 status
= write16(state
, SCU_RAM_QAM_FSM_FREQ_LIM__A
, 24);
4416 /* QAM FSM Tracking Parameters */
4418 status
= write16(state
, SCU_RAM_QAM_FSM_MEDIAN_AV_MULT__A
, (u16
) 16);
4421 status
= write16(state
, SCU_RAM_QAM_FSM_RADIUS_AV_LIMIT__A
, (u16
) 220);
4424 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET1__A
, (u16
) 25);
4427 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET2__A
, (u16
) 6);
4430 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET3__A
, (u16
) -24);
4433 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET4__A
, (u16
) -65);
4436 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET5__A
, (u16
) -127);
4442 pr_err("Error %d on %s\n", status
, __func__
);
4446 /*============================================================================*/
4449 * \brief QAM32 specific setup
4450 * \param demod instance of demod.
4451 * \return DRXStatus_t.
4453 static int set_qam32(struct drxk_state
*state
)
4459 /* QAM Equalizer Setup */
4461 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD0__A
, 6707);
4464 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD1__A
, 6707);
4467 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD2__A
, 6707);
4470 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD3__A
, 6707);
4473 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD4__A
, 6707);
4476 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD5__A
, 6707);
4480 /* Decision Feedback Equalizer */
4481 status
= write16(state
, QAM_DQ_QUAL_FUN0__A
, 3);
4484 status
= write16(state
, QAM_DQ_QUAL_FUN1__A
, 3);
4487 status
= write16(state
, QAM_DQ_QUAL_FUN2__A
, 3);
4490 status
= write16(state
, QAM_DQ_QUAL_FUN3__A
, 3);
4493 status
= write16(state
, QAM_DQ_QUAL_FUN4__A
, 3);
4496 status
= write16(state
, QAM_DQ_QUAL_FUN5__A
, 0);
4500 status
= write16(state
, QAM_SY_SYNC_HWM__A
, 6);
4503 status
= write16(state
, QAM_SY_SYNC_AWM__A
, 5);
4506 status
= write16(state
, QAM_SY_SYNC_LWM__A
, 3);
4510 /* QAM Slicer Settings */
4512 status
= write16(state
, SCU_RAM_QAM_SL_SIG_POWER__A
,
4513 DRXK_QAM_SL_SIG_POWER_QAM32
);
4518 /* QAM Loop Controller Coeficients */
4520 status
= write16(state
, SCU_RAM_QAM_LC_CA_FINE__A
, 15);
4523 status
= write16(state
, SCU_RAM_QAM_LC_CA_COARSE__A
, 40);
4526 status
= write16(state
, SCU_RAM_QAM_LC_EP_FINE__A
, 12);
4529 status
= write16(state
, SCU_RAM_QAM_LC_EP_MEDIUM__A
, 24);
4532 status
= write16(state
, SCU_RAM_QAM_LC_EP_COARSE__A
, 24);
4535 status
= write16(state
, SCU_RAM_QAM_LC_EI_FINE__A
, 12);
4538 status
= write16(state
, SCU_RAM_QAM_LC_EI_MEDIUM__A
, 16);
4541 status
= write16(state
, SCU_RAM_QAM_LC_EI_COARSE__A
, 16);
4545 status
= write16(state
, SCU_RAM_QAM_LC_CP_FINE__A
, 5);
4548 status
= write16(state
, SCU_RAM_QAM_LC_CP_MEDIUM__A
, 20);
4551 status
= write16(state
, SCU_RAM_QAM_LC_CP_COARSE__A
, 80);
4554 status
= write16(state
, SCU_RAM_QAM_LC_CI_FINE__A
, 5);
4557 status
= write16(state
, SCU_RAM_QAM_LC_CI_MEDIUM__A
, 20);
4560 status
= write16(state
, SCU_RAM_QAM_LC_CI_COARSE__A
, 50);
4563 status
= write16(state
, SCU_RAM_QAM_LC_CF_FINE__A
, 16);
4566 status
= write16(state
, SCU_RAM_QAM_LC_CF_MEDIUM__A
, 16);
4569 status
= write16(state
, SCU_RAM_QAM_LC_CF_COARSE__A
, 16);
4572 status
= write16(state
, SCU_RAM_QAM_LC_CF1_FINE__A
, 5);
4575 status
= write16(state
, SCU_RAM_QAM_LC_CF1_MEDIUM__A
, 10);
4578 status
= write16(state
, SCU_RAM_QAM_LC_CF1_COARSE__A
, 0);
4583 /* QAM State Machine (FSM) Thresholds */
4585 status
= write16(state
, SCU_RAM_QAM_FSM_RTH__A
, 90);
4588 status
= write16(state
, SCU_RAM_QAM_FSM_FTH__A
, 50);
4591 status
= write16(state
, SCU_RAM_QAM_FSM_CTH__A
, 80);
4594 status
= write16(state
, SCU_RAM_QAM_FSM_PTH__A
, 100);
4597 status
= write16(state
, SCU_RAM_QAM_FSM_QTH__A
, 170);
4600 status
= write16(state
, SCU_RAM_QAM_FSM_MTH__A
, 100);
4604 status
= write16(state
, SCU_RAM_QAM_FSM_RATE_LIM__A
, 40);
4607 status
= write16(state
, SCU_RAM_QAM_FSM_COUNT_LIM__A
, 4);
4610 status
= write16(state
, SCU_RAM_QAM_FSM_FREQ_LIM__A
, 10);
4615 /* QAM FSM Tracking Parameters */
4617 status
= write16(state
, SCU_RAM_QAM_FSM_MEDIAN_AV_MULT__A
, (u16
) 12);
4620 status
= write16(state
, SCU_RAM_QAM_FSM_RADIUS_AV_LIMIT__A
, (u16
) 140);
4623 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET1__A
, (u16
) -8);
4626 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET2__A
, (u16
) -16);
4629 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET3__A
, (u16
) -26);
4632 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET4__A
, (u16
) -56);
4635 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET5__A
, (u16
) -86);
4638 pr_err("Error %d on %s\n", status
, __func__
);
4642 /*============================================================================*/
4645 * \brief QAM64 specific setup
4646 * \param demod instance of demod.
4647 * \return DRXStatus_t.
4649 static int set_qam64(struct drxk_state
*state
)
4654 /* QAM Equalizer Setup */
4656 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD0__A
, 13336);
4659 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD1__A
, 12618);
4662 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD2__A
, 11988);
4665 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD3__A
, 13809);
4668 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD4__A
, 13809);
4671 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD5__A
, 15609);
4675 /* Decision Feedback Equalizer */
4676 status
= write16(state
, QAM_DQ_QUAL_FUN0__A
, 4);
4679 status
= write16(state
, QAM_DQ_QUAL_FUN1__A
, 4);
4682 status
= write16(state
, QAM_DQ_QUAL_FUN2__A
, 4);
4685 status
= write16(state
, QAM_DQ_QUAL_FUN3__A
, 4);
4688 status
= write16(state
, QAM_DQ_QUAL_FUN4__A
, 3);
4691 status
= write16(state
, QAM_DQ_QUAL_FUN5__A
, 0);
4695 status
= write16(state
, QAM_SY_SYNC_HWM__A
, 5);
4698 status
= write16(state
, QAM_SY_SYNC_AWM__A
, 4);
4701 status
= write16(state
, QAM_SY_SYNC_LWM__A
, 3);
4705 /* QAM Slicer Settings */
4706 status
= write16(state
, SCU_RAM_QAM_SL_SIG_POWER__A
,
4707 DRXK_QAM_SL_SIG_POWER_QAM64
);
4712 /* QAM Loop Controller Coeficients */
4714 status
= write16(state
, SCU_RAM_QAM_LC_CA_FINE__A
, 15);
4717 status
= write16(state
, SCU_RAM_QAM_LC_CA_COARSE__A
, 40);
4720 status
= write16(state
, SCU_RAM_QAM_LC_EP_FINE__A
, 12);
4723 status
= write16(state
, SCU_RAM_QAM_LC_EP_MEDIUM__A
, 24);
4726 status
= write16(state
, SCU_RAM_QAM_LC_EP_COARSE__A
, 24);
4729 status
= write16(state
, SCU_RAM_QAM_LC_EI_FINE__A
, 12);
4732 status
= write16(state
, SCU_RAM_QAM_LC_EI_MEDIUM__A
, 16);
4735 status
= write16(state
, SCU_RAM_QAM_LC_EI_COARSE__A
, 16);
4739 status
= write16(state
, SCU_RAM_QAM_LC_CP_FINE__A
, 5);
4742 status
= write16(state
, SCU_RAM_QAM_LC_CP_MEDIUM__A
, 30);
4745 status
= write16(state
, SCU_RAM_QAM_LC_CP_COARSE__A
, 100);
4748 status
= write16(state
, SCU_RAM_QAM_LC_CI_FINE__A
, 5);
4751 status
= write16(state
, SCU_RAM_QAM_LC_CI_MEDIUM__A
, 30);
4754 status
= write16(state
, SCU_RAM_QAM_LC_CI_COARSE__A
, 50);
4757 status
= write16(state
, SCU_RAM_QAM_LC_CF_FINE__A
, 16);
4760 status
= write16(state
, SCU_RAM_QAM_LC_CF_MEDIUM__A
, 25);
4763 status
= write16(state
, SCU_RAM_QAM_LC_CF_COARSE__A
, 48);
4766 status
= write16(state
, SCU_RAM_QAM_LC_CF1_FINE__A
, 5);
4769 status
= write16(state
, SCU_RAM_QAM_LC_CF1_MEDIUM__A
, 10);
4772 status
= write16(state
, SCU_RAM_QAM_LC_CF1_COARSE__A
, 10);
4777 /* QAM State Machine (FSM) Thresholds */
4779 status
= write16(state
, SCU_RAM_QAM_FSM_RTH__A
, 100);
4782 status
= write16(state
, SCU_RAM_QAM_FSM_FTH__A
, 60);
4785 status
= write16(state
, SCU_RAM_QAM_FSM_CTH__A
, 80);
4788 status
= write16(state
, SCU_RAM_QAM_FSM_PTH__A
, 110);
4791 status
= write16(state
, SCU_RAM_QAM_FSM_QTH__A
, 200);
4794 status
= write16(state
, SCU_RAM_QAM_FSM_MTH__A
, 95);
4798 status
= write16(state
, SCU_RAM_QAM_FSM_RATE_LIM__A
, 40);
4801 status
= write16(state
, SCU_RAM_QAM_FSM_COUNT_LIM__A
, 4);
4804 status
= write16(state
, SCU_RAM_QAM_FSM_FREQ_LIM__A
, 15);
4809 /* QAM FSM Tracking Parameters */
4811 status
= write16(state
, SCU_RAM_QAM_FSM_MEDIAN_AV_MULT__A
, (u16
) 12);
4814 status
= write16(state
, SCU_RAM_QAM_FSM_RADIUS_AV_LIMIT__A
, (u16
) 141);
4817 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET1__A
, (u16
) 7);
4820 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET2__A
, (u16
) 0);
4823 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET3__A
, (u16
) -15);
4826 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET4__A
, (u16
) -45);
4829 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET5__A
, (u16
) -80);
4832 pr_err("Error %d on %s\n", status
, __func__
);
4837 /*============================================================================*/
4840 * \brief QAM128 specific setup
4841 * \param demod: instance of demod.
4842 * \return DRXStatus_t.
4844 static int set_qam128(struct drxk_state
*state
)
4849 /* QAM Equalizer Setup */
4851 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD0__A
, 6564);
4854 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD1__A
, 6598);
4857 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD2__A
, 6394);
4860 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD3__A
, 6409);
4863 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD4__A
, 6656);
4866 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD5__A
, 7238);
4870 /* Decision Feedback Equalizer */
4871 status
= write16(state
, QAM_DQ_QUAL_FUN0__A
, 6);
4874 status
= write16(state
, QAM_DQ_QUAL_FUN1__A
, 6);
4877 status
= write16(state
, QAM_DQ_QUAL_FUN2__A
, 6);
4880 status
= write16(state
, QAM_DQ_QUAL_FUN3__A
, 6);
4883 status
= write16(state
, QAM_DQ_QUAL_FUN4__A
, 5);
4886 status
= write16(state
, QAM_DQ_QUAL_FUN5__A
, 0);
4890 status
= write16(state
, QAM_SY_SYNC_HWM__A
, 6);
4893 status
= write16(state
, QAM_SY_SYNC_AWM__A
, 5);
4896 status
= write16(state
, QAM_SY_SYNC_LWM__A
, 3);
4901 /* QAM Slicer Settings */
4903 status
= write16(state
, SCU_RAM_QAM_SL_SIG_POWER__A
,
4904 DRXK_QAM_SL_SIG_POWER_QAM128
);
4909 /* QAM Loop Controller Coeficients */
4911 status
= write16(state
, SCU_RAM_QAM_LC_CA_FINE__A
, 15);
4914 status
= write16(state
, SCU_RAM_QAM_LC_CA_COARSE__A
, 40);
4917 status
= write16(state
, SCU_RAM_QAM_LC_EP_FINE__A
, 12);
4920 status
= write16(state
, SCU_RAM_QAM_LC_EP_MEDIUM__A
, 24);
4923 status
= write16(state
, SCU_RAM_QAM_LC_EP_COARSE__A
, 24);
4926 status
= write16(state
, SCU_RAM_QAM_LC_EI_FINE__A
, 12);
4929 status
= write16(state
, SCU_RAM_QAM_LC_EI_MEDIUM__A
, 16);
4932 status
= write16(state
, SCU_RAM_QAM_LC_EI_COARSE__A
, 16);
4936 status
= write16(state
, SCU_RAM_QAM_LC_CP_FINE__A
, 5);
4939 status
= write16(state
, SCU_RAM_QAM_LC_CP_MEDIUM__A
, 40);
4942 status
= write16(state
, SCU_RAM_QAM_LC_CP_COARSE__A
, 120);
4945 status
= write16(state
, SCU_RAM_QAM_LC_CI_FINE__A
, 5);
4948 status
= write16(state
, SCU_RAM_QAM_LC_CI_MEDIUM__A
, 40);
4951 status
= write16(state
, SCU_RAM_QAM_LC_CI_COARSE__A
, 60);
4954 status
= write16(state
, SCU_RAM_QAM_LC_CF_FINE__A
, 16);
4957 status
= write16(state
, SCU_RAM_QAM_LC_CF_MEDIUM__A
, 25);
4960 status
= write16(state
, SCU_RAM_QAM_LC_CF_COARSE__A
, 64);
4963 status
= write16(state
, SCU_RAM_QAM_LC_CF1_FINE__A
, 5);
4966 status
= write16(state
, SCU_RAM_QAM_LC_CF1_MEDIUM__A
, 10);
4969 status
= write16(state
, SCU_RAM_QAM_LC_CF1_COARSE__A
, 0);
4974 /* QAM State Machine (FSM) Thresholds */
4976 status
= write16(state
, SCU_RAM_QAM_FSM_RTH__A
, 50);
4979 status
= write16(state
, SCU_RAM_QAM_FSM_FTH__A
, 60);
4982 status
= write16(state
, SCU_RAM_QAM_FSM_CTH__A
, 80);
4985 status
= write16(state
, SCU_RAM_QAM_FSM_PTH__A
, 100);
4988 status
= write16(state
, SCU_RAM_QAM_FSM_QTH__A
, 140);
4991 status
= write16(state
, SCU_RAM_QAM_FSM_MTH__A
, 100);
4995 status
= write16(state
, SCU_RAM_QAM_FSM_RATE_LIM__A
, 40);
4998 status
= write16(state
, SCU_RAM_QAM_FSM_COUNT_LIM__A
, 5);
5002 status
= write16(state
, SCU_RAM_QAM_FSM_FREQ_LIM__A
, 12);
5006 /* QAM FSM Tracking Parameters */
5008 status
= write16(state
, SCU_RAM_QAM_FSM_MEDIAN_AV_MULT__A
, (u16
) 8);
5011 status
= write16(state
, SCU_RAM_QAM_FSM_RADIUS_AV_LIMIT__A
, (u16
) 65);
5014 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET1__A
, (u16
) 5);
5017 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET2__A
, (u16
) 3);
5020 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET3__A
, (u16
) -1);
5023 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET4__A
, (u16
) -12);
5026 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET5__A
, (u16
) -23);
5029 pr_err("Error %d on %s\n", status
, __func__
);
5034 /*============================================================================*/
5037 * \brief QAM256 specific setup
5038 * \param demod: instance of demod.
5039 * \return DRXStatus_t.
5041 static int set_qam256(struct drxk_state
*state
)
5046 /* QAM Equalizer Setup */
5048 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD0__A
, 11502);
5051 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD1__A
, 12084);
5054 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD2__A
, 12543);
5057 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD3__A
, 12931);
5060 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD4__A
, 13629);
5063 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD5__A
, 15385);
5067 /* Decision Feedback Equalizer */
5068 status
= write16(state
, QAM_DQ_QUAL_FUN0__A
, 8);
5071 status
= write16(state
, QAM_DQ_QUAL_FUN1__A
, 8);
5074 status
= write16(state
, QAM_DQ_QUAL_FUN2__A
, 8);
5077 status
= write16(state
, QAM_DQ_QUAL_FUN3__A
, 8);
5080 status
= write16(state
, QAM_DQ_QUAL_FUN4__A
, 6);
5083 status
= write16(state
, QAM_DQ_QUAL_FUN5__A
, 0);
5087 status
= write16(state
, QAM_SY_SYNC_HWM__A
, 5);
5090 status
= write16(state
, QAM_SY_SYNC_AWM__A
, 4);
5093 status
= write16(state
, QAM_SY_SYNC_LWM__A
, 3);
5097 /* QAM Slicer Settings */
5099 status
= write16(state
, SCU_RAM_QAM_SL_SIG_POWER__A
,
5100 DRXK_QAM_SL_SIG_POWER_QAM256
);
5105 /* QAM Loop Controller Coeficients */
5107 status
= write16(state
, SCU_RAM_QAM_LC_CA_FINE__A
, 15);
5110 status
= write16(state
, SCU_RAM_QAM_LC_CA_COARSE__A
, 40);
5113 status
= write16(state
, SCU_RAM_QAM_LC_EP_FINE__A
, 12);
5116 status
= write16(state
, SCU_RAM_QAM_LC_EP_MEDIUM__A
, 24);
5119 status
= write16(state
, SCU_RAM_QAM_LC_EP_COARSE__A
, 24);
5122 status
= write16(state
, SCU_RAM_QAM_LC_EI_FINE__A
, 12);
5125 status
= write16(state
, SCU_RAM_QAM_LC_EI_MEDIUM__A
, 16);
5128 status
= write16(state
, SCU_RAM_QAM_LC_EI_COARSE__A
, 16);
5132 status
= write16(state
, SCU_RAM_QAM_LC_CP_FINE__A
, 5);
5135 status
= write16(state
, SCU_RAM_QAM_LC_CP_MEDIUM__A
, 50);
5138 status
= write16(state
, SCU_RAM_QAM_LC_CP_COARSE__A
, 250);
5141 status
= write16(state
, SCU_RAM_QAM_LC_CI_FINE__A
, 5);
5144 status
= write16(state
, SCU_RAM_QAM_LC_CI_MEDIUM__A
, 50);
5147 status
= write16(state
, SCU_RAM_QAM_LC_CI_COARSE__A
, 125);
5150 status
= write16(state
, SCU_RAM_QAM_LC_CF_FINE__A
, 16);
5153 status
= write16(state
, SCU_RAM_QAM_LC_CF_MEDIUM__A
, 25);
5156 status
= write16(state
, SCU_RAM_QAM_LC_CF_COARSE__A
, 48);
5159 status
= write16(state
, SCU_RAM_QAM_LC_CF1_FINE__A
, 5);
5162 status
= write16(state
, SCU_RAM_QAM_LC_CF1_MEDIUM__A
, 10);
5165 status
= write16(state
, SCU_RAM_QAM_LC_CF1_COARSE__A
, 10);
5170 /* QAM State Machine (FSM) Thresholds */
5172 status
= write16(state
, SCU_RAM_QAM_FSM_RTH__A
, 50);
5175 status
= write16(state
, SCU_RAM_QAM_FSM_FTH__A
, 60);
5178 status
= write16(state
, SCU_RAM_QAM_FSM_CTH__A
, 80);
5181 status
= write16(state
, SCU_RAM_QAM_FSM_PTH__A
, 100);
5184 status
= write16(state
, SCU_RAM_QAM_FSM_QTH__A
, 150);
5187 status
= write16(state
, SCU_RAM_QAM_FSM_MTH__A
, 110);
5191 status
= write16(state
, SCU_RAM_QAM_FSM_RATE_LIM__A
, 40);
5194 status
= write16(state
, SCU_RAM_QAM_FSM_COUNT_LIM__A
, 4);
5197 status
= write16(state
, SCU_RAM_QAM_FSM_FREQ_LIM__A
, 12);
5202 /* QAM FSM Tracking Parameters */
5204 status
= write16(state
, SCU_RAM_QAM_FSM_MEDIAN_AV_MULT__A
, (u16
) 8);
5207 status
= write16(state
, SCU_RAM_QAM_FSM_RADIUS_AV_LIMIT__A
, (u16
) 74);
5210 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET1__A
, (u16
) 18);
5213 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET2__A
, (u16
) 13);
5216 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET3__A
, (u16
) 7);
5219 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET4__A
, (u16
) 0);
5222 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET5__A
, (u16
) -8);
5225 pr_err("Error %d on %s\n", status
, __func__
);
5230 /*============================================================================*/
5232 * \brief Reset QAM block.
5233 * \param demod: instance of demod.
5234 * \param channel: pointer to channel data.
5235 * \return DRXStatus_t.
5237 static int qam_reset_qam(struct drxk_state
*state
)
5243 /* Stop QAM comstate->m_exec */
5244 status
= write16(state
, QAM_COMM_EXEC__A
, QAM_COMM_EXEC_STOP
);
5248 status
= scu_command(state
, SCU_RAM_COMMAND_STANDARD_QAM
5249 | SCU_RAM_COMMAND_CMD_DEMOD_RESET
,
5250 0, NULL
, 1, &cmd_result
);
5253 pr_err("Error %d on %s\n", status
, __func__
);
5257 /*============================================================================*/
5260 * \brief Set QAM symbolrate.
5261 * \param demod: instance of demod.
5262 * \param channel: pointer to channel data.
5263 * \return DRXStatus_t.
5265 static int qam_set_symbolrate(struct drxk_state
*state
)
5267 u32 adc_frequency
= 0;
5269 u32 iqm_rc_rate
= 0;
5271 u32 lc_symb_rate
= 0;
5275 /* Select & calculate correct IQM rate */
5276 adc_frequency
= (state
->m_sys_clock_freq
* 1000) / 3;
5278 if (state
->props
.symbol_rate
<= 1188750)
5280 else if (state
->props
.symbol_rate
<= 2377500)
5282 else if (state
->props
.symbol_rate
<= 4755000)
5284 status
= write16(state
, IQM_FD_RATESEL__A
, ratesel
);
5289 IqmRcRate = ((Fadc / (symbolrate * (4<<ratesel))) - 1) * (1<<23)
5291 symb_freq
= state
->props
.symbol_rate
* (1 << ratesel
);
5292 if (symb_freq
== 0) {
5293 /* Divide by zero */
5297 iqm_rc_rate
= (adc_frequency
/ symb_freq
) * (1 << 21) +
5298 (Frac28a((adc_frequency
% symb_freq
), symb_freq
) >> 7) -
5300 status
= write32(state
, IQM_RC_RATE_OFS_LO__A
, iqm_rc_rate
);
5303 state
->m_iqm_rc_rate
= iqm_rc_rate
;
5305 LcSymbFreq = round (.125 * symbolrate / adc_freq * (1<<15))
5307 symb_freq
= state
->props
.symbol_rate
;
5308 if (adc_frequency
== 0) {
5309 /* Divide by zero */
5313 lc_symb_rate
= (symb_freq
/ adc_frequency
) * (1 << 12) +
5314 (Frac28a((symb_freq
% adc_frequency
), adc_frequency
) >>
5316 if (lc_symb_rate
> 511)
5318 status
= write16(state
, QAM_LC_SYMBOL_FREQ__A
, (u16
) lc_symb_rate
);
5322 pr_err("Error %d on %s\n", status
, __func__
);
5326 /*============================================================================*/
5329 * \brief Get QAM lock status.
5330 * \param demod: instance of demod.
5331 * \param channel: pointer to channel data.
5332 * \return DRXStatus_t.
5335 static int get_qam_lock_status(struct drxk_state
*state
, u32
*p_lock_status
)
5338 u16 result
[2] = { 0, 0 };
5341 *p_lock_status
= NOT_LOCKED
;
5342 status
= scu_command(state
,
5343 SCU_RAM_COMMAND_STANDARD_QAM
|
5344 SCU_RAM_COMMAND_CMD_DEMOD_GET_LOCK
, 0, NULL
, 2,
5347 pr_err("Error %d on %s\n", status
, __func__
);
5349 if (result
[1] < SCU_RAM_QAM_LOCKED_LOCKED_DEMOD_LOCKED
) {
5350 /* 0x0000 NOT LOCKED */
5351 } else if (result
[1] < SCU_RAM_QAM_LOCKED_LOCKED_LOCKED
) {
5352 /* 0x4000 DEMOD LOCKED */
5353 *p_lock_status
= DEMOD_LOCK
;
5354 } else if (result
[1] < SCU_RAM_QAM_LOCKED_LOCKED_NEVER_LOCK
) {
5355 /* 0x8000 DEMOD + FEC LOCKED (system lock) */
5356 *p_lock_status
= MPEG_LOCK
;
5358 /* 0xC000 NEVER LOCKED */
5359 /* (system will never be able to lock to the signal) */
5361 * TODO: check this, intermediate & standard specific lock
5362 * states are not taken into account here
5364 *p_lock_status
= NEVER_LOCK
;
5369 #define QAM_MIRROR__M 0x03
5370 #define QAM_MIRROR_NORMAL 0x00
5371 #define QAM_MIRRORED 0x01
5372 #define QAM_MIRROR_AUTO_ON 0x02
5373 #define QAM_LOCKRANGE__M 0x10
5374 #define QAM_LOCKRANGE_NORMAL 0x10
5376 static int qam_demodulator_command(struct drxk_state
*state
,
5377 int number_of_parameters
)
5381 u16 set_param_parameters
[4] = { 0, 0, 0, 0 };
5383 set_param_parameters
[0] = state
->m_constellation
; /* modulation */
5384 set_param_parameters
[1] = DRXK_QAM_I12_J17
; /* interleave mode */
5386 if (number_of_parameters
== 2) {
5387 u16 set_env_parameters
[1] = { 0 };
5389 if (state
->m_operation_mode
== OM_QAM_ITU_C
)
5390 set_env_parameters
[0] = QAM_TOP_ANNEX_C
;
5392 set_env_parameters
[0] = QAM_TOP_ANNEX_A
;
5394 status
= scu_command(state
,
5395 SCU_RAM_COMMAND_STANDARD_QAM
5396 | SCU_RAM_COMMAND_CMD_DEMOD_SET_ENV
,
5397 1, set_env_parameters
, 1, &cmd_result
);
5401 status
= scu_command(state
,
5402 SCU_RAM_COMMAND_STANDARD_QAM
5403 | SCU_RAM_COMMAND_CMD_DEMOD_SET_PARAM
,
5404 number_of_parameters
, set_param_parameters
,
5406 } else if (number_of_parameters
== 4) {
5407 if (state
->m_operation_mode
== OM_QAM_ITU_C
)
5408 set_param_parameters
[2] = QAM_TOP_ANNEX_C
;
5410 set_param_parameters
[2] = QAM_TOP_ANNEX_A
;
5412 set_param_parameters
[3] |= (QAM_MIRROR_AUTO_ON
);
5413 /* Env parameters */
5414 /* check for LOCKRANGE Extended */
5415 /* set_param_parameters[3] |= QAM_LOCKRANGE_NORMAL; */
5417 status
= scu_command(state
,
5418 SCU_RAM_COMMAND_STANDARD_QAM
5419 | SCU_RAM_COMMAND_CMD_DEMOD_SET_PARAM
,
5420 number_of_parameters
, set_param_parameters
,
5423 pr_warn("Unknown QAM demodulator parameter count %d\n",
5424 number_of_parameters
);
5430 pr_warn("Warning %d on %s\n", status
, __func__
);
5434 static int set_qam(struct drxk_state
*state
, u16 intermediate_freqk_hz
,
5435 s32 tuner_freq_offset
)
5439 int qam_demod_param_count
= state
->qam_demod_parameter_count
;
5443 * STEP 1: reset demodulator
5444 * resets FEC DI and FEC RS
5446 * resets SCU variables
5448 status
= write16(state
, FEC_DI_COMM_EXEC__A
, FEC_DI_COMM_EXEC_STOP
);
5451 status
= write16(state
, FEC_RS_COMM_EXEC__A
, FEC_RS_COMM_EXEC_STOP
);
5454 status
= qam_reset_qam(state
);
5459 * STEP 2: configure demodulator
5460 * -set params; resets IQM,QAM,FEC HW; initializes some
5463 status
= qam_set_symbolrate(state
);
5468 switch (state
->props
.modulation
) {
5470 state
->m_constellation
= DRX_CONSTELLATION_QAM256
;
5474 state
->m_constellation
= DRX_CONSTELLATION_QAM64
;
5477 state
->m_constellation
= DRX_CONSTELLATION_QAM16
;
5480 state
->m_constellation
= DRX_CONSTELLATION_QAM32
;
5483 state
->m_constellation
= DRX_CONSTELLATION_QAM128
;
5492 /* Use the 4-parameter if it's requested or we're probing for
5493 * the correct command. */
5494 if (state
->qam_demod_parameter_count
== 4
5495 || !state
->qam_demod_parameter_count
) {
5496 qam_demod_param_count
= 4;
5497 status
= qam_demodulator_command(state
, qam_demod_param_count
);
5500 /* Use the 2-parameter command if it was requested or if we're
5501 * probing for the correct command and the 4-parameter command
5503 if (state
->qam_demod_parameter_count
== 2
5504 || (!state
->qam_demod_parameter_count
&& status
< 0)) {
5505 qam_demod_param_count
= 2;
5506 status
= qam_demodulator_command(state
, qam_demod_param_count
);
5510 dprintk(1, "Could not set demodulator parameters.\n");
5512 "Make sure qam_demod_parameter_count (%d) is correct for your firmware (%s).\n",
5513 state
->qam_demod_parameter_count
,
5514 state
->microcode_name
);
5516 } else if (!state
->qam_demod_parameter_count
) {
5518 "Auto-probing the QAM command parameters was successful - using %d parameters.\n",
5519 qam_demod_param_count
);
5522 * One of our commands was successful. We don't need to
5523 * auto-probe anymore, now that we got the correct command.
5525 state
->qam_demod_parameter_count
= qam_demod_param_count
;
5529 * STEP 3: enable the system in a mode where the ADC provides valid
5530 * signal setup modulation independent registers
5533 status
= set_frequency(channel
, tuner_freq_offset
));
5537 status
= set_frequency_shifter(state
, intermediate_freqk_hz
,
5538 tuner_freq_offset
, true);
5542 /* Setup BER measurement */
5543 status
= set_qam_measurement(state
, state
->m_constellation
,
5544 state
->props
.symbol_rate
);
5548 /* Reset default values */
5549 status
= write16(state
, IQM_CF_SCALE_SH__A
, IQM_CF_SCALE_SH__PRE
);
5552 status
= write16(state
, QAM_SY_TIMEOUT__A
, QAM_SY_TIMEOUT__PRE
);
5556 /* Reset default LC values */
5557 status
= write16(state
, QAM_LC_RATE_LIMIT__A
, 3);
5560 status
= write16(state
, QAM_LC_LPF_FACTORP__A
, 4);
5563 status
= write16(state
, QAM_LC_LPF_FACTORI__A
, 4);
5566 status
= write16(state
, QAM_LC_MODE__A
, 7);
5570 status
= write16(state
, QAM_LC_QUAL_TAB0__A
, 1);
5573 status
= write16(state
, QAM_LC_QUAL_TAB1__A
, 1);
5576 status
= write16(state
, QAM_LC_QUAL_TAB2__A
, 1);
5579 status
= write16(state
, QAM_LC_QUAL_TAB3__A
, 1);
5582 status
= write16(state
, QAM_LC_QUAL_TAB4__A
, 2);
5585 status
= write16(state
, QAM_LC_QUAL_TAB5__A
, 2);
5588 status
= write16(state
, QAM_LC_QUAL_TAB6__A
, 2);
5591 status
= write16(state
, QAM_LC_QUAL_TAB8__A
, 2);
5594 status
= write16(state
, QAM_LC_QUAL_TAB9__A
, 2);
5597 status
= write16(state
, QAM_LC_QUAL_TAB10__A
, 2);
5600 status
= write16(state
, QAM_LC_QUAL_TAB12__A
, 2);
5603 status
= write16(state
, QAM_LC_QUAL_TAB15__A
, 3);
5606 status
= write16(state
, QAM_LC_QUAL_TAB16__A
, 3);
5609 status
= write16(state
, QAM_LC_QUAL_TAB20__A
, 4);
5612 status
= write16(state
, QAM_LC_QUAL_TAB25__A
, 4);
5616 /* Mirroring, QAM-block starting point not inverted */
5617 status
= write16(state
, QAM_SY_SP_INV__A
,
5618 QAM_SY_SP_INV_SPECTRUM_INV_DIS
);
5622 /* Halt SCU to enable safe non-atomic accesses */
5623 status
= write16(state
, SCU_COMM_EXEC__A
, SCU_COMM_EXEC_HOLD
);
5627 /* STEP 4: modulation specific setup */
5628 switch (state
->props
.modulation
) {
5630 status
= set_qam16(state
);
5633 status
= set_qam32(state
);
5637 status
= set_qam64(state
);
5640 status
= set_qam128(state
);
5643 status
= set_qam256(state
);
5652 /* Activate SCU to enable SCU commands */
5653 status
= write16(state
, SCU_COMM_EXEC__A
, SCU_COMM_EXEC_ACTIVE
);
5657 /* Re-configure MPEG output, requires knowledge of channel bitrate */
5658 /* extAttr->currentChannel.modulation = channel->modulation; */
5659 /* extAttr->currentChannel.symbolrate = channel->symbolrate; */
5660 status
= mpegts_dto_setup(state
, state
->m_operation_mode
);
5664 /* start processes */
5665 status
= mpegts_start(state
);
5668 status
= write16(state
, FEC_COMM_EXEC__A
, FEC_COMM_EXEC_ACTIVE
);
5671 status
= write16(state
, QAM_COMM_EXEC__A
, QAM_COMM_EXEC_ACTIVE
);
5674 status
= write16(state
, IQM_COMM_EXEC__A
, IQM_COMM_EXEC_B_ACTIVE
);
5678 /* STEP 5: start QAM demodulator (starts FEC, QAM and IQM HW) */
5679 status
= scu_command(state
, SCU_RAM_COMMAND_STANDARD_QAM
5680 | SCU_RAM_COMMAND_CMD_DEMOD_START
,
5681 0, NULL
, 1, &cmd_result
);
5685 /* update global DRXK data container */
5686 /*? extAttr->qamInterleaveMode = DRXK_QAM_I12_J17; */
5690 pr_err("Error %d on %s\n", status
, __func__
);
5694 static int set_qam_standard(struct drxk_state
*state
,
5695 enum operation_mode o_mode
)
5698 #ifdef DRXK_QAM_TAPS
5699 #define DRXK_QAMA_TAPS_SELECT
5700 #include "drxk_filters.h"
5701 #undef DRXK_QAMA_TAPS_SELECT
5706 /* added antenna switch */
5707 switch_antenna_to_qam(state
);
5709 /* Ensure correct power-up mode */
5710 status
= power_up_qam(state
);
5713 /* Reset QAM block */
5714 status
= qam_reset_qam(state
);
5720 status
= write16(state
, IQM_COMM_EXEC__A
, IQM_COMM_EXEC_B_STOP
);
5723 status
= write16(state
, IQM_AF_AMUX__A
, IQM_AF_AMUX_SIGNAL2ADC
);
5727 /* Upload IQM Channel Filter settings by
5728 boot loader from ROM table */
5731 status
= bl_chain_cmd(state
, DRXK_BL_ROM_OFFSET_TAPS_ITU_A
,
5732 DRXK_BLCC_NR_ELEMENTS_TAPS
,
5736 status
= bl_direct_cmd(state
, IQM_CF_TAP_RE0__A
,
5737 DRXK_BL_ROM_OFFSET_TAPS_ITU_C
,
5738 DRXK_BLDC_NR_ELEMENTS_TAPS
,
5742 status
= bl_direct_cmd(state
,
5744 DRXK_BL_ROM_OFFSET_TAPS_ITU_C
,
5745 DRXK_BLDC_NR_ELEMENTS_TAPS
,
5754 status
= write16(state
, IQM_CF_OUT_ENA__A
, 1 << IQM_CF_OUT_ENA_QAM__B
);
5757 status
= write16(state
, IQM_CF_SYMMETRIC__A
, 0);
5760 status
= write16(state
, IQM_CF_MIDTAP__A
,
5761 ((1 << IQM_CF_MIDTAP_RE__B
) | (1 << IQM_CF_MIDTAP_IM__B
)));
5765 status
= write16(state
, IQM_RC_STRETCH__A
, 21);
5768 status
= write16(state
, IQM_AF_CLP_LEN__A
, 0);
5771 status
= write16(state
, IQM_AF_CLP_TH__A
, 448);
5774 status
= write16(state
, IQM_AF_SNS_LEN__A
, 0);
5777 status
= write16(state
, IQM_CF_POW_MEAS_LEN__A
, 0);
5781 status
= write16(state
, IQM_FS_ADJ_SEL__A
, 1);
5784 status
= write16(state
, IQM_RC_ADJ_SEL__A
, 1);
5787 status
= write16(state
, IQM_CF_ADJ_SEL__A
, 1);
5790 status
= write16(state
, IQM_AF_UPD_SEL__A
, 0);
5794 /* IQM Impulse Noise Processing Unit */
5795 status
= write16(state
, IQM_CF_CLP_VAL__A
, 500);
5798 status
= write16(state
, IQM_CF_DATATH__A
, 1000);
5801 status
= write16(state
, IQM_CF_BYPASSDET__A
, 1);
5804 status
= write16(state
, IQM_CF_DET_LCT__A
, 0);
5807 status
= write16(state
, IQM_CF_WND_LEN__A
, 1);
5810 status
= write16(state
, IQM_CF_PKDTH__A
, 1);
5813 status
= write16(state
, IQM_AF_INC_BYPASS__A
, 1);
5817 /* turn on IQMAF. Must be done before setAgc**() */
5818 status
= set_iqm_af(state
, true);
5821 status
= write16(state
, IQM_AF_START_LOCK__A
, 0x01);
5825 /* IQM will not be reset from here, sync ADC and update/init AGC */
5826 status
= adc_synchronization(state
);
5830 /* Set the FSM step period */
5831 status
= write16(state
, SCU_RAM_QAM_FSM_STEP_PERIOD__A
, 2000);
5835 /* Halt SCU to enable safe non-atomic accesses */
5836 status
= write16(state
, SCU_COMM_EXEC__A
, SCU_COMM_EXEC_HOLD
);
5840 /* No more resets of the IQM, current standard correctly set =>
5841 now AGCs can be configured. */
5843 status
= init_agc(state
, true);
5846 status
= set_pre_saw(state
, &(state
->m_qam_pre_saw_cfg
));
5850 /* Configure AGC's */
5851 status
= set_agc_rf(state
, &(state
->m_qam_rf_agc_cfg
), true);
5854 status
= set_agc_if(state
, &(state
->m_qam_if_agc_cfg
), true);
5858 /* Activate SCU to enable SCU commands */
5859 status
= write16(state
, SCU_COMM_EXEC__A
, SCU_COMM_EXEC_ACTIVE
);
5862 pr_err("Error %d on %s\n", status
, __func__
);
5866 static int write_gpio(struct drxk_state
*state
)
5872 /* stop lock indicator process */
5873 status
= write16(state
, SCU_RAM_GPIO__A
,
5874 SCU_RAM_GPIO_HW_LOCK_IND_DISABLE
);
5878 /* Write magic word to enable pdr reg write */
5879 status
= write16(state
, SIO_TOP_COMM_KEY__A
, SIO_TOP_COMM_KEY_KEY
);
5883 if (state
->m_has_sawsw
) {
5884 if (state
->uio_mask
& 0x0001) { /* UIO-1 */
5885 /* write to io pad configuration register - output mode */
5886 status
= write16(state
, SIO_PDR_SMA_TX_CFG__A
,
5891 /* use corresponding bit in io data output registar */
5892 status
= read16(state
, SIO_PDR_UIO_OUT_LO__A
, &value
);
5895 if ((state
->m_gpio
& 0x0001) == 0)
5896 value
&= 0x7FFF; /* write zero to 15th bit - 1st UIO */
5898 value
|= 0x8000; /* write one to 15th bit - 1st UIO */
5899 /* write back to io data output register */
5900 status
= write16(state
, SIO_PDR_UIO_OUT_LO__A
, value
);
5904 if (state
->uio_mask
& 0x0002) { /* UIO-2 */
5905 /* write to io pad configuration register - output mode */
5906 status
= write16(state
, SIO_PDR_SMA_RX_CFG__A
,
5911 /* use corresponding bit in io data output registar */
5912 status
= read16(state
, SIO_PDR_UIO_OUT_LO__A
, &value
);
5915 if ((state
->m_gpio
& 0x0002) == 0)
5916 value
&= 0xBFFF; /* write zero to 14th bit - 2st UIO */
5918 value
|= 0x4000; /* write one to 14th bit - 2st UIO */
5919 /* write back to io data output register */
5920 status
= write16(state
, SIO_PDR_UIO_OUT_LO__A
, value
);
5924 if (state
->uio_mask
& 0x0004) { /* UIO-3 */
5925 /* write to io pad configuration register - output mode */
5926 status
= write16(state
, SIO_PDR_GPIO_CFG__A
,
5931 /* use corresponding bit in io data output registar */
5932 status
= read16(state
, SIO_PDR_UIO_OUT_LO__A
, &value
);
5935 if ((state
->m_gpio
& 0x0004) == 0)
5936 value
&= 0xFFFB; /* write zero to 2nd bit - 3rd UIO */
5938 value
|= 0x0004; /* write one to 2nd bit - 3rd UIO */
5939 /* write back to io data output register */
5940 status
= write16(state
, SIO_PDR_UIO_OUT_LO__A
, value
);
5945 /* Write magic word to disable pdr reg write */
5946 status
= write16(state
, SIO_TOP_COMM_KEY__A
, 0x0000);
5949 pr_err("Error %d on %s\n", status
, __func__
);
5953 static int switch_antenna_to_qam(struct drxk_state
*state
)
5960 if (!state
->antenna_gpio
)
5963 gpio_state
= state
->m_gpio
& state
->antenna_gpio
;
5965 if (state
->antenna_dvbt
^ gpio_state
) {
5966 /* Antenna is on DVB-T mode. Switch */
5967 if (state
->antenna_dvbt
)
5968 state
->m_gpio
&= ~state
->antenna_gpio
;
5970 state
->m_gpio
|= state
->antenna_gpio
;
5971 status
= write_gpio(state
);
5974 pr_err("Error %d on %s\n", status
, __func__
);
5978 static int switch_antenna_to_dvbt(struct drxk_state
*state
)
5985 if (!state
->antenna_gpio
)
5988 gpio_state
= state
->m_gpio
& state
->antenna_gpio
;
5990 if (!(state
->antenna_dvbt
^ gpio_state
)) {
5991 /* Antenna is on DVB-C mode. Switch */
5992 if (state
->antenna_dvbt
)
5993 state
->m_gpio
|= state
->antenna_gpio
;
5995 state
->m_gpio
&= ~state
->antenna_gpio
;
5996 status
= write_gpio(state
);
5999 pr_err("Error %d on %s\n", status
, __func__
);
6004 static int power_down_device(struct drxk_state
*state
)
6006 /* Power down to requested mode */
6007 /* Backup some register settings */
6008 /* Set pins with possible pull-ups connected to them in input mode */
6009 /* Analog power down */
6010 /* ADC power down */
6011 /* Power down device */
6015 if (state
->m_b_p_down_open_bridge
) {
6016 /* Open I2C bridge before power down of DRXK */
6017 status
= ConfigureI2CBridge(state
, true);
6022 status
= dvbt_enable_ofdm_token_ring(state
, false);
6026 status
= write16(state
, SIO_CC_PWD_MODE__A
,
6027 SIO_CC_PWD_MODE_LEVEL_CLOCK
);
6030 status
= write16(state
, SIO_CC_UPDATE__A
, SIO_CC_UPDATE_KEY
);
6033 state
->m_hi_cfg_ctrl
|= SIO_HI_RA_RAM_PAR_5_CFG_SLEEP_ZZZ
;
6034 status
= hi_cfg_command(state
);
6037 pr_err("Error %d on %s\n", status
, __func__
);
6042 static int init_drxk(struct drxk_state
*state
)
6044 int status
= 0, n
= 0;
6045 enum drx_power_mode power_mode
= DRXK_POWER_DOWN_OFDM
;
6049 if (state
->m_drxk_state
== DRXK_UNINITIALIZED
) {
6050 drxk_i2c_lock(state
);
6051 status
= power_up_device(state
);
6054 status
= drxx_open(state
);
6057 /* Soft reset of OFDM-, sys- and osc-clockdomain */
6058 status
= write16(state
, SIO_CC_SOFT_RST__A
,
6059 SIO_CC_SOFT_RST_OFDM__M
6060 | SIO_CC_SOFT_RST_SYS__M
6061 | SIO_CC_SOFT_RST_OSC__M
);
6064 status
= write16(state
, SIO_CC_UPDATE__A
, SIO_CC_UPDATE_KEY
);
6068 * TODO is this needed? If yes, how much delay in
6069 * worst case scenario
6071 usleep_range(1000, 2000);
6072 state
->m_drxk_a3_patch_code
= true;
6073 status
= get_device_capabilities(state
);
6077 /* Bridge delay, uses oscilator clock */
6078 /* Delay = (delay (nano seconds) * oscclk (kHz))/ 1000 */
6079 /* SDA brdige delay */
6080 state
->m_hi_cfg_bridge_delay
=
6081 (u16
) ((state
->m_osc_clock_freq
/ 1000) *
6082 HI_I2C_BRIDGE_DELAY
) / 1000;
6084 if (state
->m_hi_cfg_bridge_delay
>
6085 SIO_HI_RA_RAM_PAR_3_CFG_DBL_SDA__M
) {
6086 state
->m_hi_cfg_bridge_delay
=
6087 SIO_HI_RA_RAM_PAR_3_CFG_DBL_SDA__M
;
6089 /* SCL bridge delay, same as SDA for now */
6090 state
->m_hi_cfg_bridge_delay
+=
6091 state
->m_hi_cfg_bridge_delay
<<
6092 SIO_HI_RA_RAM_PAR_3_CFG_DBL_SCL__B
;
6094 status
= init_hi(state
);
6097 /* disable various processes */
6099 if (!(state
->m_DRXK_A1_ROM_CODE
)
6100 && !(state
->m_DRXK_A2_ROM_CODE
))
6103 status
= write16(state
, SCU_RAM_GPIO__A
,
6104 SCU_RAM_GPIO_HW_LOCK_IND_DISABLE
);
6109 /* disable MPEG port */
6110 status
= mpegts_disable(state
);
6114 /* Stop AUD and SCU */
6115 status
= write16(state
, AUD_COMM_EXEC__A
, AUD_COMM_EXEC_STOP
);
6118 status
= write16(state
, SCU_COMM_EXEC__A
, SCU_COMM_EXEC_STOP
);
6122 /* enable token-ring bus through OFDM block for possible ucode upload */
6123 status
= write16(state
, SIO_OFDM_SH_OFDM_RING_ENABLE__A
,
6124 SIO_OFDM_SH_OFDM_RING_ENABLE_ON
);
6128 /* include boot loader section */
6129 status
= write16(state
, SIO_BL_COMM_EXEC__A
,
6130 SIO_BL_COMM_EXEC_ACTIVE
);
6133 status
= bl_chain_cmd(state
, 0, 6, 100);
6138 status
= download_microcode(state
, state
->fw
->data
,
6144 /* disable token-ring bus through OFDM block for possible ucode upload */
6145 status
= write16(state
, SIO_OFDM_SH_OFDM_RING_ENABLE__A
,
6146 SIO_OFDM_SH_OFDM_RING_ENABLE_OFF
);
6150 /* Run SCU for a little while to initialize microcode version numbers */
6151 status
= write16(state
, SCU_COMM_EXEC__A
, SCU_COMM_EXEC_ACTIVE
);
6154 status
= drxx_open(state
);
6157 /* added for test */
6160 power_mode
= DRXK_POWER_DOWN_OFDM
;
6161 status
= ctrl_power_mode(state
, &power_mode
);
6165 /* Stamp driver version number in SCU data RAM in BCD code
6166 Done to enable field application engineers to retrieve drxdriver version
6167 via I2C from SCU RAM.
6168 Not using SCU command interface for SCU register access since no
6169 microcode may be present.
6172 (((DRXK_VERSION_MAJOR
/ 100) % 10) << 12) +
6173 (((DRXK_VERSION_MAJOR
/ 10) % 10) << 8) +
6174 ((DRXK_VERSION_MAJOR
% 10) << 4) +
6175 (DRXK_VERSION_MINOR
% 10);
6176 status
= write16(state
, SCU_RAM_DRIVER_VER_HI__A
,
6181 (((DRXK_VERSION_PATCH
/ 1000) % 10) << 12) +
6182 (((DRXK_VERSION_PATCH
/ 100) % 10) << 8) +
6183 (((DRXK_VERSION_PATCH
/ 10) % 10) << 4) +
6184 (DRXK_VERSION_PATCH
% 10);
6185 status
= write16(state
, SCU_RAM_DRIVER_VER_LO__A
,
6190 pr_info("DRXK driver version %d.%d.%d\n",
6191 DRXK_VERSION_MAJOR
, DRXK_VERSION_MINOR
,
6192 DRXK_VERSION_PATCH
);
6195 * Dirty fix of default values for ROM/PATCH microcode
6196 * Dirty because this fix makes it impossible to setup
6197 * suitable values before calling DRX_Open. This solution
6198 * requires changes to RF AGC speed to be done via the CTRL
6199 * function after calling DRX_Open
6202 /* m_dvbt_rf_agc_cfg.speed = 3; */
6204 /* Reset driver debug flags to 0 */
6205 status
= write16(state
, SCU_RAM_DRIVER_DEBUG__A
, 0);
6210 NOTE: No more full FEC resets allowed afterwards!! */
6211 status
= write16(state
, FEC_COMM_EXEC__A
, FEC_COMM_EXEC_STOP
);
6214 /* MPEGTS functions are still the same */
6215 status
= mpegts_dto_init(state
);
6218 status
= mpegts_stop(state
);
6221 status
= mpegts_configure_polarity(state
);
6224 status
= mpegts_configure_pins(state
, state
->m_enable_mpeg_output
);
6227 /* added: configure GPIO */
6228 status
= write_gpio(state
);
6232 state
->m_drxk_state
= DRXK_STOPPED
;
6234 if (state
->m_b_power_down
) {
6235 status
= power_down_device(state
);
6238 state
->m_drxk_state
= DRXK_POWERED_DOWN
;
6240 state
->m_drxk_state
= DRXK_STOPPED
;
6242 /* Initialize the supported delivery systems */
6244 if (state
->m_has_dvbc
) {
6245 state
->frontend
.ops
.delsys
[n
++] = SYS_DVBC_ANNEX_A
;
6246 state
->frontend
.ops
.delsys
[n
++] = SYS_DVBC_ANNEX_C
;
6247 strlcat(state
->frontend
.ops
.info
.name
, " DVB-C",
6248 sizeof(state
->frontend
.ops
.info
.name
));
6250 if (state
->m_has_dvbt
) {
6251 state
->frontend
.ops
.delsys
[n
++] = SYS_DVBT
;
6252 strlcat(state
->frontend
.ops
.info
.name
, " DVB-T",
6253 sizeof(state
->frontend
.ops
.info
.name
));
6255 drxk_i2c_unlock(state
);
6259 state
->m_drxk_state
= DRXK_NO_DEV
;
6260 drxk_i2c_unlock(state
);
6261 pr_err("Error %d on %s\n", status
, __func__
);
6267 static void load_firmware_cb(const struct firmware
*fw
,
6270 struct drxk_state
*state
= context
;
6272 dprintk(1, ": %s\n", fw
? "firmware loaded" : "firmware not loaded");
6274 pr_err("Could not load firmware file %s.\n",
6275 state
->microcode_name
);
6276 pr_info("Copy %s to your hotplug directory!\n",
6277 state
->microcode_name
);
6278 state
->microcode_name
= NULL
;
6281 * As firmware is now load asynchronous, it is not possible
6282 * anymore to fail at frontend attach. We might silently
6283 * return here, and hope that the driver won't crash.
6284 * We might also change all DVB callbacks to return -ENODEV
6285 * if the device is not initialized.
6286 * As the DRX-K devices have their own internal firmware,
6287 * let's just hope that it will match a firmware revision
6288 * compatible with this driver and proceed.
6296 static void drxk_release(struct dvb_frontend
*fe
)
6298 struct drxk_state
*state
= fe
->demodulator_priv
;
6301 release_firmware(state
->fw
);
6306 static int drxk_sleep(struct dvb_frontend
*fe
)
6308 struct drxk_state
*state
= fe
->demodulator_priv
;
6312 if (state
->m_drxk_state
== DRXK_NO_DEV
)
6314 if (state
->m_drxk_state
== DRXK_UNINITIALIZED
)
6321 static int drxk_gate_ctrl(struct dvb_frontend
*fe
, int enable
)
6323 struct drxk_state
*state
= fe
->demodulator_priv
;
6325 dprintk(1, ": %s\n", enable
? "enable" : "disable");
6327 if (state
->m_drxk_state
== DRXK_NO_DEV
)
6330 return ConfigureI2CBridge(state
, enable
? true : false);
6333 static int drxk_set_parameters(struct dvb_frontend
*fe
)
6335 struct dtv_frontend_properties
*p
= &fe
->dtv_property_cache
;
6336 u32 delsys
= p
->delivery_system
, old_delsys
;
6337 struct drxk_state
*state
= fe
->demodulator_priv
;
6342 if (state
->m_drxk_state
== DRXK_NO_DEV
)
6345 if (state
->m_drxk_state
== DRXK_UNINITIALIZED
)
6348 if (!fe
->ops
.tuner_ops
.get_if_frequency
) {
6349 pr_err("Error: get_if_frequency() not defined at tuner. Can't work without it!\n");
6353 if (fe
->ops
.i2c_gate_ctrl
)
6354 fe
->ops
.i2c_gate_ctrl(fe
, 1);
6355 if (fe
->ops
.tuner_ops
.set_params
)
6356 fe
->ops
.tuner_ops
.set_params(fe
);
6357 if (fe
->ops
.i2c_gate_ctrl
)
6358 fe
->ops
.i2c_gate_ctrl(fe
, 0);
6360 old_delsys
= state
->props
.delivery_system
;
6363 if (old_delsys
!= delsys
) {
6366 case SYS_DVBC_ANNEX_A
:
6367 case SYS_DVBC_ANNEX_C
:
6368 if (!state
->m_has_dvbc
)
6370 state
->m_itut_annex_c
= (delsys
== SYS_DVBC_ANNEX_C
) ?
6372 if (state
->m_itut_annex_c
)
6373 setoperation_mode(state
, OM_QAM_ITU_C
);
6375 setoperation_mode(state
, OM_QAM_ITU_A
);
6378 if (!state
->m_has_dvbt
)
6380 setoperation_mode(state
, OM_DVBT
);
6387 fe
->ops
.tuner_ops
.get_if_frequency(fe
, &IF
);
6388 start(state
, 0, IF
);
6390 /* After set_frontend, stats aren't available */
6391 p
->strength
.stat
[0].scale
= FE_SCALE_RELATIVE
;
6392 p
->cnr
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6393 p
->block_error
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6394 p
->block_count
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6395 p
->pre_bit_error
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6396 p
->pre_bit_count
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6397 p
->post_bit_error
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6398 p
->post_bit_count
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6400 /* printk(KERN_DEBUG "drxk: %s IF=%d done\n", __func__, IF); */
6405 static int get_strength(struct drxk_state
*state
, u64
*strength
)
6408 struct s_cfg_agc rf_agc
, if_agc
;
6414 /* FIXME: those are part of the tuner presets */
6415 u16 tuner_rf_gain
= 50; /* Default value on az6007 driver */
6416 u16 tuner_if_gain
= 40; /* Default value on az6007 driver */
6420 if (is_dvbt(state
)) {
6421 rf_agc
= state
->m_dvbt_rf_agc_cfg
;
6422 if_agc
= state
->m_dvbt_if_agc_cfg
;
6423 } else if (is_qam(state
)) {
6424 rf_agc
= state
->m_qam_rf_agc_cfg
;
6425 if_agc
= state
->m_qam_if_agc_cfg
;
6427 rf_agc
= state
->m_atv_rf_agc_cfg
;
6428 if_agc
= state
->m_atv_if_agc_cfg
;
6431 if (rf_agc
.ctrl_mode
== DRXK_AGC_CTRL_AUTO
) {
6432 /* SCU output_level */
6433 status
= read16(state
, SCU_RAM_AGC_RF_IACCU_HI__A
, &scu_lvl
);
6438 status
= read16(state
, SCU_RAM_AGC_RF_IACCU_HI_CO__A
, &scu_coc
);
6442 if (((u32
) scu_lvl
+ (u32
) scu_coc
) < 0xffff)
6443 rf_agc
.output_level
= scu_lvl
+ scu_coc
;
6445 rf_agc
.output_level
= 0xffff;
6447 /* Take RF gain into account */
6448 total_gain
+= tuner_rf_gain
;
6450 /* clip output value */
6451 if (rf_agc
.output_level
< rf_agc
.min_output_level
)
6452 rf_agc
.output_level
= rf_agc
.min_output_level
;
6453 if (rf_agc
.output_level
> rf_agc
.max_output_level
)
6454 rf_agc
.output_level
= rf_agc
.max_output_level
;
6456 agc_range
= (u32
) (rf_agc
.max_output_level
- rf_agc
.min_output_level
);
6457 if (agc_range
> 0) {
6459 ((u32
)(tuner_rf_gain
)) *
6460 ((u32
)(rf_agc
.output_level
- rf_agc
.min_output_level
))
6465 if (if_agc
.ctrl_mode
== DRXK_AGC_CTRL_AUTO
) {
6466 status
= read16(state
, SCU_RAM_AGC_IF_IACCU_HI__A
,
6467 &if_agc
.output_level
);
6471 status
= read16(state
, SCU_RAM_AGC_INGAIN_TGT_MIN__A
,
6476 /* Take IF gain into account */
6477 total_gain
+= (u32
) tuner_if_gain
;
6479 /* clip output value */
6480 if (if_agc
.output_level
< if_agc
.min_output_level
)
6481 if_agc
.output_level
= if_agc
.min_output_level
;
6482 if (if_agc
.output_level
> if_agc
.max_output_level
)
6483 if_agc
.output_level
= if_agc
.max_output_level
;
6485 agc_range
= (u32
)(if_agc
.max_output_level
- if_agc
.min_output_level
);
6486 if (agc_range
> 0) {
6488 ((u32
)(tuner_if_gain
)) *
6489 ((u32
)(if_agc
.output_level
- if_agc
.min_output_level
))
6495 * Convert to 0..65535 scale.
6496 * If it can't be measured (AGC is disabled), just show 100%.
6499 *strength
= (65535UL * atten
/ total_gain
/ 100);
6506 static int drxk_get_stats(struct dvb_frontend
*fe
)
6508 struct dtv_frontend_properties
*c
= &fe
->dtv_property_cache
;
6509 struct drxk_state
*state
= fe
->demodulator_priv
;
6514 u32 post_bit_err_count
;
6515 u32 post_bit_error_scale
;
6516 u32 pre_bit_err_count
;
6519 u32 pkt_error_count
;
6522 if (state
->m_drxk_state
== DRXK_NO_DEV
)
6524 if (state
->m_drxk_state
== DRXK_UNINITIALIZED
)
6528 state
->fe_status
= 0;
6529 get_lock_status(state
, &stat
);
6530 if (stat
== MPEG_LOCK
)
6531 state
->fe_status
|= 0x1f;
6532 if (stat
== FEC_LOCK
)
6533 state
->fe_status
|= 0x0f;
6534 if (stat
== DEMOD_LOCK
)
6535 state
->fe_status
|= 0x07;
6538 * Estimate signal strength from AGC
6540 get_strength(state
, &c
->strength
.stat
[0].uvalue
);
6541 c
->strength
.stat
[0].scale
= FE_SCALE_RELATIVE
;
6544 if (stat
>= DEMOD_LOCK
) {
6545 get_signal_to_noise(state
, &cnr
);
6546 c
->cnr
.stat
[0].svalue
= cnr
* 100;
6547 c
->cnr
.stat
[0].scale
= FE_SCALE_DECIBEL
;
6549 c
->cnr
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6552 if (stat
< FEC_LOCK
) {
6553 c
->block_error
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6554 c
->block_count
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6555 c
->pre_bit_error
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6556 c
->pre_bit_count
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6557 c
->post_bit_error
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6558 c
->post_bit_count
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6564 /* BER measurement is valid if at least FEC lock is achieved */
6567 * OFDM_EC_VD_REQ_SMB_CNT__A and/or OFDM_EC_VD_REQ_BIT_CNT can be
6568 * written to set nr of symbols or bits over which to measure
6569 * EC_VD_REG_ERR_BIT_CNT__A . See CtrlSetCfg().
6572 /* Read registers for post/preViterbi BER calculation */
6573 status
= read16(state
, OFDM_EC_VD_ERR_BIT_CNT__A
, ®16
);
6576 pre_bit_err_count
= reg16
;
6578 status
= read16(state
, OFDM_EC_VD_IN_BIT_CNT__A
, ®16
);
6581 pre_bit_count
= reg16
;
6583 /* Number of bit-errors */
6584 status
= read16(state
, FEC_RS_NR_BIT_ERRORS__A
, ®16
);
6587 post_bit_err_count
= reg16
;
6589 status
= read16(state
, FEC_RS_MEASUREMENT_PRESCALE__A
, ®16
);
6592 post_bit_error_scale
= reg16
;
6594 status
= read16(state
, FEC_RS_MEASUREMENT_PERIOD__A
, ®16
);
6599 status
= read16(state
, SCU_RAM_FEC_ACCUM_PKT_FAILURES__A
, ®16
);
6602 pkt_error_count
= reg16
;
6603 write16(state
, SCU_RAM_FEC_ACCUM_PKT_FAILURES__A
, 0);
6605 post_bit_err_count
*= post_bit_error_scale
;
6607 post_bit_count
= pkt_count
* 204 * 8;
6609 /* Store the results */
6610 c
->block_error
.stat
[0].scale
= FE_SCALE_COUNTER
;
6611 c
->block_error
.stat
[0].uvalue
+= pkt_error_count
;
6612 c
->block_count
.stat
[0].scale
= FE_SCALE_COUNTER
;
6613 c
->block_count
.stat
[0].uvalue
+= pkt_count
;
6615 c
->pre_bit_error
.stat
[0].scale
= FE_SCALE_COUNTER
;
6616 c
->pre_bit_error
.stat
[0].uvalue
+= pre_bit_err_count
;
6617 c
->pre_bit_count
.stat
[0].scale
= FE_SCALE_COUNTER
;
6618 c
->pre_bit_count
.stat
[0].uvalue
+= pre_bit_count
;
6620 c
->post_bit_error
.stat
[0].scale
= FE_SCALE_COUNTER
;
6621 c
->post_bit_error
.stat
[0].uvalue
+= post_bit_err_count
;
6622 c
->post_bit_count
.stat
[0].scale
= FE_SCALE_COUNTER
;
6623 c
->post_bit_count
.stat
[0].uvalue
+= post_bit_count
;
6630 static int drxk_read_status(struct dvb_frontend
*fe
, enum fe_status
*status
)
6632 struct drxk_state
*state
= fe
->demodulator_priv
;
6637 rc
= drxk_get_stats(fe
);
6641 *status
= state
->fe_status
;
6646 static int drxk_read_signal_strength(struct dvb_frontend
*fe
,
6649 struct drxk_state
*state
= fe
->demodulator_priv
;
6650 struct dtv_frontend_properties
*c
= &fe
->dtv_property_cache
;
6654 if (state
->m_drxk_state
== DRXK_NO_DEV
)
6656 if (state
->m_drxk_state
== DRXK_UNINITIALIZED
)
6659 *strength
= c
->strength
.stat
[0].uvalue
;
6663 static int drxk_read_snr(struct dvb_frontend
*fe
, u16
*snr
)
6665 struct drxk_state
*state
= fe
->demodulator_priv
;
6670 if (state
->m_drxk_state
== DRXK_NO_DEV
)
6672 if (state
->m_drxk_state
== DRXK_UNINITIALIZED
)
6675 get_signal_to_noise(state
, &snr2
);
6677 /* No negative SNR, clip to zero */
6680 *snr
= snr2
& 0xffff;
6684 static int drxk_read_ucblocks(struct dvb_frontend
*fe
, u32
*ucblocks
)
6686 struct drxk_state
*state
= fe
->demodulator_priv
;
6691 if (state
->m_drxk_state
== DRXK_NO_DEV
)
6693 if (state
->m_drxk_state
== DRXK_UNINITIALIZED
)
6696 dvbtqam_get_acc_pkt_err(state
, &err
);
6697 *ucblocks
= (u32
) err
;
6701 static int drxk_get_tune_settings(struct dvb_frontend
*fe
,
6702 struct dvb_frontend_tune_settings
*sets
)
6704 struct drxk_state
*state
= fe
->demodulator_priv
;
6705 struct dtv_frontend_properties
*p
= &fe
->dtv_property_cache
;
6709 if (state
->m_drxk_state
== DRXK_NO_DEV
)
6711 if (state
->m_drxk_state
== DRXK_UNINITIALIZED
)
6714 switch (p
->delivery_system
) {
6715 case SYS_DVBC_ANNEX_A
:
6716 case SYS_DVBC_ANNEX_C
:
6718 sets
->min_delay_ms
= 3000;
6719 sets
->max_drift
= 0;
6720 sets
->step_size
= 0;
6727 static const struct dvb_frontend_ops drxk_ops
= {
6728 /* .delsys will be filled dynamically */
6731 .frequency_min_hz
= 47 * MHz
,
6732 .frequency_max_hz
= 865 * MHz
,
6734 .symbol_rate_min
= 870000,
6735 .symbol_rate_max
= 11700000,
6737 .frequency_stepsize_hz
= 166667,
6739 .caps
= FE_CAN_QAM_16
| FE_CAN_QAM_32
| FE_CAN_QAM_64
|
6740 FE_CAN_QAM_128
| FE_CAN_QAM_256
| FE_CAN_FEC_AUTO
|
6741 FE_CAN_FEC_1_2
| FE_CAN_FEC_2_3
| FE_CAN_FEC_3_4
|
6742 FE_CAN_FEC_5_6
| FE_CAN_FEC_7_8
| FE_CAN_MUTE_TS
|
6743 FE_CAN_TRANSMISSION_MODE_AUTO
| FE_CAN_RECOVER
|
6744 FE_CAN_GUARD_INTERVAL_AUTO
| FE_CAN_HIERARCHY_AUTO
6747 .release
= drxk_release
,
6748 .sleep
= drxk_sleep
,
6749 .i2c_gate_ctrl
= drxk_gate_ctrl
,
6751 .set_frontend
= drxk_set_parameters
,
6752 .get_tune_settings
= drxk_get_tune_settings
,
6754 .read_status
= drxk_read_status
,
6755 .read_signal_strength
= drxk_read_signal_strength
,
6756 .read_snr
= drxk_read_snr
,
6757 .read_ucblocks
= drxk_read_ucblocks
,
6760 struct dvb_frontend
*drxk_attach(const struct drxk_config
*config
,
6761 struct i2c_adapter
*i2c
)
6763 struct dtv_frontend_properties
*p
;
6764 struct drxk_state
*state
= NULL
;
6765 u8 adr
= config
->adr
;
6769 state
= kzalloc(sizeof(struct drxk_state
), GFP_KERNEL
);
6774 state
->demod_address
= adr
;
6775 state
->single_master
= config
->single_master
;
6776 state
->microcode_name
= config
->microcode_name
;
6777 state
->qam_demod_parameter_count
= config
->qam_demod_parameter_count
;
6778 state
->no_i2c_bridge
= config
->no_i2c_bridge
;
6779 state
->antenna_gpio
= config
->antenna_gpio
;
6780 state
->antenna_dvbt
= config
->antenna_dvbt
;
6781 state
->m_chunk_size
= config
->chunk_size
;
6782 state
->enable_merr_cfg
= config
->enable_merr_cfg
;
6784 if (config
->dynamic_clk
) {
6785 state
->m_dvbt_static_clk
= false;
6786 state
->m_dvbc_static_clk
= false;
6788 state
->m_dvbt_static_clk
= true;
6789 state
->m_dvbc_static_clk
= true;
6793 if (config
->mpeg_out_clk_strength
)
6794 state
->m_ts_clockk_strength
= config
->mpeg_out_clk_strength
& 0x07;
6796 state
->m_ts_clockk_strength
= 0x06;
6798 if (config
->parallel_ts
)
6799 state
->m_enable_parallel
= true;
6801 state
->m_enable_parallel
= false;
6803 /* NOTE: as more UIO bits will be used, add them to the mask */
6804 state
->uio_mask
= config
->antenna_gpio
;
6806 /* Default gpio to DVB-C */
6807 if (!state
->antenna_dvbt
&& state
->antenna_gpio
)
6808 state
->m_gpio
|= state
->antenna_gpio
;
6810 state
->m_gpio
&= ~state
->antenna_gpio
;
6812 mutex_init(&state
->mutex
);
6814 memcpy(&state
->frontend
.ops
, &drxk_ops
, sizeof(drxk_ops
));
6815 state
->frontend
.demodulator_priv
= state
;
6819 /* Load firmware and initialize DRX-K */
6820 if (state
->microcode_name
) {
6821 const struct firmware
*fw
= NULL
;
6823 status
= request_firmware(&fw
, state
->microcode_name
,
6824 state
->i2c
->dev
.parent
);
6827 load_firmware_cb(fw
, state
);
6828 } else if (init_drxk(state
) < 0)
6832 /* Initialize stats */
6833 p
= &state
->frontend
.dtv_property_cache
;
6834 p
->strength
.len
= 1;
6836 p
->block_error
.len
= 1;
6837 p
->block_count
.len
= 1;
6838 p
->pre_bit_error
.len
= 1;
6839 p
->pre_bit_count
.len
= 1;
6840 p
->post_bit_error
.len
= 1;
6841 p
->post_bit_count
.len
= 1;
6843 p
->strength
.stat
[0].scale
= FE_SCALE_RELATIVE
;
6844 p
->cnr
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6845 p
->block_error
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6846 p
->block_count
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6847 p
->pre_bit_error
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6848 p
->pre_bit_count
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6849 p
->post_bit_error
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6850 p
->post_bit_count
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6852 pr_info("frontend initialized.\n");
6853 return &state
->frontend
;
6856 pr_err("not found\n");
6860 EXPORT_SYMBOL(drxk_attach
);
6862 MODULE_DESCRIPTION("DRX-K driver");
6863 MODULE_AUTHOR("Ralph Metzler");
6864 MODULE_LICENSE("GPL");