Add IRQ enable
authorTracy Yi <tracy-yi@ti.com>
Thu, 13 Dec 2018 02:56:26 +0000 (10:56 +0800)
committerTracy Yi <tracy-yi@ti.com>
Thu, 13 Dec 2018 02:58:55 +0000 (10:58 +0800)
Signed-off-by: Tracy Yi <tracy-yi@ti.com>
tas2770-codec.c
tas2770-regmap.c

index 1e4e852969d68c5ef37128e5396c0a8574de207f..295e3bcf144976a4116df739f5677a3d44afde9f 100644 (file)
@@ -108,6 +108,7 @@ static int tas2770_codec_suspend(struct snd_soc_codec *codec)
        mutex_lock(&pTAS2770->codec_lock);
 
        dev_dbg(pTAS2770->dev, "%s\n", __func__);
+       pTAS2770->runtime_suspend(pTAS2770);
 
        mutex_unlock(&pTAS2770->codec_lock);
        return ret;
@@ -121,6 +122,7 @@ static int tas2770_codec_resume(struct snd_soc_codec *codec)
        mutex_lock(&pTAS2770->codec_lock);
 
        dev_dbg(pTAS2770->dev, "%s\n", __func__);
+       pTAS2770->runtime_resume(pTAS2770);
 
        mutex_unlock(&pTAS2770->codec_lock);
        return ret;
@@ -146,18 +148,23 @@ static int tas2770_set_power_state(struct tas2770_priv *pTAS2770, int state)
                snd_soc_update_bits(codec, TAS2770_PowerControl,
                        TAS2770_PowerControl_OperationalMode10_Mask,
                        TAS2770_PowerControl_OperationalMode10_Active);
+               pTAS2770->mnPowerState = TAS2770_POWER_ACTIVE;
+               pTAS2770->enableIRQ(pTAS2770, true);
                break;
 
        case TAS2770_POWER_MUTE:
                snd_soc_update_bits(codec, TAS2770_PowerControl,
                        TAS2770_PowerControl_OperationalMode10_Mask,
                        TAS2770_PowerControl_OperationalMode10_Mute);
+               pTAS2770->mnPowerState = TAS2770_POWER_MUTE;
                break;
 
        case TAS2770_POWER_SHUTDOWN:
                snd_soc_update_bits(codec, TAS2770_PowerControl,
                        TAS2770_PowerControl_OperationalMode10_Mask,
                        TAS2770_PowerControl_OperationalMode10_Shutdown);
+               pTAS2770->enableIRQ(pTAS2770, false);
+               pTAS2770->mnPowerState = TAS2770_POWER_SHUTDOWN;
                break;
 
        default:
@@ -248,26 +255,26 @@ static int tas2770_set_bitwidth(struct tas2770_priv *pTAS2770, int bitwidth)
                        TAS2770_TDMConfigurationReg2_RXWLEN32_Mask,
                        TAS2770_TDMConfigurationReg2_RXWLEN32_16Bits);
                        /* If machine driver did not call set slot width */
-                       if (pTAS2770->mnSlot_width == 0)
-                               tas2770_set_slot(pTAS2770->codec, 16);
+               if (pTAS2770->mnSlot_width == 0)
+                       tas2770_set_slot(pTAS2770->codec, 16);
                pTAS2770->mnVmon_slot_no = pTAS2770->mnImon_slot_no + 2;
                break;
        case SNDRV_PCM_FORMAT_S24_LE:
-                       snd_soc_update_bits(pTAS2770->codec,
+               snd_soc_update_bits(pTAS2770->codec,
                        TAS2770_TDMConfigurationReg2,
                        TAS2770_TDMConfigurationReg2_RXWLEN32_Mask,
                        TAS2770_TDMConfigurationReg2_RXWLEN32_24Bits);
-                       if (pTAS2770->mnSlot_width == 0)
-                               tas2770_set_slot(pTAS2770->codec, 32);
+               if (pTAS2770->mnSlot_width == 0)
+                       tas2770_set_slot(pTAS2770->codec, 32);
                pTAS2770->mnVmon_slot_no = pTAS2770->mnImon_slot_no + 4;
                break;
        case SNDRV_PCM_FORMAT_S32_LE:
-                       snd_soc_update_bits(pTAS2770->codec,
+               snd_soc_update_bits(pTAS2770->codec,
                        TAS2770_TDMConfigurationReg2,
                        TAS2770_TDMConfigurationReg2_RXWLEN32_Mask,
                        TAS2770_TDMConfigurationReg2_RXWLEN32_32Bits);
-                       if (pTAS2770->mnSlot_width == 0)
-                               tas2770_set_slot(pTAS2770->codec, 32);
+               if (pTAS2770->mnSlot_width == 0)
+                       tas2770_set_slot(pTAS2770->codec, 32);
                pTAS2770->mnVmon_slot_no = pTAS2770->mnImon_slot_no + 4;
                break;
 
index 196f163b897e43e2bd23c99208acb75f6702d414..c98cdc7e794bcd579f17df70c2857fe4d6d8f3f2 100644 (file)
@@ -172,7 +172,7 @@ static void irq_work_routine(struct work_struct *work)
        else
                goto reload;
 
-       dev_dbg(pTAS2770->dev, "IRQ status : 0x%x, 0x%x\n",
+       dev_info(pTAS2770->dev, "IRQ status : 0x%x, 0x%x\n",
                        nDevInt1Status, nDevInt2Status);
 
        if (((nDevInt1Status & 0x3) != 0) || ((nDevInt2Status & 0x0f) != 0)) {
@@ -409,13 +409,14 @@ static int tas2770_i2c_probe(struct i2c_client *client,
                sizeof(struct tas2770_priv), GFP_KERNEL);
        if (pTAS2770 == NULL) {
                nResult = -ENOMEM;
+               dev_info(&client->dev, "Failed to allocate i2c device\n");
                goto end;
        }
 
        pTAS2770->dev = &client->dev;
        i2c_set_clientdata(client, pTAS2770);
        dev_set_drvdata(&client->dev, pTAS2770);
-       pTAS2770->mnPowerState = TAS2770_POWER_STATE;
+       pTAS2770->mnPowerState = TAS2770_POWER_SHUTDOWN;
 
        pTAS2770->regmap = devm_regmap_init_i2c(client, &tas2770_i2c_regmap);
        if (IS_ERR(pTAS2770->regmap)) {
@@ -447,7 +448,8 @@ static int tas2770_i2c_probe(struct i2c_client *client,
                }
                gpio_direction_input(pTAS2770->mnIRQGPIO);
                pTAS2770->mnIRQ = gpio_to_irq(pTAS2770->mnIRQGPIO);
-               dev_dbg(pTAS2770->dev, "irq = %d\n", pTAS2770->mnIRQ);
+               dev_info(pTAS2770->dev, "irq = %d\n", pTAS2770->mnIRQ);
+               INIT_DELAYED_WORK(&pTAS2770->irq_work, irq_work_routine);
                nResult = request_threaded_irq(pTAS2770->mnIRQ,
                                        tas2770_irq_handler, NULL,
                                        IRQF_TRIGGER_LOW | IRQF_ONESHOT,
@@ -458,7 +460,6 @@ static int tas2770_i2c_probe(struct i2c_client *client,
                        goto free_gpio;
                }
                disable_irq_nosync(pTAS2770->mnIRQ);
-               INIT_DELAYED_WORK(&pTAS2770->irq_work, irq_work_routine);
        }
 
        pTAS2770->hw_reset = tas2770_hw_reset;