blob: f8e0ab82ef59e188714ba8851048534f0691e10b [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>
15#include <sound/soc-dapm.h>
16#include <asm/io.h>
17
Manuel Laussaef3b062007-05-14 18:40:07 +020018#define IPSEL 0xFE400034
19
20/* platform specific structs can be declared here */
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000021extern struct snd_soc_dai_driver sh4_hac_dai[2];
22extern struct snd_soc_platform_driver sh7760_soc_platform;
Manuel Laussaef3b062007-05-14 18:40:07 +020023
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000024static int machine_init(struct snd_soc_pcm_runtime *rtd)
Manuel Laussaef3b062007-05-14 18:40:07 +020025{
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000026 snd_soc_dapm_sync(rtd->codec);
Manuel Laussaef3b062007-05-14 18:40:07 +020027 return 0;
28}
29
30static struct snd_soc_dai_link sh7760_ac97_dai = {
31 .name = "AC97",
32 .stream_name = "AC97 HiFi",
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000033 .cpu_dai_name = "hac-dai.0", /* HAC0 */
34 .codec_dai_name = "ac97-hifi",
35 .platform_name = "sh7760-pcm-audio",
36 .codec_name = "ac97-codec",
Manuel Laussaef3b062007-05-14 18:40:07 +020037 .init = machine_init,
38 .ops = NULL,
39};
40
Mark Brown87506542008-11-18 20:50:34 +000041static struct snd_soc_card sh7760_ac97_soc_machine = {
Manuel Laussaef3b062007-05-14 18:40:07 +020042 .name = "SH7760 AC97",
43 .dai_link = &sh7760_ac97_dai,
44 .num_links = 1,
45};
46
Manuel Laussaef3b062007-05-14 18:40:07 +020047static struct platform_device *sh7760_ac97_snd_device;
48
49static int __init sh7760_ac97_init(void)
50{
51 int ret;
52 unsigned short ipsel;
53
54 /* enable both AC97 controllers in pinmux reg */
Paul Mundt48ccb2c2010-10-27 15:53:50 +090055 ipsel = __raw_readw(IPSEL);
56 __raw_writew(ipsel | (3 << 10), IPSEL);
Manuel Laussaef3b062007-05-14 18:40:07 +020057
58 ret = -ENOMEM;
59 sh7760_ac97_snd_device = platform_device_alloc("soc-audio", -1);
60 if (!sh7760_ac97_snd_device)
61 goto out;
62
63 platform_set_drvdata(sh7760_ac97_snd_device,
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000064 &sh7760_ac97_soc_machine);
Manuel Laussaef3b062007-05-14 18:40:07 +020065 ret = platform_device_add(sh7760_ac97_snd_device);
66
67 if (ret)
68 platform_device_put(sh7760_ac97_snd_device);
69
70out:
71 return ret;
72}
73
74static void __exit sh7760_ac97_exit(void)
75{
76 platform_device_unregister(sh7760_ac97_snd_device);
77}
78
79module_init(sh7760_ac97_init);
80module_exit(sh7760_ac97_exit);
81
82MODULE_LICENSE("GPL");
83MODULE_DESCRIPTION("Generic SH7760 AC97 sound machine");
84MODULE_AUTHOR("Manuel Lauss <mano@roarinelk.homelinux.net>");