Kuninori Morimoto | b8e583f | 2009-08-21 09:42:59 +0900 | [diff] [blame] | 1 | /* |
| 2 | * FSI-AK464x sound support for ms7724se |
| 3 | * |
| 4 | * Copyright (C) 2009 Renesas Solutions Corp. |
| 5 | * Kuninori Morimoto <morimoto.kuninori@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 | |
Kuninori Morimoto | b8e583f | 2009-08-21 09:42:59 +0900 | [diff] [blame] | 12 | #include <linux/platform_device.h> |
Kuninori Morimoto | b8e583f | 2009-08-21 09:42:59 +0900 | [diff] [blame] | 13 | #include <sound/sh_fsi.h> |
Kuninori Morimoto | b8e583f | 2009-08-21 09:42:59 +0900 | [diff] [blame] | 14 | |
Kuninori Morimoto | c8d6bf9 | 2010-11-30 11:32:04 +0900 | [diff] [blame] | 15 | struct fsi_ak4642_data { |
| 16 | const char *name; |
Kuninori Morimoto | 806bfed | 2010-12-01 15:50:52 +0900 | [diff] [blame] | 17 | const char *card; |
Kuninori Morimoto | c8d6bf9 | 2010-11-30 11:32:04 +0900 | [diff] [blame] | 18 | const char *cpu_dai; |
| 19 | const char *codec; |
| 20 | const char *platform; |
Kuninori Morimoto | a193436 | 2011-01-12 15:32:07 +0900 | [diff] [blame^] | 21 | int id; |
Kuninori Morimoto | c8d6bf9 | 2010-11-30 11:32:04 +0900 | [diff] [blame] | 22 | }; |
| 23 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 24 | static int fsi_ak4642_dai_init(struct snd_soc_pcm_runtime *rtd) |
Kuninori Morimoto | 4b6316b | 2010-03-23 16:27:28 +0900 | [diff] [blame] | 25 | { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 26 | struct snd_soc_dai *dai = rtd->codec_dai; |
Kuninori Morimoto | 4b6316b | 2010-03-23 16:27:28 +0900 | [diff] [blame] | 27 | int ret; |
| 28 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 29 | ret = snd_soc_dai_set_fmt(dai, SND_SOC_DAIFMT_CBM_CFM); |
Kuninori Morimoto | 0643ce8 | 2010-03-15 18:10:50 +0900 | [diff] [blame] | 30 | if (ret < 0) |
| 31 | return ret; |
| 32 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 33 | ret = snd_soc_dai_set_sysclk(dai, 0, 11289600, 0); |
Kuninori Morimoto | 4b6316b | 2010-03-23 16:27:28 +0900 | [diff] [blame] | 34 | |
| 35 | return ret; |
| 36 | } |
| 37 | |
Kuninori Morimoto | b8e583f | 2009-08-21 09:42:59 +0900 | [diff] [blame] | 38 | static struct snd_soc_dai_link fsi_dai_link = { |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 39 | .codec_dai_name = "ak4642-hifi", |
Kuninori Morimoto | 4b6316b | 2010-03-23 16:27:28 +0900 | [diff] [blame] | 40 | .init = fsi_ak4642_dai_init, |
Kuninori Morimoto | b8e583f | 2009-08-21 09:42:59 +0900 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | static struct snd_soc_card fsi_soc_card = { |
Kuninori Morimoto | b8e583f | 2009-08-21 09:42:59 +0900 | [diff] [blame] | 44 | .dai_link = &fsi_dai_link, |
| 45 | .num_links = 1, |
| 46 | }; |
| 47 | |
Kuninori Morimoto | b8e583f | 2009-08-21 09:42:59 +0900 | [diff] [blame] | 48 | static struct platform_device *fsi_snd_device; |
| 49 | |
Kuninori Morimoto | c8d6bf9 | 2010-11-30 11:32:04 +0900 | [diff] [blame] | 50 | static int fsi_ak4642_probe(struct platform_device *pdev) |
Kuninori Morimoto | b8e583f | 2009-08-21 09:42:59 +0900 | [diff] [blame] | 51 | { |
| 52 | int ret = -ENOMEM; |
Kuninori Morimoto | c8d6bf9 | 2010-11-30 11:32:04 +0900 | [diff] [blame] | 53 | const struct platform_device_id *id_entry; |
| 54 | struct fsi_ak4642_data *pdata; |
| 55 | |
| 56 | id_entry = pdev->id_entry; |
| 57 | if (!id_entry) { |
| 58 | dev_err(&pdev->dev, "unknown fsi ak4642\n"); |
| 59 | return -ENODEV; |
| 60 | } |
| 61 | |
| 62 | pdata = (struct fsi_ak4642_data *)id_entry->driver_data; |
Kuninori Morimoto | b8e583f | 2009-08-21 09:42:59 +0900 | [diff] [blame] | 63 | |
Kuninori Morimoto | a193436 | 2011-01-12 15:32:07 +0900 | [diff] [blame^] | 64 | fsi_snd_device = platform_device_alloc("soc-audio", pdata->id); |
Kuninori Morimoto | b8e583f | 2009-08-21 09:42:59 +0900 | [diff] [blame] | 65 | if (!fsi_snd_device) |
| 66 | goto out; |
| 67 | |
Kuninori Morimoto | c8d6bf9 | 2010-11-30 11:32:04 +0900 | [diff] [blame] | 68 | fsi_dai_link.name = pdata->name; |
| 69 | fsi_dai_link.stream_name = pdata->name; |
| 70 | fsi_dai_link.cpu_dai_name = pdata->cpu_dai; |
| 71 | fsi_dai_link.platform_name = pdata->platform; |
| 72 | fsi_dai_link.codec_name = pdata->codec; |
Kuninori Morimoto | 806bfed | 2010-12-01 15:50:52 +0900 | [diff] [blame] | 73 | fsi_soc_card.name = pdata->card; |
Kuninori Morimoto | c8d6bf9 | 2010-11-30 11:32:04 +0900 | [diff] [blame] | 74 | |
Liam Girdwood | f0fba2a | 2010-03-17 20:15:21 +0000 | [diff] [blame] | 75 | platform_set_drvdata(fsi_snd_device, &fsi_soc_card); |
Kuninori Morimoto | b8e583f | 2009-08-21 09:42:59 +0900 | [diff] [blame] | 76 | ret = platform_device_add(fsi_snd_device); |
| 77 | |
| 78 | if (ret) |
| 79 | platform_device_put(fsi_snd_device); |
| 80 | |
| 81 | out: |
| 82 | return ret; |
| 83 | } |
| 84 | |
Kuninori Morimoto | c8d6bf9 | 2010-11-30 11:32:04 +0900 | [diff] [blame] | 85 | static int fsi_ak4642_remove(struct platform_device *pdev) |
Kuninori Morimoto | b8e583f | 2009-08-21 09:42:59 +0900 | [diff] [blame] | 86 | { |
| 87 | platform_device_unregister(fsi_snd_device); |
Kuninori Morimoto | c8d6bf9 | 2010-11-30 11:32:04 +0900 | [diff] [blame] | 88 | return 0; |
| 89 | } |
| 90 | |
| 91 | static struct fsi_ak4642_data fsi_a_ak4642 = { |
| 92 | .name = "AK4642", |
Kuninori Morimoto | 806bfed | 2010-12-01 15:50:52 +0900 | [diff] [blame] | 93 | .card = "FSIA (AK4642)", |
Kuninori Morimoto | c8d6bf9 | 2010-11-30 11:32:04 +0900 | [diff] [blame] | 94 | .cpu_dai = "fsia-dai", |
| 95 | .codec = "ak4642-codec.0-0012", |
| 96 | .platform = "sh_fsi.0", |
Kuninori Morimoto | a193436 | 2011-01-12 15:32:07 +0900 | [diff] [blame^] | 97 | .id = FSI_PORT_A, |
Kuninori Morimoto | c8d6bf9 | 2010-11-30 11:32:04 +0900 | [diff] [blame] | 98 | }; |
| 99 | |
| 100 | static struct fsi_ak4642_data fsi_b_ak4642 = { |
| 101 | .name = "AK4642", |
Kuninori Morimoto | 806bfed | 2010-12-01 15:50:52 +0900 | [diff] [blame] | 102 | .card = "FSIB (AK4642)", |
Kuninori Morimoto | c8d6bf9 | 2010-11-30 11:32:04 +0900 | [diff] [blame] | 103 | .cpu_dai = "fsib-dai", |
| 104 | .codec = "ak4642-codec.0-0012", |
| 105 | .platform = "sh_fsi.0", |
Kuninori Morimoto | a193436 | 2011-01-12 15:32:07 +0900 | [diff] [blame^] | 106 | .id = FSI_PORT_B, |
Kuninori Morimoto | c8d6bf9 | 2010-11-30 11:32:04 +0900 | [diff] [blame] | 107 | }; |
| 108 | |
| 109 | static struct fsi_ak4642_data fsi_a_ak4643 = { |
| 110 | .name = "AK4643", |
Kuninori Morimoto | 806bfed | 2010-12-01 15:50:52 +0900 | [diff] [blame] | 111 | .card = "FSIA (AK4643)", |
Kuninori Morimoto | c8d6bf9 | 2010-11-30 11:32:04 +0900 | [diff] [blame] | 112 | .cpu_dai = "fsia-dai", |
| 113 | .codec = "ak4642-codec.0-0013", |
| 114 | .platform = "sh_fsi.0", |
Kuninori Morimoto | a193436 | 2011-01-12 15:32:07 +0900 | [diff] [blame^] | 115 | .id = FSI_PORT_A, |
Kuninori Morimoto | c8d6bf9 | 2010-11-30 11:32:04 +0900 | [diff] [blame] | 116 | }; |
| 117 | |
| 118 | static struct fsi_ak4642_data fsi_b_ak4643 = { |
| 119 | .name = "AK4643", |
Kuninori Morimoto | 806bfed | 2010-12-01 15:50:52 +0900 | [diff] [blame] | 120 | .card = "FSIB (AK4643)", |
Kuninori Morimoto | c8d6bf9 | 2010-11-30 11:32:04 +0900 | [diff] [blame] | 121 | .cpu_dai = "fsib-dai", |
| 122 | .codec = "ak4642-codec.0-0013", |
| 123 | .platform = "sh_fsi.0", |
Kuninori Morimoto | a193436 | 2011-01-12 15:32:07 +0900 | [diff] [blame^] | 124 | .id = FSI_PORT_B, |
Kuninori Morimoto | c8d6bf9 | 2010-11-30 11:32:04 +0900 | [diff] [blame] | 125 | }; |
| 126 | |
| 127 | static struct fsi_ak4642_data fsi2_a_ak4642 = { |
| 128 | .name = "AK4642", |
Kuninori Morimoto | 806bfed | 2010-12-01 15:50:52 +0900 | [diff] [blame] | 129 | .card = "FSI2A (AK4642)", |
Kuninori Morimoto | c8d6bf9 | 2010-11-30 11:32:04 +0900 | [diff] [blame] | 130 | .cpu_dai = "fsia-dai", |
| 131 | .codec = "ak4642-codec.0-0012", |
| 132 | .platform = "sh_fsi2", |
Kuninori Morimoto | a193436 | 2011-01-12 15:32:07 +0900 | [diff] [blame^] | 133 | .id = FSI_PORT_A, |
Kuninori Morimoto | c8d6bf9 | 2010-11-30 11:32:04 +0900 | [diff] [blame] | 134 | }; |
| 135 | |
| 136 | static struct fsi_ak4642_data fsi2_b_ak4642 = { |
| 137 | .name = "AK4642", |
Kuninori Morimoto | 806bfed | 2010-12-01 15:50:52 +0900 | [diff] [blame] | 138 | .card = "FSI2B (AK4642)", |
Kuninori Morimoto | c8d6bf9 | 2010-11-30 11:32:04 +0900 | [diff] [blame] | 139 | .cpu_dai = "fsib-dai", |
| 140 | .codec = "ak4642-codec.0-0012", |
| 141 | .platform = "sh_fsi2", |
Kuninori Morimoto | a193436 | 2011-01-12 15:32:07 +0900 | [diff] [blame^] | 142 | .id = FSI_PORT_B, |
Kuninori Morimoto | c8d6bf9 | 2010-11-30 11:32:04 +0900 | [diff] [blame] | 143 | }; |
| 144 | |
| 145 | static struct fsi_ak4642_data fsi2_a_ak4643 = { |
| 146 | .name = "AK4643", |
Kuninori Morimoto | 806bfed | 2010-12-01 15:50:52 +0900 | [diff] [blame] | 147 | .card = "FSI2A (AK4643)", |
Kuninori Morimoto | c8d6bf9 | 2010-11-30 11:32:04 +0900 | [diff] [blame] | 148 | .cpu_dai = "fsia-dai", |
| 149 | .codec = "ak4642-codec.0-0013", |
| 150 | .platform = "sh_fsi2", |
Kuninori Morimoto | a193436 | 2011-01-12 15:32:07 +0900 | [diff] [blame^] | 151 | .id = FSI_PORT_A, |
Kuninori Morimoto | c8d6bf9 | 2010-11-30 11:32:04 +0900 | [diff] [blame] | 152 | }; |
| 153 | |
| 154 | static struct fsi_ak4642_data fsi2_b_ak4643 = { |
| 155 | .name = "AK4643", |
Kuninori Morimoto | 806bfed | 2010-12-01 15:50:52 +0900 | [diff] [blame] | 156 | .card = "FSI2B (AK4643)", |
Kuninori Morimoto | c8d6bf9 | 2010-11-30 11:32:04 +0900 | [diff] [blame] | 157 | .cpu_dai = "fsib-dai", |
| 158 | .codec = "ak4642-codec.0-0013", |
| 159 | .platform = "sh_fsi2", |
Kuninori Morimoto | a193436 | 2011-01-12 15:32:07 +0900 | [diff] [blame^] | 160 | .id = FSI_PORT_B, |
Kuninori Morimoto | c8d6bf9 | 2010-11-30 11:32:04 +0900 | [diff] [blame] | 161 | }; |
| 162 | |
| 163 | static struct platform_device_id fsi_id_table[] = { |
| 164 | /* FSI */ |
| 165 | { "sh_fsi_a_ak4642", (kernel_ulong_t)&fsi_a_ak4642 }, |
| 166 | { "sh_fsi_b_ak4642", (kernel_ulong_t)&fsi_b_ak4642 }, |
| 167 | { "sh_fsi_a_ak4643", (kernel_ulong_t)&fsi_a_ak4643 }, |
| 168 | { "sh_fsi_b_ak4643", (kernel_ulong_t)&fsi_b_ak4643 }, |
| 169 | |
| 170 | /* FSI 2 */ |
| 171 | { "sh_fsi2_a_ak4642", (kernel_ulong_t)&fsi2_a_ak4642 }, |
| 172 | { "sh_fsi2_b_ak4642", (kernel_ulong_t)&fsi2_b_ak4642 }, |
| 173 | { "sh_fsi2_a_ak4643", (kernel_ulong_t)&fsi2_a_ak4643 }, |
| 174 | { "sh_fsi2_b_ak4643", (kernel_ulong_t)&fsi2_b_ak4643 }, |
| 175 | {}, |
| 176 | }; |
| 177 | |
| 178 | static struct platform_driver fsi_ak4642 = { |
| 179 | .driver = { |
| 180 | .name = "fsi-ak4642-audio", |
| 181 | }, |
| 182 | .probe = fsi_ak4642_probe, |
| 183 | .remove = fsi_ak4642_remove, |
| 184 | .id_table = fsi_id_table, |
| 185 | }; |
| 186 | |
| 187 | static int __init fsi_ak4642_init(void) |
| 188 | { |
| 189 | return platform_driver_register(&fsi_ak4642); |
| 190 | } |
| 191 | |
| 192 | static void __exit fsi_ak4642_exit(void) |
| 193 | { |
| 194 | platform_driver_unregister(&fsi_ak4642); |
Kuninori Morimoto | b8e583f | 2009-08-21 09:42:59 +0900 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | module_init(fsi_ak4642_init); |
| 198 | module_exit(fsi_ak4642_exit); |
| 199 | |
| 200 | MODULE_LICENSE("GPL"); |
| 201 | MODULE_DESCRIPTION("Generic SH4 FSI-AK4642 sound card"); |
| 202 | MODULE_AUTHOR("Kuninori Morimoto <morimoto.kuninori@renesas.com>"); |