]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - tas2557sw-android/tas2557-android-driver.git/blobdiff - tas2557-regmap.c
update for non-irq case
[tas2557sw-android/tas2557-android-driver.git] / tas2557-regmap.c
index e3c23fd486ee4ffd375892b5fa7a23eecc113436..281007072882cfbff836c71daf193fa392457a64 100755 (executable)
@@ -336,14 +336,16 @@ void tas2557_clearIRQ(struct tas2557_priv *pTAS2557)
 }
 
 
-void tas2557_enableIRQ(struct tas2557_priv *pTAS2557, bool enable)
+void tas2557_enableIRQ(struct tas2557_priv *pTAS2557, bool enable, bool startup_chk)
 {
        if (enable) {
                if (!pTAS2557->mbIRQEnable) {
                        if (gpio_is_valid(pTAS2557->mnGpioINT)) {
                                enable_irq(pTAS2557->mnIRQ);
-                               /* check after 10 ms */
-                               schedule_delayed_work(&pTAS2557->irq_work, msecs_to_jiffies(10));
+                               if (startup_chk) {
+                                       /* check after 10 ms */
+                                       schedule_delayed_work(&pTAS2557->irq_work, msecs_to_jiffies(10));
+                               }
                                pTAS2557->mbIRQEnable = true;
                        }
                }
@@ -404,11 +406,12 @@ static void irq_work_routine(struct work_struct *work)
                dev_info(pTAS2557->dev, "%s, firmware not loaded\n", __func__);
                goto end;
        }
-
+       nResult = tas2557_dev_write(pTAS2557, TAS2557_GPIO4_PIN_REG, 0x00);
+       if (nResult < 0)
+               goto program;
        nResult = tas2557_dev_read(pTAS2557, TAS2557_FLAGS_1, &nDevInt1Status);
        if (nResult >= 0)
                nResult = tas2557_dev_read(pTAS2557, TAS2557_FLAGS_2, &nDevInt2Status);
-
        if (nResult < 0)
                goto program;
 
@@ -500,10 +503,14 @@ static void irq_work_routine(struct work_struct *work)
 
 program:
        /* hardware reset and reload */
+       nResult = -1;
        tas2557_set_program(pTAS2557, pTAS2557->mnCurrentProgram, pTAS2557->mnCurrentConfiguration);
 
 end:
-
+       if (nResult >= 0) {
+               tas2557_dev_write(pTAS2557, TAS2557_GPIO4_PIN_REG, 0x07);
+               tas2557_enableIRQ(pTAS2557, true, false);
+       }
 #ifdef CONFIG_TAS2557_MISC
        mutex_unlock(&pTAS2557->file_lock);
 #endif
@@ -517,7 +524,7 @@ static irqreturn_t tas2557_irq_handler(int irq, void *dev_id)
 {
        struct tas2557_priv *pTAS2557 = (struct tas2557_priv *)dev_id;
 
-       tas2557_enableIRQ(pTAS2557, false);
+       tas2557_enableIRQ(pTAS2557, false, false);
        /* get IRQ status after 100 ms */
        schedule_delayed_work(&pTAS2557->irq_work, msecs_to_jiffies(100));
        return IRQ_HANDLED;
@@ -529,7 +536,10 @@ static enum hrtimer_restart temperature_timer_func(struct hrtimer *timer)
 
        if (pTAS2557->mbPowerUp) {
                schedule_work(&pTAS2557->mtimerwork);
-               schedule_delayed_work(&pTAS2557->irq_work, msecs_to_jiffies(1));
+               if (gpio_is_valid(pTAS2557->mnGpioINT)) {
+                       tas2557_enableIRQ(pTAS2557, false, false);
+                       schedule_delayed_work(&pTAS2557->irq_work, msecs_to_jiffies(1));
+               }
        }
        return HRTIMER_NORESTART;
 }
@@ -630,9 +640,11 @@ static int tas2557_runtime_suspend(struct tas2557_priv *pTAS2557)
                dev_dbg(pTAS2557->dev, "cancel timer work\n");
                cancel_work_sync(&pTAS2557->mtimerwork);
        }
-       if (delayed_work_pending(&pTAS2557->irq_work)) {
-               dev_dbg(pTAS2557->dev, "cancel IRQ work\n");
-               cancel_delayed_work_sync(&pTAS2557->irq_work);
+       if (gpio_is_valid(pTAS2557->mnGpioINT)) {
+               if (delayed_work_pending(&pTAS2557->irq_work)) {
+                       dev_dbg(pTAS2557->dev, "cancel IRQ work\n");
+                       cancel_delayed_work_sync(&pTAS2557->irq_work);
+               }
        }
 
        return 0;