123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557 |
- /*****************************************************************************
- Copyright(c) 2013 FCI Inc. All Rights Reserved
- File name : fc8080_bb.c
- Description : baseband source file
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- History :
- ----------------------------------------------------------------------
- *******************************************************************************/
- #include <linux/kernel.h>
- #include "fci_types.h"
- #include "fci_oal.h"
- #include "fci_hal.h"
- #include "fci_tun.h"
- #include "fc8080_regs.h"
- #define POWER_SAVE_MODE
- #define LOCK_TIME_TICK 5 /* 5ms */
- #define SLOCK_MAX_TIME 200
- #define FLOCK_MAX_TIME 300
- #define DLOCK_MAX_TIME 500
- static s32 fc8080_set_xtal(HANDLE handle)
- {
- #if (FC8080_FREQ_XTAL == 24576)
- bbm_long_write(handle, BBM_NCO_OFFSET, 0x04000000);
- bbm_byte_write(handle, BBM_NCO_INV, 0x80);
- bbm_byte_write(handle, BBM_EZ_CONST, 0x80);
- bbm_byte_write(handle, BBM_CLK_MODE, 0x02);
- /* filter coefficient */
- bbm_byte_write(handle, BBM_COEF00, 0x02);
- bbm_byte_write(handle, BBM_COEF01, 0x0f);
- bbm_byte_write(handle, BBM_COEF02, 0x0d);
- bbm_byte_write(handle, BBM_COEF03, 0x00);
- bbm_byte_write(handle, BBM_COEF04, 0x04);
- bbm_byte_write(handle, BBM_COEF05, 0x03);
- bbm_byte_write(handle, BBM_COEF06, 0x1c);
- bbm_byte_write(handle, BBM_COEF07, 0x19);
- bbm_byte_write(handle, BBM_COEF08, 0x02);
- bbm_byte_write(handle, BBM_COEF09, 0x0c);
- bbm_byte_write(handle, BBM_COEF0A, 0x04);
- bbm_byte_write(handle, BBM_COEF0B, 0x30);
- bbm_byte_write(handle, BBM_COEF0C, 0xed);
- bbm_byte_write(handle, BBM_COEF0D, 0x13);
- bbm_byte_write(handle, BBM_COEF0E, 0x4f);
- bbm_byte_write(handle, BBM_COEF0F, 0x6b);
- #elif (FC8080_FREQ_XTAL == 16384)
- /* clock mode */
- bbm_long_write(handle, BBM_NCO_OFFSET, 0x04000000);
- bbm_byte_write(handle, BBM_NCO_INV, 0x80);
- bbm_byte_write(handle, BBM_EZ_CONST, 0x80);
- bbm_byte_write(handle, BBM_CLK_MODE, 0x00);
- /* filter coefficient */
- bbm_byte_write(handle, BBM_COEF00, 0x02);
- bbm_byte_write(handle, BBM_COEF01, 0x0f);
- bbm_byte_write(handle, BBM_COEF02, 0x0d);
- bbm_byte_write(handle, BBM_COEF03, 0x00);
- bbm_byte_write(handle, BBM_COEF04, 0x04);
- bbm_byte_write(handle, BBM_COEF05, 0x03);
- bbm_byte_write(handle, BBM_COEF06, 0x1c);
- bbm_byte_write(handle, BBM_COEF07, 0x19);
- bbm_byte_write(handle, BBM_COEF08, 0x02);
- bbm_byte_write(handle, BBM_COEF09, 0x0c);
- bbm_byte_write(handle, BBM_COEF0A, 0x04);
- bbm_byte_write(handle, BBM_COEF0B, 0x30);
- bbm_byte_write(handle, BBM_COEF0C, 0xed);
- bbm_byte_write(handle, BBM_COEF0D, 0x13);
- bbm_byte_write(handle, BBM_COEF0E, 0x4f);
- bbm_byte_write(handle, BBM_COEF0F, 0x6b);
- #elif (FC8080_FREQ_XTAL == 19200)
- bbm_long_write(handle, BBM_NCO_OFFSET, 0x0369d037);
- bbm_byte_write(handle, BBM_NCO_INV, 0x96);
- bbm_byte_write(handle, BBM_EZ_CONST, 0x6d);
- bbm_byte_write(handle, BBM_CLK_MODE, 0x00);
- /* filter coefficient */
- bbm_byte_write(handle, BBM_COEF00, 0x0e);
- bbm_byte_write(handle, BBM_COEF01, 0x00);
- bbm_byte_write(handle, BBM_COEF02, 0x03);
- bbm_byte_write(handle, BBM_COEF03, 0x03);
- bbm_byte_write(handle, BBM_COEF04, 0x1f);
- bbm_byte_write(handle, BBM_COEF05, 0x1a);
- bbm_byte_write(handle, BBM_COEF06, 0x1b);
- bbm_byte_write(handle, BBM_COEF07, 0x03);
- bbm_byte_write(handle, BBM_COEF08, 0x0a);
- bbm_byte_write(handle, BBM_COEF09, 0x05);
- bbm_byte_write(handle, BBM_COEF0A, 0x37);
- bbm_byte_write(handle, BBM_COEF0B, 0x2d);
- bbm_byte_write(handle, BBM_COEF0C, 0xfa);
- bbm_byte_write(handle, BBM_COEF0D, 0x1f);
- bbm_byte_write(handle, BBM_COEF0E, 0x49);
- bbm_byte_write(handle, BBM_COEF0F, 0x5c);
- #elif (FC8080_FREQ_XTAL == 24000)
- bbm_long_write(handle, BBM_NCO_OFFSET, 0x02bb0cf8);
- bbm_byte_write(handle, BBM_NCO_INV, 0xbc);
- bbm_byte_write(handle, BBM_EZ_CONST, 0x57);
- bbm_byte_write(handle, BBM_CLK_MODE, 0x00);
- /* filter coefficient */
- bbm_byte_write(handle, BBM_COEF00, 0x02);
- bbm_byte_write(handle, BBM_COEF01, 0x02);
- bbm_byte_write(handle, BBM_COEF02, 0x00);
- bbm_byte_write(handle, BBM_COEF03, 0x0c);
- bbm_byte_write(handle, BBM_COEF04, 0x1c);
- bbm_byte_write(handle, BBM_COEF05, 0x1f);
- bbm_byte_write(handle, BBM_COEF06, 0x05);
- bbm_byte_write(handle, BBM_COEF07, 0x08);
- bbm_byte_write(handle, BBM_COEF08, 0x04);
- bbm_byte_write(handle, BBM_COEF09, 0x3a);
- bbm_byte_write(handle, BBM_COEF0A, 0x31);
- bbm_byte_write(handle, BBM_COEF0B, 0x34);
- bbm_byte_write(handle, BBM_COEF0C, 0x07);
- bbm_byte_write(handle, BBM_COEF0D, 0x26);
- bbm_byte_write(handle, BBM_COEF0E, 0x42);
- bbm_byte_write(handle, BBM_COEF0F, 0x4e);
- #elif (FC8080_FREQ_XTAL == 26000)
- bbm_long_write(handle, BBM_NCO_OFFSET, 0x03c7ea98);
- bbm_byte_write(handle, BBM_NCO_INV, 0x87);
- bbm_byte_write(handle, BBM_EZ_CONST, 0x79);
- bbm_byte_write(handle, BBM_CLK_MODE, 0x02);
- /* filter coefficient */
- bbm_byte_write(handle, BBM_COEF00, 0x0f);
- bbm_byte_write(handle, BBM_COEF01, 0x0d);
- bbm_byte_write(handle, BBM_COEF02, 0x0f);
- bbm_byte_write(handle, BBM_COEF03, 0x03);
- bbm_byte_write(handle, BBM_COEF04, 0x04);
- bbm_byte_write(handle, BBM_COEF05, 0x1f);
- bbm_byte_write(handle, BBM_COEF06, 0x19);
- bbm_byte_write(handle, BBM_COEF07, 0x1c);
- bbm_byte_write(handle, BBM_COEF08, 0x07);
- bbm_byte_write(handle, BBM_COEF09, 0x0b);
- bbm_byte_write(handle, BBM_COEF0A, 0x3f);
- bbm_byte_write(handle, BBM_COEF0B, 0x2d);
- bbm_byte_write(handle, BBM_COEF0C, 0xf2);
- bbm_byte_write(handle, BBM_COEF0D, 0x19);
- bbm_byte_write(handle, BBM_COEF0E, 0x4d);
- bbm_byte_write(handle, BBM_COEF0F, 0x65);
- #elif (FC8080_FREQ_XTAL == 27000)
- bbm_long_write(handle, BBM_NCO_OFFSET, 0x03a4114b);
- bbm_byte_write(handle, BBM_NCO_INV, 0x8d);
- bbm_byte_write(handle, BBM_EZ_CONST, 0x75);
- bbm_byte_write(handle, BBM_CLK_MODE, 0x02);
- /* filter coefficient */
- bbm_byte_write(handle, BBM_COEF00, 0x0e);
- bbm_byte_write(handle, BBM_COEF01, 0x0e);
- bbm_byte_write(handle, BBM_COEF02, 0x01);
- bbm_byte_write(handle, BBM_COEF03, 0x04);
- bbm_byte_write(handle, BBM_COEF04, 0x03);
- bbm_byte_write(handle, BBM_COEF05, 0x1d);
- bbm_byte_write(handle, BBM_COEF06, 0x19);
- bbm_byte_write(handle, BBM_COEF07, 0x1f);
- bbm_byte_write(handle, BBM_COEF08, 0x09);
- bbm_byte_write(handle, BBM_COEF09, 0x09);
- bbm_byte_write(handle, BBM_COEF0A, 0x3b);
- bbm_byte_write(handle, BBM_COEF0B, 0x2d);
- bbm_byte_write(handle, BBM_COEF0C, 0xf5);
- bbm_byte_write(handle, BBM_COEF0D, 0x1c);
- bbm_byte_write(handle, BBM_COEF0E, 0x4b);
- bbm_byte_write(handle, BBM_COEF0F, 0x61);
- #elif (FC8080_FREQ_XTAL == 27120)
- bbm_long_write(handle, BBM_NCO_OFFSET, 0x039ff180);
- bbm_byte_write(handle, BBM_NCO_INV, 0x8d);
- bbm_byte_write(handle, BBM_EZ_CONST, 0x74);
- bbm_byte_write(handle, BBM_CLK_MODE, 0x02);
- /* filter coefficient */
- bbm_byte_write(handle, BBM_COEF00, 0x0e);
- bbm_byte_write(handle, BBM_COEF01, 0x0e);
- bbm_byte_write(handle, BBM_COEF02, 0x01);
- bbm_byte_write(handle, BBM_COEF03, 0x04);
- bbm_byte_write(handle, BBM_COEF04, 0x03);
- bbm_byte_write(handle, BBM_COEF05, 0x1d);
- bbm_byte_write(handle, BBM_COEF06, 0x19);
- bbm_byte_write(handle, BBM_COEF07, 0x1f);
- bbm_byte_write(handle, BBM_COEF08, 0x09);
- bbm_byte_write(handle, BBM_COEF09, 0x09);
- bbm_byte_write(handle, BBM_COEF0A, 0x3b);
- bbm_byte_write(handle, BBM_COEF0B, 0x2d);
- bbm_byte_write(handle, BBM_COEF0C, 0xf5);
- bbm_byte_write(handle, BBM_COEF0D, 0x1c);
- bbm_byte_write(handle, BBM_COEF0E, 0x4b);
- bbm_byte_write(handle, BBM_COEF0F, 0x61);
- #elif (FC8080_FREQ_XTAL == 32000)
- bbm_long_write(handle, BBM_NCO_OFFSET, 0x03126eb8);
- bbm_byte_write(handle, BBM_NCO_INV, 0xa7);
- bbm_byte_write(handle, BBM_EZ_CONST, 0x62);
- bbm_byte_write(handle, BBM_CLK_MODE, 0x02);
- /* filter coefficient */
- bbm_byte_write(handle, BBM_COEF00, 0x0e);
- bbm_byte_write(handle, BBM_COEF01, 0x0e);
- bbm_byte_write(handle, BBM_COEF02, 0x01);
- bbm_byte_write(handle, BBM_COEF03, 0x04);
- bbm_byte_write(handle, BBM_COEF04, 0x03);
- bbm_byte_write(handle, BBM_COEF05, 0x1d);
- bbm_byte_write(handle, BBM_COEF06, 0x19);
- bbm_byte_write(handle, BBM_COEF07, 0x1f);
- bbm_byte_write(handle, BBM_COEF08, 0x09);
- bbm_byte_write(handle, BBM_COEF09, 0x09);
- bbm_byte_write(handle, BBM_COEF0A, 0x3b);
- bbm_byte_write(handle, BBM_COEF0B, 0x3d);
- bbm_byte_write(handle, BBM_COEF0C, 0xf5);
- bbm_byte_write(handle, BBM_COEF0D, 0x1c);
- bbm_byte_write(handle, BBM_COEF0E, 0x4b);
- bbm_byte_write(handle, BBM_COEF0F, 0x61);
- #elif (FC8080_FREQ_XTAL == 38400)
- bbm_long_write(handle, BBM_NCO_OFFSET, 0x0369d037);
- bbm_byte_write(handle, BBM_NCO_INV, 0x96);
- bbm_byte_write(handle, BBM_EZ_CONST, 0x6d);
- bbm_byte_write(handle, BBM_CLK_MODE, 0x01);
- /* filter coefficient */
- bbm_byte_write(handle, BBM_COEF00, 0x0e);
- bbm_byte_write(handle, BBM_COEF01, 0x00);
- bbm_byte_write(handle, BBM_COEF02, 0x03);
- bbm_byte_write(handle, BBM_COEF03, 0x03);
- bbm_byte_write(handle, BBM_COEF04, 0x1f);
- bbm_byte_write(handle, BBM_COEF05, 0x1a);
- bbm_byte_write(handle, BBM_COEF06, 0x1b);
- bbm_byte_write(handle, BBM_COEF07, 0x03);
- bbm_byte_write(handle, BBM_COEF08, 0x0a);
- bbm_byte_write(handle, BBM_COEF09, 0x05);
- bbm_byte_write(handle, BBM_COEF0A, 0x37);
- bbm_byte_write(handle, BBM_COEF0B, 0x2d);
- bbm_byte_write(handle, BBM_COEF0C, 0xfa);
- bbm_byte_write(handle, BBM_COEF0D, 0x1f);
- bbm_byte_write(handle, BBM_COEF0E, 0x49);
- bbm_byte_write(handle, BBM_COEF0F, 0x5c);
- #endif
- return BBM_OK;
- }
- s32 fc8080_reset(HANDLE handle)
- {
- bbm_write(handle, BBM_MD_RESET, 0xfe);
- ms_wait(1);
- bbm_write(handle, BBM_MD_RESET, 0xff);
- return BBM_OK;
- }
- s32 fc8080_probe(HANDLE handle)
- {
- u16 ver;
- bbm_word_read(handle, BBM_CHIP_ID, &ver);
- printk(KERN_DEBUG "TDMB %s : ver(0x%x)\n", __func__, ver);
- return (ver == 0x8080) ? BBM_OK : BBM_NOK;
- }
- s32 fc8080_init(HANDLE handle)
- {
- #ifdef FC8080_I2C
- bbm_write(handle, BBM_TSO_SELREG, 0xc4);
- #endif
- fc8080_reset(handle);
- fc8080_set_xtal(handle);
- bbm_write(handle, BBM_LDO_VCTRL, 0x35);
- bbm_write(handle, BBM_XTAL_CCTRL, 0x14);
- bbm_write(handle, BBM_RF_XTAL_EN, 0x0f);
- bbm_write(handle, BBM_ADC_OPMODE, 0x67);
- /*bbm_write(handle, BBM_FIC_CFG_CRC16, 0x03);*/
- bbm_word_write(handle, BBM_OFDM_DET_MAX_THRESHOLD, 0x0a00);
- bbm_write(handle, BBM_FTOFFSET_RANGE, 0x20);
- bbm_write(handle, BBM_AGC530_EN, 0x53);
- bbm_write(handle, BBM_BLOCK_AVG_SIZE_LOCK, 0x49);
- bbm_word_write(handle, BBM_GAIN_CONSTANT, 0x0303);
- bbm_write(handle, BBM_DET_CNT_BOUND, 0x60);
- bbm_write(handle, BBM_UNLOCK_DETECT_EN, 0x00);
- bbm_write(handle, BBM_DCE_CTRL, 0x27);
- bbm_write(handle, BBM_PGA_GAIN_MAX, 0x18);
- bbm_write(handle, BBM_PGA_GAIN_MIN, 0xe8);
- #if (FC8080_FREQ_XTAL == 24000)
- bbm_write(handle, BBM_SYNC_MTH, 0x43);
- #else
- bbm_write(handle, BBM_SYNC_MTH, 0xc3);
- #endif
- #if (FC8080_FREQ_XTAL == 16384) || (FC8080_FREQ_XTAL == 24576)
- bbm_write(handle, BBM_SFSYNC_ON, 0x00);
- #else
- bbm_write(handle, BBM_SFSYNC_ON, 0x01);
- #endif
- bbm_write(handle, BBM_RESYNC_EN, 0x01);
- bbm_write(handle, BBM_RESYNC_AUTO_CONDITION_EN, 0x00);
- bbm_write(handle, BBM_MSC_CFG_SPD, 0xff);
- #if defined(POWER_SAVE_MODE)
- bbm_write(handle, BBM_PS0_RF_ENABLE, 0x06);
- bbm_write(handle, BBM_PS1_ADC_ENABLE, 0x07);
- bbm_write(handle, BBM_PS2_BB_ENABLE, 0x07);
- bbm_write(handle, BBM_PS2_BB_ADD_SHIFT, 0x21);
- #else
- bbm_write(handle, BBM_PS0_RF_ENABLE, 0x04);
- bbm_write(handle, BBM_PS1_ADC_ENABLE, 0x05);
- bbm_write(handle, BBM_PS2_BB_ENABLE, 0x05);
- #endif
- bbm_write(handle, BBM_PS1_ADC_ADD_SHIFT, 0x71);
- bbm_word_write(handle, BBM_BUF_FIC_START, FIC_BUF_START);
- bbm_word_write(handle, BBM_BUF_FIC_END, FIC_BUF_END);
- bbm_word_write(handle, BBM_BUF_FIC_THR, FIC_BUF_THR);
- bbm_word_write(handle, BBM_BUF_CH0_START, CH0_BUF_START);
- bbm_word_write(handle, BBM_BUF_CH0_END, CH0_BUF_END);
- bbm_word_write(handle, BBM_BUF_CH0_THR, CH0_BUF_THR);
- bbm_word_write(handle, BBM_BUF_CH1_START, CH1_BUF_START);
- bbm_word_write(handle, BBM_BUF_CH1_END, CH1_BUF_END);
- bbm_word_write(handle, BBM_BUF_CH1_THR, CH1_BUF_THR);
- bbm_word_write(handle, BBM_BUF_CH2_START, CH2_BUF_START);
- bbm_word_write(handle, BBM_BUF_CH2_END, CH2_BUF_END);
- bbm_word_write(handle, BBM_BUF_CH2_THR, CH2_BUF_THR);
- bbm_write(handle, BBM_DM_CTRL, 0xa0);
- bbm_write(handle, BBM_OVERRUN_GAP, 0x06);
- bbm_word_write(handle, BBM_BUF_INT, 0x0107);
- bbm_word_write(handle, BBM_BUF_ENABLE, 0x0000);
- #ifdef FC8080_I2C
- bbm_write(handle, BBM_TSO_CLKDIV, 0x01);
- #else
- bbm_write(handle, BBM_MD_INT_EN, BBM_MF_INT);
- bbm_write(handle, BBM_MD_INT_STATUS, BBM_MF_INT);
- #endif
- return BBM_OK;
- }
- s32 fc8080_deinit(HANDLE handle)
- {
- bbm_write(handle, BBM_MD_RESET, 0x00);
- return BBM_OK;
- }
- s32 fc8080_channel_select(HANDLE handle, u8 subch_id, u8 buf_id)
- {
- u8 buf_en = 0;
- bbm_read(handle, BBM_BUF_ENABLE, &buf_en);
- bbm_write(handle, BBM_BUF_ENABLE, buf_en | (1 << buf_id));
- bbm_write(handle, BBM_SCH0_SET_IDI + buf_id, 0x40 | subch_id);
- return BBM_OK;
- }
- s32 fc8080_video_select(HANDLE handle, u8 subch_id, u8 buf_id, u8 cdi_id)
- {
- u16 fec_en = 0;
- if (cdi_id == 0) {
- bbm_write(handle, BBM_FEC_RST, 0x1c);
- bbm_write(handle, BBM_FEC_RST, 0x00);
- }
- bbm_word_read(handle, BBM_MSC_CFG_SCH0, &fec_en);
- if ((fec_en & 0x00ff) && (fec_en & 0xff00) && cdi_id == 0) {
- bbm_write(handle, BBM_FEC_ON, 0x00);
- bbm_write(handle, BBM_MSC_CFG_SCH0 + cdi_id, 0x00);
- bbm_write(handle, BBM_MSC_CFG_SCH0 + cdi_id, fec_en & 0x00ff);
- bbm_write(handle, BBM_FEC_ON, 0x01);
- }
- if (fc8080_channel_select(handle, subch_id, buf_id) != BBM_OK)
- return BBM_NOK;
- bbm_write(handle, BBM_MSC_CFG_SCH0 + cdi_id, 0x40 | subch_id);
- bbm_write(handle, BBM_BUF_CH0_SUBID + buf_id, 0x40 | subch_id);
- return BBM_OK;
- }
- s32 fc8080_audio_select(HANDLE handle, u8 subch_id, u8 buf_id)
- {
- if (fc8080_channel_select(handle, subch_id, buf_id) != BBM_OK)
- return BBM_NOK;
- bbm_write(handle, BBM_BUF_CH0_SUBID + buf_id, 0x40 | subch_id);
- return BBM_OK;
- }
- s32 fc8080_data_select(HANDLE handle, u8 subch_id, u8 buf_id)
- {
- if (fc8080_channel_select(handle, subch_id, buf_id) != BBM_OK)
- return BBM_NOK;
- bbm_write(handle, BBM_BUF_CH0_SUBID + buf_id, 0x40 | subch_id);
- return BBM_OK;
- }
- s32 fc8080_channel_deselect(HANDLE handle, u8 subch_id, u8 buf_id)
- {
- u8 buf_en = 0;
- bbm_read(handle, BBM_BUF_ENABLE, &buf_en);
- bbm_write(handle, BBM_BUF_ENABLE, buf_en & (~(1 << buf_id)));
- bbm_write(handle, BBM_SCH0_SET_IDI + buf_id, 0);
- return BBM_OK;
- }
- s32 fc8080_video_deselect(HANDLE handle, u8 subch_id, u8 buf_id, u8 cdi_id)
- {
- u16 fec_en = 0;
- u8 buf_en = 0;
- bbm_write(handle, BBM_BUF_CH0_SUBID + buf_id, 0x00);
- bbm_word_read(handle, BBM_MSC_CFG_SCH0, &fec_en);
- if (!((fec_en & 0xff00) && (fec_en & 0x00ff) && cdi_id == 0))
- bbm_write(handle, BBM_MSC_CFG_SCH0 + cdi_id, 0x00);
- if (fc8080_channel_deselect(handle, subch_id, buf_id) != BBM_OK)
- return BBM_NOK;
- bbm_read(handle, BBM_BUF_CH0_SUBID, &buf_en);
- if (buf_en == 0 && (fec_en & 0xff00) && cdi_id == 1)
- bbm_write(handle, BBM_MSC_CFG_SCH0, 0x00);
- return BBM_OK;
- }
- s32 fc8080_audio_deselect(HANDLE handle, u8 subch_id, u8 buf_id)
- {
- if (fc8080_channel_deselect(handle, subch_id, buf_id) != BBM_OK)
- return BBM_NOK;
- bbm_write(handle, BBM_BUF_CH0_SUBID + buf_id, 0);
- return BBM_OK;
- }
- s32 fc8080_data_deselect(HANDLE handle, u8 subch_id, u8 buf_id)
- {
- if (fc8080_channel_deselect(handle, subch_id, buf_id) != BBM_OK)
- return BBM_NOK;
- bbm_write(handle, BBM_BUF_CH0_SUBID + buf_id, 0);
- return BBM_OK;
- }
- s32 fc8080_scan_status(HANDLE handle)
- {
- s32 i, res = BBM_NOK;
- u8 mode = 0, status = 0, sync_status = 0;
- s32 slock_cnt, flock_cnt, dlock_cnt;
- bbm_read(handle, BBM_OFDM_DET, &mode);
- if ((mode & 0x01) == 0x01) {
- slock_cnt = SLOCK_MAX_TIME / LOCK_TIME_TICK;
- flock_cnt = FLOCK_MAX_TIME / LOCK_TIME_TICK;
- dlock_cnt = DLOCK_MAX_TIME / LOCK_TIME_TICK;
- /* OFDM Detect */
- for (i = 0; i < slock_cnt; i++) {
- ms_wait(LOCK_TIME_TICK);
- bbm_read(handle, BBM_DETECT_OFDM, &status);
- if (status & 0x01)
- break;
- }
- if (i == slock_cnt) {
- printk(KERN_DEBUG "TDMB :status(0x%x) s(%d)\n",
- status, slock_cnt);
- return BBM_NOK;
- }
- if ((status & 0x02) == 0x00) {
- printk(KERN_DEBUG "TDMB %s : status(0x%x)\n",
- __func__, status);
- return BBM_NOK;
- }
- /* FRS */
- for (i += 1; i < flock_cnt; i++) {
- ms_wait(LOCK_TIME_TICK);
- bbm_read(handle, BBM_SYNC_STAT, &sync_status);
- if (sync_status & 0x01)
- break;
- }
- if (i == flock_cnt) {
- printk(KERN_DEBUG "TDMB %s : flock_cnt(0x%x)\n"
- , __func__
- , flock_cnt);
- return BBM_NOK;
- }
- /* Digital Lock */
- for (i += 1; i < dlock_cnt; i++) {
- ms_wait(LOCK_TIME_TICK);
- bbm_read(handle, BBM_SYNC_STAT, &sync_status);
- if (sync_status & 0x20) {
- printk(KERN_DEBUG "TDMB :sync_status(0x%x)\n",
- sync_status);
- return BBM_OK;
- }
- }
- } else {
- dlock_cnt = DLOCK_MAX_TIME / LOCK_TIME_TICK;
- for (i = 0; i < dlock_cnt; i++) {
- ms_wait(LOCK_TIME_TICK);
- bbm_read(handle, BBM_SYNC_STAT, &sync_status);
- if (sync_status & 0x20) {
- printk(KERN_DEBUG "TDMB :sync_status(0x%x)\n",
- sync_status);
- return BBM_OK;
- }
- }
- }
- printk(KERN_DEBUG "TDMB %s : res(0x%x)\n"
- , __func__, res);
- return res;
- }
|