tx-macro.c 104 KB

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