--- a/sound/soc/Kconfig
+++ b/sound/soc/Kconfig
-@@ -56,6 +56,7 @@
+@@ -56,6 +56,7 @@ source "sound/soc/spear/Kconfig"
source "sound/soc/tegra/Kconfig"
source "sound/soc/txx9/Kconfig"
source "sound/soc/ux500/Kconfig"
source "sound/soc/codecs/Kconfig"
--- a/sound/soc/Makefile
+++ b/sound/soc/Makefile
-@@ -33,3 +33,4 @@
+@@ -33,3 +33,4 @@ obj-$(CONFIG_SND_SOC) += spear/
obj-$(CONFIG_SND_SOC) += tegra/
obj-$(CONFIG_SND_SOC) += txx9/
obj-$(CONFIG_SND_SOC) += ux500/
+obj-$(CONFIG_SND_SOC) += mtk/
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
-@@ -725,7 +725,7 @@
+@@ -725,7 +725,7 @@ config SND_SOC_WM8955
tristate
config SND_SOC_WM8960
+
--- /dev/null
+++ b/sound/soc/mtk/mt76xx_i2s.c
-@@ -0,0 +1,309 @@
+@@ -0,0 +1,304 @@
+/*
+ * mtk_audio_drv.c
+ *
+ struct snd_pcm_runtime *runtime = substream->runtime;
+ i2s_config_type* rtd = runtime->private_data;
+
-+ printk("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
+ //printk("******* %s *******\n", __func__);
+ switch(params_rate(params)){
+ case 8000:
+ srate = 32000;
+ break;
+ case 44100:
-+ printk("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
+ srate = 44100;
+ break;
+ case 48000:
+ break;
+ }
+ if(srate){
-+ printk("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
+ if((rtd->bRxDMAEnable != GDMA_I2S_EN) && (rtd->bTxDMAEnable != GDMA_I2S_EN)){
-+ printk("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
+ rtd->srate = srate;
+ MSG("set audio sampling rate to %d Hz\n", rtd->srate);
+ }
+static int mt76xx_i2s_drv_probe(struct platform_device *pdev)
+{
+ //printk("****** %s ******\n", __func__);
-+ printk("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
+ return snd_soc_register_component(&pdev->dev, &mt76xx_i2s_component,
+ &mt76xx_i2s_dai, 1);
+}
+#endif /* MTK_I2S_H_ */
--- /dev/null
+++ b/sound/soc/mtk/mt76xx_machine.c
-@@ -0,0 +1,319 @@
+@@ -0,0 +1,317 @@
+/*
+ * mt76xx_machine.c
+ *
+ unsigned long* pTable;
+ int mclk,ret,targetClk = 0;
+
-+ printk("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
+ /*For duplex mode, avoid setting twice.*/
+ if((rtd->bRxDMAEnable == GDMA_I2S_EN) || (rtd->bTxDMAEnable == GDMA_I2S_EN))
+ return 0;
-+ //printk("%s:%d \n",__func__,__LINE__);
+#if defined(CONFIG_I2S_MCLK_12MHZ)
+ mclk = 12000000;
+#elif defined(CONFIG_I2S_MCLK_12P288MHZ)
+#endif
+ //snd_soc_dai_set_sysclk(codec_dai,0,mclk, SND_SOC_CLOCK_IN);
+
-+ printk("%s:%s[%d]%d\n", __FILE__, __func__, __LINE__, params_rate(params));
+ switch(params_rate(params)){
+ case 8000:
+ index = 0;
+ //MSG("audio sampling rate %u should be %d ~ %d Hz\n", (u32)params_rate(params), MIN_SRATE_HZ, MAX_SRATE_HZ);
+ break;
+ }
-+printk("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
+#if defined(CONFIG_SND_SOC_WM8960)
+ /*
+ * There is a fixed divide by 4 in the PLL and a selectable
+ * divide by N after the PLL which should be set to divide by 2 to meet this requirement.
+ * */
-+ printk("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
+ ret = snd_soc_dai_set_pll(codec_dai, 0, 0,mclk, targetClk*2);
+ /* From app notes: allow Vref to stabilize to reduce clicks */
+ if(rtd->slave_en){
-+ printk("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
+ //printk("WM8960 is in master mode\n");
+ ret = snd_soc_dai_set_clkdiv(codec_dai, WM8960_DCLKDIV, 0x1c4);
+ ret = snd_soc_dai_set_clkdiv(codec_dai, WM8960_SYSCLKDIV, 0x5);
+ pTable = i2s_codec_12p288Mhz;
+ data = pTable[index];
+#endif
-+ printk("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
+ if(rtd->codec_pll_en)
+ ret = snd_soc_dai_set_clkdiv(codec_dai, WM8960_DACDIV, (data<<3)|0x5);
+ else
+ ret = snd_soc_dai_set_clkdiv(codec_dai, WM8960_DACDIV, (data<<3|0x4));
-+printk("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
+#endif
+
+ return 0;
+#if defined(CONFIG_SND_SOC_WM8750)
+ I2C_BOARD_INFO("wm8750", (0x36 >> 1)),
+#elif defined(CONFIG_SND_SOC_WM8960)
-+ // I2C_BOARD_INFO("wm8960", (0x34 >> 1)),
+ I2C_BOARD_INFO("codec_wm8960", (0x34)),
++ }, {
++ I2C_BOARD_INFO("wm8960", (0x34 >> 1)),
+#endif
-+ },
++ }
+};
+
+static struct platform_device *soc_mtk_i2s_dev;
+ adapter = i2c_get_adapter(I2C_AUDIO_DEV_ID);
+ if (!adapter)
+ return -ENODEV;
-+ client = i2c_new_device(adapter, i2c_board_info);
++ client = i2c_new_device(adapter, &i2c_board_info[0]);
+ if (!client)
+ return -ENODEV;
++ i2c_get_clientdata(client);
+
-+ i2c_put_adapter(adapter);
++ client = i2c_new_device(adapter, &i2c_board_info[1]);
++ if (!client)
++ return -ENODEV;
+ i2c_get_clientdata(client);
+
++ i2c_put_adapter(adapter);
++
+ soc_mtk_i2s_dev =
+ platform_device_register_simple("mt76xx-i2s", -1, NULL, 0);
+ if (IS_ERR(soc_mtk_i2s_dev))
+#endif
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
-@@ -1851,7 +1851,8 @@
+@@ -1851,7 +1851,8 @@ static int soc_probe(struct platform_dev
/* Bodge while we unpick instantiation */
card->dev = &pdev->dev;
{ 0x4, 0x0000 },
{ 0x5, 0x0008 },
{ 0x6, 0x0000 },
-@@ -88,8 +89,8 @@
+@@ -88,8 +89,8 @@ static const struct reg_default wm8960_r
{ 0x25, 0x0050 },
{ 0x26, 0x0000 },
{ 0x27, 0x0000 },
{ 0x2a, 0x0040 },
{ 0x2b, 0x0000 },
{ 0x2c, 0x0000 },
-@@ -127,8 +128,15 @@
+@@ -127,8 +128,15 @@ struct wm8960_priv {
int playback_fs;
};
/* enumerated controls */
static const char *wm8960_polarity[] = {"No Inversion", "Left Inverted",
"Right Inverted", "Stereo Inversion"};
-@@ -181,8 +189,8 @@
+@@ -181,8 +189,8 @@ static int wm8960_get_deemph(struct snd_
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec);
}
static int wm8960_put_deemph(struct snd_kcontrol *kcontrol,
-@@ -200,6 +208,70 @@
+@@ -200,6 +208,70 @@ static int wm8960_put_deemph(struct snd_
return wm8960_set_deemph(codec);
}
static const DECLARE_TLV_DB_SCALE(adc_tlv, -9700, 50, 0);
static const DECLARE_TLV_DB_SCALE(dac_tlv, -12700, 50, 1);
static const DECLARE_TLV_DB_SCALE(bypass_tlv, -2100, 300, 0);
-@@ -542,6 +614,7 @@
+@@ -542,6 +614,7 @@ static int wm8960_set_dai_fmt(struct snd
/* set iface */
snd_soc_write(codec, WM8960_IFACE1, iface);
return 0;
}
-@@ -623,11 +696,16 @@
+@@ -623,11 +696,16 @@ static int wm8960_set_bias_level_out3(st
break;
case SND_SOC_BIAS_PREPARE:
if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) {
regcache_sync(wm8960->regmap);
-@@ -650,9 +728,13 @@
+@@ -650,9 +728,13 @@ static int wm8960_set_bias_level_out3(st
/* Set VMID to 2x250k */
snd_soc_update_bits(codec, WM8960_POWER1, 0x180, 0x100);
/* Enable anti-pop features */
snd_soc_write(codec, WM8960_APOP1,
WM8960_POBCTRL | WM8960_SOFT_ST |
-@@ -661,6 +743,7 @@
+@@ -661,6 +743,7 @@ static int wm8960_set_bias_level_out3(st
/* Disable VMID and VREF, let them discharge */
snd_soc_write(codec, WM8960_POWER1, 0);
msleep(600);
break;
}
-@@ -853,10 +936,15 @@
+@@ -853,10 +936,15 @@ static int wm8960_set_dai_pll(struct snd
if (pll_div.k) {
reg |= 0x20;
}
snd_soc_write(codec, WM8960_PLL1, reg);
-@@ -876,19 +964,27 @@
-
- switch (div_id) {
- case WM8960_SYSCLKDIV:
-+ printk("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
- reg = snd_soc_read(codec, WM8960_CLOCK1) & 0x1f9;
- snd_soc_write(codec, WM8960_CLOCK1, reg | div);
- break;
- case WM8960_DACDIV:
- reg = snd_soc_read(codec, WM8960_CLOCK1) & 0x1c7;
-+ printk("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
- snd_soc_write(codec, WM8960_CLOCK1, reg | div);
- break;
- case WM8960_OPCLKDIV:
- reg = snd_soc_read(codec, WM8960_PLL1) & 0x03f;
-+ printk("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
+@@ -888,7 +976,11 @@ static int wm8960_set_dai_clkdiv(struct
snd_soc_write(codec, WM8960_PLL1, reg | div);
break;
case WM8960_DCLKDIV:
+#if 1
-+ printk("%s:%s[%d]\n", __FILE__, __func__, __LINE__);
reg = snd_soc_read(codec, WM8960_CLOCK2) & 0x03f;
+#else
+ reg = snd_soc_read(codec, WM8960_CLOCK2) & 0x03f;
snd_soc_write(codec, WM8960_CLOCK2, reg | div);
break;
case WM8960_TOCLKSEL:
-@@ -962,7 +1058,7 @@
+@@ -962,7 +1054,7 @@ static int wm8960_probe(struct snd_soc_c
{
struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec);
struct wm8960_data *pdata = dev_get_platdata(codec->dev);
wm8960->set_bias_level = wm8960_set_bias_level_out3;
-@@ -973,11 +1069,7 @@
+@@ -973,11 +1065,7 @@ static int wm8960_probe(struct snd_soc_c
wm8960->set_bias_level = wm8960_set_bias_level_capless;
}