tx-macro.c 104 KB

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