2019-05-27 13:55:01 +07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2010-06-08 17:01:12 +07:00
|
|
|
/*
|
|
|
|
* snappercl15.c -- SoC audio for Bluewater Systems Snapper CL15 module
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008 Bluewater Systems Ltd
|
2011-06-15 11:45:36 +07:00
|
|
|
* Author: Ryan Mallon
|
2010-06-08 17:01:12 +07:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/platform_device.h>
|
2011-07-15 23:38:28 +07:00
|
|
|
#include <linux/module.h>
|
2019-04-16 03:17:11 +07:00
|
|
|
#include <linux/soc/cirrus/ep93xx.h>
|
2010-06-08 17:01:12 +07:00
|
|
|
#include <sound/core.h>
|
|
|
|
#include <sound/pcm.h>
|
|
|
|
#include <sound/soc.h>
|
|
|
|
|
|
|
|
#include <asm/mach-types.h>
|
|
|
|
|
|
|
|
#include "../codecs/tlv320aic23.h"
|
|
|
|
|
|
|
|
#define CODEC_CLOCK 5644800
|
|
|
|
|
|
|
|
static int snappercl15_hw_params(struct snd_pcm_substream *substream,
|
|
|
|
struct snd_pcm_hw_params *params)
|
|
|
|
{
|
|
|
|
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
2010-03-18 03:15:21 +07:00
|
|
|
struct snd_soc_dai *codec_dai = rtd->codec_dai;
|
|
|
|
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
|
2010-06-08 17:01:12 +07:00
|
|
|
int err;
|
|
|
|
|
|
|
|
err = snd_soc_dai_set_sysclk(codec_dai, 0, CODEC_CLOCK,
|
|
|
|
SND_SOC_CLOCK_IN);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
err = snd_soc_dai_set_sysclk(cpu_dai, 0, CODEC_CLOCK,
|
|
|
|
SND_SOC_CLOCK_OUT);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-08-16 23:59:25 +07:00
|
|
|
static const struct snd_soc_ops snappercl15_ops = {
|
2010-06-08 17:01:12 +07:00
|
|
|
.hw_params = snappercl15_hw_params,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct snd_soc_dapm_widget tlv320aic23_dapm_widgets[] = {
|
|
|
|
SND_SOC_DAPM_HP("Headphone Jack", NULL),
|
|
|
|
SND_SOC_DAPM_LINE("Line In", NULL),
|
|
|
|
SND_SOC_DAPM_MIC("Mic Jack", NULL),
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct snd_soc_dapm_route audio_map[] = {
|
|
|
|
{"Headphone Jack", NULL, "LHPOUT"},
|
|
|
|
{"Headphone Jack", NULL, "RHPOUT"},
|
|
|
|
|
|
|
|
{"LLINEIN", NULL, "Line In"},
|
|
|
|
{"RLINEIN", NULL, "Line In"},
|
|
|
|
|
|
|
|
{"MICIN", NULL, "Mic Jack"},
|
|
|
|
};
|
|
|
|
|
2019-06-06 11:14:28 +07:00
|
|
|
SND_SOC_DAILINK_DEFS(aic23,
|
|
|
|
DAILINK_COMP_ARRAY(COMP_CPU("ep93xx-i2s")),
|
|
|
|
DAILINK_COMP_ARRAY(COMP_CODEC("tlv320aic23-codec.0-001a",
|
|
|
|
"tlv320aic23-hifi")),
|
|
|
|
DAILINK_COMP_ARRAY(COMP_PLATFORM("ep93xx-i2s")));
|
|
|
|
|
2010-06-08 17:01:12 +07:00
|
|
|
static struct snd_soc_dai_link snappercl15_dai = {
|
|
|
|
.name = "tlv320aic23",
|
|
|
|
.stream_name = "AIC23",
|
2018-04-29 03:51:38 +07:00
|
|
|
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
|
2011-12-17 14:41:11 +07:00
|
|
|
SND_SOC_DAIFMT_CBS_CFS,
|
2010-06-08 17:01:12 +07:00
|
|
|
.ops = &snappercl15_ops,
|
2019-06-06 11:14:28 +07:00
|
|
|
SND_SOC_DAILINK_REG(aic23),
|
2010-06-08 17:01:12 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct snd_soc_card snd_soc_snappercl15 = {
|
|
|
|
.name = "Snapper CL15",
|
2011-12-22 20:21:37 +07:00
|
|
|
.owner = THIS_MODULE,
|
2010-06-08 17:01:12 +07:00
|
|
|
.dai_link = &snappercl15_dai,
|
|
|
|
.num_links = 1,
|
2014-03-12 21:27:36 +07:00
|
|
|
|
|
|
|
.dapm_widgets = tlv320aic23_dapm_widgets,
|
|
|
|
.num_dapm_widgets = ARRAY_SIZE(tlv320aic23_dapm_widgets),
|
|
|
|
.dapm_routes = audio_map,
|
|
|
|
.num_dapm_routes = ARRAY_SIZE(audio_map),
|
2010-06-08 17:01:12 +07:00
|
|
|
};
|
|
|
|
|
2012-12-07 21:26:23 +07:00
|
|
|
static int snappercl15_probe(struct platform_device *pdev)
|
2010-06-08 17:01:12 +07:00
|
|
|
{
|
2011-09-11 16:28:52 +07:00
|
|
|
struct snd_soc_card *card = &snd_soc_snappercl15;
|
2010-06-08 17:01:12 +07:00
|
|
|
int ret;
|
|
|
|
|
2012-01-11 10:14:31 +07:00
|
|
|
ret = ep93xx_i2s_acquire();
|
2010-06-08 17:01:12 +07:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2011-09-11 16:28:52 +07:00
|
|
|
card->dev = &pdev->dev;
|
|
|
|
|
|
|
|
ret = snd_soc_register_card(card);
|
|
|
|
if (ret) {
|
|
|
|
dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
|
|
|
|
ret);
|
|
|
|
ep93xx_i2s_release();
|
|
|
|
}
|
2010-06-08 17:01:12 +07:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-12-07 21:26:23 +07:00
|
|
|
static int snappercl15_remove(struct platform_device *pdev)
|
2010-06-08 17:01:12 +07:00
|
|
|
{
|
2011-09-11 16:28:52 +07:00
|
|
|
struct snd_soc_card *card = platform_get_drvdata(pdev);
|
|
|
|
|
|
|
|
snd_soc_unregister_card(card);
|
2010-06-08 17:01:12 +07:00
|
|
|
ep93xx_i2s_release();
|
2011-09-11 16:28:52 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct platform_driver snappercl15_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = "snappercl15-audio",
|
|
|
|
},
|
|
|
|
.probe = snappercl15_probe,
|
2012-12-07 21:26:23 +07:00
|
|
|
.remove = snappercl15_remove,
|
2011-09-11 16:28:52 +07:00
|
|
|
};
|
|
|
|
|
2011-11-24 11:07:55 +07:00
|
|
|
module_platform_driver(snappercl15_driver);
|
2010-06-08 17:01:12 +07:00
|
|
|
|
2011-06-15 11:45:36 +07:00
|
|
|
MODULE_AUTHOR("Ryan Mallon");
|
2010-06-08 17:01:12 +07:00
|
|
|
MODULE_DESCRIPTION("ALSA SoC Snapper CL15");
|
|
|
|
MODULE_LICENSE("GPL");
|
2011-09-11 16:28:52 +07:00
|
|
|
MODULE_ALIAS("platform:snappercl15-audio");
|