]> nv-tegra.nvidia Code Review - linux-2.6.git/blob - sound/soc/sh/sh7760-ac97.c
Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux-2.6
[linux-2.6.git] / sound / soc / sh / sh7760-ac97.c
1 /*
2  * Generic AC97 sound support for SH7760
3  *
4  * (c) 2007 Manuel Lauss
5  *
6  * Licensed under the GPLv2.
7  */
8
9 #include <linux/module.h>
10 #include <linux/moduleparam.h>
11 #include <linux/platform_device.h>
12 #include <sound/driver.h>
13 #include <sound/core.h>
14 #include <sound/pcm.h>
15 #include <sound/soc.h>
16 #include <sound/soc-dapm.h>
17 #include <asm/io.h>
18
19 #include "../codecs/ac97.h"
20
21 #define IPSEL 0xFE400034
22
23 /* platform specific structs can be declared here */
24 extern struct snd_soc_cpu_dai sh4_hac_dai[2];
25 extern struct snd_soc_platform sh7760_soc_platform;
26
27 static int machine_init(struct snd_soc_codec *codec)
28 {
29         snd_soc_dapm_sync_endpoints(codec);
30         return 0;
31 }
32
33 static struct snd_soc_dai_link sh7760_ac97_dai = {
34         .name = "AC97",
35         .stream_name = "AC97 HiFi",
36         .cpu_dai = &sh4_hac_dai[0],     /* HAC0 */
37         .codec_dai = &ac97_dai,
38         .init = machine_init,
39         .ops = NULL,
40 };
41
42 static struct snd_soc_machine sh7760_ac97_soc_machine  = {
43         .name = "SH7760 AC97",
44         .dai_link = &sh7760_ac97_dai,
45         .num_links = 1,
46 };
47
48 static struct snd_soc_device sh7760_ac97_snd_devdata = {
49         .machine = &sh7760_ac97_soc_machine,
50         .platform = &sh7760_soc_platform,
51         .codec_dev = &soc_codec_dev_ac97,
52 };
53
54 static struct platform_device *sh7760_ac97_snd_device;
55
56 static int __init sh7760_ac97_init(void)
57 {
58         int ret;
59         unsigned short ipsel;
60
61         /* enable both AC97 controllers in pinmux reg */
62         ipsel = ctrl_inw(IPSEL);
63         ctrl_outw(ipsel | (3 << 10), IPSEL);
64
65         ret = -ENOMEM;
66         sh7760_ac97_snd_device = platform_device_alloc("soc-audio", -1);
67         if (!sh7760_ac97_snd_device)
68                 goto out;
69
70         platform_set_drvdata(sh7760_ac97_snd_device,
71                              &sh7760_ac97_snd_devdata);
72         sh7760_ac97_snd_devdata.dev = &sh7760_ac97_snd_device->dev;
73         ret = platform_device_add(sh7760_ac97_snd_device);
74
75         if (ret)
76                 platform_device_put(sh7760_ac97_snd_device);
77
78 out:
79         return ret;
80 }
81
82 static void __exit sh7760_ac97_exit(void)
83 {
84         platform_device_unregister(sh7760_ac97_snd_device);
85 }
86
87 module_init(sh7760_ac97_init);
88 module_exit(sh7760_ac97_exit);
89
90 MODULE_LICENSE("GPL");
91 MODULE_DESCRIPTION("Generic SH7760 AC97 sound machine");
92 MODULE_AUTHOR("Manuel Lauss <mano@roarinelk.homelinux.net>");