summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYeleswarapu Nagaradhesh <nagaradh@codeaurora.org>2015-07-20 23:18:01 +0530
committerDavid Keitel <dkeitel@codeaurora.org>2016-03-23 21:12:50 -0700
commit2b7260c155ea0120965525c9008eaa485aee8bfa (patch)
tree3c8242012bb006f688a1b032fcd90aa6ab239fa7
parent433d2262636f98e1ceba4715bfa7226285ab4c96 (diff)
ASoC: wcd: add support for wcd9326 codec
Use efuse register values, to differentiate between wcd9326 and wcd9335 codecs. Change-Id: I68e7ae5eb1717dccd0af975670ac3644304996b9 Signed-off-by: Yeleswarapu Nagaradhesh <nagaradh@codeaurora.org> Signed-off-by: Simmi Pateriya <simmip@codeaurora.org>
-rwxr-xr-xinclude/linux/mfd/wcd9xxx/core.h1
-rwxr-xr-xsound/soc/codecs/wcd9335.c64
-rw-r--r--sound/soc/codecs/wcd9335.h1
3 files changed, 66 insertions, 0 deletions
diff --git a/include/linux/mfd/wcd9xxx/core.h b/include/linux/mfd/wcd9xxx/core.h
index b0f4efcb72a6..af66a8ddfcf0 100755
--- a/include/linux/mfd/wcd9xxx/core.h
+++ b/include/linux/mfd/wcd9xxx/core.h
@@ -67,6 +67,7 @@ enum codec_variant {
WCD9XXX,
WCD9330,
WCD9335,
+ WCD9326,
};
enum {
diff --git a/sound/soc/codecs/wcd9335.c b/sound/soc/codecs/wcd9335.c
index 72bf97f81fb8..c1c6744527fa 100755
--- a/sound/soc/codecs/wcd9335.c
+++ b/sound/soc/codecs/wcd9335.c
@@ -152,6 +152,8 @@ enum tasha_sido_voltage {
SIDO_VOLTAGE_NOMINAL_MV = 1100,
};
+static enum codec_variant codec_ver;
+
static int dig_core_collapse_enable = 1;
module_param(dig_core_collapse_enable, int,
S_IRUGO | S_IWUSR | S_IWGRP);
@@ -12691,6 +12693,65 @@ err:
return;
}
+/*
+ * tasha_codec_ver: to get tasha codec version
+ * @codec: handle to snd_soc_codec *
+ * return enum codec_variant - version
+ */
+enum codec_variant tasha_codec_ver(void)
+{
+ return codec_ver;
+}
+EXPORT_SYMBOL(tasha_codec_ver);
+
+static int __tasha_enable_efuse_sensing(struct tasha_priv *tasha)
+{
+ __tasha_cdc_mclk_enable(tasha, true);
+
+ wcd9xxx_reg_update_bits(&tasha->wcd9xxx->core_res,
+ WCD9335_CHIP_TIER_CTRL_EFUSE_CTL, 0x1E, 0x20);
+ wcd9xxx_reg_update_bits(&tasha->wcd9xxx->core_res,
+ WCD9335_CHIP_TIER_CTRL_EFUSE_CTL, 0x01, 0x01);
+
+ /*
+ * 5ms sleep required after enabling efuse control
+ * before checking the status.
+ */
+ usleep_range(5000, 5500);
+ if (!(wcd9xxx_reg_read(&tasha->wcd9xxx->core_res,
+ WCD9335_CHIP_TIER_CTRL_EFUSE_STATUS) & 0x01))
+ WARN(1, "%s: Efuse sense is not complete\n", __func__);
+
+ __tasha_cdc_mclk_enable(tasha, false);
+
+ return 0;
+}
+
+void tasha_get_codec_ver(struct tasha_priv *tasha)
+{
+ int i;
+ u8 val;
+ struct tasha_reg_mask_val codec_reg[] = {
+ {WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT10, 0xFF, 0xFF},
+ {WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT11, 0xFF, 0x83},
+ {WCD9335_CHIP_TIER_CTRL_EFUSE_VAL_OUT12, 0xFF, 0x0A},
+ };
+
+ __tasha_enable_efuse_sensing(tasha);
+ for (i = 0; i < ARRAY_SIZE(codec_reg); i++) {
+ val = wcd9xxx_reg_read(&tasha->wcd9xxx->core_res,
+ codec_reg[i].reg);
+ if (!(val && codec_reg[i].val)) {
+ codec_ver = WCD9335;
+ goto ret;
+ }
+ }
+ codec_ver = WCD9326;
+ret:
+ pr_debug("%s: codec is %d\n", __func__, codec_ver);
+}
+EXPORT_SYMBOL(tasha_get_codec_ver);
+
static int tasha_probe(struct platform_device *pdev)
{
int ret = 0;
@@ -12794,6 +12855,9 @@ static int tasha_probe(struct platform_device *pdev)
/* Update codec register default values */
tasha_update_reg_defaults(tasha);
schedule_work(&tasha->swr_add_devices_work);
+
+ tasha_get_codec_ver(tasha);
+
return ret;
resmgr_remove:
diff --git a/sound/soc/codecs/wcd9335.h b/sound/soc/codecs/wcd9335.h
index b35d85304809..035e3400fdc4 100644
--- a/sound/soc/codecs/wcd9335.h
+++ b/sound/soc/codecs/wcd9335.h
@@ -144,4 +144,5 @@ extern int tasha_codec_enable_standalone_micbias(struct snd_soc_codec *codec,
bool enable);
extern int tasha_set_spkr_mode(struct snd_soc_codec *codec, int mode);
extern int tasha_set_spkr_gain_offset(struct snd_soc_codec *codec, int offset);
+extern enum codec_variant tasha_codec_ver(void);
#endif