xref: /openbmc/linux/sound/soc/sh/sh7760-ac97.c (revision f0fba2ad)
1aef3b06aSManuel Lauss /*
2aef3b06aSManuel Lauss  * Generic AC97 sound support for SH7760
3aef3b06aSManuel Lauss  *
4aef3b06aSManuel Lauss  * (c) 2007 Manuel Lauss
5aef3b06aSManuel Lauss  *
6aef3b06aSManuel Lauss  * Licensed under the GPLv2.
7aef3b06aSManuel Lauss  */
8aef3b06aSManuel Lauss 
9aef3b06aSManuel Lauss #include <linux/module.h>
10aef3b06aSManuel Lauss #include <linux/moduleparam.h>
11aef3b06aSManuel Lauss #include <linux/platform_device.h>
12aef3b06aSManuel Lauss #include <sound/core.h>
13aef3b06aSManuel Lauss #include <sound/pcm.h>
14aef3b06aSManuel Lauss #include <sound/soc.h>
15aef3b06aSManuel Lauss #include <sound/soc-dapm.h>
16aef3b06aSManuel Lauss #include <asm/io.h>
17aef3b06aSManuel Lauss 
18aef3b06aSManuel Lauss #define IPSEL 0xFE400034
19aef3b06aSManuel Lauss 
20aef3b06aSManuel Lauss /* platform specific structs can be declared here */
21f0fba2adSLiam Girdwood extern struct snd_soc_dai_driver sh4_hac_dai[2];
22f0fba2adSLiam Girdwood extern struct snd_soc_platform_driver sh7760_soc_platform;
23aef3b06aSManuel Lauss 
24f0fba2adSLiam Girdwood static int machine_init(struct snd_soc_pcm_runtime *rtd)
25aef3b06aSManuel Lauss {
26f0fba2adSLiam Girdwood 	snd_soc_dapm_sync(rtd->codec);
27aef3b06aSManuel Lauss 	return 0;
28aef3b06aSManuel Lauss }
29aef3b06aSManuel Lauss 
30aef3b06aSManuel Lauss static struct snd_soc_dai_link sh7760_ac97_dai = {
31aef3b06aSManuel Lauss 	.name = "AC97",
32aef3b06aSManuel Lauss 	.stream_name = "AC97 HiFi",
33f0fba2adSLiam Girdwood 	.cpu_dai_name = "hac-dai.0",	/* HAC0 */
34f0fba2adSLiam Girdwood 	.codec_dai_name = "ac97-hifi",
35f0fba2adSLiam Girdwood 	.platform_name = "sh7760-pcm-audio",
36f0fba2adSLiam Girdwood 	.codec_name = "ac97-codec",
37aef3b06aSManuel Lauss 	.init = machine_init,
38aef3b06aSManuel Lauss 	.ops = NULL,
39aef3b06aSManuel Lauss };
40aef3b06aSManuel Lauss 
4187506549SMark Brown static struct snd_soc_card sh7760_ac97_soc_machine  = {
42aef3b06aSManuel Lauss 	.name = "SH7760 AC97",
43aef3b06aSManuel Lauss 	.dai_link = &sh7760_ac97_dai,
44aef3b06aSManuel Lauss 	.num_links = 1,
45aef3b06aSManuel Lauss };
46aef3b06aSManuel Lauss 
47aef3b06aSManuel Lauss static struct platform_device *sh7760_ac97_snd_device;
48aef3b06aSManuel Lauss 
49aef3b06aSManuel Lauss static int __init sh7760_ac97_init(void)
50aef3b06aSManuel Lauss {
51aef3b06aSManuel Lauss 	int ret;
52aef3b06aSManuel Lauss 	unsigned short ipsel;
53aef3b06aSManuel Lauss 
54aef3b06aSManuel Lauss 	/* enable both AC97 controllers in pinmux reg */
55aef3b06aSManuel Lauss 	ipsel = ctrl_inw(IPSEL);
56aef3b06aSManuel Lauss 	ctrl_outw(ipsel | (3 << 10), IPSEL);
57aef3b06aSManuel Lauss 
58aef3b06aSManuel Lauss 	ret = -ENOMEM;
59aef3b06aSManuel Lauss 	sh7760_ac97_snd_device = platform_device_alloc("soc-audio", -1);
60aef3b06aSManuel Lauss 	if (!sh7760_ac97_snd_device)
61aef3b06aSManuel Lauss 		goto out;
62aef3b06aSManuel Lauss 
63aef3b06aSManuel Lauss 	platform_set_drvdata(sh7760_ac97_snd_device,
64f0fba2adSLiam Girdwood 			     &sh7760_ac97_soc_machine);
65aef3b06aSManuel Lauss 	ret = platform_device_add(sh7760_ac97_snd_device);
66aef3b06aSManuel Lauss 
67aef3b06aSManuel Lauss 	if (ret)
68aef3b06aSManuel Lauss 		platform_device_put(sh7760_ac97_snd_device);
69aef3b06aSManuel Lauss 
70aef3b06aSManuel Lauss out:
71aef3b06aSManuel Lauss 	return ret;
72aef3b06aSManuel Lauss }
73aef3b06aSManuel Lauss 
74aef3b06aSManuel Lauss static void __exit sh7760_ac97_exit(void)
75aef3b06aSManuel Lauss {
76aef3b06aSManuel Lauss 	platform_device_unregister(sh7760_ac97_snd_device);
77aef3b06aSManuel Lauss }
78aef3b06aSManuel Lauss 
79aef3b06aSManuel Lauss module_init(sh7760_ac97_init);
80aef3b06aSManuel Lauss module_exit(sh7760_ac97_exit);
81aef3b06aSManuel Lauss 
82aef3b06aSManuel Lauss MODULE_LICENSE("GPL");
83aef3b06aSManuel Lauss MODULE_DESCRIPTION("Generic SH7760 AC97 sound machine");
84aef3b06aSManuel Lauss MODULE_AUTHOR("Manuel Lauss <mano@roarinelk.homelinux.net>");
85