Manuel Lauss | aef3b06 | 2007-05-14 18:40:07 +0200 | [diff] [blame] | 1 | /* |
| 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 Lauss | aef3b06 | 2007-05-14 18:40:07 +0200 | [diff] [blame] | 12 | #include <sound/core.h> |
| 13 | #include <sound/pcm.h> |
| 14 | #include <sound/soc.h> |
Manuel Lauss | aef3b06 | 2007-05-14 18:40:07 +0200 | [diff] [blame] | 15 | #include <asm/io.h> |
| 16 | |
Manuel Lauss | aef3b06 | 2007-05-14 18:40:07 +0200 | [diff] [blame] | 17 | #define IPSEL 0xFE400034 |
| 18 | |
| 19 | /* platform specific structs can be declared here */ |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 20 | extern struct snd_soc_dai_driver sh4_hac_dai[2]; |
| 21 | extern struct snd_soc_platform_driver sh7760_soc_platform; |
Manuel Lauss | aef3b06 | 2007-05-14 18:40:07 +0200 | [diff] [blame] | 22 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 23 | static int machine_init(struct snd_soc_pcm_runtime *rtd) |
Manuel Lauss | aef3b06 | 2007-05-14 18:40:07 +0200 | [diff] [blame] | 24 | { |
Liam Girdwood | ce6120c | 2010-11-05 15:53:46 +0200 | [diff] [blame] | 25 | snd_soc_dapm_sync(&rtd->codec->dapm); |
Manuel Lauss | aef3b06 | 2007-05-14 18:40:07 +0200 | [diff] [blame] | 26 | return 0; |
| 27 | } |
| 28 | |
| 29 | static struct snd_soc_dai_link sh7760_ac97_dai = { |
| 30 | .name = "AC97", |
| 31 | .stream_name = "AC97 HiFi", |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 32 | .cpu_dai_name = "hac-dai.0", /* HAC0 */ |
| 33 | .codec_dai_name = "ac97-hifi", |
| 34 | .platform_name = "sh7760-pcm-audio", |
| 35 | .codec_name = "ac97-codec", |
Manuel Lauss | aef3b06 | 2007-05-14 18:40:07 +0200 | [diff] [blame] | 36 | .init = machine_init, |
| 37 | .ops = NULL, |
| 38 | }; |
| 39 | |
Mark Brown | 8750654 | 2008-11-18 20:50:34 +0000 | [diff] [blame] | 40 | static struct snd_soc_card sh7760_ac97_soc_machine = { |
Manuel Lauss | aef3b06 | 2007-05-14 18:40:07 +0200 | [diff] [blame] | 41 | .name = "SH7760 AC97", |
| 42 | .dai_link = &sh7760_ac97_dai, |
| 43 | .num_links = 1, |
| 44 | }; |
| 45 | |
Manuel Lauss | aef3b06 | 2007-05-14 18:40:07 +0200 | [diff] [blame] | 46 | static struct platform_device *sh7760_ac97_snd_device; |
| 47 | |
| 48 | static int __init sh7760_ac97_init(void) |
| 49 | { |
| 50 | int ret; |
| 51 | unsigned short ipsel; |
| 52 | |
| 53 | /* enable both AC97 controllers in pinmux reg */ |
Paul Mundt | 48ccb2c | 2010-10-27 15:53:50 +0900 | [diff] [blame] | 54 | ipsel = __raw_readw(IPSEL); |
| 55 | __raw_writew(ipsel | (3 << 10), IPSEL); |
Manuel Lauss | aef3b06 | 2007-05-14 18:40:07 +0200 | [diff] [blame] | 56 | |
| 57 | ret = -ENOMEM; |
| 58 | sh7760_ac97_snd_device = platform_device_alloc("soc-audio", -1); |
| 59 | if (!sh7760_ac97_snd_device) |
| 60 | goto out; |
| 61 | |
| 62 | platform_set_drvdata(sh7760_ac97_snd_device, |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 63 | &sh7760_ac97_soc_machine); |
Manuel Lauss | aef3b06 | 2007-05-14 18:40:07 +0200 | [diff] [blame] | 64 | ret = platform_device_add(sh7760_ac97_snd_device); |
| 65 | |
| 66 | if (ret) |
| 67 | platform_device_put(sh7760_ac97_snd_device); |
| 68 | |
| 69 | out: |
| 70 | return ret; |
| 71 | } |
| 72 | |
| 73 | static void __exit sh7760_ac97_exit(void) |
| 74 | { |
| 75 | platform_device_unregister(sh7760_ac97_snd_device); |
| 76 | } |
| 77 | |
| 78 | module_init(sh7760_ac97_init); |
| 79 | module_exit(sh7760_ac97_exit); |
| 80 | |
| 81 | MODULE_LICENSE("GPL"); |
| 82 | MODULE_DESCRIPTION("Generic SH7760 AC97 sound machine"); |
| 83 | MODULE_AUTHOR("Manuel Lauss <mano@roarinelk.homelinux.net>"); |