Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2)  * Machine driver for AMD ACP Audio engine using DA7219 & MAX98357 codec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Copyright 2017 Advanced Micro Devices, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Permission is hereby granted, free of charge, to any person obtaining a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * copy of this software and associated documentation files (the "Software"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * to deal in the Software without restriction, including without limitation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * and/or sell copies of the Software, and to permit persons to whom the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * Software is furnished to do so, subject to the following conditions:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  * The above copyright notice and this permission notice shall be included in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  * all copies or substantial portions of the Software.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  * OTHER DEALINGS IN THE SOFTWARE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #include <sound/core.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #include <sound/soc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #include <sound/pcm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #include <sound/pcm_params.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #include <sound/soc-dapm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #include <sound/jack.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #include <linux/clk.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #include <linux/gpio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #include <linux/regulator/machine.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #include <linux/regulator/driver.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #include <linux/i2c.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #include <linux/input.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #include <linux/acpi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) #include "acp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #include "../codecs/da7219.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) #include "../codecs/da7219-aad.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) #define CZ_PLAT_CLK 48000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) #define DUAL_CHANNEL		2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) static struct snd_soc_jack cz_jack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) static struct clk *da7219_dai_wclk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) static struct clk *da7219_dai_bclk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) extern bool bt_uart_enable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) static int cz_da7219_init(struct snd_soc_pcm_runtime *rtd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	struct snd_soc_card *card = rtd->card;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	struct snd_soc_component *component = codec_dai->component;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	dev_info(rtd->dev, "codec dai name = %s\n", codec_dai->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	ret = snd_soc_dai_set_sysclk(codec_dai, DA7219_CLKSRC_MCLK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 				     CZ_PLAT_CLK, SND_SOC_CLOCK_IN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 		dev_err(rtd->dev, "can't set codec sysclk: %d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	ret = snd_soc_dai_set_pll(codec_dai, 0, DA7219_SYSCLK_PLL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 				  CZ_PLAT_CLK, DA7219_PLL_FREQ_OUT_98304);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		dev_err(rtd->dev, "can't set codec pll: %d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	da7219_dai_wclk = devm_clk_get(component->dev, "da7219-dai-wclk");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	if (IS_ERR(da7219_dai_wclk))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 		return PTR_ERR(da7219_dai_wclk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	da7219_dai_bclk = devm_clk_get(component->dev, "da7219-dai-bclk");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	if (IS_ERR(da7219_dai_bclk))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		return PTR_ERR(da7219_dai_bclk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	ret = snd_soc_card_jack_new(card, "Headset Jack",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 				SND_JACK_HEADSET | SND_JACK_LINEOUT |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 				SND_JACK_BTN_0 | SND_JACK_BTN_1 |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 				SND_JACK_BTN_2 | SND_JACK_BTN_3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 				&cz_jack, NULL, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 		dev_err(card->dev, "HP jack creation failed %d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	snd_jack_set_key(cz_jack.jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	snd_jack_set_key(cz_jack.jack, SND_JACK_BTN_1, KEY_VOLUMEUP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	snd_jack_set_key(cz_jack.jack, SND_JACK_BTN_2, KEY_VOLUMEDOWN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	snd_jack_set_key(cz_jack.jack, SND_JACK_BTN_3, KEY_VOICECOMMAND);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	da7219_aad_jack_det(component, &cz_jack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) static int da7219_clk_enable(struct snd_pcm_substream *substream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	 * Set wclk to 48000 because the rate constraint of this driver is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	 * 48000. ADAU7002 spec: "The ADAU7002 requires a BCLK rate that is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	 * minimum of 64x the LRCLK sample rate." DA7219 is the only clk
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	 * source so for all codecs we have to limit bclk to 64X lrclk.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	clk_set_rate(da7219_dai_wclk, 48000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	clk_set_rate(da7219_dai_bclk, 48000 * 64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	ret = clk_prepare_enable(da7219_dai_bclk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		dev_err(rtd->dev, "can't enable master clock %d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) static void da7219_clk_disable(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	clk_disable_unprepare(da7219_dai_bclk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) static const unsigned int channels[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	DUAL_CHANNEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) static const unsigned int rates[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	48000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) static const struct snd_pcm_hw_constraint_list constraints_rates = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	.count = ARRAY_SIZE(rates),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	.list  = rates,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	.mask = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) static const struct snd_pcm_hw_constraint_list constraints_channels = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	.count = ARRAY_SIZE(channels),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	.list = channels,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	.mask = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) static int cz_da7219_play_startup(struct snd_pcm_substream *substream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	struct snd_pcm_runtime *runtime = substream->runtime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	struct snd_soc_card *card = rtd->card;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	struct acp_platform_info *machine = snd_soc_card_get_drvdata(card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	 * On this platform for PCM device we support stereo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	runtime->hw.channels_max = DUAL_CHANNEL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 				   &constraints_channels);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 				   &constraints_rates);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	machine->play_i2s_instance = I2S_SP_INSTANCE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	return da7219_clk_enable(substream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) static int cz_da7219_cap_startup(struct snd_pcm_substream *substream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	struct snd_pcm_runtime *runtime = substream->runtime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	struct snd_soc_card *card = rtd->card;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	struct acp_platform_info *machine = snd_soc_card_get_drvdata(card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	 * On this platform for PCM device we support stereo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	runtime->hw.channels_max = DUAL_CHANNEL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 				   &constraints_channels);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 				   &constraints_rates);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	machine->cap_i2s_instance = I2S_SP_INSTANCE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	machine->capture_channel = CAP_CHANNEL1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	return da7219_clk_enable(substream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) static int cz_max_startup(struct snd_pcm_substream *substream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	struct snd_pcm_runtime *runtime = substream->runtime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	struct snd_soc_card *card = rtd->card;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	struct acp_platform_info *machine = snd_soc_card_get_drvdata(card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	 * On this platform for PCM device we support stereo
^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) 	runtime->hw.channels_max = DUAL_CHANNEL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 				   &constraints_channels);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 				   &constraints_rates);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	machine->play_i2s_instance = I2S_BT_INSTANCE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	return da7219_clk_enable(substream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) static int cz_dmic0_startup(struct snd_pcm_substream *substream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	struct snd_pcm_runtime *runtime = substream->runtime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	struct snd_soc_card *card = rtd->card;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	struct acp_platform_info *machine = snd_soc_card_get_drvdata(card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	 * On this platform for PCM device we support stereo
^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) 	runtime->hw.channels_max = DUAL_CHANNEL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 				   &constraints_channels);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 				   &constraints_rates);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	machine->cap_i2s_instance = I2S_BT_INSTANCE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	return da7219_clk_enable(substream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) static int cz_dmic1_startup(struct snd_pcm_substream *substream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	struct snd_pcm_runtime *runtime = substream->runtime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	struct snd_soc_card *card = rtd->card;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	struct acp_platform_info *machine = snd_soc_card_get_drvdata(card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	 * On this platform for PCM device we support stereo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	runtime->hw.channels_max = DUAL_CHANNEL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 				   &constraints_channels);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 				   &constraints_rates);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	machine->cap_i2s_instance = I2S_SP_INSTANCE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	machine->capture_channel = CAP_CHANNEL0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	return da7219_clk_enable(substream);
^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) static void cz_da7219_shutdown(struct snd_pcm_substream *substream)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	da7219_clk_disable();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) static const struct snd_soc_ops cz_da7219_play_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	.startup = cz_da7219_play_startup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	.shutdown = cz_da7219_shutdown,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) static const struct snd_soc_ops cz_da7219_cap_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	.startup = cz_da7219_cap_startup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	.shutdown = cz_da7219_shutdown,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) static const struct snd_soc_ops cz_max_play_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	.startup = cz_max_startup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	.shutdown = cz_da7219_shutdown,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) static const struct snd_soc_ops cz_dmic0_cap_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	.startup = cz_dmic0_startup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	.shutdown = cz_da7219_shutdown,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) static const struct snd_soc_ops cz_dmic1_cap_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	.startup = cz_dmic1_startup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	.shutdown = cz_da7219_shutdown,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) SND_SOC_DAILINK_DEF(designware1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	DAILINK_COMP_ARRAY(COMP_CPU("designware-i2s.1.auto")));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) SND_SOC_DAILINK_DEF(designware2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	DAILINK_COMP_ARRAY(COMP_CPU("designware-i2s.2.auto")));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) SND_SOC_DAILINK_DEF(designware3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	DAILINK_COMP_ARRAY(COMP_CPU("designware-i2s.3.auto")));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) SND_SOC_DAILINK_DEF(dlgs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	DAILINK_COMP_ARRAY(COMP_CODEC("i2c-DLGS7219:00", "da7219-hifi")));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) SND_SOC_DAILINK_DEF(mx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	DAILINK_COMP_ARRAY(COMP_CODEC("MX98357A:00", "HiFi")));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) SND_SOC_DAILINK_DEF(adau,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 	DAILINK_COMP_ARRAY(COMP_CODEC("ADAU7002:00", "adau7002-hifi")));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) SND_SOC_DAILINK_DEF(platform,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	DAILINK_COMP_ARRAY(COMP_PLATFORM("acp_audio_dma.0.auto")));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) static struct snd_soc_dai_link cz_dai_7219_98357[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 		.name = "amd-da7219-play",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 		.stream_name = "Playback",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 		.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 				| SND_SOC_DAIFMT_CBM_CFM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 		.init = cz_da7219_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 		.dpcm_playback = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 		.ops = &cz_da7219_play_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 		SND_SOC_DAILINK_REG(designware1, dlgs, platform),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 		.name = "amd-da7219-cap",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 		.stream_name = "Capture",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 		.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 				| SND_SOC_DAIFMT_CBM_CFM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 		.dpcm_capture = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 		.ops = &cz_da7219_cap_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 		SND_SOC_DAILINK_REG(designware2, dlgs, platform),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 		.name = "amd-max98357-play",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 		.stream_name = "HiFi Playback",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 		.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 				| SND_SOC_DAIFMT_CBM_CFM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 		.dpcm_playback = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 		.ops = &cz_max_play_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 		SND_SOC_DAILINK_REG(designware3, mx, platform),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 		/* C panel DMIC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 		.name = "dmic0",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 		.stream_name = "DMIC0 Capture",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 		.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 				| SND_SOC_DAIFMT_CBM_CFM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 		.dpcm_capture = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 		.ops = &cz_dmic0_cap_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 		SND_SOC_DAILINK_REG(designware3, adau, platform),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 		/* A/B panel DMIC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 		.name = "dmic1",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 		.stream_name = "DMIC1 Capture",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 		.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 				| SND_SOC_DAIFMT_CBM_CFM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 		.dpcm_capture = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 		.ops = &cz_dmic1_cap_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 		SND_SOC_DAILINK_REG(designware2, adau, platform),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) static const struct snd_soc_dapm_widget cz_widgets[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 	SND_SOC_DAPM_HP("Headphones", NULL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 	SND_SOC_DAPM_SPK("Speakers", NULL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 	SND_SOC_DAPM_MIC("Headset Mic", NULL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 	SND_SOC_DAPM_MIC("Int Mic", NULL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) static const struct snd_soc_dapm_route cz_audio_route[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 	{"Headphones", NULL, "HPL"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 	{"Headphones", NULL, "HPR"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 	{"MIC", NULL, "Headset Mic"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 	{"Speakers", NULL, "Speaker"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	{"PDM_DAT", NULL, "Int Mic"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) static const struct snd_kcontrol_new cz_mc_controls[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 	SOC_DAPM_PIN_SWITCH("Headphones"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 	SOC_DAPM_PIN_SWITCH("Speakers"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 	SOC_DAPM_PIN_SWITCH("Headset Mic"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 	SOC_DAPM_PIN_SWITCH("Int Mic"),
^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 struct snd_soc_card cz_card = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 	.name = "acpd7219m98357",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 	.owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 	.dai_link = cz_dai_7219_98357,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 	.num_links = ARRAY_SIZE(cz_dai_7219_98357),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 	.dapm_widgets = cz_widgets,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 	.num_dapm_widgets = ARRAY_SIZE(cz_widgets),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 	.dapm_routes = cz_audio_route,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 	.num_dapm_routes = ARRAY_SIZE(cz_audio_route),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 	.controls = cz_mc_controls,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	.num_controls = ARRAY_SIZE(cz_mc_controls),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) static struct regulator_consumer_supply acp_da7219_supplies[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 	REGULATOR_SUPPLY("VDD", "i2c-DLGS7219:00"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 	REGULATOR_SUPPLY("VDDMIC", "i2c-DLGS7219:00"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 	REGULATOR_SUPPLY("VDDIO", "i2c-DLGS7219:00"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 	REGULATOR_SUPPLY("IOVDD", "ADAU7002:00"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) static struct regulator_init_data acp_da7219_data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 	.constraints = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 		.always_on = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 	.num_consumer_supplies = ARRAY_SIZE(acp_da7219_supplies),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 	.consumer_supplies = acp_da7219_supplies,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) static struct regulator_config acp_da7219_cfg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 	.init_data = &acp_da7219_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) static struct regulator_ops acp_da7219_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) static const struct regulator_desc acp_da7219_desc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 	.name = "reg-fixed-1.8V",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 	.type = REGULATOR_VOLTAGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 	.owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 	.ops = &acp_da7219_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 	.fixed_uV = 1800000, /* 1.8V */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 	.n_voltages = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) static int cz_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 	struct snd_soc_card *card;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 	struct acp_platform_info *machine;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 	struct regulator_dev *rdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 	acp_da7219_cfg.dev = &pdev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 	rdev = devm_regulator_register(&pdev->dev, &acp_da7219_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 				       &acp_da7219_cfg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 	if (IS_ERR(rdev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 		dev_err(&pdev->dev, "Failed to register regulator: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 			(int)PTR_ERR(rdev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 	machine = devm_kzalloc(&pdev->dev, sizeof(struct acp_platform_info),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 			       GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 	if (!machine)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 	card = &cz_card;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 	cz_card.dev = &pdev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 	platform_set_drvdata(pdev, card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 	snd_soc_card_set_drvdata(card, machine);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 	ret = devm_snd_soc_register_card(&pdev->dev, &cz_card);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 	if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 		dev_err(&pdev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 				"devm_snd_soc_register_card(%s) failed: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 				cz_card.name, ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 	bt_uart_enable = !device_property_read_bool(&pdev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 						    "bt-pad-enable");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) #ifdef CONFIG_ACPI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) static const struct acpi_device_id cz_audio_acpi_match[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 	{ "AMD7219", 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 	{},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) MODULE_DEVICE_TABLE(acpi, cz_audio_acpi_match);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) static struct platform_driver cz_pcm_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 	.driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 		.name = "cz-da7219-max98357a",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 		.acpi_match_table = ACPI_PTR(cz_audio_acpi_match),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 		.pm = &snd_soc_pm_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 	.probe = cz_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) module_platform_driver(cz_pcm_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) MODULE_AUTHOR("akshu.agrawal@amd.com");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) MODULE_DESCRIPTION("DA7219 & MAX98357A audio support");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) MODULE_LICENSE("GPL v2");