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); \
158 static inline u32
Frac28a(u32 a
, u32 c
)
164 R0
= (a
% c
) << 4; /* 32-28 == 4 shifts possible at max */
166 * integer part, only the 4 least significant
167 * bits will be visible in the result
170 /* division using radix 16, 7 nibbles in the result */
171 for (i
= 0; i
< 7; i
++) {
172 Q1
= (Q1
<< 4) | (R0
/ c
);
182 static inline u32
log10times100(u32 value
)
184 return (100L * intlog10(value
)) >> 24;
187 /***************************************************************************/
188 /* I2C **********************************************************************/
189 /***************************************************************************/
191 static int drxk_i2c_lock(struct drxk_state
*state
)
193 i2c_lock_bus(state
->i2c
, I2C_LOCK_SEGMENT
);
194 state
->drxk_i2c_exclusive_lock
= true;
199 static void drxk_i2c_unlock(struct drxk_state
*state
)
201 if (!state
->drxk_i2c_exclusive_lock
)
204 i2c_unlock_bus(state
->i2c
, I2C_LOCK_SEGMENT
);
205 state
->drxk_i2c_exclusive_lock
= false;
208 static int drxk_i2c_transfer(struct drxk_state
*state
, struct i2c_msg
*msgs
,
211 if (state
->drxk_i2c_exclusive_lock
)
212 return __i2c_transfer(state
->i2c
, msgs
, len
);
214 return i2c_transfer(state
->i2c
, msgs
, len
);
217 static int i2c_read1(struct drxk_state
*state
, u8 adr
, u8
*val
)
219 struct i2c_msg msgs
[1] = { {.addr
= adr
, .flags
= I2C_M_RD
,
220 .buf
= val
, .len
= 1}
223 return drxk_i2c_transfer(state
, msgs
, 1);
226 static int i2c_write(struct drxk_state
*state
, u8 adr
, u8
*data
, int len
)
229 struct i2c_msg msg
= {
230 .addr
= adr
, .flags
= 0, .buf
= data
, .len
= len
};
235 for (i
= 0; i
< len
; i
++)
236 pr_cont(" %02x", data
[i
]);
239 status
= drxk_i2c_transfer(state
, &msg
, 1);
240 if (status
>= 0 && status
!= 1)
244 pr_err("i2c write error at addr 0x%02x\n", adr
);
249 static int i2c_read(struct drxk_state
*state
,
250 u8 adr
, u8
*msg
, int len
, u8
*answ
, int alen
)
253 struct i2c_msg msgs
[2] = {
254 {.addr
= adr
, .flags
= 0,
255 .buf
= msg
, .len
= len
},
256 {.addr
= adr
, .flags
= I2C_M_RD
,
257 .buf
= answ
, .len
= alen
}
260 status
= drxk_i2c_transfer(state
, msgs
, 2);
263 pr_cont(": ERROR!\n");
267 pr_err("i2c read error at addr 0x%02x\n", adr
);
272 dprintk(2, ": read from");
273 for (i
= 0; i
< len
; i
++)
274 pr_cont(" %02x", msg
[i
]);
275 pr_cont(", value = ");
276 for (i
= 0; i
< alen
; i
++)
277 pr_cont(" %02x", answ
[i
]);
283 static int read16_flags(struct drxk_state
*state
, u32 reg
, u16
*data
, u8 flags
)
286 u8 adr
= state
->demod_address
, mm1
[4], mm2
[2], len
;
288 if (state
->single_master
)
291 if (DRXDAP_FASI_LONG_FORMAT(reg
) || (flags
!= 0)) {
292 mm1
[0] = (((reg
<< 1) & 0xFF) | 0x01);
293 mm1
[1] = ((reg
>> 16) & 0xFF);
294 mm1
[2] = ((reg
>> 24) & 0xFF) | flags
;
295 mm1
[3] = ((reg
>> 7) & 0xFF);
298 mm1
[0] = ((reg
<< 1) & 0xFF);
299 mm1
[1] = (((reg
>> 16) & 0x0F) | ((reg
>> 18) & 0xF0));
302 dprintk(2, "(0x%08x, 0x%02x)\n", reg
, flags
);
303 status
= i2c_read(state
, adr
, mm1
, len
, mm2
, 2);
307 *data
= mm2
[0] | (mm2
[1] << 8);
312 static int read16(struct drxk_state
*state
, u32 reg
, u16
*data
)
314 return read16_flags(state
, reg
, data
, 0);
317 static int read32_flags(struct drxk_state
*state
, u32 reg
, u32
*data
, u8 flags
)
320 u8 adr
= state
->demod_address
, mm1
[4], mm2
[4], len
;
322 if (state
->single_master
)
325 if (DRXDAP_FASI_LONG_FORMAT(reg
) || (flags
!= 0)) {
326 mm1
[0] = (((reg
<< 1) & 0xFF) | 0x01);
327 mm1
[1] = ((reg
>> 16) & 0xFF);
328 mm1
[2] = ((reg
>> 24) & 0xFF) | flags
;
329 mm1
[3] = ((reg
>> 7) & 0xFF);
332 mm1
[0] = ((reg
<< 1) & 0xFF);
333 mm1
[1] = (((reg
>> 16) & 0x0F) | ((reg
>> 18) & 0xF0));
336 dprintk(2, "(0x%08x, 0x%02x)\n", reg
, flags
);
337 status
= i2c_read(state
, adr
, mm1
, len
, mm2
, 4);
341 *data
= mm2
[0] | (mm2
[1] << 8) |
342 (mm2
[2] << 16) | (mm2
[3] << 24);
347 static int read32(struct drxk_state
*state
, u32 reg
, u32
*data
)
349 return read32_flags(state
, reg
, data
, 0);
352 static int write16_flags(struct drxk_state
*state
, u32 reg
, u16 data
, u8 flags
)
354 u8 adr
= state
->demod_address
, mm
[6], len
;
356 if (state
->single_master
)
358 if (DRXDAP_FASI_LONG_FORMAT(reg
) || (flags
!= 0)) {
359 mm
[0] = (((reg
<< 1) & 0xFF) | 0x01);
360 mm
[1] = ((reg
>> 16) & 0xFF);
361 mm
[2] = ((reg
>> 24) & 0xFF) | flags
;
362 mm
[3] = ((reg
>> 7) & 0xFF);
365 mm
[0] = ((reg
<< 1) & 0xFF);
366 mm
[1] = (((reg
>> 16) & 0x0F) | ((reg
>> 18) & 0xF0));
369 mm
[len
] = data
& 0xff;
370 mm
[len
+ 1] = (data
>> 8) & 0xff;
372 dprintk(2, "(0x%08x, 0x%04x, 0x%02x)\n", reg
, data
, flags
);
373 return i2c_write(state
, adr
, mm
, len
+ 2);
376 static int write16(struct drxk_state
*state
, u32 reg
, u16 data
)
378 return write16_flags(state
, reg
, data
, 0);
381 static int write32_flags(struct drxk_state
*state
, u32 reg
, u32 data
, u8 flags
)
383 u8 adr
= state
->demod_address
, mm
[8], len
;
385 if (state
->single_master
)
387 if (DRXDAP_FASI_LONG_FORMAT(reg
) || (flags
!= 0)) {
388 mm
[0] = (((reg
<< 1) & 0xFF) | 0x01);
389 mm
[1] = ((reg
>> 16) & 0xFF);
390 mm
[2] = ((reg
>> 24) & 0xFF) | flags
;
391 mm
[3] = ((reg
>> 7) & 0xFF);
394 mm
[0] = ((reg
<< 1) & 0xFF);
395 mm
[1] = (((reg
>> 16) & 0x0F) | ((reg
>> 18) & 0xF0));
398 mm
[len
] = data
& 0xff;
399 mm
[len
+ 1] = (data
>> 8) & 0xff;
400 mm
[len
+ 2] = (data
>> 16) & 0xff;
401 mm
[len
+ 3] = (data
>> 24) & 0xff;
402 dprintk(2, "(0x%08x, 0x%08x, 0x%02x)\n", reg
, data
, flags
);
404 return i2c_write(state
, adr
, mm
, len
+ 4);
407 static int write32(struct drxk_state
*state
, u32 reg
, u32 data
)
409 return write32_flags(state
, reg
, data
, 0);
412 static int write_block(struct drxk_state
*state
, u32 address
,
413 const int block_size
, const u8 p_block
[])
415 int status
= 0, blk_size
= block_size
;
418 if (state
->single_master
)
421 while (blk_size
> 0) {
422 int chunk
= blk_size
> state
->m_chunk_size
?
423 state
->m_chunk_size
: blk_size
;
424 u8
*adr_buf
= &state
->chunk
[0];
427 if (DRXDAP_FASI_LONG_FORMAT(address
) || (flags
!= 0)) {
428 adr_buf
[0] = (((address
<< 1) & 0xFF) | 0x01);
429 adr_buf
[1] = ((address
>> 16) & 0xFF);
430 adr_buf
[2] = ((address
>> 24) & 0xFF);
431 adr_buf
[3] = ((address
>> 7) & 0xFF);
434 if (chunk
== state
->m_chunk_size
)
437 adr_buf
[0] = ((address
<< 1) & 0xFF);
438 adr_buf
[1] = (((address
>> 16) & 0x0F) |
439 ((address
>> 18) & 0xF0));
442 memcpy(&state
->chunk
[adr_length
], p_block
, chunk
);
443 dprintk(2, "(0x%08x, 0x%02x)\n", address
, flags
);
447 for (i
= 0; i
< chunk
; i
++)
448 pr_cont(" %02x", p_block
[i
]);
451 status
= i2c_write(state
, state
->demod_address
,
452 &state
->chunk
[0], chunk
+ adr_length
);
454 pr_err("%s: i2c write error at addr 0x%02x\n",
459 address
+= (chunk
>> 1);
465 #ifndef DRXK_MAX_RETRIES_POWERUP
466 #define DRXK_MAX_RETRIES_POWERUP 20
469 static int power_up_device(struct drxk_state
*state
)
477 status
= i2c_read1(state
, state
->demod_address
, &data
);
481 status
= i2c_write(state
, state
->demod_address
,
483 usleep_range(10000, 11000);
487 status
= i2c_read1(state
, state
->demod_address
,
489 } while (status
< 0 &&
490 (retry_count
< DRXK_MAX_RETRIES_POWERUP
));
491 if (status
< 0 && retry_count
>= DRXK_MAX_RETRIES_POWERUP
)
495 /* Make sure all clk domains are active */
496 status
= write16(state
, SIO_CC_PWD_MODE__A
, SIO_CC_PWD_MODE_LEVEL_NONE
);
499 status
= write16(state
, SIO_CC_UPDATE__A
, SIO_CC_UPDATE_KEY
);
502 /* Enable pll lock tests */
503 status
= write16(state
, SIO_CC_PLL_LOCK__A
, 1);
507 state
->m_current_power_mode
= DRX_POWER_UP
;
511 pr_err("Error %d on %s\n", status
, __func__
);
517 static int init_state(struct drxk_state
*state
)
520 * FIXME: most (all?) of the values below should be moved into
521 * struct drxk_config, as they are probably board-specific
523 u32 ul_vsb_if_agc_mode
= DRXK_AGC_CTRL_AUTO
;
524 u32 ul_vsb_if_agc_output_level
= 0;
525 u32 ul_vsb_if_agc_min_level
= 0;
526 u32 ul_vsb_if_agc_max_level
= 0x7FFF;
527 u32 ul_vsb_if_agc_speed
= 3;
529 u32 ul_vsb_rf_agc_mode
= DRXK_AGC_CTRL_AUTO
;
530 u32 ul_vsb_rf_agc_output_level
= 0;
531 u32 ul_vsb_rf_agc_min_level
= 0;
532 u32 ul_vsb_rf_agc_max_level
= 0x7FFF;
533 u32 ul_vsb_rf_agc_speed
= 3;
534 u32 ul_vsb_rf_agc_top
= 9500;
535 u32 ul_vsb_rf_agc_cut_off_current
= 4000;
537 u32 ul_atv_if_agc_mode
= DRXK_AGC_CTRL_AUTO
;
538 u32 ul_atv_if_agc_output_level
= 0;
539 u32 ul_atv_if_agc_min_level
= 0;
540 u32 ul_atv_if_agc_max_level
= 0;
541 u32 ul_atv_if_agc_speed
= 3;
543 u32 ul_atv_rf_agc_mode
= DRXK_AGC_CTRL_OFF
;
544 u32 ul_atv_rf_agc_output_level
= 0;
545 u32 ul_atv_rf_agc_min_level
= 0;
546 u32 ul_atv_rf_agc_max_level
= 0;
547 u32 ul_atv_rf_agc_top
= 9500;
548 u32 ul_atv_rf_agc_cut_off_current
= 4000;
549 u32 ul_atv_rf_agc_speed
= 3;
551 u32 ulQual83
= DEFAULT_MER_83
;
552 u32 ulQual93
= DEFAULT_MER_93
;
554 u32 ul_mpeg_lock_time_out
= DEFAULT_DRXK_MPEG_LOCK_TIMEOUT
;
555 u32 ul_demod_lock_time_out
= DEFAULT_DRXK_DEMOD_LOCK_TIMEOUT
;
557 /* io_pad_cfg register (8 bit reg.) MSB bit is 1 (default value) */
558 /* io_pad_cfg_mode output mode is drive always */
559 /* io_pad_cfg_drive is set to power 2 (23 mA) */
560 u32 ul_gpio_cfg
= 0x0113;
561 u32 ul_invert_ts_clock
= 0;
562 u32 ul_ts_data_strength
= DRXK_MPEG_SERIAL_OUTPUT_PIN_DRIVE_STRENGTH
;
563 u32 ul_dvbt_bitrate
= 50000000;
564 u32 ul_dvbc_bitrate
= DRXK_QAM_SYMBOLRATE_MAX
* 8;
566 u32 ul_insert_rs_byte
= 0;
568 u32 ul_rf_mirror
= 1;
569 u32 ul_power_down
= 0;
573 state
->m_has_lna
= false;
574 state
->m_has_dvbt
= false;
575 state
->m_has_dvbc
= false;
576 state
->m_has_atv
= false;
577 state
->m_has_oob
= false;
578 state
->m_has_audio
= false;
580 if (!state
->m_chunk_size
)
581 state
->m_chunk_size
= 124;
583 state
->m_osc_clock_freq
= 0;
584 state
->m_smart_ant_inverted
= false;
585 state
->m_b_p_down_open_bridge
= false;
587 /* real system clock frequency in kHz */
588 state
->m_sys_clock_freq
= 151875;
589 /* Timing div, 250ns/Psys */
590 /* Timing div, = (delay (nano seconds) * sysclk (kHz))/ 1000 */
591 state
->m_hi_cfg_timing_div
= ((state
->m_sys_clock_freq
/ 1000) *
592 HI_I2C_DELAY
) / 1000;
594 if (state
->m_hi_cfg_timing_div
> SIO_HI_RA_RAM_PAR_2_CFG_DIV__M
)
595 state
->m_hi_cfg_timing_div
= SIO_HI_RA_RAM_PAR_2_CFG_DIV__M
;
596 state
->m_hi_cfg_wake_up_key
= (state
->demod_address
<< 1);
597 /* port/bridge/power down ctrl */
598 state
->m_hi_cfg_ctrl
= SIO_HI_RA_RAM_PAR_5_CFG_SLV0_SLAVE
;
600 state
->m_b_power_down
= (ul_power_down
!= 0);
602 state
->m_drxk_a3_patch_code
= false;
604 /* Init AGC and PGA parameters */
606 state
->m_vsb_if_agc_cfg
.ctrl_mode
= ul_vsb_if_agc_mode
;
607 state
->m_vsb_if_agc_cfg
.output_level
= ul_vsb_if_agc_output_level
;
608 state
->m_vsb_if_agc_cfg
.min_output_level
= ul_vsb_if_agc_min_level
;
609 state
->m_vsb_if_agc_cfg
.max_output_level
= ul_vsb_if_agc_max_level
;
610 state
->m_vsb_if_agc_cfg
.speed
= ul_vsb_if_agc_speed
;
611 state
->m_vsb_pga_cfg
= 140;
614 state
->m_vsb_rf_agc_cfg
.ctrl_mode
= ul_vsb_rf_agc_mode
;
615 state
->m_vsb_rf_agc_cfg
.output_level
= ul_vsb_rf_agc_output_level
;
616 state
->m_vsb_rf_agc_cfg
.min_output_level
= ul_vsb_rf_agc_min_level
;
617 state
->m_vsb_rf_agc_cfg
.max_output_level
= ul_vsb_rf_agc_max_level
;
618 state
->m_vsb_rf_agc_cfg
.speed
= ul_vsb_rf_agc_speed
;
619 state
->m_vsb_rf_agc_cfg
.top
= ul_vsb_rf_agc_top
;
620 state
->m_vsb_rf_agc_cfg
.cut_off_current
= ul_vsb_rf_agc_cut_off_current
;
621 state
->m_vsb_pre_saw_cfg
.reference
= 0x07;
622 state
->m_vsb_pre_saw_cfg
.use_pre_saw
= true;
624 state
->m_Quality83percent
= DEFAULT_MER_83
;
625 state
->m_Quality93percent
= DEFAULT_MER_93
;
626 if (ulQual93
<= 500 && ulQual83
< ulQual93
) {
627 state
->m_Quality83percent
= ulQual83
;
628 state
->m_Quality93percent
= ulQual93
;
632 state
->m_atv_if_agc_cfg
.ctrl_mode
= ul_atv_if_agc_mode
;
633 state
->m_atv_if_agc_cfg
.output_level
= ul_atv_if_agc_output_level
;
634 state
->m_atv_if_agc_cfg
.min_output_level
= ul_atv_if_agc_min_level
;
635 state
->m_atv_if_agc_cfg
.max_output_level
= ul_atv_if_agc_max_level
;
636 state
->m_atv_if_agc_cfg
.speed
= ul_atv_if_agc_speed
;
639 state
->m_atv_rf_agc_cfg
.ctrl_mode
= ul_atv_rf_agc_mode
;
640 state
->m_atv_rf_agc_cfg
.output_level
= ul_atv_rf_agc_output_level
;
641 state
->m_atv_rf_agc_cfg
.min_output_level
= ul_atv_rf_agc_min_level
;
642 state
->m_atv_rf_agc_cfg
.max_output_level
= ul_atv_rf_agc_max_level
;
643 state
->m_atv_rf_agc_cfg
.speed
= ul_atv_rf_agc_speed
;
644 state
->m_atv_rf_agc_cfg
.top
= ul_atv_rf_agc_top
;
645 state
->m_atv_rf_agc_cfg
.cut_off_current
= ul_atv_rf_agc_cut_off_current
;
646 state
->m_atv_pre_saw_cfg
.reference
= 0x04;
647 state
->m_atv_pre_saw_cfg
.use_pre_saw
= true;
651 state
->m_dvbt_rf_agc_cfg
.ctrl_mode
= DRXK_AGC_CTRL_OFF
;
652 state
->m_dvbt_rf_agc_cfg
.output_level
= 0;
653 state
->m_dvbt_rf_agc_cfg
.min_output_level
= 0;
654 state
->m_dvbt_rf_agc_cfg
.max_output_level
= 0xFFFF;
655 state
->m_dvbt_rf_agc_cfg
.top
= 0x2100;
656 state
->m_dvbt_rf_agc_cfg
.cut_off_current
= 4000;
657 state
->m_dvbt_rf_agc_cfg
.speed
= 1;
661 state
->m_dvbt_if_agc_cfg
.ctrl_mode
= DRXK_AGC_CTRL_AUTO
;
662 state
->m_dvbt_if_agc_cfg
.output_level
= 0;
663 state
->m_dvbt_if_agc_cfg
.min_output_level
= 0;
664 state
->m_dvbt_if_agc_cfg
.max_output_level
= 9000;
665 state
->m_dvbt_if_agc_cfg
.top
= 13424;
666 state
->m_dvbt_if_agc_cfg
.cut_off_current
= 0;
667 state
->m_dvbt_if_agc_cfg
.speed
= 3;
668 state
->m_dvbt_if_agc_cfg
.fast_clip_ctrl_delay
= 30;
669 state
->m_dvbt_if_agc_cfg
.ingain_tgt_max
= 30000;
670 /* state->m_dvbtPgaCfg = 140; */
672 state
->m_dvbt_pre_saw_cfg
.reference
= 4;
673 state
->m_dvbt_pre_saw_cfg
.use_pre_saw
= false;
676 state
->m_qam_rf_agc_cfg
.ctrl_mode
= DRXK_AGC_CTRL_OFF
;
677 state
->m_qam_rf_agc_cfg
.output_level
= 0;
678 state
->m_qam_rf_agc_cfg
.min_output_level
= 6023;
679 state
->m_qam_rf_agc_cfg
.max_output_level
= 27000;
680 state
->m_qam_rf_agc_cfg
.top
= 0x2380;
681 state
->m_qam_rf_agc_cfg
.cut_off_current
= 4000;
682 state
->m_qam_rf_agc_cfg
.speed
= 3;
685 state
->m_qam_if_agc_cfg
.ctrl_mode
= DRXK_AGC_CTRL_AUTO
;
686 state
->m_qam_if_agc_cfg
.output_level
= 0;
687 state
->m_qam_if_agc_cfg
.min_output_level
= 0;
688 state
->m_qam_if_agc_cfg
.max_output_level
= 9000;
689 state
->m_qam_if_agc_cfg
.top
= 0x0511;
690 state
->m_qam_if_agc_cfg
.cut_off_current
= 0;
691 state
->m_qam_if_agc_cfg
.speed
= 3;
692 state
->m_qam_if_agc_cfg
.ingain_tgt_max
= 5119;
693 state
->m_qam_if_agc_cfg
.fast_clip_ctrl_delay
= 50;
695 state
->m_qam_pga_cfg
= 140;
696 state
->m_qam_pre_saw_cfg
.reference
= 4;
697 state
->m_qam_pre_saw_cfg
.use_pre_saw
= false;
699 state
->m_operation_mode
= OM_NONE
;
700 state
->m_drxk_state
= DRXK_UNINITIALIZED
;
702 /* MPEG output configuration */
703 state
->m_enable_mpeg_output
= true; /* If TRUE; enable MPEG output */
704 state
->m_insert_rs_byte
= false; /* If TRUE; insert RS byte */
705 state
->m_invert_data
= false; /* If TRUE; invert DATA signals */
706 state
->m_invert_err
= false; /* If TRUE; invert ERR signal */
707 state
->m_invert_str
= false; /* If TRUE; invert STR signals */
708 state
->m_invert_val
= false; /* If TRUE; invert VAL signals */
709 state
->m_invert_clk
= (ul_invert_ts_clock
!= 0); /* If TRUE; invert CLK signals */
711 /* If TRUE; static MPEG clockrate will be used;
712 otherwise clockrate will adapt to the bitrate of the TS */
714 state
->m_dvbt_bitrate
= ul_dvbt_bitrate
;
715 state
->m_dvbc_bitrate
= ul_dvbc_bitrate
;
717 state
->m_ts_data_strength
= (ul_ts_data_strength
& 0x07);
719 /* Maximum bitrate in b/s in case static clockrate is selected */
720 state
->m_mpeg_ts_static_bitrate
= 19392658;
721 state
->m_disable_te_ihandling
= false;
723 if (ul_insert_rs_byte
)
724 state
->m_insert_rs_byte
= true;
726 state
->m_mpeg_lock_time_out
= DEFAULT_DRXK_MPEG_LOCK_TIMEOUT
;
727 if (ul_mpeg_lock_time_out
< 10000)
728 state
->m_mpeg_lock_time_out
= ul_mpeg_lock_time_out
;
729 state
->m_demod_lock_time_out
= DEFAULT_DRXK_DEMOD_LOCK_TIMEOUT
;
730 if (ul_demod_lock_time_out
< 10000)
731 state
->m_demod_lock_time_out
= ul_demod_lock_time_out
;
734 state
->m_constellation
= DRX_CONSTELLATION_AUTO
;
735 state
->m_qam_interleave_mode
= DRXK_QAM_I12_J17
;
736 state
->m_fec_rs_plen
= 204 * 8; /* fecRsPlen annex A */
737 state
->m_fec_rs_prescale
= 1;
739 state
->m_sqi_speed
= DRXK_DVBT_SQI_SPEED_MEDIUM
;
740 state
->m_agcfast_clip_ctrl_delay
= 0;
742 state
->m_gpio_cfg
= ul_gpio_cfg
;
744 state
->m_b_power_down
= false;
745 state
->m_current_power_mode
= DRX_POWER_DOWN
;
747 state
->m_rfmirror
= (ul_rf_mirror
== 0);
748 state
->m_if_agc_pol
= false;
752 static int drxx_open(struct drxk_state
*state
)
760 /* stop lock indicator process */
761 status
= write16(state
, SCU_RAM_GPIO__A
,
762 SCU_RAM_GPIO_HW_LOCK_IND_DISABLE
);
765 /* Check device id */
766 status
= read16(state
, SIO_TOP_COMM_KEY__A
, &key
);
769 status
= write16(state
, SIO_TOP_COMM_KEY__A
, SIO_TOP_COMM_KEY_KEY
);
772 status
= read32(state
, SIO_TOP_JTAGID_LO__A
, &jtag
);
775 status
= read16(state
, SIO_PDR_UIO_IN_HI__A
, &bid
);
778 status
= write16(state
, SIO_TOP_COMM_KEY__A
, key
);
781 pr_err("Error %d on %s\n", status
, __func__
);
785 static int get_device_capabilities(struct drxk_state
*state
)
787 u16 sio_pdr_ohw_cfg
= 0;
788 u32 sio_top_jtagid_lo
= 0;
790 const char *spin
= "";
795 /* stop lock indicator process */
796 status
= write16(state
, SCU_RAM_GPIO__A
,
797 SCU_RAM_GPIO_HW_LOCK_IND_DISABLE
);
800 status
= write16(state
, SIO_TOP_COMM_KEY__A
, SIO_TOP_COMM_KEY_KEY
);
803 status
= read16(state
, SIO_PDR_OHW_CFG__A
, &sio_pdr_ohw_cfg
);
806 status
= write16(state
, SIO_TOP_COMM_KEY__A
, 0x0000);
810 switch ((sio_pdr_ohw_cfg
& SIO_PDR_OHW_CFG_FREF_SEL__M
)) {
812 /* ignore (bypass ?) */
816 state
->m_osc_clock_freq
= 27000;
820 state
->m_osc_clock_freq
= 20250;
824 state
->m_osc_clock_freq
= 20250;
827 pr_err("Clock Frequency is unknown\n");
831 Determine device capabilities
834 status
= read32(state
, SIO_TOP_JTAGID_LO__A
, &sio_top_jtagid_lo
);
838 pr_info("status = 0x%08x\n", sio_top_jtagid_lo
);
841 switch ((sio_top_jtagid_lo
>> 29) & 0xF) {
843 state
->m_device_spin
= DRXK_SPIN_A1
;
847 state
->m_device_spin
= DRXK_SPIN_A2
;
851 state
->m_device_spin
= DRXK_SPIN_A3
;
855 state
->m_device_spin
= DRXK_SPIN_UNKNOWN
;
857 pr_err("Spin %d unknown\n", (sio_top_jtagid_lo
>> 29) & 0xF);
860 switch ((sio_top_jtagid_lo
>> 12) & 0xFF) {
862 /* typeId = DRX3913K_TYPE_ID */
863 state
->m_has_lna
= false;
864 state
->m_has_oob
= false;
865 state
->m_has_atv
= false;
866 state
->m_has_audio
= false;
867 state
->m_has_dvbt
= true;
868 state
->m_has_dvbc
= true;
869 state
->m_has_sawsw
= true;
870 state
->m_has_gpio2
= false;
871 state
->m_has_gpio1
= false;
872 state
->m_has_irqn
= false;
875 /* typeId = DRX3915K_TYPE_ID */
876 state
->m_has_lna
= false;
877 state
->m_has_oob
= false;
878 state
->m_has_atv
= true;
879 state
->m_has_audio
= false;
880 state
->m_has_dvbt
= true;
881 state
->m_has_dvbc
= false;
882 state
->m_has_sawsw
= true;
883 state
->m_has_gpio2
= true;
884 state
->m_has_gpio1
= true;
885 state
->m_has_irqn
= false;
888 /* typeId = DRX3916K_TYPE_ID */
889 state
->m_has_lna
= false;
890 state
->m_has_oob
= false;
891 state
->m_has_atv
= true;
892 state
->m_has_audio
= false;
893 state
->m_has_dvbt
= true;
894 state
->m_has_dvbc
= false;
895 state
->m_has_sawsw
= true;
896 state
->m_has_gpio2
= true;
897 state
->m_has_gpio1
= true;
898 state
->m_has_irqn
= false;
901 /* typeId = DRX3918K_TYPE_ID */
902 state
->m_has_lna
= false;
903 state
->m_has_oob
= false;
904 state
->m_has_atv
= true;
905 state
->m_has_audio
= true;
906 state
->m_has_dvbt
= true;
907 state
->m_has_dvbc
= false;
908 state
->m_has_sawsw
= true;
909 state
->m_has_gpio2
= true;
910 state
->m_has_gpio1
= true;
911 state
->m_has_irqn
= false;
914 /* typeId = DRX3921K_TYPE_ID */
915 state
->m_has_lna
= false;
916 state
->m_has_oob
= false;
917 state
->m_has_atv
= true;
918 state
->m_has_audio
= true;
919 state
->m_has_dvbt
= true;
920 state
->m_has_dvbc
= true;
921 state
->m_has_sawsw
= true;
922 state
->m_has_gpio2
= true;
923 state
->m_has_gpio1
= true;
924 state
->m_has_irqn
= false;
927 /* typeId = DRX3923K_TYPE_ID */
928 state
->m_has_lna
= false;
929 state
->m_has_oob
= false;
930 state
->m_has_atv
= true;
931 state
->m_has_audio
= true;
932 state
->m_has_dvbt
= true;
933 state
->m_has_dvbc
= true;
934 state
->m_has_sawsw
= true;
935 state
->m_has_gpio2
= true;
936 state
->m_has_gpio1
= true;
937 state
->m_has_irqn
= false;
940 /* typeId = DRX3925K_TYPE_ID */
941 state
->m_has_lna
= false;
942 state
->m_has_oob
= false;
943 state
->m_has_atv
= true;
944 state
->m_has_audio
= true;
945 state
->m_has_dvbt
= true;
946 state
->m_has_dvbc
= true;
947 state
->m_has_sawsw
= true;
948 state
->m_has_gpio2
= true;
949 state
->m_has_gpio1
= true;
950 state
->m_has_irqn
= false;
953 /* typeId = DRX3926K_TYPE_ID */
954 state
->m_has_lna
= false;
955 state
->m_has_oob
= false;
956 state
->m_has_atv
= true;
957 state
->m_has_audio
= false;
958 state
->m_has_dvbt
= true;
959 state
->m_has_dvbc
= true;
960 state
->m_has_sawsw
= true;
961 state
->m_has_gpio2
= true;
962 state
->m_has_gpio1
= true;
963 state
->m_has_irqn
= false;
966 pr_err("DeviceID 0x%02x not supported\n",
967 ((sio_top_jtagid_lo
>> 12) & 0xFF));
972 pr_info("detected a drx-39%02xk, spin %s, xtal %d.%03d MHz\n",
973 ((sio_top_jtagid_lo
>> 12) & 0xFF), spin
,
974 state
->m_osc_clock_freq
/ 1000,
975 state
->m_osc_clock_freq
% 1000);
979 pr_err("Error %d on %s\n", status
, __func__
);
985 static int hi_command(struct drxk_state
*state
, u16 cmd
, u16
*p_result
)
993 status
= write16(state
, SIO_HI_RA_RAM_CMD__A
, cmd
);
996 if (cmd
== SIO_HI_RA_RAM_CMD_RESET
)
997 usleep_range(1000, 2000);
1000 (bool) ((cmd
== SIO_HI_RA_RAM_CMD_CONFIG
) &&
1001 ((state
->m_hi_cfg_ctrl
) &
1002 SIO_HI_RA_RAM_PAR_5_CFG_SLEEP__M
) ==
1003 SIO_HI_RA_RAM_PAR_5_CFG_SLEEP_ZZZ
);
1004 if (!powerdown_cmd
) {
1005 /* Wait until command rdy */
1006 u32 retry_count
= 0;
1010 usleep_range(1000, 2000);
1012 status
= read16(state
, SIO_HI_RA_RAM_CMD__A
,
1014 } while ((status
< 0 || wait_cmd
) && (retry_count
< DRXK_MAX_RETRIES
));
1017 status
= read16(state
, SIO_HI_RA_RAM_RES__A
, p_result
);
1021 pr_err("Error %d on %s\n", status
, __func__
);
1026 static int hi_cfg_command(struct drxk_state
*state
)
1032 mutex_lock(&state
->mutex
);
1034 status
= write16(state
, SIO_HI_RA_RAM_PAR_6__A
,
1035 state
->m_hi_cfg_timeout
);
1038 status
= write16(state
, SIO_HI_RA_RAM_PAR_5__A
,
1039 state
->m_hi_cfg_ctrl
);
1042 status
= write16(state
, SIO_HI_RA_RAM_PAR_4__A
,
1043 state
->m_hi_cfg_wake_up_key
);
1046 status
= write16(state
, SIO_HI_RA_RAM_PAR_3__A
,
1047 state
->m_hi_cfg_bridge_delay
);
1050 status
= write16(state
, SIO_HI_RA_RAM_PAR_2__A
,
1051 state
->m_hi_cfg_timing_div
);
1054 status
= write16(state
, SIO_HI_RA_RAM_PAR_1__A
,
1055 SIO_HI_RA_RAM_PAR_1_PAR1_SEC_KEY
);
1058 status
= hi_command(state
, SIO_HI_RA_RAM_CMD_CONFIG
, NULL
);
1062 state
->m_hi_cfg_ctrl
&= ~SIO_HI_RA_RAM_PAR_5_CFG_SLEEP_ZZZ
;
1064 mutex_unlock(&state
->mutex
);
1066 pr_err("Error %d on %s\n", status
, __func__
);
1070 static int init_hi(struct drxk_state
*state
)
1074 state
->m_hi_cfg_wake_up_key
= (state
->demod_address
<< 1);
1075 state
->m_hi_cfg_timeout
= 0x96FF;
1076 /* port/bridge/power down ctrl */
1077 state
->m_hi_cfg_ctrl
= SIO_HI_RA_RAM_PAR_5_CFG_SLV0_SLAVE
;
1079 return hi_cfg_command(state
);
1082 static int mpegts_configure_pins(struct drxk_state
*state
, bool mpeg_enable
)
1085 u16 sio_pdr_mclk_cfg
= 0;
1086 u16 sio_pdr_mdx_cfg
= 0;
1089 dprintk(1, ": mpeg %s, %s mode\n",
1090 mpeg_enable
? "enable" : "disable",
1091 state
->m_enable_parallel
? "parallel" : "serial");
1093 /* stop lock indicator process */
1094 status
= write16(state
, SCU_RAM_GPIO__A
,
1095 SCU_RAM_GPIO_HW_LOCK_IND_DISABLE
);
1099 /* MPEG TS pad configuration */
1100 status
= write16(state
, SIO_TOP_COMM_KEY__A
, SIO_TOP_COMM_KEY_KEY
);
1105 /* Set MPEG TS pads to inputmode */
1106 status
= write16(state
, SIO_PDR_MSTRT_CFG__A
, 0x0000);
1109 status
= write16(state
, SIO_PDR_MERR_CFG__A
, 0x0000);
1112 status
= write16(state
, SIO_PDR_MCLK_CFG__A
, 0x0000);
1115 status
= write16(state
, SIO_PDR_MVAL_CFG__A
, 0x0000);
1118 status
= write16(state
, SIO_PDR_MD0_CFG__A
, 0x0000);
1121 status
= write16(state
, SIO_PDR_MD1_CFG__A
, 0x0000);
1124 status
= write16(state
, SIO_PDR_MD2_CFG__A
, 0x0000);
1127 status
= write16(state
, SIO_PDR_MD3_CFG__A
, 0x0000);
1130 status
= write16(state
, SIO_PDR_MD4_CFG__A
, 0x0000);
1133 status
= write16(state
, SIO_PDR_MD5_CFG__A
, 0x0000);
1136 status
= write16(state
, SIO_PDR_MD6_CFG__A
, 0x0000);
1139 status
= write16(state
, SIO_PDR_MD7_CFG__A
, 0x0000);
1143 /* Enable MPEG output */
1145 ((state
->m_ts_data_strength
<<
1146 SIO_PDR_MD0_CFG_DRIVE__B
) | 0x0003);
1147 sio_pdr_mclk_cfg
= ((state
->m_ts_clockk_strength
<<
1148 SIO_PDR_MCLK_CFG_DRIVE__B
) |
1151 status
= write16(state
, SIO_PDR_MSTRT_CFG__A
, sio_pdr_mdx_cfg
);
1155 if (state
->enable_merr_cfg
)
1156 err_cfg
= sio_pdr_mdx_cfg
;
1158 status
= write16(state
, SIO_PDR_MERR_CFG__A
, err_cfg
);
1161 status
= write16(state
, SIO_PDR_MVAL_CFG__A
, err_cfg
);
1165 if (state
->m_enable_parallel
) {
1166 /* parallel -> enable MD1 to MD7 */
1167 status
= write16(state
, SIO_PDR_MD1_CFG__A
,
1171 status
= write16(state
, SIO_PDR_MD2_CFG__A
,
1175 status
= write16(state
, SIO_PDR_MD3_CFG__A
,
1179 status
= write16(state
, SIO_PDR_MD4_CFG__A
,
1183 status
= write16(state
, SIO_PDR_MD5_CFG__A
,
1187 status
= write16(state
, SIO_PDR_MD6_CFG__A
,
1191 status
= write16(state
, SIO_PDR_MD7_CFG__A
,
1196 sio_pdr_mdx_cfg
= ((state
->m_ts_data_strength
<<
1197 SIO_PDR_MD0_CFG_DRIVE__B
)
1199 /* serial -> disable MD1 to MD7 */
1200 status
= write16(state
, SIO_PDR_MD1_CFG__A
, 0x0000);
1203 status
= write16(state
, SIO_PDR_MD2_CFG__A
, 0x0000);
1206 status
= write16(state
, SIO_PDR_MD3_CFG__A
, 0x0000);
1209 status
= write16(state
, SIO_PDR_MD4_CFG__A
, 0x0000);
1212 status
= write16(state
, SIO_PDR_MD5_CFG__A
, 0x0000);
1215 status
= write16(state
, SIO_PDR_MD6_CFG__A
, 0x0000);
1218 status
= write16(state
, SIO_PDR_MD7_CFG__A
, 0x0000);
1222 status
= write16(state
, SIO_PDR_MCLK_CFG__A
, sio_pdr_mclk_cfg
);
1225 status
= write16(state
, SIO_PDR_MD0_CFG__A
, sio_pdr_mdx_cfg
);
1229 /* Enable MB output over MPEG pads and ctl input */
1230 status
= write16(state
, SIO_PDR_MON_CFG__A
, 0x0000);
1233 /* Write nomagic word to enable pdr reg write */
1234 status
= write16(state
, SIO_TOP_COMM_KEY__A
, 0x0000);
1237 pr_err("Error %d on %s\n", status
, __func__
);
1241 static int mpegts_disable(struct drxk_state
*state
)
1245 return mpegts_configure_pins(state
, false);
1248 static int bl_chain_cmd(struct drxk_state
*state
,
1249 u16 rom_offset
, u16 nr_of_elements
, u32 time_out
)
1256 mutex_lock(&state
->mutex
);
1257 status
= write16(state
, SIO_BL_MODE__A
, SIO_BL_MODE_CHAIN
);
1260 status
= write16(state
, SIO_BL_CHAIN_ADDR__A
, rom_offset
);
1263 status
= write16(state
, SIO_BL_CHAIN_LEN__A
, nr_of_elements
);
1266 status
= write16(state
, SIO_BL_ENABLE__A
, SIO_BL_ENABLE_ON
);
1270 end
= jiffies
+ msecs_to_jiffies(time_out
);
1272 usleep_range(1000, 2000);
1273 status
= read16(state
, SIO_BL_STATUS__A
, &bl_status
);
1276 } while ((bl_status
== 0x1) &&
1277 ((time_is_after_jiffies(end
))));
1279 if (bl_status
== 0x1) {
1280 pr_err("SIO not ready\n");
1286 pr_err("Error %d on %s\n", status
, __func__
);
1288 mutex_unlock(&state
->mutex
);
1293 static int download_microcode(struct drxk_state
*state
,
1294 const u8 p_mc_image
[], u32 length
)
1296 const u8
*p_src
= p_mc_image
;
1306 /* down the drain (we don't care about MAGIC_WORD) */
1308 /* For future reference */
1309 drain
= (p_src
[0] << 8) | p_src
[1];
1311 p_src
+= sizeof(u16
);
1312 offset
+= sizeof(u16
);
1313 n_blocks
= (p_src
[0] << 8) | p_src
[1];
1314 p_src
+= sizeof(u16
);
1315 offset
+= sizeof(u16
);
1317 for (i
= 0; i
< n_blocks
; i
+= 1) {
1318 address
= (p_src
[0] << 24) | (p_src
[1] << 16) |
1319 (p_src
[2] << 8) | p_src
[3];
1320 p_src
+= sizeof(u32
);
1321 offset
+= sizeof(u32
);
1323 block_size
= ((p_src
[0] << 8) | p_src
[1]) * sizeof(u16
);
1324 p_src
+= sizeof(u16
);
1325 offset
+= sizeof(u16
);
1328 /* For future reference */
1329 flags
= (p_src
[0] << 8) | p_src
[1];
1331 p_src
+= sizeof(u16
);
1332 offset
+= sizeof(u16
);
1335 /* For future reference */
1336 block_crc
= (p_src
[0] << 8) | p_src
[1];
1338 p_src
+= sizeof(u16
);
1339 offset
+= sizeof(u16
);
1341 if (offset
+ block_size
> length
) {
1342 pr_err("Firmware is corrupted.\n");
1346 status
= write_block(state
, address
, block_size
, p_src
);
1348 pr_err("Error %d while loading firmware\n", status
);
1351 p_src
+= block_size
;
1352 offset
+= block_size
;
1357 static int dvbt_enable_ofdm_token_ring(struct drxk_state
*state
, bool enable
)
1361 u16 desired_ctrl
= SIO_OFDM_SH_OFDM_RING_ENABLE_ON
;
1362 u16 desired_status
= SIO_OFDM_SH_OFDM_RING_STATUS_ENABLED
;
1368 desired_ctrl
= SIO_OFDM_SH_OFDM_RING_ENABLE_OFF
;
1369 desired_status
= SIO_OFDM_SH_OFDM_RING_STATUS_DOWN
;
1372 status
= read16(state
, SIO_OFDM_SH_OFDM_RING_STATUS__A
, &data
);
1373 if (status
>= 0 && data
== desired_status
) {
1374 /* tokenring already has correct status */
1377 /* Disable/enable dvbt tokenring bridge */
1378 status
= write16(state
, SIO_OFDM_SH_OFDM_RING_ENABLE__A
, desired_ctrl
);
1380 end
= jiffies
+ msecs_to_jiffies(DRXK_OFDM_TR_SHUTDOWN_TIMEOUT
);
1382 status
= read16(state
, SIO_OFDM_SH_OFDM_RING_STATUS__A
, &data
);
1383 if ((status
>= 0 && data
== desired_status
)
1384 || time_is_after_jiffies(end
))
1386 usleep_range(1000, 2000);
1388 if (data
!= desired_status
) {
1389 pr_err("SIO not ready\n");
1395 static int mpegts_stop(struct drxk_state
*state
)
1398 u16 fec_oc_snc_mode
= 0;
1399 u16 fec_oc_ipr_mode
= 0;
1403 /* Graceful shutdown (byte boundaries) */
1404 status
= read16(state
, FEC_OC_SNC_MODE__A
, &fec_oc_snc_mode
);
1407 fec_oc_snc_mode
|= FEC_OC_SNC_MODE_SHUTDOWN__M
;
1408 status
= write16(state
, FEC_OC_SNC_MODE__A
, fec_oc_snc_mode
);
1412 /* Suppress MCLK during absence of data */
1413 status
= read16(state
, FEC_OC_IPR_MODE__A
, &fec_oc_ipr_mode
);
1416 fec_oc_ipr_mode
|= FEC_OC_IPR_MODE_MCLK_DIS_DAT_ABS__M
;
1417 status
= write16(state
, FEC_OC_IPR_MODE__A
, fec_oc_ipr_mode
);
1421 pr_err("Error %d on %s\n", status
, __func__
);
1426 static int scu_command(struct drxk_state
*state
,
1427 u16 cmd
, u8 parameter_len
,
1428 u16
*parameter
, u8 result_len
, u16
*result
)
1430 #if (SCU_RAM_PARAM_0__A - SCU_RAM_PARAM_15__A) != 15
1431 #error DRXK register mapping no longer compatible with this routine!
1434 int status
= -EINVAL
;
1443 if ((cmd
== 0) || ((parameter_len
> 0) && (parameter
== NULL
)) ||
1444 ((result_len
> 0) && (result
== NULL
))) {
1445 pr_err("Error %d on %s\n", status
, __func__
);
1449 mutex_lock(&state
->mutex
);
1451 /* assume that the command register is ready
1452 since it is checked afterwards */
1454 for (ii
= parameter_len
- 1; ii
>= 0; ii
-= 1) {
1455 buffer
[cnt
++] = (parameter
[ii
] & 0xFF);
1456 buffer
[cnt
++] = ((parameter
[ii
] >> 8) & 0xFF);
1459 buffer
[cnt
++] = (cmd
& 0xFF);
1460 buffer
[cnt
++] = ((cmd
>> 8) & 0xFF);
1462 write_block(state
, SCU_RAM_PARAM_0__A
-
1463 (parameter_len
- 1), cnt
, buffer
);
1464 /* Wait until SCU has processed command */
1465 end
= jiffies
+ msecs_to_jiffies(DRXK_MAX_WAITTIME
);
1467 usleep_range(1000, 2000);
1468 status
= read16(state
, SCU_RAM_COMMAND__A
, &cur_cmd
);
1471 } while (!(cur_cmd
== DRX_SCU_READY
) && (time_is_after_jiffies(end
)));
1472 if (cur_cmd
!= DRX_SCU_READY
) {
1473 pr_err("SCU not ready\n");
1478 if ((result_len
> 0) && (result
!= NULL
)) {
1482 for (ii
= result_len
- 1; ii
>= 0; ii
-= 1) {
1483 status
= read16(state
, SCU_RAM_PARAM_0__A
- ii
,
1489 /* Check if an error was reported by SCU */
1490 err
= (s16
)result
[0];
1494 /* check for the known error codes */
1496 case SCU_RESULT_UNKCMD
:
1497 p
= "SCU_RESULT_UNKCMD";
1499 case SCU_RESULT_UNKSTD
:
1500 p
= "SCU_RESULT_UNKSTD";
1502 case SCU_RESULT_SIZE
:
1503 p
= "SCU_RESULT_SIZE";
1505 case SCU_RESULT_INVPAR
:
1506 p
= "SCU_RESULT_INVPAR";
1508 default: /* Other negative values are errors */
1509 sprintf(errname
, "ERROR: %d\n", err
);
1512 pr_err("%s while sending cmd 0x%04x with params:", p
, cmd
);
1513 print_hex_dump_bytes("drxk: ", DUMP_PREFIX_NONE
, buffer
, cnt
);
1520 pr_err("Error %d on %s\n", status
, __func__
);
1522 mutex_unlock(&state
->mutex
);
1526 static int set_iqm_af(struct drxk_state
*state
, bool active
)
1534 status
= read16(state
, IQM_AF_STDBY__A
, &data
);
1539 data
|= (IQM_AF_STDBY_STDBY_ADC_STANDBY
1540 | IQM_AF_STDBY_STDBY_AMP_STANDBY
1541 | IQM_AF_STDBY_STDBY_PD_STANDBY
1542 | IQM_AF_STDBY_STDBY_TAGC_IF_STANDBY
1543 | IQM_AF_STDBY_STDBY_TAGC_RF_STANDBY
);
1545 data
&= ((~IQM_AF_STDBY_STDBY_ADC_STANDBY
)
1546 & (~IQM_AF_STDBY_STDBY_AMP_STANDBY
)
1547 & (~IQM_AF_STDBY_STDBY_PD_STANDBY
)
1548 & (~IQM_AF_STDBY_STDBY_TAGC_IF_STANDBY
)
1549 & (~IQM_AF_STDBY_STDBY_TAGC_RF_STANDBY
)
1552 status
= write16(state
, IQM_AF_STDBY__A
, data
);
1556 pr_err("Error %d on %s\n", status
, __func__
);
1560 static int ctrl_power_mode(struct drxk_state
*state
, enum drx_power_mode
*mode
)
1563 u16 sio_cc_pwd_mode
= 0;
1567 /* Check arguments */
1573 sio_cc_pwd_mode
= SIO_CC_PWD_MODE_LEVEL_NONE
;
1575 case DRXK_POWER_DOWN_OFDM
:
1576 sio_cc_pwd_mode
= SIO_CC_PWD_MODE_LEVEL_OFDM
;
1578 case DRXK_POWER_DOWN_CORE
:
1579 sio_cc_pwd_mode
= SIO_CC_PWD_MODE_LEVEL_CLOCK
;
1581 case DRXK_POWER_DOWN_PLL
:
1582 sio_cc_pwd_mode
= SIO_CC_PWD_MODE_LEVEL_PLL
;
1584 case DRX_POWER_DOWN
:
1585 sio_cc_pwd_mode
= SIO_CC_PWD_MODE_LEVEL_OSC
;
1588 /* Unknow sleep mode */
1592 /* If already in requested power mode, do nothing */
1593 if (state
->m_current_power_mode
== *mode
)
1596 /* For next steps make sure to start from DRX_POWER_UP mode */
1597 if (state
->m_current_power_mode
!= DRX_POWER_UP
) {
1598 status
= power_up_device(state
);
1601 status
= dvbt_enable_ofdm_token_ring(state
, true);
1606 if (*mode
== DRX_POWER_UP
) {
1607 /* Restore analog & pin configuration */
1609 /* Power down to requested mode */
1610 /* Backup some register settings */
1611 /* Set pins with possible pull-ups connected
1612 to them in input mode */
1613 /* Analog power down */
1614 /* ADC power down */
1615 /* Power down device */
1616 /* stop all comm_exec */
1617 /* Stop and power down previous standard */
1618 switch (state
->m_operation_mode
) {
1620 status
= mpegts_stop(state
);
1623 status
= power_down_dvbt(state
, false);
1629 status
= mpegts_stop(state
);
1632 status
= power_down_qam(state
);
1639 status
= dvbt_enable_ofdm_token_ring(state
, false);
1642 status
= write16(state
, SIO_CC_PWD_MODE__A
, sio_cc_pwd_mode
);
1645 status
= write16(state
, SIO_CC_UPDATE__A
, SIO_CC_UPDATE_KEY
);
1649 if (*mode
!= DRXK_POWER_DOWN_OFDM
) {
1650 state
->m_hi_cfg_ctrl
|=
1651 SIO_HI_RA_RAM_PAR_5_CFG_SLEEP_ZZZ
;
1652 status
= hi_cfg_command(state
);
1657 state
->m_current_power_mode
= *mode
;
1661 pr_err("Error %d on %s\n", status
, __func__
);
1666 static int power_down_dvbt(struct drxk_state
*state
, bool set_power_mode
)
1668 enum drx_power_mode power_mode
= DRXK_POWER_DOWN_OFDM
;
1675 status
= read16(state
, SCU_COMM_EXEC__A
, &data
);
1678 if (data
== SCU_COMM_EXEC_ACTIVE
) {
1679 /* Send OFDM stop command */
1680 status
= scu_command(state
,
1681 SCU_RAM_COMMAND_STANDARD_OFDM
1682 | SCU_RAM_COMMAND_CMD_DEMOD_STOP
,
1683 0, NULL
, 1, &cmd_result
);
1686 /* Send OFDM reset command */
1687 status
= scu_command(state
,
1688 SCU_RAM_COMMAND_STANDARD_OFDM
1689 | SCU_RAM_COMMAND_CMD_DEMOD_RESET
,
1690 0, NULL
, 1, &cmd_result
);
1695 /* Reset datapath for OFDM, processors first */
1696 status
= write16(state
, OFDM_SC_COMM_EXEC__A
, OFDM_SC_COMM_EXEC_STOP
);
1699 status
= write16(state
, OFDM_LC_COMM_EXEC__A
, OFDM_LC_COMM_EXEC_STOP
);
1702 status
= write16(state
, IQM_COMM_EXEC__A
, IQM_COMM_EXEC_B_STOP
);
1707 status
= set_iqm_af(state
, false);
1711 /* powerdown to OFDM mode */
1712 if (set_power_mode
) {
1713 status
= ctrl_power_mode(state
, &power_mode
);
1719 pr_err("Error %d on %s\n", status
, __func__
);
1723 static int setoperation_mode(struct drxk_state
*state
,
1724 enum operation_mode o_mode
)
1730 Stop and power down previous standard
1731 TODO investigate total power down instead of partial
1732 power down depending on "previous" standard.
1735 /* disable HW lock indicator */
1736 status
= write16(state
, SCU_RAM_GPIO__A
,
1737 SCU_RAM_GPIO_HW_LOCK_IND_DISABLE
);
1741 /* Device is already at the required mode */
1742 if (state
->m_operation_mode
== o_mode
)
1745 switch (state
->m_operation_mode
) {
1746 /* OM_NONE was added for start up */
1750 status
= mpegts_stop(state
);
1753 status
= power_down_dvbt(state
, true);
1756 state
->m_operation_mode
= OM_NONE
;
1760 status
= mpegts_stop(state
);
1763 status
= power_down_qam(state
);
1766 state
->m_operation_mode
= OM_NONE
;
1775 Power up new standard
1779 dprintk(1, ": DVB-T\n");
1780 state
->m_operation_mode
= o_mode
;
1781 status
= set_dvbt_standard(state
, o_mode
);
1787 dprintk(1, ": DVB-C Annex %c\n",
1788 (state
->m_operation_mode
== OM_QAM_ITU_A
) ? 'A' : 'C');
1789 state
->m_operation_mode
= o_mode
;
1790 status
= set_qam_standard(state
, o_mode
);
1800 pr_err("Error %d on %s\n", status
, __func__
);
1804 static int start(struct drxk_state
*state
, s32 offset_freq
,
1805 s32 intermediate_frequency
)
1807 int status
= -EINVAL
;
1810 s32 offsetk_hz
= offset_freq
/ 1000;
1813 if (state
->m_drxk_state
!= DRXK_STOPPED
&&
1814 state
->m_drxk_state
!= DRXK_DTV_STARTED
)
1817 state
->m_b_mirror_freq_spect
= (state
->props
.inversion
== INVERSION_ON
);
1819 if (intermediate_frequency
< 0) {
1820 state
->m_b_mirror_freq_spect
= !state
->m_b_mirror_freq_spect
;
1821 intermediate_frequency
= -intermediate_frequency
;
1824 switch (state
->m_operation_mode
) {
1827 i_freqk_hz
= (intermediate_frequency
/ 1000);
1828 status
= set_qam(state
, i_freqk_hz
, offsetk_hz
);
1831 state
->m_drxk_state
= DRXK_DTV_STARTED
;
1834 i_freqk_hz
= (intermediate_frequency
/ 1000);
1835 status
= mpegts_stop(state
);
1838 status
= set_dvbt(state
, i_freqk_hz
, offsetk_hz
);
1841 status
= dvbt_start(state
);
1844 state
->m_drxk_state
= DRXK_DTV_STARTED
;
1851 pr_err("Error %d on %s\n", status
, __func__
);
1855 static int shut_down(struct drxk_state
*state
)
1863 static int get_lock_status(struct drxk_state
*state
, u32
*p_lock_status
)
1865 int status
= -EINVAL
;
1869 if (p_lock_status
== NULL
)
1872 *p_lock_status
= NOT_LOCKED
;
1874 /* define the SCU command code */
1875 switch (state
->m_operation_mode
) {
1879 status
= get_qam_lock_status(state
, p_lock_status
);
1882 status
= get_dvbt_lock_status(state
, p_lock_status
);
1885 pr_debug("Unsupported operation mode %d in %s\n",
1886 state
->m_operation_mode
, __func__
);
1891 pr_err("Error %d on %s\n", status
, __func__
);
1895 static int mpegts_start(struct drxk_state
*state
)
1899 u16 fec_oc_snc_mode
= 0;
1901 /* Allow OC to sync again */
1902 status
= read16(state
, FEC_OC_SNC_MODE__A
, &fec_oc_snc_mode
);
1905 fec_oc_snc_mode
&= ~FEC_OC_SNC_MODE_SHUTDOWN__M
;
1906 status
= write16(state
, FEC_OC_SNC_MODE__A
, fec_oc_snc_mode
);
1909 status
= write16(state
, FEC_OC_SNC_UNLOCK__A
, 1);
1912 pr_err("Error %d on %s\n", status
, __func__
);
1916 static int mpegts_dto_init(struct drxk_state
*state
)
1922 /* Rate integration settings */
1923 status
= write16(state
, FEC_OC_RCN_CTL_STEP_LO__A
, 0x0000);
1926 status
= write16(state
, FEC_OC_RCN_CTL_STEP_HI__A
, 0x000C);
1929 status
= write16(state
, FEC_OC_RCN_GAIN__A
, 0x000A);
1932 status
= write16(state
, FEC_OC_AVR_PARM_A__A
, 0x0008);
1935 status
= write16(state
, FEC_OC_AVR_PARM_B__A
, 0x0006);
1938 status
= write16(state
, FEC_OC_TMD_HI_MARGIN__A
, 0x0680);
1941 status
= write16(state
, FEC_OC_TMD_LO_MARGIN__A
, 0x0080);
1944 status
= write16(state
, FEC_OC_TMD_COUNT__A
, 0x03F4);
1948 /* Additional configuration */
1949 status
= write16(state
, FEC_OC_OCR_INVERT__A
, 0);
1952 status
= write16(state
, FEC_OC_SNC_LWM__A
, 2);
1955 status
= write16(state
, FEC_OC_SNC_HWM__A
, 12);
1958 pr_err("Error %d on %s\n", status
, __func__
);
1963 static int mpegts_dto_setup(struct drxk_state
*state
,
1964 enum operation_mode o_mode
)
1968 u16 fec_oc_reg_mode
= 0; /* FEC_OC_MODE register value */
1969 u16 fec_oc_reg_ipr_mode
= 0; /* FEC_OC_IPR_MODE register value */
1970 u16 fec_oc_dto_mode
= 0; /* FEC_OC_IPR_INVERT register value */
1971 u16 fec_oc_fct_mode
= 0; /* FEC_OC_IPR_INVERT register value */
1972 u16 fec_oc_dto_period
= 2; /* FEC_OC_IPR_INVERT register value */
1973 u16 fec_oc_dto_burst_len
= 188; /* FEC_OC_IPR_INVERT register value */
1974 u32 fec_oc_rcn_ctl_rate
= 0; /* FEC_OC_IPR_INVERT register value */
1975 u16 fec_oc_tmd_mode
= 0;
1976 u16 fec_oc_tmd_int_upd_rate
= 0;
1977 u32 max_bit_rate
= 0;
1978 bool static_clk
= false;
1982 /* Check insertion of the Reed-Solomon parity bytes */
1983 status
= read16(state
, FEC_OC_MODE__A
, &fec_oc_reg_mode
);
1986 status
= read16(state
, FEC_OC_IPR_MODE__A
, &fec_oc_reg_ipr_mode
);
1989 fec_oc_reg_mode
&= (~FEC_OC_MODE_PARITY__M
);
1990 fec_oc_reg_ipr_mode
&= (~FEC_OC_IPR_MODE_MVAL_DIS_PAR__M
);
1991 if (state
->m_insert_rs_byte
) {
1992 /* enable parity symbol forward */
1993 fec_oc_reg_mode
|= FEC_OC_MODE_PARITY__M
;
1994 /* MVAL disable during parity bytes */
1995 fec_oc_reg_ipr_mode
|= FEC_OC_IPR_MODE_MVAL_DIS_PAR__M
;
1996 /* TS burst length to 204 */
1997 fec_oc_dto_burst_len
= 204;
2000 /* Check serial or parallel output */
2001 fec_oc_reg_ipr_mode
&= (~(FEC_OC_IPR_MODE_SERIAL__M
));
2002 if (!state
->m_enable_parallel
) {
2003 /* MPEG data output is serial -> set ipr_mode[0] */
2004 fec_oc_reg_ipr_mode
|= FEC_OC_IPR_MODE_SERIAL__M
;
2009 max_bit_rate
= state
->m_dvbt_bitrate
;
2010 fec_oc_tmd_mode
= 3;
2011 fec_oc_rcn_ctl_rate
= 0xC00000;
2012 static_clk
= state
->m_dvbt_static_clk
;
2016 fec_oc_tmd_mode
= 0x0004;
2017 fec_oc_rcn_ctl_rate
= 0xD2B4EE; /* good for >63 Mb/s */
2018 max_bit_rate
= state
->m_dvbc_bitrate
;
2019 static_clk
= state
->m_dvbc_static_clk
;
2023 } /* switch (standard) */
2027 /* Configure DTO's */
2031 /* Rational DTO for MCLK source (static MCLK rate),
2032 Dynamic DTO for optimal grouping
2033 (avoid intra-packet gaps),
2034 DTO offset enable to sync TS burst with MSTRT */
2035 fec_oc_dto_mode
= (FEC_OC_DTO_MODE_DYNAMIC__M
|
2036 FEC_OC_DTO_MODE_OFFSET_ENABLE__M
);
2037 fec_oc_fct_mode
= (FEC_OC_FCT_MODE_RAT_ENA__M
|
2038 FEC_OC_FCT_MODE_VIRT_ENA__M
);
2040 /* Check user defined bitrate */
2041 bit_rate
= max_bit_rate
;
2042 if (bit_rate
> 75900000UL) { /* max is 75.9 Mb/s */
2043 bit_rate
= 75900000UL;
2045 /* Rational DTO period:
2046 dto_period = (Fsys / bitrate) - 2
2048 result should be floored,
2049 to make sure >= requested bitrate
2051 fec_oc_dto_period
= (u16
) (((state
->m_sys_clock_freq
)
2052 * 1000) / bit_rate
);
2053 if (fec_oc_dto_period
<= 2)
2054 fec_oc_dto_period
= 0;
2056 fec_oc_dto_period
-= 2;
2057 fec_oc_tmd_int_upd_rate
= 8;
2059 /* (commonAttr->static_clk == false) => dynamic mode */
2060 fec_oc_dto_mode
= FEC_OC_DTO_MODE_DYNAMIC__M
;
2061 fec_oc_fct_mode
= FEC_OC_FCT_MODE__PRE
;
2062 fec_oc_tmd_int_upd_rate
= 5;
2065 /* Write appropriate registers with requested configuration */
2066 status
= write16(state
, FEC_OC_DTO_BURST_LEN__A
, fec_oc_dto_burst_len
);
2069 status
= write16(state
, FEC_OC_DTO_PERIOD__A
, fec_oc_dto_period
);
2072 status
= write16(state
, FEC_OC_DTO_MODE__A
, fec_oc_dto_mode
);
2075 status
= write16(state
, FEC_OC_FCT_MODE__A
, fec_oc_fct_mode
);
2078 status
= write16(state
, FEC_OC_MODE__A
, fec_oc_reg_mode
);
2081 status
= write16(state
, FEC_OC_IPR_MODE__A
, fec_oc_reg_ipr_mode
);
2085 /* Rate integration settings */
2086 status
= write32(state
, FEC_OC_RCN_CTL_RATE_LO__A
, fec_oc_rcn_ctl_rate
);
2089 status
= write16(state
, FEC_OC_TMD_INT_UPD_RATE__A
,
2090 fec_oc_tmd_int_upd_rate
);
2093 status
= write16(state
, FEC_OC_TMD_MODE__A
, fec_oc_tmd_mode
);
2096 pr_err("Error %d on %s\n", status
, __func__
);
2100 static int mpegts_configure_polarity(struct drxk_state
*state
)
2102 u16 fec_oc_reg_ipr_invert
= 0;
2104 /* Data mask for the output data byte */
2105 u16 invert_data_mask
=
2106 FEC_OC_IPR_INVERT_MD7__M
| FEC_OC_IPR_INVERT_MD6__M
|
2107 FEC_OC_IPR_INVERT_MD5__M
| FEC_OC_IPR_INVERT_MD4__M
|
2108 FEC_OC_IPR_INVERT_MD3__M
| FEC_OC_IPR_INVERT_MD2__M
|
2109 FEC_OC_IPR_INVERT_MD1__M
| FEC_OC_IPR_INVERT_MD0__M
;
2113 /* Control selective inversion of output bits */
2114 fec_oc_reg_ipr_invert
&= (~(invert_data_mask
));
2115 if (state
->m_invert_data
)
2116 fec_oc_reg_ipr_invert
|= invert_data_mask
;
2117 fec_oc_reg_ipr_invert
&= (~(FEC_OC_IPR_INVERT_MERR__M
));
2118 if (state
->m_invert_err
)
2119 fec_oc_reg_ipr_invert
|= FEC_OC_IPR_INVERT_MERR__M
;
2120 fec_oc_reg_ipr_invert
&= (~(FEC_OC_IPR_INVERT_MSTRT__M
));
2121 if (state
->m_invert_str
)
2122 fec_oc_reg_ipr_invert
|= FEC_OC_IPR_INVERT_MSTRT__M
;
2123 fec_oc_reg_ipr_invert
&= (~(FEC_OC_IPR_INVERT_MVAL__M
));
2124 if (state
->m_invert_val
)
2125 fec_oc_reg_ipr_invert
|= FEC_OC_IPR_INVERT_MVAL__M
;
2126 fec_oc_reg_ipr_invert
&= (~(FEC_OC_IPR_INVERT_MCLK__M
));
2127 if (state
->m_invert_clk
)
2128 fec_oc_reg_ipr_invert
|= FEC_OC_IPR_INVERT_MCLK__M
;
2130 return write16(state
, FEC_OC_IPR_INVERT__A
, fec_oc_reg_ipr_invert
);
2133 #define SCU_RAM_AGC_KI_INV_RF_POL__M 0x4000
2135 static int set_agc_rf(struct drxk_state
*state
,
2136 struct s_cfg_agc
*p_agc_cfg
, bool is_dtv
)
2138 int status
= -EINVAL
;
2140 struct s_cfg_agc
*p_if_agc_settings
;
2144 if (p_agc_cfg
== NULL
)
2147 switch (p_agc_cfg
->ctrl_mode
) {
2148 case DRXK_AGC_CTRL_AUTO
:
2149 /* Enable RF AGC DAC */
2150 status
= read16(state
, IQM_AF_STDBY__A
, &data
);
2153 data
&= ~IQM_AF_STDBY_STDBY_TAGC_RF_STANDBY
;
2154 status
= write16(state
, IQM_AF_STDBY__A
, data
);
2157 status
= read16(state
, SCU_RAM_AGC_CONFIG__A
, &data
);
2161 /* Enable SCU RF AGC loop */
2162 data
&= ~SCU_RAM_AGC_CONFIG_DISABLE_RF_AGC__M
;
2165 if (state
->m_rf_agc_pol
)
2166 data
|= SCU_RAM_AGC_CONFIG_INV_RF_POL__M
;
2168 data
&= ~SCU_RAM_AGC_CONFIG_INV_RF_POL__M
;
2169 status
= write16(state
, SCU_RAM_AGC_CONFIG__A
, data
);
2173 /* Set speed (using complementary reduction value) */
2174 status
= read16(state
, SCU_RAM_AGC_KI_RED__A
, &data
);
2178 data
&= ~SCU_RAM_AGC_KI_RED_RAGC_RED__M
;
2179 data
|= (~(p_agc_cfg
->speed
<<
2180 SCU_RAM_AGC_KI_RED_RAGC_RED__B
)
2181 & SCU_RAM_AGC_KI_RED_RAGC_RED__M
);
2183 status
= write16(state
, SCU_RAM_AGC_KI_RED__A
, data
);
2188 p_if_agc_settings
= &state
->m_dvbt_if_agc_cfg
;
2189 else if (is_qam(state
))
2190 p_if_agc_settings
= &state
->m_qam_if_agc_cfg
;
2192 p_if_agc_settings
= &state
->m_atv_if_agc_cfg
;
2193 if (p_if_agc_settings
== NULL
) {
2198 /* Set TOP, only if IF-AGC is in AUTO mode */
2199 if (p_if_agc_settings
->ctrl_mode
== DRXK_AGC_CTRL_AUTO
) {
2200 status
= write16(state
,
2201 SCU_RAM_AGC_IF_IACCU_HI_TGT_MAX__A
,
2207 /* Cut-Off current */
2208 status
= write16(state
, SCU_RAM_AGC_RF_IACCU_HI_CO__A
,
2209 p_agc_cfg
->cut_off_current
);
2213 /* Max. output level */
2214 status
= write16(state
, SCU_RAM_AGC_RF_MAX__A
,
2215 p_agc_cfg
->max_output_level
);
2221 case DRXK_AGC_CTRL_USER
:
2222 /* Enable RF AGC DAC */
2223 status
= read16(state
, IQM_AF_STDBY__A
, &data
);
2226 data
&= ~IQM_AF_STDBY_STDBY_TAGC_RF_STANDBY
;
2227 status
= write16(state
, IQM_AF_STDBY__A
, data
);
2231 /* Disable SCU RF AGC loop */
2232 status
= read16(state
, SCU_RAM_AGC_CONFIG__A
, &data
);
2235 data
|= SCU_RAM_AGC_CONFIG_DISABLE_RF_AGC__M
;
2236 if (state
->m_rf_agc_pol
)
2237 data
|= SCU_RAM_AGC_CONFIG_INV_RF_POL__M
;
2239 data
&= ~SCU_RAM_AGC_CONFIG_INV_RF_POL__M
;
2240 status
= write16(state
, SCU_RAM_AGC_CONFIG__A
, data
);
2244 /* SCU c.o.c. to 0, enabling full control range */
2245 status
= write16(state
, SCU_RAM_AGC_RF_IACCU_HI_CO__A
, 0);
2249 /* Write value to output pin */
2250 status
= write16(state
, SCU_RAM_AGC_RF_IACCU_HI__A
,
2251 p_agc_cfg
->output_level
);
2256 case DRXK_AGC_CTRL_OFF
:
2257 /* Disable RF AGC DAC */
2258 status
= read16(state
, IQM_AF_STDBY__A
, &data
);
2261 data
|= IQM_AF_STDBY_STDBY_TAGC_RF_STANDBY
;
2262 status
= write16(state
, IQM_AF_STDBY__A
, data
);
2266 /* Disable SCU RF AGC loop */
2267 status
= read16(state
, SCU_RAM_AGC_CONFIG__A
, &data
);
2270 data
|= SCU_RAM_AGC_CONFIG_DISABLE_RF_AGC__M
;
2271 status
= write16(state
, SCU_RAM_AGC_CONFIG__A
, data
);
2282 pr_err("Error %d on %s\n", status
, __func__
);
2286 #define SCU_RAM_AGC_KI_INV_IF_POL__M 0x2000
2288 static int set_agc_if(struct drxk_state
*state
,
2289 struct s_cfg_agc
*p_agc_cfg
, bool is_dtv
)
2293 struct s_cfg_agc
*p_rf_agc_settings
;
2297 switch (p_agc_cfg
->ctrl_mode
) {
2298 case DRXK_AGC_CTRL_AUTO
:
2300 /* Enable IF AGC DAC */
2301 status
= read16(state
, IQM_AF_STDBY__A
, &data
);
2304 data
&= ~IQM_AF_STDBY_STDBY_TAGC_IF_STANDBY
;
2305 status
= write16(state
, IQM_AF_STDBY__A
, data
);
2309 status
= read16(state
, SCU_RAM_AGC_CONFIG__A
, &data
);
2313 /* Enable SCU IF AGC loop */
2314 data
&= ~SCU_RAM_AGC_CONFIG_DISABLE_IF_AGC__M
;
2317 if (state
->m_if_agc_pol
)
2318 data
|= SCU_RAM_AGC_CONFIG_INV_IF_POL__M
;
2320 data
&= ~SCU_RAM_AGC_CONFIG_INV_IF_POL__M
;
2321 status
= write16(state
, SCU_RAM_AGC_CONFIG__A
, data
);
2325 /* Set speed (using complementary reduction value) */
2326 status
= read16(state
, SCU_RAM_AGC_KI_RED__A
, &data
);
2329 data
&= ~SCU_RAM_AGC_KI_RED_IAGC_RED__M
;
2330 data
|= (~(p_agc_cfg
->speed
<<
2331 SCU_RAM_AGC_KI_RED_IAGC_RED__B
)
2332 & SCU_RAM_AGC_KI_RED_IAGC_RED__M
);
2334 status
= write16(state
, SCU_RAM_AGC_KI_RED__A
, data
);
2339 p_rf_agc_settings
= &state
->m_qam_rf_agc_cfg
;
2341 p_rf_agc_settings
= &state
->m_atv_rf_agc_cfg
;
2342 if (p_rf_agc_settings
== NULL
)
2345 status
= write16(state
, SCU_RAM_AGC_IF_IACCU_HI_TGT_MAX__A
,
2346 p_rf_agc_settings
->top
);
2351 case DRXK_AGC_CTRL_USER
:
2353 /* Enable IF AGC DAC */
2354 status
= read16(state
, IQM_AF_STDBY__A
, &data
);
2357 data
&= ~IQM_AF_STDBY_STDBY_TAGC_IF_STANDBY
;
2358 status
= write16(state
, IQM_AF_STDBY__A
, data
);
2362 status
= read16(state
, SCU_RAM_AGC_CONFIG__A
, &data
);
2366 /* Disable SCU IF AGC loop */
2367 data
|= SCU_RAM_AGC_CONFIG_DISABLE_IF_AGC__M
;
2370 if (state
->m_if_agc_pol
)
2371 data
|= SCU_RAM_AGC_CONFIG_INV_IF_POL__M
;
2373 data
&= ~SCU_RAM_AGC_CONFIG_INV_IF_POL__M
;
2374 status
= write16(state
, SCU_RAM_AGC_CONFIG__A
, data
);
2378 /* Write value to output pin */
2379 status
= write16(state
, SCU_RAM_AGC_IF_IACCU_HI_TGT_MAX__A
,
2380 p_agc_cfg
->output_level
);
2385 case DRXK_AGC_CTRL_OFF
:
2387 /* Disable If AGC DAC */
2388 status
= read16(state
, IQM_AF_STDBY__A
, &data
);
2391 data
|= IQM_AF_STDBY_STDBY_TAGC_IF_STANDBY
;
2392 status
= write16(state
, IQM_AF_STDBY__A
, data
);
2396 /* Disable SCU IF AGC loop */
2397 status
= read16(state
, SCU_RAM_AGC_CONFIG__A
, &data
);
2400 data
|= SCU_RAM_AGC_CONFIG_DISABLE_IF_AGC__M
;
2401 status
= write16(state
, SCU_RAM_AGC_CONFIG__A
, data
);
2405 } /* switch (agcSettingsIf->ctrl_mode) */
2407 /* always set the top to support
2408 configurations without if-loop */
2409 status
= write16(state
, SCU_RAM_AGC_INGAIN_TGT_MIN__A
, p_agc_cfg
->top
);
2412 pr_err("Error %d on %s\n", status
, __func__
);
2416 static int get_qam_signal_to_noise(struct drxk_state
*state
,
2417 s32
*p_signal_to_noise
)
2420 u16 qam_sl_err_power
= 0; /* accum. error between
2421 raw and sliced symbols */
2422 u32 qam_sl_sig_power
= 0; /* used for MER, depends of
2424 u32 qam_sl_mer
= 0; /* QAM MER */
2428 /* MER calculation */
2430 /* get the register value needed for MER */
2431 status
= read16(state
, QAM_SL_ERR_POWER__A
, &qam_sl_err_power
);
2433 pr_err("Error %d on %s\n", status
, __func__
);
2437 switch (state
->props
.modulation
) {
2439 qam_sl_sig_power
= DRXK_QAM_SL_SIG_POWER_QAM16
<< 2;
2442 qam_sl_sig_power
= DRXK_QAM_SL_SIG_POWER_QAM32
<< 2;
2445 qam_sl_sig_power
= DRXK_QAM_SL_SIG_POWER_QAM64
<< 2;
2448 qam_sl_sig_power
= DRXK_QAM_SL_SIG_POWER_QAM128
<< 2;
2452 qam_sl_sig_power
= DRXK_QAM_SL_SIG_POWER_QAM256
<< 2;
2456 if (qam_sl_err_power
> 0) {
2457 qam_sl_mer
= log10times100(qam_sl_sig_power
) -
2458 log10times100((u32
) qam_sl_err_power
);
2460 *p_signal_to_noise
= qam_sl_mer
;
2465 static int get_dvbt_signal_to_noise(struct drxk_state
*state
,
2466 s32
*p_signal_to_noise
)
2470 u32 eq_reg_td_sqr_err_i
= 0;
2471 u32 eq_reg_td_sqr_err_q
= 0;
2472 u16 eq_reg_td_sqr_err_exp
= 0;
2473 u16 eq_reg_td_tps_pwr_ofs
= 0;
2474 u16 eq_reg_td_req_smb_cnt
= 0;
2481 u16 transmission_params
= 0;
2485 status
= read16(state
, OFDM_EQ_TOP_TD_TPS_PWR_OFS__A
,
2486 &eq_reg_td_tps_pwr_ofs
);
2489 status
= read16(state
, OFDM_EQ_TOP_TD_REQ_SMB_CNT__A
,
2490 &eq_reg_td_req_smb_cnt
);
2493 status
= read16(state
, OFDM_EQ_TOP_TD_SQR_ERR_EXP__A
,
2494 &eq_reg_td_sqr_err_exp
);
2497 status
= read16(state
, OFDM_EQ_TOP_TD_SQR_ERR_I__A
,
2501 /* Extend SQR_ERR_I operational range */
2502 eq_reg_td_sqr_err_i
= (u32
) reg_data
;
2503 if ((eq_reg_td_sqr_err_exp
> 11) &&
2504 (eq_reg_td_sqr_err_i
< 0x00000FFFUL
)) {
2505 eq_reg_td_sqr_err_i
+= 0x00010000UL
;
2507 status
= read16(state
, OFDM_EQ_TOP_TD_SQR_ERR_Q__A
, ®_data
);
2510 /* Extend SQR_ERR_Q operational range */
2511 eq_reg_td_sqr_err_q
= (u32
) reg_data
;
2512 if ((eq_reg_td_sqr_err_exp
> 11) &&
2513 (eq_reg_td_sqr_err_q
< 0x00000FFFUL
))
2514 eq_reg_td_sqr_err_q
+= 0x00010000UL
;
2516 status
= read16(state
, OFDM_SC_RA_RAM_OP_PARAM__A
,
2517 &transmission_params
);
2521 /* Check input data for MER */
2523 /* MER calculation (in 0.1 dB) without math.h */
2524 if ((eq_reg_td_tps_pwr_ofs
== 0) || (eq_reg_td_req_smb_cnt
== 0))
2526 else if ((eq_reg_td_sqr_err_i
+ eq_reg_td_sqr_err_q
) == 0) {
2527 /* No error at all, this must be the HW reset value
2528 * Apparently no first measurement yet
2532 sqr_err_iq
= (eq_reg_td_sqr_err_i
+ eq_reg_td_sqr_err_q
) <<
2533 eq_reg_td_sqr_err_exp
;
2534 if ((transmission_params
&
2535 OFDM_SC_RA_RAM_OP_PARAM_MODE__M
)
2536 == OFDM_SC_RA_RAM_OP_PARAM_MODE_2K
)
2541 /* IMER = 100 * log10 (x)
2542 where x = (eq_reg_td_tps_pwr_ofs^2 *
2543 eq_reg_td_req_smb_cnt * tps_cnt)/sqr_err_iq
2546 where a = 100 * log10 (eq_reg_td_tps_pwr_ofs^2)
2547 b = 100 * log10 (eq_reg_td_req_smb_cnt * tps_cnt)
2548 c = 100 * log10 (sqr_err_iq)
2551 /* log(x) x = 9bits * 9bits->18 bits */
2552 a
= log10times100(eq_reg_td_tps_pwr_ofs
*
2553 eq_reg_td_tps_pwr_ofs
);
2554 /* log(x) x = 16bits * 7bits->23 bits */
2555 b
= log10times100(eq_reg_td_req_smb_cnt
* tps_cnt
);
2556 /* log(x) x = (16bits + 16bits) << 15 ->32 bits */
2557 c
= log10times100(sqr_err_iq
);
2561 *p_signal_to_noise
= i_mer
;
2565 pr_err("Error %d on %s\n", status
, __func__
);
2569 static int get_signal_to_noise(struct drxk_state
*state
, s32
*p_signal_to_noise
)
2573 *p_signal_to_noise
= 0;
2574 switch (state
->m_operation_mode
) {
2576 return get_dvbt_signal_to_noise(state
, p_signal_to_noise
);
2579 return get_qam_signal_to_noise(state
, p_signal_to_noise
);
2587 static int get_dvbt_quality(struct drxk_state
*state
, s32
*p_quality
)
2589 /* SNR Values for quasi errorfree reception rom Nordig 2.2 */
2594 static s32 QE_SN
[] = {
2600 108, /* 16-QAM 1/2 */
2601 131, /* 16-QAM 2/3 */
2602 146, /* 16-QAM 3/4 */
2603 156, /* 16-QAM 5/6 */
2604 160, /* 16-QAM 7/8 */
2605 165, /* 64-QAM 1/2 */
2606 187, /* 64-QAM 2/3 */
2607 202, /* 64-QAM 3/4 */
2608 216, /* 64-QAM 5/6 */
2609 225, /* 64-QAM 7/8 */
2615 s32 signal_to_noise
= 0;
2616 u16 constellation
= 0;
2618 u32 signal_to_noise_rel
;
2621 status
= get_dvbt_signal_to_noise(state
, &signal_to_noise
);
2624 status
= read16(state
, OFDM_EQ_TOP_TD_TPS_CONST__A
,
2628 constellation
&= OFDM_EQ_TOP_TD_TPS_CONST__M
;
2630 status
= read16(state
, OFDM_EQ_TOP_TD_TPS_CODE_HP__A
,
2634 code_rate
&= OFDM_EQ_TOP_TD_TPS_CODE_HP__M
;
2636 if (constellation
> OFDM_EQ_TOP_TD_TPS_CONST_64QAM
||
2637 code_rate
> OFDM_EQ_TOP_TD_TPS_CODE_LP_7_8
)
2639 signal_to_noise_rel
= signal_to_noise
-
2640 QE_SN
[constellation
* 5 + code_rate
];
2643 if (signal_to_noise_rel
< -70)
2645 else if (signal_to_noise_rel
< 30)
2646 *p_quality
= ((signal_to_noise_rel
+ 70) *
2649 *p_quality
= ber_quality
;
2654 static int get_dvbc_quality(struct drxk_state
*state
, s32
*p_quality
)
2662 u32 signal_to_noise
= 0;
2663 u32 ber_quality
= 100;
2664 u32 signal_to_noise_rel
= 0;
2666 status
= get_qam_signal_to_noise(state
, &signal_to_noise
);
2670 switch (state
->props
.modulation
) {
2672 signal_to_noise_rel
= signal_to_noise
- 200;
2675 signal_to_noise_rel
= signal_to_noise
- 230;
2676 break; /* Not in NorDig */
2678 signal_to_noise_rel
= signal_to_noise
- 260;
2681 signal_to_noise_rel
= signal_to_noise
- 290;
2685 signal_to_noise_rel
= signal_to_noise
- 320;
2689 if (signal_to_noise_rel
< -70)
2691 else if (signal_to_noise_rel
< 30)
2692 *p_quality
= ((signal_to_noise_rel
+ 70) *
2695 *p_quality
= ber_quality
;
2701 static int get_quality(struct drxk_state
*state
, s32
*p_quality
)
2705 switch (state
->m_operation_mode
) {
2707 return get_dvbt_quality(state
, p_quality
);
2709 return get_dvbc_quality(state
, p_quality
);
2718 /* Free data ram in SIO HI */
2719 #define SIO_HI_RA_RAM_USR_BEGIN__A 0x420040
2720 #define SIO_HI_RA_RAM_USR_END__A 0x420060
2722 #define DRXK_HI_ATOMIC_BUF_START (SIO_HI_RA_RAM_USR_BEGIN__A)
2723 #define DRXK_HI_ATOMIC_BUF_END (SIO_HI_RA_RAM_USR_BEGIN__A + 7)
2724 #define DRXK_HI_ATOMIC_READ SIO_HI_RA_RAM_PAR_3_ACP_RW_READ
2725 #define DRXK_HI_ATOMIC_WRITE SIO_HI_RA_RAM_PAR_3_ACP_RW_WRITE
2727 #define DRXDAP_FASI_ADDR2BLOCK(addr) (((addr) >> 22) & 0x3F)
2728 #define DRXDAP_FASI_ADDR2BANK(addr) (((addr) >> 16) & 0x3F)
2729 #define DRXDAP_FASI_ADDR2OFFSET(addr) ((addr) & 0x7FFF)
2731 static int ConfigureI2CBridge(struct drxk_state
*state
, bool b_enable_bridge
)
2733 int status
= -EINVAL
;
2737 if (state
->m_drxk_state
== DRXK_UNINITIALIZED
)
2739 if (state
->m_drxk_state
== DRXK_POWERED_DOWN
)
2742 if (state
->no_i2c_bridge
)
2745 status
= write16(state
, SIO_HI_RA_RAM_PAR_1__A
,
2746 SIO_HI_RA_RAM_PAR_1_PAR1_SEC_KEY
);
2749 if (b_enable_bridge
) {
2750 status
= write16(state
, SIO_HI_RA_RAM_PAR_2__A
,
2751 SIO_HI_RA_RAM_PAR_2_BRD_CFG_CLOSED
);
2755 status
= write16(state
, SIO_HI_RA_RAM_PAR_2__A
,
2756 SIO_HI_RA_RAM_PAR_2_BRD_CFG_OPEN
);
2761 status
= hi_command(state
, SIO_HI_RA_RAM_CMD_BRDCTRL
, NULL
);
2765 pr_err("Error %d on %s\n", status
, __func__
);
2769 static int set_pre_saw(struct drxk_state
*state
,
2770 struct s_cfg_pre_saw
*p_pre_saw_cfg
)
2772 int status
= -EINVAL
;
2776 if ((p_pre_saw_cfg
== NULL
)
2777 || (p_pre_saw_cfg
->reference
> IQM_AF_PDREF__M
))
2780 status
= write16(state
, IQM_AF_PDREF__A
, p_pre_saw_cfg
->reference
);
2783 pr_err("Error %d on %s\n", status
, __func__
);
2787 static int bl_direct_cmd(struct drxk_state
*state
, u32 target_addr
,
2788 u16 rom_offset
, u16 nr_of_elements
, u32 time_out
)
2791 u16 offset
= (u16
) ((target_addr
>> 0) & 0x00FFFF);
2792 u16 blockbank
= (u16
) ((target_addr
>> 16) & 0x000FFF);
2798 mutex_lock(&state
->mutex
);
2799 status
= write16(state
, SIO_BL_MODE__A
, SIO_BL_MODE_DIRECT
);
2802 status
= write16(state
, SIO_BL_TGT_HDR__A
, blockbank
);
2805 status
= write16(state
, SIO_BL_TGT_ADDR__A
, offset
);
2808 status
= write16(state
, SIO_BL_SRC_ADDR__A
, rom_offset
);
2811 status
= write16(state
, SIO_BL_SRC_LEN__A
, nr_of_elements
);
2814 status
= write16(state
, SIO_BL_ENABLE__A
, SIO_BL_ENABLE_ON
);
2818 end
= jiffies
+ msecs_to_jiffies(time_out
);
2820 status
= read16(state
, SIO_BL_STATUS__A
, &bl_status
);
2823 } while ((bl_status
== 0x1) && time_is_after_jiffies(end
));
2824 if (bl_status
== 0x1) {
2825 pr_err("SIO not ready\n");
2831 pr_err("Error %d on %s\n", status
, __func__
);
2833 mutex_unlock(&state
->mutex
);
2838 static int adc_sync_measurement(struct drxk_state
*state
, u16
*count
)
2845 /* start measurement */
2846 status
= write16(state
, IQM_AF_COMM_EXEC__A
, IQM_AF_COMM_EXEC_ACTIVE
);
2849 status
= write16(state
, IQM_AF_START_LOCK__A
, 1);
2854 status
= read16(state
, IQM_AF_PHASE0__A
, &data
);
2858 *count
= *count
+ 1;
2859 status
= read16(state
, IQM_AF_PHASE1__A
, &data
);
2863 *count
= *count
+ 1;
2864 status
= read16(state
, IQM_AF_PHASE2__A
, &data
);
2868 *count
= *count
+ 1;
2872 pr_err("Error %d on %s\n", status
, __func__
);
2876 static int adc_synchronization(struct drxk_state
*state
)
2883 status
= adc_sync_measurement(state
, &count
);
2888 /* Try sampling on a different edge */
2891 status
= read16(state
, IQM_AF_CLKNEG__A
, &clk_neg
);
2894 if ((clk_neg
& IQM_AF_CLKNEG_CLKNEGDATA__M
) ==
2895 IQM_AF_CLKNEG_CLKNEGDATA_CLK_ADC_DATA_POS
) {
2896 clk_neg
&= (~(IQM_AF_CLKNEG_CLKNEGDATA__M
));
2898 IQM_AF_CLKNEG_CLKNEGDATA_CLK_ADC_DATA_NEG
;
2900 clk_neg
&= (~(IQM_AF_CLKNEG_CLKNEGDATA__M
));
2902 IQM_AF_CLKNEG_CLKNEGDATA_CLK_ADC_DATA_POS
;
2904 status
= write16(state
, IQM_AF_CLKNEG__A
, clk_neg
);
2907 status
= adc_sync_measurement(state
, &count
);
2916 pr_err("Error %d on %s\n", status
, __func__
);
2920 static int set_frequency_shifter(struct drxk_state
*state
,
2921 u16 intermediate_freqk_hz
,
2922 s32 tuner_freq_offset
, bool is_dtv
)
2924 bool select_pos_image
= false;
2925 u32 rf_freq_residual
= tuner_freq_offset
;
2926 u32 fm_frequency_shift
= 0;
2927 bool tuner_mirror
= !state
->m_b_mirror_freq_spect
;
2932 u32 sampling_frequency
= (u32
) (state
->m_sys_clock_freq
/ 3);
2933 u32 frequency_shift
;
2934 bool image_to_select
;
2939 Program frequency shifter
2940 No need to account for mirroring on RF
2943 if ((state
->m_operation_mode
== OM_QAM_ITU_A
) ||
2944 (state
->m_operation_mode
== OM_QAM_ITU_C
) ||
2945 (state
->m_operation_mode
== OM_DVBT
))
2946 select_pos_image
= true;
2948 select_pos_image
= false;
2951 /* tuner doesn't mirror */
2952 if_freq_actual
= intermediate_freqk_hz
+
2953 rf_freq_residual
+ fm_frequency_shift
;
2956 if_freq_actual
= intermediate_freqk_hz
-
2957 rf_freq_residual
- fm_frequency_shift
;
2958 if (if_freq_actual
> sampling_frequency
/ 2) {
2960 adc_freq
= sampling_frequency
- if_freq_actual
;
2963 /* adc doesn't mirror */
2964 adc_freq
= if_freq_actual
;
2968 frequency_shift
= adc_freq
;
2969 image_to_select
= state
->m_rfmirror
^ tuner_mirror
^
2970 adc_flip
^ select_pos_image
;
2971 state
->m_iqm_fs_rate_ofs
=
2972 Frac28a((frequency_shift
), sampling_frequency
);
2974 if (image_to_select
)
2975 state
->m_iqm_fs_rate_ofs
= ~state
->m_iqm_fs_rate_ofs
+ 1;
2977 /* Program frequency shifter with tuner offset compensation */
2978 /* frequency_shift += tuner_freq_offset; TODO */
2979 status
= write32(state
, IQM_FS_RATE_OFS_LO__A
,
2980 state
->m_iqm_fs_rate_ofs
);
2982 pr_err("Error %d on %s\n", status
, __func__
);
2986 static int init_agc(struct drxk_state
*state
, bool is_dtv
)
2989 u16 ingain_tgt_min
= 0;
2990 u16 ingain_tgt_max
= 0;
2992 u16 clp_sum_min
= 0;
2994 u16 sns_sum_min
= 0;
2995 u16 sns_sum_max
= 0;
2996 u16 clp_sum_max
= 0;
2998 u16 ki_innergain_min
= 0;
2999 u16 if_iaccu_hi_tgt
= 0;
3000 u16 if_iaccu_hi_tgt_min
= 0;
3001 u16 if_iaccu_hi_tgt_max
= 0;
3003 u16 fast_clp_ctrl_delay
= 0;
3004 u16 clp_ctrl_mode
= 0;
3009 /* Common settings */
3011 if_iaccu_hi_tgt_min
= 2047;
3015 /* AGCInit() not available for DVBT; init done in microcode */
3016 if (!is_qam(state
)) {
3017 pr_err("%s: mode %d is not DVB-C\n",
3018 __func__
, state
->m_operation_mode
);
3022 /* FIXME: Analog TV AGC require different settings */
3024 /* Standard specific settings */
3026 clp_dir_to
= (u16
) -9;
3029 sns_dir_to
= (u16
) -9;
3030 ki_innergain_min
= (u16
) -1030;
3031 if_iaccu_hi_tgt_max
= 0x2380;
3032 if_iaccu_hi_tgt
= 0x2380;
3033 ingain_tgt_min
= 0x0511;
3034 ingain_tgt
= 0x0511;
3035 ingain_tgt_max
= 5119;
3036 fast_clp_ctrl_delay
= state
->m_qam_if_agc_cfg
.fast_clip_ctrl_delay
;
3038 status
= write16(state
, SCU_RAM_AGC_FAST_CLP_CTRL_DELAY__A
,
3039 fast_clp_ctrl_delay
);
3043 status
= write16(state
, SCU_RAM_AGC_CLP_CTRL_MODE__A
, clp_ctrl_mode
);
3046 status
= write16(state
, SCU_RAM_AGC_INGAIN_TGT__A
, ingain_tgt
);
3049 status
= write16(state
, SCU_RAM_AGC_INGAIN_TGT_MIN__A
, ingain_tgt_min
);
3052 status
= write16(state
, SCU_RAM_AGC_INGAIN_TGT_MAX__A
, ingain_tgt_max
);
3055 status
= write16(state
, SCU_RAM_AGC_IF_IACCU_HI_TGT_MIN__A
,
3056 if_iaccu_hi_tgt_min
);
3059 status
= write16(state
, SCU_RAM_AGC_IF_IACCU_HI_TGT_MAX__A
,
3060 if_iaccu_hi_tgt_max
);
3063 status
= write16(state
, SCU_RAM_AGC_IF_IACCU_HI__A
, 0);
3066 status
= write16(state
, SCU_RAM_AGC_IF_IACCU_LO__A
, 0);
3069 status
= write16(state
, SCU_RAM_AGC_RF_IACCU_HI__A
, 0);
3072 status
= write16(state
, SCU_RAM_AGC_RF_IACCU_LO__A
, 0);
3075 status
= write16(state
, SCU_RAM_AGC_CLP_SUM_MAX__A
, clp_sum_max
);
3078 status
= write16(state
, SCU_RAM_AGC_SNS_SUM_MAX__A
, sns_sum_max
);
3082 status
= write16(state
, SCU_RAM_AGC_KI_INNERGAIN_MIN__A
,
3086 status
= write16(state
, SCU_RAM_AGC_IF_IACCU_HI_TGT__A
,
3090 status
= write16(state
, SCU_RAM_AGC_CLP_CYCLEN__A
, clp_cyclen
);
3094 status
= write16(state
, SCU_RAM_AGC_RF_SNS_DEV_MAX__A
, 1023);
3097 status
= write16(state
, SCU_RAM_AGC_RF_SNS_DEV_MIN__A
, (u16
) -1023);
3100 status
= write16(state
, SCU_RAM_AGC_FAST_SNS_CTRL_DELAY__A
, 50);
3104 status
= write16(state
, SCU_RAM_AGC_KI_MAXMINGAIN_TH__A
, 20);
3107 status
= write16(state
, SCU_RAM_AGC_CLP_SUM_MIN__A
, clp_sum_min
);
3110 status
= write16(state
, SCU_RAM_AGC_SNS_SUM_MIN__A
, sns_sum_min
);
3113 status
= write16(state
, SCU_RAM_AGC_CLP_DIR_TO__A
, clp_dir_to
);
3116 status
= write16(state
, SCU_RAM_AGC_SNS_DIR_TO__A
, sns_dir_to
);
3119 status
= write16(state
, SCU_RAM_AGC_KI_MINGAIN__A
, 0x7fff);
3122 status
= write16(state
, SCU_RAM_AGC_KI_MAXGAIN__A
, 0x0);
3125 status
= write16(state
, SCU_RAM_AGC_KI_MIN__A
, 0x0117);
3128 status
= write16(state
, SCU_RAM_AGC_KI_MAX__A
, 0x0657);
3131 status
= write16(state
, SCU_RAM_AGC_CLP_SUM__A
, 0);
3134 status
= write16(state
, SCU_RAM_AGC_CLP_CYCCNT__A
, 0);
3137 status
= write16(state
, SCU_RAM_AGC_CLP_DIR_WD__A
, 0);
3140 status
= write16(state
, SCU_RAM_AGC_CLP_DIR_STP__A
, 1);
3143 status
= write16(state
, SCU_RAM_AGC_SNS_SUM__A
, 0);
3146 status
= write16(state
, SCU_RAM_AGC_SNS_CYCCNT__A
, 0);
3149 status
= write16(state
, SCU_RAM_AGC_SNS_DIR_WD__A
, 0);
3152 status
= write16(state
, SCU_RAM_AGC_SNS_DIR_STP__A
, 1);
3155 status
= write16(state
, SCU_RAM_AGC_SNS_CYCLEN__A
, 500);
3158 status
= write16(state
, SCU_RAM_AGC_KI_CYCLEN__A
, 500);
3162 /* Initialize inner-loop KI gain factors */
3163 status
= read16(state
, SCU_RAM_AGC_KI__A
, &data
);
3168 data
&= ~SCU_RAM_AGC_KI_RF__M
;
3169 data
|= (DRXK_KI_RAGC_QAM
<< SCU_RAM_AGC_KI_RF__B
);
3170 data
&= ~SCU_RAM_AGC_KI_IF__M
;
3171 data
|= (DRXK_KI_IAGC_QAM
<< SCU_RAM_AGC_KI_IF__B
);
3173 status
= write16(state
, SCU_RAM_AGC_KI__A
, data
);
3176 pr_err("Error %d on %s\n", status
, __func__
);
3180 static int dvbtqam_get_acc_pkt_err(struct drxk_state
*state
, u16
*packet_err
)
3185 if (packet_err
== NULL
)
3186 status
= write16(state
, SCU_RAM_FEC_ACCUM_PKT_FAILURES__A
, 0);
3188 status
= read16(state
, SCU_RAM_FEC_ACCUM_PKT_FAILURES__A
,
3191 pr_err("Error %d on %s\n", status
, __func__
);
3195 static int dvbt_sc_command(struct drxk_state
*state
,
3196 u16 cmd
, u16 subcmd
,
3197 u16 param0
, u16 param1
, u16 param2
,
3198 u16 param3
, u16 param4
)
3207 status
= read16(state
, OFDM_SC_COMM_EXEC__A
, &sc_exec
);
3209 /* SC is not running */
3215 /* Wait until sc is ready to receive command */
3218 usleep_range(1000, 2000);
3219 status
= read16(state
, OFDM_SC_RA_RAM_CMD__A
, &cur_cmd
);
3221 } while ((cur_cmd
!= 0) && (retry_cnt
< DRXK_MAX_RETRIES
));
3222 if (retry_cnt
>= DRXK_MAX_RETRIES
&& (status
< 0))
3225 /* Write sub-command */
3227 /* All commands using sub-cmd */
3228 case OFDM_SC_RA_RAM_CMD_PROC_START
:
3229 case OFDM_SC_RA_RAM_CMD_SET_PREF_PARAM
:
3230 case OFDM_SC_RA_RAM_CMD_PROGRAM_PARAM
:
3231 status
= write16(state
, OFDM_SC_RA_RAM_CMD_ADDR__A
, subcmd
);
3240 /* Write needed parameters and the command */
3243 /* All commands using 5 parameters */
3244 /* All commands using 4 parameters */
3245 /* All commands using 3 parameters */
3246 /* All commands using 2 parameters */
3247 case OFDM_SC_RA_RAM_CMD_PROC_START
:
3248 case OFDM_SC_RA_RAM_CMD_SET_PREF_PARAM
:
3249 case OFDM_SC_RA_RAM_CMD_PROGRAM_PARAM
:
3250 status
|= write16(state
, OFDM_SC_RA_RAM_PARAM1__A
, param1
);
3251 fallthrough
; /* All commands using 1 parameters */
3252 case OFDM_SC_RA_RAM_CMD_SET_ECHO_TIMING
:
3253 case OFDM_SC_RA_RAM_CMD_USER_IO
:
3254 status
|= write16(state
, OFDM_SC_RA_RAM_PARAM0__A
, param0
);
3255 fallthrough
; /* All commands using 0 parameters */
3256 case OFDM_SC_RA_RAM_CMD_GET_OP_PARAM
:
3257 case OFDM_SC_RA_RAM_CMD_NULL
:
3259 status
|= write16(state
, OFDM_SC_RA_RAM_CMD__A
, cmd
);
3262 /* Unknown command */
3268 /* Wait until sc is ready processing command */
3271 usleep_range(1000, 2000);
3272 status
= read16(state
, OFDM_SC_RA_RAM_CMD__A
, &cur_cmd
);
3274 } while ((cur_cmd
!= 0) && (retry_cnt
< DRXK_MAX_RETRIES
));
3275 if (retry_cnt
>= DRXK_MAX_RETRIES
&& (status
< 0))
3278 /* Check for illegal cmd */
3279 status
= read16(state
, OFDM_SC_RA_RAM_CMD_ADDR__A
, &err_code
);
3280 if (err_code
== 0xFFFF) {
3281 /* illegal command */
3287 /* Retrieve results parameters from SC */
3289 /* All commands yielding 5 results */
3290 /* All commands yielding 4 results */
3291 /* All commands yielding 3 results */
3292 /* All commands yielding 2 results */
3293 /* All commands yielding 1 result */
3294 case OFDM_SC_RA_RAM_CMD_USER_IO
:
3295 case OFDM_SC_RA_RAM_CMD_GET_OP_PARAM
:
3296 status
= read16(state
, OFDM_SC_RA_RAM_PARAM0__A
, &(param0
));
3297 /* All commands yielding 0 results */
3298 case OFDM_SC_RA_RAM_CMD_SET_ECHO_TIMING
:
3299 case OFDM_SC_RA_RAM_CMD_SET_TIMER
:
3300 case OFDM_SC_RA_RAM_CMD_PROC_START
:
3301 case OFDM_SC_RA_RAM_CMD_SET_PREF_PARAM
:
3302 case OFDM_SC_RA_RAM_CMD_PROGRAM_PARAM
:
3303 case OFDM_SC_RA_RAM_CMD_NULL
:
3306 /* Unknown command */
3309 } /* switch (cmd->cmd) */
3312 pr_err("Error %d on %s\n", status
, __func__
);
3316 static int power_up_dvbt(struct drxk_state
*state
)
3318 enum drx_power_mode power_mode
= DRX_POWER_UP
;
3322 status
= ctrl_power_mode(state
, &power_mode
);
3324 pr_err("Error %d on %s\n", status
, __func__
);
3328 static int dvbt_ctrl_set_inc_enable(struct drxk_state
*state
, bool *enabled
)
3334 status
= write16(state
, IQM_CF_BYPASSDET__A
, 0);
3336 status
= write16(state
, IQM_CF_BYPASSDET__A
, 1);
3338 pr_err("Error %d on %s\n", status
, __func__
);
3342 #define DEFAULT_FR_THRES_8K 4000
3343 static int dvbt_ctrl_set_fr_enable(struct drxk_state
*state
, bool *enabled
)
3350 /* write mask to 1 */
3351 status
= write16(state
, OFDM_SC_RA_RAM_FR_THRES_8K__A
,
3352 DEFAULT_FR_THRES_8K
);
3354 /* write mask to 0 */
3355 status
= write16(state
, OFDM_SC_RA_RAM_FR_THRES_8K__A
, 0);
3358 pr_err("Error %d on %s\n", status
, __func__
);
3363 static int dvbt_ctrl_set_echo_threshold(struct drxk_state
*state
,
3364 struct drxk_cfg_dvbt_echo_thres_t
*echo_thres
)
3370 status
= read16(state
, OFDM_SC_RA_RAM_ECHO_THRES__A
, &data
);
3374 switch (echo_thres
->fft_mode
) {
3375 case DRX_FFTMODE_2K
:
3376 data
&= ~OFDM_SC_RA_RAM_ECHO_THRES_2K__M
;
3377 data
|= ((echo_thres
->threshold
<<
3378 OFDM_SC_RA_RAM_ECHO_THRES_2K__B
)
3379 & (OFDM_SC_RA_RAM_ECHO_THRES_2K__M
));
3381 case DRX_FFTMODE_8K
:
3382 data
&= ~OFDM_SC_RA_RAM_ECHO_THRES_8K__M
;
3383 data
|= ((echo_thres
->threshold
<<
3384 OFDM_SC_RA_RAM_ECHO_THRES_8K__B
)
3385 & (OFDM_SC_RA_RAM_ECHO_THRES_8K__M
));
3391 status
= write16(state
, OFDM_SC_RA_RAM_ECHO_THRES__A
, data
);
3394 pr_err("Error %d on %s\n", status
, __func__
);
3398 static int dvbt_ctrl_set_sqi_speed(struct drxk_state
*state
,
3399 enum drxk_cfg_dvbt_sqi_speed
*speed
)
3401 int status
= -EINVAL
;
3406 case DRXK_DVBT_SQI_SPEED_FAST
:
3407 case DRXK_DVBT_SQI_SPEED_MEDIUM
:
3408 case DRXK_DVBT_SQI_SPEED_SLOW
:
3413 status
= write16(state
, SCU_RAM_FEC_PRE_RS_BER_FILTER_SH__A
,
3417 pr_err("Error %d on %s\n", status
, __func__
);
3421 /*============================================================================*/
3424 * \brief Activate DVBT specific presets
3425 * \param demod instance of demodulator.
3426 * \return DRXStatus_t.
3428 * Called in DVBTSetStandard
3431 static int dvbt_activate_presets(struct drxk_state
*state
)
3434 bool setincenable
= false;
3435 bool setfrenable
= true;
3437 struct drxk_cfg_dvbt_echo_thres_t echo_thres2k
= { 0, DRX_FFTMODE_2K
};
3438 struct drxk_cfg_dvbt_echo_thres_t echo_thres8k
= { 0, DRX_FFTMODE_8K
};
3441 status
= dvbt_ctrl_set_inc_enable(state
, &setincenable
);
3444 status
= dvbt_ctrl_set_fr_enable(state
, &setfrenable
);
3447 status
= dvbt_ctrl_set_echo_threshold(state
, &echo_thres2k
);
3450 status
= dvbt_ctrl_set_echo_threshold(state
, &echo_thres8k
);
3453 status
= write16(state
, SCU_RAM_AGC_INGAIN_TGT_MAX__A
,
3454 state
->m_dvbt_if_agc_cfg
.ingain_tgt_max
);
3457 pr_err("Error %d on %s\n", status
, __func__
);
3461 /*============================================================================*/
3464 * \brief Initialize channelswitch-independent settings for DVBT.
3465 * \param demod instance of demodulator.
3466 * \return DRXStatus_t.
3468 * For ROM code channel filter taps are loaded from the bootloader. For microcode
3469 * the DVB-T taps from the drxk_filters.h are used.
3471 static int set_dvbt_standard(struct drxk_state
*state
,
3472 enum operation_mode o_mode
)
3480 power_up_dvbt(state
);
3481 /* added antenna switch */
3482 switch_antenna_to_dvbt(state
);
3483 /* send OFDM reset command */
3484 status
= scu_command(state
,
3485 SCU_RAM_COMMAND_STANDARD_OFDM
3486 | SCU_RAM_COMMAND_CMD_DEMOD_RESET
,
3487 0, NULL
, 1, &cmd_result
);
3491 /* send OFDM setenv command */
3492 status
= scu_command(state
, SCU_RAM_COMMAND_STANDARD_OFDM
3493 | SCU_RAM_COMMAND_CMD_DEMOD_SET_ENV
,
3494 0, NULL
, 1, &cmd_result
);
3498 /* reset datapath for OFDM, processors first */
3499 status
= write16(state
, OFDM_SC_COMM_EXEC__A
, OFDM_SC_COMM_EXEC_STOP
);
3502 status
= write16(state
, OFDM_LC_COMM_EXEC__A
, OFDM_LC_COMM_EXEC_STOP
);
3505 status
= write16(state
, IQM_COMM_EXEC__A
, IQM_COMM_EXEC_B_STOP
);
3510 /* synchronize on ofdstate->m_festart */
3511 status
= write16(state
, IQM_AF_UPD_SEL__A
, 1);
3514 /* window size for clipping ADC detection */
3515 status
= write16(state
, IQM_AF_CLP_LEN__A
, 0);
3518 /* window size for for sense pre-SAW detection */
3519 status
= write16(state
, IQM_AF_SNS_LEN__A
, 0);
3522 /* sense threshold for sense pre-SAW detection */
3523 status
= write16(state
, IQM_AF_AMUX__A
, IQM_AF_AMUX_SIGNAL2ADC
);
3526 status
= set_iqm_af(state
, true);
3530 status
= write16(state
, IQM_AF_AGC_RF__A
, 0);
3534 /* Impulse noise cruncher setup */
3535 status
= write16(state
, IQM_AF_INC_LCT__A
, 0); /* crunch in IQM_CF */
3538 status
= write16(state
, IQM_CF_DET_LCT__A
, 0); /* detect in IQM_CF */
3541 status
= write16(state
, IQM_CF_WND_LEN__A
, 3); /* peak detector window length */
3545 status
= write16(state
, IQM_RC_STRETCH__A
, 16);
3548 status
= write16(state
, IQM_CF_OUT_ENA__A
, 0x4); /* enable output 2 */
3551 status
= write16(state
, IQM_CF_DS_ENA__A
, 0x4); /* decimate output 2 */
3554 status
= write16(state
, IQM_CF_SCALE__A
, 1600);
3557 status
= write16(state
, IQM_CF_SCALE_SH__A
, 0);
3561 /* virtual clipping threshold for clipping ADC detection */
3562 status
= write16(state
, IQM_AF_CLP_TH__A
, 448);
3565 status
= write16(state
, IQM_CF_DATATH__A
, 495); /* crunching threshold */
3569 status
= bl_chain_cmd(state
, DRXK_BL_ROM_OFFSET_TAPS_DVBT
,
3570 DRXK_BLCC_NR_ELEMENTS_TAPS
, DRXK_BLC_TIMEOUT
);
3574 status
= write16(state
, IQM_CF_PKDTH__A
, 2); /* peak detector threshold */
3577 status
= write16(state
, IQM_CF_POW_MEAS_LEN__A
, 2);
3580 /* enable power measurement interrupt */
3581 status
= write16(state
, IQM_CF_COMM_INT_MSK__A
, 1);
3584 status
= write16(state
, IQM_COMM_EXEC__A
, IQM_COMM_EXEC_B_ACTIVE
);
3588 /* IQM will not be reset from here, sync ADC and update/init AGC */
3589 status
= adc_synchronization(state
);
3592 status
= set_pre_saw(state
, &state
->m_dvbt_pre_saw_cfg
);
3596 /* Halt SCU to enable safe non-atomic accesses */
3597 status
= write16(state
, SCU_COMM_EXEC__A
, SCU_COMM_EXEC_HOLD
);
3601 status
= set_agc_rf(state
, &state
->m_dvbt_rf_agc_cfg
, true);
3604 status
= set_agc_if(state
, &state
->m_dvbt_if_agc_cfg
, true);
3608 /* Set Noise Estimation notch width and enable DC fix */
3609 status
= read16(state
, OFDM_SC_RA_RAM_CONFIG__A
, &data
);
3612 data
|= OFDM_SC_RA_RAM_CONFIG_NE_FIX_ENABLE__M
;
3613 status
= write16(state
, OFDM_SC_RA_RAM_CONFIG__A
, data
);
3617 /* Activate SCU to enable SCU commands */
3618 status
= write16(state
, SCU_COMM_EXEC__A
, SCU_COMM_EXEC_ACTIVE
);
3622 if (!state
->m_drxk_a3_rom_code
) {
3623 /* AGCInit() is not done for DVBT, so set agcfast_clip_ctrl_delay */
3624 status
= write16(state
, SCU_RAM_AGC_FAST_CLP_CTRL_DELAY__A
,
3625 state
->m_dvbt_if_agc_cfg
.fast_clip_ctrl_delay
);
3631 #ifdef COMPILE_FOR_NONRT
3632 status
= write16(state
, OFDM_SC_RA_RAM_BE_OPT_DELAY__A
, 1);
3635 status
= write16(state
, OFDM_SC_RA_RAM_BE_OPT_INIT_DELAY__A
, 2);
3641 status
= write16(state
, FEC_DI_INPUT_CTL__A
, 1); /* OFDM input */
3646 #ifdef COMPILE_FOR_NONRT
3647 status
= write16(state
, FEC_RS_MEASUREMENT_PERIOD__A
, 0x400);
3651 status
= write16(state
, FEC_RS_MEASUREMENT_PERIOD__A
, 0x1000);
3655 status
= write16(state
, FEC_RS_MEASUREMENT_PRESCALE__A
, 0x0001);
3659 /* Setup MPEG bus */
3660 status
= mpegts_dto_setup(state
, OM_DVBT
);
3663 /* Set DVBT Presets */
3664 status
= dvbt_activate_presets(state
);
3670 pr_err("Error %d on %s\n", status
, __func__
);
3674 /*============================================================================*/
3676 * \brief start dvbt demodulating for channel.
3677 * \param demod instance of demodulator.
3678 * \return DRXStatus_t.
3680 static int dvbt_start(struct drxk_state
*state
)
3684 /* drxk_ofdm_sc_cmd_t scCmd; */
3687 /* start correct processes to get in lock */
3688 /* DRXK: OFDM_SC_RA_RAM_PROC_LOCKTRACK is no longer in mapfile! */
3689 param1
= OFDM_SC_RA_RAM_LOCKTRACK_MIN
;
3690 status
= dvbt_sc_command(state
, OFDM_SC_RA_RAM_CMD_PROC_START
, 0,
3691 OFDM_SC_RA_RAM_SW_EVENT_RUN_NMASK__M
, param1
,
3696 status
= mpegts_start(state
);
3699 status
= write16(state
, FEC_COMM_EXEC__A
, FEC_COMM_EXEC_ACTIVE
);
3704 pr_err("Error %d on %s\n", status
, __func__
);
3709 /*============================================================================*/
3712 * \brief Set up dvbt demodulator for channel.
3713 * \param demod instance of demodulator.
3714 * \return DRXStatus_t.
3715 * // original DVBTSetChannel()
3717 static int set_dvbt(struct drxk_state
*state
, u16 intermediate_freqk_hz
,
3718 s32 tuner_freq_offset
)
3721 u16 transmission_params
= 0;
3722 u16 operation_mode
= 0;
3723 u32 iqm_rc_rate_ofs
= 0;
3728 dprintk(1, "IF =%d, TFO = %d\n",
3729 intermediate_freqk_hz
, tuner_freq_offset
);
3731 status
= scu_command(state
, SCU_RAM_COMMAND_STANDARD_OFDM
3732 | SCU_RAM_COMMAND_CMD_DEMOD_STOP
,
3733 0, NULL
, 1, &cmd_result
);
3737 /* Halt SCU to enable safe non-atomic accesses */
3738 status
= write16(state
, SCU_COMM_EXEC__A
, SCU_COMM_EXEC_HOLD
);
3742 /* Stop processors */
3743 status
= write16(state
, OFDM_SC_COMM_EXEC__A
, OFDM_SC_COMM_EXEC_STOP
);
3746 status
= write16(state
, OFDM_LC_COMM_EXEC__A
, OFDM_LC_COMM_EXEC_STOP
);
3750 /* Mandatory fix, always stop CP, required to set spl offset back to
3751 hardware default (is set to 0 by ucode during pilot detection */
3752 status
= write16(state
, OFDM_CP_COMM_EXEC__A
, OFDM_CP_COMM_EXEC_STOP
);
3756 /*== Write channel settings to device ================================*/
3759 switch (state
->props
.transmission_mode
) {
3760 case TRANSMISSION_MODE_AUTO
:
3762 operation_mode
|= OFDM_SC_RA_RAM_OP_AUTO_MODE__M
;
3763 fallthrough
; /* try first guess DRX_FFTMODE_8K */
3764 case TRANSMISSION_MODE_8K
:
3765 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_MODE_8K
;
3767 case TRANSMISSION_MODE_2K
:
3768 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_MODE_2K
;
3773 switch (state
->props
.guard_interval
) {
3775 case GUARD_INTERVAL_AUTO
:
3776 operation_mode
|= OFDM_SC_RA_RAM_OP_AUTO_GUARD__M
;
3777 fallthrough
; /* try first guess DRX_GUARD_1DIV4 */
3778 case GUARD_INTERVAL_1_4
:
3779 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_GUARD_4
;
3781 case GUARD_INTERVAL_1_32
:
3782 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_GUARD_32
;
3784 case GUARD_INTERVAL_1_16
:
3785 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_GUARD_16
;
3787 case GUARD_INTERVAL_1_8
:
3788 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_GUARD_8
;
3793 switch (state
->props
.hierarchy
) {
3794 case HIERARCHY_AUTO
:
3795 case HIERARCHY_NONE
:
3797 operation_mode
|= OFDM_SC_RA_RAM_OP_AUTO_HIER__M
;
3798 /* try first guess SC_RA_RAM_OP_PARAM_HIER_NO */
3799 /* transmission_params |= OFDM_SC_RA_RAM_OP_PARAM_HIER_NO; */
3802 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_HIER_A1
;
3805 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_HIER_A2
;
3808 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_HIER_A4
;
3814 switch (state
->props
.modulation
) {
3817 operation_mode
|= OFDM_SC_RA_RAM_OP_AUTO_CONST__M
;
3818 fallthrough
; /* try first guess DRX_CONSTELLATION_QAM64 */
3820 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_CONST_QAM64
;
3823 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_CONST_QPSK
;
3826 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_CONST_QAM16
;
3830 /* No hierarchical channels support in BDA */
3831 /* Priority (only for hierarchical channels) */
3832 switch (channel
->priority
) {
3833 case DRX_PRIORITY_LOW
:
3834 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_PRIO_LO
;
3835 WR16(dev_addr
, OFDM_EC_SB_PRIOR__A
,
3836 OFDM_EC_SB_PRIOR_LO
);
3838 case DRX_PRIORITY_HIGH
:
3839 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_PRIO_HI
;
3840 WR16(dev_addr
, OFDM_EC_SB_PRIOR__A
,
3841 OFDM_EC_SB_PRIOR_HI
));
3843 case DRX_PRIORITY_UNKNOWN
:
3849 /* Set Priority high */
3850 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_PRIO_HI
;
3851 status
= write16(state
, OFDM_EC_SB_PRIOR__A
, OFDM_EC_SB_PRIOR_HI
);
3857 switch (state
->props
.code_rate_HP
) {
3860 operation_mode
|= OFDM_SC_RA_RAM_OP_AUTO_RATE__M
;
3861 fallthrough
; /* try first guess DRX_CODERATE_2DIV3 */
3863 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_RATE_2_3
;
3866 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_RATE_1_2
;
3869 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_RATE_3_4
;
3872 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_RATE_5_6
;
3875 transmission_params
|= OFDM_SC_RA_RAM_OP_PARAM_RATE_7_8
;
3880 * SAW filter selection: normally not necessary, but if wanted
3881 * the application can select a SAW filter via the driver by
3885 /* First determine real bandwidth (Hz) */
3886 /* Also set delay for impulse noise cruncher */
3888 * Also set parameters for EC_OC fix, note EC_OC_REG_TMD_HIL_MAR is
3889 * changed by SC for fix for some 8K,1/8 guard but is restored by
3890 * InitEC and ResetEC functions
3892 switch (state
->props
.bandwidth_hz
) {
3894 state
->props
.bandwidth_hz
= 8000000;
3897 bandwidth
= DRXK_BANDWIDTH_8MHZ_IN_HZ
;
3898 status
= write16(state
, OFDM_SC_RA_RAM_SRMM_FIX_FACT_8K__A
,
3902 /* cochannel protection for PAL 8 MHz */
3903 status
= write16(state
, OFDM_SC_RA_RAM_NI_INIT_8K_PER_LEFT__A
,
3907 status
= write16(state
, OFDM_SC_RA_RAM_NI_INIT_8K_PER_RIGHT__A
,
3911 status
= write16(state
, OFDM_SC_RA_RAM_NI_INIT_2K_PER_LEFT__A
,
3915 status
= write16(state
, OFDM_SC_RA_RAM_NI_INIT_2K_PER_RIGHT__A
,
3921 bandwidth
= DRXK_BANDWIDTH_7MHZ_IN_HZ
;
3922 status
= write16(state
, OFDM_SC_RA_RAM_SRMM_FIX_FACT_8K__A
,
3926 /* cochannel protection for PAL 7 MHz */
3927 status
= write16(state
, OFDM_SC_RA_RAM_NI_INIT_8K_PER_LEFT__A
,
3931 status
= write16(state
, OFDM_SC_RA_RAM_NI_INIT_8K_PER_RIGHT__A
,
3935 status
= write16(state
, OFDM_SC_RA_RAM_NI_INIT_2K_PER_LEFT__A
,
3939 status
= write16(state
, OFDM_SC_RA_RAM_NI_INIT_2K_PER_RIGHT__A
,
3945 bandwidth
= DRXK_BANDWIDTH_6MHZ_IN_HZ
;
3946 status
= write16(state
, OFDM_SC_RA_RAM_SRMM_FIX_FACT_8K__A
,
3950 /* cochannel protection for NTSC 6 MHz */
3951 status
= write16(state
, OFDM_SC_RA_RAM_NI_INIT_8K_PER_LEFT__A
,
3955 status
= write16(state
, OFDM_SC_RA_RAM_NI_INIT_8K_PER_RIGHT__A
,
3959 status
= write16(state
, OFDM_SC_RA_RAM_NI_INIT_2K_PER_LEFT__A
,
3963 status
= write16(state
, OFDM_SC_RA_RAM_NI_INIT_2K_PER_RIGHT__A
,
3973 if (iqm_rc_rate_ofs
== 0) {
3974 /* Now compute IQM_RC_RATE_OFS
3975 (((SysFreq/BandWidth)/2)/2) -1) * 2^23)
3977 ((SysFreq / BandWidth) * (2^21)) - (2^23)
3979 /* (SysFreq / BandWidth) * (2^28) */
3981 * assert (MAX(sysClk)/MIN(bandwidth) < 16)
3982 * => assert(MAX(sysClk) < 16*MIN(bandwidth))
3983 * => assert(109714272 > 48000000) = true
3984 * so Frac 28 can be used
3986 iqm_rc_rate_ofs
= Frac28a((u32
)
3987 ((state
->m_sys_clock_freq
*
3988 1000) / 3), bandwidth
);
3989 /* (SysFreq / BandWidth) * (2^21), rounding before truncating */
3990 if ((iqm_rc_rate_ofs
& 0x7fL
) >= 0x40)
3991 iqm_rc_rate_ofs
+= 0x80L
;
3992 iqm_rc_rate_ofs
= iqm_rc_rate_ofs
>> 7;
3993 /* ((SysFreq / BandWidth) * (2^21)) - (2^23) */
3994 iqm_rc_rate_ofs
= iqm_rc_rate_ofs
- (1 << 23);
3998 ((((u32
) IQM_RC_RATE_OFS_HI__M
) <<
3999 IQM_RC_RATE_OFS_LO__W
) | IQM_RC_RATE_OFS_LO__M
);
4000 status
= write32(state
, IQM_RC_RATE_OFS_LO__A
, iqm_rc_rate_ofs
);
4004 /* Bandwidth setting done */
4007 status
= dvbt_set_frequency_shift(demod
, channel
, tuner_offset
);
4011 status
= set_frequency_shifter(state
, intermediate_freqk_hz
,
4012 tuner_freq_offset
, true);
4016 /*== start SC, write channel settings to SC ==========================*/
4018 /* Activate SCU to enable SCU commands */
4019 status
= write16(state
, SCU_COMM_EXEC__A
, SCU_COMM_EXEC_ACTIVE
);
4023 /* Enable SC after setting all other parameters */
4024 status
= write16(state
, OFDM_SC_COMM_STATE__A
, 0);
4027 status
= write16(state
, OFDM_SC_COMM_EXEC__A
, 1);
4032 status
= scu_command(state
, SCU_RAM_COMMAND_STANDARD_OFDM
4033 | SCU_RAM_COMMAND_CMD_DEMOD_START
,
4034 0, NULL
, 1, &cmd_result
);
4038 /* Write SC parameter registers, set all AUTO flags in operation mode */
4039 param1
= (OFDM_SC_RA_RAM_OP_AUTO_MODE__M
|
4040 OFDM_SC_RA_RAM_OP_AUTO_GUARD__M
|
4041 OFDM_SC_RA_RAM_OP_AUTO_CONST__M
|
4042 OFDM_SC_RA_RAM_OP_AUTO_HIER__M
|
4043 OFDM_SC_RA_RAM_OP_AUTO_RATE__M
);
4044 status
= dvbt_sc_command(state
, OFDM_SC_RA_RAM_CMD_SET_PREF_PARAM
,
4045 0, transmission_params
, param1
, 0, 0, 0);
4049 if (!state
->m_drxk_a3_rom_code
)
4050 status
= dvbt_ctrl_set_sqi_speed(state
, &state
->m_sqi_speed
);
4053 pr_err("Error %d on %s\n", status
, __func__
);
4059 /*============================================================================*/
4062 * \brief Retrieve lock status .
4063 * \param demod Pointer to demodulator instance.
4064 * \param lockStat Pointer to lock status structure.
4065 * \return DRXStatus_t.
4068 static int get_dvbt_lock_status(struct drxk_state
*state
, u32
*p_lock_status
)
4071 const u16 mpeg_lock_mask
= (OFDM_SC_RA_RAM_LOCK_MPEG__M
|
4072 OFDM_SC_RA_RAM_LOCK_FEC__M
);
4073 const u16 fec_lock_mask
= (OFDM_SC_RA_RAM_LOCK_FEC__M
);
4074 const u16 demod_lock_mask
= OFDM_SC_RA_RAM_LOCK_DEMOD__M
;
4076 u16 sc_ra_ram_lock
= 0;
4077 u16 sc_comm_exec
= 0;
4081 *p_lock_status
= NOT_LOCKED
;
4083 /* Check if SC is running */
4084 status
= read16(state
, OFDM_SC_COMM_EXEC__A
, &sc_comm_exec
);
4087 if (sc_comm_exec
== OFDM_SC_COMM_EXEC_STOP
)
4090 status
= read16(state
, OFDM_SC_RA_RAM_LOCK__A
, &sc_ra_ram_lock
);
4094 if ((sc_ra_ram_lock
& mpeg_lock_mask
) == mpeg_lock_mask
)
4095 *p_lock_status
= MPEG_LOCK
;
4096 else if ((sc_ra_ram_lock
& fec_lock_mask
) == fec_lock_mask
)
4097 *p_lock_status
= FEC_LOCK
;
4098 else if ((sc_ra_ram_lock
& demod_lock_mask
) == demod_lock_mask
)
4099 *p_lock_status
= DEMOD_LOCK
;
4100 else if (sc_ra_ram_lock
& OFDM_SC_RA_RAM_LOCK_NODVBT__M
)
4101 *p_lock_status
= NEVER_LOCK
;
4104 pr_err("Error %d on %s\n", status
, __func__
);
4109 static int power_up_qam(struct drxk_state
*state
)
4111 enum drx_power_mode power_mode
= DRXK_POWER_DOWN_OFDM
;
4115 status
= ctrl_power_mode(state
, &power_mode
);
4117 pr_err("Error %d on %s\n", status
, __func__
);
4123 /* Power Down QAM */
4124 static int power_down_qam(struct drxk_state
*state
)
4131 status
= read16(state
, SCU_COMM_EXEC__A
, &data
);
4134 if (data
== SCU_COMM_EXEC_ACTIVE
) {
4139 /* stop all comstate->m_exec */
4140 status
= write16(state
, QAM_COMM_EXEC__A
, QAM_COMM_EXEC_STOP
);
4143 status
= scu_command(state
, SCU_RAM_COMMAND_STANDARD_QAM
4144 | SCU_RAM_COMMAND_CMD_DEMOD_STOP
,
4145 0, NULL
, 1, &cmd_result
);
4150 status
= set_iqm_af(state
, false);
4154 pr_err("Error %d on %s\n", status
, __func__
);
4159 /*============================================================================*/
4162 * \brief Setup of the QAM Measurement intervals for signal quality
4163 * \param demod instance of demod.
4164 * \param modulation current modulation.
4165 * \return DRXStatus_t.
4168 * Take into account that for certain settings the errorcounters can overflow.
4169 * The implementation does not check this.
4172 static int set_qam_measurement(struct drxk_state
*state
,
4173 enum e_drxk_constellation modulation
,
4176 u32 fec_bits_desired
= 0; /* BER accounting period */
4177 u32 fec_rs_period_total
= 0; /* Total period */
4178 u16 fec_rs_prescale
= 0; /* ReedSolomon Measurement Prescale */
4179 u16 fec_rs_period
= 0; /* Value for corresponding I2C register */
4184 fec_rs_prescale
= 1;
4185 /* fec_bits_desired = symbol_rate [kHz] *
4191 switch (modulation
) {
4192 case DRX_CONSTELLATION_QAM16
:
4193 fec_bits_desired
= 4 * symbol_rate
;
4195 case DRX_CONSTELLATION_QAM32
:
4196 fec_bits_desired
= 5 * symbol_rate
;
4198 case DRX_CONSTELLATION_QAM64
:
4199 fec_bits_desired
= 6 * symbol_rate
;
4201 case DRX_CONSTELLATION_QAM128
:
4202 fec_bits_desired
= 7 * symbol_rate
;
4204 case DRX_CONSTELLATION_QAM256
:
4205 fec_bits_desired
= 8 * symbol_rate
;
4213 fec_bits_desired
/= 1000; /* symbol_rate [Hz] -> symbol_rate [kHz] */
4214 fec_bits_desired
*= 500; /* meas. period [ms] */
4216 /* Annex A/C: bits/RsPeriod = 204 * 8 = 1632 */
4217 /* fec_rs_period_total = fec_bits_desired / 1632 */
4218 fec_rs_period_total
= (fec_bits_desired
/ 1632UL) + 1; /* roughly ceil */
4220 /* fec_rs_period_total = fec_rs_prescale * fec_rs_period */
4221 fec_rs_prescale
= 1 + (u16
) (fec_rs_period_total
>> 16);
4222 if (fec_rs_prescale
== 0) {
4223 /* Divide by zero (though impossible) */
4229 ((u16
) fec_rs_period_total
+
4230 (fec_rs_prescale
>> 1)) / fec_rs_prescale
;
4232 /* write corresponding registers */
4233 status
= write16(state
, FEC_RS_MEASUREMENT_PERIOD__A
, fec_rs_period
);
4236 status
= write16(state
, FEC_RS_MEASUREMENT_PRESCALE__A
,
4240 status
= write16(state
, FEC_OC_SNC_FAIL_PERIOD__A
, fec_rs_period
);
4243 pr_err("Error %d on %s\n", status
, __func__
);
4247 static int set_qam16(struct drxk_state
*state
)
4252 /* QAM Equalizer Setup */
4254 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD0__A
, 13517);
4257 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD1__A
, 13517);
4260 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD2__A
, 13517);
4263 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD3__A
, 13517);
4266 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD4__A
, 13517);
4269 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD5__A
, 13517);
4272 /* Decision Feedback Equalizer */
4273 status
= write16(state
, QAM_DQ_QUAL_FUN0__A
, 2);
4276 status
= write16(state
, QAM_DQ_QUAL_FUN1__A
, 2);
4279 status
= write16(state
, QAM_DQ_QUAL_FUN2__A
, 2);
4282 status
= write16(state
, QAM_DQ_QUAL_FUN3__A
, 2);
4285 status
= write16(state
, QAM_DQ_QUAL_FUN4__A
, 2);
4288 status
= write16(state
, QAM_DQ_QUAL_FUN5__A
, 0);
4292 status
= write16(state
, QAM_SY_SYNC_HWM__A
, 5);
4295 status
= write16(state
, QAM_SY_SYNC_AWM__A
, 4);
4298 status
= write16(state
, QAM_SY_SYNC_LWM__A
, 3);
4302 /* QAM Slicer Settings */
4303 status
= write16(state
, SCU_RAM_QAM_SL_SIG_POWER__A
,
4304 DRXK_QAM_SL_SIG_POWER_QAM16
);
4308 /* QAM Loop Controller Coeficients */
4309 status
= write16(state
, SCU_RAM_QAM_LC_CA_FINE__A
, 15);
4312 status
= write16(state
, SCU_RAM_QAM_LC_CA_COARSE__A
, 40);
4315 status
= write16(state
, SCU_RAM_QAM_LC_EP_FINE__A
, 12);
4318 status
= write16(state
, SCU_RAM_QAM_LC_EP_MEDIUM__A
, 24);
4321 status
= write16(state
, SCU_RAM_QAM_LC_EP_COARSE__A
, 24);
4324 status
= write16(state
, SCU_RAM_QAM_LC_EI_FINE__A
, 12);
4327 status
= write16(state
, SCU_RAM_QAM_LC_EI_MEDIUM__A
, 16);
4330 status
= write16(state
, SCU_RAM_QAM_LC_EI_COARSE__A
, 16);
4334 status
= write16(state
, SCU_RAM_QAM_LC_CP_FINE__A
, 5);
4337 status
= write16(state
, SCU_RAM_QAM_LC_CP_MEDIUM__A
, 20);
4340 status
= write16(state
, SCU_RAM_QAM_LC_CP_COARSE__A
, 80);
4343 status
= write16(state
, SCU_RAM_QAM_LC_CI_FINE__A
, 5);
4346 status
= write16(state
, SCU_RAM_QAM_LC_CI_MEDIUM__A
, 20);
4349 status
= write16(state
, SCU_RAM_QAM_LC_CI_COARSE__A
, 50);
4352 status
= write16(state
, SCU_RAM_QAM_LC_CF_FINE__A
, 16);
4355 status
= write16(state
, SCU_RAM_QAM_LC_CF_MEDIUM__A
, 16);
4358 status
= write16(state
, SCU_RAM_QAM_LC_CF_COARSE__A
, 32);
4361 status
= write16(state
, SCU_RAM_QAM_LC_CF1_FINE__A
, 5);
4364 status
= write16(state
, SCU_RAM_QAM_LC_CF1_MEDIUM__A
, 10);
4367 status
= write16(state
, SCU_RAM_QAM_LC_CF1_COARSE__A
, 10);
4372 /* QAM State Machine (FSM) Thresholds */
4374 status
= write16(state
, SCU_RAM_QAM_FSM_RTH__A
, 140);
4377 status
= write16(state
, SCU_RAM_QAM_FSM_FTH__A
, 50);
4380 status
= write16(state
, SCU_RAM_QAM_FSM_CTH__A
, 95);
4383 status
= write16(state
, SCU_RAM_QAM_FSM_PTH__A
, 120);
4386 status
= write16(state
, SCU_RAM_QAM_FSM_QTH__A
, 230);
4389 status
= write16(state
, SCU_RAM_QAM_FSM_MTH__A
, 105);
4393 status
= write16(state
, SCU_RAM_QAM_FSM_RATE_LIM__A
, 40);
4396 status
= write16(state
, SCU_RAM_QAM_FSM_COUNT_LIM__A
, 4);
4399 status
= write16(state
, SCU_RAM_QAM_FSM_FREQ_LIM__A
, 24);
4404 /* QAM FSM Tracking Parameters */
4406 status
= write16(state
, SCU_RAM_QAM_FSM_MEDIAN_AV_MULT__A
, (u16
) 16);
4409 status
= write16(state
, SCU_RAM_QAM_FSM_RADIUS_AV_LIMIT__A
, (u16
) 220);
4412 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET1__A
, (u16
) 25);
4415 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET2__A
, (u16
) 6);
4418 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET3__A
, (u16
) -24);
4421 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET4__A
, (u16
) -65);
4424 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET5__A
, (u16
) -127);
4430 pr_err("Error %d on %s\n", status
, __func__
);
4434 /*============================================================================*/
4437 * \brief QAM32 specific setup
4438 * \param demod instance of demod.
4439 * \return DRXStatus_t.
4441 static int set_qam32(struct drxk_state
*state
)
4447 /* QAM Equalizer Setup */
4449 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD0__A
, 6707);
4452 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD1__A
, 6707);
4455 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD2__A
, 6707);
4458 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD3__A
, 6707);
4461 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD4__A
, 6707);
4464 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD5__A
, 6707);
4468 /* Decision Feedback Equalizer */
4469 status
= write16(state
, QAM_DQ_QUAL_FUN0__A
, 3);
4472 status
= write16(state
, QAM_DQ_QUAL_FUN1__A
, 3);
4475 status
= write16(state
, QAM_DQ_QUAL_FUN2__A
, 3);
4478 status
= write16(state
, QAM_DQ_QUAL_FUN3__A
, 3);
4481 status
= write16(state
, QAM_DQ_QUAL_FUN4__A
, 3);
4484 status
= write16(state
, QAM_DQ_QUAL_FUN5__A
, 0);
4488 status
= write16(state
, QAM_SY_SYNC_HWM__A
, 6);
4491 status
= write16(state
, QAM_SY_SYNC_AWM__A
, 5);
4494 status
= write16(state
, QAM_SY_SYNC_LWM__A
, 3);
4498 /* QAM Slicer Settings */
4500 status
= write16(state
, SCU_RAM_QAM_SL_SIG_POWER__A
,
4501 DRXK_QAM_SL_SIG_POWER_QAM32
);
4506 /* QAM Loop Controller Coeficients */
4508 status
= write16(state
, SCU_RAM_QAM_LC_CA_FINE__A
, 15);
4511 status
= write16(state
, SCU_RAM_QAM_LC_CA_COARSE__A
, 40);
4514 status
= write16(state
, SCU_RAM_QAM_LC_EP_FINE__A
, 12);
4517 status
= write16(state
, SCU_RAM_QAM_LC_EP_MEDIUM__A
, 24);
4520 status
= write16(state
, SCU_RAM_QAM_LC_EP_COARSE__A
, 24);
4523 status
= write16(state
, SCU_RAM_QAM_LC_EI_FINE__A
, 12);
4526 status
= write16(state
, SCU_RAM_QAM_LC_EI_MEDIUM__A
, 16);
4529 status
= write16(state
, SCU_RAM_QAM_LC_EI_COARSE__A
, 16);
4533 status
= write16(state
, SCU_RAM_QAM_LC_CP_FINE__A
, 5);
4536 status
= write16(state
, SCU_RAM_QAM_LC_CP_MEDIUM__A
, 20);
4539 status
= write16(state
, SCU_RAM_QAM_LC_CP_COARSE__A
, 80);
4542 status
= write16(state
, SCU_RAM_QAM_LC_CI_FINE__A
, 5);
4545 status
= write16(state
, SCU_RAM_QAM_LC_CI_MEDIUM__A
, 20);
4548 status
= write16(state
, SCU_RAM_QAM_LC_CI_COARSE__A
, 50);
4551 status
= write16(state
, SCU_RAM_QAM_LC_CF_FINE__A
, 16);
4554 status
= write16(state
, SCU_RAM_QAM_LC_CF_MEDIUM__A
, 16);
4557 status
= write16(state
, SCU_RAM_QAM_LC_CF_COARSE__A
, 16);
4560 status
= write16(state
, SCU_RAM_QAM_LC_CF1_FINE__A
, 5);
4563 status
= write16(state
, SCU_RAM_QAM_LC_CF1_MEDIUM__A
, 10);
4566 status
= write16(state
, SCU_RAM_QAM_LC_CF1_COARSE__A
, 0);
4571 /* QAM State Machine (FSM) Thresholds */
4573 status
= write16(state
, SCU_RAM_QAM_FSM_RTH__A
, 90);
4576 status
= write16(state
, SCU_RAM_QAM_FSM_FTH__A
, 50);
4579 status
= write16(state
, SCU_RAM_QAM_FSM_CTH__A
, 80);
4582 status
= write16(state
, SCU_RAM_QAM_FSM_PTH__A
, 100);
4585 status
= write16(state
, SCU_RAM_QAM_FSM_QTH__A
, 170);
4588 status
= write16(state
, SCU_RAM_QAM_FSM_MTH__A
, 100);
4592 status
= write16(state
, SCU_RAM_QAM_FSM_RATE_LIM__A
, 40);
4595 status
= write16(state
, SCU_RAM_QAM_FSM_COUNT_LIM__A
, 4);
4598 status
= write16(state
, SCU_RAM_QAM_FSM_FREQ_LIM__A
, 10);
4603 /* QAM FSM Tracking Parameters */
4605 status
= write16(state
, SCU_RAM_QAM_FSM_MEDIAN_AV_MULT__A
, (u16
) 12);
4608 status
= write16(state
, SCU_RAM_QAM_FSM_RADIUS_AV_LIMIT__A
, (u16
) 140);
4611 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET1__A
, (u16
) -8);
4614 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET2__A
, (u16
) -16);
4617 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET3__A
, (u16
) -26);
4620 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET4__A
, (u16
) -56);
4623 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET5__A
, (u16
) -86);
4626 pr_err("Error %d on %s\n", status
, __func__
);
4630 /*============================================================================*/
4633 * \brief QAM64 specific setup
4634 * \param demod instance of demod.
4635 * \return DRXStatus_t.
4637 static int set_qam64(struct drxk_state
*state
)
4642 /* QAM Equalizer Setup */
4644 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD0__A
, 13336);
4647 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD1__A
, 12618);
4650 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD2__A
, 11988);
4653 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD3__A
, 13809);
4656 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD4__A
, 13809);
4659 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD5__A
, 15609);
4663 /* Decision Feedback Equalizer */
4664 status
= write16(state
, QAM_DQ_QUAL_FUN0__A
, 4);
4667 status
= write16(state
, QAM_DQ_QUAL_FUN1__A
, 4);
4670 status
= write16(state
, QAM_DQ_QUAL_FUN2__A
, 4);
4673 status
= write16(state
, QAM_DQ_QUAL_FUN3__A
, 4);
4676 status
= write16(state
, QAM_DQ_QUAL_FUN4__A
, 3);
4679 status
= write16(state
, QAM_DQ_QUAL_FUN5__A
, 0);
4683 status
= write16(state
, QAM_SY_SYNC_HWM__A
, 5);
4686 status
= write16(state
, QAM_SY_SYNC_AWM__A
, 4);
4689 status
= write16(state
, QAM_SY_SYNC_LWM__A
, 3);
4693 /* QAM Slicer Settings */
4694 status
= write16(state
, SCU_RAM_QAM_SL_SIG_POWER__A
,
4695 DRXK_QAM_SL_SIG_POWER_QAM64
);
4700 /* QAM Loop Controller Coeficients */
4702 status
= write16(state
, SCU_RAM_QAM_LC_CA_FINE__A
, 15);
4705 status
= write16(state
, SCU_RAM_QAM_LC_CA_COARSE__A
, 40);
4708 status
= write16(state
, SCU_RAM_QAM_LC_EP_FINE__A
, 12);
4711 status
= write16(state
, SCU_RAM_QAM_LC_EP_MEDIUM__A
, 24);
4714 status
= write16(state
, SCU_RAM_QAM_LC_EP_COARSE__A
, 24);
4717 status
= write16(state
, SCU_RAM_QAM_LC_EI_FINE__A
, 12);
4720 status
= write16(state
, SCU_RAM_QAM_LC_EI_MEDIUM__A
, 16);
4723 status
= write16(state
, SCU_RAM_QAM_LC_EI_COARSE__A
, 16);
4727 status
= write16(state
, SCU_RAM_QAM_LC_CP_FINE__A
, 5);
4730 status
= write16(state
, SCU_RAM_QAM_LC_CP_MEDIUM__A
, 30);
4733 status
= write16(state
, SCU_RAM_QAM_LC_CP_COARSE__A
, 100);
4736 status
= write16(state
, SCU_RAM_QAM_LC_CI_FINE__A
, 5);
4739 status
= write16(state
, SCU_RAM_QAM_LC_CI_MEDIUM__A
, 30);
4742 status
= write16(state
, SCU_RAM_QAM_LC_CI_COARSE__A
, 50);
4745 status
= write16(state
, SCU_RAM_QAM_LC_CF_FINE__A
, 16);
4748 status
= write16(state
, SCU_RAM_QAM_LC_CF_MEDIUM__A
, 25);
4751 status
= write16(state
, SCU_RAM_QAM_LC_CF_COARSE__A
, 48);
4754 status
= write16(state
, SCU_RAM_QAM_LC_CF1_FINE__A
, 5);
4757 status
= write16(state
, SCU_RAM_QAM_LC_CF1_MEDIUM__A
, 10);
4760 status
= write16(state
, SCU_RAM_QAM_LC_CF1_COARSE__A
, 10);
4765 /* QAM State Machine (FSM) Thresholds */
4767 status
= write16(state
, SCU_RAM_QAM_FSM_RTH__A
, 100);
4770 status
= write16(state
, SCU_RAM_QAM_FSM_FTH__A
, 60);
4773 status
= write16(state
, SCU_RAM_QAM_FSM_CTH__A
, 80);
4776 status
= write16(state
, SCU_RAM_QAM_FSM_PTH__A
, 110);
4779 status
= write16(state
, SCU_RAM_QAM_FSM_QTH__A
, 200);
4782 status
= write16(state
, SCU_RAM_QAM_FSM_MTH__A
, 95);
4786 status
= write16(state
, SCU_RAM_QAM_FSM_RATE_LIM__A
, 40);
4789 status
= write16(state
, SCU_RAM_QAM_FSM_COUNT_LIM__A
, 4);
4792 status
= write16(state
, SCU_RAM_QAM_FSM_FREQ_LIM__A
, 15);
4797 /* QAM FSM Tracking Parameters */
4799 status
= write16(state
, SCU_RAM_QAM_FSM_MEDIAN_AV_MULT__A
, (u16
) 12);
4802 status
= write16(state
, SCU_RAM_QAM_FSM_RADIUS_AV_LIMIT__A
, (u16
) 141);
4805 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET1__A
, (u16
) 7);
4808 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET2__A
, (u16
) 0);
4811 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET3__A
, (u16
) -15);
4814 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET4__A
, (u16
) -45);
4817 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET5__A
, (u16
) -80);
4820 pr_err("Error %d on %s\n", status
, __func__
);
4825 /*============================================================================*/
4828 * \brief QAM128 specific setup
4829 * \param demod: instance of demod.
4830 * \return DRXStatus_t.
4832 static int set_qam128(struct drxk_state
*state
)
4837 /* QAM Equalizer Setup */
4839 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD0__A
, 6564);
4842 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD1__A
, 6598);
4845 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD2__A
, 6394);
4848 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD3__A
, 6409);
4851 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD4__A
, 6656);
4854 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD5__A
, 7238);
4858 /* Decision Feedback Equalizer */
4859 status
= write16(state
, QAM_DQ_QUAL_FUN0__A
, 6);
4862 status
= write16(state
, QAM_DQ_QUAL_FUN1__A
, 6);
4865 status
= write16(state
, QAM_DQ_QUAL_FUN2__A
, 6);
4868 status
= write16(state
, QAM_DQ_QUAL_FUN3__A
, 6);
4871 status
= write16(state
, QAM_DQ_QUAL_FUN4__A
, 5);
4874 status
= write16(state
, QAM_DQ_QUAL_FUN5__A
, 0);
4878 status
= write16(state
, QAM_SY_SYNC_HWM__A
, 6);
4881 status
= write16(state
, QAM_SY_SYNC_AWM__A
, 5);
4884 status
= write16(state
, QAM_SY_SYNC_LWM__A
, 3);
4889 /* QAM Slicer Settings */
4891 status
= write16(state
, SCU_RAM_QAM_SL_SIG_POWER__A
,
4892 DRXK_QAM_SL_SIG_POWER_QAM128
);
4897 /* QAM Loop Controller Coeficients */
4899 status
= write16(state
, SCU_RAM_QAM_LC_CA_FINE__A
, 15);
4902 status
= write16(state
, SCU_RAM_QAM_LC_CA_COARSE__A
, 40);
4905 status
= write16(state
, SCU_RAM_QAM_LC_EP_FINE__A
, 12);
4908 status
= write16(state
, SCU_RAM_QAM_LC_EP_MEDIUM__A
, 24);
4911 status
= write16(state
, SCU_RAM_QAM_LC_EP_COARSE__A
, 24);
4914 status
= write16(state
, SCU_RAM_QAM_LC_EI_FINE__A
, 12);
4917 status
= write16(state
, SCU_RAM_QAM_LC_EI_MEDIUM__A
, 16);
4920 status
= write16(state
, SCU_RAM_QAM_LC_EI_COARSE__A
, 16);
4924 status
= write16(state
, SCU_RAM_QAM_LC_CP_FINE__A
, 5);
4927 status
= write16(state
, SCU_RAM_QAM_LC_CP_MEDIUM__A
, 40);
4930 status
= write16(state
, SCU_RAM_QAM_LC_CP_COARSE__A
, 120);
4933 status
= write16(state
, SCU_RAM_QAM_LC_CI_FINE__A
, 5);
4936 status
= write16(state
, SCU_RAM_QAM_LC_CI_MEDIUM__A
, 40);
4939 status
= write16(state
, SCU_RAM_QAM_LC_CI_COARSE__A
, 60);
4942 status
= write16(state
, SCU_RAM_QAM_LC_CF_FINE__A
, 16);
4945 status
= write16(state
, SCU_RAM_QAM_LC_CF_MEDIUM__A
, 25);
4948 status
= write16(state
, SCU_RAM_QAM_LC_CF_COARSE__A
, 64);
4951 status
= write16(state
, SCU_RAM_QAM_LC_CF1_FINE__A
, 5);
4954 status
= write16(state
, SCU_RAM_QAM_LC_CF1_MEDIUM__A
, 10);
4957 status
= write16(state
, SCU_RAM_QAM_LC_CF1_COARSE__A
, 0);
4962 /* QAM State Machine (FSM) Thresholds */
4964 status
= write16(state
, SCU_RAM_QAM_FSM_RTH__A
, 50);
4967 status
= write16(state
, SCU_RAM_QAM_FSM_FTH__A
, 60);
4970 status
= write16(state
, SCU_RAM_QAM_FSM_CTH__A
, 80);
4973 status
= write16(state
, SCU_RAM_QAM_FSM_PTH__A
, 100);
4976 status
= write16(state
, SCU_RAM_QAM_FSM_QTH__A
, 140);
4979 status
= write16(state
, SCU_RAM_QAM_FSM_MTH__A
, 100);
4983 status
= write16(state
, SCU_RAM_QAM_FSM_RATE_LIM__A
, 40);
4986 status
= write16(state
, SCU_RAM_QAM_FSM_COUNT_LIM__A
, 5);
4990 status
= write16(state
, SCU_RAM_QAM_FSM_FREQ_LIM__A
, 12);
4994 /* QAM FSM Tracking Parameters */
4996 status
= write16(state
, SCU_RAM_QAM_FSM_MEDIAN_AV_MULT__A
, (u16
) 8);
4999 status
= write16(state
, SCU_RAM_QAM_FSM_RADIUS_AV_LIMIT__A
, (u16
) 65);
5002 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET1__A
, (u16
) 5);
5005 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET2__A
, (u16
) 3);
5008 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET3__A
, (u16
) -1);
5011 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET4__A
, (u16
) -12);
5014 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET5__A
, (u16
) -23);
5017 pr_err("Error %d on %s\n", status
, __func__
);
5022 /*============================================================================*/
5025 * \brief QAM256 specific setup
5026 * \param demod: instance of demod.
5027 * \return DRXStatus_t.
5029 static int set_qam256(struct drxk_state
*state
)
5034 /* QAM Equalizer Setup */
5036 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD0__A
, 11502);
5039 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD1__A
, 12084);
5042 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD2__A
, 12543);
5045 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD3__A
, 12931);
5048 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD4__A
, 13629);
5051 status
= write16(state
, SCU_RAM_QAM_EQ_CMA_RAD5__A
, 15385);
5055 /* Decision Feedback Equalizer */
5056 status
= write16(state
, QAM_DQ_QUAL_FUN0__A
, 8);
5059 status
= write16(state
, QAM_DQ_QUAL_FUN1__A
, 8);
5062 status
= write16(state
, QAM_DQ_QUAL_FUN2__A
, 8);
5065 status
= write16(state
, QAM_DQ_QUAL_FUN3__A
, 8);
5068 status
= write16(state
, QAM_DQ_QUAL_FUN4__A
, 6);
5071 status
= write16(state
, QAM_DQ_QUAL_FUN5__A
, 0);
5075 status
= write16(state
, QAM_SY_SYNC_HWM__A
, 5);
5078 status
= write16(state
, QAM_SY_SYNC_AWM__A
, 4);
5081 status
= write16(state
, QAM_SY_SYNC_LWM__A
, 3);
5085 /* QAM Slicer Settings */
5087 status
= write16(state
, SCU_RAM_QAM_SL_SIG_POWER__A
,
5088 DRXK_QAM_SL_SIG_POWER_QAM256
);
5093 /* QAM Loop Controller Coeficients */
5095 status
= write16(state
, SCU_RAM_QAM_LC_CA_FINE__A
, 15);
5098 status
= write16(state
, SCU_RAM_QAM_LC_CA_COARSE__A
, 40);
5101 status
= write16(state
, SCU_RAM_QAM_LC_EP_FINE__A
, 12);
5104 status
= write16(state
, SCU_RAM_QAM_LC_EP_MEDIUM__A
, 24);
5107 status
= write16(state
, SCU_RAM_QAM_LC_EP_COARSE__A
, 24);
5110 status
= write16(state
, SCU_RAM_QAM_LC_EI_FINE__A
, 12);
5113 status
= write16(state
, SCU_RAM_QAM_LC_EI_MEDIUM__A
, 16);
5116 status
= write16(state
, SCU_RAM_QAM_LC_EI_COARSE__A
, 16);
5120 status
= write16(state
, SCU_RAM_QAM_LC_CP_FINE__A
, 5);
5123 status
= write16(state
, SCU_RAM_QAM_LC_CP_MEDIUM__A
, 50);
5126 status
= write16(state
, SCU_RAM_QAM_LC_CP_COARSE__A
, 250);
5129 status
= write16(state
, SCU_RAM_QAM_LC_CI_FINE__A
, 5);
5132 status
= write16(state
, SCU_RAM_QAM_LC_CI_MEDIUM__A
, 50);
5135 status
= write16(state
, SCU_RAM_QAM_LC_CI_COARSE__A
, 125);
5138 status
= write16(state
, SCU_RAM_QAM_LC_CF_FINE__A
, 16);
5141 status
= write16(state
, SCU_RAM_QAM_LC_CF_MEDIUM__A
, 25);
5144 status
= write16(state
, SCU_RAM_QAM_LC_CF_COARSE__A
, 48);
5147 status
= write16(state
, SCU_RAM_QAM_LC_CF1_FINE__A
, 5);
5150 status
= write16(state
, SCU_RAM_QAM_LC_CF1_MEDIUM__A
, 10);
5153 status
= write16(state
, SCU_RAM_QAM_LC_CF1_COARSE__A
, 10);
5158 /* QAM State Machine (FSM) Thresholds */
5160 status
= write16(state
, SCU_RAM_QAM_FSM_RTH__A
, 50);
5163 status
= write16(state
, SCU_RAM_QAM_FSM_FTH__A
, 60);
5166 status
= write16(state
, SCU_RAM_QAM_FSM_CTH__A
, 80);
5169 status
= write16(state
, SCU_RAM_QAM_FSM_PTH__A
, 100);
5172 status
= write16(state
, SCU_RAM_QAM_FSM_QTH__A
, 150);
5175 status
= write16(state
, SCU_RAM_QAM_FSM_MTH__A
, 110);
5179 status
= write16(state
, SCU_RAM_QAM_FSM_RATE_LIM__A
, 40);
5182 status
= write16(state
, SCU_RAM_QAM_FSM_COUNT_LIM__A
, 4);
5185 status
= write16(state
, SCU_RAM_QAM_FSM_FREQ_LIM__A
, 12);
5190 /* QAM FSM Tracking Parameters */
5192 status
= write16(state
, SCU_RAM_QAM_FSM_MEDIAN_AV_MULT__A
, (u16
) 8);
5195 status
= write16(state
, SCU_RAM_QAM_FSM_RADIUS_AV_LIMIT__A
, (u16
) 74);
5198 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET1__A
, (u16
) 18);
5201 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET2__A
, (u16
) 13);
5204 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET3__A
, (u16
) 7);
5207 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET4__A
, (u16
) 0);
5210 status
= write16(state
, SCU_RAM_QAM_FSM_LCAVG_OFFSET5__A
, (u16
) -8);
5213 pr_err("Error %d on %s\n", status
, __func__
);
5218 /*============================================================================*/
5220 * \brief Reset QAM block.
5221 * \param demod: instance of demod.
5222 * \param channel: pointer to channel data.
5223 * \return DRXStatus_t.
5225 static int qam_reset_qam(struct drxk_state
*state
)
5231 /* Stop QAM comstate->m_exec */
5232 status
= write16(state
, QAM_COMM_EXEC__A
, QAM_COMM_EXEC_STOP
);
5236 status
= scu_command(state
, SCU_RAM_COMMAND_STANDARD_QAM
5237 | SCU_RAM_COMMAND_CMD_DEMOD_RESET
,
5238 0, NULL
, 1, &cmd_result
);
5241 pr_err("Error %d on %s\n", status
, __func__
);
5245 /*============================================================================*/
5248 * \brief Set QAM symbolrate.
5249 * \param demod: instance of demod.
5250 * \param channel: pointer to channel data.
5251 * \return DRXStatus_t.
5253 static int qam_set_symbolrate(struct drxk_state
*state
)
5255 u32 adc_frequency
= 0;
5257 u32 iqm_rc_rate
= 0;
5259 u32 lc_symb_rate
= 0;
5263 /* Select & calculate correct IQM rate */
5264 adc_frequency
= (state
->m_sys_clock_freq
* 1000) / 3;
5266 if (state
->props
.symbol_rate
<= 1188750)
5268 else if (state
->props
.symbol_rate
<= 2377500)
5270 else if (state
->props
.symbol_rate
<= 4755000)
5272 status
= write16(state
, IQM_FD_RATESEL__A
, ratesel
);
5277 IqmRcRate = ((Fadc / (symbolrate * (4<<ratesel))) - 1) * (1<<23)
5279 symb_freq
= state
->props
.symbol_rate
* (1 << ratesel
);
5280 if (symb_freq
== 0) {
5281 /* Divide by zero */
5285 iqm_rc_rate
= (adc_frequency
/ symb_freq
) * (1 << 21) +
5286 (Frac28a((adc_frequency
% symb_freq
), symb_freq
) >> 7) -
5288 status
= write32(state
, IQM_RC_RATE_OFS_LO__A
, iqm_rc_rate
);
5291 state
->m_iqm_rc_rate
= iqm_rc_rate
;
5293 LcSymbFreq = round (.125 * symbolrate / adc_freq * (1<<15))
5295 symb_freq
= state
->props
.symbol_rate
;
5296 if (adc_frequency
== 0) {
5297 /* Divide by zero */
5301 lc_symb_rate
= (symb_freq
/ adc_frequency
) * (1 << 12) +
5302 (Frac28a((symb_freq
% adc_frequency
), adc_frequency
) >>
5304 if (lc_symb_rate
> 511)
5306 status
= write16(state
, QAM_LC_SYMBOL_FREQ__A
, (u16
) lc_symb_rate
);
5310 pr_err("Error %d on %s\n", status
, __func__
);
5314 /*============================================================================*/
5317 * \brief Get QAM lock status.
5318 * \param demod: instance of demod.
5319 * \param channel: pointer to channel data.
5320 * \return DRXStatus_t.
5323 static int get_qam_lock_status(struct drxk_state
*state
, u32
*p_lock_status
)
5326 u16 result
[2] = { 0, 0 };
5329 *p_lock_status
= NOT_LOCKED
;
5330 status
= scu_command(state
,
5331 SCU_RAM_COMMAND_STANDARD_QAM
|
5332 SCU_RAM_COMMAND_CMD_DEMOD_GET_LOCK
, 0, NULL
, 2,
5335 pr_err("Error %d on %s\n", status
, __func__
);
5337 if (result
[1] < SCU_RAM_QAM_LOCKED_LOCKED_DEMOD_LOCKED
) {
5338 /* 0x0000 NOT LOCKED */
5339 } else if (result
[1] < SCU_RAM_QAM_LOCKED_LOCKED_LOCKED
) {
5340 /* 0x4000 DEMOD LOCKED */
5341 *p_lock_status
= DEMOD_LOCK
;
5342 } else if (result
[1] < SCU_RAM_QAM_LOCKED_LOCKED_NEVER_LOCK
) {
5343 /* 0x8000 DEMOD + FEC LOCKED (system lock) */
5344 *p_lock_status
= MPEG_LOCK
;
5346 /* 0xC000 NEVER LOCKED */
5347 /* (system will never be able to lock to the signal) */
5349 * TODO: check this, intermediate & standard specific lock
5350 * states are not taken into account here
5352 *p_lock_status
= NEVER_LOCK
;
5357 #define QAM_MIRROR__M 0x03
5358 #define QAM_MIRROR_NORMAL 0x00
5359 #define QAM_MIRRORED 0x01
5360 #define QAM_MIRROR_AUTO_ON 0x02
5361 #define QAM_LOCKRANGE__M 0x10
5362 #define QAM_LOCKRANGE_NORMAL 0x10
5364 static int qam_demodulator_command(struct drxk_state
*state
,
5365 int number_of_parameters
)
5369 u16 set_param_parameters
[4] = { 0, 0, 0, 0 };
5371 set_param_parameters
[0] = state
->m_constellation
; /* modulation */
5372 set_param_parameters
[1] = DRXK_QAM_I12_J17
; /* interleave mode */
5374 if (number_of_parameters
== 2) {
5375 u16 set_env_parameters
[1] = { 0 };
5377 if (state
->m_operation_mode
== OM_QAM_ITU_C
)
5378 set_env_parameters
[0] = QAM_TOP_ANNEX_C
;
5380 set_env_parameters
[0] = QAM_TOP_ANNEX_A
;
5382 status
= scu_command(state
,
5383 SCU_RAM_COMMAND_STANDARD_QAM
5384 | SCU_RAM_COMMAND_CMD_DEMOD_SET_ENV
,
5385 1, set_env_parameters
, 1, &cmd_result
);
5389 status
= scu_command(state
,
5390 SCU_RAM_COMMAND_STANDARD_QAM
5391 | SCU_RAM_COMMAND_CMD_DEMOD_SET_PARAM
,
5392 number_of_parameters
, set_param_parameters
,
5394 } else if (number_of_parameters
== 4) {
5395 if (state
->m_operation_mode
== OM_QAM_ITU_C
)
5396 set_param_parameters
[2] = QAM_TOP_ANNEX_C
;
5398 set_param_parameters
[2] = QAM_TOP_ANNEX_A
;
5400 set_param_parameters
[3] |= (QAM_MIRROR_AUTO_ON
);
5401 /* Env parameters */
5402 /* check for LOCKRANGE Extended */
5403 /* set_param_parameters[3] |= QAM_LOCKRANGE_NORMAL; */
5405 status
= scu_command(state
,
5406 SCU_RAM_COMMAND_STANDARD_QAM
5407 | SCU_RAM_COMMAND_CMD_DEMOD_SET_PARAM
,
5408 number_of_parameters
, set_param_parameters
,
5411 pr_warn("Unknown QAM demodulator parameter count %d\n",
5412 number_of_parameters
);
5418 pr_warn("Warning %d on %s\n", status
, __func__
);
5422 static int set_qam(struct drxk_state
*state
, u16 intermediate_freqk_hz
,
5423 s32 tuner_freq_offset
)
5427 int qam_demod_param_count
= state
->qam_demod_parameter_count
;
5431 * STEP 1: reset demodulator
5432 * resets FEC DI and FEC RS
5434 * resets SCU variables
5436 status
= write16(state
, FEC_DI_COMM_EXEC__A
, FEC_DI_COMM_EXEC_STOP
);
5439 status
= write16(state
, FEC_RS_COMM_EXEC__A
, FEC_RS_COMM_EXEC_STOP
);
5442 status
= qam_reset_qam(state
);
5447 * STEP 2: configure demodulator
5448 * -set params; resets IQM,QAM,FEC HW; initializes some
5451 status
= qam_set_symbolrate(state
);
5456 switch (state
->props
.modulation
) {
5458 state
->m_constellation
= DRX_CONSTELLATION_QAM256
;
5462 state
->m_constellation
= DRX_CONSTELLATION_QAM64
;
5465 state
->m_constellation
= DRX_CONSTELLATION_QAM16
;
5468 state
->m_constellation
= DRX_CONSTELLATION_QAM32
;
5471 state
->m_constellation
= DRX_CONSTELLATION_QAM128
;
5480 /* Use the 4-parameter if it's requested or we're probing for
5481 * the correct command. */
5482 if (state
->qam_demod_parameter_count
== 4
5483 || !state
->qam_demod_parameter_count
) {
5484 qam_demod_param_count
= 4;
5485 status
= qam_demodulator_command(state
, qam_demod_param_count
);
5488 /* Use the 2-parameter command if it was requested or if we're
5489 * probing for the correct command and the 4-parameter command
5491 if (state
->qam_demod_parameter_count
== 2
5492 || (!state
->qam_demod_parameter_count
&& status
< 0)) {
5493 qam_demod_param_count
= 2;
5494 status
= qam_demodulator_command(state
, qam_demod_param_count
);
5498 dprintk(1, "Could not set demodulator parameters.\n");
5500 "Make sure qam_demod_parameter_count (%d) is correct for your firmware (%s).\n",
5501 state
->qam_demod_parameter_count
,
5502 state
->microcode_name
);
5504 } else if (!state
->qam_demod_parameter_count
) {
5506 "Auto-probing the QAM command parameters was successful - using %d parameters.\n",
5507 qam_demod_param_count
);
5510 * One of our commands was successful. We don't need to
5511 * auto-probe anymore, now that we got the correct command.
5513 state
->qam_demod_parameter_count
= qam_demod_param_count
;
5517 * STEP 3: enable the system in a mode where the ADC provides valid
5518 * signal setup modulation independent registers
5521 status
= set_frequency(channel
, tuner_freq_offset
));
5525 status
= set_frequency_shifter(state
, intermediate_freqk_hz
,
5526 tuner_freq_offset
, true);
5530 /* Setup BER measurement */
5531 status
= set_qam_measurement(state
, state
->m_constellation
,
5532 state
->props
.symbol_rate
);
5536 /* Reset default values */
5537 status
= write16(state
, IQM_CF_SCALE_SH__A
, IQM_CF_SCALE_SH__PRE
);
5540 status
= write16(state
, QAM_SY_TIMEOUT__A
, QAM_SY_TIMEOUT__PRE
);
5544 /* Reset default LC values */
5545 status
= write16(state
, QAM_LC_RATE_LIMIT__A
, 3);
5548 status
= write16(state
, QAM_LC_LPF_FACTORP__A
, 4);
5551 status
= write16(state
, QAM_LC_LPF_FACTORI__A
, 4);
5554 status
= write16(state
, QAM_LC_MODE__A
, 7);
5558 status
= write16(state
, QAM_LC_QUAL_TAB0__A
, 1);
5561 status
= write16(state
, QAM_LC_QUAL_TAB1__A
, 1);
5564 status
= write16(state
, QAM_LC_QUAL_TAB2__A
, 1);
5567 status
= write16(state
, QAM_LC_QUAL_TAB3__A
, 1);
5570 status
= write16(state
, QAM_LC_QUAL_TAB4__A
, 2);
5573 status
= write16(state
, QAM_LC_QUAL_TAB5__A
, 2);
5576 status
= write16(state
, QAM_LC_QUAL_TAB6__A
, 2);
5579 status
= write16(state
, QAM_LC_QUAL_TAB8__A
, 2);
5582 status
= write16(state
, QAM_LC_QUAL_TAB9__A
, 2);
5585 status
= write16(state
, QAM_LC_QUAL_TAB10__A
, 2);
5588 status
= write16(state
, QAM_LC_QUAL_TAB12__A
, 2);
5591 status
= write16(state
, QAM_LC_QUAL_TAB15__A
, 3);
5594 status
= write16(state
, QAM_LC_QUAL_TAB16__A
, 3);
5597 status
= write16(state
, QAM_LC_QUAL_TAB20__A
, 4);
5600 status
= write16(state
, QAM_LC_QUAL_TAB25__A
, 4);
5604 /* Mirroring, QAM-block starting point not inverted */
5605 status
= write16(state
, QAM_SY_SP_INV__A
,
5606 QAM_SY_SP_INV_SPECTRUM_INV_DIS
);
5610 /* Halt SCU to enable safe non-atomic accesses */
5611 status
= write16(state
, SCU_COMM_EXEC__A
, SCU_COMM_EXEC_HOLD
);
5615 /* STEP 4: modulation specific setup */
5616 switch (state
->props
.modulation
) {
5618 status
= set_qam16(state
);
5621 status
= set_qam32(state
);
5625 status
= set_qam64(state
);
5628 status
= set_qam128(state
);
5631 status
= set_qam256(state
);
5640 /* Activate SCU to enable SCU commands */
5641 status
= write16(state
, SCU_COMM_EXEC__A
, SCU_COMM_EXEC_ACTIVE
);
5645 /* Re-configure MPEG output, requires knowledge of channel bitrate */
5646 /* extAttr->currentChannel.modulation = channel->modulation; */
5647 /* extAttr->currentChannel.symbolrate = channel->symbolrate; */
5648 status
= mpegts_dto_setup(state
, state
->m_operation_mode
);
5652 /* start processes */
5653 status
= mpegts_start(state
);
5656 status
= write16(state
, FEC_COMM_EXEC__A
, FEC_COMM_EXEC_ACTIVE
);
5659 status
= write16(state
, QAM_COMM_EXEC__A
, QAM_COMM_EXEC_ACTIVE
);
5662 status
= write16(state
, IQM_COMM_EXEC__A
, IQM_COMM_EXEC_B_ACTIVE
);
5666 /* STEP 5: start QAM demodulator (starts FEC, QAM and IQM HW) */
5667 status
= scu_command(state
, SCU_RAM_COMMAND_STANDARD_QAM
5668 | SCU_RAM_COMMAND_CMD_DEMOD_START
,
5669 0, NULL
, 1, &cmd_result
);
5673 /* update global DRXK data container */
5674 /*? extAttr->qamInterleaveMode = DRXK_QAM_I12_J17; */
5678 pr_err("Error %d on %s\n", status
, __func__
);
5682 static int set_qam_standard(struct drxk_state
*state
,
5683 enum operation_mode o_mode
)
5686 #ifdef DRXK_QAM_TAPS
5687 #define DRXK_QAMA_TAPS_SELECT
5688 #include "drxk_filters.h"
5689 #undef DRXK_QAMA_TAPS_SELECT
5694 /* added antenna switch */
5695 switch_antenna_to_qam(state
);
5697 /* Ensure correct power-up mode */
5698 status
= power_up_qam(state
);
5701 /* Reset QAM block */
5702 status
= qam_reset_qam(state
);
5708 status
= write16(state
, IQM_COMM_EXEC__A
, IQM_COMM_EXEC_B_STOP
);
5711 status
= write16(state
, IQM_AF_AMUX__A
, IQM_AF_AMUX_SIGNAL2ADC
);
5715 /* Upload IQM Channel Filter settings by
5716 boot loader from ROM table */
5719 status
= bl_chain_cmd(state
, DRXK_BL_ROM_OFFSET_TAPS_ITU_A
,
5720 DRXK_BLCC_NR_ELEMENTS_TAPS
,
5724 status
= bl_direct_cmd(state
, IQM_CF_TAP_RE0__A
,
5725 DRXK_BL_ROM_OFFSET_TAPS_ITU_C
,
5726 DRXK_BLDC_NR_ELEMENTS_TAPS
,
5730 status
= bl_direct_cmd(state
,
5732 DRXK_BL_ROM_OFFSET_TAPS_ITU_C
,
5733 DRXK_BLDC_NR_ELEMENTS_TAPS
,
5742 status
= write16(state
, IQM_CF_OUT_ENA__A
, 1 << IQM_CF_OUT_ENA_QAM__B
);
5745 status
= write16(state
, IQM_CF_SYMMETRIC__A
, 0);
5748 status
= write16(state
, IQM_CF_MIDTAP__A
,
5749 ((1 << IQM_CF_MIDTAP_RE__B
) | (1 << IQM_CF_MIDTAP_IM__B
)));
5753 status
= write16(state
, IQM_RC_STRETCH__A
, 21);
5756 status
= write16(state
, IQM_AF_CLP_LEN__A
, 0);
5759 status
= write16(state
, IQM_AF_CLP_TH__A
, 448);
5762 status
= write16(state
, IQM_AF_SNS_LEN__A
, 0);
5765 status
= write16(state
, IQM_CF_POW_MEAS_LEN__A
, 0);
5769 status
= write16(state
, IQM_FS_ADJ_SEL__A
, 1);
5772 status
= write16(state
, IQM_RC_ADJ_SEL__A
, 1);
5775 status
= write16(state
, IQM_CF_ADJ_SEL__A
, 1);
5778 status
= write16(state
, IQM_AF_UPD_SEL__A
, 0);
5782 /* IQM Impulse Noise Processing Unit */
5783 status
= write16(state
, IQM_CF_CLP_VAL__A
, 500);
5786 status
= write16(state
, IQM_CF_DATATH__A
, 1000);
5789 status
= write16(state
, IQM_CF_BYPASSDET__A
, 1);
5792 status
= write16(state
, IQM_CF_DET_LCT__A
, 0);
5795 status
= write16(state
, IQM_CF_WND_LEN__A
, 1);
5798 status
= write16(state
, IQM_CF_PKDTH__A
, 1);
5801 status
= write16(state
, IQM_AF_INC_BYPASS__A
, 1);
5805 /* turn on IQMAF. Must be done before setAgc**() */
5806 status
= set_iqm_af(state
, true);
5809 status
= write16(state
, IQM_AF_START_LOCK__A
, 0x01);
5813 /* IQM will not be reset from here, sync ADC and update/init AGC */
5814 status
= adc_synchronization(state
);
5818 /* Set the FSM step period */
5819 status
= write16(state
, SCU_RAM_QAM_FSM_STEP_PERIOD__A
, 2000);
5823 /* Halt SCU to enable safe non-atomic accesses */
5824 status
= write16(state
, SCU_COMM_EXEC__A
, SCU_COMM_EXEC_HOLD
);
5828 /* No more resets of the IQM, current standard correctly set =>
5829 now AGCs can be configured. */
5831 status
= init_agc(state
, true);
5834 status
= set_pre_saw(state
, &(state
->m_qam_pre_saw_cfg
));
5838 /* Configure AGC's */
5839 status
= set_agc_rf(state
, &(state
->m_qam_rf_agc_cfg
), true);
5842 status
= set_agc_if(state
, &(state
->m_qam_if_agc_cfg
), true);
5846 /* Activate SCU to enable SCU commands */
5847 status
= write16(state
, SCU_COMM_EXEC__A
, SCU_COMM_EXEC_ACTIVE
);
5850 pr_err("Error %d on %s\n", status
, __func__
);
5854 static int write_gpio(struct drxk_state
*state
)
5860 /* stop lock indicator process */
5861 status
= write16(state
, SCU_RAM_GPIO__A
,
5862 SCU_RAM_GPIO_HW_LOCK_IND_DISABLE
);
5866 /* Write magic word to enable pdr reg write */
5867 status
= write16(state
, SIO_TOP_COMM_KEY__A
, SIO_TOP_COMM_KEY_KEY
);
5871 if (state
->m_has_sawsw
) {
5872 if (state
->uio_mask
& 0x0001) { /* UIO-1 */
5873 /* write to io pad configuration register - output mode */
5874 status
= write16(state
, SIO_PDR_SMA_TX_CFG__A
,
5879 /* use corresponding bit in io data output registar */
5880 status
= read16(state
, SIO_PDR_UIO_OUT_LO__A
, &value
);
5883 if ((state
->m_gpio
& 0x0001) == 0)
5884 value
&= 0x7FFF; /* write zero to 15th bit - 1st UIO */
5886 value
|= 0x8000; /* write one to 15th bit - 1st UIO */
5887 /* write back to io data output register */
5888 status
= write16(state
, SIO_PDR_UIO_OUT_LO__A
, value
);
5892 if (state
->uio_mask
& 0x0002) { /* UIO-2 */
5893 /* write to io pad configuration register - output mode */
5894 status
= write16(state
, SIO_PDR_SMA_RX_CFG__A
,
5899 /* use corresponding bit in io data output registar */
5900 status
= read16(state
, SIO_PDR_UIO_OUT_LO__A
, &value
);
5903 if ((state
->m_gpio
& 0x0002) == 0)
5904 value
&= 0xBFFF; /* write zero to 14th bit - 2st UIO */
5906 value
|= 0x4000; /* write one to 14th bit - 2st UIO */
5907 /* write back to io data output register */
5908 status
= write16(state
, SIO_PDR_UIO_OUT_LO__A
, value
);
5912 if (state
->uio_mask
& 0x0004) { /* UIO-3 */
5913 /* write to io pad configuration register - output mode */
5914 status
= write16(state
, SIO_PDR_GPIO_CFG__A
,
5919 /* use corresponding bit in io data output registar */
5920 status
= read16(state
, SIO_PDR_UIO_OUT_LO__A
, &value
);
5923 if ((state
->m_gpio
& 0x0004) == 0)
5924 value
&= 0xFFFB; /* write zero to 2nd bit - 3rd UIO */
5926 value
|= 0x0004; /* write one to 2nd bit - 3rd UIO */
5927 /* write back to io data output register */
5928 status
= write16(state
, SIO_PDR_UIO_OUT_LO__A
, value
);
5933 /* Write magic word to disable pdr reg write */
5934 status
= write16(state
, SIO_TOP_COMM_KEY__A
, 0x0000);
5937 pr_err("Error %d on %s\n", status
, __func__
);
5941 static int switch_antenna_to_qam(struct drxk_state
*state
)
5948 if (!state
->antenna_gpio
)
5951 gpio_state
= state
->m_gpio
& state
->antenna_gpio
;
5953 if (state
->antenna_dvbt
^ gpio_state
) {
5954 /* Antenna is on DVB-T mode. Switch */
5955 if (state
->antenna_dvbt
)
5956 state
->m_gpio
&= ~state
->antenna_gpio
;
5958 state
->m_gpio
|= state
->antenna_gpio
;
5959 status
= write_gpio(state
);
5962 pr_err("Error %d on %s\n", status
, __func__
);
5966 static int switch_antenna_to_dvbt(struct drxk_state
*state
)
5973 if (!state
->antenna_gpio
)
5976 gpio_state
= state
->m_gpio
& state
->antenna_gpio
;
5978 if (!(state
->antenna_dvbt
^ gpio_state
)) {
5979 /* Antenna is on DVB-C mode. Switch */
5980 if (state
->antenna_dvbt
)
5981 state
->m_gpio
|= state
->antenna_gpio
;
5983 state
->m_gpio
&= ~state
->antenna_gpio
;
5984 status
= write_gpio(state
);
5987 pr_err("Error %d on %s\n", status
, __func__
);
5992 static int power_down_device(struct drxk_state
*state
)
5994 /* Power down to requested mode */
5995 /* Backup some register settings */
5996 /* Set pins with possible pull-ups connected to them in input mode */
5997 /* Analog power down */
5998 /* ADC power down */
5999 /* Power down device */
6003 if (state
->m_b_p_down_open_bridge
) {
6004 /* Open I2C bridge before power down of DRXK */
6005 status
= ConfigureI2CBridge(state
, true);
6010 status
= dvbt_enable_ofdm_token_ring(state
, false);
6014 status
= write16(state
, SIO_CC_PWD_MODE__A
,
6015 SIO_CC_PWD_MODE_LEVEL_CLOCK
);
6018 status
= write16(state
, SIO_CC_UPDATE__A
, SIO_CC_UPDATE_KEY
);
6021 state
->m_hi_cfg_ctrl
|= SIO_HI_RA_RAM_PAR_5_CFG_SLEEP_ZZZ
;
6022 status
= hi_cfg_command(state
);
6025 pr_err("Error %d on %s\n", status
, __func__
);
6030 static int init_drxk(struct drxk_state
*state
)
6032 int status
= 0, n
= 0;
6033 enum drx_power_mode power_mode
= DRXK_POWER_DOWN_OFDM
;
6037 if (state
->m_drxk_state
== DRXK_UNINITIALIZED
) {
6038 drxk_i2c_lock(state
);
6039 status
= power_up_device(state
);
6042 status
= drxx_open(state
);
6045 /* Soft reset of OFDM-, sys- and osc-clockdomain */
6046 status
= write16(state
, SIO_CC_SOFT_RST__A
,
6047 SIO_CC_SOFT_RST_OFDM__M
6048 | SIO_CC_SOFT_RST_SYS__M
6049 | SIO_CC_SOFT_RST_OSC__M
);
6052 status
= write16(state
, SIO_CC_UPDATE__A
, SIO_CC_UPDATE_KEY
);
6056 * TODO is this needed? If yes, how much delay in
6057 * worst case scenario
6059 usleep_range(1000, 2000);
6060 state
->m_drxk_a3_patch_code
= true;
6061 status
= get_device_capabilities(state
);
6065 /* Bridge delay, uses oscilator clock */
6066 /* Delay = (delay (nano seconds) * oscclk (kHz))/ 1000 */
6067 /* SDA brdige delay */
6068 state
->m_hi_cfg_bridge_delay
=
6069 (u16
) ((state
->m_osc_clock_freq
/ 1000) *
6070 HI_I2C_BRIDGE_DELAY
) / 1000;
6072 if (state
->m_hi_cfg_bridge_delay
>
6073 SIO_HI_RA_RAM_PAR_3_CFG_DBL_SDA__M
) {
6074 state
->m_hi_cfg_bridge_delay
=
6075 SIO_HI_RA_RAM_PAR_3_CFG_DBL_SDA__M
;
6077 /* SCL bridge delay, same as SDA for now */
6078 state
->m_hi_cfg_bridge_delay
+=
6079 state
->m_hi_cfg_bridge_delay
<<
6080 SIO_HI_RA_RAM_PAR_3_CFG_DBL_SCL__B
;
6082 status
= init_hi(state
);
6085 /* disable various processes */
6087 if (!(state
->m_DRXK_A1_ROM_CODE
)
6088 && !(state
->m_DRXK_A2_ROM_CODE
))
6091 status
= write16(state
, SCU_RAM_GPIO__A
,
6092 SCU_RAM_GPIO_HW_LOCK_IND_DISABLE
);
6097 /* disable MPEG port */
6098 status
= mpegts_disable(state
);
6102 /* Stop AUD and SCU */
6103 status
= write16(state
, AUD_COMM_EXEC__A
, AUD_COMM_EXEC_STOP
);
6106 status
= write16(state
, SCU_COMM_EXEC__A
, SCU_COMM_EXEC_STOP
);
6110 /* enable token-ring bus through OFDM block for possible ucode upload */
6111 status
= write16(state
, SIO_OFDM_SH_OFDM_RING_ENABLE__A
,
6112 SIO_OFDM_SH_OFDM_RING_ENABLE_ON
);
6116 /* include boot loader section */
6117 status
= write16(state
, SIO_BL_COMM_EXEC__A
,
6118 SIO_BL_COMM_EXEC_ACTIVE
);
6121 status
= bl_chain_cmd(state
, 0, 6, 100);
6126 status
= download_microcode(state
, state
->fw
->data
,
6132 /* disable token-ring bus through OFDM block for possible ucode upload */
6133 status
= write16(state
, SIO_OFDM_SH_OFDM_RING_ENABLE__A
,
6134 SIO_OFDM_SH_OFDM_RING_ENABLE_OFF
);
6138 /* Run SCU for a little while to initialize microcode version numbers */
6139 status
= write16(state
, SCU_COMM_EXEC__A
, SCU_COMM_EXEC_ACTIVE
);
6142 status
= drxx_open(state
);
6145 /* added for test */
6148 power_mode
= DRXK_POWER_DOWN_OFDM
;
6149 status
= ctrl_power_mode(state
, &power_mode
);
6153 /* Stamp driver version number in SCU data RAM in BCD code
6154 Done to enable field application engineers to retrieve drxdriver version
6155 via I2C from SCU RAM.
6156 Not using SCU command interface for SCU register access since no
6157 microcode may be present.
6160 (((DRXK_VERSION_MAJOR
/ 100) % 10) << 12) +
6161 (((DRXK_VERSION_MAJOR
/ 10) % 10) << 8) +
6162 ((DRXK_VERSION_MAJOR
% 10) << 4) +
6163 (DRXK_VERSION_MINOR
% 10);
6164 status
= write16(state
, SCU_RAM_DRIVER_VER_HI__A
,
6169 (((DRXK_VERSION_PATCH
/ 1000) % 10) << 12) +
6170 (((DRXK_VERSION_PATCH
/ 100) % 10) << 8) +
6171 (((DRXK_VERSION_PATCH
/ 10) % 10) << 4) +
6172 (DRXK_VERSION_PATCH
% 10);
6173 status
= write16(state
, SCU_RAM_DRIVER_VER_LO__A
,
6178 pr_info("DRXK driver version %d.%d.%d\n",
6179 DRXK_VERSION_MAJOR
, DRXK_VERSION_MINOR
,
6180 DRXK_VERSION_PATCH
);
6183 * Dirty fix of default values for ROM/PATCH microcode
6184 * Dirty because this fix makes it impossible to setup
6185 * suitable values before calling DRX_Open. This solution
6186 * requires changes to RF AGC speed to be done via the CTRL
6187 * function after calling DRX_Open
6190 /* m_dvbt_rf_agc_cfg.speed = 3; */
6192 /* Reset driver debug flags to 0 */
6193 status
= write16(state
, SCU_RAM_DRIVER_DEBUG__A
, 0);
6198 NOTE: No more full FEC resets allowed afterwards!! */
6199 status
= write16(state
, FEC_COMM_EXEC__A
, FEC_COMM_EXEC_STOP
);
6202 /* MPEGTS functions are still the same */
6203 status
= mpegts_dto_init(state
);
6206 status
= mpegts_stop(state
);
6209 status
= mpegts_configure_polarity(state
);
6212 status
= mpegts_configure_pins(state
, state
->m_enable_mpeg_output
);
6215 /* added: configure GPIO */
6216 status
= write_gpio(state
);
6220 state
->m_drxk_state
= DRXK_STOPPED
;
6222 if (state
->m_b_power_down
) {
6223 status
= power_down_device(state
);
6226 state
->m_drxk_state
= DRXK_POWERED_DOWN
;
6228 state
->m_drxk_state
= DRXK_STOPPED
;
6230 /* Initialize the supported delivery systems */
6232 if (state
->m_has_dvbc
) {
6233 state
->frontend
.ops
.delsys
[n
++] = SYS_DVBC_ANNEX_A
;
6234 state
->frontend
.ops
.delsys
[n
++] = SYS_DVBC_ANNEX_C
;
6235 strlcat(state
->frontend
.ops
.info
.name
, " DVB-C",
6236 sizeof(state
->frontend
.ops
.info
.name
));
6238 if (state
->m_has_dvbt
) {
6239 state
->frontend
.ops
.delsys
[n
++] = SYS_DVBT
;
6240 strlcat(state
->frontend
.ops
.info
.name
, " DVB-T",
6241 sizeof(state
->frontend
.ops
.info
.name
));
6243 drxk_i2c_unlock(state
);
6247 state
->m_drxk_state
= DRXK_NO_DEV
;
6248 drxk_i2c_unlock(state
);
6249 pr_err("Error %d on %s\n", status
, __func__
);
6255 static void load_firmware_cb(const struct firmware
*fw
,
6258 struct drxk_state
*state
= context
;
6260 dprintk(1, ": %s\n", fw
? "firmware loaded" : "firmware not loaded");
6262 pr_err("Could not load firmware file %s.\n",
6263 state
->microcode_name
);
6264 pr_info("Copy %s to your hotplug directory!\n",
6265 state
->microcode_name
);
6266 state
->microcode_name
= NULL
;
6269 * As firmware is now load asynchronous, it is not possible
6270 * anymore to fail at frontend attach. We might silently
6271 * return here, and hope that the driver won't crash.
6272 * We might also change all DVB callbacks to return -ENODEV
6273 * if the device is not initialized.
6274 * As the DRX-K devices have their own internal firmware,
6275 * let's just hope that it will match a firmware revision
6276 * compatible with this driver and proceed.
6284 static void drxk_release(struct dvb_frontend
*fe
)
6286 struct drxk_state
*state
= fe
->demodulator_priv
;
6289 release_firmware(state
->fw
);
6294 static int drxk_sleep(struct dvb_frontend
*fe
)
6296 struct drxk_state
*state
= fe
->demodulator_priv
;
6300 if (state
->m_drxk_state
== DRXK_NO_DEV
)
6302 if (state
->m_drxk_state
== DRXK_UNINITIALIZED
)
6309 static int drxk_gate_ctrl(struct dvb_frontend
*fe
, int enable
)
6311 struct drxk_state
*state
= fe
->demodulator_priv
;
6313 dprintk(1, ": %s\n", enable
? "enable" : "disable");
6315 if (state
->m_drxk_state
== DRXK_NO_DEV
)
6318 return ConfigureI2CBridge(state
, enable
? true : false);
6321 static int drxk_set_parameters(struct dvb_frontend
*fe
)
6323 struct dtv_frontend_properties
*p
= &fe
->dtv_property_cache
;
6324 u32 delsys
= p
->delivery_system
, old_delsys
;
6325 struct drxk_state
*state
= fe
->demodulator_priv
;
6330 if (state
->m_drxk_state
== DRXK_NO_DEV
)
6333 if (state
->m_drxk_state
== DRXK_UNINITIALIZED
)
6336 if (!fe
->ops
.tuner_ops
.get_if_frequency
) {
6337 pr_err("Error: get_if_frequency() not defined at tuner. Can't work without it!\n");
6341 if (fe
->ops
.i2c_gate_ctrl
)
6342 fe
->ops
.i2c_gate_ctrl(fe
, 1);
6343 if (fe
->ops
.tuner_ops
.set_params
)
6344 fe
->ops
.tuner_ops
.set_params(fe
);
6345 if (fe
->ops
.i2c_gate_ctrl
)
6346 fe
->ops
.i2c_gate_ctrl(fe
, 0);
6348 old_delsys
= state
->props
.delivery_system
;
6351 if (old_delsys
!= delsys
) {
6354 case SYS_DVBC_ANNEX_A
:
6355 case SYS_DVBC_ANNEX_C
:
6356 if (!state
->m_has_dvbc
)
6358 state
->m_itut_annex_c
= (delsys
== SYS_DVBC_ANNEX_C
) ?
6360 if (state
->m_itut_annex_c
)
6361 setoperation_mode(state
, OM_QAM_ITU_C
);
6363 setoperation_mode(state
, OM_QAM_ITU_A
);
6366 if (!state
->m_has_dvbt
)
6368 setoperation_mode(state
, OM_DVBT
);
6375 fe
->ops
.tuner_ops
.get_if_frequency(fe
, &IF
);
6376 start(state
, 0, IF
);
6378 /* After set_frontend, stats aren't available */
6379 p
->strength
.stat
[0].scale
= FE_SCALE_RELATIVE
;
6380 p
->cnr
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6381 p
->block_error
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6382 p
->block_count
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6383 p
->pre_bit_error
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6384 p
->pre_bit_count
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6385 p
->post_bit_error
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6386 p
->post_bit_count
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6388 /* printk(KERN_DEBUG "drxk: %s IF=%d done\n", __func__, IF); */
6393 static int get_strength(struct drxk_state
*state
, u64
*strength
)
6396 struct s_cfg_agc rf_agc
, if_agc
;
6402 /* FIXME: those are part of the tuner presets */
6403 u16 tuner_rf_gain
= 50; /* Default value on az6007 driver */
6404 u16 tuner_if_gain
= 40; /* Default value on az6007 driver */
6408 if (is_dvbt(state
)) {
6409 rf_agc
= state
->m_dvbt_rf_agc_cfg
;
6410 if_agc
= state
->m_dvbt_if_agc_cfg
;
6411 } else if (is_qam(state
)) {
6412 rf_agc
= state
->m_qam_rf_agc_cfg
;
6413 if_agc
= state
->m_qam_if_agc_cfg
;
6415 rf_agc
= state
->m_atv_rf_agc_cfg
;
6416 if_agc
= state
->m_atv_if_agc_cfg
;
6419 if (rf_agc
.ctrl_mode
== DRXK_AGC_CTRL_AUTO
) {
6420 /* SCU output_level */
6421 status
= read16(state
, SCU_RAM_AGC_RF_IACCU_HI__A
, &scu_lvl
);
6426 status
= read16(state
, SCU_RAM_AGC_RF_IACCU_HI_CO__A
, &scu_coc
);
6430 if (((u32
) scu_lvl
+ (u32
) scu_coc
) < 0xffff)
6431 rf_agc
.output_level
= scu_lvl
+ scu_coc
;
6433 rf_agc
.output_level
= 0xffff;
6435 /* Take RF gain into account */
6436 total_gain
+= tuner_rf_gain
;
6438 /* clip output value */
6439 if (rf_agc
.output_level
< rf_agc
.min_output_level
)
6440 rf_agc
.output_level
= rf_agc
.min_output_level
;
6441 if (rf_agc
.output_level
> rf_agc
.max_output_level
)
6442 rf_agc
.output_level
= rf_agc
.max_output_level
;
6444 agc_range
= (u32
) (rf_agc
.max_output_level
- rf_agc
.min_output_level
);
6445 if (agc_range
> 0) {
6447 ((u32
)(tuner_rf_gain
)) *
6448 ((u32
)(rf_agc
.output_level
- rf_agc
.min_output_level
))
6453 if (if_agc
.ctrl_mode
== DRXK_AGC_CTRL_AUTO
) {
6454 status
= read16(state
, SCU_RAM_AGC_IF_IACCU_HI__A
,
6455 &if_agc
.output_level
);
6459 status
= read16(state
, SCU_RAM_AGC_INGAIN_TGT_MIN__A
,
6464 /* Take IF gain into account */
6465 total_gain
+= (u32
) tuner_if_gain
;
6467 /* clip output value */
6468 if (if_agc
.output_level
< if_agc
.min_output_level
)
6469 if_agc
.output_level
= if_agc
.min_output_level
;
6470 if (if_agc
.output_level
> if_agc
.max_output_level
)
6471 if_agc
.output_level
= if_agc
.max_output_level
;
6473 agc_range
= (u32
)(if_agc
.max_output_level
- if_agc
.min_output_level
);
6474 if (agc_range
> 0) {
6476 ((u32
)(tuner_if_gain
)) *
6477 ((u32
)(if_agc
.output_level
- if_agc
.min_output_level
))
6483 * Convert to 0..65535 scale.
6484 * If it can't be measured (AGC is disabled), just show 100%.
6487 *strength
= (65535UL * atten
/ total_gain
/ 100);
6494 static int drxk_get_stats(struct dvb_frontend
*fe
)
6496 struct dtv_frontend_properties
*c
= &fe
->dtv_property_cache
;
6497 struct drxk_state
*state
= fe
->demodulator_priv
;
6502 u32 post_bit_err_count
;
6503 u32 post_bit_error_scale
;
6504 u32 pre_bit_err_count
;
6507 u32 pkt_error_count
;
6510 if (state
->m_drxk_state
== DRXK_NO_DEV
)
6512 if (state
->m_drxk_state
== DRXK_UNINITIALIZED
)
6516 state
->fe_status
= 0;
6517 get_lock_status(state
, &stat
);
6518 if (stat
== MPEG_LOCK
)
6519 state
->fe_status
|= 0x1f;
6520 if (stat
== FEC_LOCK
)
6521 state
->fe_status
|= 0x0f;
6522 if (stat
== DEMOD_LOCK
)
6523 state
->fe_status
|= 0x07;
6526 * Estimate signal strength from AGC
6528 get_strength(state
, &c
->strength
.stat
[0].uvalue
);
6529 c
->strength
.stat
[0].scale
= FE_SCALE_RELATIVE
;
6532 if (stat
>= DEMOD_LOCK
) {
6533 get_signal_to_noise(state
, &cnr
);
6534 c
->cnr
.stat
[0].svalue
= cnr
* 100;
6535 c
->cnr
.stat
[0].scale
= FE_SCALE_DECIBEL
;
6537 c
->cnr
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6540 if (stat
< FEC_LOCK
) {
6541 c
->block_error
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6542 c
->block_count
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6543 c
->pre_bit_error
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6544 c
->pre_bit_count
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6545 c
->post_bit_error
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6546 c
->post_bit_count
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6552 /* BER measurement is valid if at least FEC lock is achieved */
6555 * OFDM_EC_VD_REQ_SMB_CNT__A and/or OFDM_EC_VD_REQ_BIT_CNT can be
6556 * written to set nr of symbols or bits over which to measure
6557 * EC_VD_REG_ERR_BIT_CNT__A . See CtrlSetCfg().
6560 /* Read registers for post/preViterbi BER calculation */
6561 status
= read16(state
, OFDM_EC_VD_ERR_BIT_CNT__A
, ®16
);
6564 pre_bit_err_count
= reg16
;
6566 status
= read16(state
, OFDM_EC_VD_IN_BIT_CNT__A
, ®16
);
6569 pre_bit_count
= reg16
;
6571 /* Number of bit-errors */
6572 status
= read16(state
, FEC_RS_NR_BIT_ERRORS__A
, ®16
);
6575 post_bit_err_count
= reg16
;
6577 status
= read16(state
, FEC_RS_MEASUREMENT_PRESCALE__A
, ®16
);
6580 post_bit_error_scale
= reg16
;
6582 status
= read16(state
, FEC_RS_MEASUREMENT_PERIOD__A
, ®16
);
6587 status
= read16(state
, SCU_RAM_FEC_ACCUM_PKT_FAILURES__A
, ®16
);
6590 pkt_error_count
= reg16
;
6591 write16(state
, SCU_RAM_FEC_ACCUM_PKT_FAILURES__A
, 0);
6593 post_bit_err_count
*= post_bit_error_scale
;
6595 post_bit_count
= pkt_count
* 204 * 8;
6597 /* Store the results */
6598 c
->block_error
.stat
[0].scale
= FE_SCALE_COUNTER
;
6599 c
->block_error
.stat
[0].uvalue
+= pkt_error_count
;
6600 c
->block_count
.stat
[0].scale
= FE_SCALE_COUNTER
;
6601 c
->block_count
.stat
[0].uvalue
+= pkt_count
;
6603 c
->pre_bit_error
.stat
[0].scale
= FE_SCALE_COUNTER
;
6604 c
->pre_bit_error
.stat
[0].uvalue
+= pre_bit_err_count
;
6605 c
->pre_bit_count
.stat
[0].scale
= FE_SCALE_COUNTER
;
6606 c
->pre_bit_count
.stat
[0].uvalue
+= pre_bit_count
;
6608 c
->post_bit_error
.stat
[0].scale
= FE_SCALE_COUNTER
;
6609 c
->post_bit_error
.stat
[0].uvalue
+= post_bit_err_count
;
6610 c
->post_bit_count
.stat
[0].scale
= FE_SCALE_COUNTER
;
6611 c
->post_bit_count
.stat
[0].uvalue
+= post_bit_count
;
6618 static int drxk_read_status(struct dvb_frontend
*fe
, enum fe_status
*status
)
6620 struct drxk_state
*state
= fe
->demodulator_priv
;
6625 rc
= drxk_get_stats(fe
);
6629 *status
= state
->fe_status
;
6634 static int drxk_read_signal_strength(struct dvb_frontend
*fe
,
6637 struct drxk_state
*state
= fe
->demodulator_priv
;
6638 struct dtv_frontend_properties
*c
= &fe
->dtv_property_cache
;
6642 if (state
->m_drxk_state
== DRXK_NO_DEV
)
6644 if (state
->m_drxk_state
== DRXK_UNINITIALIZED
)
6647 *strength
= c
->strength
.stat
[0].uvalue
;
6651 static int drxk_read_snr(struct dvb_frontend
*fe
, u16
*snr
)
6653 struct drxk_state
*state
= fe
->demodulator_priv
;
6658 if (state
->m_drxk_state
== DRXK_NO_DEV
)
6660 if (state
->m_drxk_state
== DRXK_UNINITIALIZED
)
6663 get_signal_to_noise(state
, &snr2
);
6665 /* No negative SNR, clip to zero */
6668 *snr
= snr2
& 0xffff;
6672 static int drxk_read_ucblocks(struct dvb_frontend
*fe
, u32
*ucblocks
)
6674 struct drxk_state
*state
= fe
->demodulator_priv
;
6679 if (state
->m_drxk_state
== DRXK_NO_DEV
)
6681 if (state
->m_drxk_state
== DRXK_UNINITIALIZED
)
6684 dvbtqam_get_acc_pkt_err(state
, &err
);
6685 *ucblocks
= (u32
) err
;
6689 static int drxk_get_tune_settings(struct dvb_frontend
*fe
,
6690 struct dvb_frontend_tune_settings
*sets
)
6692 struct drxk_state
*state
= fe
->demodulator_priv
;
6693 struct dtv_frontend_properties
*p
= &fe
->dtv_property_cache
;
6697 if (state
->m_drxk_state
== DRXK_NO_DEV
)
6699 if (state
->m_drxk_state
== DRXK_UNINITIALIZED
)
6702 switch (p
->delivery_system
) {
6703 case SYS_DVBC_ANNEX_A
:
6704 case SYS_DVBC_ANNEX_C
:
6706 sets
->min_delay_ms
= 3000;
6707 sets
->max_drift
= 0;
6708 sets
->step_size
= 0;
6715 static const struct dvb_frontend_ops drxk_ops
= {
6716 /* .delsys will be filled dynamically */
6719 .frequency_min_hz
= 47 * MHz
,
6720 .frequency_max_hz
= 865 * MHz
,
6722 .symbol_rate_min
= 870000,
6723 .symbol_rate_max
= 11700000,
6725 .frequency_stepsize_hz
= 166667,
6727 .caps
= FE_CAN_QAM_16
| FE_CAN_QAM_32
| FE_CAN_QAM_64
|
6728 FE_CAN_QAM_128
| FE_CAN_QAM_256
| FE_CAN_FEC_AUTO
|
6729 FE_CAN_FEC_1_2
| FE_CAN_FEC_2_3
| FE_CAN_FEC_3_4
|
6730 FE_CAN_FEC_5_6
| FE_CAN_FEC_7_8
| FE_CAN_MUTE_TS
|
6731 FE_CAN_TRANSMISSION_MODE_AUTO
| FE_CAN_RECOVER
|
6732 FE_CAN_GUARD_INTERVAL_AUTO
| FE_CAN_HIERARCHY_AUTO
6735 .release
= drxk_release
,
6736 .sleep
= drxk_sleep
,
6737 .i2c_gate_ctrl
= drxk_gate_ctrl
,
6739 .set_frontend
= drxk_set_parameters
,
6740 .get_tune_settings
= drxk_get_tune_settings
,
6742 .read_status
= drxk_read_status
,
6743 .read_signal_strength
= drxk_read_signal_strength
,
6744 .read_snr
= drxk_read_snr
,
6745 .read_ucblocks
= drxk_read_ucblocks
,
6748 struct dvb_frontend
*drxk_attach(const struct drxk_config
*config
,
6749 struct i2c_adapter
*i2c
)
6751 struct dtv_frontend_properties
*p
;
6752 struct drxk_state
*state
= NULL
;
6753 u8 adr
= config
->adr
;
6757 state
= kzalloc(sizeof(struct drxk_state
), GFP_KERNEL
);
6762 state
->demod_address
= adr
;
6763 state
->single_master
= config
->single_master
;
6764 state
->microcode_name
= config
->microcode_name
;
6765 state
->qam_demod_parameter_count
= config
->qam_demod_parameter_count
;
6766 state
->no_i2c_bridge
= config
->no_i2c_bridge
;
6767 state
->antenna_gpio
= config
->antenna_gpio
;
6768 state
->antenna_dvbt
= config
->antenna_dvbt
;
6769 state
->m_chunk_size
= config
->chunk_size
;
6770 state
->enable_merr_cfg
= config
->enable_merr_cfg
;
6772 if (config
->dynamic_clk
) {
6773 state
->m_dvbt_static_clk
= false;
6774 state
->m_dvbc_static_clk
= false;
6776 state
->m_dvbt_static_clk
= true;
6777 state
->m_dvbc_static_clk
= true;
6781 if (config
->mpeg_out_clk_strength
)
6782 state
->m_ts_clockk_strength
= config
->mpeg_out_clk_strength
& 0x07;
6784 state
->m_ts_clockk_strength
= 0x06;
6786 if (config
->parallel_ts
)
6787 state
->m_enable_parallel
= true;
6789 state
->m_enable_parallel
= false;
6791 /* NOTE: as more UIO bits will be used, add them to the mask */
6792 state
->uio_mask
= config
->antenna_gpio
;
6794 /* Default gpio to DVB-C */
6795 if (!state
->antenna_dvbt
&& state
->antenna_gpio
)
6796 state
->m_gpio
|= state
->antenna_gpio
;
6798 state
->m_gpio
&= ~state
->antenna_gpio
;
6800 mutex_init(&state
->mutex
);
6802 memcpy(&state
->frontend
.ops
, &drxk_ops
, sizeof(drxk_ops
));
6803 state
->frontend
.demodulator_priv
= state
;
6807 /* Load firmware and initialize DRX-K */
6808 if (state
->microcode_name
) {
6809 const struct firmware
*fw
= NULL
;
6811 status
= request_firmware(&fw
, state
->microcode_name
,
6812 state
->i2c
->dev
.parent
);
6815 load_firmware_cb(fw
, state
);
6816 } else if (init_drxk(state
) < 0)
6820 /* Initialize stats */
6821 p
= &state
->frontend
.dtv_property_cache
;
6822 p
->strength
.len
= 1;
6824 p
->block_error
.len
= 1;
6825 p
->block_count
.len
= 1;
6826 p
->pre_bit_error
.len
= 1;
6827 p
->pre_bit_count
.len
= 1;
6828 p
->post_bit_error
.len
= 1;
6829 p
->post_bit_count
.len
= 1;
6831 p
->strength
.stat
[0].scale
= FE_SCALE_RELATIVE
;
6832 p
->cnr
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6833 p
->block_error
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6834 p
->block_count
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6835 p
->pre_bit_error
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6836 p
->pre_bit_count
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6837 p
->post_bit_error
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6838 p
->post_bit_count
.stat
[0].scale
= FE_SCALE_NOT_AVAILABLE
;
6840 pr_info("frontend initialized.\n");
6841 return &state
->frontend
;
6844 pr_err("not found\n");
6848 EXPORT_SYMBOL(drxk_attach
);
6850 MODULE_DESCRIPTION("DRX-K driver");
6851 MODULE_AUTHOR("Ralph Metzler");
6852 MODULE_LICENSE("GPL");