725 lines
18 KiB
C
725 lines
18 KiB
C
/*
|
|
* Driver for COD3034 CODECs on Exynos7872
|
|
*
|
|
* Copyright 2013 Wolfson Microelectronics
|
|
* Copyright 2016 Cirrus Logic
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms of the GNU General Public License as published by the
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
* option) any later version.
|
|
*/
|
|
|
|
#include <linux/debugfs.h>
|
|
#include <sound/pcm_params.h>
|
|
#include <sound/soc.h>
|
|
#include <linux/mfd/madera/core.h>
|
|
#include <linux/extcon/extcon-madera.h>
|
|
#include <linux/module.h>
|
|
#include <linux/of.h>
|
|
#include <linux/clk.h>
|
|
|
|
#include <soc/samsung/exynos-pmu.h>
|
|
#include <sound/samsung/abox.h>
|
|
|
|
#include "../codecs/madera.h"
|
|
|
|
#define EXYNOS_PMU_PMU_DEBUG_OFFSET (0x0A00)
|
|
#define MADERA_DAI_OFFSET (13)
|
|
|
|
#ifdef CONFIG_SOC_EXYNOS8895
|
|
/* Used for debugging and test automation */
|
|
static u32 voice_trigger_count;
|
|
#endif
|
|
|
|
struct clk_conf {
|
|
int id;
|
|
int source;
|
|
int rate;
|
|
};
|
|
|
|
struct exynos7872_drvdata {
|
|
struct device *dev;
|
|
|
|
struct clk_conf fll1_refclk;
|
|
struct clk_conf sysclk;
|
|
struct clk_conf dspclk;
|
|
|
|
struct notifier_block nb;
|
|
};
|
|
|
|
static struct exynos7872_drvdata exynos7872_drvdata;
|
|
|
|
static const struct snd_soc_ops rdma_ops = {
|
|
};
|
|
|
|
static const struct snd_soc_ops wdma_ops = {
|
|
};
|
|
|
|
static const struct snd_soc_ops uaif_ops = {
|
|
};
|
|
#ifdef CONFIG_SOC_EXYNOS8895
|
|
static int dsif_hw_params(struct snd_pcm_substream *substream,
|
|
struct snd_pcm_hw_params *hw_params)
|
|
{
|
|
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
|
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
|
|
int tx_slot[] = {0, 1};
|
|
|
|
/* bclk ratio 64 for DSD64, 128 for DSD128 */
|
|
snd_soc_dai_set_bclk_ratio(cpu_dai, 64);
|
|
|
|
/* channel map 0 1 if left is first, 1 0 if right is first */
|
|
snd_soc_dai_set_channel_map(cpu_dai, 2, tx_slot, 0, NULL);
|
|
return 0;
|
|
}
|
|
|
|
static const struct snd_soc_ops dsif_ops = {
|
|
.hw_params = dsif_hw_params,
|
|
};
|
|
#endif
|
|
static int exynos7872_set_bias_level(struct snd_soc_card *card,
|
|
struct snd_soc_dapm_context *dapm,
|
|
enum snd_soc_bias_level level)
|
|
{
|
|
#if 0
|
|
struct exynos7872_drvdata *drvdata = card->drvdata;
|
|
struct snd_soc_pcm_runtime *rtd;
|
|
struct snd_soc_dai *codec_dai;
|
|
struct snd_soc_codec *codec;
|
|
int ret;
|
|
|
|
rtd = snd_soc_get_pcm_runtime(card, card->dai_link[MADERA_DAI_OFFSET].name);
|
|
codec_dai = rtd->codec_dai;
|
|
codec = codec_dai->codec;
|
|
|
|
if (dapm->dev != codec_dai->dev)
|
|
return 0;
|
|
|
|
switch (level) {
|
|
case SND_SOC_BIAS_PREPARE:
|
|
if (dapm->bias_level != SND_SOC_BIAS_STANDBY)
|
|
break;
|
|
|
|
ret = snd_soc_codec_set_pll(codec, drvdata->fll1_refclk.id,
|
|
drvdata->fll1_refclk.source,
|
|
drvdata->fll1_refclk.rate,
|
|
drvdata->sysclk.rate);
|
|
if (ret < 0)
|
|
dev_err(drvdata->dev, "Failed to start FLL: %d\n", ret);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
#endif
|
|
return 0;
|
|
}
|
|
|
|
static int exynos7872_set_bias_level_post(struct snd_soc_card *card,
|
|
struct snd_soc_dapm_context *dapm,
|
|
enum snd_soc_bias_level level)
|
|
{
|
|
#if 0
|
|
struct exynos7872_drvdata *drvdata = card->drvdata;
|
|
struct snd_soc_pcm_runtime *rtd;
|
|
struct snd_soc_dai *codec_dai;
|
|
struct snd_soc_codec *codec;
|
|
int ret;
|
|
|
|
rtd = snd_soc_get_pcm_runtime(card, card->dai_link[MADERA_DAI_OFFSET].name);
|
|
codec_dai = rtd->codec_dai;
|
|
codec = codec_dai->codec;
|
|
|
|
if (dapm->dev != codec_dai->dev)
|
|
return 0;
|
|
|
|
switch (level) {
|
|
case SND_SOC_BIAS_STANDBY:
|
|
ret = snd_soc_codec_set_pll(codec, drvdata->fll1_refclk.id,
|
|
0, 0, 0);
|
|
if (ret < 0) {
|
|
dev_err(drvdata->dev, "Failed to stop FLL: %d\n", ret);
|
|
return ret;
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
#endif
|
|
return 0;
|
|
}
|
|
|
|
#ifdef CONFIG_SOC_EXYNOS8895
|
|
static int exynos7872_madera_notify(struct notifier_block *nb,
|
|
unsigned long event, void *data)
|
|
{
|
|
const struct madera_hpdet_notify_data *hp_inf;
|
|
const struct madera_micdet_notify_data *md_inf;
|
|
const struct madera_voice_trigger_info *vt_inf;
|
|
const struct exynos7872_drvdata *drvdata =
|
|
container_of(nb, struct exynos7872_drvdata, nb);
|
|
|
|
switch (event) {
|
|
case MADERA_NOTIFY_VOICE_TRIGGER:
|
|
vt_inf = data;
|
|
dev_info(drvdata->dev, "Voice Triggered (core_num=%d)\n",
|
|
vt_inf->core_num);
|
|
++voice_trigger_count;
|
|
break;
|
|
case MADERA_NOTIFY_HPDET:
|
|
hp_inf = data;
|
|
dev_info(drvdata->dev, "HPDET val=%d.%02d ohms\n",
|
|
hp_inf->impedance_x100 / 100,
|
|
hp_inf->impedance_x100 % 100);
|
|
break;
|
|
case MADERA_NOTIFY_MICDET:
|
|
md_inf = data;
|
|
dev_info(drvdata->dev, "MICDET present=%c val=%d.%02d ohms\n",
|
|
md_inf->present ? 'Y' : 'N',
|
|
md_inf->impedance_x100 / 100,
|
|
md_inf->impedance_x100 % 100);
|
|
break;
|
|
default:
|
|
dev_info(drvdata->dev, "notifier event=0x%lx data=0x%p\n",
|
|
event, data);
|
|
break;
|
|
}
|
|
|
|
return NOTIFY_DONE;
|
|
}
|
|
#endif
|
|
|
|
#ifdef CONFIG_DEBUG_FS
|
|
#ifdef CONFIG_SOC_EXYNOS8895
|
|
static void exynos7872_init_debugfs(struct snd_soc_card *card)
|
|
{
|
|
struct dentry *root;
|
|
|
|
if (!card->debugfs_card_root) {
|
|
dev_warn(card->dev, "No card debugfs root\n");
|
|
return;
|
|
}
|
|
|
|
root = debugfs_create_dir("test-automation", card->debugfs_card_root);
|
|
if (!root) {
|
|
dev_warn(card->dev, "Failed to create debugfs dir\n");
|
|
return;
|
|
}
|
|
|
|
debugfs_create_u32("voice_trigger_count", S_IRUGO, root,
|
|
&voice_trigger_count);
|
|
}
|
|
#endif
|
|
#else
|
|
static void arndale_init_debugfs(struct snd_soc_card *card)
|
|
{
|
|
}
|
|
#endif
|
|
|
|
static int exynos7872_late_probe(struct snd_soc_card *card)
|
|
{
|
|
struct snd_soc_pcm_runtime *rtd;
|
|
struct snd_soc_dai *aif1_dai;
|
|
struct snd_soc_codec *cpu;
|
|
|
|
rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
|
|
aif1_dai = rtd->cpu_dai;
|
|
cpu = aif1_dai->codec;
|
|
|
|
|
|
snd_soc_dapm_ignore_suspend(&card->dapm, "VOUTPUT");
|
|
snd_soc_dapm_ignore_suspend(&card->dapm, "VOUTPUTCALL");
|
|
snd_soc_dapm_ignore_suspend(&card->dapm, "VINPUTCALL");
|
|
|
|
snd_soc_dapm_ignore_suspend(snd_soc_codec_get_dapm(cpu), "ABOX RDMA0 Playback");
|
|
snd_soc_dapm_ignore_suspend(snd_soc_codec_get_dapm(cpu), "ABOX RDMA1 Playback");
|
|
snd_soc_dapm_ignore_suspend(snd_soc_codec_get_dapm(cpu), "ABOX RDMA2 Playback");
|
|
snd_soc_dapm_ignore_suspend(snd_soc_codec_get_dapm(cpu), "ABOX RDMA3 Playback");
|
|
snd_soc_dapm_ignore_suspend(snd_soc_codec_get_dapm(cpu), "ABOX RDMA4 Playback");
|
|
snd_soc_dapm_ignore_suspend(snd_soc_codec_get_dapm(cpu), "ABOX RDMA5 Playback");
|
|
snd_soc_dapm_ignore_suspend(snd_soc_codec_get_dapm(cpu), "ABOX RDMA6 Playback");
|
|
snd_soc_dapm_ignore_suspend(snd_soc_codec_get_dapm(cpu), "ABOX RDMA7 Playback");
|
|
snd_soc_dapm_ignore_suspend(snd_soc_codec_get_dapm(cpu), "ABOX WDMA0 Capture");
|
|
snd_soc_dapm_ignore_suspend(snd_soc_codec_get_dapm(cpu), "ABOX WDMA1 Capture");
|
|
snd_soc_dapm_ignore_suspend(snd_soc_codec_get_dapm(cpu), "ABOX WDMA2 Capture");
|
|
snd_soc_dapm_ignore_suspend(snd_soc_codec_get_dapm(cpu), "ABOX WDMA3 Capture");
|
|
snd_soc_dapm_ignore_suspend(snd_soc_codec_get_dapm(cpu), "ABOX WDMA4 Capture");
|
|
snd_soc_dapm_sync(snd_soc_codec_get_dapm(cpu));
|
|
|
|
return 0;
|
|
}
|
|
|
|
static struct snd_soc_dai_link exynos7872_dai[] = {
|
|
{
|
|
.name = "RDMA0",
|
|
.stream_name = "RDMA0",
|
|
.cpu_dai_name = "RDMA0",
|
|
.platform_name = "14a51000.abox_rdma",
|
|
.codec_name = "snd-soc-dummy",
|
|
.codec_dai_name = "snd-soc-dummy-dai",
|
|
.dynamic = 1,
|
|
.ignore_suspend = 1,
|
|
.trigger = {SND_SOC_DPCM_TRIGGER_POST_PRE, SND_SOC_DPCM_TRIGGER_PRE_POST},
|
|
.ops = &rdma_ops,
|
|
.dpcm_playback = 1,
|
|
},
|
|
{
|
|
.name = "RDMA1",
|
|
.stream_name = "RDMA1",
|
|
.cpu_dai_name = "RDMA1",
|
|
.platform_name = "14a51100.abox_rdma",
|
|
.codec_name = "snd-soc-dummy",
|
|
.codec_dai_name = "snd-soc-dummy-dai",
|
|
.dynamic = 1,
|
|
.ignore_suspend = 1,
|
|
.trigger = {SND_SOC_DPCM_TRIGGER_POST_PRE, SND_SOC_DPCM_TRIGGER_PRE_POST},
|
|
.ops = &rdma_ops,
|
|
.dpcm_playback = 1,
|
|
},
|
|
{
|
|
.name = "RDMA2",
|
|
.stream_name = "RDMA2",
|
|
.cpu_dai_name = "RDMA2",
|
|
.platform_name = "14a51200.abox_rdma",
|
|
.codec_name = "snd-soc-dummy",
|
|
.codec_dai_name = "snd-soc-dummy-dai",
|
|
.dynamic = 1,
|
|
.ignore_suspend = 1,
|
|
.trigger = {SND_SOC_DPCM_TRIGGER_POST_PRE, SND_SOC_DPCM_TRIGGER_PRE_POST},
|
|
.ops = &rdma_ops,
|
|
.dpcm_playback = 1,
|
|
},
|
|
{
|
|
.name = "RDMA3",
|
|
.stream_name = "RDMA3",
|
|
.cpu_dai_name = "RDMA3",
|
|
.platform_name = "14a51300.abox_rdma",
|
|
.codec_name = "snd-soc-dummy",
|
|
.codec_dai_name = "snd-soc-dummy-dai",
|
|
.dynamic = 1,
|
|
.ignore_suspend = 1,
|
|
.trigger = {SND_SOC_DPCM_TRIGGER_POST_PRE, SND_SOC_DPCM_TRIGGER_PRE_POST},
|
|
.ops = &rdma_ops,
|
|
.dpcm_playback = 1,
|
|
},
|
|
{
|
|
.name = "RDMA4",
|
|
.stream_name = "RDMA4",
|
|
.cpu_dai_name = "RDMA4",
|
|
.platform_name = "14a51400.abox_rdma",
|
|
.codec_name = "snd-soc-dummy",
|
|
.codec_dai_name = "snd-soc-dummy-dai",
|
|
.dynamic = 1,
|
|
.ignore_suspend = 1,
|
|
.trigger = {SND_SOC_DPCM_TRIGGER_POST_PRE, SND_SOC_DPCM_TRIGGER_PRE_POST},
|
|
.ops = &rdma_ops,
|
|
.dpcm_playback = 1,
|
|
},
|
|
{
|
|
.name = "RDMA5",
|
|
.stream_name = "RDMA5",
|
|
.cpu_dai_name = "RDMA5",
|
|
.platform_name = "14a51500.abox_rdma",
|
|
.codec_name = "snd-soc-dummy",
|
|
.codec_dai_name = "snd-soc-dummy-dai",
|
|
.dynamic = 1,
|
|
.ignore_suspend = 1,
|
|
.trigger = {SND_SOC_DPCM_TRIGGER_POST_PRE, SND_SOC_DPCM_TRIGGER_PRE_POST},
|
|
.ops = &rdma_ops,
|
|
.dpcm_playback = 1,
|
|
},
|
|
{
|
|
.name = "RDMA6",
|
|
.stream_name = "RDMA6",
|
|
.cpu_dai_name = "RDMA6",
|
|
.platform_name = "14a51600.abox_rdma",
|
|
.codec_name = "snd-soc-dummy",
|
|
.codec_dai_name = "snd-soc-dummy-dai",
|
|
.dynamic = 1,
|
|
.ignore_suspend = 1,
|
|
.trigger = {SND_SOC_DPCM_TRIGGER_POST_PRE, SND_SOC_DPCM_TRIGGER_PRE_POST},
|
|
.ops = &rdma_ops,
|
|
.dpcm_playback = 1,
|
|
},
|
|
{
|
|
.name = "RDMA7",
|
|
.stream_name = "RDMA7",
|
|
.cpu_dai_name = "RDMA7",
|
|
.platform_name = "14a51700.abox_rdma",
|
|
.codec_name = "snd-soc-dummy",
|
|
.codec_dai_name = "snd-soc-dummy-dai",
|
|
.dynamic = 1,
|
|
.ignore_suspend = 1,
|
|
.trigger = {SND_SOC_DPCM_TRIGGER_POST_PRE, SND_SOC_DPCM_TRIGGER_PRE_POST},
|
|
.ops = &rdma_ops,
|
|
.dpcm_playback = 1,
|
|
},
|
|
{
|
|
.name = "WDMA0",
|
|
.stream_name = "WDMA0",
|
|
.cpu_dai_name = "WDMA0",
|
|
.platform_name = "14a52000.abox_wdma",
|
|
.codec_name = "snd-soc-dummy",
|
|
.codec_dai_name = "snd-soc-dummy-dai",
|
|
.dynamic = 1,
|
|
.ignore_suspend = 1,
|
|
.trigger = {SND_SOC_DPCM_TRIGGER_POST_PRE, SND_SOC_DPCM_TRIGGER_PRE_POST},
|
|
.ops = &wdma_ops,
|
|
.dpcm_capture = 1,
|
|
},
|
|
{
|
|
.name = "WDMA1",
|
|
.stream_name = "WDMA1",
|
|
.cpu_dai_name = "WDMA1",
|
|
.platform_name = "14a52100.abox_wdma",
|
|
.codec_name = "snd-soc-dummy",
|
|
.codec_dai_name = "snd-soc-dummy-dai",
|
|
.dynamic = 1,
|
|
.ignore_suspend = 1,
|
|
.trigger = {SND_SOC_DPCM_TRIGGER_POST_PRE, SND_SOC_DPCM_TRIGGER_PRE_POST},
|
|
.ops = &wdma_ops,
|
|
.dpcm_capture = 1,
|
|
},
|
|
{
|
|
.name = "WDMA2",
|
|
.stream_name = "WDMA2",
|
|
.cpu_dai_name = "WDMA2",
|
|
.platform_name = "14a52200.abox_wdma",
|
|
.codec_name = "snd-soc-dummy",
|
|
.codec_dai_name = "snd-soc-dummy-dai",
|
|
.dynamic = 1,
|
|
.ignore_suspend = 1,
|
|
.trigger = {SND_SOC_DPCM_TRIGGER_POST_PRE, SND_SOC_DPCM_TRIGGER_PRE_POST},
|
|
.ops = &wdma_ops,
|
|
.dpcm_capture = 1,
|
|
},
|
|
{
|
|
.name = "WDMA3",
|
|
.stream_name = "WDMA3",
|
|
.cpu_dai_name = "WDMA3",
|
|
.platform_name = "14a52300.abox_wdma",
|
|
.codec_name = "snd-soc-dummy",
|
|
.codec_dai_name = "snd-soc-dummy-dai",
|
|
.dynamic = 1,
|
|
.ignore_suspend = 1,
|
|
.trigger = {SND_SOC_DPCM_TRIGGER_POST_PRE, SND_SOC_DPCM_TRIGGER_PRE_POST},
|
|
.ops = &wdma_ops,
|
|
.dpcm_capture = 1,
|
|
},
|
|
{
|
|
.name = "WDMA4",
|
|
.stream_name = "WDMA4",
|
|
.cpu_dai_name = "WDMA4",
|
|
.platform_name = "14a52400.abox_wdma",
|
|
.codec_name = "snd-soc-dummy",
|
|
.codec_dai_name = "snd-soc-dummy-dai",
|
|
.dynamic = 1,
|
|
.ignore_suspend = 1,
|
|
.trigger = {SND_SOC_DPCM_TRIGGER_POST_PRE, SND_SOC_DPCM_TRIGGER_PRE_POST},
|
|
.ops = &wdma_ops,
|
|
.dpcm_capture = 1,
|
|
},
|
|
{
|
|
.name = "UAIF0",
|
|
.stream_name = "UAIF0",
|
|
.cpu_dai_name = "UAIF0",
|
|
.platform_name = "snd-soc-dummy",
|
|
.codec_dai_name = "cod3034x-aif",
|
|
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS,
|
|
.no_pcm = 1,
|
|
.ignore_suspend = 1,
|
|
.ignore_pmdown_time = 1,
|
|
.be_hw_params_fixup = abox_hw_params_fixup_helper,
|
|
.ops = &uaif_ops,
|
|
.dpcm_playback = 1,
|
|
.dpcm_capture = 1,
|
|
},
|
|
{
|
|
.name = "UAIF1",
|
|
.stream_name = "UAIF1",
|
|
.cpu_dai_name = "UAIF1",
|
|
.platform_name = "snd-soc-dummy",
|
|
.codec_name = "snd-soc-dummy",
|
|
.codec_dai_name = "snd-soc-dummy-dai",
|
|
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM,
|
|
.no_pcm = 1,
|
|
.ignore_suspend = 1,
|
|
.ignore_pmdown_time = 1,
|
|
.be_hw_params_fixup = abox_hw_params_fixup_helper,
|
|
.ops = &uaif_ops,
|
|
.dpcm_playback = 1,
|
|
.dpcm_capture = 1,
|
|
},
|
|
{
|
|
.name = "UAIF2",
|
|
.stream_name = "UAIF2",
|
|
.cpu_dai_name = "UAIF2",
|
|
.platform_name = "snd-soc-dummy",
|
|
.codec_name = "snd-soc-dummy",
|
|
.codec_dai_name = "snd-soc-dummy-dai",
|
|
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS,
|
|
.no_pcm = 1,
|
|
.ignore_suspend = 1,
|
|
.ignore_pmdown_time = 1,
|
|
.be_hw_params_fixup = abox_hw_params_fixup_helper,
|
|
.ops = &uaif_ops,
|
|
.dpcm_playback = 1,
|
|
.dpcm_capture = 1,
|
|
},
|
|
{
|
|
.name = "UAIF3",
|
|
.stream_name = "UAIF3",
|
|
.cpu_dai_name = "UAIF3",
|
|
.platform_name = "snd-soc-dummy",
|
|
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS,
|
|
.no_pcm = 1,
|
|
.ignore_suspend = 1,
|
|
.ignore_pmdown_time = 1,
|
|
.be_hw_params_fixup = abox_hw_params_fixup_helper,
|
|
.ops = &uaif_ops,
|
|
.dpcm_playback = 1,
|
|
.dpcm_capture = 1,
|
|
},
|
|
{
|
|
.name = "ABOX Internal",
|
|
.stream_name = "ABOX Internal",
|
|
.cpu_dai_name = "Internal",
|
|
.platform_name = "snd-soc-dummy",
|
|
.codec_name = "snd-soc-dummy",
|
|
.codec_dai_name = "snd-soc-dummy-dai",
|
|
.dai_fmt = SND_SOC_DAIFMT_PDM | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS,
|
|
.no_pcm = 1,
|
|
.ignore_suspend = 1,
|
|
.ignore_pmdown_time = 1,
|
|
.dpcm_playback = 1,
|
|
.dpcm_capture = 1,
|
|
},
|
|
};
|
|
|
|
static const char * const vts_output_texts[] = {
|
|
"None",
|
|
"DMIC",
|
|
};
|
|
|
|
static const struct soc_enum vts_output_enum =
|
|
SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, ARRAY_SIZE(vts_output_texts),
|
|
vts_output_texts);
|
|
|
|
static const struct snd_kcontrol_new vts_output_mux[] = {
|
|
SOC_DAPM_ENUM("VTS Virtual Output Mux", vts_output_enum),
|
|
};
|
|
|
|
static const struct snd_kcontrol_new exynos7872_controls[] = {
|
|
SOC_DAPM_PIN_SWITCH("DMIC"),
|
|
};
|
|
|
|
static struct snd_soc_dapm_widget exynos7872_widgets[] = {
|
|
SND_SOC_DAPM_OUTPUT("VOUTPUT"),
|
|
SND_SOC_DAPM_OUTPUT("VOUTPUTCALL"),
|
|
SND_SOC_DAPM_INPUT("VINPUTCALL"),
|
|
};
|
|
|
|
static struct snd_soc_codec_conf codec_conf[] = {
|
|
{
|
|
.name_prefix = "ABOX",
|
|
},
|
|
#ifdef CONFIG_SOC_EXYNOS8895
|
|
{
|
|
.name_prefix = "VTS",
|
|
},
|
|
#endif
|
|
};
|
|
|
|
static struct snd_soc_aux_dev aux_dev[] = {
|
|
#ifdef CONFIG_SOC_EXYNOS8895
|
|
{
|
|
.name = "EFFECT",
|
|
},
|
|
#endif
|
|
};
|
|
|
|
static struct snd_soc_card exynos7872 = {
|
|
.name = "Exynos7872-COD3034",
|
|
.owner = THIS_MODULE,
|
|
.dai_link = exynos7872_dai,
|
|
.num_links = ARRAY_SIZE(exynos7872_dai),
|
|
|
|
.late_probe = exynos7872_late_probe,
|
|
|
|
.controls = exynos7872_controls,
|
|
.num_controls = ARRAY_SIZE(exynos7872_controls),
|
|
.dapm_widgets = exynos7872_widgets,
|
|
.num_dapm_widgets = ARRAY_SIZE(exynos7872_widgets),
|
|
|
|
.set_bias_level = exynos7872_set_bias_level,
|
|
.set_bias_level_post = exynos7872_set_bias_level_post,
|
|
|
|
.drvdata = (void *)&exynos7872_drvdata,
|
|
|
|
.codec_conf = codec_conf,
|
|
.num_configs = ARRAY_SIZE(codec_conf),
|
|
|
|
.aux_dev = aux_dev,
|
|
.num_aux_devs = ARRAY_SIZE(aux_dev),
|
|
};
|
|
|
|
static int exynos7872_read_dai(struct device_node *np, const char * const prop,
|
|
struct device_node **dai, const char **name)
|
|
{
|
|
int ret = 0;
|
|
|
|
np = of_get_child_by_name(np, prop);
|
|
if (!np)
|
|
return -ENOENT;
|
|
|
|
*dai = of_parse_phandle(np, "sound-dai", 0);
|
|
if (!*dai) {
|
|
ret = -ENODEV;
|
|
goto out;
|
|
}
|
|
|
|
if (*name == NULL) {
|
|
/* Ignoring the return as we don't register DAIs to the platform */
|
|
ret = snd_soc_of_get_dai_name(np, name);
|
|
if (ret && !*name)
|
|
return ret;
|
|
}
|
|
|
|
out:
|
|
of_node_put(np);
|
|
|
|
return ret;
|
|
}
|
|
|
|
#ifdef CONFIG_SOC_EXYNOS8895
|
|
static struct clk *xclkout;
|
|
|
|
static void control_xclkout(bool on)
|
|
{
|
|
if (on) {
|
|
clk_enable(xclkout);
|
|
} else {
|
|
clk_disable(xclkout);
|
|
}
|
|
}
|
|
#endif
|
|
static int exynos7872_audio_probe(struct platform_device *pdev)
|
|
{
|
|
struct snd_soc_card *card = &exynos7872;
|
|
struct exynos7872_drvdata *drvdata = card->drvdata;
|
|
struct device_node *np = pdev->dev.of_node;
|
|
struct device_node *dai;
|
|
int nlink = 0, n;
|
|
int ret;
|
|
|
|
card->dev = &pdev->dev;
|
|
drvdata->dev = card->dev;
|
|
dev_info(card->dev, "%s\n", __func__);
|
|
|
|
#ifdef CONFIG_SOC_EXYNOS8895
|
|
xclkout = devm_clk_get(&pdev->dev, "xclkout");
|
|
if (IS_ERR(xclkout)) {
|
|
dev_err(&pdev->dev, "xclkout get failed\n");
|
|
return PTR_ERR(xclkout);
|
|
}
|
|
clk_prepare(xclkout);
|
|
#endif
|
|
|
|
for_each_child_of_node(np, dai) {
|
|
ret = exynos7872_read_dai(dai, "cpu",
|
|
&exynos7872_dai[nlink].cpu_of_node,
|
|
&exynos7872_dai[nlink].cpu_dai_name);
|
|
if (ret) {
|
|
dev_warn(card->dev,
|
|
"Failed to parse cpu DAI for %s: %d\n",
|
|
dai->name, ret);
|
|
}
|
|
|
|
if (!exynos7872_dai[nlink].platform_name) {
|
|
exynos7872_dai[nlink].platform_of_node = exynos7872_dai[nlink].cpu_of_node;
|
|
}
|
|
|
|
if (!exynos7872_dai[nlink].codec_name) {
|
|
ret = exynos7872_read_dai(dai, "codec",
|
|
&exynos7872_dai[nlink].codec_of_node,
|
|
&exynos7872_dai[nlink].codec_dai_name);
|
|
if (ret) {
|
|
dev_warn(card->dev,
|
|
"Failed to parse codec DAI for %s: %d\n",
|
|
dai->name, ret);
|
|
}
|
|
}
|
|
|
|
if (++nlink == card->num_links)
|
|
break;
|
|
}
|
|
|
|
if (!nlink) {
|
|
dev_warn(card->dev, "No DAIs specified\n");
|
|
}
|
|
|
|
if (of_property_read_bool(np, "samsung,routing")) {
|
|
ret = snd_soc_of_parse_audio_routing(card, "samsung,routing");
|
|
if (ret)
|
|
return ret;
|
|
}
|
|
|
|
for (n = 0; n < ARRAY_SIZE(codec_conf); n++) {
|
|
codec_conf[n].of_node = of_parse_phandle(np, "samsung,codec", n);
|
|
|
|
if (!codec_conf[n].of_node) {
|
|
dev_err(&pdev->dev,
|
|
"Property 'samsung,codec' missing\n");
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
#ifdef CONFIG_SOC_EXYNOS8895
|
|
for (n = 0; n < ARRAY_SIZE(aux_dev); n++) {
|
|
aux_dev[n].codec_of_node = of_parse_phandle(np, "samsung,aux", n);
|
|
|
|
if (!aux_dev[n].codec_of_node) {
|
|
dev_err(&pdev->dev,
|
|
"Property 'samsung,aux' missing\n");
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
#endif
|
|
|
|
#ifdef CONFIG_SOC_EXYNOS8895
|
|
control_xclkout(true);
|
|
#endif
|
|
ret = devm_snd_soc_register_card(card->dev, card);
|
|
if (ret)
|
|
{
|
|
dev_err(card->dev, "snd_soc_register_card() failed:%d\n", ret);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
#ifdef CONFIG_OF
|
|
static const struct of_device_id exynos7872_of_match[] = {
|
|
{ .compatible = "samsung,exynos7872-cod3034", },
|
|
{},
|
|
};
|
|
MODULE_DEVICE_TABLE(of, exynos7872_of_match);
|
|
#endif /* CONFIG_OF */
|
|
|
|
static struct platform_driver exynos7872_audio_driver = {
|
|
.driver = {
|
|
.name = "exynos7872-cod3034",
|
|
.owner = THIS_MODULE,
|
|
.pm = &snd_soc_pm_ops,
|
|
.of_match_table = of_match_ptr(exynos7872_of_match),
|
|
},
|
|
|
|
.probe = exynos7872_audio_probe,
|
|
};
|
|
|
|
module_platform_driver(exynos7872_audio_driver);
|
|
|
|
MODULE_DESCRIPTION("ALSA SoC Exynos7872 COD3034 Driver");
|
|
MODULE_AUTHOR("Charles Keepax <ckeepax@opensource.wolfsonmicro.com>");
|
|
MODULE_LICENSE("GPL");
|
|
MODULE_ALIAS("platform:exynos7872-cod3034");
|