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