blob: 6e41908323e80b24da3a5c44dd454c643544e777 [file] [log] [blame]
Kuninori Morimoto41a686e2010-08-31 14:46:53 +09001/*
2 * FSI - HDMI sound support
3 *
4 * Copyright (C) 2010 Renesas Solutions Corp.
5 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
6 *
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive
9 * for more details.
10 */
11
12#include <linux/platform_device.h>
Paul Gortmakerda155d52011-07-15 12:38:28 -040013#include <linux/module.h>
Kuninori Morimoto41a686e2010-08-31 14:46:53 +090014#include <sound/sh_fsi.h>
Kuninori Morimoto41a686e2010-08-31 14:46:53 +090015
Kuninori Morimoto3f25c9c2011-01-24 10:09:02 +090016struct fsi_hdmi_data {
17 const char *cpu_dai;
18 const char *card;
19 int id;
20};
21
Kuninori Morimoto4d805f72011-01-20 11:46:02 +090022static int fsi_hdmi_dai_init(struct snd_soc_pcm_runtime *rtd)
23{
24 struct snd_soc_dai *cpu = rtd->cpu_dai;
25 int ret;
26
27 ret = snd_soc_dai_set_fmt(cpu, SND_SOC_DAIFMT_CBM_CFM);
28
29 return ret;
30}
31
Kuninori Morimoto41a686e2010-08-31 14:46:53 +090032static struct snd_soc_dai_link fsi_dai_link = {
33 .name = "HDMI",
34 .stream_name = "HDMI",
Kuninori Morimoto41a686e2010-08-31 14:46:53 +090035 .codec_dai_name = "sh_mobile_hdmi-hifi",
36 .platform_name = "sh_fsi2",
37 .codec_name = "sh-mobile-hdmi",
Kuninori Morimoto4d805f72011-01-20 11:46:02 +090038 .init = fsi_hdmi_dai_init,
Kuninori Morimoto41a686e2010-08-31 14:46:53 +090039};
40
41static struct snd_soc_card fsi_soc_card = {
Axel Lin4a7042e2011-12-23 14:53:32 +080042 .owner = THIS_MODULE,
Kuninori Morimoto41a686e2010-08-31 14:46:53 +090043 .dai_link = &fsi_dai_link,
44 .num_links = 1,
45};
46
47static struct platform_device *fsi_snd_device;
48
Kuninori Morimoto3f25c9c2011-01-24 10:09:02 +090049static int fsi_hdmi_probe(struct platform_device *pdev)
Kuninori Morimoto41a686e2010-08-31 14:46:53 +090050{
51 int ret = -ENOMEM;
Kuninori Morimoto3f25c9c2011-01-24 10:09:02 +090052 const struct platform_device_id *id_entry;
53 struct fsi_hdmi_data *pdata;
Kuninori Morimoto41a686e2010-08-31 14:46:53 +090054
Kuninori Morimoto3f25c9c2011-01-24 10:09:02 +090055 id_entry = pdev->id_entry;
56 if (!id_entry) {
57 dev_err(&pdev->dev, "unknown fsi hdmi\n");
58 return -ENODEV;
59 }
60
61 pdata = (struct fsi_hdmi_data *)id_entry->driver_data;
62
63 fsi_snd_device = platform_device_alloc("soc-audio", pdata->id);
Kuninori Morimoto41a686e2010-08-31 14:46:53 +090064 if (!fsi_snd_device)
65 goto out;
66
Kuninori Morimoto3f25c9c2011-01-24 10:09:02 +090067 fsi_dai_link.cpu_dai_name = pdata->cpu_dai;
68 fsi_soc_card.name = pdata->card;
69
Kuninori Morimoto41a686e2010-08-31 14:46:53 +090070 platform_set_drvdata(fsi_snd_device, &fsi_soc_card);
71 ret = platform_device_add(fsi_snd_device);
72
73 if (ret)
74 platform_device_put(fsi_snd_device);
75
76out:
77 return ret;
78}
79
Kuninori Morimoto3f25c9c2011-01-24 10:09:02 +090080static int fsi_hdmi_remove(struct platform_device *pdev)
Kuninori Morimoto41a686e2010-08-31 14:46:53 +090081{
82 platform_device_unregister(fsi_snd_device);
Kuninori Morimoto3f25c9c2011-01-24 10:09:02 +090083 return 0;
84}
85
86static struct fsi_hdmi_data fsi2_a_hdmi = {
87 .cpu_dai = "fsia-dai",
Kuninori Morimoto2c7beb92011-07-05 00:16:17 -070088 .card = "FSI2A-HDMI",
Kuninori Morimoto3f25c9c2011-01-24 10:09:02 +090089 .id = FSI_PORT_A,
90};
91
92static struct fsi_hdmi_data fsi2_b_hdmi = {
93 .cpu_dai = "fsib-dai",
Kuninori Morimoto2c7beb92011-07-05 00:16:17 -070094 .card = "FSI2B-HDMI",
Kuninori Morimoto3f25c9c2011-01-24 10:09:02 +090095 .id = FSI_PORT_B,
96};
97
98static struct platform_device_id fsi_id_table[] = {
99 /* FSI 2 */
100 { "sh_fsi2_a_hdmi", (kernel_ulong_t)&fsi2_a_hdmi },
101 { "sh_fsi2_b_hdmi", (kernel_ulong_t)&fsi2_b_hdmi },
102 {},
103};
104
105static struct platform_driver fsi_hdmi = {
106 .driver = {
107 .name = "fsi-hdmi-audio",
108 },
109 .probe = fsi_hdmi_probe,
110 .remove = fsi_hdmi_remove,
111 .id_table = fsi_id_table,
112};
113
Axel Lincb5e8732011-11-25 10:15:07 +0800114module_platform_driver(fsi_hdmi);
Kuninori Morimoto41a686e2010-08-31 14:46:53 +0900115
116MODULE_LICENSE("GPL");
117MODULE_DESCRIPTION("Generic SH4 FSI-HDMI sound card");
118MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>");