holi.c 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #include <linux/clk.h>
  7. #include <linux/delay.h>
  8. #include <linux/gpio.h>
  9. #include <linux/of_gpio.h>
  10. #include <linux/platform_device.h>
  11. #include <linux/slab.h>
  12. #include <linux/io.h>
  13. #include <linux/module.h>
  14. #include <linux/input.h>
  15. #include <linux/of_device.h>
  16. //#include <linux/soc/qcom/fsa4480-i2c.h>
  17. #include <linux/pm_qos.h>
  18. #include <linux/nvmem-consumer.h>
  19. #include <sound/control.h>
  20. #include <sound/core.h>
  21. #include <sound/soc.h>
  22. #include <sound/soc-dapm.h>
  23. #include <sound/pcm.h>
  24. #include <sound/pcm_params.h>
  25. #include <sound/info.h>
  26. #include <soc/snd_event.h>
  27. #include <dsp/audio_prm.h>
  28. #include <soc/swr-common.h>
  29. #include <soc/soundwire.h>
  30. #include "device_event.h"
  31. #include "asoc/msm-cdc-pinctrl.h"
  32. #include "asoc/wcd-mbhc-v2.h"
  33. #include "codecs/wsa881x-analog.h"
  34. #include "codecs/wcd937x/wcd937x-mbhc.h"
  35. #include "codecs/wcd937x/wcd937x.h"
  36. #include "codecs/wcd938x/wcd938x-mbhc.h"
  37. #include "codecs/wcd938x/wcd938x.h"
  38. #include "codecs/bolero/bolero-cdc.h"
  39. #include <bindings/audio-codec-port-types.h>
  40. #include "holi-port-config.h"
  41. #include "msm-audio-defs.h"
  42. #include "msm_common.h"
  43. #include "msm_holi_dailink.h"
  44. #define DRV_NAME "holi-asoc-snd"
  45. #define __CHIPSET__ "HOLI "
  46. #define MSM_DAILINK_NAME(name) (__CHIPSET__#name)
  47. #define SAMPLING_RATE_8KHZ 8000
  48. #define SAMPLING_RATE_11P025KHZ 11025
  49. #define SAMPLING_RATE_16KHZ 16000
  50. #define SAMPLING_RATE_22P05KHZ 22050
  51. #define SAMPLING_RATE_32KHZ 32000
  52. #define SAMPLING_RATE_44P1KHZ 44100
  53. #define SAMPLING_RATE_48KHZ 48000
  54. #define SAMPLING_RATE_88P2KHZ 88200
  55. #define SAMPLING_RATE_96KHZ 96000
  56. #define SAMPLING_RATE_176P4KHZ 176400
  57. #define SAMPLING_RATE_192KHZ 192000
  58. #define SAMPLING_RATE_352P8KHZ 352800
  59. #define SAMPLING_RATE_384KHZ 384000
  60. #define IS_FRACTIONAL(x) \
  61. ((x == SAMPLING_RATE_11P025KHZ) || (x == SAMPLING_RATE_22P05KHZ) || \
  62. (x == SAMPLING_RATE_44P1KHZ) || (x == SAMPLING_RATE_88P2KHZ) || \
  63. (x == SAMPLING_RATE_176P4KHZ) || (x == SAMPLING_RATE_352P8KHZ))
  64. #define IS_MSM_INTERFACE_MI2S(x) \
  65. ((x == PRIM_MI2S) || (x == SEC_MI2S) || (x == TERT_MI2S))
  66. #define WCD9XXX_MBHC_DEF_RLOADS 5
  67. #define WCD9XXX_MBHC_DEF_BUTTONS 8
  68. #define CODEC_EXT_CLK_RATE 9600000
  69. #define ADSP_STATE_READY_TIMEOUT_MS 3000
  70. #define DEV_NAME_STR_LEN 32
  71. #define WCD_MBHC_HS_V_MAX 1600
  72. #define TDM_CHANNEL_MAX 8
  73. #define DEV_NAME_STR_LEN 32
  74. /* time in us to ensure LPM doesn't go in C3/C4 */
  75. #define MSM_LL_QOS_VALUE 300
  76. #define ADSP_STATE_READY_TIMEOUT_MS 3000
  77. #define WCN_CDC_SLIM_RX_CH_MAX 2
  78. #define WCN_CDC_SLIM_TX_CH_MAX 3
  79. #define WCN_CDC_SLIM_TX_CH_MAX_LITO 3
  80. enum {
  81. RX_PATH = 0,
  82. TX_PATH,
  83. MAX_PATH,
  84. };
  85. enum {
  86. TDM_0 = 0,
  87. TDM_1,
  88. TDM_2,
  89. TDM_3,
  90. TDM_4,
  91. TDM_5,
  92. TDM_6,
  93. TDM_7,
  94. TDM_PORT_MAX,
  95. };
  96. #define TDM_MAX_SLOTS 8
  97. #define TDM_SLOT_WIDTH_BITS 32
  98. enum {
  99. TDM_PRI = 0,
  100. TDM_SEC,
  101. TDM_TERT,
  102. TDM_QUAT,
  103. TDM_INTERFACE_MAX,
  104. };
  105. enum {
  106. PRIM_AUX_PCM = 0,
  107. SEC_AUX_PCM,
  108. TERT_AUX_PCM,
  109. QUAT_AUX_PCM,
  110. AUX_PCM_MAX,
  111. };
  112. enum {
  113. PRIM_MI2S = 0,
  114. SEC_MI2S,
  115. TERT_MI2S,
  116. QUAT_MI2S,
  117. MI2S_MAX,
  118. };
  119. enum {
  120. RX_CDC_DMA_RX_0 = 0,
  121. RX_CDC_DMA_RX_1,
  122. RX_CDC_DMA_RX_2,
  123. RX_CDC_DMA_RX_3,
  124. RX_CDC_DMA_RX_5,
  125. RX_CDC_DMA_RX_6,
  126. CDC_DMA_RX_MAX,
  127. };
  128. enum {
  129. TX_CDC_DMA_TX_0 = 0,
  130. TX_CDC_DMA_TX_3,
  131. TX_CDC_DMA_TX_4,
  132. VA_CDC_DMA_TX_0,
  133. VA_CDC_DMA_TX_1,
  134. VA_CDC_DMA_TX_2,
  135. CDC_DMA_TX_MAX,
  136. };
  137. enum {
  138. SLIM_RX_7 = 0,
  139. SLIM_RX_MAX,
  140. };
  141. enum {
  142. SLIM_TX_7 = 0,
  143. SLIM_TX_8,
  144. SLIM_TX_MAX,
  145. };
  146. enum {
  147. AFE_LOOPBACK_TX_IDX = 0,
  148. AFE_LOOPBACK_TX_IDX_MAX,
  149. };
  150. struct msm_asoc_mach_data {
  151. struct snd_info_entry *codec_root;
  152. struct msm_common_pdata *common_pdata;
  153. int usbc_en2_gpio; /* used by gpio driver API */
  154. struct device_node *dmic01_gpio_p; /* used by pinctrl API */
  155. struct device_node *dmic23_gpio_p; /* used by pinctrl API */
  156. struct device_node *dmic45_gpio_p; /* used by pinctrl API */
  157. struct device_node *mi2s_gpio_p[MI2S_MAX]; /* used by pinctrl API */
  158. atomic_t mi2s_gpio_ref_count[MI2S_MAX]; /* used by pinctrl API */
  159. struct device_node *us_euro_gpio_p; /* used by pinctrl API */
  160. struct pinctrl *usbc_en2_gpio_p; /* used by pinctrl API */
  161. struct device_node *hph_en1_gpio_p; /* used by pinctrl API */
  162. struct device_node *hph_en0_gpio_p; /* used by pinctrl API */
  163. bool is_afe_config_done;
  164. struct device_node *fsa_handle;
  165. struct clk *lpass_audio_hw_vote;
  166. int core_audio_vote_count;
  167. u32 wcd_disabled;
  168. u32 wsa_max_devs;
  169. };
  170. struct tdm_port {
  171. u32 mode;
  172. u32 channel;
  173. };
  174. struct tdm_dev_config {
  175. unsigned int tdm_slot_offset[TDM_MAX_SLOTS];
  176. };
  177. struct dev_config {
  178. u32 sample_rate;
  179. u32 bit_format;
  180. u32 channels;
  181. };
  182. struct mi2s_conf {
  183. struct mutex lock;
  184. u32 ref_cnt;
  185. u32 msm_is_mi2s_master;
  186. };
  187. static bool is_initial_boot;
  188. static bool codec_reg_done;
  189. static struct snd_soc_card snd_soc_card_holi_msm;
  190. static int dmic_0_1_gpio_cnt;
  191. static int dmic_2_3_gpio_cnt;
  192. static int dmic_4_5_gpio_cnt;
  193. static void *def_wcd_mbhc_cal(void);
  194. static int msm_rx_tx_codec_init(struct snd_soc_pcm_runtime *);
  195. static int msm_int_wsa_init(struct snd_soc_pcm_runtime *rtd);
  196. /*
  197. * Need to report LINEIN
  198. * if R/L channel impedance is larger than 5K ohm
  199. */
  200. static struct wcd_mbhc_config wcd_mbhc_cfg = {
  201. .read_fw_bin = false,
  202. .calibration = NULL,
  203. .detect_extn_cable = true,
  204. .mono_stero_detection = false,
  205. .swap_gnd_mic = NULL,
  206. .hs_ext_micbias = true,
  207. .key_code[0] = KEY_MEDIA,
  208. .key_code[1] = KEY_VOICECOMMAND,
  209. .key_code[2] = KEY_VOLUMEUP,
  210. .key_code[3] = KEY_VOLUMEDOWN,
  211. .key_code[4] = 0,
  212. .key_code[5] = 0,
  213. .key_code[6] = 0,
  214. .key_code[7] = 0,
  215. .linein_th = 5000,
  216. .moisture_en = false,
  217. .mbhc_micbias = MIC_BIAS_2,
  218. .anc_micbias = MIC_BIAS_2,
  219. .enable_anc_mic_detect = false,
  220. .moisture_duty_cycle_en = true,
  221. };
  222. struct msm_common_pdata *msm_common_get_pdata(struct snd_soc_card *card)
  223. {
  224. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  225. if (!pdata)
  226. return NULL;
  227. return pdata->common_pdata;
  228. }
  229. void msm_common_set_pdata(struct snd_soc_card *card,
  230. struct msm_common_pdata *common_pdata)
  231. {
  232. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  233. if (!pdata)
  234. return;
  235. pdata->common_pdata = common_pdata;
  236. }
  237. static bool msm_usbc_swap_gnd_mic(struct snd_soc_component *component,
  238. bool active)
  239. {
  240. struct snd_soc_card *card = component->card;
  241. struct msm_asoc_mach_data *pdata =
  242. snd_soc_card_get_drvdata(card);
  243. if (!pdata->fsa_handle)
  244. return false;
  245. //return fsa4480_switch_event(pdata->fsa_handle, FSA_MIC_GND_SWAP);
  246. return true;
  247. }
  248. static bool msm_swap_gnd_mic(struct snd_soc_component *component, bool active)
  249. {
  250. int value = 0;
  251. bool ret = false;
  252. struct snd_soc_card *card;
  253. struct msm_asoc_mach_data *pdata;
  254. if (!component) {
  255. pr_err("%s component is NULL\n", __func__);
  256. return false;
  257. }
  258. card = component->card;
  259. pdata = snd_soc_card_get_drvdata(card);
  260. if (!pdata)
  261. return false;
  262. if (wcd_mbhc_cfg.enable_usbc_analog)
  263. return msm_usbc_swap_gnd_mic(component, active);
  264. /* if usbc is not defined, swap using us_euro_gpio_p */
  265. if (pdata->us_euro_gpio_p) {
  266. value = msm_cdc_pinctrl_get_state(
  267. pdata->us_euro_gpio_p);
  268. if (value)
  269. msm_cdc_pinctrl_select_sleep_state(
  270. pdata->us_euro_gpio_p);
  271. else
  272. msm_cdc_pinctrl_select_active_state(
  273. pdata->us_euro_gpio_p);
  274. dev_dbg(component->dev, "%s: swap select switch %d to %d\n",
  275. __func__, value, !value);
  276. ret = true;
  277. }
  278. return ret;
  279. }
  280. static int msm_dmic_event(struct snd_soc_dapm_widget *w,
  281. struct snd_kcontrol *kcontrol, int event)
  282. {
  283. struct msm_asoc_mach_data *pdata = NULL;
  284. struct snd_soc_component *component =
  285. snd_soc_dapm_to_component(w->dapm);
  286. int ret = 0;
  287. u32 dmic_idx;
  288. int *dmic_gpio_cnt;
  289. struct device_node *dmic_gpio;
  290. char *wname;
  291. wname = strpbrk(w->name, "0123");
  292. if (!wname) {
  293. dev_err(component->dev, "%s: widget not found\n", __func__);
  294. return -EINVAL;
  295. }
  296. ret = kstrtouint(wname, 10, &dmic_idx);
  297. if (ret < 0) {
  298. dev_err(component->dev, "%s: Invalid DMIC line on the codec\n",
  299. __func__);
  300. return -EINVAL;
  301. }
  302. pdata = snd_soc_card_get_drvdata(component->card);
  303. switch (dmic_idx) {
  304. case 0:
  305. case 1:
  306. dmic_gpio_cnt = &dmic_0_1_gpio_cnt;
  307. dmic_gpio = pdata->dmic01_gpio_p;
  308. break;
  309. case 2:
  310. case 3:
  311. dmic_gpio_cnt = &dmic_2_3_gpio_cnt;
  312. dmic_gpio = pdata->dmic23_gpio_p;
  313. break;
  314. case 4:
  315. case 5:
  316. dmic_gpio_cnt = &dmic_4_5_gpio_cnt;
  317. dmic_gpio = pdata->dmic45_gpio_p;
  318. break;
  319. default:
  320. dev_err(component->dev, "%s: Invalid DMIC Selection\n",
  321. __func__);
  322. return -EINVAL;
  323. }
  324. dev_dbg(component->dev, "%s: event %d DMIC%d dmic_gpio_cnt %d\n",
  325. __func__, event, dmic_idx, *dmic_gpio_cnt);
  326. switch (event) {
  327. case SND_SOC_DAPM_PRE_PMU:
  328. (*dmic_gpio_cnt)++;
  329. if (*dmic_gpio_cnt == 1) {
  330. ret = msm_cdc_pinctrl_select_active_state(
  331. dmic_gpio);
  332. if (ret < 0) {
  333. pr_err("%s: gpio set cannot be activated %sd",
  334. __func__, "dmic_gpio");
  335. return ret;
  336. }
  337. }
  338. break;
  339. case SND_SOC_DAPM_POST_PMD:
  340. (*dmic_gpio_cnt)--;
  341. if (*dmic_gpio_cnt == 0) {
  342. ret = msm_cdc_pinctrl_select_sleep_state(
  343. dmic_gpio);
  344. if (ret < 0) {
  345. pr_err("%s: gpio set cannot be de-activated %sd",
  346. __func__, "dmic_gpio");
  347. return ret;
  348. }
  349. }
  350. break;
  351. default:
  352. pr_err("%s: invalid DAPM event %d\n", __func__, event);
  353. return -EINVAL;
  354. }
  355. return 0;
  356. }
  357. static const struct snd_soc_dapm_widget msm_int_dapm_widgets[] = {
  358. SND_SOC_DAPM_MIC("Analog Mic1", NULL),
  359. SND_SOC_DAPM_MIC("Analog Mic2", NULL),
  360. SND_SOC_DAPM_MIC("Analog Mic3", NULL),
  361. SND_SOC_DAPM_MIC("Analog Mic4", NULL),
  362. SND_SOC_DAPM_MIC("Analog Mic5", NULL),
  363. SND_SOC_DAPM_MIC("Digital Mic0", msm_dmic_event),
  364. SND_SOC_DAPM_MIC("Digital Mic1", msm_dmic_event),
  365. SND_SOC_DAPM_MIC("Digital Mic2", msm_dmic_event),
  366. SND_SOC_DAPM_MIC("Digital Mic3", msm_dmic_event),
  367. SND_SOC_DAPM_MIC("Digital Mic4", msm_dmic_event),
  368. SND_SOC_DAPM_MIC("Digital Mic5", msm_dmic_event),
  369. SND_SOC_DAPM_MIC("Digital Mic6", NULL),
  370. SND_SOC_DAPM_MIC("Digital Mic7", NULL),
  371. };
  372. static int msm_wcn_init(struct snd_soc_pcm_runtime *rtd)
  373. {
  374. unsigned int rx_ch[WCN_CDC_SLIM_RX_CH_MAX] = {157, 158};
  375. unsigned int tx_ch[WCN_CDC_SLIM_TX_CH_MAX] = {159, 160, 161};
  376. struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
  377. int ret = 0;
  378. ret = snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
  379. tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
  380. if (ret)
  381. return ret;
  382. msm_common_dai_link_init(rtd);
  383. return ret;
  384. }
  385. static struct snd_info_entry *msm_snd_info_create_subdir(struct module *mod,
  386. const char *name,
  387. struct snd_info_entry *parent)
  388. {
  389. struct snd_info_entry *entry;
  390. entry = snd_info_create_module_entry(mod, name, parent);
  391. if (!entry)
  392. return NULL;
  393. entry->mode = S_IFDIR | 0555;
  394. if (snd_info_register(entry) < 0) {
  395. snd_info_free_entry(entry);
  396. return NULL;
  397. }
  398. return entry;
  399. }
  400. static void *def_wcd_mbhc_cal(void)
  401. {
  402. void *wcd_mbhc_cal;
  403. struct wcd_mbhc_btn_detect_cfg *btn_cfg;
  404. u16 *btn_high;
  405. wcd_mbhc_cal = kzalloc(WCD_MBHC_CAL_SIZE(WCD_MBHC_DEF_BUTTONS,
  406. WCD9XXX_MBHC_DEF_RLOADS), GFP_KERNEL);
  407. if (!wcd_mbhc_cal)
  408. return NULL;
  409. WCD_MBHC_CAL_PLUG_TYPE_PTR(wcd_mbhc_cal)->v_hs_max = WCD_MBHC_HS_V_MAX;
  410. WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal)->num_btn = WCD_MBHC_DEF_BUTTONS;
  411. btn_cfg = WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal);
  412. btn_high = ((void *)&btn_cfg->_v_btn_low) +
  413. (sizeof(btn_cfg->_v_btn_low[0]) * btn_cfg->num_btn);
  414. btn_high[0] = 75;
  415. btn_high[1] = 150;
  416. btn_high[2] = 237;
  417. btn_high[3] = 500;
  418. btn_high[4] = 500;
  419. btn_high[5] = 500;
  420. btn_high[6] = 500;
  421. btn_high[7] = 500;
  422. return wcd_mbhc_cal;
  423. }
  424. static struct snd_soc_ops msm_common_be_ops = {
  425. .hw_params = msm_common_snd_hw_params,
  426. .startup = msm_common_snd_startup,
  427. .shutdown = msm_common_snd_shutdown,
  428. };
  429. static struct snd_soc_dai_link msm_common_be_dai_links[] = {
  430. /* Backend AFE DAI Links */
  431. #if 0
  432. /* Incall Record Uplink BACK END DAI Link */
  433. {
  434. .name = LPASS_BE_INCALL_RECORD_TX,
  435. .stream_name = "Voice Uplink Capture",
  436. .cpu_dai_name = "msm-dai-q6-dev.32772",
  437. .platform_name = "msm-pcm-routing",
  438. .codec_name = "msm-stub-codec.1",
  439. .codec_dai_name = "msm-stub-tx",
  440. .no_pcm = 1,
  441. .dpcm_capture = 1,
  442. .id = MSM_BACKEND_DAI_INCALL_RECORD_TX,
  443. .be_hw_params_fixup = msm_be_hw_params_fixup,
  444. .ignore_suspend = 1,
  445. },
  446. /* Incall Record Downlink BACK END DAI Link */
  447. {
  448. .name = LPASS_BE_INCALL_RECORD_RX,
  449. .stream_name = "Voice Downlink Capture",
  450. .cpu_dai_name = "msm-dai-q6-dev.32771",
  451. .platform_name = "msm-pcm-routing",
  452. .codec_name = "msm-stub-codec.1",
  453. .codec_dai_name = "msm-stub-tx",
  454. .no_pcm = 1,
  455. .dpcm_capture = 1,
  456. .id = MSM_BACKEND_DAI_INCALL_RECORD_RX,
  457. .be_hw_params_fixup = msm_be_hw_params_fixup,
  458. .ignore_suspend = 1,
  459. },
  460. /* Incall Music BACK END DAI Link */
  461. {
  462. .name = LPASS_BE_VOICE_PLAYBACK_TX,
  463. .stream_name = "Voice Farend Playback",
  464. .cpu_dai_name = "msm-dai-q6-dev.32773",
  465. .platform_name = "msm-pcm-routing",
  466. .codec_name = "msm-stub-codec.1",
  467. .codec_dai_name = "msm-stub-rx",
  468. .no_pcm = 1,
  469. .dpcm_playback = 1,
  470. .id = MSM_BACKEND_DAI_VOICE_PLAYBACK_TX,
  471. .be_hw_params_fixup = msm_be_hw_params_fixup,
  472. .ignore_suspend = 1,
  473. .ignore_pmdown_time = 1,
  474. },
  475. /* Incall Music 2 BACK END DAI Link */
  476. {
  477. .name = LPASS_BE_VOICE2_PLAYBACK_TX,
  478. .stream_name = "Voice2 Farend Playback",
  479. .cpu_dai_name = "msm-dai-q6-dev.32770",
  480. .platform_name = "msm-pcm-routing",
  481. .codec_name = "msm-stub-codec.1",
  482. .codec_dai_name = "msm-stub-rx",
  483. .no_pcm = 1,
  484. .dpcm_playback = 1,
  485. .id = MSM_BACKEND_DAI_VOICE2_PLAYBACK_TX,
  486. .be_hw_params_fixup = msm_be_hw_params_fixup,
  487. .ignore_suspend = 1,
  488. .ignore_pmdown_time = 1,
  489. },
  490. #endif
  491. /* Proxy Tx BACK END DAI Link */
  492. {
  493. .name = LPASS_BE_RT_PROXY_PCM_TX,
  494. .stream_name = LPASS_BE_RT_PROXY_PCM_TX,
  495. .capture_only = 1,
  496. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  497. SND_SOC_DPCM_TRIGGER_POST},
  498. .ignore_suspend = 1,
  499. .ops = &msm_common_be_ops,
  500. SND_SOC_DAILINK_REG(proxy_tx),
  501. },
  502. /* Proxy Rx BACK END DAI Link */
  503. {
  504. .name = LPASS_BE_RT_PROXY_PCM_RX,
  505. .stream_name = LPASS_BE_RT_PROXY_PCM_RX,
  506. .playback_only = 1,
  507. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  508. SND_SOC_DPCM_TRIGGER_POST},
  509. .ignore_pmdown_time = 1,
  510. .ignore_suspend = 1,
  511. .ops = &msm_common_be_ops,
  512. SND_SOC_DAILINK_REG(proxy_rx),
  513. },
  514. {
  515. .name = LPASS_BE_USB_AUDIO_RX,
  516. .stream_name = LPASS_BE_USB_AUDIO_RX,
  517. .playback_only = 1,
  518. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  519. SND_SOC_DPCM_TRIGGER_POST},
  520. .ignore_pmdown_time = 1,
  521. .ignore_suspend = 1,
  522. .ops = &msm_common_be_ops,
  523. SND_SOC_DAILINK_REG(usb_audio_rx),
  524. },
  525. {
  526. .name = LPASS_BE_USB_AUDIO_TX,
  527. .stream_name = LPASS_BE_USB_AUDIO_TX,
  528. .capture_only = 1,
  529. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  530. SND_SOC_DPCM_TRIGGER_POST},
  531. .ignore_suspend = 1,
  532. .ops = &msm_common_be_ops,
  533. SND_SOC_DAILINK_REG(usb_audio_tx),
  534. },
  535. };
  536. static struct snd_soc_dai_link msm_tdm_be_dai_links[] = {
  537. {
  538. .name = LPASS_BE_PRI_TDM_RX_0,
  539. .stream_name = LPASS_BE_PRI_TDM_RX_0,
  540. .playback_only = 1,
  541. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  542. SND_SOC_DPCM_TRIGGER_POST},
  543. .ops = &msm_common_be_ops,
  544. .ignore_suspend = 1,
  545. .ignore_pmdown_time = 1,
  546. SND_SOC_DAILINK_REG(pri_tdm_rx_0),
  547. },
  548. {
  549. .name = LPASS_BE_PRI_TDM_TX_0,
  550. .stream_name = LPASS_BE_PRI_TDM_TX_0,
  551. .capture_only = 1,
  552. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  553. SND_SOC_DPCM_TRIGGER_POST},
  554. .ops = &msm_common_be_ops,
  555. .ignore_suspend = 1,
  556. SND_SOC_DAILINK_REG(pri_tdm_tx_0),
  557. },
  558. {
  559. .name = LPASS_BE_SEC_TDM_RX_0,
  560. .stream_name = LPASS_BE_SEC_TDM_RX_0,
  561. .playback_only = 1,
  562. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  563. SND_SOC_DPCM_TRIGGER_POST},
  564. .ops = &msm_common_be_ops,
  565. .ignore_suspend = 1,
  566. .ignore_pmdown_time = 1,
  567. SND_SOC_DAILINK_REG(sec_tdm_rx_0),
  568. },
  569. {
  570. .name = LPASS_BE_SEC_TDM_TX_0,
  571. .stream_name = LPASS_BE_SEC_TDM_TX_0,
  572. .capture_only = 1,
  573. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  574. SND_SOC_DPCM_TRIGGER_POST},
  575. .ops = &msm_common_be_ops,
  576. .ignore_suspend = 1,
  577. SND_SOC_DAILINK_REG(sec_tdm_tx_0),
  578. },
  579. {
  580. .name = LPASS_BE_TERT_TDM_RX_0,
  581. .stream_name = LPASS_BE_TERT_TDM_RX_0,
  582. .playback_only = 1,
  583. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  584. SND_SOC_DPCM_TRIGGER_POST},
  585. .ops = &msm_common_be_ops,
  586. .ignore_suspend = 1,
  587. .ignore_pmdown_time = 1,
  588. SND_SOC_DAILINK_REG(tert_tdm_tx_0),
  589. },
  590. {
  591. .name = LPASS_BE_TERT_TDM_TX_0,
  592. .stream_name = LPASS_BE_TERT_TDM_TX_0,
  593. .capture_only = 1,
  594. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  595. SND_SOC_DPCM_TRIGGER_POST},
  596. .ops = &msm_common_be_ops,
  597. .ignore_suspend = 1,
  598. SND_SOC_DAILINK_REG(tert_tdm_tx_0),
  599. },
  600. {
  601. .name = LPASS_BE_QUAT_TDM_RX_0,
  602. .stream_name = LPASS_BE_QUAT_TDM_RX_0,
  603. .playback_only = 1,
  604. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  605. SND_SOC_DPCM_TRIGGER_POST},
  606. .ops = &msm_common_be_ops,
  607. .ignore_suspend = 1,
  608. .ignore_pmdown_time = 1,
  609. SND_SOC_DAILINK_REG(quat_tdm_rx_0),
  610. },
  611. {
  612. .name = LPASS_BE_QUAT_TDM_TX_0,
  613. .stream_name = LPASS_BE_QUAT_TDM_TX_0,
  614. .capture_only = 1,
  615. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  616. SND_SOC_DPCM_TRIGGER_POST},
  617. .ops = &msm_common_be_ops,
  618. .ignore_suspend = 1,
  619. SND_SOC_DAILINK_REG(quat_tdm_tx_0),
  620. },
  621. };
  622. static struct snd_soc_dai_link msm_wcn_btfm_be_dai_links[] = {
  623. {
  624. .name = LPASS_BE_SLIMBUS_7_RX,
  625. .stream_name = LPASS_BE_SLIMBUS_7_RX,
  626. .playback_only = 1,
  627. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  628. SND_SOC_DPCM_TRIGGER_POST},
  629. .init = &msm_wcn_init,
  630. .ops = &msm_common_be_ops,
  631. /* dai link has playback support */
  632. .ignore_pmdown_time = 1,
  633. .ignore_suspend = 1,
  634. SND_SOC_DAILINK_REG(slimbus_7_rx),
  635. },
  636. {
  637. .name = LPASS_BE_SLIMBUS_7_TX,
  638. .stream_name = LPASS_BE_SLIMBUS_7_TX,
  639. .capture_only = 1,
  640. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  641. SND_SOC_DPCM_TRIGGER_POST},
  642. .ops = &msm_common_be_ops,
  643. .ignore_suspend = 1,
  644. SND_SOC_DAILINK_REG(slimbus_7_tx),
  645. },
  646. {
  647. .name = LPASS_BE_SLIMBUS_8_TX,
  648. .stream_name = LPASS_BE_SLIMBUS_8_TX,
  649. .capture_only = 1,
  650. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  651. SND_SOC_DPCM_TRIGGER_POST},
  652. .ops = &msm_common_be_ops,
  653. .ignore_suspend = 1,
  654. SND_SOC_DAILINK_REG(slimbus_8_tx),
  655. },
  656. };
  657. static struct snd_soc_dai_link msm_mi2s_be_dai_links[] = {
  658. {
  659. .name = LPASS_BE_PRI_MI2S_RX,
  660. .stream_name = LPASS_BE_PRI_MI2S_RX,
  661. .playback_only = 1,
  662. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  663. SND_SOC_DPCM_TRIGGER_POST},
  664. .ops = &msm_common_be_ops,
  665. .ignore_suspend = 1,
  666. .ignore_pmdown_time = 1,
  667. SND_SOC_DAILINK_REG(pri_mi2s_rx),
  668. },
  669. {
  670. .name = LPASS_BE_PRI_MI2S_TX,
  671. .stream_name = LPASS_BE_PRI_MI2S_TX,
  672. .capture_only = 1,
  673. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  674. SND_SOC_DPCM_TRIGGER_POST},
  675. .ops = &msm_common_be_ops,
  676. .ignore_suspend = 1,
  677. SND_SOC_DAILINK_REG(pri_mi2s_tx),
  678. },
  679. {
  680. .name = LPASS_BE_SEC_MI2S_RX,
  681. .stream_name = LPASS_BE_SEC_MI2S_RX,
  682. .playback_only = 1,
  683. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  684. SND_SOC_DPCM_TRIGGER_POST},
  685. .ops = &msm_common_be_ops,
  686. .ignore_suspend = 1,
  687. .ignore_pmdown_time = 1,
  688. SND_SOC_DAILINK_REG(sec_mi2s_rx),
  689. },
  690. {
  691. .name = LPASS_BE_SEC_MI2S_TX,
  692. .stream_name = LPASS_BE_SEC_MI2S_TX,
  693. .capture_only = 1,
  694. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  695. SND_SOC_DPCM_TRIGGER_POST},
  696. .ops = &msm_common_be_ops,
  697. .ignore_suspend = 1,
  698. SND_SOC_DAILINK_REG(sec_mi2s_tx),
  699. },
  700. {
  701. .name = LPASS_BE_TERT_MI2S_RX,
  702. .stream_name = LPASS_BE_TERT_MI2S_RX,
  703. .playback_only = 1,
  704. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  705. SND_SOC_DPCM_TRIGGER_POST},
  706. .ops = &msm_common_be_ops,
  707. .ignore_suspend = 1,
  708. .ignore_pmdown_time = 1,
  709. SND_SOC_DAILINK_REG(tert_mi2s_rx),
  710. },
  711. {
  712. .name = LPASS_BE_TERT_MI2S_TX,
  713. .stream_name = LPASS_BE_TERT_MI2S_TX,
  714. .capture_only = 1,
  715. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  716. SND_SOC_DPCM_TRIGGER_POST},
  717. .ops = &msm_common_be_ops,
  718. .ignore_suspend = 1,
  719. SND_SOC_DAILINK_REG(tert_mi2s_tx),
  720. },
  721. {
  722. .name = LPASS_BE_QUAT_MI2S_RX,
  723. .stream_name = LPASS_BE_QUAT_MI2S_RX,
  724. .playback_only = 1,
  725. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  726. SND_SOC_DPCM_TRIGGER_POST},
  727. .ops = &msm_common_be_ops,
  728. .ignore_suspend = 1,
  729. .ignore_pmdown_time = 1,
  730. SND_SOC_DAILINK_REG(quat_mi2s_rx),
  731. },
  732. {
  733. .name = LPASS_BE_QUAT_MI2S_TX,
  734. .stream_name = LPASS_BE_QUAT_MI2S_TX,
  735. .capture_only = 1,
  736. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  737. SND_SOC_DPCM_TRIGGER_POST},
  738. .ops = &msm_common_be_ops,
  739. .ignore_suspend = 1,
  740. SND_SOC_DAILINK_REG(quat_mi2s_tx),
  741. },
  742. };
  743. static struct snd_soc_dai_link msm_auxpcm_be_dai_links[] = {
  744. /* Primary AUX PCM Backend DAI Links */
  745. {
  746. .name = LPASS_BE_PRI_AUXPCM_RX,
  747. .stream_name = LPASS_BE_PRI_AUXPCM_RX,
  748. .playback_only = 1,
  749. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  750. SND_SOC_DPCM_TRIGGER_POST},
  751. .ops = &msm_common_be_ops,// TODO for AUX
  752. .ignore_pmdown_time = 1,
  753. .ignore_suspend = 1,
  754. SND_SOC_DAILINK_REG(auxpcm_rx),
  755. },
  756. {
  757. .name = LPASS_BE_PRI_AUXPCM_TX,
  758. .stream_name = LPASS_BE_PRI_AUXPCM_TX,
  759. .capture_only = 1,
  760. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  761. SND_SOC_DPCM_TRIGGER_POST},
  762. .ops = &msm_common_be_ops,
  763. .ignore_suspend = 1,
  764. SND_SOC_DAILINK_REG(auxpcm_tx),
  765. },
  766. /* Secondary AUX PCM Backend DAI Links */
  767. {
  768. .name = LPASS_BE_SEC_AUXPCM_RX,
  769. .stream_name = LPASS_BE_SEC_AUXPCM_RX,
  770. .playback_only = 1,
  771. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  772. SND_SOC_DPCM_TRIGGER_POST},
  773. .ops = &msm_common_be_ops,// TODO for AUX
  774. .ignore_pmdown_time = 1,
  775. .ignore_suspend = 1,
  776. SND_SOC_DAILINK_REG(sec_auxpcm_rx),
  777. },
  778. {
  779. .name = LPASS_BE_SEC_AUXPCM_TX,
  780. .stream_name = LPASS_BE_SEC_AUXPCM_TX,
  781. .capture_only = 1,
  782. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  783. SND_SOC_DPCM_TRIGGER_POST},
  784. .ops = &msm_common_be_ops,
  785. .ignore_suspend = 1,
  786. SND_SOC_DAILINK_REG(sec_auxpcm_tx),
  787. },
  788. /* Tertiary AUX PCM Backend DAI Links */
  789. {
  790. .name = LPASS_BE_TERT_AUXPCM_RX,
  791. .stream_name = LPASS_BE_TERT_AUXPCM_RX,
  792. .playback_only = 1,
  793. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  794. SND_SOC_DPCM_TRIGGER_POST},
  795. .ops = &msm_common_be_ops,// TODO for AUX
  796. .ignore_suspend = 1,
  797. SND_SOC_DAILINK_REG(tert_auxpcm_rx),
  798. },
  799. {
  800. .name = LPASS_BE_TERT_AUXPCM_TX,
  801. .stream_name = LPASS_BE_TERT_AUXPCM_TX,
  802. .capture_only = 1,
  803. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  804. SND_SOC_DPCM_TRIGGER_POST},
  805. .ops = &msm_common_be_ops,
  806. .ignore_suspend = 1,
  807. SND_SOC_DAILINK_REG(tert_auxpcm_tx),
  808. },
  809. /* Quaternary AUX PCM Backend DAI Links */
  810. {
  811. .name = LPASS_BE_QUAT_AUXPCM_RX,
  812. .stream_name = LPASS_BE_QUAT_AUXPCM_RX,
  813. .playback_only = 1,
  814. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  815. SND_SOC_DPCM_TRIGGER_POST},
  816. .ops = &msm_common_be_ops,// TODO for AUX
  817. .ignore_suspend = 1,
  818. SND_SOC_DAILINK_REG(quat_auxpcm_rx),
  819. },
  820. {
  821. .name = LPASS_BE_QUAT_AUXPCM_TX,
  822. .stream_name = LPASS_BE_QUAT_AUXPCM_TX,
  823. .capture_only = 1,
  824. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  825. SND_SOC_DPCM_TRIGGER_POST},
  826. .ops = &msm_common_be_ops,
  827. .ignore_suspend = 1,
  828. SND_SOC_DAILINK_REG(quat_auxpcm_tx),
  829. },
  830. };
  831. static struct snd_soc_dai_link msm_rx_tx_cdc_dma_be_dai_links[] = {
  832. /* RX CDC DMA Backend DAI Links */
  833. {
  834. .name = LPASS_BE_RX_CDC_DMA_RX_0,
  835. .stream_name = LPASS_BE_RX_CDC_DMA_RX_0,
  836. .playback_only = 1,
  837. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  838. SND_SOC_DPCM_TRIGGER_POST},
  839. .ignore_pmdown_time = 1,
  840. .ignore_suspend = 1,
  841. .ops = &msm_common_be_ops,
  842. SND_SOC_DAILINK_REG(rx_dma_rx0),
  843. .init = &msm_rx_tx_codec_init,
  844. },
  845. {
  846. .name = LPASS_BE_RX_CDC_DMA_RX_1,
  847. .stream_name = LPASS_BE_RX_CDC_DMA_RX_1,
  848. .playback_only = 1,
  849. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  850. SND_SOC_DPCM_TRIGGER_POST},
  851. .ignore_pmdown_time = 1,
  852. .ignore_suspend = 1,
  853. .ops = &msm_common_be_ops,
  854. SND_SOC_DAILINK_REG(rx_dma_rx1),
  855. .init = &msm_int_wsa_init,
  856. },
  857. {
  858. .name = LPASS_BE_RX_CDC_DMA_RX_2,
  859. .stream_name = LPASS_BE_RX_CDC_DMA_RX_2,
  860. .playback_only = 1,
  861. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  862. SND_SOC_DPCM_TRIGGER_POST},
  863. .ignore_pmdown_time = 1,
  864. .ignore_suspend = 1,
  865. .ops = &msm_common_be_ops,
  866. SND_SOC_DAILINK_REG(rx_dma_rx2),
  867. },
  868. {
  869. .name = LPASS_BE_RX_CDC_DMA_RX_3,
  870. .stream_name = LPASS_BE_RX_CDC_DMA_RX_3,
  871. .playback_only = 1,
  872. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  873. SND_SOC_DPCM_TRIGGER_POST},
  874. .ignore_pmdown_time = 1,
  875. .ignore_suspend = 1,
  876. .ops = &msm_common_be_ops,
  877. SND_SOC_DAILINK_REG(rx_dma_rx3),
  878. },
  879. /* TX CDC DMA Backend DAI Links */
  880. {
  881. .name = LPASS_BE_TX_CDC_DMA_TX_3,
  882. .stream_name = LPASS_BE_TX_CDC_DMA_TX_3,
  883. .capture_only = 1,
  884. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  885. SND_SOC_DPCM_TRIGGER_POST},
  886. .ignore_suspend = 1,
  887. .ops = &msm_common_be_ops,
  888. SND_SOC_DAILINK_REG(tx_dma_tx3),
  889. },
  890. {
  891. .name = LPASS_BE_TX_CDC_DMA_TX_4,
  892. .stream_name = LPASS_BE_TX_CDC_DMA_TX_4,
  893. .capture_only = 1,
  894. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  895. SND_SOC_DPCM_TRIGGER_POST},
  896. .ignore_suspend = 1,
  897. .ops = &msm_common_be_ops,
  898. SND_SOC_DAILINK_REG(tx_dma_tx4),
  899. },
  900. };
  901. static struct snd_soc_dai_link msm_va_cdc_dma_be_dai_links[] = {
  902. {
  903. .name = LPASS_BE_VA_CDC_DMA_TX_0,
  904. .stream_name = LPASS_BE_VA_CDC_DMA_TX_0,
  905. .capture_only = 1,
  906. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  907. SND_SOC_DPCM_TRIGGER_POST},
  908. .ignore_suspend = 1,
  909. .ops = &msm_common_be_ops,
  910. SND_SOC_DAILINK_REG(va_dma_tx0),
  911. },
  912. {
  913. .name = LPASS_BE_VA_CDC_DMA_TX_1,
  914. .stream_name = LPASS_BE_VA_CDC_DMA_TX_1,
  915. .capture_only = 1,
  916. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  917. SND_SOC_DPCM_TRIGGER_POST},
  918. .ignore_suspend = 1,
  919. .ops = &msm_common_be_ops,
  920. SND_SOC_DAILINK_REG(va_dma_tx1),
  921. },
  922. {
  923. .name = LPASS_BE_VA_CDC_DMA_TX_2,
  924. .stream_name = LPASS_BE_VA_CDC_DMA_TX_2,
  925. .capture_only = 1,
  926. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  927. SND_SOC_DPCM_TRIGGER_POST},
  928. .ignore_suspend = 1,
  929. .ops = &msm_common_be_ops,
  930. SND_SOC_DAILINK_REG(va_dma_tx2),
  931. },
  932. };
  933. static struct snd_soc_dai_link msm_holi_dai_links[
  934. ARRAY_SIZE(msm_common_be_dai_links) +
  935. ARRAY_SIZE(msm_mi2s_be_dai_links) +
  936. ARRAY_SIZE(msm_auxpcm_be_dai_links) +
  937. ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links) +
  938. ARRAY_SIZE(msm_va_cdc_dma_be_dai_links) +
  939. ARRAY_SIZE(msm_wcn_btfm_be_dai_links) +
  940. ARRAY_SIZE(msm_tdm_be_dai_links)];
  941. static int msm_populate_dai_link_component_of_node(
  942. struct snd_soc_card *card)
  943. {
  944. int i, j, index, ret = 0;
  945. struct device *cdev = card->dev;
  946. struct snd_soc_dai_link *dai_link = card->dai_link;
  947. struct device_node *np = NULL;
  948. int codecs_enabled = 0;
  949. struct snd_soc_dai_link_component *codecs_comp = NULL;
  950. if (!cdev) {
  951. dev_err(cdev, "%s: Sound card device memory NULL\n", __func__);
  952. return -ENODEV;
  953. }
  954. for (i = 0; i < card->num_links; i++) {
  955. if (dai_link[i].init == NULL)
  956. dai_link[i].init = &msm_common_dai_link_init;
  957. /* populate codec_of_node for snd card dai links */
  958. if (dai_link[i].num_codecs > 0) {
  959. for (j = 0; j < dai_link[i].num_codecs; j++) {
  960. if (dai_link[i].codecs[j].of_node ||
  961. !dai_link[i].codecs[j].name)
  962. continue;
  963. index = of_property_match_string(cdev->of_node,
  964. "asoc-codec-names",
  965. dai_link[i].codecs[j].name);
  966. if (index < 0)
  967. continue;
  968. np = of_parse_phandle(cdev->of_node,
  969. "asoc-codec",
  970. index);
  971. if (!np) {
  972. dev_err(cdev, "%s: retrieving phandle for codec %s failed\n",
  973. __func__,
  974. dai_link[i].codecs[j].name);
  975. ret = -ENODEV;
  976. goto err;
  977. }
  978. dai_link[i].codecs[j].of_node = np;
  979. dai_link[i].codecs[j].name = NULL;
  980. }
  981. }
  982. }
  983. /* In multi-codec scenario, check if codecs are enabled for this platform */
  984. for (i = 0; i < card->num_links; i++) {
  985. codecs_enabled = 0;
  986. if (dai_link[i].num_codecs > 1) {
  987. for (j = 0; j < dai_link[i].num_codecs; j++) {
  988. if (!dai_link[i].codecs[j].of_node)
  989. continue;
  990. np = dai_link[i].codecs[j].of_node;
  991. if (!of_device_is_available(np)) {
  992. dev_err(cdev, "%s: codec is disabled: %s\n",
  993. __func__,
  994. np->full_name);
  995. dai_link[i].codecs[j].of_node = NULL;
  996. continue;
  997. }
  998. codecs_enabled++;
  999. }
  1000. if (codecs_enabled > 0 &&
  1001. codecs_enabled < dai_link[i].num_codecs) {
  1002. codecs_comp = devm_kzalloc(cdev,
  1003. sizeof(struct snd_soc_dai_link_component)
  1004. * codecs_enabled, GFP_KERNEL);
  1005. if (!codecs_comp) {
  1006. dev_err(cdev, "%s: %s dailink codec component alloc failed\n",
  1007. __func__, dai_link[i].name);
  1008. ret = -ENOMEM;
  1009. goto err;
  1010. }
  1011. index = 0;
  1012. for (j = 0; j < dai_link[i].num_codecs; j++) {
  1013. if (dai_link[i].codecs[j].of_node) {
  1014. codecs_comp[index].of_node =
  1015. dai_link[i].codecs[j].of_node;
  1016. codecs_comp[index].dai_name =
  1017. dai_link[i].codecs[j].dai_name;
  1018. codecs_comp[index].name = NULL;
  1019. index++;
  1020. }
  1021. }
  1022. dai_link[i].codecs = codecs_comp;
  1023. dai_link[i].num_codecs = codecs_enabled;
  1024. }
  1025. }
  1026. }
  1027. err:
  1028. return ret;
  1029. }
  1030. static int msm_audrx_stub_init(struct snd_soc_pcm_runtime *rtd)
  1031. {
  1032. return 0;
  1033. }
  1034. static int msm_snd_stub_hw_params(struct snd_pcm_substream *substream,
  1035. struct snd_pcm_hw_params *params)
  1036. {
  1037. return 0;
  1038. }
  1039. static struct snd_soc_ops msm_stub_be_ops = {
  1040. .hw_params = msm_snd_stub_hw_params,
  1041. };
  1042. struct snd_soc_card snd_soc_card_stub_msm = {
  1043. .name = "holi-stub-snd-card",
  1044. };
  1045. static struct snd_soc_dai_link msm_stub_be_dai_links[] = {
  1046. /* Backend DAI Links */
  1047. {
  1048. .name = LPASS_BE_PRI_AUXPCM_RX,
  1049. .stream_name = LPASS_BE_PRI_AUXPCM_RX,
  1050. .playback_only = 1,
  1051. .init = &msm_audrx_stub_init,
  1052. .ignore_pmdown_time = 1,
  1053. .ignore_suspend = 1,
  1054. .ops = &msm_stub_be_ops,
  1055. SND_SOC_DAILINK_REG(auxpcm_rx),
  1056. },
  1057. {
  1058. .name = LPASS_BE_PRI_AUXPCM_TX,
  1059. .stream_name = LPASS_BE_PRI_AUXPCM_TX,
  1060. .capture_only = 1,
  1061. .ignore_suspend = 1,
  1062. .ops = &msm_stub_be_ops,
  1063. SND_SOC_DAILINK_REG(auxpcm_tx),
  1064. },
  1065. };
  1066. static struct snd_soc_dai_link msm_stub_dai_links[
  1067. ARRAY_SIZE(msm_stub_be_dai_links)];
  1068. static const struct of_device_id holi_asoc_machine_of_match[] = {
  1069. { .compatible = "qcom,holi-asoc-snd",
  1070. .data = "codec"},
  1071. { .compatible = "qcom,holi-asoc-snd-stub",
  1072. .data = "stub_codec"},
  1073. {},
  1074. };
  1075. static struct snd_soc_card *populate_snd_card_dailinks(struct device *dev)
  1076. {
  1077. struct snd_soc_card *card = NULL;
  1078. struct snd_soc_dai_link *dailink = NULL;
  1079. int total_links = 0;
  1080. int len_1 = 0;
  1081. int rc = 0;
  1082. u32 mi2s_audio_intf = 0;
  1083. u32 auxpcm_audio_intf = 0;
  1084. u32 rxtx_bolero_codec = 0;
  1085. u32 va_bolero_codec = 0;
  1086. u32 val = 0;
  1087. u32 wcn_btfm_intf = 0;
  1088. const struct of_device_id *match;
  1089. match = of_match_node(holi_asoc_machine_of_match, dev->of_node);
  1090. if (!match) {
  1091. dev_err(dev, "%s: No DT match found for sound card\n",
  1092. __func__);
  1093. return NULL;
  1094. }
  1095. if (!strcmp(match->data, "codec")) {
  1096. card = &snd_soc_card_holi_msm;
  1097. memcpy(msm_holi_dai_links + total_links,
  1098. msm_common_be_dai_links,
  1099. sizeof(msm_common_be_dai_links));
  1100. total_links += ARRAY_SIZE(msm_common_be_dai_links);
  1101. rc = of_property_read_u32(dev->of_node,
  1102. "qcom,rxtx-bolero-codec",
  1103. &rxtx_bolero_codec);
  1104. if (rc) {
  1105. dev_dbg(dev, "%s: No DT match RXTX Macro codec\n",
  1106. __func__);
  1107. } else {
  1108. if (rxtx_bolero_codec) {
  1109. memcpy(msm_holi_dai_links + total_links,
  1110. msm_rx_tx_cdc_dma_be_dai_links,
  1111. sizeof(msm_rx_tx_cdc_dma_be_dai_links));
  1112. total_links +=
  1113. ARRAY_SIZE(
  1114. msm_rx_tx_cdc_dma_be_dai_links);
  1115. }
  1116. }
  1117. rc = of_property_read_u32(dev->of_node, "qcom,va-bolero-codec",
  1118. &va_bolero_codec);
  1119. if (rc) {
  1120. dev_dbg(dev, "%s: No DT match VA Macro codec\n",
  1121. __func__);
  1122. } else {
  1123. if (va_bolero_codec) {
  1124. memcpy(msm_holi_dai_links + total_links,
  1125. msm_va_cdc_dma_be_dai_links,
  1126. sizeof(msm_va_cdc_dma_be_dai_links));
  1127. total_links +=
  1128. ARRAY_SIZE(msm_va_cdc_dma_be_dai_links);
  1129. }
  1130. }
  1131. rc = of_property_read_u32(dev->of_node, "qcom,mi2s-audio-intf",
  1132. &mi2s_audio_intf);
  1133. if (rc) {
  1134. dev_dbg(dev, "%s: No DT match MI2S audio interface\n",
  1135. __func__);
  1136. } else {
  1137. if (mi2s_audio_intf) {
  1138. memcpy(msm_holi_dai_links + total_links,
  1139. msm_mi2s_be_dai_links,
  1140. sizeof(msm_mi2s_be_dai_links));
  1141. total_links +=
  1142. ARRAY_SIZE(msm_mi2s_be_dai_links);
  1143. }
  1144. }
  1145. rc = of_property_read_u32(dev->of_node,
  1146. "qcom,auxpcm-audio-intf",
  1147. &auxpcm_audio_intf);
  1148. if (rc) {
  1149. dev_dbg(dev, "%s: No DT match Aux PCM interface\n",
  1150. __func__);
  1151. } else {
  1152. if (auxpcm_audio_intf) {
  1153. memcpy(msm_holi_dai_links + total_links,
  1154. msm_auxpcm_be_dai_links,
  1155. sizeof(msm_auxpcm_be_dai_links));
  1156. total_links +=
  1157. ARRAY_SIZE(msm_auxpcm_be_dai_links);
  1158. }
  1159. }
  1160. rc = of_property_read_u32(dev->of_node, "qcom,tdm-audio-intf",
  1161. &val);
  1162. if (!rc && val) {
  1163. memcpy(msm_holi_dai_links + total_links,
  1164. msm_tdm_be_dai_links,
  1165. sizeof(msm_tdm_be_dai_links));
  1166. total_links +=
  1167. ARRAY_SIZE(msm_tdm_be_dai_links);
  1168. }
  1169. rc = of_property_read_u32(dev->of_node, "qcom,wcn-btfm",
  1170. &wcn_btfm_intf);
  1171. if (rc) {
  1172. dev_dbg(dev, "%s: No DT match wcn btfm interface\n",
  1173. __func__);
  1174. } else {
  1175. if (wcn_btfm_intf) {
  1176. memcpy(msm_holi_dai_links + total_links,
  1177. msm_wcn_btfm_be_dai_links,
  1178. sizeof(msm_wcn_btfm_be_dai_links));
  1179. total_links +=
  1180. ARRAY_SIZE(msm_wcn_btfm_be_dai_links);
  1181. }
  1182. }
  1183. dailink = msm_holi_dai_links;
  1184. }
  1185. else if (!strcmp(match->data, "stub_codec")) {
  1186. card = &snd_soc_card_stub_msm;
  1187. len_1 = ARRAY_SIZE(msm_stub_be_dai_links);
  1188. memcpy(msm_stub_dai_links,
  1189. msm_stub_be_dai_links,
  1190. sizeof(msm_stub_be_dai_links));
  1191. dailink = msm_stub_dai_links;
  1192. total_links = len_1;
  1193. }
  1194. if (card) {
  1195. card->dai_link = dailink;
  1196. card->num_links = total_links;
  1197. }
  1198. return card;
  1199. }
  1200. static int msm_rx_tx_codec_init(struct snd_soc_pcm_runtime *rtd)
  1201. {
  1202. struct snd_soc_component *bolero_component = NULL;
  1203. struct snd_soc_component *component = NULL;
  1204. struct snd_soc_dapm_context *dapm = NULL;
  1205. int ret = 0;
  1206. void *mbhc_calibration;
  1207. struct snd_info_entry *entry;
  1208. struct snd_card *card = NULL;
  1209. struct msm_asoc_mach_data *pdata =
  1210. snd_soc_card_get_drvdata(rtd->card);
  1211. pr_err("%s:: enter \n", __func__);
  1212. bolero_component = snd_soc_rtdcom_lookup(rtd, "bolero_codec");
  1213. if (!bolero_component) {
  1214. pr_err("%s: could not find component for bolero_codec\n",
  1215. __func__);
  1216. return -EINVAL;
  1217. }
  1218. pr_err("%s:: bolero comp lookup done\n", __func__);
  1219. dapm = snd_soc_component_get_dapm(bolero_component);
  1220. snd_soc_dapm_new_controls(dapm, msm_int_dapm_widgets,
  1221. ARRAY_SIZE(msm_int_dapm_widgets));
  1222. pr_err("%s:: dapm new controls msm_int_dapm_widgets \n", __func__);
  1223. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic0");
  1224. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic1");
  1225. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic2");
  1226. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic3");
  1227. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic1");
  1228. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic2");
  1229. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic3");
  1230. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic4");
  1231. snd_soc_dapm_sync(dapm);
  1232. card = rtd->card->snd_card;
  1233. if (!pdata->codec_root) {
  1234. entry = msm_snd_info_create_subdir(card->module, "codecs",
  1235. card->proc_root);
  1236. if (!entry) {
  1237. pr_debug("%s: Cannot create codecs module entry\n",
  1238. __func__);
  1239. ret = 0;
  1240. goto err;
  1241. }
  1242. pdata->codec_root = entry;
  1243. }
  1244. bolero_info_create_codec_entry(pdata->codec_root, bolero_component);
  1245. bolero_register_wake_irq(bolero_component, false);
  1246. component = snd_soc_rtdcom_lookup(rtd, WCD937X_DRV_NAME);
  1247. if (!component)
  1248. component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
  1249. if (!component) {
  1250. pr_err("%s component is NULL\n", __func__);
  1251. return -EINVAL;
  1252. }
  1253. dapm = snd_soc_component_get_dapm(component);
  1254. card = component->card->snd_card;
  1255. pdata = snd_soc_card_get_drvdata(component->card);
  1256. if (!pdata)
  1257. return -EINVAL;
  1258. if (!pdata->codec_root) {
  1259. entry = msm_snd_info_create_subdir(card->module, "codecs",
  1260. card->proc_root);
  1261. if (!entry) {
  1262. dev_dbg(component->dev, "%s: Cannot create codecs module entry\n",
  1263. __func__);
  1264. ret = 0;
  1265. goto mbhc_cfg_cal;
  1266. }
  1267. pdata->codec_root = entry;
  1268. }
  1269. if (!strncmp(component->driver->name, WCD937X_DRV_NAME, 13)) {
  1270. wcd937x_info_create_codec_entry(pdata->codec_root, component);
  1271. bolero_set_port_map(bolero_component,
  1272. ARRAY_SIZE(sm_port_map),
  1273. sm_port_map);
  1274. }
  1275. snd_soc_dapm_ignore_suspend(dapm, "EAR");
  1276. snd_soc_dapm_ignore_suspend(dapm, "AUX");
  1277. snd_soc_dapm_ignore_suspend(dapm, "LO");
  1278. snd_soc_dapm_ignore_suspend(dapm, "HPHL");
  1279. snd_soc_dapm_ignore_suspend(dapm, "HPHR");
  1280. snd_soc_dapm_ignore_suspend(dapm, "AMIC1");
  1281. snd_soc_dapm_ignore_suspend(dapm, "AMIC2");
  1282. snd_soc_dapm_ignore_suspend(dapm, "AMIC3");
  1283. snd_soc_dapm_ignore_suspend(dapm, "AMIC4");
  1284. snd_soc_dapm_sync(dapm);
  1285. codec_reg_done = true;
  1286. msm_common_dai_link_init(rtd);
  1287. mbhc_cfg_cal:
  1288. if (!strncmp(component->driver->name, WCD937X_DRV_NAME, 13)) {
  1289. mbhc_calibration = def_wcd_mbhc_cal();
  1290. if (!mbhc_calibration)
  1291. return -ENOMEM;
  1292. wcd_mbhc_cfg.calibration = mbhc_calibration;
  1293. ret = wcd937x_mbhc_hs_detect(component, &wcd_mbhc_cfg);
  1294. }
  1295. if (ret) {
  1296. dev_err(component->dev, "%s: mbhc hs detect failed, err:%d\n",
  1297. __func__, ret);
  1298. goto err_hs_detect;
  1299. }
  1300. return 0;
  1301. err_hs_detect:
  1302. kfree(mbhc_calibration);
  1303. err:
  1304. pr_err("%s:: return %d \n", __func__, ret);
  1305. return ret;
  1306. }
  1307. static int msm_int_wsa_init(struct snd_soc_pcm_runtime *rtd)
  1308. {
  1309. struct msm_asoc_mach_data *pdata =
  1310. snd_soc_card_get_drvdata(rtd->card);
  1311. int ret = 0;
  1312. if (pdata->wsa_max_devs == 0)
  1313. pr_info("%s: WSA is not enabled\n", __func__);
  1314. msm_common_dai_link_init(rtd);
  1315. return ret;
  1316. }
  1317. static int holi_ssr_enable(struct device *dev, void *data)
  1318. {
  1319. struct platform_device *pdev = to_platform_device(dev);
  1320. struct snd_soc_card *card = platform_get_drvdata(pdev);
  1321. int ret = 0;
  1322. if (!card) {
  1323. dev_err(dev, "%s: card is NULL\n", __func__);
  1324. ret = -EINVAL;
  1325. goto err;
  1326. }
  1327. if (!strcmp(card->name, "holi-stub-snd-card")) {
  1328. /* TODO */
  1329. dev_dbg(dev, "%s: TODO \n", __func__);
  1330. }
  1331. snd_card_notify_user(SND_CARD_STATUS_ONLINE);
  1332. dev_dbg(dev, "%s: setting snd_card to ONLINE\n", __func__);
  1333. err:
  1334. return ret;
  1335. }
  1336. static void holi_ssr_disable(struct device *dev, void *data)
  1337. {
  1338. struct platform_device *pdev = to_platform_device(dev);
  1339. struct snd_soc_card *card = platform_get_drvdata(pdev);
  1340. if (!card) {
  1341. dev_err(dev, "%s: card is NULL\n", __func__);
  1342. return;
  1343. }
  1344. dev_dbg(dev, "%s: setting snd_card to OFFLINE\n", __func__);
  1345. snd_card_notify_user(SND_CARD_STATUS_OFFLINE);
  1346. if (!strcmp(card->name, "holi-stub-snd-card")) {
  1347. /* TODO */
  1348. dev_dbg(dev, "%s: TODO \n", __func__);
  1349. }
  1350. }
  1351. static const struct snd_event_ops holi_ssr_ops = {
  1352. .enable = holi_ssr_enable,
  1353. .disable = holi_ssr_disable,
  1354. };
  1355. static int msm_audio_ssr_compare(struct device *dev, void *data)
  1356. {
  1357. struct device_node *node = data;
  1358. dev_dbg(dev, "%s: dev->of_node = 0x%p, node = 0x%p\n",
  1359. __func__, dev->of_node, node);
  1360. return (dev->of_node && dev->of_node == node);
  1361. }
  1362. static int msm_audio_ssr_register(struct device *dev)
  1363. {
  1364. struct device_node *np = dev->of_node;
  1365. struct snd_event_clients *ssr_clients = NULL;
  1366. struct device_node *node = NULL;
  1367. int ret = 0;
  1368. int i = 0;
  1369. for (i = 0; ; i++) {
  1370. node = of_parse_phandle(np, "qcom,msm_audio_ssr_devs", i);
  1371. if (!node)
  1372. break;
  1373. snd_event_mstr_add_client(&ssr_clients,
  1374. msm_audio_ssr_compare, node);
  1375. }
  1376. ret = snd_event_master_register(dev, &holi_ssr_ops,
  1377. ssr_clients, NULL);
  1378. if (!ret)
  1379. snd_event_notify(dev, SND_EVENT_UP);
  1380. return ret;
  1381. }
  1382. static int msm_asoc_parse_soundcard_name(struct platform_device *pdev,
  1383. struct snd_soc_card *card)
  1384. {
  1385. struct nvmem_cell *cell;
  1386. size_t len;
  1387. u32 *buf;
  1388. u32 adsp_var_idx = 0;
  1389. int ret = 0;
  1390. /* get adsp variant idx */
  1391. cell = nvmem_cell_get(&pdev->dev, "adsp_variant");
  1392. if (IS_ERR_OR_NULL(cell)) {
  1393. dev_dbg(&pdev->dev, "%s: FAILED to get nvmem cell \n", __func__);
  1394. goto parse;
  1395. }
  1396. buf = nvmem_cell_read(cell, &len);
  1397. nvmem_cell_put(cell);
  1398. if (IS_ERR_OR_NULL(buf)) {
  1399. dev_dbg(&pdev->dev, "%s: FAILED to read nvmem cell \n", __func__);
  1400. goto parse;
  1401. }
  1402. if (len <= 0 || len > sizeof(u32)) {
  1403. dev_dbg(&pdev->dev, "%s: nvmem cell length out of range: %d\n",
  1404. __func__, len);
  1405. kfree(buf);
  1406. goto parse;
  1407. }
  1408. memcpy(&adsp_var_idx, buf, len);
  1409. kfree(buf);
  1410. parse:
  1411. if(adsp_var_idx == 1)
  1412. ret = snd_soc_of_parse_card_name(card, "qcom,sku-model");
  1413. else
  1414. ret = snd_soc_of_parse_card_name(card, "qcom,model");
  1415. if (ret)
  1416. dev_err(&pdev->dev, "%s: parse card name failed, err:%d\n",
  1417. __func__, ret);
  1418. return ret;
  1419. }
  1420. static int msm_asoc_machine_probe(struct platform_device *pdev)
  1421. {
  1422. struct snd_soc_card *card = NULL;
  1423. struct msm_asoc_mach_data *pdata = NULL;
  1424. const char *mbhc_audio_jack_type = NULL;
  1425. int ret = 0;
  1426. uint index = 0;
  1427. struct clk *lpass_audio_hw_vote = NULL;
  1428. if (!pdev->dev.of_node) {
  1429. dev_err(&pdev->dev,
  1430. "%s: No platform supplied from device tree\n", __func__);
  1431. return -EINVAL;
  1432. }
  1433. pdata = devm_kzalloc(&pdev->dev,
  1434. sizeof(struct msm_asoc_mach_data), GFP_KERNEL);
  1435. if (!pdata)
  1436. return -ENOMEM;
  1437. of_property_read_u32(pdev->dev.of_node,
  1438. "qcom,wcd-disabled",
  1439. &pdata->wcd_disabled);
  1440. card = populate_snd_card_dailinks(&pdev->dev);
  1441. if (!card) {
  1442. dev_err(&pdev->dev, "%s: Card uninitialized\n", __func__);
  1443. ret = -EINVAL;
  1444. goto err;
  1445. }
  1446. card->dev = &pdev->dev;
  1447. platform_set_drvdata(pdev, card);
  1448. snd_soc_card_set_drvdata(card, pdata);
  1449. ret = msm_asoc_parse_soundcard_name(pdev, card);
  1450. if (ret) {
  1451. dev_err(&pdev->dev, "%s: parse soundcard name failed, err:%d\n",
  1452. __func__, ret);
  1453. goto err;
  1454. }
  1455. ret = snd_soc_of_parse_audio_routing(card, "qcom,audio-routing");
  1456. if (ret) {
  1457. dev_err(&pdev->dev, "%s: parse audio routing failed, err:%d\n",
  1458. __func__, ret);
  1459. goto err;
  1460. }
  1461. ret = msm_populate_dai_link_component_of_node(card);
  1462. if (ret) {
  1463. ret = -EPROBE_DEFER;
  1464. goto err;
  1465. }
  1466. /* Get maximum WSA device count for this platform */
  1467. ret = of_property_read_u32(pdev->dev.of_node,
  1468. "qcom,wsa-max-devs", &pdata->wsa_max_devs);
  1469. if (ret) {
  1470. dev_err(&pdev->dev,
  1471. "%s: wsa-max-devs property missing in DT %s, ret = %d\n",
  1472. __func__, pdev->dev.of_node->full_name, ret);
  1473. pdata->wsa_max_devs = 0;
  1474. }
  1475. /* Make sure prefix string passed for each WSA device */
  1476. ret = of_property_count_strings(pdev->dev.of_node,
  1477. "qcom,wsa-aux-dev-prefix");
  1478. if (!ret) {
  1479. dev_err(&pdev->dev,
  1480. "%s: property %s not defined in DT\n",
  1481. __func__, "qcom,wsa-aux-dev-prefix");
  1482. }
  1483. ret = devm_snd_soc_register_card(&pdev->dev, card);
  1484. if (ret == -EPROBE_DEFER) {
  1485. if (codec_reg_done)
  1486. ret = -EINVAL;
  1487. goto err;
  1488. } else if (ret) {
  1489. dev_err(&pdev->dev, "%s: snd_soc_register_card failed (%d)\n",
  1490. __func__, ret);
  1491. goto err;
  1492. }
  1493. dev_info(&pdev->dev, "%s: Sound card %s registered\n",
  1494. __func__, card->name);
  1495. pdata->hph_en1_gpio_p = of_parse_phandle(pdev->dev.of_node,
  1496. "qcom,hph-en1-gpio", 0);
  1497. if (!pdata->hph_en1_gpio_p) {
  1498. dev_dbg(&pdev->dev, "%s: property %s not detected in node %s\n",
  1499. __func__, "qcom,hph-en1-gpio",
  1500. pdev->dev.of_node->full_name);
  1501. }
  1502. pdata->hph_en0_gpio_p = of_parse_phandle(pdev->dev.of_node,
  1503. "qcom,hph-en0-gpio", 0);
  1504. if (!pdata->hph_en0_gpio_p) {
  1505. dev_dbg(&pdev->dev, "%s: property %s not detected in node %s\n",
  1506. __func__, "qcom,hph-en0-gpio",
  1507. pdev->dev.of_node->full_name);
  1508. }
  1509. ret = of_property_read_string(pdev->dev.of_node,
  1510. "qcom,mbhc-audio-jack-type", &mbhc_audio_jack_type);
  1511. if (ret) {
  1512. dev_dbg(&pdev->dev, "%s: Looking up %s property in node %s failed\n",
  1513. __func__, "qcom,mbhc-audio-jack-type",
  1514. pdev->dev.of_node->full_name);
  1515. dev_dbg(&pdev->dev, "Jack type properties set to default\n");
  1516. } else {
  1517. if (!strcmp(mbhc_audio_jack_type, "4-pole-jack")) {
  1518. wcd_mbhc_cfg.enable_anc_mic_detect = false;
  1519. dev_dbg(&pdev->dev, "This hardware has 4 pole jack");
  1520. } else if (!strcmp(mbhc_audio_jack_type, "5-pole-jack")) {
  1521. wcd_mbhc_cfg.enable_anc_mic_detect = true;
  1522. dev_dbg(&pdev->dev, "This hardware has 5 pole jack");
  1523. } else if (!strcmp(mbhc_audio_jack_type, "6-pole-jack")) {
  1524. wcd_mbhc_cfg.enable_anc_mic_detect = true;
  1525. dev_dbg(&pdev->dev, "This hardware has 6 pole jack");
  1526. } else {
  1527. wcd_mbhc_cfg.enable_anc_mic_detect = false;
  1528. dev_dbg(&pdev->dev, "Unknown value, set to default\n");
  1529. }
  1530. }
  1531. /*
  1532. * Parse US-Euro gpio info from DT. Report no error if us-euro
  1533. * entry is not found in DT file as some targets do not support
  1534. * US-Euro detection
  1535. */
  1536. pdata->us_euro_gpio_p = of_parse_phandle(pdev->dev.of_node,
  1537. "qcom,us-euro-gpios", 0);
  1538. if (!pdata->us_euro_gpio_p) {
  1539. dev_dbg(&pdev->dev, "property %s not detected in node %s",
  1540. "qcom,us-euro-gpios", pdev->dev.of_node->full_name);
  1541. } else {
  1542. dev_dbg(&pdev->dev, "%s detected\n",
  1543. "qcom,us-euro-gpios");
  1544. wcd_mbhc_cfg.swap_gnd_mic = msm_swap_gnd_mic;
  1545. }
  1546. if (wcd_mbhc_cfg.enable_usbc_analog)
  1547. wcd_mbhc_cfg.swap_gnd_mic = msm_usbc_swap_gnd_mic;
  1548. pdata->fsa_handle = of_parse_phandle(pdev->dev.of_node,
  1549. "fsa4480-i2c-handle", 0);
  1550. if (!pdata->fsa_handle)
  1551. dev_dbg(&pdev->dev, "property %s not detected in node %s\n",
  1552. "fsa4480-i2c-handle", pdev->dev.of_node->full_name);
  1553. pdata->dmic01_gpio_p = of_parse_phandle(pdev->dev.of_node,
  1554. "qcom,cdc-dmic01-gpios",
  1555. 0);
  1556. pdata->dmic23_gpio_p = of_parse_phandle(pdev->dev.of_node,
  1557. "qcom,cdc-dmic23-gpios",
  1558. 0);
  1559. pdata->dmic45_gpio_p = of_parse_phandle(pdev->dev.of_node,
  1560. "qcom,cdc-dmic45-gpios",
  1561. 0);
  1562. if (pdata->dmic01_gpio_p)
  1563. msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic01_gpio_p, false);
  1564. if (pdata->dmic23_gpio_p)
  1565. msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic23_gpio_p, false);
  1566. if (pdata->dmic45_gpio_p)
  1567. msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic45_gpio_p, false);
  1568. pdata->mi2s_gpio_p[PRIM_MI2S] = of_parse_phandle(pdev->dev.of_node,
  1569. "qcom,pri-mi2s-gpios", 0);
  1570. pdata->mi2s_gpio_p[SEC_MI2S] = of_parse_phandle(pdev->dev.of_node,
  1571. "qcom,sec-mi2s-gpios", 0);
  1572. pdata->mi2s_gpio_p[TERT_MI2S] = of_parse_phandle(pdev->dev.of_node,
  1573. "qcom,tert-mi2s-gpios", 0);
  1574. pdata->mi2s_gpio_p[QUAT_MI2S] = of_parse_phandle(pdev->dev.of_node,
  1575. "qcom,quat-mi2s-gpios", 0);
  1576. for (index = PRIM_MI2S; index < MI2S_MAX; index++)
  1577. atomic_set(&(pdata->mi2s_gpio_ref_count[index]), 0);
  1578. /* Register LPASS audio hw vote */
  1579. lpass_audio_hw_vote = devm_clk_get(&pdev->dev, "lpass_audio_hw_vote");
  1580. if (IS_ERR(lpass_audio_hw_vote)) {
  1581. ret = PTR_ERR(lpass_audio_hw_vote);
  1582. dev_dbg(&pdev->dev, "%s: clk get %s failed %d\n",
  1583. __func__, "lpass_audio_hw_vote", ret);
  1584. lpass_audio_hw_vote = NULL;
  1585. ret = 0;
  1586. }
  1587. pdata->lpass_audio_hw_vote = lpass_audio_hw_vote;
  1588. pdata->core_audio_vote_count = 0;
  1589. msm_common_snd_init(pdev, card);
  1590. ret = msm_audio_ssr_register(&pdev->dev);
  1591. if (ret)
  1592. pr_err("%s: Registration with SND event FWK failed ret = %d\n",
  1593. __func__, ret);
  1594. is_initial_boot = true;
  1595. /* change card status to ONLINE */
  1596. dev_dbg(&pdev->dev, "%s: setting snd_card to ONLINE\n", __func__);
  1597. snd_card_set_card_status(SND_CARD_STATUS_ONLINE);
  1598. return 0;
  1599. err:
  1600. devm_kfree(&pdev->dev, pdata);
  1601. return ret;
  1602. }
  1603. static int msm_asoc_machine_remove(struct platform_device *pdev)
  1604. {
  1605. struct snd_soc_card *card = platform_get_drvdata(pdev);
  1606. struct msm_asoc_mach_data *pdata = NULL;
  1607. struct msm_common_pdata *common_pdata = NULL;
  1608. if (card)
  1609. pdata = snd_soc_card_get_drvdata(card);
  1610. if (pdata)
  1611. common_pdata = pdata->common_pdata;
  1612. msm_common_snd_deinit(common_pdata);
  1613. snd_event_master_deregister(&pdev->dev);
  1614. snd_soc_unregister_card(card);
  1615. return 0;
  1616. }
  1617. static struct platform_driver holi_asoc_machine_driver = {
  1618. .driver = {
  1619. .name = DRV_NAME,
  1620. .owner = THIS_MODULE,
  1621. .pm = &snd_soc_pm_ops,
  1622. .of_match_table = holi_asoc_machine_of_match,
  1623. .suppress_bind_attrs = true,
  1624. },
  1625. .probe = msm_asoc_machine_probe,
  1626. .remove = msm_asoc_machine_remove,
  1627. };
  1628. static int __init msm_asoc_machine_init(void)
  1629. {
  1630. snd_card_sysfs_init();
  1631. return platform_driver_register(&holi_asoc_machine_driver);
  1632. }
  1633. module_init(msm_asoc_machine_init);
  1634. static void __exit msm_asoc_machine_exit(void)
  1635. {
  1636. platform_driver_unregister(&holi_asoc_machine_driver);
  1637. }
  1638. module_exit(msm_asoc_machine_exit);
  1639. MODULE_SOFTDEP("pre: bt_fm_slim");
  1640. MODULE_DESCRIPTION("ALSA SoC msm");
  1641. MODULE_LICENSE("GPL v2");
  1642. MODULE_ALIAS("platform:" DRV_NAME);
  1643. MODULE_DEVICE_TABLE(of, holi_asoc_machine_of_match);