Merge tag 'pm+acpi-3.16-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafae...
[firefly-linux-kernel-4.4.55.git] / sound / soc / kirkwood / kirkwood-t5325.c
1 /*
2  * kirkwood-t5325.c
3  *
4  * (c) 2010 Arnaud Patard <arnaud.patard@rtp-net.org>
5  *
6  *  This program is free software; you can redistribute  it and/or modify it
7  *  under  the terms of  the GNU General  Public License as published by the
8  *  Free Software Foundation;  either version 2 of the  License, or (at your
9  *  option) any later version.
10  */
11
12 #include <linux/module.h>
13 #include <linux/moduleparam.h>
14 #include <linux/interrupt.h>
15 #include <linux/platform_device.h>
16 #include <linux/slab.h>
17 #include <sound/soc.h>
18 #include <linux/platform_data/asoc-kirkwood.h>
19 #include "../codecs/alc5623.h"
20
21 static int t5325_hw_params(struct snd_pcm_substream *substream,
22                 struct snd_pcm_hw_params *params)
23 {
24         struct snd_soc_pcm_runtime *rtd = substream->private_data;
25         struct snd_soc_dai *codec_dai = rtd->codec_dai;
26         unsigned int freq;
27
28         freq = params_rate(params) * 256;
29
30         return snd_soc_dai_set_sysclk(codec_dai, 0, freq, SND_SOC_CLOCK_IN);
31
32 }
33
34 static struct snd_soc_ops t5325_ops = {
35         .hw_params = t5325_hw_params,
36 };
37
38 static const struct snd_soc_dapm_widget t5325_dapm_widgets[] = {
39         SND_SOC_DAPM_HP("Headphone Jack", NULL),
40         SND_SOC_DAPM_SPK("Speaker", NULL),
41         SND_SOC_DAPM_MIC("Mic Jack", NULL),
42 };
43
44 static const struct snd_soc_dapm_route t5325_route[] = {
45         { "Headphone Jack",     NULL,   "HPL" },
46         { "Headphone Jack",     NULL,   "HPR" },
47
48         {"Speaker",             NULL,   "SPKOUT"},
49         {"Speaker",             NULL,   "SPKOUTN"},
50
51         { "MIC1",               NULL,   "Mic Jack" },
52         { "MIC2",               NULL,   "Mic Jack" },
53 };
54
55 static struct snd_soc_dai_link t5325_dai[] = {
56 {
57         .name = "ALC5621",
58         .stream_name = "ALC5621 HiFi",
59         .cpu_dai_name = "i2s",
60         .platform_name = "mvebu-audio",
61         .codec_dai_name = "alc5621-hifi",
62         .codec_name = "alc562x-codec.0-001a",
63         .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS,
64         .ops = &t5325_ops,
65 },
66 };
67
68 static struct snd_soc_card t5325 = {
69         .name = "t5325",
70         .owner = THIS_MODULE,
71         .dai_link = t5325_dai,
72         .num_links = ARRAY_SIZE(t5325_dai),
73
74         .dapm_widgets = t5325_dapm_widgets,
75         .num_dapm_widgets = ARRAY_SIZE(t5325_dapm_widgets),
76         .dapm_routes = t5325_route,
77         .num_dapm_routes = ARRAY_SIZE(t5325_route),
78 };
79
80 static int t5325_probe(struct platform_device *pdev)
81 {
82         struct snd_soc_card *card = &t5325;
83         int ret;
84
85         card->dev = &pdev->dev;
86
87         ret = snd_soc_register_card(card);
88         if (ret)
89                 dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
90                         ret);
91         return ret;
92 }
93
94 static int t5325_remove(struct platform_device *pdev)
95 {
96         struct snd_soc_card *card = platform_get_drvdata(pdev);
97
98         snd_soc_unregister_card(card);
99         return 0;
100 }
101
102 static struct platform_driver t5325_driver = {
103         .driver         = {
104                 .name   = "t5325-audio",
105                 .owner  = THIS_MODULE,
106         },
107         .probe          = t5325_probe,
108         .remove         = t5325_remove,
109 };
110
111 module_platform_driver(t5325_driver);
112
113 MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>");
114 MODULE_DESCRIPTION("ALSA SoC t5325 audio client");
115 MODULE_LICENSE("GPL");
116 MODULE_ALIAS("platform:t5325-audio");