V4L/DVB (7435): tda18271: add function tda18271_charge_pump_source
authorMichael Krufky <mkrufky@linuxtv.org>
Tue, 22 Apr 2008 17:46:23 +0000 (14:46 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Thu, 24 Apr 2008 17:07:55 +0000 (14:07 -0300)
Force the main pll charge pump or cal pll charge pump to source current
to the main pll loop filter or cal pll loop filter, respectively.

Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
drivers/media/dvb/frontends/tda18271-common.c
drivers/media/dvb/frontends/tda18271-fe.c
drivers/media/dvb/frontends/tda18271-priv.h

index 84d430c528547011c0aa5a36eb520379393a147a..e27a7620a32f20b2f68990bc968714b270e168eb 100644 (file)
@@ -217,6 +217,21 @@ int tda18271_write_regs(struct dvb_frontend *fe, int idx, int len)
 
 /*---------------------------------------------------------------------*/
 
+int tda18271_charge_pump_source(struct dvb_frontend *fe,
+                               enum tda18271_pll pll, int force)
+{
+       struct tda18271_priv *priv = fe->tuner_priv;
+       unsigned char *regs = priv->tda18271_regs;
+
+       int r_cp = (pll == TDA18271_CAL_PLL) ? R_EB7 : R_EB4;
+
+       regs[r_cp] &= ~0x20;
+       regs[r_cp] |= ((force & 1) << 5);
+       tda18271_write_regs(fe, r_cp, 1);
+
+       return 0;
+}
+
 int tda18271_init_regs(struct dvb_frontend *fe)
 {
        struct tda18271_priv *priv = fe->tuner_priv;
@@ -359,13 +374,11 @@ int tda18271_init_regs(struct dvb_frontend *fe)
 
        if ((priv->id) == TDA18271HDC2) {
                /* main pll cp source on */
-               regs[R_EB4] = 0x61;
-               tda18271_write_regs(fe, R_EB4, 1);
+               tda18271_charge_pump_source(fe, TDA18271_MAIN_PLL, 1);
                msleep(1);
 
                /* main pll cp source off */
-               regs[R_EB4] = 0x41;
-               tda18271_write_regs(fe, R_EB4, 1);
+               tda18271_charge_pump_source(fe, TDA18271_MAIN_PLL, 0);
        }
 
        msleep(5); /* pll locking */
index b3b0425dbbed03ed740efb34edc80c86bd07beb3..46905a773e4608f79d1d017fc607e3bb142b56fc 100644 (file)
@@ -119,14 +119,12 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe,
        tda18271_write_regs(fe, R_TM, 7);
 
        /* main pll charge pump source */
-       regs[R_EB4] |= 0x20;
-       tda18271_write_regs(fe, R_EB4, 1);
+       tda18271_charge_pump_source(fe, TDA18271_MAIN_PLL, 1);
 
        msleep(1);
 
        /* normal operation for the main pll */
-       regs[R_EB4] &= ~0x20;
-       tda18271_write_regs(fe, R_EB4, 1);
+       tda18271_charge_pump_source(fe, TDA18271_MAIN_PLL, 0);
 
        msleep(20);
 
@@ -285,12 +283,10 @@ static int tda18271_calibrate_rf(struct dvb_frontend *fe, u32 freq)
        tda18271_write_regs(fe, R_EB13, 1);
 
        /* main pll charge pump source */
-       regs[R_EB4]  |= 0x20;
-       tda18271_write_regs(fe, R_EB4, 1);
+       tda18271_charge_pump_source(fe, TDA18271_MAIN_PLL, 1);
 
        /* cal pll charge pump source */
-       regs[R_EB7]  |= 0x20;
-       tda18271_write_regs(fe, R_EB7, 1);
+       tda18271_charge_pump_source(fe, TDA18271_CAL_PLL, 1);
 
        /* force dcdc converter to 0 V */
        regs[R_EB14] = 0x00;
@@ -328,12 +324,10 @@ static int tda18271_calibrate_rf(struct dvb_frontend *fe, u32 freq)
        /* --------------------------------------------------------------- */
 
        /* normal operation for the main pll */
-       regs[R_EB4] &= ~0x20;
-       tda18271_write_regs(fe, R_EB4, 1);
+       tda18271_charge_pump_source(fe, TDA18271_MAIN_PLL, 0);
 
        /* normal operation for the cal pll  */
-       regs[R_EB7] &= ~0x20;
-       tda18271_write_regs(fe, R_EB7, 1);
+       tda18271_charge_pump_source(fe, TDA18271_CAL_PLL, 0);
 
        msleep(10); /* plls locking */
 
index ecb588e5f7d5519d71292b87396325e5dcbfa2ae..2a37f794e1b63ac5ada4c24006c256badaa6bdc8 100644 (file)
@@ -86,6 +86,11 @@ struct tda18271_rf_tracking_filter_cal {
        int rf_b2;
 };
 
+enum tda18271_pll {
+       TDA18271_MAIN_PLL,
+       TDA18271_CAL_PLL,
+};
+
 enum tda18271_mode {
        TDA18271_ANALOG,
        TDA18271_DIGITAL,
@@ -188,6 +193,8 @@ extern int tda18271_read_extended(struct dvb_frontend *fe);
 extern int tda18271_write_regs(struct dvb_frontend *fe, int idx, int len);
 extern int tda18271_init_regs(struct dvb_frontend *fe);
 
+extern int tda18271_charge_pump_source(struct dvb_frontend *fe,
+                                      enum tda18271_pll pll, int force);
 extern int tda18271_set_standby_mode(struct dvb_frontend *fe,
                                     int sm, int sm_lt, int sm_xt);