Commit | Line | Data |
---|---|---|
dce944db BS |
1 | /* |
2 | * File: sound/soc/blackfin/bf5xx-ad1836.c | |
3 | * Author: Barry Song <Barry.Song@analog.com> | |
4 | * | |
5 | * Created: Aug 4 2009 | |
6 | * Description: Board driver for ad1836 sound chip | |
7 | * | |
8 | * Bugs: Enter bugs at http://blackfin.uclinux.org/ | |
9 | * | |
10 | * This program is free software; you can redistribute it and/or modify | |
11 | * it under the terms of the GNU General Public License as published by | |
12 | * the Free Software Foundation; either version 2 of the License, or | |
13 | * (at your option) any later version. | |
14 | * | |
15 | */ | |
16 | ||
17 | #include <linux/module.h> | |
18 | #include <linux/moduleparam.h> | |
19 | #include <linux/device.h> | |
20 | #include <sound/core.h> | |
21 | #include <sound/pcm.h> | |
22 | #include <sound/soc.h> | |
dce944db BS |
23 | #include <sound/pcm_params.h> |
24 | ||
25 | #include <asm/blackfin.h> | |
26 | #include <asm/cacheflush.h> | |
27 | #include <asm/irq.h> | |
28 | #include <asm/dma.h> | |
29 | #include <asm/portmux.h> | |
30 | ||
31 | #include "../codecs/ad1836.h" | |
dce944db | 32 | |
dce944db BS |
33 | #include "bf5xx-tdm.h" |
34 | ||
35 | static struct snd_soc_card bf5xx_ad1836; | |
36 | ||
dce944db BS |
37 | static int bf5xx_ad1836_hw_params(struct snd_pcm_substream *substream, |
38 | struct snd_pcm_hw_params *params) | |
39 | { | |
40 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | |
f0fba2ad | 41 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
08db48f1 | 42 | unsigned int channel_map[] = {0, 4, 1, 5, 2, 6, 3, 7}; |
dce944db | 43 | int ret = 0; |
dce944db | 44 | |
08db48f1 BS |
45 | /* set cpu DAI channel mapping */ |
46 | ret = snd_soc_dai_set_channel_map(cpu_dai, ARRAY_SIZE(channel_map), | |
47 | channel_map, ARRAY_SIZE(channel_map), channel_map); | |
48 | if (ret < 0) | |
49 | return ret; | |
50 | ||
dce944db BS |
51 | return 0; |
52 | } | |
53 | ||
54 | static struct snd_soc_ops bf5xx_ad1836_ops = { | |
dce944db BS |
55 | .hw_params = bf5xx_ad1836_hw_params, |
56 | }; | |
57 | ||
980b0bc6 LPC |
58 | #define BF5XX_AD1836_DAIFMT (SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_IB_IF | \ |
59 | SND_SOC_DAIFMT_CBM_CFM) | |
60 | ||
d14a13d3 SJ |
61 | static struct snd_soc_dai_link bf5xx_ad1836_dai = { |
62 | .name = "ad1836", | |
63 | .stream_name = "AD1836", | |
64 | .codec_dai_name = "ad1836-hifi", | |
65 | .platform_name = "bfin-tdm-pcm-audio", | |
66 | .ops = &bf5xx_ad1836_ops, | |
67 | .dai_fmt = BF5XX_AD1836_DAIFMT, | |
dce944db BS |
68 | }; |
69 | ||
70 | static struct snd_soc_card bf5xx_ad1836 = { | |
bfe4ee0a | 71 | .name = "bfin-ad1836", |
30e49530 | 72 | .owner = THIS_MODULE, |
d14a13d3 | 73 | .dai_link = &bf5xx_ad1836_dai, |
dce944db BS |
74 | .num_links = 1, |
75 | }; | |
76 | ||
dca66dab | 77 | static int bf5xx_ad1836_driver_probe(struct platform_device *pdev) |
dce944db | 78 | { |
d14a13d3 SJ |
79 | struct snd_soc_card *card = &bf5xx_ad1836; |
80 | const char **link_name; | |
dce944db BS |
81 | int ret; |
82 | ||
d14a13d3 SJ |
83 | link_name = pdev->dev.platform_data; |
84 | if (!link_name) { | |
85 | dev_err(&pdev->dev, "No platform data supplied\n"); | |
86 | return -EINVAL; | |
87 | } | |
88 | bf5xx_ad1836_dai.cpu_dai_name = link_name[0]; | |
89 | bf5xx_ad1836_dai.codec_name = link_name[1]; | |
dce944db | 90 | |
d14a13d3 SJ |
91 | card->dev = &pdev->dev; |
92 | platform_set_drvdata(pdev, card); | |
dce944db | 93 | |
d14a13d3 | 94 | ret = snd_soc_register_card(card); |
dce944db | 95 | if (ret) |
d14a13d3 | 96 | dev_err(&pdev->dev, "Failed to register card\n"); |
dce944db BS |
97 | return ret; |
98 | } | |
99 | ||
dca66dab | 100 | static int bf5xx_ad1836_driver_remove(struct platform_device *pdev) |
dce944db | 101 | { |
d14a13d3 SJ |
102 | struct snd_soc_card *card = platform_get_drvdata(pdev); |
103 | ||
104 | snd_soc_unregister_card(card); | |
105 | return 0; | |
dce944db BS |
106 | } |
107 | ||
d14a13d3 SJ |
108 | static struct platform_driver bf5xx_ad1836_driver = { |
109 | .driver = { | |
110 | .name = "bfin-snd-ad1836", | |
111 | .owner = THIS_MODULE, | |
112 | .pm = &snd_soc_pm_ops, | |
113 | }, | |
114 | .probe = bf5xx_ad1836_driver_probe, | |
dca66dab | 115 | .remove = bf5xx_ad1836_driver_remove, |
d14a13d3 SJ |
116 | }; |
117 | module_platform_driver(bf5xx_ad1836_driver); | |
dce944db BS |
118 | |
119 | /* Module information */ | |
120 | MODULE_AUTHOR("Barry Song"); | |
121 | MODULE_DESCRIPTION("ALSA SoC AD1836 board driver"); | |
122 | MODULE_LICENSE("GPL"); | |
123 |