tx-macro.c 108 KB

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