Mark Brown | 22313ea | 2010-02-10 10:42:33 +0000 | [diff] [blame] | 1 | /* |
| 2 | * phycore-ac97.c -- SoC audio for imx_phycore in AC97 mode |
| 3 | * |
| 4 | * Copyright 2009 Sascha Hauer, Pengutronix <s.hauer@pengutronix.de> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License as published by the |
| 8 | * Free Software Foundation; either version 2 of the License, or (at your |
| 9 | * option) any later version. |
| 10 | * |
| 11 | */ |
| 12 | |
| 13 | #include <linux/module.h> |
| 14 | #include <linux/moduleparam.h> |
| 15 | #include <linux/device.h> |
| 16 | #include <linux/i2c.h> |
| 17 | #include <sound/core.h> |
| 18 | #include <sound/pcm.h> |
| 19 | #include <sound/soc.h> |
Mark Brown | 22313ea | 2010-02-10 10:42:33 +0000 | [diff] [blame] | 20 | #include <asm/mach-types.h> |
| 21 | |
Mark Brown | 22313ea | 2010-02-10 10:42:33 +0000 | [diff] [blame] | 22 | static struct snd_soc_card imx_phycore; |
| 23 | |
| 24 | static struct snd_soc_ops imx_phycore_hifi_ops = { |
| 25 | }; |
| 26 | |
| 27 | static struct snd_soc_dai_link imx_phycore_dai_ac97[] = { |
| 28 | { |
| 29 | .name = "HiFi", |
| 30 | .stream_name = "HiFi", |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 31 | .codec_dai_name = "wm9712-hifi", |
| 32 | .codec_name = "wm9712-codec", |
Mark Brown | 205d231 | 2010-09-30 13:46:14 -0700 | [diff] [blame] | 33 | .cpu_dai_name = "imx-ssi.0", |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 34 | .platform_name = "imx-fiq-pcm-audio.0", |
Mark Brown | 22313ea | 2010-02-10 10:42:33 +0000 | [diff] [blame] | 35 | .ops = &imx_phycore_hifi_ops, |
| 36 | }, |
| 37 | }; |
| 38 | |
| 39 | static struct snd_soc_card imx_phycore = { |
Sascha Hauer | 6424dca | 2010-11-04 17:05:44 +0100 | [diff] [blame] | 40 | .name = "PhyCORE-ac97-audio", |
Axel Lin | 6aff8cc | 2011-12-23 14:47:08 +0800 | [diff] [blame] | 41 | .owner = THIS_MODULE, |
Mark Brown | 22313ea | 2010-02-10 10:42:33 +0000 | [diff] [blame] | 42 | .dai_link = imx_phycore_dai_ac97, |
| 43 | .num_links = ARRAY_SIZE(imx_phycore_dai_ac97), |
| 44 | }; |
| 45 | |
Axel Lin | 09de953 | 2010-11-25 15:14:03 +0800 | [diff] [blame] | 46 | static struct platform_device *imx_phycore_snd_ac97_device; |
Mark Brown | 22313ea | 2010-02-10 10:42:33 +0000 | [diff] [blame] | 47 | static struct platform_device *imx_phycore_snd_device; |
| 48 | |
| 49 | static int __init imx_phycore_init(void) |
| 50 | { |
| 51 | int ret; |
| 52 | |
| 53 | if (!machine_is_pcm043() && !machine_is_pca100()) |
| 54 | /* return happy. We might run on a totally different machine */ |
| 55 | return 0; |
| 56 | |
Axel Lin | 09de953 | 2010-11-25 15:14:03 +0800 | [diff] [blame] | 57 | imx_phycore_snd_ac97_device = platform_device_alloc("soc-audio", -1); |
| 58 | if (!imx_phycore_snd_ac97_device) |
Mark Brown | 22313ea | 2010-02-10 10:42:33 +0000 | [diff] [blame] | 59 | return -ENOMEM; |
| 60 | |
Axel Lin | 09de953 | 2010-11-25 15:14:03 +0800 | [diff] [blame] | 61 | platform_set_drvdata(imx_phycore_snd_ac97_device, &imx_phycore); |
| 62 | ret = platform_device_add(imx_phycore_snd_ac97_device); |
| 63 | if (ret) |
| 64 | goto fail1; |
Mark Brown | 22313ea | 2010-02-10 10:42:33 +0000 | [diff] [blame] | 65 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 66 | imx_phycore_snd_device = platform_device_alloc("wm9712-codec", -1); |
Axel Lin | 09de953 | 2010-11-25 15:14:03 +0800 | [diff] [blame] | 67 | if (!imx_phycore_snd_device) { |
| 68 | ret = -ENOMEM; |
| 69 | goto fail2; |
| 70 | } |
Mark Brown | 22313ea | 2010-02-10 10:42:33 +0000 | [diff] [blame] | 71 | ret = platform_device_add(imx_phycore_snd_device); |
| 72 | |
| 73 | if (ret) { |
| 74 | printk(KERN_ERR "ASoC: Platform device allocation failed\n"); |
Axel Lin | 09de953 | 2010-11-25 15:14:03 +0800 | [diff] [blame] | 75 | goto fail3; |
Mark Brown | 22313ea | 2010-02-10 10:42:33 +0000 | [diff] [blame] | 76 | } |
| 77 | |
Axel Lin | 09de953 | 2010-11-25 15:14:03 +0800 | [diff] [blame] | 78 | return 0; |
| 79 | |
| 80 | fail3: |
| 81 | platform_device_put(imx_phycore_snd_device); |
| 82 | fail2: |
| 83 | platform_device_del(imx_phycore_snd_ac97_device); |
| 84 | fail1: |
| 85 | platform_device_put(imx_phycore_snd_ac97_device); |
Mark Brown | 22313ea | 2010-02-10 10:42:33 +0000 | [diff] [blame] | 86 | return ret; |
| 87 | } |
| 88 | |
| 89 | static void __exit imx_phycore_exit(void) |
| 90 | { |
| 91 | platform_device_unregister(imx_phycore_snd_device); |
Axel Lin | 09de953 | 2010-11-25 15:14:03 +0800 | [diff] [blame] | 92 | platform_device_unregister(imx_phycore_snd_ac97_device); |
Mark Brown | 22313ea | 2010-02-10 10:42:33 +0000 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | late_initcall(imx_phycore_init); |
| 96 | module_exit(imx_phycore_exit); |
| 97 | |
| 98 | MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>"); |
| 99 | MODULE_DESCRIPTION("PhyCORE ALSA SoC driver"); |
| 100 | MODULE_LICENSE("GPL"); |