tx-macro.c 100 KB

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