va-macro.c 92 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051
  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. if (!(is_amic_enabled(component, decimator) < BOLERO_ADC_MAX)) {
  976. snd_soc_component_update_bits(component,
  977. hpf_gate_reg, 0x01, 0x00);
  978. /*
  979. * Minimum 1 clk cycle delay is required as per HW spec
  980. */
  981. usleep_range(1000, 1010);
  982. }
  983. hpf_cut_off_freq = (snd_soc_component_read32(
  984. component, dec_cfg_reg) &
  985. TX_HPF_CUT_OFF_FREQ_MASK) >> 5;
  986. va_priv->va_hpf_work[decimator].hpf_cut_off_freq =
  987. hpf_cut_off_freq;
  988. if (hpf_cut_off_freq != CF_MIN_3DB_150HZ) {
  989. snd_soc_component_update_bits(component, dec_cfg_reg,
  990. TX_HPF_CUT_OFF_FREQ_MASK,
  991. CF_MIN_3DB_150HZ << 5);
  992. }
  993. if (is_amic_enabled(component, decimator) < BOLERO_ADC_MAX) {
  994. hpf_delay = BOLERO_CDC_VA_TX_AMIC_HPF_DELAY_MS;
  995. unmute_delay = BOLERO_CDC_VA_TX_AMIC_UNMUTE_DELAY_MS;
  996. if (va_tx_unmute_delay < unmute_delay)
  997. va_tx_unmute_delay = unmute_delay;
  998. }
  999. snd_soc_component_update_bits(component,
  1000. hpf_gate_reg, 0x03, 0x02);
  1001. if (!(is_amic_enabled(component, decimator) < BOLERO_ADC_MAX))
  1002. snd_soc_component_update_bits(component,
  1003. hpf_gate_reg, 0x03, 0x00);
  1004. /*
  1005. * Minimum 1 clk cycle delay is required as per HW spec
  1006. */
  1007. usleep_range(1000, 1010);
  1008. snd_soc_component_update_bits(component,
  1009. hpf_gate_reg, 0x03, 0x01);
  1010. /*
  1011. * 6ms delay is required as per HW spec
  1012. */
  1013. usleep_range(6000, 6010);
  1014. /* schedule work queue to Remove Mute */
  1015. queue_delayed_work(system_freezable_wq,
  1016. &va_priv->va_mute_dwork[decimator].dwork,
  1017. msecs_to_jiffies(va_tx_unmute_delay));
  1018. if (va_priv->va_hpf_work[decimator].hpf_cut_off_freq !=
  1019. CF_MIN_3DB_150HZ)
  1020. queue_delayed_work(system_freezable_wq,
  1021. &va_priv->va_hpf_work[decimator].dwork,
  1022. msecs_to_jiffies(hpf_delay));
  1023. /* apply gain after decimator is enabled */
  1024. snd_soc_component_write(component, tx_gain_ctl_reg,
  1025. snd_soc_component_read32(component, tx_gain_ctl_reg));
  1026. if (va_priv->version == BOLERO_VERSION_2_0) {
  1027. if (snd_soc_component_read32(component, adc_mux_reg)
  1028. & SWR_MIC) {
  1029. snd_soc_component_update_bits(component,
  1030. BOLERO_CDC_TX_TOP_CSR_SWR_CTRL,
  1031. 0x01, 0x01);
  1032. snd_soc_component_update_bits(component,
  1033. BOLERO_CDC_TX_TOP_CSR_SWR_MIC0_CTL,
  1034. 0x0E, 0x0C);
  1035. snd_soc_component_update_bits(component,
  1036. BOLERO_CDC_TX_TOP_CSR_SWR_MIC1_CTL,
  1037. 0x0E, 0x0C);
  1038. snd_soc_component_update_bits(component,
  1039. BOLERO_CDC_TX_TOP_CSR_SWR_MIC2_CTL,
  1040. 0x0E, 0x00);
  1041. snd_soc_component_update_bits(component,
  1042. BOLERO_CDC_TX_TOP_CSR_SWR_MIC3_CTL,
  1043. 0x0E, 0x00);
  1044. snd_soc_component_update_bits(component,
  1045. BOLERO_CDC_TX_TOP_CSR_SWR_MIC4_CTL,
  1046. 0x0E, 0x00);
  1047. snd_soc_component_update_bits(component,
  1048. BOLERO_CDC_TX_TOP_CSR_SWR_MIC5_CTL,
  1049. 0x0E, 0x00);
  1050. }
  1051. }
  1052. break;
  1053. case SND_SOC_DAPM_PRE_PMD:
  1054. hpf_cut_off_freq =
  1055. va_priv->va_hpf_work[decimator].hpf_cut_off_freq;
  1056. snd_soc_component_update_bits(component, tx_vol_ctl_reg,
  1057. 0x10, 0x10);
  1058. if (cancel_delayed_work_sync(
  1059. &va_priv->va_hpf_work[decimator].dwork)) {
  1060. if (hpf_cut_off_freq != CF_MIN_3DB_150HZ) {
  1061. snd_soc_component_update_bits(component,
  1062. dec_cfg_reg,
  1063. TX_HPF_CUT_OFF_FREQ_MASK,
  1064. hpf_cut_off_freq << 5);
  1065. if (is_amic_enabled(component, decimator) <
  1066. BOLERO_ADC_MAX)
  1067. snd_soc_component_update_bits(component,
  1068. hpf_gate_reg,
  1069. 0x03, 0x02);
  1070. else
  1071. snd_soc_component_update_bits(component,
  1072. hpf_gate_reg,
  1073. 0x03, 0x03);
  1074. /*
  1075. * Minimum 1 clk cycle delay is required
  1076. * as per HW spec
  1077. */
  1078. usleep_range(1000, 1010);
  1079. snd_soc_component_update_bits(component,
  1080. hpf_gate_reg,
  1081. 0x03, 0x01);
  1082. }
  1083. }
  1084. cancel_delayed_work_sync(
  1085. &va_priv->va_mute_dwork[decimator].dwork);
  1086. if (va_priv->version == BOLERO_VERSION_2_0) {
  1087. if (snd_soc_component_read32(component, adc_mux_reg)
  1088. & SWR_MIC)
  1089. snd_soc_component_update_bits(component,
  1090. BOLERO_CDC_TX_TOP_CSR_SWR_CTRL,
  1091. 0x01, 0x00);
  1092. }
  1093. break;
  1094. case SND_SOC_DAPM_POST_PMD:
  1095. /* Disable TX CLK */
  1096. snd_soc_component_update_bits(component, tx_vol_ctl_reg,
  1097. 0x20, 0x00);
  1098. snd_soc_component_update_bits(component, tx_vol_ctl_reg,
  1099. 0x10, 0x00);
  1100. break;
  1101. }
  1102. return 0;
  1103. }
  1104. static int va_macro_enable_tx(struct snd_soc_dapm_widget *w,
  1105. struct snd_kcontrol *kcontrol, int event)
  1106. {
  1107. struct snd_soc_component *component =
  1108. snd_soc_dapm_to_component(w->dapm);
  1109. struct device *va_dev = NULL;
  1110. struct va_macro_priv *va_priv = NULL;
  1111. int ret = 0;
  1112. if (!va_macro_get_data(component, &va_dev, &va_priv, __func__))
  1113. return -EINVAL;
  1114. dev_dbg(va_dev, "%s: event = %d\n", __func__, event);
  1115. switch (event) {
  1116. case SND_SOC_DAPM_POST_PMU:
  1117. if (bolero_tx_clk_switch(component))
  1118. dev_dbg(va_dev, "%s: clock switch failed\n",__func__);
  1119. if (va_priv->tx_clk_status > 0) {
  1120. ret = bolero_clk_rsc_request_clock(va_priv->dev,
  1121. va_priv->default_clk_id,
  1122. TX_CORE_CLK,
  1123. false);
  1124. va_priv->tx_clk_status--;
  1125. }
  1126. break;
  1127. case SND_SOC_DAPM_PRE_PMD:
  1128. ret = bolero_clk_rsc_request_clock(va_priv->dev,
  1129. va_priv->default_clk_id,
  1130. TX_CORE_CLK,
  1131. true);
  1132. if (!ret)
  1133. va_priv->tx_clk_status++;
  1134. break;
  1135. default:
  1136. dev_err(va_priv->dev,
  1137. "%s: invalid DAPM event %d\n", __func__, event);
  1138. ret = -EINVAL;
  1139. break;
  1140. }
  1141. return ret;
  1142. }
  1143. static int va_macro_enable_micbias(struct snd_soc_dapm_widget *w,
  1144. struct snd_kcontrol *kcontrol, int event)
  1145. {
  1146. struct snd_soc_component *component =
  1147. snd_soc_dapm_to_component(w->dapm);
  1148. struct device *va_dev = NULL;
  1149. struct va_macro_priv *va_priv = NULL;
  1150. int ret = 0;
  1151. if (!va_macro_get_data(component, &va_dev, &va_priv, __func__))
  1152. return -EINVAL;
  1153. if (!va_priv->micb_supply) {
  1154. dev_err(va_dev,
  1155. "%s:regulator not provided in dtsi\n", __func__);
  1156. return -EINVAL;
  1157. }
  1158. switch (event) {
  1159. case SND_SOC_DAPM_PRE_PMU:
  1160. if (va_priv->micb_users++ > 0)
  1161. return 0;
  1162. ret = regulator_set_voltage(va_priv->micb_supply,
  1163. va_priv->micb_voltage,
  1164. va_priv->micb_voltage);
  1165. if (ret) {
  1166. dev_err(va_dev, "%s: Setting voltage failed, err = %d\n",
  1167. __func__, ret);
  1168. return ret;
  1169. }
  1170. ret = regulator_set_load(va_priv->micb_supply,
  1171. va_priv->micb_current);
  1172. if (ret) {
  1173. dev_err(va_dev, "%s: Setting current failed, err = %d\n",
  1174. __func__, ret);
  1175. return ret;
  1176. }
  1177. ret = regulator_enable(va_priv->micb_supply);
  1178. if (ret) {
  1179. dev_err(va_dev, "%s: regulator enable failed, err = %d\n",
  1180. __func__, ret);
  1181. return ret;
  1182. }
  1183. break;
  1184. case SND_SOC_DAPM_POST_PMD:
  1185. if (--va_priv->micb_users > 0)
  1186. return 0;
  1187. if (va_priv->micb_users < 0) {
  1188. va_priv->micb_users = 0;
  1189. dev_dbg(va_dev, "%s: regulator already disabled\n",
  1190. __func__);
  1191. return 0;
  1192. }
  1193. ret = regulator_disable(va_priv->micb_supply);
  1194. if (ret) {
  1195. dev_err(va_dev, "%s: regulator disable failed, err = %d\n",
  1196. __func__, ret);
  1197. return ret;
  1198. }
  1199. regulator_set_voltage(va_priv->micb_supply, 0,
  1200. va_priv->micb_voltage);
  1201. regulator_set_load(va_priv->micb_supply, 0);
  1202. break;
  1203. }
  1204. return 0;
  1205. }
  1206. static int va_macro_hw_params(struct snd_pcm_substream *substream,
  1207. struct snd_pcm_hw_params *params,
  1208. struct snd_soc_dai *dai)
  1209. {
  1210. int tx_fs_rate = -EINVAL;
  1211. struct snd_soc_component *component = dai->component;
  1212. u32 decimator, sample_rate;
  1213. u16 tx_fs_reg = 0;
  1214. struct device *va_dev = NULL;
  1215. struct va_macro_priv *va_priv = NULL;
  1216. if (!va_macro_get_data(component, &va_dev, &va_priv, __func__))
  1217. return -EINVAL;
  1218. dev_dbg(va_dev,
  1219. "%s: dai_name = %s DAI-ID %x rate %d num_ch %d\n", __func__,
  1220. dai->name, dai->id, params_rate(params),
  1221. params_channels(params));
  1222. sample_rate = params_rate(params);
  1223. switch (sample_rate) {
  1224. case 8000:
  1225. tx_fs_rate = 0;
  1226. break;
  1227. case 16000:
  1228. tx_fs_rate = 1;
  1229. break;
  1230. case 32000:
  1231. tx_fs_rate = 3;
  1232. break;
  1233. case 48000:
  1234. tx_fs_rate = 4;
  1235. break;
  1236. case 96000:
  1237. tx_fs_rate = 5;
  1238. break;
  1239. case 192000:
  1240. tx_fs_rate = 6;
  1241. break;
  1242. case 384000:
  1243. tx_fs_rate = 7;
  1244. break;
  1245. default:
  1246. dev_err(va_dev, "%s: Invalid TX sample rate: %d\n",
  1247. __func__, params_rate(params));
  1248. return -EINVAL;
  1249. }
  1250. for_each_set_bit(decimator, &va_priv->active_ch_mask[dai->id],
  1251. VA_MACRO_DEC_MAX) {
  1252. if (decimator >= 0) {
  1253. tx_fs_reg = BOLERO_CDC_VA_TX0_TX_PATH_CTL +
  1254. VA_MACRO_TX_PATH_OFFSET * decimator;
  1255. dev_dbg(va_dev, "%s: set DEC%u rate to %u\n",
  1256. __func__, decimator, sample_rate);
  1257. snd_soc_component_update_bits(component, tx_fs_reg,
  1258. 0x0F, tx_fs_rate);
  1259. } else {
  1260. dev_err(va_dev,
  1261. "%s: ERROR: Invalid decimator: %d\n",
  1262. __func__, decimator);
  1263. return -EINVAL;
  1264. }
  1265. }
  1266. return 0;
  1267. }
  1268. static int va_macro_get_channel_map(struct snd_soc_dai *dai,
  1269. unsigned int *tx_num, unsigned int *tx_slot,
  1270. unsigned int *rx_num, unsigned int *rx_slot)
  1271. {
  1272. struct snd_soc_component *component = dai->component;
  1273. struct device *va_dev = NULL;
  1274. struct va_macro_priv *va_priv = NULL;
  1275. if (!va_macro_get_data(component, &va_dev, &va_priv, __func__))
  1276. return -EINVAL;
  1277. switch (dai->id) {
  1278. case VA_MACRO_AIF1_CAP:
  1279. case VA_MACRO_AIF2_CAP:
  1280. case VA_MACRO_AIF3_CAP:
  1281. *tx_slot = va_priv->active_ch_mask[dai->id];
  1282. *tx_num = va_priv->active_ch_cnt[dai->id];
  1283. break;
  1284. default:
  1285. dev_err(va_dev, "%s: Invalid AIF\n", __func__);
  1286. break;
  1287. }
  1288. return 0;
  1289. }
  1290. static struct snd_soc_dai_ops va_macro_dai_ops = {
  1291. .hw_params = va_macro_hw_params,
  1292. .get_channel_map = va_macro_get_channel_map,
  1293. };
  1294. static struct snd_soc_dai_driver va_macro_dai[] = {
  1295. {
  1296. .name = "va_macro_tx1",
  1297. .id = VA_MACRO_AIF1_CAP,
  1298. .capture = {
  1299. .stream_name = "VA_AIF1 Capture",
  1300. .rates = VA_MACRO_RATES,
  1301. .formats = VA_MACRO_FORMATS,
  1302. .rate_max = 192000,
  1303. .rate_min = 8000,
  1304. .channels_min = 1,
  1305. .channels_max = 8,
  1306. },
  1307. .ops = &va_macro_dai_ops,
  1308. },
  1309. {
  1310. .name = "va_macro_tx2",
  1311. .id = VA_MACRO_AIF2_CAP,
  1312. .capture = {
  1313. .stream_name = "VA_AIF2 Capture",
  1314. .rates = VA_MACRO_RATES,
  1315. .formats = VA_MACRO_FORMATS,
  1316. .rate_max = 192000,
  1317. .rate_min = 8000,
  1318. .channels_min = 1,
  1319. .channels_max = 8,
  1320. },
  1321. .ops = &va_macro_dai_ops,
  1322. },
  1323. {
  1324. .name = "va_macro_tx3",
  1325. .id = VA_MACRO_AIF3_CAP,
  1326. .capture = {
  1327. .stream_name = "VA_AIF3 Capture",
  1328. .rates = VA_MACRO_RATES,
  1329. .formats = VA_MACRO_FORMATS,
  1330. .rate_max = 192000,
  1331. .rate_min = 8000,
  1332. .channels_min = 1,
  1333. .channels_max = 8,
  1334. },
  1335. .ops = &va_macro_dai_ops,
  1336. },
  1337. };
  1338. #define STRING(name) #name
  1339. #define VA_MACRO_DAPM_ENUM(name, reg, offset, text) \
  1340. static SOC_ENUM_SINGLE_DECL(name##_enum, reg, offset, text); \
  1341. static const struct snd_kcontrol_new name##_mux = \
  1342. SOC_DAPM_ENUM(STRING(name), name##_enum)
  1343. #define VA_MACRO_DAPM_ENUM_EXT(name, reg, offset, text, getname, putname) \
  1344. static SOC_ENUM_SINGLE_DECL(name##_enum, reg, offset, text); \
  1345. static const struct snd_kcontrol_new name##_mux = \
  1346. SOC_DAPM_ENUM_EXT(STRING(name), name##_enum, getname, putname)
  1347. #define VA_MACRO_DAPM_MUX(name, shift, kctl) \
  1348. SND_SOC_DAPM_MUX(name, SND_SOC_NOPM, shift, 0, &kctl##_mux)
  1349. static const char * const adc_mux_text[] = {
  1350. "MSM_DMIC", "SWR_MIC"
  1351. };
  1352. VA_MACRO_DAPM_ENUM(va_dec0, BOLERO_CDC_VA_INP_MUX_ADC_MUX0_CFG1,
  1353. 0, adc_mux_text);
  1354. VA_MACRO_DAPM_ENUM(va_dec1, BOLERO_CDC_VA_INP_MUX_ADC_MUX1_CFG1,
  1355. 0, adc_mux_text);
  1356. VA_MACRO_DAPM_ENUM(va_dec2, BOLERO_CDC_VA_INP_MUX_ADC_MUX2_CFG1,
  1357. 0, adc_mux_text);
  1358. VA_MACRO_DAPM_ENUM(va_dec3, BOLERO_CDC_VA_INP_MUX_ADC_MUX3_CFG1,
  1359. 0, adc_mux_text);
  1360. VA_MACRO_DAPM_ENUM(va_dec4, BOLERO_CDC_VA_INP_MUX_ADC_MUX4_CFG1,
  1361. 0, adc_mux_text);
  1362. VA_MACRO_DAPM_ENUM(va_dec5, BOLERO_CDC_VA_INP_MUX_ADC_MUX5_CFG1,
  1363. 0, adc_mux_text);
  1364. VA_MACRO_DAPM_ENUM(va_dec6, BOLERO_CDC_VA_INP_MUX_ADC_MUX6_CFG1,
  1365. 0, adc_mux_text);
  1366. VA_MACRO_DAPM_ENUM(va_dec7, BOLERO_CDC_VA_INP_MUX_ADC_MUX7_CFG1,
  1367. 0, adc_mux_text);
  1368. static const char * const dmic_mux_text[] = {
  1369. "ZERO", "DMIC0", "DMIC1", "DMIC2", "DMIC3",
  1370. "DMIC4", "DMIC5", "DMIC6", "DMIC7"
  1371. };
  1372. VA_MACRO_DAPM_ENUM_EXT(va_dmic0, BOLERO_CDC_VA_INP_MUX_ADC_MUX0_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_dmic1, BOLERO_CDC_VA_INP_MUX_ADC_MUX1_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_dmic2, BOLERO_CDC_VA_INP_MUX_ADC_MUX2_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_dmic3, BOLERO_CDC_VA_INP_MUX_ADC_MUX3_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_dmic4, BOLERO_CDC_VA_INP_MUX_ADC_MUX4_CFG0,
  1385. 4, dmic_mux_text, snd_soc_dapm_get_enum_double,
  1386. va_macro_put_dec_enum);
  1387. VA_MACRO_DAPM_ENUM_EXT(va_dmic5, BOLERO_CDC_VA_INP_MUX_ADC_MUX5_CFG0,
  1388. 4, dmic_mux_text, snd_soc_dapm_get_enum_double,
  1389. va_macro_put_dec_enum);
  1390. VA_MACRO_DAPM_ENUM_EXT(va_dmic6, BOLERO_CDC_VA_INP_MUX_ADC_MUX6_CFG0,
  1391. 4, dmic_mux_text, snd_soc_dapm_get_enum_double,
  1392. va_macro_put_dec_enum);
  1393. VA_MACRO_DAPM_ENUM_EXT(va_dmic7, BOLERO_CDC_VA_INP_MUX_ADC_MUX7_CFG0,
  1394. 4, dmic_mux_text, snd_soc_dapm_get_enum_double,
  1395. va_macro_put_dec_enum);
  1396. static const char * const smic_mux_text[] = {
  1397. "ZERO", "ADC0", "ADC1", "ADC2", "ADC3",
  1398. "SWR_DMIC0", "SWR_DMIC1", "SWR_DMIC2", "SWR_DMIC3",
  1399. "SWR_DMIC4", "SWR_DMIC5", "SWR_DMIC6", "SWR_DMIC7"
  1400. };
  1401. VA_MACRO_DAPM_ENUM_EXT(va_smic0, BOLERO_CDC_VA_INP_MUX_ADC_MUX0_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_smic1, BOLERO_CDC_VA_INP_MUX_ADC_MUX1_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_smic2, BOLERO_CDC_VA_INP_MUX_ADC_MUX2_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_smic3, BOLERO_CDC_VA_INP_MUX_ADC_MUX3_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_smic4, BOLERO_CDC_VA_INP_MUX_ADC_MUX4_CFG0,
  1414. 0, smic_mux_text, snd_soc_dapm_get_enum_double,
  1415. va_macro_put_dec_enum);
  1416. VA_MACRO_DAPM_ENUM_EXT(va_smic5, BOLERO_CDC_VA_INP_MUX_ADC_MUX5_CFG0,
  1417. 0, smic_mux_text, snd_soc_dapm_get_enum_double,
  1418. va_macro_put_dec_enum);
  1419. VA_MACRO_DAPM_ENUM_EXT(va_smic6, BOLERO_CDC_VA_INP_MUX_ADC_MUX6_CFG0,
  1420. 0, smic_mux_text, snd_soc_dapm_get_enum_double,
  1421. va_macro_put_dec_enum);
  1422. VA_MACRO_DAPM_ENUM_EXT(va_smic7, BOLERO_CDC_VA_INP_MUX_ADC_MUX7_CFG0,
  1423. 0, smic_mux_text, snd_soc_dapm_get_enum_double,
  1424. va_macro_put_dec_enum);
  1425. static const char * const smic_mux_text_v2[] = {
  1426. "ZERO", "SWR_MIC0", "SWR_MIC1", "SWR_MIC2", "SWR_MIC3",
  1427. "SWR_MIC4", "SWR_MIC5", "SWR_MIC6", "SWR_MIC7",
  1428. "SWR_MIC8", "SWR_MIC9", "SWR_MIC10", "SWR_MIC11"
  1429. };
  1430. VA_MACRO_DAPM_ENUM_EXT(va_smic0_v2, BOLERO_CDC_VA_INP_MUX_ADC_MUX0_CFG0,
  1431. 0, smic_mux_text_v2, snd_soc_dapm_get_enum_double,
  1432. va_macro_put_dec_enum);
  1433. VA_MACRO_DAPM_ENUM_EXT(va_smic1_v2, BOLERO_CDC_VA_INP_MUX_ADC_MUX1_CFG0,
  1434. 0, smic_mux_text_v2, snd_soc_dapm_get_enum_double,
  1435. va_macro_put_dec_enum);
  1436. VA_MACRO_DAPM_ENUM_EXT(va_smic2_v3, BOLERO_CDC_VA_INP_MUX_ADC_MUX2_CFG0,
  1437. 0, smic_mux_text_v2, snd_soc_dapm_get_enum_double,
  1438. va_macro_put_dec_enum);
  1439. VA_MACRO_DAPM_ENUM_EXT(va_smic3_v3, BOLERO_CDC_VA_INP_MUX_ADC_MUX3_CFG0,
  1440. 0, smic_mux_text_v2, snd_soc_dapm_get_enum_double,
  1441. va_macro_put_dec_enum);
  1442. static const struct snd_kcontrol_new va_aif1_cap_mixer[] = {
  1443. SOC_SINGLE_EXT("DEC0", SND_SOC_NOPM, VA_MACRO_DEC0, 1, 0,
  1444. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1445. SOC_SINGLE_EXT("DEC1", SND_SOC_NOPM, VA_MACRO_DEC1, 1, 0,
  1446. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1447. SOC_SINGLE_EXT("DEC2", SND_SOC_NOPM, VA_MACRO_DEC2, 1, 0,
  1448. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1449. SOC_SINGLE_EXT("DEC3", SND_SOC_NOPM, VA_MACRO_DEC3, 1, 0,
  1450. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1451. SOC_SINGLE_EXT("DEC4", SND_SOC_NOPM, VA_MACRO_DEC4, 1, 0,
  1452. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1453. SOC_SINGLE_EXT("DEC5", SND_SOC_NOPM, VA_MACRO_DEC5, 1, 0,
  1454. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1455. SOC_SINGLE_EXT("DEC6", SND_SOC_NOPM, VA_MACRO_DEC6, 1, 0,
  1456. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1457. SOC_SINGLE_EXT("DEC7", SND_SOC_NOPM, VA_MACRO_DEC7, 1, 0,
  1458. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1459. };
  1460. static const struct snd_kcontrol_new va_aif2_cap_mixer[] = {
  1461. SOC_SINGLE_EXT("DEC0", SND_SOC_NOPM, VA_MACRO_DEC0, 1, 0,
  1462. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1463. SOC_SINGLE_EXT("DEC1", SND_SOC_NOPM, VA_MACRO_DEC1, 1, 0,
  1464. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1465. SOC_SINGLE_EXT("DEC2", SND_SOC_NOPM, VA_MACRO_DEC2, 1, 0,
  1466. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1467. SOC_SINGLE_EXT("DEC3", SND_SOC_NOPM, VA_MACRO_DEC3, 1, 0,
  1468. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1469. SOC_SINGLE_EXT("DEC4", SND_SOC_NOPM, VA_MACRO_DEC4, 1, 0,
  1470. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1471. SOC_SINGLE_EXT("DEC5", SND_SOC_NOPM, VA_MACRO_DEC5, 1, 0,
  1472. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1473. SOC_SINGLE_EXT("DEC6", SND_SOC_NOPM, VA_MACRO_DEC6, 1, 0,
  1474. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1475. SOC_SINGLE_EXT("DEC7", SND_SOC_NOPM, VA_MACRO_DEC7, 1, 0,
  1476. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1477. };
  1478. static const struct snd_kcontrol_new va_aif3_cap_mixer[] = {
  1479. SOC_SINGLE_EXT("DEC0", SND_SOC_NOPM, VA_MACRO_DEC0, 1, 0,
  1480. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1481. SOC_SINGLE_EXT("DEC1", SND_SOC_NOPM, VA_MACRO_DEC1, 1, 0,
  1482. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1483. SOC_SINGLE_EXT("DEC2", SND_SOC_NOPM, VA_MACRO_DEC2, 1, 0,
  1484. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1485. SOC_SINGLE_EXT("DEC3", SND_SOC_NOPM, VA_MACRO_DEC3, 1, 0,
  1486. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1487. SOC_SINGLE_EXT("DEC4", SND_SOC_NOPM, VA_MACRO_DEC4, 1, 0,
  1488. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1489. SOC_SINGLE_EXT("DEC5", SND_SOC_NOPM, VA_MACRO_DEC5, 1, 0,
  1490. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1491. SOC_SINGLE_EXT("DEC6", SND_SOC_NOPM, VA_MACRO_DEC6, 1, 0,
  1492. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1493. SOC_SINGLE_EXT("DEC7", SND_SOC_NOPM, VA_MACRO_DEC7, 1, 0,
  1494. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1495. };
  1496. static const struct snd_kcontrol_new va_aif1_cap_mixer_v2[] = {
  1497. SOC_SINGLE_EXT("DEC0", SND_SOC_NOPM, VA_MACRO_DEC0, 1, 0,
  1498. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1499. SOC_SINGLE_EXT("DEC1", SND_SOC_NOPM, VA_MACRO_DEC1, 1, 0,
  1500. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1501. };
  1502. static const struct snd_kcontrol_new va_aif2_cap_mixer_v2[] = {
  1503. SOC_SINGLE_EXT("DEC0", SND_SOC_NOPM, VA_MACRO_DEC0, 1, 0,
  1504. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1505. SOC_SINGLE_EXT("DEC1", SND_SOC_NOPM, VA_MACRO_DEC1, 1, 0,
  1506. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1507. };
  1508. static const struct snd_kcontrol_new va_aif3_cap_mixer_v2[] = {
  1509. SOC_SINGLE_EXT("DEC0", SND_SOC_NOPM, VA_MACRO_DEC0, 1, 0,
  1510. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1511. SOC_SINGLE_EXT("DEC1", SND_SOC_NOPM, VA_MACRO_DEC1, 1, 0,
  1512. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1513. };
  1514. static const struct snd_kcontrol_new va_aif1_cap_mixer_v3[] = {
  1515. SOC_SINGLE_EXT("DEC0", SND_SOC_NOPM, VA_MACRO_DEC0, 1, 0,
  1516. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1517. SOC_SINGLE_EXT("DEC1", SND_SOC_NOPM, VA_MACRO_DEC1, 1, 0,
  1518. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1519. SOC_SINGLE_EXT("DEC2", SND_SOC_NOPM, VA_MACRO_DEC2, 1, 0,
  1520. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1521. SOC_SINGLE_EXT("DEC3", SND_SOC_NOPM, VA_MACRO_DEC3, 1, 0,
  1522. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1523. };
  1524. static const struct snd_kcontrol_new va_aif2_cap_mixer_v3[] = {
  1525. SOC_SINGLE_EXT("DEC0", SND_SOC_NOPM, VA_MACRO_DEC0, 1, 0,
  1526. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1527. SOC_SINGLE_EXT("DEC1", SND_SOC_NOPM, VA_MACRO_DEC1, 1, 0,
  1528. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1529. SOC_SINGLE_EXT("DEC2", SND_SOC_NOPM, VA_MACRO_DEC2, 1, 0,
  1530. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1531. SOC_SINGLE_EXT("DEC3", SND_SOC_NOPM, VA_MACRO_DEC3, 1, 0,
  1532. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1533. };
  1534. static const struct snd_kcontrol_new va_aif3_cap_mixer_v3[] = {
  1535. SOC_SINGLE_EXT("DEC0", SND_SOC_NOPM, VA_MACRO_DEC0, 1, 0,
  1536. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1537. SOC_SINGLE_EXT("DEC1", SND_SOC_NOPM, VA_MACRO_DEC1, 1, 0,
  1538. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1539. SOC_SINGLE_EXT("DEC2", SND_SOC_NOPM, VA_MACRO_DEC2, 1, 0,
  1540. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1541. SOC_SINGLE_EXT("DEC3", SND_SOC_NOPM, VA_MACRO_DEC3, 1, 0,
  1542. va_macro_tx_mixer_get, va_macro_tx_mixer_put),
  1543. };
  1544. static const struct snd_soc_dapm_widget va_macro_dapm_widgets_common[] = {
  1545. SND_SOC_DAPM_AIF_OUT_E("VA_AIF1 CAP", "VA_AIF1 Capture", 0,
  1546. SND_SOC_NOPM, VA_MACRO_AIF1_CAP, 0,
  1547. va_macro_enable_tx, SND_SOC_DAPM_POST_PMU |
  1548. SND_SOC_DAPM_PRE_PMD),
  1549. SND_SOC_DAPM_AIF_OUT_E("VA_AIF2 CAP", "VA_AIF2 Capture", 0,
  1550. SND_SOC_NOPM, VA_MACRO_AIF2_CAP, 0,
  1551. va_macro_enable_tx, SND_SOC_DAPM_POST_PMU |
  1552. SND_SOC_DAPM_PRE_PMD),
  1553. SND_SOC_DAPM_AIF_OUT_E("VA_AIF3 CAP", "VA_AIF3 Capture", 0,
  1554. SND_SOC_NOPM, VA_MACRO_AIF3_CAP, 0,
  1555. va_macro_enable_tx, SND_SOC_DAPM_POST_PMU |
  1556. SND_SOC_DAPM_PRE_PMD),
  1557. VA_MACRO_DAPM_MUX("VA DMIC MUX0", 0, va_dmic0),
  1558. VA_MACRO_DAPM_MUX("VA DMIC MUX1", 0, va_dmic1),
  1559. VA_MACRO_DAPM_MUX("VA SMIC MUX0", 0, va_smic0_v2),
  1560. VA_MACRO_DAPM_MUX("VA SMIC MUX1", 0, va_smic1_v2),
  1561. SND_SOC_DAPM_INPUT("VA SWR_INPUT"),
  1562. SND_SOC_DAPM_SUPPLY("VA MIC BIAS1", SND_SOC_NOPM, 0, 0,
  1563. va_macro_enable_micbias,
  1564. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1565. SND_SOC_DAPM_ADC_E("VA DMIC0", 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 DMIC1", 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 DMIC2", 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 DMIC3", 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 DMIC4", 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_ADC_E("VA DMIC5", NULL, SND_SOC_NOPM, 0, 0,
  1581. va_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1582. SND_SOC_DAPM_POST_PMD),
  1583. SND_SOC_DAPM_ADC_E("VA DMIC6", NULL, SND_SOC_NOPM, 0, 0,
  1584. va_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1585. SND_SOC_DAPM_POST_PMD),
  1586. SND_SOC_DAPM_ADC_E("VA DMIC7", NULL, SND_SOC_NOPM, 0, 0,
  1587. va_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1588. SND_SOC_DAPM_POST_PMD),
  1589. SND_SOC_DAPM_MUX_E("VA DEC0 MUX", SND_SOC_NOPM, VA_MACRO_DEC0, 0,
  1590. &va_dec0_mux, va_macro_enable_dec,
  1591. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1592. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1593. SND_SOC_DAPM_MUX_E("VA DEC1 MUX", SND_SOC_NOPM, VA_MACRO_DEC1, 0,
  1594. &va_dec1_mux, va_macro_enable_dec,
  1595. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1596. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1597. SND_SOC_DAPM_SUPPLY_S("VA_MCLK", -1, SND_SOC_NOPM, 0, 0,
  1598. va_macro_mclk_event,
  1599. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1600. };
  1601. static const struct snd_soc_dapm_widget va_macro_dapm_widgets_v2[] = {
  1602. SND_SOC_DAPM_MIXER("VA_AIF1_CAP Mixer", SND_SOC_NOPM,
  1603. VA_MACRO_AIF1_CAP, 0,
  1604. va_aif1_cap_mixer_v2, ARRAY_SIZE(va_aif1_cap_mixer_v2)),
  1605. SND_SOC_DAPM_MIXER("VA_AIF2_CAP Mixer", SND_SOC_NOPM,
  1606. VA_MACRO_AIF2_CAP, 0,
  1607. va_aif2_cap_mixer_v2, ARRAY_SIZE(va_aif2_cap_mixer_v2)),
  1608. SND_SOC_DAPM_MIXER("VA_AIF3_CAP Mixer", SND_SOC_NOPM,
  1609. VA_MACRO_AIF3_CAP, 0,
  1610. va_aif3_cap_mixer_v2, ARRAY_SIZE(va_aif3_cap_mixer_v2)),
  1611. SND_SOC_DAPM_SUPPLY_S("VA_SWR_PWR", -1, SND_SOC_NOPM, 0, 0,
  1612. va_macro_swr_pwr_event_v2,
  1613. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1614. SND_SOC_DAPM_SUPPLY_S("VA_TX_SWR_CLK", 0, SND_SOC_NOPM, 0, 0,
  1615. va_macro_tx_swr_clk_event_v2,
  1616. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1617. };
  1618. static const struct snd_soc_dapm_widget va_macro_dapm_widgets_v3[] = {
  1619. SND_SOC_DAPM_MIXER("VA_AIF1_CAP Mixer", SND_SOC_NOPM,
  1620. VA_MACRO_AIF1_CAP, 0,
  1621. va_aif1_cap_mixer_v3, ARRAY_SIZE(va_aif1_cap_mixer_v3)),
  1622. SND_SOC_DAPM_MIXER("VA_AIF2_CAP Mixer", SND_SOC_NOPM,
  1623. VA_MACRO_AIF2_CAP, 0,
  1624. va_aif2_cap_mixer_v3, ARRAY_SIZE(va_aif2_cap_mixer_v3)),
  1625. SND_SOC_DAPM_MIXER("VA_AIF3_CAP Mixer", SND_SOC_NOPM,
  1626. VA_MACRO_AIF3_CAP, 0,
  1627. va_aif3_cap_mixer_v3, ARRAY_SIZE(va_aif3_cap_mixer_v3)),
  1628. VA_MACRO_DAPM_MUX("VA DMIC MUX2", 0, va_dmic2),
  1629. VA_MACRO_DAPM_MUX("VA DMIC MUX3", 0, va_dmic3),
  1630. VA_MACRO_DAPM_MUX("VA SMIC MUX2", 0, va_smic2_v3),
  1631. VA_MACRO_DAPM_MUX("VA SMIC MUX3", 0, va_smic3_v3),
  1632. SND_SOC_DAPM_MUX_E("VA DEC2 MUX", SND_SOC_NOPM, VA_MACRO_DEC2, 0,
  1633. &va_dec2_mux, va_macro_enable_dec,
  1634. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1635. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1636. SND_SOC_DAPM_MUX_E("VA DEC3 MUX", SND_SOC_NOPM, VA_MACRO_DEC3, 0,
  1637. &va_dec3_mux, va_macro_enable_dec,
  1638. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1639. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1640. SND_SOC_DAPM_SUPPLY_S("VA_SWR_PWR", -1, SND_SOC_NOPM, 0, 0,
  1641. va_macro_swr_pwr_event,
  1642. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1643. };
  1644. static const struct snd_soc_dapm_widget va_macro_dapm_widgets[] = {
  1645. SND_SOC_DAPM_AIF_OUT_E("VA_AIF1 CAP", "VA_AIF1 Capture", 0,
  1646. SND_SOC_NOPM, VA_MACRO_AIF1_CAP, 0,
  1647. va_macro_enable_tx, SND_SOC_DAPM_POST_PMU |
  1648. SND_SOC_DAPM_PRE_PMD),
  1649. SND_SOC_DAPM_AIF_OUT_E("VA_AIF2 CAP", "VA_AIF2 Capture", 0,
  1650. SND_SOC_NOPM, VA_MACRO_AIF2_CAP, 0,
  1651. va_macro_enable_tx, SND_SOC_DAPM_POST_PMU |
  1652. SND_SOC_DAPM_PRE_PMD),
  1653. SND_SOC_DAPM_AIF_OUT_E("VA_AIF3 CAP", "VA_AIF3 Capture", 0,
  1654. SND_SOC_NOPM, VA_MACRO_AIF3_CAP, 0,
  1655. va_macro_enable_tx, SND_SOC_DAPM_POST_PMU |
  1656. SND_SOC_DAPM_PRE_PMD),
  1657. SND_SOC_DAPM_MIXER("VA_AIF1_CAP Mixer", SND_SOC_NOPM,
  1658. VA_MACRO_AIF1_CAP, 0,
  1659. va_aif1_cap_mixer, ARRAY_SIZE(va_aif1_cap_mixer)),
  1660. SND_SOC_DAPM_MIXER("VA_AIF2_CAP Mixer", SND_SOC_NOPM,
  1661. VA_MACRO_AIF2_CAP, 0,
  1662. va_aif2_cap_mixer, ARRAY_SIZE(va_aif2_cap_mixer)),
  1663. SND_SOC_DAPM_MIXER("VA_AIF3_CAP Mixer", SND_SOC_NOPM,
  1664. VA_MACRO_AIF3_CAP, 0,
  1665. va_aif3_cap_mixer, ARRAY_SIZE(va_aif3_cap_mixer)),
  1666. VA_MACRO_DAPM_MUX("VA DMIC MUX0", 0, va_dmic0),
  1667. VA_MACRO_DAPM_MUX("VA DMIC MUX1", 0, va_dmic1),
  1668. VA_MACRO_DAPM_MUX("VA DMIC MUX2", 0, va_dmic2),
  1669. VA_MACRO_DAPM_MUX("VA DMIC MUX3", 0, va_dmic3),
  1670. VA_MACRO_DAPM_MUX("VA DMIC MUX4", 0, va_dmic4),
  1671. VA_MACRO_DAPM_MUX("VA DMIC MUX5", 0, va_dmic5),
  1672. VA_MACRO_DAPM_MUX("VA DMIC MUX6", 0, va_dmic6),
  1673. VA_MACRO_DAPM_MUX("VA DMIC MUX7", 0, va_dmic7),
  1674. VA_MACRO_DAPM_MUX("VA SMIC MUX0", 0, va_smic0),
  1675. VA_MACRO_DAPM_MUX("VA SMIC MUX1", 0, va_smic1),
  1676. VA_MACRO_DAPM_MUX("VA SMIC MUX2", 0, va_smic2),
  1677. VA_MACRO_DAPM_MUX("VA SMIC MUX3", 0, va_smic3),
  1678. VA_MACRO_DAPM_MUX("VA SMIC MUX4", 0, va_smic4),
  1679. VA_MACRO_DAPM_MUX("VA SMIC MUX5", 0, va_smic5),
  1680. VA_MACRO_DAPM_MUX("VA SMIC MUX6", 0, va_smic6),
  1681. VA_MACRO_DAPM_MUX("VA SMIC MUX7", 0, va_smic7),
  1682. SND_SOC_DAPM_SUPPLY("VA MIC BIAS1", SND_SOC_NOPM, 0, 0,
  1683. va_macro_enable_micbias,
  1684. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1685. SND_SOC_DAPM_ADC_E("VA DMIC0", 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 DMIC1", 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 DMIC2", 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 DMIC3", 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 DMIC4", 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_ADC_E("VA DMIC5", NULL, SND_SOC_NOPM, 0, 0,
  1701. va_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1702. SND_SOC_DAPM_POST_PMD),
  1703. SND_SOC_DAPM_ADC_E("VA DMIC6", NULL, SND_SOC_NOPM, 0, 0,
  1704. va_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1705. SND_SOC_DAPM_POST_PMD),
  1706. SND_SOC_DAPM_ADC_E("VA DMIC7", NULL, SND_SOC_NOPM, 0, 0,
  1707. va_macro_enable_dmic, SND_SOC_DAPM_PRE_PMU |
  1708. SND_SOC_DAPM_POST_PMD),
  1709. SND_SOC_DAPM_INPUT("VA SWR_ADC0"),
  1710. SND_SOC_DAPM_INPUT("VA SWR_ADC1"),
  1711. SND_SOC_DAPM_INPUT("VA SWR_ADC2"),
  1712. SND_SOC_DAPM_INPUT("VA SWR_ADC3"),
  1713. SND_SOC_DAPM_INPUT("VA SWR_MIC0"),
  1714. SND_SOC_DAPM_INPUT("VA SWR_MIC1"),
  1715. SND_SOC_DAPM_INPUT("VA SWR_MIC2"),
  1716. SND_SOC_DAPM_INPUT("VA SWR_MIC3"),
  1717. SND_SOC_DAPM_INPUT("VA SWR_MIC4"),
  1718. SND_SOC_DAPM_INPUT("VA SWR_MIC5"),
  1719. SND_SOC_DAPM_INPUT("VA SWR_MIC6"),
  1720. SND_SOC_DAPM_INPUT("VA SWR_MIC7"),
  1721. SND_SOC_DAPM_MUX_E("VA DEC0 MUX", SND_SOC_NOPM, VA_MACRO_DEC0, 0,
  1722. &va_dec0_mux, va_macro_enable_dec,
  1723. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1724. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1725. SND_SOC_DAPM_MUX_E("VA DEC1 MUX", SND_SOC_NOPM, VA_MACRO_DEC1, 0,
  1726. &va_dec1_mux, va_macro_enable_dec,
  1727. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1728. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1729. SND_SOC_DAPM_MUX_E("VA DEC2 MUX", SND_SOC_NOPM, VA_MACRO_DEC2, 0,
  1730. &va_dec2_mux, va_macro_enable_dec,
  1731. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1732. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1733. SND_SOC_DAPM_MUX_E("VA DEC3 MUX", SND_SOC_NOPM, VA_MACRO_DEC3, 0,
  1734. &va_dec3_mux, va_macro_enable_dec,
  1735. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1736. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1737. SND_SOC_DAPM_MUX_E("VA DEC4 MUX", SND_SOC_NOPM, VA_MACRO_DEC4, 0,
  1738. &va_dec4_mux, va_macro_enable_dec,
  1739. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1740. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1741. SND_SOC_DAPM_MUX_E("VA DEC5 MUX", SND_SOC_NOPM, VA_MACRO_DEC5, 0,
  1742. &va_dec5_mux, va_macro_enable_dec,
  1743. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1744. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1745. SND_SOC_DAPM_MUX_E("VA DEC6 MUX", SND_SOC_NOPM, VA_MACRO_DEC6, 0,
  1746. &va_dec6_mux, va_macro_enable_dec,
  1747. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1748. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1749. SND_SOC_DAPM_MUX_E("VA DEC7 MUX", SND_SOC_NOPM, VA_MACRO_DEC7, 0,
  1750. &va_dec7_mux, va_macro_enable_dec,
  1751. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1752. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1753. SND_SOC_DAPM_SUPPLY_S("VA_SWR_PWR", -1, SND_SOC_NOPM, 0, 0,
  1754. va_macro_swr_pwr_event,
  1755. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1756. SND_SOC_DAPM_SUPPLY_S("VA_MCLK", -1, SND_SOC_NOPM, 0, 0,
  1757. va_macro_mclk_event,
  1758. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1759. };
  1760. static const struct snd_soc_dapm_widget va_macro_wod_dapm_widgets[] = {
  1761. SND_SOC_DAPM_SUPPLY_S("VA_MCLK", -1, SND_SOC_NOPM, 0, 0,
  1762. va_macro_mclk_event,
  1763. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1764. };
  1765. static const struct snd_soc_dapm_route va_audio_map_common[] = {
  1766. {"VA_AIF1 CAP", NULL, "VA_MCLK"},
  1767. {"VA_AIF2 CAP", NULL, "VA_MCLK"},
  1768. {"VA_AIF3 CAP", NULL, "VA_MCLK"},
  1769. {"VA_AIF1 CAP", NULL, "VA_AIF1_CAP Mixer"},
  1770. {"VA_AIF2 CAP", NULL, "VA_AIF2_CAP Mixer"},
  1771. {"VA_AIF3 CAP", NULL, "VA_AIF3_CAP Mixer"},
  1772. {"VA_AIF1_CAP Mixer", "DEC0", "VA DEC0 MUX"},
  1773. {"VA_AIF1_CAP Mixer", "DEC1", "VA DEC1 MUX"},
  1774. {"VA_AIF2_CAP Mixer", "DEC0", "VA DEC0 MUX"},
  1775. {"VA_AIF2_CAP Mixer", "DEC1", "VA DEC1 MUX"},
  1776. {"VA_AIF3_CAP Mixer", "DEC0", "VA DEC0 MUX"},
  1777. {"VA_AIF3_CAP Mixer", "DEC1", "VA DEC1 MUX"},
  1778. {"VA DEC0 MUX", "MSM_DMIC", "VA DMIC MUX0"},
  1779. {"VA DMIC MUX0", "DMIC0", "VA DMIC0"},
  1780. {"VA DMIC MUX0", "DMIC1", "VA DMIC1"},
  1781. {"VA DMIC MUX0", "DMIC2", "VA DMIC2"},
  1782. {"VA DMIC MUX0", "DMIC3", "VA DMIC3"},
  1783. {"VA DMIC MUX0", "DMIC4", "VA DMIC4"},
  1784. {"VA DMIC MUX0", "DMIC5", "VA DMIC5"},
  1785. {"VA DMIC MUX0", "DMIC6", "VA DMIC6"},
  1786. {"VA DMIC MUX0", "DMIC7", "VA DMIC7"},
  1787. {"VA DEC0 MUX", "SWR_MIC", "VA SMIC MUX0"},
  1788. {"VA SMIC MUX0", "SWR_MIC0", "VA SWR_INPUT"},
  1789. {"VA SMIC MUX0", "SWR_MIC1", "VA SWR_INPUT"},
  1790. {"VA SMIC MUX0", "SWR_MIC2", "VA SWR_INPUT"},
  1791. {"VA SMIC MUX0", "SWR_MIC3", "VA SWR_INPUT"},
  1792. {"VA SMIC MUX0", "SWR_MIC4", "VA SWR_INPUT"},
  1793. {"VA SMIC MUX0", "SWR_MIC5", "VA SWR_INPUT"},
  1794. {"VA SMIC MUX0", "SWR_MIC6", "VA SWR_INPUT"},
  1795. {"VA SMIC MUX0", "SWR_MIC7", "VA SWR_INPUT"},
  1796. {"VA SMIC MUX0", "SWR_MIC8", "VA SWR_INPUT"},
  1797. {"VA SMIC MUX0", "SWR_MIC9", "VA SWR_INPUT"},
  1798. {"VA SMIC MUX0", "SWR_MIC10", "VA SWR_INPUT"},
  1799. {"VA SMIC MUX0", "SWR_MIC11", "VA SWR_INPUT"},
  1800. {"VA DEC1 MUX", "MSM_DMIC", "VA DMIC MUX1"},
  1801. {"VA DMIC MUX1", "DMIC0", "VA DMIC0"},
  1802. {"VA DMIC MUX1", "DMIC1", "VA DMIC1"},
  1803. {"VA DMIC MUX1", "DMIC2", "VA DMIC2"},
  1804. {"VA DMIC MUX1", "DMIC3", "VA DMIC3"},
  1805. {"VA DMIC MUX1", "DMIC4", "VA DMIC4"},
  1806. {"VA DMIC MUX1", "DMIC5", "VA DMIC5"},
  1807. {"VA DMIC MUX1", "DMIC6", "VA DMIC6"},
  1808. {"VA DMIC MUX1", "DMIC7", "VA DMIC7"},
  1809. {"VA DEC1 MUX", "SWR_MIC", "VA SMIC MUX1"},
  1810. {"VA SMIC MUX1", "SWR_MIC0", "VA SWR_INPUT"},
  1811. {"VA SMIC MUX1", "SWR_MIC1", "VA SWR_INPUT"},
  1812. {"VA SMIC MUX1", "SWR_MIC2", "VA SWR_INPUT"},
  1813. {"VA SMIC MUX1", "SWR_MIC3", "VA SWR_INPUT"},
  1814. {"VA SMIC MUX1", "SWR_MIC4", "VA SWR_INPUT"},
  1815. {"VA SMIC MUX1", "SWR_MIC5", "VA SWR_INPUT"},
  1816. {"VA SMIC MUX1", "SWR_MIC6", "VA SWR_INPUT"},
  1817. {"VA SMIC MUX1", "SWR_MIC7", "VA SWR_INPUT"},
  1818. {"VA SMIC MUX1", "SWR_MIC8", "VA SWR_INPUT"},
  1819. {"VA SMIC MUX1", "SWR_MIC9", "VA SWR_INPUT"},
  1820. {"VA SMIC MUX1", "SWR_MIC10", "VA SWR_INPUT"},
  1821. {"VA SMIC MUX1", "SWR_MIC11", "VA SWR_INPUT"},
  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. {"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
  1826. {"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
  1827. {"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
  1828. {"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
  1829. {"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
  1830. {"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
  1831. {"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
  1832. {"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
  1833. {"VA SWR_INPUT", NULL, "VA_SWR_PWR"},
  1834. };
  1835. static const struct snd_soc_dapm_route va_audio_map_v3[] = {
  1836. {"VA_AIF1_CAP Mixer", "DEC2", "VA DEC2 MUX"},
  1837. {"VA_AIF1_CAP Mixer", "DEC3", "VA DEC3 MUX"},
  1838. {"VA_AIF2_CAP Mixer", "DEC2", "VA DEC2 MUX"},
  1839. {"VA_AIF2_CAP Mixer", "DEC3", "VA DEC3 MUX"},
  1840. {"VA_AIF3_CAP Mixer", "DEC2", "VA DEC2 MUX"},
  1841. {"VA_AIF3_CAP Mixer", "DEC3", "VA DEC3 MUX"},
  1842. {"VA DEC2 MUX", "MSM_DMIC", "VA DMIC MUX2"},
  1843. {"VA DMIC MUX2", "DMIC0", "VA DMIC0"},
  1844. {"VA DMIC MUX2", "DMIC1", "VA DMIC1"},
  1845. {"VA DMIC MUX2", "DMIC2", "VA DMIC2"},
  1846. {"VA DMIC MUX2", "DMIC3", "VA DMIC3"},
  1847. {"VA DMIC MUX2", "DMIC4", "VA DMIC4"},
  1848. {"VA DMIC MUX2", "DMIC5", "VA DMIC5"},
  1849. {"VA DMIC MUX2", "DMIC6", "VA DMIC6"},
  1850. {"VA DMIC MUX2", "DMIC7", "VA DMIC7"},
  1851. {"VA DEC2 MUX", "SWR_MIC", "VA SMIC MUX2"},
  1852. {"VA SMIC MUX2", "SWR_MIC0", "VA SWR_INPUT"},
  1853. {"VA SMIC MUX2", "SWR_MIC1", "VA SWR_INPUT"},
  1854. {"VA SMIC MUX2", "SWR_MIC2", "VA SWR_INPUT"},
  1855. {"VA SMIC MUX2", "SWR_MIC3", "VA SWR_INPUT"},
  1856. {"VA SMIC MUX2", "SWR_MIC4", "VA SWR_INPUT"},
  1857. {"VA SMIC MUX2", "SWR_MIC5", "VA SWR_INPUT"},
  1858. {"VA SMIC MUX2", "SWR_MIC6", "VA SWR_INPUT"},
  1859. {"VA SMIC MUX2", "SWR_MIC7", "VA SWR_INPUT"},
  1860. {"VA SMIC MUX2", "SWR_MIC8", "VA SWR_INPUT"},
  1861. {"VA SMIC MUX2", "SWR_MIC9", "VA SWR_INPUT"},
  1862. {"VA SMIC MUX2", "SWR_MIC10", "VA SWR_INPUT"},
  1863. {"VA SMIC MUX2", "SWR_MIC11", "VA SWR_INPUT"},
  1864. {"VA DEC3 MUX", "MSM_DMIC", "VA DMIC MUX3"},
  1865. {"VA DMIC MUX3", "DMIC0", "VA DMIC0"},
  1866. {"VA DMIC MUX3", "DMIC1", "VA DMIC1"},
  1867. {"VA DMIC MUX3", "DMIC2", "VA DMIC2"},
  1868. {"VA DMIC MUX3", "DMIC3", "VA DMIC3"},
  1869. {"VA DMIC MUX3", "DMIC4", "VA DMIC4"},
  1870. {"VA DMIC MUX3", "DMIC5", "VA DMIC5"},
  1871. {"VA DMIC MUX3", "DMIC6", "VA DMIC6"},
  1872. {"VA DMIC MUX3", "DMIC7", "VA DMIC7"},
  1873. {"VA DEC3 MUX", "SWR_MIC", "VA SMIC MUX3"},
  1874. {"VA SMIC MUX3", "SWR_MIC0", "VA SWR_INPUT"},
  1875. {"VA SMIC MUX3", "SWR_MIC1", "VA SWR_INPUT"},
  1876. {"VA SMIC MUX3", "SWR_MIC2", "VA SWR_INPUT"},
  1877. {"VA SMIC MUX3", "SWR_MIC3", "VA SWR_INPUT"},
  1878. {"VA SMIC MUX3", "SWR_MIC4", "VA SWR_INPUT"},
  1879. {"VA SMIC MUX3", "SWR_MIC5", "VA SWR_INPUT"},
  1880. {"VA SMIC MUX3", "SWR_MIC6", "VA SWR_INPUT"},
  1881. {"VA SMIC MUX3", "SWR_MIC7", "VA SWR_INPUT"},
  1882. {"VA SMIC MUX3", "SWR_MIC8", "VA SWR_INPUT"},
  1883. {"VA SMIC MUX3", "SWR_MIC9", "VA SWR_INPUT"},
  1884. {"VA SMIC MUX3", "SWR_MIC10", "VA SWR_INPUT"},
  1885. {"VA SMIC MUX3", "SWR_MIC11", "VA SWR_INPUT"},
  1886. };
  1887. static const struct snd_soc_dapm_route va_audio_map[] = {
  1888. {"VA_AIF1 CAP", NULL, "VA_MCLK"},
  1889. {"VA_AIF2 CAP", NULL, "VA_MCLK"},
  1890. {"VA_AIF3 CAP", NULL, "VA_MCLK"},
  1891. {"VA_AIF1 CAP", NULL, "VA_AIF1_CAP Mixer"},
  1892. {"VA_AIF2 CAP", NULL, "VA_AIF2_CAP Mixer"},
  1893. {"VA_AIF3 CAP", NULL, "VA_AIF3_CAP Mixer"},
  1894. {"VA_AIF1_CAP Mixer", "DEC0", "VA DEC0 MUX"},
  1895. {"VA_AIF1_CAP Mixer", "DEC1", "VA DEC1 MUX"},
  1896. {"VA_AIF1_CAP Mixer", "DEC2", "VA DEC2 MUX"},
  1897. {"VA_AIF1_CAP Mixer", "DEC3", "VA DEC3 MUX"},
  1898. {"VA_AIF1_CAP Mixer", "DEC4", "VA DEC4 MUX"},
  1899. {"VA_AIF1_CAP Mixer", "DEC5", "VA DEC5 MUX"},
  1900. {"VA_AIF1_CAP Mixer", "DEC6", "VA DEC6 MUX"},
  1901. {"VA_AIF1_CAP Mixer", "DEC7", "VA DEC7 MUX"},
  1902. {"VA_AIF2_CAP Mixer", "DEC0", "VA DEC0 MUX"},
  1903. {"VA_AIF2_CAP Mixer", "DEC1", "VA DEC1 MUX"},
  1904. {"VA_AIF2_CAP Mixer", "DEC2", "VA DEC2 MUX"},
  1905. {"VA_AIF2_CAP Mixer", "DEC3", "VA DEC3 MUX"},
  1906. {"VA_AIF2_CAP Mixer", "DEC4", "VA DEC4 MUX"},
  1907. {"VA_AIF2_CAP Mixer", "DEC5", "VA DEC5 MUX"},
  1908. {"VA_AIF2_CAP Mixer", "DEC6", "VA DEC6 MUX"},
  1909. {"VA_AIF2_CAP Mixer", "DEC7", "VA DEC7 MUX"},
  1910. {"VA_AIF3_CAP Mixer", "DEC0", "VA DEC0 MUX"},
  1911. {"VA_AIF3_CAP Mixer", "DEC1", "VA DEC1 MUX"},
  1912. {"VA_AIF3_CAP Mixer", "DEC2", "VA DEC2 MUX"},
  1913. {"VA_AIF3_CAP Mixer", "DEC3", "VA DEC3 MUX"},
  1914. {"VA_AIF3_CAP Mixer", "DEC4", "VA DEC4 MUX"},
  1915. {"VA_AIF3_CAP Mixer", "DEC5", "VA DEC5 MUX"},
  1916. {"VA_AIF3_CAP Mixer", "DEC6", "VA DEC6 MUX"},
  1917. {"VA_AIF3_CAP Mixer", "DEC7", "VA DEC7 MUX"},
  1918. {"VA DEC0 MUX", "MSM_DMIC", "VA DMIC MUX0"},
  1919. {"VA DMIC MUX0", "DMIC0", "VA DMIC0"},
  1920. {"VA DMIC MUX0", "DMIC1", "VA DMIC1"},
  1921. {"VA DMIC MUX0", "DMIC2", "VA DMIC2"},
  1922. {"VA DMIC MUX0", "DMIC3", "VA DMIC3"},
  1923. {"VA DMIC MUX0", "DMIC4", "VA DMIC4"},
  1924. {"VA DMIC MUX0", "DMIC5", "VA DMIC5"},
  1925. {"VA DMIC MUX0", "DMIC6", "VA DMIC6"},
  1926. {"VA DMIC MUX0", "DMIC7", "VA DMIC7"},
  1927. {"VA DEC0 MUX", "SWR_MIC", "VA SMIC MUX0"},
  1928. {"VA SMIC MUX0", "ADC0", "VA SWR_ADC0"},
  1929. {"VA SMIC MUX0", "ADC1", "VA SWR_ADC1"},
  1930. {"VA SMIC MUX0", "ADC2", "VA SWR_ADC2"},
  1931. {"VA SMIC MUX0", "ADC3", "VA SWR_ADC3"},
  1932. {"VA SMIC MUX0", "SWR_DMIC0", "VA SWR_MIC0"},
  1933. {"VA SMIC MUX0", "SWR_DMIC1", "VA SWR_MIC1"},
  1934. {"VA SMIC MUX0", "SWR_DMIC2", "VA SWR_MIC2"},
  1935. {"VA SMIC MUX0", "SWR_DMIC3", "VA SWR_MIC3"},
  1936. {"VA SMIC MUX0", "SWR_DMIC4", "VA SWR_MIC4"},
  1937. {"VA SMIC MUX0", "SWR_DMIC5", "VA SWR_MIC5"},
  1938. {"VA SMIC MUX0", "SWR_DMIC6", "VA SWR_MIC6"},
  1939. {"VA SMIC MUX0", "SWR_DMIC7", "VA SWR_MIC7"},
  1940. {"VA DEC1 MUX", "MSM_DMIC", "VA DMIC MUX1"},
  1941. {"VA DMIC MUX1", "DMIC0", "VA DMIC0"},
  1942. {"VA DMIC MUX1", "DMIC1", "VA DMIC1"},
  1943. {"VA DMIC MUX1", "DMIC2", "VA DMIC2"},
  1944. {"VA DMIC MUX1", "DMIC3", "VA DMIC3"},
  1945. {"VA DMIC MUX1", "DMIC4", "VA DMIC4"},
  1946. {"VA DMIC MUX1", "DMIC5", "VA DMIC5"},
  1947. {"VA DMIC MUX1", "DMIC6", "VA DMIC6"},
  1948. {"VA DMIC MUX1", "DMIC7", "VA DMIC7"},
  1949. {"VA DEC1 MUX", "SWR_MIC", "VA SMIC MUX1"},
  1950. {"VA SMIC MUX1", "ADC0", "VA SWR_ADC0"},
  1951. {"VA SMIC MUX1", "ADC1", "VA SWR_ADC1"},
  1952. {"VA SMIC MUX1", "ADC2", "VA SWR_ADC2"},
  1953. {"VA SMIC MUX1", "ADC3", "VA SWR_ADC3"},
  1954. {"VA SMIC MUX1", "SWR_DMIC0", "VA SWR_MIC0"},
  1955. {"VA SMIC MUX1", "SWR_DMIC1", "VA SWR_MIC1"},
  1956. {"VA SMIC MUX1", "SWR_DMIC2", "VA SWR_MIC2"},
  1957. {"VA SMIC MUX1", "SWR_DMIC3", "VA SWR_MIC3"},
  1958. {"VA SMIC MUX1", "SWR_DMIC4", "VA SWR_MIC4"},
  1959. {"VA SMIC MUX1", "SWR_DMIC5", "VA SWR_MIC5"},
  1960. {"VA SMIC MUX1", "SWR_DMIC6", "VA SWR_MIC6"},
  1961. {"VA SMIC MUX1", "SWR_DMIC7", "VA SWR_MIC7"},
  1962. {"VA DEC2 MUX", "MSM_DMIC", "VA DMIC MUX2"},
  1963. {"VA DMIC MUX2", "DMIC0", "VA DMIC0"},
  1964. {"VA DMIC MUX2", "DMIC1", "VA DMIC1"},
  1965. {"VA DMIC MUX2", "DMIC2", "VA DMIC2"},
  1966. {"VA DMIC MUX2", "DMIC3", "VA DMIC3"},
  1967. {"VA DMIC MUX2", "DMIC4", "VA DMIC4"},
  1968. {"VA DMIC MUX2", "DMIC5", "VA DMIC5"},
  1969. {"VA DMIC MUX2", "DMIC6", "VA DMIC6"},
  1970. {"VA DMIC MUX2", "DMIC7", "VA DMIC7"},
  1971. {"VA DEC2 MUX", "SWR_MIC", "VA SMIC MUX2"},
  1972. {"VA SMIC MUX2", "ADC0", "VA SWR_ADC0"},
  1973. {"VA SMIC MUX2", "ADC1", "VA SWR_ADC1"},
  1974. {"VA SMIC MUX2", "ADC2", "VA SWR_ADC2"},
  1975. {"VA SMIC MUX2", "ADC3", "VA SWR_ADC3"},
  1976. {"VA SMIC MUX2", "SWR_DMIC0", "VA SWR_MIC0"},
  1977. {"VA SMIC MUX2", "SWR_DMIC1", "VA SWR_MIC1"},
  1978. {"VA SMIC MUX2", "SWR_DMIC2", "VA SWR_MIC2"},
  1979. {"VA SMIC MUX2", "SWR_DMIC3", "VA SWR_MIC3"},
  1980. {"VA SMIC MUX2", "SWR_DMIC4", "VA SWR_MIC4"},
  1981. {"VA SMIC MUX2", "SWR_DMIC5", "VA SWR_MIC5"},
  1982. {"VA SMIC MUX2", "SWR_DMIC6", "VA SWR_MIC6"},
  1983. {"VA SMIC MUX2", "SWR_DMIC7", "VA SWR_MIC7"},
  1984. {"VA DEC3 MUX", "MSM_DMIC", "VA DMIC MUX3"},
  1985. {"VA DMIC MUX3", "DMIC0", "VA DMIC0"},
  1986. {"VA DMIC MUX3", "DMIC1", "VA DMIC1"},
  1987. {"VA DMIC MUX3", "DMIC2", "VA DMIC2"},
  1988. {"VA DMIC MUX3", "DMIC3", "VA DMIC3"},
  1989. {"VA DMIC MUX3", "DMIC4", "VA DMIC4"},
  1990. {"VA DMIC MUX3", "DMIC5", "VA DMIC5"},
  1991. {"VA DMIC MUX3", "DMIC6", "VA DMIC6"},
  1992. {"VA DMIC MUX3", "DMIC7", "VA DMIC7"},
  1993. {"VA DEC3 MUX", "SWR_MIC", "VA SMIC MUX3"},
  1994. {"VA SMIC MUX3", "ADC0", "VA SWR_ADC0"},
  1995. {"VA SMIC MUX3", "ADC1", "VA SWR_ADC1"},
  1996. {"VA SMIC MUX3", "ADC2", "VA SWR_ADC2"},
  1997. {"VA SMIC MUX3", "ADC3", "VA SWR_ADC3"},
  1998. {"VA SMIC MUX3", "SWR_DMIC0", "VA SWR_MIC0"},
  1999. {"VA SMIC MUX3", "SWR_DMIC1", "VA SWR_MIC1"},
  2000. {"VA SMIC MUX3", "SWR_DMIC2", "VA SWR_MIC2"},
  2001. {"VA SMIC MUX3", "SWR_DMIC3", "VA SWR_MIC3"},
  2002. {"VA SMIC MUX3", "SWR_DMIC4", "VA SWR_MIC4"},
  2003. {"VA SMIC MUX3", "SWR_DMIC5", "VA SWR_MIC5"},
  2004. {"VA SMIC MUX3", "SWR_DMIC6", "VA SWR_MIC6"},
  2005. {"VA SMIC MUX3", "SWR_DMIC7", "VA SWR_MIC7"},
  2006. {"VA DEC4 MUX", "MSM_DMIC", "VA DMIC MUX4"},
  2007. {"VA DMIC MUX4", "DMIC0", "VA DMIC0"},
  2008. {"VA DMIC MUX4", "DMIC1", "VA DMIC1"},
  2009. {"VA DMIC MUX4", "DMIC2", "VA DMIC2"},
  2010. {"VA DMIC MUX4", "DMIC3", "VA DMIC3"},
  2011. {"VA DMIC MUX4", "DMIC4", "VA DMIC4"},
  2012. {"VA DMIC MUX4", "DMIC5", "VA DMIC5"},
  2013. {"VA DMIC MUX4", "DMIC6", "VA DMIC6"},
  2014. {"VA DMIC MUX4", "DMIC7", "VA DMIC7"},
  2015. {"VA DEC4 MUX", "SWR_MIC", "VA SMIC MUX4"},
  2016. {"VA SMIC MUX4", "ADC0", "VA SWR_ADC0"},
  2017. {"VA SMIC MUX4", "ADC1", "VA SWR_ADC1"},
  2018. {"VA SMIC MUX4", "ADC2", "VA SWR_ADC2"},
  2019. {"VA SMIC MUX4", "ADC3", "VA SWR_ADC3"},
  2020. {"VA SMIC MUX4", "SWR_DMIC0", "VA SWR_MIC0"},
  2021. {"VA SMIC MUX4", "SWR_DMIC1", "VA SWR_MIC1"},
  2022. {"VA SMIC MUX4", "SWR_DMIC2", "VA SWR_MIC2"},
  2023. {"VA SMIC MUX4", "SWR_DMIC3", "VA SWR_MIC3"},
  2024. {"VA SMIC MUX4", "SWR_DMIC4", "VA SWR_MIC4"},
  2025. {"VA SMIC MUX4", "SWR_DMIC5", "VA SWR_MIC5"},
  2026. {"VA SMIC MUX4", "SWR_DMIC6", "VA SWR_MIC6"},
  2027. {"VA SMIC MUX4", "SWR_DMIC7", "VA SWR_MIC7"},
  2028. {"VA DEC5 MUX", "MSM_DMIC", "VA DMIC MUX5"},
  2029. {"VA DMIC MUX5", "DMIC0", "VA DMIC0"},
  2030. {"VA DMIC MUX5", "DMIC1", "VA DMIC1"},
  2031. {"VA DMIC MUX5", "DMIC2", "VA DMIC2"},
  2032. {"VA DMIC MUX5", "DMIC3", "VA DMIC3"},
  2033. {"VA DMIC MUX5", "DMIC4", "VA DMIC4"},
  2034. {"VA DMIC MUX5", "DMIC5", "VA DMIC5"},
  2035. {"VA DMIC MUX5", "DMIC6", "VA DMIC6"},
  2036. {"VA DMIC MUX5", "DMIC7", "VA DMIC7"},
  2037. {"VA DEC5 MUX", "SWR_MIC", "VA SMIC MUX5"},
  2038. {"VA SMIC MUX5", "ADC0", "VA SWR_ADC0"},
  2039. {"VA SMIC MUX5", "ADC1", "VA SWR_ADC1"},
  2040. {"VA SMIC MUX5", "ADC2", "VA SWR_ADC2"},
  2041. {"VA SMIC MUX5", "ADC3", "VA SWR_ADC3"},
  2042. {"VA SMIC MUX5", "SWR_DMIC0", "VA SWR_MIC0"},
  2043. {"VA SMIC MUX5", "SWR_DMIC1", "VA SWR_MIC1"},
  2044. {"VA SMIC MUX5", "SWR_DMIC2", "VA SWR_MIC2"},
  2045. {"VA SMIC MUX5", "SWR_DMIC3", "VA SWR_MIC3"},
  2046. {"VA SMIC MUX5", "SWR_DMIC4", "VA SWR_MIC4"},
  2047. {"VA SMIC MUX5", "SWR_DMIC5", "VA SWR_MIC5"},
  2048. {"VA SMIC MUX5", "SWR_DMIC6", "VA SWR_MIC6"},
  2049. {"VA SMIC MUX5", "SWR_DMIC7", "VA SWR_MIC7"},
  2050. {"VA DEC6 MUX", "MSM_DMIC", "VA DMIC MUX6"},
  2051. {"VA DMIC MUX6", "DMIC0", "VA DMIC0"},
  2052. {"VA DMIC MUX6", "DMIC1", "VA DMIC1"},
  2053. {"VA DMIC MUX6", "DMIC2", "VA DMIC2"},
  2054. {"VA DMIC MUX6", "DMIC3", "VA DMIC3"},
  2055. {"VA DMIC MUX6", "DMIC4", "VA DMIC4"},
  2056. {"VA DMIC MUX6", "DMIC5", "VA DMIC5"},
  2057. {"VA DMIC MUX6", "DMIC6", "VA DMIC6"},
  2058. {"VA DMIC MUX6", "DMIC7", "VA DMIC7"},
  2059. {"VA DEC6 MUX", "SWR_MIC", "VA SMIC MUX6"},
  2060. {"VA SMIC MUX6", "ADC0", "VA SWR_ADC0"},
  2061. {"VA SMIC MUX6", "ADC1", "VA SWR_ADC1"},
  2062. {"VA SMIC MUX6", "ADC2", "VA SWR_ADC2"},
  2063. {"VA SMIC MUX6", "ADC3", "VA SWR_ADC3"},
  2064. {"VA SMIC MUX6", "SWR_DMIC0", "VA SWR_MIC0"},
  2065. {"VA SMIC MUX6", "SWR_DMIC1", "VA SWR_MIC1"},
  2066. {"VA SMIC MUX6", "SWR_DMIC2", "VA SWR_MIC2"},
  2067. {"VA SMIC MUX6", "SWR_DMIC3", "VA SWR_MIC3"},
  2068. {"VA SMIC MUX6", "SWR_DMIC4", "VA SWR_MIC4"},
  2069. {"VA SMIC MUX6", "SWR_DMIC5", "VA SWR_MIC5"},
  2070. {"VA SMIC MUX6", "SWR_DMIC6", "VA SWR_MIC6"},
  2071. {"VA SMIC MUX6", "SWR_DMIC7", "VA SWR_MIC7"},
  2072. {"VA DEC7 MUX", "MSM_DMIC", "VA DMIC MUX7"},
  2073. {"VA DMIC MUX7", "DMIC0", "VA DMIC0"},
  2074. {"VA DMIC MUX7", "DMIC1", "VA DMIC1"},
  2075. {"VA DMIC MUX7", "DMIC2", "VA DMIC2"},
  2076. {"VA DMIC MUX7", "DMIC3", "VA DMIC3"},
  2077. {"VA DMIC MUX7", "DMIC4", "VA DMIC4"},
  2078. {"VA DMIC MUX7", "DMIC5", "VA DMIC5"},
  2079. {"VA DMIC MUX7", "DMIC6", "VA DMIC6"},
  2080. {"VA DMIC MUX7", "DMIC7", "VA DMIC7"},
  2081. {"VA DEC7 MUX", "SWR_MIC", "VA SMIC MUX7"},
  2082. {"VA SMIC MUX7", "ADC0", "VA SWR_ADC0"},
  2083. {"VA SMIC MUX7", "ADC1", "VA SWR_ADC1"},
  2084. {"VA SMIC MUX7", "ADC2", "VA SWR_ADC2"},
  2085. {"VA SMIC MUX7", "ADC3", "VA SWR_ADC3"},
  2086. {"VA SMIC MUX7", "SWR_DMIC0", "VA SWR_MIC0"},
  2087. {"VA SMIC MUX7", "SWR_DMIC1", "VA SWR_MIC1"},
  2088. {"VA SMIC MUX7", "SWR_DMIC2", "VA SWR_MIC2"},
  2089. {"VA SMIC MUX7", "SWR_DMIC3", "VA SWR_MIC3"},
  2090. {"VA SMIC MUX7", "SWR_DMIC4", "VA SWR_MIC4"},
  2091. {"VA SMIC MUX7", "SWR_DMIC5", "VA SWR_MIC5"},
  2092. {"VA SMIC MUX7", "SWR_DMIC6", "VA SWR_MIC6"},
  2093. {"VA SMIC MUX7", "SWR_DMIC7", "VA SWR_MIC7"},
  2094. {"VA SWR_ADC0", NULL, "VA_SWR_PWR"},
  2095. {"VA SWR_ADC1", NULL, "VA_SWR_PWR"},
  2096. {"VA SWR_ADC2", NULL, "VA_SWR_PWR"},
  2097. {"VA SWR_ADC3", NULL, "VA_SWR_PWR"},
  2098. };
  2099. static const struct snd_kcontrol_new va_macro_snd_controls[] = {
  2100. SOC_SINGLE_SX_TLV("VA_DEC0 Volume",
  2101. BOLERO_CDC_VA_TX0_TX_VOL_CTL,
  2102. 0, -84, 40, digital_gain),
  2103. SOC_SINGLE_SX_TLV("VA_DEC1 Volume",
  2104. BOLERO_CDC_VA_TX1_TX_VOL_CTL,
  2105. 0, -84, 40, digital_gain),
  2106. SOC_SINGLE_SX_TLV("VA_DEC2 Volume",
  2107. BOLERO_CDC_VA_TX2_TX_VOL_CTL,
  2108. 0, -84, 40, digital_gain),
  2109. SOC_SINGLE_SX_TLV("VA_DEC3 Volume",
  2110. BOLERO_CDC_VA_TX3_TX_VOL_CTL,
  2111. 0, -84, 40, digital_gain),
  2112. SOC_SINGLE_SX_TLV("VA_DEC4 Volume",
  2113. BOLERO_CDC_VA_TX4_TX_VOL_CTL,
  2114. 0, -84, 40, digital_gain),
  2115. SOC_SINGLE_SX_TLV("VA_DEC5 Volume",
  2116. BOLERO_CDC_VA_TX5_TX_VOL_CTL,
  2117. 0, -84, 40, digital_gain),
  2118. SOC_SINGLE_SX_TLV("VA_DEC6 Volume",
  2119. BOLERO_CDC_VA_TX6_TX_VOL_CTL,
  2120. 0, -84, 40, digital_gain),
  2121. SOC_SINGLE_SX_TLV("VA_DEC7 Volume",
  2122. BOLERO_CDC_VA_TX7_TX_VOL_CTL,
  2123. 0, -84, 40, digital_gain),
  2124. SOC_SINGLE_EXT("LPI Enable", 0, 0, 1, 0,
  2125. va_macro_lpi_get, va_macro_lpi_put),
  2126. };
  2127. static const struct snd_kcontrol_new va_macro_snd_controls_common[] = {
  2128. SOC_SINGLE_SX_TLV("VA_DEC0 Volume",
  2129. BOLERO_CDC_VA_TX0_TX_VOL_CTL,
  2130. 0, -84, 40, digital_gain),
  2131. SOC_SINGLE_SX_TLV("VA_DEC1 Volume",
  2132. BOLERO_CDC_VA_TX1_TX_VOL_CTL,
  2133. 0, -84, 40, digital_gain),
  2134. };
  2135. static const struct snd_kcontrol_new va_macro_snd_controls_v3[] = {
  2136. SOC_SINGLE_SX_TLV("VA_DEC2 Volume",
  2137. BOLERO_CDC_VA_TX2_TX_VOL_CTL,
  2138. 0, -84, 40, digital_gain),
  2139. SOC_SINGLE_SX_TLV("VA_DEC3 Volume",
  2140. BOLERO_CDC_VA_TX3_TX_VOL_CTL,
  2141. 0, -84, 40, digital_gain),
  2142. SOC_SINGLE_EXT("LPI Enable", 0, 0, 1, 0,
  2143. va_macro_lpi_get, va_macro_lpi_put),
  2144. };
  2145. static int va_macro_validate_dmic_sample_rate(u32 dmic_sample_rate,
  2146. struct va_macro_priv *va_priv)
  2147. {
  2148. u32 div_factor;
  2149. u32 mclk_rate = VA_MACRO_MCLK_FREQ;
  2150. if (dmic_sample_rate == VA_MACRO_DMIC_SAMPLE_RATE_UNDEFINED ||
  2151. mclk_rate % dmic_sample_rate != 0)
  2152. goto undefined_rate;
  2153. div_factor = mclk_rate / dmic_sample_rate;
  2154. switch (div_factor) {
  2155. case 2:
  2156. va_priv->dmic_clk_div = VA_MACRO_CLK_DIV_2;
  2157. break;
  2158. case 3:
  2159. va_priv->dmic_clk_div = VA_MACRO_CLK_DIV_3;
  2160. break;
  2161. case 4:
  2162. va_priv->dmic_clk_div = VA_MACRO_CLK_DIV_4;
  2163. break;
  2164. case 6:
  2165. va_priv->dmic_clk_div = VA_MACRO_CLK_DIV_6;
  2166. break;
  2167. case 8:
  2168. va_priv->dmic_clk_div = VA_MACRO_CLK_DIV_8;
  2169. break;
  2170. case 16:
  2171. va_priv->dmic_clk_div = VA_MACRO_CLK_DIV_16;
  2172. break;
  2173. default:
  2174. /* Any other DIV factor is invalid */
  2175. goto undefined_rate;
  2176. }
  2177. /* Valid dmic DIV factors */
  2178. dev_dbg(va_priv->dev, "%s: DMIC_DIV = %u, mclk_rate = %u\n",
  2179. __func__, div_factor, mclk_rate);
  2180. return dmic_sample_rate;
  2181. undefined_rate:
  2182. dev_dbg(va_priv->dev, "%s: Invalid rate %d, for mclk %d\n",
  2183. __func__, dmic_sample_rate, mclk_rate);
  2184. dmic_sample_rate = VA_MACRO_DMIC_SAMPLE_RATE_UNDEFINED;
  2185. return dmic_sample_rate;
  2186. }
  2187. static int va_macro_init(struct snd_soc_component *component)
  2188. {
  2189. struct snd_soc_dapm_context *dapm =
  2190. snd_soc_component_get_dapm(component);
  2191. int ret, i;
  2192. struct device *va_dev = NULL;
  2193. struct va_macro_priv *va_priv = NULL;
  2194. va_dev = bolero_get_device_ptr(component->dev, VA_MACRO);
  2195. if (!va_dev) {
  2196. dev_err(component->dev,
  2197. "%s: null device for macro!\n", __func__);
  2198. return -EINVAL;
  2199. }
  2200. va_priv = dev_get_drvdata(va_dev);
  2201. if (!va_priv) {
  2202. dev_err(component->dev,
  2203. "%s: priv is null for macro!\n", __func__);
  2204. return -EINVAL;
  2205. }
  2206. va_priv->lpi_enable = false;
  2207. va_priv->register_event_listener = false;
  2208. if (va_priv->va_without_decimation) {
  2209. ret = snd_soc_dapm_new_controls(dapm, va_macro_wod_dapm_widgets,
  2210. ARRAY_SIZE(va_macro_wod_dapm_widgets));
  2211. if (ret < 0) {
  2212. dev_err(va_dev,
  2213. "%s: Failed to add without dec controls\n",
  2214. __func__);
  2215. return ret;
  2216. }
  2217. va_priv->component = component;
  2218. return 0;
  2219. }
  2220. va_priv->version = bolero_get_version(va_dev);
  2221. if (va_priv->version >= BOLERO_VERSION_2_0) {
  2222. ret = snd_soc_dapm_new_controls(dapm,
  2223. va_macro_dapm_widgets_common,
  2224. ARRAY_SIZE(va_macro_dapm_widgets_common));
  2225. if (ret < 0) {
  2226. dev_err(va_dev, "%s: Failed to add controls\n",
  2227. __func__);
  2228. return ret;
  2229. }
  2230. if (va_priv->version == BOLERO_VERSION_2_1)
  2231. ret = snd_soc_dapm_new_controls(dapm,
  2232. va_macro_dapm_widgets_v2,
  2233. ARRAY_SIZE(va_macro_dapm_widgets_v2));
  2234. else if (va_priv->version == BOLERO_VERSION_2_0)
  2235. ret = snd_soc_dapm_new_controls(dapm,
  2236. va_macro_dapm_widgets_v3,
  2237. ARRAY_SIZE(va_macro_dapm_widgets_v3));
  2238. if (ret < 0) {
  2239. dev_err(va_dev, "%s: Failed to add controls\n",
  2240. __func__);
  2241. return ret;
  2242. }
  2243. } else {
  2244. ret = snd_soc_dapm_new_controls(dapm, va_macro_dapm_widgets,
  2245. ARRAY_SIZE(va_macro_dapm_widgets));
  2246. if (ret < 0) {
  2247. dev_err(va_dev, "%s: Failed to add controls\n",
  2248. __func__);
  2249. return ret;
  2250. }
  2251. }
  2252. if (va_priv->version >= BOLERO_VERSION_2_0) {
  2253. ret = snd_soc_dapm_add_routes(dapm,
  2254. va_audio_map_common,
  2255. ARRAY_SIZE(va_audio_map_common));
  2256. if (ret < 0) {
  2257. dev_err(va_dev, "%s: Failed to add routes\n",
  2258. __func__);
  2259. return ret;
  2260. }
  2261. if (va_priv->version == BOLERO_VERSION_2_0)
  2262. ret = snd_soc_dapm_add_routes(dapm,
  2263. va_audio_map_v3,
  2264. ARRAY_SIZE(va_audio_map_v3));
  2265. if (ret < 0) {
  2266. dev_err(va_dev, "%s: Failed to add routes\n",
  2267. __func__);
  2268. return ret;
  2269. }
  2270. } else {
  2271. ret = snd_soc_dapm_add_routes(dapm, va_audio_map,
  2272. ARRAY_SIZE(va_audio_map));
  2273. if (ret < 0) {
  2274. dev_err(va_dev, "%s: Failed to add routes\n",
  2275. __func__);
  2276. return ret;
  2277. }
  2278. }
  2279. ret = snd_soc_dapm_new_widgets(dapm->card);
  2280. if (ret < 0) {
  2281. dev_err(va_dev, "%s: Failed to add widgets\n", __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_common,
  2287. ARRAY_SIZE(va_macro_snd_controls_common));
  2288. if (ret < 0) {
  2289. dev_err(va_dev, "%s: Failed to add snd_ctls\n",
  2290. __func__);
  2291. return ret;
  2292. }
  2293. if (va_priv->version == BOLERO_VERSION_2_0)
  2294. ret = snd_soc_add_component_controls(component,
  2295. va_macro_snd_controls_v3,
  2296. ARRAY_SIZE(va_macro_snd_controls_v3));
  2297. if (ret < 0) {
  2298. dev_err(va_dev, "%s: Failed to add snd_ctls\n",
  2299. __func__);
  2300. return ret;
  2301. }
  2302. } else {
  2303. ret = snd_soc_add_component_controls(component,
  2304. va_macro_snd_controls,
  2305. ARRAY_SIZE(va_macro_snd_controls));
  2306. if (ret < 0) {
  2307. dev_err(va_dev, "%s: Failed to add snd_ctls\n",
  2308. __func__);
  2309. return ret;
  2310. }
  2311. }
  2312. snd_soc_dapm_ignore_suspend(dapm, "VA_AIF1 Capture");
  2313. snd_soc_dapm_ignore_suspend(dapm, "VA_AIF2 Capture");
  2314. snd_soc_dapm_ignore_suspend(dapm, "VA_AIF3 Capture");
  2315. if (va_priv->version >= BOLERO_VERSION_2_0) {
  2316. snd_soc_dapm_ignore_suspend(dapm, "VA SWR_INPUT");
  2317. } else {
  2318. snd_soc_dapm_ignore_suspend(dapm, "VA SWR_ADC0");
  2319. snd_soc_dapm_ignore_suspend(dapm, "VA SWR_ADC1");
  2320. snd_soc_dapm_ignore_suspend(dapm, "VA SWR_ADC2");
  2321. snd_soc_dapm_ignore_suspend(dapm, "VA SWR_ADC3");
  2322. snd_soc_dapm_ignore_suspend(dapm, "VA SWR_MIC0");
  2323. snd_soc_dapm_ignore_suspend(dapm, "VA SWR_MIC1");
  2324. snd_soc_dapm_ignore_suspend(dapm, "VA SWR_MIC2");
  2325. snd_soc_dapm_ignore_suspend(dapm, "VA SWR_MIC3");
  2326. snd_soc_dapm_ignore_suspend(dapm, "VA SWR_MIC4");
  2327. snd_soc_dapm_ignore_suspend(dapm, "VA SWR_MIC5");
  2328. snd_soc_dapm_ignore_suspend(dapm, "VA SWR_MIC6");
  2329. snd_soc_dapm_ignore_suspend(dapm, "VA SWR_MIC7");
  2330. }
  2331. snd_soc_dapm_sync(dapm);
  2332. for (i = 0; i < VA_MACRO_NUM_DECIMATORS; i++) {
  2333. va_priv->va_hpf_work[i].va_priv = va_priv;
  2334. va_priv->va_hpf_work[i].decimator = i;
  2335. INIT_DELAYED_WORK(&va_priv->va_hpf_work[i].dwork,
  2336. va_macro_tx_hpf_corner_freq_callback);
  2337. }
  2338. for (i = 0; i < VA_MACRO_NUM_DECIMATORS; i++) {
  2339. va_priv->va_mute_dwork[i].va_priv = va_priv;
  2340. va_priv->va_mute_dwork[i].decimator = i;
  2341. INIT_DELAYED_WORK(&va_priv->va_mute_dwork[i].dwork,
  2342. va_macro_mute_update_callback);
  2343. }
  2344. va_priv->component = component;
  2345. if (va_priv->version == BOLERO_VERSION_2_1) {
  2346. snd_soc_component_update_bits(component,
  2347. BOLERO_CDC_VA_TOP_CSR_SWR_MIC_CTL0, 0xEE, 0xCC);
  2348. snd_soc_component_update_bits(component,
  2349. BOLERO_CDC_VA_TOP_CSR_SWR_MIC_CTL1, 0xEE, 0xCC);
  2350. snd_soc_component_update_bits(component,
  2351. BOLERO_CDC_VA_TOP_CSR_SWR_MIC_CTL2, 0xEE, 0xCC);
  2352. }
  2353. return 0;
  2354. }
  2355. static int va_macro_deinit(struct snd_soc_component *component)
  2356. {
  2357. struct device *va_dev = NULL;
  2358. struct va_macro_priv *va_priv = NULL;
  2359. if (!va_macro_get_data(component, &va_dev, &va_priv, __func__))
  2360. return -EINVAL;
  2361. va_priv->component = NULL;
  2362. return 0;
  2363. }
  2364. static void va_macro_add_child_devices(struct work_struct *work)
  2365. {
  2366. struct va_macro_priv *va_priv = NULL;
  2367. struct platform_device *pdev = NULL;
  2368. struct device_node *node = NULL;
  2369. struct va_macro_swr_ctrl_data *swr_ctrl_data = NULL, *temp = NULL;
  2370. int ret = 0;
  2371. u16 count = 0, ctrl_num = 0;
  2372. struct va_macro_swr_ctrl_platform_data *platdata = NULL;
  2373. char plat_dev_name[VA_MACRO_SWR_STRING_LEN] = "";
  2374. bool va_swr_master_node = false;
  2375. va_priv = container_of(work, struct va_macro_priv,
  2376. va_macro_add_child_devices_work);
  2377. if (!va_priv) {
  2378. pr_err("%s: Memory for va_priv does not exist\n",
  2379. __func__);
  2380. return;
  2381. }
  2382. if (!va_priv->dev) {
  2383. pr_err("%s: VA dev does not exist\n", __func__);
  2384. return;
  2385. }
  2386. if (!va_priv->dev->of_node) {
  2387. dev_err(va_priv->dev,
  2388. "%s: DT node for va_priv does not exist\n", __func__);
  2389. return;
  2390. }
  2391. platdata = &va_priv->swr_plat_data;
  2392. va_priv->child_count = 0;
  2393. for_each_available_child_of_node(va_priv->dev->of_node, node) {
  2394. va_swr_master_node = false;
  2395. if (strnstr(node->name, "va_swr_master",
  2396. strlen("va_swr_master")) != NULL)
  2397. va_swr_master_node = true;
  2398. if (va_swr_master_node)
  2399. strlcpy(plat_dev_name, "va_swr_ctrl",
  2400. (VA_MACRO_SWR_STRING_LEN - 1));
  2401. else
  2402. strlcpy(plat_dev_name, node->name,
  2403. (VA_MACRO_SWR_STRING_LEN - 1));
  2404. pdev = platform_device_alloc(plat_dev_name, -1);
  2405. if (!pdev) {
  2406. dev_err(va_priv->dev, "%s: pdev memory alloc failed\n",
  2407. __func__);
  2408. ret = -ENOMEM;
  2409. goto err;
  2410. }
  2411. pdev->dev.parent = va_priv->dev;
  2412. pdev->dev.of_node = node;
  2413. if (va_swr_master_node) {
  2414. ret = platform_device_add_data(pdev, platdata,
  2415. sizeof(*platdata));
  2416. if (ret) {
  2417. dev_err(&pdev->dev,
  2418. "%s: cannot add plat data ctrl:%d\n",
  2419. __func__, ctrl_num);
  2420. goto fail_pdev_add;
  2421. }
  2422. }
  2423. ret = platform_device_add(pdev);
  2424. if (ret) {
  2425. dev_err(&pdev->dev,
  2426. "%s: Cannot add platform device\n",
  2427. __func__);
  2428. goto fail_pdev_add;
  2429. }
  2430. if (va_swr_master_node) {
  2431. temp = krealloc(swr_ctrl_data,
  2432. (ctrl_num + 1) * sizeof(
  2433. struct va_macro_swr_ctrl_data),
  2434. GFP_KERNEL);
  2435. if (!temp) {
  2436. ret = -ENOMEM;
  2437. goto fail_pdev_add;
  2438. }
  2439. swr_ctrl_data = temp;
  2440. swr_ctrl_data[ctrl_num].va_swr_pdev = pdev;
  2441. ctrl_num++;
  2442. dev_dbg(&pdev->dev,
  2443. "%s: Added soundwire ctrl device(s)\n",
  2444. __func__);
  2445. va_priv->swr_ctrl_data = swr_ctrl_data;
  2446. }
  2447. if (va_priv->child_count < VA_MACRO_CHILD_DEVICES_MAX)
  2448. va_priv->pdev_child_devices[
  2449. va_priv->child_count++] = pdev;
  2450. else
  2451. goto err;
  2452. }
  2453. return;
  2454. fail_pdev_add:
  2455. for (count = 0; count < va_priv->child_count; count++)
  2456. platform_device_put(va_priv->pdev_child_devices[count]);
  2457. err:
  2458. return;
  2459. }
  2460. static int va_macro_set_port_map(struct snd_soc_component *component,
  2461. u32 usecase, u32 size, void *data)
  2462. {
  2463. struct device *va_dev = NULL;
  2464. struct va_macro_priv *va_priv = NULL;
  2465. struct swrm_port_config port_cfg;
  2466. int ret = 0;
  2467. if (!va_macro_get_data(component, &va_dev, &va_priv, __func__))
  2468. return -EINVAL;
  2469. memset(&port_cfg, 0, sizeof(port_cfg));
  2470. port_cfg.uc = usecase;
  2471. port_cfg.size = size;
  2472. port_cfg.params = data;
  2473. if (va_priv->swr_ctrl_data)
  2474. ret = swrm_wcd_notify(
  2475. va_priv->swr_ctrl_data[0].va_swr_pdev,
  2476. SWR_SET_PORT_MAP, &port_cfg);
  2477. return ret;
  2478. }
  2479. static int va_macro_reg_wake_irq(struct snd_soc_component *component,
  2480. u32 data)
  2481. {
  2482. struct device *va_dev = NULL;
  2483. struct va_macro_priv *va_priv = NULL;
  2484. u32 ipc_wakeup = data;
  2485. int ret = 0;
  2486. if (!va_macro_get_data(component, &va_dev, &va_priv, __func__))
  2487. return -EINVAL;
  2488. if (va_priv->swr_ctrl_data)
  2489. ret = swrm_wcd_notify(
  2490. va_priv->swr_ctrl_data[0].va_swr_pdev,
  2491. SWR_REGISTER_WAKE_IRQ, &ipc_wakeup);
  2492. return ret;
  2493. }
  2494. static void va_macro_init_ops(struct macro_ops *ops,
  2495. char __iomem *va_io_base,
  2496. bool va_without_decimation)
  2497. {
  2498. memset(ops, 0, sizeof(struct macro_ops));
  2499. if (!va_without_decimation) {
  2500. ops->dai_ptr = va_macro_dai;
  2501. ops->num_dais = ARRAY_SIZE(va_macro_dai);
  2502. } else {
  2503. ops->dai_ptr = NULL;
  2504. ops->num_dais = 0;
  2505. }
  2506. ops->init = va_macro_init;
  2507. ops->exit = va_macro_deinit;
  2508. ops->io_base = va_io_base;
  2509. ops->event_handler = va_macro_event_handler;
  2510. ops->set_port_map = va_macro_set_port_map;
  2511. ops->reg_wake_irq = va_macro_reg_wake_irq;
  2512. ops->clk_div_get = va_macro_clk_div_get;
  2513. }
  2514. static int va_macro_probe(struct platform_device *pdev)
  2515. {
  2516. struct macro_ops ops;
  2517. struct va_macro_priv *va_priv;
  2518. u32 va_base_addr, sample_rate = 0;
  2519. char __iomem *va_io_base;
  2520. bool va_without_decimation = false;
  2521. const char *micb_supply_str = "va-vdd-micb-supply";
  2522. const char *micb_supply_str1 = "va-vdd-micb";
  2523. const char *micb_voltage_str = "qcom,va-vdd-micb-voltage";
  2524. const char *micb_current_str = "qcom,va-vdd-micb-current";
  2525. int ret = 0;
  2526. const char *dmic_sample_rate = "qcom,va-dmic-sample-rate";
  2527. u32 default_clk_id = 0;
  2528. struct clk *lpass_audio_hw_vote = NULL;
  2529. u32 is_used_va_swr_gpio = 0;
  2530. const char *is_used_va_swr_gpio_dt = "qcom,is-used-swr-gpio";
  2531. va_priv = devm_kzalloc(&pdev->dev, sizeof(struct va_macro_priv),
  2532. GFP_KERNEL);
  2533. if (!va_priv)
  2534. return -ENOMEM;
  2535. va_priv->dev = &pdev->dev;
  2536. ret = of_property_read_u32(pdev->dev.of_node, "reg",
  2537. &va_base_addr);
  2538. if (ret) {
  2539. dev_err(&pdev->dev, "%s: could not find %s entry in dt\n",
  2540. __func__, "reg");
  2541. return ret;
  2542. }
  2543. va_without_decimation = of_property_read_bool(pdev->dev.parent->of_node,
  2544. "qcom,va-without-decimation");
  2545. va_priv->va_without_decimation = va_without_decimation;
  2546. ret = of_property_read_u32(pdev->dev.of_node, dmic_sample_rate,
  2547. &sample_rate);
  2548. if (ret) {
  2549. dev_err(&pdev->dev, "%s: could not find %d entry in dt\n",
  2550. __func__, sample_rate);
  2551. va_priv->dmic_clk_div = VA_MACRO_CLK_DIV_2;
  2552. } else {
  2553. if (va_macro_validate_dmic_sample_rate(
  2554. sample_rate, va_priv) == VA_MACRO_DMIC_SAMPLE_RATE_UNDEFINED)
  2555. return -EINVAL;
  2556. }
  2557. if (of_find_property(pdev->dev.of_node, is_used_va_swr_gpio_dt,
  2558. NULL)) {
  2559. ret = of_property_read_u32(pdev->dev.of_node,
  2560. is_used_va_swr_gpio_dt,
  2561. &is_used_va_swr_gpio);
  2562. if (ret) {
  2563. dev_err(&pdev->dev, "%s: error reading %s in dt\n",
  2564. __func__, is_used_va_swr_gpio_dt);
  2565. is_used_va_swr_gpio = 0;
  2566. }
  2567. }
  2568. va_priv->va_swr_gpio_p = of_parse_phandle(pdev->dev.of_node,
  2569. "qcom,va-swr-gpios", 0);
  2570. if (!va_priv->va_swr_gpio_p && is_used_va_swr_gpio) {
  2571. dev_err(&pdev->dev, "%s: swr_gpios handle not provided!\n",
  2572. __func__);
  2573. return -EINVAL;
  2574. }
  2575. if ((msm_cdc_pinctrl_get_state(va_priv->va_swr_gpio_p) < 0) &&
  2576. is_used_va_swr_gpio) {
  2577. dev_err(&pdev->dev, "%s: failed to get swr pin state\n",
  2578. __func__);
  2579. return -EPROBE_DEFER;
  2580. }
  2581. va_io_base = devm_ioremap(&pdev->dev, va_base_addr,
  2582. VA_MACRO_MAX_OFFSET);
  2583. if (!va_io_base) {
  2584. dev_err(&pdev->dev, "%s: ioremap failed\n", __func__);
  2585. return -EINVAL;
  2586. }
  2587. va_priv->va_io_base = va_io_base;
  2588. lpass_audio_hw_vote = devm_clk_get(&pdev->dev, "lpass_audio_hw_vote");
  2589. if (IS_ERR(lpass_audio_hw_vote)) {
  2590. ret = PTR_ERR(lpass_audio_hw_vote);
  2591. dev_dbg(&pdev->dev, "%s: clk get %s failed %d\n",
  2592. __func__, "lpass_audio_hw_vote", ret);
  2593. lpass_audio_hw_vote = NULL;
  2594. ret = 0;
  2595. }
  2596. va_priv->lpass_audio_hw_vote = lpass_audio_hw_vote;
  2597. if (of_parse_phandle(pdev->dev.of_node, micb_supply_str, 0)) {
  2598. va_priv->micb_supply = devm_regulator_get(&pdev->dev,
  2599. micb_supply_str1);
  2600. if (IS_ERR(va_priv->micb_supply)) {
  2601. ret = PTR_ERR(va_priv->micb_supply);
  2602. dev_err(&pdev->dev,
  2603. "%s:Failed to get micbias supply for VA Mic %d\n",
  2604. __func__, ret);
  2605. return ret;
  2606. }
  2607. ret = of_property_read_u32(pdev->dev.of_node,
  2608. micb_voltage_str,
  2609. &va_priv->micb_voltage);
  2610. if (ret) {
  2611. dev_err(&pdev->dev,
  2612. "%s:Looking up %s property in node %s failed\n",
  2613. __func__, micb_voltage_str,
  2614. pdev->dev.of_node->full_name);
  2615. return ret;
  2616. }
  2617. ret = of_property_read_u32(pdev->dev.of_node,
  2618. micb_current_str,
  2619. &va_priv->micb_current);
  2620. if (ret) {
  2621. dev_err(&pdev->dev,
  2622. "%s:Looking up %s property in node %s failed\n",
  2623. __func__, micb_current_str,
  2624. pdev->dev.of_node->full_name);
  2625. return ret;
  2626. }
  2627. }
  2628. ret = of_property_read_u32(pdev->dev.of_node, "qcom,default-clk-id",
  2629. &default_clk_id);
  2630. if (ret) {
  2631. dev_err(&pdev->dev, "%s: could not find %s entry in dt\n",
  2632. __func__, "qcom,default-clk-id");
  2633. default_clk_id = VA_CORE_CLK;
  2634. }
  2635. va_priv->clk_id = VA_CORE_CLK;
  2636. va_priv->default_clk_id = default_clk_id;
  2637. if (is_used_va_swr_gpio) {
  2638. va_priv->reset_swr = true;
  2639. INIT_WORK(&va_priv->va_macro_add_child_devices_work,
  2640. va_macro_add_child_devices);
  2641. va_priv->swr_plat_data.handle = (void *) va_priv;
  2642. va_priv->swr_plat_data.read = NULL;
  2643. va_priv->swr_plat_data.write = NULL;
  2644. va_priv->swr_plat_data.bulk_write = NULL;
  2645. va_priv->swr_plat_data.clk = va_macro_swrm_clock;
  2646. va_priv->swr_plat_data.core_vote = va_macro_core_vote;
  2647. va_priv->swr_plat_data.handle_irq = NULL;
  2648. mutex_init(&va_priv->swr_clk_lock);
  2649. }
  2650. va_priv->is_used_va_swr_gpio = is_used_va_swr_gpio;
  2651. mutex_init(&va_priv->mclk_lock);
  2652. dev_set_drvdata(&pdev->dev, va_priv);
  2653. va_macro_init_ops(&ops, va_io_base, va_without_decimation);
  2654. ops.clk_id_req = va_priv->default_clk_id;
  2655. ops.default_clk_id = va_priv->default_clk_id;
  2656. ret = bolero_register_macro(&pdev->dev, VA_MACRO, &ops);
  2657. if (ret < 0) {
  2658. dev_err(&pdev->dev, "%s: register macro failed\n", __func__);
  2659. goto reg_macro_fail;
  2660. }
  2661. if (is_used_va_swr_gpio)
  2662. schedule_work(&va_priv->va_macro_add_child_devices_work);
  2663. pm_runtime_set_autosuspend_delay(&pdev->dev, VA_AUTO_SUSPEND_DELAY);
  2664. pm_runtime_use_autosuspend(&pdev->dev);
  2665. pm_runtime_set_suspended(&pdev->dev);
  2666. pm_suspend_ignore_children(&pdev->dev, true);
  2667. pm_runtime_enable(&pdev->dev);
  2668. return ret;
  2669. reg_macro_fail:
  2670. mutex_destroy(&va_priv->mclk_lock);
  2671. if (is_used_va_swr_gpio)
  2672. mutex_destroy(&va_priv->swr_clk_lock);
  2673. return ret;
  2674. }
  2675. static int va_macro_remove(struct platform_device *pdev)
  2676. {
  2677. struct va_macro_priv *va_priv;
  2678. int count = 0;
  2679. va_priv = dev_get_drvdata(&pdev->dev);
  2680. if (!va_priv)
  2681. return -EINVAL;
  2682. if (va_priv->is_used_va_swr_gpio) {
  2683. if (va_priv->swr_ctrl_data)
  2684. kfree(va_priv->swr_ctrl_data);
  2685. for (count = 0; count < va_priv->child_count &&
  2686. count < VA_MACRO_CHILD_DEVICES_MAX; count++)
  2687. platform_device_unregister(
  2688. va_priv->pdev_child_devices[count]);
  2689. }
  2690. pm_runtime_disable(&pdev->dev);
  2691. pm_runtime_set_suspended(&pdev->dev);
  2692. bolero_unregister_macro(&pdev->dev, VA_MACRO);
  2693. mutex_destroy(&va_priv->mclk_lock);
  2694. if (va_priv->is_used_va_swr_gpio)
  2695. mutex_destroy(&va_priv->swr_clk_lock);
  2696. return 0;
  2697. }
  2698. static const struct of_device_id va_macro_dt_match[] = {
  2699. {.compatible = "qcom,va-macro"},
  2700. {}
  2701. };
  2702. static const struct dev_pm_ops bolero_dev_pm_ops = {
  2703. SET_SYSTEM_SLEEP_PM_OPS(
  2704. pm_runtime_force_suspend,
  2705. pm_runtime_force_resume
  2706. )
  2707. SET_RUNTIME_PM_OPS(
  2708. bolero_runtime_suspend,
  2709. bolero_runtime_resume,
  2710. NULL
  2711. )
  2712. };
  2713. static struct platform_driver va_macro_driver = {
  2714. .driver = {
  2715. .name = "va_macro",
  2716. .owner = THIS_MODULE,
  2717. .pm = &bolero_dev_pm_ops,
  2718. .of_match_table = va_macro_dt_match,
  2719. .suppress_bind_attrs = true,
  2720. },
  2721. .probe = va_macro_probe,
  2722. .remove = va_macro_remove,
  2723. };
  2724. module_platform_driver(va_macro_driver);
  2725. MODULE_DESCRIPTION("VA macro driver");
  2726. MODULE_LICENSE("GPL v2");