xref: /openbmc/linux/sound/soc/sh/sh7760-ac97.c (revision 1802d0be)
1 // SPDX-License-Identifier: GPL-2.0
2 //
3 // Generic AC97 sound support for SH7760
4 //
5 // (c) 2007 Manuel Lauss
6 
7 #include <linux/module.h>
8 #include <linux/moduleparam.h>
9 #include <linux/platform_device.h>
10 #include <sound/core.h>
11 #include <sound/pcm.h>
12 #include <sound/soc.h>
13 #include <asm/io.h>
14 
15 #define IPSEL 0xFE400034
16 
17 static struct snd_soc_dai_link sh7760_ac97_dai = {
18 	.name = "AC97",
19 	.stream_name = "AC97 HiFi",
20 	.cpu_dai_name = "hac-dai.0",	/* HAC0 */
21 	.codec_dai_name = "ac97-hifi",
22 	.platform_name = "sh7760-pcm-audio",
23 	.codec_name = "ac97-codec",
24 	.ops = NULL,
25 };
26 
27 static struct snd_soc_card sh7760_ac97_soc_machine  = {
28 	.name = "SH7760 AC97",
29 	.owner = THIS_MODULE,
30 	.dai_link = &sh7760_ac97_dai,
31 	.num_links = 1,
32 };
33 
34 static struct platform_device *sh7760_ac97_snd_device;
35 
36 static int __init sh7760_ac97_init(void)
37 {
38 	int ret;
39 	unsigned short ipsel;
40 
41 	/* enable both AC97 controllers in pinmux reg */
42 	ipsel = __raw_readw(IPSEL);
43 	__raw_writew(ipsel | (3 << 10), IPSEL);
44 
45 	ret = -ENOMEM;
46 	sh7760_ac97_snd_device = platform_device_alloc("soc-audio", -1);
47 	if (!sh7760_ac97_snd_device)
48 		goto out;
49 
50 	platform_set_drvdata(sh7760_ac97_snd_device,
51 			     &sh7760_ac97_soc_machine);
52 	ret = platform_device_add(sh7760_ac97_snd_device);
53 
54 	if (ret)
55 		platform_device_put(sh7760_ac97_snd_device);
56 
57 out:
58 	return ret;
59 }
60 
61 static void __exit sh7760_ac97_exit(void)
62 {
63 	platform_device_unregister(sh7760_ac97_snd_device);
64 }
65 
66 module_init(sh7760_ac97_init);
67 module_exit(sh7760_ac97_exit);
68 
69 MODULE_LICENSE("GPL v2");
70 MODULE_DESCRIPTION("Generic SH7760 AC97 sound machine");
71 MODULE_AUTHOR("Manuel Lauss <mano@roarinelk.homelinux.net>");
72