update for non-irq case
authorPeter Li <a0220410@ti.com>
Mon, 28 Aug 2017 14:39:33 +0000 (22:39 +0800)
committerPeter Li <a0220410@ti.com>
Mon, 28 Aug 2017 14:39:33 +0000 (22:39 +0800)
tas2557-core.c
tas2557-regmap.c
tas2557.h

index 7e9bab7aa81706a68e2c09696cb021946fcae14b..24495e17b11d27d86312c4641a5fda5bd89338e5 100755 (executable)
@@ -295,7 +295,7 @@ static void failsafe(struct tas2557_priv *pTAS2557)
        pTAS2557->mnErrCode |= ERROR_FAILSAFE;
        if (hrtimer_active(&pTAS2557->mtimer))
                hrtimer_cancel(&pTAS2557->mtimer);
-       pTAS2557->enableIRQ(pTAS2557, false);
+       pTAS2557->enableIRQ(pTAS2557, false, false);
        tas2557_dev_load_data(pTAS2557, p_tas2557_shutdown_data);
        pTAS2557->mbPowerUp = false;
        pTAS2557->hw_reset(pTAS2557);
@@ -365,7 +365,7 @@ static int tas2557_load_coefficient(struct tas2557_priv *pTAS2557,
                        hrtimer_cancel(&pTAS2557->mtimer);
 
                if (pProgram->mnAppMode == TAS2557_APP_TUNINGMODE)
-                       pTAS2557->enableIRQ(pTAS2557, false);
+                       pTAS2557->enableIRQ(pTAS2557, false, false);
 
                nResult = tas2557_dev_load_data(pTAS2557, p_tas2557_shutdown_data);
                if (nResult < 0)
@@ -422,7 +422,7 @@ prog_coefficient:
                if (nResult < 0)
                        goto end;
                if (pProgram->mnAppMode == TAS2557_APP_TUNINGMODE) {
-                       pTAS2557->enableIRQ(pTAS2557, true);
+                       pTAS2557->enableIRQ(pTAS2557, true, true);
                        if (!hrtimer_active(&pTAS2557->mtimer)) {
                                pTAS2557->mnDieTvReadCounter = 0;
                                hrtimer_start(&pTAS2557->mtimer,
@@ -490,7 +490,7 @@ int tas2557_enable(struct tas2557_priv *pTAS2557, bool bEnable)
 
                        if (pProgram->mnAppMode == TAS2557_APP_TUNINGMODE) {
                                /* turn on IRQ */
-                               pTAS2557->enableIRQ(pTAS2557, true);
+                               pTAS2557->enableIRQ(pTAS2557, true, true);
                                if (!hrtimer_active(&pTAS2557->mtimer)) {
                                        pTAS2557->mnDieTvReadCounter = 0;
                                        hrtimer_start(&pTAS2557->mtimer,
@@ -507,7 +507,7 @@ int tas2557_enable(struct tas2557_priv *pTAS2557, bool bEnable)
                        dev_dbg(pTAS2557->dev, "Enable: load shutdown sequence\n");
                        if (pProgram->mnAppMode == TAS2557_APP_TUNINGMODE) {
                                /* turn off IRQ */
-                               pTAS2557->enableIRQ(pTAS2557, false);
+                               pTAS2557->enableIRQ(pTAS2557, false, false);
                        }
                        nResult = tas2557_dev_load_data(pTAS2557, p_tas2557_shutdown_data);
                        if (nResult < 0)
@@ -1805,7 +1805,7 @@ int tas2557_set_program(struct tas2557_priv *pTAS2557,
                        hrtimer_cancel(&pTAS2557->mtimer);
 
                if (pProgram->mnAppMode == TAS2557_APP_TUNINGMODE)
-                       pTAS2557->enableIRQ(pTAS2557, false);
+                       pTAS2557->enableIRQ(pTAS2557, false, false);
 
                nResult = tas2557_dev_load_data(pTAS2557, p_tas2557_shutdown_data);
                if (nResult < 0)
@@ -1857,7 +1857,7 @@ int tas2557_set_program(struct tas2557_priv *pTAS2557,
                        goto end;
 
                if (pProgram->mnAppMode == TAS2557_APP_TUNINGMODE) {
-                       pTAS2557->enableIRQ(pTAS2557, true);
+                       pTAS2557->enableIRQ(pTAS2557, true, true);
                        if (!hrtimer_active(&pTAS2557->mtimer)) {
                                pTAS2557->mnDieTvReadCounter = 0;
                                hrtimer_start(&pTAS2557->mtimer,
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;
index d109454bf99a13d2e5f751176b72eab4f20785ac..33d91efee12589c08832d5627b25755b5a9bb6af 100755 (executable)
--- a/tas2557.h
+++ b/tas2557.h
@@ -440,7 +440,7 @@ struct tas2557_priv {
        int (*set_calibration)(struct tas2557_priv *pTAS2557,
                int calibration);
        void (*clearIRQ)(struct tas2557_priv *pTAS2557);
-       void (*enableIRQ)(struct tas2557_priv *pTAS2557, bool enable);
+       void (*enableIRQ)(struct tas2557_priv *pTAS2557, bool enable, bool startup_chk);
        void (*hw_reset)(struct tas2557_priv *pTAS2557);
        /* device is working, but system is suspended */
        int (*runtime_suspend)(struct tas2557_priv *pTAS2557);