Commit | Line | Data |
---|---|---|
315f7da6 RM |
1 | /* |
2 | * snappercl15.c -- SoC audio for Bluewater Systems Snapper CL15 module | |
3 | * | |
4 | * Copyright (C) 2008 Bluewater Systems Ltd | |
1c5454ee | 5 | * Author: Ryan Mallon |
315f7da6 RM |
6 | * |
7 | * This program is free software; you can redistribute it and/or modify it | |
8 | * under the terms of the GNU General Public License as published by the | |
9 | * Free Software Foundation; either version 2 of the License, or (at your | |
10 | * option) any later version. | |
11 | * | |
12 | */ | |
13 | ||
14 | #include <linux/platform_device.h> | |
da155d5b | 15 | #include <linux/module.h> |
315f7da6 RM |
16 | #include <sound/core.h> |
17 | #include <sound/pcm.h> | |
18 | #include <sound/soc.h> | |
315f7da6 RM |
19 | |
20 | #include <asm/mach-types.h> | |
21 | #include <mach/hardware.h> | |
22 | ||
23 | #include "../codecs/tlv320aic23.h" | |
315f7da6 RM |
24 | |
25 | #define CODEC_CLOCK 5644800 | |
26 | ||
27 | static int snappercl15_hw_params(struct snd_pcm_substream *substream, | |
28 | struct snd_pcm_hw_params *params) | |
29 | { | |
30 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | |
f0fba2ad LG |
31 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
32 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | |
315f7da6 RM |
33 | int err; |
34 | ||
315f7da6 RM |
35 | err = snd_soc_dai_set_sysclk(codec_dai, 0, CODEC_CLOCK, |
36 | SND_SOC_CLOCK_IN); | |
37 | if (err) | |
38 | return err; | |
39 | ||
40 | err = snd_soc_dai_set_sysclk(cpu_dai, 0, CODEC_CLOCK, | |
41 | SND_SOC_CLOCK_OUT); | |
42 | if (err) | |
43 | return err; | |
44 | ||
45 | return 0; | |
46 | } | |
47 | ||
48 | static struct snd_soc_ops snappercl15_ops = { | |
49 | .hw_params = snappercl15_hw_params, | |
50 | }; | |
51 | ||
52 | static const struct snd_soc_dapm_widget tlv320aic23_dapm_widgets[] = { | |
53 | SND_SOC_DAPM_HP("Headphone Jack", NULL), | |
54 | SND_SOC_DAPM_LINE("Line In", NULL), | |
55 | SND_SOC_DAPM_MIC("Mic Jack", NULL), | |
56 | }; | |
57 | ||
58 | static const struct snd_soc_dapm_route audio_map[] = { | |
59 | {"Headphone Jack", NULL, "LHPOUT"}, | |
60 | {"Headphone Jack", NULL, "RHPOUT"}, | |
61 | ||
62 | {"LLINEIN", NULL, "Line In"}, | |
63 | {"RLINEIN", NULL, "Line In"}, | |
64 | ||
65 | {"MICIN", NULL, "Mic Jack"}, | |
66 | }; | |
67 | ||
f0fba2ad | 68 | static int snappercl15_tlv320aic23_init(struct snd_soc_pcm_runtime *rtd) |
315f7da6 | 69 | { |
f0fba2ad | 70 | struct snd_soc_codec *codec = rtd->codec; |
ce6120cc | 71 | struct snd_soc_dapm_context *dapm = &codec->dapm; |
f0fba2ad | 72 | |
ce6120cc | 73 | snd_soc_dapm_new_controls(dapm, tlv320aic23_dapm_widgets, |
315f7da6 RM |
74 | ARRAY_SIZE(tlv320aic23_dapm_widgets)); |
75 | ||
ce6120cc | 76 | snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); |
315f7da6 RM |
77 | return 0; |
78 | } | |
79 | ||
80 | static struct snd_soc_dai_link snappercl15_dai = { | |
81 | .name = "tlv320aic23", | |
82 | .stream_name = "AIC23", | |
f0fba2ad LG |
83 | .cpu_dai_name = "ep93xx-i2s", |
84 | .codec_dai_name = "tlv320aic23-hifi", | |
85 | .codec_name = "tlv320aic23-codec.0-001a", | |
6f2032a1 | 86 | .platform_name = "ep93xx-i2s", |
315f7da6 | 87 | .init = snappercl15_tlv320aic23_init, |
f49f8510 AL |
88 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_IF | |
89 | SND_SOC_DAIFMT_CBS_CFS, | |
315f7da6 RM |
90 | .ops = &snappercl15_ops, |
91 | }; | |
92 | ||
93 | static struct snd_soc_card snd_soc_snappercl15 = { | |
94 | .name = "Snapper CL15", | |
a76a7023 | 95 | .owner = THIS_MODULE, |
315f7da6 RM |
96 | .dai_link = &snappercl15_dai, |
97 | .num_links = 1, | |
98 | }; | |
99 | ||
145e2879 | 100 | static int snappercl15_probe(struct platform_device *pdev) |
315f7da6 | 101 | { |
62e4f7d1 | 102 | struct snd_soc_card *card = &snd_soc_snappercl15; |
315f7da6 RM |
103 | int ret; |
104 | ||
44fb864b | 105 | ret = ep93xx_i2s_acquire(); |
315f7da6 RM |
106 | if (ret) |
107 | return ret; | |
108 | ||
62e4f7d1 MW |
109 | card->dev = &pdev->dev; |
110 | ||
111 | ret = snd_soc_register_card(card); | |
112 | if (ret) { | |
113 | dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", | |
114 | ret); | |
115 | ep93xx_i2s_release(); | |
116 | } | |
315f7da6 RM |
117 | |
118 | return ret; | |
119 | } | |
120 | ||
145e2879 | 121 | static int snappercl15_remove(struct platform_device *pdev) |
315f7da6 | 122 | { |
62e4f7d1 MW |
123 | struct snd_soc_card *card = platform_get_drvdata(pdev); |
124 | ||
125 | snd_soc_unregister_card(card); | |
315f7da6 | 126 | ep93xx_i2s_release(); |
62e4f7d1 MW |
127 | |
128 | return 0; | |
129 | } | |
130 | ||
131 | static struct platform_driver snappercl15_driver = { | |
132 | .driver = { | |
133 | .name = "snappercl15-audio", | |
134 | .owner = THIS_MODULE, | |
135 | }, | |
136 | .probe = snappercl15_probe, | |
145e2879 | 137 | .remove = snappercl15_remove, |
62e4f7d1 MW |
138 | }; |
139 | ||
ee18f631 | 140 | module_platform_driver(snappercl15_driver); |
315f7da6 | 141 | |
1c5454ee | 142 | MODULE_AUTHOR("Ryan Mallon"); |
315f7da6 RM |
143 | MODULE_DESCRIPTION("ALSA SoC Snapper CL15"); |
144 | MODULE_LICENSE("GPL"); | |
62e4f7d1 | 145 | MODULE_ALIAS("platform:snappercl15-audio"); |