tx-macro.c 102 KB

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