kalama.c 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2021-2022. 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 <sound/control.h>
  19. #include <sound/core.h>
  20. #include <sound/soc.h>
  21. #include <sound/soc-dapm.h>
  22. #include <sound/pcm.h>
  23. #include <sound/pcm_params.h>
  24. #include <sound/info.h>
  25. #include <soc/snd_event.h>
  26. #include <dsp/audio_prm.h>
  27. #include <soc/swr-common.h>
  28. #include <soc/soundwire.h>
  29. #include "device_event.h"
  30. #include "asoc/msm-cdc-pinctrl.h"
  31. #include "asoc/wcd-mbhc-v2.h"
  32. #include "codecs/wcd938x/wcd938x-mbhc.h"
  33. #include "codecs/wsa884x/wsa884x.h"
  34. #include "codecs/wsa883x/wsa883x.h"
  35. #include "codecs/wcd938x/wcd938x.h"
  36. #include "codecs/lpass-cdc/lpass-cdc.h"
  37. #include <bindings/audio-codec-port-types.h>
  38. #include "codecs/lpass-cdc/lpass-cdc-wsa-macro.h"
  39. #include "kalama-port-config.h"
  40. #include "msm-audio-defs.h"
  41. #include "msm_common.h"
  42. #include "msm_dailink.h"
  43. #define DRV_NAME "kalama-asoc-snd"
  44. #define __CHIPSET__ "KALAMA "
  45. #define MSM_DAILINK_NAME(name) (__CHIPSET__#name)
  46. #define WCD9XXX_MBHC_DEF_RLOADS 5
  47. #define WCD9XXX_MBHC_DEF_BUTTONS 8
  48. #define CODEC_EXT_CLK_RATE 9600000
  49. #define DEV_NAME_STR_LEN 32
  50. #define WCD_MBHC_HS_V_MAX 1600
  51. #define WCN_CDC_SLIM_RX_CH_MAX 2
  52. #define WCN_CDC_SLIM_TX_CH_MAX 2
  53. #define WCN_CDC_SLIM_TX_CH_MAX_LITO 3
  54. /* Number of WSAs */
  55. #define MONO_SPEAKER 1
  56. #define STEREO_SPEAKER 2
  57. #define QUAD_SPEAKER 4
  58. struct msm_asoc_mach_data {
  59. struct snd_info_entry *codec_root;
  60. struct msm_common_pdata *common_pdata;
  61. int usbc_en2_gpio; /* used by gpio driver API */
  62. struct device_node *dmic01_gpio_p; /* used by pinctrl API */
  63. struct device_node *dmic23_gpio_p; /* used by pinctrl API */
  64. struct device_node *dmic45_gpio_p; /* used by pinctrl API */
  65. struct device_node *dmic67_gpio_p; /* used by pinctrl API */
  66. struct pinctrl *usbc_en2_gpio_p; /* used by pinctrl API */
  67. bool is_afe_config_done;
  68. struct device_node *fsa_handle;
  69. struct clk *lpass_audio_hw_vote;
  70. int core_audio_vote_count;
  71. u32 wsa_max_devs;
  72. int wcd_disabled;
  73. int (*get_dev_num)(struct snd_soc_component *);
  74. int backend_used;
  75. struct prm_earpa_hw_intf_config upd_config;
  76. };
  77. static bool is_initial_boot;
  78. static bool codec_reg_done;
  79. static struct snd_soc_card snd_soc_card_kalama_msm;
  80. static int dmic_0_1_gpio_cnt;
  81. static int dmic_2_3_gpio_cnt;
  82. static int dmic_4_5_gpio_cnt;
  83. static int dmic_6_7_gpio_cnt;
  84. static void *def_wcd_mbhc_cal(void);
  85. static int msm_rx_tx_codec_init(struct snd_soc_pcm_runtime*);
  86. static int msm_int_wsa_init(struct snd_soc_pcm_runtime*);
  87. static int msm_int_wsa884x_init(struct snd_soc_pcm_runtime*);
  88. static int msm_int_wsa883x_init(struct snd_soc_pcm_runtime*);
  89. /*
  90. * Need to report LINEIN
  91. * if R/L channel impedance is larger than 5K ohm
  92. */
  93. static struct wcd_mbhc_config wcd_mbhc_cfg = {
  94. .read_fw_bin = false,
  95. .calibration = NULL,
  96. .detect_extn_cable = true,
  97. .mono_stero_detection = false,
  98. .swap_gnd_mic = NULL,
  99. .hs_ext_micbias = true,
  100. .key_code[0] = KEY_MEDIA,
  101. .key_code[1] = KEY_VOICECOMMAND,
  102. .key_code[2] = KEY_VOLUMEUP,
  103. .key_code[3] = KEY_VOLUMEDOWN,
  104. .key_code[4] = 0,
  105. .key_code[5] = 0,
  106. .key_code[6] = 0,
  107. .key_code[7] = 0,
  108. .linein_th = 5000,
  109. .moisture_en = false,
  110. .mbhc_micbias = MIC_BIAS_2,
  111. .anc_micbias = MIC_BIAS_2,
  112. .enable_anc_mic_detect = false,
  113. .moisture_duty_cycle_en = true,
  114. };
  115. static bool msm_usbc_swap_gnd_mic(struct snd_soc_component *component, bool active)
  116. {
  117. struct snd_soc_card *card = component->card;
  118. struct msm_asoc_mach_data *pdata =
  119. snd_soc_card_get_drvdata(card);
  120. if (!pdata->fsa_handle)
  121. return false;
  122. return fsa4480_switch_event(pdata->fsa_handle, FSA_MIC_GND_SWAP);
  123. }
  124. static void msm_parse_upd_configuration(struct platform_device *pdev,
  125. struct msm_asoc_mach_data *pdata)
  126. {
  127. int ret = 0;
  128. u32 dt_values[2];
  129. struct snd_soc_card *card = NULL;
  130. if (!pdev || !pdata)
  131. return;
  132. ret = of_property_read_string(pdev->dev.of_node,
  133. "qcom,upd_backends_used", &pdata->upd_config.backend_used);
  134. if (ret) {
  135. pr_debug("%s:could not find %s entry in dt\n",
  136. __func__, "qcom,upd_backends_used");
  137. return;
  138. }
  139. if (!strcmp(pdata->upd_config.backend_used, "wsa")) {
  140. card = (struct snd_soc_card *)platform_get_drvdata(pdev);
  141. if (strstr(card->name, "wsa883x"))
  142. pdata->get_dev_num = wsa883x_codec_get_dev_num;
  143. else
  144. pdata->get_dev_num = wsa884x_codec_get_dev_num;
  145. } else {
  146. pdata->get_dev_num = wcd938x_codec_get_dev_num;
  147. }
  148. ret = of_property_read_u32_array(pdev->dev.of_node,
  149. "qcom,upd_lpass_reg_addr", dt_values, MAX_EARPA_REG);
  150. if (ret) {
  151. pr_debug("%s: could not find %s entry in dt\n",
  152. __func__, "qcom,upd_lpass_reg_addr");
  153. return;
  154. } else {
  155. pdata->upd_config.ear_pa_hw_reg_cfg.lpass_cdc_rx0_rx_path_ctl_phy_addr =
  156. dt_values[0];
  157. pdata->upd_config.ear_pa_hw_reg_cfg.lpass_wr_fifo_reg_phy_addr =
  158. dt_values[1];
  159. }
  160. ret = of_property_read_u32(pdev->dev.of_node,
  161. "qcom,upd_ear_pa_reg_addr", &pdata->upd_config.ear_pa_pkd_reg_addr);
  162. if (ret) {
  163. pr_debug("%s: could not find %s entry in dt\n",
  164. __func__, "qcom,upd_ear_pa_reg_addr");
  165. }
  166. }
  167. static void msm_set_upd_config(struct snd_soc_pcm_runtime *rtd)
  168. {
  169. int val1 = 0, val2 = 0, ret = 0;
  170. u8 dev_num = 0;
  171. char cdc_name[DEV_NAME_STR_LEN];
  172. struct snd_soc_component *component = NULL;
  173. struct msm_asoc_mach_data *pdata = NULL;
  174. if (!rtd) {
  175. pr_err_ratelimited("%s: rtd is NULL\n", __func__);
  176. return;
  177. }
  178. pdata = snd_soc_card_get_drvdata(rtd->card);
  179. if (!pdata) {
  180. pr_err_ratelimited("%s: pdata is NULL\n", __func__);
  181. return;
  182. }
  183. if (!pdata->get_dev_num) {
  184. pr_err_ratelimited("%s: get_dev_num is NULL\n", __func__);
  185. return;
  186. }
  187. if (!pdata->upd_config.ear_pa_hw_reg_cfg.lpass_cdc_rx0_rx_path_ctl_phy_addr ||
  188. !pdata->upd_config.ear_pa_hw_reg_cfg.lpass_wr_fifo_reg_phy_addr ||
  189. !pdata->upd_config.ear_pa_pkd_reg_addr) {
  190. pr_err_ratelimited("%s: upd static configuration is not set\n", __func__);
  191. return;
  192. }
  193. memset(cdc_name, '\0', DEV_NAME_STR_LEN);
  194. if (!strcmp(pdata->upd_config.backend_used, "wsa")) {
  195. if (pdata->wsa_max_devs > 0)
  196. memcpy(cdc_name, "wsa-codec.1", strlen("wsa-codec.1"));
  197. }
  198. else
  199. memcpy(cdc_name, WCD938X_DRV_NAME, sizeof(WCD938X_DRV_NAME));
  200. component = snd_soc_rtdcom_lookup(rtd, cdc_name);
  201. if (!component) {
  202. pr_err_ratelimited("%s: %s component is NULL\n", __func__,
  203. cdc_name);
  204. return;
  205. }
  206. dev_num = pdata->get_dev_num(component);
  207. if (dev_num < 0 || dev_num > 6) {
  208. pr_err_ratelimited("%s: invalid slave dev num : %d\n", __func__,
  209. dev_num);
  210. return;
  211. }
  212. pdata->upd_config.ear_pa_pkd_cfg.ear_pa_enable_pkd_reg_addr =
  213. pdata->upd_config.ear_pa_pkd_reg_addr & 0xFFFF;
  214. pdata->upd_config.ear_pa_pkd_cfg.ear_pa_disable_pkd_reg_addr =
  215. pdata->upd_config.ear_pa_pkd_reg_addr & 0xFFFF;
  216. val1 = val2 = 0;
  217. /* bits 16:19 carry command id */
  218. val1 |= 1 << 16;
  219. /* bits 20:23 carry swr device number */
  220. val1 |= dev_num << 20;
  221. /*
  222. * bits 24:31 carry 8 bit data to disable or enable ear pa
  223. * for wcd 7bit is global enable bit - 1 -enable. 0 - disable
  224. * for wsa 0bit is global enable bit - 1 -enable, 0 - disable
  225. */
  226. val2 = val1;
  227. if (!strcmp(pdata->upd_config.backend_used, "wsa"))
  228. val1 |= 1 << 24;
  229. else
  230. val1 |= 1 << 31;
  231. pdata->upd_config.ear_pa_pkd_cfg.ear_pa_enable_pkd_reg_addr |= val1;
  232. pdata->upd_config.ear_pa_pkd_cfg.ear_pa_disable_pkd_reg_addr |= val2;
  233. ret = audio_prm_set_cdc_earpa_duty_cycling_req(&pdata->upd_config, 1);
  234. if (ret < 0)
  235. pr_err_ratelimited("%s: upd cdc duty cycling registration failed\n", __func__);
  236. }
  237. static struct snd_soc_ops msm_common_be_ops = {
  238. .hw_params = msm_common_snd_hw_params,
  239. .startup = msm_common_snd_startup,
  240. .shutdown = msm_common_snd_shutdown,
  241. };
  242. static int msm_dmic_event(struct snd_soc_dapm_widget *w,
  243. struct snd_kcontrol *kcontrol, int event)
  244. {
  245. struct msm_asoc_mach_data *pdata = NULL;
  246. struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
  247. int ret = 0;
  248. u32 dmic_idx;
  249. int *dmic_gpio_cnt;
  250. struct device_node *dmic_gpio;
  251. char *wname;
  252. wname = strpbrk(w->name, "01234567");
  253. if (!wname) {
  254. dev_err_ratelimited(component->dev, "%s: widget not found\n", __func__);
  255. return -EINVAL;
  256. }
  257. ret = kstrtouint(wname, 10, &dmic_idx);
  258. if (ret < 0) {
  259. dev_err_ratelimited(component->dev, "%s: Invalid DMIC line on the codec\n",
  260. __func__);
  261. return -EINVAL;
  262. }
  263. pdata = snd_soc_card_get_drvdata(component->card);
  264. switch (dmic_idx) {
  265. case 0:
  266. case 1:
  267. dmic_gpio_cnt = &dmic_0_1_gpio_cnt;
  268. dmic_gpio = pdata->dmic01_gpio_p;
  269. break;
  270. case 2:
  271. case 3:
  272. dmic_gpio_cnt = &dmic_2_3_gpio_cnt;
  273. dmic_gpio = pdata->dmic23_gpio_p;
  274. break;
  275. case 4:
  276. case 5:
  277. dmic_gpio_cnt = &dmic_4_5_gpio_cnt;
  278. dmic_gpio = pdata->dmic45_gpio_p;
  279. break;
  280. case 6:
  281. case 7:
  282. dmic_gpio_cnt = &dmic_6_7_gpio_cnt;
  283. dmic_gpio = pdata->dmic67_gpio_p;
  284. break;
  285. default:
  286. dev_err_ratelimited(component->dev, "%s: Invalid DMIC Selection\n",
  287. __func__);
  288. return -EINVAL;
  289. }
  290. dev_dbg(component->dev, "%s: event %d DMIC%d dmic_gpio_cnt %d\n",
  291. __func__, event, dmic_idx, *dmic_gpio_cnt);
  292. switch (event) {
  293. case SND_SOC_DAPM_PRE_PMU:
  294. (*dmic_gpio_cnt)++;
  295. if (*dmic_gpio_cnt == 1) {
  296. ret = msm_cdc_pinctrl_select_active_state(
  297. dmic_gpio);
  298. if (ret < 0) {
  299. pr_err_ratelimited("%s: gpio set cannot be activated %sd",
  300. __func__, "dmic_gpio");
  301. return ret;
  302. }
  303. }
  304. break;
  305. case SND_SOC_DAPM_POST_PMD:
  306. (*dmic_gpio_cnt)--;
  307. if (*dmic_gpio_cnt == 0) {
  308. ret = msm_cdc_pinctrl_select_sleep_state(
  309. dmic_gpio);
  310. if (ret < 0) {
  311. pr_err_ratelimited("%s: gpio set cannot be de-activated %sd",
  312. __func__, "dmic_gpio");
  313. return ret;
  314. }
  315. }
  316. break;
  317. default:
  318. pr_err_ratelimited("%s: invalid DAPM event %d\n", __func__, event);
  319. return -EINVAL;
  320. }
  321. return 0;
  322. }
  323. static const struct snd_soc_dapm_widget msm_int_dapm_widgets[] = {
  324. SND_SOC_DAPM_MIC("Analog Mic1", NULL),
  325. SND_SOC_DAPM_MIC("Analog Mic2", NULL),
  326. SND_SOC_DAPM_MIC("Analog Mic3", NULL),
  327. SND_SOC_DAPM_MIC("Analog Mic4", NULL),
  328. SND_SOC_DAPM_MIC("Analog Mic5", NULL),
  329. SND_SOC_DAPM_MIC("Digital Mic0", msm_dmic_event),
  330. SND_SOC_DAPM_MIC("Digital Mic1", msm_dmic_event),
  331. SND_SOC_DAPM_MIC("Digital Mic2", msm_dmic_event),
  332. SND_SOC_DAPM_MIC("Digital Mic3", msm_dmic_event),
  333. SND_SOC_DAPM_MIC("Digital Mic4", msm_dmic_event),
  334. SND_SOC_DAPM_MIC("Digital Mic5", msm_dmic_event),
  335. SND_SOC_DAPM_MIC("Digital Mic6", NULL),
  336. SND_SOC_DAPM_MIC("Digital Mic7", NULL),
  337. };
  338. static int msm_wcn_init(struct snd_soc_pcm_runtime *rtd)
  339. {
  340. unsigned int rx_ch[WCN_CDC_SLIM_RX_CH_MAX] = {157, 158};
  341. unsigned int tx_ch[WCN_CDC_SLIM_TX_CH_MAX] = {159, 160};
  342. struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
  343. int ret = 0;
  344. ret = snd_soc_dai_set_channel_map(codec_dai, ARRAY_SIZE(tx_ch),
  345. tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
  346. if (ret)
  347. return ret;
  348. msm_common_dai_link_init(rtd);
  349. return ret;
  350. }
  351. static struct snd_info_entry *msm_snd_info_create_subdir(struct module *mod,
  352. const char *name,
  353. struct snd_info_entry *parent)
  354. {
  355. struct snd_info_entry *entry;
  356. entry = snd_info_create_module_entry(mod, name, parent);
  357. if (!entry)
  358. return NULL;
  359. entry->mode = S_IFDIR | 0555;
  360. if (snd_info_register(entry) < 0) {
  361. snd_info_free_entry(entry);
  362. return NULL;
  363. }
  364. return entry;
  365. }
  366. static void *def_wcd_mbhc_cal(void)
  367. {
  368. void *wcd_mbhc_cal;
  369. struct wcd_mbhc_btn_detect_cfg *btn_cfg;
  370. u16 *btn_high;
  371. wcd_mbhc_cal = kzalloc(WCD_MBHC_CAL_SIZE(WCD_MBHC_DEF_BUTTONS,
  372. WCD9XXX_MBHC_DEF_RLOADS), GFP_KERNEL);
  373. if (!wcd_mbhc_cal)
  374. return NULL;
  375. WCD_MBHC_CAL_PLUG_TYPE_PTR(wcd_mbhc_cal)->v_hs_max = WCD_MBHC_HS_V_MAX;
  376. WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal)->num_btn = WCD_MBHC_DEF_BUTTONS;
  377. btn_cfg = WCD_MBHC_CAL_BTN_DET_PTR(wcd_mbhc_cal);
  378. btn_high = ((void *)&btn_cfg->_v_btn_low) +
  379. (sizeof(btn_cfg->_v_btn_low[0]) * btn_cfg->num_btn);
  380. btn_high[0] = 75;
  381. btn_high[1] = 150;
  382. btn_high[2] = 237;
  383. btn_high[3] = 500;
  384. btn_high[4] = 500;
  385. btn_high[5] = 500;
  386. btn_high[6] = 500;
  387. btn_high[7] = 500;
  388. return wcd_mbhc_cal;
  389. }
  390. /* Digital audio interface glue - connects codec <---> CPU */
  391. static struct snd_soc_dai_link msm_common_be_dai_links[] = {
  392. /* Proxy Tx BACK END DAI Link */
  393. {
  394. .name = LPASS_BE_RT_PROXY_PCM_TX,
  395. .stream_name = LPASS_BE_RT_PROXY_PCM_TX,
  396. .capture_only = 1,
  397. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  398. SND_SOC_DPCM_TRIGGER_POST},
  399. .ignore_suspend = 1,
  400. .ops = &msm_common_be_ops,
  401. SND_SOC_DAILINK_REG(proxy_tx),
  402. },
  403. /* Proxy Rx BACK END DAI Link */
  404. {
  405. .name = LPASS_BE_RT_PROXY_PCM_RX,
  406. .stream_name = LPASS_BE_RT_PROXY_PCM_RX,
  407. .playback_only = 1,
  408. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  409. SND_SOC_DPCM_TRIGGER_POST},
  410. .ignore_pmdown_time = 1,
  411. .ignore_suspend = 1,
  412. .ops = &msm_common_be_ops,
  413. SND_SOC_DAILINK_REG(proxy_rx),
  414. },
  415. {
  416. .name = LPASS_BE_USB_AUDIO_RX,
  417. .stream_name = LPASS_BE_USB_AUDIO_RX,
  418. .playback_only = 1,
  419. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  420. SND_SOC_DPCM_TRIGGER_POST},
  421. .ignore_pmdown_time = 1,
  422. .ignore_suspend = 1,
  423. .ops = &msm_common_be_ops,
  424. SND_SOC_DAILINK_REG(usb_audio_rx),
  425. },
  426. {
  427. .name = LPASS_BE_USB_AUDIO_TX,
  428. .stream_name = LPASS_BE_USB_AUDIO_TX,
  429. .capture_only = 1,
  430. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  431. SND_SOC_DPCM_TRIGGER_POST},
  432. .ignore_suspend = 1,
  433. .ops = &msm_common_be_ops,
  434. SND_SOC_DAILINK_REG(usb_audio_tx),
  435. },
  436. {
  437. .name = LPASS_BE_PCM_DUMMY_TX_0,
  438. .stream_name = LPASS_BE_PCM_DUMMY_TX_0,
  439. .capture_only = 1,
  440. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  441. SND_SOC_DPCM_TRIGGER_POST},
  442. .ignore_suspend = 1,
  443. .ops = &msm_common_be_ops,
  444. SND_SOC_DAILINK_REG(pcm_dummy_tx0),
  445. },
  446. };
  447. static struct snd_soc_dai_link msm_wcn_be_dai_links[] = {
  448. {
  449. .name = LPASS_BE_SLIMBUS_7_RX,
  450. .stream_name = LPASS_BE_SLIMBUS_7_RX,
  451. .playback_only = 1,
  452. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  453. SND_SOC_DPCM_TRIGGER_POST},
  454. .init = &msm_wcn_init,
  455. .ops = &msm_common_be_ops,
  456. /* dai link has playback support */
  457. .ignore_pmdown_time = 1,
  458. .ignore_suspend = 1,
  459. SND_SOC_DAILINK_REG(slimbus_7_rx),
  460. },
  461. {
  462. .name = LPASS_BE_SLIMBUS_7_TX,
  463. .stream_name = LPASS_BE_SLIMBUS_7_TX,
  464. .capture_only = 1,
  465. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  466. SND_SOC_DPCM_TRIGGER_POST},
  467. .ops = &msm_common_be_ops,
  468. .ignore_suspend = 1,
  469. SND_SOC_DAILINK_REG(slimbus_7_tx),
  470. },
  471. };
  472. static struct snd_soc_dai_link ext_disp_be_dai_link[] = {
  473. /* DISP PORT BACK END DAI Link */
  474. {
  475. .name = LPASS_BE_DISPLAY_PORT_RX,
  476. .stream_name = LPASS_BE_DISPLAY_PORT_RX,
  477. .playback_only = 1,
  478. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  479. SND_SOC_DPCM_TRIGGER_POST},
  480. .ignore_pmdown_time = 1,
  481. .ignore_suspend = 1,
  482. SND_SOC_DAILINK_REG(display_port),
  483. },
  484. };
  485. static struct snd_soc_dai_link msm_wsa_cdc_dma_be_dai_links[] = {
  486. /* WSA CDC DMA Backend DAI Links */
  487. {
  488. .name = LPASS_BE_WSA_CDC_DMA_RX_0,
  489. .stream_name = LPASS_BE_WSA_CDC_DMA_RX_0,
  490. .playback_only = 1,
  491. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  492. SND_SOC_DPCM_TRIGGER_POST},
  493. .ignore_pmdown_time = 1,
  494. .ignore_suspend = 1,
  495. .ops = &msm_common_be_ops,
  496. SND_SOC_DAILINK_REG(wsa_dma_rx0),
  497. .init = &msm_int_wsa_init,
  498. },
  499. {
  500. .name = LPASS_BE_WSA_CDC_DMA_RX_1,
  501. .stream_name = LPASS_BE_WSA_CDC_DMA_RX_1,
  502. .playback_only = 1,
  503. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  504. SND_SOC_DPCM_TRIGGER_POST},
  505. .ignore_pmdown_time = 1,
  506. .ignore_suspend = 1,
  507. .ops = &msm_common_be_ops,
  508. SND_SOC_DAILINK_REG(wsa_dma_rx1),
  509. },
  510. {
  511. .name = LPASS_BE_WSA_CDC_DMA_TX_1,
  512. .stream_name = LPASS_BE_WSA_CDC_DMA_TX_1,
  513. .capture_only = 1,
  514. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  515. SND_SOC_DPCM_TRIGGER_POST},
  516. .ignore_suspend = 1,
  517. .ops = &msm_common_be_ops,
  518. SND_SOC_DAILINK_REG(wsa_dma_tx1),
  519. },
  520. {
  521. .name = LPASS_BE_WSA_CDC_DMA_TX_0,
  522. .stream_name = LPASS_BE_WSA_CDC_DMA_TX_0,
  523. .capture_only = 1,
  524. .ignore_suspend = 1,
  525. .ops = &msm_common_be_ops,
  526. /* .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, */
  527. SND_SOC_DAILINK_REG(vi_feedback),
  528. },
  529. {
  530. .name = LPASS_BE_WSA_CDC_DMA_TX_2,
  531. .stream_name = LPASS_BE_WSA_CDC_DMA_TX_2,
  532. .capture_only = 1,
  533. .ignore_suspend = 1,
  534. .ops = &msm_common_be_ops,
  535. /* .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, */
  536. SND_SOC_DAILINK_REG(cps_feedback),
  537. },
  538. {
  539. .name = LPASS_BE_WSA_CDC_DMA_RX_0_VIRT,
  540. .stream_name = LPASS_BE_WSA_CDC_DMA_RX_0_VIRT,
  541. .playback_only = 1,
  542. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  543. SND_SOC_DPCM_TRIGGER_POST},
  544. .ignore_pmdown_time = 1,
  545. .ignore_suspend = 1,
  546. .ops = &msm_common_be_ops,
  547. SND_SOC_DAILINK_REG(wsa_dma_rx0),
  548. .init = &msm_int_wsa_init,
  549. },
  550. };
  551. static struct snd_soc_dai_link msm_wsa2_cdc_dma_be_dai_links[] = {
  552. /* WSA2 CDC DMA Backend DAI Links */
  553. {
  554. .name = LPASS_BE_WSA2_CDC_DMA_RX_0,
  555. .stream_name = LPASS_BE_WSA2_CDC_DMA_RX_0,
  556. .playback_only = 1,
  557. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  558. SND_SOC_DPCM_TRIGGER_POST},
  559. .ignore_pmdown_time = 1,
  560. .ignore_suspend = 1,
  561. .ops = &msm_common_be_ops,
  562. SND_SOC_DAILINK_REG(wsa2_dma_rx0),
  563. },
  564. {
  565. .name = LPASS_BE_WSA2_CDC_DMA_RX_1,
  566. .stream_name = LPASS_BE_WSA2_CDC_DMA_RX_1,
  567. .playback_only = 1,
  568. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  569. SND_SOC_DPCM_TRIGGER_POST},
  570. .ignore_pmdown_time = 1,
  571. .ignore_suspend = 1,
  572. .ops = &msm_common_be_ops,
  573. SND_SOC_DAILINK_REG(wsa2_dma_rx1),
  574. },
  575. {
  576. .name = LPASS_BE_WSA2_CDC_DMA_TX_1,
  577. .stream_name = LPASS_BE_WSA2_CDC_DMA_TX_1,
  578. .capture_only = 1,
  579. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  580. SND_SOC_DPCM_TRIGGER_POST},
  581. .ignore_suspend = 1,
  582. .ops = &msm_common_be_ops,
  583. SND_SOC_DAILINK_REG(wsa2_dma_tx1),
  584. },
  585. {
  586. .name = LPASS_BE_WSA2_CDC_DMA_TX_0,
  587. .stream_name = LPASS_BE_WSA2_CDC_DMA_TX_0,
  588. .capture_only = 1,
  589. .ignore_suspend = 1,
  590. .ops = &msm_common_be_ops,
  591. /* .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, */
  592. SND_SOC_DAILINK_REG(wsa2_vi_feedback),
  593. },
  594. {
  595. .name = LPASS_BE_WSA2_CDC_DMA_TX_2,
  596. .stream_name = LPASS_BE_WSA2_CDC_DMA_TX_2,
  597. .capture_only = 1,
  598. .ignore_suspend = 1,
  599. .ops = &msm_common_be_ops,
  600. /* .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, */
  601. SND_SOC_DAILINK_REG(wsa2_cps_feedback),
  602. },
  603. };
  604. static struct snd_soc_dai_link msm_wsa_wsa2_cdc_dma_be_dai_links[] = {
  605. /* WSA CDC DMA Backend DAI Links */
  606. {
  607. .name = LPASS_BE_WSA_CDC_DMA_RX_0,
  608. .stream_name = LPASS_BE_WSA_CDC_DMA_RX_0,
  609. .playback_only = 1,
  610. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  611. SND_SOC_DPCM_TRIGGER_POST},
  612. .ignore_pmdown_time = 1,
  613. .ignore_suspend = 1,
  614. .ops = &msm_common_be_ops,
  615. SND_SOC_DAILINK_REG(wsa_wsa2_dma_rx0),
  616. .init = &msm_int_wsa_init,
  617. },
  618. {
  619. .name = LPASS_BE_WSA_CDC_DMA_RX_1,
  620. .stream_name = LPASS_BE_WSA_CDC_DMA_RX_1,
  621. .playback_only = 1,
  622. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  623. SND_SOC_DPCM_TRIGGER_POST},
  624. .ignore_pmdown_time = 1,
  625. .ignore_suspend = 1,
  626. .ops = &msm_common_be_ops,
  627. SND_SOC_DAILINK_REG(wsa_wsa2_dma_rx1),
  628. },
  629. {
  630. .name = LPASS_BE_WSA_CDC_DMA_TX_1,
  631. .stream_name = LPASS_BE_WSA_CDC_DMA_TX_1,
  632. .capture_only = 1,
  633. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  634. SND_SOC_DPCM_TRIGGER_POST},
  635. .ignore_suspend = 1,
  636. .ops = &msm_common_be_ops,
  637. SND_SOC_DAILINK_REG(wsa_wsa2_dma_tx1),
  638. },
  639. {
  640. .name = LPASS_BE_WSA_CDC_DMA_TX_0,
  641. .stream_name = LPASS_BE_WSA_CDC_DMA_TX_0,
  642. .capture_only = 1,
  643. .ignore_suspend = 1,
  644. .ops = &msm_common_be_ops,
  645. /* .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, */
  646. SND_SOC_DAILINK_REG(wsa_wsa2_vi_feedback),
  647. },
  648. {
  649. .name = LPASS_BE_WSA_CDC_DMA_TX_2,
  650. .stream_name = LPASS_BE_WSA_CDC_DMA_TX_2,
  651. .capture_only = 1,
  652. .ignore_suspend = 1,
  653. .ops = &msm_common_be_ops,
  654. /* .no_host_mode = SND_SOC_DAI_LINK_NO_HOST, */
  655. SND_SOC_DAILINK_REG(wsa_wsa2_cps_feedback),
  656. },
  657. };
  658. static struct snd_soc_dai_link msm_rx_tx_cdc_dma_be_dai_links[] = {
  659. /* RX CDC DMA Backend DAI Links */
  660. {
  661. .name = LPASS_BE_RX_CDC_DMA_RX_0,
  662. .stream_name = LPASS_BE_RX_CDC_DMA_RX_0,
  663. .playback_only = 1,
  664. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  665. SND_SOC_DPCM_TRIGGER_POST},
  666. .ignore_pmdown_time = 1,
  667. .ignore_suspend = 1,
  668. .ops = &msm_common_be_ops,
  669. SND_SOC_DAILINK_REG(rx_dma_rx0),
  670. .init = &msm_rx_tx_codec_init,
  671. },
  672. {
  673. .name = LPASS_BE_RX_CDC_DMA_RX_1,
  674. .stream_name = LPASS_BE_RX_CDC_DMA_RX_1,
  675. .playback_only = 1,
  676. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  677. SND_SOC_DPCM_TRIGGER_POST},
  678. .ignore_pmdown_time = 1,
  679. .ignore_suspend = 1,
  680. .ops = &msm_common_be_ops,
  681. SND_SOC_DAILINK_REG(rx_dma_rx1),
  682. },
  683. {
  684. .name = LPASS_BE_RX_CDC_DMA_RX_2,
  685. .stream_name = LPASS_BE_RX_CDC_DMA_RX_2,
  686. .playback_only = 1,
  687. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  688. SND_SOC_DPCM_TRIGGER_POST},
  689. .ignore_pmdown_time = 1,
  690. .ignore_suspend = 1,
  691. .ops = &msm_common_be_ops,
  692. SND_SOC_DAILINK_REG(rx_dma_rx2),
  693. },
  694. {
  695. .name = LPASS_BE_RX_CDC_DMA_RX_3,
  696. .stream_name = LPASS_BE_RX_CDC_DMA_RX_3,
  697. .playback_only = 1,
  698. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  699. SND_SOC_DPCM_TRIGGER_POST},
  700. .ignore_pmdown_time = 1,
  701. .ignore_suspend = 1,
  702. .ops = &msm_common_be_ops,
  703. SND_SOC_DAILINK_REG(rx_dma_rx3),
  704. },
  705. {
  706. .name = LPASS_BE_RX_CDC_DMA_RX_5,
  707. .stream_name = LPASS_BE_RX_CDC_DMA_RX_5,
  708. .playback_only = 1,
  709. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  710. SND_SOC_DPCM_TRIGGER_POST},
  711. .ignore_pmdown_time = 1,
  712. .ignore_suspend = 1,
  713. .ops = &msm_common_be_ops,
  714. SND_SOC_DAILINK_REG(rx_dma_rx5),
  715. },
  716. {
  717. .name = LPASS_BE_RX_CDC_DMA_RX_6,
  718. .stream_name = LPASS_BE_RX_CDC_DMA_RX_6,
  719. .playback_only = 1,
  720. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  721. SND_SOC_DPCM_TRIGGER_POST},
  722. .ignore_pmdown_time = 1,
  723. .ignore_suspend = 1,
  724. .ops = &msm_common_be_ops,
  725. SND_SOC_DAILINK_REG(rx_dma_rx6),
  726. },
  727. /* TX CDC DMA Backend DAI Links */
  728. {
  729. .name = LPASS_BE_TX_CDC_DMA_TX_3,
  730. .stream_name = LPASS_BE_TX_CDC_DMA_TX_3,
  731. .capture_only = 1,
  732. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  733. SND_SOC_DPCM_TRIGGER_POST},
  734. .ignore_suspend = 1,
  735. .ops = &msm_common_be_ops,
  736. SND_SOC_DAILINK_REG(tx_dma_tx3),
  737. },
  738. {
  739. .name = LPASS_BE_TX_CDC_DMA_TX_4,
  740. .stream_name = LPASS_BE_TX_CDC_DMA_TX_4,
  741. .capture_only = 1,
  742. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  743. SND_SOC_DPCM_TRIGGER_POST},
  744. .ignore_suspend = 1,
  745. .ops = &msm_common_be_ops,
  746. SND_SOC_DAILINK_REG(tx_dma_tx4),
  747. },
  748. };
  749. static struct snd_soc_dai_link msm_va_cdc_dma_be_dai_links[] = {
  750. {
  751. .name = LPASS_BE_VA_CDC_DMA_TX_0,
  752. .stream_name = LPASS_BE_VA_CDC_DMA_TX_0,
  753. .capture_only = 1,
  754. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  755. SND_SOC_DPCM_TRIGGER_POST},
  756. .ignore_suspend = 1,
  757. .ops = &msm_common_be_ops,
  758. SND_SOC_DAILINK_REG(va_dma_tx0),
  759. },
  760. {
  761. .name = LPASS_BE_VA_CDC_DMA_TX_1,
  762. .stream_name = LPASS_BE_VA_CDC_DMA_TX_1,
  763. .capture_only = 1,
  764. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  765. SND_SOC_DPCM_TRIGGER_POST},
  766. .ignore_suspend = 1,
  767. .ops = &msm_common_be_ops,
  768. SND_SOC_DAILINK_REG(va_dma_tx1),
  769. },
  770. {
  771. .name = LPASS_BE_VA_CDC_DMA_TX_2,
  772. .stream_name = LPASS_BE_VA_CDC_DMA_TX_2,
  773. .capture_only = 1,
  774. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  775. SND_SOC_DPCM_TRIGGER_POST},
  776. .ignore_suspend = 1,
  777. .ops = &msm_common_be_ops,
  778. SND_SOC_DAILINK_REG(va_dma_tx2),
  779. },
  780. };
  781. /*
  782. * I2S interface pinctrl mapping
  783. * ------------------------------------
  784. * Primary - pri_mi2s
  785. * Secondary - lpi_i2s3
  786. * Tertiary - tert_mi2s
  787. * Quaternary - quat_mi2s (lpi_i2s0)
  788. * Quinary - lpi_i2s1
  789. * Senary - lpi_i2s2
  790. * ------------------------------------
  791. */
  792. static struct snd_soc_dai_link msm_mi2s_dai_links[] = {
  793. {
  794. .name = LPASS_BE_PRI_MI2S_RX,
  795. .stream_name = LPASS_BE_PRI_MI2S_RX,
  796. .playback_only = 1,
  797. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  798. SND_SOC_DPCM_TRIGGER_POST},
  799. .ops = &msm_common_be_ops,
  800. .ignore_suspend = 1,
  801. .ignore_pmdown_time = 1,
  802. SND_SOC_DAILINK_REG(pri_mi2s_rx),
  803. },
  804. {
  805. .name = LPASS_BE_PRI_MI2S_TX,
  806. .stream_name = LPASS_BE_PRI_MI2S_TX,
  807. .capture_only = 1,
  808. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  809. SND_SOC_DPCM_TRIGGER_POST},
  810. .ops = &msm_common_be_ops,
  811. .ignore_suspend = 1,
  812. SND_SOC_DAILINK_REG(pri_mi2s_tx),
  813. },
  814. {
  815. .name = LPASS_BE_SEC_MI2S_RX,
  816. .stream_name = LPASS_BE_SEC_MI2S_RX,
  817. .playback_only = 1,
  818. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  819. SND_SOC_DPCM_TRIGGER_POST},
  820. .ops = &msm_common_be_ops,
  821. .ignore_suspend = 1,
  822. .ignore_pmdown_time = 1,
  823. SND_SOC_DAILINK_REG(sec_mi2s_rx),
  824. },
  825. {
  826. .name = LPASS_BE_SEC_MI2S_TX,
  827. .stream_name = LPASS_BE_SEC_MI2S_TX,
  828. .capture_only = 1,
  829. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  830. SND_SOC_DPCM_TRIGGER_POST},
  831. .ops = &msm_common_be_ops,
  832. .ignore_suspend = 1,
  833. SND_SOC_DAILINK_REG(sec_mi2s_tx),
  834. },
  835. {
  836. .name = LPASS_BE_TERT_MI2S_RX,
  837. .stream_name = LPASS_BE_TERT_MI2S_RX,
  838. .playback_only = 1,
  839. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  840. SND_SOC_DPCM_TRIGGER_POST},
  841. .ops = &msm_common_be_ops,
  842. .ignore_suspend = 1,
  843. .ignore_pmdown_time = 1,
  844. SND_SOC_DAILINK_REG(tert_mi2s_rx),
  845. },
  846. {
  847. .name = LPASS_BE_TERT_MI2S_TX,
  848. .stream_name = LPASS_BE_TERT_MI2S_TX,
  849. .capture_only = 1,
  850. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  851. SND_SOC_DPCM_TRIGGER_POST},
  852. .ops = &msm_common_be_ops,
  853. .ignore_suspend = 1,
  854. SND_SOC_DAILINK_REG(tert_mi2s_tx),
  855. },
  856. {
  857. .name = LPASS_BE_QUAT_MI2S_RX,
  858. .stream_name = LPASS_BE_QUAT_MI2S_RX,
  859. .playback_only = 1,
  860. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  861. SND_SOC_DPCM_TRIGGER_POST},
  862. .ops = &msm_common_be_ops,
  863. .ignore_suspend = 1,
  864. .ignore_pmdown_time = 1,
  865. SND_SOC_DAILINK_REG(quat_mi2s_rx),
  866. },
  867. {
  868. .name = LPASS_BE_QUAT_MI2S_TX,
  869. .stream_name = LPASS_BE_QUAT_MI2S_TX,
  870. .capture_only = 1,
  871. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  872. SND_SOC_DPCM_TRIGGER_POST},
  873. .ops = &msm_common_be_ops,
  874. .ignore_suspend = 1,
  875. SND_SOC_DAILINK_REG(quat_mi2s_tx),
  876. },
  877. {
  878. .name = LPASS_BE_QUIN_MI2S_RX,
  879. .stream_name = LPASS_BE_QUIN_MI2S_RX,
  880. .playback_only = 1,
  881. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  882. SND_SOC_DPCM_TRIGGER_POST},
  883. .ops = &msm_common_be_ops,
  884. .ignore_suspend = 1,
  885. .ignore_pmdown_time = 1,
  886. SND_SOC_DAILINK_REG(quin_mi2s_rx),
  887. },
  888. {
  889. .name = LPASS_BE_QUIN_MI2S_TX,
  890. .stream_name = LPASS_BE_QUIN_MI2S_TX,
  891. .capture_only = 1,
  892. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  893. SND_SOC_DPCM_TRIGGER_POST},
  894. .ops = &msm_common_be_ops,
  895. .ignore_suspend = 1,
  896. SND_SOC_DAILINK_REG(quin_mi2s_tx),
  897. },
  898. {
  899. .name = LPASS_BE_SEN_MI2S_RX,
  900. .stream_name = LPASS_BE_SEN_MI2S_RX,
  901. .playback_only = 1,
  902. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  903. SND_SOC_DPCM_TRIGGER_POST},
  904. .ops = &msm_common_be_ops,
  905. .ignore_suspend = 1,
  906. .ignore_pmdown_time = 1,
  907. SND_SOC_DAILINK_REG(sen_mi2s_rx),
  908. },
  909. {
  910. .name = LPASS_BE_SEN_MI2S_TX,
  911. .stream_name = LPASS_BE_SEN_MI2S_TX,
  912. .capture_only = 1,
  913. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  914. SND_SOC_DPCM_TRIGGER_POST},
  915. .ops = &msm_common_be_ops,
  916. .ignore_suspend = 1,
  917. SND_SOC_DAILINK_REG(sen_mi2s_tx),
  918. },
  919. {
  920. .name = LPASS_BE_SEP_MI2S_RX,
  921. .stream_name = LPASS_BE_SEP_MI2S_RX,
  922. .playback_only = 1,
  923. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  924. SND_SOC_DPCM_TRIGGER_POST},
  925. .ops = &msm_common_be_ops,
  926. .ignore_suspend = 1,
  927. .ignore_pmdown_time = 1,
  928. SND_SOC_DAILINK_REG(sep_mi2s_rx),
  929. },
  930. {
  931. .name = LPASS_BE_SEP_MI2S_TX,
  932. .stream_name = LPASS_BE_SEP_MI2S_TX,
  933. .capture_only = 1,
  934. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  935. SND_SOC_DPCM_TRIGGER_POST},
  936. .ops = &msm_common_be_ops,
  937. .ignore_suspend = 1,
  938. SND_SOC_DAILINK_REG(sep_mi2s_tx),
  939. },
  940. };
  941. static struct snd_soc_dai_link msm_tdm_dai_links[] = {
  942. {
  943. .name = LPASS_BE_PRI_TDM_RX_0,
  944. .stream_name = LPASS_BE_PRI_TDM_RX_0,
  945. .playback_only = 1,
  946. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  947. SND_SOC_DPCM_TRIGGER_POST},
  948. .ops = &msm_common_be_ops,
  949. .ignore_suspend = 1,
  950. .ignore_pmdown_time = 1,
  951. SND_SOC_DAILINK_REG(pri_tdm_rx_0),
  952. },
  953. {
  954. .name = LPASS_BE_PRI_TDM_TX_0,
  955. .stream_name = LPASS_BE_PRI_TDM_TX_0,
  956. .capture_only = 1,
  957. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  958. SND_SOC_DPCM_TRIGGER_POST},
  959. .ops = &msm_common_be_ops,
  960. .ignore_suspend = 1,
  961. SND_SOC_DAILINK_REG(pri_tdm_tx_0),
  962. },
  963. {
  964. .name = LPASS_BE_SEC_TDM_RX_0,
  965. .stream_name = LPASS_BE_SEC_TDM_RX_0,
  966. .playback_only = 1,
  967. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  968. SND_SOC_DPCM_TRIGGER_POST},
  969. .ops = &msm_common_be_ops,
  970. .ignore_suspend = 1,
  971. .ignore_pmdown_time = 1,
  972. SND_SOC_DAILINK_REG(sec_tdm_rx_0),
  973. },
  974. {
  975. .name = LPASS_BE_SEC_TDM_TX_0,
  976. .stream_name = LPASS_BE_SEC_TDM_TX_0,
  977. .capture_only = 1,
  978. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  979. SND_SOC_DPCM_TRIGGER_POST},
  980. .ops = &msm_common_be_ops,
  981. .ignore_suspend = 1,
  982. SND_SOC_DAILINK_REG(sec_tdm_tx_0),
  983. },
  984. {
  985. .name = LPASS_BE_TERT_TDM_RX_0,
  986. .stream_name = LPASS_BE_TERT_TDM_RX_0,
  987. .playback_only = 1,
  988. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  989. SND_SOC_DPCM_TRIGGER_POST},
  990. .ops = &msm_common_be_ops,
  991. .ignore_suspend = 1,
  992. .ignore_pmdown_time = 1,
  993. SND_SOC_DAILINK_REG(tert_tdm_rx_0),
  994. },
  995. {
  996. .name = LPASS_BE_TERT_TDM_TX_0,
  997. .stream_name = LPASS_BE_TERT_TDM_TX_0,
  998. .capture_only = 1,
  999. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1000. SND_SOC_DPCM_TRIGGER_POST},
  1001. .ops = &msm_common_be_ops,
  1002. .ignore_suspend = 1,
  1003. SND_SOC_DAILINK_REG(tert_tdm_tx_0),
  1004. },
  1005. {
  1006. .name = LPASS_BE_QUAT_TDM_RX_0,
  1007. .stream_name = LPASS_BE_QUAT_TDM_RX_0,
  1008. .playback_only = 1,
  1009. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1010. SND_SOC_DPCM_TRIGGER_POST},
  1011. .ops = &msm_common_be_ops,
  1012. .ignore_suspend = 1,
  1013. .ignore_pmdown_time = 1,
  1014. SND_SOC_DAILINK_REG(quat_tdm_rx_0),
  1015. },
  1016. {
  1017. .name = LPASS_BE_QUAT_TDM_TX_0,
  1018. .stream_name = LPASS_BE_QUAT_TDM_TX_0,
  1019. .capture_only = 1,
  1020. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1021. SND_SOC_DPCM_TRIGGER_POST},
  1022. .ops = &msm_common_be_ops,
  1023. .ignore_suspend = 1,
  1024. SND_SOC_DAILINK_REG(quat_tdm_tx_0),
  1025. },
  1026. {
  1027. .name = LPASS_BE_QUIN_TDM_RX_0,
  1028. .stream_name = LPASS_BE_QUIN_TDM_RX_0,
  1029. .playback_only = 1,
  1030. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1031. SND_SOC_DPCM_TRIGGER_POST},
  1032. .ops = &msm_common_be_ops,
  1033. .ignore_suspend = 1,
  1034. .ignore_pmdown_time = 1,
  1035. SND_SOC_DAILINK_REG(quin_tdm_rx_0),
  1036. },
  1037. {
  1038. .name = LPASS_BE_QUIN_TDM_TX_0,
  1039. .stream_name = LPASS_BE_QUIN_TDM_TX_0,
  1040. .capture_only = 1,
  1041. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1042. SND_SOC_DPCM_TRIGGER_POST},
  1043. .ops = &msm_common_be_ops,
  1044. .ignore_suspend = 1,
  1045. SND_SOC_DAILINK_REG(quin_tdm_tx_0),
  1046. },
  1047. {
  1048. .name = LPASS_BE_SEN_TDM_RX_0,
  1049. .stream_name = LPASS_BE_SEN_TDM_RX_0,
  1050. .playback_only = 1,
  1051. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1052. SND_SOC_DPCM_TRIGGER_POST},
  1053. .ops = &msm_common_be_ops,
  1054. .ignore_suspend = 1,
  1055. .ignore_pmdown_time = 1,
  1056. SND_SOC_DAILINK_REG(sen_tdm_rx_0),
  1057. },
  1058. {
  1059. .name = LPASS_BE_SEN_TDM_TX_0,
  1060. .stream_name = LPASS_BE_SEN_TDM_TX_0,
  1061. .capture_only = 1,
  1062. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1063. SND_SOC_DPCM_TRIGGER_POST},
  1064. .ops = &msm_common_be_ops,
  1065. .ignore_suspend = 1,
  1066. SND_SOC_DAILINK_REG(sen_tdm_tx_0),
  1067. },
  1068. {
  1069. .name = LPASS_BE_SEP_TDM_RX_0,
  1070. .stream_name = LPASS_BE_SEP_TDM_RX_0,
  1071. .playback_only = 1,
  1072. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1073. SND_SOC_DPCM_TRIGGER_POST},
  1074. .ops = &msm_common_be_ops,
  1075. .ignore_suspend = 1,
  1076. .ignore_pmdown_time = 1,
  1077. SND_SOC_DAILINK_REG(sep_tdm_rx_0),
  1078. },
  1079. {
  1080. .name = LPASS_BE_SEP_TDM_TX_0,
  1081. .stream_name = LPASS_BE_SEP_TDM_TX_0,
  1082. .capture_only = 1,
  1083. .trigger = {SND_SOC_DPCM_TRIGGER_POST,
  1084. SND_SOC_DPCM_TRIGGER_POST},
  1085. .ops = &msm_common_be_ops,
  1086. .ignore_suspend = 1,
  1087. SND_SOC_DAILINK_REG(sep_tdm_tx_0),
  1088. },
  1089. };
  1090. static struct snd_soc_dai_link msm_kalama_dai_links[
  1091. ARRAY_SIZE(msm_wsa_cdc_dma_be_dai_links) +
  1092. ARRAY_SIZE(msm_wsa2_cdc_dma_be_dai_links) +
  1093. ARRAY_SIZE(msm_wsa_wsa2_cdc_dma_be_dai_links) +
  1094. ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links) +
  1095. ARRAY_SIZE(msm_va_cdc_dma_be_dai_links) +
  1096. ARRAY_SIZE(ext_disp_be_dai_link) +
  1097. ARRAY_SIZE(msm_common_be_dai_links) +
  1098. ARRAY_SIZE(msm_wcn_be_dai_links) +
  1099. ARRAY_SIZE(msm_mi2s_dai_links) +
  1100. ARRAY_SIZE(msm_tdm_dai_links)];
  1101. static int msm_populate_dai_link_component_of_node(
  1102. struct snd_soc_card *card)
  1103. {
  1104. int i, j, index, ret = 0;
  1105. struct device *cdev = card->dev;
  1106. struct snd_soc_dai_link *dai_link = card->dai_link;
  1107. struct device_node *np = NULL;
  1108. int codecs_enabled = 0;
  1109. struct snd_soc_dai_link_component *codecs_comp = NULL;
  1110. if (!cdev) {
  1111. dev_err_ratelimited(cdev, "%s: Sound card device memory NULL\n", __func__);
  1112. return -ENODEV;
  1113. }
  1114. for (i = 0; i < card->num_links; i++) {
  1115. if (dai_link[i].init == NULL)
  1116. dai_link[i].init = &msm_common_dai_link_init;
  1117. /* populate codec_of_node for snd card dai links */
  1118. if (dai_link[i].num_codecs > 0) {
  1119. for (j = 0; j < dai_link[i].num_codecs; j++) {
  1120. if (dai_link[i].codecs[j].of_node ||
  1121. !dai_link[i].codecs[j].name)
  1122. continue;
  1123. index = of_property_match_string(cdev->of_node,
  1124. "asoc-codec-names",
  1125. dai_link[i].codecs[j].name);
  1126. if (index < 0)
  1127. continue;
  1128. np = of_parse_phandle(cdev->of_node,
  1129. "asoc-codec",
  1130. index);
  1131. if (!np) {
  1132. dev_err_ratelimited(cdev,
  1133. "%s: retrieving phandle for codec %s failed\n",
  1134. __func__,
  1135. dai_link[i].codecs[j].name);
  1136. ret = -ENODEV;
  1137. goto err;
  1138. }
  1139. dai_link[i].codecs[j].of_node = np;
  1140. dai_link[i].codecs[j].name = NULL;
  1141. }
  1142. }
  1143. }
  1144. /* In multi-codec scenario, check if codecs are enabled for this platform */
  1145. for (i = 0; i < card->num_links; i++) {
  1146. codecs_enabled = 0;
  1147. if (dai_link[i].num_codecs > 1) {
  1148. for (j = 0; j < dai_link[i].num_codecs; j++) {
  1149. if (!dai_link[i].codecs[j].of_node)
  1150. continue;
  1151. np = dai_link[i].codecs[j].of_node;
  1152. if (!of_device_is_available(np)) {
  1153. dev_err_ratelimited(cdev, "%s: codec is disabled: %s\n",
  1154. __func__,
  1155. np->full_name);
  1156. dai_link[i].codecs[j].of_node = NULL;
  1157. continue;
  1158. }
  1159. codecs_enabled++;
  1160. }
  1161. if (codecs_enabled > 0 &&
  1162. codecs_enabled < dai_link[i].num_codecs) {
  1163. codecs_comp = devm_kzalloc(cdev,
  1164. sizeof(struct snd_soc_dai_link_component)
  1165. * codecs_enabled, GFP_KERNEL);
  1166. if (!codecs_comp) {
  1167. dev_err_ratelimited(cdev,
  1168. "%s: %s dailink codec component alloc failed\n",
  1169. __func__, dai_link[i].name);
  1170. ret = -ENOMEM;
  1171. goto err;
  1172. }
  1173. index = 0;
  1174. for (j = 0; j < dai_link[i].num_codecs; j++) {
  1175. if(dai_link[i].codecs[j].of_node) {
  1176. codecs_comp[index].of_node =
  1177. dai_link[i].codecs[j].of_node;
  1178. codecs_comp[index].dai_name =
  1179. dai_link[i].codecs[j].dai_name;
  1180. codecs_comp[index].name = NULL;
  1181. index++;
  1182. }
  1183. }
  1184. dai_link[i].codecs = codecs_comp;
  1185. dai_link[i].num_codecs = codecs_enabled;
  1186. }
  1187. }
  1188. }
  1189. err:
  1190. return ret;
  1191. }
  1192. static int msm_audrx_stub_init(struct snd_soc_pcm_runtime *rtd)
  1193. {
  1194. return 0;
  1195. }
  1196. static int msm_snd_stub_hw_params(struct snd_pcm_substream *substream,
  1197. struct snd_pcm_hw_params *params)
  1198. {
  1199. return 0;
  1200. }
  1201. static struct snd_soc_ops msm_stub_be_ops = {
  1202. .hw_params = msm_snd_stub_hw_params,
  1203. };
  1204. struct snd_soc_card snd_soc_card_stub_msm = {
  1205. .name = "kalama-stub-snd-card",
  1206. };
  1207. static struct snd_soc_dai_link msm_stub_be_dai_links[] = {
  1208. /* Backend DAI Links */
  1209. {
  1210. .name = LPASS_BE_PRI_AUXPCM_RX,
  1211. .stream_name = LPASS_BE_PRI_AUXPCM_RX,
  1212. .playback_only = 1,
  1213. .init = &msm_audrx_stub_init,
  1214. .ignore_pmdown_time = 1,
  1215. .ignore_suspend = 1,
  1216. .ops = &msm_stub_be_ops,
  1217. SND_SOC_DAILINK_REG(auxpcm_rx),
  1218. },
  1219. {
  1220. .name = LPASS_BE_PRI_AUXPCM_TX,
  1221. .stream_name = LPASS_BE_PRI_AUXPCM_TX,
  1222. .capture_only = 1,
  1223. .ignore_suspend = 1,
  1224. .ops = &msm_stub_be_ops,
  1225. SND_SOC_DAILINK_REG(auxpcm_tx),
  1226. },
  1227. };
  1228. static struct snd_soc_dai_link msm_stub_dai_links[
  1229. ARRAY_SIZE(msm_stub_be_dai_links)];
  1230. static const struct of_device_id kalama_asoc_machine_of_match[] = {
  1231. { .compatible = "qcom,kalama-asoc-snd",
  1232. .data = "codec"},
  1233. { .compatible = "qcom,kalama-asoc-snd-stub",
  1234. .data = "stub_codec"},
  1235. {},
  1236. };
  1237. static int msm_snd_card_late_probe(struct snd_soc_card *card)
  1238. {
  1239. struct snd_soc_component *component = NULL;
  1240. struct snd_soc_pcm_runtime *rtd;
  1241. struct msm_asoc_mach_data *pdata;
  1242. int ret = 0;
  1243. void *mbhc_calibration;
  1244. pdata = snd_soc_card_get_drvdata(card);
  1245. if (!pdata)
  1246. return -EINVAL;
  1247. if (pdata->wcd_disabled)
  1248. return 0;
  1249. rtd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]);
  1250. if (!rtd) {
  1251. dev_err(card->dev,
  1252. "%s: snd_soc_get_pcm_runtime for %s failed!\n",
  1253. __func__, card->dai_link[0]);
  1254. return -EINVAL;
  1255. }
  1256. component = snd_soc_rtdcom_lookup(rtd, WCD938X_DRV_NAME);
  1257. if (!component) {
  1258. pr_err("%s component is NULL\n", __func__);
  1259. return -EINVAL;
  1260. }
  1261. mbhc_calibration = def_wcd_mbhc_cal();
  1262. if (!mbhc_calibration)
  1263. return -ENOMEM;
  1264. wcd_mbhc_cfg.calibration = mbhc_calibration;
  1265. ret = wcd938x_mbhc_hs_detect(component, &wcd_mbhc_cfg);
  1266. if (ret) {
  1267. dev_err(component->dev, "%s: mbhc hs detect failed, err:%d\n",
  1268. __func__, ret);
  1269. goto err_hs_detect;
  1270. }
  1271. return 0;
  1272. err_hs_detect:
  1273. kfree(mbhc_calibration);
  1274. return ret;
  1275. }
  1276. static struct snd_soc_card *populate_snd_card_dailinks(struct device *dev, int wsa_max_devs)
  1277. {
  1278. struct snd_soc_card *card = NULL;
  1279. struct snd_soc_dai_link *dailink = NULL;
  1280. int total_links = 0;
  1281. int rc = 0;
  1282. u32 val = 0;
  1283. const struct of_device_id *match;
  1284. match = of_match_node(kalama_asoc_machine_of_match, dev->of_node);
  1285. if (!match) {
  1286. dev_err_ratelimited(dev, "%s: No DT match found for sound card\n",
  1287. __func__);
  1288. return NULL;
  1289. }
  1290. if (!strcmp(match->data, "codec")) {
  1291. card = &snd_soc_card_kalama_msm;
  1292. /* late probe uses dai link at index '0' to get wcd component */
  1293. memcpy(msm_kalama_dai_links + total_links,
  1294. msm_rx_tx_cdc_dma_be_dai_links,
  1295. sizeof(msm_rx_tx_cdc_dma_be_dai_links));
  1296. total_links +=
  1297. ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links);
  1298. switch (wsa_max_devs) {
  1299. case MONO_SPEAKER:
  1300. case STEREO_SPEAKER:
  1301. memcpy(msm_kalama_dai_links + total_links,
  1302. msm_wsa_cdc_dma_be_dai_links,
  1303. sizeof(msm_wsa_cdc_dma_be_dai_links));
  1304. total_links += ARRAY_SIZE(msm_wsa_cdc_dma_be_dai_links);
  1305. break;
  1306. case QUAD_SPEAKER:
  1307. memcpy(msm_kalama_dai_links + total_links,
  1308. msm_wsa2_cdc_dma_be_dai_links,
  1309. sizeof(msm_wsa2_cdc_dma_be_dai_links));
  1310. total_links += ARRAY_SIZE(msm_wsa2_cdc_dma_be_dai_links);
  1311. memcpy(msm_kalama_dai_links + total_links,
  1312. msm_wsa_wsa2_cdc_dma_be_dai_links,
  1313. sizeof(msm_wsa_wsa2_cdc_dma_be_dai_links));
  1314. total_links += ARRAY_SIZE(msm_wsa_wsa2_cdc_dma_be_dai_links);
  1315. break;
  1316. default:
  1317. dev_dbg(dev,
  1318. "%s: Unexpected number of WSAs, wsa_max_devs: %d\n",
  1319. __func__, wsa_max_devs);
  1320. break;
  1321. }
  1322. memcpy(msm_kalama_dai_links + total_links,
  1323. msm_va_cdc_dma_be_dai_links,
  1324. sizeof(msm_va_cdc_dma_be_dai_links));
  1325. total_links += ARRAY_SIZE(msm_va_cdc_dma_be_dai_links);
  1326. memcpy(msm_kalama_dai_links + total_links,
  1327. msm_common_be_dai_links,
  1328. sizeof(msm_common_be_dai_links));
  1329. total_links += ARRAY_SIZE(msm_common_be_dai_links);
  1330. rc = of_property_read_u32(dev->of_node,
  1331. "qcom,mi2s-audio-intf", &val);
  1332. if (!rc && val) {
  1333. memcpy(msm_kalama_dai_links + total_links,
  1334. msm_mi2s_dai_links,
  1335. sizeof(msm_mi2s_dai_links));
  1336. total_links += ARRAY_SIZE(msm_mi2s_dai_links);
  1337. }
  1338. rc = of_property_read_u32(dev->of_node,
  1339. "qcom,tdm-audio-intf", &val);
  1340. if (!rc && val) {
  1341. memcpy(msm_kalama_dai_links + total_links,
  1342. msm_tdm_dai_links,
  1343. sizeof(msm_tdm_dai_links));
  1344. total_links += ARRAY_SIZE(msm_tdm_dai_links);
  1345. }
  1346. rc = of_property_read_u32(dev->of_node,
  1347. "qcom,ext-disp-audio-rx", &val);
  1348. if (!rc && val) {
  1349. dev_dbg(dev, "%s(): ext disp audio support present\n",
  1350. __func__);
  1351. memcpy(msm_kalama_dai_links + total_links,
  1352. ext_disp_be_dai_link,
  1353. sizeof(ext_disp_be_dai_link));
  1354. total_links += ARRAY_SIZE(ext_disp_be_dai_link);
  1355. }
  1356. rc = of_property_read_u32(dev->of_node, "qcom,wcn-bt", &val);
  1357. if (!rc && val) {
  1358. dev_dbg(dev, "%s(): WCN BT support present\n",
  1359. __func__);
  1360. memcpy(msm_kalama_dai_links + total_links,
  1361. msm_wcn_be_dai_links,
  1362. sizeof(msm_wcn_be_dai_links));
  1363. total_links += ARRAY_SIZE(msm_wcn_be_dai_links);
  1364. }
  1365. dailink = msm_kalama_dai_links;
  1366. } else if(!strcmp(match->data, "stub_codec")) {
  1367. card = &snd_soc_card_stub_msm;
  1368. memcpy(msm_stub_dai_links,
  1369. msm_stub_be_dai_links,
  1370. sizeof(msm_stub_be_dai_links));
  1371. dailink = msm_stub_dai_links;
  1372. total_links = ARRAY_SIZE(msm_stub_be_dai_links);
  1373. }
  1374. if (card) {
  1375. card->dai_link = dailink;
  1376. card->num_links = total_links;
  1377. if (!strcmp(match->data, "codec"))
  1378. card->late_probe = msm_snd_card_late_probe;
  1379. }
  1380. return card;
  1381. }
  1382. static int msm_int_wsa883x_init(struct snd_soc_pcm_runtime *rtd)
  1383. {
  1384. u8 spkleft_ports[WSA883X_MAX_SWR_PORTS] = {0, 1, 2, 3};
  1385. u8 spkright_ports[WSA883X_MAX_SWR_PORTS] = {0, 1, 2, 3};
  1386. u8 spkleft_port_types[WSA883X_MAX_SWR_PORTS] = {SPKR_L, SPKR_L_COMP,
  1387. SPKR_L_BOOST, SPKR_L_VI};
  1388. u8 spkright_port_types[WSA883X_MAX_SWR_PORTS] = {SPKR_R, SPKR_R_COMP,
  1389. SPKR_R_BOOST, SPKR_R_VI};
  1390. unsigned int ch_rate[WSA883X_MAX_SWR_PORTS] = {SWR_CLK_RATE_2P4MHZ, SWR_CLK_RATE_0P6MHZ,
  1391. SWR_CLK_RATE_0P3MHZ, SWR_CLK_RATE_1P2MHZ};
  1392. unsigned int ch_mask[WSA883X_MAX_SWR_PORTS] = {0x1, 0xF, 0x3, 0x3};
  1393. struct snd_soc_component *component = NULL;
  1394. struct msm_asoc_mach_data *pdata =
  1395. snd_soc_card_get_drvdata(rtd->card);
  1396. if (pdata->wsa_max_devs > 0) {
  1397. component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.1");
  1398. if (!component) {
  1399. pr_err("%s: wsa-codec.1 component is NULL\n", __func__);
  1400. return -EINVAL;
  1401. }
  1402. wsa883x_set_channel_map(component, &spkleft_ports[0],
  1403. WSA883X_MAX_SWR_PORTS, &ch_mask[0],
  1404. &ch_rate[0], &spkleft_port_types[0]);
  1405. wsa883x_codec_info_create_codec_entry(pdata->codec_root,
  1406. component);
  1407. }
  1408. /* If current platform has more than one WSA */
  1409. if (pdata->wsa_max_devs > 1) {
  1410. component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.2");
  1411. if (!component) {
  1412. pr_err("%s: wsa-codec.2 component is NULL\n", __func__);
  1413. return -EINVAL;
  1414. }
  1415. wsa883x_set_channel_map(component, &spkright_ports[0],
  1416. WSA883X_MAX_SWR_PORTS, &ch_mask[0],
  1417. &ch_rate[0], &spkright_port_types[0]);
  1418. wsa883x_codec_info_create_codec_entry(pdata->codec_root,
  1419. component);
  1420. }
  1421. if (pdata->wsa_max_devs > 2) {
  1422. component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.3");
  1423. if (!component) {
  1424. pr_err("%s: wsa-codec.3 component is NULL\n", __func__);
  1425. return -EINVAL;
  1426. }
  1427. wsa883x_set_channel_map(component, &spkleft_ports[0],
  1428. WSA883X_MAX_SWR_PORTS, &ch_mask[0],
  1429. &ch_rate[0], &spkleft_port_types[0]);
  1430. wsa883x_codec_info_create_codec_entry(pdata->codec_root,
  1431. component);
  1432. }
  1433. if (pdata->wsa_max_devs > 3) {
  1434. component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.4");
  1435. if (!component) {
  1436. pr_err("%s: wsa-codec.4 component is NULL\n", __func__);
  1437. return -EINVAL;
  1438. }
  1439. wsa883x_set_channel_map(component, &spkright_ports[0],
  1440. WSA883X_MAX_SWR_PORTS, &ch_mask[0],
  1441. &ch_rate[0], &spkright_port_types[0]);
  1442. wsa883x_codec_info_create_codec_entry(pdata->codec_root,
  1443. component);
  1444. }
  1445. msm_common_dai_link_init(rtd);
  1446. return 0;
  1447. }
  1448. static int msm_int_wsa884x_init(struct snd_soc_pcm_runtime *rtd)
  1449. {
  1450. u8 spkleft_ports[WSA884X_MAX_SWR_PORTS] = {0, 1, 2, 3, 4, 5};
  1451. u8 spkright_ports[WSA884X_MAX_SWR_PORTS] = {0, 1, 2, 3, 4, 5};
  1452. u8 spkleft_port_types[WSA884X_MAX_SWR_PORTS] = {SPKR_L, SPKR_L_COMP,
  1453. SPKR_L_BOOST, PBR, SPKR_L_VI, CPS};
  1454. u8 spkright_port_types[WSA884X_MAX_SWR_PORTS] = {SPKR_R, SPKR_R_COMP,
  1455. SPKR_R_BOOST, PBR, SPKR_R_VI, CPS};
  1456. unsigned int ch_rate[WSA884X_MAX_SWR_PORTS] = {SWR_CLK_RATE_2P4MHZ, SWR_CLK_RATE_0P6MHZ,
  1457. SWR_CLK_RATE_0P3MHZ, SWR_CLK_RATE_48KHZ,
  1458. SWR_CLK_RATE_1P2MHZ, SWR_CLK_RATE_24KHZ};
  1459. unsigned int ch_mask[WSA884X_MAX_SWR_PORTS] = {0x1, 0xF, 0x3, 0x1, 0x3, 0x3};
  1460. struct snd_soc_component *component = NULL;
  1461. struct msm_asoc_mach_data *pdata =
  1462. snd_soc_card_get_drvdata(rtd->card);
  1463. if (pdata->wsa_max_devs > 0) {
  1464. component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.1");
  1465. if (!component) {
  1466. pr_err("%s: wsa-codec.1 component is NULL\n", __func__);
  1467. return -EINVAL;
  1468. }
  1469. wsa884x_set_channel_map(component, &spkleft_ports[0],
  1470. WSA884X_MAX_SWR_PORTS, &ch_mask[0],
  1471. &ch_rate[0], &spkleft_port_types[0]);
  1472. wsa884x_codec_info_create_codec_entry(pdata->codec_root,
  1473. component);
  1474. }
  1475. /* If current platform has more than one WSA */
  1476. if (pdata->wsa_max_devs > 1) {
  1477. component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.2");
  1478. if (!component) {
  1479. pr_err("%s: wsa-codec.2 component is NULL\n", __func__);
  1480. return -EINVAL;
  1481. }
  1482. wsa884x_set_channel_map(component, &spkright_ports[0],
  1483. WSA884X_MAX_SWR_PORTS, &ch_mask[0],
  1484. &ch_rate[0], &spkright_port_types[0]);
  1485. wsa884x_codec_info_create_codec_entry(pdata->codec_root,
  1486. component);
  1487. }
  1488. if (pdata->wsa_max_devs > 2) {
  1489. component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.3");
  1490. if (!component) {
  1491. pr_err("%s: wsa-codec.3 component is NULL\n", __func__);
  1492. return -EINVAL;
  1493. }
  1494. wsa884x_set_channel_map(component, &spkleft_ports[0],
  1495. WSA884X_MAX_SWR_PORTS, &ch_mask[0],
  1496. &ch_rate[0], &spkleft_port_types[0]);
  1497. wsa884x_codec_info_create_codec_entry(pdata->codec_root,
  1498. component);
  1499. }
  1500. if (pdata->wsa_max_devs > 3) {
  1501. component = snd_soc_rtdcom_lookup(rtd, "wsa-codec.4");
  1502. if (!component) {
  1503. pr_err("%s: wsa-codec.4 component is NULL\n", __func__);
  1504. return -EINVAL;
  1505. }
  1506. wsa884x_set_channel_map(component, &spkright_ports[0],
  1507. WSA884X_MAX_SWR_PORTS, &ch_mask[0],
  1508. &ch_rate[0], &spkright_port_types[0]);
  1509. wsa884x_codec_info_create_codec_entry(pdata->codec_root,
  1510. component);
  1511. }
  1512. msm_common_dai_link_init(rtd);
  1513. return 0;
  1514. }
  1515. static int msm_int_wsa_init(struct snd_soc_pcm_runtime *rtd)
  1516. {
  1517. if (strstr(rtd->card->name, "wsa883x"))
  1518. return msm_int_wsa883x_init(rtd);
  1519. return msm_int_wsa884x_init(rtd);
  1520. }
  1521. static int msm_rx_tx_codec_init(struct snd_soc_pcm_runtime *rtd)
  1522. {
  1523. int codec_variant = -1;
  1524. struct snd_soc_component *component = NULL;
  1525. struct snd_soc_component *lpass_cdc_component = NULL;
  1526. struct snd_soc_dapm_context *dapm = NULL;
  1527. struct snd_info_entry *entry = NULL;
  1528. struct snd_card *card = NULL;
  1529. struct msm_asoc_mach_data *pdata =
  1530. snd_soc_card_get_drvdata(rtd->card);
  1531. int ret = 0;
  1532. lpass_cdc_component = snd_soc_rtdcom_lookup(rtd, "lpass-cdc");
  1533. if (!lpass_cdc_component) {
  1534. pr_err("%s: could not find component for lpass-cdc\n",
  1535. __func__);
  1536. return ret;
  1537. }
  1538. dapm = snd_soc_component_get_dapm(lpass_cdc_component);
  1539. snd_soc_dapm_new_controls(dapm, msm_int_dapm_widgets,
  1540. ARRAY_SIZE(msm_int_dapm_widgets));
  1541. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic0");
  1542. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic1");
  1543. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic2");
  1544. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic3");
  1545. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic4");
  1546. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic5");
  1547. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic6");
  1548. snd_soc_dapm_ignore_suspend(dapm, "Digital Mic7");
  1549. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic1");
  1550. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic2");
  1551. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic3");
  1552. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic4");
  1553. snd_soc_dapm_ignore_suspend(dapm, "Analog Mic5");
  1554. lpass_cdc_set_port_map(lpass_cdc_component, ARRAY_SIZE(sm_port_map), sm_port_map);
  1555. card = rtd->card->snd_card;
  1556. if (!pdata->codec_root) {
  1557. entry = msm_snd_info_create_subdir(card->module, "codecs",
  1558. card->proc_root);
  1559. if (!entry) {
  1560. pr_debug("%s: Cannot create codecs module entry\n",
  1561. __func__);
  1562. return ret;
  1563. }
  1564. pdata->codec_root = entry;
  1565. }
  1566. lpass_cdc_info_create_codec_entry(pdata->codec_root, lpass_cdc_component);
  1567. lpass_cdc_register_wake_irq(lpass_cdc_component, false);
  1568. if (pdata->wcd_disabled)
  1569. goto done;
  1570. component = snd_soc_rtdcom_lookup(rtd, WCD938X_DRV_NAME);
  1571. if (!component) {
  1572. pr_err("%s could not find component for %s\n",
  1573. __func__, WCD938X_DRV_NAME);
  1574. return -EINVAL;
  1575. }
  1576. dapm = snd_soc_component_get_dapm(component);
  1577. card = component->card->snd_card;
  1578. snd_soc_dapm_ignore_suspend(dapm, "EAR");
  1579. snd_soc_dapm_ignore_suspend(dapm, "AUX");
  1580. snd_soc_dapm_ignore_suspend(dapm, "HPHL");
  1581. snd_soc_dapm_ignore_suspend(dapm, "HPHR");
  1582. snd_soc_dapm_ignore_suspend(dapm, "AMIC1");
  1583. snd_soc_dapm_ignore_suspend(dapm, "AMIC2");
  1584. snd_soc_dapm_ignore_suspend(dapm, "AMIC3");
  1585. snd_soc_dapm_ignore_suspend(dapm, "AMIC4");
  1586. snd_soc_dapm_sync(dapm);
  1587. pdata = snd_soc_card_get_drvdata(component->card);
  1588. if (!pdata->codec_root) {
  1589. entry = msm_snd_info_create_subdir(card->module, "codecs",
  1590. card->proc_root);
  1591. if (!entry) {
  1592. dev_dbg(component->dev, "%s: Cannot create codecs module entry\n",
  1593. __func__);
  1594. return 0;
  1595. }
  1596. pdata->codec_root = entry;
  1597. }
  1598. wcd938x_info_create_codec_entry(pdata->codec_root, component);
  1599. codec_variant = wcd938x_get_codec_variant(component);
  1600. dev_dbg(component->dev, "%s: variant %d\n", __func__, codec_variant);
  1601. if (codec_variant == WCD9385)
  1602. ret = lpass_cdc_rx_set_fir_capability(lpass_cdc_component, true);
  1603. else
  1604. ret = lpass_cdc_rx_set_fir_capability(lpass_cdc_component, false);
  1605. if (ret < 0) {
  1606. dev_err_ratelimited(component->dev, "%s: set fir capability failed: %d\n",
  1607. __func__, ret);
  1608. return ret;
  1609. }
  1610. done:
  1611. codec_reg_done = true;
  1612. msm_common_dai_link_init(rtd);
  1613. return ret;
  1614. }
  1615. static int kalama_ssr_enable(struct device *dev, void *data)
  1616. {
  1617. struct platform_device *pdev = to_platform_device(dev);
  1618. struct snd_soc_card *card = platform_get_drvdata(pdev);
  1619. struct snd_soc_pcm_runtime *rtd = NULL, *rtd_wcd = NULL, *rtd_wsa = NULL;
  1620. struct msm_asoc_mach_data *pdata = NULL;
  1621. int ret = 0;
  1622. if (!card) {
  1623. dev_err_ratelimited(dev, "%s: card is NULL\n", __func__);
  1624. ret = -EINVAL;
  1625. goto err;
  1626. }
  1627. if (!strcmp(card->name, "kalama-stub-snd-card")) {
  1628. /* TODO */
  1629. dev_dbg(dev, "%s: TODO \n", __func__);
  1630. }
  1631. snd_card_notify_user(SND_CARD_STATUS_ONLINE);
  1632. dev_dbg(dev, "%s: setting snd_card to ONLINE\n", __func__);
  1633. pdata = snd_soc_card_get_drvdata(card);
  1634. if (!pdata) {
  1635. dev_dbg(dev, "%s: pdata is NULL \n", __func__);
  1636. goto err;
  1637. }
  1638. rtd_wcd = snd_soc_get_pcm_runtime(card, &card->dai_link[0]);
  1639. if (!rtd_wcd) {
  1640. dev_dbg(dev,
  1641. "%s: snd_soc_get_pcm_runtime for %s failed!\n",
  1642. __func__, card->dai_link[0]);
  1643. }
  1644. if (pdata->wsa_max_devs > 0) {
  1645. rtd_wsa = snd_soc_get_pcm_runtime(card,
  1646. &card->dai_link[ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links)]);
  1647. if (!rtd_wsa) {
  1648. dev_dbg(dev,
  1649. "%s: snd_soc_get_pcm_runtime for %s failed!\n",
  1650. __func__, card->dai_link[ARRAY_SIZE(msm_rx_tx_cdc_dma_be_dai_links)]);
  1651. }
  1652. }
  1653. /* set UPD configuration */
  1654. if(!pdata->upd_config.backend_used) {
  1655. dev_dbg(dev,
  1656. "%s: upd- backend_used is NULL\n", __func__);
  1657. goto err;
  1658. }
  1659. if (!strcmp(pdata->upd_config.backend_used, "wsa")) {
  1660. if (!rtd_wsa)
  1661. goto err;
  1662. else
  1663. rtd = rtd_wsa;
  1664. } else if(!strcmp(pdata->upd_config.backend_used, "wcd")) {
  1665. if (!rtd_wcd &&!pdata->wcd_disabled)
  1666. goto err;
  1667. else
  1668. rtd = rtd_wcd;
  1669. } else {
  1670. dev_err_ratelimited(card->dev, "%s: Invalid backend to set UPD config\n",
  1671. __func__);
  1672. goto err;
  1673. }
  1674. msm_set_upd_config(rtd);
  1675. err:
  1676. return ret;
  1677. }
  1678. static void kalama_ssr_disable(struct device *dev, void *data)
  1679. {
  1680. struct platform_device *pdev = to_platform_device(dev);
  1681. struct snd_soc_card *card = platform_get_drvdata(pdev);
  1682. if (!card) {
  1683. dev_err_ratelimited(dev, "%s: card is NULL\n", __func__);
  1684. return;
  1685. }
  1686. dev_dbg(dev, "%s: setting snd_card to OFFLINE\n", __func__);
  1687. snd_card_notify_user(SND_CARD_STATUS_OFFLINE);
  1688. if (!strcmp(card->name, "kalama-stub-snd-card")) {
  1689. /* TODO */
  1690. dev_dbg(dev, "%s: TODO \n", __func__);
  1691. }
  1692. }
  1693. static const struct snd_event_ops kalama_ssr_ops = {
  1694. .enable = kalama_ssr_enable,
  1695. .disable = kalama_ssr_disable,
  1696. };
  1697. static int msm_audio_ssr_compare(struct device *dev, void *data)
  1698. {
  1699. struct device_node *node = data;
  1700. dev_dbg(dev, "%s: dev->of_node = 0x%p, node = 0x%p\n",
  1701. __func__, dev->of_node, node);
  1702. return (dev->of_node && dev->of_node == node);
  1703. }
  1704. static int msm_audio_ssr_register(struct device *dev)
  1705. {
  1706. struct device_node *np = dev->of_node;
  1707. struct snd_event_clients *ssr_clients = NULL;
  1708. struct device_node *node = NULL;
  1709. int ret = 0;
  1710. int i = 0;
  1711. for (i = 0; ; i++) {
  1712. node = of_parse_phandle(np, "qcom,msm_audio_ssr_devs", i);
  1713. if (!node)
  1714. break;
  1715. snd_event_mstr_add_client(&ssr_clients,
  1716. msm_audio_ssr_compare, node);
  1717. }
  1718. ret = snd_event_master_register(dev, &kalama_ssr_ops,
  1719. ssr_clients, NULL);
  1720. if (!ret)
  1721. snd_event_notify(dev, SND_EVENT_UP);
  1722. return ret;
  1723. }
  1724. struct msm_common_pdata *msm_common_get_pdata(struct snd_soc_card *card)
  1725. {
  1726. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  1727. if (!pdata)
  1728. return NULL;
  1729. return pdata->common_pdata;
  1730. }
  1731. void msm_common_set_pdata(struct snd_soc_card *card,
  1732. struct msm_common_pdata *common_pdata)
  1733. {
  1734. struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card);
  1735. if (!pdata)
  1736. return;
  1737. pdata->common_pdata = common_pdata;
  1738. }
  1739. static int msm_asoc_machine_probe(struct platform_device *pdev)
  1740. {
  1741. struct snd_soc_card *card = NULL;
  1742. struct msm_asoc_mach_data *pdata = NULL;
  1743. int ret = 0;
  1744. struct clk *lpass_audio_hw_vote = NULL;
  1745. const struct of_device_id *match;
  1746. if (!pdev->dev.of_node) {
  1747. dev_err(&pdev->dev, "%s: No platform supplied from device tree\n", __func__);
  1748. return -EINVAL;
  1749. }
  1750. pdata = devm_kzalloc(&pdev->dev,
  1751. sizeof(struct msm_asoc_mach_data), GFP_KERNEL);
  1752. if (!pdata)
  1753. return -ENOMEM;
  1754. of_property_read_u32(pdev->dev.of_node,
  1755. "qcom,wcd-disabled",
  1756. &pdata->wcd_disabled);
  1757. /* Get maximum WSA device count for this platform */
  1758. ret = of_property_read_u32(pdev->dev.of_node,
  1759. "qcom,wsa-max-devs", &pdata->wsa_max_devs);
  1760. if (ret) {
  1761. dev_info(&pdev->dev,
  1762. "%s: wsa-max-devs property missing in DT %s, ret = %d\n",
  1763. __func__, pdev->dev.of_node->full_name, ret);
  1764. pdata->wsa_max_devs = 0;
  1765. }
  1766. card = populate_snd_card_dailinks(&pdev->dev, pdata->wsa_max_devs);
  1767. if (!card) {
  1768. dev_err(&pdev->dev, "%s: Card uninitialized\n", __func__);
  1769. ret = -EINVAL;
  1770. goto err;
  1771. }
  1772. match = of_match_node(kalama_asoc_machine_of_match, pdev->dev.of_node);
  1773. if (!match) {
  1774. dev_err(&pdev->dev, "%s: No DT match found for sound card\n",
  1775. __func__);
  1776. ret = -EINVAL;
  1777. goto err;
  1778. }
  1779. card->dev = &pdev->dev;
  1780. platform_set_drvdata(pdev, card);
  1781. snd_soc_card_set_drvdata(card, pdata);
  1782. ret = snd_soc_of_parse_card_name(card, "qcom,model");
  1783. if (ret) {
  1784. dev_err(&pdev->dev, "%s: parse card name failed, err:%d\n",
  1785. __func__, ret);
  1786. goto err;
  1787. }
  1788. if(!strcmp(match->data, "codec")) {
  1789. ret = snd_soc_of_parse_audio_routing(card, "qcom,audio-routing");
  1790. if (ret) {
  1791. dev_err(&pdev->dev, "%s: parse audio routing failed, err:%d\n",
  1792. __func__, ret);
  1793. goto err;
  1794. }
  1795. }
  1796. ret = msm_populate_dai_link_component_of_node(card);
  1797. if (ret) {
  1798. ret = -EPROBE_DEFER;
  1799. goto err;
  1800. }
  1801. /* parse upd configuration */
  1802. msm_parse_upd_configuration(pdev, pdata);
  1803. ret = devm_snd_soc_register_card(&pdev->dev, card);
  1804. if (ret == -EPROBE_DEFER) {
  1805. if (codec_reg_done)
  1806. ret = -EINVAL;
  1807. goto err;
  1808. } else if (ret) {
  1809. dev_err(&pdev->dev, "%s: snd_soc_register_card failed (%d)\n",
  1810. __func__, ret);
  1811. goto err;
  1812. }
  1813. dev_info(&pdev->dev, "%s: Sound card %s registered\n",
  1814. __func__, card->name);
  1815. if (wcd_mbhc_cfg.enable_usbc_analog)
  1816. wcd_mbhc_cfg.swap_gnd_mic = msm_usbc_swap_gnd_mic;
  1817. pdata->fsa_handle = of_parse_phandle(pdev->dev.of_node,
  1818. "fsa4480-i2c-handle", 0);
  1819. if (!pdata->fsa_handle)
  1820. dev_dbg(&pdev->dev, "property %s not detected in node %s\n",
  1821. "fsa4480-i2c-handle", pdev->dev.of_node->full_name);
  1822. pdata->dmic01_gpio_p = of_parse_phandle(pdev->dev.of_node,
  1823. "qcom,cdc-dmic01-gpios",
  1824. 0);
  1825. pdata->dmic23_gpio_p = of_parse_phandle(pdev->dev.of_node,
  1826. "qcom,cdc-dmic23-gpios",
  1827. 0);
  1828. pdata->dmic45_gpio_p = of_parse_phandle(pdev->dev.of_node,
  1829. "qcom,cdc-dmic45-gpios",
  1830. 0);
  1831. pdata->dmic67_gpio_p = of_parse_phandle(pdev->dev.of_node,
  1832. "qcom,cdc-dmic67-gpios",
  1833. 0);
  1834. if (pdata->dmic01_gpio_p)
  1835. msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic01_gpio_p, false);
  1836. if (pdata->dmic23_gpio_p)
  1837. msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic23_gpio_p, false);
  1838. if (pdata->dmic45_gpio_p)
  1839. msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic45_gpio_p, false);
  1840. if (pdata->dmic67_gpio_p)
  1841. msm_cdc_pinctrl_set_wakeup_capable(pdata->dmic67_gpio_p, false);
  1842. msm_common_snd_init(pdev, card);
  1843. /* Register LPASS audio hw vote */
  1844. lpass_audio_hw_vote = devm_clk_get(&pdev->dev, "lpass_audio_hw_vote");
  1845. if (IS_ERR(lpass_audio_hw_vote)) {
  1846. ret = PTR_ERR(lpass_audio_hw_vote);
  1847. dev_dbg(&pdev->dev, "%s: clk get %s failed %d\n",
  1848. __func__, "lpass_audio_hw_vote", ret);
  1849. lpass_audio_hw_vote = NULL;
  1850. ret = 0;
  1851. }
  1852. pdata->lpass_audio_hw_vote = lpass_audio_hw_vote;
  1853. pdata->core_audio_vote_count = 0;
  1854. ret = msm_audio_ssr_register(&pdev->dev);
  1855. if (ret)
  1856. pr_err("%s: Registration with SND event FWK failed ret = %d\n",
  1857. __func__, ret);
  1858. is_initial_boot = true;
  1859. /* change card status to ONLINE */
  1860. dev_dbg(&pdev->dev, "%s: setting snd_card to ONLINE\n", __func__);
  1861. snd_card_set_card_status(SND_CARD_STATUS_ONLINE);
  1862. return 0;
  1863. err:
  1864. devm_kfree(&pdev->dev, pdata);
  1865. return ret;
  1866. }
  1867. static int msm_asoc_machine_remove(struct platform_device *pdev)
  1868. {
  1869. struct snd_soc_card *card = platform_get_drvdata(pdev);
  1870. struct msm_asoc_mach_data *pdata = NULL;
  1871. struct msm_common_pdata *common_pdata = NULL;
  1872. if (card)
  1873. pdata = snd_soc_card_get_drvdata(card);
  1874. if (pdata)
  1875. common_pdata = pdata->common_pdata;
  1876. msm_common_snd_deinit(common_pdata);
  1877. snd_event_master_deregister(&pdev->dev);
  1878. snd_soc_unregister_card(card);
  1879. return 0;
  1880. }
  1881. static struct platform_driver kalama_asoc_machine_driver = {
  1882. .driver = {
  1883. .name = DRV_NAME,
  1884. .owner = THIS_MODULE,
  1885. .pm = &snd_soc_pm_ops,
  1886. .of_match_table = kalama_asoc_machine_of_match,
  1887. .suppress_bind_attrs = true,
  1888. },
  1889. .probe = msm_asoc_machine_probe,
  1890. .remove = msm_asoc_machine_remove,
  1891. };
  1892. static int __init msm_asoc_machine_init(void)
  1893. {
  1894. snd_card_sysfs_init();
  1895. return platform_driver_register(&kalama_asoc_machine_driver);
  1896. }
  1897. module_init(msm_asoc_machine_init);
  1898. static void __exit msm_asoc_machine_exit(void)
  1899. {
  1900. platform_driver_unregister(&kalama_asoc_machine_driver);
  1901. }
  1902. module_exit(msm_asoc_machine_exit);
  1903. MODULE_SOFTDEP("pre: bt_fm_slim");
  1904. MODULE_DESCRIPTION("ALSA SoC msm");
  1905. MODULE_LICENSE("GPL v2");
  1906. MODULE_ALIAS("platform:" DRV_NAME);
  1907. MODULE_DEVICE_TABLE(of, kalama_asoc_machine_of_match);