Add IRQ support
authorTracy Yi <tracy-yi@ti.com>
Sat, 29 Dec 2018 14:19:21 +0000 (22:19 +0800)
committerTracy Yi <tracy-yi@ti.com>
Sat, 29 Dec 2018 14:19:21 +0000 (22:19 +0800)
Signed-off-by: Tracy Yi <tracy-yi@ti.com>
tas2562-codec.c
tas2562-codec.h
tas2562-regmap.c
tas2562.h

index dc9a4dc60b765afbdfbee00a9839c39cc4f0b223..2efdc0786b45a1e876b4fcc14f098e38d72d5a7f 100644 (file)
@@ -21,7 +21,7 @@
 */
 
 #ifdef CONFIG_TAS2562_CODEC
-#define DEBUG
+#define DEBUG 5
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/init.h>
 
 #define TAS2562_MDELAY 0xFFFFFFFE
 /* #define KCONTROL_CODEC */
+
+static char pICN[] = {0x00, 0x03, 0x46, 0xdc};
 static char const *iv_enable_text[] = {"Off", "On"};
 static int tas2562iv_enable;
 static const struct soc_enum tas2562_enum[] = {
     SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(iv_enable_text), iv_enable_text),
 };
+static int tas2562_set_fmt(struct tas2562_priv *pTAS2562, unsigned int fmt);
 
 static unsigned int tas2562_codec_read(struct snd_soc_codec *codec,
                unsigned int reg)
@@ -79,53 +82,58 @@ static unsigned int tas2562_codec_read(struct snd_soc_codec *codec,
                return nResult;
 }
 
-static int tas2562iv_put(struct snd_kcontrol *kcontrol,
-                                  struct snd_ctl_elem_value *ucontrol)
+static int tas2562_iv_enable(struct tas2562_priv *pTAS2562, int enable)
 {
-    struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
-
-    if (codec == NULL) {
-               pr_err("%s: codec is NULL \n",  __func__);
-               return 0;
-    }
+       int nResult;
 
-    tas2562iv_enable = ucontrol->value.integer.value[0];
-
-       if (tas2562iv_enable) {
+       if (enable) {
                pr_debug("%s: tas2562iv_enable \n", __func__);
-               snd_soc_update_bits(codec, TAS2562_PowerControl,
-                       TAS2562_PowerControl_OperationalMode10_Mask |
+               nResult = pTAS2562->update_bits(pTAS2562, TAS2562_PowerControl,
                    TAS2562_PowerControl_ISNSPower_Mask |
                    TAS2562_PowerControl_VSNSPower_Mask,
-                   TAS2562_PowerControl_OperationalMode10_Active |
                    TAS2562_PowerControl_VSNSPower_Active |
                    TAS2562_PowerControl_ISNSPower_Active);
        } else {
                pr_debug("%s: tas2562iv_disable \n", __func__);
-               snd_soc_update_bits(codec, TAS2562_PowerControl,
-                       TAS2562_PowerControl_OperationalMode10_Mask |
+               nResult = pTAS2562->update_bits(pTAS2562, TAS2562_PowerControl,
                        TAS2562_PowerControl_ISNSPower_Mask |
                        TAS2562_PowerControl_VSNSPower_Mask,
-                       TAS2562_PowerControl_OperationalMode10_Active |
                        TAS2562_PowerControl_VSNSPower_PoweredDown |
                        TAS2562_PowerControl_ISNSPower_PoweredDown);
        }
+       tas2562iv_enable = enable;
+
+       return nResult;
+}
+
+static int tas2562iv_put(struct snd_kcontrol *kcontrol,
+                                  struct snd_ctl_elem_value *ucontrol)
+{
+    struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
+       struct tas2562_priv *pTAS2562 = snd_soc_codec_get_drvdata(codec);
+       int iv_enable = 0, nResult = 0;
+
+    if (codec == NULL) {
+               pr_err("%s: codec is NULL \n",  __func__);
+               return 0;
+    }
+
+    iv_enable = ucontrol->value.integer.value[0];
+
+       nResult = tas2562_iv_enable(pTAS2562, iv_enable);
 
        pr_debug("%s: tas2562iv_enable = %d\n", __func__, tas2562iv_enable);
 
-       return 0;
+       return nResult;
 }
 
 static int tas2562iv_get(struct snd_kcontrol *kcontrol,
                                  struct snd_ctl_elem_value *ucontrol)
 {
-   int value;
    ucontrol->value.integer.value[0] = tas2562iv_enable;
-   value=gpio_get_value(37);
-   pr_debug("%s: tas2562iv_enable = %d\n", __func__, tas2562iv_enable);
-   pr_debug("%s: gpio37 value = %d\n", __func__, value);
    return 0;
 }
+
 static const struct snd_kcontrol_new tas2562_controls[] = {
 SOC_ENUM_EXT("TAS2562 IVSENSE ENABLE", tas2562_enum[0],
                    tas2562iv_get, tas2562iv_put),
@@ -192,26 +200,86 @@ static const struct snd_kcontrol_new tas2562_asi_controls[] = {
                4, 3, 0),
 };
 
-
-static int tas2562_dac_event(struct snd_soc_dapm_widget *w,
-                       struct snd_kcontrol *kcontrol, int event)
+static int tas2562_set_power_state(struct tas2562_priv *pTAS2562, int state)
 {
-       struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
+       int nResult = 0;
+       /*unsigned int nValue;*/
+
+       dev_err(pTAS2562->dev, "set power state: %d\n", state);
+
+       switch (state) {
+       case TAS2562_POWER_ACTIVE:
+        //if set format was not called by asoc, then set it default
+               if(pTAS2562->mnASIFormat == 0)
+                       pTAS2562->mnASIFormat = SND_SOC_DAIFMT_CBS_CFS
+                               | SND_SOC_DAIFMT_IB_NF
+                               | SND_SOC_DAIFMT_I2S;
+               nResult = tas2562_set_fmt(pTAS2562, pTAS2562->mnASIFormat);
+               if (nResult < 0)
+                       return nResult;
+
+               nResult = pTAS2562->update_bits(pTAS2562, TAS2562_PowerControl,
+                       TAS2562_PowerControl_OperationalMode10_Mask,
+                       TAS2562_PowerControl_OperationalMode10_Active);
+               if (nResult < 0)
+                       return nResult;
+               pTAS2562->mbPowerUp = true;
+               dev_info(pTAS2562->dev, "set ICN to -80dB\n");
+               nResult = pTAS2562->bulk_write(pTAS2562, TAS2562_ICN_REG, pICN, 4);
+               pTAS2562->mnPowerState = TAS2562_POWER_ACTIVE;
+        pTAS2562->enableIRQ(pTAS2562, true);
+               break;
 
-       switch (event) {
-       case SND_SOC_DAPM_POST_PMU:
-               snd_soc_update_bits(codec, TAS2562_PowerControl,
+       case TAS2562_POWER_MUTE:
+               nResult = pTAS2562->update_bits(pTAS2562, TAS2562_PowerControl,
                        TAS2562_PowerControl_OperationalMode10_Mask |
                        TAS2562_PowerControl_ISNSPower_Mask |
                        TAS2562_PowerControl_VSNSPower_Mask,
-                       TAS2562_PowerControl_OperationalMode10_Active |
+                       TAS2562_PowerControl_OperationalMode10_Mute |
                        TAS2562_PowerControl_VSNSPower_Active |
                        TAS2562_PowerControl_ISNSPower_Active);
+                       pTAS2562->mbPowerUp = true;
+                       pTAS2562->mnPowerState = TAS2562_POWER_MUTE;
                break;
-       case SND_SOC_DAPM_PRE_PMD:
-               snd_soc_update_bits(codec, TAS2562_PowerControl,
+
+       case TAS2562_POWER_SHUTDOWN:
+               pTAS2562->enableIRQ(pTAS2562, false);
+               if (hrtimer_active(&pTAS2562->mtimer))
+               {
+                       dev_info(pTAS2562->dev, "cancel timer\n");
+                       hrtimer_cancel(&pTAS2562->mtimer);
+               }
+
+               nResult = pTAS2562->update_bits(pTAS2562, TAS2562_PowerControl,
                        TAS2562_PowerControl_OperationalMode10_Mask,
                        TAS2562_PowerControl_OperationalMode10_Shutdown);
+                       pTAS2562->mbPowerUp = false;
+                       pTAS2562->mnPowerState = TAS2562_POWER_SHUTDOWN;
+               msleep(20);
+
+               break;
+
+       default:
+               dev_err(pTAS2562->dev, "wrong power state setting %d\n", state);
+
+       }
+
+       return nResult;
+}
+
+
+static int tas2562_dac_event(struct snd_soc_dapm_widget *w,
+                       struct snd_kcontrol *kcontrol, int event)
+{
+       struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
+       struct tas2562_priv *pTAS2562 = snd_soc_codec_get_drvdata(codec);
+
+       switch (event) {
+       case SND_SOC_DAPM_POST_PMU:
+               tas2562_set_power_state(pTAS2562, TAS2562_POWER_ACTIVE);
+               break;
+       case SND_SOC_DAPM_PRE_PMD:
+               tas2562_set_power_state(pTAS2562, TAS2562_POWER_SHUTDOWN);
                break;
 
        }
@@ -252,15 +320,13 @@ static int tas2562_mute(struct snd_soc_dai *dai, int mute)
        struct snd_soc_codec *codec = dai->codec;
        struct tas2562_priv *pTAS2562 = snd_soc_codec_get_drvdata(codec);
 
+       dev_dbg(pTAS2562->dev, "%s, %d \n", __func__, mute);
+
        mutex_lock(&pTAS2562->codec_lock);
        if (mute) {
-               snd_soc_update_bits(codec, TAS2562_PowerControl,
-                       TAS2562_PowerControl_OperationalMode10_Mask,
-                       TAS2562_PowerControl_OperationalMode10_Mute);
+               tas2562_set_power_state(pTAS2562, TAS2562_POWER_SHUTDOWN);
        } else {
-               snd_soc_update_bits(codec, TAS2562_PowerControl,
-                       TAS2562_PowerControl_OperationalMode10_Mask,
-                       TAS2562_PowerControl_OperationalMode10_Active);
+               tas2562_set_power_state(pTAS2562, TAS2562_POWER_ACTIVE);
        }
        mutex_unlock(&pTAS2562->codec_lock);
        return 0;
@@ -269,18 +335,15 @@ static int tas2562_mute(struct snd_soc_dai *dai, int mute)
 static int tas2562_slot_config(struct snd_soc_codec *codec, struct tas2562_priv *pTAS2562, int blr_clk_ratio)
 {
        int ret = 0;
-               snd_soc_update_bits(codec,
+               pTAS2562->update_bits(pTAS2562,
                        TAS2562_TDMConfigurationReg5, 0xff, 0x42);
 
-               snd_soc_update_bits(codec,
+               pTAS2562->update_bits(pTAS2562,
                        TAS2562_TDMConfigurationReg6, 0xff, 0x40);
 
        return ret;
 }
 
-//Added/Mofified 060356-PP
-//To avoid implicit decleration 
-
 static int tas2562_set_slot(struct snd_soc_codec *codec, int slot_width)
 {
        int ret = 0;
@@ -288,21 +351,21 @@ static int tas2562_set_slot(struct snd_soc_codec *codec, int slot_width)
 
        switch (slot_width) {
        case 16:
-       ret = snd_soc_update_bits(codec,
+       ret = pTAS2562->update_bits(pTAS2562,
                TAS2562_TDMConfigurationReg2,
                TAS2562_TDMConfigurationReg2_RXSLEN10_Mask,
                TAS2562_TDMConfigurationReg2_RXSLEN10_16Bits);
        break;
 
        case 24:
-       ret = snd_soc_update_bits(codec,
+       ret = pTAS2562->update_bits(pTAS2562,
                TAS2562_TDMConfigurationReg2,
                TAS2562_TDMConfigurationReg2_RXSLEN10_Mask,
                TAS2562_TDMConfigurationReg2_RXSLEN10_24Bits);
        break;
 
        case 32:
-       ret = snd_soc_update_bits(codec,
+       ret = pTAS2562->update_bits(pTAS2562,
                TAS2562_TDMConfigurationReg2,
                TAS2562_TDMConfigurationReg2_RXSLEN10_Mask,
                TAS2562_TDMConfigurationReg2_RXSLEN10_32Bits);
@@ -313,7 +376,7 @@ static int tas2562_set_slot(struct snd_soc_codec *codec, int slot_width)
        break;
 
        default:
-               dev_dbg(pTAS2562->dev, "slot width not supported");
+               dev_err(pTAS2562->dev, "slot width not supported");
                ret = -EINVAL;
        }
 
@@ -323,136 +386,168 @@ static int tas2562_set_slot(struct snd_soc_codec *codec, int slot_width)
        return ret;
 }
 
-static int tas2562_hw_params(struct snd_pcm_substream *substream,
-               struct snd_pcm_hw_params *params,
-               struct snd_soc_dai *dai)
+static int tas2562_set_bitwidth(struct tas2562_priv *pTAS2562, int bitwidth)
 {
-       struct snd_soc_codec *codec = dai->codec;
-       struct tas2562_priv *pTAS2562 = snd_soc_codec_get_drvdata(codec);
-       int blr_clk_ratio;
-       int ret = 0;
        int slot_width_tmp = 16;
+       dev_info(pTAS2562->dev, "%s %d\n", __func__, bitwidth);
 
-       dev_dbg(pTAS2562->dev, "%s, format: %d\n", __func__,
-               params_format(params));
-
-       switch (params_format(params)) {
+       switch (bitwidth) {
        case SNDRV_PCM_FORMAT_S16_LE:
-               snd_soc_update_bits(codec,
+                       pTAS2562->update_bits(pTAS2562,
                        TAS2562_TDMConfigurationReg2,
                        TAS2562_TDMConfigurationReg2_RXWLEN32_Mask,
                        TAS2562_TDMConfigurationReg2_RXWLEN32_16Bits);
-                       pTAS2562->ch_size = 16;
+                       pTAS2562->mnCh_size = 16;
                        if (pTAS2562->mnSlot_width == 0)
                                slot_width_tmp = 16;
                break;
-       case SNDRV_PCM_FMTBIT_S24_LE:
-                       snd_soc_update_bits(codec,
+       case SNDRV_PCM_FORMAT_S24_LE:
+                       pTAS2562->update_bits(pTAS2562,
                        TAS2562_TDMConfigurationReg2,
                        TAS2562_TDMConfigurationReg2_RXWLEN32_Mask,
                        TAS2562_TDMConfigurationReg2_RXWLEN32_24Bits);
-                       pTAS2562->ch_size = 24;
+                       pTAS2562->mnCh_size = 24;
                        if (pTAS2562->mnSlot_width == 0)
                                slot_width_tmp = 32;
                break;
-       case SNDRV_PCM_FMTBIT_S32_LE:
-                       snd_soc_update_bits(codec,
+       case SNDRV_PCM_FORMAT_S32_LE:
+                       pTAS2562->update_bits(pTAS2562,
                        TAS2562_TDMConfigurationReg2,
                        TAS2562_TDMConfigurationReg2_RXWLEN32_Mask,
                        TAS2562_TDMConfigurationReg2_RXWLEN32_32Bits);
-                       pTAS2562->ch_size = 32;
+                       pTAS2562->mnCh_size = 32;
                        if (pTAS2562->mnSlot_width == 0)
                                slot_width_tmp = 32;
                break;
 
+       default:
+               dev_info(pTAS2562->dev, "Not supported params format\n");
        }
 
        /* If machine driver did not call set slot width */
        if (pTAS2562->mnSlot_width == 0)
-               tas2562_set_slot(codec, slot_width_tmp);
+               tas2562_set_slot(pTAS2562->codec, slot_width_tmp);
 
-       blr_clk_ratio = params_channels(params) * pTAS2562->ch_size;
-       dev_dbg(pTAS2562->dev, "blr_clk_ratio: %d\n", blr_clk_ratio);
-       tas2562_slot_config(codec, pTAS2562, blr_clk_ratio);
+       dev_info(pTAS2562->dev, "mnCh_size: %d\n", pTAS2562->mnCh_size);
+       pTAS2562->mnPCMFormat = bitwidth;
 
-       dev_dbg(pTAS2562->dev, "%s, sample rate: %d\n", __func__,
-               params_rate(params));
-       switch (params_rate(params)) {
+       return 0;
+}
+
+static int tas2562_set_samplerate(struct tas2562_priv *pTAS2562, int samplerate)
+{
+       switch (samplerate) {
        case 48000:
-                       snd_soc_update_bits(codec,
+                       pTAS2562->update_bits(pTAS2562,
                                TAS2562_TDMConfigurationReg0,
                                TAS2562_TDMConfigurationReg0_SAMPRATERAMP_Mask,
-                       TAS2562_TDMConfigurationReg0_SAMPRATERAMP_48KHz);
-                       snd_soc_update_bits(codec,
+                               TAS2562_TDMConfigurationReg0_SAMPRATERAMP_48KHz);
+                       pTAS2562->update_bits(pTAS2562,
                                TAS2562_TDMConfigurationReg0,
                                TAS2562_TDMConfigurationReg0_SAMPRATE31_Mask,
-                       TAS2562_TDMConfigurationReg0_SAMPRATE31_44_1_48kHz);
+                               TAS2562_TDMConfigurationReg0_SAMPRATE31_44_1_48kHz);
                        break;
        case 44100:
-                       snd_soc_update_bits(codec,
+                       pTAS2562->update_bits(pTAS2562,
                                TAS2562_TDMConfigurationReg0,
                                TAS2562_TDMConfigurationReg0_SAMPRATERAMP_Mask,
-                       TAS2562_TDMConfigurationReg0_SAMPRATERAMP_44_1KHz);
-                       snd_soc_update_bits(codec,
+                               TAS2562_TDMConfigurationReg0_SAMPRATERAMP_44_1KHz);
+                       pTAS2562->update_bits(pTAS2562,
                                TAS2562_TDMConfigurationReg0,
                                TAS2562_TDMConfigurationReg0_SAMPRATE31_Mask,
-                       TAS2562_TDMConfigurationReg0_SAMPRATE31_44_1_48kHz);
+                               TAS2562_TDMConfigurationReg0_SAMPRATE31_44_1_48kHz);
                        break;
        case 96000:
-                       snd_soc_update_bits(codec,
+                       pTAS2562->update_bits(pTAS2562,
                                TAS2562_TDMConfigurationReg0,
                                TAS2562_TDMConfigurationReg0_SAMPRATERAMP_Mask,
-                       TAS2562_TDMConfigurationReg0_SAMPRATERAMP_48KHz);
-                       snd_soc_update_bits(codec,
+                               TAS2562_TDMConfigurationReg0_SAMPRATERAMP_48KHz);
+                       pTAS2562->update_bits(pTAS2562,
                                TAS2562_TDMConfigurationReg0,
                                TAS2562_TDMConfigurationReg0_SAMPRATE31_Mask,
-                       TAS2562_TDMConfigurationReg0_SAMPRATE31_88_2_96kHz);
+                               TAS2562_TDMConfigurationReg0_SAMPRATE31_88_2_96kHz);
                        break;
        case 88200:
-                       snd_soc_update_bits(codec,
+                       pTAS2562->update_bits(pTAS2562,
                                TAS2562_TDMConfigurationReg0,
                                TAS2562_TDMConfigurationReg0_SAMPRATERAMP_Mask,
-                       TAS2562_TDMConfigurationReg0_SAMPRATERAMP_44_1KHz);
-                       snd_soc_update_bits(codec,
+                               TAS2562_TDMConfigurationReg0_SAMPRATERAMP_44_1KHz);
+                       pTAS2562->update_bits(pTAS2562,
                                TAS2562_TDMConfigurationReg0,
                                TAS2562_TDMConfigurationReg0_SAMPRATE31_Mask,
-                       TAS2562_TDMConfigurationReg0_SAMPRATE31_88_2_96kHz);
+                               TAS2562_TDMConfigurationReg0_SAMPRATE31_88_2_96kHz);
                        break;
        case 19200:
-                       snd_soc_update_bits(codec,
+                       pTAS2562->update_bits(pTAS2562,
                                TAS2562_TDMConfigurationReg0,
                                TAS2562_TDMConfigurationReg0_SAMPRATERAMP_Mask,
-                       TAS2562_TDMConfigurationReg0_SAMPRATERAMP_48KHz);
-                       snd_soc_update_bits(codec,
+                               TAS2562_TDMConfigurationReg0_SAMPRATERAMP_48KHz);
+                       pTAS2562->update_bits(pTAS2562,
                                TAS2562_TDMConfigurationReg0,
                                TAS2562_TDMConfigurationReg0_SAMPRATE31_Mask,
-                       TAS2562_TDMConfigurationReg0_SAMPRATE31_176_4_192kHz);
+                               TAS2562_TDMConfigurationReg0_SAMPRATE31_176_4_192kHz);
                        break;
        case 17640:
-                       snd_soc_update_bits(codec,
+                       pTAS2562->update_bits(pTAS2562,
                                TAS2562_TDMConfigurationReg0,
                                TAS2562_TDMConfigurationReg0_SAMPRATERAMP_Mask,
-                       TAS2562_TDMConfigurationReg0_SAMPRATERAMP_44_1KHz);
-                       snd_soc_update_bits(codec,
+                               TAS2562_TDMConfigurationReg0_SAMPRATERAMP_44_1KHz);
+                       pTAS2562->update_bits(pTAS2562,
                                TAS2562_TDMConfigurationReg0,
                                TAS2562_TDMConfigurationReg0_SAMPRATE31_Mask,
-                       TAS2562_TDMConfigurationReg0_SAMPRATE31_176_4_192kHz);
+                               TAS2562_TDMConfigurationReg0_SAMPRATE31_176_4_192kHz);
                        break;
        default:
-       dev_dbg(pTAS2562->dev, "%s, unsupported sample rate\n", __func__);
+                       dev_info(pTAS2562->dev, "%s, unsupported sample rate, %d\n", __func__, samplerate);
 
        }
-       return ret;
+
+       pTAS2562->mnSamplingRate = samplerate;
+       return 0;
 }
 
-static int tas2562_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
+
+
+static int tas2562_hw_params(struct snd_pcm_substream *substream,
+               struct snd_pcm_hw_params *params,
+               struct snd_soc_dai *dai)
 {
-       u8 tdm_rx_start_slot = 0, asi_cfg_1 = 0;
        struct snd_soc_codec *codec = dai->codec;
        struct tas2562_priv *pTAS2562 = snd_soc_codec_get_drvdata(codec);
+       int blr_clk_ratio;
        int ret = 0;
 
-       dev_dbg(pTAS2562->dev, "%s, format=0x%x\n", __func__, fmt);
+       dev_dbg(pTAS2562->dev, "%s, format: %d\n", __func__,
+               params_format(params));
+
+       mutex_lock(&pTAS2562->codec_lock);
+
+       ret = tas2562_set_bitwidth(pTAS2562, params_format(params));
+       if(ret < 0)
+       {
+               dev_info(pTAS2562->dev, "set bitwidth failed, %d\n", ret);
+               goto ret;
+       }
+
+       blr_clk_ratio = params_channels(params) * pTAS2562->mnCh_size;
+       dev_info(pTAS2562->dev, "blr_clk_ratio: %d\n", blr_clk_ratio);
+       if(blr_clk_ratio != 0)
+               tas2562_slot_config(pTAS2562->codec, pTAS2562, blr_clk_ratio);
+
+       dev_info(pTAS2562->dev, "%s, sample rate: %d\n", __func__,
+               params_rate(params));
+
+       ret = tas2562_set_samplerate(pTAS2562, params_rate(params));
+
+ret:
+       mutex_unlock(&pTAS2562->codec_lock);
+       return ret;
+}
+
+static int tas2562_set_fmt(struct tas2562_priv *pTAS2562, unsigned int fmt)
+{
+       u8 tdm_rx_start_slot = 0, asi_cfg_1 = 0;
+       int ret = 0;
 
        switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
        case SND_SOC_DAIFMT_CBS_CFS:
@@ -465,11 +560,11 @@ static int tas2562_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
 
        switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
        case SND_SOC_DAIFMT_NB_NF:
-               dev_dbg(pTAS2562->dev, "INV format: NBNF\n");
+               dev_info(pTAS2562->dev, "INV format: NBNF\n");
                asi_cfg_1 |= TAS2562_TDMConfigurationReg1_RXEDGE_Rising;
                break;
        case SND_SOC_DAIFMT_IB_NF:
-               dev_dbg(pTAS2562->dev, "INV format: IBNF\n");
+               dev_info(pTAS2562->dev, "INV format: IBNF\n");
                asi_cfg_1 |= TAS2562_TDMConfigurationReg1_RXEDGE_Falling;
                break;
        default:
@@ -477,7 +572,7 @@ static int tas2562_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
                ret = -EINVAL;
        }
 
-       snd_soc_update_bits(codec, TAS2562_TDMConfigurationReg1,
+       pTAS2562->update_bits(pTAS2562, TAS2562_TDMConfigurationReg1,
                TAS2562_TDMConfigurationReg1_RXEDGE_Mask,
                asi_cfg_1);
 
@@ -498,9 +593,24 @@ static int tas2562_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
                break;
        }
 
-       snd_soc_update_bits(codec, TAS2562_TDMConfigurationReg1,
+       pTAS2562->update_bits(pTAS2562, TAS2562_TDMConfigurationReg1,
                TAS2562_TDMConfigurationReg1_RXOFFSET51_Mask,
-       (tdm_rx_start_slot << TAS2562_TDMConfigurationReg1_RXOFFSET51_Shift));
+               (tdm_rx_start_slot << TAS2562_TDMConfigurationReg1_RXOFFSET51_Shift));
+
+       pTAS2562->mnASIFormat = fmt;
+
+       return 0;
+}
+
+static int tas2562_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
+{
+       struct snd_soc_codec *codec = dai->codec;
+       struct tas2562_priv *pTAS2562 = snd_soc_codec_get_drvdata(codec);
+       int ret = 0;
+
+       dev_dbg(pTAS2562->dev, "%s, format=0x%x\n", __func__, fmt);
+
+       ret = tas2562_set_fmt(pTAS2562, fmt);
        return ret;
 }
 
@@ -573,7 +683,8 @@ static int tas2562_codec_probe(struct snd_soc_codec *codec)
                return ret;
        }
 
-
+       tas2562_iv_enable(pTAS2562, 1);
+       pTAS2562->codec = codec;
        dev_err(pTAS2562->dev, "%s\n", __func__);
 
        return 0;
@@ -584,17 +695,12 @@ static int tas2562_codec_remove(struct snd_soc_codec *codec)
        return 0;
 }
 
-/*static DECLARE_TLV_DB_SCALE(dac_tlv, 0, 100, 0);*/
 static DECLARE_TLV_DB_SCALE(tas2562_digital_tlv, 1100, 50, 0);
-static DECLARE_TLV_DB_SCALE(tas2562_playback_volume, -12750, 50, 0);
 
 static const struct snd_kcontrol_new tas2562_snd_controls[] = {
        SOC_SINGLE_TLV("Amp Output Level", TAS2562_PlaybackConfigurationReg0,
                0, 0x16, 0,
                tas2562_digital_tlv),
-       SOC_SINGLE_TLV("Playback Volume", TAS2562_PlaybackConfigurationReg2,
-               0, TAS2562_PlaybackConfigurationReg2_DVCPCM70_Mask, 1,
-               tas2562_playback_volume),
 };
 
 static struct snd_soc_codec_driver soc_codec_driver_tas2562 = {
@@ -632,6 +738,51 @@ int tas2562_deregister_codec(struct tas2562_priv *pTAS2562)
        return 0;
 }
 
+void tas2562_LoadConfig(struct tas2562_priv *pTAS2562)
+{
+       int ret = 0;
+
+       if (hrtimer_active(&pTAS2562->mtimer))
+       {
+               dev_info(pTAS2562->dev, "cancel timer\n");
+               hrtimer_cancel(&pTAS2562->mtimer);
+       } else
+               dev_info(pTAS2562->dev, "timer not active\n");
+               
+       pTAS2562->hw_reset(pTAS2562);
+       pTAS2562->write(pTAS2562, TAS2562_SoftwareReset,
+                       TAS2562_SoftwareReset_SoftwareReset_Reset);
+    msleep(3);
+
+    pTAS2562->write(pTAS2562, TAS2562_MiscConfigurationReg0, 0xce);
+
+       ret = tas2562_set_slot(pTAS2562->codec, pTAS2562->mnSlot_width);
+       if (ret < 0)
+               goto end;
+
+       ret = tas2562_set_fmt(pTAS2562, pTAS2562->mnASIFormat);
+       if (ret < 0)
+               goto end;
+
+       ret = tas2562_set_bitwidth(pTAS2562, pTAS2562->mnPCMFormat);
+       if (ret < 0)
+               goto end;
+
+       ret = tas2562_set_samplerate(pTAS2562, pTAS2562->mnSamplingRate);
+       if (ret < 0)
+               goto end;
+
+       ret = tas2562_set_power_state(pTAS2562, pTAS2562->mnPowerState);
+       if (ret < 0)
+               goto end;
+
+end:
+/* power up failed, restart later */
+       if (ret < 0)
+               schedule_delayed_work(&pTAS2562->irq_work,
+                               msecs_to_jiffies(1000));
+}
+
 MODULE_AUTHOR("Texas Instruments Inc.");
 MODULE_DESCRIPTION("TAS2562 ALSA SOC Smart Amplifier driver");
 MODULE_LICENSE("GPL v2");
index cd1389470208f94e70b92513b353069647aff2bb..e9cf64bc24f0a4155bd7a0abfa59cabab48553d9 100644 (file)
@@ -26,6 +26,6 @@
 
 int tas2562_register_codec(struct tas2562_priv *pTAS2562);
 int tas2562_deregister_codec(struct tas2562_priv *pTAS2562);
-int tas2562_LoadConfig(struct tas2562_priv *pTAS2562, bool bPowerOn);
+int tas2562_LoadConfig(struct tas2562_priv *pTAS2562);
 
 #endif /* _TAS2562_CODEC_H */
index 47153b57111858c42bd1b4f0d355f1d107102f36..cb293c55d1a21ea6db3e251f810399d0eb5ab483 100644 (file)
@@ -16,7 +16,7 @@
  */
 #ifdef CONFIG_TAS2562_REGMAP
 
-#define DEBUG
+#define DEBUG 5
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/err.h>
@@ -211,59 +211,13 @@ end:
        return nResult;
 }
 
-static const struct reg_default tas2562_reg_defaults[] = {
-       { TAS2562_Page, 0x00 },
-       { TAS2562_SoftwareReset, 0x00 },
-       { TAS2562_PowerControl, 0x0e },
-       { TAS2562_PlaybackConfigurationReg0, 0x10 },
-       { TAS2562_PlaybackConfigurationReg1, 0x01 },
-       { TAS2562_PlaybackConfigurationReg2, 0x00 },
-       { TAS2562_MiscConfigurationReg0, 0x07 },
-       { TAS2562_TDMConfigurationReg1, 0x02 },
-       { TAS2562_TDMConfigurationReg2, 0x0a },
-       { TAS2562_TDMConfigurationReg3, 0x10 },
-       { TAS2562_InterruptMaskReg0, 0xfc },
-       { TAS2562_InterruptMaskReg1, 0xb1 },
-       { TAS2562_InterruptConfiguration, 0x05 },
-       { TAS2562_MiscIRQ, 0x81 },
-       { TAS2562_ClockConfiguration, 0x0c },
-
-};
-
 static bool tas2562_volatile(struct device *dev, unsigned int reg)
 {
-       switch (reg) {
-       case TAS2562_Page: /* regmap implementation requires this */
-       case TAS2562_SoftwareReset: /* always clears after write */
-       case TAS2562_BrownOutPreventionReg0:/* has a self clearing bit */
-       case TAS2562_LiveInterruptReg0:
-       case TAS2562_LiveInterruptReg1:
-       case TAS2562_LatchedInterruptReg0:/* Sticky interrupt flags */
-       case TAS2562_LatchedInterruptReg1:/* Sticky interrupt flags */
-       case TAS2562_VBATMSB:
-       case TAS2562_VBATLSB:
-       case TAS2562_TEMPMSB:
-       case TAS2562_TEMPLSB:
-               return true;
-       }
-       return false;
+       return true;
 }
 
 static bool tas2562_writeable(struct device *dev, unsigned int reg)
 {
-       switch (reg) {
-       case TAS2562_LiveInterruptReg0:
-       case TAS2562_LiveInterruptReg1:
-       case TAS2562_LatchedInterruptReg0:
-       case TAS2562_LatchedInterruptReg1:
-       case TAS2562_VBATMSB:
-       case TAS2562_VBATLSB:
-       case TAS2562_TEMPMSB:
-       case TAS2562_TEMPLSB:
-       case TAS2562_TDMClockdetectionmonitor:
-       case TAS2562_RevisionandPGID:
-               return false;
-       }
        return true;
 }
 static const struct regmap_config tas2562_i2c_regmap = {
@@ -271,9 +225,7 @@ static const struct regmap_config tas2562_i2c_regmap = {
        .val_bits = 8,
        .writeable_reg = tas2562_writeable,
        .volatile_reg = tas2562_volatile,
-       .reg_defaults = tas2562_reg_defaults,
-       .num_reg_defaults = ARRAY_SIZE(tas2562_reg_defaults),
-       .cache_type = REGCACHE_RBTREE,
+       .cache_type = REGCACHE_NONE,
        .max_register = 1 * 128,
 };
 
@@ -286,6 +238,7 @@ static void tas2562_hw_reset(struct tas2562_priv *pTAS2562)
                gpio_direction_output(pTAS2562->mnResetGPIO, 1);
                msleep(2);
        }
+       dev_err(pTAS2562->dev, "gpio up !!\n");
 
        pTAS2562->mnCurrentBook = -1;
        pTAS2562->mnCurrentPage = -1;
@@ -301,11 +254,9 @@ void tas2562_enableIRQ(struct tas2562_priv *pTAS2562, bool enable)
                        enable_irq(pTAS2562->mnIRQ);
 
                schedule_delayed_work(&pTAS2562->irq_work, msecs_to_jiffies(10));
+
                pTAS2562->mbIRQEnable = true;
        } else {
-               if (!pTAS2562->mbIRQEnable)
-                       return;
-
                if (gpio_is_valid(pTAS2562->mnIRQGPIO))
                        disable_irq_nosync(pTAS2562->mnIRQ);
                pTAS2562->mbIRQEnable = false;
@@ -316,188 +267,125 @@ static void irq_work_routine(struct work_struct *work)
 {
        struct tas2562_priv *pTAS2562 =
                container_of(work, struct tas2562_priv, irq_work.work);
-        unsigned int nDevInt1Status = 0, nDevInt2Status = 0; 
-// int nCounter = 2; 
- int nResult = 0; 
+       unsigned int nDevInt1Status = 0, nDevInt2Status = 0;
+       int nCounter = 2;
+       int nResult = 0;
 
+       dev_info(pTAS2562->dev, "%s\n", __func__);
 #ifdef CONFIG_TAS2562_CODEC
        mutex_lock(&pTAS2562->codec_lock);
 #endif
 
-#ifdef CONFIG_TAS2562_MISC
-       mutex_lock(&pTAS2562->file_lock);
-#endif
        if (pTAS2562->mbRuntimeSuspend) {
                dev_info(pTAS2562->dev, "%s, Runtime Suspended\n", __func__);
                goto end;
        }
-/*
-       if (!pTAS2562->mbPowerUp) {
+
+       if (pTAS2562->mnPowerState == TAS2562_POWER_SHUTDOWN) {
                dev_info(pTAS2562->dev, "%s, device not powered\n", __func__);
                goto end;
        }
-*/
-#if 1
-       nResult = tas2562_dev_write(pTAS2562, TAS2562_InterruptMaskReg0, 0x00);
-       if (nResult < 0)
-               goto reload;
 
-       nResult = tas2562_dev_write(pTAS2562, TAS2562_InterruptMaskReg1, 0x00);
-       if (nResult < 0)
-               goto reload;
-       nResult = tas2562_dev_read(pTAS2562, TAS2562_LiveInterruptReg0, &nDevInt1Status);
+       nResult = tas2562_dev_read(pTAS2562, TAS2562_LatchedInterruptReg0, &nDevInt1Status);
        if (nResult >= 0)
-       nResult = tas2562_dev_read(pTAS2562, TAS2562_LiveInterruptReg1, &nDevInt2Status);
+               nResult = tas2562_dev_read(pTAS2562, TAS2562_LatchedInterruptReg1, &nDevInt2Status);
        else
                goto reload;
 
-       if (((nDevInt1Status & 0xff) != 0) || ((nDevInt2Status & 0x8f) != 0)) {
- /*in case of INT_OC, INT_UV, INT_OT, INT_BO, INT_CL, INT_CLK1, INT_CLK2*/
-       dev_dbg(pTAS2562->dev, "IRQ critical Error : 0x%x, 0x%x\n",
+       dev_dbg(pTAS2562->dev, "IRQ status : 0x%x, 0x%x\n",
                        nDevInt1Status, nDevInt2Status);
 
-               if (nDevInt1Status & 0x02) {
+       if (((nDevInt1Status & 0x3) != 0) || ((nDevInt2Status & 0x0f) != 0)) {
+               /* in case of INT_OC, INT_OT, INT_OVLT, INT_UVLT, INT_BO */
+
+               if (nDevInt1Status & TAS2562_LatchedInterruptReg0_OCEFlagSticky_Interrupt) {
                        pTAS2562->mnErrCode |= ERROR_OVER_CURRENT;
                        dev_err(pTAS2562->dev, "SPK over current!\n");
                } else
                        pTAS2562->mnErrCode &= ~ERROR_OVER_CURRENT;
 
-               if (nDevInt1Status & 0x10) {
-                       pTAS2562->mnErrCode |= ERROR_UNDER_VOLTAGE;
-                       dev_err(pTAS2562->dev, "VBAT below limiter inflection point!\n");
-               } else
-                       pTAS2562->mnErrCode &= ~ERROR_UNDER_VOLTAGE;
-
-               if (nDevInt1Status & 0x04) {
-                       pTAS2562->mnErrCode |= ERROR_CLK_HALT;
-                       dev_err(pTAS2562->dev, "TDM clock error!\n");
-               } else
-                       pTAS2562->mnErrCode &= ~ERROR_CLK_HALT;
-
-               if (nDevInt1Status & 0x01) {
+               if (nDevInt1Status & TAS2562_LatchedInterruptReg0_OTEFlagSticky_Interrupt) {
                        pTAS2562->mnErrCode |= ERROR_DIE_OVERTEMP;
                        dev_err(pTAS2562->dev, "die over temperature!\n");
                } else
                        pTAS2562->mnErrCode &= ~ERROR_DIE_OVERTEMP;
 
-               if (nDevInt1Status & 0x80) {
-                       pTAS2562->mnErrCode |= ERROR_BROWNOUT;
-                       dev_err(pTAS2562->dev, "limiter mute!\n");
+               if (nDevInt2Status & TAS2562_LatchedInterruptReg1_VBATOVLOSticky_Interrupt) {
+                       pTAS2562->mnErrCode |= ERROR_OVER_VOLTAGE;
+                       dev_err(pTAS2562->dev, "SPK over voltage!\n");
                } else
-                       pTAS2562->mnErrCode &= ~ERROR_BROWNOUT;
+                       pTAS2562->mnErrCode &= ~ERROR_UNDER_VOLTAGE;
 
-               if (nDevInt1Status & 0x40) {
-                       pTAS2562->mnErrCode |= ERROR_BROWNOUT;
-                       dev_err(pTAS2562->dev, "limiter infinite hold!\n");
-               } else
-                       pTAS2562->mnErrCode &= ~ERROR_BROWNOUT;
-               if (nDevInt1Status & 0x20) {
-                       pTAS2562->mnErrCode |= ERROR_BROWNOUT;
-                       dev_err(pTAS2562->dev, "limiter max attenuation!\n");
+               if (nDevInt2Status & TAS2562_LatchedInterruptReg1_VBATUVLOSticky_Interrupt) {
+                       pTAS2562->mnErrCode |= ERROR_UNDER_VOLTAGE;
+                       dev_err(pTAS2562->dev, "SPK under voltage!\n");
                } else
-                       pTAS2562->mnErrCode &= ~ERROR_BROWNOUT;
-               if (nDevInt1Status & 0x04) {
+                       pTAS2562->mnErrCode &= ~ERROR_UNDER_VOLTAGE;
+
+               if (nDevInt2Status & TAS2562_LatchedInterruptReg1_BrownOutFlagSticky_Interrupt) {
                        pTAS2562->mnErrCode |= ERROR_BROWNOUT;
-                       dev_err(pTAS2562->dev, "limiter active!\n");
+                       dev_err(pTAS2562->dev, "brownout!\n");
                } else
                        pTAS2562->mnErrCode &= ~ERROR_BROWNOUT;
-               if (nDevInt2Status & 0x80) {
-                       pTAS2562->mnErrCode |= ERROR_CLK_DET1;
-                       dev_err(pTAS2562->dev, "PDM audio data invalid!\n");
-               } else
-                       pTAS2562->mnErrCode &= ~ERROR_CLK_DET1;
-
-               if (nDevInt2Status & 0x08) {
-                       pTAS2562->mnErrCode |= ERROR_CLK_DET2;
-                       dev_err(pTAS2562->dev, "VBAT OVLO flag!\n");
-               } else
-                       pTAS2562->mnErrCode &= ~ERROR_CLK_DET2;
-
-               if (nDevInt2Status & 0x04) {
-                       pTAS2562->mnErrCode |= ERROR_CLK_DET2;
-                       dev_err(pTAS2562->dev, "VBAT UVLO flag!\n");
-               } else
-                       pTAS2562->mnErrCode &= ~ERROR_CLK_DET2;
 
-               if (nDevInt2Status & 0x02) {
-                       pTAS2562->mnErrCode |= ERROR_CLK_DET2;
-                       dev_err(pTAS2562->dev, "VBAT brown out flag!\n");
-               } else
-                       pTAS2562->mnErrCode &= ~ERROR_CLK_DET2;
-
-               if (nDevInt2Status & 0x01) {
-                       pTAS2562->mnErrCode |= ERROR_CLK_DET2;
-                       dev_err(pTAS2562->dev, "PDM clock error!\n");
-               } else
-                       pTAS2562->mnErrCode &= ~ERROR_CLK_DET2;
+               dev_err(pTAS2562->dev, "before goto reload\n");
                goto reload;
        } else {
-#if 0
-               dev_dbg(pTAS2562->dev, "IRQ status : 0x%x, 0x%x\n",
-                               nDevInt1Status, nDevInt2Status);
                nCounter = 2;
 
                while (nCounter > 0) {
-               nResult = tas2562_dev_read(pTAS2562,
-                       TAS2562_POWER_UP_FLAG_REG, &nDevInt1Status);
+                       nResult = tas2562_dev_read(pTAS2562, TAS2562_PowerControl, &nDevInt1Status);
                        if (nResult < 0)
                                goto reload;
 
-                       if ((nDevInt1Status & 0xc0) == 0xc0)
+                       if ((nDevInt1Status & TAS2562_PowerControl_OperationalMode10_Mask)
+                               != TAS2562_PowerControl_OperationalMode10_Shutdown)
                                break;
 
                        nCounter--;
                        if (nCounter > 0) {
-       /* in case check pow status just after power on TAS2562 */
+                               /* in case check pow status just after power on TAS2562 */
                                dev_dbg(pTAS2562->dev, "PowSts B: 0x%x, check again after 10ms\n",
                                        nDevInt1Status);
-                               msleep(20);
+                               msleep(10);
                        }
                }
 
-               if ((nDevInt1Status & 0xc0) != 0xc0) {
-                       dev_err(pTAS2562->dev, "%s, Critical ERROR B[%d]_P[%d]_R[%d]= 0x%x\n",
+               if ((nDevInt1Status & TAS2562_PowerControl_OperationalMode10_Mask)
+                       == TAS2562_PowerControl_OperationalMode10_Shutdown) {
+                       dev_err(pTAS2562->dev, "%s, Critical ERROR REG[0x%x] = 0x%x\n",
                                __func__,
-                               TAS2562_BOOK_ID(TAS2562_POWER_UP_FLAG_REG),
-                               TAS2562_PAGE_ID(TAS2562_POWER_UP_FLAG_REG),
-                               TAS2562_PAGE_REG(TAS2562_POWER_UP_FLAG_REG),
+                               TAS2562_PowerControl,
                                nDevInt1Status);
                        pTAS2562->mnErrCode |= ERROR_CLASSD_PWR;
                        goto reload;
                }
                pTAS2562->mnErrCode &= ~ERROR_CLASSD_PWR;
-#endif
        }
 
-       nResult = tas2562_dev_write(pTAS2562, TAS2562_InterruptMaskReg0, 0xff);
-       if (nResult < 0)
-               goto reload;
-
-       nResult = tas2562_dev_write(pTAS2562, TAS2562_InterruptMaskReg1, 0xff);
-       if (nResult < 0)
-               goto reload;
-
        goto end;
 
 reload:
        /* hardware reset and reload */
-       //tas2562_LoadConfig(pTAS2562, true);
-#endif
+       nResult = -1;
+       tas2562_LoadConfig(pTAS2562);
 
 end:
-/*
-       if (!hrtimer_active(&pTAS2562->mtimer)) {
-               dev_dbg(pTAS2562->dev, "%s, start timer\n", __func__);
-               hrtimer_start(&pTAS2562->mtimer,
-                       ns_to_ktime((u64)CHECK_PERIOD * NSEC_PER_MSEC),
-                       HRTIMER_MODE_REL);
+       if (nResult >= 0) {
+               tas2562_enableIRQ(pTAS2562, true);
+           dev_info(pTAS2562->dev, "enable IRQ\n");
        }
-*/
 
-#ifdef CONFIG_TAS2562_MISC
-       mutex_unlock(&pTAS2562->file_lock);
-#endif
+       nResult = gpio_get_value(pTAS2562->mnIRQGPIO);
+       dev_info(pTAS2562->dev, "%s, irq GPIO state: %d\n", __func__, nResult);
 
+       if (!hrtimer_active(&pTAS2562->mtimer)) {
+               dev_dbg(pTAS2562->dev, "%s, start timer\n", __func__);
+               hrtimer_start(&pTAS2562->mtimer,
+                       ns_to_ktime((u64)CHECK_PERIOD * NSEC_PER_MSEC), HRTIMER_MODE_REL);
+       } else
+               dev_info(pTAS2562->dev, "timer not active\n");
+       
 #ifdef CONFIG_TAS2562_CODEC
        mutex_unlock(&pTAS2562->codec_lock);
 #endif
@@ -516,49 +404,14 @@ static enum hrtimer_restart timer_func(struct hrtimer *timer)
 
        return HRTIMER_NORESTART;
 }
-static inline void irqd_set(struct irq_data *d, unsigned int mask)
-{
-       //Debug Addded/Modified 060356-PP
-       //__irqd_to_state(d) |= mask;
-}
-
-static void irq_state_set_masked(struct irq_desc *desc)
-{
-       irqd_set(&desc->irq_data, IRQD_IRQ_MASKED);
-}
-
-static void irq_state_set_disabled(struct irq_desc *desc)
-{
-       irqd_set(&desc->irq_data, IRQD_IRQ_DISABLED);
-}
-
-static void irq_shutdown(struct irq_desc *desc)
-{
-       irq_state_set_disabled(desc);
-       desc->depth = 1;
-       if (desc->irq_data.chip->irq_shutdown)
-               desc->irq_data.chip->irq_shutdown(&desc->irq_data);
-       else if (desc->irq_data.chip->irq_disable)
-               desc->irq_data.chip->irq_disable(&desc->irq_data);
-       else
-               desc->irq_data.chip->irq_mask(&desc->irq_data);
-       irq_domain_deactivate_irq(&desc->irq_data);
-       irq_state_set_masked(desc);
-}
 
 static irqreturn_t tas2562_irq_handler(int irq, void *dev_id)
 {
        struct tas2562_priv *pTAS2562 = (struct tas2562_priv *)dev_id;
-       struct irq_desc *desc = irq_to_desc(irq);
 
-#if 1
+       tas2562_enableIRQ(pTAS2562, false);
        /* get IRQ status after 100 ms */
-       if (!delayed_work_pending(&pTAS2562->irq_work))
-               schedule_delayed_work(&pTAS2562->irq_work,
-                       msecs_to_jiffies(100));
-#endif
-       /* avoid interrupt storm, mask corresponding gic interrupt controller bit*/
-       irq_shutdown(desc);
+       schedule_delayed_work(&pTAS2562->irq_work, msecs_to_jiffies(100));
        return IRQ_HANDLED;
 }
 
@@ -569,7 +422,7 @@ static int tas2562_runtime_suspend(struct tas2562_priv *pTAS2562)
        pTAS2562->mbRuntimeSuspend = true;
 
        if (hrtimer_active(&pTAS2562->mtimer)) {
-               dev_dbg(pTAS2562->dev, "cancel die temp timer\n");
+               dev_dbg(pTAS2562->dev, "cancel timer\n");
                hrtimer_cancel(&pTAS2562->mtimer);
        }
 
@@ -586,13 +439,12 @@ static int tas2562_runtime_resume(struct tas2562_priv *pTAS2562)
        dev_dbg(pTAS2562->dev, "%s\n", __func__);
 
        if (pTAS2562->mbPowerUp) {
-/*             if (!hrtimer_active(&pTAS2562->mtimer)) {
+               if (!hrtimer_active(&pTAS2562->mtimer)) {
                dev_dbg(pTAS2562->dev, "%s, start check timer\n", __func__);
                        hrtimer_start(&pTAS2562->mtimer,
                                ns_to_ktime((u64)CHECK_PERIOD * NSEC_PER_MSEC),
                                HRTIMER_MODE_REL);
                }
-*/
        }
 
        pTAS2562->mbRuntimeSuspend = false;
@@ -605,7 +457,7 @@ static int tas2562_parse_dt(struct device *dev, struct tas2562_priv *pTAS2562)
        struct device_node *np = dev->of_node;
        int rc = 0, ret = 0;
 
-       u32 debounceInfo[2] = { 0, 0 };
+//     u32 debounceInfo[2] = { 0, 0 };
        rc = of_property_read_u32(np, "ti,asi-format", &pTAS2562->mnASIFormat);
        if (rc) {
                dev_err(pTAS2562->dev, "Looking up %s property in node %s failed %d\n",
@@ -623,10 +475,11 @@ static int tas2562_parse_dt(struct device *dev, struct tas2562_priv *pTAS2562)
                dev_dbg(pTAS2562->dev, "ti,reset-gpio=%d",
                        pTAS2562->mnResetGPIO);
        }
-
+/*
        of_property_read_u32_array(np, "debounce",
                            debounceInfo, ARRAY_SIZE(debounceInfo));
        gpio_set_debounce(37, debounceInfo[1]);
+*/
        pTAS2562->mnIRQGPIO = of_get_named_gpio(np, "ti,irq-gpio", 0);
        if (!gpio_is_valid(pTAS2562->mnIRQGPIO)) {
                dev_err(pTAS2562->dev, "Looking up %s property in node %s failed %d\n",
@@ -638,49 +491,36 @@ static int tas2562_parse_dt(struct device *dev, struct tas2562_priv *pTAS2562)
        return ret;
 }
 
-static int tas2562_i2c_probe(struct i2c_client *client,
+static int tas2562_i2c_probe(struct i2c_client *pClient,
                        const struct i2c_device_id *id)
 {
        struct tas2562_priv *pTAS2562;
        int nResult;
 
-       //struct pinctrl *pinctrl;
-       //struct pinctrl_state *pin_state;
-       dev_info(&client->dev, "%s enter\n", __func__);
+       dev_info(&pClient->dev, "%s enter\n", __func__);
 
-       pTAS2562 = devm_kzalloc(&client->dev,
+       pTAS2562 = devm_kzalloc(&pClient->dev,
                sizeof(struct tas2562_priv), GFP_KERNEL);
        if (pTAS2562 == NULL) {
+               dev_err(&pClient->dev, "failed to get i2c device\n");
                nResult = -ENOMEM;
-               goto end;
+               goto err;
        }
 
-       pTAS2562->dev = &client->dev;
-       i2c_set_clientdata(client, pTAS2562);
-       dev_set_drvdata(&client->dev, pTAS2562);
+       pTAS2562->dev = &pClient->dev;
+       i2c_set_clientdata(pClient, pTAS2562);
+       dev_set_drvdata(&pClient->dev, pTAS2562);
 
-       pTAS2562->regmap = devm_regmap_init_i2c(client, &tas2562_i2c_regmap);
+       pTAS2562->regmap = devm_regmap_init_i2c(pClient, &tas2562_i2c_regmap);
        if (IS_ERR(pTAS2562->regmap)) {
                nResult = PTR_ERR(pTAS2562->regmap);
-               dev_err(&client->dev, "Failed to allocate register map: %d\n",
+               dev_err(&pClient->dev, "Failed to allocate register map: %d\n",
                                        nResult);
-               goto end;
+               goto err;
        }
-#if 0
-pinctrl = devm_pinctrl_get(&client->dev);
-if (IS_ERR(pinctrl)) {
-           dev_err(&client->dev,
-                                      "Unable to acquire pinctrl: Error = %lu",
-                                                  (unsigned long)pinctrl);
-} else {
-                                    /* Configure GPIO interrupt pin */
-                                    pin_state = pinctrl_lookup_state(pinctrl, "ti_int");
-                                        pinctrl_select_state(pinctrl, pin_state);
-}
-#endif
-/* TODO */
-       if (client->dev.of_node)
-               tas2562_parse_dt(&client->dev, pTAS2562);
+
+       if (pClient->dev.of_node)
+               tas2562_parse_dt(&pClient->dev, pTAS2562);
 
        if (gpio_is_valid(pTAS2562->mnResetGPIO)) {
                nResult = gpio_request(pTAS2562->mnResetGPIO, "TAS2562_RESET");
@@ -688,93 +528,88 @@ if (IS_ERR(pinctrl)) {
                        dev_err(pTAS2562->dev, "%s: Failed to request gpio %d\n",
                                __func__, pTAS2562->mnResetGPIO);
                        nResult = -EINVAL;
-                       goto free_gpio;
+                       goto err;
                }
+               tas2562_hw_reset(pTAS2562);
+       }
+
+       pTAS2562->read = tas2562_dev_read;
+       pTAS2562->write = tas2562_dev_write;
+       pTAS2562->bulk_read = tas2562_dev_bulk_read;
+       pTAS2562->bulk_write = tas2562_dev_bulk_write;
+       pTAS2562->update_bits = tas2562_dev_update_bits;
+       pTAS2562->hw_reset = tas2562_hw_reset;
+       pTAS2562->enableIRQ = tas2562_enableIRQ;
+       //pTAS2562->clearIRQ = tas2562_clearIRQ;
+       pTAS2562->runtime_suspend = tas2562_runtime_suspend;
+       pTAS2562->runtime_resume = tas2562_runtime_resume;
+       pTAS2562->mnPowerState = TAS2562_POWER_SHUTDOWN;
+
+       mutex_init(&pTAS2562->dev_lock);
+
+       /* Reset the chip */
+       nResult = tas2562_dev_write(pTAS2562, TAS2562_SoftwareReset, 0x01);
+       if (nResult < 0) {
+               dev_err(&pClient->dev, "I2c fail, %d\n", nResult);
+               goto err;
        }
-#if 0
+
        if (gpio_is_valid(pTAS2562->mnIRQGPIO)) {
                nResult = gpio_request(pTAS2562->mnIRQGPIO, "TAS2562-IRQ");
                if (nResult < 0) {
                        dev_err(pTAS2562->dev, "%s: GPIO %d request error\n",
                                __func__, pTAS2562->mnIRQGPIO);
-                       goto free_gpio;
+                       goto err;
                }
                gpio_direction_input(pTAS2562->mnIRQGPIO);
-#endif
-if (gpio_is_valid(pTAS2562->mnIRQGPIO)) {
-       nResult = devm_gpio_request_one(&client->dev, pTAS2562->mnIRQGPIO,
-               GPIOF_DIR_IN, "TAS2562_INT");
-
-               if (nResult < 0) {
-                       dev_err(pTAS2562->dev, "%s: GPIO %d request error\n",
-                               __func__, pTAS2562->mnIRQGPIO);
-                       goto free_gpio;
-               }
+               nResult = gpio_get_value(pTAS2562->mnIRQGPIO);
+               dev_info(pTAS2562->dev, "irq GPIO state: %d\n", nResult);
+               tas2562_dev_write(pTAS2562, TAS2562_MiscConfigurationReg0, 0xce);
 
                pTAS2562->mnIRQ = gpio_to_irq(pTAS2562->mnIRQGPIO);
                dev_dbg(pTAS2562->dev, "irq = %d\n", pTAS2562->mnIRQ);
-               nResult =devm_request_threaded_irq(&client->dev, pTAS2562->mnIRQ,
-           NULL, tas2562_irq_handler, IRQF_TRIGGER_FALLING|IRQF_ONESHOT,
-                                       client->name, pTAS2562);
+               INIT_DELAYED_WORK(&pTAS2562->irq_work, irq_work_routine);
+               nResult = request_threaded_irq(pTAS2562->mnIRQ, tas2562_irq_handler,
+                               NULL, IRQF_TRIGGER_LOW|IRQF_ONESHOT,
+                               pClient->name, pTAS2562);
                if (nResult < 0) {
                        dev_err(pTAS2562->dev,
                                "request_irq failed, %d\n", nResult);
-                       goto free_gpio;
+                       goto err;
                }
-               //disable_irq_nosync(pTAS2562->mnIRQ);
-               enable_irq(pTAS2562->mnIRQ);
-               INIT_DELAYED_WORK(&pTAS2562->irq_work, irq_work_routine);
+               disable_irq_nosync(pTAS2562->mnIRQ);
        }
 
-       pTAS2562->read = tas2562_dev_read;
-       pTAS2562->write = tas2562_dev_write;
-       pTAS2562->bulk_read = tas2562_dev_bulk_read;
-       pTAS2562->bulk_write = tas2562_dev_bulk_write;
-       pTAS2562->update_bits = tas2562_dev_update_bits;
-       pTAS2562->hw_reset = tas2562_hw_reset;
-       pTAS2562->enableIRQ = tas2562_enableIRQ;
-       //pTAS2562->clearIRQ = tas2562_clearIRQ;
-       pTAS2562->runtime_suspend = tas2562_runtime_suspend;
-       pTAS2562->runtime_resume = tas2562_runtime_resume;
-       mutex_init(&pTAS2562->dev_lock);
-       if (nResult < 0)
-               goto destroy_mutex;
-
-       nResult = tas2562_dev_write(pTAS2562, TAS2562_InterruptConfiguration, 0x00);
-       if (nResult < 0)
-               pr_err("Write TAS2562_InterruptConfiguration failed\n");
 #ifdef CONFIG_TAS2562_CODEC
        mutex_init(&pTAS2562->codec_lock);
-       tas2562_register_codec(pTAS2562);
+       nResult = tas2562_register_codec(pTAS2562);
+       if (nResult < 0) {
+               dev_err(pTAS2562->dev,
+                       "register codec failed, %d\n", nResult);
+               goto err;
+       }
 #endif
 
 #ifdef CONFIG_TAS2562_MISC
        mutex_init(&pTAS2562->file_lock);
-       tas2562_register_misc(pTAS2562);
+       nResult = tas2562_register_misc(pTAS2562);
+       if (nResult < 0) {
+               dev_err(pTAS2562->dev,
+                       "register codec failed, %d\n", nResult);
+               goto err;
+       }
 #endif
 
        hrtimer_init(&pTAS2562->mtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
        pTAS2562->mtimer.function = timer_func;
 
-destroy_mutex:
-       if (nResult < 0)
-               mutex_destroy(&pTAS2562->dev_lock);
-
-free_gpio:
-       if (nResult < 0) {
-               if (gpio_is_valid(pTAS2562->mnResetGPIO))
-                       gpio_free(pTAS2562->mnResetGPIO);
-               if (gpio_is_valid(pTAS2562->mnIRQGPIO))
-                       gpio_free(pTAS2562->mnIRQGPIO);
-       }
-
-end:
+err:
        return nResult;
 }
 
-static int tas2562_i2c_remove(struct i2c_client *client)
+static int tas2562_i2c_remove(struct i2c_client *pClient)
 {
-       struct tas2562_priv *pTAS2562 = i2c_get_clientdata(client);
+       struct tas2562_priv *pTAS2562 = i2c_get_clientdata(pClient);
 
        dev_info(pTAS2562->dev, "%s\n", __func__);
 
index 3fd18253e1203e879079cc925163d03056e7c499..b8d788fd6ac63b2e999c21a8818b6c71cc84efec 100644 (file)
--- a/tas2562.h
+++ b/tas2562.h
 #define TAS2562_PlaybackConfigurationReg0_PlaybackSource_Pdm  (0x1 << 5)
 #define TAS2562_PlaybackConfigurationReg0_AmplifierLevel40_Mask  (0x1f << 0)
 
-    /* Playback Configuration Reg1 */
-#define TAS2562_PlaybackConfigurationReg1  TAS2562_REG(0X0, 0x04)
-#define TAS2562_PlaybackConfigurationReg1_HPFFrequency20_Mask  (0x7 << 0)
-#define TAS2562_PlaybackConfigurationReg1_HPFFrequency20_2  (0x1 << 0)
-#define TAS2562_PlaybackConfigurationReg1_HPFFrequency20_50  (0x2 << 0)
-#define TAS2562_PlaybackConfigurationReg1_HPFFrequency20_100  (0x3 << 0)
-#define TAS2562_PlaybackConfigurationReg1_HPFFrequency20_200  (0x4 << 0)
-#define TAS2562_PlaybackConfigurationReg1_HPFFrequency20_400  (0x5 << 0)
-#define TAS2562_PlaybackConfigurationReg1_HPFFrequency20_800  (0x6 << 0)
-#define TAS2562_PlaybackConfigurationReg1_HPFFrequency20_Bypass  (0x0 << 0)
-
-    /* Playback Configuration Reg2 */
-#define TAS2562_PlaybackConfigurationReg2  TAS2562_REG(0X0, 0x05)
-#define TAS2562_PlaybackConfigurationReg2_DVCPCM70_Mask  (0xff << 0)
-
-    /* Playback Configuration Reg3 */
-#define TAS2562_PlaybackConfigurationReg3  TAS2562_REG(0X0, 0x06)
-#define TAS2562_PlaybackConfigurationReg3_DVCPDM70_Mask  (0xff << 0)
-
     /* Misc Configuration Reg0 */
 #define TAS2562_MiscConfigurationReg0  TAS2562_REG(0X0, 0x04)
-#define TAS2562_MiscConfigurationReg0_DVCRampRate76_Mask  (0x3 << 6)
-#define TAS2562_MiscConfigurationReg0_DVCRampRate76_0_5dbPer1Sample  (0x0 << 6)
-#define TAS2562_MiscConfigurationReg0_DVCRampRate76_0_5dbPer4Sample  (0x1 << 6)
-#define TAS2562_MiscConfigurationReg0_DVCRampRate76_0_5dbPer8Sample  (0x2 << 6)
-#define TAS2562_MiscConfigurationReg0_DVCRampRate76_VolRampDisabled  (0x3 << 6)
+#define TAS2562_MiscConfigurationReg0_CPPGRetry_Mask  (0x1 << 7)
+#define TAS2562_MiscConfigurationReg0_CPPGRetry_DoNotRetry  (0x0 << 7)
+#define TAS2562_MiscConfigurationReg0_CPPGRetry_Retry  (0x1 << 7)
+#define TAS2562_MiscConfigurationReg0_VBATPRORetry_Mask  (0x1 << 6)
+#define TAS2562_MiscConfigurationReg0_VBATPRORetry_DoNotRetry  (0x0 << 6)
+#define TAS2562_MiscConfigurationReg0_VBATPRORetry_Retry  (0x1 << 6)
 #define TAS2562_MiscConfigurationReg0_OCERetry_Mask  (0x1 << 5)
 #define TAS2562_MiscConfigurationReg0_OCERetry_DoNotRetry  (0x0 << 5)
 #define TAS2562_MiscConfigurationReg0_OCERetry_Retry  (0x1 << 5)
 #define TAS2562_MiscConfigurationReg0_AMPSS_Disabled  (0x0 << 2)
 #define TAS2562_MiscConfigurationReg0_AMPSS_Enabled  (0x1 << 2)
 
-    /* PDM Input Reg0 */
-#define TAS2562_PDMInputReg0  TAS2562_REG(0X0, 0x08)
-#define TAS2562_PDMInputReg0_ClassDSYNC_Mask  (0x1 << 6)
-#define TAS2562_PDMInputReg0_ClassDSYNC_AsyncMode  (0x0 << 6)
-#define TAS2562_PDMInputReg0_ClassDSYNC_Retry  (0x1 << 6),
-#define TAS2562_PDMInputReg0_PDMRATESW54_Mask  (0x3 << 4)
-#define TAS2562_PDMInputReg0_PDMRATED132_Mask  (0x3 << 2)
-#define TAS2562_PDMInputReg0_PDMRATED132_2_543_38MHz  (0x0 << 2)
-#define TAS2562_PDMInputReg0_PDMRATED132_5_086_76MHz  (0x1 << 2)
-#define TAS2562_PDMInputReg0_PDMRATED010_Mask  (0x3 << 0)
-#define TAS2562_PDMInputReg0_PDMRATED010_2_543_38MHz  (0x0 << 0)
-#define TAS2562_PDMInputReg0_PDMRATED010_5_086_76MHz  (0x1 << 0)
-
-    /* PDM Configuration Reg1 */
-#define TAS2562_PDMConfigurationReg1  TAS2562_REG(0X0, 0x09)
-#define TAS2562_PDMConfigurationReg1_PDMEDGED1_Mask  (0x1 << 7)
-#define TAS2562_PDMConfigurationReg1_PDMEDGED1_Rising  (0x0 << 7)
-#define TAS2562_PDMConfigurationReg1_PDMEDGED1_Falling  (0x1 << 7)
-#define TAS2562_PDMConfigurationReg1_PDMEDGED0_Mask  (0x1 << 6)
-#define TAS2562_PDMConfigurationReg1_PDMEDGED0_Rising  (0x0 << 6)
-#define TAS2562_PDMConfigurationReg1_PDMEDGED0_Falling  (0x1 << 6)
-#define TAS2562_PDMConfigurationReg1_PDMSLVD1_Mask  (0x1 << 5)
-#define TAS2562_PDMConfigurationReg1_PDMSLVD1_Slave  (0x0 << 5)
-#define TAS2562_PDMConfigurationReg1_PDMSLVD1_Master  (0x1 << 5)
-#define TAS2562_PDMConfigurationReg1_PDMSLVD0_Mask  (0x1 << 4)
-#define TAS2562_PDMConfigurationReg1_PDMSLVD0_Slave  (0x0 << 4)
-#define TAS2562_PDMConfigurationReg1_PDMSLVD0_Master  (0x1 << 4)
-#define TAS2562_PDMConfigurationReg1_PDMCLKD1_Mask  (0x1 << 3)
-#define TAS2562_PDMConfigurationReg1_PDMCLKD1_Pdmck0  (0x0 << 3)
-#define TAS2562_PDMConfigurationReg1_PDMCLKD1_Pdmck1  (0x1 << 3)
-#define TAS2562_PDMConfigurationReg1_PDMCLKD0_Mask  (0x1 << 2)
-#define TAS2562_PDMConfigurationReg1_PDMCLKD0_Pdmck0  (0x0 << 2)
-#define TAS2562_PDMConfigurationReg1_PDMCLKD0_Pdmck1  (0x1 << 2)
-#define TAS2562_PDMConfigurationReg1_PDMGATED1_Mask  (0x1 << 1)
-#define TAS2562_PDMConfigurationReg1_PDMGATED1_GatedOff  (0x0 << 1)
-#define TAS2562_PDMConfigurationReg1_PDMGATED1_Active  (0x1 << 1)
-#define TAS2562_PDMConfigurationReg1_PDMGATED0_Mask  (0x1 << 0)
-#define TAS2562_PDMConfigurationReg1_PDMGATED0_GatedOff  (0x0 << 0)
-#define TAS2562_PDMConfigurationReg1_PDMGATED0_Active  (0x1 << 0)
-
     /* TDM Configuration Reg0 */
 #define TAS2562_TDMConfigurationReg0  TAS2562_REG(0X0, 0x06)
 #define TAS2562_TDMConfigurationReg0_SAMPRATERAMP_Mask  (0x1 << 5)
 #define TAS2562_TDMConfigurationReg0_DETECTSAMPRATE_Disabled  (0x1 << 4)
 #define TAS2562_TDMConfigurationReg0_DETECTSAMPRATE_Enabled  (0x0 << 4)
 #define TAS2562_TDMConfigurationReg0_SAMPRATE31_Mask  (0x7 << 1)
+#define TAS2562_TDMConfigurationReg0_SAMPRATE31_14_7_16kHz  (0x1 << 1)
 #define TAS2562_TDMConfigurationReg0_SAMPRATE31_44_1_48kHz  (0x4 << 1)
 #define TAS2562_TDMConfigurationReg0_SAMPRATE31_88_2_96kHz  (0x5 << 1)
 #define TAS2562_TDMConfigurationReg0_SAMPRATE31_176_4_192kHz  (0x6 << 1)
 #define TAS2562_TDMConfigurationReg6_ISNSSLOT50_Mask  (0x3f << 0)
 
     /* TDM Configuration Reg7 */
-#define TAS2562_TDMConfigurationReg7  TAS2562_REG(0X0, 0x11)
-#define TAS2562_TDMConfigurationReg7_PDMTX_Mask  (0x1 << 6)
-#define TAS2562_TDMConfigurationReg7_PDMTX_Disable  (0x0 << 6)
-#define TAS2562_TDMConfigurationReg7_PDMTX_Enable  (0x1 << 6)
-#define TAS2562_TDMConfigurationReg7_PDMSLOT50_Mask  (0x3f << 0)
+#define TAS2562_TDMConfigurationReg7  TAS2562_REG(0X0, 0x0D)
+#define TAS2562_TDMConfigurationReg7_VBATSLEN_Mask  (0x1 << 7)
+#define TAS2562_TDMConfigurationReg7_VBATSLEN_8Bits  (0x0 << 7)
+#define TAS2562_TDMConfigurationReg7_VBATSLEN_16Bits  (0x1 << 7)
+#define TAS2562_TDMConfigurationReg7_VBATTX_Mask  (0x1 << 6)
+#define TAS2562_TDMConfigurationReg7_VBATTX_Disable  (0x0 << 6)
+#define TAS2562_TDMConfigurationReg7_VBATTX_Enable  (0x1 << 6)
+#define TAS2562_TDMConfigurationReg7_VBATSLOT50_Mask  (0x3f << 0)
 
     /* TDM Configuration Reg8 */
-#define TAS2562_TDMConfigurationReg8  TAS2562_REG(0X0, 0x12)
-#define TAS2562_TDMConfigurationReg8_VBATSLEN_Mask  (0x1 << 7)
-#define TAS2562_TDMConfigurationReg8_VBATSLEN_8Bits  (0x0 << 7)
-#define TAS2562_TDMConfigurationReg8_VBATSLEN_16Bits  (0x1 << 7)
-#define TAS2562_TDMConfigurationReg8_VBATTX_Mask  (0x1 << 6)
-#define TAS2562_TDMConfigurationReg8_VBATTX_Disable  (0x0 << 6)
-#define TAS2562_TDMConfigurationReg8_VBATTX_Enable  (0x1 << 6)
-#define TAS2562_TDMConfigurationReg8_VBATSLOT50_Mask  (0x3f << 0)
+#define TAS2562_TDMConfigurationReg8  TAS2562_REG(0X0, 0x0E)
+#define TAS2562_TDMConfigurationReg8_TEMPTX_Mask  (0x1 << 6)
+#define TAS2562_TDMConfigurationReg8_TEMPTX_Disable  (0x0 << 6)
+#define TAS2562_TDMConfigurationReg8_TEMPTX_Enable  (0x1 << 6)
+#define TAS2562_TDMConfigurationReg8_TEMPSLOT50_Mask  (0x3f << 0)
 
     /* TDM Configuration Reg9 */
-#define TAS2562_TDMConfigurationReg9  TAS2562_REG(0X0, 0x13)
-#define TAS2562_TDMConfigurationReg9_TEMPTX_Mask  (0x1 << 6)
-#define TAS2562_TDMConfigurationReg9_TEMPTX_Disable  (0x0 << 6)
-#define TAS2562_TDMConfigurationReg9_TEMPTX_Enable  (0x1 << 6)
-#define TAS2562_TDMConfigurationReg9_TEMPSLOT50_Mask  (0x3f << 0)
-
-    /* TDM Configuration Reg10 */
-#define TAS2562_TDMConfigurationReg10  TAS2562_REG(0X0, 0x14)
-#define TAS2562_TDMConfigurationReg10_GAINTX_Mask  (0x1 << 6)
-#define TAS2562_TDMConfigurationReg10_GAINTX_Disable  (0x0 << 6)
-#define TAS2562_TDMConfigurationReg10_GAINTX_Enable  (0x1 << 6)
-#define TAS2562_TDMConfigurationReg10_GAINSLOT50_Mask  (0x3f << 0)
+#define TAS2562_TDMConfigurationReg9  TAS2562_REG(0X0, 0x0F)
+#define TAS2562_TDMConfigurationReg9_GAINTX_Mask  (0x1 << 6)
+#define TAS2562_TDMConfigurationReg9_GAINTX_Disable  (0x0 << 6)
+#define TAS2562_TDMConfigurationReg9_GAINTX_Enable  (0x1 << 6)
+#define TAS2562_TDMConfigurationReg9_GAINSLOT50_Mask  (0x3f << 0)
 
     /* Limiter Configuration Reg0 */
-#define TAS2562_LimiterConfigurationReg0  TAS2562_REG(0X0, 0x15)
+#define TAS2562_LimiterConfigurationReg0  TAS2562_REG(0X0, 0x12)
 #define TAS2562_LimiterConfigurationReg0_LIMATKST54_Mask  (0x3 << 4)
 #define TAS2562_LimiterConfigurationReg0_LIMATKST54_1  (0x2 << 4)
 #define TAS2562_LimiterConfigurationReg0_LIMATKST54_2  (0x3 << 4)
 #define TAS2562_LimiterConfigurationReg0_LIMEN_Enabled  (0x1 << 0)
 
     /* Limiter Configuration Reg1 */
-#define TAS2562_LimiterConfigurationReg1  TAS2562_REG(0X0, 0x16)
+#define TAS2562_LimiterConfigurationReg1  TAS2562_REG(0X0, 0x13)
 #define TAS2562_LimiterConfigurationReg1_LIMRLSST76_Mask  (0x3 << 6)
 #define TAS2562_LimiterConfigurationReg1_LIMRLSST76_1  (0x2 << 6)
 #define TAS2562_LimiterConfigurationReg1_LIMRLSST76_2  (0x3 << 6)
 #define TAS2562_LimiterConfigurationReg1_LIMHLDTM20_500  (0x6 << 0)
 #define TAS2562_LimiterConfigurationReg1_LIMHLDTM20_1000  (0x7 << 0)
 
-    /* Limiter Configuration Reg2 */
-#define TAS2562_LimiterConfigurationReg2  TAS2562_REG(0X0, 0x17)
-#define TAS2562_LimiterConfigurationReg2_LIMMAXATN40_Mask  (0x1f << 0)
-
-    /* Limiter Configuration Reg3 */
-#define TAS2562_LimiterConfigurationReg3  TAS2562_REG(0X0, 0x18)
-#define TAS2562_LimiterConfigurationReg3_LIMTHMAX60_Mask  (0x7f << 0)
-
-    /* Limiter Configuration Reg4 */
-#define TAS2562_LimiterConfigurationReg4  TAS2562_REG(0X0, 0x19)
-#define TAS2562_LimiterConfigurationReg4_LIMTHMIN60_Mask  (0x7f << 0)
-
-    /* Limiter Configuration Reg5 */
-#define TAS2562_LimiterConfigurationReg5  TAS2562_REG(0X0, 0x1A)
-#define TAS2562_LimiterConfigurationReg5_LIMINFPOINT_Mask  (0x7f << 0)
-
     /* Brown Out Prevention Reg0 */
-#define TAS2562_BrownOutPreventionReg0  TAS2562_REG(0X0, 0x1B)
-#define TAS2562_BrownOutPreventionReg0_LIMSLOPE54_Mask  (0x3 << 4)
-#define TAS2562_BrownOutPreventionReg0_LIMSLOPE54_1  (0x0 << 4)
-#define TAS2562_BrownOutPreventionReg0_LIMSLOPE54_2  (0x2 << 4)
-#define TAS2562_BrownOutPreventionReg0_LIMSLOPE54_4  (0x3 << 4)
-#define TAS2562_BrownOutPreventionReg0_LIMSLOPE54_1_5  (0x1 << 4)
+#define TAS2562_BrownOutPreventionReg0  TAS2562_REG(0X0, 0x14)
+#define TAS2562_BrownOutPreventionReg0_BOPSDEN_Mask  (0x1 << 4)
+#define TAS2562_BrownOutPreventionReg0_BOPSDEN_Disabled  (0x0 << 4)
+#define TAS2562_BrownOutPreventionReg0_BOPSDEN_Enabled  (0x1 << 4)
 #define TAS2562_BrownOutPreventionReg0_BOPHLDCLR_Mask  (0x1 << 3)
 #define TAS2562_BrownOutPreventionReg0_BOPHLDCLR_DontClear  (0x0 << 3)
 #define TAS2562_BrownOutPreventionReg0_BOPHLDCLR_Clear  (0x1 << 3)
 #define TAS2562_BrownOutPreventionReg0_BOPEN_Enabled  (0x1 << 0)
 
     /* Brown Out Prevention Reg1 */
-#define TAS2562_BrownOutPreventionReg1  TAS2562_REG(0X0, 0x1C)
-#define TAS2562_BrownOutPreventionReg1_BOPTH70_Mask  (0xff << 0)
-
-    /* Brown Out Prevention Reg2 */
-#define TAS2562_BrownOutPreventionReg2  TAS2562_REG(0X0, 0x1D)
-#define TAS2562_BrownOutPreventionReg2_BOPATKRT75_Mask  (0x7 << 5)
-#define TAS2562_BrownOutPreventionReg2_BOPATKRT75_5  (0x0 << 5)
-#define TAS2562_BrownOutPreventionReg2_BOPATKRT75_10  (0x1 << 5)
-#define TAS2562_BrownOutPreventionReg2_BOPATKRT75_20  (0x2 << 5)
-#define TAS2562_BrownOutPreventionReg2_BOPATKRT75_40  (0x3 << 5)
-#define TAS2562_BrownOutPreventionReg2_BOPATKRT75_80  (0x4 << 5)
-#define TAS2562_BrownOutPreventionReg2_BOPATKRT75_160  (0x5 << 5)
-#define TAS2562_BrownOutPreventionReg2_BOPATKRT75_320  (0x6 << 5)
-#define TAS2562_BrownOutPreventionReg2_BOPATKRT75_640  (0x7 << 5)
-#define TAS2562_BrownOutPreventionReg2_BOPATKST43_Mask  (0x3 << 3)
-#define TAS2562_BrownOutPreventionReg2_BOPATKST43_1  (0x1 << 3)
-#define TAS2562_BrownOutPreventionReg2_BOPATKST43_2  (0x3 << 3)
-#define TAS2562_BrownOutPreventionReg2_BOPATKST43_0_5  (0x0 << 3)
-#define TAS2562_BrownOutPreventionReg2_BOPATKST43_1_5  (0x2 << 3)
-#define TAS2562_BrownOutPreventionReg2_BOPHLDTM20_Mask  (0x7 << 0)
-#define TAS2562_BrownOutPreventionReg2_BOPHLDTM20_0  (0x0 << 0)
-#define TAS2562_BrownOutPreventionReg2_BOPHLDTM20_10  (0x1 << 0)
-#define TAS2562_BrownOutPreventionReg2_BOPHLDTM20_25  (0x2 << 0)
-#define TAS2562_BrownOutPreventionReg2_BOPHLDTM20_50  (0x3 << 0)
-#define TAS2562_BrownOutPreventionReg2_BOPHLDTM20_100  (0x4 << 0)
-#define TAS2562_BrownOutPreventionReg2_BOPHLDTM20_250  (0x5 << 0)
-#define TAS2562_BrownOutPreventionReg2_BOPHLDTM20_500  (0x6 << 0)
-#define TAS2562_BrownOutPreventionReg2_BOPHLDTM20_1000  (0x7 << 0)
-
-    /* ICLA Reg0 */
-#define TAS2562_ICLAReg0  TAS2562_REG(0X0, 0x1E)
-#define TAS2562_ICLAReg0_ICLAUSEMAX_Mask  (0x1 << 7)
-#define TAS2562_ICLAReg0_ICLAUSEMAX_Min  (0x0 << 7)
-#define TAS2562_ICLAReg0_ICLAUSEMAX_Max  (0x1 << 7)
-#define TAS2562_ICLAReg0_ICLASLOT61_Mask  (0x3f << 1)
-#define TAS2562_ICLAReg0_ICLAEN_Mask  (0x1 << 0)
-#define TAS2562_ICLAReg0_ICLAEN_Disabled  (0x0 << 0)
-#define TAS2562_ICLAReg0_ICLAEN_Enabled  (0x1 << 0)
-
-    /* ICLA Reg1 */
-#define TAS2562_ICLAReg1  TAS2562_REG(0X0, 0x1F)
-#define TAS2562_ICLAReg1_ICLASEN_Mask  (0xff << 0)
-#define TAS2562_ICLAReg1_ICLASLOT_7_Disable  (0x0 << 7)
-#define TAS2562_ICLAReg1_ICLASLOT_7_Enable  (0x1 << 7)
-#define TAS2562_ICLAReg1_ICLASLOT_6_Disable  (0x0 << 6)
-#define TAS2562_ICLAReg1_ICLASLOT_6_Enable  (0x1 << 6)
-#define TAS2562_ICLAReg1_ICLASLOT_5_Disable  (0x0 << 5)
-#define TAS2562_ICLAReg1_ICLASLOT_5_Enable  (0x1 << 5)
-#define TAS2562_ICLAReg1_ICLASLOT_4_Disable  (0x0 << 4)
-#define TAS2562_ICLAReg1_ICLASLOT_4_Enable  (0x1 << 4)
-#define TAS2562_ICLAReg1_ICLASLOT_3_Disable  (0x0 << 3)
-#define TAS2562_ICLAReg1_ICLASLOT_3_Enable  (0x1 << 3)
-#define TAS2562_ICLAReg1_ICLASLOT_2_Disable  (0x0 << 2)
-#define TAS2562_ICLAReg1_ICLASLOT_2_Enable  (0x1 << 2)
-#define TAS2562_ICLAReg1_ICLASLOT_1_Disable  (0x0 << 1)
-#define TAS2562_ICLAReg1_ICLASLOT_1_Enable  (0x1 << 1)
-#define TAS2562_ICLAReg1_ICLASLOT_0_Disable  (0x0 << 0)
-#define TAS2562_ICLAReg1_ICLASLOT_0_Enable  (0x1 << 0)
+#define TAS2562_BrownOutPreventionReg1  TAS2562_REG(0X0, 0x15)
+#define TAS2562_BrownOutPreventionReg1_BOPATKRT75_Mask  (0x7 << 5)
+#define TAS2562_BrownOutPreventionReg1_BOPATKRT75_1  (0x0 << 5)
+#define TAS2562_BrownOutPreventionReg1_BOPATKRT75_2  (0x1 << 5)
+#define TAS2562_BrownOutPreventionReg1_BOPATKRT75_4  (0x2 << 5)
+#define TAS2562_BrownOutPreventionReg1_BOPATKRT75_8  (0x3 << 5)
+#define TAS2562_BrownOutPreventionReg1_BOPATKRT75_16  (0x4 << 5)
+#define TAS2562_BrownOutPreventionReg1_BOPATKRT75_32  (0x5 << 5)
+#define TAS2562_BrownOutPreventionReg1_BOPATKRT75_64  (0x6 << 5)
+#define TAS2562_BrownOutPreventionReg1_BOPATKRT75_128  (0x7 << 5)
+#define TAS2562_BrownOutPreventionReg1_BOPATKST43_Mask  (0x3 << 3)
+#define TAS2562_BrownOutPreventionReg1_BOPATKST43_1  (0x1 << 3)
+#define TAS2562_BrownOutPreventionReg1_BOPATKST43_2  (0x3 << 3)
+#define TAS2562_BrownOutPreventionReg1_BOPATKST43_0_5  (0x0 << 3)
+#define TAS2562_BrownOutPreventionReg1_BOPATKST43_1_5  (0x2 << 3)
+#define TAS2562_BrownOutPreventionReg1_BOPHLDTM20_Mask  (0x7 << 0)
+#define TAS2562_BrownOutPreventionReg1_BOPHLDTM20_0  (0x0 << 0)
+#define TAS2562_BrownOutPreventionReg1_BOPHLDTM20_10  (0x1 << 0)
+#define TAS2562_BrownOutPreventionReg1_BOPHLDTM20_25  (0x2 << 0)
+#define TAS2562_BrownOutPreventionReg1_BOPHLDTM20_50  (0x3 << 0)
+#define TAS2562_BrownOutPreventionReg1_BOPHLDTM20_100  (0x4 << 0)
+#define TAS2562_BrownOutPreventionReg1_BOPHLDTM20_250  (0x5 << 0)
+#define TAS2562_BrownOutPreventionReg1_BOPHLDTM20_500  (0x6 << 0)
+#define TAS2562_BrownOutPreventionReg1_BOPHLDTM20_1000  (0x7 << 0
 
     /* Interrupt Mask Reg0 */
-#define TAS2562_InterruptMaskReg0  TAS2562_REG(0X0, 0x20)
+#define TAS2562_InterruptMaskReg0  TAS2562_REG(0X0, 0x1A)
 #define TAS2562_InterruptMaskReg0_LIMMUTEINTMASK_Mask  (0x1 << 7)
 #define TAS2562_InterruptMaskReg0_LIMMUTEINTMASK_Unmask  (0x0 << 7)
 #define TAS2562_InterruptMaskReg0_LIMMUTEINTMASK_Disable  (0x1 << 7)
 #define TAS2562_InterruptMaskReg0_OTEINTMASK_Mask  (0x1 << 0)
 #define TAS2562_InterruptMaskReg0_OTEINTMASK_Unmask  (0x0 << 0)
 #define TAS2562_InterruptMaskReg0_OTEINTMASK_Disable  (0x1 << 0)
+#define TAS2562_InterruptMaskReg0_Disable 0xff
 
     /* Interrupt Mask Reg1 */
-#define TAS2562_InterruptMaskReg1  TAS2562_REG(0X0, 0x21)
-#define TAS2562_InterruptMaskReg1_PDMAUDDATAINVALIDINTMASK_Mask  (0x1 << 7)
-#define TAS2562_InterruptMaskReg1_PDMAUDDATAINVALIDINTMASK_Unmask  (0x0 << 7)
-#define TAS2562_InterruptMaskReg1_PDMAUDDATAINVALIDINTMASK_Disable  (0x1 << 7)
-#define TAS2562_InterruptMaskReg1_VBATOVLOINTMASK_Mask  (0x1 << 3)
-#define TAS2562_InterruptMaskReg1_VBATOVLOINTMASK_Unmask  (0x0 << 3)
-#define TAS2562_InterruptMaskReg1_VBATOVLOINTMASK_Disable  (0x1 << 3)
-#define TAS2562_InterruptMaskReg1_VBATUVLOINTMASK_Mask  (0x1 << 2)
-#define TAS2562_InterruptMaskReg1_VBATUVLOINTMASK_Unmask  (0x0 << 2)
-#define TAS2562_InterruptMaskReg1_VBATUVLOINTMASK_Disable  (0x1 << 2)
-#define TAS2562_InterruptMaskReg1_BrownOutFlagINTMASK_Mask  (0x1 << 1)
-#define TAS2562_InterruptMaskReg1_BrownOutFlagINTMASK_Unmask  (0x0 << 1)
-#define TAS2562_InterruptMaskReg1_BrownOutFlagINTMASK_Disable  (0x1 << 1)
-#define TAS2562_InterruptMaskReg1_PDMClockErrorINTMASK_Mask  (0x1 << 0)
-#define TAS2562_InterruptMaskReg1_PDMClockErrorINTMASK_Unmask  (0x0 << 0)
-#define TAS2562_InterruptMaskReg1_PDMClockErrorINTMASK_Disable  (0x1 << 0)
+#define TAS2562_InterruptMaskReg1  TAS2562_REG(0X0, 0x1B)
+#define TAS2562_InterruptMaskReg1_DSPOUTPUTINTMASK_Mask  (0x1 << 7)
+#define TAS2562_InterruptMaskReg1_DSPOUTPUTINTMASK_Unmask  (0x0 << 7)
+#define TAS2562_InterruptMaskReg1_DSPOUTPUTINTMASK_Disable  (0x1 << 7)
+#define TAS2562_InterruptMaskReg1_CRCINTMASK_Mask  (0x1 << 6)
+#define TAS2562_InterruptMaskReg1_CRCINTMASK_Unmask  (0x0 << 6)
+#define TAS2562_InterruptMaskReg1_CRCINTMASK_Disable  (0x1 << 6)
+#define TAS2562_InterruptMaskReg1_VBATOVLOINTMASK_Mask  (0x1 << 2)
+#define TAS2562_InterruptMaskReg1_VBATOVLOINTMASK_Unmask  (0x0 << 2)
+#define TAS2562_InterruptMaskReg1_VBATOVLOINTMASK_Disable  (0x1 << 2)
+#define TAS2562_InterruptMaskReg1_VBATUVLOINTMASK_Mask  (0x1 << 1)
+#define TAS2562_InterruptMaskReg1_VBATUVLOINTMASK_Unmask  (0x0 << 1)
+#define TAS2562_InterruptMaskReg1_VBATUVLOINTMASK_Disable  (0x1 << 1)
+#define TAS2562_InterruptMaskReg1_BrownOutFlagINTMASK_Mask  (0x1 << 0)
+#define TAS2562_InterruptMaskReg1_BrownOutFlagINTMASK_Unmask  (0x0 << 0)
+#define TAS2562_InterruptMaskReg1_BrownOutFlagINTMASK_Disable  (0x1 << 0)
+#define TAS2562_InterruptMaskReg1_Disable 0xff
+
+    /* Interrupt Mask Reg2 */
+#define TAS2562_InterruptMaskReg2  TAS2562_REG(0X0, 0x1C)
+#define TAS2562_InterruptMaskReg2_DACLKINTMASK_Mask  (0x1 << 7)
+#define TAS2562_InterruptMaskReg2_DACLKINTMASK_Unmask  (0x0 << 7)
+#define TAS2562_InterruptMaskReg2_DACLKINTMASK_Disable  (0x1 << 7)
+#define TAS2562_InterruptMaskReg2_BSTCLKINTMASK_Mask  (0x1 << 6)
+#define TAS2562_InterruptMaskReg2_BSTCLKINTMASK_Unmask  (0x0 << 6)
+#define TAS2562_InterruptMaskReg2_BSTCLKINTMASK_Disable  (0x1 << 6)
+#define TAS2562_InterruptMaskReg2_VBATPORCLKINTMASK_Mask  (0x1 << 5)
+#define TAS2562_InterruptMaskReg2_VBATPORCLKINTMASK_Unmask  (0x0 << 5)
+#define TAS2562_InterruptMaskReg2_VBATPORCLKINTMASK_Disable  (0x1 << 5)
+#define TAS2562_InterruptMaskReg2_PLLOCKINTMASK_Mask  (0x1 << 4)
+#define TAS2562_InterruptMaskReg2_PLLOCKINTMASK_Unmask  (0x0 << 4)
+#define TAS2562_InterruptMaskReg2_PLLOCKINTMASK_Disable  (0x1 << 4)
+#define TAS2562_InterruptMaskReg2_DCDETECTINTMASK_Mask  (0x1 << 3)
+#define TAS2562_InterruptMaskReg2_DCDETECTINTMASK_Unmask  (0x0 << 3)
+#define TAS2562_InterruptMaskReg2_DCDETECTINTMASK_Disable  (0x1 << 3)
 
     /* Live-Interrupt Reg0 */
-#define TAS2562_LiveInterruptReg0  TAS2562_REG(0X0, 0x22)
+#define TAS2562_LiveInterruptReg0  TAS2562_REG(0X0, 0x1F)
 #define TAS2562_LiveInterruptReg0_LIMMUTE_Mask  (0x1 << 7)
 #define TAS2562_LiveInterruptReg0_LIMMUTE_NoInterrupt  (0x0 << 7)
 #define TAS2562_LiveInterruptReg0_LIMMUTE_Interrupt  (0x1 << 7)
 #define TAS2562_LiveInterruptReg0_OTEFlag_Interrupt  (0x1 << 0)
 
     /* Live-Interrupt Reg1 */
-#define TAS2562_LiveInterruptReg1  TAS2562_REG(0X0, 0x23)
-#define TAS2562_LiveInterruptReg1_PDMAUDDATAINVALID_Mask  (0x1 << 7)
-#define TAS2562_LiveInterruptReg1_PDMAUDDATAINVALID_NoInterrupt  (0x0 << 7)
-#define TAS2562_LiveInterruptReg1_PDMAUDDATAINVALID_Interrupt  (0x1 << 7)
-#define TAS2562_LiveInterruptReg1_VBATOVLO_Mask  (0x1 << 3)
-#define TAS2562_LiveInterruptReg1_VBATOVLO_NoInterrupt  (0x0 << 3)
-#define TAS2562_LiveInterruptReg1_VBATOVLO_Interrupt  (0x1 << 3)
-#define TAS2562_LiveInterruptReg1_VBATUVLO_Mask  (0x1 << 2)
-#define TAS2562_LiveInterruptReg1_VBATUVLO_NoInterrupt  (0x0 << 2)
-#define TAS2562_LiveInterruptReg1_VBATUVLO_Interrupt  (0x1 << 2)
+#define TAS2562_LiveInterruptReg1  TAS2562_REG(0X0, 0x20)
+#define TAS2562_LiveInterruptReg1_DSPINTOutput_Mask  (0x1 << 7)
+#define TAS2562_LiveInterruptReg1_DSPINTOutput_NoInterrupt  (0x0 << 7)
+#define TAS2562_LiveInterruptReg1_DSPINTOutput_Interrupt  (0x1 << 7)
+#define TAS2562_LiveInterruptReg1_OTPCRC_Mask  (0x1 << 6)
+#define TAS2562_LiveInterruptReg1_OTPCRC_NoInterrupt  (0x0 << 6)
+#define TAS2562_LiveInterruptReg1_OTPCRC_Interrupt  (0x1 << 6)
 #define TAS2562_LiveInterruptReg1_BrownOutFlag_Mask  (0x1 << 1)
 #define TAS2562_LiveInterruptReg1_BrownOutFlag_NoInterrupt  (0x0 << 1)
 #define TAS2562_LiveInterruptReg1_BrownOutFlag_Interrupt  (0x1 << 1)
-#define TAS2562_LiveInterruptReg1_PDMClockError_Mask  (0x1 << 0)
-#define TAS2562_LiveInterruptReg1_PDMClockError_NoInterrupt  (0x0 << 0)
-#define TAS2562_LiveInterruptReg1_PDMClockError_Interrupt  (0x1 << 0)
+#define TAS2562_LiveInterruptReg1_BrownOutDetected_Mask  (0x1 << 1)
+#define TAS2562_LiveInterruptReg1_BrownOutDetected_NoInterrupt  (0x0 << 1)
+#define TAS2562_LiveInterruptReg1_BrownOutDetected_Interrupt  (0x1 << 1)
 
     /* Latched-Interrupt Reg0 */
 #define TAS2562_LatchedInterruptReg0  TAS2562_REG(0X0, 0x24)
 #define TAS2562_LatchedInterruptReg1_PDMClockErrorSticky_Interrupt  (0x1 << 0)
 
     /* VBAT MSB */
-#define TAS2562_VBATMSB  TAS2562_REG(0X0, 0x27)
+#define TAS2562_VBATMSB  TAS2562_REG(0X0, 0x2A)
 #define TAS2562_VBATMSB_VBATMSB70_Mask  (0xff << 0)
 
     /* VBAT LSB */
-#define TAS2562_VBATLSB  TAS2562_REG(0X0, 0x28)
+#define TAS2562_VBATLSB  TAS2562_REG(0X0, 0x2B)
 #define TAS2562_VBATLSB_VBATLSB74_Mask  (0xf << 4)
 
-    /* TEMP MSB */
-#define TAS2562_TEMPMSB  TAS2562_REG(0X0, 0x29)
-#define TAS2562_TEMPMSB_TEMPMSB70_Mask  (0xff << 0)
-
-    /* TEMP LSB */
-#define TAS2562_TEMPLSB  TAS2562_REG(0X0, 0x2A)
-#define TAS2562_TEMPLSB_TEMPLSB74_Mask  (0xf << 4)
-
-       /* SDZ Config */
-#define TAS2562_SDZCONFIG  TAS2562_REG(0X0, 0x2F)
-#define TAS2562_SDZCONFIG_ICLANONZEROMIN_Mask  (0x1 << 4)
-#define TAS2562_SDZCONFIG_ICLANONZEROMIN_Disable  (0x0 << 4)
-#define TAS2562_SDZCONFIG_ICLANONZEROMIN_Enable  (0x1 << 4)
-#define TAS2562_SDZCONFIG_SDZMODECONF_Mask  (0x3 << 2)
-#define TAS2562_SDZCONFIG_SDZMODECONF_ForcedShutdownAfterTimeout  (0x0 << 2)
-#define TAS2562_SDZCONFIG_SDZMODECONF_ForceShutdown  (0x1 << 2)
-#define TAS2562_SDZCONFIG_SDZMODECONF_NormalShutdown  (0x2 << 2)
-#define TAS2562_SDZCONFIG_SDZMODETIMEOUT_Mask  (0x3 << 0)
-#define TAS2562_SDZCONFIG_SDZMODETIMEOUT_2ms  (0x0 << 0)
-#define TAS2562_SDZCONFIG_SDZMODETIMEOUT_4ms  (0x1 << 0)
-#define TAS2562_SDZCONFIG_SDZMODETIMEOUT_6ms  (0x2 << 0)
-#define TAS2562_SDZCONFIG_SDZMODETIMEOUT_23p8ms  (0x3 << 0)
+    /* TEMP */
+#define TAS2562_TEMP  TAS2562_REG(0X0, 0x2C)
+#define TAS2562_TEMP_TEMPMSB70_Mask  (0xff << 0)
 
 
     /* Interrupt Configuration */
 #define TAS2562_InterruptConfiguration  TAS2562_REG(0X0, 0x30)
-#define TAS2562_InterruptConfiguration_INTTHRUSW_Mask  (0x1 << 2),
-#define TAS2562_InterruptConfiguration_INTTHRUSW_IntOnIRQZ  (0x0 << 2)
-#define TAS2562_InterruptConfiguration_INTTHRUSW_IntFor2ms  (0x1 << 2)
+#define TAS2562_InterruptConfiguration_LTCHINTClear_Mask (0x1 << 2)
+#define TAS2562_InterruptConfiguration_LTCHINTClear (0x1 << 2)
 #define TAS2562_InterruptConfiguration_PININTConfig10_Mask  (0x3 << 0)
 #define TAS2562_InterruptConfiguration_PININTConfig10_AssertOnLiveInterrupts \
        (0x0 << 0)
@@ -633,41 +514,7 @@ TAS2562_InterruptConfiguration_PININTConfig10_Assert2msOnLatchedInterrupts \
 #define TAS2562_ClockConfiguration_DISCLKRateDetect10_Disabled  (0x1 << 0)
 #define TAS2562_ClockConfiguration_DISCLKRateDetect10_Enabled  (0x0 << 0)
 
-
-#define TAS2562_BDIVSelection_BCLKMaster  TAS2562_REG(0X0, 0x3D)
-#define TAS2562_BDIVSelection_BCLKMaster_ClockSource10_Mask  (0x3 << 0)
-#define TAS2562_BDIVSelection_BCLKMaster_ClockSource10_NDIV2Output  (0x0 << 0)
-#define TAS2562_BDIVSelection_BCLKMaster_ClockSource10_NDIV1Output  (0x1 << 0)
-#define TAS2562_BDIVSelection_BCLKMaster_ClockSource10_MCLKOutput  (0x2 << 0)
-#define TAS2562_BDIVSelection_BCLKMaster_ClockSource10_PDMCLK1PAD  (0x3 << 0)
-
-#define TAS2562_BDIVSelection_HOLDSARUPDATE  TAS2562_REG(0X0, 0x41)
-#define TAS2562_BDIVSelection_HOLDSARUPDATE10_Mask  (0x1 << 0)
-#define TAS2562_BDIVSelection_HOLDSARUPDATE10_Disabled  (0x0 << 0)
-#define TAS2562_BDIVSelection_HOLDSARUPDATE10_Enabled  (0x1 << 0)
-
-
-    /* TDM Clock detection monitor */
-#define TAS2562_TDMClockdetectionmonitor  TAS2562_REG(0X0, 0x77)
-#define TAS2562_TDMClockdetectionmonitor_SBCLKtoFSYNC63_Mask  (0xf << 3)
-#define TAS2562_TDMClockdetectionmonitor_SBCLKtoFSYNC63_16  (0x0 << 3)
-#define TAS2562_TDMClockdetectionmonitor_SBCLKtoFSYNC63_24  (0x1 << 3)
-#define TAS2562_TDMClockdetectionmonitor_SBCLKtoFSYNC63_32  (0x2 << 3)
-#define TAS2562_TDMClockdetectionmonitor_SBCLKtoFSYNC63_48  (0x3 << 3)
-#define TAS2562_TDMClockdetectionmonitor_SBCLKtoFSYNC63_64  (0x4 << 3)
-#define TAS2562_TDMClockdetectionmonitor_SBCLKtoFSYNC63_96  (0x5 << 3)
-#define TAS2562_TDMClockdetectionmonitor_SBCLKtoFSYNC63_128  (0x6 << 3)
-#define TAS2562_TDMClockdetectionmonitor_SBCLKtoFSYNC63_192  (0x7 << 3)
-#define TAS2562_TDMClockdetectionmonitor_SBCLKtoFSYNC63_256  (0x8 << 3)
-#define TAS2562_TDMClockdetectionmonitor_SBCLKtoFSYNC63_384  (0x9 << 3)
-#define TAS2562_TDMClockdetectionmonitor_SBCLKtoFSYNC63_512  (0xf << 3)
-#define TAS2562_TDMClockdetectionmonitor_DetectedSampleRate20_Mask  (0x7 << 0),
-#define TAS2562_TDMClockdetectionmonitor_DetectedSampleRate20_8khz  (0x0 << 0)
-#define TAS2562_TDMClockdetectionmonitor_DetectedSampleRate20_16khz  (0x1 << 0)
-#define TAS2562_TDMClockdetectionmonitor_DetectedSampleRate20_32khz  (0x2 << 0)
-#define TAS2562_TDMClockdetectionmonitor_DetectedSampleRate20_48khz  (0x3 << 0)
-#define TAS2562_TDMClockdetectionmonitor_DetectedSampleRate20_96khz  (0x4 << 0)
-#define TAS2562_TDMClockdetectionmonitor_DetectedSampleRate20_192khz  (0x5 << 0)
+#define TAS2562_ICN_REG TAS2562_REG(2, 0x5c)
 
     /* Revision and PG ID */
 #define TAS2562_RevisionandPGID  TAS2562_REG(0X0, 0x7D)
@@ -682,25 +529,25 @@ TAS2562_InterruptConfiguration_PININTConfig10_Assert2msOnLatchedInterrupts \
 #define TAS2562_Book  TAS2562_REG(0X0, 0x7F)
 #define TAS2562_Book_Book70_Mask  (0xff << 0)
 
-
-#define TAS2562_RegisterCount  55
-
-#define ERROR_NONE          0x0000000
-#define ERROR_PLL_ABSENT    0x0000000
-#define ERROR_DEVA_I2C_COMM 0x0000000
-#define ERROR_DEVB_I2C_COMM 0x0000000
-#define ERROR_PRAM_CRCCHK   0x0000000
-#define ERROR_YRAM_CRCCHK   0x0000001
-#define ERROR_CLK_DET2      0x0000002
-#define ERROR_CLK_DET1      0x0000004
-#define ERROR_CLK_LOST      0x0000008
-#define ERROR_BROWNOUT      0x0000010
-#define ERROR_DIE_OVERTEMP  0x0000020
-#define ERROR_CLK_HALT      0x0000040
-#define ERROR_UNDER_VOLTAGE 0x0000080
-#define ERROR_OVER_CURRENT  0x0000100
-#define ERROR_CLASSD_PWR    0x0000200
-#define ERROR_FAILSAFE      0x4000000
+#define TAS2562_POWER_ACTIVE 0
+#define TAS2562_POWER_MUTE 1
+#define TAS2562_POWER_SHUTDOWN 2
+
+#define ERROR_NONE             0x0000000
+#define ERROR_PLL_ABSENT       0x0000000
+#define ERROR_DEVA_I2C_COMM    0x0000000
+#define ERROR_DEVB_I2C_COMM    0x0000000
+#define ERROR_PRAM_CRCCHK      0x0000000
+#define ERROR_YRAM_CRCCHK      0x0000001
+#define ERROR_OVER_CURRENT     0x0000002
+#define ERROR_DIE_OVERTEMP     0x0000004
+#define ERROR_OVER_VOLTAGE     0x0000008
+#define ERROR_UNDER_VOLTAGE    0x0000010
+#define ERROR_BROWNOUT         0x0000020
+#define ERROR_CLASSD_PWR       0x0000040
+#define ERROR_FAILSAFE         0x4000000
+
+#define CHECK_PERIOD   5000    /* 5 second */
 
 struct tas2562_register {
 int book;
@@ -719,9 +566,13 @@ struct regmap *regmap;
 struct mutex dev_lock;
 struct delayed_work irq_work;
 struct hrtimer mtimer;
+#ifdef CONFIG_TAS2562_CODEC
+struct snd_soc_codec *codec;
+#endif
 int mnClkin;
 int mnClkid;
 bool mbPowerUp;
+int mnPowerState;
 int mnCurrentBook;
 int mnCurrentPage;
 int mnLoad;
@@ -734,9 +585,10 @@ int mnSamplingRate;
 int mnFrameSize;
 int mnPLL;
 int mnPPG;
-//Added 060356-PP
+int mnCh_size;
 int mnSlot_width;
 int ch_size;
+int mnPCMFormat;
 int (*read)(struct tas2562_priv *pTAS2562,
        unsigned int reg, unsigned int *pValue);
 int (*write)(struct tas2562_priv *pTAS2562,