va-macro.c 92 KB

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