^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * ASoC machine driver for Intel Broadwell platforms with RT5677 codec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (c) 2014, The Chromium OS Authors. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/gpio/consumer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <sound/core.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <sound/pcm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <sound/soc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <sound/pcm_params.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <sound/jack.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <sound/soc-acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include "../../codecs/rt5677.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) struct bdw_rt5677_priv {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) struct gpio_desc *gpio_hp_en;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) struct snd_soc_component *component;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) static int bdw_rt5677_event_hp(struct snd_soc_dapm_widget *w,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) struct snd_kcontrol *k, int event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) struct snd_soc_dapm_context *dapm = w->dapm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) struct snd_soc_card *card = dapm->card;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) struct bdw_rt5677_priv *bdw_rt5677 = snd_soc_card_get_drvdata(card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) if (SND_SOC_DAPM_EVENT_ON(event))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) msleep(70);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) gpiod_set_value_cansleep(bdw_rt5677->gpio_hp_en,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) SND_SOC_DAPM_EVENT_ON(event));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) static const struct snd_soc_dapm_widget bdw_rt5677_widgets[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) SND_SOC_DAPM_HP("Headphone", bdw_rt5677_event_hp),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) SND_SOC_DAPM_SPK("Speaker", NULL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) SND_SOC_DAPM_MIC("Headset Mic", NULL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) SND_SOC_DAPM_MIC("Local DMICs", NULL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) SND_SOC_DAPM_MIC("Remote DMICs", NULL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) static const struct snd_soc_dapm_route bdw_rt5677_map[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) /* Speakers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) {"Speaker", NULL, "PDM1L"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) {"Speaker", NULL, "PDM1R"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) /* Headset jack connectors */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) {"Headphone", NULL, "LOUT1"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) {"Headphone", NULL, "LOUT2"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) {"IN1P", NULL, "Headset Mic"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) {"IN1N", NULL, "Headset Mic"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) /* Digital MICs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) * Local DMICs: the two DMICs on the mainboard
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * Remote DMICs: the two DMICs on the camera module
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) {"DMIC L1", NULL, "Remote DMICs"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) {"DMIC R1", NULL, "Remote DMICs"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) {"DMIC L2", NULL, "Local DMICs"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) {"DMIC R2", NULL, "Local DMICs"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) /* CODEC BE connections */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) {"SSP0 CODEC IN", NULL, "AIF1 Capture"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) {"AIF1 Playback", NULL, "SSP0 CODEC OUT"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) {"DSP Capture", NULL, "DSP Buffer"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) /* DSP Clock Connections */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) { "DSP Buffer", NULL, "SSP0 CODEC IN" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) { "SSP0 CODEC IN", NULL, "DSPTX" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) static const struct snd_kcontrol_new bdw_rt5677_controls[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) SOC_DAPM_PIN_SWITCH("Speaker"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) SOC_DAPM_PIN_SWITCH("Headphone"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) SOC_DAPM_PIN_SWITCH("Headset Mic"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) SOC_DAPM_PIN_SWITCH("Local DMICs"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) SOC_DAPM_PIN_SWITCH("Remote DMICs"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) static struct snd_soc_jack headphone_jack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) static struct snd_soc_jack mic_jack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) static struct snd_soc_jack_pin headphone_jack_pin = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) .pin = "Headphone",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) .mask = SND_JACK_HEADPHONE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) static struct snd_soc_jack_pin mic_jack_pin = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) .pin = "Headset Mic",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) .mask = SND_JACK_MICROPHONE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) static struct snd_soc_jack_gpio headphone_jack_gpio = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) .name = "plug-det",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) .report = SND_JACK_HEADPHONE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) .debounce_time = 200,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) static struct snd_soc_jack_gpio mic_jack_gpio = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) .name = "mic-present",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) .report = SND_JACK_MICROPHONE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) .debounce_time = 200,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) .invert = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) /* GPIO indexes defined by ACPI */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) RT5677_GPIO_PLUG_DET = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) RT5677_GPIO_MIC_PRESENT_L = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) RT5677_GPIO_HOTWORD_DET_L = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) RT5677_GPIO_DSP_INT = 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) RT5677_GPIO_HP_AMP_SHDN_L = 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) static const struct acpi_gpio_params plug_det_gpio = { RT5677_GPIO_PLUG_DET, 0, false };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) static const struct acpi_gpio_params mic_present_gpio = { RT5677_GPIO_MIC_PRESENT_L, 0, false };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) static const struct acpi_gpio_params headphone_enable_gpio = { RT5677_GPIO_HP_AMP_SHDN_L, 0, false };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) static const struct acpi_gpio_mapping bdw_rt5677_gpios[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) { "plug-det-gpios", &plug_det_gpio, 1 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) { "mic-present-gpios", &mic_present_gpio, 1 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) { "headphone-enable-gpios", &headphone_enable_gpio, 1 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) { NULL },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) static int broadwell_ssp0_fixup(struct snd_soc_pcm_runtime *rtd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) struct snd_pcm_hw_params *params)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) struct snd_interval *rate = hw_param_interval(params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) SNDRV_PCM_HW_PARAM_RATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) struct snd_interval *chan = hw_param_interval(params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) SNDRV_PCM_HW_PARAM_CHANNELS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) /* The ADSP will covert the FE rate to 48k, stereo */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) rate->min = rate->max = 48000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) chan->min = chan->max = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) /* set SSP0 to 16 bit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) params_set_format(params, SNDRV_PCM_FORMAT_S16_LE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) static int bdw_rt5677_hw_params(struct snd_pcm_substream *substream,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) struct snd_pcm_hw_params *params)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) ret = snd_soc_dai_set_sysclk(codec_dai, RT5677_SCLK_S_MCLK, 24576000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) SND_SOC_CLOCK_IN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) dev_err(rtd->dev, "can't set codec sysclk configuration\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) static int bdw_rt5677_dsp_hw_params(struct snd_pcm_substream *substream,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) struct snd_pcm_hw_params *params)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) ret = snd_soc_dai_set_sysclk(codec_dai, RT5677_SCLK_S_PLL1, 24576000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) SND_SOC_CLOCK_IN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) dev_err(rtd->dev, "can't set codec sysclk configuration\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) ret = snd_soc_dai_set_pll(codec_dai, 0, RT5677_PLL1_S_MCLK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 24000000, 24576000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) dev_err(rtd->dev, "can't set codec pll configuration\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) static const struct snd_soc_ops bdw_rt5677_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) .hw_params = bdw_rt5677_hw_params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) static const struct snd_soc_ops bdw_rt5677_dsp_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) .hw_params = bdw_rt5677_dsp_hw_params,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) static const unsigned int channels[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) static const struct snd_pcm_hw_constraint_list constraints_channels = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) .count = ARRAY_SIZE(channels),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) .list = channels,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) .mask = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) static int bdw_rt5677_fe_startup(struct snd_pcm_substream *substream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) struct snd_pcm_runtime *runtime = substream->runtime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) /* Board supports stereo configuration only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) runtime->hw.channels_max = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) return snd_pcm_hw_constraint_list(runtime, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) SNDRV_PCM_HW_PARAM_CHANNELS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) &constraints_channels);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) static const struct snd_soc_ops bdw_rt5677_fe_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) .startup = bdw_rt5677_fe_startup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) static int bdw_rt5677_init(struct snd_soc_pcm_runtime *rtd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) struct bdw_rt5677_priv *bdw_rt5677 =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) snd_soc_card_get_drvdata(rtd->card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) ret = devm_acpi_dev_add_driver_gpios(component->dev, bdw_rt5677_gpios);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) dev_warn(component->dev, "Failed to add driver gpios\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) /* Enable codec ASRC function for Stereo DAC/Stereo1 ADC/DMIC/I2S1.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) * The ASRC clock source is clk_i2s1_asrc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) rt5677_sel_asrc_clk_src(component, RT5677_DA_STEREO_FILTER |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) RT5677_AD_STEREO1_FILTER | RT5677_I2S1_SOURCE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) RT5677_CLK_SEL_I2S1_ASRC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) /* Enable codec ASRC function for Mono ADC L.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) * The ASRC clock source is clk_sys2_asrc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) rt5677_sel_asrc_clk_src(component, RT5677_AD_MONO_L_FILTER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) RT5677_CLK_SEL_SYS2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) /* Request rt5677 GPIO for headphone amp control */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) bdw_rt5677->gpio_hp_en = gpiod_get(component->dev, "headphone-enable",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) GPIOD_OUT_LOW);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) if (IS_ERR(bdw_rt5677->gpio_hp_en)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) dev_err(component->dev, "Can't find HP_AMP_SHDN_L gpio\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) return PTR_ERR(bdw_rt5677->gpio_hp_en);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) /* Create and initialize headphone jack */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) if (!snd_soc_card_jack_new(rtd->card, "Headphone Jack",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) SND_JACK_HEADPHONE, &headphone_jack,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) &headphone_jack_pin, 1)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) headphone_jack_gpio.gpiod_dev = component->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) if (snd_soc_jack_add_gpios(&headphone_jack, 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) &headphone_jack_gpio))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) dev_err(component->dev, "Can't add headphone jack gpio\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) dev_err(component->dev, "Can't create headphone jack\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) /* Create and initialize mic jack */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) if (!snd_soc_card_jack_new(rtd->card, "Mic Jack",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) SND_JACK_MICROPHONE, &mic_jack,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) &mic_jack_pin, 1)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) mic_jack_gpio.gpiod_dev = component->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) if (snd_soc_jack_add_gpios(&mic_jack, 1, &mic_jack_gpio))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) dev_err(component->dev, "Can't add mic jack gpio\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) dev_err(component->dev, "Can't create mic jack\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) bdw_rt5677->component = component;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) snd_soc_dapm_force_enable_pin(dapm, "MICBIAS1");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) static void bdw_rt5677_exit(struct snd_soc_pcm_runtime *rtd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) struct bdw_rt5677_priv *bdw_rt5677 =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) snd_soc_card_get_drvdata(rtd->card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) * The .exit() can be reached without going through the .init()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) * so explicitly test if the gpiod is valid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) if (!IS_ERR_OR_NULL(bdw_rt5677->gpio_hp_en))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) gpiod_put(bdw_rt5677->gpio_hp_en);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) /* broadwell digital audio interface glue - connects codec <--> CPU */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) SND_SOC_DAILINK_DEF(dummy,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) DAILINK_COMP_ARRAY(COMP_DUMMY()));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) SND_SOC_DAILINK_DEF(fe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) DAILINK_COMP_ARRAY(COMP_CPU("System Pin")));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) SND_SOC_DAILINK_DEF(platform,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) DAILINK_COMP_ARRAY(COMP_PLATFORM("haswell-pcm-audio")));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) SND_SOC_DAILINK_DEF(be,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) DAILINK_COMP_ARRAY(COMP_CODEC("i2c-RT5677CE:00", "rt5677-aif1")));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) SND_SOC_DAILINK_DEF(ssp0_port,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) DAILINK_COMP_ARRAY(COMP_CPU("ssp0-port")));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) /* Wake on voice interface */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) SND_SOC_DAILINK_DEFS(dsp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) DAILINK_COMP_ARRAY(COMP_CPU("spi-RT5677AA:00")),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) DAILINK_COMP_ARRAY(COMP_CODEC("i2c-RT5677CE:00", "rt5677-dspbuffer")),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) DAILINK_COMP_ARRAY(COMP_PLATFORM("spi-RT5677AA:00")));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) static struct snd_soc_dai_link bdw_rt5677_dais[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) /* Front End DAI links */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) .name = "System PCM",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) .stream_name = "System Playback/Capture",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) .nonatomic = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) .dynamic = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) .trigger = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) SND_SOC_DPCM_TRIGGER_POST,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) SND_SOC_DPCM_TRIGGER_POST
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) .dpcm_capture = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) .dpcm_playback = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) .ops = &bdw_rt5677_fe_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) SND_SOC_DAILINK_REG(fe, dummy, platform),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) /* Non-DPCM links */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) .name = "Codec DSP",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) .stream_name = "Wake on Voice",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) .capture_only = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) .ops = &bdw_rt5677_dsp_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) SND_SOC_DAILINK_REG(dsp),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) /* Back End DAI links */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) /* SSP0 - Codec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) .name = "Codec",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) .id = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) .no_pcm = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) SND_SOC_DAIFMT_CBS_CFS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) .ignore_pmdown_time = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) .be_hw_params_fixup = broadwell_ssp0_fixup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) .ops = &bdw_rt5677_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) .dpcm_playback = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) .dpcm_capture = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) .init = bdw_rt5677_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) .exit = bdw_rt5677_exit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) SND_SOC_DAILINK_REG(ssp0_port, be, platform),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) static int bdw_rt5677_suspend_pre(struct snd_soc_card *card)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) struct bdw_rt5677_priv *bdw_rt5677 = snd_soc_card_get_drvdata(card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) struct snd_soc_dapm_context *dapm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) if (bdw_rt5677->component) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) dapm = snd_soc_component_get_dapm(bdw_rt5677->component);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) snd_soc_dapm_disable_pin(dapm, "MICBIAS1");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) static int bdw_rt5677_resume_post(struct snd_soc_card *card)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) struct bdw_rt5677_priv *bdw_rt5677 = snd_soc_card_get_drvdata(card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) struct snd_soc_dapm_context *dapm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) if (bdw_rt5677->component) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) dapm = snd_soc_component_get_dapm(bdw_rt5677->component);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) snd_soc_dapm_force_enable_pin(dapm, "MICBIAS1");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) #if IS_ENABLED(CONFIG_SND_SOC_SOF_BROADWELL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) /* use space before codec name to simplify card ID, and simplify driver name */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) #define CARD_NAME "bdw rt5677" /* card name will be 'sof-bdw rt5677' */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) #define DRIVER_NAME "SOF"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) #define CARD_NAME "bdw-rt5677"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) #define DRIVER_NAME NULL /* card name will be used for driver name */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) /* ASoC machine driver for Broadwell DSP + RT5677 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) static struct snd_soc_card bdw_rt5677_card = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) .name = CARD_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) .driver_name = DRIVER_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) .dai_link = bdw_rt5677_dais,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) .num_links = ARRAY_SIZE(bdw_rt5677_dais),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) .dapm_widgets = bdw_rt5677_widgets,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) .num_dapm_widgets = ARRAY_SIZE(bdw_rt5677_widgets),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) .dapm_routes = bdw_rt5677_map,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) .num_dapm_routes = ARRAY_SIZE(bdw_rt5677_map),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) .controls = bdw_rt5677_controls,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) .num_controls = ARRAY_SIZE(bdw_rt5677_controls),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) .fully_routed = true,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) .suspend_pre = bdw_rt5677_suspend_pre,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) .resume_post = bdw_rt5677_resume_post,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) static int bdw_rt5677_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) struct bdw_rt5677_priv *bdw_rt5677;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) struct snd_soc_acpi_mach *mach;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) bdw_rt5677_card.dev = &pdev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) /* Allocate driver private struct */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) bdw_rt5677 = devm_kzalloc(&pdev->dev, sizeof(struct bdw_rt5677_priv),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) if (!bdw_rt5677) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) dev_err(&pdev->dev, "Can't allocate bdw_rt5677\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) /* override plaform name, if required */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) mach = pdev->dev.platform_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) ret = snd_soc_fixup_dai_links_platform_name(&bdw_rt5677_card,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) mach->mach_params.platform);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) snd_soc_card_set_drvdata(&bdw_rt5677_card, bdw_rt5677);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) return devm_snd_soc_register_card(&pdev->dev, &bdw_rt5677_card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) static struct platform_driver bdw_rt5677_audio = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) .probe = bdw_rt5677_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) .driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) .name = "bdw-rt5677",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) module_platform_driver(bdw_rt5677_audio)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) /* Module information */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) MODULE_AUTHOR("Ben Zhang");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) MODULE_DESCRIPTION("Intel Broadwell RT5677 machine driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) MODULE_LICENSE("GPL v2");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) MODULE_ALIAS("platform:bdw-rt5677");