va-macro.c 92 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043
  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/regulator/consumer.h>
  11. #include <sound/soc.h>
  12. #include <sound/soc-dapm.h>
  13. #include <sound/tlv.h>
  14. #include <linux/pm_runtime.h>
  15. #include <asoc/msm-cdc-pinctrl.h>
  16. #include <soc/swr-common.h>
  17. #include <soc/swr-wcd.h>
  18. #include "bolero-cdc.h"
  19. #include "bolero-cdc-registers.h"
  20. #include "bolero-clk-rsc.h"
  21. /* pm runtime auto suspend timer in msecs */
  22. #define VA_AUTO_SUSPEND_DELAY 100 /* delay in msec */
  23. #define VA_MACRO_MAX_OFFSET 0x1000
  24. #define VA_MACRO_NUM_DECIMATORS 8
  25. #define VA_MACRO_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\
  26. SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |\
  27. SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000)
  28. #define VA_MACRO_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\
  29. SNDRV_PCM_FMTBIT_S24_LE |\
  30. SNDRV_PCM_FMTBIT_S24_3LE)
  31. #define TX_HPF_CUT_OFF_FREQ_MASK 0x60
  32. #define CF_MIN_3DB_4HZ 0x0
  33. #define CF_MIN_3DB_75HZ 0x1
  34. #define CF_MIN_3DB_150HZ 0x2
  35. #define VA_MACRO_DMIC_SAMPLE_RATE_UNDEFINED 0
  36. #define VA_MACRO_MCLK_FREQ 9600000
  37. #define VA_MACRO_TX_PATH_OFFSET 0x80
  38. #define VA_MACRO_TX_DMIC_CLK_DIV_MASK 0x0E
  39. #define VA_MACRO_TX_DMIC_CLK_DIV_SHFT 0x01
  40. #define VA_MACRO_SWR_MIC_MUX_SEL_MASK 0xF
  41. #define VA_MACRO_ADC_MUX_CFG_OFFSET 0x8
  42. #define BOLERO_CDC_VA_TX_DMIC_UNMUTE_DELAY_MS 40
  43. #define BOLERO_CDC_VA_TX_AMIC_UNMUTE_DELAY_MS 100
  44. #define BOLERO_CDC_VA_TX_DMIC_HPF_DELAY_MS 300
  45. #define BOLERO_CDC_VA_TX_AMIC_HPF_DELAY_MS 300
  46. #define MAX_RETRY_ATTEMPTS 500
  47. #define VA_MACRO_SWR_STRING_LEN 80
  48. #define VA_MACRO_CHILD_DEVICES_MAX 3
  49. static const DECLARE_TLV_DB_SCALE(digital_gain, 0, 1, 0);
  50. static int va_tx_unmute_delay = BOLERO_CDC_VA_TX_DMIC_UNMUTE_DELAY_MS;
  51. module_param(va_tx_unmute_delay, int, 0664);
  52. MODULE_PARM_DESC(va_tx_unmute_delay, "delay to unmute the tx path");
  53. enum {
  54. VA_MACRO_AIF_INVALID = 0,
  55. VA_MACRO_AIF1_CAP,
  56. VA_MACRO_AIF2_CAP,
  57. VA_MACRO_AIF3_CAP,
  58. VA_MACRO_MAX_DAIS,
  59. };
  60. enum {
  61. VA_MACRO_DEC0,
  62. VA_MACRO_DEC1,
  63. VA_MACRO_DEC2,
  64. VA_MACRO_DEC3,
  65. VA_MACRO_DEC4,
  66. VA_MACRO_DEC5,
  67. VA_MACRO_DEC6,
  68. VA_MACRO_DEC7,
  69. VA_MACRO_DEC_MAX,
  70. };
  71. enum {
  72. VA_MACRO_CLK_DIV_2,
  73. VA_MACRO_CLK_DIV_3,
  74. VA_MACRO_CLK_DIV_4,
  75. VA_MACRO_CLK_DIV_6,
  76. VA_MACRO_CLK_DIV_8,
  77. VA_MACRO_CLK_DIV_16,
  78. };
  79. enum {
  80. MSM_DMIC,
  81. SWR_MIC,
  82. };
  83. enum {
  84. TX_MCLK,
  85. VA_MCLK,
  86. };
  87. struct va_mute_work {
  88. struct va_macro_priv *va_priv;
  89. u32 decimator;
  90. struct delayed_work dwork;
  91. };
  92. struct hpf_work {
  93. struct va_macro_priv *va_priv;
  94. u8 decimator;
  95. u8 hpf_cut_off_freq;
  96. struct delayed_work dwork;
  97. };
  98. /* Hold instance to soundwire platform device */
  99. struct va_macro_swr_ctrl_data {
  100. struct platform_device *va_swr_pdev;
  101. };
  102. struct va_macro_swr_ctrl_platform_data {
  103. void *handle; /* holds codec private data */
  104. int (*read)(void *handle, int reg);
  105. int (*write)(void *handle, int reg, int val);
  106. int (*bulk_write)(void *handle, u32 *reg, u32 *val, size_t len);
  107. int (*clk)(void *handle, bool enable);
  108. int (*core_vote)(void *handle, bool enable);
  109. int (*handle_irq)(void *handle,
  110. irqreturn_t (*swrm_irq_handler)(int irq,
  111. void *data),
  112. void *swrm_handle,
  113. int action);
  114. };
  115. struct va_macro_priv {
  116. struct device *dev;
  117. bool dec_active[VA_MACRO_NUM_DECIMATORS];
  118. bool va_without_decimation;
  119. struct clk *lpass_audio_hw_vote;
  120. struct mutex mclk_lock;
  121. struct mutex swr_clk_lock;
  122. struct snd_soc_component *component;
  123. struct hpf_work va_hpf_work[VA_MACRO_NUM_DECIMATORS];
  124. struct va_mute_work va_mute_dwork[VA_MACRO_NUM_DECIMATORS];
  125. unsigned long active_ch_mask[VA_MACRO_MAX_DAIS];
  126. unsigned long active_ch_cnt[VA_MACRO_MAX_DAIS];
  127. u16 dmic_clk_div;
  128. u16 va_mclk_users;
  129. int swr_clk_users;
  130. bool reset_swr;
  131. struct device_node *va_swr_gpio_p;
  132. struct va_macro_swr_ctrl_data *swr_ctrl_data;
  133. struct va_macro_swr_ctrl_platform_data swr_plat_data;
  134. struct work_struct va_macro_add_child_devices_work;
  135. int child_count;
  136. u16 mclk_mux_sel;
  137. char __iomem *va_io_base;
  138. char __iomem *va_island_mode_muxsel;
  139. struct platform_device *pdev_child_devices
  140. [VA_MACRO_CHILD_DEVICES_MAX];
  141. struct regulator *micb_supply;
  142. u32 micb_voltage;
  143. u32 micb_current;
  144. u32 version;
  145. u32 is_used_va_swr_gpio;
  146. int micb_users;
  147. u16 default_clk_id;
  148. u16 clk_id;
  149. int tx_swr_clk_cnt;
  150. int va_swr_clk_cnt;
  151. int va_clk_status;
  152. int tx_clk_status;
  153. bool lpi_enable;
  154. bool register_event_listener;
  155. };
  156. static bool va_macro_get_data(struct snd_soc_component *component,
  157. struct device **va_dev,
  158. struct va_macro_priv **va_priv,
  159. const char *func_name)
  160. {
  161. *va_dev = bolero_get_device_ptr(component->dev, VA_MACRO);
  162. if (!(*va_dev)) {
  163. dev_err(component->dev,
  164. "%s: null device for macro!\n", func_name);
  165. return false;
  166. }
  167. *va_priv = dev_get_drvdata((*va_dev));
  168. if (!(*va_priv) || !(*va_priv)->component) {
  169. dev_err(component->dev,
  170. "%s: priv is null for macro!\n", func_name);
  171. return false;
  172. }
  173. return true;
  174. }
  175. static int va_macro_clk_div_get(struct snd_soc_component *component)
  176. {
  177. struct device *va_dev = NULL;
  178. struct va_macro_priv *va_priv = NULL;
  179. if (!va_macro_get_data(component, &va_dev, &va_priv, __func__))
  180. return -EINVAL;
  181. if ((va_priv->version == BOLERO_VERSION_2_1)
  182. && !va_priv->lpi_enable
  183. && (va_priv->dmic_clk_div == VA_MACRO_CLK_DIV_16))
  184. return VA_MACRO_CLK_DIV_8;
  185. return va_priv->dmic_clk_div;
  186. }
  187. static int va_macro_mclk_enable(struct va_macro_priv *va_priv,
  188. bool mclk_enable, bool dapm)
  189. {
  190. struct regmap *regmap = dev_get_regmap(va_priv->dev->parent, NULL);
  191. int ret = 0;
  192. if (regmap == NULL) {
  193. dev_err(va_priv->dev, "%s: regmap is NULL\n", __func__);
  194. return -EINVAL;
  195. }
  196. dev_dbg(va_priv->dev, "%s: mclk_enable = %u, dapm = %d clk_users= %d\n",
  197. __func__, mclk_enable, dapm, va_priv->va_mclk_users);
  198. mutex_lock(&va_priv->mclk_lock);
  199. if (mclk_enable) {
  200. if (va_priv->va_mclk_users == 0) {
  201. ret = bolero_clk_rsc_request_clock(va_priv->dev,
  202. va_priv->default_clk_id,
  203. va_priv->clk_id,
  204. true);
  205. if (ret < 0) {
  206. dev_err(va_priv->dev,
  207. "%s: va request clock en failed\n",
  208. __func__);
  209. goto exit;
  210. }
  211. bolero_clk_rsc_fs_gen_request(va_priv->dev,
  212. true);
  213. regcache_mark_dirty(regmap);
  214. regcache_sync_region(regmap,
  215. VA_START_OFFSET,
  216. VA_MAX_OFFSET);
  217. }
  218. va_priv->va_mclk_users++;
  219. } else {
  220. if (va_priv->va_mclk_users <= 0) {
  221. dev_err(va_priv->dev, "%s: clock already disabled\n",
  222. __func__);
  223. va_priv->va_mclk_users = 0;
  224. goto exit;
  225. }
  226. va_priv->va_mclk_users--;
  227. if (va_priv->va_mclk_users == 0) {
  228. bolero_clk_rsc_fs_gen_request(va_priv->dev,
  229. false);
  230. bolero_clk_rsc_request_clock(va_priv->dev,
  231. va_priv->default_clk_id,
  232. va_priv->clk_id,
  233. false);
  234. }
  235. }
  236. exit:
  237. mutex_unlock(&va_priv->mclk_lock);
  238. return ret;
  239. }
  240. static int va_macro_event_handler(struct snd_soc_component *component,
  241. u16 event, u32 data)
  242. {
  243. struct device *va_dev = NULL;
  244. struct va_macro_priv *va_priv = NULL;
  245. int retry_cnt = MAX_RETRY_ATTEMPTS;
  246. int ret = 0;
  247. if (!va_macro_get_data(component, &va_dev, &va_priv, __func__))
  248. return -EINVAL;
  249. switch (event) {
  250. case BOLERO_MACRO_EVT_WAIT_VA_CLK_RESET:
  251. while ((va_priv->va_mclk_users != 0) && (retry_cnt != 0)) {
  252. dev_dbg_ratelimited(va_dev, "%s:retry_cnt: %d\n",
  253. __func__, retry_cnt);
  254. /*
  255. * Userspace takes 10 seconds to close
  256. * the session when pcm_start fails due to concurrency
  257. * with PDR/SSR. Loop and check every 20ms till 10
  258. * seconds for va_mclk user count to get reset to 0
  259. * which ensures userspace teardown is done and SSR
  260. * powerup seq can proceed.
  261. */
  262. msleep(20);
  263. retry_cnt--;
  264. }
  265. if (retry_cnt == 0)
  266. dev_err(va_dev,
  267. "%s: va_mclk_users is non-zero still, audio SSR fail!!\n",
  268. __func__);
  269. break;
  270. case BOLERO_MACRO_EVT_SSR_UP:
  271. /* enable&disable VA_CORE_CLK to reset GFMUX reg */
  272. ret = bolero_clk_rsc_request_clock(va_priv->dev,
  273. va_priv->default_clk_id,
  274. VA_CORE_CLK, true);
  275. if (ret < 0)
  276. dev_err_ratelimited(va_priv->dev,
  277. "%s, failed to enable clk, ret:%d\n",
  278. __func__, ret);
  279. else
  280. bolero_clk_rsc_request_clock(va_priv->dev,
  281. va_priv->default_clk_id,
  282. VA_CORE_CLK, false);
  283. /* reset swr after ssr/pdr */
  284. va_priv->reset_swr = true;
  285. if (va_priv->swr_ctrl_data)
  286. swrm_wcd_notify(
  287. va_priv->swr_ctrl_data[0].va_swr_pdev,
  288. SWR_DEVICE_SSR_UP, NULL);
  289. break;
  290. case BOLERO_MACRO_EVT_CLK_RESET:
  291. bolero_rsc_clk_reset(va_dev, VA_CORE_CLK);
  292. break;
  293. case BOLERO_MACRO_EVT_SSR_DOWN:
  294. if (va_priv->swr_ctrl_data) {
  295. swrm_wcd_notify(
  296. va_priv->swr_ctrl_data[0].va_swr_pdev,
  297. SWR_DEVICE_DOWN, NULL);
  298. swrm_wcd_notify(
  299. va_priv->swr_ctrl_data[0].va_swr_pdev,
  300. SWR_DEVICE_SSR_DOWN, NULL);
  301. }
  302. if ((!pm_runtime_enabled(va_dev) ||
  303. !pm_runtime_suspended(va_dev))) {
  304. ret = bolero_runtime_suspend(va_dev);
  305. if (!ret) {
  306. pm_runtime_disable(va_dev);
  307. pm_runtime_set_suspended(va_dev);
  308. pm_runtime_enable(va_dev);
  309. }
  310. }
  311. break;
  312. default:
  313. break;
  314. }
  315. return 0;
  316. }
  317. static int va_macro_swr_pwr_event_v2(struct snd_soc_dapm_widget *w,
  318. struct snd_kcontrol *kcontrol, int event)
  319. {
  320. struct snd_soc_component *component =
  321. snd_soc_dapm_to_component(w->dapm);
  322. int ret = 0;
  323. struct device *va_dev = NULL;
  324. struct va_macro_priv *va_priv = NULL;
  325. if (!va_macro_get_data(component, &va_dev, &va_priv, __func__))
  326. return -EINVAL;
  327. dev_dbg(va_dev, "%s: event = %d\n", __func__, event);
  328. switch (event) {
  329. case SND_SOC_DAPM_PRE_PMU:
  330. va_priv->va_swr_clk_cnt++;
  331. if (va_priv->swr_ctrl_data) {
  332. ret = swrm_wcd_notify(
  333. va_priv->swr_ctrl_data[0].va_swr_pdev,
  334. SWR_REQ_CLK_SWITCH, NULL);
  335. if (ret)
  336. dev_dbg(va_dev, "%s: clock switch failed\n",
  337. __func__);
  338. }
  339. msm_cdc_pinctrl_set_wakeup_capable(
  340. va_priv->va_swr_gpio_p, false);
  341. break;
  342. case SND_SOC_DAPM_POST_PMD:
  343. msm_cdc_pinctrl_set_wakeup_capable(
  344. va_priv->va_swr_gpio_p, true);
  345. if (va_priv->swr_ctrl_data) {
  346. ret = swrm_wcd_notify(
  347. va_priv->swr_ctrl_data[0].va_swr_pdev,
  348. SWR_REQ_CLK_SWITCH, NULL);
  349. if (ret)
  350. dev_dbg(va_dev, "%s: clock switch failed\n",
  351. __func__);
  352. }
  353. va_priv->va_swr_clk_cnt--;
  354. break;
  355. default:
  356. dev_err(va_priv->dev,
  357. "%s: invalid DAPM event %d\n", __func__, event);
  358. ret = -EINVAL;
  359. }
  360. return ret;
  361. }
  362. static int va_macro_swr_pwr_event(struct snd_soc_dapm_widget *w,
  363. struct snd_kcontrol *kcontrol, int event)
  364. {
  365. struct snd_soc_component *component =
  366. snd_soc_dapm_to_component(w->dapm);
  367. int ret = 0;
  368. struct device *va_dev = NULL;
  369. struct va_macro_priv *va_priv = NULL;
  370. if (!va_macro_get_data(component, &va_dev, &va_priv, __func__))
  371. return -EINVAL;
  372. dev_dbg(va_dev, "%s: event = %d\n", __func__, event);
  373. switch (event) {
  374. case SND_SOC_DAPM_PRE_PMU:
  375. if (va_priv->lpass_audio_hw_vote) {
  376. ret = clk_prepare_enable(va_priv->lpass_audio_hw_vote);
  377. if (ret)
  378. dev_err(va_dev,
  379. "%s: lpass audio hw enable failed\n",
  380. __func__);
  381. }
  382. if (!ret)
  383. if (bolero_tx_clk_switch(component))
  384. dev_dbg(va_dev, "%s: clock switch failed\n",
  385. __func__);
  386. if (va_priv->lpi_enable) {
  387. bolero_register_event_listener(component, true);
  388. va_priv->register_event_listener = true;
  389. }
  390. break;
  391. case SND_SOC_DAPM_POST_PMD:
  392. if (va_priv->register_event_listener) {
  393. va_priv->register_event_listener = false;
  394. bolero_register_event_listener(component, false);
  395. }
  396. if (bolero_tx_clk_switch(component))
  397. dev_dbg(va_dev, "%s: clock switch failed\n",__func__);
  398. if (va_priv->lpass_audio_hw_vote)
  399. clk_disable_unprepare(va_priv->lpass_audio_hw_vote);
  400. break;
  401. default:
  402. dev_err(va_priv->dev,
  403. "%s: invalid DAPM event %d\n", __func__, event);
  404. ret = -EINVAL;
  405. }
  406. return ret;
  407. }
  408. static int va_macro_tx_swr_clk_event_v2(struct snd_soc_dapm_widget *w,
  409. struct snd_kcontrol *kcontrol, int event)
  410. {
  411. struct device *va_dev = NULL;
  412. struct va_macro_priv *va_priv = NULL;
  413. struct snd_soc_component *component =
  414. snd_soc_dapm_to_component(w->dapm);
  415. if (!va_macro_get_data(component, &va_dev, &va_priv, __func__))
  416. return -EINVAL;
  417. if (SND_SOC_DAPM_EVENT_ON(event))
  418. ++va_priv->tx_swr_clk_cnt;
  419. if (SND_SOC_DAPM_EVENT_OFF(event))
  420. --va_priv->tx_swr_clk_cnt;
  421. return 0;
  422. }
  423. static int va_macro_mclk_event(struct snd_soc_dapm_widget *w,
  424. struct snd_kcontrol *kcontrol, int event)
  425. {
  426. struct snd_soc_component *component =
  427. snd_soc_dapm_to_component(w->dapm);
  428. int ret = 0;
  429. struct device *va_dev = NULL;
  430. struct va_macro_priv *va_priv = NULL;
  431. if (!va_macro_get_data(component, &va_dev, &va_priv, __func__))
  432. return -EINVAL;
  433. dev_dbg(va_dev, "%s: event = %d\n", __func__, event);
  434. switch (event) {
  435. case SND_SOC_DAPM_PRE_PMU:
  436. ret = bolero_clk_rsc_request_clock(va_priv->dev,
  437. va_priv->default_clk_id,
  438. TX_CORE_CLK,
  439. true);
  440. if (!ret)
  441. va_priv->tx_clk_status++;
  442. if (va_priv->lpi_enable)
  443. ret = va_macro_mclk_enable(va_priv, 1, true);
  444. else
  445. ret = bolero_tx_mclk_enable(component, 1);
  446. break;
  447. case SND_SOC_DAPM_POST_PMD:
  448. if (bolero_tx_clk_switch(component))
  449. dev_dbg(va_dev, "%s: clock switch failed\n",__func__);
  450. if (va_priv->lpi_enable)
  451. va_macro_mclk_enable(va_priv, 0, true);
  452. else
  453. bolero_tx_mclk_enable(component, 0);
  454. if (va_priv->tx_clk_status > 0) {
  455. bolero_clk_rsc_request_clock(va_priv->dev,
  456. va_priv->default_clk_id,
  457. TX_CORE_CLK,
  458. false);
  459. va_priv->tx_clk_status--;
  460. }
  461. break;
  462. default:
  463. dev_err(va_priv->dev,
  464. "%s: invalid DAPM event %d\n", __func__, event);
  465. ret = -EINVAL;
  466. }
  467. return ret;
  468. }
  469. static int va_macro_tx_va_mclk_enable(struct va_macro_priv *va_priv,
  470. struct regmap *regmap, int clk_type,
  471. bool enable)
  472. {
  473. int ret = 0, clk_tx_ret = 0;
  474. dev_dbg(va_priv->dev,
  475. "%s: clock type %s, enable: %s tx_mclk_users: %d\n",
  476. __func__, (clk_type ? "VA_MCLK" : "TX_MCLK"),
  477. (enable ? "enable" : "disable"), va_priv->va_mclk_users);
  478. if (enable) {
  479. if (va_priv->swr_clk_users == 0)
  480. msm_cdc_pinctrl_select_active_state(
  481. va_priv->va_swr_gpio_p);
  482. clk_tx_ret = bolero_clk_rsc_request_clock(va_priv->dev,
  483. TX_CORE_CLK,
  484. TX_CORE_CLK,
  485. true);
  486. if (clk_type == TX_MCLK) {
  487. ret = bolero_clk_rsc_request_clock(va_priv->dev,
  488. TX_CORE_CLK,
  489. TX_CORE_CLK,
  490. true);
  491. if (ret < 0) {
  492. if (va_priv->swr_clk_users == 0)
  493. msm_cdc_pinctrl_select_sleep_state(
  494. va_priv->va_swr_gpio_p);
  495. dev_err_ratelimited(va_priv->dev,
  496. "%s: swr request clk failed\n",
  497. __func__);
  498. goto done;
  499. }
  500. bolero_clk_rsc_fs_gen_request(va_priv->dev,
  501. true);
  502. }
  503. if (clk_type == VA_MCLK) {
  504. ret = va_macro_mclk_enable(va_priv, 1, true);
  505. if (ret < 0) {
  506. if (va_priv->swr_clk_users == 0)
  507. msm_cdc_pinctrl_select_sleep_state(
  508. va_priv->va_swr_gpio_p);
  509. dev_err_ratelimited(va_priv->dev,
  510. "%s: request clock enable failed\n",
  511. __func__);
  512. goto done;
  513. }
  514. }
  515. if (va_priv->swr_clk_users == 0) {
  516. dev_dbg(va_priv->dev, "%s: reset_swr: %d\n",
  517. __func__, va_priv->reset_swr);
  518. if (va_priv->reset_swr)
  519. regmap_update_bits(regmap,
  520. BOLERO_CDC_VA_CLK_RST_CTRL_SWR_CONTROL,
  521. 0x02, 0x02);
  522. regmap_update_bits(regmap,
  523. BOLERO_CDC_VA_CLK_RST_CTRL_SWR_CONTROL,
  524. 0x01, 0x01);
  525. if (va_priv->reset_swr)
  526. regmap_update_bits(regmap,
  527. BOLERO_CDC_VA_CLK_RST_CTRL_SWR_CONTROL,
  528. 0x02, 0x00);
  529. va_priv->reset_swr = false;
  530. }
  531. if (!clk_tx_ret)
  532. ret = bolero_clk_rsc_request_clock(va_priv->dev,
  533. TX_CORE_CLK,
  534. TX_CORE_CLK,
  535. false);
  536. va_priv->swr_clk_users++;
  537. } else {
  538. if (va_priv->swr_clk_users <= 0) {
  539. dev_err_ratelimited(va_priv->dev,
  540. "va swrm clock users already 0\n");
  541. va_priv->swr_clk_users = 0;
  542. return 0;
  543. }
  544. clk_tx_ret = bolero_clk_rsc_request_clock(va_priv->dev,
  545. TX_CORE_CLK,
  546. TX_CORE_CLK,
  547. true);
  548. va_priv->swr_clk_users--;
  549. if (va_priv->swr_clk_users == 0)
  550. regmap_update_bits(regmap,
  551. BOLERO_CDC_VA_CLK_RST_CTRL_SWR_CONTROL,
  552. 0x01, 0x00);
  553. if (clk_type == VA_MCLK)
  554. va_macro_mclk_enable(va_priv, 0, true);
  555. if (clk_type == TX_MCLK) {
  556. bolero_clk_rsc_fs_gen_request(va_priv->dev,
  557. false);
  558. ret = bolero_clk_rsc_request_clock(va_priv->dev,
  559. TX_CORE_CLK,
  560. TX_CORE_CLK,
  561. false);
  562. if (ret < 0) {
  563. dev_err_ratelimited(va_priv->dev,
  564. "%s: swr request clk failed\n",
  565. __func__);
  566. goto done;
  567. }
  568. }
  569. if (!clk_tx_ret)
  570. ret = bolero_clk_rsc_request_clock(va_priv->dev,
  571. TX_CORE_CLK,
  572. TX_CORE_CLK,
  573. false);
  574. if (va_priv->swr_clk_users == 0)
  575. msm_cdc_pinctrl_select_sleep_state(
  576. va_priv->va_swr_gpio_p);
  577. }
  578. return 0;
  579. done:
  580. if (!clk_tx_ret)
  581. bolero_clk_rsc_request_clock(va_priv->dev,
  582. TX_CORE_CLK,
  583. TX_CORE_CLK,
  584. false);
  585. return ret;
  586. }
  587. static int va_macro_core_vote(void *handle, bool enable)
  588. {
  589. struct va_macro_priv *va_priv = (struct va_macro_priv *) handle;
  590. if (va_priv == NULL) {
  591. pr_err("%s: va priv data is NULL\n", __func__);
  592. return -EINVAL;
  593. }
  594. if (enable) {
  595. pm_runtime_get_sync(va_priv->dev);
  596. pm_runtime_put_autosuspend(va_priv->dev);
  597. pm_runtime_mark_last_busy(va_priv->dev);
  598. }
  599. if (bolero_check_core_votes(va_priv->dev))
  600. return 0;
  601. else
  602. return -EINVAL;
  603. }
  604. static int va_macro_swrm_clock(void *handle, bool enable)
  605. {
  606. struct va_macro_priv *va_priv = (struct va_macro_priv *) handle;
  607. struct regmap *regmap = dev_get_regmap(va_priv->dev->parent, NULL);
  608. int ret = 0;
  609. if (regmap == NULL) {
  610. dev_err(va_priv->dev, "%s: regmap is NULL\n", __func__);
  611. return -EINVAL;
  612. }
  613. mutex_lock(&va_priv->swr_clk_lock);
  614. dev_dbg(va_priv->dev,
  615. "%s: swrm clock %s tx_swr_clk_cnt: %d va_swr_clk_cnt: %d\n",
  616. __func__, (enable ? "enable" : "disable"),
  617. va_priv->tx_swr_clk_cnt, va_priv->va_swr_clk_cnt);
  618. if (enable) {
  619. pm_runtime_get_sync(va_priv->dev);
  620. if (va_priv->va_swr_clk_cnt && !va_priv->tx_swr_clk_cnt) {
  621. ret = va_macro_tx_va_mclk_enable(va_priv, regmap,
  622. VA_MCLK, enable);
  623. if (ret)
  624. goto done;
  625. va_priv->va_clk_status++;
  626. } else {
  627. ret = va_macro_tx_va_mclk_enable(va_priv, regmap,
  628. TX_MCLK, enable);
  629. if (ret)
  630. goto done;
  631. va_priv->tx_clk_status++;
  632. }
  633. pm_runtime_mark_last_busy(va_priv->dev);
  634. pm_runtime_put_autosuspend(va_priv->dev);
  635. } else {
  636. if (va_priv->va_clk_status && !va_priv->tx_clk_status) {
  637. ret = va_macro_tx_va_mclk_enable(va_priv, regmap,
  638. VA_MCLK, enable);
  639. if (ret)
  640. goto done;
  641. --va_priv->va_clk_status;
  642. } else if (!va_priv->va_clk_status && va_priv->tx_clk_status) {
  643. ret = va_macro_tx_va_mclk_enable(va_priv, regmap,
  644. TX_MCLK, enable);
  645. if (ret)
  646. goto done;
  647. --va_priv->tx_clk_status;
  648. } else if (va_priv->va_clk_status && va_priv->tx_clk_status) {
  649. if (!va_priv->va_swr_clk_cnt && va_priv->tx_swr_clk_cnt) {
  650. ret = va_macro_tx_va_mclk_enable(va_priv, regmap,
  651. VA_MCLK, enable);
  652. if (ret)
  653. goto done;
  654. --va_priv->va_clk_status;
  655. } else {
  656. ret = va_macro_tx_va_mclk_enable(va_priv, regmap,
  657. TX_MCLK, enable);
  658. if (ret)
  659. goto done;
  660. --va_priv->tx_clk_status;
  661. }
  662. } else {
  663. dev_dbg(va_priv->dev,
  664. "%s: Both clocks are disabled\n", __func__);
  665. }
  666. }
  667. dev_dbg(va_priv->dev,
  668. "%s: swrm clock users %d tx_clk_sts_cnt: %d va_clk_sts_cnt: %d\n",
  669. __func__, va_priv->swr_clk_users, va_priv->tx_clk_status,
  670. va_priv->va_clk_status);
  671. done:
  672. mutex_unlock(&va_priv->swr_clk_lock);
  673. return ret;
  674. }
  675. static int is_amic_enabled(struct snd_soc_component *component, int decimator)
  676. {
  677. u16 adc_mux_reg = 0, adc_reg = 0;
  678. u16 adc_n = BOLERO_ADC_MAX;
  679. adc_mux_reg = BOLERO_CDC_VA_INP_MUX_ADC_MUX0_CFG1 +
  680. VA_MACRO_ADC_MUX_CFG_OFFSET * decimator;
  681. if (snd_soc_component_read32(component, adc_mux_reg) & SWR_MIC) {
  682. adc_reg = BOLERO_CDC_VA_INP_MUX_ADC_MUX0_CFG0 +
  683. VA_MACRO_ADC_MUX_CFG_OFFSET * decimator;
  684. adc_n = snd_soc_component_read32(component, adc_reg) &
  685. VA_MACRO_SWR_MIC_MUX_SEL_MASK;
  686. if (adc_n >= BOLERO_ADC_MAX)
  687. adc_n = BOLERO_ADC_MAX;
  688. }
  689. return adc_n;
  690. }
  691. static void va_macro_tx_hpf_corner_freq_callback(struct work_struct *work)
  692. {
  693. struct delayed_work *hpf_delayed_work;
  694. struct hpf_work *hpf_work;
  695. struct va_macro_priv *va_priv;
  696. struct snd_soc_component *component;
  697. u16 dec_cfg_reg, hpf_gate_reg;
  698. u8 hpf_cut_off_freq;
  699. u16 adc_n = 0;
  700. hpf_delayed_work = to_delayed_work(work);
  701. hpf_work = container_of(hpf_delayed_work, struct hpf_work, dwork);
  702. va_priv = hpf_work->va_priv;
  703. component = va_priv->component;
  704. hpf_cut_off_freq = hpf_work->hpf_cut_off_freq;
  705. dec_cfg_reg = BOLERO_CDC_VA_TX0_TX_PATH_CFG0 +
  706. VA_MACRO_TX_PATH_OFFSET * hpf_work->decimator;
  707. hpf_gate_reg = BOLERO_CDC_VA_TX0_TX_PATH_SEC2 +
  708. VA_MACRO_TX_PATH_OFFSET * hpf_work->decimator;
  709. dev_dbg(va_priv->dev, "%s: decimator %u hpf_cut_of_freq 0x%x\n",
  710. __func__, hpf_work->decimator, hpf_cut_off_freq);
  711. adc_n = is_amic_enabled(component, hpf_work->decimator);
  712. if (adc_n < BOLERO_ADC_MAX) {
  713. /* analog mic clear TX hold */
  714. bolero_clear_amic_tx_hold(component->dev, adc_n);
  715. snd_soc_component_update_bits(component,
  716. dec_cfg_reg, TX_HPF_CUT_OFF_FREQ_MASK,
  717. hpf_cut_off_freq << 5);
  718. snd_soc_component_update_bits(component, hpf_gate_reg,
  719. 0x03, 0x02);
  720. /* Minimum 1 clk cycle delay is required as per HW spec */
  721. usleep_range(1000, 1010);
  722. snd_soc_component_update_bits(component, hpf_gate_reg,
  723. 0x03, 0x01);
  724. } else {
  725. snd_soc_component_update_bits(component,
  726. dec_cfg_reg, TX_HPF_CUT_OFF_FREQ_MASK,
  727. hpf_cut_off_freq << 5);
  728. snd_soc_component_update_bits(component, hpf_gate_reg,
  729. 0x02, 0x02);
  730. /* Minimum 1 clk cycle delay is required as per HW spec */
  731. usleep_range(1000, 1010);
  732. snd_soc_component_update_bits(component, hpf_gate_reg,
  733. 0x02, 0x00);
  734. }
  735. }
  736. static void va_macro_mute_update_callback(struct work_struct *work)
  737. {
  738. struct va_mute_work *va_mute_dwork;
  739. struct snd_soc_component *component = NULL;
  740. struct va_macro_priv *va_priv;
  741. struct delayed_work *delayed_work;
  742. u16 tx_vol_ctl_reg, decimator;
  743. delayed_work = to_delayed_work(work);
  744. va_mute_dwork = container_of(delayed_work, struct va_mute_work, dwork);
  745. va_priv = va_mute_dwork->va_priv;
  746. component = va_priv->component;
  747. decimator = va_mute_dwork->decimator;
  748. tx_vol_ctl_reg =
  749. BOLERO_CDC_VA_TX0_TX_PATH_CTL +
  750. VA_MACRO_TX_PATH_OFFSET * decimator;
  751. snd_soc_component_update_bits(component, tx_vol_ctl_reg, 0x10, 0x00);
  752. dev_dbg(va_priv->dev, "%s: decimator %u unmute\n",
  753. __func__, decimator);
  754. }
  755. static int va_macro_put_dec_enum(struct snd_kcontrol *kcontrol,
  756. struct snd_ctl_elem_value *ucontrol)
  757. {
  758. struct snd_soc_dapm_widget *widget =
  759. snd_soc_dapm_kcontrol_widget(kcontrol);
  760. struct snd_soc_component *component =
  761. snd_soc_dapm_to_component(widget->dapm);
  762. struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
  763. unsigned int val;
  764. u16 mic_sel_reg, dmic_clk_reg;
  765. struct device *va_dev = NULL;
  766. struct va_macro_priv *va_priv = NULL;
  767. if (!va_macro_get_data(component, &va_dev, &va_priv, __func__))
  768. return -EINVAL;
  769. val = ucontrol->value.enumerated.item[0];
  770. if (val > e->items - 1)
  771. return -EINVAL;
  772. dev_dbg(component->dev, "%s: wname: %s, val: 0x%x\n", __func__,
  773. widget->name, val);
  774. switch (e->reg) {
  775. case BOLERO_CDC_VA_INP_MUX_ADC_MUX0_CFG0:
  776. mic_sel_reg = BOLERO_CDC_VA_TX0_TX_PATH_CFG0;
  777. break;
  778. case BOLERO_CDC_VA_INP_MUX_ADC_MUX1_CFG0:
  779. mic_sel_reg = BOLERO_CDC_VA_TX1_TX_PATH_CFG0;
  780. break;
  781. case BOLERO_CDC_VA_INP_MUX_ADC_MUX2_CFG0:
  782. mic_sel_reg = BOLERO_CDC_VA_TX2_TX_PATH_CFG0;
  783. break;
  784. case BOLERO_CDC_VA_INP_MUX_ADC_MUX3_CFG0:
  785. mic_sel_reg = BOLERO_CDC_VA_TX3_TX_PATH_CFG0;
  786. break;
  787. case BOLERO_CDC_VA_INP_MUX_ADC_MUX4_CFG0:
  788. mic_sel_reg = BOLERO_CDC_VA_TX4_TX_PATH_CFG0;
  789. break;
  790. case BOLERO_CDC_VA_INP_MUX_ADC_MUX5_CFG0:
  791. mic_sel_reg = BOLERO_CDC_VA_TX5_TX_PATH_CFG0;
  792. break;
  793. case BOLERO_CDC_VA_INP_MUX_ADC_MUX6_CFG0:
  794. mic_sel_reg = BOLERO_CDC_VA_TX6_TX_PATH_CFG0;
  795. break;
  796. case BOLERO_CDC_VA_INP_MUX_ADC_MUX7_CFG0:
  797. mic_sel_reg = BOLERO_CDC_VA_TX7_TX_PATH_CFG0;
  798. break;
  799. default:
  800. dev_err(component->dev, "%s: e->reg: 0x%x not expected\n",
  801. __func__, e->reg);
  802. return -EINVAL;
  803. }
  804. if (strnstr(widget->name, "SMIC", strlen(widget->name))) {
  805. if (val != 0) {
  806. if (val < 5) {
  807. snd_soc_component_update_bits(component,
  808. mic_sel_reg,
  809. 1 << 7, 0x0 << 7);
  810. } else {
  811. snd_soc_component_update_bits(component,
  812. mic_sel_reg,
  813. 1 << 7, 0x1 << 7);
  814. snd_soc_component_update_bits(component,
  815. BOLERO_CDC_VA_TOP_CSR_DMIC_CFG,
  816. 0x80, 0x00);
  817. dmic_clk_reg =
  818. BOLERO_CDC_TX_TOP_CSR_SWR_DMIC0_CTL +
  819. ((val - 5)/2) * 4;
  820. snd_soc_component_update_bits(component,
  821. dmic_clk_reg,
  822. 0x0E, va_priv->dmic_clk_div << 0x1);
  823. }
  824. }
  825. } else {
  826. /* DMIC selected */
  827. if (val != 0)
  828. snd_soc_component_update_bits(component, mic_sel_reg,
  829. 1 << 7, 1 << 7);
  830. }
  831. return snd_soc_dapm_put_enum_double(kcontrol, ucontrol);
  832. }
  833. static int va_macro_lpi_get(struct snd_kcontrol *kcontrol,
  834. struct snd_ctl_elem_value *ucontrol)
  835. {
  836. struct snd_soc_component *component =
  837. snd_soc_kcontrol_component(kcontrol);
  838. struct device *va_dev = NULL;
  839. struct va_macro_priv *va_priv = NULL;
  840. if (!va_macro_get_data(component, &va_dev, &va_priv, __func__))
  841. return -EINVAL;
  842. ucontrol->value.integer.value[0] = va_priv->lpi_enable;
  843. return 0;
  844. }
  845. static int va_macro_lpi_put(struct snd_kcontrol *kcontrol,
  846. struct snd_ctl_elem_value *ucontrol)
  847. {
  848. struct snd_soc_component *component =
  849. snd_soc_kcontrol_component(kcontrol);
  850. struct device *va_dev = NULL;
  851. struct va_macro_priv *va_priv = NULL;
  852. if (!va_macro_get_data(component, &va_dev, &va_priv, __func__))
  853. return -EINVAL;
  854. va_priv->lpi_enable = ucontrol->value.integer.value[0];
  855. return 0;
  856. }
  857. static int va_macro_tx_mixer_get(struct snd_kcontrol *kcontrol,
  858. struct snd_ctl_elem_value *ucontrol)
  859. {
  860. struct snd_soc_dapm_widget *widget =
  861. snd_soc_dapm_kcontrol_widget(kcontrol);
  862. struct snd_soc_component *component =
  863. snd_soc_dapm_to_component(widget->dapm);
  864. struct soc_multi_mixer_control *mixer =
  865. ((struct soc_multi_mixer_control *)kcontrol->private_value);
  866. u32 dai_id = widget->shift;
  867. u32 dec_id = mixer->shift;
  868. struct device *va_dev = NULL;
  869. struct va_macro_priv *va_priv = NULL;
  870. if (!va_macro_get_data(component, &va_dev, &va_priv, __func__))
  871. return -EINVAL;
  872. if (test_bit(dec_id, &va_priv->active_ch_mask[dai_id]))
  873. ucontrol->value.integer.value[0] = 1;
  874. else
  875. ucontrol->value.integer.value[0] = 0;
  876. return 0;
  877. }
  878. static int va_macro_tx_mixer_put(struct snd_kcontrol *kcontrol,
  879. struct snd_ctl_elem_value *ucontrol)
  880. {
  881. struct snd_soc_dapm_widget *widget =
  882. snd_soc_dapm_kcontrol_widget(kcontrol);
  883. struct snd_soc_component *component =
  884. snd_soc_dapm_to_component(widget->dapm);
  885. struct snd_soc_dapm_update *update = NULL;
  886. struct soc_multi_mixer_control *mixer =
  887. ((struct soc_multi_mixer_control *)kcontrol->private_value);
  888. u32 dai_id = widget->shift;
  889. u32 dec_id = mixer->shift;
  890. u32 enable = ucontrol->value.integer.value[0];
  891. struct device *va_dev = NULL;
  892. struct va_macro_priv *va_priv = NULL;
  893. if (!va_macro_get_data(component, &va_dev, &va_priv, __func__))
  894. return -EINVAL;
  895. if (enable) {
  896. set_bit(dec_id, &va_priv->active_ch_mask[dai_id]);
  897. va_priv->active_ch_cnt[dai_id]++;
  898. } else {
  899. clear_bit(dec_id, &va_priv->active_ch_mask[dai_id]);
  900. va_priv->active_ch_cnt[dai_id]--;
  901. }
  902. snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, enable, update);
  903. return 0;
  904. }
  905. static int va_macro_enable_dmic(struct snd_soc_dapm_widget *w,
  906. struct snd_kcontrol *kcontrol, int event)
  907. {
  908. struct snd_soc_component *component =
  909. snd_soc_dapm_to_component(w->dapm);
  910. unsigned int dmic = 0;
  911. int ret = 0;
  912. char *wname;
  913. wname = strpbrk(w->name, "01234567");
  914. if (!wname) {
  915. dev_err(component->dev, "%s: widget not found\n", __func__);
  916. return -EINVAL;
  917. }
  918. ret = kstrtouint(wname, 10, &dmic);
  919. if (ret < 0) {
  920. dev_err(component->dev, "%s: Invalid DMIC line on the codec\n",
  921. __func__);
  922. return -EINVAL;
  923. }
  924. dev_dbg(component->dev, "%s: event %d DMIC%d\n",
  925. __func__, event, dmic);
  926. switch (event) {
  927. case SND_SOC_DAPM_PRE_PMU:
  928. bolero_dmic_clk_enable(component, dmic, DMIC_VA, true);
  929. break;
  930. case SND_SOC_DAPM_POST_PMD:
  931. bolero_dmic_clk_enable(component, dmic, DMIC_VA, false);
  932. break;
  933. }
  934. return 0;
  935. }
  936. static int va_macro_enable_dec(struct snd_soc_dapm_widget *w,
  937. struct snd_kcontrol *kcontrol, int event)
  938. {
  939. struct snd_soc_component *component =
  940. snd_soc_dapm_to_component(w->dapm);
  941. unsigned int decimator;
  942. u16 tx_vol_ctl_reg, dec_cfg_reg, hpf_gate_reg;
  943. u16 tx_gain_ctl_reg;
  944. u8 hpf_cut_off_freq;
  945. u16 adc_mux_reg = 0;
  946. struct device *va_dev = NULL;
  947. struct va_macro_priv *va_priv = NULL;
  948. int hpf_delay = BOLERO_CDC_VA_TX_DMIC_HPF_DELAY_MS;
  949. int unmute_delay = BOLERO_CDC_VA_TX_DMIC_UNMUTE_DELAY_MS;
  950. if (!va_macro_get_data(component, &va_dev, &va_priv, __func__))
  951. return -EINVAL;
  952. decimator = w->shift;
  953. dev_dbg(va_dev, "%s(): widget = %s decimator = %u\n", __func__,
  954. w->name, decimator);
  955. tx_vol_ctl_reg = BOLERO_CDC_VA_TX0_TX_PATH_CTL +
  956. VA_MACRO_TX_PATH_OFFSET * decimator;
  957. hpf_gate_reg = BOLERO_CDC_VA_TX0_TX_PATH_SEC2 +
  958. VA_MACRO_TX_PATH_OFFSET * decimator;
  959. dec_cfg_reg = BOLERO_CDC_VA_TX0_TX_PATH_CFG0 +
  960. VA_MACRO_TX_PATH_OFFSET * decimator;
  961. tx_gain_ctl_reg = BOLERO_CDC_VA_TX0_TX_VOL_CTL +
  962. VA_MACRO_TX_PATH_OFFSET * decimator;
  963. adc_mux_reg = BOLERO_CDC_VA_INP_MUX_ADC_MUX0_CFG1 +
  964. VA_MACRO_ADC_MUX_CFG_OFFSET * decimator;
  965. switch (event) {
  966. case SND_SOC_DAPM_PRE_PMU:
  967. /* Enable TX PGA Mute */
  968. snd_soc_component_update_bits(component,
  969. tx_vol_ctl_reg, 0x10, 0x10);
  970. break;
  971. case SND_SOC_DAPM_POST_PMU:
  972. /* Enable TX CLK */
  973. snd_soc_component_update_bits(component,
  974. tx_vol_ctl_reg, 0x20, 0x20);
  975. snd_soc_component_update_bits(component,
  976. hpf_gate_reg, 0x01, 0x00);
  977. /*
  978. * Minimum 1 clk cycle delay is required as per HW spec
  979. */
  980. usleep_range(1000, 1010);
  981. hpf_cut_off_freq = (snd_soc_component_read32(
  982. component, dec_cfg_reg) &
  983. TX_HPF_CUT_OFF_FREQ_MASK) >> 5;
  984. va_priv->va_hpf_work[decimator].hpf_cut_off_freq =
  985. hpf_cut_off_freq;
  986. if (hpf_cut_off_freq != CF_MIN_3DB_150HZ) {
  987. snd_soc_component_update_bits(component, dec_cfg_reg,
  988. TX_HPF_CUT_OFF_FREQ_MASK,
  989. CF_MIN_3DB_150HZ << 5);
  990. }
  991. if (is_amic_enabled(component, decimator) < BOLERO_ADC_MAX) {
  992. hpf_delay = BOLERO_CDC_VA_TX_AMIC_HPF_DELAY_MS;
  993. unmute_delay = BOLERO_CDC_VA_TX_AMIC_UNMUTE_DELAY_MS;
  994. if (va_tx_unmute_delay < unmute_delay)
  995. va_tx_unmute_delay = unmute_delay;
  996. }
  997. snd_soc_component_update_bits(component,
  998. hpf_gate_reg, 0x03, 0x03);
  999. /*
  1000. * Minimum 1 clk cycle delay is required as per HW spec
  1001. */
  1002. usleep_range(1000, 1010);
  1003. snd_soc_component_update_bits(component,
  1004. hpf_gate_reg, 0x02, 0x00);
  1005. snd_soc_component_update_bits(component,
  1006. hpf_gate_reg, 0x01, 0x01);
  1007. /*
  1008. * 6ms delay is required as per HW spec
  1009. */
  1010. usleep_range(6000, 6010);
  1011. /* schedule work queue to Remove Mute */
  1012. queue_delayed_work(system_freezable_wq,
  1013. &va_priv->va_mute_dwork[decimator].dwork,
  1014. msecs_to_jiffies(va_tx_unmute_delay));
  1015. if (va_priv->va_hpf_work[decimator].hpf_cut_off_freq !=
  1016. CF_MIN_3DB_150HZ)
  1017. queue_delayed_work(system_freezable_wq,
  1018. &va_priv->va_hpf_work[decimator].dwork,
  1019. msecs_to_jiffies(hpf_delay));
  1020. /* apply gain after decimator is enabled */
  1021. snd_soc_component_write(component, tx_gain_ctl_reg,
  1022. snd_soc_component_read32(component, tx_gain_ctl_reg));
  1023. if (va_priv->version == BOLERO_VERSION_2_0) {
  1024. if (snd_soc_component_read32(component, adc_mux_reg)
  1025. & SWR_MIC) {
  1026. snd_soc_component_update_bits(component,
  1027. BOLERO_CDC_TX_TOP_CSR_SWR_CTRL,
  1028. 0x01, 0x01);
  1029. snd_soc_component_update_bits(component,
  1030. BOLERO_CDC_TX_TOP_CSR_SWR_MIC0_CTL,
  1031. 0x0E, 0x0C);
  1032. snd_soc_component_update_bits(component,
  1033. BOLERO_CDC_TX_TOP_CSR_SWR_MIC1_CTL,
  1034. 0x0E, 0x0C);
  1035. snd_soc_component_update_bits(component,
  1036. BOLERO_CDC_TX_TOP_CSR_SWR_MIC2_CTL,
  1037. 0x0E, 0x00);
  1038. snd_soc_component_update_bits(component,
  1039. BOLERO_CDC_TX_TOP_CSR_SWR_MIC3_CTL,
  1040. 0x0E, 0x00);
  1041. snd_soc_component_update_bits(component,
  1042. BOLERO_CDC_TX_TOP_CSR_SWR_MIC4_CTL,
  1043. 0x0E, 0x00);
  1044. snd_soc_component_update_bits(component,
  1045. BOLERO_CDC_TX_TOP_CSR_SWR_MIC5_CTL,
  1046. 0x0E, 0x00);
  1047. }
  1048. }
  1049. break;
  1050. case SND_SOC_DAPM_PRE_PMD:
  1051. hpf_cut_off_freq =
  1052. va_priv->va_hpf_work[decimator].hpf_cut_off_freq;
  1053. snd_soc_component_update_bits(component, tx_vol_ctl_reg,
  1054. 0x10, 0x10);
  1055. if (cancel_delayed_work_sync(
  1056. &va_priv->va_hpf_work[decimator].dwork)) {
  1057. if (hpf_cut_off_freq != CF_MIN_3DB_150HZ) {
  1058. snd_soc_component_update_bits(component,
  1059. dec_cfg_reg,
  1060. TX_HPF_CUT_OFF_FREQ_MASK,
  1061. hpf_cut_off_freq << 5);
  1062. snd_soc_component_update_bits(component,
  1063. hpf_gate_reg,
  1064. 0x02, 0x02);
  1065. /*
  1066. * Minimum 1 clk cycle delay is required
  1067. * as per HW spec
  1068. */
  1069. usleep_range(1000, 1010);
  1070. snd_soc_component_update_bits(component,
  1071. hpf_gate_reg,
  1072. 0x02, 0x00);
  1073. }
  1074. }
  1075. cancel_delayed_work_sync(
  1076. &va_priv->va_mute_dwork[decimator].dwork);
  1077. if (va_priv->version == BOLERO_VERSION_2_0) {
  1078. if (snd_soc_component_read32(component, adc_mux_reg)
  1079. & SWR_MIC)
  1080. snd_soc_component_update_bits(component,
  1081. BOLERO_CDC_TX_TOP_CSR_SWR_CTRL,
  1082. 0x01, 0x00);
  1083. }
  1084. break;
  1085. case SND_SOC_DAPM_POST_PMD:
  1086. /* Disable TX CLK */
  1087. snd_soc_component_update_bits(component, tx_vol_ctl_reg,
  1088. 0x20, 0x00);
  1089. snd_soc_component_update_bits(component, tx_vol_ctl_reg,
  1090. 0x10, 0x00);
  1091. break;
  1092. }
  1093. return 0;
  1094. }
  1095. static int va_macro_enable_tx(struct snd_soc_dapm_widget *w,
  1096. struct snd_kcontrol *kcontrol, int event)
  1097. {
  1098. struct snd_soc_component *component =
  1099. snd_soc_dapm_to_component(w->dapm);
  1100. struct device *va_dev = NULL;
  1101. struct va_macro_priv *va_priv = NULL;
  1102. int ret = 0;
  1103. if (!va_macro_get_data(component, &va_dev, &va_priv, __func__))
  1104. return -EINVAL;
  1105. dev_dbg(va_dev, "%s: event = %d\n", __func__, event);
  1106. switch (event) {
  1107. case SND_SOC_DAPM_POST_PMU:
  1108. if (bolero_tx_clk_switch(component))
  1109. dev_dbg(va_dev, "%s: clock switch failed\n",__func__);
  1110. if (va_priv->tx_clk_status > 0) {
  1111. ret = bolero_clk_rsc_request_clock(va_priv->dev,
  1112. va_priv->default_clk_id,
  1113. TX_CORE_CLK,
  1114. false);
  1115. va_priv->tx_clk_status--;
  1116. }
  1117. break;
  1118. case SND_SOC_DAPM_PRE_PMD:
  1119. ret = bolero_clk_rsc_request_clock(va_priv->dev,
  1120. va_priv->default_clk_id,
  1121. TX_CORE_CLK,
  1122. true);
  1123. if (!ret)
  1124. va_priv->tx_clk_status++;
  1125. break;
  1126. default:
  1127. dev_err(va_priv->dev,
  1128. "%s: invalid DAPM event %d\n", __func__, event);
  1129. ret = -EINVAL;
  1130. break;
  1131. }
  1132. return ret;
  1133. }
  1134. static int va_macro_enable_micbias(struct snd_soc_dapm_widget *w,
  1135. struct snd_kcontrol *kcontrol, int event)
  1136. {
  1137. struct snd_soc_component *component =
  1138. snd_soc_dapm_to_component(w->dapm);
  1139. struct device *va_dev = NULL;
  1140. struct va_macro_priv *va_priv = NULL;
  1141. int ret = 0;
  1142. if (!va_macro_get_data(component, &va_dev, &va_priv, __func__))
  1143. return -EINVAL;
  1144. if (!va_priv->micb_supply) {
  1145. dev_err(va_dev,
  1146. "%s:regulator not provided in dtsi\n", __func__);
  1147. return -EINVAL;
  1148. }
  1149. switch (event) {
  1150. case SND_SOC_DAPM_PRE_PMU:
  1151. if (va_priv->micb_users++ > 0)
  1152. return 0;
  1153. ret = regulator_set_voltage(va_priv->micb_supply,
  1154. va_priv->micb_voltage,
  1155. va_priv->micb_voltage);
  1156. if (ret) {
  1157. dev_err(va_dev, "%s: Setting voltage failed, err = %d\n",
  1158. __func__, ret);
  1159. return ret;
  1160. }
  1161. ret = regulator_set_load(va_priv->micb_supply,
  1162. va_priv->micb_current);
  1163. if (ret) {
  1164. dev_err(va_dev, "%s: Setting current failed, err = %d\n",
  1165. __func__, ret);
  1166. return ret;
  1167. }
  1168. ret = regulator_enable(va_priv->micb_supply);
  1169. if (ret) {
  1170. dev_err(va_dev, "%s: regulator enable failed, err = %d\n",
  1171. __func__, ret);
  1172. return ret;
  1173. }
  1174. break;
  1175. case SND_SOC_DAPM_POST_PMD:
  1176. if (--va_priv->micb_users > 0)
  1177. return 0;
  1178. if (va_priv->micb_users < 0) {
  1179. va_priv->micb_users = 0;
  1180. dev_dbg(va_dev, "%s: regulator already disabled\n",
  1181. __func__);
  1182. return 0;
  1183. }
  1184. ret = regulator_disable(va_priv->micb_supply);
  1185. if (ret) {
  1186. dev_err(va_dev, "%s: regulator disable failed, err = %d\n",
  1187. __func__, ret);
  1188. return ret;
  1189. }
  1190. regulator_set_voltage(va_priv->micb_supply, 0,
  1191. va_priv->micb_voltage);
  1192. regulator_set_load(va_priv->micb_supply, 0);
  1193. break;
  1194. }
  1195. return 0;
  1196. }
  1197. static int va_macro_hw_params(struct snd_pcm_substream *substream,
  1198. struct snd_pcm_hw_params *params,
  1199. struct snd_soc_dai *dai)
  1200. {
  1201. int tx_fs_rate = -EINVAL;
  1202. struct snd_soc_component *component = dai->component;
  1203. u32 decimator, sample_rate;
  1204. u16 tx_fs_reg = 0;
  1205. struct device *va_dev = NULL;
  1206. struct va_macro_priv *va_priv = NULL;
  1207. if (!va_macro_get_data(component, &va_dev, &va_priv, __func__))
  1208. return -EINVAL;
  1209. dev_dbg(va_dev,
  1210. "%s: dai_name = %s DAI-ID %x rate %d num_ch %d\n", __func__,
  1211. dai->name, dai->id, params_rate(params),
  1212. params_channels(params));
  1213. sample_rate = params_rate(params);
  1214. switch (sample_rate) {
  1215. case 8000:
  1216. tx_fs_rate = 0;
  1217. break;
  1218. case 16000:
  1219. tx_fs_rate = 1;
  1220. break;
  1221. case 32000:
  1222. tx_fs_rate = 3;
  1223. break;
  1224. case 48000:
  1225. tx_fs_rate = 4;
  1226. break;
  1227. case 96000:
  1228. tx_fs_rate = 5;
  1229. break;
  1230. case 192000:
  1231. tx_fs_rate = 6;
  1232. break;
  1233. case 384000:
  1234. tx_fs_rate = 7;
  1235. break;
  1236. default:
  1237. dev_err(va_dev, "%s: Invalid TX sample rate: %d\n",
  1238. __func__, params_rate(params));
  1239. return -EINVAL;
  1240. }
  1241. for_each_set_bit(decimator, &va_priv->active_ch_mask[dai->id],
  1242. VA_MACRO_DEC_MAX) {
  1243. if (decimator >= 0) {
  1244. tx_fs_reg = BOLERO_CDC_VA_TX0_TX_PATH_CTL +
  1245. VA_MACRO_TX_PATH_OFFSET * decimator;
  1246. dev_dbg(va_dev, "%s: set DEC%u rate to %u\n",
  1247. __func__, decimator, sample_rate);
  1248. snd_soc_component_update_bits(component, tx_fs_reg,
  1249. 0x0F, tx_fs_rate);
  1250. } else {
  1251. dev_err(va_dev,
  1252. "%s: ERROR: Invalid decimator: %d\n",
  1253. __func__, decimator);
  1254. return -EINVAL;
  1255. }
  1256. }
  1257. return 0;
  1258. }
  1259. static int va_macro_get_channel_map(struct snd_soc_dai *dai,
  1260. unsigned int *tx_num, unsigned int *tx_slot,
  1261. unsigned int *rx_num, unsigned int *rx_slot)
  1262. {
  1263. struct snd_soc_component *component = dai->component;
  1264. struct device *va_dev = NULL;
  1265. struct va_macro_priv *va_priv = NULL;
  1266. if (!va_macro_get_data(component, &va_dev, &va_priv, __func__))
  1267. return -EINVAL;
  1268. switch (dai->id) {
  1269. case VA_MACRO_AIF1_CAP:
  1270. case VA_MACRO_AIF2_CAP:
  1271. case VA_MACRO_AIF3_CAP:
  1272. *tx_slot = va_priv->active_ch_mask[dai->id];
  1273. *tx_num = va_priv->active_ch_cnt[dai->id];
  1274. break;
  1275. default:
  1276. dev_err(va_dev, "%s: Invalid AIF\n", __func__);
  1277. break;
  1278. }
  1279. return 0;
  1280. }
  1281. static struct snd_soc_dai_ops va_macro_dai_ops = {
  1282. .hw_params = va_macro_hw_params,
  1283. .get_channel_map = va_macro_get_channel_map,
  1284. };
  1285. static struct snd_soc_dai_driver va_macro_dai[] = {
  1286. {
  1287. .name = "va_macro_tx1",
  1288. .id = VA_MACRO_AIF1_CAP,
  1289. .capture = {
  1290. .stream_name = "VA_AIF1 Capture",
  1291. .rates = VA_MACRO_RATES,
  1292. .formats = VA_MACRO_FORMATS,
  1293. .rate_max = 192000,
  1294. .rate_min = 8000,
  1295. .channels_min = 1,
  1296. .channels_max = 8,
  1297. },
  1298. .ops = &va_macro_dai_ops,
  1299. },
  1300. {
  1301. .name = "va_macro_tx2",
  1302. .id = VA_MACRO_AIF2_CAP,
  1303. .capture = {
  1304. .stream_name = "VA_AIF2 Capture",
  1305. .rates = VA_MACRO_RATES,
  1306. .formats = VA_MACRO_FORMATS,
  1307. .rate_max = 192000,
  1308. .rate_min = 8000,
  1309. .channels_min = 1,
  1310. .channels_max = 8,
  1311. },
  1312. .ops = &va_macro_dai_ops,
  1313. },
  1314. {
  1315. .name = "va_macro_tx3",
  1316. .id = VA_MACRO_AIF3_CAP,
  1317. .capture = {
  1318. .stream_name = "VA_AIF3 Capture",
  1319. .rates = VA_MACRO_RATES,
  1320. .formats = VA_MACRO_FORMATS,
  1321. .rate_max = 192000,
  1322. .rate_min = 8000,
  1323. .channels_min = 1,
  1324. .channels_max = 8,
  1325. },
  1326. .ops = &va_macro_dai_ops,
  1327. },
  1328. };
  1329. #define STRING(name) #name
  1330. #define VA_MACRO_DAPM_ENUM(name, reg, offset, text) \
  1331. static SOC_ENUM_SINGLE_DECL(name##_enum, reg, offset, text); \
  1332. static const struct snd_kcontrol_new name##_mux = \
  1333. SOC_DAPM_ENUM(STRING(name), name##_enum)
  1334. #define VA_MACRO_DAPM_ENUM_EXT(name, reg, offset, text, getname, putname) \
  1335. static SOC_ENUM_SINGLE_DECL(name##_enum, reg, offset, text); \
  1336. static const struct snd_kcontrol_new name##_mux = \
  1337. SOC_DAPM_ENUM_EXT(STRING(name), name##_enum, getname, putname)
  1338. #define VA_MACRO_DAPM_MUX(name, shift, kctl) \
  1339. SND_SOC_DAPM_MUX(name, SND_SOC_NOPM, shift, 0, &kctl##_mux)
  1340. static const char * const adc_mux_text[] = {
  1341. "MSM_DMIC", "SWR_MIC"
  1342. };
  1343. VA_MACRO_DAPM_ENUM(va_dec0, BOLERO_CDC_VA_INP_MUX_ADC_MUX0_CFG1,
  1344. 0, adc_mux_text);
  1345. VA_MACRO_DAPM_ENUM(va_dec1, BOLERO_CDC_VA_INP_MUX_ADC_MUX1_CFG1,
  1346. 0, adc_mux_text);
  1347. VA_MACRO_DAPM_ENUM(va_dec2, BOLERO_CDC_VA_INP_MUX_ADC_MUX2_CFG1,
  1348. 0, adc_mux_text);
  1349. VA_MACRO_DAPM_ENUM(va_dec3, BOLERO_CDC_VA_INP_MUX_ADC_MUX3_CFG1,
  1350. 0, adc_mux_text);
  1351. VA_MACRO_DAPM_ENUM(va_dec4, BOLERO_CDC_VA_INP_MUX_ADC_MUX4_CFG1,
  1352. 0, adc_mux_text);
  1353. VA_MACRO_DAPM_ENUM(va_dec5, BOLERO_CDC_VA_INP_MUX_ADC_MUX5_CFG1,
  1354. 0, adc_mux_text);
  1355. VA_MACRO_DAPM_ENUM(va_dec6, BOLERO_CDC_VA_INP_MUX_ADC_MUX6_CFG1,
  1356. 0, adc_mux_text);
  1357. VA_MACRO_DAPM_ENUM(va_dec7, BOLERO_CDC_VA_INP_MUX_ADC_MUX7_CFG1,
  1358. 0, adc_mux_text);
  1359. static const char * const dmic_mux_text[] = {
  1360. "ZERO", "DMIC0", "DMIC1", "DMIC2", "DMIC3",
  1361. "DMIC4", "DMIC5", "DMIC6", "DMIC7"
  1362. };
  1363. VA_MACRO_DAPM_ENUM_EXT(va_dmic0, BOLERO_CDC_VA_INP_MUX_ADC_MUX0_CFG0,
  1364. 4, dmic_mux_text, snd_soc_dapm_get_enum_double,
  1365. va_macro_put_dec_enum);
  1366. VA_MACRO_DAPM_ENUM_EXT(va_dmic1, BOLERO_CDC_VA_INP_MUX_ADC_MUX1_CFG0,
  1367. 4, dmic_mux_text, snd_soc_dapm_get_enum_double,
  1368. va_macro_put_dec_enum);
  1369. VA_MACRO_DAPM_ENUM_EXT(va_dmic2, BOLERO_CDC_VA_INP_MUX_ADC_MUX2_CFG0,
  1370. 4, dmic_mux_text, snd_soc_dapm_get_enum_double,
  1371. va_macro_put_dec_enum);
  1372. VA_MACRO_DAPM_ENUM_EXT(va_dmic3, BOLERO_CDC_VA_INP_MUX_ADC_MUX3_CFG0,
  1373. 4, dmic_mux_text, snd_soc_dapm_get_enum_double,
  1374. va_macro_put_dec_enum);
  1375. VA_MACRO_DAPM_ENUM_EXT(va_dmic4, BOLERO_CDC_VA_INP_MUX_ADC_MUX4_CFG0,
  1376. 4, dmic_mux_text, snd_soc_dapm_get_enum_double,
  1377. va_macro_put_dec_enum);
  1378. VA_MACRO_DAPM_ENUM_EXT(va_dmic5, BOLERO_CDC_VA_INP_MUX_ADC_MUX5_CFG0,
  1379. 4, dmic_mux_text, snd_soc_dapm_get_enum_double,
  1380. va_macro_put_dec_enum);
  1381. VA_MACRO_DAPM_ENUM_EXT(va_dmic6, BOLERO_CDC_VA_INP_MUX_ADC_MUX6_CFG0,
  1382. 4, dmic_mux_text, snd_soc_dapm_get_enum_double,
  1383. va_macro_put_dec_enum);
  1384. VA_MACRO_DAPM_ENUM_EXT(va_dmic7, BOLERO_CDC_VA_INP_MUX_ADC_MUX7_CFG0,
  1385. 4, dmic_mux_text, snd_soc_dapm_get_enum_double,
  1386. va_macro_put_dec_enum);
  1387. static const char * const smic_mux_text[] = {
  1388. "ZERO", "ADC0", "ADC1", "ADC2", "ADC3",
  1389. "SWR_DMIC0", "SWR_DMIC1", "SWR_DMIC2", "SWR_DMIC3",
  1390. "SWR_DMIC4", "SWR_DMIC5", "SWR_DMIC6", "SWR_DMIC7"
  1391. };
  1392. VA_MACRO_DAPM_ENUM_EXT(va_smic0, BOLERO_CDC_VA_INP_MUX_ADC_MUX0_CFG0,
  1393. 0, smic_mux_text, snd_soc_dapm_get_enum_double,
  1394. va_macro_put_dec_enum);
  1395. VA_MACRO_DAPM_ENUM_EXT(va_smic1, BOLERO_CDC_VA_INP_MUX_ADC_MUX1_CFG0,
  1396. 0, smic_mux_text, snd_soc_dapm_get_enum_double,
  1397. va_macro_put_dec_enum);
  1398. VA_MACRO_DAPM_ENUM_EXT(va_smic2, BOLERO_CDC_VA_INP_MUX_ADC_MUX2_CFG0,
  1399. 0, smic_mux_text, snd_soc_dapm_get_enum_double,
  1400. va_macro_put_dec_enum);
  1401. VA_MACRO_DAPM_ENUM_EXT(va_smic3, BOLERO_CDC_VA_INP_MUX_ADC_MUX3_CFG0,
  1402. 0, smic_mux_text, snd_soc_dapm_get_enum_double,
  1403. va_macro_put_dec_enum);
  1404. VA_MACRO_DAPM_ENUM_EXT(va_smic4, BOLERO_CDC_VA_INP_MUX_ADC_MUX4_CFG0,
  1405. 0, smic_mux_text, snd_soc_dapm_get_enum_double,
  1406. va_macro_put_dec_enum);
  1407. VA_MACRO_DAPM_ENUM_EXT(va_smic5, BOLERO_CDC_VA_INP_MUX_ADC_MUX5_CFG0,
  1408. 0, smic_mux_text, snd_soc_dapm_get_enum_double,
  1409. va_macro_put_dec_enum);
  1410. VA_MACRO_DAPM_ENUM_EXT(va_smic6, BOLERO_CDC_VA_INP_MUX_ADC_MUX6_CFG0,
  1411. 0, smic_mux_text, snd_soc_dapm_get_enum_double,
  1412. va_macro_put_dec_enum);
  1413. VA_MACRO_DAPM_ENUM_EXT(va_smic7, BOLERO_CDC_VA_INP_MUX_ADC_MUX7_CFG0,
  1414. 0, smic_mux_text, snd_soc_dapm_get_enum_double,
  1415. va_macro_put_dec_enum);
  1416. static const char * const smic_mux_text_v2[] = {
  1417. "ZERO", "SWR_MIC0", "SWR_MIC1", "SWR_MIC2", "SWR_MIC3",
  1418. "SWR_MIC4", "SWR_MIC5", "SWR_MIC6", "SWR_MIC7",
  1419. "SWR_MIC8", "SWR_MIC9", "SWR_MIC10", "SWR_MIC11"
  1420. };
  1421. VA_MACRO_DAPM_ENUM_EXT(va_smic0_v2, BOLERO_CDC_VA_INP_MUX_ADC_MUX0_CFG0,
  1422. 0, smic_mux_text_v2, snd_soc_dapm_get_enum_double,
  1423. va_macro_put_dec_enum);
  1424. VA_MACRO_DAPM_ENUM_EXT(va_smic1_v2, BOLERO_CDC_VA_INP_MUX_ADC_MUX1_CFG0,
  1425. 0, smic_mux_text_v2, snd_soc_dapm_get_enum_double,
  1426. va_macro_put_dec_enum);
  1427. VA_MACRO_DAPM_ENUM_EXT(va_smic2_v3, BOLERO_CDC_VA_INP_MUX_ADC_MUX2_CFG0,
  1428. 0, smic_mux_text_v2, snd_soc_dapm_get_enum_double,
  1429. va_macro_put_dec_enum);
  1430. VA_MACRO_DAPM_ENUM_EXT(va_smic3_v3, BOLERO_CDC_VA_INP_MUX_ADC_MUX3_CFG0,
  1431. 0, smic_mux_text_v2, snd_soc_dapm_get_enum_double,
  1432. va_macro_put_dec_enum);
  1433. static const struct snd_kcontrol_new va_aif1_cap_mixer[] = {
  1434. SOC_SINGLE_EXT("DEC0", SND_SOC_NOPM, VA_MACRO_DEC0, 1, 0,
  1435. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1436. SOC_SINGLE_EXT("DEC1", SND_SOC_NOPM, VA_MACRO_DEC1, 1, 0,
  1437. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1438. SOC_SINGLE_EXT("DEC2", SND_SOC_NOPM, VA_MACRO_DEC2, 1, 0,
  1439. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1440. SOC_SINGLE_EXT("DEC3", SND_SOC_NOPM, VA_MACRO_DEC3, 1, 0,
  1441. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1442. SOC_SINGLE_EXT("DEC4", SND_SOC_NOPM, VA_MACRO_DEC4, 1, 0,
  1443. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1444. SOC_SINGLE_EXT("DEC5", SND_SOC_NOPM, VA_MACRO_DEC5, 1, 0,
  1445. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1446. SOC_SINGLE_EXT("DEC6", SND_SOC_NOPM, VA_MACRO_DEC6, 1, 0,
  1447. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1448. SOC_SINGLE_EXT("DEC7", SND_SOC_NOPM, VA_MACRO_DEC7, 1, 0,
  1449. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1450. };
  1451. static const struct snd_kcontrol_new va_aif2_cap_mixer[] = {
  1452. SOC_SINGLE_EXT("DEC0", SND_SOC_NOPM, VA_MACRO_DEC0, 1, 0,
  1453. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1454. SOC_SINGLE_EXT("DEC1", SND_SOC_NOPM, VA_MACRO_DEC1, 1, 0,
  1455. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1456. SOC_SINGLE_EXT("DEC2", SND_SOC_NOPM, VA_MACRO_DEC2, 1, 0,
  1457. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1458. SOC_SINGLE_EXT("DEC3", SND_SOC_NOPM, VA_MACRO_DEC3, 1, 0,
  1459. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1460. SOC_SINGLE_EXT("DEC4", SND_SOC_NOPM, VA_MACRO_DEC4, 1, 0,
  1461. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1462. SOC_SINGLE_EXT("DEC5", SND_SOC_NOPM, VA_MACRO_DEC5, 1, 0,
  1463. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1464. SOC_SINGLE_EXT("DEC6", SND_SOC_NOPM, VA_MACRO_DEC6, 1, 0,
  1465. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1466. SOC_SINGLE_EXT("DEC7", SND_SOC_NOPM, VA_MACRO_DEC7, 1, 0,
  1467. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1468. };
  1469. static const struct snd_kcontrol_new va_aif3_cap_mixer[] = {
  1470. SOC_SINGLE_EXT("DEC0", SND_SOC_NOPM, VA_MACRO_DEC0, 1, 0,
  1471. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1472. SOC_SINGLE_EXT("DEC1", SND_SOC_NOPM, VA_MACRO_DEC1, 1, 0,
  1473. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1474. SOC_SINGLE_EXT("DEC2", SND_SOC_NOPM, VA_MACRO_DEC2, 1, 0,
  1475. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1476. SOC_SINGLE_EXT("DEC3", SND_SOC_NOPM, VA_MACRO_DEC3, 1, 0,
  1477. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1478. SOC_SINGLE_EXT("DEC4", SND_SOC_NOPM, VA_MACRO_DEC4, 1, 0,
  1479. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1480. SOC_SINGLE_EXT("DEC5", SND_SOC_NOPM, VA_MACRO_DEC5, 1, 0,
  1481. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1482. SOC_SINGLE_EXT("DEC6", SND_SOC_NOPM, VA_MACRO_DEC6, 1, 0,
  1483. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1484. SOC_SINGLE_EXT("DEC7", SND_SOC_NOPM, VA_MACRO_DEC7, 1, 0,
  1485. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1486. };
  1487. static const struct snd_kcontrol_new va_aif1_cap_mixer_v2[] = {
  1488. SOC_SINGLE_EXT("DEC0", SND_SOC_NOPM, VA_MACRO_DEC0, 1, 0,
  1489. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1490. SOC_SINGLE_EXT("DEC1", SND_SOC_NOPM, VA_MACRO_DEC1, 1, 0,
  1491. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1492. };
  1493. static const struct snd_kcontrol_new va_aif2_cap_mixer_v2[] = {
  1494. SOC_SINGLE_EXT("DEC0", SND_SOC_NOPM, VA_MACRO_DEC0, 1, 0,
  1495. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1496. SOC_SINGLE_EXT("DEC1", SND_SOC_NOPM, VA_MACRO_DEC1, 1, 0,
  1497. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1498. };
  1499. static const struct snd_kcontrol_new va_aif3_cap_mixer_v2[] = {
  1500. SOC_SINGLE_EXT("DEC0", SND_SOC_NOPM, VA_MACRO_DEC0, 1, 0,
  1501. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1502. SOC_SINGLE_EXT("DEC1", SND_SOC_NOPM, VA_MACRO_DEC1, 1, 0,
  1503. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1504. };
  1505. static const struct snd_kcontrol_new va_aif1_cap_mixer_v3[] = {
  1506. SOC_SINGLE_EXT("DEC0", SND_SOC_NOPM, VA_MACRO_DEC0, 1, 0,
  1507. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1508. SOC_SINGLE_EXT("DEC1", SND_SOC_NOPM, VA_MACRO_DEC1, 1, 0,
  1509. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1510. SOC_SINGLE_EXT("DEC2", SND_SOC_NOPM, VA_MACRO_DEC2, 1, 0,
  1511. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1512. SOC_SINGLE_EXT("DEC3", SND_SOC_NOPM, VA_MACRO_DEC3, 1, 0,
  1513. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1514. };
  1515. static const struct snd_kcontrol_new va_aif2_cap_mixer_v3[] = {
  1516. SOC_SINGLE_EXT("DEC0", SND_SOC_NOPM, VA_MACRO_DEC0, 1, 0,
  1517. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1518. SOC_SINGLE_EXT("DEC1", SND_SOC_NOPM, VA_MACRO_DEC1, 1, 0,
  1519. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1520. SOC_SINGLE_EXT("DEC2", SND_SOC_NOPM, VA_MACRO_DEC2, 1, 0,
  1521. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1522. SOC_SINGLE_EXT("DEC3", SND_SOC_NOPM, VA_MACRO_DEC3, 1, 0,
  1523. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1524. };
  1525. static const struct snd_kcontrol_new va_aif3_cap_mixer_v3[] = {
  1526. SOC_SINGLE_EXT("DEC0", SND_SOC_NOPM, VA_MACRO_DEC0, 1, 0,
  1527. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1528. SOC_SINGLE_EXT("DEC1", SND_SOC_NOPM, VA_MACRO_DEC1, 1, 0,
  1529. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1530. SOC_SINGLE_EXT("DEC2", SND_SOC_NOPM, VA_MACRO_DEC2, 1, 0,
  1531. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1532. SOC_SINGLE_EXT("DEC3", SND_SOC_NOPM, VA_MACRO_DEC3, 1, 0,
  1533. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1534. };
  1535. static const struct snd_soc_dapm_widget va_macro_dapm_widgets_common[] = {
  1536. SND_SOC_DAPM_AIF_OUT_E("VA_AIF1 CAP", "VA_AIF1 Capture", 0,
  1537. SND_SOC_NOPM, VA_MACRO_AIF1_CAP, 0,
  1538. va_macro_enable_tx, SND_SOC_DAPM_POST_PMU |
  1539. SND_SOC_DAPM_PRE_PMD),
  1540. SND_SOC_DAPM_AIF_OUT_E("VA_AIF2 CAP", "VA_AIF2 Capture", 0,
  1541. SND_SOC_NOPM, VA_MACRO_AIF2_CAP, 0,
  1542. va_macro_enable_tx, SND_SOC_DAPM_POST_PMU |
  1543. SND_SOC_DAPM_PRE_PMD),
  1544. SND_SOC_DAPM_AIF_OUT_E("VA_AIF3 CAP", "VA_AIF3 Capture", 0,
  1545. SND_SOC_NOPM, VA_MACRO_AIF3_CAP, 0,
  1546. va_macro_enable_tx, SND_SOC_DAPM_POST_PMU |
  1547. SND_SOC_DAPM_PRE_PMD),
  1548. VA_MACRO_DAPM_MUX("VA DMIC MUX0", 0, va_dmic0),
  1549. VA_MACRO_DAPM_MUX("VA DMIC MUX1", 0, va_dmic1),
  1550. VA_MACRO_DAPM_MUX("VA SMIC MUX0", 0, va_smic0_v2),
  1551. VA_MACRO_DAPM_MUX("VA SMIC MUX1", 0, va_smic1_v2),
  1552. SND_SOC_DAPM_INPUT("VA SWR_INPUT"),
  1553. SND_SOC_DAPM_SUPPLY("VA MIC BIAS1", SND_SOC_NOPM, 0, 0,
  1554. va_macro_enable_micbias,
  1555. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1556. SND_SOC_DAPM_ADC_E("VA DMIC0", NULL, SND_SOC_NOPM, 0, 0,
  1557. va_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1558. SND_SOC_DAPM_POST_PMD),
  1559. SND_SOC_DAPM_ADC_E("VA DMIC1", NULL, SND_SOC_NOPM, 0, 0,
  1560. va_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1561. SND_SOC_DAPM_POST_PMD),
  1562. SND_SOC_DAPM_ADC_E("VA DMIC2", NULL, SND_SOC_NOPM, 0, 0,
  1563. va_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1564. SND_SOC_DAPM_POST_PMD),
  1565. SND_SOC_DAPM_ADC_E("VA DMIC3", NULL, SND_SOC_NOPM, 0, 0,
  1566. va_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1567. SND_SOC_DAPM_POST_PMD),
  1568. SND_SOC_DAPM_ADC_E("VA DMIC4", NULL, SND_SOC_NOPM, 0, 0,
  1569. va_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1570. SND_SOC_DAPM_POST_PMD),
  1571. SND_SOC_DAPM_ADC_E("VA DMIC5", NULL, SND_SOC_NOPM, 0, 0,
  1572. va_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1573. SND_SOC_DAPM_POST_PMD),
  1574. SND_SOC_DAPM_ADC_E("VA DMIC6", NULL, SND_SOC_NOPM, 0, 0,
  1575. va_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1576. SND_SOC_DAPM_POST_PMD),
  1577. SND_SOC_DAPM_ADC_E("VA DMIC7", NULL, SND_SOC_NOPM, 0, 0,
  1578. va_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1579. SND_SOC_DAPM_POST_PMD),
  1580. SND_SOC_DAPM_MUX_E("VA DEC0 MUX", SND_SOC_NOPM, VA_MACRO_DEC0, 0,
  1581. &va_dec0_mux, va_macro_enable_dec,
  1582. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1583. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1584. SND_SOC_DAPM_MUX_E("VA DEC1 MUX", SND_SOC_NOPM, VA_MACRO_DEC1, 0,
  1585. &va_dec1_mux, va_macro_enable_dec,
  1586. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1587. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1588. SND_SOC_DAPM_SUPPLY_S("VA_MCLK", -1, SND_SOC_NOPM, 0, 0,
  1589. va_macro_mclk_event,
  1590. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1591. };
  1592. static const struct snd_soc_dapm_widget va_macro_dapm_widgets_v2[] = {
  1593. SND_SOC_DAPM_MIXER("VA_AIF1_CAP Mixer", SND_SOC_NOPM,
  1594. VA_MACRO_AIF1_CAP, 0,
  1595. va_aif1_cap_mixer_v2, ARRAY_SIZE(va_aif1_cap_mixer_v2)),
  1596. SND_SOC_DAPM_MIXER("VA_AIF2_CAP Mixer", SND_SOC_NOPM,
  1597. VA_MACRO_AIF2_CAP, 0,
  1598. va_aif2_cap_mixer_v2, ARRAY_SIZE(va_aif2_cap_mixer_v2)),
  1599. SND_SOC_DAPM_MIXER("VA_AIF3_CAP Mixer", SND_SOC_NOPM,
  1600. VA_MACRO_AIF3_CAP, 0,
  1601. va_aif3_cap_mixer_v2, ARRAY_SIZE(va_aif3_cap_mixer_v2)),
  1602. SND_SOC_DAPM_SUPPLY_S("VA_SWR_PWR", -1, SND_SOC_NOPM, 0, 0,
  1603. va_macro_swr_pwr_event_v2,
  1604. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1605. SND_SOC_DAPM_SUPPLY_S("VA_TX_SWR_CLK", 0, SND_SOC_NOPM, 0, 0,
  1606. va_macro_tx_swr_clk_event_v2,
  1607. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1608. };
  1609. static const struct snd_soc_dapm_widget va_macro_dapm_widgets_v3[] = {
  1610. SND_SOC_DAPM_MIXER("VA_AIF1_CAP Mixer", SND_SOC_NOPM,
  1611. VA_MACRO_AIF1_CAP, 0,
  1612. va_aif1_cap_mixer_v3, ARRAY_SIZE(va_aif1_cap_mixer_v3)),
  1613. SND_SOC_DAPM_MIXER("VA_AIF2_CAP Mixer", SND_SOC_NOPM,
  1614. VA_MACRO_AIF2_CAP, 0,
  1615. va_aif2_cap_mixer_v3, ARRAY_SIZE(va_aif2_cap_mixer_v3)),
  1616. SND_SOC_DAPM_MIXER("VA_AIF3_CAP Mixer", SND_SOC_NOPM,
  1617. VA_MACRO_AIF3_CAP, 0,
  1618. va_aif3_cap_mixer_v3, ARRAY_SIZE(va_aif3_cap_mixer_v3)),
  1619. VA_MACRO_DAPM_MUX("VA DMIC MUX2", 0, va_dmic2),
  1620. VA_MACRO_DAPM_MUX("VA DMIC MUX3", 0, va_dmic3),
  1621. VA_MACRO_DAPM_MUX("VA SMIC MUX2", 0, va_smic2_v3),
  1622. VA_MACRO_DAPM_MUX("VA SMIC MUX3", 0, va_smic3_v3),
  1623. SND_SOC_DAPM_MUX_E("VA DEC2 MUX", SND_SOC_NOPM, VA_MACRO_DEC2, 0,
  1624. &va_dec2_mux, va_macro_enable_dec,
  1625. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1626. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1627. SND_SOC_DAPM_MUX_E("VA DEC3 MUX", SND_SOC_NOPM, VA_MACRO_DEC3, 0,
  1628. &va_dec3_mux, va_macro_enable_dec,
  1629. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1630. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1631. SND_SOC_DAPM_SUPPLY_S("VA_SWR_PWR", -1, SND_SOC_NOPM, 0, 0,
  1632. va_macro_swr_pwr_event,
  1633. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1634. };
  1635. static const struct snd_soc_dapm_widget va_macro_dapm_widgets[] = {
  1636. SND_SOC_DAPM_AIF_OUT_E("VA_AIF1 CAP", "VA_AIF1 Capture", 0,
  1637. SND_SOC_NOPM, VA_MACRO_AIF1_CAP, 0,
  1638. va_macro_enable_tx, SND_SOC_DAPM_POST_PMU |
  1639. SND_SOC_DAPM_PRE_PMD),
  1640. SND_SOC_DAPM_AIF_OUT_E("VA_AIF2 CAP", "VA_AIF2 Capture", 0,
  1641. SND_SOC_NOPM, VA_MACRO_AIF2_CAP, 0,
  1642. va_macro_enable_tx, SND_SOC_DAPM_POST_PMU |
  1643. SND_SOC_DAPM_PRE_PMD),
  1644. SND_SOC_DAPM_AIF_OUT_E("VA_AIF3 CAP", "VA_AIF3 Capture", 0,
  1645. SND_SOC_NOPM, VA_MACRO_AIF3_CAP, 0,
  1646. va_macro_enable_tx, SND_SOC_DAPM_POST_PMU |
  1647. SND_SOC_DAPM_PRE_PMD),
  1648. SND_SOC_DAPM_MIXER("VA_AIF1_CAP Mixer", SND_SOC_NOPM,
  1649. VA_MACRO_AIF1_CAP, 0,
  1650. va_aif1_cap_mixer, ARRAY_SIZE(va_aif1_cap_mixer)),
  1651. SND_SOC_DAPM_MIXER("VA_AIF2_CAP Mixer", SND_SOC_NOPM,
  1652. VA_MACRO_AIF2_CAP, 0,
  1653. va_aif2_cap_mixer, ARRAY_SIZE(va_aif2_cap_mixer)),
  1654. SND_SOC_DAPM_MIXER("VA_AIF3_CAP Mixer", SND_SOC_NOPM,
  1655. VA_MACRO_AIF3_CAP, 0,
  1656. va_aif3_cap_mixer, ARRAY_SIZE(va_aif3_cap_mixer)),
  1657. VA_MACRO_DAPM_MUX("VA DMIC MUX0", 0, va_dmic0),
  1658. VA_MACRO_DAPM_MUX("VA DMIC MUX1", 0, va_dmic1),
  1659. VA_MACRO_DAPM_MUX("VA DMIC MUX2", 0, va_dmic2),
  1660. VA_MACRO_DAPM_MUX("VA DMIC MUX3", 0, va_dmic3),
  1661. VA_MACRO_DAPM_MUX("VA DMIC MUX4", 0, va_dmic4),
  1662. VA_MACRO_DAPM_MUX("VA DMIC MUX5", 0, va_dmic5),
  1663. VA_MACRO_DAPM_MUX("VA DMIC MUX6", 0, va_dmic6),
  1664. VA_MACRO_DAPM_MUX("VA DMIC MUX7", 0, va_dmic7),
  1665. VA_MACRO_DAPM_MUX("VA SMIC MUX0", 0, va_smic0),
  1666. VA_MACRO_DAPM_MUX("VA SMIC MUX1", 0, va_smic1),
  1667. VA_MACRO_DAPM_MUX("VA SMIC MUX2", 0, va_smic2),
  1668. VA_MACRO_DAPM_MUX("VA SMIC MUX3", 0, va_smic3),
  1669. VA_MACRO_DAPM_MUX("VA SMIC MUX4", 0, va_smic4),
  1670. VA_MACRO_DAPM_MUX("VA SMIC MUX5", 0, va_smic5),
  1671. VA_MACRO_DAPM_MUX("VA SMIC MUX6", 0, va_smic6),
  1672. VA_MACRO_DAPM_MUX("VA SMIC MUX7", 0, va_smic7),
  1673. SND_SOC_DAPM_SUPPLY("VA MIC BIAS1", SND_SOC_NOPM, 0, 0,
  1674. va_macro_enable_micbias,
  1675. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1676. SND_SOC_DAPM_ADC_E("VA DMIC0", NULL, SND_SOC_NOPM, 0, 0,
  1677. va_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1678. SND_SOC_DAPM_POST_PMD),
  1679. SND_SOC_DAPM_ADC_E("VA DMIC1", NULL, SND_SOC_NOPM, 0, 0,
  1680. va_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1681. SND_SOC_DAPM_POST_PMD),
  1682. SND_SOC_DAPM_ADC_E("VA DMIC2", NULL, SND_SOC_NOPM, 0, 0,
  1683. va_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1684. SND_SOC_DAPM_POST_PMD),
  1685. SND_SOC_DAPM_ADC_E("VA DMIC3", NULL, SND_SOC_NOPM, 0, 0,
  1686. va_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1687. SND_SOC_DAPM_POST_PMD),
  1688. SND_SOC_DAPM_ADC_E("VA DMIC4", NULL, SND_SOC_NOPM, 0, 0,
  1689. va_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1690. SND_SOC_DAPM_POST_PMD),
  1691. SND_SOC_DAPM_ADC_E("VA DMIC5", NULL, SND_SOC_NOPM, 0, 0,
  1692. va_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1693. SND_SOC_DAPM_POST_PMD),
  1694. SND_SOC_DAPM_ADC_E("VA DMIC6", NULL, SND_SOC_NOPM, 0, 0,
  1695. va_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1696. SND_SOC_DAPM_POST_PMD),
  1697. SND_SOC_DAPM_ADC_E("VA DMIC7", NULL, SND_SOC_NOPM, 0, 0,
  1698. va_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1699. SND_SOC_DAPM_POST_PMD),
  1700. SND_SOC_DAPM_INPUT("VA SWR_ADC0"),
  1701. SND_SOC_DAPM_INPUT("VA SWR_ADC1"),
  1702. SND_SOC_DAPM_INPUT("VA SWR_ADC2"),
  1703. SND_SOC_DAPM_INPUT("VA SWR_ADC3"),
  1704. SND_SOC_DAPM_INPUT("VA SWR_MIC0"),
  1705. SND_SOC_DAPM_INPUT("VA SWR_MIC1"),
  1706. SND_SOC_DAPM_INPUT("VA SWR_MIC2"),
  1707. SND_SOC_DAPM_INPUT("VA SWR_MIC3"),
  1708. SND_SOC_DAPM_INPUT("VA SWR_MIC4"),
  1709. SND_SOC_DAPM_INPUT("VA SWR_MIC5"),
  1710. SND_SOC_DAPM_INPUT("VA SWR_MIC6"),
  1711. SND_SOC_DAPM_INPUT("VA SWR_MIC7"),
  1712. SND_SOC_DAPM_MUX_E("VA DEC0 MUX", SND_SOC_NOPM, VA_MACRO_DEC0, 0,
  1713. &va_dec0_mux, va_macro_enable_dec,
  1714. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1715. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1716. SND_SOC_DAPM_MUX_E("VA DEC1 MUX", SND_SOC_NOPM, VA_MACRO_DEC1, 0,
  1717. &va_dec1_mux, va_macro_enable_dec,
  1718. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1719. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1720. SND_SOC_DAPM_MUX_E("VA DEC2 MUX", SND_SOC_NOPM, VA_MACRO_DEC2, 0,
  1721. &va_dec2_mux, va_macro_enable_dec,
  1722. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1723. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1724. SND_SOC_DAPM_MUX_E("VA DEC3 MUX", SND_SOC_NOPM, VA_MACRO_DEC3, 0,
  1725. &va_dec3_mux, va_macro_enable_dec,
  1726. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1727. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1728. SND_SOC_DAPM_MUX_E("VA DEC4 MUX", SND_SOC_NOPM, VA_MACRO_DEC4, 0,
  1729. &va_dec4_mux, va_macro_enable_dec,
  1730. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1731. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1732. SND_SOC_DAPM_MUX_E("VA DEC5 MUX", SND_SOC_NOPM, VA_MACRO_DEC5, 0,
  1733. &va_dec5_mux, va_macro_enable_dec,
  1734. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1735. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1736. SND_SOC_DAPM_MUX_E("VA DEC6 MUX", SND_SOC_NOPM, VA_MACRO_DEC6, 0,
  1737. &va_dec6_mux, va_macro_enable_dec,
  1738. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1739. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1740. SND_SOC_DAPM_MUX_E("VA DEC7 MUX", SND_SOC_NOPM, VA_MACRO_DEC7, 0,
  1741. &va_dec7_mux, va_macro_enable_dec,
  1742. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1743. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1744. SND_SOC_DAPM_SUPPLY_S("VA_SWR_PWR", -1, SND_SOC_NOPM, 0, 0,
  1745. va_macro_swr_pwr_event,
  1746. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1747. SND_SOC_DAPM_SUPPLY_S("VA_MCLK", -1, SND_SOC_NOPM, 0, 0,
  1748. va_macro_mclk_event,
  1749. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1750. };
  1751. static const struct snd_soc_dapm_widget va_macro_wod_dapm_widgets[] = {
  1752. SND_SOC_DAPM_SUPPLY_S("VA_MCLK", -1, SND_SOC_NOPM, 0, 0,
  1753. va_macro_mclk_event,
  1754. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1755. };
  1756. static const struct snd_soc_dapm_route va_audio_map_common[] = {
  1757. {"VA_AIF1 CAP", NULL, "VA_MCLK"},
  1758. {"VA_AIF2 CAP", NULL, "VA_MCLK"},
  1759. {"VA_AIF3 CAP", NULL, "VA_MCLK"},
  1760. {"VA_AIF1 CAP", NULL, "VA_AIF1_CAP Mixer"},
  1761. {"VA_AIF2 CAP", NULL, "VA_AIF2_CAP Mixer"},
  1762. {"VA_AIF3 CAP", NULL, "VA_AIF3_CAP Mixer"},
  1763. {"VA_AIF1_CAP Mixer", "DEC0", "VA DEC0 MUX"},
  1764. {"VA_AIF1_CAP Mixer", "DEC1", "VA DEC1 MUX"},
  1765. {"VA_AIF2_CAP Mixer", "DEC0", "VA DEC0 MUX"},
  1766. {"VA_AIF2_CAP Mixer", "DEC1", "VA DEC1 MUX"},
  1767. {"VA_AIF3_CAP Mixer", "DEC0", "VA DEC0 MUX"},
  1768. {"VA_AIF3_CAP Mixer", "DEC1", "VA DEC1 MUX"},
  1769. {"VA DEC0 MUX", "MSM_DMIC", "VA DMIC MUX0"},
  1770. {"VA DMIC MUX0", "DMIC0", "VA DMIC0"},
  1771. {"VA DMIC MUX0", "DMIC1", "VA DMIC1"},
  1772. {"VA DMIC MUX0", "DMIC2", "VA DMIC2"},
  1773. {"VA DMIC MUX0", "DMIC3", "VA DMIC3"},
  1774. {"VA DMIC MUX0", "DMIC4", "VA DMIC4"},
  1775. {"VA DMIC MUX0", "DMIC5", "VA DMIC5"},
  1776. {"VA DMIC MUX0", "DMIC6", "VA DMIC6"},
  1777. {"VA DMIC MUX0", "DMIC7", "VA DMIC7"},
  1778. {"VA DEC0 MUX", "SWR_MIC", "VA SMIC MUX0"},
  1779. {"VA SMIC MUX0", "SWR_MIC0", "VA SWR_INPUT"},
  1780. {"VA SMIC MUX0", "SWR_MIC1", "VA SWR_INPUT"},
  1781. {"VA SMIC MUX0", "SWR_MIC2", "VA SWR_INPUT"},
  1782. {"VA SMIC MUX0", "SWR_MIC3", "VA SWR_INPUT"},
  1783. {"VA SMIC MUX0", "SWR_MIC4", "VA SWR_INPUT"},
  1784. {"VA SMIC MUX0", "SWR_MIC5", "VA SWR_INPUT"},
  1785. {"VA SMIC MUX0", "SWR_MIC6", "VA SWR_INPUT"},
  1786. {"VA SMIC MUX0", "SWR_MIC7", "VA SWR_INPUT"},
  1787. {"VA SMIC MUX0", "SWR_MIC8", "VA SWR_INPUT"},
  1788. {"VA SMIC MUX0", "SWR_MIC9", "VA SWR_INPUT"},
  1789. {"VA SMIC MUX0", "SWR_MIC10", "VA SWR_INPUT"},
  1790. {"VA SMIC MUX0", "SWR_MIC11", "VA SWR_INPUT"},
  1791. {"VA DEC1 MUX", "MSM_DMIC", "VA DMIC MUX1"},
  1792. {"VA DMIC MUX1", "DMIC0", "VA DMIC0"},
  1793. {"VA DMIC MUX1", "DMIC1", "VA DMIC1"},
  1794. {"VA DMIC MUX1", "DMIC2", "VA DMIC2"},
  1795. {"VA DMIC MUX1", "DMIC3", "VA DMIC3"},
  1796. {"VA DMIC MUX1", "DMIC4", "VA DMIC4"},
  1797. {"VA DMIC MUX1", "DMIC5", "VA DMIC5"},
  1798. {"VA DMIC MUX1", "DMIC6", "VA DMIC6"},
  1799. {"VA DMIC MUX1", "DMIC7", "VA DMIC7"},
  1800. {"VA DEC1 MUX", "SWR_MIC", "VA SMIC MUX1"},
  1801. {"VA SMIC MUX1", "SWR_MIC0", "VA SWR_INPUT"},
  1802. {"VA SMIC MUX1", "SWR_MIC1", "VA SWR_INPUT"},
  1803. {"VA SMIC MUX1", "SWR_MIC2", "VA SWR_INPUT"},
  1804. {"VA SMIC MUX1", "SWR_MIC3", "VA SWR_INPUT"},
  1805. {"VA SMIC MUX1", "SWR_MIC4", "VA SWR_INPUT"},
  1806. {"VA SMIC MUX1", "SWR_MIC5", "VA SWR_INPUT"},
  1807. {"VA SMIC MUX1", "SWR_MIC6", "VA SWR_INPUT"},
  1808. {"VA SMIC MUX1", "SWR_MIC7", "VA SWR_INPUT"},
  1809. {"VA SMIC MUX1", "SWR_MIC8", "VA SWR_INPUT"},
  1810. {"VA SMIC MUX1", "SWR_MIC9", "VA SWR_INPUT"},
  1811. {"VA SMIC MUX1", "SWR_MIC10", "VA SWR_INPUT"},
  1812. {"VA SMIC MUX1", "SWR_MIC11", "VA SWR_INPUT"},
  1813. {"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
  1814. {"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
  1815. {"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
  1816. {"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
  1817. {"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
  1818. {"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
  1819. {"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
  1820. {"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
  1821. {"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
  1822. {"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
  1823. {"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
  1824. {"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
  1825. };
  1826. static const struct snd_soc_dapm_route va_audio_map_v3[] = {
  1827. {"VA_AIF1_CAP Mixer", "DEC2", "VA DEC2 MUX"},
  1828. {"VA_AIF1_CAP Mixer", "DEC3", "VA DEC3 MUX"},
  1829. {"VA_AIF2_CAP Mixer", "DEC2", "VA DEC2 MUX"},
  1830. {"VA_AIF2_CAP Mixer", "DEC3", "VA DEC3 MUX"},
  1831. {"VA_AIF3_CAP Mixer", "DEC2", "VA DEC2 MUX"},
  1832. {"VA_AIF3_CAP Mixer", "DEC3", "VA DEC3 MUX"},
  1833. {"VA DEC2 MUX", "MSM_DMIC", "VA DMIC MUX2"},
  1834. {"VA DMIC MUX2", "DMIC0", "VA DMIC0"},
  1835. {"VA DMIC MUX2", "DMIC1", "VA DMIC1"},
  1836. {"VA DMIC MUX2", "DMIC2", "VA DMIC2"},
  1837. {"VA DMIC MUX2", "DMIC3", "VA DMIC3"},
  1838. {"VA DMIC MUX2", "DMIC4", "VA DMIC4"},
  1839. {"VA DMIC MUX2", "DMIC5", "VA DMIC5"},
  1840. {"VA DMIC MUX2", "DMIC6", "VA DMIC6"},
  1841. {"VA DMIC MUX2", "DMIC7", "VA DMIC7"},
  1842. {"VA DEC2 MUX", "SWR_MIC", "VA SMIC MUX2"},
  1843. {"VA SMIC MUX2", "SWR_MIC0", "VA SWR_INPUT"},
  1844. {"VA SMIC MUX2", "SWR_MIC1", "VA SWR_INPUT"},
  1845. {"VA SMIC MUX2", "SWR_MIC2", "VA SWR_INPUT"},
  1846. {"VA SMIC MUX2", "SWR_MIC3", "VA SWR_INPUT"},
  1847. {"VA SMIC MUX2", "SWR_MIC4", "VA SWR_INPUT"},
  1848. {"VA SMIC MUX2", "SWR_MIC5", "VA SWR_INPUT"},
  1849. {"VA SMIC MUX2", "SWR_MIC6", "VA SWR_INPUT"},
  1850. {"VA SMIC MUX2", "SWR_MIC7", "VA SWR_INPUT"},
  1851. {"VA SMIC MUX2", "SWR_MIC8", "VA SWR_INPUT"},
  1852. {"VA SMIC MUX2", "SWR_MIC9", "VA SWR_INPUT"},
  1853. {"VA SMIC MUX2", "SWR_MIC10", "VA SWR_INPUT"},
  1854. {"VA SMIC MUX2", "SWR_MIC11", "VA SWR_INPUT"},
  1855. {"VA DEC3 MUX", "MSM_DMIC", "VA DMIC MUX3"},
  1856. {"VA DMIC MUX3", "DMIC0", "VA DMIC0"},
  1857. {"VA DMIC MUX3", "DMIC1", "VA DMIC1"},
  1858. {"VA DMIC MUX3", "DMIC2", "VA DMIC2"},
  1859. {"VA DMIC MUX3", "DMIC3", "VA DMIC3"},
  1860. {"VA DMIC MUX3", "DMIC4", "VA DMIC4"},
  1861. {"VA DMIC MUX3", "DMIC5", "VA DMIC5"},
  1862. {"VA DMIC MUX3", "DMIC6", "VA DMIC6"},
  1863. {"VA DMIC MUX3", "DMIC7", "VA DMIC7"},
  1864. {"VA DEC3 MUX", "SWR_MIC", "VA SMIC MUX3"},
  1865. {"VA SMIC MUX3", "SWR_MIC0", "VA SWR_INPUT"},
  1866. {"VA SMIC MUX3", "SWR_MIC1", "VA SWR_INPUT"},
  1867. {"VA SMIC MUX3", "SWR_MIC2", "VA SWR_INPUT"},
  1868. {"VA SMIC MUX3", "SWR_MIC3", "VA SWR_INPUT"},
  1869. {"VA SMIC MUX3", "SWR_MIC4", "VA SWR_INPUT"},
  1870. {"VA SMIC MUX3", "SWR_MIC5", "VA SWR_INPUT"},
  1871. {"VA SMIC MUX3", "SWR_MIC6", "VA SWR_INPUT"},
  1872. {"VA SMIC MUX3", "SWR_MIC7", "VA SWR_INPUT"},
  1873. {"VA SMIC MUX3", "SWR_MIC8", "VA SWR_INPUT"},
  1874. {"VA SMIC MUX3", "SWR_MIC9", "VA SWR_INPUT"},
  1875. {"VA SMIC MUX3", "SWR_MIC10", "VA SWR_INPUT"},
  1876. {"VA SMIC MUX3", "SWR_MIC11", "VA SWR_INPUT"},
  1877. };
  1878. static const struct snd_soc_dapm_route va_audio_map[] = {
  1879. {"VA_AIF1 CAP", NULL, "VA_MCLK"},
  1880. {"VA_AIF2 CAP", NULL, "VA_MCLK"},
  1881. {"VA_AIF3 CAP", NULL, "VA_MCLK"},
  1882. {"VA_AIF1 CAP", NULL, "VA_AIF1_CAP Mixer"},
  1883. {"VA_AIF2 CAP", NULL, "VA_AIF2_CAP Mixer"},
  1884. {"VA_AIF3 CAP", NULL, "VA_AIF3_CAP Mixer"},
  1885. {"VA_AIF1_CAP Mixer", "DEC0", "VA DEC0 MUX"},
  1886. {"VA_AIF1_CAP Mixer", "DEC1", "VA DEC1 MUX"},
  1887. {"VA_AIF1_CAP Mixer", "DEC2", "VA DEC2 MUX"},
  1888. {"VA_AIF1_CAP Mixer", "DEC3", "VA DEC3 MUX"},
  1889. {"VA_AIF1_CAP Mixer", "DEC4", "VA DEC4 MUX"},
  1890. {"VA_AIF1_CAP Mixer", "DEC5", "VA DEC5 MUX"},
  1891. {"VA_AIF1_CAP Mixer", "DEC6", "VA DEC6 MUX"},
  1892. {"VA_AIF1_CAP Mixer", "DEC7", "VA DEC7 MUX"},
  1893. {"VA_AIF2_CAP Mixer", "DEC0", "VA DEC0 MUX"},
  1894. {"VA_AIF2_CAP Mixer", "DEC1", "VA DEC1 MUX"},
  1895. {"VA_AIF2_CAP Mixer", "DEC2", "VA DEC2 MUX"},
  1896. {"VA_AIF2_CAP Mixer", "DEC3", "VA DEC3 MUX"},
  1897. {"VA_AIF2_CAP Mixer", "DEC4", "VA DEC4 MUX"},
  1898. {"VA_AIF2_CAP Mixer", "DEC5", "VA DEC5 MUX"},
  1899. {"VA_AIF2_CAP Mixer", "DEC6", "VA DEC6 MUX"},
  1900. {"VA_AIF2_CAP Mixer", "DEC7", "VA DEC7 MUX"},
  1901. {"VA_AIF3_CAP Mixer", "DEC0", "VA DEC0 MUX"},
  1902. {"VA_AIF3_CAP Mixer", "DEC1", "VA DEC1 MUX"},
  1903. {"VA_AIF3_CAP Mixer", "DEC2", "VA DEC2 MUX"},
  1904. {"VA_AIF3_CAP Mixer", "DEC3", "VA DEC3 MUX"},
  1905. {"VA_AIF3_CAP Mixer", "DEC4", "VA DEC4 MUX"},
  1906. {"VA_AIF3_CAP Mixer", "DEC5", "VA DEC5 MUX"},
  1907. {"VA_AIF3_CAP Mixer", "DEC6", "VA DEC6 MUX"},
  1908. {"VA_AIF3_CAP Mixer", "DEC7", "VA DEC7 MUX"},
  1909. {"VA DEC0 MUX", "MSM_DMIC", "VA DMIC MUX0"},
  1910. {"VA DMIC MUX0", "DMIC0", "VA DMIC0"},
  1911. {"VA DMIC MUX0", "DMIC1", "VA DMIC1"},
  1912. {"VA DMIC MUX0", "DMIC2", "VA DMIC2"},
  1913. {"VA DMIC MUX0", "DMIC3", "VA DMIC3"},
  1914. {"VA DMIC MUX0", "DMIC4", "VA DMIC4"},
  1915. {"VA DMIC MUX0", "DMIC5", "VA DMIC5"},
  1916. {"VA DMIC MUX0", "DMIC6", "VA DMIC6"},
  1917. {"VA DMIC MUX0", "DMIC7", "VA DMIC7"},
  1918. {"VA DEC0 MUX", "SWR_MIC", "VA SMIC MUX0"},
  1919. {"VA SMIC MUX0", "ADC0", "VA SWR_ADC0"},
  1920. {"VA SMIC MUX0", "ADC1", "VA SWR_ADC1"},
  1921. {"VA SMIC MUX0", "ADC2", "VA SWR_ADC2"},
  1922. {"VA SMIC MUX0", "ADC3", "VA SWR_ADC3"},
  1923. {"VA SMIC MUX0", "SWR_DMIC0", "VA SWR_MIC0"},
  1924. {"VA SMIC MUX0", "SWR_DMIC1", "VA SWR_MIC1"},
  1925. {"VA SMIC MUX0", "SWR_DMIC2", "VA SWR_MIC2"},
  1926. {"VA SMIC MUX0", "SWR_DMIC3", "VA SWR_MIC3"},
  1927. {"VA SMIC MUX0", "SWR_DMIC4", "VA SWR_MIC4"},
  1928. {"VA SMIC MUX0", "SWR_DMIC5", "VA SWR_MIC5"},
  1929. {"VA SMIC MUX0", "SWR_DMIC6", "VA SWR_MIC6"},
  1930. {"VA SMIC MUX0", "SWR_DMIC7", "VA SWR_MIC7"},
  1931. {"VA DEC1 MUX", "MSM_DMIC", "VA DMIC MUX1"},
  1932. {"VA DMIC MUX1", "DMIC0", "VA DMIC0"},
  1933. {"VA DMIC MUX1", "DMIC1", "VA DMIC1"},
  1934. {"VA DMIC MUX1", "DMIC2", "VA DMIC2"},
  1935. {"VA DMIC MUX1", "DMIC3", "VA DMIC3"},
  1936. {"VA DMIC MUX1", "DMIC4", "VA DMIC4"},
  1937. {"VA DMIC MUX1", "DMIC5", "VA DMIC5"},
  1938. {"VA DMIC MUX1", "DMIC6", "VA DMIC6"},
  1939. {"VA DMIC MUX1", "DMIC7", "VA DMIC7"},
  1940. {"VA DEC1 MUX", "SWR_MIC", "VA SMIC MUX1"},
  1941. {"VA SMIC MUX1", "ADC0", "VA SWR_ADC0"},
  1942. {"VA SMIC MUX1", "ADC1", "VA SWR_ADC1"},
  1943. {"VA SMIC MUX1", "ADC2", "VA SWR_ADC2"},
  1944. {"VA SMIC MUX1", "ADC3", "VA SWR_ADC3"},
  1945. {"VA SMIC MUX1", "SWR_DMIC0", "VA SWR_MIC0"},
  1946. {"VA SMIC MUX1", "SWR_DMIC1", "VA SWR_MIC1"},
  1947. {"VA SMIC MUX1", "SWR_DMIC2", "VA SWR_MIC2"},
  1948. {"VA SMIC MUX1", "SWR_DMIC3", "VA SWR_MIC3"},
  1949. {"VA SMIC MUX1", "SWR_DMIC4", "VA SWR_MIC4"},
  1950. {"VA SMIC MUX1", "SWR_DMIC5", "VA SWR_MIC5"},
  1951. {"VA SMIC MUX1", "SWR_DMIC6", "VA SWR_MIC6"},
  1952. {"VA SMIC MUX1", "SWR_DMIC7", "VA SWR_MIC7"},
  1953. {"VA DEC2 MUX", "MSM_DMIC", "VA DMIC MUX2"},
  1954. {"VA DMIC MUX2", "DMIC0", "VA DMIC0"},
  1955. {"VA DMIC MUX2", "DMIC1", "VA DMIC1"},
  1956. {"VA DMIC MUX2", "DMIC2", "VA DMIC2"},
  1957. {"VA DMIC MUX2", "DMIC3", "VA DMIC3"},
  1958. {"VA DMIC MUX2", "DMIC4", "VA DMIC4"},
  1959. {"VA DMIC MUX2", "DMIC5", "VA DMIC5"},
  1960. {"VA DMIC MUX2", "DMIC6", "VA DMIC6"},
  1961. {"VA DMIC MUX2", "DMIC7", "VA DMIC7"},
  1962. {"VA DEC2 MUX", "SWR_MIC", "VA SMIC MUX2"},
  1963. {"VA SMIC MUX2", "ADC0", "VA SWR_ADC0"},
  1964. {"VA SMIC MUX2", "ADC1", "VA SWR_ADC1"},
  1965. {"VA SMIC MUX2", "ADC2", "VA SWR_ADC2"},
  1966. {"VA SMIC MUX2", "ADC3", "VA SWR_ADC3"},
  1967. {"VA SMIC MUX2", "SWR_DMIC0", "VA SWR_MIC0"},
  1968. {"VA SMIC MUX2", "SWR_DMIC1", "VA SWR_MIC1"},
  1969. {"VA SMIC MUX2", "SWR_DMIC2", "VA SWR_MIC2"},
  1970. {"VA SMIC MUX2", "SWR_DMIC3", "VA SWR_MIC3"},
  1971. {"VA SMIC MUX2", "SWR_DMIC4", "VA SWR_MIC4"},
  1972. {"VA SMIC MUX2", "SWR_DMIC5", "VA SWR_MIC5"},
  1973. {"VA SMIC MUX2", "SWR_DMIC6", "VA SWR_MIC6"},
  1974. {"VA SMIC MUX2", "SWR_DMIC7", "VA SWR_MIC7"},
  1975. {"VA DEC3 MUX", "MSM_DMIC", "VA DMIC MUX3"},
  1976. {"VA DMIC MUX3", "DMIC0", "VA DMIC0"},
  1977. {"VA DMIC MUX3", "DMIC1", "VA DMIC1"},
  1978. {"VA DMIC MUX3", "DMIC2", "VA DMIC2"},
  1979. {"VA DMIC MUX3", "DMIC3", "VA DMIC3"},
  1980. {"VA DMIC MUX3", "DMIC4", "VA DMIC4"},
  1981. {"VA DMIC MUX3", "DMIC5", "VA DMIC5"},
  1982. {"VA DMIC MUX3", "DMIC6", "VA DMIC6"},
  1983. {"VA DMIC MUX3", "DMIC7", "VA DMIC7"},
  1984. {"VA DEC3 MUX", "SWR_MIC", "VA SMIC MUX3"},
  1985. {"VA SMIC MUX3", "ADC0", "VA SWR_ADC0"},
  1986. {"VA SMIC MUX3", "ADC1", "VA SWR_ADC1"},
  1987. {"VA SMIC MUX3", "ADC2", "VA SWR_ADC2"},
  1988. {"VA SMIC MUX3", "ADC3", "VA SWR_ADC3"},
  1989. {"VA SMIC MUX3", "SWR_DMIC0", "VA SWR_MIC0"},
  1990. {"VA SMIC MUX3", "SWR_DMIC1", "VA SWR_MIC1"},
  1991. {"VA SMIC MUX3", "SWR_DMIC2", "VA SWR_MIC2"},
  1992. {"VA SMIC MUX3", "SWR_DMIC3", "VA SWR_MIC3"},
  1993. {"VA SMIC MUX3", "SWR_DMIC4", "VA SWR_MIC4"},
  1994. {"VA SMIC MUX3", "SWR_DMIC5", "VA SWR_MIC5"},
  1995. {"VA SMIC MUX3", "SWR_DMIC6", "VA SWR_MIC6"},
  1996. {"VA SMIC MUX3", "SWR_DMIC7", "VA SWR_MIC7"},
  1997. {"VA DEC4 MUX", "MSM_DMIC", "VA DMIC MUX4"},
  1998. {"VA DMIC MUX4", "DMIC0", "VA DMIC0"},
  1999. {"VA DMIC MUX4", "DMIC1", "VA DMIC1"},
  2000. {"VA DMIC MUX4", "DMIC2", "VA DMIC2"},
  2001. {"VA DMIC MUX4", "DMIC3", "VA DMIC3"},
  2002. {"VA DMIC MUX4", "DMIC4", "VA DMIC4"},
  2003. {"VA DMIC MUX4", "DMIC5", "VA DMIC5"},
  2004. {"VA DMIC MUX4", "DMIC6", "VA DMIC6"},
  2005. {"VA DMIC MUX4", "DMIC7", "VA DMIC7"},
  2006. {"VA DEC4 MUX", "SWR_MIC", "VA SMIC MUX4"},
  2007. {"VA SMIC MUX4", "ADC0", "VA SWR_ADC0"},
  2008. {"VA SMIC MUX4", "ADC1", "VA SWR_ADC1"},
  2009. {"VA SMIC MUX4", "ADC2", "VA SWR_ADC2"},
  2010. {"VA SMIC MUX4", "ADC3", "VA SWR_ADC3"},
  2011. {"VA SMIC MUX4", "SWR_DMIC0", "VA SWR_MIC0"},
  2012. {"VA SMIC MUX4", "SWR_DMIC1", "VA SWR_MIC1"},
  2013. {"VA SMIC MUX4", "SWR_DMIC2", "VA SWR_MIC2"},
  2014. {"VA SMIC MUX4", "SWR_DMIC3", "VA SWR_MIC3"},
  2015. {"VA SMIC MUX4", "SWR_DMIC4", "VA SWR_MIC4"},
  2016. {"VA SMIC MUX4", "SWR_DMIC5", "VA SWR_MIC5"},
  2017. {"VA SMIC MUX4", "SWR_DMIC6", "VA SWR_MIC6"},
  2018. {"VA SMIC MUX4", "SWR_DMIC7", "VA SWR_MIC7"},
  2019. {"VA DEC5 MUX", "MSM_DMIC", "VA DMIC MUX5"},
  2020. {"VA DMIC MUX5", "DMIC0", "VA DMIC0"},
  2021. {"VA DMIC MUX5", "DMIC1", "VA DMIC1"},
  2022. {"VA DMIC MUX5", "DMIC2", "VA DMIC2"},
  2023. {"VA DMIC MUX5", "DMIC3", "VA DMIC3"},
  2024. {"VA DMIC MUX5", "DMIC4", "VA DMIC4"},
  2025. {"VA DMIC MUX5", "DMIC5", "VA DMIC5"},
  2026. {"VA DMIC MUX5", "DMIC6", "VA DMIC6"},
  2027. {"VA DMIC MUX5", "DMIC7", "VA DMIC7"},
  2028. {"VA DEC5 MUX", "SWR_MIC", "VA SMIC MUX5"},
  2029. {"VA SMIC MUX5", "ADC0", "VA SWR_ADC0"},
  2030. {"VA SMIC MUX5", "ADC1", "VA SWR_ADC1"},
  2031. {"VA SMIC MUX5", "ADC2", "VA SWR_ADC2"},
  2032. {"VA SMIC MUX5", "ADC3", "VA SWR_ADC3"},
  2033. {"VA SMIC MUX5", "SWR_DMIC0", "VA SWR_MIC0"},
  2034. {"VA SMIC MUX5", "SWR_DMIC1", "VA SWR_MIC1"},
  2035. {"VA SMIC MUX5", "SWR_DMIC2", "VA SWR_MIC2"},
  2036. {"VA SMIC MUX5", "SWR_DMIC3", "VA SWR_MIC3"},
  2037. {"VA SMIC MUX5", "SWR_DMIC4", "VA SWR_MIC4"},
  2038. {"VA SMIC MUX5", "SWR_DMIC5", "VA SWR_MIC5"},
  2039. {"VA SMIC MUX5", "SWR_DMIC6", "VA SWR_MIC6"},
  2040. {"VA SMIC MUX5", "SWR_DMIC7", "VA SWR_MIC7"},
  2041. {"VA DEC6 MUX", "MSM_DMIC", "VA DMIC MUX6"},
  2042. {"VA DMIC MUX6", "DMIC0", "VA DMIC0"},
  2043. {"VA DMIC MUX6", "DMIC1", "VA DMIC1"},
  2044. {"VA DMIC MUX6", "DMIC2", "VA DMIC2"},
  2045. {"VA DMIC MUX6", "DMIC3", "VA DMIC3"},
  2046. {"VA DMIC MUX6", "DMIC4", "VA DMIC4"},
  2047. {"VA DMIC MUX6", "DMIC5", "VA DMIC5"},
  2048. {"VA DMIC MUX6", "DMIC6", "VA DMIC6"},
  2049. {"VA DMIC MUX6", "DMIC7", "VA DMIC7"},
  2050. {"VA DEC6 MUX", "SWR_MIC", "VA SMIC MUX6"},
  2051. {"VA SMIC MUX6", "ADC0", "VA SWR_ADC0"},
  2052. {"VA SMIC MUX6", "ADC1", "VA SWR_ADC1"},
  2053. {"VA SMIC MUX6", "ADC2", "VA SWR_ADC2"},
  2054. {"VA SMIC MUX6", "ADC3", "VA SWR_ADC3"},
  2055. {"VA SMIC MUX6", "SWR_DMIC0", "VA SWR_MIC0"},
  2056. {"VA SMIC MUX6", "SWR_DMIC1", "VA SWR_MIC1"},
  2057. {"VA SMIC MUX6", "SWR_DMIC2", "VA SWR_MIC2"},
  2058. {"VA SMIC MUX6", "SWR_DMIC3", "VA SWR_MIC3"},
  2059. {"VA SMIC MUX6", "SWR_DMIC4", "VA SWR_MIC4"},
  2060. {"VA SMIC MUX6", "SWR_DMIC5", "VA SWR_MIC5"},
  2061. {"VA SMIC MUX6", "SWR_DMIC6", "VA SWR_MIC6"},
  2062. {"VA SMIC MUX6", "SWR_DMIC7", "VA SWR_MIC7"},
  2063. {"VA DEC7 MUX", "MSM_DMIC", "VA DMIC MUX7"},
  2064. {"VA DMIC MUX7", "DMIC0", "VA DMIC0"},
  2065. {"VA DMIC MUX7", "DMIC1", "VA DMIC1"},
  2066. {"VA DMIC MUX7", "DMIC2", "VA DMIC2"},
  2067. {"VA DMIC MUX7", "DMIC3", "VA DMIC3"},
  2068. {"VA DMIC MUX7", "DMIC4", "VA DMIC4"},
  2069. {"VA DMIC MUX7", "DMIC5", "VA DMIC5"},
  2070. {"VA DMIC MUX7", "DMIC6", "VA DMIC6"},
  2071. {"VA DMIC MUX7", "DMIC7", "VA DMIC7"},
  2072. {"VA DEC7 MUX", "SWR_MIC", "VA SMIC MUX7"},
  2073. {"VA SMIC MUX7", "ADC0", "VA SWR_ADC0"},
  2074. {"VA SMIC MUX7", "ADC1", "VA SWR_ADC1"},
  2075. {"VA SMIC MUX7", "ADC2", "VA SWR_ADC2"},
  2076. {"VA SMIC MUX7", "ADC3", "VA SWR_ADC3"},
  2077. {"VA SMIC MUX7", "SWR_DMIC0", "VA SWR_MIC0"},
  2078. {"VA SMIC MUX7", "SWR_DMIC1", "VA SWR_MIC1"},
  2079. {"VA SMIC MUX7", "SWR_DMIC2", "VA SWR_MIC2"},
  2080. {"VA SMIC MUX7", "SWR_DMIC3", "VA SWR_MIC3"},
  2081. {"VA SMIC MUX7", "SWR_DMIC4", "VA SWR_MIC4"},
  2082. {"VA SMIC MUX7", "SWR_DMIC5", "VA SWR_MIC5"},
  2083. {"VA SMIC MUX7", "SWR_DMIC6", "VA SWR_MIC6"},
  2084. {"VA SMIC MUX7", "SWR_DMIC7", "VA SWR_MIC7"},
  2085. {"VA SWR_ADC0", NULL, "VA_SWR_PWR"},
  2086. {"VA SWR_ADC1", NULL, "VA_SWR_PWR"},
  2087. {"VA SWR_ADC2", NULL, "VA_SWR_PWR"},
  2088. {"VA SWR_ADC3", NULL, "VA_SWR_PWR"},
  2089. };
  2090. static const struct snd_kcontrol_new va_macro_snd_controls[] = {
  2091. SOC_SINGLE_SX_TLV("VA_DEC0 Volume",
  2092. BOLERO_CDC_VA_TX0_TX_VOL_CTL,
  2093. 0, -84, 40, digital_gain),
  2094. SOC_SINGLE_SX_TLV("VA_DEC1 Volume",
  2095. BOLERO_CDC_VA_TX1_TX_VOL_CTL,
  2096. 0, -84, 40, digital_gain),
  2097. SOC_SINGLE_SX_TLV("VA_DEC2 Volume",
  2098. BOLERO_CDC_VA_TX2_TX_VOL_CTL,
  2099. 0, -84, 40, digital_gain),
  2100. SOC_SINGLE_SX_TLV("VA_DEC3 Volume",
  2101. BOLERO_CDC_VA_TX3_TX_VOL_CTL,
  2102. 0, -84, 40, digital_gain),
  2103. SOC_SINGLE_SX_TLV("VA_DEC4 Volume",
  2104. BOLERO_CDC_VA_TX4_TX_VOL_CTL,
  2105. 0, -84, 40, digital_gain),
  2106. SOC_SINGLE_SX_TLV("VA_DEC5 Volume",
  2107. BOLERO_CDC_VA_TX5_TX_VOL_CTL,
  2108. 0, -84, 40, digital_gain),
  2109. SOC_SINGLE_SX_TLV("VA_DEC6 Volume",
  2110. BOLERO_CDC_VA_TX6_TX_VOL_CTL,
  2111. 0, -84, 40, digital_gain),
  2112. SOC_SINGLE_SX_TLV("VA_DEC7 Volume",
  2113. BOLERO_CDC_VA_TX7_TX_VOL_CTL,
  2114. 0, -84, 40, digital_gain),
  2115. SOC_SINGLE_EXT("LPI Enable", 0, 0, 1, 0,
  2116. va_macro_lpi_get, va_macro_lpi_put),
  2117. };
  2118. static const struct snd_kcontrol_new va_macro_snd_controls_common[] = {
  2119. SOC_SINGLE_SX_TLV("VA_DEC0 Volume",
  2120. BOLERO_CDC_VA_TX0_TX_VOL_CTL,
  2121. 0, -84, 40, digital_gain),
  2122. SOC_SINGLE_SX_TLV("VA_DEC1 Volume",
  2123. BOLERO_CDC_VA_TX1_TX_VOL_CTL,
  2124. 0, -84, 40, digital_gain),
  2125. };
  2126. static const struct snd_kcontrol_new va_macro_snd_controls_v3[] = {
  2127. SOC_SINGLE_SX_TLV("VA_DEC2 Volume",
  2128. BOLERO_CDC_VA_TX2_TX_VOL_CTL,
  2129. 0, -84, 40, digital_gain),
  2130. SOC_SINGLE_SX_TLV("VA_DEC3 Volume",
  2131. BOLERO_CDC_VA_TX3_TX_VOL_CTL,
  2132. 0, -84, 40, digital_gain),
  2133. SOC_SINGLE_EXT("LPI Enable", 0, 0, 1, 0,
  2134. va_macro_lpi_get, va_macro_lpi_put),
  2135. };
  2136. static int va_macro_validate_dmic_sample_rate(u32 dmic_sample_rate,
  2137. struct va_macro_priv *va_priv)
  2138. {
  2139. u32 div_factor;
  2140. u32 mclk_rate = VA_MACRO_MCLK_FREQ;
  2141. if (dmic_sample_rate == VA_MACRO_DMIC_SAMPLE_RATE_UNDEFINED ||
  2142. mclk_rate % dmic_sample_rate != 0)
  2143. goto undefined_rate;
  2144. div_factor = mclk_rate / dmic_sample_rate;
  2145. switch (div_factor) {
  2146. case 2:
  2147. va_priv->dmic_clk_div = VA_MACRO_CLK_DIV_2;
  2148. break;
  2149. case 3:
  2150. va_priv->dmic_clk_div = VA_MACRO_CLK_DIV_3;
  2151. break;
  2152. case 4:
  2153. va_priv->dmic_clk_div = VA_MACRO_CLK_DIV_4;
  2154. break;
  2155. case 6:
  2156. va_priv->dmic_clk_div = VA_MACRO_CLK_DIV_6;
  2157. break;
  2158. case 8:
  2159. va_priv->dmic_clk_div = VA_MACRO_CLK_DIV_8;
  2160. break;
  2161. case 16:
  2162. va_priv->dmic_clk_div = VA_MACRO_CLK_DIV_16;
  2163. break;
  2164. default:
  2165. /* Any other DIV factor is invalid */
  2166. goto undefined_rate;
  2167. }
  2168. /* Valid dmic DIV factors */
  2169. dev_dbg(va_priv->dev, "%s: DMIC_DIV = %u, mclk_rate = %u\n",
  2170. __func__, div_factor, mclk_rate);
  2171. return dmic_sample_rate;
  2172. undefined_rate:
  2173. dev_dbg(va_priv->dev, "%s: Invalid rate %d, for mclk %d\n",
  2174. __func__, dmic_sample_rate, mclk_rate);
  2175. dmic_sample_rate = VA_MACRO_DMIC_SAMPLE_RATE_UNDEFINED;
  2176. return dmic_sample_rate;
  2177. }
  2178. static int va_macro_init(struct snd_soc_component *component)
  2179. {
  2180. struct snd_soc_dapm_context *dapm =
  2181. snd_soc_component_get_dapm(component);
  2182. int ret, i;
  2183. struct device *va_dev = NULL;
  2184. struct va_macro_priv *va_priv = NULL;
  2185. va_dev = bolero_get_device_ptr(component->dev, VA_MACRO);
  2186. if (!va_dev) {
  2187. dev_err(component->dev,
  2188. "%s: null device for macro!\n", __func__);
  2189. return -EINVAL;
  2190. }
  2191. va_priv = dev_get_drvdata(va_dev);
  2192. if (!va_priv) {
  2193. dev_err(component->dev,
  2194. "%s: priv is null for macro!\n", __func__);
  2195. return -EINVAL;
  2196. }
  2197. va_priv->lpi_enable = false;
  2198. va_priv->register_event_listener = false;
  2199. if (va_priv->va_without_decimation) {
  2200. ret = snd_soc_dapm_new_controls(dapm, va_macro_wod_dapm_widgets,
  2201. ARRAY_SIZE(va_macro_wod_dapm_widgets));
  2202. if (ret < 0) {
  2203. dev_err(va_dev,
  2204. "%s: Failed to add without dec controls\n",
  2205. __func__);
  2206. return ret;
  2207. }
  2208. va_priv->component = component;
  2209. return 0;
  2210. }
  2211. va_priv->version = bolero_get_version(va_dev);
  2212. if (va_priv->version >= BOLERO_VERSION_2_0) {
  2213. ret = snd_soc_dapm_new_controls(dapm,
  2214. va_macro_dapm_widgets_common,
  2215. ARRAY_SIZE(va_macro_dapm_widgets_common));
  2216. if (ret < 0) {
  2217. dev_err(va_dev, "%s: Failed to add controls\n",
  2218. __func__);
  2219. return ret;
  2220. }
  2221. if (va_priv->version == BOLERO_VERSION_2_1)
  2222. ret = snd_soc_dapm_new_controls(dapm,
  2223. va_macro_dapm_widgets_v2,
  2224. ARRAY_SIZE(va_macro_dapm_widgets_v2));
  2225. else if (va_priv->version == BOLERO_VERSION_2_0)
  2226. ret = snd_soc_dapm_new_controls(dapm,
  2227. va_macro_dapm_widgets_v3,
  2228. ARRAY_SIZE(va_macro_dapm_widgets_v3));
  2229. if (ret < 0) {
  2230. dev_err(va_dev, "%s: Failed to add controls\n",
  2231. __func__);
  2232. return ret;
  2233. }
  2234. } else {
  2235. ret = snd_soc_dapm_new_controls(dapm, va_macro_dapm_widgets,
  2236. ARRAY_SIZE(va_macro_dapm_widgets));
  2237. if (ret < 0) {
  2238. dev_err(va_dev, "%s: Failed to add controls\n",
  2239. __func__);
  2240. return ret;
  2241. }
  2242. }
  2243. if (va_priv->version >= BOLERO_VERSION_2_0) {
  2244. ret = snd_soc_dapm_add_routes(dapm,
  2245. va_audio_map_common,
  2246. ARRAY_SIZE(va_audio_map_common));
  2247. if (ret < 0) {
  2248. dev_err(va_dev, "%s: Failed to add routes\n",
  2249. __func__);
  2250. return ret;
  2251. }
  2252. if (va_priv->version == BOLERO_VERSION_2_0)
  2253. ret = snd_soc_dapm_add_routes(dapm,
  2254. va_audio_map_v3,
  2255. ARRAY_SIZE(va_audio_map_v3));
  2256. if (ret < 0) {
  2257. dev_err(va_dev, "%s: Failed to add routes\n",
  2258. __func__);
  2259. return ret;
  2260. }
  2261. } else {
  2262. ret = snd_soc_dapm_add_routes(dapm, va_audio_map,
  2263. ARRAY_SIZE(va_audio_map));
  2264. if (ret < 0) {
  2265. dev_err(va_dev, "%s: Failed to add routes\n",
  2266. __func__);
  2267. return ret;
  2268. }
  2269. }
  2270. ret = snd_soc_dapm_new_widgets(dapm->card);
  2271. if (ret < 0) {
  2272. dev_err(va_dev, "%s: Failed to add widgets\n", __func__);
  2273. return ret;
  2274. }
  2275. if (va_priv->version >= BOLERO_VERSION_2_0) {
  2276. ret = snd_soc_add_component_controls(component,
  2277. va_macro_snd_controls_common,
  2278. ARRAY_SIZE(va_macro_snd_controls_common));
  2279. if (ret < 0) {
  2280. dev_err(va_dev, "%s: Failed to add snd_ctls\n",
  2281. __func__);
  2282. return ret;
  2283. }
  2284. if (va_priv->version == BOLERO_VERSION_2_0)
  2285. ret = snd_soc_add_component_controls(component,
  2286. va_macro_snd_controls_v3,
  2287. ARRAY_SIZE(va_macro_snd_controls_v3));
  2288. if (ret < 0) {
  2289. dev_err(va_dev, "%s: Failed to add snd_ctls\n",
  2290. __func__);
  2291. return ret;
  2292. }
  2293. } else {
  2294. ret = snd_soc_add_component_controls(component,
  2295. va_macro_snd_controls,
  2296. ARRAY_SIZE(va_macro_snd_controls));
  2297. if (ret < 0) {
  2298. dev_err(va_dev, "%s: Failed to add snd_ctls\n",
  2299. __func__);
  2300. return ret;
  2301. }
  2302. }
  2303. snd_soc_dapm_ignore_suspend(dapm, "VA_AIF1 Capture");
  2304. snd_soc_dapm_ignore_suspend(dapm, "VA_AIF2 Capture");
  2305. snd_soc_dapm_ignore_suspend(dapm, "VA_AIF3 Capture");
  2306. if (va_priv->version >= BOLERO_VERSION_2_0) {
  2307. snd_soc_dapm_ignore_suspend(dapm, "VA SWR_INPUT");
  2308. } else {
  2309. snd_soc_dapm_ignore_suspend(dapm, "VA SWR_ADC0");
  2310. snd_soc_dapm_ignore_suspend(dapm, "VA SWR_ADC1");
  2311. snd_soc_dapm_ignore_suspend(dapm, "VA SWR_ADC2");
  2312. snd_soc_dapm_ignore_suspend(dapm, "VA SWR_ADC3");
  2313. snd_soc_dapm_ignore_suspend(dapm, "VA SWR_MIC0");
  2314. snd_soc_dapm_ignore_suspend(dapm, "VA SWR_MIC1");
  2315. snd_soc_dapm_ignore_suspend(dapm, "VA SWR_MIC2");
  2316. snd_soc_dapm_ignore_suspend(dapm, "VA SWR_MIC3");
  2317. snd_soc_dapm_ignore_suspend(dapm, "VA SWR_MIC4");
  2318. snd_soc_dapm_ignore_suspend(dapm, "VA SWR_MIC5");
  2319. snd_soc_dapm_ignore_suspend(dapm, "VA SWR_MIC6");
  2320. snd_soc_dapm_ignore_suspend(dapm, "VA SWR_MIC7");
  2321. }
  2322. snd_soc_dapm_sync(dapm);
  2323. for (i = 0; i < VA_MACRO_NUM_DECIMATORS; i++) {
  2324. va_priv->va_hpf_work[i].va_priv = va_priv;
  2325. va_priv->va_hpf_work[i].decimator = i;
  2326. INIT_DELAYED_WORK(&va_priv->va_hpf_work[i].dwork,
  2327. va_macro_tx_hpf_corner_freq_callback);
  2328. }
  2329. for (i = 0; i < VA_MACRO_NUM_DECIMATORS; i++) {
  2330. va_priv->va_mute_dwork[i].va_priv = va_priv;
  2331. va_priv->va_mute_dwork[i].decimator = i;
  2332. INIT_DELAYED_WORK(&va_priv->va_mute_dwork[i].dwork,
  2333. va_macro_mute_update_callback);
  2334. }
  2335. va_priv->component = component;
  2336. if (va_priv->version == BOLERO_VERSION_2_1) {
  2337. snd_soc_component_update_bits(component,
  2338. BOLERO_CDC_VA_TOP_CSR_SWR_MIC_CTL0, 0xEE, 0xCC);
  2339. snd_soc_component_update_bits(component,
  2340. BOLERO_CDC_VA_TOP_CSR_SWR_MIC_CTL1, 0xEE, 0xCC);
  2341. snd_soc_component_update_bits(component,
  2342. BOLERO_CDC_VA_TOP_CSR_SWR_MIC_CTL2, 0xEE, 0xCC);
  2343. }
  2344. return 0;
  2345. }
  2346. static int va_macro_deinit(struct snd_soc_component *component)
  2347. {
  2348. struct device *va_dev = NULL;
  2349. struct va_macro_priv *va_priv = NULL;
  2350. if (!va_macro_get_data(component, &va_dev, &va_priv, __func__))
  2351. return -EINVAL;
  2352. va_priv->component = NULL;
  2353. return 0;
  2354. }
  2355. static void va_macro_add_child_devices(struct work_struct *work)
  2356. {
  2357. struct va_macro_priv *va_priv = NULL;
  2358. struct platform_device *pdev = NULL;
  2359. struct device_node *node = NULL;
  2360. struct va_macro_swr_ctrl_data *swr_ctrl_data = NULL, *temp = NULL;
  2361. int ret = 0;
  2362. u16 count = 0, ctrl_num = 0;
  2363. struct va_macro_swr_ctrl_platform_data *platdata = NULL;
  2364. char plat_dev_name[VA_MACRO_SWR_STRING_LEN] = "";
  2365. bool va_swr_master_node = false;
  2366. va_priv = container_of(work, struct va_macro_priv,
  2367. va_macro_add_child_devices_work);
  2368. if (!va_priv) {
  2369. pr_err("%s: Memory for va_priv does not exist\n",
  2370. __func__);
  2371. return;
  2372. }
  2373. if (!va_priv->dev) {
  2374. pr_err("%s: VA dev does not exist\n", __func__);
  2375. return;
  2376. }
  2377. if (!va_priv->dev->of_node) {
  2378. dev_err(va_priv->dev,
  2379. "%s: DT node for va_priv does not exist\n", __func__);
  2380. return;
  2381. }
  2382. platdata = &va_priv->swr_plat_data;
  2383. va_priv->child_count = 0;
  2384. for_each_available_child_of_node(va_priv->dev->of_node, node) {
  2385. va_swr_master_node = false;
  2386. if (strnstr(node->name, "va_swr_master",
  2387. strlen("va_swr_master")) != NULL)
  2388. va_swr_master_node = true;
  2389. if (va_swr_master_node)
  2390. strlcpy(plat_dev_name, "va_swr_ctrl",
  2391. (VA_MACRO_SWR_STRING_LEN - 1));
  2392. else
  2393. strlcpy(plat_dev_name, node->name,
  2394. (VA_MACRO_SWR_STRING_LEN - 1));
  2395. pdev = platform_device_alloc(plat_dev_name, -1);
  2396. if (!pdev) {
  2397. dev_err(va_priv->dev, "%s: pdev memory alloc failed\n",
  2398. __func__);
  2399. ret = -ENOMEM;
  2400. goto err;
  2401. }
  2402. pdev->dev.parent = va_priv->dev;
  2403. pdev->dev.of_node = node;
  2404. if (va_swr_master_node) {
  2405. ret = platform_device_add_data(pdev, platdata,
  2406. sizeof(*platdata));
  2407. if (ret) {
  2408. dev_err(&pdev->dev,
  2409. "%s: cannot add plat data ctrl:%d\n",
  2410. __func__, ctrl_num);
  2411. goto fail_pdev_add;
  2412. }
  2413. }
  2414. ret = platform_device_add(pdev);
  2415. if (ret) {
  2416. dev_err(&pdev->dev,
  2417. "%s: Cannot add platform device\n",
  2418. __func__);
  2419. goto fail_pdev_add;
  2420. }
  2421. if (va_swr_master_node) {
  2422. temp = krealloc(swr_ctrl_data,
  2423. (ctrl_num + 1) * sizeof(
  2424. struct va_macro_swr_ctrl_data),
  2425. GFP_KERNEL);
  2426. if (!temp) {
  2427. ret = -ENOMEM;
  2428. goto fail_pdev_add;
  2429. }
  2430. swr_ctrl_data = temp;
  2431. swr_ctrl_data[ctrl_num].va_swr_pdev = pdev;
  2432. ctrl_num++;
  2433. dev_dbg(&pdev->dev,
  2434. "%s: Added soundwire ctrl device(s)\n",
  2435. __func__);
  2436. va_priv->swr_ctrl_data = swr_ctrl_data;
  2437. }
  2438. if (va_priv->child_count < VA_MACRO_CHILD_DEVICES_MAX)
  2439. va_priv->pdev_child_devices[
  2440. va_priv->child_count++] = pdev;
  2441. else
  2442. goto err;
  2443. }
  2444. return;
  2445. fail_pdev_add:
  2446. for (count = 0; count < va_priv->child_count; count++)
  2447. platform_device_put(va_priv->pdev_child_devices[count]);
  2448. err:
  2449. return;
  2450. }
  2451. static int va_macro_set_port_map(struct snd_soc_component *component,
  2452. u32 usecase, u32 size, void *data)
  2453. {
  2454. struct device *va_dev = NULL;
  2455. struct va_macro_priv *va_priv = NULL;
  2456. struct swrm_port_config port_cfg;
  2457. int ret = 0;
  2458. if (!va_macro_get_data(component, &va_dev, &va_priv, __func__))
  2459. return -EINVAL;
  2460. memset(&port_cfg, 0, sizeof(port_cfg));
  2461. port_cfg.uc = usecase;
  2462. port_cfg.size = size;
  2463. port_cfg.params = data;
  2464. if (va_priv->swr_ctrl_data)
  2465. ret = swrm_wcd_notify(
  2466. va_priv->swr_ctrl_data[0].va_swr_pdev,
  2467. SWR_SET_PORT_MAP, &port_cfg);
  2468. return ret;
  2469. }
  2470. static int va_macro_reg_wake_irq(struct snd_soc_component *component,
  2471. u32 data)
  2472. {
  2473. struct device *va_dev = NULL;
  2474. struct va_macro_priv *va_priv = NULL;
  2475. u32 ipc_wakeup = data;
  2476. int ret = 0;
  2477. if (!va_macro_get_data(component, &va_dev, &va_priv, __func__))
  2478. return -EINVAL;
  2479. if (va_priv->swr_ctrl_data)
  2480. ret = swrm_wcd_notify(
  2481. va_priv->swr_ctrl_data[0].va_swr_pdev,
  2482. SWR_REGISTER_WAKE_IRQ, &ipc_wakeup);
  2483. return ret;
  2484. }
  2485. static void va_macro_init_ops(struct macro_ops *ops,
  2486. char __iomem *va_io_base,
  2487. bool va_without_decimation)
  2488. {
  2489. memset(ops, 0, sizeof(struct macro_ops));
  2490. if (!va_without_decimation) {
  2491. ops->dai_ptr = va_macro_dai;
  2492. ops->num_dais = ARRAY_SIZE(va_macro_dai);
  2493. } else {
  2494. ops->dai_ptr = NULL;
  2495. ops->num_dais = 0;
  2496. }
  2497. ops->init = va_macro_init;
  2498. ops->exit = va_macro_deinit;
  2499. ops->io_base = va_io_base;
  2500. ops->event_handler = va_macro_event_handler;
  2501. ops->set_port_map = va_macro_set_port_map;
  2502. ops->reg_wake_irq = va_macro_reg_wake_irq;
  2503. ops->clk_div_get = va_macro_clk_div_get;
  2504. }
  2505. static int va_macro_probe(struct platform_device *pdev)
  2506. {
  2507. struct macro_ops ops;
  2508. struct va_macro_priv *va_priv;
  2509. u32 va_base_addr, sample_rate = 0;
  2510. char __iomem *va_io_base;
  2511. bool va_without_decimation = false;
  2512. const char *micb_supply_str = "va-vdd-micb-supply";
  2513. const char *micb_supply_str1 = "va-vdd-micb";
  2514. const char *micb_voltage_str = "qcom,va-vdd-micb-voltage";
  2515. const char *micb_current_str = "qcom,va-vdd-micb-current";
  2516. int ret = 0;
  2517. const char *dmic_sample_rate = "qcom,va-dmic-sample-rate";
  2518. u32 default_clk_id = 0;
  2519. struct clk *lpass_audio_hw_vote = NULL;
  2520. u32 is_used_va_swr_gpio = 0;
  2521. const char *is_used_va_swr_gpio_dt = "qcom,is-used-swr-gpio";
  2522. va_priv = devm_kzalloc(&pdev->dev, sizeof(struct va_macro_priv),
  2523. GFP_KERNEL);
  2524. if (!va_priv)
  2525. return -ENOMEM;
  2526. va_priv->dev = &pdev->dev;
  2527. ret = of_property_read_u32(pdev->dev.of_node, "reg",
  2528. &va_base_addr);
  2529. if (ret) {
  2530. dev_err(&pdev->dev, "%s: could not find %s entry in dt\n",
  2531. __func__, "reg");
  2532. return ret;
  2533. }
  2534. va_without_decimation = of_property_read_bool(pdev->dev.parent->of_node,
  2535. "qcom,va-without-decimation");
  2536. va_priv->va_without_decimation = va_without_decimation;
  2537. ret = of_property_read_u32(pdev->dev.of_node, dmic_sample_rate,
  2538. &sample_rate);
  2539. if (ret) {
  2540. dev_err(&pdev->dev, "%s: could not find %d entry in dt\n",
  2541. __func__, sample_rate);
  2542. va_priv->dmic_clk_div = VA_MACRO_CLK_DIV_2;
  2543. } else {
  2544. if (va_macro_validate_dmic_sample_rate(
  2545. sample_rate, va_priv) == VA_MACRO_DMIC_SAMPLE_RATE_UNDEFINED)
  2546. return -EINVAL;
  2547. }
  2548. if (of_find_property(pdev->dev.of_node, is_used_va_swr_gpio_dt,
  2549. NULL)) {
  2550. ret = of_property_read_u32(pdev->dev.of_node,
  2551. is_used_va_swr_gpio_dt,
  2552. &is_used_va_swr_gpio);
  2553. if (ret) {
  2554. dev_err(&pdev->dev, "%s: error reading %s in dt\n",
  2555. __func__, is_used_va_swr_gpio_dt);
  2556. is_used_va_swr_gpio = 0;
  2557. }
  2558. }
  2559. va_priv->va_swr_gpio_p = of_parse_phandle(pdev->dev.of_node,
  2560. "qcom,va-swr-gpios", 0);
  2561. if (!va_priv->va_swr_gpio_p && is_used_va_swr_gpio) {
  2562. dev_err(&pdev->dev, "%s: swr_gpios handle not provided!\n",
  2563. __func__);
  2564. return -EINVAL;
  2565. }
  2566. if ((msm_cdc_pinctrl_get_state(va_priv->va_swr_gpio_p) < 0) &&
  2567. is_used_va_swr_gpio) {
  2568. dev_err(&pdev->dev, "%s: failed to get swr pin state\n",
  2569. __func__);
  2570. return -EPROBE_DEFER;
  2571. }
  2572. va_io_base = devm_ioremap(&pdev->dev, va_base_addr,
  2573. VA_MACRO_MAX_OFFSET);
  2574. if (!va_io_base) {
  2575. dev_err(&pdev->dev, "%s: ioremap failed\n", __func__);
  2576. return -EINVAL;
  2577. }
  2578. va_priv->va_io_base = va_io_base;
  2579. lpass_audio_hw_vote = devm_clk_get(&pdev->dev, "lpass_audio_hw_vote");
  2580. if (IS_ERR(lpass_audio_hw_vote)) {
  2581. ret = PTR_ERR(lpass_audio_hw_vote);
  2582. dev_dbg(&pdev->dev, "%s: clk get %s failed %d\n",
  2583. __func__, "lpass_audio_hw_vote", ret);
  2584. lpass_audio_hw_vote = NULL;
  2585. ret = 0;
  2586. }
  2587. va_priv->lpass_audio_hw_vote = lpass_audio_hw_vote;
  2588. if (of_parse_phandle(pdev->dev.of_node, micb_supply_str, 0)) {
  2589. va_priv->micb_supply = devm_regulator_get(&pdev->dev,
  2590. micb_supply_str1);
  2591. if (IS_ERR(va_priv->micb_supply)) {
  2592. ret = PTR_ERR(va_priv->micb_supply);
  2593. dev_err(&pdev->dev,
  2594. "%s:Failed to get micbias supply for VA Mic %d\n",
  2595. __func__, ret);
  2596. return ret;
  2597. }
  2598. ret = of_property_read_u32(pdev->dev.of_node,
  2599. micb_voltage_str,
  2600. &va_priv->micb_voltage);
  2601. if (ret) {
  2602. dev_err(&pdev->dev,
  2603. "%s:Looking up %s property in node %s failed\n",
  2604. __func__, micb_voltage_str,
  2605. pdev->dev.of_node->full_name);
  2606. return ret;
  2607. }
  2608. ret = of_property_read_u32(pdev->dev.of_node,
  2609. micb_current_str,
  2610. &va_priv->micb_current);
  2611. if (ret) {
  2612. dev_err(&pdev->dev,
  2613. "%s:Looking up %s property in node %s failed\n",
  2614. __func__, micb_current_str,
  2615. pdev->dev.of_node->full_name);
  2616. return ret;
  2617. }
  2618. }
  2619. ret = of_property_read_u32(pdev->dev.of_node, "qcom,default-clk-id",
  2620. &default_clk_id);
  2621. if (ret) {
  2622. dev_err(&pdev->dev, "%s: could not find %s entry in dt\n",
  2623. __func__, "qcom,default-clk-id");
  2624. default_clk_id = VA_CORE_CLK;
  2625. }
  2626. va_priv->clk_id = VA_CORE_CLK;
  2627. va_priv->default_clk_id = default_clk_id;
  2628. if (is_used_va_swr_gpio) {
  2629. va_priv->reset_swr = true;
  2630. INIT_WORK(&va_priv->va_macro_add_child_devices_work,
  2631. va_macro_add_child_devices);
  2632. va_priv->swr_plat_data.handle = (void *) va_priv;
  2633. va_priv->swr_plat_data.read = NULL;
  2634. va_priv->swr_plat_data.write = NULL;
  2635. va_priv->swr_plat_data.bulk_write = NULL;
  2636. va_priv->swr_plat_data.clk = va_macro_swrm_clock;
  2637. va_priv->swr_plat_data.core_vote = va_macro_core_vote;
  2638. va_priv->swr_plat_data.handle_irq = NULL;
  2639. mutex_init(&va_priv->swr_clk_lock);
  2640. }
  2641. va_priv->is_used_va_swr_gpio = is_used_va_swr_gpio;
  2642. mutex_init(&va_priv->mclk_lock);
  2643. dev_set_drvdata(&pdev->dev, va_priv);
  2644. va_macro_init_ops(&ops, va_io_base, va_without_decimation);
  2645. ops.clk_id_req = va_priv->default_clk_id;
  2646. ops.default_clk_id = va_priv->default_clk_id;
  2647. ret = bolero_register_macro(&pdev->dev, VA_MACRO, &ops);
  2648. if (ret < 0) {
  2649. dev_err(&pdev->dev, "%s: register macro failed\n", __func__);
  2650. goto reg_macro_fail;
  2651. }
  2652. if (is_used_va_swr_gpio)
  2653. schedule_work(&va_priv->va_macro_add_child_devices_work);
  2654. pm_runtime_set_autosuspend_delay(&pdev->dev, VA_AUTO_SUSPEND_DELAY);
  2655. pm_runtime_use_autosuspend(&pdev->dev);
  2656. pm_runtime_set_suspended(&pdev->dev);
  2657. pm_suspend_ignore_children(&pdev->dev, true);
  2658. pm_runtime_enable(&pdev->dev);
  2659. return ret;
  2660. reg_macro_fail:
  2661. mutex_destroy(&va_priv->mclk_lock);
  2662. if (is_used_va_swr_gpio)
  2663. mutex_destroy(&va_priv->swr_clk_lock);
  2664. return ret;
  2665. }
  2666. static int va_macro_remove(struct platform_device *pdev)
  2667. {
  2668. struct va_macro_priv *va_priv;
  2669. int count = 0;
  2670. va_priv = dev_get_drvdata(&pdev->dev);
  2671. if (!va_priv)
  2672. return -EINVAL;
  2673. if (va_priv->is_used_va_swr_gpio) {
  2674. if (va_priv->swr_ctrl_data)
  2675. kfree(va_priv->swr_ctrl_data);
  2676. for (count = 0; count < va_priv->child_count &&
  2677. count < VA_MACRO_CHILD_DEVICES_MAX; count++)
  2678. platform_device_unregister(
  2679. va_priv->pdev_child_devices[count]);
  2680. }
  2681. pm_runtime_disable(&pdev->dev);
  2682. pm_runtime_set_suspended(&pdev->dev);
  2683. bolero_unregister_macro(&pdev->dev, VA_MACRO);
  2684. mutex_destroy(&va_priv->mclk_lock);
  2685. if (va_priv->is_used_va_swr_gpio)
  2686. mutex_destroy(&va_priv->swr_clk_lock);
  2687. return 0;
  2688. }
  2689. static const struct of_device_id va_macro_dt_match[] = {
  2690. {.compatible = "qcom,va-macro"},
  2691. {}
  2692. };
  2693. static const struct dev_pm_ops bolero_dev_pm_ops = {
  2694. SET_SYSTEM_SLEEP_PM_OPS(
  2695. pm_runtime_force_suspend,
  2696. pm_runtime_force_resume
  2697. )
  2698. SET_RUNTIME_PM_OPS(
  2699. bolero_runtime_suspend,
  2700. bolero_runtime_resume,
  2701. NULL
  2702. )
  2703. };
  2704. static struct platform_driver va_macro_driver = {
  2705. .driver = {
  2706. .name = "va_macro",
  2707. .owner = THIS_MODULE,
  2708. .pm = &bolero_dev_pm_ops,
  2709. .of_match_table = va_macro_dt_match,
  2710. .suppress_bind_attrs = true,
  2711. },
  2712. .probe = va_macro_probe,
  2713. .remove = va_macro_remove,
  2714. };
  2715. module_platform_driver(va_macro_driver);
  2716. MODULE_DESCRIPTION("VA macro driver");
  2717. MODULE_LICENSE("GPL v2");