18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci//
38c2ecf20Sopenharmony_ci// Copyright 2009 Simtec Electronics
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#include <linux/module.h>
68c2ecf20Sopenharmony_ci#include <sound/soc.h>
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#include "s3c24xx_simtec.h"
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_cistatic const struct snd_soc_dapm_widget dapm_widgets[] = {
118c2ecf20Sopenharmony_ci	SND_SOC_DAPM_LINE("GSM Out", NULL),
128c2ecf20Sopenharmony_ci	SND_SOC_DAPM_LINE("GSM In", NULL),
138c2ecf20Sopenharmony_ci	SND_SOC_DAPM_LINE("Line In", NULL),
148c2ecf20Sopenharmony_ci	SND_SOC_DAPM_LINE("Line Out", NULL),
158c2ecf20Sopenharmony_ci	SND_SOC_DAPM_LINE("ZV", NULL),
168c2ecf20Sopenharmony_ci	SND_SOC_DAPM_MIC("Mic Jack", NULL),
178c2ecf20Sopenharmony_ci	SND_SOC_DAPM_HP("Headphone Jack", NULL),
188c2ecf20Sopenharmony_ci};
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_cistatic const struct snd_soc_dapm_route base_map[] = {
218c2ecf20Sopenharmony_ci	/* Headphone connected to HP{L,R}OUT and HP{L,R}COM */
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci	{ "Headphone Jack", NULL, "HPLOUT" },
248c2ecf20Sopenharmony_ci	{ "Headphone Jack", NULL, "HPLCOM" },
258c2ecf20Sopenharmony_ci	{ "Headphone Jack", NULL, "HPROUT" },
268c2ecf20Sopenharmony_ci	{ "Headphone Jack", NULL, "HPRCOM" },
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci	/* ZV connected to Line1 */
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci	{ "LINE1L", NULL, "ZV" },
318c2ecf20Sopenharmony_ci	{ "LINE1R", NULL, "ZV" },
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci	/* Line In connected to Line2 */
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci	{ "LINE2L", NULL, "Line In" },
368c2ecf20Sopenharmony_ci	{ "LINE2R", NULL, "Line In" },
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci	/* Microphone connected to MIC3R and MIC_BIAS */
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci	{ "MIC3L", NULL, "Mic Jack" },
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci	/* GSM connected to MONO_LOUT and MIC3L (in) */
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci	{ "GSM Out", NULL, "MONO_LOUT" },
458c2ecf20Sopenharmony_ci	{ "MIC3L", NULL, "GSM In" },
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci	/* Speaker is connected to LINEOUT{LN,LP,RN,RP}, however we are
488c2ecf20Sopenharmony_ci	 * not using the DAPM to power it up and down as there it makes
498c2ecf20Sopenharmony_ci	 * a click when powering up. */
508c2ecf20Sopenharmony_ci};
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci/**
538c2ecf20Sopenharmony_ci * simtec_hermes_init - initialise and add controls
548c2ecf20Sopenharmony_ci * @codec; The codec instance to attach to.
558c2ecf20Sopenharmony_ci *
568c2ecf20Sopenharmony_ci * Attach our controls and configure the necessary codec
578c2ecf20Sopenharmony_ci * mappings for our sound card instance.
588c2ecf20Sopenharmony_ci*/
598c2ecf20Sopenharmony_cistatic int simtec_hermes_init(struct snd_soc_pcm_runtime *rtd)
608c2ecf20Sopenharmony_ci{
618c2ecf20Sopenharmony_ci	simtec_audio_init(rtd);
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci	return 0;
648c2ecf20Sopenharmony_ci}
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ciSND_SOC_DAILINK_DEFS(tlv320aic33,
678c2ecf20Sopenharmony_ci	DAILINK_COMP_ARRAY(COMP_CPU("s3c24xx-iis")),
688c2ecf20Sopenharmony_ci	DAILINK_COMP_ARRAY(COMP_CODEC("tlv320aic3x-codec.0-001a",
698c2ecf20Sopenharmony_ci				      "tlv320aic3x-hifi")),
708c2ecf20Sopenharmony_ci	DAILINK_COMP_ARRAY(COMP_PLATFORM("s3c24xx-iis")));
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_cistatic struct snd_soc_dai_link simtec_dai_aic33 = {
738c2ecf20Sopenharmony_ci	.name		= "tlv320aic33",
748c2ecf20Sopenharmony_ci	.stream_name	= "TLV320AIC33",
758c2ecf20Sopenharmony_ci	.init		= simtec_hermes_init,
768c2ecf20Sopenharmony_ci	SND_SOC_DAILINK_REG(tlv320aic33),
778c2ecf20Sopenharmony_ci};
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci/* simtec audio machine driver */
808c2ecf20Sopenharmony_cistatic struct snd_soc_card snd_soc_machine_simtec_aic33 = {
818c2ecf20Sopenharmony_ci	.name		= "Simtec-Hermes",
828c2ecf20Sopenharmony_ci	.owner		= THIS_MODULE,
838c2ecf20Sopenharmony_ci	.dai_link	= &simtec_dai_aic33,
848c2ecf20Sopenharmony_ci	.num_links	= 1,
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci	.dapm_widgets	= dapm_widgets,
878c2ecf20Sopenharmony_ci	.num_dapm_widgets = ARRAY_SIZE(dapm_widgets),
888c2ecf20Sopenharmony_ci	.dapm_routes	= base_map,
898c2ecf20Sopenharmony_ci	.num_dapm_routes = ARRAY_SIZE(base_map),
908c2ecf20Sopenharmony_ci};
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_cistatic int simtec_audio_hermes_probe(struct platform_device *pd)
938c2ecf20Sopenharmony_ci{
948c2ecf20Sopenharmony_ci	dev_info(&pd->dev, "probing....\n");
958c2ecf20Sopenharmony_ci	return simtec_audio_core_probe(pd, &snd_soc_machine_simtec_aic33);
968c2ecf20Sopenharmony_ci}
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_cistatic struct platform_driver simtec_audio_hermes_platdrv = {
998c2ecf20Sopenharmony_ci	.driver	= {
1008c2ecf20Sopenharmony_ci		.name	= "s3c24xx-simtec-hermes-snd",
1018c2ecf20Sopenharmony_ci		.pm	= simtec_audio_pm,
1028c2ecf20Sopenharmony_ci	},
1038c2ecf20Sopenharmony_ci	.probe	= simtec_audio_hermes_probe,
1048c2ecf20Sopenharmony_ci	.remove	= simtec_audio_remove,
1058c2ecf20Sopenharmony_ci};
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_cimodule_platform_driver(simtec_audio_hermes_platdrv);
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ciMODULE_ALIAS("platform:s3c24xx-simtec-hermes-snd");
1108c2ecf20Sopenharmony_ciMODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
1118c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("ALSA SoC Simtec Audio support");
1128c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL");
113