Add support for boost always on
authorTracy Yi <tracy-yi@ti.com>
Tue, 5 Mar 2019 10:05:54 +0000 (18:05 +0800)
committerTracy Yi <tracy-yi@ti.com>
Tue, 5 Mar 2019 10:05:54 +0000 (18:05 +0800)
Signed-off-by: Tracy Yi <tracy-yi@ti.com>
tas2563-codec.c
tas2563.h

index b150b1e1236525b8e2d0d7879b564cfe6eb26c5a..002fcc006b7e89d790861d7fdb07d4777328c654 100644 (file)
@@ -72,9 +72,8 @@
 #define TAS2563_BLOCK_CFG_POST                 0x05
 #define TAS2563_BLOCK_CFG_POST_POWER   0x06
 
-/*600ms, -105dB*/
-static char pICN[] = {0x00, 0x00, 0x2f, 0x2c};
-static char pICNDelay[] = {0x00, 0x00, 0x70, 0x80};
+static char pICN[] = {0x00, 0x01, 0x09, 0x45};
+static char pICNDelay[] = {0x00, 0x01, 0x00, 0x00};
 static int tas2563_set_fmt(struct tas2563_priv *pTAS2563, unsigned int fmt);
 static void tas2563_clear_firmware(struct TFirmware *pFirmware);
 
@@ -2330,16 +2329,8 @@ static struct snd_soc_dai_driver tas2563_dai_driver[] = {
 
 static int tas2563_codec_probe(struct snd_soc_codec *codec)
 {
-       int ret;
        struct tas2563_priv *pTAS2563 = snd_soc_codec_get_drvdata(codec);
 
-/*     ret = snd_soc_add_codec_controls(codec, tas2563_controls,
-                                        ARRAY_SIZE(tas2563_controls));*/
-       if (ret < 0) {
-               pr_err("%s: add_codec_controls failed, err %d\n",
-                       __func__, ret);
-               return ret;
-       }
        pTAS2563->codec = codec;
        pTAS2563->set_calibration = tas2563_set_calibration;
        pTAS2563->set_config = tas2563_set_config;
@@ -2357,6 +2348,62 @@ static int tas2563_codec_remove(struct snd_soc_codec *codec)
 /*static DECLARE_TLV_DB_SCALE(dac_tlv, 0, 100, 0);*/
 static DECLARE_TLV_DB_SCALE(tas2563_digital_tlv, 1100, 50, 0);
 
+static const char * const vboost_ctl_text[] = {
+       "default",
+       "Device(s) AlwaysOn"
+};
+
+static const struct soc_enum vboost_ctl_enum[] = {
+       SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(vboost_ctl_text), vboost_ctl_text),
+};
+
+static int tas2563_vboost_ctl_get(struct snd_kcontrol *pKcontrol,
+                       struct snd_ctl_elem_value *pValue)
+{
+#ifdef KCONTROL_CODEC
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(pKcontrol);
+#else
+       struct snd_soc_codec *codec = snd_kcontrol_chip(pKcontrol);
+#endif
+       struct tas2563_priv *pTAS2563 = snd_soc_codec_get_drvdata(codec);
+       //int nResult = 0, nVBoost = 0;
+
+       mutex_lock(&pTAS2563->codec_lock);
+
+       pValue->value.integer.value[0] = pTAS2563->mnVBoostState;
+
+       mutex_unlock(&pTAS2563->codec_lock);
+       return 0;
+}
+
+static int tas2563_vboost_ctl_put(struct snd_kcontrol *pKcontrol,
+                       struct snd_ctl_elem_value *pValue)
+{
+#ifdef KCONTROL_CODEC
+       struct snd_soc_codec *codec = snd_soc_kcontrol_codec(pKcontrol);
+#else
+       struct snd_soc_codec *codec = snd_kcontrol_chip(pKcontrol);
+#endif
+       struct tas2563_priv *pTAS2563 = snd_soc_codec_get_drvdata(codec);
+       int vboost_state = pValue->value.integer.value[0];
+
+       mutex_lock(&pTAS2563->codec_lock);
+
+       if(vboost_state)
+               pTAS2563->update_bits(pTAS2563, TAS2563_BoostConfiguration,
+                       TAS2563_BoostConfiguration_BoostMode_Mask,
+                       TAS2563_BoostConfiguration_BoostMode_AlwaysOn);
+       else
+               pTAS2563->update_bits(pTAS2563, TAS2563_BoostConfiguration,
+                       TAS2563_BoostConfiguration_BoostMode_Mask,
+                       TAS2563_BoostConfiguration_BoostMode_ClassH);
+
+       pTAS2563->mnVBoostState = vboost_state;
+       mutex_unlock(&pTAS2563->codec_lock);
+
+       return 0;
+}
+
 static const struct snd_kcontrol_new tas2563_snd_controls[] = {
        SOC_SINGLE_TLV("Amp Output Level", TAS2563_PlaybackConfigurationReg0,
                0, 0x16, 0,
@@ -2367,6 +2414,8 @@ static const struct snd_kcontrol_new tas2563_snd_controls[] = {
                tas2563_configuration_get, tas2563_configuration_put),
        SOC_SINGLE_EXT("Calibration", SND_SOC_NOPM, 0, 0x00FF, 0,
                tas2563_calibration_get, tas2563_calibration_put),
+       SOC_ENUM_EXT("VBoost Ctrl", vboost_ctl_enum[0],
+               tas2563_vboost_ctl_get, tas2563_vboost_ctl_put),
 };
 
 static struct snd_soc_codec_driver soc_codec_driver_tas2563 = {
index 114a105a4895196b9ecc650c7f9bd0f090aa072c..bae9a2b1f7da24c0f7c658f3a95dac8342dc1027 100644 (file)
--- a/tas2563.h
+++ b/tas2563.h
@@ -576,6 +576,14 @@ TAS2563_InterruptConfiguration_PININTConfig10_Assert2msOnLatchedInterrupts \
 #define TAS2563_MiscIRQ_IRQZBITBANG_IRQZInputBuf0  (0x0 << 0)
 #define TAS2563_MiscIRQ_IRQZBITBANG_IRQZInputBuf1  (0x1 << 0)
 
+    /* Boost Configuration */
+#define TAS2563_BoostConfiguration  TAS2563_REG(0x0, 0x0, 0x33)
+#define TAS2563_BoostConfiguration_BoostMode_Mask   (0x3 << 6)
+#define TAS2563_BoostConfiguration_BoostMode_ClassH (0x0 << 6)
+#define TAS2563_BoostConfiguration_BoostMode_ClassG (0x1 << 6)
+#define TAS2563_BoostConfiguration_BoostMode_AlwaysOn (0x2 << 6)
+#define TAS2563_BoostConfiguration_BoostMode_AlwaysOff (0x3 << 6)
+
     /* Clock Configuration */
 #define TAS2563_ClockConfiguration  TAS2563_REG(0x0, 0x0, 0x38)
 #define TAS2563_ClockConfiguration_SBCLKtoFS52_Mask  (0xf << 2)
@@ -663,7 +671,7 @@ TAS2563_InterruptConfiguration_PININTConfig10_Assert2msOnLatchedInterrupts \
 #define        TAS2563_APP_TUNINGMODE  2
 #define        TAS2563_APP_ROM1_96KHZ  3
 #define        TAS2563_APP_ROM2_96KHZ  4
-#define        TAS2563_APP_RAMMODE             5
+#define        TAS2563_APP_RAMMODE     5
 
 #define TAS2563_RegisterCount  55
 
@@ -679,10 +687,10 @@ TAS2563_InterruptConfiguration_PININTConfig10_Assert2msOnLatchedInterrupts \
 #define ERROR_UNDER_VOLTAGE    0x0000010
 #define ERROR_BROWNOUT         0x0000020
 #define ERROR_CLASSD_PWR       0x0000040
-#define ERROR_FAILSAFE      0x4000000
+#define ERROR_FAILSAFE         0x4000000
 
 #define TAS2563_COEFFICIENT_TMAX       0x7fffffff
-#define TAS2563_SAFE_GUARD_PATTERN             0x5a
+#define TAS2563_SAFE_GUARD_PATTERN     0x5a
 #define LOW_TEMPERATURE_CHECK_PERIOD 5000      /* 5 second */
 
 struct tas2563_register {
@@ -814,6 +822,7 @@ struct tas2563_priv {
        int mnCh_size;
        int mnDieTvReadCounter;
        int mnPCMFormat;
+       int mnVBoostState;
        bool mbLoadConfigurationPrePowerUp;
        bool mbLoadCalibrationPostPowerUp;
        bool mbCalibrationLoaded;