]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
V4L/DVB: tm6000, reset I2C bus function
authorDmitri Belimov <d.belimov@gmail.com>
Tue, 18 May 2010 07:23:29 +0000 (04:23 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Tue, 1 Jun 2010 04:21:57 +0000 (01:21 -0300)
Add new function for reset I2C bus. Rework some code for use this function.

Signed-off-by: Beholder Intl. Ltd. Dmitry Belimov <d.belimov@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/staging/tm6000/tm6000-cards.c
drivers/staging/tm6000/tm6000-core.c
drivers/staging/tm6000/tm6000.h

index 33b134b521befa414a7910b8cd886602f561f621..22fbd75a551df4f241fb001714206b186abb2c96 100644 (file)
@@ -363,13 +363,7 @@ int tm6000_tuner_callback(void *ptr, int component, int command, int arg)
                tm6000_set_reg(dev, REQ_04_EN_DISABLE_MCU_INT,
                                        0x02, arg);
                msleep(10);
-               rc = tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
-                                       TM6000_GPIO_CLK, 0);
-               if (rc < 0)
-                       return rc;
-               msleep(10);
-               rc = tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
-                                       TM6000_GPIO_CLK, 1);
+               rc = tm6000_i2c_reset(dev, 10);
                break;
        case XC2028_TUNER_RESET:
                /* Reset codes during load firmware */
@@ -423,14 +417,7 @@ int tm6000_tuner_callback(void *ptr, int component, int command, int arg)
                        break;
 
                case 2:
-                       rc = tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
-                                               TM6000_GPIO_CLK, 0);
-                       if (rc < 0)
-                               return rc;
-                       msleep(100);
-                       rc = tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN,
-                                               TM6000_GPIO_CLK, 1);
-                       msleep(100);
+                       rc = tm6000_i2c_reset(dev, 100);
                        break;
                }
        }
index 1259ae550547bedccbf62e2dd4f5194e63ad84f4..65feb8cb421caa7d5ede3f199050472bb8c3252c 100644 (file)
@@ -153,6 +153,22 @@ int tm6000_get_reg32 (struct tm6000_core *dev, u8 req, u16 value, u16 index)
        return buf[3] | buf[2] << 8 | buf[1] << 16 | buf[0] << 24;
 }
 
+int tm6000_i2c_reset(struct tm6000_core *dev, u16 tsleep)
+{
+       int rc;
+
+       rc = tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN, TM6000_GPIO_CLK, 0);
+       if (rc < 0)
+               return rc;
+
+       msleep(tsleep);
+
+       rc = tm6000_set_reg(dev, REQ_03_SET_GET_MCU_PIN, TM6000_GPIO_CLK, 1);
+       msleep(tsleep);
+
+       return rc;
+}
+
 void tm6000_set_fourcc_format(struct tm6000_core *dev)
 {
        if (dev->dev_type == TM6010) {
index 79ef72a3f4317ff74c22b476f19d3255fcda5608..7bbaf26dea14f292b1808820698a702981514ebe 100644 (file)
@@ -246,6 +246,8 @@ int tm6000_get_reg (struct tm6000_core *dev, u8 req, u16 value, u16 index);
 int tm6000_get_reg16(struct tm6000_core *dev, u8 req, u16 value, u16 index);
 int tm6000_get_reg32(struct tm6000_core *dev, u8 req, u16 value, u16 index);
 int tm6000_set_reg (struct tm6000_core *dev, u8 req, u16 value, u16 index);
+int tm6000_i2c_reset(struct tm6000_core *dev, u16 tsleep);
+
 int tm6000_init (struct tm6000_core *dev);
 
 int tm6000_init_analog_mode (struct tm6000_core *dev);