123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821 |
- /*****************************************************************************
- Copyright(c) 2012 FCI Inc. All Rights Reserved
- File name : fc8150_bb.c
- Description : API of 1-SEG baseband module
- *******************************************************************************/
- #include <linux/delay.h>
- #include "fci_types.h"
- #include "fci_oal.h"
- #include "fci_hal.h"
- #include "fci_tun.h"
- #include "fc8150_regs.h"
- static u8 filter_coef_6M[7][16] = {
- { 0x00, 0x00, 0x00, 0x07, 0x0f, 0x01, 0x03, 0x04
- , 0x01, 0x19, 0x14, 0x18, 0x0a, 0x26, 0x40, 0x4a},
- /*xtal_in : 24,16,32 (adc clk = 4.0000)*/
- { 0x00, 0x07, 0x07, 0x00, 0x01, 0x03, 0x03, 0x01
- , 0x1c, 0x17, 0x16, 0x1e, 0x10, 0x27, 0x3b, 0x43},
- /*xtal_in : 26 (adc clk = 4.3333)*/
- { 0x00, 0x07, 0x07, 0x00, 0x01, 0x03, 0x03, 0x00
- , 0x1b, 0x16, 0x16, 0x1f, 0x11, 0x27, 0x3a, 0x41},
- /*xtal_in : 27,18 (adc clk = 4.5000)*/
- { 0x00, 0x00, 0x07, 0x07, 0x00, 0x02, 0x03, 0x03
- , 0x1f, 0x18, 0x14, 0x1a, 0x0c, 0x26, 0x3e, 0x47},
- /*xtal_in : 16.384, 24.576 (adc clk = 4.0960)*/
- { 0x00, 0x07, 0x07, 0x00, 0x02, 0x03, 0x02, 0x0f
- , 0x1a, 0x16, 0x18, 0x02, 0x13, 0x27, 0x38, 0x3e},
- /*xtal_in : 19.2, 38.4 (adc clk = 4.8000)*/
- { 0x00, 0x07, 0x07, 0x00, 0x01, 0x03, 0x03, 0x00
- , 0x1b, 0x16, 0x16, 0x1f, 0x11, 0x27, 0x3a, 0x41},
- /*xtal_in : 27.12 (adc clk = 4.5200)*/
- { 0x00, 0x07, 0x07, 0x00, 0x02, 0x03, 0x03, 0x00
- , 0x1a, 0x16, 0x17, 0x01, 0x12, 0x27, 0x39, 0x3f}
- /*xtal_in : 37.4 (adc clk = 4.6750)*/
- };
- #if 0
- static u8 filter_coef_7M[7][16] = {
- { 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0e, 0x00, 0x04, 0x05
- , 0x1f, 0x15, 0x12, 0x01, 0x22, 0x45, 0x55},
- /*xtal_in : 24,16,32 (adc clk = 4.0000)*/
- { 0x00, 0x00, 0x00, 0x07, 0x0e, 0x0f, 0x02, 0x05, 0x04
- , 0x1c, 0x14, 0x14, 0x05, 0x24, 0x43, 0x50},
- /*xtal_in : 26 (adc clk = 4.3333)*/
- { 0x00, 0x00, 0x00, 0x07, 0x0f, 0x00, 0x03, 0x05, 0x02
- , 0x1b, 0x14, 0x16, 0x07, 0x25, 0x42, 0x4d},
- /*xtal_in : 27,18 (adc clk = 4.5000)*/
- { 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x01, 0x04, 0x05
- , 0x1e, 0x15, 0x13, 0x02, 0x23, 0x44, 0x53},
- /*xtal_in : 16.384, 24.576 (adc clk = 4.0960)*/
- { 0x00, 0x00, 0x07, 0x07, 0x00, 0x02, 0x04, 0x03, 0x1f
- , 0x18, 0x14, 0x1a, 0x0c, 0x26, 0x3e, 0x47},
- /*xtal_in : 19.2, 38.4 (adc clk = 4.8000)*/
- { 0x00, 0x00, 0x00, 0x07, 0x0f, 0x00, 0x03, 0x05, 0x02
- , 0x1b, 0x14, 0x16, 0x07, 0x25, 0x41, 0x4d},
- /*xtal_in : 27.12 (adc clk = 4.5200)*/
- { 0x00, 0x00, 0x00, 0x07, 0x0f, 0x01, 0x03, 0x04, 0x00
- , 0x19, 0x14, 0x18, 0x0a, 0x26, 0x3f, 0x4a}
- /*xtal_in : 37.4 (adc clk = 4.6750)*/
- };
- static u8 filter_coef_8M[7][16] = {
- { 0x00, 0x00, 0x00, 0x01, 0x01, 0x0f, 0x0d, 0x0f, 0x05
- , 0x06, 0x1d, 0x10, 0xf6, 0x1a, 0x4b, 0x62},
- /*xtal_in : 24,16,32 (adc clk = 4.0000)*/
- { 0x00, 0x00, 0x00, 0x01, 0x00, 0x0e, 0x0e, 0x02, 0x06
- , 0x04, 0x19, 0x10, 0xfb, 0x1e, 0x48, 0x5b},
- /*xtal_in : 26 (adc clk = 4.3333)*/
- { 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0e, 0x00, 0x03, 0x05
- , 0x00, 0x16, 0x11, 0xff, 0x21, 0x46, 0x56},
- /*xtal_in : 27,18 (adc clk = 4.5000)*/
- { 0x00, 0x00, 0x00, 0x01, 0x00, 0x0f, 0x0d, 0x00, 0x05
- , 0x06, 0x1c, 0x10, 0xf7, 0x1b, 0x4a, 0x60},
- /*xtal_in : 16.384, 24.576 (adc clk = 4.0960)*/
- { 0x00, 0x00, 0x00, 0x07, 0x0e, 0x0f, 0x01, 0x05, 0x04
- , 0x1d, 0x14, 0x13, 0x04, 0x23, 0x44, 0x51},
- /*xtal_in : 19.2, 38.4 (adc clk = 4.8000)*/
- { 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0e, 0x00, 0x04, 0x05
- , 0x00, 0x16, 0x12, 0x00, 0x21, 0x46, 0x56},
- /*xtal_in : 27.12 (adc clk = 4.5200)*/
- { 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x01, 0x04, 0x05
- , 0x1e, 0x15, 0x13, 0x02, 0x23, 0x44, 0x53}
- /*xtal_in : 37.4 (adc clk = 4.6750)*/
- };
- #endif
- static void fc8150_clock_mode(HANDLE hDevice)
- {
- int i;
- #if (BBM_XTAL_FREQ == 16000)
- bbm_write(hDevice, 0x0016, 0);
- #if (BBM_BAND_WIDTH == 6)
- bbm_word_write(hDevice, 0x1032, 0x30a4);
- bbm_long_write(hDevice, 0x103c, 0x1f800000);
- bbm_write(hDevice, 0x200a, 0x04);
- bbm_write(hDevice, 0x2009, 0x10);
- bbm_write(hDevice, 0x2008, 0x41);
- for (i = 0; i < 16; i++)
- bbm_write(hDevice, 0x1040+i, filter_coef_6M[0][i]);
- #elif (BBM_BAND_WIDTH == 7)
- bbm_word_write(hDevice, 0x1032, 0x30a4);
- bbm_long_write(hDevice, 0x103c, 0x1b000000);
- bbm_write(hDevice, 0x200a, 0x04);
- bbm_write(hDevice, 0x2009, 0xbd);
- bbm_write(hDevice, 0x2008, 0xa1);
- for (i = 0; i < 16; i++)
- bbm_write(hDevice, 0x1040+i, filter_coef_7M[0][i]);
- #else
- bbm_word_write(hDevice, 0x1032, 0x3ae1);
- bbm_long_write(hDevice, 0x103c, 0x17a00000);
- bbm_write(hDevice, 0x200a, 0x05);
- bbm_write(hDevice, 0x2009, 0x6b);
- bbm_write(hDevice, 0x2008, 0x01);
- for (i = 0; i < 16; i++)
- bbm_write(hDevice, 0x1040+i, filter_coef_8M[0][i]);
- #endif
- #elif (BBM_XTAL_FREQ == 16384)
- bbm_write(hDevice, 0x0016, 0);
- #if (BBM_BAND_WIDTH == 6)
- bbm_word_write(hDevice, 0x1032, 0x2f80);
- bbm_long_write(hDevice, 0x103c, 0x20418937);
- bbm_write(hDevice, 0x200a, 0x03);
- bbm_write(hDevice, 0x2009, 0xf7);
- bbm_write(hDevice, 0x2008, 0xdf);
- for (i = 0; i < 16; i++)
- bbm_write(hDevice, 0x1040+i, filter_coef_6M[3][i]);
- #elif (BBM_BAND_WIDTH == 7)
- bbm_word_write(hDevice, 0x1032, 0x2f80);
- bbm_long_write(hDevice, 0x103c, 0x1ba5e354);
- bbm_write(hDevice, 0x200a, 0x04);
- bbm_write(hDevice, 0x2009, 0xa1);
- bbm_write(hDevice, 0x2008, 0x2f);
- for (i = 0; i < 16; i++)
- bbm_write(hDevice, 0x1040+i, filter_coef_7M[3][i]);
- #else
- bbm_word_write(hDevice, 0x1032, 0x3980);
- bbm_long_write(hDevice, 0x103c, 0x183126e9);
- bbm_write(hDevice, 0x200a, 0x05);
- bbm_write(hDevice, 0x2009, 0x4a);
- bbm_write(hDevice, 0x2008, 0x7f);
- for (i = 0; i < 16; i++)
- bbm_write(hDevice, 0x1040+i, filter_coef_8M[3][i]);
- #endif
- #elif (BBM_XTAL_FREQ == 18000)
- bbm_write(hDevice, 0x0016, 0);
- #if (BBM_BAND_WIDTH == 6)
- bbm_word_write(hDevice, 0x1032, 0x2b3c);
- bbm_long_write(hDevice, 0x103c, 0x23700000);
- bbm_write(hDevice, 0x200a, 0x03);
- bbm_write(hDevice, 0x2009, 0x9c);
- bbm_write(hDevice, 0x2008, 0xac);
- for (i = 0; i < 16; i++)
- bbm_write(hDevice, 0x1040+i, filter_coef_6M[2][i]);
- #elif (BBM_BAND_WIDTH == 7)
- bbm_word_write(hDevice, 0x1032, 0x2b3c);
- bbm_long_write(hDevice, 0x103c, 0x1e600000);
- bbm_write(hDevice, 0x200a, 0x04);
- bbm_write(hDevice, 0x2009, 0x36);
- bbm_write(hDevice, 0x2008, 0xc8);
- for (i = 0; i < 16; i++)
- bbm_write(hDevice, 0x1040+i, filter_coef_7M[2][i]);
- #else
- bbm_word_write(hDevice, 0x1032, 0x3456);
- bbm_long_write(hDevice, 0x103c, 0x1a940000);
- bbm_write(hDevice, 0x200a, 0x04);
- bbm_write(hDevice, 0x2009, 0xd0);
- bbm_write(hDevice, 0x2008, 0xe5);
- for (i = 0; i < 16; i++)
- bbm_write(hDevice, 0x1040+i, filter_coef_8M[2][i]);
- #endif
- #elif (BBM_XTAL_FREQ == 19200)
- bbm_write(hDevice, 0x0016, 0);
- #if (BBM_BAND_WIDTH == 6)
- bbm_word_write(hDevice, 0x1032, 0x2889);
- bbm_long_write(hDevice, 0x103c, 0x25cccccd);
- bbm_write(hDevice, 0x200a, 0x03);
- bbm_write(hDevice, 0x2009, 0x62);
- bbm_write(hDevice, 0x2008, 0xe1);
- for (i = 0; i < 16; i++)
- bbm_write(hDevice, 0x1040+i, filter_coef_6M[4][i]);
- #elif (BBM_BAND_WIDTH == 7)
- bbm_word_write(hDevice, 0x1032, 0x2889);
- bbm_long_write(hDevice, 0x103c, 0x20666666);
- bbm_write(hDevice, 0x200a, 0x03);
- bbm_write(hDevice, 0x2009, 0xf3);
- bbm_write(hDevice, 0x2008, 0x5c);
- for (i = 0; i < 16; i++)
- bbm_write(hDevice, 0x1040+i, filter_coef_7M[4][i]);
- #else
- bbm_word_write(hDevice, 0x1032, 0x3111);
- bbm_long_write(hDevice, 0x103c, 0x1c59999a);
- bbm_write(hDevice, 0x200a, 0x04);
- bbm_write(hDevice, 0x2009, 0x83);
- bbm_write(hDevice, 0x2008, 0xd6);
- for (i = 0; i < 16; i++)
- bbm_write(hDevice, 0x1040+i, filter_coef_8M[4][i]);
- #endif
- #elif (BBM_XTAL_FREQ == 24000)
- bbm_write(hDevice, 0x0016, 2);
- #if (BBM_BAND_WIDTH == 6)
- bbm_word_write(hDevice, 0x1032, 0x30a4);
- bbm_long_write(hDevice, 0x103c, 0x1f800000);
- bbm_write(hDevice, 0x200a, 0x04);
- bbm_write(hDevice, 0x2009, 0x10);
- bbm_write(hDevice, 0x2008, 0x41);
- for (i = 0; i < 16; i++)
- bbm_write(hDevice, 0x1040+i, filter_coef_6M[0][i]);
- #elif (BBM_BAND_WIDTH == 7)
- bbm_word_write(hDevice, 0x1032, 0x30a4);
- bbm_long_write(hDevice, 0x103c, 0x1b000000);
- bbm_write(hDevice, 0x200a, 0x04);
- bbm_write(hDevice, 0x2009, 0xbd);
- bbm_write(hDevice, 0x2008, 0xa1);
- for (i = 0; i < 16; i++)
- bbm_write(hDevice, 0x1040+i, filter_coef_7M[0][i]);
- #else
- bbm_word_write(hDevice, 0x1032, 0x3ae1);
- bbm_long_write(hDevice, 0x103c, 0x17a00000);
- bbm_write(hDevice, 0x200a, 0x05);
- bbm_write(hDevice, 0x2009, 0x6b);
- bbm_write(hDevice, 0x2008, 0x01);
- for (i = 0; i < 16; i++)
- bbm_write(hDevice, 0x1040+i, filter_coef_8M[0][i]);
- #endif
- #elif (BBM_XTAL_FREQ == 26000)
- bbm_write(hDevice, 0x0016, 2);
- #if (BBM_BAND_WIDTH == 6)
- bbm_word_write(hDevice, 0x1032, 0x2ce6);
- bbm_long_write(hDevice, 0x103c, 0x221fffd4);
- bbm_write(hDevice, 0x200a, 0x03);
- bbm_write(hDevice, 0x2009, 0xc0);
- bbm_write(hDevice, 0x2008, 0x3c);
- for (i = 0; i < 16; i++)
- bbm_write(hDevice, 0x1040+i, filter_coef_6M[1][i]);
- #elif (BBM_BAND_WIDTH == 7)
- bbm_word_write(hDevice, 0x1032, 0x2ce6);
- bbm_long_write(hDevice, 0x103c, 0x1d3fffda);
- bbm_write(hDevice, 0x200a, 0x04);
- bbm_write(hDevice, 0x2009, 0x60);
- bbm_write(hDevice, 0x2008, 0x46);
- for (i = 0; i < 16; i++)
- bbm_write(hDevice, 0x1040+i, filter_coef_7M[1][i]);
- #else
- bbm_word_write(hDevice, 0x1032, 0x365a);
- bbm_long_write(hDevice, 0x103c, 0x1997ffdf);
- bbm_write(hDevice, 0x200a, 0x05);
- bbm_write(hDevice, 0x2009, 0x00);
- bbm_write(hDevice, 0x2008, 0x50);
- for (i = 0; i < 16; i++)
- bbm_write(hDevice, 0x1040+i, filter_coef_8M[1][i]);
- #endif
- #elif (BBM_XTAL_FREQ == 27000)
- bbm_write(hDevice, 0x0016, 2);
- #if (BBM_BAND_WIDTH == 6)
- bbm_word_write(hDevice, 0x1032, 0x2b3c);
- bbm_long_write(hDevice, 0x103c, 0x23700000);
- bbm_write(hDevice, 0x200a, 0x03);
- bbm_write(hDevice, 0x2009, 0x9c);
- bbm_write(hDevice, 0x2008, 0xac);
- for (i = 0; i < 16; i++)
- bbm_write(hDevice, 0x1040+i, filter_coef_6M[2][i]);
- #elif (BBM_BAND_WIDTH == 7)
- bbm_word_write(hDevice, 0x1032, 0x2b3c);
- bbm_long_write(hDevice, 0x103c, 0x1e600000);
- bbm_write(hDevice, 0x200a, 0x04);
- bbm_write(hDevice, 0x2009, 0x36);
- bbm_write(hDevice, 0x2008, 0xc8);
- for (i = 0; i < 16; i++)
- bbm_write(hDevice, 0x1040+i, filter_coef_7M[2][i]);
- #else
- bbm_word_write(hDevice, 0x1032, 0x3456);
- bbm_long_write(hDevice, 0x103c, 0x1a940000);
- bbm_write(hDevice, 0x200a, 0x04);
- bbm_write(hDevice, 0x2009, 0xd0);
- bbm_write(hDevice, 0x2008, 0xe5);
- for (i = 0; i < 16; i++)
- bbm_write(hDevice, 0x1040+i, filter_coef_8M[2][i]);
- #endif
- #elif (BBM_XTAL_FREQ == 27120)
- bbm_write(hDevice, 0x0016, 2);
- #if (BBM_BAND_WIDTH == 6)
- bbm_word_write(hDevice, 0x1032, 0x2b0b);
- bbm_long_write(hDevice, 0x103c, 0x239851ec);
- bbm_write(hDevice, 0x200a, 0x03);
- bbm_write(hDevice, 0x2009, 0x98);
- bbm_write(hDevice, 0x2008, 0x94);
- for (i = 0; i < 16; i++)
- bbm_write(hDevice, 0x1040+i, filter_coef_6M[5][i]);
- #elif (BBM_BAND_WIDTH == 7)
- bbm_word_write(hDevice, 0x1032, 0x2b0b);
- bbm_long_write(hDevice, 0x103c, 0x1e828f5c);
- bbm_write(hDevice, 0x200a, 0x04);
- bbm_write(hDevice, 0x2009, 0x32);
- bbm_write(hDevice, 0x2008, 0x02);
- for (i = 0; i < 16; i++)
- bbm_write(hDevice, 0x1040+i, filter_coef_7M[5][i]);
- #else
- bbm_word_write(hDevice, 0x1032, 0x341b);
- bbm_long_write(hDevice, 0x103c, 0x1ab23d71);
- bbm_write(hDevice, 0x200a, 0x04);
- bbm_write(hDevice, 0x2009, 0xcb);
- bbm_write(hDevice, 0x2008, 0x70);
- for (i = 0; i < 16; i++)
- bbm_write(hDevice, 0x1040+i, filter_coef_8M[5][i]);
- #endif
- #elif (BBM_XTAL_FREQ == 24576)
- bbm_write(hDevice, 0x0016, 2);
- #if (BBM_BAND_WIDTH == 6)
- bbm_word_write(hDevice, 0x1032, 0x2f80);
- bbm_long_write(hDevice, 0x103c, 0x20418937);
- bbm_write(hDevice, 0x200a, 0x03);
- bbm_write(hDevice, 0x2009, 0xf7);
- bbm_write(hDevice, 0x2008, 0xdf);
- for (i = 0; i < 16; i++)
- bbm_write(hDevice, 0x1040+i, filter_coef_6M[3][i]);
- #elif (BBM_BAND_WIDTH == 7)
- bbm_word_write(hDevice, 0x1032, 0x2f80);
- bbm_long_write(hDevice, 0x103c, 0x1ba5e354);
- bbm_write(hDevice, 0x200a, 0x04);
- bbm_write(hDevice, 0x2009, 0xa1);
- bbm_write(hDevice, 0x2008, 0x2f);
- for (i = 0; i < 16; i++)
- bbm_write(hDevice, 0x1040+i, filter_coef_7M[3][i]);
- #else
- bbm_word_write(hDevice, 0x1032, 0x3980);
- bbm_long_write(hDevice, 0x103c, 0x183126e9);
- bbm_write(hDevice, 0x200a, 0x05);
- bbm_write(hDevice, 0x2009, 0x4a);
- bbm_write(hDevice, 0x2008, 0x7f);
- for (i = 0; i < 16; i++)
- bbm_write(hDevice, 0x1040+i, filter_coef_8M[3][i]);
- #endif
- #elif (BBM_XTAL_FREQ == 32000)
- /* Default Clock */
- bbm_write(hDevice, 0x0016, 1);
- #if (BBM_BAND_WIDTH == 6)
- /* Default Band-width */
- bbm_word_write(hDevice, 0x1032, 0x30a4);
- bbm_long_write(hDevice, 0x103c, 0x1f800000);
- bbm_write(hDevice, 0x200a, 0x04);
- bbm_write(hDevice, 0x2009, 0x10);
- bbm_write(hDevice, 0x2008, 0x41);
- for (i = 0; i < 16; i++)
- bbm_write(hDevice, 0x1040+i, filter_coef_6M[0][i]);
- #elif (BBM_BAND_WIDTH == 7)
- bbm_word_write(hDevice, 0x1032, 0x30a4);
- bbm_long_write(hDevice, 0x103c, 0x1b000000);
- bbm_write(hDevice, 0x200a, 0x04);
- bbm_write(hDevice, 0x2009, 0xbd);
- bbm_write(hDevice, 0x2008, 0xa1);
- for (i = 0; i < 16; i++)
- bbm_write(hDevice, 0x1040+i, filter_coef_7M[0][i]);
- #else
- bbm_word_write(hDevice, 0x1032, 0x3ae1);
- bbm_long_write(hDevice, 0x103c, 0x17a00000);
- bbm_write(hDevice, 0x200a, 0x05);
- bbm_write(hDevice, 0x2009, 0x6b);
- bbm_write(hDevice, 0x2008, 0x01);
- for (i = 0; i < 16; i++)
- bbm_write(hDevice, 0x1040+i, filter_coef_8M[0][i]);
- #endif
- #elif (BBM_XTAL_FREQ == 37400)
- bbm_write(hDevice, 0x0016, 1);
- #if (BBM_BAND_WIDTH == 6)
- bbm_word_write(hDevice, 0x1032, 0x299e);
- bbm_long_write(hDevice, 0x103c, 0x24d0cccd);
- bbm_write(hDevice, 0x200a, 0x03);
- bbm_write(hDevice, 0x2009, 0x7a);
- bbm_write(hDevice, 0x2008, 0x0f);
- for (i = 0; i < 16; i++)
- bbm_write(hDevice, 0x1040+i, filter_coef_6M[6][i]);
- #elif (BBM_BAND_WIDTH == 7)
- bbm_word_write(hDevice, 0x1032, 0x299e);
- bbm_long_write(hDevice, 0x103c, 0x1f8e6666);
- bbm_write(hDevice, 0x200a, 0x04);
- bbm_write(hDevice, 0x2009, 0x0e);
- bbm_write(hDevice, 0x2008, 0x66);
- for (i = 0; i < 16; i++)
- bbm_write(hDevice, 0x1040+i, filter_coef_7M[6][i]);
- #else
- bbm_word_write(hDevice, 0x1032, 0x3261);
- bbm_long_write(hDevice, 0x103c, 0x1b9c999a);
- bbm_write(hDevice, 0x200a, 0x04);
- bbm_write(hDevice, 0x2009, 0xa2);
- bbm_write(hDevice, 0x2008, 0xbe);
- for (i = 0; i < 16; i++)
- bbm_write(hDevice, 0x1040+i, filter_coef_8M[6][i]);
- #endif
- #elif (BBM_XTAL_FREQ == 38400)
- bbm_write(hDevice, 0x0016, 1);
- #if (BBM_BAND_WIDTH == 6)
- bbm_word_write(hDevice, 0x1032, 0x2889);
- bbm_long_write(hDevice, 0x103c, 0x25cccccd);
- bbm_write(hDevice, 0x200a, 0x03);
- bbm_write(hDevice, 0x2009, 0x62);
- bbm_write(hDevice, 0x2008, 0xe1);
- for (i = 0; i < 16; i++)
- bbm_write(hDevice, 0x1040+i, filter_coef_6M[4][i]);
- #elif (BBM_BAND_WIDTH == 7)
- bbm_word_write(hDevice, 0x1032, 0x2889);
- bbm_long_write(hDevice, 0x103c, 0x20666666);
- bbm_write(hDevice, 0x200a, 0x03);
- bbm_write(hDevice, 0x2009, 0xf3);
- bbm_write(hDevice, 0x2008, 0x5c);
- for (i = 0; i < 16; i++)
- bbm_write(hDevice, 0x1040+i, filter_coef_7M[4][i]);
- #else
- bbm_word_write(hDevice, 0x1032, 0x3111);
- bbm_long_write(hDevice, 0x103c, 0x1c59999a);
- bbm_write(hDevice, 0x200a, 0x04);
- bbm_write(hDevice, 0x2009, 0x83);
- bbm_write(hDevice, 0x2008, 0xd6);
- for (i = 0; i < 16; i++)
- bbm_write(hDevice, 0x1040+i, filter_coef_8M[4][i]);
- #endif
- #endif
- }
- int fc8150_reset(HANDLE hDevice)
- {
- bbm_write(hDevice, BBM_SW_RESET, 0x7f);
- bbm_write(hDevice, BBM_SW_RESET, 0xff);
- return BBM_OK;
- }
- int fc8150_probe(HANDLE hDevice)
- {
- u16 ver;
- bbm_word_read(hDevice, BBM_CHIP_ID_L, &ver);
- return (ver == 0x8150) ? BBM_OK : BBM_NOK;
- }
- int fc8150_init(HANDLE hDevice)
- {
- printk(KERN_ERR "ISDBT fc8150_init \n");
- bbm_write(hDevice, 0x00b0, 0x03);
- bbm_write(hDevice, 0x00b1, 0x00);
- bbm_write(hDevice, 0x00b2, 0x05);
- fc8150_reset(hDevice);
- fc8150_clock_mode(hDevice);
- bbm_write(hDevice, 0x1000, 0x27);
- bbm_write(hDevice, 0x1004, 0x4d);
- bbm_write(hDevice, 0x1069, 0x09);
- bbm_write(hDevice, 0x1075, 0x00);
- bbm_write(hDevice, 0x1083, 0x14);
- bbm_write(hDevice, 0x1084, 0x0f);
- bbm_word_write(hDevice, 0x00b4, 0x0000);
- /*bbm_write(hDevice, 0x00b6, 0x03);*/ /* Default 0x03, 0x00, 0x07*/
- bbm_write(hDevice, 0x00b9, 0x00);
- bbm_write(hDevice, 0x00ba, 0x01);
- bbm_write(hDevice, 0x2004, 0x41);
- bbm_write(hDevice, 0x2106, 0x1f);
- bbm_write(hDevice, 0x5010, 0x00);
- bbm_write(hDevice, BBM_RS_FAIL_TX, 0x00); /* RS FAILURE TX: 0x02 original:0x00*/
- bbm_word_write(hDevice, BBM_BUF_TS_START, TS_BUF_START);
- bbm_word_write(hDevice, BBM_BUF_TS_END, TS_BUF_END);
- bbm_word_write(hDevice, BBM_BUF_TS_THR, TS_BUF_THR);
- /*bbm_word_write(hDevice, BBM_BUF_AC_START, AC_BUF_START);*/
- /*bbm_word_write(hDevice, BBM_BUF_AC_END, AC_BUF_END);*/
- /*bbm_word_write(hDevice, BBM_BUF_AC_THR, AC_BUF_THR);*/
- /*bbm_write(hDevice, BBM_INT_POLAR_SEL, 0x00);*/
- bbm_write(hDevice, BBM_INT_AUTO_CLEAR, 0x01);
- #ifdef FEATURE_INT_AUTO_MODE
- bbm_write(hDevice, BBM_STATUS_AUTO_CLEAR_EN, 0x00);
- #endif
- bbm_write(hDevice, BBM_BUF_ENABLE, 0x01);
- bbm_write(hDevice, BBM_BUF_INT, 0x01);
- bbm_write(hDevice, BBM_INT_MASK, 0x07);
- #ifdef BBM_I2C_TSIF
- bbm_write(hDevice, BBM_INT_STS_EN, 0x00);
- #else
- bbm_write(hDevice, BBM_INT_STS_EN, 0x01);
- #endif
- return BBM_OK;
- }
- int fc8150_deinit(HANDLE hDevice)
- {
- bbm_write(hDevice, BBM_SW_RESET, 0x00);
- printk(KERN_ERR "ISDBT fc8150_deinit \n");
- return BBM_OK;
- }
- int fc8150_scan_status(HANDLE hDevice)
- {
- u32 ifagc_timeout = 7;
- u32 ofdm_timeout = 16;
- u32 ffs_lock_timeout = 10;
- u32 dagc_timeout = 100; /* always done*/
- u32 cfs_timeout = 12;
- u32 tmcc_timeout = 105;
- u32 ts_err_free_timeout = 0;
- int rssi;
- u8 data, data1;
- u8 lay0_mod, lay0_cr;
- int i;
- printk(KERN_ERR "ISDBT fc8150_scan_status \n");
- for (i = 0; i < ifagc_timeout; i++) {
- bbm_read(hDevice, 0x3025, &data);
- printk(KERN_ERR "ifagc loop: data=0x%x\n",data);
- if (data & 0x01)
- break;
- msWait(10);
- }
- if (i == ifagc_timeout)
- return BBM_NOK;
- tuner_get_rssi(hDevice, &rssi);
- if (rssi < -107)
- return BBM_NOK;
- for (; i < ofdm_timeout; i++) {
- bbm_read(hDevice, 0x3025, &data);
- printk(KERN_ERR "ofdm loop: data=0x%x\n",data);
- if (data & 0x08)
- break;
- msWait(10);
- }
- if (i == ofdm_timeout)
- {
- printk(KERN_ERR "ISDBT ofdm_timeout \n");
- return BBM_NOK;
- }
- if (0 == (data & 0x04))
- return BBM_NOK;
- for (; i < ffs_lock_timeout; i++) {
- bbm_read(hDevice, 0x3026, &data);
- printk(KERN_ERR "ffs loop: data=0x%x\n",data);
- if (data & 0x10)
- break;
- msWait(10);
- }
- if (i == ffs_lock_timeout)
- {
- printk(KERN_ERR "ISDBT ffs_lock_timeout \n");
- return BBM_NOK;
- }
- /* DAGC Lock*/
- for (i = 0; i < dagc_timeout; i++) {
- bbm_read(hDevice, 0x3026, &data);
- if (data & 0x01)
- break;
- msWait(10);
- }
- if (i == dagc_timeout)
- return BBM_NOK;
- for (i = 0; i < cfs_timeout; i++) {
- bbm_read(hDevice, 0x3025, &data);
- printk(KERN_ERR "cfs loop: data=0x%x\n",data);
- if (data & 0x40)
- break;
- msWait(10);
- }
- if (i == cfs_timeout)
- {
- printk(KERN_ERR "ISDBT cfs_timeout \n");
- return BBM_NOK;
- }
- bbm_read(hDevice, 0x2023, &data1);
- if (data1 & 1)
- {
- printk(KERN_ERR "ISDBT data1 & 0x01 = 1 return BBM_NOK \n");
- return BBM_NOK;
- }
- for (i = 0; i < tmcc_timeout; i++) {
- bbm_read(hDevice, 0x3026, &data);
- printk(KERN_ERR "tmcc loop: data=0x%x\n",data);
- if (data & 0x02)
- break;
- msWait(10);
- }
- if (i == tmcc_timeout)
- {
- printk(KERN_ERR "ISDBT tmcc_timeout \n");
- return BBM_NOK;
- }
- bbm_read(hDevice, 0x4113, &data);
- bbm_read(hDevice, 0x4114, &data1);
- if (((data >> 3) & 0x1) == 0)
- return BBM_NOK;
- lay0_mod = ((data & 0x10) >> 2) |
- ((data & 0x20) >> 4) |
- ((data & 0x40) >> 6);
- lay0_cr = ((data & 0x80) >> 5) |
- ((data1 & 0x01) << 1) |
- ((data1 & 0x02) >> 1);
- if (!((lay0_mod == 1) || (lay0_mod == 2)))
- return BBM_NOK;
- if (((0x70 & data) == 0x40) && ((0x1c & data1) == 0x18))
- ts_err_free_timeout = 40;
- else
- ts_err_free_timeout = 65;
- for (i = 0; i < ts_err_free_timeout; i++) {
- bbm_read(hDevice, 0x5053, &data);
- printk(KERN_ERR "ts-err loop: data=0x%x\n",data);
- if (data & 0x01)
- break;
- msWait(10);
- }
- if (i == ts_err_free_timeout)
- {
- printk(KERN_ERR "ISDBT ts_err_free_timeout\n");
- return BBM_NOK;
- }
- return BBM_OK;
- }
|