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 | |
Mika Westerberg | d42a280 | 2010-10-14 17:49:08 +0300 | [diff] [blame] | 24 | static struct snd_soc_dai_link simone_dai = { |
| 25 | .name = "AC97", |
| 26 | .stream_name = "AC97 HiFi", |
| 27 | .cpu_dai_name = "ep93xx-ac97", |
| 28 | .codec_dai_name = "ac97-hifi", |
| 29 | .codec_name = "ac97-codec", |
| 30 | .platform_name = "ep93xx-pcm-audio", |
| 31 | }; |
| 32 | |
| 33 | static struct snd_soc_card snd_soc_simone = { |
| 34 | .name = "Sim.One", |
Axel Lin | a76a702 | 2011-12-22 21:21:37 +0800 | [diff] [blame] | 35 | .owner = THIS_MODULE, |
Mika Westerberg | d42a280 | 2010-10-14 17:49:08 +0300 | [diff] [blame] | 36 | .dai_link = &simone_dai, |
| 37 | .num_links = 1, |
| 38 | }; |
| 39 | |
| 40 | static struct platform_device *simone_snd_ac97_device; |
Mika Westerberg | 5a0a03c | 2011-09-11 12:28:50 +0300 | [diff] [blame] | 41 | |
Bill Pemberton | 145e287 | 2012-12-07 09:26:23 -0500 | [diff] [blame] | 42 | static int simone_probe(struct platform_device *pdev) |
Mika Westerberg | 5a0a03c | 2011-09-11 12:28:50 +0300 | [diff] [blame] | 43 | { |
| 44 | struct snd_soc_card *card = &snd_soc_simone; |
| 45 | int ret; |
| 46 | |
| 47 | simone_snd_ac97_device = platform_device_register_simple("ac97-codec", |
| 48 | -1, NULL, 0); |
| 49 | if (IS_ERR(simone_snd_ac97_device)) |
| 50 | return PTR_ERR(simone_snd_ac97_device); |
| 51 | |
| 52 | card->dev = &pdev->dev; |
| 53 | |
| 54 | ret = snd_soc_register_card(card); |
| 55 | if (ret) { |
| 56 | dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", |
| 57 | ret); |
| 58 | platform_device_unregister(simone_snd_ac97_device); |
| 59 | } |
| 60 | |
| 61 | return ret; |
| 62 | } |
| 63 | |
Bill Pemberton | 145e287 | 2012-12-07 09:26:23 -0500 | [diff] [blame] | 64 | static int simone_remove(struct platform_device *pdev) |
Mika Westerberg | 5a0a03c | 2011-09-11 12:28:50 +0300 | [diff] [blame] | 65 | { |
| 66 | struct snd_soc_card *card = platform_get_drvdata(pdev); |
| 67 | |
| 68 | snd_soc_unregister_card(card); |
| 69 | platform_device_unregister(simone_snd_ac97_device); |
| 70 | |
| 71 | return 0; |
| 72 | } |
| 73 | |
| 74 | static struct platform_driver simone_driver = { |
| 75 | .driver = { |
| 76 | .name = "simone-audio", |
| 77 | .owner = THIS_MODULE, |
| 78 | }, |
| 79 | .probe = simone_probe, |
Bill Pemberton | 145e287 | 2012-12-07 09:26:23 -0500 | [diff] [blame] | 80 | .remove = simone_remove, |
Mika Westerberg | 5a0a03c | 2011-09-11 12:28:50 +0300 | [diff] [blame] | 81 | }; |
Mika Westerberg | d42a280 | 2010-10-14 17:49:08 +0300 | [diff] [blame] | 82 | |
Axel Lin | ee18f63 | 2011-11-24 12:07:55 +0800 | [diff] [blame] | 83 | module_platform_driver(simone_driver); |
Mika Westerberg | d42a280 | 2010-10-14 17:49:08 +0300 | [diff] [blame] | 84 | |
| 85 | MODULE_DESCRIPTION("ALSA SoC Simplemachines Sim.One"); |
| 86 | MODULE_AUTHOR("Mika Westerberg <mika.westerberg@iki.fi>"); |
| 87 | MODULE_LICENSE("GPL"); |
Mika Westerberg | 5a0a03c | 2011-09-11 12:28:50 +0300 | [diff] [blame] | 88 | MODULE_ALIAS("platform:simone-audio"); |