]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - tas256xsw-android/tas2563-android-driver.git/blobdiff - tas2563-regmap.c
Fix IRQ related bugs
[tas256xsw-android/tas2563-android-driver.git] / tas2563-regmap.c
index a9c580f4bcb35fa2ddb65dea4e5d92bed83257b7..3a98cdb751588e57b7c290759c3c4e7bfc5771bd 100755 (executable)
@@ -56,6 +56,8 @@
 
 #define LOW_TEMPERATURE_GAIN 6
 #define LOW_TEMPERATURE_COUNTER 12
+static char pICN[] = {0x00, 0x00, 0x2f, 0x2c};
+static char pICNDelay[] = {0x00, 0x00, 0x70, 0x80};
 
 static int tas2563_change_book_page(struct tas2563_priv *pTAS2563,
        int book, int page)
@@ -115,9 +117,9 @@ static int tas2563_dev_read(struct tas2563_priv *pTAS2563,
                dev_err(pTAS2563->dev, "%s, ERROR, L=%d, E=%d\n",
                        __func__, __LINE__, nResult);
        else
-               dev_dbg(pTAS2563->dev, "%s: BOOK:PAGE:REG %u:%u:%u\n", __func__,
+               dev_dbg(pTAS2563->dev, "%s: BOOK:PAGE:REG %u:%u:%u,%x\n", __func__,
                        TAS2563_BOOK_ID(reg), TAS2563_PAGE_ID(reg),
-                       TAS2563_PAGE_REG(reg));
+                       TAS2563_PAGE_REG(reg), *pValue);
 
 end:
        mutex_unlock(&pTAS2563->dev_lock);
@@ -262,7 +264,7 @@ static const struct reg_default tas2563_reg_defaults[] = {
        { TAS2563_TDMConfigurationReg3, 0x10 },
        { TAS2563_InterruptMaskReg0, 0xfc },
        { TAS2563_InterruptMaskReg1, 0xb1 },
-       { TAS2563_InterruptConfiguration, 0x05 },
+       { TAS2563_InterruptConfiguration, 0x1d },
        { TAS2563_MiscIRQ, 0x81 },
        { TAS2563_ClockConfiguration, 0x0c },
 
@@ -328,6 +330,7 @@ static void irq_work_routine(struct work_struct *work)
        unsigned int nDevInt1Status = 0, nDevInt2Status = 0;
        int nCounter = 2;
        int nResult = 0;
+       int irqreg;
 
        dev_info(pTAS2563->dev, "%s\n", __func__);
 #ifdef CONFIG_TAS2563_CODEC
@@ -344,24 +347,24 @@ static void irq_work_routine(struct work_struct *work)
                goto end;
        }
 
-       nResult = regmap_write(pTAS2563->regmap, TAS2563_InterruptMaskReg0,
+       nResult = tas2563_dev_write(pTAS2563, TAS2563_InterruptMaskReg0,
                                TAS2563_InterruptMaskReg0_Disable);
-       nResult = regmap_write(pTAS2563->regmap, TAS2563_InterruptMaskReg1,
+       nResult = tas2563_dev_write(pTAS2563, TAS2563_InterruptMaskReg1,
                                TAS2563_InterruptMaskReg1_Disable);
 
        if (nResult < 0)
                goto reload;
 
-       nResult = regmap_read(pTAS2563->regmap, TAS2563_LatchedInterruptReg0, &nDevInt1Status);
+       nResult = tas2563_dev_read(pTAS2563, TAS2563_LatchedInterruptReg0, &nDevInt1Status);
        if (nResult >= 0)
-               nResult = regmap_read(pTAS2563->regmap, TAS2563_LatchedInterruptReg1, &nDevInt2Status);
+               nResult = tas2563_dev_read(pTAS2563, TAS2563_LatchedInterruptReg1, &nDevInt2Status);
        else
                goto reload;
 
-       dev_dbg(pTAS2563->dev, "IRQ status : 0x%x, 0x%x\n",
+       dev_info(pTAS2563->dev, "IRQ status : 0x%x, 0x%x\n",
                        nDevInt1Status, nDevInt2Status);
 
-       if (((nDevInt1Status & 0x3) != 0) || ((nDevInt2Status & 0x0f) != 0)) {
+       if (((nDevInt1Status & 0x7) != 0) || ((nDevInt2Status & 0x0f) != 0)) {
                /* in case of INT_OC, INT_OT, INT_OVLT, INT_UVLT, INT_BO */
 
                if (nDevInt1Status & TAS2563_LatchedInterruptReg0_OCEFlagSticky_Interrupt) {
@@ -399,7 +402,7 @@ static void irq_work_routine(struct work_struct *work)
                nCounter = 2;
 
                while (nCounter > 0) {
-                       nResult = regmap_read(pTAS2563->regmap, TAS2563_PowerControl, &nDevInt1Status);
+                       nResult = tas2563_dev_read(pTAS2563, TAS2563_PowerControl, &nDevInt1Status);
                        if (nResult < 0)
                                goto reload;
 
@@ -407,12 +410,42 @@ static void irq_work_routine(struct work_struct *work)
                                != TAS2563_PowerControl_OperationalMode10_Shutdown)
                                break;
 
+                       pTAS2563->read(pTAS2563, TAS2563_LatchedInterruptReg0, &irqreg);
+                       dev_info(pTAS2563->dev, "IRQ reg is: %s %d, %d\n", __func__, irqreg, __LINE__);
+
+                       nResult = pTAS2563->update_bits(pTAS2563, TAS2563_PowerControl,
+                               TAS2563_PowerControl_OperationalMode10_Mask |
+                               TAS2563_PowerControl_ISNSPower_Mask |
+                               TAS2563_PowerControl_VSNSPower_Mask,
+                               TAS2563_PowerControl_OperationalMode10_Active |
+                               TAS2563_PowerControl_VSNSPower_Active |
+                               TAS2563_PowerControl_ISNSPower_Active);
+                       if (nResult < 0)
+                               goto reload;
+
+                       pTAS2563->read(pTAS2563, TAS2563_LatchedInterruptReg0, &irqreg);
+                       dev_info(pTAS2563->dev, "IRQ reg is: %s, %d, %d\n", __func__, irqreg, __LINE__);
+
+                       dev_info(pTAS2563->dev, "set ICN to -90dB\n");
+                       nResult = pTAS2563->bulk_write(pTAS2563, TAS2563_ICN_REG, pICN, 4);
+                       if(nResult < 0)
+                               goto reload;
+
+                       pTAS2563->read(pTAS2563, TAS2563_LatchedInterruptReg0, &irqreg);
+                       dev_info(pTAS2563->dev, "IRQ reg is: %d, %d\n", irqreg, __LINE__);
+
+                       dev_info(pTAS2563->dev, "set ICN delay\n");
+                       nResult = pTAS2563->bulk_write(pTAS2563, TAS2563_ICN_DELAY, pICNDelay, 4);
+
+                       pTAS2563->read(pTAS2563, TAS2563_LatchedInterruptReg0, &irqreg);
+                       dev_info(pTAS2563->dev, "IRQ reg is: %d, %d\n", irqreg, __LINE__);
+
                        nCounter--;
                        if (nCounter > 0) {
-                               /* in case check pow status just after power on TAS2563 */
+                               /* in case check power status just after power on TAS2563 */
                                dev_dbg(pTAS2563->dev, "PowSts B: 0x%x, check again after 10ms\n",
                                        nDevInt1Status);
-                               msleep(10);
+                               msleep(20);
                        }
                }
 
@@ -428,11 +461,11 @@ static void irq_work_routine(struct work_struct *work)
                pTAS2563->mnErrCode &= ~ERROR_CLASSD_PWR;
        }
 
-       nResult = regmap_write(pTAS2563->regmap, TAS2563_InterruptMaskReg0, 0xfc);
+       nResult = tas2563_dev_write(pTAS2563, TAS2563_InterruptMaskReg0, 0xf8);
        if (nResult < 0)
                goto reload;
 
-       nResult = regmap_write(pTAS2563->regmap, TAS2563_InterruptMaskReg1, 0xb1);
+       nResult = tas2563_dev_write(pTAS2563, TAS2563_InterruptMaskReg1, 0xb1);
        if (nResult < 0)
                goto reload;
 
@@ -444,11 +477,11 @@ reload:
        //tas2563_LoadConfig(pTAS2563);
        tas2563_set_program(pTAS2563, pTAS2563->mnCurrentProgram, pTAS2563->mnCurrentConfiguration);
 
+end:
        if (nResult >= 0) {
                tas2563_enableIRQ(pTAS2563, true);
        }
-       
-end:
+
 #ifdef CONFIG_TAS2563_CODEC
        mutex_unlock(&pTAS2563->codec_lock);
 #endif
@@ -677,7 +710,7 @@ static int tas2563_i2c_probe(struct i2c_client *pClient,
                dev_dbg(pTAS2563->dev, "irq = %d\n", pTAS2563->mnIRQ);
                INIT_DELAYED_WORK(&pTAS2563->irq_work, irq_work_routine);
                nResult = request_threaded_irq(pTAS2563->mnIRQ, tas2563_irq_handler,
-                                       NULL, IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
+                                       NULL, IRQF_TRIGGER_LOW | IRQF_ONESHOT,
                                        pClient->name, pTAS2563);
                if (nResult < 0) {
                        dev_err(pTAS2563->dev,