1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * snappercl15.c -- SoC audio for Bluewater Systems Snapper CL15 module
5 * Copyright (C) 2008 Bluewater Systems Ltd
9 #include <linux/platform_device.h>
10 #include <linux/module.h>
11 #include <linux/soc/cirrus/ep93xx.h>
12 #include <sound/core.h>
13 #include <sound/pcm.h>
14 #include <sound/soc.h>
16 #include <asm/mach-types.h>
18 #include "../codecs/tlv320aic23.h"
20 #define CODEC_CLOCK 5644800
22 static int snappercl15_hw_params(struct snd_pcm_substream
*substream
,
23 struct snd_pcm_hw_params
*params
)
25 struct snd_soc_pcm_runtime
*rtd
= substream
->private_data
;
26 struct snd_soc_dai
*codec_dai
= rtd
->codec_dai
;
27 struct snd_soc_dai
*cpu_dai
= rtd
->cpu_dai
;
30 err
= snd_soc_dai_set_sysclk(codec_dai
, 0, CODEC_CLOCK
,
35 err
= snd_soc_dai_set_sysclk(cpu_dai
, 0, CODEC_CLOCK
,
43 static const struct snd_soc_ops snappercl15_ops
= {
44 .hw_params
= snappercl15_hw_params
,
47 static const struct snd_soc_dapm_widget tlv320aic23_dapm_widgets
[] = {
48 SND_SOC_DAPM_HP("Headphone Jack", NULL
),
49 SND_SOC_DAPM_LINE("Line In", NULL
),
50 SND_SOC_DAPM_MIC("Mic Jack", NULL
),
53 static const struct snd_soc_dapm_route audio_map
[] = {
54 {"Headphone Jack", NULL
, "LHPOUT"},
55 {"Headphone Jack", NULL
, "RHPOUT"},
57 {"LLINEIN", NULL
, "Line In"},
58 {"RLINEIN", NULL
, "Line In"},
60 {"MICIN", NULL
, "Mic Jack"},
63 SND_SOC_DAILINK_DEFS(aic23
,
64 DAILINK_COMP_ARRAY(COMP_CPU("ep93xx-i2s")),
65 DAILINK_COMP_ARRAY(COMP_CODEC("tlv320aic23-codec.0-001a",
67 DAILINK_COMP_ARRAY(COMP_PLATFORM("ep93xx-i2s")));
69 static struct snd_soc_dai_link snappercl15_dai
= {
70 .name
= "tlv320aic23",
71 .stream_name
= "AIC23",
72 .dai_fmt
= SND_SOC_DAIFMT_I2S
| SND_SOC_DAIFMT_NB_NF
|
73 SND_SOC_DAIFMT_CBS_CFS
,
74 .ops
= &snappercl15_ops
,
75 SND_SOC_DAILINK_REG(aic23
),
78 static struct snd_soc_card snd_soc_snappercl15
= {
79 .name
= "Snapper CL15",
81 .dai_link
= &snappercl15_dai
,
84 .dapm_widgets
= tlv320aic23_dapm_widgets
,
85 .num_dapm_widgets
= ARRAY_SIZE(tlv320aic23_dapm_widgets
),
86 .dapm_routes
= audio_map
,
87 .num_dapm_routes
= ARRAY_SIZE(audio_map
),
90 static int snappercl15_probe(struct platform_device
*pdev
)
92 struct snd_soc_card
*card
= &snd_soc_snappercl15
;
95 ret
= ep93xx_i2s_acquire();
99 card
->dev
= &pdev
->dev
;
101 ret
= snd_soc_register_card(card
);
103 dev_err(&pdev
->dev
, "snd_soc_register_card() failed: %d\n",
105 ep93xx_i2s_release();
111 static int snappercl15_remove(struct platform_device
*pdev
)
113 struct snd_soc_card
*card
= platform_get_drvdata(pdev
);
115 snd_soc_unregister_card(card
);
116 ep93xx_i2s_release();
121 static struct platform_driver snappercl15_driver
= {
123 .name
= "snappercl15-audio",
125 .probe
= snappercl15_probe
,
126 .remove
= snappercl15_remove
,
129 module_platform_driver(snappercl15_driver
);
131 MODULE_AUTHOR("Ryan Mallon");
132 MODULE_DESCRIPTION("ALSA SoC Snapper CL15");
133 MODULE_LICENSE("GPL");
134 MODULE_ALIAS("platform:snappercl15-audio");