tx-macro.c 104 KB

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