Sylwester Nawrocki | 686f47b | 2019-04-19 12:22:01 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | // |
| 3 | // Copyright (C) 2015 - 2016 Samsung Electronics Co., Ltd. |
| 4 | // |
| 5 | // Authors: Inha Song <ideal.song@samsung.com> |
| 6 | // Sylwester Nawrocki <s.nawrocki@samsung.com> |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 7 | |
| 8 | #include <linux/clk.h> |
| 9 | #include <linux/gpio.h> |
Fabian Frederick | 5d079fd | 2016-12-09 19:12:50 +0100 | [diff] [blame] | 10 | #include <linux/gpio/consumer.h> |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 11 | #include <linux/module.h> |
| 12 | #include <linux/of.h> |
| 13 | #include <sound/pcm_params.h> |
| 14 | #include <sound/soc.h> |
| 15 | |
| 16 | #include "i2s.h" |
| 17 | #include "../codecs/wm5110.h" |
| 18 | |
| 19 | /* |
| 20 | * The source clock is XCLKOUT with its mux set to the external fixed rate |
| 21 | * oscillator (XXTI). |
| 22 | */ |
| 23 | #define MCLK_RATE 24000000U |
| 24 | |
| 25 | #define TM2_DAI_AIF1 0 |
| 26 | #define TM2_DAI_AIF2 1 |
| 27 | |
| 28 | struct tm2_machine_priv { |
Kuninori Morimoto | 0fe1daa | 2018-02-13 02:03:12 +0000 | [diff] [blame] | 29 | struct snd_soc_component *component; |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 30 | unsigned int sysclk_rate; |
| 31 | struct gpio_desc *gpio_mic_bias; |
| 32 | }; |
| 33 | |
| 34 | static int tm2_start_sysclk(struct snd_soc_card *card) |
| 35 | { |
| 36 | struct tm2_machine_priv *priv = snd_soc_card_get_drvdata(card); |
Kuninori Morimoto | 0fe1daa | 2018-02-13 02:03:12 +0000 | [diff] [blame] | 37 | struct snd_soc_component *component = priv->component; |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 38 | int ret; |
| 39 | |
Kuninori Morimoto | 0fe1daa | 2018-02-13 02:03:12 +0000 | [diff] [blame] | 40 | ret = snd_soc_component_set_pll(component, WM5110_FLL1_REFCLK, |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 41 | ARIZONA_FLL_SRC_MCLK1, |
| 42 | MCLK_RATE, |
| 43 | priv->sysclk_rate); |
| 44 | if (ret < 0) { |
Kuninori Morimoto | 0fe1daa | 2018-02-13 02:03:12 +0000 | [diff] [blame] | 45 | dev_err(component->dev, "Failed to set FLL1 source: %d\n", ret); |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 46 | return ret; |
| 47 | } |
| 48 | |
Kuninori Morimoto | 0fe1daa | 2018-02-13 02:03:12 +0000 | [diff] [blame] | 49 | ret = snd_soc_component_set_pll(component, WM5110_FLL1, |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 50 | ARIZONA_FLL_SRC_MCLK1, |
| 51 | MCLK_RATE, |
| 52 | priv->sysclk_rate); |
| 53 | if (ret < 0) { |
Kuninori Morimoto | 0fe1daa | 2018-02-13 02:03:12 +0000 | [diff] [blame] | 54 | dev_err(component->dev, "Failed to start FLL1: %d\n", ret); |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 55 | return ret; |
| 56 | } |
| 57 | |
Kuninori Morimoto | 0fe1daa | 2018-02-13 02:03:12 +0000 | [diff] [blame] | 58 | ret = snd_soc_component_set_sysclk(component, ARIZONA_CLK_SYSCLK, |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 59 | ARIZONA_CLK_SRC_FLL1, |
| 60 | priv->sysclk_rate, |
| 61 | SND_SOC_CLOCK_IN); |
| 62 | if (ret < 0) { |
Kuninori Morimoto | 0fe1daa | 2018-02-13 02:03:12 +0000 | [diff] [blame] | 63 | dev_err(component->dev, "Failed to set SYSCLK source: %d\n", ret); |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 64 | return ret; |
| 65 | } |
| 66 | |
| 67 | return 0; |
| 68 | } |
| 69 | |
| 70 | static int tm2_stop_sysclk(struct snd_soc_card *card) |
| 71 | { |
| 72 | struct tm2_machine_priv *priv = snd_soc_card_get_drvdata(card); |
Kuninori Morimoto | 0fe1daa | 2018-02-13 02:03:12 +0000 | [diff] [blame] | 73 | struct snd_soc_component *component = priv->component; |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 74 | int ret; |
| 75 | |
Kuninori Morimoto | 0fe1daa | 2018-02-13 02:03:12 +0000 | [diff] [blame] | 76 | ret = snd_soc_component_set_pll(component, WM5110_FLL1, 0, 0, 0); |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 77 | if (ret < 0) { |
Kuninori Morimoto | 0fe1daa | 2018-02-13 02:03:12 +0000 | [diff] [blame] | 78 | dev_err(component->dev, "Failed to stop FLL1: %d\n", ret); |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 79 | return ret; |
| 80 | } |
| 81 | |
Kuninori Morimoto | 0fe1daa | 2018-02-13 02:03:12 +0000 | [diff] [blame] | 82 | ret = snd_soc_component_set_sysclk(component, ARIZONA_CLK_SYSCLK, |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 83 | ARIZONA_CLK_SRC_FLL1, 0, 0); |
| 84 | if (ret < 0) { |
Kuninori Morimoto | 0fe1daa | 2018-02-13 02:03:12 +0000 | [diff] [blame] | 85 | dev_err(component->dev, "Failed to stop SYSCLK: %d\n", ret); |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 86 | return ret; |
| 87 | } |
| 88 | |
| 89 | return 0; |
| 90 | } |
| 91 | |
| 92 | static int tm2_aif1_hw_params(struct snd_pcm_substream *substream, |
| 93 | struct snd_pcm_hw_params *params) |
| 94 | { |
Kuninori Morimoto | c101ce8 | 2020-07-20 10:18:14 +0900 | [diff] [blame] | 95 | struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
Kuninori Morimoto | 7de6b6b | 2020-03-23 14:20:20 +0900 | [diff] [blame] | 96 | struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component; |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 97 | struct tm2_machine_priv *priv = snd_soc_card_get_drvdata(rtd->card); |
| 98 | |
| 99 | switch (params_rate(params)) { |
| 100 | case 4000: |
| 101 | case 8000: |
| 102 | case 12000: |
| 103 | case 16000: |
| 104 | case 24000: |
| 105 | case 32000: |
| 106 | case 48000: |
| 107 | case 96000: |
| 108 | case 192000: |
| 109 | /* Highest possible SYSCLK frequency: 147.456MHz */ |
| 110 | priv->sysclk_rate = 147456000U; |
| 111 | break; |
| 112 | case 11025: |
| 113 | case 22050: |
| 114 | case 44100: |
| 115 | case 88200: |
| 116 | case 176400: |
| 117 | /* Highest possible SYSCLK frequency: 135.4752 MHz */ |
| 118 | priv->sysclk_rate = 135475200U; |
| 119 | break; |
| 120 | default: |
Kuninori Morimoto | 0fe1daa | 2018-02-13 02:03:12 +0000 | [diff] [blame] | 121 | dev_err(component->dev, "Not supported sample rate: %d\n", |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 122 | params_rate(params)); |
| 123 | return -EINVAL; |
| 124 | } |
| 125 | |
| 126 | return tm2_start_sysclk(rtd->card); |
| 127 | } |
| 128 | |
Rikard Falkeborn | 2080acf | 2021-07-28 19:25:48 +0200 | [diff] [blame] | 129 | static const struct snd_soc_ops tm2_aif1_ops = { |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 130 | .hw_params = tm2_aif1_hw_params, |
| 131 | }; |
| 132 | |
| 133 | static int tm2_aif2_hw_params(struct snd_pcm_substream *substream, |
| 134 | struct snd_pcm_hw_params *params) |
| 135 | { |
Kuninori Morimoto | c101ce8 | 2020-07-20 10:18:14 +0900 | [diff] [blame] | 136 | struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
Kuninori Morimoto | 7de6b6b | 2020-03-23 14:20:20 +0900 | [diff] [blame] | 137 | struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component; |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 138 | unsigned int asyncclk_rate; |
| 139 | int ret; |
| 140 | |
| 141 | switch (params_rate(params)) { |
| 142 | case 8000: |
| 143 | case 12000: |
| 144 | case 16000: |
| 145 | /* Highest possible ASYNCCLK frequency: 49.152MHz */ |
| 146 | asyncclk_rate = 49152000U; |
| 147 | break; |
| 148 | case 11025: |
| 149 | /* Highest possible ASYNCCLK frequency: 45.1584 MHz */ |
| 150 | asyncclk_rate = 45158400U; |
| 151 | break; |
| 152 | default: |
Kuninori Morimoto | 0fe1daa | 2018-02-13 02:03:12 +0000 | [diff] [blame] | 153 | dev_err(component->dev, "Not supported sample rate: %d\n", |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 154 | params_rate(params)); |
| 155 | return -EINVAL; |
| 156 | } |
| 157 | |
Kuninori Morimoto | 0fe1daa | 2018-02-13 02:03:12 +0000 | [diff] [blame] | 158 | ret = snd_soc_component_set_pll(component, WM5110_FLL2_REFCLK, |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 159 | ARIZONA_FLL_SRC_MCLK1, |
| 160 | MCLK_RATE, |
| 161 | asyncclk_rate); |
| 162 | if (ret < 0) { |
Kuninori Morimoto | 0fe1daa | 2018-02-13 02:03:12 +0000 | [diff] [blame] | 163 | dev_err(component->dev, "Failed to set FLL2 source: %d\n", ret); |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 164 | return ret; |
| 165 | } |
| 166 | |
Kuninori Morimoto | 0fe1daa | 2018-02-13 02:03:12 +0000 | [diff] [blame] | 167 | ret = snd_soc_component_set_pll(component, WM5110_FLL2, |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 168 | ARIZONA_FLL_SRC_MCLK1, |
| 169 | MCLK_RATE, |
| 170 | asyncclk_rate); |
| 171 | if (ret < 0) { |
Kuninori Morimoto | 0fe1daa | 2018-02-13 02:03:12 +0000 | [diff] [blame] | 172 | dev_err(component->dev, "Failed to start FLL2: %d\n", ret); |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 173 | return ret; |
| 174 | } |
| 175 | |
Kuninori Morimoto | 0fe1daa | 2018-02-13 02:03:12 +0000 | [diff] [blame] | 176 | ret = snd_soc_component_set_sysclk(component, ARIZONA_CLK_ASYNCCLK, |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 177 | ARIZONA_CLK_SRC_FLL2, |
| 178 | asyncclk_rate, |
| 179 | SND_SOC_CLOCK_IN); |
| 180 | if (ret < 0) { |
Kuninori Morimoto | 0fe1daa | 2018-02-13 02:03:12 +0000 | [diff] [blame] | 181 | dev_err(component->dev, "Failed to set ASYNCCLK source: %d\n", ret); |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 182 | return ret; |
| 183 | } |
| 184 | |
| 185 | return 0; |
| 186 | } |
| 187 | |
| 188 | static int tm2_aif2_hw_free(struct snd_pcm_substream *substream) |
| 189 | { |
Kuninori Morimoto | c101ce8 | 2020-07-20 10:18:14 +0900 | [diff] [blame] | 190 | struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
Kuninori Morimoto | 7de6b6b | 2020-03-23 14:20:20 +0900 | [diff] [blame] | 191 | struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component; |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 192 | int ret; |
| 193 | |
| 194 | /* disable FLL2 */ |
Kuninori Morimoto | 0fe1daa | 2018-02-13 02:03:12 +0000 | [diff] [blame] | 195 | ret = snd_soc_component_set_pll(component, WM5110_FLL2, ARIZONA_FLL_SRC_MCLK1, |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 196 | 0, 0); |
| 197 | if (ret < 0) |
Kuninori Morimoto | 0fe1daa | 2018-02-13 02:03:12 +0000 | [diff] [blame] | 198 | dev_err(component->dev, "Failed to stop FLL2: %d\n", ret); |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 199 | |
| 200 | return ret; |
| 201 | } |
| 202 | |
Rikard Falkeborn | 2080acf | 2021-07-28 19:25:48 +0200 | [diff] [blame] | 203 | static const struct snd_soc_ops tm2_aif2_ops = { |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 204 | .hw_params = tm2_aif2_hw_params, |
| 205 | .hw_free = tm2_aif2_hw_free, |
| 206 | }; |
| 207 | |
Sylwester Nawrocki | 8d1513c | 2018-02-12 17:15:37 +0100 | [diff] [blame] | 208 | static int tm2_hdmi_hw_params(struct snd_pcm_substream *substream, |
| 209 | struct snd_pcm_hw_params *params) |
| 210 | { |
Kuninori Morimoto | c101ce8 | 2020-07-20 10:18:14 +0900 | [diff] [blame] | 211 | struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
Kuninori Morimoto | 7de6b6b | 2020-03-23 14:20:20 +0900 | [diff] [blame] | 212 | struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0); |
Sylwester Nawrocki | 8d1513c | 2018-02-12 17:15:37 +0100 | [diff] [blame] | 213 | unsigned int bfs; |
| 214 | int bitwidth, ret; |
| 215 | |
| 216 | bitwidth = snd_pcm_format_width(params_format(params)); |
| 217 | if (bitwidth < 0) { |
| 218 | dev_err(rtd->card->dev, "Invalid bit-width: %d\n", bitwidth); |
| 219 | return bitwidth; |
| 220 | } |
| 221 | |
| 222 | switch (bitwidth) { |
| 223 | case 48: |
| 224 | bfs = 64; |
| 225 | break; |
| 226 | case 16: |
| 227 | bfs = 32; |
| 228 | break; |
| 229 | default: |
| 230 | dev_err(rtd->card->dev, "Unsupported bit-width: %d\n", bitwidth); |
| 231 | return -EINVAL; |
| 232 | } |
| 233 | |
| 234 | switch (params_rate(params)) { |
| 235 | case 48000: |
| 236 | case 96000: |
| 237 | case 192000: |
| 238 | break; |
| 239 | default: |
| 240 | dev_err(rtd->card->dev, "Unsupported sample rate: %d\n", |
| 241 | params_rate(params)); |
| 242 | return -EINVAL; |
| 243 | } |
| 244 | |
| 245 | ret = snd_soc_dai_set_sysclk(cpu_dai, SAMSUNG_I2S_OPCLK, |
| 246 | 0, SAMSUNG_I2S_OPCLK_PCLK); |
| 247 | if (ret < 0) |
| 248 | return ret; |
| 249 | |
| 250 | ret = snd_soc_dai_set_clkdiv(cpu_dai, SAMSUNG_I2S_DIV_BCLK, bfs); |
| 251 | if (ret < 0) |
| 252 | return ret; |
| 253 | |
| 254 | return 0; |
| 255 | } |
| 256 | |
Rikard Falkeborn | 2080acf | 2021-07-28 19:25:48 +0200 | [diff] [blame] | 257 | static const struct snd_soc_ops tm2_hdmi_ops = { |
Sylwester Nawrocki | 8d1513c | 2018-02-12 17:15:37 +0100 | [diff] [blame] | 258 | .hw_params = tm2_hdmi_hw_params, |
| 259 | }; |
| 260 | |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 261 | static int tm2_mic_bias(struct snd_soc_dapm_widget *w, |
| 262 | struct snd_kcontrol *kcontrol, int event) |
| 263 | { |
| 264 | struct snd_soc_card *card = w->dapm->card; |
| 265 | struct tm2_machine_priv *priv = snd_soc_card_get_drvdata(card); |
| 266 | |
| 267 | switch (event) { |
| 268 | case SND_SOC_DAPM_PRE_PMU: |
| 269 | gpiod_set_value_cansleep(priv->gpio_mic_bias, 1); |
| 270 | break; |
| 271 | case SND_SOC_DAPM_POST_PMD: |
| 272 | gpiod_set_value_cansleep(priv->gpio_mic_bias, 0); |
| 273 | break; |
| 274 | } |
| 275 | |
| 276 | return 0; |
| 277 | } |
| 278 | |
| 279 | static int tm2_set_bias_level(struct snd_soc_card *card, |
| 280 | struct snd_soc_dapm_context *dapm, |
| 281 | enum snd_soc_bias_level level) |
| 282 | { |
| 283 | struct snd_soc_pcm_runtime *rtd; |
| 284 | |
Kuninori Morimoto | 4468189 | 2019-12-10 09:34:08 +0900 | [diff] [blame] | 285 | rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]); |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 286 | |
Kuninori Morimoto | 7de6b6b | 2020-03-23 14:20:20 +0900 | [diff] [blame] | 287 | if (dapm->dev != asoc_rtd_to_codec(rtd, 0)->dev) |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 288 | return 0; |
| 289 | |
| 290 | switch (level) { |
| 291 | case SND_SOC_BIAS_STANDBY: |
| 292 | if (card->dapm.bias_level == SND_SOC_BIAS_OFF) |
| 293 | tm2_start_sysclk(card); |
| 294 | break; |
| 295 | case SND_SOC_BIAS_OFF: |
| 296 | tm2_stop_sysclk(card); |
| 297 | break; |
| 298 | default: |
| 299 | break; |
| 300 | } |
| 301 | |
| 302 | return 0; |
| 303 | } |
| 304 | |
| 305 | static struct snd_soc_aux_dev tm2_speaker_amp_dev; |
| 306 | |
| 307 | static int tm2_late_probe(struct snd_soc_card *card) |
| 308 | { |
| 309 | struct tm2_machine_priv *priv = snd_soc_card_get_drvdata(card); |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 310 | unsigned int ch_map[] = { 0, 1 }; |
| 311 | struct snd_soc_dai *amp_pdm_dai; |
| 312 | struct snd_soc_pcm_runtime *rtd; |
| 313 | struct snd_soc_dai *aif1_dai; |
| 314 | struct snd_soc_dai *aif2_dai; |
| 315 | int ret; |
| 316 | |
Kuninori Morimoto | 4468189 | 2019-12-10 09:34:08 +0900 | [diff] [blame] | 317 | rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[TM2_DAI_AIF1]); |
Kuninori Morimoto | 7de6b6b | 2020-03-23 14:20:20 +0900 | [diff] [blame] | 318 | aif1_dai = asoc_rtd_to_codec(rtd, 0); |
| 319 | priv->component = asoc_rtd_to_codec(rtd, 0)->component; |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 320 | |
| 321 | ret = snd_soc_dai_set_sysclk(aif1_dai, ARIZONA_CLK_SYSCLK, 0, 0); |
| 322 | if (ret < 0) { |
| 323 | dev_err(aif1_dai->dev, "Failed to set SYSCLK: %d\n", ret); |
| 324 | return ret; |
| 325 | } |
| 326 | |
Kuninori Morimoto | 4468189 | 2019-12-10 09:34:08 +0900 | [diff] [blame] | 327 | rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[TM2_DAI_AIF2]); |
Kuninori Morimoto | 7de6b6b | 2020-03-23 14:20:20 +0900 | [diff] [blame] | 328 | aif2_dai = asoc_rtd_to_codec(rtd, 0); |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 329 | |
| 330 | ret = snd_soc_dai_set_sysclk(aif2_dai, ARIZONA_CLK_ASYNCCLK, 0, 0); |
| 331 | if (ret < 0) { |
| 332 | dev_err(aif2_dai->dev, "Failed to set ASYNCCLK: %d\n", ret); |
| 333 | return ret; |
| 334 | } |
| 335 | |
Kuninori Morimoto | 1247491 | 2019-08-08 14:54:20 +0900 | [diff] [blame] | 336 | amp_pdm_dai = snd_soc_find_dai(&tm2_speaker_amp_dev.dlc); |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 337 | if (!amp_pdm_dai) |
| 338 | return -ENODEV; |
| 339 | |
| 340 | /* Set the MAX98504 V/I sense PDM Tx DAI channel mapping */ |
| 341 | ret = snd_soc_dai_set_channel_map(amp_pdm_dai, ARRAY_SIZE(ch_map), |
| 342 | ch_map, 0, NULL); |
| 343 | if (ret < 0) |
| 344 | return ret; |
| 345 | |
| 346 | ret = snd_soc_dai_set_tdm_slot(amp_pdm_dai, 0x3, 0x0, 2, 16); |
| 347 | if (ret < 0) |
| 348 | return ret; |
| 349 | |
| 350 | return 0; |
| 351 | } |
| 352 | |
| 353 | static const struct snd_kcontrol_new tm2_controls[] = { |
| 354 | SOC_DAPM_PIN_SWITCH("HP"), |
| 355 | SOC_DAPM_PIN_SWITCH("SPK"), |
| 356 | SOC_DAPM_PIN_SWITCH("RCV"), |
| 357 | SOC_DAPM_PIN_SWITCH("VPS"), |
| 358 | SOC_DAPM_PIN_SWITCH("HDMI"), |
| 359 | |
| 360 | SOC_DAPM_PIN_SWITCH("Main Mic"), |
| 361 | SOC_DAPM_PIN_SWITCH("Sub Mic"), |
| 362 | SOC_DAPM_PIN_SWITCH("Third Mic"), |
| 363 | |
| 364 | SOC_DAPM_PIN_SWITCH("Headset Mic"), |
| 365 | }; |
| 366 | |
Colin Ian King | fa99125 | 2017-08-13 16:37:15 +0100 | [diff] [blame] | 367 | static const struct snd_soc_dapm_widget tm2_dapm_widgets[] = { |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 368 | SND_SOC_DAPM_HP("HP", NULL), |
| 369 | SND_SOC_DAPM_SPK("SPK", NULL), |
| 370 | SND_SOC_DAPM_SPK("RCV", NULL), |
| 371 | SND_SOC_DAPM_LINE("VPS", NULL), |
| 372 | SND_SOC_DAPM_LINE("HDMI", NULL), |
| 373 | |
| 374 | SND_SOC_DAPM_MIC("Main Mic", tm2_mic_bias), |
| 375 | SND_SOC_DAPM_MIC("Sub Mic", NULL), |
| 376 | SND_SOC_DAPM_MIC("Third Mic", NULL), |
| 377 | |
| 378 | SND_SOC_DAPM_MIC("Headset Mic", NULL), |
| 379 | }; |
| 380 | |
| 381 | static const struct snd_soc_component_driver tm2_component = { |
| 382 | .name = "tm2-audio", |
| 383 | }; |
| 384 | |
| 385 | static struct snd_soc_dai_driver tm2_ext_dai[] = { |
| 386 | { |
| 387 | .name = "Voice call", |
| 388 | .playback = { |
| 389 | .channels_min = 1, |
| 390 | .channels_max = 4, |
| 391 | .rate_min = 8000, |
| 392 | .rate_max = 48000, |
| 393 | .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 | |
| 394 | SNDRV_PCM_RATE_48000), |
| 395 | .formats = SNDRV_PCM_FMTBIT_S16_LE, |
| 396 | }, |
| 397 | .capture = { |
| 398 | .channels_min = 1, |
| 399 | .channels_max = 4, |
| 400 | .rate_min = 8000, |
| 401 | .rate_max = 48000, |
| 402 | .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 | |
| 403 | SNDRV_PCM_RATE_48000), |
| 404 | .formats = SNDRV_PCM_FMTBIT_S16_LE, |
| 405 | }, |
| 406 | }, |
| 407 | { |
| 408 | .name = "Bluetooth", |
| 409 | .playback = { |
| 410 | .channels_min = 1, |
| 411 | .channels_max = 4, |
| 412 | .rate_min = 8000, |
| 413 | .rate_max = 16000, |
| 414 | .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000), |
| 415 | .formats = SNDRV_PCM_FMTBIT_S16_LE, |
| 416 | }, |
| 417 | .capture = { |
| 418 | .channels_min = 1, |
| 419 | .channels_max = 2, |
| 420 | .rate_min = 8000, |
| 421 | .rate_max = 16000, |
| 422 | .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000), |
| 423 | .formats = SNDRV_PCM_FMTBIT_S16_LE, |
| 424 | }, |
| 425 | }, |
| 426 | }; |
| 427 | |
Kuninori Morimoto | f1d26f2 | 2019-06-06 13:09:44 +0900 | [diff] [blame] | 428 | SND_SOC_DAILINK_DEFS(aif1, |
| 429 | DAILINK_COMP_ARRAY(COMP_CPU(SAMSUNG_I2S_DAI)), |
Kuninori Morimoto | 74a25f3 | 2019-06-28 10:48:27 +0900 | [diff] [blame] | 430 | DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "wm5110-aif1")), |
| 431 | DAILINK_COMP_ARRAY(COMP_EMPTY())); |
Kuninori Morimoto | f1d26f2 | 2019-06-06 13:09:44 +0900 | [diff] [blame] | 432 | |
| 433 | SND_SOC_DAILINK_DEFS(voice, |
| 434 | DAILINK_COMP_ARRAY(COMP_CPU(SAMSUNG_I2S_DAI)), |
Kuninori Morimoto | 74a25f3 | 2019-06-28 10:48:27 +0900 | [diff] [blame] | 435 | DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "wm5110-aif2")), |
| 436 | DAILINK_COMP_ARRAY(COMP_EMPTY())); |
Kuninori Morimoto | f1d26f2 | 2019-06-06 13:09:44 +0900 | [diff] [blame] | 437 | |
| 438 | SND_SOC_DAILINK_DEFS(bt, |
| 439 | DAILINK_COMP_ARRAY(COMP_CPU(SAMSUNG_I2S_DAI)), |
Kuninori Morimoto | 74a25f3 | 2019-06-28 10:48:27 +0900 | [diff] [blame] | 440 | DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "wm5110-aif3")), |
| 441 | DAILINK_COMP_ARRAY(COMP_EMPTY())); |
Kuninori Morimoto | f1d26f2 | 2019-06-06 13:09:44 +0900 | [diff] [blame] | 442 | |
| 443 | SND_SOC_DAILINK_DEFS(hdmi, |
| 444 | DAILINK_COMP_ARRAY(COMP_EMPTY()), |
Kuninori Morimoto | 74a25f3 | 2019-06-28 10:48:27 +0900 | [diff] [blame] | 445 | DAILINK_COMP_ARRAY(COMP_EMPTY()), |
Kuninori Morimoto | f1d26f2 | 2019-06-06 13:09:44 +0900 | [diff] [blame] | 446 | DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 447 | |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 448 | static struct snd_soc_dai_link tm2_dai_links[] = { |
| 449 | { |
| 450 | .name = "WM5110 AIF1", |
| 451 | .stream_name = "HiFi Primary", |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 452 | .ops = &tm2_aif1_ops, |
| 453 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | |
| 454 | SND_SOC_DAIFMT_CBM_CFM, |
Kuninori Morimoto | f1d26f2 | 2019-06-06 13:09:44 +0900 | [diff] [blame] | 455 | SND_SOC_DAILINK_REG(aif1), |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 456 | }, { |
| 457 | .name = "WM5110 Voice", |
| 458 | .stream_name = "Voice call", |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 459 | .ops = &tm2_aif2_ops, |
| 460 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | |
| 461 | SND_SOC_DAIFMT_CBM_CFM, |
| 462 | .ignore_suspend = 1, |
Kuninori Morimoto | f1d26f2 | 2019-06-06 13:09:44 +0900 | [diff] [blame] | 463 | SND_SOC_DAILINK_REG(voice), |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 464 | }, { |
| 465 | .name = "WM5110 BT", |
| 466 | .stream_name = "Bluetooth", |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 467 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | |
| 468 | SND_SOC_DAIFMT_CBM_CFM, |
| 469 | .ignore_suspend = 1, |
Kuninori Morimoto | f1d26f2 | 2019-06-06 13:09:44 +0900 | [diff] [blame] | 470 | SND_SOC_DAILINK_REG(bt), |
Sylwester Nawrocki | 8d1513c | 2018-02-12 17:15:37 +0100 | [diff] [blame] | 471 | }, { |
| 472 | .name = "HDMI", |
| 473 | .stream_name = "i2s1", |
| 474 | .ops = &tm2_hdmi_ops, |
| 475 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | |
| 476 | SND_SOC_DAIFMT_CBS_CFS, |
Kuninori Morimoto | f1d26f2 | 2019-06-06 13:09:44 +0900 | [diff] [blame] | 477 | SND_SOC_DAILINK_REG(hdmi), |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 478 | } |
| 479 | }; |
| 480 | |
| 481 | static struct snd_soc_card tm2_card = { |
| 482 | .owner = THIS_MODULE, |
| 483 | |
| 484 | .dai_link = tm2_dai_links, |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 485 | .controls = tm2_controls, |
| 486 | .num_controls = ARRAY_SIZE(tm2_controls), |
| 487 | .dapm_widgets = tm2_dapm_widgets, |
| 488 | .num_dapm_widgets = ARRAY_SIZE(tm2_dapm_widgets), |
| 489 | .aux_dev = &tm2_speaker_amp_dev, |
| 490 | .num_aux_devs = 1, |
| 491 | |
| 492 | .late_probe = tm2_late_probe, |
| 493 | .set_bias_level = tm2_set_bias_level, |
| 494 | }; |
| 495 | |
| 496 | static int tm2_probe(struct platform_device *pdev) |
| 497 | { |
Sylwester Nawrocki | 8d1513c | 2018-02-12 17:15:37 +0100 | [diff] [blame] | 498 | struct device_node *cpu_dai_node[2] = {}; |
| 499 | struct device_node *codec_dai_node[2] = {}; |
| 500 | const char *cells_name = NULL; |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 501 | struct device *dev = &pdev->dev; |
| 502 | struct snd_soc_card *card = &tm2_card; |
| 503 | struct tm2_machine_priv *priv; |
Kuninori Morimoto | 7fe072b | 2018-09-18 01:28:49 +0000 | [diff] [blame] | 504 | struct snd_soc_dai_link *dai_link; |
Sylwester Nawrocki | 8d1513c | 2018-02-12 17:15:37 +0100 | [diff] [blame] | 505 | int num_codecs, ret, i; |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 506 | |
| 507 | priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); |
| 508 | if (!priv) |
| 509 | return -ENOMEM; |
| 510 | |
| 511 | snd_soc_card_set_drvdata(card, priv); |
| 512 | card->dev = dev; |
| 513 | |
Jaechul Lee | 975b6a9 | 2017-09-06 10:04:15 +0900 | [diff] [blame] | 514 | priv->gpio_mic_bias = devm_gpiod_get(dev, "mic-bias", GPIOD_OUT_HIGH); |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 515 | if (IS_ERR(priv->gpio_mic_bias)) { |
| 516 | dev_err(dev, "Failed to get mic bias gpio\n"); |
| 517 | return PTR_ERR(priv->gpio_mic_bias); |
| 518 | } |
| 519 | |
| 520 | ret = snd_soc_of_parse_card_name(card, "model"); |
| 521 | if (ret < 0) { |
| 522 | dev_err(dev, "Card name is not specified\n"); |
| 523 | return ret; |
| 524 | } |
| 525 | |
| 526 | ret = snd_soc_of_parse_audio_routing(card, "samsung,audio-routing"); |
| 527 | if (ret < 0) { |
| 528 | dev_err(dev, "Audio routing is not specified or invalid\n"); |
| 529 | return ret; |
| 530 | } |
| 531 | |
Kuninori Morimoto | 1247491 | 2019-08-08 14:54:20 +0900 | [diff] [blame] | 532 | card->aux_dev[0].dlc.of_node = of_parse_phandle(dev->of_node, |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 533 | "audio-amplifier", 0); |
Kuninori Morimoto | 1247491 | 2019-08-08 14:54:20 +0900 | [diff] [blame] | 534 | if (!card->aux_dev[0].dlc.of_node) { |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 535 | dev_err(dev, "audio-amplifier property invalid or missing\n"); |
| 536 | return -EINVAL; |
| 537 | } |
| 538 | |
Sylwester Nawrocki | 8d1513c | 2018-02-12 17:15:37 +0100 | [diff] [blame] | 539 | num_codecs = of_count_phandle_with_args(dev->of_node, "audio-codec", |
| 540 | NULL); |
| 541 | |
| 542 | /* Skip the HDMI link if not specified in DT */ |
| 543 | if (num_codecs > 1) { |
| 544 | card->num_links = ARRAY_SIZE(tm2_dai_links); |
| 545 | cells_name = "#sound-dai-cells"; |
| 546 | } else { |
| 547 | card->num_links = ARRAY_SIZE(tm2_dai_links) - 1; |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 548 | } |
| 549 | |
Sylwester Nawrocki | 8d1513c | 2018-02-12 17:15:37 +0100 | [diff] [blame] | 550 | for (i = 0; i < num_codecs; i++) { |
| 551 | struct of_phandle_args args; |
| 552 | |
| 553 | ret = of_parse_phandle_with_args(dev->of_node, "i2s-controller", |
| 554 | cells_name, i, &args); |
Pierre-Louis Bossart | d58970d | 2021-03-12 12:02:30 -0600 | [diff] [blame] | 555 | if (ret) { |
Sylwester Nawrocki | 8d1513c | 2018-02-12 17:15:37 +0100 | [diff] [blame] | 556 | dev_err(dev, "i2s-controller property parse error: %d\n", i); |
| 557 | ret = -EINVAL; |
| 558 | goto dai_node_put; |
| 559 | } |
| 560 | cpu_dai_node[i] = args.np; |
| 561 | |
| 562 | codec_dai_node[i] = of_parse_phandle(dev->of_node, |
| 563 | "audio-codec", i); |
| 564 | if (!codec_dai_node[i]) { |
| 565 | dev_err(dev, "audio-codec property parse error\n"); |
| 566 | ret = -EINVAL; |
| 567 | goto dai_node_put; |
| 568 | } |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 569 | } |
| 570 | |
Sylwester Nawrocki | 8d1513c | 2018-02-12 17:15:37 +0100 | [diff] [blame] | 571 | /* Initialize WM5110 - I2S and HDMI - I2S1 DAI links */ |
Kuninori Morimoto | 7fe072b | 2018-09-18 01:28:49 +0000 | [diff] [blame] | 572 | for_each_card_prelinks(card, i, dai_link) { |
Sylwester Nawrocki | 8d1513c | 2018-02-12 17:15:37 +0100 | [diff] [blame] | 573 | unsigned int dai_index = 0; /* WM5110 */ |
| 574 | |
Kuninori Morimoto | f1d26f2 | 2019-06-06 13:09:44 +0900 | [diff] [blame] | 575 | dai_link->cpus->name = NULL; |
Kuninori Morimoto | 74a25f3 | 2019-06-28 10:48:27 +0900 | [diff] [blame] | 576 | dai_link->platforms->name = NULL; |
Sylwester Nawrocki | 8d1513c | 2018-02-12 17:15:37 +0100 | [diff] [blame] | 577 | |
| 578 | if (num_codecs > 1 && i == card->num_links - 1) |
| 579 | dai_index = 1; /* HDMI */ |
| 580 | |
Kuninori Morimoto | f1d26f2 | 2019-06-06 13:09:44 +0900 | [diff] [blame] | 581 | dai_link->codecs->of_node = codec_dai_node[dai_index]; |
| 582 | dai_link->cpus->of_node = cpu_dai_node[dai_index]; |
Kuninori Morimoto | 74a25f3 | 2019-06-28 10:48:27 +0900 | [diff] [blame] | 583 | dai_link->platforms->of_node = cpu_dai_node[dai_index]; |
Sylwester Nawrocki | 8d1513c | 2018-02-12 17:15:37 +0100 | [diff] [blame] | 584 | } |
| 585 | |
| 586 | if (num_codecs > 1) { |
Pierre-Louis Bossart | f7b6128 | 2021-03-12 12:02:31 -0600 | [diff] [blame] | 587 | struct of_phandle_args args; |
| 588 | |
Sylwester Nawrocki | 8d1513c | 2018-02-12 17:15:37 +0100 | [diff] [blame] | 589 | /* HDMI DAI link (I2S1) */ |
| 590 | i = card->num_links - 1; |
| 591 | |
| 592 | ret = of_parse_phandle_with_fixed_args(dev->of_node, |
| 593 | "audio-codec", 0, 1, &args); |
| 594 | if (ret) { |
| 595 | dev_err(dev, "audio-codec property parse error\n"); |
| 596 | goto dai_node_put; |
| 597 | } |
| 598 | |
Kuninori Morimoto | f1d26f2 | 2019-06-06 13:09:44 +0900 | [diff] [blame] | 599 | ret = snd_soc_get_dai_name(&args, &card->dai_link[i].codecs->dai_name); |
Sylwester Nawrocki | 8d1513c | 2018-02-12 17:15:37 +0100 | [diff] [blame] | 600 | if (ret) { |
| 601 | dev_err(dev, "Unable to get codec_dai_name\n"); |
| 602 | goto dai_node_put; |
| 603 | } |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 604 | } |
| 605 | |
| 606 | ret = devm_snd_soc_register_component(dev, &tm2_component, |
| 607 | tm2_ext_dai, ARRAY_SIZE(tm2_ext_dai)); |
| 608 | if (ret < 0) { |
| 609 | dev_err(dev, "Failed to register component: %d\n", ret); |
Sylwester Nawrocki | 8d1513c | 2018-02-12 17:15:37 +0100 | [diff] [blame] | 610 | goto dai_node_put; |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 611 | } |
| 612 | |
| 613 | ret = devm_snd_soc_register_card(dev, card); |
| 614 | if (ret < 0) { |
Marek Szyprowski | 1a1b374 | 2020-02-28 11:11:20 +0100 | [diff] [blame] | 615 | if (ret != -EPROBE_DEFER) |
| 616 | dev_err(dev, "Failed to register card: %d\n", ret); |
Sylwester Nawrocki | 8d1513c | 2018-02-12 17:15:37 +0100 | [diff] [blame] | 617 | goto dai_node_put; |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 618 | } |
| 619 | |
Sylwester Nawrocki | 8d1513c | 2018-02-12 17:15:37 +0100 | [diff] [blame] | 620 | dai_node_put: |
| 621 | for (i = 0; i < num_codecs; i++) { |
| 622 | of_node_put(codec_dai_node[i]); |
| 623 | of_node_put(cpu_dai_node[i]); |
| 624 | } |
| 625 | |
Kuninori Morimoto | 1247491 | 2019-08-08 14:54:20 +0900 | [diff] [blame] | 626 | of_node_put(card->aux_dev[0].dlc.of_node); |
Sylwester Nawrocki | 8d1513c | 2018-02-12 17:15:37 +0100 | [diff] [blame] | 627 | |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 628 | return ret; |
| 629 | } |
| 630 | |
| 631 | static int tm2_pm_prepare(struct device *dev) |
| 632 | { |
| 633 | struct snd_soc_card *card = dev_get_drvdata(dev); |
| 634 | |
| 635 | return tm2_stop_sysclk(card); |
| 636 | } |
| 637 | |
| 638 | static void tm2_pm_complete(struct device *dev) |
| 639 | { |
| 640 | struct snd_soc_card *card = dev_get_drvdata(dev); |
| 641 | |
| 642 | tm2_start_sysclk(card); |
| 643 | } |
| 644 | |
Colin Ian King | fa99125 | 2017-08-13 16:37:15 +0100 | [diff] [blame] | 645 | static const struct dev_pm_ops tm2_pm_ops = { |
Sylwester Nawrocki | 1bfbc26 | 2016-11-02 17:05:45 +0100 | [diff] [blame] | 646 | .prepare = tm2_pm_prepare, |
| 647 | .suspend = snd_soc_suspend, |
| 648 | .resume = snd_soc_resume, |
| 649 | .complete = tm2_pm_complete, |
| 650 | .freeze = snd_soc_suspend, |
| 651 | .thaw = snd_soc_resume, |
| 652 | .poweroff = snd_soc_poweroff, |
| 653 | .restore = snd_soc_resume, |
| 654 | }; |
| 655 | |
| 656 | static const struct of_device_id tm2_of_match[] = { |
| 657 | { .compatible = "samsung,tm2-audio" }, |
| 658 | { }, |
| 659 | }; |
| 660 | MODULE_DEVICE_TABLE(of, tm2_of_match); |
| 661 | |
| 662 | static struct platform_driver tm2_driver = { |
| 663 | .driver = { |
| 664 | .name = "tm2-audio", |
| 665 | .pm = &tm2_pm_ops, |
| 666 | .of_match_table = tm2_of_match, |
| 667 | }, |
| 668 | .probe = tm2_probe, |
| 669 | }; |
| 670 | module_platform_driver(tm2_driver); |
| 671 | |
| 672 | MODULE_AUTHOR("Inha Song <ideal.song@samsung.com>"); |
| 673 | MODULE_DESCRIPTION("ALSA SoC Exynos TM2 Audio Support"); |
| 674 | MODULE_LICENSE("GPL v2"); |