tx-macro.c 99 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
  3. */
  4. #include <linux/module.h>
  5. #include <linux/init.h>
  6. #include <linux/clk.h>
  7. #include <linux/io.h>
  8. #include <linux/platform_device.h>
  9. #include <linux/regmap.h>
  10. #include <linux/pm_runtime.h>
  11. #include <sound/soc.h>
  12. #include <sound/soc-dapm.h>
  13. #include <sound/tlv.h>
  14. #include <soc/swr-common.h>
  15. #include <soc/swr-wcd.h>
  16. #include <asoc/msm-cdc-pinctrl.h>
  17. #include "bolero-cdc.h"
  18. #include "bolero-cdc-registers.h"
  19. #include "bolero-clk-rsc.h"
  20. #define AUTO_SUSPEND_DELAY 50 /* delay in msec */
  21. #define TX_MACRO_MAX_OFFSET 0x1000
  22. #define NUM_DECIMATORS 8
  23. #define TX_MACRO_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\
  24. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |\
  25. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000)
  26. #define TX_MACRO_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\
  27. SNDRV_PCM_FMTBIT_S24_LE |\
  28. SNDRV_PCM_FMTBIT_S24_3LE)
  29. #define TX_HPF_CUT_OFF_FREQ_MASK 0x60
  30. #define CF_MIN_3DB_4HZ 0x0
  31. #define CF_MIN_3DB_75HZ 0x1
  32. #define CF_MIN_3DB_150HZ 0x2
  33. #define TX_MACRO_DMIC_SAMPLE_RATE_UNDEFINED 0
  34. #define TX_MACRO_MCLK_FREQ 9600000
  35. #define TX_MACRO_TX_PATH_OFFSET 0x80
  36. #define TX_MACRO_SWR_MIC_MUX_SEL_MASK 0xF
  37. #define TX_MACRO_ADC_MUX_CFG_OFFSET 0x8
  38. #define TX_MACRO_ADC_MODE_CFG0_SHIFT 1
  39. #define TX_MACRO_DMIC_UNMUTE_DELAY_MS 40
  40. #define TX_MACRO_AMIC_UNMUTE_DELAY_MS 100
  41. #define TX_MACRO_DMIC_HPF_DELAY_MS 300
  42. #define TX_MACRO_AMIC_HPF_DELAY_MS 300
  43. static int tx_unmute_delay = TX_MACRO_DMIC_UNMUTE_DELAY_MS;
  44. module_param(tx_unmute_delay, int, 0664);
  45. MODULE_PARM_DESC(tx_unmute_delay, "delay to unmute the tx path");
  46. static const DECLARE_TLV_DB_SCALE(digital_gain, 0, 1, 0);
  47. static int tx_macro_hw_params(struct snd_pcm_substream *substream,
  48. struct snd_pcm_hw_params *params,
  49. struct snd_soc_dai *dai);
  50. static int tx_macro_get_channel_map(struct snd_soc_dai *dai,
  51. unsigned int *tx_num, unsigned int *tx_slot,
  52. unsigned int *rx_num, unsigned int *rx_slot);
  53. #define TX_MACRO_SWR_STRING_LEN 80
  54. #define TX_MACRO_CHILD_DEVICES_MAX 3
  55. /* Hold instance to soundwire platform device */
  56. struct tx_macro_swr_ctrl_data {
  57. struct platform_device *tx_swr_pdev;
  58. };
  59. struct tx_macro_swr_ctrl_platform_data {
  60. void *handle; /* holds codec private data */
  61. int (*read)(void *handle, int reg);
  62. int (*write)(void *handle, int reg, int val);
  63. int (*bulk_write)(void *handle, u32 *reg, u32 *val, size_t len);
  64. int (*clk)(void *handle, bool enable);
  65. int (*core_vote)(void *handle, bool enable);
  66. int (*handle_irq)(void *handle,
  67. irqreturn_t (*swrm_irq_handler)(int irq,
  68. void *data),
  69. void *swrm_handle,
  70. int action);
  71. };
  72. enum {
  73. TX_MACRO_AIF_INVALID = 0,
  74. TX_MACRO_AIF1_CAP,
  75. TX_MACRO_AIF2_CAP,
  76. TX_MACRO_AIF3_CAP,
  77. TX_MACRO_MAX_DAIS
  78. };
  79. enum {
  80. TX_MACRO_DEC0,
  81. TX_MACRO_DEC1,
  82. TX_MACRO_DEC2,
  83. TX_MACRO_DEC3,
  84. TX_MACRO_DEC4,
  85. TX_MACRO_DEC5,
  86. TX_MACRO_DEC6,
  87. TX_MACRO_DEC7,
  88. TX_MACRO_DEC_MAX,
  89. };
  90. enum {
  91. TX_MACRO_CLK_DIV_2,
  92. TX_MACRO_CLK_DIV_3,
  93. TX_MACRO_CLK_DIV_4,
  94. TX_MACRO_CLK_DIV_6,
  95. TX_MACRO_CLK_DIV_8,
  96. TX_MACRO_CLK_DIV_16,
  97. };
  98. enum {
  99. MSM_DMIC,
  100. SWR_MIC,
  101. ANC_FB_TUNE1
  102. };
  103. enum {
  104. TX_MCLK,
  105. VA_MCLK,
  106. };
  107. struct tx_macro_reg_mask_val {
  108. u16 reg;
  109. u8 mask;
  110. u8 val;
  111. };
  112. struct tx_mute_work {
  113. struct tx_macro_priv *tx_priv;
  114. u32 decimator;
  115. struct delayed_work dwork;
  116. };
  117. struct hpf_work {
  118. struct tx_macro_priv *tx_priv;
  119. u8 decimator;
  120. u8 hpf_cut_off_freq;
  121. struct delayed_work dwork;
  122. };
  123. struct tx_macro_priv {
  124. struct device *dev;
  125. bool dec_active[NUM_DECIMATORS];
  126. int tx_mclk_users;
  127. int swr_clk_users;
  128. bool dapm_mclk_enable;
  129. bool reset_swr;
  130. struct mutex mclk_lock;
  131. struct mutex swr_clk_lock;
  132. struct snd_soc_component *component;
  133. struct device_node *tx_swr_gpio_p;
  134. struct tx_macro_swr_ctrl_data *swr_ctrl_data;
  135. struct tx_macro_swr_ctrl_platform_data swr_plat_data;
  136. struct work_struct tx_macro_add_child_devices_work;
  137. struct hpf_work tx_hpf_work[NUM_DECIMATORS];
  138. struct tx_mute_work tx_mute_dwork[NUM_DECIMATORS];
  139. s32 dmic_0_1_clk_cnt;
  140. s32 dmic_2_3_clk_cnt;
  141. s32 dmic_4_5_clk_cnt;
  142. s32 dmic_6_7_clk_cnt;
  143. u16 dmic_clk_div;
  144. u32 version;
  145. u32 is_used_tx_swr_gpio;
  146. unsigned long active_ch_mask[TX_MACRO_MAX_DAIS];
  147. unsigned long active_ch_cnt[TX_MACRO_MAX_DAIS];
  148. char __iomem *tx_io_base;
  149. struct platform_device *pdev_child_devices
  150. [TX_MACRO_CHILD_DEVICES_MAX];
  151. int child_count;
  152. int tx_swr_clk_cnt;
  153. int va_swr_clk_cnt;
  154. int va_clk_status;
  155. int tx_clk_status;
  156. bool bcs_enable;
  157. int dec_mode[NUM_DECIMATORS];
  158. int bcs_ch;
  159. bool bcs_clk_en;
  160. bool hs_slow_insert_complete;
  161. };
  162. static bool tx_macro_get_data(struct snd_soc_component *component,
  163. struct device **tx_dev,
  164. struct tx_macro_priv **tx_priv,
  165. const char *func_name)
  166. {
  167. *tx_dev = bolero_get_device_ptr(component->dev, TX_MACRO);
  168. if (!(*tx_dev)) {
  169. dev_err(component->dev,
  170. "%s: null device for macro!\n", func_name);
  171. return false;
  172. }
  173. *tx_priv = dev_get_drvdata((*tx_dev));
  174. if (!(*tx_priv)) {
  175. dev_err(component->dev,
  176. "%s: priv is null for macro!\n", func_name);
  177. return false;
  178. }
  179. if (!(*tx_priv)->component) {
  180. dev_err(component->dev,
  181. "%s: tx_priv->component not initialized!\n", func_name);
  182. return false;
  183. }
  184. return true;
  185. }
  186. static int tx_macro_mclk_enable(struct tx_macro_priv *tx_priv,
  187. bool mclk_enable)
  188. {
  189. struct regmap *regmap = dev_get_regmap(tx_priv->dev->parent, NULL);
  190. int ret = 0;
  191. if (regmap == NULL) {
  192. dev_err(tx_priv->dev, "%s: regmap is NULL\n", __func__);
  193. return -EINVAL;
  194. }
  195. dev_dbg(tx_priv->dev, "%s: mclk_enable = %u,clk_users= %d\n",
  196. __func__, mclk_enable, tx_priv->tx_mclk_users);
  197. mutex_lock(&tx_priv->mclk_lock);
  198. if (mclk_enable) {
  199. if (tx_priv->tx_mclk_users == 0) {
  200. ret = bolero_clk_rsc_request_clock(tx_priv->dev,
  201. TX_CORE_CLK,
  202. TX_CORE_CLK,
  203. true);
  204. if (ret < 0) {
  205. dev_err_ratelimited(tx_priv->dev,
  206. "%s: request clock enable failed\n",
  207. __func__);
  208. goto exit;
  209. }
  210. bolero_clk_rsc_fs_gen_request(tx_priv->dev,
  211. true);
  212. regcache_mark_dirty(regmap);
  213. regcache_sync_region(regmap,
  214. TX_START_OFFSET,
  215. TX_MAX_OFFSET);
  216. /* 9.6MHz MCLK, set value 0x00 if other frequency */
  217. regmap_update_bits(regmap,
  218. BOLERO_CDC_TX_TOP_CSR_FREQ_MCLK, 0x01, 0x01);
  219. regmap_update_bits(regmap,
  220. BOLERO_CDC_TX_CLK_RST_CTRL_MCLK_CONTROL,
  221. 0x01, 0x01);
  222. regmap_update_bits(regmap,
  223. BOLERO_CDC_TX_CLK_RST_CTRL_FS_CNT_CONTROL,
  224. 0x01, 0x01);
  225. }
  226. tx_priv->tx_mclk_users++;
  227. } else {
  228. if (tx_priv->tx_mclk_users <= 0) {
  229. dev_err(tx_priv->dev, "%s: clock already disabled\n",
  230. __func__);
  231. tx_priv->tx_mclk_users = 0;
  232. goto exit;
  233. }
  234. tx_priv->tx_mclk_users--;
  235. if (tx_priv->tx_mclk_users == 0) {
  236. regmap_update_bits(regmap,
  237. BOLERO_CDC_TX_CLK_RST_CTRL_FS_CNT_CONTROL,
  238. 0x01, 0x00);
  239. regmap_update_bits(regmap,
  240. BOLERO_CDC_TX_CLK_RST_CTRL_MCLK_CONTROL,
  241. 0x01, 0x00);
  242. bolero_clk_rsc_fs_gen_request(tx_priv->dev,
  243. false);
  244. bolero_clk_rsc_request_clock(tx_priv->dev,
  245. TX_CORE_CLK,
  246. TX_CORE_CLK,
  247. false);
  248. }
  249. }
  250. exit:
  251. mutex_unlock(&tx_priv->mclk_lock);
  252. return ret;
  253. }
  254. static int tx_macro_va_swr_clk_event(struct snd_soc_dapm_widget *w,
  255. struct snd_kcontrol *kcontrol, int event)
  256. {
  257. struct device *tx_dev = NULL;
  258. struct tx_macro_priv *tx_priv = NULL;
  259. struct snd_soc_component *component =
  260. snd_soc_dapm_to_component(w->dapm);
  261. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  262. return -EINVAL;
  263. if (SND_SOC_DAPM_EVENT_ON(event))
  264. ++tx_priv->va_swr_clk_cnt;
  265. if (SND_SOC_DAPM_EVENT_OFF(event))
  266. --tx_priv->va_swr_clk_cnt;
  267. return 0;
  268. }
  269. static int tx_macro_tx_swr_clk_event(struct snd_soc_dapm_widget *w,
  270. struct snd_kcontrol *kcontrol, int event)
  271. {
  272. struct device *tx_dev = NULL;
  273. struct tx_macro_priv *tx_priv = NULL;
  274. struct snd_soc_component *component =
  275. snd_soc_dapm_to_component(w->dapm);
  276. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  277. return -EINVAL;
  278. if (SND_SOC_DAPM_EVENT_ON(event))
  279. ++tx_priv->tx_swr_clk_cnt;
  280. if (SND_SOC_DAPM_EVENT_OFF(event))
  281. --tx_priv->tx_swr_clk_cnt;
  282. return 0;
  283. }
  284. static int tx_macro_mclk_event(struct snd_soc_dapm_widget *w,
  285. struct snd_kcontrol *kcontrol, int event)
  286. {
  287. struct snd_soc_component *component =
  288. snd_soc_dapm_to_component(w->dapm);
  289. int ret = 0;
  290. struct device *tx_dev = NULL;
  291. struct tx_macro_priv *tx_priv = NULL;
  292. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  293. return -EINVAL;
  294. dev_dbg(tx_dev, "%s: event = %d\n", __func__, event);
  295. switch (event) {
  296. case SND_SOC_DAPM_PRE_PMU:
  297. ret = tx_macro_mclk_enable(tx_priv, 1);
  298. if (ret)
  299. tx_priv->dapm_mclk_enable = false;
  300. else
  301. tx_priv->dapm_mclk_enable = true;
  302. break;
  303. case SND_SOC_DAPM_POST_PMD:
  304. if (tx_priv->dapm_mclk_enable)
  305. ret = tx_macro_mclk_enable(tx_priv, 0);
  306. break;
  307. default:
  308. dev_err(tx_priv->dev,
  309. "%s: invalid DAPM event %d\n", __func__, event);
  310. ret = -EINVAL;
  311. }
  312. return ret;
  313. }
  314. static int tx_macro_event_handler(struct snd_soc_component *component,
  315. u16 event, u32 data)
  316. {
  317. struct device *tx_dev = NULL;
  318. struct tx_macro_priv *tx_priv = NULL;
  319. int ret = 0;
  320. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  321. return -EINVAL;
  322. switch (event) {
  323. case BOLERO_MACRO_EVT_SSR_DOWN:
  324. if (tx_priv->swr_ctrl_data) {
  325. swrm_wcd_notify(
  326. tx_priv->swr_ctrl_data[0].tx_swr_pdev,
  327. SWR_DEVICE_DOWN, NULL);
  328. swrm_wcd_notify(
  329. tx_priv->swr_ctrl_data[0].tx_swr_pdev,
  330. SWR_DEVICE_SSR_DOWN, NULL);
  331. }
  332. if ((!pm_runtime_enabled(tx_dev) ||
  333. !pm_runtime_suspended(tx_dev))) {
  334. ret = bolero_runtime_suspend(tx_dev);
  335. if (!ret) {
  336. pm_runtime_disable(tx_dev);
  337. pm_runtime_set_suspended(tx_dev);
  338. pm_runtime_enable(tx_dev);
  339. }
  340. }
  341. break;
  342. case BOLERO_MACRO_EVT_SSR_UP:
  343. /* reset swr after ssr/pdr */
  344. tx_priv->reset_swr = true;
  345. if (tx_priv->swr_ctrl_data)
  346. swrm_wcd_notify(
  347. tx_priv->swr_ctrl_data[0].tx_swr_pdev,
  348. SWR_DEVICE_SSR_UP, NULL);
  349. break;
  350. case BOLERO_MACRO_EVT_CLK_RESET:
  351. bolero_rsc_clk_reset(tx_dev, TX_CORE_CLK);
  352. break;
  353. case BOLERO_MACRO_EVT_BCS_CLK_OFF:
  354. if (tx_priv->bcs_clk_en)
  355. snd_soc_component_update_bits(component,
  356. BOLERO_CDC_TX0_TX_PATH_SEC7, 0x40, data << 6);
  357. if (data)
  358. tx_priv->hs_slow_insert_complete = true;
  359. else
  360. tx_priv->hs_slow_insert_complete = false;
  361. break;
  362. }
  363. return 0;
  364. }
  365. static int tx_macro_reg_wake_irq(struct snd_soc_component *component,
  366. u32 data)
  367. {
  368. struct device *tx_dev = NULL;
  369. struct tx_macro_priv *tx_priv = NULL;
  370. u32 ipc_wakeup = data;
  371. int ret = 0;
  372. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  373. return -EINVAL;
  374. if (tx_priv->swr_ctrl_data)
  375. ret = swrm_wcd_notify(
  376. tx_priv->swr_ctrl_data[0].tx_swr_pdev,
  377. SWR_REGISTER_WAKE_IRQ, &ipc_wakeup);
  378. return ret;
  379. }
  380. static int is_amic_enabled(struct snd_soc_component *component, int decimator)
  381. {
  382. u16 adc_mux_reg = 0, adc_reg = 0;
  383. u16 adc_n = BOLERO_ADC_MAX;
  384. adc_mux_reg = BOLERO_CDC_TX_INP_MUX_ADC_MUX0_CFG1 +
  385. TX_MACRO_ADC_MUX_CFG_OFFSET * decimator;
  386. if (snd_soc_component_read32(component, adc_mux_reg) & SWR_MIC) {
  387. adc_reg = BOLERO_CDC_TX_INP_MUX_ADC_MUX0_CFG0 +
  388. TX_MACRO_ADC_MUX_CFG_OFFSET * decimator;
  389. adc_n = snd_soc_component_read32(component, adc_reg) &
  390. TX_MACRO_SWR_MIC_MUX_SEL_MASK;
  391. if (adc_n >= BOLERO_ADC_MAX)
  392. adc_n = BOLERO_ADC_MAX;
  393. }
  394. return adc_n;
  395. }
  396. static void tx_macro_tx_hpf_corner_freq_callback(struct work_struct *work)
  397. {
  398. struct delayed_work *hpf_delayed_work = NULL;
  399. struct hpf_work *hpf_work = NULL;
  400. struct tx_macro_priv *tx_priv = NULL;
  401. struct snd_soc_component *component = NULL;
  402. u16 dec_cfg_reg = 0, hpf_gate_reg = 0;
  403. u8 hpf_cut_off_freq = 0;
  404. u16 adc_n = 0;
  405. hpf_delayed_work = to_delayed_work(work);
  406. hpf_work = container_of(hpf_delayed_work, struct hpf_work, dwork);
  407. tx_priv = hpf_work->tx_priv;
  408. component = tx_priv->component;
  409. hpf_cut_off_freq = hpf_work->hpf_cut_off_freq;
  410. dec_cfg_reg = BOLERO_CDC_TX0_TX_PATH_CFG0 +
  411. TX_MACRO_TX_PATH_OFFSET * hpf_work->decimator;
  412. hpf_gate_reg = BOLERO_CDC_TX0_TX_PATH_SEC2 +
  413. TX_MACRO_TX_PATH_OFFSET * hpf_work->decimator;
  414. dev_dbg(component->dev, "%s: decimator %u hpf_cut_of_freq 0x%x\n",
  415. __func__, hpf_work->decimator, hpf_cut_off_freq);
  416. adc_n = is_amic_enabled(component, hpf_work->decimator);
  417. if (adc_n < BOLERO_ADC_MAX) {
  418. /* analog mic clear TX hold */
  419. bolero_clear_amic_tx_hold(component->dev, adc_n);
  420. snd_soc_component_update_bits(component,
  421. dec_cfg_reg, TX_HPF_CUT_OFF_FREQ_MASK,
  422. hpf_cut_off_freq << 5);
  423. snd_soc_component_update_bits(component, hpf_gate_reg,
  424. 0x03, 0x02);
  425. /* Minimum 1 clk cycle delay is required as per HW spec */
  426. usleep_range(1000, 1010);
  427. snd_soc_component_update_bits(component, hpf_gate_reg,
  428. 0x03, 0x01);
  429. } else {
  430. snd_soc_component_update_bits(component,
  431. dec_cfg_reg, TX_HPF_CUT_OFF_FREQ_MASK,
  432. hpf_cut_off_freq << 5);
  433. snd_soc_component_update_bits(component, hpf_gate_reg,
  434. 0x02, 0x02);
  435. /* Minimum 1 clk cycle delay is required as per HW spec */
  436. usleep_range(1000, 1010);
  437. snd_soc_component_update_bits(component, hpf_gate_reg,
  438. 0x02, 0x00);
  439. }
  440. }
  441. static void tx_macro_mute_update_callback(struct work_struct *work)
  442. {
  443. struct tx_mute_work *tx_mute_dwork = NULL;
  444. struct snd_soc_component *component = NULL;
  445. struct tx_macro_priv *tx_priv = NULL;
  446. struct delayed_work *delayed_work = NULL;
  447. u16 tx_vol_ctl_reg = 0;
  448. u8 decimator = 0;
  449. delayed_work = to_delayed_work(work);
  450. tx_mute_dwork = container_of(delayed_work, struct tx_mute_work, dwork);
  451. tx_priv = tx_mute_dwork->tx_priv;
  452. component = tx_priv->component;
  453. decimator = tx_mute_dwork->decimator;
  454. tx_vol_ctl_reg =
  455. BOLERO_CDC_TX0_TX_PATH_CTL +
  456. TX_MACRO_TX_PATH_OFFSET * decimator;
  457. snd_soc_component_update_bits(component, tx_vol_ctl_reg, 0x10, 0x00);
  458. dev_dbg(tx_priv->dev, "%s: decimator %u unmute\n",
  459. __func__, decimator);
  460. }
  461. static int tx_macro_put_dec_enum(struct snd_kcontrol *kcontrol,
  462. struct snd_ctl_elem_value *ucontrol)
  463. {
  464. struct snd_soc_dapm_widget *widget =
  465. snd_soc_dapm_kcontrol_widget(kcontrol);
  466. struct snd_soc_component *component =
  467. snd_soc_dapm_to_component(widget->dapm);
  468. struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
  469. unsigned int val = 0;
  470. u16 mic_sel_reg = 0;
  471. u16 dmic_clk_reg = 0;
  472. struct device *tx_dev = NULL;
  473. struct tx_macro_priv *tx_priv = NULL;
  474. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  475. return -EINVAL;
  476. val = ucontrol->value.enumerated.item[0];
  477. if (val > e->items - 1)
  478. return -EINVAL;
  479. dev_dbg(component->dev, "%s: wname: %s, val: 0x%x\n", __func__,
  480. widget->name, val);
  481. switch (e->reg) {
  482. case BOLERO_CDC_TX_INP_MUX_ADC_MUX0_CFG0:
  483. mic_sel_reg = BOLERO_CDC_TX0_TX_PATH_CFG0;
  484. break;
  485. case BOLERO_CDC_TX_INP_MUX_ADC_MUX1_CFG0:
  486. mic_sel_reg = BOLERO_CDC_TX1_TX_PATH_CFG0;
  487. break;
  488. case BOLERO_CDC_TX_INP_MUX_ADC_MUX2_CFG0:
  489. mic_sel_reg = BOLERO_CDC_TX2_TX_PATH_CFG0;
  490. break;
  491. case BOLERO_CDC_TX_INP_MUX_ADC_MUX3_CFG0:
  492. mic_sel_reg = BOLERO_CDC_TX3_TX_PATH_CFG0;
  493. break;
  494. case BOLERO_CDC_TX_INP_MUX_ADC_MUX4_CFG0:
  495. mic_sel_reg = BOLERO_CDC_TX4_TX_PATH_CFG0;
  496. break;
  497. case BOLERO_CDC_TX_INP_MUX_ADC_MUX5_CFG0:
  498. mic_sel_reg = BOLERO_CDC_TX5_TX_PATH_CFG0;
  499. break;
  500. case BOLERO_CDC_TX_INP_MUX_ADC_MUX6_CFG0:
  501. mic_sel_reg = BOLERO_CDC_TX6_TX_PATH_CFG0;
  502. break;
  503. case BOLERO_CDC_TX_INP_MUX_ADC_MUX7_CFG0:
  504. mic_sel_reg = BOLERO_CDC_TX7_TX_PATH_CFG0;
  505. break;
  506. default:
  507. dev_err(component->dev, "%s: e->reg: 0x%x not expected\n",
  508. __func__, e->reg);
  509. return -EINVAL;
  510. }
  511. if (strnstr(widget->name, "SMIC", strlen(widget->name))) {
  512. if (val != 0) {
  513. if (val < 5) {
  514. snd_soc_component_update_bits(component,
  515. mic_sel_reg,
  516. 1 << 7, 0x0 << 7);
  517. } else {
  518. snd_soc_component_update_bits(component,
  519. mic_sel_reg,
  520. 1 << 7, 0x1 << 7);
  521. snd_soc_component_update_bits(component,
  522. BOLERO_CDC_VA_TOP_CSR_DMIC_CFG,
  523. 0x80, 0x00);
  524. dmic_clk_reg =
  525. BOLERO_CDC_TX_TOP_CSR_SWR_DMIC0_CTL +
  526. ((val - 5)/2) * 4;
  527. snd_soc_component_update_bits(component,
  528. dmic_clk_reg,
  529. 0x0E, tx_priv->dmic_clk_div << 0x1);
  530. }
  531. }
  532. } else {
  533. /* DMIC selected */
  534. if (val != 0)
  535. snd_soc_component_update_bits(component, mic_sel_reg,
  536. 1 << 7, 1 << 7);
  537. }
  538. return snd_soc_dapm_put_enum_double(kcontrol, ucontrol);
  539. }
  540. static int tx_macro_tx_mixer_get(struct snd_kcontrol *kcontrol,
  541. struct snd_ctl_elem_value *ucontrol)
  542. {
  543. struct snd_soc_dapm_widget *widget =
  544. snd_soc_dapm_kcontrol_widget(kcontrol);
  545. struct snd_soc_component *component =
  546. snd_soc_dapm_to_component(widget->dapm);
  547. struct soc_multi_mixer_control *mixer =
  548. ((struct soc_multi_mixer_control *)kcontrol->private_value);
  549. u32 dai_id = widget->shift;
  550. u32 dec_id = mixer->shift;
  551. struct device *tx_dev = NULL;
  552. struct tx_macro_priv *tx_priv = NULL;
  553. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  554. return -EINVAL;
  555. if (test_bit(dec_id, &tx_priv->active_ch_mask[dai_id]))
  556. ucontrol->value.integer.value[0] = 1;
  557. else
  558. ucontrol->value.integer.value[0] = 0;
  559. return 0;
  560. }
  561. static int tx_macro_tx_mixer_put(struct snd_kcontrol *kcontrol,
  562. struct snd_ctl_elem_value *ucontrol)
  563. {
  564. struct snd_soc_dapm_widget *widget =
  565. snd_soc_dapm_kcontrol_widget(kcontrol);
  566. struct snd_soc_component *component =
  567. snd_soc_dapm_to_component(widget->dapm);
  568. struct snd_soc_dapm_update *update = NULL;
  569. struct soc_multi_mixer_control *mixer =
  570. ((struct soc_multi_mixer_control *)kcontrol->private_value);
  571. u32 dai_id = widget->shift;
  572. u32 dec_id = mixer->shift;
  573. u32 enable = ucontrol->value.integer.value[0];
  574. struct device *tx_dev = NULL;
  575. struct tx_macro_priv *tx_priv = NULL;
  576. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  577. return -EINVAL;
  578. if (enable) {
  579. set_bit(dec_id, &tx_priv->active_ch_mask[dai_id]);
  580. tx_priv->active_ch_cnt[dai_id]++;
  581. } else {
  582. tx_priv->active_ch_cnt[dai_id]--;
  583. clear_bit(dec_id, &tx_priv->active_ch_mask[dai_id]);
  584. }
  585. snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, enable, update);
  586. return 0;
  587. }
  588. static inline int tx_macro_path_get(const char *wname,
  589. unsigned int *path_num)
  590. {
  591. int ret = 0;
  592. char *widget_name = NULL;
  593. char *w_name = NULL;
  594. char *path_num_char = NULL;
  595. char *path_name = NULL;
  596. widget_name = kstrndup(wname, 10, GFP_KERNEL);
  597. if (!widget_name)
  598. return -EINVAL;
  599. w_name = widget_name;
  600. path_name = strsep(&widget_name, " ");
  601. if (!path_name) {
  602. pr_err("%s: Invalid widget name = %s\n",
  603. __func__, widget_name);
  604. ret = -EINVAL;
  605. goto err;
  606. }
  607. path_num_char = strpbrk(path_name, "01234567");
  608. if (!path_num_char) {
  609. pr_err("%s: tx path index not found\n",
  610. __func__);
  611. ret = -EINVAL;
  612. goto err;
  613. }
  614. ret = kstrtouint(path_num_char, 10, path_num);
  615. if (ret < 0)
  616. pr_err("%s: Invalid tx path = %s\n",
  617. __func__, w_name);
  618. err:
  619. kfree(w_name);
  620. return ret;
  621. }
  622. static int tx_macro_dec_mode_get(struct snd_kcontrol *kcontrol,
  623. struct snd_ctl_elem_value *ucontrol)
  624. {
  625. struct snd_soc_component *component =
  626. snd_soc_kcontrol_component(kcontrol);
  627. struct tx_macro_priv *tx_priv = NULL;
  628. struct device *tx_dev = NULL;
  629. int ret = 0;
  630. int path = 0;
  631. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  632. return -EINVAL;
  633. ret = tx_macro_path_get(kcontrol->id.name, &path);
  634. if (ret)
  635. return ret;
  636. ucontrol->value.integer.value[0] = tx_priv->dec_mode[path];
  637. return 0;
  638. }
  639. static int tx_macro_dec_mode_put(struct snd_kcontrol *kcontrol,
  640. struct snd_ctl_elem_value *ucontrol)
  641. {
  642. struct snd_soc_component *component =
  643. snd_soc_kcontrol_component(kcontrol);
  644. struct tx_macro_priv *tx_priv = NULL;
  645. struct device *tx_dev = NULL;
  646. int value = ucontrol->value.integer.value[0];
  647. int ret = 0;
  648. int path = 0;
  649. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  650. return -EINVAL;
  651. ret = tx_macro_path_get(kcontrol->id.name, &path);
  652. if (ret)
  653. return ret;
  654. tx_priv->dec_mode[path] = value;
  655. return 0;
  656. }
  657. static int tx_macro_bcs_ch_get(struct snd_kcontrol *kcontrol,
  658. struct snd_ctl_elem_value *ucontrol)
  659. {
  660. struct snd_soc_component *component =
  661. snd_soc_kcontrol_component(kcontrol);
  662. struct tx_macro_priv *tx_priv = NULL;
  663. struct device *tx_dev = NULL;
  664. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  665. return -EINVAL;
  666. ucontrol->value.enumerated.item[0] = tx_priv->bcs_ch;
  667. return 0;
  668. }
  669. static int tx_macro_bcs_ch_put(struct snd_kcontrol *kcontrol,
  670. struct snd_ctl_elem_value *ucontrol)
  671. {
  672. struct snd_soc_component *component =
  673. snd_soc_kcontrol_component(kcontrol);
  674. struct tx_macro_priv *tx_priv = NULL;
  675. struct device *tx_dev = NULL;
  676. int value = ucontrol->value.enumerated.item[0];
  677. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  678. return -EINVAL;
  679. tx_priv->bcs_ch = value;
  680. return 0;
  681. }
  682. static int tx_macro_get_bcs(struct snd_kcontrol *kcontrol,
  683. struct snd_ctl_elem_value *ucontrol)
  684. {
  685. struct snd_soc_component *component =
  686. snd_soc_kcontrol_component(kcontrol);
  687. struct tx_macro_priv *tx_priv = NULL;
  688. struct device *tx_dev = NULL;
  689. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  690. return -EINVAL;
  691. ucontrol->value.integer.value[0] = tx_priv->bcs_enable;
  692. return 0;
  693. }
  694. static int tx_macro_set_bcs(struct snd_kcontrol *kcontrol,
  695. struct snd_ctl_elem_value *ucontrol)
  696. {
  697. struct snd_soc_component *component =
  698. snd_soc_kcontrol_component(kcontrol);
  699. struct tx_macro_priv *tx_priv = NULL;
  700. struct device *tx_dev = NULL;
  701. int value = ucontrol->value.integer.value[0];
  702. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  703. return -EINVAL;
  704. tx_priv->bcs_enable = value;
  705. return 0;
  706. }
  707. static int tx_macro_enable_dmic(struct snd_soc_dapm_widget *w,
  708. struct snd_kcontrol *kcontrol, int event)
  709. {
  710. struct snd_soc_component *component =
  711. snd_soc_dapm_to_component(w->dapm);
  712. u8 dmic_clk_en = 0x01;
  713. u16 dmic_clk_reg = 0;
  714. s32 *dmic_clk_cnt = NULL;
  715. unsigned int dmic = 0;
  716. int ret = 0;
  717. char *wname = NULL;
  718. struct device *tx_dev = NULL;
  719. struct tx_macro_priv *tx_priv = NULL;
  720. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  721. return -EINVAL;
  722. wname = strpbrk(w->name, "01234567");
  723. if (!wname) {
  724. dev_err(component->dev, "%s: widget not found\n", __func__);
  725. return -EINVAL;
  726. }
  727. ret = kstrtouint(wname, 10, &dmic);
  728. if (ret < 0) {
  729. dev_err(component->dev, "%s: Invalid DMIC line on the codec\n",
  730. __func__);
  731. return -EINVAL;
  732. }
  733. switch (dmic) {
  734. case 0:
  735. case 1:
  736. dmic_clk_cnt = &(tx_priv->dmic_0_1_clk_cnt);
  737. dmic_clk_reg = BOLERO_CDC_VA_TOP_CSR_DMIC0_CTL;
  738. break;
  739. case 2:
  740. case 3:
  741. dmic_clk_cnt = &(tx_priv->dmic_2_3_clk_cnt);
  742. dmic_clk_reg = BOLERO_CDC_VA_TOP_CSR_DMIC1_CTL;
  743. break;
  744. case 4:
  745. case 5:
  746. dmic_clk_cnt = &(tx_priv->dmic_4_5_clk_cnt);
  747. dmic_clk_reg = BOLERO_CDC_VA_TOP_CSR_DMIC2_CTL;
  748. break;
  749. case 6:
  750. case 7:
  751. dmic_clk_cnt = &(tx_priv->dmic_6_7_clk_cnt);
  752. dmic_clk_reg = BOLERO_CDC_VA_TOP_CSR_DMIC3_CTL;
  753. break;
  754. default:
  755. dev_err(component->dev, "%s: Invalid DMIC Selection\n",
  756. __func__);
  757. return -EINVAL;
  758. }
  759. dev_dbg(component->dev, "%s: event %d DMIC%d dmic_clk_cnt %d\n",
  760. __func__, event, dmic, *dmic_clk_cnt);
  761. switch (event) {
  762. case SND_SOC_DAPM_PRE_PMU:
  763. (*dmic_clk_cnt)++;
  764. if (*dmic_clk_cnt == 1) {
  765. snd_soc_component_update_bits(component,
  766. BOLERO_CDC_VA_TOP_CSR_DMIC_CFG,
  767. 0x80, 0x00);
  768. snd_soc_component_update_bits(component, dmic_clk_reg,
  769. 0x0E, tx_priv->dmic_clk_div << 0x1);
  770. snd_soc_component_update_bits(component, dmic_clk_reg,
  771. dmic_clk_en, dmic_clk_en);
  772. }
  773. break;
  774. case SND_SOC_DAPM_POST_PMD:
  775. (*dmic_clk_cnt)--;
  776. if (*dmic_clk_cnt == 0)
  777. snd_soc_component_update_bits(component, dmic_clk_reg,
  778. dmic_clk_en, 0);
  779. break;
  780. }
  781. return 0;
  782. }
  783. static int tx_macro_enable_dec(struct snd_soc_dapm_widget *w,
  784. struct snd_kcontrol *kcontrol, int event)
  785. {
  786. struct snd_soc_component *component =
  787. snd_soc_dapm_to_component(w->dapm);
  788. unsigned int decimator = 0;
  789. u16 tx_vol_ctl_reg = 0;
  790. u16 dec_cfg_reg = 0;
  791. u16 hpf_gate_reg = 0;
  792. u16 tx_gain_ctl_reg = 0;
  793. u8 hpf_cut_off_freq = 0;
  794. int hpf_delay = TX_MACRO_DMIC_HPF_DELAY_MS;
  795. int unmute_delay = TX_MACRO_DMIC_UNMUTE_DELAY_MS;
  796. struct device *tx_dev = NULL;
  797. struct tx_macro_priv *tx_priv = NULL;
  798. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  799. return -EINVAL;
  800. decimator = w->shift;
  801. dev_dbg(component->dev, "%s(): widget = %s decimator = %u\n", __func__,
  802. w->name, decimator);
  803. tx_vol_ctl_reg = BOLERO_CDC_TX0_TX_PATH_CTL +
  804. TX_MACRO_TX_PATH_OFFSET * decimator;
  805. hpf_gate_reg = BOLERO_CDC_TX0_TX_PATH_SEC2 +
  806. TX_MACRO_TX_PATH_OFFSET * decimator;
  807. dec_cfg_reg = BOLERO_CDC_TX0_TX_PATH_CFG0 +
  808. TX_MACRO_TX_PATH_OFFSET * decimator;
  809. tx_gain_ctl_reg = BOLERO_CDC_TX0_TX_VOL_CTL +
  810. TX_MACRO_TX_PATH_OFFSET * decimator;
  811. switch (event) {
  812. case SND_SOC_DAPM_PRE_PMU:
  813. snd_soc_component_update_bits(component,
  814. dec_cfg_reg, 0x06, tx_priv->dec_mode[decimator] <<
  815. TX_MACRO_ADC_MODE_CFG0_SHIFT);
  816. /* Enable TX PGA Mute */
  817. snd_soc_component_update_bits(component,
  818. tx_vol_ctl_reg, 0x10, 0x10);
  819. break;
  820. case SND_SOC_DAPM_POST_PMU:
  821. snd_soc_component_update_bits(component,
  822. tx_vol_ctl_reg, 0x20, 0x20);
  823. snd_soc_component_update_bits(component,
  824. hpf_gate_reg, 0x01, 0x00);
  825. /*
  826. * Minimum 1 clk cycle delay is required as per HW spec
  827. */
  828. usleep_range(1000, 1010);
  829. hpf_cut_off_freq = (
  830. snd_soc_component_read32(component, dec_cfg_reg) &
  831. TX_HPF_CUT_OFF_FREQ_MASK) >> 5;
  832. tx_priv->tx_hpf_work[decimator].hpf_cut_off_freq =
  833. hpf_cut_off_freq;
  834. if (hpf_cut_off_freq != CF_MIN_3DB_150HZ)
  835. snd_soc_component_update_bits(component, dec_cfg_reg,
  836. TX_HPF_CUT_OFF_FREQ_MASK,
  837. CF_MIN_3DB_150HZ << 5);
  838. if (is_amic_enabled(component, decimator) < BOLERO_ADC_MAX) {
  839. hpf_delay = TX_MACRO_AMIC_HPF_DELAY_MS;
  840. unmute_delay = TX_MACRO_AMIC_UNMUTE_DELAY_MS;
  841. }
  842. if (tx_unmute_delay < unmute_delay)
  843. tx_unmute_delay = unmute_delay;
  844. /* schedule work queue to Remove Mute */
  845. schedule_delayed_work(&tx_priv->tx_mute_dwork[decimator].dwork,
  846. msecs_to_jiffies(tx_unmute_delay));
  847. if (tx_priv->tx_hpf_work[decimator].hpf_cut_off_freq !=
  848. CF_MIN_3DB_150HZ) {
  849. schedule_delayed_work(
  850. &tx_priv->tx_hpf_work[decimator].dwork,
  851. msecs_to_jiffies(hpf_delay));
  852. snd_soc_component_update_bits(component,
  853. hpf_gate_reg, 0x03, 0x03);
  854. /*
  855. * Minimum 1 clk cycle delay is required as per HW spec
  856. */
  857. usleep_range(1000, 1010);
  858. snd_soc_component_update_bits(component,
  859. hpf_gate_reg, 0x02, 0x00);
  860. snd_soc_component_update_bits(component,
  861. hpf_gate_reg, 0x01, 0x01);
  862. /*
  863. * 6ms delay is required as per HW spec
  864. */
  865. usleep_range(6000, 6010);
  866. }
  867. /* apply gain after decimator is enabled */
  868. snd_soc_component_write(component, tx_gain_ctl_reg,
  869. snd_soc_component_read32(component,
  870. tx_gain_ctl_reg));
  871. if (tx_priv->bcs_enable) {
  872. if (tx_priv->version == BOLERO_VERSION_2_1)
  873. snd_soc_component_update_bits(component,
  874. BOLERO_CDC_VA_TOP_CSR_SWR_CTRL, 0x0F,
  875. tx_priv->bcs_ch);
  876. else if (tx_priv->version == BOLERO_VERSION_2_0)
  877. snd_soc_component_update_bits(component,
  878. BOLERO_CDC_TX_TOP_CSR_SWR_CTRL, 0xF0,
  879. (tx_priv->bcs_ch << 4));
  880. snd_soc_component_update_bits(component, dec_cfg_reg,
  881. 0x01, 0x01);
  882. tx_priv->bcs_clk_en = true;
  883. if (tx_priv->hs_slow_insert_complete)
  884. snd_soc_component_update_bits(component,
  885. BOLERO_CDC_TX0_TX_PATH_SEC7, 0x40,
  886. 0x40);
  887. }
  888. break;
  889. case SND_SOC_DAPM_PRE_PMD:
  890. hpf_cut_off_freq =
  891. tx_priv->tx_hpf_work[decimator].hpf_cut_off_freq;
  892. snd_soc_component_update_bits(component,
  893. tx_vol_ctl_reg, 0x10, 0x10);
  894. if (cancel_delayed_work_sync(
  895. &tx_priv->tx_hpf_work[decimator].dwork)) {
  896. if (hpf_cut_off_freq != CF_MIN_3DB_150HZ) {
  897. snd_soc_component_update_bits(
  898. component, dec_cfg_reg,
  899. TX_HPF_CUT_OFF_FREQ_MASK,
  900. hpf_cut_off_freq << 5);
  901. snd_soc_component_update_bits(component,
  902. hpf_gate_reg,
  903. 0x02, 0x02);
  904. /*
  905. * Minimum 1 clk cycle delay is required
  906. * as per HW spec
  907. */
  908. usleep_range(1000, 1010);
  909. snd_soc_component_update_bits(component,
  910. hpf_gate_reg,
  911. 0x02, 0x00);
  912. }
  913. }
  914. cancel_delayed_work_sync(
  915. &tx_priv->tx_mute_dwork[decimator].dwork);
  916. break;
  917. case SND_SOC_DAPM_POST_PMD:
  918. snd_soc_component_update_bits(component, tx_vol_ctl_reg,
  919. 0x20, 0x00);
  920. snd_soc_component_update_bits(component,
  921. dec_cfg_reg, 0x06, 0x00);
  922. snd_soc_component_update_bits(component, tx_vol_ctl_reg,
  923. 0x10, 0x00);
  924. if (tx_priv->bcs_enable) {
  925. snd_soc_component_update_bits(component, dec_cfg_reg,
  926. 0x01, 0x00);
  927. snd_soc_component_update_bits(component,
  928. BOLERO_CDC_TX0_TX_PATH_SEC7, 0x40, 0x00);
  929. tx_priv->bcs_clk_en = false;
  930. if (tx_priv->version == BOLERO_VERSION_2_1)
  931. snd_soc_component_update_bits(component,
  932. BOLERO_CDC_VA_TOP_CSR_SWR_CTRL, 0x0F,
  933. 0x00);
  934. else if (tx_priv->version == BOLERO_VERSION_2_0)
  935. snd_soc_component_update_bits(component,
  936. BOLERO_CDC_TX_TOP_CSR_SWR_CTRL, 0xF0,
  937. 0x00);
  938. }
  939. break;
  940. }
  941. return 0;
  942. }
  943. static int tx_macro_enable_micbias(struct snd_soc_dapm_widget *w,
  944. struct snd_kcontrol *kcontrol, int event)
  945. {
  946. return 0;
  947. }
  948. static int tx_macro_hw_params(struct snd_pcm_substream *substream,
  949. struct snd_pcm_hw_params *params,
  950. struct snd_soc_dai *dai)
  951. {
  952. int tx_fs_rate = -EINVAL;
  953. struct snd_soc_component *component = dai->component;
  954. u32 decimator = 0;
  955. u32 sample_rate = 0;
  956. u16 tx_fs_reg = 0;
  957. struct device *tx_dev = NULL;
  958. struct tx_macro_priv *tx_priv = NULL;
  959. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  960. return -EINVAL;
  961. pr_debug("%s: dai_name = %s DAI-ID %x rate %d num_ch %d\n", __func__,
  962. dai->name, dai->id, params_rate(params),
  963. params_channels(params));
  964. sample_rate = params_rate(params);
  965. switch (sample_rate) {
  966. case 8000:
  967. tx_fs_rate = 0;
  968. break;
  969. case 16000:
  970. tx_fs_rate = 1;
  971. break;
  972. case 32000:
  973. tx_fs_rate = 3;
  974. break;
  975. case 48000:
  976. tx_fs_rate = 4;
  977. break;
  978. case 96000:
  979. tx_fs_rate = 5;
  980. break;
  981. case 192000:
  982. tx_fs_rate = 6;
  983. break;
  984. case 384000:
  985. tx_fs_rate = 7;
  986. break;
  987. default:
  988. dev_err(component->dev, "%s: Invalid TX sample rate: %d\n",
  989. __func__, params_rate(params));
  990. return -EINVAL;
  991. }
  992. for_each_set_bit(decimator, &tx_priv->active_ch_mask[dai->id],
  993. TX_MACRO_DEC_MAX) {
  994. if (decimator >= 0) {
  995. tx_fs_reg = BOLERO_CDC_TX0_TX_PATH_CTL +
  996. TX_MACRO_TX_PATH_OFFSET * decimator;
  997. dev_dbg(component->dev, "%s: set DEC%u rate to %u\n",
  998. __func__, decimator, sample_rate);
  999. snd_soc_component_update_bits(component, tx_fs_reg,
  1000. 0x0F, tx_fs_rate);
  1001. } else {
  1002. dev_err(component->dev,
  1003. "%s: ERROR: Invalid decimator: %d\n",
  1004. __func__, decimator);
  1005. return -EINVAL;
  1006. }
  1007. }
  1008. return 0;
  1009. }
  1010. static int tx_macro_get_channel_map(struct snd_soc_dai *dai,
  1011. unsigned int *tx_num, unsigned int *tx_slot,
  1012. unsigned int *rx_num, unsigned int *rx_slot)
  1013. {
  1014. struct snd_soc_component *component = dai->component;
  1015. struct device *tx_dev = NULL;
  1016. struct tx_macro_priv *tx_priv = NULL;
  1017. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  1018. return -EINVAL;
  1019. switch (dai->id) {
  1020. case TX_MACRO_AIF1_CAP:
  1021. case TX_MACRO_AIF2_CAP:
  1022. case TX_MACRO_AIF3_CAP:
  1023. *tx_slot = tx_priv->active_ch_mask[dai->id];
  1024. *tx_num = tx_priv->active_ch_cnt[dai->id];
  1025. break;
  1026. default:
  1027. dev_err(tx_dev, "%s: Invalid AIF\n", __func__);
  1028. break;
  1029. }
  1030. return 0;
  1031. }
  1032. static struct snd_soc_dai_ops tx_macro_dai_ops = {
  1033. .hw_params = tx_macro_hw_params,
  1034. .get_channel_map = tx_macro_get_channel_map,
  1035. };
  1036. static struct snd_soc_dai_driver tx_macro_dai[] = {
  1037. {
  1038. .name = "tx_macro_tx1",
  1039. .id = TX_MACRO_AIF1_CAP,
  1040. .capture = {
  1041. .stream_name = "TX_AIF1 Capture",
  1042. .rates = TX_MACRO_RATES,
  1043. .formats = TX_MACRO_FORMATS,
  1044. .rate_max = 192000,
  1045. .rate_min = 8000,
  1046. .channels_min = 1,
  1047. .channels_max = 8,
  1048. },
  1049. .ops = &tx_macro_dai_ops,
  1050. },
  1051. {
  1052. .name = "tx_macro_tx2",
  1053. .id = TX_MACRO_AIF2_CAP,
  1054. .capture = {
  1055. .stream_name = "TX_AIF2 Capture",
  1056. .rates = TX_MACRO_RATES,
  1057. .formats = TX_MACRO_FORMATS,
  1058. .rate_max = 192000,
  1059. .rate_min = 8000,
  1060. .channels_min = 1,
  1061. .channels_max = 8,
  1062. },
  1063. .ops = &tx_macro_dai_ops,
  1064. },
  1065. {
  1066. .name = "tx_macro_tx3",
  1067. .id = TX_MACRO_AIF3_CAP,
  1068. .capture = {
  1069. .stream_name = "TX_AIF3 Capture",
  1070. .rates = TX_MACRO_RATES,
  1071. .formats = TX_MACRO_FORMATS,
  1072. .rate_max = 192000,
  1073. .rate_min = 8000,
  1074. .channels_min = 1,
  1075. .channels_max = 8,
  1076. },
  1077. .ops = &tx_macro_dai_ops,
  1078. },
  1079. };
  1080. #define STRING(name) #name
  1081. #define TX_MACRO_DAPM_ENUM(name, reg, offset, text) \
  1082. static SOC_ENUM_SINGLE_DECL(name##_enum, reg, offset, text); \
  1083. static const struct snd_kcontrol_new name##_mux = \
  1084. SOC_DAPM_ENUM(STRING(name), name##_enum)
  1085. #define TX_MACRO_DAPM_ENUM_EXT(name, reg, offset, text, getname, putname) \
  1086. static SOC_ENUM_SINGLE_DECL(name##_enum, reg, offset, text); \
  1087. static const struct snd_kcontrol_new name##_mux = \
  1088. SOC_DAPM_ENUM_EXT(STRING(name), name##_enum, getname, putname)
  1089. #define TX_MACRO_DAPM_MUX(name, shift, kctl) \
  1090. SND_SOC_DAPM_MUX(name, SND_SOC_NOPM, shift, 0, &kctl##_mux)
  1091. static const char * const adc_mux_text[] = {
  1092. "MSM_DMIC", "SWR_MIC", "ANC_FB_TUNE1"
  1093. };
  1094. TX_MACRO_DAPM_ENUM(tx_dec0, BOLERO_CDC_TX_INP_MUX_ADC_MUX0_CFG1,
  1095. 0, adc_mux_text);
  1096. TX_MACRO_DAPM_ENUM(tx_dec1, BOLERO_CDC_TX_INP_MUX_ADC_MUX1_CFG1,
  1097. 0, adc_mux_text);
  1098. TX_MACRO_DAPM_ENUM(tx_dec2, BOLERO_CDC_TX_INP_MUX_ADC_MUX2_CFG1,
  1099. 0, adc_mux_text);
  1100. TX_MACRO_DAPM_ENUM(tx_dec3, BOLERO_CDC_TX_INP_MUX_ADC_MUX3_CFG1,
  1101. 0, adc_mux_text);
  1102. TX_MACRO_DAPM_ENUM(tx_dec4, BOLERO_CDC_TX_INP_MUX_ADC_MUX4_CFG1,
  1103. 0, adc_mux_text);
  1104. TX_MACRO_DAPM_ENUM(tx_dec5, BOLERO_CDC_TX_INP_MUX_ADC_MUX5_CFG1,
  1105. 0, adc_mux_text);
  1106. TX_MACRO_DAPM_ENUM(tx_dec6, BOLERO_CDC_TX_INP_MUX_ADC_MUX6_CFG1,
  1107. 0, adc_mux_text);
  1108. TX_MACRO_DAPM_ENUM(tx_dec7, BOLERO_CDC_TX_INP_MUX_ADC_MUX7_CFG1,
  1109. 0, adc_mux_text);
  1110. static const char * const dmic_mux_text[] = {
  1111. "ZERO", "DMIC0", "DMIC1", "DMIC2", "DMIC3",
  1112. "DMIC4", "DMIC5", "DMIC6", "DMIC7"
  1113. };
  1114. TX_MACRO_DAPM_ENUM_EXT(tx_dmic0, BOLERO_CDC_TX_INP_MUX_ADC_MUX0_CFG0,
  1115. 4, dmic_mux_text, snd_soc_dapm_get_enum_double,
  1116. tx_macro_put_dec_enum);
  1117. TX_MACRO_DAPM_ENUM_EXT(tx_dmic1, BOLERO_CDC_TX_INP_MUX_ADC_MUX1_CFG0,
  1118. 4, dmic_mux_text, snd_soc_dapm_get_enum_double,
  1119. tx_macro_put_dec_enum);
  1120. TX_MACRO_DAPM_ENUM_EXT(tx_dmic2, BOLERO_CDC_TX_INP_MUX_ADC_MUX2_CFG0,
  1121. 4, dmic_mux_text, snd_soc_dapm_get_enum_double,
  1122. tx_macro_put_dec_enum);
  1123. TX_MACRO_DAPM_ENUM_EXT(tx_dmic3, BOLERO_CDC_TX_INP_MUX_ADC_MUX3_CFG0,
  1124. 4, dmic_mux_text, snd_soc_dapm_get_enum_double,
  1125. tx_macro_put_dec_enum);
  1126. TX_MACRO_DAPM_ENUM_EXT(tx_dmic4, BOLERO_CDC_TX_INP_MUX_ADC_MUX4_CFG0,
  1127. 4, dmic_mux_text, snd_soc_dapm_get_enum_double,
  1128. tx_macro_put_dec_enum);
  1129. TX_MACRO_DAPM_ENUM_EXT(tx_dmic5, BOLERO_CDC_TX_INP_MUX_ADC_MUX5_CFG0,
  1130. 4, dmic_mux_text, snd_soc_dapm_get_enum_double,
  1131. tx_macro_put_dec_enum);
  1132. TX_MACRO_DAPM_ENUM_EXT(tx_dmic6, BOLERO_CDC_TX_INP_MUX_ADC_MUX6_CFG0,
  1133. 4, dmic_mux_text, snd_soc_dapm_get_enum_double,
  1134. tx_macro_put_dec_enum);
  1135. TX_MACRO_DAPM_ENUM_EXT(tx_dmic7, BOLERO_CDC_TX_INP_MUX_ADC_MUX7_CFG0,
  1136. 4, dmic_mux_text, snd_soc_dapm_get_enum_double,
  1137. tx_macro_put_dec_enum);
  1138. static const char * const smic_mux_text[] = {
  1139. "ZERO", "ADC0", "ADC1", "ADC2", "ADC3", "SWR_DMIC0",
  1140. "SWR_DMIC1", "SWR_DMIC2", "SWR_DMIC3", "SWR_DMIC4",
  1141. "SWR_DMIC5", "SWR_DMIC6", "SWR_DMIC7"
  1142. };
  1143. TX_MACRO_DAPM_ENUM_EXT(tx_smic0, BOLERO_CDC_TX_INP_MUX_ADC_MUX0_CFG0,
  1144. 0, smic_mux_text, snd_soc_dapm_get_enum_double,
  1145. tx_macro_put_dec_enum);
  1146. TX_MACRO_DAPM_ENUM_EXT(tx_smic1, BOLERO_CDC_TX_INP_MUX_ADC_MUX1_CFG0,
  1147. 0, smic_mux_text, snd_soc_dapm_get_enum_double,
  1148. tx_macro_put_dec_enum);
  1149. TX_MACRO_DAPM_ENUM_EXT(tx_smic2, BOLERO_CDC_TX_INP_MUX_ADC_MUX2_CFG0,
  1150. 0, smic_mux_text, snd_soc_dapm_get_enum_double,
  1151. tx_macro_put_dec_enum);
  1152. TX_MACRO_DAPM_ENUM_EXT(tx_smic3, BOLERO_CDC_TX_INP_MUX_ADC_MUX3_CFG0,
  1153. 0, smic_mux_text, snd_soc_dapm_get_enum_double,
  1154. tx_macro_put_dec_enum);
  1155. TX_MACRO_DAPM_ENUM_EXT(tx_smic4, BOLERO_CDC_TX_INP_MUX_ADC_MUX4_CFG0,
  1156. 0, smic_mux_text, snd_soc_dapm_get_enum_double,
  1157. tx_macro_put_dec_enum);
  1158. TX_MACRO_DAPM_ENUM_EXT(tx_smic5, BOLERO_CDC_TX_INP_MUX_ADC_MUX5_CFG0,
  1159. 0, smic_mux_text, snd_soc_dapm_get_enum_double,
  1160. tx_macro_put_dec_enum);
  1161. TX_MACRO_DAPM_ENUM_EXT(tx_smic6, BOLERO_CDC_TX_INP_MUX_ADC_MUX6_CFG0,
  1162. 0, smic_mux_text, snd_soc_dapm_get_enum_double,
  1163. tx_macro_put_dec_enum);
  1164. TX_MACRO_DAPM_ENUM_EXT(tx_smic7, BOLERO_CDC_TX_INP_MUX_ADC_MUX7_CFG0,
  1165. 0, smic_mux_text, snd_soc_dapm_get_enum_double,
  1166. tx_macro_put_dec_enum);
  1167. static const char * const smic_mux_text_v2[] = {
  1168. "ZERO", "SWR_MIC0", "SWR_MIC1", "SWR_MIC2", "SWR_MIC3",
  1169. "SWR_MIC4", "SWR_MIC5", "SWR_MIC6", "SWR_MIC7",
  1170. "SWR_MIC8", "SWR_MIC9", "SWR_MIC10", "SWR_MIC11"
  1171. };
  1172. TX_MACRO_DAPM_ENUM_EXT(tx_smic0_v2, BOLERO_CDC_TX_INP_MUX_ADC_MUX0_CFG0,
  1173. 0, smic_mux_text_v2, snd_soc_dapm_get_enum_double,
  1174. tx_macro_put_dec_enum);
  1175. TX_MACRO_DAPM_ENUM_EXT(tx_smic1_v2, BOLERO_CDC_TX_INP_MUX_ADC_MUX1_CFG0,
  1176. 0, smic_mux_text_v2, snd_soc_dapm_get_enum_double,
  1177. tx_macro_put_dec_enum);
  1178. TX_MACRO_DAPM_ENUM_EXT(tx_smic2_v2, BOLERO_CDC_TX_INP_MUX_ADC_MUX2_CFG0,
  1179. 0, smic_mux_text_v2, snd_soc_dapm_get_enum_double,
  1180. tx_macro_put_dec_enum);
  1181. TX_MACRO_DAPM_ENUM_EXT(tx_smic3_v2, BOLERO_CDC_TX_INP_MUX_ADC_MUX3_CFG0,
  1182. 0, smic_mux_text_v2, snd_soc_dapm_get_enum_double,
  1183. tx_macro_put_dec_enum);
  1184. TX_MACRO_DAPM_ENUM_EXT(tx_smic4_v3, BOLERO_CDC_TX_INP_MUX_ADC_MUX4_CFG0,
  1185. 0, smic_mux_text_v2, snd_soc_dapm_get_enum_double,
  1186. tx_macro_put_dec_enum);
  1187. TX_MACRO_DAPM_ENUM_EXT(tx_smic5_v3, BOLERO_CDC_TX_INP_MUX_ADC_MUX5_CFG0,
  1188. 0, smic_mux_text_v2, snd_soc_dapm_get_enum_double,
  1189. tx_macro_put_dec_enum);
  1190. TX_MACRO_DAPM_ENUM_EXT(tx_smic6_v3, BOLERO_CDC_TX_INP_MUX_ADC_MUX6_CFG0,
  1191. 0, smic_mux_text_v2, snd_soc_dapm_get_enum_double,
  1192. tx_macro_put_dec_enum);
  1193. TX_MACRO_DAPM_ENUM_EXT(tx_smic7_v3, BOLERO_CDC_TX_INP_MUX_ADC_MUX7_CFG0,
  1194. 0, smic_mux_text_v2, snd_soc_dapm_get_enum_double,
  1195. tx_macro_put_dec_enum);
  1196. static const char * const dec_mode_mux_text[] = {
  1197. "ADC_DEFAULT", "ADC_LOW_PWR", "ADC_HIGH_PERF",
  1198. };
  1199. static const struct soc_enum dec_mode_mux_enum =
  1200. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(dec_mode_mux_text),
  1201. dec_mode_mux_text);
  1202. static const char * const bcs_ch_enum_text[] = {
  1203. "CH0", "CH1", "CH2", "CH3", "CH4", "CH5", "CH6", "CH7", "CH8", "CH9",
  1204. "CH10", "CH11",
  1205. };
  1206. static const struct soc_enum bcs_ch_enum =
  1207. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(bcs_ch_enum_text),
  1208. bcs_ch_enum_text);
  1209. static const struct snd_kcontrol_new tx_aif1_cap_mixer[] = {
  1210. SOC_SINGLE_EXT("DEC0", SND_SOC_NOPM, TX_MACRO_DEC0, 1, 0,
  1211. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1212. SOC_SINGLE_EXT("DEC1", SND_SOC_NOPM, TX_MACRO_DEC1, 1, 0,
  1213. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1214. SOC_SINGLE_EXT("DEC2", SND_SOC_NOPM, TX_MACRO_DEC2, 1, 0,
  1215. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1216. SOC_SINGLE_EXT("DEC3", SND_SOC_NOPM, TX_MACRO_DEC3, 1, 0,
  1217. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1218. SOC_SINGLE_EXT("DEC4", SND_SOC_NOPM, TX_MACRO_DEC4, 1, 0,
  1219. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1220. SOC_SINGLE_EXT("DEC5", SND_SOC_NOPM, TX_MACRO_DEC5, 1, 0,
  1221. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1222. SOC_SINGLE_EXT("DEC6", SND_SOC_NOPM, TX_MACRO_DEC6, 1, 0,
  1223. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1224. SOC_SINGLE_EXT("DEC7", SND_SOC_NOPM, TX_MACRO_DEC7, 1, 0,
  1225. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1226. };
  1227. static const struct snd_kcontrol_new tx_aif2_cap_mixer[] = {
  1228. SOC_SINGLE_EXT("DEC0", SND_SOC_NOPM, TX_MACRO_DEC0, 1, 0,
  1229. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1230. SOC_SINGLE_EXT("DEC1", SND_SOC_NOPM, TX_MACRO_DEC1, 1, 0,
  1231. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1232. SOC_SINGLE_EXT("DEC2", SND_SOC_NOPM, TX_MACRO_DEC2, 1, 0,
  1233. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1234. SOC_SINGLE_EXT("DEC3", SND_SOC_NOPM, TX_MACRO_DEC3, 1, 0,
  1235. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1236. SOC_SINGLE_EXT("DEC4", SND_SOC_NOPM, TX_MACRO_DEC4, 1, 0,
  1237. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1238. SOC_SINGLE_EXT("DEC5", SND_SOC_NOPM, TX_MACRO_DEC5, 1, 0,
  1239. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1240. SOC_SINGLE_EXT("DEC6", SND_SOC_NOPM, TX_MACRO_DEC6, 1, 0,
  1241. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1242. SOC_SINGLE_EXT("DEC7", SND_SOC_NOPM, TX_MACRO_DEC7, 1, 0,
  1243. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1244. };
  1245. static const struct snd_kcontrol_new tx_aif3_cap_mixer[] = {
  1246. SOC_SINGLE_EXT("DEC0", SND_SOC_NOPM, TX_MACRO_DEC0, 1, 0,
  1247. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1248. SOC_SINGLE_EXT("DEC1", SND_SOC_NOPM, TX_MACRO_DEC1, 1, 0,
  1249. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1250. SOC_SINGLE_EXT("DEC2", SND_SOC_NOPM, TX_MACRO_DEC2, 1, 0,
  1251. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1252. SOC_SINGLE_EXT("DEC3", SND_SOC_NOPM, TX_MACRO_DEC3, 1, 0,
  1253. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1254. SOC_SINGLE_EXT("DEC4", SND_SOC_NOPM, TX_MACRO_DEC4, 1, 0,
  1255. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1256. SOC_SINGLE_EXT("DEC5", SND_SOC_NOPM, TX_MACRO_DEC5, 1, 0,
  1257. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1258. SOC_SINGLE_EXT("DEC6", SND_SOC_NOPM, TX_MACRO_DEC6, 1, 0,
  1259. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1260. SOC_SINGLE_EXT("DEC7", SND_SOC_NOPM, TX_MACRO_DEC7, 1, 0,
  1261. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1262. };
  1263. static const struct snd_kcontrol_new tx_aif1_cap_mixer_v2[] = {
  1264. SOC_SINGLE_EXT("DEC0", SND_SOC_NOPM, TX_MACRO_DEC0, 1, 0,
  1265. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1266. SOC_SINGLE_EXT("DEC1", SND_SOC_NOPM, TX_MACRO_DEC1, 1, 0,
  1267. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1268. SOC_SINGLE_EXT("DEC2", SND_SOC_NOPM, TX_MACRO_DEC2, 1, 0,
  1269. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1270. SOC_SINGLE_EXT("DEC3", SND_SOC_NOPM, TX_MACRO_DEC3, 1, 0,
  1271. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1272. };
  1273. static const struct snd_kcontrol_new tx_aif2_cap_mixer_v2[] = {
  1274. SOC_SINGLE_EXT("DEC0", SND_SOC_NOPM, TX_MACRO_DEC0, 1, 0,
  1275. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1276. SOC_SINGLE_EXT("DEC1", SND_SOC_NOPM, TX_MACRO_DEC1, 1, 0,
  1277. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1278. SOC_SINGLE_EXT("DEC2", SND_SOC_NOPM, TX_MACRO_DEC2, 1, 0,
  1279. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1280. SOC_SINGLE_EXT("DEC3", SND_SOC_NOPM, TX_MACRO_DEC3, 1, 0,
  1281. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1282. };
  1283. static const struct snd_kcontrol_new tx_aif3_cap_mixer_v2[] = {
  1284. SOC_SINGLE_EXT("DEC0", SND_SOC_NOPM, TX_MACRO_DEC0, 1, 0,
  1285. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1286. SOC_SINGLE_EXT("DEC1", SND_SOC_NOPM, TX_MACRO_DEC1, 1, 0,
  1287. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1288. SOC_SINGLE_EXT("DEC2", SND_SOC_NOPM, TX_MACRO_DEC2, 1, 0,
  1289. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1290. SOC_SINGLE_EXT("DEC3", SND_SOC_NOPM, TX_MACRO_DEC3, 1, 0,
  1291. tx_macro_tx_mixer_get, tx_macro_tx_mixer_put),
  1292. };
  1293. static const struct snd_soc_dapm_widget tx_macro_dapm_widgets_common[] = {
  1294. SND_SOC_DAPM_AIF_OUT("TX_AIF1 CAP", "TX_AIF1 Capture", 0,
  1295. SND_SOC_NOPM, TX_MACRO_AIF1_CAP, 0),
  1296. SND_SOC_DAPM_AIF_OUT("TX_AIF2 CAP", "TX_AIF2 Capture", 0,
  1297. SND_SOC_NOPM, TX_MACRO_AIF2_CAP, 0),
  1298. SND_SOC_DAPM_AIF_OUT("TX_AIF3 CAP", "TX_AIF3 Capture", 0,
  1299. SND_SOC_NOPM, TX_MACRO_AIF3_CAP, 0),
  1300. TX_MACRO_DAPM_MUX("TX DMIC MUX0", 0, tx_dmic0),
  1301. TX_MACRO_DAPM_MUX("TX DMIC MUX1", 0, tx_dmic1),
  1302. TX_MACRO_DAPM_MUX("TX DMIC MUX2", 0, tx_dmic2),
  1303. TX_MACRO_DAPM_MUX("TX DMIC MUX3", 0, tx_dmic3),
  1304. TX_MACRO_DAPM_MUX("TX SMIC MUX0", 0, tx_smic0_v2),
  1305. TX_MACRO_DAPM_MUX("TX SMIC MUX1", 0, tx_smic1_v2),
  1306. TX_MACRO_DAPM_MUX("TX SMIC MUX2", 0, tx_smic2_v2),
  1307. TX_MACRO_DAPM_MUX("TX SMIC MUX3", 0, tx_smic3_v2),
  1308. SND_SOC_DAPM_SUPPLY("TX MIC BIAS1", SND_SOC_NOPM, 0, 0,
  1309. tx_macro_enable_micbias,
  1310. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1311. SND_SOC_DAPM_ADC_E("TX DMIC0", NULL, SND_SOC_NOPM, 0, 0,
  1312. tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1313. SND_SOC_DAPM_POST_PMD),
  1314. SND_SOC_DAPM_ADC_E("TX DMIC1", NULL, SND_SOC_NOPM, 0, 0,
  1315. tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1316. SND_SOC_DAPM_POST_PMD),
  1317. SND_SOC_DAPM_ADC_E("TX DMIC2", NULL, SND_SOC_NOPM, 0, 0,
  1318. tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1319. SND_SOC_DAPM_POST_PMD),
  1320. SND_SOC_DAPM_ADC_E("TX DMIC3", NULL, SND_SOC_NOPM, 0, 0,
  1321. tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1322. SND_SOC_DAPM_POST_PMD),
  1323. SND_SOC_DAPM_ADC_E("TX DMIC4", NULL, SND_SOC_NOPM, 0, 0,
  1324. tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1325. SND_SOC_DAPM_POST_PMD),
  1326. SND_SOC_DAPM_ADC_E("TX DMIC5", NULL, SND_SOC_NOPM, 0, 0,
  1327. tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1328. SND_SOC_DAPM_POST_PMD),
  1329. SND_SOC_DAPM_ADC_E("TX DMIC6", NULL, SND_SOC_NOPM, 0, 0,
  1330. tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1331. SND_SOC_DAPM_POST_PMD),
  1332. SND_SOC_DAPM_ADC_E("TX DMIC7", NULL, SND_SOC_NOPM, 0, 0,
  1333. tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1334. SND_SOC_DAPM_POST_PMD),
  1335. SND_SOC_DAPM_INPUT("TX SWR_MIC0"),
  1336. SND_SOC_DAPM_INPUT("TX SWR_MIC1"),
  1337. SND_SOC_DAPM_INPUT("TX SWR_MIC2"),
  1338. SND_SOC_DAPM_INPUT("TX SWR_MIC3"),
  1339. SND_SOC_DAPM_INPUT("TX SWR_MIC4"),
  1340. SND_SOC_DAPM_INPUT("TX SWR_MIC5"),
  1341. SND_SOC_DAPM_INPUT("TX SWR_MIC6"),
  1342. SND_SOC_DAPM_INPUT("TX SWR_MIC7"),
  1343. SND_SOC_DAPM_INPUT("TX SWR_MIC8"),
  1344. SND_SOC_DAPM_INPUT("TX SWR_MIC9"),
  1345. SND_SOC_DAPM_INPUT("TX SWR_MIC10"),
  1346. SND_SOC_DAPM_INPUT("TX SWR_MIC11"),
  1347. SND_SOC_DAPM_MUX_E("TX DEC0 MUX", SND_SOC_NOPM,
  1348. TX_MACRO_DEC0, 0,
  1349. &tx_dec0_mux, tx_macro_enable_dec,
  1350. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1351. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1352. SND_SOC_DAPM_MUX_E("TX DEC1 MUX", SND_SOC_NOPM,
  1353. TX_MACRO_DEC1, 0,
  1354. &tx_dec1_mux, tx_macro_enable_dec,
  1355. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1356. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1357. SND_SOC_DAPM_MUX_E("TX DEC2 MUX", SND_SOC_NOPM,
  1358. TX_MACRO_DEC2, 0,
  1359. &tx_dec2_mux, tx_macro_enable_dec,
  1360. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1361. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1362. SND_SOC_DAPM_MUX_E("TX DEC3 MUX", SND_SOC_NOPM,
  1363. TX_MACRO_DEC3, 0,
  1364. &tx_dec3_mux, tx_macro_enable_dec,
  1365. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1366. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1367. SND_SOC_DAPM_SUPPLY_S("TX_MCLK", 0, SND_SOC_NOPM, 0, 0,
  1368. tx_macro_mclk_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1369. };
  1370. static const struct snd_soc_dapm_widget tx_macro_dapm_widgets_v2[] = {
  1371. SND_SOC_DAPM_MIXER("TX_AIF1_CAP Mixer", SND_SOC_NOPM,
  1372. TX_MACRO_AIF1_CAP, 0,
  1373. tx_aif1_cap_mixer_v2, ARRAY_SIZE(tx_aif1_cap_mixer_v2)),
  1374. SND_SOC_DAPM_MIXER("TX_AIF2_CAP Mixer", SND_SOC_NOPM,
  1375. TX_MACRO_AIF2_CAP, 0,
  1376. tx_aif2_cap_mixer_v2, ARRAY_SIZE(tx_aif2_cap_mixer_v2)),
  1377. SND_SOC_DAPM_MIXER("TX_AIF3_CAP Mixer", SND_SOC_NOPM,
  1378. TX_MACRO_AIF3_CAP, 0,
  1379. tx_aif3_cap_mixer_v2, ARRAY_SIZE(tx_aif3_cap_mixer_v2)),
  1380. };
  1381. static const struct snd_soc_dapm_widget tx_macro_dapm_widgets_v3[] = {
  1382. SND_SOC_DAPM_MIXER("TX_AIF1_CAP Mixer", SND_SOC_NOPM,
  1383. TX_MACRO_AIF1_CAP, 0,
  1384. tx_aif1_cap_mixer, ARRAY_SIZE(tx_aif1_cap_mixer)),
  1385. SND_SOC_DAPM_MIXER("TX_AIF2_CAP Mixer", SND_SOC_NOPM,
  1386. TX_MACRO_AIF2_CAP, 0,
  1387. tx_aif2_cap_mixer, ARRAY_SIZE(tx_aif2_cap_mixer)),
  1388. SND_SOC_DAPM_MIXER("TX_AIF3_CAP Mixer", SND_SOC_NOPM,
  1389. TX_MACRO_AIF3_CAP, 0,
  1390. tx_aif3_cap_mixer, ARRAY_SIZE(tx_aif3_cap_mixer)),
  1391. TX_MACRO_DAPM_MUX("TX DMIC MUX4", 0, tx_dmic4),
  1392. TX_MACRO_DAPM_MUX("TX DMIC MUX5", 0, tx_dmic5),
  1393. TX_MACRO_DAPM_MUX("TX DMIC MUX6", 0, tx_dmic6),
  1394. TX_MACRO_DAPM_MUX("TX DMIC MUX7", 0, tx_dmic7),
  1395. TX_MACRO_DAPM_MUX("TX SMIC MUX4", 0, tx_smic4_v3),
  1396. TX_MACRO_DAPM_MUX("TX SMIC MUX5", 0, tx_smic5_v3),
  1397. TX_MACRO_DAPM_MUX("TX SMIC MUX6", 0, tx_smic6_v3),
  1398. TX_MACRO_DAPM_MUX("TX SMIC MUX7", 0, tx_smic7_v3),
  1399. SND_SOC_DAPM_MUX_E("TX DEC4 MUX", SND_SOC_NOPM,
  1400. TX_MACRO_DEC4, 0,
  1401. &tx_dec4_mux, tx_macro_enable_dec,
  1402. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1403. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1404. SND_SOC_DAPM_MUX_E("TX DEC5 MUX", SND_SOC_NOPM,
  1405. TX_MACRO_DEC5, 0,
  1406. &tx_dec5_mux, tx_macro_enable_dec,
  1407. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1408. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1409. SND_SOC_DAPM_MUX_E("TX DEC6 MUX", SND_SOC_NOPM,
  1410. TX_MACRO_DEC6, 0,
  1411. &tx_dec6_mux, tx_macro_enable_dec,
  1412. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1413. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1414. SND_SOC_DAPM_MUX_E("TX DEC7 MUX", SND_SOC_NOPM,
  1415. TX_MACRO_DEC7, 0,
  1416. &tx_dec7_mux, tx_macro_enable_dec,
  1417. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1418. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1419. SND_SOC_DAPM_SUPPLY_S("TX_SWR_CLK", 0, SND_SOC_NOPM, 0, 0,
  1420. tx_macro_tx_swr_clk_event,
  1421. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1422. SND_SOC_DAPM_SUPPLY_S("VA_SWR_CLK", 0, SND_SOC_NOPM, 0, 0,
  1423. tx_macro_va_swr_clk_event,
  1424. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1425. };
  1426. static const struct snd_soc_dapm_widget tx_macro_dapm_widgets[] = {
  1427. SND_SOC_DAPM_AIF_OUT("TX_AIF1 CAP", "TX_AIF1 Capture", 0,
  1428. SND_SOC_NOPM, TX_MACRO_AIF1_CAP, 0),
  1429. SND_SOC_DAPM_AIF_OUT("TX_AIF2 CAP", "TX_AIF2 Capture", 0,
  1430. SND_SOC_NOPM, TX_MACRO_AIF2_CAP, 0),
  1431. SND_SOC_DAPM_AIF_OUT("TX_AIF3 CAP", "TX_AIF3 Capture", 0,
  1432. SND_SOC_NOPM, TX_MACRO_AIF3_CAP, 0),
  1433. SND_SOC_DAPM_MIXER("TX_AIF1_CAP Mixer", SND_SOC_NOPM, TX_MACRO_AIF1_CAP, 0,
  1434. tx_aif1_cap_mixer, ARRAY_SIZE(tx_aif1_cap_mixer)),
  1435. SND_SOC_DAPM_MIXER("TX_AIF2_CAP Mixer", SND_SOC_NOPM, TX_MACRO_AIF2_CAP, 0,
  1436. tx_aif2_cap_mixer, ARRAY_SIZE(tx_aif2_cap_mixer)),
  1437. SND_SOC_DAPM_MIXER("TX_AIF3_CAP Mixer", SND_SOC_NOPM, TX_MACRO_AIF3_CAP, 0,
  1438. tx_aif3_cap_mixer, ARRAY_SIZE(tx_aif3_cap_mixer)),
  1439. TX_MACRO_DAPM_MUX("TX DMIC MUX0", 0, tx_dmic0),
  1440. TX_MACRO_DAPM_MUX("TX DMIC MUX1", 0, tx_dmic1),
  1441. TX_MACRO_DAPM_MUX("TX DMIC MUX2", 0, tx_dmic2),
  1442. TX_MACRO_DAPM_MUX("TX DMIC MUX3", 0, tx_dmic3),
  1443. TX_MACRO_DAPM_MUX("TX DMIC MUX4", 0, tx_dmic4),
  1444. TX_MACRO_DAPM_MUX("TX DMIC MUX5", 0, tx_dmic5),
  1445. TX_MACRO_DAPM_MUX("TX DMIC MUX6", 0, tx_dmic6),
  1446. TX_MACRO_DAPM_MUX("TX DMIC MUX7", 0, tx_dmic7),
  1447. TX_MACRO_DAPM_MUX("TX SMIC MUX0", 0, tx_smic0),
  1448. TX_MACRO_DAPM_MUX("TX SMIC MUX1", 0, tx_smic1),
  1449. TX_MACRO_DAPM_MUX("TX SMIC MUX2", 0, tx_smic2),
  1450. TX_MACRO_DAPM_MUX("TX SMIC MUX3", 0, tx_smic3),
  1451. TX_MACRO_DAPM_MUX("TX SMIC MUX4", 0, tx_smic4),
  1452. TX_MACRO_DAPM_MUX("TX SMIC MUX5", 0, tx_smic5),
  1453. TX_MACRO_DAPM_MUX("TX SMIC MUX6", 0, tx_smic6),
  1454. TX_MACRO_DAPM_MUX("TX SMIC MUX7", 0, tx_smic7),
  1455. SND_SOC_DAPM_SUPPLY("TX MIC BIAS1", SND_SOC_NOPM, 0, 0,
  1456. tx_macro_enable_micbias,
  1457. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1458. SND_SOC_DAPM_ADC_E("TX DMIC0", NULL, SND_SOC_NOPM, 0, 0,
  1459. tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1460. SND_SOC_DAPM_POST_PMD),
  1461. SND_SOC_DAPM_ADC_E("TX DMIC1", NULL, SND_SOC_NOPM, 0, 0,
  1462. tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1463. SND_SOC_DAPM_POST_PMD),
  1464. SND_SOC_DAPM_ADC_E("TX DMIC2", NULL, SND_SOC_NOPM, 0, 0,
  1465. tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1466. SND_SOC_DAPM_POST_PMD),
  1467. SND_SOC_DAPM_ADC_E("TX DMIC3", NULL, SND_SOC_NOPM, 0, 0,
  1468. tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1469. SND_SOC_DAPM_POST_PMD),
  1470. SND_SOC_DAPM_ADC_E("TX DMIC4", NULL, SND_SOC_NOPM, 0, 0,
  1471. tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1472. SND_SOC_DAPM_POST_PMD),
  1473. SND_SOC_DAPM_ADC_E("TX DMIC5", NULL, SND_SOC_NOPM, 0, 0,
  1474. tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1475. SND_SOC_DAPM_POST_PMD),
  1476. SND_SOC_DAPM_ADC_E("TX DMIC6", NULL, SND_SOC_NOPM, 0, 0,
  1477. tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1478. SND_SOC_DAPM_POST_PMD),
  1479. SND_SOC_DAPM_ADC_E("TX DMIC7", NULL, SND_SOC_NOPM, 0, 0,
  1480. tx_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1481. SND_SOC_DAPM_POST_PMD),
  1482. SND_SOC_DAPM_INPUT("TX SWR_ADC0"),
  1483. SND_SOC_DAPM_INPUT("TX SWR_ADC1"),
  1484. SND_SOC_DAPM_INPUT("TX SWR_ADC2"),
  1485. SND_SOC_DAPM_INPUT("TX SWR_ADC3"),
  1486. SND_SOC_DAPM_INPUT("TX SWR_DMIC0"),
  1487. SND_SOC_DAPM_INPUT("TX SWR_DMIC1"),
  1488. SND_SOC_DAPM_INPUT("TX SWR_DMIC2"),
  1489. SND_SOC_DAPM_INPUT("TX SWR_DMIC3"),
  1490. SND_SOC_DAPM_INPUT("TX SWR_DMIC4"),
  1491. SND_SOC_DAPM_INPUT("TX SWR_DMIC5"),
  1492. SND_SOC_DAPM_INPUT("TX SWR_DMIC6"),
  1493. SND_SOC_DAPM_INPUT("TX SWR_DMIC7"),
  1494. SND_SOC_DAPM_MUX_E("TX DEC0 MUX", SND_SOC_NOPM,
  1495. TX_MACRO_DEC0, 0,
  1496. &tx_dec0_mux, tx_macro_enable_dec,
  1497. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1498. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1499. SND_SOC_DAPM_MUX_E("TX DEC1 MUX", SND_SOC_NOPM,
  1500. TX_MACRO_DEC1, 0,
  1501. &tx_dec1_mux, tx_macro_enable_dec,
  1502. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1503. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1504. SND_SOC_DAPM_MUX_E("TX DEC2 MUX", SND_SOC_NOPM,
  1505. TX_MACRO_DEC2, 0,
  1506. &tx_dec2_mux, tx_macro_enable_dec,
  1507. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1508. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1509. SND_SOC_DAPM_MUX_E("TX DEC3 MUX", SND_SOC_NOPM,
  1510. TX_MACRO_DEC3, 0,
  1511. &tx_dec3_mux, tx_macro_enable_dec,
  1512. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1513. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1514. SND_SOC_DAPM_MUX_E("TX DEC4 MUX", SND_SOC_NOPM,
  1515. TX_MACRO_DEC4, 0,
  1516. &tx_dec4_mux, tx_macro_enable_dec,
  1517. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1518. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1519. SND_SOC_DAPM_MUX_E("TX DEC5 MUX", SND_SOC_NOPM,
  1520. TX_MACRO_DEC5, 0,
  1521. &tx_dec5_mux, tx_macro_enable_dec,
  1522. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1523. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1524. SND_SOC_DAPM_MUX_E("TX DEC6 MUX", SND_SOC_NOPM,
  1525. TX_MACRO_DEC6, 0,
  1526. &tx_dec6_mux, tx_macro_enable_dec,
  1527. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1528. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1529. SND_SOC_DAPM_MUX_E("TX DEC7 MUX", SND_SOC_NOPM,
  1530. TX_MACRO_DEC7, 0,
  1531. &tx_dec7_mux, tx_macro_enable_dec,
  1532. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1533. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1534. SND_SOC_DAPM_SUPPLY_S("TX_MCLK", 0, SND_SOC_NOPM, 0, 0,
  1535. tx_macro_mclk_event, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1536. SND_SOC_DAPM_SUPPLY_S("TX_SWR_CLK", 0, SND_SOC_NOPM, 0, 0,
  1537. tx_macro_tx_swr_clk_event,
  1538. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1539. SND_SOC_DAPM_SUPPLY_S("VA_SWR_CLK", 0, SND_SOC_NOPM, 0, 0,
  1540. tx_macro_va_swr_clk_event,
  1541. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1542. };
  1543. static const struct snd_soc_dapm_route tx_audio_map_common[] = {
  1544. {"TX_AIF1 CAP", NULL, "TX_MCLK"},
  1545. {"TX_AIF2 CAP", NULL, "TX_MCLK"},
  1546. {"TX_AIF3 CAP", NULL, "TX_MCLK"},
  1547. {"TX_AIF1 CAP", NULL, "TX_AIF1_CAP Mixer"},
  1548. {"TX_AIF2 CAP", NULL, "TX_AIF2_CAP Mixer"},
  1549. {"TX_AIF3 CAP", NULL, "TX_AIF3_CAP Mixer"},
  1550. {"TX_AIF1_CAP Mixer", "DEC0", "TX DEC0 MUX"},
  1551. {"TX_AIF1_CAP Mixer", "DEC1", "TX DEC1 MUX"},
  1552. {"TX_AIF1_CAP Mixer", "DEC2", "TX DEC2 MUX"},
  1553. {"TX_AIF1_CAP Mixer", "DEC3", "TX DEC3 MUX"},
  1554. {"TX_AIF2_CAP Mixer", "DEC0", "TX DEC0 MUX"},
  1555. {"TX_AIF2_CAP Mixer", "DEC1", "TX DEC1 MUX"},
  1556. {"TX_AIF2_CAP Mixer", "DEC2", "TX DEC2 MUX"},
  1557. {"TX_AIF2_CAP Mixer", "DEC3", "TX DEC3 MUX"},
  1558. {"TX_AIF3_CAP Mixer", "DEC0", "TX DEC0 MUX"},
  1559. {"TX_AIF3_CAP Mixer", "DEC1", "TX DEC1 MUX"},
  1560. {"TX_AIF3_CAP Mixer", "DEC2", "TX DEC2 MUX"},
  1561. {"TX_AIF3_CAP Mixer", "DEC3", "TX DEC3 MUX"},
  1562. {"TX DEC0 MUX", NULL, "TX_MCLK"},
  1563. {"TX DEC1 MUX", NULL, "TX_MCLK"},
  1564. {"TX DEC2 MUX", NULL, "TX_MCLK"},
  1565. {"TX DEC3 MUX", NULL, "TX_MCLK"},
  1566. {"TX DEC0 MUX", "MSM_DMIC", "TX DMIC MUX0"},
  1567. {"TX DMIC MUX0", "DMIC0", "TX DMIC0"},
  1568. {"TX DMIC MUX0", "DMIC1", "TX DMIC1"},
  1569. {"TX DMIC MUX0", "DMIC2", "TX DMIC2"},
  1570. {"TX DMIC MUX0", "DMIC3", "TX DMIC3"},
  1571. {"TX DMIC MUX0", "DMIC4", "TX DMIC4"},
  1572. {"TX DMIC MUX0", "DMIC5", "TX DMIC5"},
  1573. {"TX DMIC MUX0", "DMIC6", "TX DMIC6"},
  1574. {"TX DMIC MUX0", "DMIC7", "TX DMIC7"},
  1575. {"TX DEC0 MUX", "SWR_MIC", "TX SMIC MUX0"},
  1576. {"TX SMIC MUX0", "SWR_MIC0", "TX SWR_MIC0"},
  1577. {"TX SMIC MUX0", "SWR_MIC1", "TX SWR_MIC1"},
  1578. {"TX SMIC MUX0", "SWR_MIC2", "TX SWR_MIC2"},
  1579. {"TX SMIC MUX0", "SWR_MIC3", "TX SWR_MIC3"},
  1580. {"TX SMIC MUX0", "SWR_MIC4", "TX SWR_MIC4"},
  1581. {"TX SMIC MUX0", "SWR_MIC5", "TX SWR_MIC5"},
  1582. {"TX SMIC MUX0", "SWR_MIC6", "TX SWR_MIC6"},
  1583. {"TX SMIC MUX0", "SWR_MIC7", "TX SWR_MIC7"},
  1584. {"TX SMIC MUX0", "SWR_MIC8", "TX SWR_MIC8"},
  1585. {"TX SMIC MUX0", "SWR_MIC9", "TX SWR_MIC9"},
  1586. {"TX SMIC MUX0", "SWR_MIC10", "TX SWR_MIC10"},
  1587. {"TX SMIC MUX0", "SWR_MIC11", "TX SWR_MIC11"},
  1588. {"TX DEC1 MUX", "MSM_DMIC", "TX DMIC MUX1"},
  1589. {"TX DMIC MUX1", "DMIC0", "TX DMIC0"},
  1590. {"TX DMIC MUX1", "DMIC1", "TX DMIC1"},
  1591. {"TX DMIC MUX1", "DMIC2", "TX DMIC2"},
  1592. {"TX DMIC MUX1", "DMIC3", "TX DMIC3"},
  1593. {"TX DMIC MUX1", "DMIC4", "TX DMIC4"},
  1594. {"TX DMIC MUX1", "DMIC5", "TX DMIC5"},
  1595. {"TX DMIC MUX1", "DMIC6", "TX DMIC6"},
  1596. {"TX DMIC MUX1", "DMIC7", "TX DMIC7"},
  1597. {"TX DEC1 MUX", "SWR_MIC", "TX SMIC MUX1"},
  1598. {"TX SMIC MUX1", "SWR_MIC0", "TX SWR_MIC0"},
  1599. {"TX SMIC MUX1", "SWR_MIC1", "TX SWR_MIC1"},
  1600. {"TX SMIC MUX1", "SWR_MIC2", "TX SWR_MIC2"},
  1601. {"TX SMIC MUX1", "SWR_MIC3", "TX SWR_MIC3"},
  1602. {"TX SMIC MUX1", "SWR_MIC4", "TX SWR_MIC4"},
  1603. {"TX SMIC MUX1", "SWR_MIC5", "TX SWR_MIC5"},
  1604. {"TX SMIC MUX1", "SWR_MIC6", "TX SWR_MIC6"},
  1605. {"TX SMIC MUX1", "SWR_MIC7", "TX SWR_MIC7"},
  1606. {"TX SMIC MUX1", "SWR_MIC8", "TX SWR_MIC8"},
  1607. {"TX SMIC MUX1", "SWR_MIC9", "TX SWR_MIC9"},
  1608. {"TX SMIC MUX1", "SWR_MIC10", "TX SWR_MIC10"},
  1609. {"TX SMIC MUX1", "SWR_MIC11", "TX SWR_MIC11"},
  1610. {"TX DEC2 MUX", "MSM_DMIC", "TX DMIC MUX2"},
  1611. {"TX DMIC MUX2", "DMIC0", "TX DMIC0"},
  1612. {"TX DMIC MUX2", "DMIC1", "TX DMIC1"},
  1613. {"TX DMIC MUX2", "DMIC2", "TX DMIC2"},
  1614. {"TX DMIC MUX2", "DMIC3", "TX DMIC3"},
  1615. {"TX DMIC MUX2", "DMIC4", "TX DMIC4"},
  1616. {"TX DMIC MUX2", "DMIC5", "TX DMIC5"},
  1617. {"TX DMIC MUX2", "DMIC6", "TX DMIC6"},
  1618. {"TX DMIC MUX2", "DMIC7", "TX DMIC7"},
  1619. {"TX DEC2 MUX", "SWR_MIC", "TX SMIC MUX2"},
  1620. {"TX SMIC MUX2", "SWR_MIC0", "TX SWR_MIC0"},
  1621. {"TX SMIC MUX2", "SWR_MIC1", "TX SWR_MIC1"},
  1622. {"TX SMIC MUX2", "SWR_MIC2", "TX SWR_MIC2"},
  1623. {"TX SMIC MUX2", "SWR_MIC3", "TX SWR_MIC3"},
  1624. {"TX SMIC MUX2", "SWR_MIC4", "TX SWR_MIC4"},
  1625. {"TX SMIC MUX2", "SWR_MIC5", "TX SWR_MIC5"},
  1626. {"TX SMIC MUX2", "SWR_MIC6", "TX SWR_MIC6"},
  1627. {"TX SMIC MUX2", "SWR_MIC7", "TX SWR_MIC7"},
  1628. {"TX SMIC MUX2", "SWR_MIC8", "TX SWR_MIC8"},
  1629. {"TX SMIC MUX2", "SWR_MIC9", "TX SWR_MIC9"},
  1630. {"TX SMIC MUX2", "SWR_MIC10", "TX SWR_MIC10"},
  1631. {"TX SMIC MUX2", "SWR_MIC11", "TX SWR_MIC11"},
  1632. {"TX DEC3 MUX", "MSM_DMIC", "TX DMIC MUX3"},
  1633. {"TX DMIC MUX3", "DMIC0", "TX DMIC0"},
  1634. {"TX DMIC MUX3", "DMIC1", "TX DMIC1"},
  1635. {"TX DMIC MUX3", "DMIC2", "TX DMIC2"},
  1636. {"TX DMIC MUX3", "DMIC3", "TX DMIC3"},
  1637. {"TX DMIC MUX3", "DMIC4", "TX DMIC4"},
  1638. {"TX DMIC MUX3", "DMIC5", "TX DMIC5"},
  1639. {"TX DMIC MUX3", "DMIC6", "TX DMIC6"},
  1640. {"TX DMIC MUX3", "DMIC7", "TX DMIC7"},
  1641. {"TX DEC3 MUX", "SWR_MIC", "TX SMIC MUX3"},
  1642. {"TX SMIC MUX3", "SWR_MIC0", "TX SWR_MIC0"},
  1643. {"TX SMIC MUX3", "SWR_MIC1", "TX SWR_MIC1"},
  1644. {"TX SMIC MUX3", "SWR_MIC2", "TX SWR_MIC2"},
  1645. {"TX SMIC MUX3", "SWR_MIC3", "TX SWR_MIC3"},
  1646. {"TX SMIC MUX3", "SWR_MIC4", "TX SWR_MIC4"},
  1647. {"TX SMIC MUX3", "SWR_MIC5", "TX SWR_MIC5"},
  1648. {"TX SMIC MUX3", "SWR_MIC6", "TX SWR_MIC6"},
  1649. {"TX SMIC MUX3", "SWR_MIC7", "TX SWR_MIC7"},
  1650. {"TX SMIC MUX3", "SWR_MIC8", "TX SWR_MIC8"},
  1651. {"TX SMIC MUX3", "SWR_MIC9", "TX SWR_MIC9"},
  1652. {"TX SMIC MUX3", "SWR_MIC10", "TX SWR_MIC10"},
  1653. {"TX SMIC MUX3", "SWR_MIC11", "TX SWR_MIC11"},
  1654. };
  1655. static const struct snd_soc_dapm_route tx_audio_map_v3[] = {
  1656. {"TX_AIF1_CAP Mixer", "DEC4", "TX DEC4 MUX"},
  1657. {"TX_AIF1_CAP Mixer", "DEC5", "TX DEC5 MUX"},
  1658. {"TX_AIF1_CAP Mixer", "DEC6", "TX DEC6 MUX"},
  1659. {"TX_AIF1_CAP Mixer", "DEC7", "TX DEC7 MUX"},
  1660. {"TX_AIF2_CAP Mixer", "DEC4", "TX DEC4 MUX"},
  1661. {"TX_AIF2_CAP Mixer", "DEC5", "TX DEC5 MUX"},
  1662. {"TX_AIF2_CAP Mixer", "DEC6", "TX DEC6 MUX"},
  1663. {"TX_AIF2_CAP Mixer", "DEC7", "TX DEC7 MUX"},
  1664. {"TX_AIF3_CAP Mixer", "DEC4", "TX DEC4 MUX"},
  1665. {"TX_AIF3_CAP Mixer", "DEC5", "TX DEC5 MUX"},
  1666. {"TX_AIF3_CAP Mixer", "DEC6", "TX DEC6 MUX"},
  1667. {"TX_AIF3_CAP Mixer", "DEC7", "TX DEC7 MUX"},
  1668. {"TX DEC4 MUX", NULL, "TX_MCLK"},
  1669. {"TX DEC5 MUX", NULL, "TX_MCLK"},
  1670. {"TX DEC6 MUX", NULL, "TX_MCLK"},
  1671. {"TX DEC7 MUX", NULL, "TX_MCLK"},
  1672. {"TX DEC4 MUX", "MSM_DMIC", "TX DMIC MUX4"},
  1673. {"TX DMIC MUX4", "DMIC0", "TX DMIC0"},
  1674. {"TX DMIC MUX4", "DMIC1", "TX DMIC1"},
  1675. {"TX DMIC MUX4", "DMIC2", "TX DMIC2"},
  1676. {"TX DMIC MUX4", "DMIC3", "TX DMIC3"},
  1677. {"TX DMIC MUX4", "DMIC4", "TX DMIC4"},
  1678. {"TX DMIC MUX4", "DMIC5", "TX DMIC5"},
  1679. {"TX DMIC MUX4", "DMIC6", "TX DMIC6"},
  1680. {"TX DMIC MUX4", "DMIC7", "TX DMIC7"},
  1681. {"TX DEC4 MUX", "SWR_MIC", "TX SMIC MUX4"},
  1682. {"TX SMIC MUX4", "SWR_MIC0", "TX SWR_MIC0"},
  1683. {"TX SMIC MUX4", "SWR_MIC1", "TX SWR_MIC1"},
  1684. {"TX SMIC MUX4", "SWR_MIC2", "TX SWR_MIC2"},
  1685. {"TX SMIC MUX4", "SWR_MIC3", "TX SWR_MIC3"},
  1686. {"TX SMIC MUX4", "SWR_MIC4", "TX SWR_MIC4"},
  1687. {"TX SMIC MUX4", "SWR_MIC5", "TX SWR_MIC5"},
  1688. {"TX SMIC MUX4", "SWR_MIC6", "TX SWR_MIC6"},
  1689. {"TX SMIC MUX4", "SWR_MIC7", "TX SWR_MIC7"},
  1690. {"TX SMIC MUX4", "SWR_MIC8", "TX SWR_MIC8"},
  1691. {"TX SMIC MUX4", "SWR_MIC9", "TX SWR_MIC9"},
  1692. {"TX SMIC MUX4", "SWR_MIC10", "TX SWR_MIC10"},
  1693. {"TX SMIC MUX4", "SWR_MIC11", "TX SWR_MIC11"},
  1694. {"TX DEC5 MUX", "MSM_DMIC", "TX DMIC MUX5"},
  1695. {"TX DMIC MUX5", "DMIC0", "TX DMIC0"},
  1696. {"TX DMIC MUX5", "DMIC1", "TX DMIC1"},
  1697. {"TX DMIC MUX5", "DMIC2", "TX DMIC2"},
  1698. {"TX DMIC MUX5", "DMIC3", "TX DMIC3"},
  1699. {"TX DMIC MUX5", "DMIC4", "TX DMIC4"},
  1700. {"TX DMIC MUX5", "DMIC5", "TX DMIC5"},
  1701. {"TX DMIC MUX5", "DMIC6", "TX DMIC6"},
  1702. {"TX DMIC MUX5", "DMIC7", "TX DMIC7"},
  1703. {"TX DEC5 MUX", "SWR_MIC", "TX SMIC MUX5"},
  1704. {"TX SMIC MUX5", "SWR_MIC0", "TX SWR_MIC0"},
  1705. {"TX SMIC MUX5", "SWR_MIC1", "TX SWR_MIC1"},
  1706. {"TX SMIC MUX5", "SWR_MIC2", "TX SWR_MIC2"},
  1707. {"TX SMIC MUX5", "SWR_MIC3", "TX SWR_MIC3"},
  1708. {"TX SMIC MUX5", "SWR_MIC4", "TX SWR_MIC4"},
  1709. {"TX SMIC MUX5", "SWR_MIC5", "TX SWR_MIC5"},
  1710. {"TX SMIC MUX5", "SWR_MIC6", "TX SWR_MIC6"},
  1711. {"TX SMIC MUX5", "SWR_MIC7", "TX SWR_MIC7"},
  1712. {"TX SMIC MUX5", "SWR_MIC8", "TX SWR_MIC8"},
  1713. {"TX SMIC MUX5", "SWR_MIC9", "TX SWR_MIC9"},
  1714. {"TX SMIC MUX5", "SWR_MIC10", "TX SWR_MIC10"},
  1715. {"TX SMIC MUX5", "SWR_MIC11", "TX SWR_MIC11"},
  1716. {"TX DEC6 MUX", "MSM_DMIC", "TX DMIC MUX6"},
  1717. {"TX DMIC MUX6", "DMIC0", "TX DMIC0"},
  1718. {"TX DMIC MUX6", "DMIC1", "TX DMIC1"},
  1719. {"TX DMIC MUX6", "DMIC2", "TX DMIC2"},
  1720. {"TX DMIC MUX6", "DMIC3", "TX DMIC3"},
  1721. {"TX DMIC MUX6", "DMIC4", "TX DMIC4"},
  1722. {"TX DMIC MUX6", "DMIC5", "TX DMIC5"},
  1723. {"TX DMIC MUX6", "DMIC6", "TX DMIC6"},
  1724. {"TX DMIC MUX6", "DMIC7", "TX DMIC7"},
  1725. {"TX DEC6 MUX", "SWR_MIC", "TX SMIC MUX6"},
  1726. {"TX SMIC MUX6", "SWR_MIC0", "TX SWR_MIC0"},
  1727. {"TX SMIC MUX6", "SWR_MIC1", "TX SWR_MIC1"},
  1728. {"TX SMIC MUX6", "SWR_MIC2", "TX SWR_MIC2"},
  1729. {"TX SMIC MUX6", "SWR_MIC3", "TX SWR_MIC3"},
  1730. {"TX SMIC MUX6", "SWR_MIC4", "TX SWR_MIC4"},
  1731. {"TX SMIC MUX6", "SWR_MIC5", "TX SWR_MIC5"},
  1732. {"TX SMIC MUX6", "SWR_MIC6", "TX SWR_MIC6"},
  1733. {"TX SMIC MUX6", "SWR_MIC7", "TX SWR_MIC7"},
  1734. {"TX SMIC MUX6", "SWR_MIC8", "TX SWR_MIC8"},
  1735. {"TX SMIC MUX6", "SWR_MIC9", "TX SWR_MIC9"},
  1736. {"TX SMIC MUX6", "SWR_MIC10", "TX SWR_MIC10"},
  1737. {"TX SMIC MUX6", "SWR_MIC11", "TX SWR_MIC11"},
  1738. {"TX DEC7 MUX", "MSM_DMIC", "TX DMIC MUX7"},
  1739. {"TX DMIC MUX7", "DMIC0", "TX DMIC0"},
  1740. {"TX DMIC MUX7", "DMIC1", "TX DMIC1"},
  1741. {"TX DMIC MUX7", "DMIC2", "TX DMIC2"},
  1742. {"TX DMIC MUX7", "DMIC3", "TX DMIC3"},
  1743. {"TX DMIC MUX7", "DMIC4", "TX DMIC4"},
  1744. {"TX DMIC MUX7", "DMIC5", "TX DMIC5"},
  1745. {"TX DMIC MUX7", "DMIC6", "TX DMIC6"},
  1746. {"TX DMIC MUX7", "DMIC7", "TX DMIC7"},
  1747. {"TX DEC7 MUX", "SWR_MIC", "TX SMIC MUX7"},
  1748. {"TX SMIC MUX7", "SWR_MIC0", "TX SWR_MIC0"},
  1749. {"TX SMIC MUX7", "SWR_MIC1", "TX SWR_MIC1"},
  1750. {"TX SMIC MUX7", "SWR_MIC2", "TX SWR_MIC2"},
  1751. {"TX SMIC MUX7", "SWR_MIC3", "TX SWR_MIC3"},
  1752. {"TX SMIC MUX7", "SWR_MIC4", "TX SWR_MIC4"},
  1753. {"TX SMIC MUX7", "SWR_MIC5", "TX SWR_MIC5"},
  1754. {"TX SMIC MUX7", "SWR_MIC6", "TX SWR_MIC6"},
  1755. {"TX SMIC MUX7", "SWR_MIC7", "TX SWR_MIC7"},
  1756. {"TX SMIC MUX7", "SWR_MIC8", "TX SWR_MIC8"},
  1757. {"TX SMIC MUX7", "SWR_MIC9", "TX SWR_MIC9"},
  1758. {"TX SMIC MUX7", "SWR_MIC10", "TX SWR_MIC10"},
  1759. {"TX SMIC MUX7", "SWR_MIC11", "TX SWR_MIC11"},
  1760. {"TX SMIC MUX0", NULL, "TX_SWR_CLK"},
  1761. {"TX SMIC MUX1", NULL, "TX_SWR_CLK"},
  1762. {"TX SMIC MUX2", NULL, "TX_SWR_CLK"},
  1763. {"TX SMIC MUX3", NULL, "TX_SWR_CLK"},
  1764. {"TX SMIC MUX4", NULL, "TX_SWR_CLK"},
  1765. {"TX SMIC MUX5", NULL, "TX_SWR_CLK"},
  1766. {"TX SMIC MUX6", NULL, "TX_SWR_CLK"},
  1767. {"TX SMIC MUX7", NULL, "TX_SWR_CLK"},
  1768. };
  1769. static const struct snd_soc_dapm_route tx_audio_map[] = {
  1770. {"TX_AIF1 CAP", NULL, "TX_MCLK"},
  1771. {"TX_AIF2 CAP", NULL, "TX_MCLK"},
  1772. {"TX_AIF3 CAP", NULL, "TX_MCLK"},
  1773. {"TX_AIF1 CAP", NULL, "TX_AIF1_CAP Mixer"},
  1774. {"TX_AIF2 CAP", NULL, "TX_AIF2_CAP Mixer"},
  1775. {"TX_AIF3 CAP", NULL, "TX_AIF3_CAP Mixer"},
  1776. {"TX_AIF1_CAP Mixer", "DEC0", "TX DEC0 MUX"},
  1777. {"TX_AIF1_CAP Mixer", "DEC1", "TX DEC1 MUX"},
  1778. {"TX_AIF1_CAP Mixer", "DEC2", "TX DEC2 MUX"},
  1779. {"TX_AIF1_CAP Mixer", "DEC3", "TX DEC3 MUX"},
  1780. {"TX_AIF1_CAP Mixer", "DEC4", "TX DEC4 MUX"},
  1781. {"TX_AIF1_CAP Mixer", "DEC5", "TX DEC5 MUX"},
  1782. {"TX_AIF1_CAP Mixer", "DEC6", "TX DEC6 MUX"},
  1783. {"TX_AIF1_CAP Mixer", "DEC7", "TX DEC7 MUX"},
  1784. {"TX_AIF2_CAP Mixer", "DEC0", "TX DEC0 MUX"},
  1785. {"TX_AIF2_CAP Mixer", "DEC1", "TX DEC1 MUX"},
  1786. {"TX_AIF2_CAP Mixer", "DEC2", "TX DEC2 MUX"},
  1787. {"TX_AIF2_CAP Mixer", "DEC3", "TX DEC3 MUX"},
  1788. {"TX_AIF2_CAP Mixer", "DEC4", "TX DEC4 MUX"},
  1789. {"TX_AIF2_CAP Mixer", "DEC5", "TX DEC5 MUX"},
  1790. {"TX_AIF2_CAP Mixer", "DEC6", "TX DEC6 MUX"},
  1791. {"TX_AIF2_CAP Mixer", "DEC7", "TX DEC7 MUX"},
  1792. {"TX_AIF3_CAP Mixer", "DEC0", "TX DEC0 MUX"},
  1793. {"TX_AIF3_CAP Mixer", "DEC1", "TX DEC1 MUX"},
  1794. {"TX_AIF3_CAP Mixer", "DEC2", "TX DEC2 MUX"},
  1795. {"TX_AIF3_CAP Mixer", "DEC3", "TX DEC3 MUX"},
  1796. {"TX_AIF3_CAP Mixer", "DEC4", "TX DEC4 MUX"},
  1797. {"TX_AIF3_CAP Mixer", "DEC5", "TX DEC5 MUX"},
  1798. {"TX_AIF3_CAP Mixer", "DEC6", "TX DEC6 MUX"},
  1799. {"TX_AIF3_CAP Mixer", "DEC7", "TX DEC7 MUX"},
  1800. {"TX DEC0 MUX", NULL, "TX_MCLK"},
  1801. {"TX DEC1 MUX", NULL, "TX_MCLK"},
  1802. {"TX DEC2 MUX", NULL, "TX_MCLK"},
  1803. {"TX DEC3 MUX", NULL, "TX_MCLK"},
  1804. {"TX DEC4 MUX", NULL, "TX_MCLK"},
  1805. {"TX DEC5 MUX", NULL, "TX_MCLK"},
  1806. {"TX DEC6 MUX", NULL, "TX_MCLK"},
  1807. {"TX DEC7 MUX", NULL, "TX_MCLK"},
  1808. {"TX DEC0 MUX", "MSM_DMIC", "TX DMIC MUX0"},
  1809. {"TX DMIC MUX0", "DMIC0", "TX DMIC0"},
  1810. {"TX DMIC MUX0", "DMIC1", "TX DMIC1"},
  1811. {"TX DMIC MUX0", "DMIC2", "TX DMIC2"},
  1812. {"TX DMIC MUX0", "DMIC3", "TX DMIC3"},
  1813. {"TX DMIC MUX0", "DMIC4", "TX DMIC4"},
  1814. {"TX DMIC MUX0", "DMIC5", "TX DMIC5"},
  1815. {"TX DMIC MUX0", "DMIC6", "TX DMIC6"},
  1816. {"TX DMIC MUX0", "DMIC7", "TX DMIC7"},
  1817. {"TX DEC0 MUX", "SWR_MIC", "TX SMIC MUX0"},
  1818. {"TX SMIC MUX0", NULL, "TX_SWR_CLK"},
  1819. {"TX SMIC MUX0", "ADC0", "TX SWR_ADC0"},
  1820. {"TX SMIC MUX0", "ADC1", "TX SWR_ADC1"},
  1821. {"TX SMIC MUX0", "ADC2", "TX SWR_ADC2"},
  1822. {"TX SMIC MUX0", "ADC3", "TX SWR_ADC3"},
  1823. {"TX SMIC MUX0", "SWR_DMIC0", "TX SWR_DMIC0"},
  1824. {"TX SMIC MUX0", "SWR_DMIC1", "TX SWR_DMIC1"},
  1825. {"TX SMIC MUX0", "SWR_DMIC2", "TX SWR_DMIC2"},
  1826. {"TX SMIC MUX0", "SWR_DMIC3", "TX SWR_DMIC3"},
  1827. {"TX SMIC MUX0", "SWR_DMIC4", "TX SWR_DMIC4"},
  1828. {"TX SMIC MUX0", "SWR_DMIC5", "TX SWR_DMIC5"},
  1829. {"TX SMIC MUX0", "SWR_DMIC6", "TX SWR_DMIC6"},
  1830. {"TX SMIC MUX0", "SWR_DMIC7", "TX SWR_DMIC7"},
  1831. {"TX DEC1 MUX", "MSM_DMIC", "TX DMIC MUX1"},
  1832. {"TX DMIC MUX1", "DMIC0", "TX DMIC0"},
  1833. {"TX DMIC MUX1", "DMIC1", "TX DMIC1"},
  1834. {"TX DMIC MUX1", "DMIC2", "TX DMIC2"},
  1835. {"TX DMIC MUX1", "DMIC3", "TX DMIC3"},
  1836. {"TX DMIC MUX1", "DMIC4", "TX DMIC4"},
  1837. {"TX DMIC MUX1", "DMIC5", "TX DMIC5"},
  1838. {"TX DMIC MUX1", "DMIC6", "TX DMIC6"},
  1839. {"TX DMIC MUX1", "DMIC7", "TX DMIC7"},
  1840. {"TX DEC1 MUX", "SWR_MIC", "TX SMIC MUX1"},
  1841. {"TX SMIC MUX1", NULL, "TX_SWR_CLK"},
  1842. {"TX SMIC MUX1", "ADC0", "TX SWR_ADC0"},
  1843. {"TX SMIC MUX1", "ADC1", "TX SWR_ADC1"},
  1844. {"TX SMIC MUX1", "ADC2", "TX SWR_ADC2"},
  1845. {"TX SMIC MUX1", "ADC3", "TX SWR_ADC3"},
  1846. {"TX SMIC MUX1", "SWR_DMIC0", "TX SWR_DMIC0"},
  1847. {"TX SMIC MUX1", "SWR_DMIC1", "TX SWR_DMIC1"},
  1848. {"TX SMIC MUX1", "SWR_DMIC2", "TX SWR_DMIC2"},
  1849. {"TX SMIC MUX1", "SWR_DMIC3", "TX SWR_DMIC3"},
  1850. {"TX SMIC MUX1", "SWR_DMIC4", "TX SWR_DMIC4"},
  1851. {"TX SMIC MUX1", "SWR_DMIC5", "TX SWR_DMIC5"},
  1852. {"TX SMIC MUX1", "SWR_DMIC6", "TX SWR_DMIC6"},
  1853. {"TX SMIC MUX1", "SWR_DMIC7", "TX SWR_DMIC7"},
  1854. {"TX DEC2 MUX", "MSM_DMIC", "TX DMIC MUX2"},
  1855. {"TX DMIC MUX2", "DMIC0", "TX DMIC0"},
  1856. {"TX DMIC MUX2", "DMIC1", "TX DMIC1"},
  1857. {"TX DMIC MUX2", "DMIC2", "TX DMIC2"},
  1858. {"TX DMIC MUX2", "DMIC3", "TX DMIC3"},
  1859. {"TX DMIC MUX2", "DMIC4", "TX DMIC4"},
  1860. {"TX DMIC MUX2", "DMIC5", "TX DMIC5"},
  1861. {"TX DMIC MUX2", "DMIC6", "TX DMIC6"},
  1862. {"TX DMIC MUX2", "DMIC7", "TX DMIC7"},
  1863. {"TX DEC2 MUX", "SWR_MIC", "TX SMIC MUX2"},
  1864. {"TX SMIC MUX2", NULL, "TX_SWR_CLK"},
  1865. {"TX SMIC MUX2", "ADC0", "TX SWR_ADC0"},
  1866. {"TX SMIC MUX2", "ADC1", "TX SWR_ADC1"},
  1867. {"TX SMIC MUX2", "ADC2", "TX SWR_ADC2"},
  1868. {"TX SMIC MUX2", "ADC3", "TX SWR_ADC3"},
  1869. {"TX SMIC MUX2", "SWR_DMIC0", "TX SWR_DMIC0"},
  1870. {"TX SMIC MUX2", "SWR_DMIC1", "TX SWR_DMIC1"},
  1871. {"TX SMIC MUX2", "SWR_DMIC2", "TX SWR_DMIC2"},
  1872. {"TX SMIC MUX2", "SWR_DMIC3", "TX SWR_DMIC3"},
  1873. {"TX SMIC MUX2", "SWR_DMIC4", "TX SWR_DMIC4"},
  1874. {"TX SMIC MUX2", "SWR_DMIC5", "TX SWR_DMIC5"},
  1875. {"TX SMIC MUX2", "SWR_DMIC6", "TX SWR_DMIC6"},
  1876. {"TX SMIC MUX2", "SWR_DMIC7", "TX SWR_DMIC7"},
  1877. {"TX DEC3 MUX", "MSM_DMIC", "TX DMIC MUX3"},
  1878. {"TX DMIC MUX3", "DMIC0", "TX DMIC0"},
  1879. {"TX DMIC MUX3", "DMIC1", "TX DMIC1"},
  1880. {"TX DMIC MUX3", "DMIC2", "TX DMIC2"},
  1881. {"TX DMIC MUX3", "DMIC3", "TX DMIC3"},
  1882. {"TX DMIC MUX3", "DMIC4", "TX DMIC4"},
  1883. {"TX DMIC MUX3", "DMIC5", "TX DMIC5"},
  1884. {"TX DMIC MUX3", "DMIC6", "TX DMIC6"},
  1885. {"TX DMIC MUX3", "DMIC7", "TX DMIC7"},
  1886. {"TX DEC3 MUX", "SWR_MIC", "TX SMIC MUX3"},
  1887. {"TX SMIC MUX3", NULL, "TX_SWR_CLK"},
  1888. {"TX SMIC MUX3", "ADC0", "TX SWR_ADC0"},
  1889. {"TX SMIC MUX3", "ADC1", "TX SWR_ADC1"},
  1890. {"TX SMIC MUX3", "ADC2", "TX SWR_ADC2"},
  1891. {"TX SMIC MUX3", "ADC3", "TX SWR_ADC3"},
  1892. {"TX SMIC MUX3", "SWR_DMIC0", "TX SWR_DMIC0"},
  1893. {"TX SMIC MUX3", "SWR_DMIC1", "TX SWR_DMIC1"},
  1894. {"TX SMIC MUX3", "SWR_DMIC2", "TX SWR_DMIC2"},
  1895. {"TX SMIC MUX3", "SWR_DMIC3", "TX SWR_DMIC3"},
  1896. {"TX SMIC MUX3", "SWR_DMIC4", "TX SWR_DMIC4"},
  1897. {"TX SMIC MUX3", "SWR_DMIC5", "TX SWR_DMIC5"},
  1898. {"TX SMIC MUX3", "SWR_DMIC6", "TX SWR_DMIC6"},
  1899. {"TX SMIC MUX3", "SWR_DMIC7", "TX SWR_DMIC7"},
  1900. {"TX DEC4 MUX", "MSM_DMIC", "TX DMIC MUX4"},
  1901. {"TX DMIC MUX4", "DMIC0", "TX DMIC0"},
  1902. {"TX DMIC MUX4", "DMIC1", "TX DMIC1"},
  1903. {"TX DMIC MUX4", "DMIC2", "TX DMIC2"},
  1904. {"TX DMIC MUX4", "DMIC3", "TX DMIC3"},
  1905. {"TX DMIC MUX4", "DMIC4", "TX DMIC4"},
  1906. {"TX DMIC MUX4", "DMIC5", "TX DMIC5"},
  1907. {"TX DMIC MUX4", "DMIC6", "TX DMIC6"},
  1908. {"TX DMIC MUX4", "DMIC7", "TX DMIC7"},
  1909. {"TX DEC4 MUX", "SWR_MIC", "TX SMIC MUX4"},
  1910. {"TX SMIC MUX4", NULL, "TX_SWR_CLK"},
  1911. {"TX SMIC MUX4", "ADC0", "TX SWR_ADC0"},
  1912. {"TX SMIC MUX4", "ADC1", "TX SWR_ADC1"},
  1913. {"TX SMIC MUX4", "ADC2", "TX SWR_ADC2"},
  1914. {"TX SMIC MUX4", "ADC3", "TX SWR_ADC3"},
  1915. {"TX SMIC MUX4", "SWR_DMIC0", "TX SWR_DMIC0"},
  1916. {"TX SMIC MUX4", "SWR_DMIC1", "TX SWR_DMIC1"},
  1917. {"TX SMIC MUX4", "SWR_DMIC2", "TX SWR_DMIC2"},
  1918. {"TX SMIC MUX4", "SWR_DMIC3", "TX SWR_DMIC3"},
  1919. {"TX SMIC MUX4", "SWR_DMIC4", "TX SWR_DMIC4"},
  1920. {"TX SMIC MUX4", "SWR_DMIC5", "TX SWR_DMIC5"},
  1921. {"TX SMIC MUX4", "SWR_DMIC6", "TX SWR_DMIC6"},
  1922. {"TX SMIC MUX4", "SWR_DMIC7", "TX SWR_DMIC7"},
  1923. {"TX DEC5 MUX", "MSM_DMIC", "TX DMIC MUX5"},
  1924. {"TX DMIC MUX5", "DMIC0", "TX DMIC0"},
  1925. {"TX DMIC MUX5", "DMIC1", "TX DMIC1"},
  1926. {"TX DMIC MUX5", "DMIC2", "TX DMIC2"},
  1927. {"TX DMIC MUX5", "DMIC3", "TX DMIC3"},
  1928. {"TX DMIC MUX5", "DMIC4", "TX DMIC4"},
  1929. {"TX DMIC MUX5", "DMIC5", "TX DMIC5"},
  1930. {"TX DMIC MUX5", "DMIC6", "TX DMIC6"},
  1931. {"TX DMIC MUX5", "DMIC7", "TX DMIC7"},
  1932. {"TX DEC5 MUX", "SWR_MIC", "TX SMIC MUX5"},
  1933. {"TX SMIC MUX5", NULL, "TX_SWR_CLK"},
  1934. {"TX SMIC MUX5", "ADC0", "TX SWR_ADC0"},
  1935. {"TX SMIC MUX5", "ADC1", "TX SWR_ADC1"},
  1936. {"TX SMIC MUX5", "ADC2", "TX SWR_ADC2"},
  1937. {"TX SMIC MUX5", "ADC3", "TX SWR_ADC3"},
  1938. {"TX SMIC MUX5", "SWR_DMIC0", "TX SWR_DMIC0"},
  1939. {"TX SMIC MUX5", "SWR_DMIC1", "TX SWR_DMIC1"},
  1940. {"TX SMIC MUX5", "SWR_DMIC2", "TX SWR_DMIC2"},
  1941. {"TX SMIC MUX5", "SWR_DMIC3", "TX SWR_DMIC3"},
  1942. {"TX SMIC MUX5", "SWR_DMIC4", "TX SWR_DMIC4"},
  1943. {"TX SMIC MUX5", "SWR_DMIC5", "TX SWR_DMIC5"},
  1944. {"TX SMIC MUX5", "SWR_DMIC6", "TX SWR_DMIC6"},
  1945. {"TX SMIC MUX5", "SWR_DMIC7", "TX SWR_DMIC7"},
  1946. {"TX DEC6 MUX", "MSM_DMIC", "TX DMIC MUX6"},
  1947. {"TX DMIC MUX6", "DMIC0", "TX DMIC0"},
  1948. {"TX DMIC MUX6", "DMIC1", "TX DMIC1"},
  1949. {"TX DMIC MUX6", "DMIC2", "TX DMIC2"},
  1950. {"TX DMIC MUX6", "DMIC3", "TX DMIC3"},
  1951. {"TX DMIC MUX6", "DMIC4", "TX DMIC4"},
  1952. {"TX DMIC MUX6", "DMIC5", "TX DMIC5"},
  1953. {"TX DMIC MUX6", "DMIC6", "TX DMIC6"},
  1954. {"TX DMIC MUX6", "DMIC7", "TX DMIC7"},
  1955. {"TX DEC6 MUX", "SWR_MIC", "TX SMIC MUX6"},
  1956. {"TX SMIC MUX6", NULL, "TX_SWR_CLK"},
  1957. {"TX SMIC MUX6", "ADC0", "TX SWR_ADC0"},
  1958. {"TX SMIC MUX6", "ADC1", "TX SWR_ADC1"},
  1959. {"TX SMIC MUX6", "ADC2", "TX SWR_ADC2"},
  1960. {"TX SMIC MUX6", "ADC3", "TX SWR_ADC3"},
  1961. {"TX SMIC MUX6", "SWR_DMIC0", "TX SWR_DMIC0"},
  1962. {"TX SMIC MUX6", "SWR_DMIC1", "TX SWR_DMIC1"},
  1963. {"TX SMIC MUX6", "SWR_DMIC2", "TX SWR_DMIC2"},
  1964. {"TX SMIC MUX6", "SWR_DMIC3", "TX SWR_DMIC3"},
  1965. {"TX SMIC MUX6", "SWR_DMIC4", "TX SWR_DMIC4"},
  1966. {"TX SMIC MUX6", "SWR_DMIC5", "TX SWR_DMIC5"},
  1967. {"TX SMIC MUX6", "SWR_DMIC6", "TX SWR_DMIC6"},
  1968. {"TX SMIC MUX6", "SWR_DMIC7", "TX SWR_DMIC7"},
  1969. {"TX DEC7 MUX", "MSM_DMIC", "TX DMIC MUX7"},
  1970. {"TX DMIC MUX7", "DMIC0", "TX DMIC0"},
  1971. {"TX DMIC MUX7", "DMIC1", "TX DMIC1"},
  1972. {"TX DMIC MUX7", "DMIC2", "TX DMIC2"},
  1973. {"TX DMIC MUX7", "DMIC3", "TX DMIC3"},
  1974. {"TX DMIC MUX7", "DMIC4", "TX DMIC4"},
  1975. {"TX DMIC MUX7", "DMIC5", "TX DMIC5"},
  1976. {"TX DMIC MUX7", "DMIC6", "TX DMIC6"},
  1977. {"TX DMIC MUX7", "DMIC7", "TX DMIC7"},
  1978. {"TX DEC7 MUX", "SWR_MIC", "TX SMIC MUX7"},
  1979. {"TX SMIC MUX7", NULL, "TX_SWR_CLK"},
  1980. {"TX SMIC MUX7", "ADC0", "TX SWR_ADC0"},
  1981. {"TX SMIC MUX7", "ADC1", "TX SWR_ADC1"},
  1982. {"TX SMIC MUX7", "ADC2", "TX SWR_ADC2"},
  1983. {"TX SMIC MUX7", "ADC3", "TX SWR_ADC3"},
  1984. {"TX SMIC MUX7", "SWR_DMIC0", "TX SWR_DMIC0"},
  1985. {"TX SMIC MUX7", "SWR_DMIC1", "TX SWR_DMIC1"},
  1986. {"TX SMIC MUX7", "SWR_DMIC2", "TX SWR_DMIC2"},
  1987. {"TX SMIC MUX7", "SWR_DMIC3", "TX SWR_DMIC3"},
  1988. {"TX SMIC MUX7", "SWR_DMIC4", "TX SWR_DMIC4"},
  1989. {"TX SMIC MUX7", "SWR_DMIC5", "TX SWR_DMIC5"},
  1990. {"TX SMIC MUX7", "SWR_DMIC6", "TX SWR_DMIC6"},
  1991. {"TX SMIC MUX7", "SWR_DMIC7", "TX SWR_DMIC7"},
  1992. };
  1993. static const struct snd_kcontrol_new tx_macro_snd_controls_common[] = {
  1994. SOC_SINGLE_SX_TLV("TX_DEC0 Volume",
  1995. BOLERO_CDC_TX0_TX_VOL_CTL,
  1996. 0, -84, 40, digital_gain),
  1997. SOC_SINGLE_SX_TLV("TX_DEC1 Volume",
  1998. BOLERO_CDC_TX1_TX_VOL_CTL,
  1999. 0, -84, 40, digital_gain),
  2000. SOC_SINGLE_SX_TLV("TX_DEC2 Volume",
  2001. BOLERO_CDC_TX2_TX_VOL_CTL,
  2002. 0, -84, 40, digital_gain),
  2003. SOC_SINGLE_SX_TLV("TX_DEC3 Volume",
  2004. BOLERO_CDC_TX3_TX_VOL_CTL,
  2005. 0, -84, 40, digital_gain),
  2006. SOC_ENUM_EXT("DEC0 MODE", dec_mode_mux_enum,
  2007. tx_macro_dec_mode_get, tx_macro_dec_mode_put),
  2008. SOC_ENUM_EXT("DEC1 MODE", dec_mode_mux_enum,
  2009. tx_macro_dec_mode_get, tx_macro_dec_mode_put),
  2010. SOC_ENUM_EXT("DEC2 MODE", dec_mode_mux_enum,
  2011. tx_macro_dec_mode_get, tx_macro_dec_mode_put),
  2012. SOC_ENUM_EXT("DEC3 MODE", dec_mode_mux_enum,
  2013. tx_macro_dec_mode_get, tx_macro_dec_mode_put),
  2014. SOC_SINGLE_EXT("DEC0_BCS Switch", SND_SOC_NOPM, 0, 1, 0,
  2015. tx_macro_get_bcs, tx_macro_set_bcs),
  2016. SOC_ENUM_EXT("BCS Channel", bcs_ch_enum,
  2017. tx_macro_bcs_ch_get, tx_macro_bcs_ch_put),
  2018. };
  2019. static const struct snd_kcontrol_new tx_macro_snd_controls_v3[] = {
  2020. SOC_SINGLE_SX_TLV("TX_DEC4 Volume",
  2021. BOLERO_CDC_TX4_TX_VOL_CTL,
  2022. 0, -84, 40, digital_gain),
  2023. SOC_SINGLE_SX_TLV("TX_DEC5 Volume",
  2024. BOLERO_CDC_TX5_TX_VOL_CTL,
  2025. 0, -84, 40, digital_gain),
  2026. SOC_SINGLE_SX_TLV("TX_DEC6 Volume",
  2027. BOLERO_CDC_TX6_TX_VOL_CTL,
  2028. 0, -84, 40, digital_gain),
  2029. SOC_SINGLE_SX_TLV("TX_DEC7 Volume",
  2030. BOLERO_CDC_TX7_TX_VOL_CTL,
  2031. 0, -84, 40, digital_gain),
  2032. SOC_ENUM_EXT("DEC4 MODE", dec_mode_mux_enum,
  2033. tx_macro_dec_mode_get, tx_macro_dec_mode_put),
  2034. SOC_ENUM_EXT("DEC5 MODE", dec_mode_mux_enum,
  2035. tx_macro_dec_mode_get, tx_macro_dec_mode_put),
  2036. SOC_ENUM_EXT("DEC6 MODE", dec_mode_mux_enum,
  2037. tx_macro_dec_mode_get, tx_macro_dec_mode_put),
  2038. SOC_ENUM_EXT("DEC7 MODE", dec_mode_mux_enum,
  2039. tx_macro_dec_mode_get, tx_macro_dec_mode_put),
  2040. };
  2041. static const struct snd_kcontrol_new tx_macro_snd_controls[] = {
  2042. SOC_SINGLE_SX_TLV("TX_DEC0 Volume",
  2043. BOLERO_CDC_TX0_TX_VOL_CTL,
  2044. 0, -84, 40, digital_gain),
  2045. SOC_SINGLE_SX_TLV("TX_DEC1 Volume",
  2046. BOLERO_CDC_TX1_TX_VOL_CTL,
  2047. 0, -84, 40, digital_gain),
  2048. SOC_SINGLE_SX_TLV("TX_DEC2 Volume",
  2049. BOLERO_CDC_TX2_TX_VOL_CTL,
  2050. 0, -84, 40, digital_gain),
  2051. SOC_SINGLE_SX_TLV("TX_DEC3 Volume",
  2052. BOLERO_CDC_TX3_TX_VOL_CTL,
  2053. 0, -84, 40, digital_gain),
  2054. SOC_SINGLE_SX_TLV("TX_DEC4 Volume",
  2055. BOLERO_CDC_TX4_TX_VOL_CTL,
  2056. 0, -84, 40, digital_gain),
  2057. SOC_SINGLE_SX_TLV("TX_DEC5 Volume",
  2058. BOLERO_CDC_TX5_TX_VOL_CTL,
  2059. 0, -84, 40, digital_gain),
  2060. SOC_SINGLE_SX_TLV("TX_DEC6 Volume",
  2061. BOLERO_CDC_TX6_TX_VOL_CTL,
  2062. 0, -84, 40, digital_gain),
  2063. SOC_SINGLE_SX_TLV("TX_DEC7 Volume",
  2064. BOLERO_CDC_TX7_TX_VOL_CTL,
  2065. 0, -84, 40, digital_gain),
  2066. SOC_ENUM_EXT("DEC0 MODE", dec_mode_mux_enum,
  2067. tx_macro_dec_mode_get, tx_macro_dec_mode_put),
  2068. SOC_ENUM_EXT("DEC1 MODE", dec_mode_mux_enum,
  2069. tx_macro_dec_mode_get, tx_macro_dec_mode_put),
  2070. SOC_ENUM_EXT("DEC2 MODE", dec_mode_mux_enum,
  2071. tx_macro_dec_mode_get, tx_macro_dec_mode_put),
  2072. SOC_ENUM_EXT("DEC3 MODE", dec_mode_mux_enum,
  2073. tx_macro_dec_mode_get, tx_macro_dec_mode_put),
  2074. SOC_ENUM_EXT("DEC4 MODE", dec_mode_mux_enum,
  2075. tx_macro_dec_mode_get, tx_macro_dec_mode_put),
  2076. SOC_ENUM_EXT("DEC5 MODE", dec_mode_mux_enum,
  2077. tx_macro_dec_mode_get, tx_macro_dec_mode_put),
  2078. SOC_ENUM_EXT("DEC6 MODE", dec_mode_mux_enum,
  2079. tx_macro_dec_mode_get, tx_macro_dec_mode_put),
  2080. SOC_ENUM_EXT("DEC7 MODE", dec_mode_mux_enum,
  2081. tx_macro_dec_mode_get, tx_macro_dec_mode_put),
  2082. SOC_SINGLE_EXT("DEC0_BCS Switch", SND_SOC_NOPM, 0, 1, 0,
  2083. tx_macro_get_bcs, tx_macro_set_bcs),
  2084. };
  2085. static int tx_macro_register_event_listener(struct snd_soc_component *component,
  2086. bool enable)
  2087. {
  2088. struct device *tx_dev = NULL;
  2089. struct tx_macro_priv *tx_priv = NULL;
  2090. int ret = 0;
  2091. if (!component)
  2092. return -EINVAL;
  2093. tx_dev = bolero_get_device_ptr(component->dev, TX_MACRO);
  2094. if (!tx_dev) {
  2095. dev_err(component->dev,
  2096. "%s: null device for macro!\n", __func__);
  2097. return -EINVAL;
  2098. }
  2099. tx_priv = dev_get_drvdata(tx_dev);
  2100. if (!tx_priv) {
  2101. dev_err(component->dev,
  2102. "%s: priv is null for macro!\n", __func__);
  2103. return -EINVAL;
  2104. }
  2105. if (tx_priv->swr_ctrl_data) {
  2106. if (enable) {
  2107. ret = swrm_wcd_notify(
  2108. tx_priv->swr_ctrl_data[0].tx_swr_pdev,
  2109. SWR_REGISTER_WAKEUP, NULL);
  2110. msm_cdc_pinctrl_set_wakeup_capable(
  2111. tx_priv->tx_swr_gpio_p, false);
  2112. } else {
  2113. msm_cdc_pinctrl_set_wakeup_capable(
  2114. tx_priv->tx_swr_gpio_p, true);
  2115. ret = swrm_wcd_notify(
  2116. tx_priv->swr_ctrl_data[0].tx_swr_pdev,
  2117. SWR_DEREGISTER_WAKEUP, NULL);
  2118. }
  2119. }
  2120. return ret;
  2121. }
  2122. static int tx_macro_tx_va_mclk_enable(struct tx_macro_priv *tx_priv,
  2123. struct regmap *regmap, int clk_type,
  2124. bool enable)
  2125. {
  2126. int ret = 0, clk_tx_ret = 0;
  2127. dev_dbg(tx_priv->dev,
  2128. "%s: clock type %s, enable: %s tx_mclk_users: %d\n",
  2129. __func__, (clk_type ? "VA_MCLK" : "TX_MCLK"),
  2130. (enable ? "enable" : "disable"), tx_priv->tx_mclk_users);
  2131. if (enable) {
  2132. if (tx_priv->swr_clk_users == 0) {
  2133. ret = msm_cdc_pinctrl_select_active_state(
  2134. tx_priv->tx_swr_gpio_p);
  2135. if (ret < 0) {
  2136. dev_err_ratelimited(tx_priv->dev,
  2137. "%s: tx swr pinctrl enable failed\n",
  2138. __func__);
  2139. goto exit;
  2140. }
  2141. }
  2142. clk_tx_ret = bolero_clk_rsc_request_clock(tx_priv->dev,
  2143. TX_CORE_CLK,
  2144. TX_CORE_CLK,
  2145. true);
  2146. if (clk_type == TX_MCLK) {
  2147. ret = tx_macro_mclk_enable(tx_priv, 1);
  2148. if (ret < 0) {
  2149. if (tx_priv->swr_clk_users == 0)
  2150. msm_cdc_pinctrl_select_sleep_state(
  2151. tx_priv->tx_swr_gpio_p);
  2152. dev_err_ratelimited(tx_priv->dev,
  2153. "%s: request clock enable failed\n",
  2154. __func__);
  2155. goto done;
  2156. }
  2157. }
  2158. if (clk_type == VA_MCLK) {
  2159. ret = bolero_clk_rsc_request_clock(tx_priv->dev,
  2160. TX_CORE_CLK,
  2161. VA_CORE_CLK,
  2162. true);
  2163. if (ret < 0) {
  2164. if (tx_priv->swr_clk_users == 0)
  2165. msm_cdc_pinctrl_select_sleep_state(
  2166. tx_priv->tx_swr_gpio_p);
  2167. dev_err_ratelimited(tx_priv->dev,
  2168. "%s: swr request clk failed\n",
  2169. __func__);
  2170. goto done;
  2171. }
  2172. bolero_clk_rsc_fs_gen_request(tx_priv->dev,
  2173. true);
  2174. if (tx_priv->tx_mclk_users == 0) {
  2175. regmap_update_bits(regmap,
  2176. BOLERO_CDC_TX_TOP_CSR_FREQ_MCLK,
  2177. 0x01, 0x01);
  2178. regmap_update_bits(regmap,
  2179. BOLERO_CDC_TX_CLK_RST_CTRL_MCLK_CONTROL,
  2180. 0x01, 0x01);
  2181. regmap_update_bits(regmap,
  2182. BOLERO_CDC_TX_CLK_RST_CTRL_FS_CNT_CONTROL,
  2183. 0x01, 0x01);
  2184. }
  2185. }
  2186. if (tx_priv->swr_clk_users == 0) {
  2187. dev_dbg(tx_priv->dev, "%s: reset_swr: %d\n",
  2188. __func__, tx_priv->reset_swr);
  2189. if (tx_priv->reset_swr)
  2190. regmap_update_bits(regmap,
  2191. BOLERO_CDC_TX_CLK_RST_CTRL_SWR_CONTROL,
  2192. 0x02, 0x02);
  2193. regmap_update_bits(regmap,
  2194. BOLERO_CDC_TX_CLK_RST_CTRL_SWR_CONTROL,
  2195. 0x01, 0x01);
  2196. if (tx_priv->reset_swr)
  2197. regmap_update_bits(regmap,
  2198. BOLERO_CDC_TX_CLK_RST_CTRL_SWR_CONTROL,
  2199. 0x02, 0x00);
  2200. tx_priv->reset_swr = false;
  2201. }
  2202. if (!clk_tx_ret)
  2203. ret = bolero_clk_rsc_request_clock(tx_priv->dev,
  2204. TX_CORE_CLK,
  2205. TX_CORE_CLK,
  2206. false);
  2207. tx_priv->swr_clk_users++;
  2208. } else {
  2209. if (tx_priv->swr_clk_users <= 0) {
  2210. dev_err_ratelimited(tx_priv->dev,
  2211. "tx swrm clock users already 0\n");
  2212. tx_priv->swr_clk_users = 0;
  2213. return 0;
  2214. }
  2215. clk_tx_ret = bolero_clk_rsc_request_clock(tx_priv->dev,
  2216. TX_CORE_CLK,
  2217. TX_CORE_CLK,
  2218. true);
  2219. tx_priv->swr_clk_users--;
  2220. if (tx_priv->swr_clk_users == 0)
  2221. regmap_update_bits(regmap,
  2222. BOLERO_CDC_TX_CLK_RST_CTRL_SWR_CONTROL,
  2223. 0x01, 0x00);
  2224. if (clk_type == TX_MCLK)
  2225. tx_macro_mclk_enable(tx_priv, 0);
  2226. if (clk_type == VA_MCLK) {
  2227. if (tx_priv->tx_mclk_users == 0) {
  2228. regmap_update_bits(regmap,
  2229. BOLERO_CDC_TX_CLK_RST_CTRL_FS_CNT_CONTROL,
  2230. 0x01, 0x00);
  2231. regmap_update_bits(regmap,
  2232. BOLERO_CDC_TX_CLK_RST_CTRL_MCLK_CONTROL,
  2233. 0x01, 0x00);
  2234. }
  2235. bolero_clk_rsc_fs_gen_request(tx_priv->dev,
  2236. false);
  2237. ret = bolero_clk_rsc_request_clock(tx_priv->dev,
  2238. TX_CORE_CLK,
  2239. VA_CORE_CLK,
  2240. false);
  2241. if (ret < 0) {
  2242. dev_err_ratelimited(tx_priv->dev,
  2243. "%s: swr request clk failed\n",
  2244. __func__);
  2245. goto done;
  2246. }
  2247. }
  2248. if (!clk_tx_ret)
  2249. ret = bolero_clk_rsc_request_clock(tx_priv->dev,
  2250. TX_CORE_CLK,
  2251. TX_CORE_CLK,
  2252. false);
  2253. if (tx_priv->swr_clk_users == 0) {
  2254. ret = msm_cdc_pinctrl_select_sleep_state(
  2255. tx_priv->tx_swr_gpio_p);
  2256. if (ret < 0) {
  2257. dev_err_ratelimited(tx_priv->dev,
  2258. "%s: tx swr pinctrl disable failed\n",
  2259. __func__);
  2260. goto exit;
  2261. }
  2262. }
  2263. }
  2264. return 0;
  2265. done:
  2266. if (!clk_tx_ret)
  2267. bolero_clk_rsc_request_clock(tx_priv->dev,
  2268. TX_CORE_CLK,
  2269. TX_CORE_CLK,
  2270. false);
  2271. exit:
  2272. return ret;
  2273. }
  2274. static int tx_macro_clk_switch(struct snd_soc_component *component)
  2275. {
  2276. struct device *tx_dev = NULL;
  2277. struct tx_macro_priv *tx_priv = NULL;
  2278. int ret = 0;
  2279. if (!component)
  2280. return -EINVAL;
  2281. tx_dev = bolero_get_device_ptr(component->dev, TX_MACRO);
  2282. if (!tx_dev) {
  2283. dev_err(component->dev,
  2284. "%s: null device for macro!\n", __func__);
  2285. return -EINVAL;
  2286. }
  2287. tx_priv = dev_get_drvdata(tx_dev);
  2288. if (!tx_priv) {
  2289. dev_err(component->dev,
  2290. "%s: priv is null for macro!\n", __func__);
  2291. return -EINVAL;
  2292. }
  2293. if (tx_priv->swr_ctrl_data) {
  2294. ret = swrm_wcd_notify(
  2295. tx_priv->swr_ctrl_data[0].tx_swr_pdev,
  2296. SWR_REQ_CLK_SWITCH, NULL);
  2297. }
  2298. return ret;
  2299. }
  2300. static int tx_macro_core_vote(void *handle, bool enable)
  2301. {
  2302. struct tx_macro_priv *tx_priv = (struct tx_macro_priv *) handle;
  2303. if (tx_priv == NULL) {
  2304. pr_err("%s: tx priv data is NULL\n", __func__);
  2305. return -EINVAL;
  2306. }
  2307. if (enable) {
  2308. pm_runtime_get_sync(tx_priv->dev);
  2309. pm_runtime_put_autosuspend(tx_priv->dev);
  2310. pm_runtime_mark_last_busy(tx_priv->dev);
  2311. }
  2312. if (bolero_check_core_votes(tx_priv->dev))
  2313. return 0;
  2314. else
  2315. return -EINVAL;
  2316. }
  2317. static int tx_macro_swrm_clock(void *handle, bool enable)
  2318. {
  2319. struct tx_macro_priv *tx_priv = (struct tx_macro_priv *) handle;
  2320. struct regmap *regmap = dev_get_regmap(tx_priv->dev->parent, NULL);
  2321. int ret = 0;
  2322. if (regmap == NULL) {
  2323. dev_err(tx_priv->dev, "%s: regmap is NULL\n", __func__);
  2324. return -EINVAL;
  2325. }
  2326. mutex_lock(&tx_priv->swr_clk_lock);
  2327. dev_dbg(tx_priv->dev,
  2328. "%s: swrm clock %s tx_swr_clk_cnt: %d va_swr_clk_cnt: %d\n",
  2329. __func__, (enable ? "enable" : "disable"),
  2330. tx_priv->tx_swr_clk_cnt, tx_priv->va_swr_clk_cnt);
  2331. if (enable) {
  2332. pm_runtime_get_sync(tx_priv->dev);
  2333. if (tx_priv->va_swr_clk_cnt && !tx_priv->tx_swr_clk_cnt) {
  2334. ret = tx_macro_tx_va_mclk_enable(tx_priv, regmap,
  2335. VA_MCLK, enable);
  2336. if (ret) {
  2337. pm_runtime_mark_last_busy(tx_priv->dev);
  2338. pm_runtime_put_autosuspend(tx_priv->dev);
  2339. goto done;
  2340. }
  2341. tx_priv->va_clk_status++;
  2342. } else {
  2343. ret = tx_macro_tx_va_mclk_enable(tx_priv, regmap,
  2344. TX_MCLK, enable);
  2345. if (ret) {
  2346. pm_runtime_mark_last_busy(tx_priv->dev);
  2347. pm_runtime_put_autosuspend(tx_priv->dev);
  2348. goto done;
  2349. }
  2350. tx_priv->tx_clk_status++;
  2351. }
  2352. pm_runtime_mark_last_busy(tx_priv->dev);
  2353. pm_runtime_put_autosuspend(tx_priv->dev);
  2354. } else {
  2355. if (tx_priv->va_clk_status && !tx_priv->tx_clk_status) {
  2356. ret = tx_macro_tx_va_mclk_enable(tx_priv, regmap,
  2357. VA_MCLK, enable);
  2358. if (ret)
  2359. goto done;
  2360. --tx_priv->va_clk_status;
  2361. } else if (!tx_priv->va_clk_status && tx_priv->tx_clk_status) {
  2362. ret = tx_macro_tx_va_mclk_enable(tx_priv, regmap,
  2363. TX_MCLK, enable);
  2364. if (ret)
  2365. goto done;
  2366. --tx_priv->tx_clk_status;
  2367. } else if (tx_priv->va_clk_status && tx_priv->tx_clk_status) {
  2368. if (!tx_priv->va_swr_clk_cnt && tx_priv->tx_swr_clk_cnt) {
  2369. ret = tx_macro_tx_va_mclk_enable(tx_priv, regmap,
  2370. VA_MCLK, enable);
  2371. if (ret)
  2372. goto done;
  2373. --tx_priv->va_clk_status;
  2374. } else {
  2375. ret = tx_macro_tx_va_mclk_enable(tx_priv, regmap,
  2376. TX_MCLK, enable);
  2377. if (ret)
  2378. goto done;
  2379. --tx_priv->tx_clk_status;
  2380. }
  2381. } else {
  2382. dev_dbg(tx_priv->dev,
  2383. "%s: Both clocks are disabled\n", __func__);
  2384. }
  2385. }
  2386. dev_dbg(tx_priv->dev,
  2387. "%s: swrm clock users %d tx_clk_sts_cnt: %d va_clk_sts_cnt: %d\n",
  2388. __func__, tx_priv->swr_clk_users, tx_priv->tx_clk_status,
  2389. tx_priv->va_clk_status);
  2390. done:
  2391. mutex_unlock(&tx_priv->swr_clk_lock);
  2392. return ret;
  2393. }
  2394. static int tx_macro_validate_dmic_sample_rate(u32 dmic_sample_rate,
  2395. struct tx_macro_priv *tx_priv)
  2396. {
  2397. u32 div_factor = TX_MACRO_CLK_DIV_2;
  2398. u32 mclk_rate = TX_MACRO_MCLK_FREQ;
  2399. if (dmic_sample_rate == TX_MACRO_DMIC_SAMPLE_RATE_UNDEFINED ||
  2400. mclk_rate % dmic_sample_rate != 0)
  2401. goto undefined_rate;
  2402. div_factor = mclk_rate / dmic_sample_rate;
  2403. switch (div_factor) {
  2404. case 2:
  2405. tx_priv->dmic_clk_div = TX_MACRO_CLK_DIV_2;
  2406. break;
  2407. case 3:
  2408. tx_priv->dmic_clk_div = TX_MACRO_CLK_DIV_3;
  2409. break;
  2410. case 4:
  2411. tx_priv->dmic_clk_div = TX_MACRO_CLK_DIV_4;
  2412. break;
  2413. case 6:
  2414. tx_priv->dmic_clk_div = TX_MACRO_CLK_DIV_6;
  2415. break;
  2416. case 8:
  2417. tx_priv->dmic_clk_div = TX_MACRO_CLK_DIV_8;
  2418. break;
  2419. case 16:
  2420. tx_priv->dmic_clk_div = TX_MACRO_CLK_DIV_16;
  2421. break;
  2422. default:
  2423. /* Any other DIV factor is invalid */
  2424. goto undefined_rate;
  2425. }
  2426. /* Valid dmic DIV factors */
  2427. dev_dbg(tx_priv->dev, "%s: DMIC_DIV = %u, mclk_rate = %u\n",
  2428. __func__, div_factor, mclk_rate);
  2429. return dmic_sample_rate;
  2430. undefined_rate:
  2431. dev_dbg(tx_priv->dev, "%s: Invalid rate %d, for mclk %d\n",
  2432. __func__, dmic_sample_rate, mclk_rate);
  2433. dmic_sample_rate = TX_MACRO_DMIC_SAMPLE_RATE_UNDEFINED;
  2434. return dmic_sample_rate;
  2435. }
  2436. static const struct tx_macro_reg_mask_val tx_macro_reg_init[] = {
  2437. {BOLERO_CDC_TX0_TX_PATH_SEC7, 0x3F, 0x02},
  2438. };
  2439. static int tx_macro_init(struct snd_soc_component *component)
  2440. {
  2441. struct snd_soc_dapm_context *dapm =
  2442. snd_soc_component_get_dapm(component);
  2443. int ret = 0, i = 0;
  2444. struct device *tx_dev = NULL;
  2445. struct tx_macro_priv *tx_priv = NULL;
  2446. tx_dev = bolero_get_device_ptr(component->dev, TX_MACRO);
  2447. if (!tx_dev) {
  2448. dev_err(component->dev,
  2449. "%s: null device for macro!\n", __func__);
  2450. return -EINVAL;
  2451. }
  2452. tx_priv = dev_get_drvdata(tx_dev);
  2453. if (!tx_priv) {
  2454. dev_err(component->dev,
  2455. "%s: priv is null for macro!\n", __func__);
  2456. return -EINVAL;
  2457. }
  2458. tx_priv->version = bolero_get_version(tx_dev);
  2459. if (tx_priv->version >= BOLERO_VERSION_2_0) {
  2460. ret = snd_soc_dapm_new_controls(dapm,
  2461. tx_macro_dapm_widgets_common,
  2462. ARRAY_SIZE(tx_macro_dapm_widgets_common));
  2463. if (ret < 0) {
  2464. dev_err(tx_dev, "%s: Failed to add controls\n",
  2465. __func__);
  2466. return ret;
  2467. }
  2468. if (tx_priv->version == BOLERO_VERSION_2_1)
  2469. ret = snd_soc_dapm_new_controls(dapm,
  2470. tx_macro_dapm_widgets_v2,
  2471. ARRAY_SIZE(tx_macro_dapm_widgets_v2));
  2472. else if (tx_priv->version == BOLERO_VERSION_2_0)
  2473. ret = snd_soc_dapm_new_controls(dapm,
  2474. tx_macro_dapm_widgets_v3,
  2475. ARRAY_SIZE(tx_macro_dapm_widgets_v3));
  2476. if (ret < 0) {
  2477. dev_err(tx_dev, "%s: Failed to add controls\n",
  2478. __func__);
  2479. return ret;
  2480. }
  2481. } else {
  2482. ret = snd_soc_dapm_new_controls(dapm, tx_macro_dapm_widgets,
  2483. ARRAY_SIZE(tx_macro_dapm_widgets));
  2484. if (ret < 0) {
  2485. dev_err(tx_dev, "%s: Failed to add controls\n",
  2486. __func__);
  2487. return ret;
  2488. }
  2489. }
  2490. if (tx_priv->version >= BOLERO_VERSION_2_0) {
  2491. ret = snd_soc_dapm_add_routes(dapm,
  2492. tx_audio_map_common,
  2493. ARRAY_SIZE(tx_audio_map_common));
  2494. if (ret < 0) {
  2495. dev_err(tx_dev, "%s: Failed to add routes\n",
  2496. __func__);
  2497. return ret;
  2498. }
  2499. if (tx_priv->version == BOLERO_VERSION_2_0)
  2500. ret = snd_soc_dapm_add_routes(dapm,
  2501. tx_audio_map_v3,
  2502. ARRAY_SIZE(tx_audio_map_v3));
  2503. if (ret < 0) {
  2504. dev_err(tx_dev, "%s: Failed to add routes\n",
  2505. __func__);
  2506. return ret;
  2507. }
  2508. } else {
  2509. ret = snd_soc_dapm_add_routes(dapm, tx_audio_map,
  2510. ARRAY_SIZE(tx_audio_map));
  2511. if (ret < 0) {
  2512. dev_err(tx_dev, "%s: Failed to add routes\n",
  2513. __func__);
  2514. return ret;
  2515. }
  2516. }
  2517. ret = snd_soc_dapm_new_widgets(dapm->card);
  2518. if (ret < 0) {
  2519. dev_err(tx_dev, "%s: Failed to add widgets\n", __func__);
  2520. return ret;
  2521. }
  2522. if (tx_priv->version >= BOLERO_VERSION_2_0) {
  2523. ret = snd_soc_add_component_controls(component,
  2524. tx_macro_snd_controls_common,
  2525. ARRAY_SIZE(tx_macro_snd_controls_common));
  2526. if (ret < 0) {
  2527. dev_err(tx_dev, "%s: Failed to add snd_ctls\n",
  2528. __func__);
  2529. return ret;
  2530. }
  2531. if (tx_priv->version == BOLERO_VERSION_2_0)
  2532. ret = snd_soc_add_component_controls(component,
  2533. tx_macro_snd_controls_v3,
  2534. ARRAY_SIZE(tx_macro_snd_controls_v3));
  2535. if (ret < 0) {
  2536. dev_err(tx_dev, "%s: Failed to add snd_ctls\n",
  2537. __func__);
  2538. return ret;
  2539. }
  2540. } else {
  2541. ret = snd_soc_add_component_controls(component,
  2542. tx_macro_snd_controls,
  2543. ARRAY_SIZE(tx_macro_snd_controls));
  2544. if (ret < 0) {
  2545. dev_err(tx_dev, "%s: Failed to add snd_ctls\n",
  2546. __func__);
  2547. return ret;
  2548. }
  2549. }
  2550. snd_soc_dapm_ignore_suspend(dapm, "TX_AIF1 Capture");
  2551. snd_soc_dapm_ignore_suspend(dapm, "TX_AIF2 Capture");
  2552. snd_soc_dapm_ignore_suspend(dapm, "TX_AIF3 Capture");
  2553. if (tx_priv->version >= BOLERO_VERSION_2_0) {
  2554. snd_soc_dapm_ignore_suspend(dapm, "TX SWR_MIC0");
  2555. snd_soc_dapm_ignore_suspend(dapm, "TX SWR_MIC1");
  2556. snd_soc_dapm_ignore_suspend(dapm, "TX SWR_MIC2");
  2557. snd_soc_dapm_ignore_suspend(dapm, "TX SWR_MIC3");
  2558. snd_soc_dapm_ignore_suspend(dapm, "TX SWR_MIC4");
  2559. snd_soc_dapm_ignore_suspend(dapm, "TX SWR_MIC5");
  2560. snd_soc_dapm_ignore_suspend(dapm, "TX SWR_MIC6");
  2561. snd_soc_dapm_ignore_suspend(dapm, "TX SWR_MIC7");
  2562. snd_soc_dapm_ignore_suspend(dapm, "TX SWR_MIC8");
  2563. snd_soc_dapm_ignore_suspend(dapm, "TX SWR_MIC9");
  2564. snd_soc_dapm_ignore_suspend(dapm, "TX SWR_MIC10");
  2565. snd_soc_dapm_ignore_suspend(dapm, "TX SWR_MIC11");
  2566. } else {
  2567. snd_soc_dapm_ignore_suspend(dapm, "TX SWR_ADC0");
  2568. snd_soc_dapm_ignore_suspend(dapm, "TX SWR_ADC1");
  2569. snd_soc_dapm_ignore_suspend(dapm, "TX SWR_ADC2");
  2570. snd_soc_dapm_ignore_suspend(dapm, "TX SWR_ADC3");
  2571. snd_soc_dapm_ignore_suspend(dapm, "TX SWR_DMIC0");
  2572. snd_soc_dapm_ignore_suspend(dapm, "TX SWR_DMIC1");
  2573. snd_soc_dapm_ignore_suspend(dapm, "TX SWR_DMIC2");
  2574. snd_soc_dapm_ignore_suspend(dapm, "TX SWR_DMIC3");
  2575. snd_soc_dapm_ignore_suspend(dapm, "TX SWR_DMIC4");
  2576. snd_soc_dapm_ignore_suspend(dapm, "TX SWR_DMIC5");
  2577. snd_soc_dapm_ignore_suspend(dapm, "TX SWR_DMIC6");
  2578. snd_soc_dapm_ignore_suspend(dapm, "TX SWR_DMIC7");
  2579. }
  2580. snd_soc_dapm_sync(dapm);
  2581. for (i = 0; i < NUM_DECIMATORS; i++) {
  2582. tx_priv->tx_hpf_work[i].tx_priv = tx_priv;
  2583. tx_priv->tx_hpf_work[i].decimator = i;
  2584. INIT_DELAYED_WORK(&tx_priv->tx_hpf_work[i].dwork,
  2585. tx_macro_tx_hpf_corner_freq_callback);
  2586. }
  2587. for (i = 0; i < NUM_DECIMATORS; i++) {
  2588. tx_priv->tx_mute_dwork[i].tx_priv = tx_priv;
  2589. tx_priv->tx_mute_dwork[i].decimator = i;
  2590. INIT_DELAYED_WORK(&tx_priv->tx_mute_dwork[i].dwork,
  2591. tx_macro_mute_update_callback);
  2592. }
  2593. tx_priv->component = component;
  2594. for (i = 0; i < ARRAY_SIZE(tx_macro_reg_init); i++)
  2595. snd_soc_component_update_bits(component,
  2596. tx_macro_reg_init[i].reg,
  2597. tx_macro_reg_init[i].mask,
  2598. tx_macro_reg_init[i].val);
  2599. return 0;
  2600. }
  2601. static int tx_macro_deinit(struct snd_soc_component *component)
  2602. {
  2603. struct device *tx_dev = NULL;
  2604. struct tx_macro_priv *tx_priv = NULL;
  2605. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  2606. return -EINVAL;
  2607. tx_priv->component = NULL;
  2608. return 0;
  2609. }
  2610. static void tx_macro_add_child_devices(struct work_struct *work)
  2611. {
  2612. struct tx_macro_priv *tx_priv = NULL;
  2613. struct platform_device *pdev = NULL;
  2614. struct device_node *node = NULL;
  2615. struct tx_macro_swr_ctrl_data *swr_ctrl_data = NULL, *temp = NULL;
  2616. int ret = 0;
  2617. u16 count = 0, ctrl_num = 0;
  2618. struct tx_macro_swr_ctrl_platform_data *platdata = NULL;
  2619. char plat_dev_name[TX_MACRO_SWR_STRING_LEN] = "";
  2620. bool tx_swr_master_node = false;
  2621. tx_priv = container_of(work, struct tx_macro_priv,
  2622. tx_macro_add_child_devices_work);
  2623. if (!tx_priv) {
  2624. pr_err("%s: Memory for tx_priv does not exist\n",
  2625. __func__);
  2626. return;
  2627. }
  2628. if (!tx_priv->dev) {
  2629. pr_err("%s: tx dev does not exist\n", __func__);
  2630. return;
  2631. }
  2632. if (!tx_priv->dev->of_node) {
  2633. dev_err(tx_priv->dev,
  2634. "%s: DT node for tx_priv does not exist\n", __func__);
  2635. return;
  2636. }
  2637. platdata = &tx_priv->swr_plat_data;
  2638. tx_priv->child_count = 0;
  2639. for_each_available_child_of_node(tx_priv->dev->of_node, node) {
  2640. tx_swr_master_node = false;
  2641. if (strnstr(node->name, "tx_swr_master",
  2642. strlen("tx_swr_master")) != NULL)
  2643. tx_swr_master_node = true;
  2644. if (tx_swr_master_node)
  2645. strlcpy(plat_dev_name, "tx_swr_ctrl",
  2646. (TX_MACRO_SWR_STRING_LEN - 1));
  2647. else
  2648. strlcpy(plat_dev_name, node->name,
  2649. (TX_MACRO_SWR_STRING_LEN - 1));
  2650. pdev = platform_device_alloc(plat_dev_name, -1);
  2651. if (!pdev) {
  2652. dev_err(tx_priv->dev, "%s: pdev memory alloc failed\n",
  2653. __func__);
  2654. ret = -ENOMEM;
  2655. goto err;
  2656. }
  2657. pdev->dev.parent = tx_priv->dev;
  2658. pdev->dev.of_node = node;
  2659. if (tx_swr_master_node) {
  2660. ret = platform_device_add_data(pdev, platdata,
  2661. sizeof(*platdata));
  2662. if (ret) {
  2663. dev_err(&pdev->dev,
  2664. "%s: cannot add plat data ctrl:%d\n",
  2665. __func__, ctrl_num);
  2666. goto fail_pdev_add;
  2667. }
  2668. }
  2669. ret = platform_device_add(pdev);
  2670. if (ret) {
  2671. dev_err(&pdev->dev,
  2672. "%s: Cannot add platform device\n",
  2673. __func__);
  2674. goto fail_pdev_add;
  2675. }
  2676. if (tx_swr_master_node) {
  2677. temp = krealloc(swr_ctrl_data,
  2678. (ctrl_num + 1) * sizeof(
  2679. struct tx_macro_swr_ctrl_data),
  2680. GFP_KERNEL);
  2681. if (!temp) {
  2682. ret = -ENOMEM;
  2683. goto fail_pdev_add;
  2684. }
  2685. swr_ctrl_data = temp;
  2686. swr_ctrl_data[ctrl_num].tx_swr_pdev = pdev;
  2687. ctrl_num++;
  2688. dev_dbg(&pdev->dev,
  2689. "%s: Added soundwire ctrl device(s)\n",
  2690. __func__);
  2691. tx_priv->swr_ctrl_data = swr_ctrl_data;
  2692. }
  2693. if (tx_priv->child_count < TX_MACRO_CHILD_DEVICES_MAX)
  2694. tx_priv->pdev_child_devices[
  2695. tx_priv->child_count++] = pdev;
  2696. else
  2697. goto err;
  2698. }
  2699. return;
  2700. fail_pdev_add:
  2701. for (count = 0; count < tx_priv->child_count; count++)
  2702. platform_device_put(tx_priv->pdev_child_devices[count]);
  2703. err:
  2704. return;
  2705. }
  2706. static int tx_macro_set_port_map(struct snd_soc_component *component,
  2707. u32 usecase, u32 size, void *data)
  2708. {
  2709. struct device *tx_dev = NULL;
  2710. struct tx_macro_priv *tx_priv = NULL;
  2711. struct swrm_port_config port_cfg;
  2712. int ret = 0;
  2713. if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
  2714. return -EINVAL;
  2715. memset(&port_cfg, 0, sizeof(port_cfg));
  2716. port_cfg.uc = usecase;
  2717. port_cfg.size = size;
  2718. port_cfg.params = data;
  2719. if (tx_priv->swr_ctrl_data)
  2720. ret = swrm_wcd_notify(
  2721. tx_priv->swr_ctrl_data[0].tx_swr_pdev,
  2722. SWR_SET_PORT_MAP, &port_cfg);
  2723. return ret;
  2724. }
  2725. static void tx_macro_init_ops(struct macro_ops *ops,
  2726. char __iomem *tx_io_base)
  2727. {
  2728. memset(ops, 0, sizeof(struct macro_ops));
  2729. ops->init = tx_macro_init;
  2730. ops->exit = tx_macro_deinit;
  2731. ops->io_base = tx_io_base;
  2732. ops->dai_ptr = tx_macro_dai;
  2733. ops->num_dais = ARRAY_SIZE(tx_macro_dai);
  2734. ops->event_handler = tx_macro_event_handler;
  2735. ops->reg_wake_irq = tx_macro_reg_wake_irq;
  2736. ops->set_port_map = tx_macro_set_port_map;
  2737. ops->clk_switch = tx_macro_clk_switch;
  2738. ops->reg_evt_listener = tx_macro_register_event_listener;
  2739. }
  2740. static int tx_macro_probe(struct platform_device *pdev)
  2741. {
  2742. struct macro_ops ops = {0};
  2743. struct tx_macro_priv *tx_priv = NULL;
  2744. u32 tx_base_addr = 0, sample_rate = 0;
  2745. char __iomem *tx_io_base = NULL;
  2746. int ret = 0;
  2747. const char *dmic_sample_rate = "qcom,tx-dmic-sample-rate";
  2748. u32 is_used_tx_swr_gpio = 1;
  2749. const char *is_used_tx_swr_gpio_dt = "qcom,is-used-swr-gpio";
  2750. tx_priv = devm_kzalloc(&pdev->dev, sizeof(struct tx_macro_priv),
  2751. GFP_KERNEL);
  2752. if (!tx_priv)
  2753. return -ENOMEM;
  2754. platform_set_drvdata(pdev, tx_priv);
  2755. tx_priv->dev = &pdev->dev;
  2756. ret = of_property_read_u32(pdev->dev.of_node, "reg",
  2757. &tx_base_addr);
  2758. if (ret) {
  2759. dev_err(&pdev->dev, "%s: could not find %s entry in dt\n",
  2760. __func__, "reg");
  2761. return ret;
  2762. }
  2763. dev_set_drvdata(&pdev->dev, tx_priv);
  2764. if (of_find_property(pdev->dev.of_node, is_used_tx_swr_gpio_dt,
  2765. NULL)) {
  2766. ret = of_property_read_u32(pdev->dev.of_node,
  2767. is_used_tx_swr_gpio_dt,
  2768. &is_used_tx_swr_gpio);
  2769. if (ret) {
  2770. dev_err(&pdev->dev, "%s: error reading %s in dt\n",
  2771. __func__, is_used_tx_swr_gpio_dt);
  2772. is_used_tx_swr_gpio = 1;
  2773. }
  2774. }
  2775. tx_priv->tx_swr_gpio_p = of_parse_phandle(pdev->dev.of_node,
  2776. "qcom,tx-swr-gpios", 0);
  2777. if (!tx_priv->tx_swr_gpio_p && is_used_tx_swr_gpio) {
  2778. dev_err(&pdev->dev, "%s: swr_gpios handle not provided!\n",
  2779. __func__);
  2780. return -EINVAL;
  2781. }
  2782. if (msm_cdc_pinctrl_get_state(tx_priv->tx_swr_gpio_p) < 0 &&
  2783. is_used_tx_swr_gpio) {
  2784. dev_err(&pdev->dev, "%s: failed to get swr pin state\n",
  2785. __func__);
  2786. return -EPROBE_DEFER;
  2787. }
  2788. tx_io_base = devm_ioremap(&pdev->dev,
  2789. tx_base_addr, TX_MACRO_MAX_OFFSET);
  2790. if (!tx_io_base) {
  2791. dev_err(&pdev->dev, "%s: ioremap failed\n", __func__);
  2792. return -ENOMEM;
  2793. }
  2794. tx_priv->tx_io_base = tx_io_base;
  2795. ret = of_property_read_u32(pdev->dev.of_node, dmic_sample_rate,
  2796. &sample_rate);
  2797. if (ret) {
  2798. dev_err(&pdev->dev,
  2799. "%s: could not find sample_rate entry in dt\n",
  2800. __func__);
  2801. tx_priv->dmic_clk_div = TX_MACRO_CLK_DIV_2;
  2802. } else {
  2803. if (tx_macro_validate_dmic_sample_rate(
  2804. sample_rate, tx_priv) == TX_MACRO_DMIC_SAMPLE_RATE_UNDEFINED)
  2805. return -EINVAL;
  2806. }
  2807. if (is_used_tx_swr_gpio) {
  2808. tx_priv->reset_swr = true;
  2809. INIT_WORK(&tx_priv->tx_macro_add_child_devices_work,
  2810. tx_macro_add_child_devices);
  2811. tx_priv->swr_plat_data.handle = (void *) tx_priv;
  2812. tx_priv->swr_plat_data.read = NULL;
  2813. tx_priv->swr_plat_data.write = NULL;
  2814. tx_priv->swr_plat_data.bulk_write = NULL;
  2815. tx_priv->swr_plat_data.clk = tx_macro_swrm_clock;
  2816. tx_priv->swr_plat_data.core_vote = tx_macro_core_vote;
  2817. tx_priv->swr_plat_data.handle_irq = NULL;
  2818. mutex_init(&tx_priv->swr_clk_lock);
  2819. }
  2820. tx_priv->is_used_tx_swr_gpio = is_used_tx_swr_gpio;
  2821. mutex_init(&tx_priv->mclk_lock);
  2822. tx_macro_init_ops(&ops, tx_io_base);
  2823. ops.clk_id_req = TX_CORE_CLK;
  2824. ops.default_clk_id = TX_CORE_CLK;
  2825. ret = bolero_register_macro(&pdev->dev, TX_MACRO, &ops);
  2826. if (ret) {
  2827. dev_err(&pdev->dev,
  2828. "%s: register macro failed\n", __func__);
  2829. goto err_reg_macro;
  2830. }
  2831. if (is_used_tx_swr_gpio)
  2832. schedule_work(&tx_priv->tx_macro_add_child_devices_work);
  2833. pm_runtime_set_autosuspend_delay(&pdev->dev, AUTO_SUSPEND_DELAY);
  2834. pm_runtime_use_autosuspend(&pdev->dev);
  2835. pm_runtime_set_suspended(&pdev->dev);
  2836. pm_suspend_ignore_children(&pdev->dev, true);
  2837. pm_runtime_enable(&pdev->dev);
  2838. return 0;
  2839. err_reg_macro:
  2840. mutex_destroy(&tx_priv->mclk_lock);
  2841. if (is_used_tx_swr_gpio)
  2842. mutex_destroy(&tx_priv->swr_clk_lock);
  2843. return ret;
  2844. }
  2845. static int tx_macro_remove(struct platform_device *pdev)
  2846. {
  2847. struct tx_macro_priv *tx_priv = NULL;
  2848. u16 count = 0;
  2849. tx_priv = platform_get_drvdata(pdev);
  2850. if (!tx_priv)
  2851. return -EINVAL;
  2852. if (tx_priv->is_used_tx_swr_gpio) {
  2853. if (tx_priv->swr_ctrl_data)
  2854. kfree(tx_priv->swr_ctrl_data);
  2855. for (count = 0; count < tx_priv->child_count &&
  2856. count < TX_MACRO_CHILD_DEVICES_MAX; count++)
  2857. platform_device_unregister(
  2858. tx_priv->pdev_child_devices[count]);
  2859. }
  2860. pm_runtime_disable(&pdev->dev);
  2861. pm_runtime_set_suspended(&pdev->dev);
  2862. mutex_destroy(&tx_priv->mclk_lock);
  2863. if (tx_priv->is_used_tx_swr_gpio)
  2864. mutex_destroy(&tx_priv->swr_clk_lock);
  2865. bolero_unregister_macro(&pdev->dev, TX_MACRO);
  2866. return 0;
  2867. }
  2868. static const struct of_device_id tx_macro_dt_match[] = {
  2869. {.compatible = "qcom,tx-macro"},
  2870. {}
  2871. };
  2872. static const struct dev_pm_ops bolero_dev_pm_ops = {
  2873. SET_RUNTIME_PM_OPS(
  2874. bolero_runtime_suspend,
  2875. bolero_runtime_resume,
  2876. NULL
  2877. )
  2878. };
  2879. static struct platform_driver tx_macro_driver = {
  2880. .driver = {
  2881. .name = "tx_macro",
  2882. .owner = THIS_MODULE,
  2883. .pm = &bolero_dev_pm_ops,
  2884. .of_match_table = tx_macro_dt_match,
  2885. .suppress_bind_attrs = true,
  2886. },
  2887. .probe = tx_macro_probe,
  2888. .remove = tx_macro_remove,
  2889. };
  2890. module_platform_driver(tx_macro_driver);
  2891. MODULE_DESCRIPTION("TX macro driver");
  2892. MODULE_LICENSE("GPL v2");