Kuninori Morimoto | f239088 | 2012-04-08 21:17:50 -0700 | [diff] [blame] | 1 | /* |
| 2 | * ASoC simple sound card support |
| 3 | * |
| 4 | * Copyright (C) 2012 Renesas Solutions Corp. |
| 5 | * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License version 2 as |
| 9 | * published by the Free Software Foundation. |
| 10 | */ |
Kuninori Morimoto | fa558c2 | 2013-11-20 15:25:02 +0900 | [diff] [blame] | 11 | #include <linux/clk.h> |
Kuninori Morimoto | f239088 | 2012-04-08 21:17:50 -0700 | [diff] [blame] | 12 | #include <linux/module.h> |
Kuninori Morimoto | fa558c2 | 2013-11-20 15:25:02 +0900 | [diff] [blame] | 13 | #include <linux/of.h> |
Kuninori Morimoto | f239088 | 2012-04-08 21:17:50 -0700 | [diff] [blame] | 14 | #include <linux/platform_device.h> |
Xiubo Li | ca919fe | 2014-01-14 12:35:32 +0800 | [diff] [blame] | 15 | #include <linux/string.h> |
Kuninori Morimoto | f239088 | 2012-04-08 21:17:50 -0700 | [diff] [blame] | 16 | #include <sound/simple_card.h> |
| 17 | |
Jean-Francois Moine | 45fce59 | 2014-01-15 16:51:56 +0100 | [diff] [blame] | 18 | struct simple_card_data { |
| 19 | struct snd_soc_card snd_card; |
| 20 | unsigned int daifmt; |
| 21 | struct asoc_simple_dai cpu_dai; |
| 22 | struct asoc_simple_dai codec_dai; |
| 23 | struct snd_soc_dai_link snd_link; |
| 24 | }; |
| 25 | |
Kuninori Morimoto | a4a2992 | 2013-01-10 16:49:11 -0800 | [diff] [blame] | 26 | static int __asoc_simple_card_dai_init(struct snd_soc_dai *dai, |
Xiubo Li | 30d0341 | 2014-01-24 15:43:01 +0800 | [diff] [blame^] | 27 | struct asoc_simple_dai *set) |
Kuninori Morimoto | a4a2992 | 2013-01-10 16:49:11 -0800 | [diff] [blame] | 28 | { |
Xiubo Li | 4763ebe | 2014-01-24 15:43:00 +0800 | [diff] [blame] | 29 | int ret; |
Kuninori Morimoto | a4a2992 | 2013-01-10 16:49:11 -0800 | [diff] [blame] | 30 | |
Xiubo Li | 30d0341 | 2014-01-24 15:43:01 +0800 | [diff] [blame^] | 31 | if (set->fmt) { |
| 32 | ret = snd_soc_dai_set_fmt(dai, set->fmt); |
Xiubo Li | 4763ebe | 2014-01-24 15:43:00 +0800 | [diff] [blame] | 33 | if (ret && ret != -ENOTSUPP) { |
| 34 | dev_err(dai->dev, "simple-card: set_fmt error\n"); |
| 35 | goto err; |
| 36 | } |
Kuninori Morimoto | e244bb9 | 2013-10-17 22:46:49 -0700 | [diff] [blame] | 37 | } |
| 38 | |
Xiubo Li | 4763ebe | 2014-01-24 15:43:00 +0800 | [diff] [blame] | 39 | if (set->sysclk) { |
Kuninori Morimoto | a4a2992 | 2013-01-10 16:49:11 -0800 | [diff] [blame] | 40 | ret = snd_soc_dai_set_sysclk(dai, 0, set->sysclk, 0); |
Xiubo Li | 4763ebe | 2014-01-24 15:43:00 +0800 | [diff] [blame] | 41 | if (ret && ret != -ENOTSUPP) { |
| 42 | dev_err(dai->dev, "simple-card: set_sysclk error\n"); |
| 43 | goto err; |
| 44 | } |
| 45 | } |
Kuninori Morimoto | a4a2992 | 2013-01-10 16:49:11 -0800 | [diff] [blame] | 46 | |
Xiubo Li | 4763ebe | 2014-01-24 15:43:00 +0800 | [diff] [blame] | 47 | ret = 0; |
| 48 | |
| 49 | err: |
Kuninori Morimoto | a4a2992 | 2013-01-10 16:49:11 -0800 | [diff] [blame] | 50 | return ret; |
| 51 | } |
| 52 | |
Kuninori Morimoto | f239088 | 2012-04-08 21:17:50 -0700 | [diff] [blame] | 53 | static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd) |
| 54 | { |
Jean-Francois Moine | b367a32 | 2014-01-15 16:52:00 +0100 | [diff] [blame] | 55 | struct simple_card_data *priv = |
Xiubo Li | ba194a4 | 2014-01-13 17:08:08 +0800 | [diff] [blame] | 56 | snd_soc_card_get_drvdata(rtd->card); |
Kuninori Morimoto | f239088 | 2012-04-08 21:17:50 -0700 | [diff] [blame] | 57 | struct snd_soc_dai *codec = rtd->codec_dai; |
| 58 | struct snd_soc_dai *cpu = rtd->cpu_dai; |
Kuninori Morimoto | f239088 | 2012-04-08 21:17:50 -0700 | [diff] [blame] | 59 | int ret; |
| 60 | |
Xiubo Li | 30d0341 | 2014-01-24 15:43:01 +0800 | [diff] [blame^] | 61 | ret = __asoc_simple_card_dai_init(codec, &priv->codec_dai); |
Kuninori Morimoto | a4a2992 | 2013-01-10 16:49:11 -0800 | [diff] [blame] | 62 | if (ret < 0) |
| 63 | return ret; |
Kuninori Morimoto | f239088 | 2012-04-08 21:17:50 -0700 | [diff] [blame] | 64 | |
Xiubo Li | 30d0341 | 2014-01-24 15:43:01 +0800 | [diff] [blame^] | 65 | ret = __asoc_simple_card_dai_init(cpu, &priv->cpu_dai); |
Kuninori Morimoto | a4a2992 | 2013-01-10 16:49:11 -0800 | [diff] [blame] | 66 | if (ret < 0) |
| 67 | return ret; |
Kuninori Morimoto | f239088 | 2012-04-08 21:17:50 -0700 | [diff] [blame] | 68 | |
| 69 | return 0; |
| 70 | } |
| 71 | |
Kuninori Morimoto | fa558c2 | 2013-11-20 15:25:02 +0900 | [diff] [blame] | 72 | static int |
| 73 | asoc_simple_card_sub_parse_of(struct device_node *np, |
Xiubo Li | 30d0341 | 2014-01-24 15:43:01 +0800 | [diff] [blame^] | 74 | unsigned int daifmt, |
Kuninori Morimoto | fa558c2 | 2013-11-20 15:25:02 +0900 | [diff] [blame] | 75 | struct asoc_simple_dai *dai, |
Jean-Francois Moine | 5200847 | 2014-01-15 16:51:48 +0100 | [diff] [blame] | 76 | const struct device_node **p_node, |
| 77 | const char **name) |
Kuninori Morimoto | fa558c2 | 2013-11-20 15:25:02 +0900 | [diff] [blame] | 78 | { |
Jean-Francois Moine | 201a0ea | 2014-01-15 16:51:41 +0100 | [diff] [blame] | 79 | struct device_node *node; |
Kuninori Morimoto | fa558c2 | 2013-11-20 15:25:02 +0900 | [diff] [blame] | 80 | struct clk *clk; |
| 81 | int ret; |
| 82 | |
| 83 | /* |
| 84 | * get node via "sound-dai = <&phandle port>" |
| 85 | * it will be used as xxx_of_node on soc_bind_dai_link() |
| 86 | */ |
Jean-Francois Moine | 201a0ea | 2014-01-15 16:51:41 +0100 | [diff] [blame] | 87 | node = of_parse_phandle(np, "sound-dai", 0); |
| 88 | if (!node) |
Kuninori Morimoto | fa558c2 | 2013-11-20 15:25:02 +0900 | [diff] [blame] | 89 | return -ENODEV; |
Jean-Francois Moine | 201a0ea | 2014-01-15 16:51:41 +0100 | [diff] [blame] | 90 | *p_node = node; |
Kuninori Morimoto | fa558c2 | 2013-11-20 15:25:02 +0900 | [diff] [blame] | 91 | |
| 92 | /* get dai->name */ |
Jean-Francois Moine | 5200847 | 2014-01-15 16:51:48 +0100 | [diff] [blame] | 93 | ret = snd_soc_of_get_dai_name(np, name); |
Kuninori Morimoto | fa558c2 | 2013-11-20 15:25:02 +0900 | [diff] [blame] | 94 | if (ret < 0) |
| 95 | goto parse_error; |
| 96 | |
| 97 | /* |
| 98 | * bitclock-inversion, frame-inversion |
| 99 | * bitclock-master, frame-master |
| 100 | * and specific "format" if it has |
| 101 | */ |
| 102 | dai->fmt = snd_soc_of_parse_daifmt(np, NULL); |
Xiubo Li | 30d0341 | 2014-01-24 15:43:01 +0800 | [diff] [blame^] | 103 | dai->fmt |= daifmt; |
Kuninori Morimoto | fa558c2 | 2013-11-20 15:25:02 +0900 | [diff] [blame] | 104 | |
| 105 | /* |
| 106 | * dai->sysclk come from |
| 107 | * "clocks = <&xxx>" (if system has common clock) |
| 108 | * or "system-clock-frequency = <xxx>" |
Xiubo Li | 71467e4 | 2013-12-23 15:25:38 +0800 | [diff] [blame] | 109 | * or device's module clock. |
Kuninori Morimoto | fa558c2 | 2013-11-20 15:25:02 +0900 | [diff] [blame] | 110 | */ |
Xiubo Li | 71467e4 | 2013-12-23 15:25:38 +0800 | [diff] [blame] | 111 | if (of_property_read_bool(np, "clocks")) { |
| 112 | clk = of_clk_get(np, 0); |
| 113 | if (IS_ERR(clk)) { |
| 114 | ret = PTR_ERR(clk); |
| 115 | goto parse_error; |
| 116 | } |
| 117 | |
| 118 | dai->sysclk = clk_get_rate(clk); |
| 119 | } else if (of_property_read_bool(np, "system-clock-frequency")) { |
Kuninori Morimoto | fa558c2 | 2013-11-20 15:25:02 +0900 | [diff] [blame] | 120 | of_property_read_u32(np, |
| 121 | "system-clock-frequency", |
| 122 | &dai->sysclk); |
Xiubo Li | 71467e4 | 2013-12-23 15:25:38 +0800 | [diff] [blame] | 123 | } else { |
Jean-Francois Moine | 201a0ea | 2014-01-15 16:51:41 +0100 | [diff] [blame] | 124 | clk = of_clk_get(node, 0); |
Xiubo Li | e2a19ac | 2014-01-06 12:34:36 +0800 | [diff] [blame] | 125 | if (!IS_ERR(clk)) |
| 126 | dai->sysclk = clk_get_rate(clk); |
Xiubo Li | 71467e4 | 2013-12-23 15:25:38 +0800 | [diff] [blame] | 127 | } |
Kuninori Morimoto | fa558c2 | 2013-11-20 15:25:02 +0900 | [diff] [blame] | 128 | |
| 129 | ret = 0; |
| 130 | |
| 131 | parse_error: |
Jean-Francois Moine | 201a0ea | 2014-01-15 16:51:41 +0100 | [diff] [blame] | 132 | of_node_put(node); |
Kuninori Morimoto | fa558c2 | 2013-11-20 15:25:02 +0900 | [diff] [blame] | 133 | |
| 134 | return ret; |
| 135 | } |
| 136 | |
| 137 | static int asoc_simple_card_parse_of(struct device_node *node, |
Jean-Francois Moine | b367a32 | 2014-01-15 16:52:00 +0100 | [diff] [blame] | 138 | struct simple_card_data *priv, |
Jean-Francois Moine | 201a0ea | 2014-01-15 16:51:41 +0100 | [diff] [blame] | 139 | struct device *dev) |
Kuninori Morimoto | fa558c2 | 2013-11-20 15:25:02 +0900 | [diff] [blame] | 140 | { |
Jean-Francois Moine | b367a32 | 2014-01-15 16:52:00 +0100 | [diff] [blame] | 141 | struct snd_soc_dai_link *dai_link = priv->snd_card.dai_link; |
Kuninori Morimoto | fa558c2 | 2013-11-20 15:25:02 +0900 | [diff] [blame] | 142 | struct device_node *np; |
| 143 | char *name; |
Xiubo Li | d4c2209 | 2013-12-23 12:57:01 +0800 | [diff] [blame] | 144 | int ret; |
Kuninori Morimoto | fa558c2 | 2013-11-20 15:25:02 +0900 | [diff] [blame] | 145 | |
| 146 | /* get CPU/CODEC common format via simple-audio-card,format */ |
Jean-Francois Moine | b367a32 | 2014-01-15 16:52:00 +0100 | [diff] [blame] | 147 | priv->daifmt = snd_soc_of_parse_daifmt(node, "simple-audio-card,") & |
Kuninori Morimoto | fa558c2 | 2013-11-20 15:25:02 +0900 | [diff] [blame] | 148 | (SND_SOC_DAIFMT_FORMAT_MASK | SND_SOC_DAIFMT_INV_MASK); |
| 149 | |
Xiubo Li | d4c2209 | 2013-12-23 12:57:01 +0800 | [diff] [blame] | 150 | /* DAPM routes */ |
Xiubo Li | 8c0b823 | 2014-01-07 09:15:16 +0800 | [diff] [blame] | 151 | if (of_property_read_bool(node, "simple-audio-card,routing")) { |
Jean-Francois Moine | b367a32 | 2014-01-15 16:52:00 +0100 | [diff] [blame] | 152 | ret = snd_soc_of_parse_audio_routing(&priv->snd_card, |
Xiubo Li | 8c0b823 | 2014-01-07 09:15:16 +0800 | [diff] [blame] | 153 | "simple-audio-card,routing"); |
Xiubo Li | f87a3e8 | 2014-01-07 09:13:42 +0800 | [diff] [blame] | 154 | if (ret) |
| 155 | return ret; |
| 156 | } |
Xiubo Li | d4c2209 | 2013-12-23 12:57:01 +0800 | [diff] [blame] | 157 | |
Kuninori Morimoto | fa558c2 | 2013-11-20 15:25:02 +0900 | [diff] [blame] | 158 | /* CPU sub-node */ |
| 159 | ret = -EINVAL; |
| 160 | np = of_get_child_by_name(node, "simple-audio-card,cpu"); |
| 161 | if (np) |
Xiubo Li | 30d0341 | 2014-01-24 15:43:01 +0800 | [diff] [blame^] | 162 | ret = asoc_simple_card_sub_parse_of(np, priv->daifmt, |
Jean-Francois Moine | b367a32 | 2014-01-15 16:52:00 +0100 | [diff] [blame] | 163 | &priv->cpu_dai, |
Jean-Francois Moine | 5200847 | 2014-01-15 16:51:48 +0100 | [diff] [blame] | 164 | &dai_link->cpu_of_node, |
| 165 | &dai_link->cpu_dai_name); |
Kuninori Morimoto | fa558c2 | 2013-11-20 15:25:02 +0900 | [diff] [blame] | 166 | if (ret < 0) |
| 167 | return ret; |
| 168 | |
| 169 | /* CODEC sub-node */ |
| 170 | ret = -EINVAL; |
| 171 | np = of_get_child_by_name(node, "simple-audio-card,codec"); |
| 172 | if (np) |
Xiubo Li | 30d0341 | 2014-01-24 15:43:01 +0800 | [diff] [blame^] | 173 | ret = asoc_simple_card_sub_parse_of(np, priv->daifmt, |
Jean-Francois Moine | b367a32 | 2014-01-15 16:52:00 +0100 | [diff] [blame] | 174 | &priv->codec_dai, |
Jean-Francois Moine | 5200847 | 2014-01-15 16:51:48 +0100 | [diff] [blame] | 175 | &dai_link->codec_of_node, |
| 176 | &dai_link->codec_dai_name); |
Kuninori Morimoto | fa558c2 | 2013-11-20 15:25:02 +0900 | [diff] [blame] | 177 | if (ret < 0) |
| 178 | return ret; |
| 179 | |
Jean-Francois Moine | 5200847 | 2014-01-15 16:51:48 +0100 | [diff] [blame] | 180 | if (!dai_link->cpu_dai_name || !dai_link->codec_dai_name) |
Xiubo Li | dd41e0c | 2013-12-20 14:39:50 +0800 | [diff] [blame] | 181 | return -EINVAL; |
| 182 | |
Kuninori Morimoto | fa558c2 | 2013-11-20 15:25:02 +0900 | [diff] [blame] | 183 | /* card name is created from CPU/CODEC dai name */ |
| 184 | name = devm_kzalloc(dev, |
Jean-Francois Moine | 5200847 | 2014-01-15 16:51:48 +0100 | [diff] [blame] | 185 | strlen(dai_link->cpu_dai_name) + |
| 186 | strlen(dai_link->codec_dai_name) + 2, |
Kuninori Morimoto | fa558c2 | 2013-11-20 15:25:02 +0900 | [diff] [blame] | 187 | GFP_KERNEL); |
Jean-Francois Moine | 5200847 | 2014-01-15 16:51:48 +0100 | [diff] [blame] | 188 | sprintf(name, "%s-%s", dai_link->cpu_dai_name, |
| 189 | dai_link->codec_dai_name); |
Jean-Francois Moine | b367a32 | 2014-01-15 16:52:00 +0100 | [diff] [blame] | 190 | priv->snd_card.name = name; |
Jean-Francois Moine | 5ca8ba4 | 2014-01-15 16:51:45 +0100 | [diff] [blame] | 191 | dai_link->name = dai_link->stream_name = name; |
Kuninori Morimoto | fa558c2 | 2013-11-20 15:25:02 +0900 | [diff] [blame] | 192 | |
| 193 | /* simple-card assumes platform == cpu */ |
Jean-Francois Moine | 5ca8ba4 | 2014-01-15 16:51:45 +0100 | [diff] [blame] | 194 | dai_link->platform_of_node = dai_link->cpu_of_node; |
Kuninori Morimoto | fa558c2 | 2013-11-20 15:25:02 +0900 | [diff] [blame] | 195 | |
Jean-Francois Moine | 2bee991 | 2014-01-15 16:51:37 +0100 | [diff] [blame] | 196 | dev_dbg(dev, "card-name : %s\n", name); |
Jean-Francois Moine | b367a32 | 2014-01-15 16:52:00 +0100 | [diff] [blame] | 197 | dev_dbg(dev, "platform : %04x\n", priv->daifmt); |
Kuninori Morimoto | fa558c2 | 2013-11-20 15:25:02 +0900 | [diff] [blame] | 198 | dev_dbg(dev, "cpu : %s / %04x / %d\n", |
Jean-Francois Moine | 5200847 | 2014-01-15 16:51:48 +0100 | [diff] [blame] | 199 | dai_link->cpu_dai_name, |
Jean-Francois Moine | b367a32 | 2014-01-15 16:52:00 +0100 | [diff] [blame] | 200 | priv->cpu_dai.fmt, |
| 201 | priv->cpu_dai.sysclk); |
Kuninori Morimoto | fa558c2 | 2013-11-20 15:25:02 +0900 | [diff] [blame] | 202 | dev_dbg(dev, "codec : %s / %04x / %d\n", |
Jean-Francois Moine | 5200847 | 2014-01-15 16:51:48 +0100 | [diff] [blame] | 203 | dai_link->codec_dai_name, |
Jean-Francois Moine | b367a32 | 2014-01-15 16:52:00 +0100 | [diff] [blame] | 204 | priv->codec_dai.fmt, |
| 205 | priv->codec_dai.sysclk); |
Kuninori Morimoto | fa558c2 | 2013-11-20 15:25:02 +0900 | [diff] [blame] | 206 | |
| 207 | return 0; |
| 208 | } |
| 209 | |
Kuninori Morimoto | f239088 | 2012-04-08 21:17:50 -0700 | [diff] [blame] | 210 | static int asoc_simple_card_probe(struct platform_device *pdev) |
| 211 | { |
Jean-Francois Moine | 45fce59 | 2014-01-15 16:51:56 +0100 | [diff] [blame] | 212 | struct simple_card_data *priv; |
Jean-Francois Moine | 5ca8ba4 | 2014-01-15 16:51:45 +0100 | [diff] [blame] | 213 | struct snd_soc_dai_link *dai_link; |
Kuninori Morimoto | fa558c2 | 2013-11-20 15:25:02 +0900 | [diff] [blame] | 214 | struct device_node *np = pdev->dev.of_node; |
Kuninori Morimoto | f89983e | 2012-12-25 22:52:33 -0800 | [diff] [blame] | 215 | struct device *dev = &pdev->dev; |
Xiubo Li | ca919fe | 2014-01-14 12:35:32 +0800 | [diff] [blame] | 216 | int ret; |
Kuninori Morimoto | f239088 | 2012-04-08 21:17:50 -0700 | [diff] [blame] | 217 | |
Jean-Francois Moine | ca65b49 | 2014-01-15 16:51:52 +0100 | [diff] [blame] | 218 | priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); |
| 219 | if (!priv) |
Xiubo Li | ca919fe | 2014-01-14 12:35:32 +0800 | [diff] [blame] | 220 | return -ENOMEM; |
| 221 | |
Jean-Francois Moine | 201a0ea | 2014-01-15 16:51:41 +0100 | [diff] [blame] | 222 | /* |
| 223 | * init snd_soc_card |
| 224 | */ |
Jean-Francois Moine | ca65b49 | 2014-01-15 16:51:52 +0100 | [diff] [blame] | 225 | priv->snd_card.owner = THIS_MODULE; |
| 226 | priv->snd_card.dev = dev; |
| 227 | dai_link = &priv->snd_link; |
| 228 | priv->snd_card.dai_link = dai_link; |
| 229 | priv->snd_card.num_links = 1; |
Xiubo Li | ca919fe | 2014-01-14 12:35:32 +0800 | [diff] [blame] | 230 | |
Jean-Francois Moine | 201a0ea | 2014-01-15 16:51:41 +0100 | [diff] [blame] | 231 | if (np && of_device_is_available(np)) { |
| 232 | |
Jean-Francois Moine | ca65b49 | 2014-01-15 16:51:52 +0100 | [diff] [blame] | 233 | ret = asoc_simple_card_parse_of(np, priv, dev); |
Xiubo Li | ca919fe | 2014-01-14 12:35:32 +0800 | [diff] [blame] | 234 | if (ret < 0) { |
| 235 | if (ret != -EPROBE_DEFER) |
| 236 | dev_err(dev, "parse error %d\n", ret); |
| 237 | return ret; |
Kuninori Morimoto | fa558c2 | 2013-11-20 15:25:02 +0900 | [diff] [blame] | 238 | } |
| 239 | } else { |
Jean-Francois Moine | ca65b49 | 2014-01-15 16:51:52 +0100 | [diff] [blame] | 240 | struct asoc_simple_card_info *cinfo; |
| 241 | |
| 242 | cinfo = dev->platform_data; |
| 243 | if (!cinfo) { |
Xiubo Li | 34787d0 | 2014-01-09 17:49:40 +0800 | [diff] [blame] | 244 | dev_err(dev, "no info for asoc-simple-card\n"); |
| 245 | return -EINVAL; |
| 246 | } |
Kuninori Morimoto | fa558c2 | 2013-11-20 15:25:02 +0900 | [diff] [blame] | 247 | |
Jean-Francois Moine | 7722f83 | 2014-01-15 16:51:33 +0100 | [diff] [blame] | 248 | if (!cinfo->name || |
| 249 | !cinfo->card || |
| 250 | !cinfo->codec_dai.name || |
| 251 | !cinfo->codec || |
| 252 | !cinfo->platform || |
| 253 | !cinfo->cpu_dai.name) { |
| 254 | dev_err(dev, "insufficient asoc_simple_card_info settings\n"); |
| 255 | return -EINVAL; |
| 256 | } |
Jean-Francois Moine | 2bee991 | 2014-01-15 16:51:37 +0100 | [diff] [blame] | 257 | |
Jean-Francois Moine | ca65b49 | 2014-01-15 16:51:52 +0100 | [diff] [blame] | 258 | priv->snd_card.name = cinfo->card; |
Jean-Francois Moine | 5ca8ba4 | 2014-01-15 16:51:45 +0100 | [diff] [blame] | 259 | dai_link->name = cinfo->name; |
| 260 | dai_link->stream_name = cinfo->name; |
| 261 | dai_link->platform_name = cinfo->platform; |
| 262 | dai_link->codec_name = cinfo->codec; |
Jean-Francois Moine | 5200847 | 2014-01-15 16:51:48 +0100 | [diff] [blame] | 263 | dai_link->cpu_dai_name = cinfo->cpu_dai.name; |
| 264 | dai_link->codec_dai_name = cinfo->codec_dai.name; |
Jean-Francois Moine | ca65b49 | 2014-01-15 16:51:52 +0100 | [diff] [blame] | 265 | memcpy(&priv->cpu_dai, &cinfo->cpu_dai, |
| 266 | sizeof(priv->cpu_dai)); |
| 267 | memcpy(&priv->codec_dai, &cinfo->codec_dai, |
| 268 | sizeof(priv->codec_dai)); |
Kuninori Morimoto | f239088 | 2012-04-08 21:17:50 -0700 | [diff] [blame] | 269 | } |
| 270 | |
| 271 | /* |
| 272 | * init snd_soc_dai_link |
| 273 | */ |
Jean-Francois Moine | 5ca8ba4 | 2014-01-15 16:51:45 +0100 | [diff] [blame] | 274 | dai_link->init = asoc_simple_card_dai_init; |
Kuninori Morimoto | f239088 | 2012-04-08 21:17:50 -0700 | [diff] [blame] | 275 | |
Jean-Francois Moine | ca65b49 | 2014-01-15 16:51:52 +0100 | [diff] [blame] | 276 | snd_soc_card_set_drvdata(&priv->snd_card, priv); |
Xiubo Li | ba194a4 | 2014-01-13 17:08:08 +0800 | [diff] [blame] | 277 | |
Jean-Francois Moine | ca65b49 | 2014-01-15 16:51:52 +0100 | [diff] [blame] | 278 | return devm_snd_soc_register_card(&pdev->dev, &priv->snd_card); |
Kuninori Morimoto | f239088 | 2012-04-08 21:17:50 -0700 | [diff] [blame] | 279 | } |
| 280 | |
Kuninori Morimoto | fa558c2 | 2013-11-20 15:25:02 +0900 | [diff] [blame] | 281 | static const struct of_device_id asoc_simple_of_match[] = { |
| 282 | { .compatible = "simple-audio-card", }, |
| 283 | {}, |
| 284 | }; |
| 285 | MODULE_DEVICE_TABLE(of, asoc_simple_of_match); |
| 286 | |
Kuninori Morimoto | f239088 | 2012-04-08 21:17:50 -0700 | [diff] [blame] | 287 | static struct platform_driver asoc_simple_card = { |
| 288 | .driver = { |
| 289 | .name = "asoc-simple-card", |
Fabio Estevam | c445be3 | 2013-08-23 14:35:17 -0300 | [diff] [blame] | 290 | .owner = THIS_MODULE, |
Kuninori Morimoto | fa558c2 | 2013-11-20 15:25:02 +0900 | [diff] [blame] | 291 | .of_match_table = asoc_simple_of_match, |
Kuninori Morimoto | f239088 | 2012-04-08 21:17:50 -0700 | [diff] [blame] | 292 | }, |
| 293 | .probe = asoc_simple_card_probe, |
Kuninori Morimoto | f239088 | 2012-04-08 21:17:50 -0700 | [diff] [blame] | 294 | }; |
| 295 | |
| 296 | module_platform_driver(asoc_simple_card); |
| 297 | |
Fabio Estevam | c445be3 | 2013-08-23 14:35:17 -0300 | [diff] [blame] | 298 | MODULE_ALIAS("platform:asoc-simple-card"); |
Kuninori Morimoto | f239088 | 2012-04-08 21:17:50 -0700 | [diff] [blame] | 299 | MODULE_LICENSE("GPL"); |
| 300 | MODULE_DESCRIPTION("ASoC Simple Sound Card"); |
| 301 | MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>"); |