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; |
Mika Westerberg | 5a0a03c | 2011-09-11 12:28:50 +0300 | [diff] [blame] | 42 | |
| 43 | static int __devinit simone_probe(struct platform_device *pdev) |
| 44 | { |
| 45 | struct snd_soc_card *card = &snd_soc_simone; |
| 46 | int ret; |
| 47 | |
| 48 | simone_snd_ac97_device = platform_device_register_simple("ac97-codec", |
| 49 | -1, NULL, 0); |
| 50 | if (IS_ERR(simone_snd_ac97_device)) |
| 51 | return PTR_ERR(simone_snd_ac97_device); |
| 52 | |
| 53 | card->dev = &pdev->dev; |
| 54 | |
| 55 | ret = snd_soc_register_card(card); |
| 56 | if (ret) { |
| 57 | dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", |
| 58 | ret); |
| 59 | platform_device_unregister(simone_snd_ac97_device); |
| 60 | } |
| 61 | |
| 62 | return ret; |
| 63 | } |
| 64 | |
| 65 | static int __devexit simone_remove(struct platform_device *pdev) |
| 66 | { |
| 67 | struct snd_soc_card *card = platform_get_drvdata(pdev); |
| 68 | |
| 69 | snd_soc_unregister_card(card); |
| 70 | platform_device_unregister(simone_snd_ac97_device); |
| 71 | |
| 72 | return 0; |
| 73 | } |
| 74 | |
| 75 | static struct platform_driver simone_driver = { |
| 76 | .driver = { |
| 77 | .name = "simone-audio", |
| 78 | .owner = THIS_MODULE, |
| 79 | }, |
| 80 | .probe = simone_probe, |
| 81 | .remove = __devexit_p(simone_remove), |
| 82 | }; |
Mika Westerberg | d42a280 | 2010-10-14 17:49:08 +0300 | [diff] [blame] | 83 | |
| 84 | static int __init simone_init(void) |
| 85 | { |
Mika Westerberg | 5a0a03c | 2011-09-11 12:28:50 +0300 | [diff] [blame] | 86 | return platform_driver_register(&simone_driver); |
Mika Westerberg | d42a280 | 2010-10-14 17:49:08 +0300 | [diff] [blame] | 87 | } |
| 88 | module_init(simone_init); |
| 89 | |
| 90 | static void __exit simone_exit(void) |
| 91 | { |
Mika Westerberg | 5a0a03c | 2011-09-11 12:28:50 +0300 | [diff] [blame] | 92 | platform_driver_unregister(&simone_driver); |
Mika Westerberg | d42a280 | 2010-10-14 17:49:08 +0300 | [diff] [blame] | 93 | } |
| 94 | module_exit(simone_exit); |
| 95 | |
| 96 | MODULE_DESCRIPTION("ALSA SoC Simplemachines Sim.One"); |
| 97 | MODULE_AUTHOR("Mika Westerberg <mika.westerberg@iki.fi>"); |
| 98 | MODULE_LICENSE("GPL"); |
Mika Westerberg | 5a0a03c | 2011-09-11 12:28:50 +0300 | [diff] [blame] | 99 | MODULE_ALIAS("platform:simone-audio"); |