Kuninori Morimoto | 03849405 | 2009-12-14 13:22:00 +0900 | [diff] [blame] | 1 | /* |
| 2 | * fsi-da7210.c |
| 3 | * |
| 4 | * Copyright (C) 2009 Renesas Solutions Corp. |
| 5 | * Kuninori Morimoto <morimoto.kuninori@renesas.com> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify it |
| 8 | * under the terms of the GNU General Public License as published by the |
| 9 | * Free Software Foundation; either version 2 of the License, or (at your |
| 10 | * option) any later version. |
| 11 | */ |
| 12 | |
Kuninori Morimoto | 03849405 | 2009-12-14 13:22:00 +0900 | [diff] [blame] | 13 | #include <linux/platform_device.h> |
Paul Gortmaker | da155d5 | 2011-07-15 12:38:28 -0400 | [diff] [blame] | 14 | #include <linux/module.h> |
Kuninori Morimoto | 03849405 | 2009-12-14 13:22:00 +0900 | [diff] [blame] | 15 | #include <sound/sh_fsi.h> |
Kuninori Morimoto | 03849405 | 2009-12-14 13:22:00 +0900 | [diff] [blame] | 16 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 17 | static int fsi_da7210_init(struct snd_soc_pcm_runtime *rtd) |
Kuninori Morimoto | 03849405 | 2009-12-14 13:22:00 +0900 | [diff] [blame] | 18 | { |
Kuninori Morimoto | 4d805f7 | 2011-01-20 11:46:02 +0900 | [diff] [blame] | 19 | struct snd_soc_dai *codec = rtd->codec_dai; |
| 20 | struct snd_soc_dai *cpu = rtd->cpu_dai; |
| 21 | int ret; |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 22 | |
Kuninori Morimoto | 4d805f7 | 2011-01-20 11:46:02 +0900 | [diff] [blame] | 23 | ret = snd_soc_dai_set_fmt(codec, |
Kuninori Morimoto | e9d3f95 | 2010-12-28 14:55:45 +0900 | [diff] [blame] | 24 | SND_SOC_DAIFMT_I2S | |
Kuninori Morimoto | 03849405 | 2009-12-14 13:22:00 +0900 | [diff] [blame] | 25 | SND_SOC_DAIFMT_CBM_CFM); |
Kuninori Morimoto | 4d805f7 | 2011-01-20 11:46:02 +0900 | [diff] [blame] | 26 | if (ret < 0) |
| 27 | return ret; |
| 28 | |
Kuninori Morimoto | f17c13c | 2011-01-24 10:43:19 +0900 | [diff] [blame] | 29 | ret = snd_soc_dai_set_fmt(cpu, SND_SOC_DAIFMT_I2S | |
| 30 | SND_SOC_DAIFMT_CBS_CFS); |
Kuninori Morimoto | 4d805f7 | 2011-01-20 11:46:02 +0900 | [diff] [blame] | 31 | |
| 32 | return ret; |
Kuninori Morimoto | 03849405 | 2009-12-14 13:22:00 +0900 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | static struct snd_soc_dai_link fsi_da7210_dai = { |
| 36 | .name = "DA7210", |
| 37 | .stream_name = "DA7210", |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 38 | .cpu_dai_name = "fsib-dai", /* FSI B */ |
| 39 | .codec_dai_name = "da7210-hifi", |
Kuninori Morimoto | 2c28032 | 2010-08-30 20:47:19 +0900 | [diff] [blame] | 40 | .platform_name = "sh_fsi.0", |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 41 | .codec_name = "da7210-codec.0-001a", |
Kuninori Morimoto | 03849405 | 2009-12-14 13:22:00 +0900 | [diff] [blame] | 42 | .init = fsi_da7210_init, |
| 43 | }; |
| 44 | |
| 45 | static struct snd_soc_card fsi_soc_card = { |
Kuninori Morimoto | f15c941 | 2011-07-05 00:16:03 -0700 | [diff] [blame] | 46 | .name = "FSI-DA7210", |
Kuninori Morimoto | 03849405 | 2009-12-14 13:22:00 +0900 | [diff] [blame] | 47 | .dai_link = &fsi_da7210_dai, |
| 48 | .num_links = 1, |
| 49 | }; |
| 50 | |
Kuninori Morimoto | 03849405 | 2009-12-14 13:22:00 +0900 | [diff] [blame] | 51 | static struct platform_device *fsi_da7210_snd_device; |
| 52 | |
| 53 | static int __init fsi_da7210_sound_init(void) |
| 54 | { |
| 55 | int ret; |
| 56 | |
Kuninori Morimoto | 3c2ef84 | 2010-07-16 19:51:06 +0900 | [diff] [blame] | 57 | fsi_da7210_snd_device = platform_device_alloc("soc-audio", FSI_PORT_B); |
Kuninori Morimoto | 03849405 | 2009-12-14 13:22:00 +0900 | [diff] [blame] | 58 | if (!fsi_da7210_snd_device) |
| 59 | return -ENOMEM; |
| 60 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 61 | platform_set_drvdata(fsi_da7210_snd_device, &fsi_soc_card); |
Kuninori Morimoto | 03849405 | 2009-12-14 13:22:00 +0900 | [diff] [blame] | 62 | ret = platform_device_add(fsi_da7210_snd_device); |
| 63 | if (ret) |
| 64 | platform_device_put(fsi_da7210_snd_device); |
| 65 | |
| 66 | return ret; |
| 67 | } |
| 68 | |
| 69 | static void __exit fsi_da7210_sound_exit(void) |
| 70 | { |
| 71 | platform_device_unregister(fsi_da7210_snd_device); |
| 72 | } |
| 73 | |
| 74 | module_init(fsi_da7210_sound_init); |
| 75 | module_exit(fsi_da7210_sound_exit); |
| 76 | |
| 77 | /* Module information */ |
| 78 | MODULE_DESCRIPTION("ALSA SoC FSI DA2710"); |
| 79 | MODULE_AUTHOR("Kuninori Morimoto <morimoto.kuninori@renesas.com>"); |
| 80 | MODULE_LICENSE("GPL"); |