pandora: defconfig: update
[pandora-kernel.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/core.h>
13 #include <sound/pcm.h>
14 #include <sound/soc.h>
15 #include <asm/io.h>
16
17 #define IPSEL 0xFE400034
18
19 /* platform specific structs can be declared here */
20 extern struct snd_soc_dai_driver sh4_hac_dai[2];
21 extern struct snd_soc_platform_driver sh7760_soc_platform;
22
23 static struct snd_soc_dai_link sh7760_ac97_dai = {
24         .name = "AC97",
25         .stream_name = "AC97 HiFi",
26         .cpu_dai_name = "hac-dai.0",    /* HAC0 */
27         .codec_dai_name = "ac97-hifi",
28         .platform_name = "sh7760-pcm-audio",
29         .codec_name = "ac97-codec",
30         .ops = NULL,
31 };
32
33 static struct snd_soc_card sh7760_ac97_soc_machine  = {
34         .name = "SH7760 AC97",
35         .dai_link = &sh7760_ac97_dai,
36         .num_links = 1,
37 };
38
39 static struct platform_device *sh7760_ac97_snd_device;
40
41 static int __init sh7760_ac97_init(void)
42 {
43         int ret;
44         unsigned short ipsel;
45
46         /* enable both AC97 controllers in pinmux reg */
47         ipsel = __raw_readw(IPSEL);
48         __raw_writew(ipsel | (3 << 10), IPSEL);
49
50         ret = -ENOMEM;
51         sh7760_ac97_snd_device = platform_device_alloc("soc-audio", -1);
52         if (!sh7760_ac97_snd_device)
53                 goto out;
54
55         platform_set_drvdata(sh7760_ac97_snd_device,
56                              &sh7760_ac97_soc_machine);
57         ret = platform_device_add(sh7760_ac97_snd_device);
58
59         if (ret)
60                 platform_device_put(sh7760_ac97_snd_device);
61
62 out:
63         return ret;
64 }
65
66 static void __exit sh7760_ac97_exit(void)
67 {
68         platform_device_unregister(sh7760_ac97_snd_device);
69 }
70
71 module_init(sh7760_ac97_init);
72 module_exit(sh7760_ac97_exit);
73
74 MODULE_LICENSE("GPL");
75 MODULE_DESCRIPTION("Generic SH7760 AC97 sound machine");
76 MODULE_AUTHOR("Manuel Lauss <mano@roarinelk.homelinux.net>");