xref: /openbmc/linux/sound/soc/sh/sh7760-ac97.c (revision 87506549)
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 #include "../codecs/ac97.h"
19aef3b06aSManuel Lauss 
20aef3b06aSManuel Lauss #define IPSEL 0xFE400034
21aef3b06aSManuel Lauss 
22aef3b06aSManuel Lauss /* platform specific structs can be declared here */
2353640650SLiam Girdwood extern struct snd_soc_dai sh4_hac_dai[2];
24aef3b06aSManuel Lauss extern struct snd_soc_platform sh7760_soc_platform;
25aef3b06aSManuel Lauss 
26aef3b06aSManuel Lauss static int machine_init(struct snd_soc_codec *codec)
27aef3b06aSManuel Lauss {
28a5302181SLiam Girdwood 	snd_soc_dapm_sync(codec);
29aef3b06aSManuel Lauss 	return 0;
30aef3b06aSManuel Lauss }
31aef3b06aSManuel Lauss 
32aef3b06aSManuel Lauss static struct snd_soc_dai_link sh7760_ac97_dai = {
33aef3b06aSManuel Lauss 	.name = "AC97",
34aef3b06aSManuel Lauss 	.stream_name = "AC97 HiFi",
35aef3b06aSManuel Lauss 	.cpu_dai = &sh4_hac_dai[0],	/* HAC0 */
36aef3b06aSManuel Lauss 	.codec_dai = &ac97_dai,
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 snd_soc_device sh7760_ac97_snd_devdata = {
4887506549SMark Brown 	.card = &sh7760_ac97_soc_machine,
49aef3b06aSManuel Lauss 	.platform = &sh7760_soc_platform,
50aef3b06aSManuel Lauss 	.codec_dev = &soc_codec_dev_ac97,
51aef3b06aSManuel Lauss };
52aef3b06aSManuel Lauss 
53aef3b06aSManuel Lauss static struct platform_device *sh7760_ac97_snd_device;
54aef3b06aSManuel Lauss 
55aef3b06aSManuel Lauss static int __init sh7760_ac97_init(void)
56aef3b06aSManuel Lauss {
57aef3b06aSManuel Lauss 	int ret;
58aef3b06aSManuel Lauss 	unsigned short ipsel;
59aef3b06aSManuel Lauss 
60aef3b06aSManuel Lauss 	/* enable both AC97 controllers in pinmux reg */
61aef3b06aSManuel Lauss 	ipsel = ctrl_inw(IPSEL);
62aef3b06aSManuel Lauss 	ctrl_outw(ipsel | (3 << 10), IPSEL);
63aef3b06aSManuel Lauss 
64aef3b06aSManuel Lauss 	ret = -ENOMEM;
65aef3b06aSManuel Lauss 	sh7760_ac97_snd_device = platform_device_alloc("soc-audio", -1);
66aef3b06aSManuel Lauss 	if (!sh7760_ac97_snd_device)
67aef3b06aSManuel Lauss 		goto out;
68aef3b06aSManuel Lauss 
69aef3b06aSManuel Lauss 	platform_set_drvdata(sh7760_ac97_snd_device,
70aef3b06aSManuel Lauss 			     &sh7760_ac97_snd_devdata);
71aef3b06aSManuel Lauss 	sh7760_ac97_snd_devdata.dev = &sh7760_ac97_snd_device->dev;
72aef3b06aSManuel Lauss 	ret = platform_device_add(sh7760_ac97_snd_device);
73aef3b06aSManuel Lauss 
74aef3b06aSManuel Lauss 	if (ret)
75aef3b06aSManuel Lauss 		platform_device_put(sh7760_ac97_snd_device);
76aef3b06aSManuel Lauss 
77aef3b06aSManuel Lauss out:
78aef3b06aSManuel Lauss 	return ret;
79aef3b06aSManuel Lauss }
80aef3b06aSManuel Lauss 
81aef3b06aSManuel Lauss static void __exit sh7760_ac97_exit(void)
82aef3b06aSManuel Lauss {
83aef3b06aSManuel Lauss 	platform_device_unregister(sh7760_ac97_snd_device);
84aef3b06aSManuel Lauss }
85aef3b06aSManuel Lauss 
86aef3b06aSManuel Lauss module_init(sh7760_ac97_init);
87aef3b06aSManuel Lauss module_exit(sh7760_ac97_exit);
88aef3b06aSManuel Lauss 
89aef3b06aSManuel Lauss MODULE_LICENSE("GPL");
90aef3b06aSManuel Lauss MODULE_DESCRIPTION("Generic SH7760 AC97 sound machine");
91aef3b06aSManuel Lauss MODULE_AUTHOR("Manuel Lauss <mano@roarinelk.homelinux.net>");
92