blob: 98089df08df62e6c738f95b08c204be10970598e [file] [log] [blame]
Ryan Mallon315f7da2010-06-08 22:01:12 +12001/*
2 * snappercl15.c -- SoC audio for Bluewater Systems Snapper CL15 module
3 *
4 * Copyright (C) 2008 Bluewater Systems Ltd
Ryan Mallon1c5454e2011-06-15 14:45:36 +10005 * Author: Ryan Mallon
Ryan Mallon315f7da2010-06-08 22:01:12 +12006 *
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>
Paul Gortmakerda155d52011-07-15 12:38:28 -040015#include <linux/module.h>
Ryan Mallon315f7da2010-06-08 22:01:12 +120016#include <sound/core.h>
17#include <sound/pcm.h>
18#include <sound/soc.h>
Ryan Mallon315f7da2010-06-08 22:01:12 +120019
20#include <asm/mach-types.h>
21#include <mach/hardware.h>
22
23#include "../codecs/tlv320aic23.h"
Ryan Mallon315f7da2010-06-08 22:01:12 +120024
25#define CODEC_CLOCK 5644800
26
27static 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;
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000031 struct snd_soc_dai *codec_dai = rtd->codec_dai;
32 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
Ryan Mallon315f7da2010-06-08 22:01:12 +120033 int err;
34
Ryan Mallon315f7da2010-06-08 22:01:12 +120035 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
48static struct snd_soc_ops snappercl15_ops = {
49 .hw_params = snappercl15_hw_params,
50};
51
52static 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
58static 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
Ryan Mallon315f7da2010-06-08 22:01:12 +120068static struct snd_soc_dai_link snappercl15_dai = {
69 .name = "tlv320aic23",
70 .stream_name = "AIC23",
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000071 .cpu_dai_name = "ep93xx-i2s",
72 .codec_dai_name = "tlv320aic23-hifi",
73 .codec_name = "tlv320aic23-codec.0-001a",
Stephen Warren6f2032a2013-12-10 12:34:45 -070074 .platform_name = "ep93xx-i2s",
Axel Linf49f8512011-12-17 15:41:11 +080075 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_IF |
76 SND_SOC_DAIFMT_CBS_CFS,
Ryan Mallon315f7da2010-06-08 22:01:12 +120077 .ops = &snappercl15_ops,
78};
79
80static struct snd_soc_card snd_soc_snappercl15 = {
81 .name = "Snapper CL15",
Axel Lina76a7022011-12-22 21:21:37 +080082 .owner = THIS_MODULE,
Ryan Mallon315f7da2010-06-08 22:01:12 +120083 .dai_link = &snappercl15_dai,
84 .num_links = 1,
Lars-Peter Clausen7b2655b2014-03-12 15:27:36 +010085
86 .dapm_widgets = tlv320aic23_dapm_widgets,
87 .num_dapm_widgets = ARRAY_SIZE(tlv320aic23_dapm_widgets),
88 .dapm_routes = audio_map,
89 .num_dapm_routes = ARRAY_SIZE(audio_map),
Ryan Mallon315f7da2010-06-08 22:01:12 +120090};
91
Bill Pemberton145e2872012-12-07 09:26:23 -050092static int snappercl15_probe(struct platform_device *pdev)
Ryan Mallon315f7da2010-06-08 22:01:12 +120093{
Mika Westerberg62e4f7d2011-09-11 12:28:52 +030094 struct snd_soc_card *card = &snd_soc_snappercl15;
Ryan Mallon315f7da2010-06-08 22:01:12 +120095 int ret;
96
Ryan Mallon44fb8642012-01-11 14:14:31 +110097 ret = ep93xx_i2s_acquire();
Ryan Mallon315f7da2010-06-08 22:01:12 +120098 if (ret)
99 return ret;
100
Mika Westerberg62e4f7d2011-09-11 12:28:52 +0300101 card->dev = &pdev->dev;
102
103 ret = snd_soc_register_card(card);
104 if (ret) {
105 dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
106 ret);
107 ep93xx_i2s_release();
108 }
Ryan Mallon315f7da2010-06-08 22:01:12 +1200109
110 return ret;
111}
112
Bill Pemberton145e2872012-12-07 09:26:23 -0500113static int snappercl15_remove(struct platform_device *pdev)
Mika Westerberg62e4f7d2011-09-11 12:28:52 +0300114{
115 struct snd_soc_card *card = platform_get_drvdata(pdev);
116
117 snd_soc_unregister_card(card);
118 ep93xx_i2s_release();
119
120 return 0;
121}
122
123static struct platform_driver snappercl15_driver = {
124 .driver = {
125 .name = "snappercl15-audio",
Mika Westerberg62e4f7d2011-09-11 12:28:52 +0300126 },
127 .probe = snappercl15_probe,
Bill Pemberton145e2872012-12-07 09:26:23 -0500128 .remove = snappercl15_remove,
Mika Westerberg62e4f7d2011-09-11 12:28:52 +0300129};
130
Axel Linee18f632011-11-24 12:07:55 +0800131module_platform_driver(snappercl15_driver);
Ryan Mallon315f7da2010-06-08 22:01:12 +1200132
Ryan Mallon1c5454e2011-06-15 14:45:36 +1000133MODULE_AUTHOR("Ryan Mallon");
Ryan Mallon315f7da2010-06-08 22:01:12 +1200134MODULE_DESCRIPTION("ALSA SoC Snapper CL15");
135MODULE_LICENSE("GPL");
Mika Westerberg62e4f7d2011-09-11 12:28:52 +0300136MODULE_ALIAS("platform:snappercl15-audio");