blob: 1dd3354c7411daff1954240dc6e1901f13ff57eb [file] [log] [blame]
Kuninori Morimoto038494052009-12-14 13:22:00 +09001/*
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 Morimoto038494052009-12-14 13:22:00 +090013#include <linux/platform_device.h>
Paul Gortmakerda155d52011-07-15 12:38:28 -040014#include <linux/module.h>
Kuninori Morimoto038494052009-12-14 13:22:00 +090015#include <sound/sh_fsi.h>
Kuninori Morimoto038494052009-12-14 13:22:00 +090016
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000017static int fsi_da7210_init(struct snd_soc_pcm_runtime *rtd)
Kuninori Morimoto038494052009-12-14 13:22:00 +090018{
Kuninori Morimoto4d805f72011-01-20 11:46:02 +090019 struct snd_soc_dai *codec = rtd->codec_dai;
20 struct snd_soc_dai *cpu = rtd->cpu_dai;
21 int ret;
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000022
Kuninori Morimoto4d805f72011-01-20 11:46:02 +090023 ret = snd_soc_dai_set_fmt(codec,
Kuninori Morimotoe9d3f952010-12-28 14:55:45 +090024 SND_SOC_DAIFMT_I2S |
Kuninori Morimoto038494052009-12-14 13:22:00 +090025 SND_SOC_DAIFMT_CBM_CFM);
Kuninori Morimoto4d805f72011-01-20 11:46:02 +090026 if (ret < 0)
27 return ret;
28
Kuninori Morimotof17c13c2011-01-24 10:43:19 +090029 ret = snd_soc_dai_set_fmt(cpu, SND_SOC_DAIFMT_I2S |
30 SND_SOC_DAIFMT_CBS_CFS);
Kuninori Morimoto4d805f72011-01-20 11:46:02 +090031
32 return ret;
Kuninori Morimoto038494052009-12-14 13:22:00 +090033}
34
35static struct snd_soc_dai_link fsi_da7210_dai = {
36 .name = "DA7210",
37 .stream_name = "DA7210",
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000038 .cpu_dai_name = "fsib-dai", /* FSI B */
39 .codec_dai_name = "da7210-hifi",
Kuninori Morimoto2c280322010-08-30 20:47:19 +090040 .platform_name = "sh_fsi.0",
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000041 .codec_name = "da7210-codec.0-001a",
Kuninori Morimoto038494052009-12-14 13:22:00 +090042 .init = fsi_da7210_init,
43};
44
45static struct snd_soc_card fsi_soc_card = {
Kuninori Morimotof15c9412011-07-05 00:16:03 -070046 .name = "FSI-DA7210",
Axel Lin4a7042e2011-12-23 14:53:32 +080047 .owner = THIS_MODULE,
Kuninori Morimoto038494052009-12-14 13:22:00 +090048 .dai_link = &fsi_da7210_dai,
49 .num_links = 1,
50};
51
Kuninori Morimoto038494052009-12-14 13:22:00 +090052static struct platform_device *fsi_da7210_snd_device;
53
54static int __init fsi_da7210_sound_init(void)
55{
56 int ret;
57
Kuninori Morimoto3c2ef842010-07-16 19:51:06 +090058 fsi_da7210_snd_device = platform_device_alloc("soc-audio", FSI_PORT_B);
Kuninori Morimoto038494052009-12-14 13:22:00 +090059 if (!fsi_da7210_snd_device)
60 return -ENOMEM;
61
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000062 platform_set_drvdata(fsi_da7210_snd_device, &fsi_soc_card);
Kuninori Morimoto038494052009-12-14 13:22:00 +090063 ret = platform_device_add(fsi_da7210_snd_device);
64 if (ret)
65 platform_device_put(fsi_da7210_snd_device);
66
67 return ret;
68}
69
70static void __exit fsi_da7210_sound_exit(void)
71{
72 platform_device_unregister(fsi_da7210_snd_device);
73}
74
75module_init(fsi_da7210_sound_init);
76module_exit(fsi_da7210_sound_exit);
77
78/* Module information */
79MODULE_DESCRIPTION("ALSA SoC FSI DA2710");
80MODULE_AUTHOR("Kuninori Morimoto <morimoto.kuninori@renesas.com>");
81MODULE_LICENSE("GPL");