Ryder Lee | 3a280ed | 2018-04-25 12:19:59 +0800 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 2 | /* |
| 3 | * mt8173-rt5650-rt5676.c -- MT8173 machine driver with RT5650/5676 codecs |
| 4 | * |
| 5 | * Copyright (c) 2015 MediaTek Inc. |
| 6 | * Author: Koro Chen <koro.chen@mediatek.com> |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <linux/module.h> |
| 10 | #include <linux/gpio.h> |
| 11 | #include <linux/of_gpio.h> |
| 12 | #include <sound/soc.h> |
| 13 | #include <sound/jack.h> |
Garlic Tseng | 0d1d7a6 | 2016-06-17 15:43:52 +0800 | [diff] [blame] | 14 | #include "../../codecs/rt5645.h" |
| 15 | #include "../../codecs/rt5677.h" |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 16 | |
| 17 | #define MCLK_FOR_CODECS 12288000 |
| 18 | |
| 19 | static const struct snd_soc_dapm_widget mt8173_rt5650_rt5676_widgets[] = { |
| 20 | SND_SOC_DAPM_SPK("Speaker", NULL), |
| 21 | SND_SOC_DAPM_MIC("Int Mic", NULL), |
| 22 | SND_SOC_DAPM_HP("Headphone", NULL), |
| 23 | SND_SOC_DAPM_MIC("Headset Mic", NULL), |
| 24 | }; |
| 25 | |
| 26 | static const struct snd_soc_dapm_route mt8173_rt5650_rt5676_routes[] = { |
| 27 | {"Speaker", NULL, "SPOL"}, |
| 28 | {"Speaker", NULL, "SPOR"}, |
| 29 | {"Speaker", NULL, "Sub AIF2TX"}, /* IF2 ADC to 5650 */ |
| 30 | {"Sub DMIC L1", NULL, "Int Mic"}, /* DMIC from 5676 */ |
| 31 | {"Sub DMIC R1", NULL, "Int Mic"}, |
| 32 | {"Headphone", NULL, "HPOL"}, |
| 33 | {"Headphone", NULL, "HPOR"}, |
| 34 | {"Headphone", NULL, "Sub AIF2TX"}, /* IF2 ADC to 5650 */ |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 35 | {"IN1P", NULL, "Headset Mic"}, |
| 36 | {"IN1N", NULL, "Headset Mic"}, |
| 37 | {"Sub AIF2RX", NULL, "Headset Mic"}, /* IF2 DAC from 5650 */ |
| 38 | }; |
| 39 | |
| 40 | static const struct snd_kcontrol_new mt8173_rt5650_rt5676_controls[] = { |
| 41 | SOC_DAPM_PIN_SWITCH("Speaker"), |
| 42 | SOC_DAPM_PIN_SWITCH("Int Mic"), |
| 43 | SOC_DAPM_PIN_SWITCH("Headphone"), |
| 44 | SOC_DAPM_PIN_SWITCH("Headset Mic"), |
| 45 | }; |
| 46 | |
| 47 | static int mt8173_rt5650_rt5676_hw_params(struct snd_pcm_substream *substream, |
| 48 | struct snd_pcm_hw_params *params) |
| 49 | { |
Kuninori Morimoto | 0cd08b1 | 2020-07-20 10:18:48 +0900 | [diff] [blame] | 50 | struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); |
Kuninori Morimoto | 0b7990e | 2018-09-03 02:12:56 +0000 | [diff] [blame] | 51 | struct snd_soc_dai *codec_dai; |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 52 | int i, ret; |
| 53 | |
Kuninori Morimoto | c865452 | 2020-03-09 13:07:42 +0900 | [diff] [blame] | 54 | for_each_rtd_codec_dais(rtd, i, codec_dai) { |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 55 | /* pll from mclk 12.288M */ |
| 56 | ret = snd_soc_dai_set_pll(codec_dai, 0, 0, MCLK_FOR_CODECS, |
| 57 | params_rate(params) * 512); |
| 58 | if (ret) |
| 59 | return ret; |
| 60 | |
| 61 | /* sysclk from pll */ |
| 62 | ret = snd_soc_dai_set_sysclk(codec_dai, 1, |
| 63 | params_rate(params) * 512, |
| 64 | SND_SOC_CLOCK_IN); |
| 65 | if (ret) |
| 66 | return ret; |
| 67 | } |
| 68 | return 0; |
| 69 | } |
| 70 | |
Bhumika Goyal | 424dfbf | 2017-03-18 23:13:14 +0530 | [diff] [blame] | 71 | static const struct snd_soc_ops mt8173_rt5650_rt5676_ops = { |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 72 | .hw_params = mt8173_rt5650_rt5676_hw_params, |
| 73 | }; |
| 74 | |
| 75 | static struct snd_soc_jack mt8173_rt5650_rt5676_jack; |
| 76 | |
| 77 | static int mt8173_rt5650_rt5676_init(struct snd_soc_pcm_runtime *runtime) |
| 78 | { |
| 79 | struct snd_soc_card *card = runtime->card; |
Kuninori Morimoto | c8ac821 | 2020-03-23 14:19:23 +0900 | [diff] [blame] | 80 | struct snd_soc_component *component = asoc_rtd_to_codec(runtime, 0)->component; |
| 81 | struct snd_soc_component *component_sub = asoc_rtd_to_codec(runtime, 1)->component; |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 82 | int ret; |
| 83 | |
Kuninori Morimoto | 79223bf | 2018-01-29 03:49:31 +0000 | [diff] [blame] | 84 | rt5645_sel_asrc_clk_src(component, |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 85 | RT5645_DA_STEREO_FILTER | |
| 86 | RT5645_AD_STEREO_FILTER, |
| 87 | RT5645_CLK_SEL_I2S1_ASRC); |
Kuninori Morimoto | 79223bf | 2018-01-29 03:49:31 +0000 | [diff] [blame] | 88 | rt5677_sel_asrc_clk_src(component_sub, |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 89 | RT5677_DA_STEREO_FILTER | |
| 90 | RT5677_AD_STEREO1_FILTER, |
| 91 | RT5677_CLK_SEL_I2S1_ASRC); |
Kuninori Morimoto | 79223bf | 2018-01-29 03:49:31 +0000 | [diff] [blame] | 92 | rt5677_sel_asrc_clk_src(component_sub, |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 93 | RT5677_AD_STEREO2_FILTER | |
| 94 | RT5677_I2S2_SOURCE, |
| 95 | RT5677_CLK_SEL_I2S2_ASRC); |
| 96 | |
| 97 | /* enable jack detection */ |
| 98 | ret = snd_soc_card_jack_new(card, "Headset Jack", |
| 99 | SND_JACK_HEADPHONE | SND_JACK_MICROPHONE | |
| 100 | SND_JACK_BTN_0 | SND_JACK_BTN_1 | |
| 101 | SND_JACK_BTN_2 | SND_JACK_BTN_3, |
| 102 | &mt8173_rt5650_rt5676_jack, NULL, 0); |
| 103 | if (ret) { |
| 104 | dev_err(card->dev, "Can't new Headset Jack %d\n", ret); |
| 105 | return ret; |
| 106 | } |
| 107 | |
Kuninori Morimoto | 79223bf | 2018-01-29 03:49:31 +0000 | [diff] [blame] | 108 | return rt5645_set_jack_detect(component, |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 109 | &mt8173_rt5650_rt5676_jack, |
| 110 | &mt8173_rt5650_rt5676_jack, |
| 111 | &mt8173_rt5650_rt5676_jack); |
| 112 | } |
| 113 | |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 114 | |
Philipp Zabel | 05f5afd | 2016-03-02 15:49:06 +0100 | [diff] [blame] | 115 | enum { |
| 116 | DAI_LINK_PLAYBACK, |
| 117 | DAI_LINK_CAPTURE, |
Koro Chen | c0133e3 | 2016-04-20 10:59:56 +0200 | [diff] [blame] | 118 | DAI_LINK_HDMI, |
Philipp Zabel | 05f5afd | 2016-03-02 15:49:06 +0100 | [diff] [blame] | 119 | DAI_LINK_CODEC_I2S, |
Koro Chen | c0133e3 | 2016-04-20 10:59:56 +0200 | [diff] [blame] | 120 | DAI_LINK_HDMI_I2S, |
Philipp Zabel | 05f5afd | 2016-03-02 15:49:06 +0100 | [diff] [blame] | 121 | DAI_LINK_INTERCODEC |
| 122 | }; |
| 123 | |
Kuninori Morimoto | 05ab661 | 2019-06-06 13:08:23 +0900 | [diff] [blame] | 124 | SND_SOC_DAILINK_DEFS(playback, |
| 125 | DAILINK_COMP_ARRAY(COMP_CPU("DL1")), |
| 126 | DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 127 | DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 128 | |
| 129 | SND_SOC_DAILINK_DEFS(capture, |
| 130 | DAILINK_COMP_ARRAY(COMP_CPU("VUL")), |
| 131 | DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 132 | DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 133 | |
| 134 | SND_SOC_DAILINK_DEFS(hdmi_pcm, |
| 135 | DAILINK_COMP_ARRAY(COMP_CPU("HDMI")), |
| 136 | DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 137 | DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 138 | |
| 139 | SND_SOC_DAILINK_DEFS(codec, |
| 140 | DAILINK_COMP_ARRAY(COMP_CPU("I2S")), |
| 141 | DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "rt5645-aif1"), |
| 142 | COMP_CODEC(NULL, "rt5677-aif1")), |
| 143 | DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 144 | |
| 145 | SND_SOC_DAILINK_DEFS(hdmi_be, |
| 146 | DAILINK_COMP_ARRAY(COMP_CPU("HDMIO")), |
| 147 | DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "i2s-hifi")), |
| 148 | DAILINK_COMP_ARRAY(COMP_EMPTY())); |
| 149 | |
| 150 | SND_SOC_DAILINK_DEFS(intercodec, |
| 151 | DAILINK_COMP_ARRAY(COMP_DUMMY()), |
| 152 | DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "rt5677-aif2")), |
| 153 | DAILINK_COMP_ARRAY(COMP_DUMMY())); |
| 154 | |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 155 | /* Digital audio interface glue - connects codec <---> CPU */ |
| 156 | static struct snd_soc_dai_link mt8173_rt5650_rt5676_dais[] = { |
| 157 | /* Front End DAI links */ |
Philipp Zabel | 05f5afd | 2016-03-02 15:49:06 +0100 | [diff] [blame] | 158 | [DAI_LINK_PLAYBACK] = { |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 159 | .name = "rt5650_rt5676 Playback", |
| 160 | .stream_name = "rt5650_rt5676 Playback", |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 161 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, |
| 162 | .dynamic = 1, |
| 163 | .dpcm_playback = 1, |
Kuninori Morimoto | 05ab661 | 2019-06-06 13:08:23 +0900 | [diff] [blame] | 164 | SND_SOC_DAILINK_REG(playback), |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 165 | }, |
Philipp Zabel | 05f5afd | 2016-03-02 15:49:06 +0100 | [diff] [blame] | 166 | [DAI_LINK_CAPTURE] = { |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 167 | .name = "rt5650_rt5676 Capture", |
| 168 | .stream_name = "rt5650_rt5676 Capture", |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 169 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, |
| 170 | .dynamic = 1, |
| 171 | .dpcm_capture = 1, |
Kuninori Morimoto | 05ab661 | 2019-06-06 13:08:23 +0900 | [diff] [blame] | 172 | SND_SOC_DAILINK_REG(capture), |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 173 | }, |
Koro Chen | c0133e3 | 2016-04-20 10:59:56 +0200 | [diff] [blame] | 174 | [DAI_LINK_HDMI] = { |
| 175 | .name = "HDMI", |
| 176 | .stream_name = "HDMI PCM", |
Koro Chen | c0133e3 | 2016-04-20 10:59:56 +0200 | [diff] [blame] | 177 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, |
| 178 | .dynamic = 1, |
| 179 | .dpcm_playback = 1, |
Kuninori Morimoto | 05ab661 | 2019-06-06 13:08:23 +0900 | [diff] [blame] | 180 | SND_SOC_DAILINK_REG(hdmi_pcm), |
Koro Chen | c0133e3 | 2016-04-20 10:59:56 +0200 | [diff] [blame] | 181 | }, |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 182 | |
| 183 | /* Back End DAI links */ |
Philipp Zabel | 05f5afd | 2016-03-02 15:49:06 +0100 | [diff] [blame] | 184 | [DAI_LINK_CODEC_I2S] = { |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 185 | .name = "Codec", |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 186 | .no_pcm = 1, |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 187 | .init = mt8173_rt5650_rt5676_init, |
| 188 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | |
| 189 | SND_SOC_DAIFMT_CBS_CFS, |
| 190 | .ops = &mt8173_rt5650_rt5676_ops, |
| 191 | .ignore_pmdown_time = 1, |
| 192 | .dpcm_playback = 1, |
| 193 | .dpcm_capture = 1, |
Kuninori Morimoto | 05ab661 | 2019-06-06 13:08:23 +0900 | [diff] [blame] | 194 | SND_SOC_DAILINK_REG(codec), |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 195 | }, |
Koro Chen | c0133e3 | 2016-04-20 10:59:56 +0200 | [diff] [blame] | 196 | [DAI_LINK_HDMI_I2S] = { |
| 197 | .name = "HDMI BE", |
Koro Chen | c0133e3 | 2016-04-20 10:59:56 +0200 | [diff] [blame] | 198 | .no_pcm = 1, |
Koro Chen | c0133e3 | 2016-04-20 10:59:56 +0200 | [diff] [blame] | 199 | .dpcm_playback = 1, |
Kuninori Morimoto | 05ab661 | 2019-06-06 13:08:23 +0900 | [diff] [blame] | 200 | SND_SOC_DAILINK_REG(hdmi_be), |
Koro Chen | c0133e3 | 2016-04-20 10:59:56 +0200 | [diff] [blame] | 201 | }, |
Philipp Zabel | 05f5afd | 2016-03-02 15:49:06 +0100 | [diff] [blame] | 202 | /* rt5676 <-> rt5650 intercodec link: Sets rt5676 I2S2 as master */ |
| 203 | [DAI_LINK_INTERCODEC] = { |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 204 | .name = "rt5650_rt5676 intercodec", |
| 205 | .stream_name = "rt5650_rt5676 intercodec", |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 206 | .no_pcm = 1, |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 207 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | |
| 208 | SND_SOC_DAIFMT_CBM_CFM, |
Kuninori Morimoto | 05ab661 | 2019-06-06 13:08:23 +0900 | [diff] [blame] | 209 | SND_SOC_DAILINK_REG(intercodec), |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 210 | }, |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 211 | }; |
| 212 | |
| 213 | static struct snd_soc_codec_conf mt8173_rt5650_rt5676_codec_conf[] = { |
| 214 | { |
| 215 | .name_prefix = "Sub", |
| 216 | }, |
| 217 | }; |
| 218 | |
| 219 | static struct snd_soc_card mt8173_rt5650_rt5676_card = { |
| 220 | .name = "mtk-rt5650-rt5676", |
Axel Lin | 54d8697 | 2015-08-21 20:59:21 +0800 | [diff] [blame] | 221 | .owner = THIS_MODULE, |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 222 | .dai_link = mt8173_rt5650_rt5676_dais, |
| 223 | .num_links = ARRAY_SIZE(mt8173_rt5650_rt5676_dais), |
| 224 | .codec_conf = mt8173_rt5650_rt5676_codec_conf, |
| 225 | .num_configs = ARRAY_SIZE(mt8173_rt5650_rt5676_codec_conf), |
| 226 | .controls = mt8173_rt5650_rt5676_controls, |
| 227 | .num_controls = ARRAY_SIZE(mt8173_rt5650_rt5676_controls), |
| 228 | .dapm_widgets = mt8173_rt5650_rt5676_widgets, |
| 229 | .num_dapm_widgets = ARRAY_SIZE(mt8173_rt5650_rt5676_widgets), |
| 230 | .dapm_routes = mt8173_rt5650_rt5676_routes, |
| 231 | .num_dapm_routes = ARRAY_SIZE(mt8173_rt5650_rt5676_routes), |
| 232 | }; |
| 233 | |
| 234 | static int mt8173_rt5650_rt5676_dev_probe(struct platform_device *pdev) |
| 235 | { |
| 236 | struct snd_soc_card *card = &mt8173_rt5650_rt5676_card; |
Koro Chen | 94319ba | 2015-07-09 10:51:27 +0800 | [diff] [blame] | 237 | struct device_node *platform_node; |
Kuninori Morimoto | 7fe072b | 2018-09-18 01:28:49 +0000 | [diff] [blame] | 238 | struct snd_soc_dai_link *dai_link; |
Koro Chen | 94319ba | 2015-07-09 10:51:27 +0800 | [diff] [blame] | 239 | int i, ret; |
| 240 | |
| 241 | platform_node = of_parse_phandle(pdev->dev.of_node, |
| 242 | "mediatek,platform", 0); |
| 243 | if (!platform_node) { |
| 244 | dev_err(&pdev->dev, "Property 'platform' missing or invalid\n"); |
| 245 | return -EINVAL; |
| 246 | } |
| 247 | |
Kuninori Morimoto | 7fe072b | 2018-09-18 01:28:49 +0000 | [diff] [blame] | 248 | for_each_card_prelinks(card, i, dai_link) { |
Kuninori Morimoto | 05ab661 | 2019-06-06 13:08:23 +0900 | [diff] [blame] | 249 | if (dai_link->platforms->name) |
Koro Chen | 94319ba | 2015-07-09 10:51:27 +0800 | [diff] [blame] | 250 | continue; |
Kuninori Morimoto | 05ab661 | 2019-06-06 13:08:23 +0900 | [diff] [blame] | 251 | dai_link->platforms->of_node = platform_node; |
Koro Chen | 94319ba | 2015-07-09 10:51:27 +0800 | [diff] [blame] | 252 | } |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 253 | |
Kuninori Morimoto | 05ab661 | 2019-06-06 13:08:23 +0900 | [diff] [blame] | 254 | mt8173_rt5650_rt5676_dais[DAI_LINK_CODEC_I2S].codecs[0].of_node = |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 255 | of_parse_phandle(pdev->dev.of_node, "mediatek,audio-codec", 0); |
Kuninori Morimoto | 05ab661 | 2019-06-06 13:08:23 +0900 | [diff] [blame] | 256 | if (!mt8173_rt5650_rt5676_dais[DAI_LINK_CODEC_I2S].codecs[0].of_node) { |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 257 | dev_err(&pdev->dev, |
| 258 | "Property 'audio-codec' missing or invalid\n"); |
| 259 | return -EINVAL; |
| 260 | } |
Kuninori Morimoto | 05ab661 | 2019-06-06 13:08:23 +0900 | [diff] [blame] | 261 | mt8173_rt5650_rt5676_dais[DAI_LINK_CODEC_I2S].codecs[1].of_node = |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 262 | of_parse_phandle(pdev->dev.of_node, "mediatek,audio-codec", 1); |
Kuninori Morimoto | 05ab661 | 2019-06-06 13:08:23 +0900 | [diff] [blame] | 263 | if (!mt8173_rt5650_rt5676_dais[DAI_LINK_CODEC_I2S].codecs[1].of_node) { |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 264 | dev_err(&pdev->dev, |
| 265 | "Property 'audio-codec' missing or invalid\n"); |
| 266 | return -EINVAL; |
| 267 | } |
Kuninori Morimoto | fe71bf9 | 2019-12-13 09:55:20 +0900 | [diff] [blame] | 268 | mt8173_rt5650_rt5676_codec_conf[0].dlc.of_node = |
Kuninori Morimoto | 05ab661 | 2019-06-06 13:08:23 +0900 | [diff] [blame] | 269 | mt8173_rt5650_rt5676_dais[DAI_LINK_CODEC_I2S].codecs[1].of_node; |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 270 | |
Kuninori Morimoto | 05ab661 | 2019-06-06 13:08:23 +0900 | [diff] [blame] | 271 | mt8173_rt5650_rt5676_dais[DAI_LINK_INTERCODEC].codecs->of_node = |
| 272 | mt8173_rt5650_rt5676_dais[DAI_LINK_CODEC_I2S].codecs[1].of_node; |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 273 | |
Kuninori Morimoto | 05ab661 | 2019-06-06 13:08:23 +0900 | [diff] [blame] | 274 | mt8173_rt5650_rt5676_dais[DAI_LINK_HDMI_I2S].codecs->of_node = |
Koro Chen | c0133e3 | 2016-04-20 10:59:56 +0200 | [diff] [blame] | 275 | of_parse_phandle(pdev->dev.of_node, "mediatek,audio-codec", 2); |
Kuninori Morimoto | 05ab661 | 2019-06-06 13:08:23 +0900 | [diff] [blame] | 276 | if (!mt8173_rt5650_rt5676_dais[DAI_LINK_HDMI_I2S].codecs->of_node) { |
Koro Chen | c0133e3 | 2016-04-20 10:59:56 +0200 | [diff] [blame] | 277 | dev_err(&pdev->dev, |
| 278 | "Property 'audio-codec' missing or invalid\n"); |
| 279 | return -EINVAL; |
| 280 | } |
| 281 | |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 282 | card->dev = &pdev->dev; |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 283 | |
Axel Lin | 887e83e | 2015-08-30 17:18:50 +0800 | [diff] [blame] | 284 | ret = devm_snd_soc_register_card(&pdev->dev, card); |
Tzung-Bi Shih | 4934337 | 2021-12-24 14:47:16 +0800 | [diff] [blame] | 285 | |
| 286 | of_node_put(platform_node); |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 287 | return ret; |
| 288 | } |
| 289 | |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 290 | static const struct of_device_id mt8173_rt5650_rt5676_dt_match[] = { |
| 291 | { .compatible = "mediatek,mt8173-rt5650-rt5676", }, |
| 292 | { } |
| 293 | }; |
| 294 | MODULE_DEVICE_TABLE(of, mt8173_rt5650_rt5676_dt_match); |
| 295 | |
| 296 | static struct platform_driver mt8173_rt5650_rt5676_driver = { |
| 297 | .driver = { |
| 298 | .name = "mtk-rt5650-rt5676", |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 299 | .of_match_table = mt8173_rt5650_rt5676_dt_match, |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 300 | .pm = &snd_soc_pm_ops, |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 301 | }, |
| 302 | .probe = mt8173_rt5650_rt5676_dev_probe, |
Koro Chen | 662e8d9 | 2015-06-15 22:38:04 +0800 | [diff] [blame] | 303 | }; |
| 304 | |
| 305 | module_platform_driver(mt8173_rt5650_rt5676_driver); |
| 306 | |
| 307 | /* Module information */ |
| 308 | MODULE_DESCRIPTION("MT8173 RT5650 and RT5676 SoC machine driver"); |
| 309 | MODULE_AUTHOR("Koro Chen <koro.chen@mediatek.com>"); |
| 310 | MODULE_LICENSE("GPL v2"); |
| 311 | MODULE_ALIAS("platform:mtk-rt5650-rt5676"); |
| 312 | |