Committer: Michael Beasley <mike@snafu.setup>
[mikesnafu-overlay.git] / sound / soc / sh / sh7760-ac97.c
blob2f91de84c5c762a2896c14230140c90b216d39a9
1 /*
2 * Generic AC97 sound support for SH7760
4 * (c) 2007 Manuel Lauss
6 * Licensed under the GPLv2.
7 */
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 <sound/soc-dapm.h>
16 #include <asm/io.h>
18 #include "../codecs/ac97.h"
20 #define IPSEL 0xFE400034
22 /* platform specific structs can be declared here */
23 extern struct snd_soc_cpu_dai sh4_hac_dai[2];
24 extern struct snd_soc_platform sh7760_soc_platform;
26 static int machine_init(struct snd_soc_codec *codec)
28 snd_soc_dapm_sync_endpoints(codec);
29 return 0;
32 static struct snd_soc_dai_link sh7760_ac97_dai = {
33 .name = "AC97",
34 .stream_name = "AC97 HiFi",
35 .cpu_dai = &sh4_hac_dai[0], /* HAC0 */
36 .codec_dai = &ac97_dai,
37 .init = machine_init,
38 .ops = NULL,
41 static struct snd_soc_machine sh7760_ac97_soc_machine = {
42 .name = "SH7760 AC97",
43 .dai_link = &sh7760_ac97_dai,
44 .num_links = 1,
47 static struct snd_soc_device sh7760_ac97_snd_devdata = {
48 .machine = &sh7760_ac97_soc_machine,
49 .platform = &sh7760_soc_platform,
50 .codec_dev = &soc_codec_dev_ac97,
53 static struct platform_device *sh7760_ac97_snd_device;
55 static int __init sh7760_ac97_init(void)
57 int ret;
58 unsigned short ipsel;
60 /* enable both AC97 controllers in pinmux reg */
61 ipsel = ctrl_inw(IPSEL);
62 ctrl_outw(ipsel | (3 << 10), IPSEL);
64 ret = -ENOMEM;
65 sh7760_ac97_snd_device = platform_device_alloc("soc-audio", -1);
66 if (!sh7760_ac97_snd_device)
67 goto out;
69 platform_set_drvdata(sh7760_ac97_snd_device,
70 &sh7760_ac97_snd_devdata);
71 sh7760_ac97_snd_devdata.dev = &sh7760_ac97_snd_device->dev;
72 ret = platform_device_add(sh7760_ac97_snd_device);
74 if (ret)
75 platform_device_put(sh7760_ac97_snd_device);
77 out:
78 return ret;
81 static void __exit sh7760_ac97_exit(void)
83 platform_device_unregister(sh7760_ac97_snd_device);
86 module_init(sh7760_ac97_init);
87 module_exit(sh7760_ac97_exit);
89 MODULE_LICENSE("GPL");
90 MODULE_DESCRIPTION("Generic SH7760 AC97 sound machine");
91 MODULE_AUTHOR("Manuel Lauss <mano@roarinelk.homelinux.net>");