| Mika Westerberg | d42a280 | 2010-10-14 17:49:08 +0300 | [diff] [blame] | 1 | /* | 
|  | 2 | * simone.c -- ASoC audio for Simplemachines Sim.One board | 
|  | 3 | * | 
|  | 4 | * Copyright (c) 2010 Mika Westerberg | 
|  | 5 | * | 
|  | 6 | * Based on snappercl15 machine driver by Ryan Mallon. | 
|  | 7 | * | 
|  | 8 | * This program is free software; you can redistribute it and/or modify | 
|  | 9 | * it under the terms of the GNU General Public License version 2 as | 
|  | 10 | * published by the Free Software Foundation. | 
|  | 11 | */ | 
|  | 12 |  | 
|  | 13 | #include <linux/init.h> | 
|  | 14 | #include <linux/module.h> | 
|  | 15 | #include <linux/platform_device.h> | 
|  | 16 |  | 
|  | 17 | #include <sound/core.h> | 
|  | 18 | #include <sound/pcm.h> | 
|  | 19 | #include <sound/soc.h> | 
|  | 20 |  | 
|  | 21 | #include <asm/mach-types.h> | 
|  | 22 | #include <mach/hardware.h> | 
|  | 23 |  | 
|  | 24 | #include "ep93xx-pcm.h" | 
|  | 25 |  | 
|  | 26 | static struct snd_soc_dai_link simone_dai = { | 
|  | 27 | .name		= "AC97", | 
|  | 28 | .stream_name	= "AC97 HiFi", | 
|  | 29 | .cpu_dai_name	= "ep93xx-ac97", | 
|  | 30 | .codec_dai_name	= "ac97-hifi", | 
|  | 31 | .codec_name	= "ac97-codec", | 
|  | 32 | .platform_name	= "ep93xx-pcm-audio", | 
|  | 33 | }; | 
|  | 34 |  | 
|  | 35 | static struct snd_soc_card snd_soc_simone = { | 
|  | 36 | .name		= "Sim.One", | 
|  | 37 | .dai_link	= &simone_dai, | 
|  | 38 | .num_links	= 1, | 
|  | 39 | }; | 
|  | 40 |  | 
|  | 41 | static struct platform_device *simone_snd_ac97_device; | 
|  | 42 | static struct platform_device *simone_snd_device; | 
|  | 43 |  | 
|  | 44 | static int __init simone_init(void) | 
|  | 45 | { | 
|  | 46 | int ret; | 
|  | 47 |  | 
|  | 48 | if (!machine_is_sim_one()) | 
|  | 49 | return -ENODEV; | 
|  | 50 |  | 
|  | 51 | simone_snd_ac97_device = platform_device_alloc("ac97-codec", -1); | 
|  | 52 | if (!simone_snd_ac97_device) | 
|  | 53 | return -ENOMEM; | 
|  | 54 |  | 
|  | 55 | ret = platform_device_add(simone_snd_ac97_device); | 
|  | 56 | if (ret) | 
| Axel Lin | 14abca3 | 2010-11-25 15:12:30 +0800 | [diff] [blame] | 57 | goto fail1; | 
| Mika Westerberg | d42a280 | 2010-10-14 17:49:08 +0300 | [diff] [blame] | 58 |  | 
|  | 59 | simone_snd_device = platform_device_alloc("soc-audio", -1); | 
|  | 60 | if (!simone_snd_device) { | 
|  | 61 | ret = -ENOMEM; | 
| Axel Lin | 14abca3 | 2010-11-25 15:12:30 +0800 | [diff] [blame] | 62 | goto fail2; | 
| Mika Westerberg | d42a280 | 2010-10-14 17:49:08 +0300 | [diff] [blame] | 63 | } | 
|  | 64 |  | 
|  | 65 | platform_set_drvdata(simone_snd_device, &snd_soc_simone); | 
|  | 66 | ret = platform_device_add(simone_snd_device); | 
| Axel Lin | 14abca3 | 2010-11-25 15:12:30 +0800 | [diff] [blame] | 67 | if (ret) | 
|  | 68 | goto fail3; | 
| Mika Westerberg | d42a280 | 2010-10-14 17:49:08 +0300 | [diff] [blame] | 69 |  | 
| Axel Lin | 14abca3 | 2010-11-25 15:12:30 +0800 | [diff] [blame] | 70 | return 0; | 
| Mika Westerberg | d42a280 | 2010-10-14 17:49:08 +0300 | [diff] [blame] | 71 |  | 
| Axel Lin | 14abca3 | 2010-11-25 15:12:30 +0800 | [diff] [blame] | 72 | fail3: | 
|  | 73 | platform_device_put(simone_snd_device); | 
|  | 74 | fail2: | 
|  | 75 | platform_device_del(simone_snd_ac97_device); | 
|  | 76 | fail1: | 
| Mika Westerberg | d42a280 | 2010-10-14 17:49:08 +0300 | [diff] [blame] | 77 | platform_device_put(simone_snd_ac97_device); | 
|  | 78 | return ret; | 
|  | 79 | } | 
|  | 80 | module_init(simone_init); | 
|  | 81 |  | 
|  | 82 | static void __exit simone_exit(void) | 
|  | 83 | { | 
|  | 84 | platform_device_unregister(simone_snd_device); | 
|  | 85 | platform_device_unregister(simone_snd_ac97_device); | 
|  | 86 | } | 
|  | 87 | module_exit(simone_exit); | 
|  | 88 |  | 
|  | 89 | MODULE_DESCRIPTION("ALSA SoC Simplemachines Sim.One"); | 
|  | 90 | MODULE_AUTHOR("Mika Westerberg <mika.westerberg@iki.fi>"); | 
|  | 91 | MODULE_LICENSE("GPL"); |