blob: 4a3568a9bf59015cc2e1692edd29ee77d8291c2a [file] [log] [blame]
Manuel Laussaef3b062007-05-14 18:40:07 +02001/*
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>
Manuel Laussaef3b062007-05-14 18:40:07 +020012#include <sound/core.h>
13#include <sound/pcm.h>
14#include <sound/soc.h>
Manuel Laussaef3b062007-05-14 18:40:07 +020015#include <asm/io.h>
16
Manuel Laussaef3b062007-05-14 18:40:07 +020017#define IPSEL 0xFE400034
18
Manuel Laussaef3b062007-05-14 18:40:07 +020019static struct snd_soc_dai_link sh7760_ac97_dai = {
20 .name = "AC97",
21 .stream_name = "AC97 HiFi",
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000022 .cpu_dai_name = "hac-dai.0", /* HAC0 */
23 .codec_dai_name = "ac97-hifi",
24 .platform_name = "sh7760-pcm-audio",
25 .codec_name = "ac97-codec",
Manuel Laussaef3b062007-05-14 18:40:07 +020026 .ops = NULL,
27};
28
Mark Brown87506542008-11-18 20:50:34 +000029static struct snd_soc_card sh7760_ac97_soc_machine = {
Manuel Laussaef3b062007-05-14 18:40:07 +020030 .name = "SH7760 AC97",
Axel Lin4a7042e2011-12-23 14:53:32 +080031 .owner = THIS_MODULE,
Manuel Laussaef3b062007-05-14 18:40:07 +020032 .dai_link = &sh7760_ac97_dai,
33 .num_links = 1,
34};
35
Manuel Laussaef3b062007-05-14 18:40:07 +020036static struct platform_device *sh7760_ac97_snd_device;
37
38static int __init sh7760_ac97_init(void)
39{
40 int ret;
41 unsigned short ipsel;
42
43 /* enable both AC97 controllers in pinmux reg */
Paul Mundt48ccb2c2010-10-27 15:53:50 +090044 ipsel = __raw_readw(IPSEL);
45 __raw_writew(ipsel | (3 << 10), IPSEL);
Manuel Laussaef3b062007-05-14 18:40:07 +020046
47 ret = -ENOMEM;
48 sh7760_ac97_snd_device = platform_device_alloc("soc-audio", -1);
49 if (!sh7760_ac97_snd_device)
50 goto out;
51
52 platform_set_drvdata(sh7760_ac97_snd_device,
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000053 &sh7760_ac97_soc_machine);
Manuel Laussaef3b062007-05-14 18:40:07 +020054 ret = platform_device_add(sh7760_ac97_snd_device);
55
56 if (ret)
57 platform_device_put(sh7760_ac97_snd_device);
58
59out:
60 return ret;
61}
62
63static void __exit sh7760_ac97_exit(void)
64{
65 platform_device_unregister(sh7760_ac97_snd_device);
66}
67
68module_init(sh7760_ac97_init);
69module_exit(sh7760_ac97_exit);
70
71MODULE_LICENSE("GPL");
72MODULE_DESCRIPTION("Generic SH7760 AC97 sound machine");
73MODULE_AUTHOR("Manuel Lauss <mano@roarinelk.homelinux.net>");