tx-macro.c 103 KB

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