tx-macro.c 97 KB

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