tx-macro.c 104 KB

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