tx-macro.c 103 KB

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