tx-macro.c 97 KB

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