tx-macro.c 116 KB

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