wcd937x.c 68 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441
  1. /*
  2. * Copyright (c) 2018, The Linux Foundation. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 and
  6. * only version 2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #include <linux/module.h>
  14. #include <linux/slab.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/device.h>
  17. #include <linux/delay.h>
  18. #include <linux/kernel.h>
  19. #include <linux/component.h>
  20. #include <sound/soc.h>
  21. #include <sound/tlv.h>
  22. #include <soc/soundwire.h>
  23. #include <linux/regmap.h>
  24. #include <sound/soc.h>
  25. #include <sound/soc-dapm.h>
  26. #include "internal.h"
  27. #include "wcd937x.h"
  28. #include "../wcdcal-hwdep.h"
  29. #include "wcd937x-registers.h"
  30. #include "../msm-cdc-pinctrl.h"
  31. #include <dt-bindings/sound/audio-codec-port-types.h>
  32. #include "../msm-cdc-supply.h"
  33. #define WCD9370_VARIANT 0
  34. #define WCD9375_VARIANT 5
  35. #define NUM_SWRS_DT_PARAMS 5
  36. #define WCD937X_VERSION_1_0 1
  37. #define WCD937X_VERSION_ENTRY_SIZE 32
  38. enum {
  39. CODEC_TX = 0,
  40. CODEC_RX,
  41. };
  42. static const DECLARE_TLV_DB_SCALE(line_gain, 0, 7, 1);
  43. static const DECLARE_TLV_DB_SCALE(analog_gain, 0, 25, 1);
  44. static int wcd937x_handle_post_irq(void *data);
  45. static int wcd937x_reset(struct device *dev);
  46. static int wcd937x_reset_low(struct device *dev);
  47. static const struct regmap_irq wcd937x_irqs[WCD937X_NUM_IRQS] = {
  48. REGMAP_IRQ_REG(WCD937X_IRQ_MBHC_BUTTON_PRESS_DET, 0, 0x01),
  49. REGMAP_IRQ_REG(WCD937X_IRQ_MBHC_BUTTON_RELEASE_DET, 0, 0x02),
  50. REGMAP_IRQ_REG(WCD937X_IRQ_MBHC_ELECT_INS_REM_DET, 0, 0x04),
  51. REGMAP_IRQ_REG(WCD937X_IRQ_MBHC_ELECT_INS_REM_LEG_DET, 0, 0x08),
  52. REGMAP_IRQ_REG(WCD937X_IRQ_MBHC_SW_DET, 0, 0x10),
  53. REGMAP_IRQ_REG(WCD937X_IRQ_HPHR_OCP_INT, 0, 0x20),
  54. REGMAP_IRQ_REG(WCD937X_IRQ_HPHR_CNP_INT, 0, 0x40),
  55. REGMAP_IRQ_REG(WCD937X_IRQ_HPHL_OCP_INT, 0, 0x80),
  56. REGMAP_IRQ_REG(WCD937X_IRQ_HPHL_CNP_INT, 1, 0x01),
  57. REGMAP_IRQ_REG(WCD937X_IRQ_EAR_CNP_INT, 1, 0x02),
  58. REGMAP_IRQ_REG(WCD937X_IRQ_EAR_SCD_INT, 1, 0x04),
  59. REGMAP_IRQ_REG(WCD937X_IRQ_AUX_CNP_INT, 1, 0x08),
  60. REGMAP_IRQ_REG(WCD937X_IRQ_AUX_SCD_INT, 1, 0x10),
  61. REGMAP_IRQ_REG(WCD937X_IRQ_HPHL_PDM_WD_INT, 1, 0x20),
  62. REGMAP_IRQ_REG(WCD937X_IRQ_HPHR_PDM_WD_INT, 1, 0x40),
  63. REGMAP_IRQ_REG(WCD937X_IRQ_AUX_PDM_WD_INT, 1, 0x80),
  64. REGMAP_IRQ_REG(WCD937X_IRQ_LDORT_SCD_INT, 2, 0x01),
  65. REGMAP_IRQ_REG(WCD937X_IRQ_MBHC_MOISTURE_INT, 2, 0x02),
  66. REGMAP_IRQ_REG(WCD937X_IRQ_HPHL_SURGE_DET_INT, 2, 0x04),
  67. REGMAP_IRQ_REG(WCD937X_IRQ_HPHR_SURGE_DET_INT, 2, 0x08),
  68. };
  69. static struct regmap_irq_chip wcd937x_regmap_irq_chip = {
  70. .name = "wcd937x",
  71. .irqs = wcd937x_irqs,
  72. .num_irqs = ARRAY_SIZE(wcd937x_irqs),
  73. .num_regs = 3,
  74. .status_base = WCD937X_DIGITAL_INTR_STATUS_0,
  75. .mask_base = WCD937X_DIGITAL_INTR_MASK_0,
  76. .ack_base = WCD937X_DIGITAL_INTR_CLEAR_0,
  77. .use_ack = 1,
  78. .clear_ack = 1,
  79. .type_base = WCD937X_DIGITAL_INTR_LEVEL_0,
  80. .runtime_pm = false,
  81. .handle_post_irq = wcd937x_handle_post_irq,
  82. .irq_drv_data = NULL,
  83. };
  84. static int wcd937x_handle_post_irq(void *data)
  85. {
  86. struct wcd937x_priv *wcd937x = data;
  87. u32 status1 = 0, status2 = 0, status3 = 0;
  88. regmap_read(wcd937x->regmap, WCD937X_DIGITAL_INTR_STATUS_0, &status1);
  89. regmap_read(wcd937x->regmap, WCD937X_DIGITAL_INTR_STATUS_1, &status2);
  90. regmap_read(wcd937x->regmap, WCD937X_DIGITAL_INTR_STATUS_2, &status3);
  91. wcd937x->tx_swr_dev->slave_irq_pending =
  92. ((status1 || status2 || status3) ? true : false);
  93. return IRQ_HANDLED;
  94. }
  95. static int wcd937x_init_reg(struct snd_soc_codec *codec)
  96. {
  97. snd_soc_update_bits(codec, WCD937X_SLEEP_CTL, 0x0E, 0x0E);
  98. snd_soc_update_bits(codec, WCD937X_SLEEP_CTL, 0x80, 0x80);
  99. usleep_range(1000, 1010);
  100. snd_soc_update_bits(codec, WCD937X_SLEEP_CTL, 0x40, 0x40);
  101. usleep_range(1000, 1010);
  102. snd_soc_update_bits(codec, WCD937X_LDORXTX_CONFIG, 0x10, 0x00);
  103. snd_soc_update_bits(codec, WCD937X_BIAS_VBG_FINE_ADJ, 0xF0, 0x80);
  104. snd_soc_update_bits(codec, WCD937X_ANA_BIAS, 0x80, 0x80);
  105. snd_soc_update_bits(codec, WCD937X_ANA_BIAS, 0x40, 0x40);
  106. usleep_range(10000, 10010);
  107. snd_soc_update_bits(codec, WCD937X_ANA_BIAS, 0x40, 0x00);
  108. return 0;
  109. }
  110. static int wcd937x_set_port_params(struct snd_soc_codec *codec, u8 slv_prt_type,
  111. u8 *port_id, u8 *num_ch, u8 *ch_mask, u32 *ch_rate,
  112. u8 *port_type, u8 path)
  113. {
  114. int i, j;
  115. u8 num_ports = 0;
  116. struct codec_port_info (*map)[MAX_PORT][MAX_CH_PER_PORT] = NULL;
  117. struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec);
  118. switch (path) {
  119. case CODEC_RX:
  120. map = &wcd937x->rx_port_mapping;
  121. num_ports = wcd937x->num_rx_ports;
  122. break;
  123. case CODEC_TX:
  124. map = &wcd937x->tx_port_mapping;
  125. num_ports = wcd937x->num_tx_ports;
  126. break;
  127. }
  128. for (i = 0; i <= num_ports; i++) {
  129. for (j = 0; j < MAX_CH_PER_PORT; j++) {
  130. if ((*map)[i][j].slave_port_type == slv_prt_type)
  131. goto found;
  132. }
  133. }
  134. found:
  135. if (i > num_ports || j == MAX_CH_PER_PORT) {
  136. dev_err(codec->dev, "%s Failed to find slave port for type %u\n",
  137. __func__, slv_prt_type);
  138. return -EINVAL;
  139. }
  140. *port_id = i;
  141. *num_ch = (*map)[i][j].num_ch;
  142. *ch_mask = (*map)[i][j].ch_mask;
  143. *ch_rate = (*map)[i][j].ch_rate;
  144. *port_type = (*map)[i][j].master_port_type;
  145. return 0;
  146. }
  147. static int wcd937x_parse_port_mapping(struct device *dev,
  148. char *prop, u8 path)
  149. {
  150. u32 *dt_array, map_size, map_length;
  151. u32 port_num = 0, ch_mask, ch_rate, old_port_num = 0;
  152. u32 slave_port_type, master_port_type;
  153. u32 i, ch_iter = 0;
  154. int ret = 0;
  155. u8 *num_ports = NULL;
  156. struct codec_port_info (*map)[MAX_PORT][MAX_CH_PER_PORT] = NULL;
  157. struct wcd937x_priv *wcd937x = dev_get_drvdata(dev);
  158. switch (path) {
  159. case CODEC_RX:
  160. map = &wcd937x->rx_port_mapping;
  161. num_ports = &wcd937x->num_rx_ports;
  162. break;
  163. case CODEC_TX:
  164. map = &wcd937x->tx_port_mapping;
  165. num_ports = &wcd937x->num_tx_ports;
  166. break;
  167. }
  168. if (!of_find_property(dev->of_node, prop,
  169. &map_size)) {
  170. dev_err(dev, "missing port mapping prop %s\n", prop);
  171. ret = -EINVAL;
  172. goto err;
  173. }
  174. map_length = map_size / (NUM_SWRS_DT_PARAMS * sizeof(u32));
  175. dt_array = kzalloc(map_size, GFP_KERNEL);
  176. if (!dt_array) {
  177. ret = -ENOMEM;
  178. goto err;
  179. }
  180. ret = of_property_read_u32_array(dev->of_node, prop, dt_array,
  181. NUM_SWRS_DT_PARAMS * map_length);
  182. if (ret) {
  183. dev_err(dev, "%s: Failed to read port mapping from prop %s\n",
  184. __func__, prop);
  185. ret = -EINVAL;
  186. goto err_pdata_fail;
  187. }
  188. for (i = 0; i < map_length; i++) {
  189. port_num = dt_array[NUM_SWRS_DT_PARAMS * i];
  190. slave_port_type = dt_array[NUM_SWRS_DT_PARAMS * i + 1];
  191. ch_mask = dt_array[NUM_SWRS_DT_PARAMS * i + 2];
  192. ch_rate = dt_array[NUM_SWRS_DT_PARAMS * i + 3];
  193. master_port_type = dt_array[NUM_SWRS_DT_PARAMS * i + 4];
  194. if (port_num != old_port_num)
  195. ch_iter = 0;
  196. (*map)[port_num][ch_iter].slave_port_type = slave_port_type;
  197. (*map)[port_num][ch_iter].ch_mask = ch_mask;
  198. (*map)[port_num][ch_iter].master_port_type = master_port_type;
  199. (*map)[port_num][ch_iter].num_ch = __sw_hweight8(ch_mask);
  200. (*map)[port_num][ch_iter++].ch_rate = ch_rate;
  201. old_port_num = port_num;
  202. }
  203. *num_ports = port_num;
  204. kfree(dt_array);
  205. return 0;
  206. err_pdata_fail:
  207. kfree(dt_array);
  208. err:
  209. return ret;
  210. }
  211. static int wcd937x_tx_connect_port(struct snd_soc_codec *codec,
  212. u8 slv_port_type, u8 enable)
  213. {
  214. struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec);
  215. u8 port_id;
  216. u8 num_ch;
  217. u8 ch_mask;
  218. u32 ch_rate;
  219. u8 port_type;
  220. u8 num_port = 1;
  221. int ret = 0;
  222. ret = wcd937x_set_port_params(codec, slv_port_type, &port_id,
  223. &num_ch, &ch_mask, &ch_rate,
  224. &port_type, CODEC_TX);
  225. if (ret)
  226. return ret;
  227. if (enable)
  228. ret = swr_connect_port(wcd937x->tx_swr_dev, &port_id,
  229. num_port, &ch_mask, &ch_rate,
  230. &num_ch, &port_type);
  231. else
  232. ret = swr_disconnect_port(wcd937x->tx_swr_dev, &port_id,
  233. num_port, &ch_mask, &port_type);
  234. return ret;
  235. }
  236. static int wcd937x_rx_connect_port(struct snd_soc_codec *codec,
  237. u8 slv_port_type, u8 enable)
  238. {
  239. struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec);
  240. u8 port_id;
  241. u8 num_ch;
  242. u8 ch_mask;
  243. u32 ch_rate;
  244. u8 port_type;
  245. u8 num_port = 1;
  246. int ret = 0;
  247. ret = wcd937x_set_port_params(codec, slv_port_type, &port_id,
  248. &num_ch, &ch_mask, &ch_rate,
  249. &port_type, CODEC_RX);
  250. if (ret)
  251. return ret;
  252. if (enable)
  253. ret = swr_connect_port(wcd937x->rx_swr_dev, &port_id,
  254. num_port, &ch_mask, &ch_rate,
  255. &num_ch, &port_type);
  256. else
  257. ret = swr_disconnect_port(wcd937x->rx_swr_dev, &port_id,
  258. num_port, &ch_mask, &port_type);
  259. return ret;
  260. }
  261. static int wcd937x_rx_clk_enable(struct snd_soc_codec *codec)
  262. {
  263. struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec);
  264. if (wcd937x->rx_clk_cnt == 0) {
  265. snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_DIG_CLK_CTL,
  266. 0x08, 0x08);
  267. snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_ANA_CLK_CTL,
  268. 0x01, 0x01);
  269. snd_soc_update_bits(codec, WCD937X_ANA_RX_SUPPLIES, 0x01, 0x01);
  270. snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_RX0_CTL,
  271. 0x40, 0x00);
  272. snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_RX1_CTL,
  273. 0x40, 0x00);
  274. snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_RX2_CTL,
  275. 0x40, 0x00);
  276. snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_ANA_CLK_CTL,
  277. 0x02, 0x02);
  278. }
  279. wcd937x->rx_clk_cnt++;
  280. return 0;
  281. }
  282. static int wcd937x_rx_clk_disable(struct snd_soc_codec *codec)
  283. {
  284. struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec);
  285. wcd937x->rx_clk_cnt--;
  286. if (wcd937x->rx_clk_cnt == 0) {
  287. snd_soc_update_bits(codec, WCD937X_ANA_RX_SUPPLIES, 0x40, 0x00);
  288. snd_soc_update_bits(codec, WCD937X_ANA_RX_SUPPLIES, 0x80, 0x00);
  289. snd_soc_update_bits(codec, WCD937X_ANA_RX_SUPPLIES, 0x01, 0x00);
  290. snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_ANA_CLK_CTL,
  291. 0x02, 0x00);
  292. snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_ANA_CLK_CTL,
  293. 0x01, 0x00);
  294. }
  295. return 0;
  296. }
  297. /*
  298. * wcd937x_soc_get_mbhc: get wcd937x_mbhc handle of corresponding codec
  299. * @codec: handle to snd_soc_codec *
  300. *
  301. * return wcd937x_mbhc handle or error code in case of failure
  302. */
  303. struct wcd937x_mbhc *wcd937x_soc_get_mbhc(struct snd_soc_codec *codec)
  304. {
  305. struct wcd937x_priv *wcd937x;
  306. if (!codec) {
  307. pr_err("%s: Invalid params, NULL codec\n", __func__);
  308. return NULL;
  309. }
  310. wcd937x = snd_soc_codec_get_drvdata(codec);
  311. if (!wcd937x) {
  312. pr_err("%s: Invalid params, NULL tavil\n", __func__);
  313. return NULL;
  314. }
  315. return wcd937x->mbhc;
  316. }
  317. EXPORT_SYMBOL(wcd937x_soc_get_mbhc);
  318. static int wcd937x_codec_hphl_dac_event(struct snd_soc_dapm_widget *w,
  319. struct snd_kcontrol *kcontrol,
  320. int event)
  321. {
  322. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  323. struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec);
  324. int ret = 0;
  325. dev_dbg(codec->dev, "%s wname: %s event: %d\n", __func__,
  326. w->name, event);
  327. switch (event) {
  328. case SND_SOC_DAPM_PRE_PMU:
  329. wcd937x_rx_clk_enable(codec);
  330. snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_DIG_CLK_CTL,
  331. 0x01, 0x01);
  332. snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_HPH_GAIN_CTL,
  333. 0x04, 0x04);
  334. snd_soc_update_bits(codec, WCD937X_HPH_RDAC_CLK_CTL1,
  335. 0x80, 0x00);
  336. break;
  337. case SND_SOC_DAPM_POST_PMU:
  338. snd_soc_update_bits(codec, WCD937X_HPH_NEW_INT_RDAC_HD2_CTL_L,
  339. 0x0F, 0x02);
  340. if (wcd937x->comp1_enable) {
  341. snd_soc_update_bits(codec,
  342. WCD937X_DIGITAL_CDC_COMP_CTL_0,
  343. 0x02, 0x02);
  344. snd_soc_update_bits(codec,
  345. WCD937X_HPH_L_EN, 0x20, 0x00);
  346. } else {
  347. snd_soc_update_bits(codec,
  348. WCD937X_DIGITAL_CDC_COMP_CTL_0,
  349. 0x02, 0x00);
  350. snd_soc_update_bits(codec,
  351. WCD937X_HPH_L_EN, 0x20, 0x20);
  352. }
  353. usleep_range(5000, 5010);
  354. snd_soc_update_bits(codec, WCD937X_HPH_NEW_INT_HPH_TIMER1,
  355. 0x02, 0x00);
  356. break;
  357. case SND_SOC_DAPM_POST_PMD:
  358. ret = swr_slvdev_datapath_control(wcd937x->rx_swr_dev,
  359. wcd937x->rx_swr_dev->dev_num,
  360. false);
  361. break;
  362. }
  363. return ret;
  364. }
  365. static int wcd937x_codec_hphr_dac_event(struct snd_soc_dapm_widget *w,
  366. struct snd_kcontrol *kcontrol,
  367. int event)
  368. {
  369. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  370. struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec);
  371. int ret = 0;
  372. dev_dbg(codec->dev, "%s wname: %s event: %d\n", __func__,
  373. w->name, event);
  374. switch (event) {
  375. case SND_SOC_DAPM_PRE_PMU:
  376. wcd937x_rx_clk_enable(codec);
  377. snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_DIG_CLK_CTL,
  378. 0x02, 0x02);
  379. snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_HPH_GAIN_CTL,
  380. 0x08, 0x08);
  381. snd_soc_update_bits(codec, WCD937X_HPH_RDAC_CLK_CTL1,
  382. 0x80, 0x00);
  383. break;
  384. case SND_SOC_DAPM_POST_PMU:
  385. snd_soc_update_bits(codec, WCD937X_HPH_NEW_INT_RDAC_HD2_CTL_R,
  386. 0x0F, 0x02);
  387. if (wcd937x->comp2_enable) {
  388. snd_soc_update_bits(codec,
  389. WCD937X_DIGITAL_CDC_COMP_CTL_0,
  390. 0x01, 0x01);
  391. snd_soc_update_bits(codec,
  392. WCD937X_HPH_R_EN, 0x20, 0x00);
  393. } else {
  394. snd_soc_update_bits(codec,
  395. WCD937X_DIGITAL_CDC_COMP_CTL_0,
  396. 0x01, 0x00);
  397. snd_soc_update_bits(codec,
  398. WCD937X_HPH_R_EN, 0x20, 0x20);
  399. }
  400. usleep_range(5000, 5010);
  401. snd_soc_update_bits(codec, WCD937X_HPH_NEW_INT_HPH_TIMER1,
  402. 0x02, 0x00);
  403. break;
  404. case SND_SOC_DAPM_POST_PMD:
  405. ret = swr_slvdev_datapath_control(wcd937x->rx_swr_dev,
  406. wcd937x->rx_swr_dev->dev_num,
  407. false);
  408. break;
  409. }
  410. return ret;
  411. }
  412. static int wcd937x_codec_ear_dac_event(struct snd_soc_dapm_widget *w,
  413. struct snd_kcontrol *kcontrol,
  414. int event)
  415. {
  416. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  417. struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec);
  418. int ret = 0;
  419. dev_dbg(codec->dev, "%s wname: %s event: %d\n", __func__,
  420. w->name, event);
  421. switch (event) {
  422. case SND_SOC_DAPM_PRE_PMU:
  423. wcd937x_rx_clk_enable(codec);
  424. snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_HPH_GAIN_CTL,
  425. 0x04, 0x04);
  426. snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_DIG_CLK_CTL,
  427. 0x01, 0x01);
  428. snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_COMP_CTL_0,
  429. 0x02, 0x02);
  430. usleep_range(5000, 5010);
  431. break;
  432. case SND_SOC_DAPM_POST_PMD:
  433. ret = swr_slvdev_datapath_control(wcd937x->rx_swr_dev,
  434. wcd937x->rx_swr_dev->dev_num,
  435. false);
  436. break;
  437. };
  438. return ret;
  439. }
  440. static int wcd937x_codec_aux_dac_event(struct snd_soc_dapm_widget *w,
  441. struct snd_kcontrol *kcontrol,
  442. int event)
  443. {
  444. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  445. struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec);
  446. int ret = 0;
  447. dev_dbg(codec->dev, "%s wname: %s event: %d\n", __func__,
  448. w->name, event);
  449. switch (event) {
  450. case SND_SOC_DAPM_PRE_PMU:
  451. wcd937x_rx_clk_enable(codec);
  452. snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_ANA_CLK_CTL,
  453. 0x04, 0x04);
  454. snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_DIG_CLK_CTL,
  455. 0x04, 0x04);
  456. snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_AUX_GAIN_CTL,
  457. 0x01, 0x01);
  458. break;
  459. case SND_SOC_DAPM_POST_PMD:
  460. ret = swr_slvdev_datapath_control(wcd937x->rx_swr_dev,
  461. wcd937x->rx_swr_dev->dev_num,
  462. false);
  463. wcd937x_rx_clk_disable(codec);
  464. snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_ANA_CLK_CTL,
  465. 0x04, 0x00);
  466. break;
  467. };
  468. return ret;
  469. }
  470. static int wcd937x_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w,
  471. struct snd_kcontrol *kcontrol,
  472. int event)
  473. {
  474. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  475. struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec);
  476. int ret = 0;
  477. dev_dbg(codec->dev, "%s wname: %s event: %d\n", __func__,
  478. w->name, event);
  479. switch (event) {
  480. case SND_SOC_DAPM_PRE_PMU:
  481. snd_soc_update_bits(codec, WCD937X_ANA_HPH, 0x10, 0x10);
  482. usleep_range(100, 110);
  483. ret = swr_slvdev_datapath_control(wcd937x->rx_swr_dev,
  484. wcd937x->rx_swr_dev->dev_num,
  485. true);
  486. break;
  487. case SND_SOC_DAPM_POST_PMU:
  488. usleep_range(7000, 7010);
  489. snd_soc_update_bits(codec, WCD937X_HPH_NEW_INT_HPH_TIMER1,
  490. 0x02, 0x02);
  491. snd_soc_update_bits(codec, WCD937X_ANA_RX_SUPPLIES,
  492. 0x02, 0x02);
  493. if (wcd937x->update_wcd_event)
  494. wcd937x->update_wcd_event(wcd937x->handle,
  495. WCD_BOLERO_EVT_RX_MUTE,
  496. (WCD_RX2 << 0x10));
  497. break;
  498. case SND_SOC_DAPM_PRE_PMD:
  499. if (wcd937x->update_wcd_event)
  500. wcd937x->update_wcd_event(wcd937x->handle,
  501. WCD_BOLERO_EVT_RX_MUTE,
  502. (WCD_RX2 << 0x10 | 0x1));
  503. blocking_notifier_call_chain(&wcd937x->mbhc->notifier,
  504. WCD_EVENT_PRE_HPHR_PA_OFF,
  505. &wcd937x->mbhc->wcd_mbhc);
  506. break;
  507. case SND_SOC_DAPM_POST_PMD:
  508. usleep_range(7000, 7010);
  509. blocking_notifier_call_chain(&wcd937x->mbhc->notifier,
  510. WCD_EVENT_POST_HPHR_PA_OFF,
  511. &wcd937x->mbhc->wcd_mbhc);
  512. snd_soc_update_bits(codec, WCD937X_ANA_HPH, 0x10, 0x00);
  513. break;
  514. };
  515. return ret;
  516. }
  517. static int wcd937x_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w,
  518. struct snd_kcontrol *kcontrol,
  519. int event)
  520. {
  521. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  522. struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec);
  523. int ret = 0;
  524. switch (event) {
  525. case SND_SOC_DAPM_PRE_PMU:
  526. snd_soc_update_bits(codec, WCD937X_ANA_HPH, 0x20, 0x20);
  527. usleep_range(100, 110);
  528. ret = swr_slvdev_datapath_control(wcd937x->rx_swr_dev,
  529. wcd937x->rx_swr_dev->dev_num,
  530. true);
  531. break;
  532. case SND_SOC_DAPM_POST_PMU:
  533. usleep_range(7000, 7010);
  534. snd_soc_update_bits(codec, WCD937X_HPH_NEW_INT_HPH_TIMER1,
  535. 0x02, 0x02);
  536. snd_soc_update_bits(codec, WCD937X_ANA_RX_SUPPLIES,
  537. 0x02, 0x02);
  538. if (wcd937x->update_wcd_event)
  539. wcd937x->update_wcd_event(wcd937x->handle,
  540. WCD_BOLERO_EVT_RX_MUTE,
  541. (WCD_RX1 << 0x10));
  542. break;
  543. case SND_SOC_DAPM_PRE_PMD:
  544. if (wcd937x->update_wcd_event)
  545. wcd937x->update_wcd_event(wcd937x->handle,
  546. WCD_BOLERO_EVT_RX_MUTE,
  547. (WCD_RX1 << 0x10 | 0x1));
  548. blocking_notifier_call_chain(&wcd937x->mbhc->notifier,
  549. WCD_EVENT_PRE_HPHL_PA_OFF,
  550. &wcd937x->mbhc->wcd_mbhc);
  551. break;
  552. case SND_SOC_DAPM_POST_PMD:
  553. usleep_range(7000, 7010);
  554. blocking_notifier_call_chain(&wcd937x->mbhc->notifier,
  555. WCD_EVENT_POST_HPHL_PA_OFF,
  556. &wcd937x->mbhc->wcd_mbhc);
  557. snd_soc_update_bits(codec, WCD937X_ANA_HPH, 0x20, 0x00);
  558. break;
  559. };
  560. return ret;
  561. }
  562. static int wcd937x_codec_enable_aux_pa(struct snd_soc_dapm_widget *w,
  563. struct snd_kcontrol *kcontrol,
  564. int event)
  565. {
  566. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  567. struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec);
  568. int ret = 0;
  569. dev_dbg(codec->dev, "%s wname: %s event: %d\n", __func__,
  570. w->name, event);
  571. switch (event) {
  572. case SND_SOC_DAPM_PRE_PMU:
  573. snd_soc_update_bits(codec, WCD937X_ANA_RX_SUPPLIES,
  574. 0x80, 0x80);
  575. usleep_range(500, 510);
  576. snd_soc_update_bits(codec, WCD937X_CLASSH_MODE_2, 0xFF, 0x3A);
  577. usleep_range(500, 510);
  578. ret = swr_slvdev_datapath_control(wcd937x->rx_swr_dev,
  579. wcd937x->rx_swr_dev->dev_num,
  580. true);
  581. break;
  582. case SND_SOC_DAPM_POST_PMU:
  583. usleep_range(1000, 1010);
  584. snd_soc_update_bits(codec, WCD937X_ANA_RX_SUPPLIES,
  585. 0x20, 0x20);
  586. if (wcd937x->update_wcd_event)
  587. wcd937x->update_wcd_event(wcd937x->handle,
  588. WCD_BOLERO_EVT_RX_MUTE,
  589. (WCD_RX3 << 0x10));
  590. break;
  591. case SND_SOC_DAPM_PRE_PMD:
  592. if (wcd937x->update_wcd_event)
  593. wcd937x->update_wcd_event(wcd937x->handle,
  594. WCD_BOLERO_EVT_RX_MUTE,
  595. (WCD_RX3 << 0x10 | 0x1));
  596. break;
  597. case SND_SOC_DAPM_POST_PMD:
  598. usleep_range(1000, 1010);
  599. usleep_range(1000, 1010);
  600. break;
  601. };
  602. return ret;
  603. }
  604. static int wcd937x_codec_enable_ear_pa(struct snd_soc_dapm_widget *w,
  605. struct snd_kcontrol *kcontrol,
  606. int event)
  607. {
  608. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  609. struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec);
  610. int ret = 0;
  611. dev_dbg(codec->dev, "%s wname: %s event: %d\n", __func__,
  612. w->name, event);
  613. switch (event) {
  614. case SND_SOC_DAPM_PRE_PMU:
  615. snd_soc_update_bits(codec, WCD937X_ANA_RX_SUPPLIES,
  616. 0x08, 0x08);
  617. usleep_range(500, 510);
  618. snd_soc_update_bits(codec, WCD937X_CLASSH_MODE_2, 0xFF, 0x3A);
  619. usleep_range(500, 510);
  620. ret = swr_slvdev_datapath_control(wcd937x->rx_swr_dev,
  621. wcd937x->rx_swr_dev->dev_num,
  622. true);
  623. break;
  624. case SND_SOC_DAPM_POST_PMU:
  625. usleep_range(6000, 6010);
  626. snd_soc_update_bits(codec, WCD937X_ANA_RX_SUPPLIES,
  627. 0x02, 0x02);
  628. if (wcd937x->update_wcd_event)
  629. wcd937x->update_wcd_event(wcd937x->handle,
  630. WCD_BOLERO_EVT_RX_MUTE,
  631. (WCD_RX1 << 0x10));
  632. break;
  633. case SND_SOC_DAPM_PRE_PMD:
  634. if (wcd937x->update_wcd_event)
  635. wcd937x->update_wcd_event(wcd937x->handle,
  636. WCD_BOLERO_EVT_RX_MUTE,
  637. (WCD_RX1 << 0x10 | 0x1));
  638. break;
  639. case SND_SOC_DAPM_POST_PMD:
  640. usleep_range(7000, 7010);
  641. break;
  642. };
  643. return ret;
  644. }
  645. static int wcd937x_enable_rx1(struct snd_soc_dapm_widget *w,
  646. struct snd_kcontrol *kcontrol,
  647. int event)
  648. {
  649. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  650. struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec);
  651. dev_dbg(codec->dev, "%s wname: %s event: %d\n", __func__,
  652. w->name, event);
  653. switch (event) {
  654. case SND_SOC_DAPM_PRE_PMU:
  655. snd_soc_update_bits(codec, WCD937X_FLYBACK_VNEG_CTRL_4,
  656. 0xF0, 0x80);
  657. snd_soc_update_bits(codec, WCD937X_FLYBACK_VNEGDAC_CTRL_2,
  658. 0xE0, 0xA0);
  659. snd_soc_update_bits(codec, WCD937X_CLASSH_MODE_3,
  660. 0x02, 0x02);
  661. snd_soc_update_bits(codec, WCD937X_CLASSH_MODE_2,
  662. 0xFF, 0x1C);
  663. snd_soc_update_bits(codec, WCD937X_ANA_RX_SUPPLIES,
  664. 0x40, 0x40);
  665. usleep_range(100, 110);
  666. snd_soc_update_bits(codec, WCD937X_FLYBACK_VNEGDAC_CTRL_2,
  667. 0xE0, 0xE0);
  668. usleep_range(100, 110);
  669. snd_soc_update_bits(codec, WCD937X_ANA_RX_SUPPLIES,
  670. 0x80, 0x80);
  671. usleep_range(500, 510);
  672. snd_soc_update_bits(codec, WCD937X_CLASSH_MODE_2, 0xFF, 0x3A);
  673. usleep_range(500, 510);
  674. wcd937x_rx_connect_port(codec, HPH_L, true);
  675. if (wcd937x->comp1_enable)
  676. wcd937x_rx_connect_port(codec, COMP_L, true);
  677. break;
  678. case SND_SOC_DAPM_POST_PMD:
  679. wcd937x_rx_connect_port(codec, HPH_L, false);
  680. if (wcd937x->comp1_enable)
  681. wcd937x_rx_connect_port(codec, COMP_L, false);
  682. wcd937x_rx_clk_disable(codec);
  683. snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_DIG_CLK_CTL,
  684. 0x01, 0x00);
  685. break;
  686. };
  687. return 0;
  688. }
  689. static int wcd937x_enable_rx2(struct snd_soc_dapm_widget *w,
  690. struct snd_kcontrol *kcontrol, int event)
  691. {
  692. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  693. struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec);
  694. dev_dbg(codec->dev, "%s wname: %s event: %d\n", __func__,
  695. w->name, event);
  696. switch (event) {
  697. case SND_SOC_DAPM_PRE_PMU:
  698. snd_soc_update_bits(codec, WCD937X_FLYBACK_VNEG_CTRL_4,
  699. 0xF0, 0x80);
  700. snd_soc_update_bits(codec, WCD937X_FLYBACK_VNEGDAC_CTRL_2,
  701. 0xE0, 0xA0);
  702. snd_soc_update_bits(codec, WCD937X_CLASSH_MODE_3, 0x02, 0x02);
  703. snd_soc_update_bits(codec, WCD937X_CLASSH_MODE_2, 0xFF, 0x1C);
  704. snd_soc_update_bits(codec, WCD937X_ANA_RX_SUPPLIES,
  705. 0x40, 0x40);
  706. usleep_range(100, 110);
  707. snd_soc_update_bits(codec, WCD937X_FLYBACK_VNEGDAC_CTRL_2,
  708. 0xE0, 0xE0);
  709. usleep_range(100, 110);
  710. snd_soc_update_bits(codec, WCD937X_ANA_RX_SUPPLIES,
  711. 0x80, 0x80);
  712. usleep_range(500, 510);
  713. snd_soc_update_bits(codec, WCD937X_CLASSH_MODE_2, 0xFF, 0x3A);
  714. usleep_range(500, 510);
  715. wcd937x_rx_connect_port(codec, HPH_R, true);
  716. if (wcd937x->comp2_enable)
  717. wcd937x_rx_connect_port(codec, COMP_R, true);
  718. break;
  719. case SND_SOC_DAPM_POST_PMD:
  720. wcd937x_rx_connect_port(codec, HPH_R, false);
  721. if (wcd937x->comp2_enable)
  722. wcd937x_rx_connect_port(codec, COMP_R, false);
  723. wcd937x_rx_clk_disable(codec);
  724. snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_DIG_CLK_CTL,
  725. 0x02, 0x00);
  726. break;
  727. };
  728. return 0;
  729. }
  730. static int wcd937x_enable_rx3(struct snd_soc_dapm_widget *w,
  731. struct snd_kcontrol *kcontrol,
  732. int event)
  733. {
  734. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  735. dev_dbg(codec->dev, "%s wname: %s event: %d\n", __func__,
  736. w->name, event);
  737. switch (event) {
  738. case SND_SOC_DAPM_PRE_PMU:
  739. snd_soc_update_bits(codec, WCD937X_FLYBACK_VNEG_CTRL_2,
  740. 0xE0, 0xA0);
  741. snd_soc_update_bits(codec, WCD937X_CLASSH_MODE_3, 0x02, 0x02);
  742. snd_soc_update_bits(codec, WCD937X_CLASSH_MODE_2, 0xFF, 0x1C);
  743. snd_soc_update_bits(codec, WCD937X_ANA_RX_SUPPLIES,
  744. 0x40, 0x40);
  745. usleep_range(100, 110);
  746. snd_soc_update_bits(codec, WCD937X_FLYBACK_VNEG_CTRL_2,
  747. 0xE0, 0xE0);
  748. usleep_range(100, 110);
  749. wcd937x_rx_connect_port(codec, LO, true);
  750. break;
  751. case SND_SOC_DAPM_POST_PMD:
  752. wcd937x_rx_connect_port(codec, LO, false);
  753. usleep_range(6000, 6010);
  754. wcd937x_rx_clk_disable(codec);
  755. snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_DIG_CLK_CTL,
  756. 0x04, 0x00);
  757. break;
  758. }
  759. return 0;
  760. }
  761. static int wcd937x_codec_enable_dmic(struct snd_soc_dapm_widget *w,
  762. struct snd_kcontrol *kcontrol,
  763. int event)
  764. {
  765. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  766. struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec);
  767. u16 dmic_clk_reg;
  768. s32 *dmic_clk_cnt;
  769. unsigned int dmic;
  770. char *wname;
  771. int ret = 0;
  772. wname = strpbrk(w->name, "012345");
  773. if (!wname) {
  774. dev_err(codec->dev, "%s: widget not found\n", __func__);
  775. return -EINVAL;
  776. }
  777. ret = kstrtouint(wname, 10, &dmic);
  778. if (ret < 0) {
  779. dev_err(codec->dev, "%s: Invalid DMIC line on the codec\n",
  780. __func__);
  781. return -EINVAL;
  782. }
  783. dev_dbg(codec->dev, "%s wname: %s event: %d\n", __func__,
  784. w->name, event);
  785. switch (dmic) {
  786. case 0:
  787. case 1:
  788. dmic_clk_cnt = &(wcd937x->dmic_0_1_clk_cnt);
  789. dmic_clk_reg = WCD937X_DIGITAL_CDC_DMIC0_CTL;
  790. break;
  791. case 2:
  792. case 3:
  793. dmic_clk_cnt = &(wcd937x->dmic_2_3_clk_cnt);
  794. dmic_clk_reg = WCD937X_DIGITAL_CDC_DMIC1_CTL;
  795. break;
  796. case 4:
  797. case 5:
  798. dmic_clk_cnt = &(wcd937x->dmic_4_5_clk_cnt);
  799. dmic_clk_reg = WCD937X_DIGITAL_CDC_DMIC2_CTL;
  800. break;
  801. default:
  802. dev_err(codec->dev, "%s: Invalid DMIC Selection\n",
  803. __func__);
  804. return -EINVAL;
  805. };
  806. dev_dbg(codec->dev, "%s: event %d DMIC%d dmic_clk_cnt %d\n",
  807. __func__, event, dmic, *dmic_clk_cnt);
  808. switch (event) {
  809. case SND_SOC_DAPM_PRE_PMU:
  810. snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_DIG_CLK_CTL,
  811. 0x80, 0x80);
  812. snd_soc_update_bits(codec, dmic_clk_reg, 0x07, 0x02);
  813. snd_soc_update_bits(codec, dmic_clk_reg, 0x08, 0x08);
  814. snd_soc_update_bits(codec, dmic_clk_reg, 0x70, 0x20);
  815. wcd937x_tx_connect_port(codec, DMIC0 + (w->shift), true);
  816. break;
  817. case SND_SOC_DAPM_POST_PMD:
  818. wcd937x_tx_connect_port(codec, DMIC0 + (w->shift), false);
  819. break;
  820. };
  821. return 0;
  822. }
  823. /*
  824. * wcd937x_get_micb_vout_ctl_val: converts micbias from volts to register value
  825. * @micb_mv: micbias in mv
  826. *
  827. * return register value converted
  828. */
  829. int wcd937x_get_micb_vout_ctl_val(u32 micb_mv)
  830. {
  831. /* min micbias voltage is 1V and maximum is 2.85V */
  832. if (micb_mv < 1000 || micb_mv > 2850) {
  833. pr_err("%s: unsupported micbias voltage\n", __func__);
  834. return -EINVAL;
  835. }
  836. return (micb_mv - 1000) / 50;
  837. }
  838. EXPORT_SYMBOL(wcd937x_get_micb_vout_ctl_val);
  839. /*
  840. * wcd937x_mbhc_micb_adjust_voltage: adjust specific micbias voltage
  841. * @codec: handle to snd_soc_codec *
  842. * @req_volt: micbias voltage to be set
  843. * @micb_num: micbias to be set, e.g. micbias1 or micbias2
  844. *
  845. * return 0 if adjustment is success or error code in case of failure
  846. */
  847. int wcd937x_mbhc_micb_adjust_voltage(struct snd_soc_codec *codec,
  848. int req_volt, int micb_num)
  849. {
  850. struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec);
  851. int cur_vout_ctl, req_vout_ctl;
  852. int micb_reg, micb_val, micb_en;
  853. int ret = 0;
  854. switch (micb_num) {
  855. case MIC_BIAS_1:
  856. micb_reg = WCD937X_ANA_MICB1;
  857. break;
  858. case MIC_BIAS_2:
  859. micb_reg = WCD937X_ANA_MICB2;
  860. break;
  861. case MIC_BIAS_3:
  862. micb_reg = WCD937X_ANA_MICB3;
  863. break;
  864. default:
  865. return -EINVAL;
  866. }
  867. mutex_lock(&wcd937x->micb_lock);
  868. /*
  869. * If requested micbias voltage is same as current micbias
  870. * voltage, then just return. Otherwise, adjust voltage as
  871. * per requested value. If micbias is already enabled, then
  872. * to avoid slow micbias ramp-up or down enable pull-up
  873. * momentarily, change the micbias value and then re-enable
  874. * micbias.
  875. */
  876. micb_val = snd_soc_read(codec, micb_reg);
  877. micb_en = (micb_val & 0xC0) >> 6;
  878. cur_vout_ctl = micb_val & 0x3F;
  879. req_vout_ctl = wcd937x_get_micb_vout_ctl_val(req_volt);
  880. if (req_vout_ctl < 0) {
  881. ret = -EINVAL;
  882. goto exit;
  883. }
  884. if (cur_vout_ctl == req_vout_ctl) {
  885. ret = 0;
  886. goto exit;
  887. }
  888. dev_dbg(codec->dev, "%s: micb_num: %d, cur_mv: %d, req_mv: %d, micb_en: %d\n",
  889. __func__, micb_num, WCD_VOUT_CTL_TO_MICB(cur_vout_ctl),
  890. req_volt, micb_en);
  891. if (micb_en == 0x1)
  892. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80);
  893. snd_soc_update_bits(codec, micb_reg, 0x3F, req_vout_ctl);
  894. if (micb_en == 0x1) {
  895. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x40);
  896. /*
  897. * Add 2ms delay as per HW requirement after enabling
  898. * micbias
  899. */
  900. usleep_range(2000, 2100);
  901. }
  902. exit:
  903. mutex_unlock(&wcd937x->micb_lock);
  904. return ret;
  905. }
  906. EXPORT_SYMBOL(wcd937x_mbhc_micb_adjust_voltage);
  907. static int wcd937x_tx_swr_ctrl(struct snd_soc_dapm_widget *w,
  908. struct snd_kcontrol *kcontrol,
  909. int event)
  910. {
  911. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  912. struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec);
  913. int ret = 0;
  914. switch (event) {
  915. case SND_SOC_DAPM_PRE_PMU:
  916. ret = swr_slvdev_datapath_control(wcd937x->tx_swr_dev,
  917. wcd937x->tx_swr_dev->dev_num,
  918. true);
  919. break;
  920. case SND_SOC_DAPM_POST_PMD:
  921. ret = swr_slvdev_datapath_control(wcd937x->tx_swr_dev,
  922. wcd937x->tx_swr_dev->dev_num,
  923. false);
  924. break;
  925. };
  926. return ret;
  927. }
  928. static int wcd937x_codec_enable_adc(struct snd_soc_dapm_widget *w,
  929. struct snd_kcontrol *kcontrol,
  930. int event){
  931. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  932. dev_dbg(codec->dev, "%s wname: %s event: %d\n", __func__,
  933. w->name, event);
  934. switch (event) {
  935. case SND_SOC_DAPM_PRE_PMU:
  936. snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_DIG_CLK_CTL,
  937. 0x80, 0x80);
  938. snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_ANA_CLK_CTL,
  939. 0x08, 0x08);
  940. snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_ANA_CLK_CTL,
  941. 0x10, 0x10);
  942. wcd937x_tx_connect_port(codec, ADC1 + (w->shift), true);
  943. break;
  944. case SND_SOC_DAPM_POST_PMD:
  945. wcd937x_tx_connect_port(codec, ADC1 + (w->shift), false);
  946. snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_ANA_CLK_CTL,
  947. 0x08, 0x00);
  948. break;
  949. };
  950. return 0;
  951. }
  952. static int wcd937x_enable_req(struct snd_soc_dapm_widget *w,
  953. struct snd_kcontrol *kcontrol, int event)
  954. {
  955. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  956. dev_dbg(codec->dev, "%s wname: %s event: %d\n", __func__,
  957. w->name, event);
  958. switch (event) {
  959. case SND_SOC_DAPM_PRE_PMU:
  960. snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_REQ_CTL,
  961. 0x02, 0x02);
  962. snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_REQ_CTL, 0x01,
  963. 0x00);
  964. snd_soc_update_bits(codec, WCD937X_ANA_TX_CH2, 0x40, 0x40);
  965. snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_DIG_CLK_CTL,
  966. 0x30, 0x30);
  967. snd_soc_update_bits(codec, WCD937X_ANA_TX_CH1, 0x80, 0x80);
  968. snd_soc_update_bits(codec, WCD937X_ANA_TX_CH2, 0x40, 0x00);
  969. snd_soc_update_bits(codec, WCD937X_ANA_TX_CH2, 0x80, 0x80);
  970. break;
  971. case SND_SOC_DAPM_POST_PMD:
  972. snd_soc_update_bits(codec, WCD937X_ANA_TX_CH1, 0x80, 0x00);
  973. snd_soc_update_bits(codec, WCD937X_ANA_TX_CH2, 0x80, 0x00);
  974. snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_DIG_CLK_CTL,
  975. 0x10, 0x00);
  976. snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_ANA_CLK_CTL,
  977. 0x10, 0x00);
  978. snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_DIG_CLK_CTL,
  979. 0x80, 0x00);
  980. break;
  981. };
  982. return 0;
  983. }
  984. int wcd937x_micbias_control(struct snd_soc_codec *codec,
  985. int micb_num, int req, bool is_dapm)
  986. {
  987. struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec);
  988. int micb_index = micb_num - 1;
  989. u16 micb_reg;
  990. int pre_off_event = 0, post_off_event = 0;
  991. int post_on_event = 0, post_dapm_off = 0;
  992. int post_dapm_on = 0;
  993. if ((micb_index < 0) || (micb_index > WCD937X_MAX_MICBIAS - 1)) {
  994. dev_err(codec->dev, "%s: Invalid micbias index, micb_ind:%d\n",
  995. __func__, micb_index);
  996. return -EINVAL;
  997. }
  998. switch (micb_num) {
  999. case MIC_BIAS_1:
  1000. micb_reg = WCD937X_ANA_MICB1;
  1001. break;
  1002. case MIC_BIAS_2:
  1003. micb_reg = WCD937X_ANA_MICB2;
  1004. pre_off_event = WCD_EVENT_PRE_MICBIAS_2_OFF;
  1005. post_off_event = WCD_EVENT_POST_MICBIAS_2_OFF;
  1006. post_on_event = WCD_EVENT_POST_MICBIAS_2_ON;
  1007. post_dapm_on = WCD_EVENT_POST_DAPM_MICBIAS_2_ON;
  1008. post_dapm_off = WCD_EVENT_POST_DAPM_MICBIAS_2_OFF;
  1009. break;
  1010. case MIC_BIAS_3:
  1011. micb_reg = WCD937X_ANA_MICB3;
  1012. break;
  1013. default:
  1014. dev_err(codec->dev, "%s: Invalid micbias number: %d\n",
  1015. __func__, micb_num);
  1016. return -EINVAL;
  1017. };
  1018. mutex_lock(&wcd937x->micb_lock);
  1019. switch (req) {
  1020. case MICB_PULLUP_ENABLE:
  1021. wcd937x->pullup_ref[micb_index]++;
  1022. if ((wcd937x->pullup_ref[micb_index] == 1) &&
  1023. (wcd937x->micb_ref[micb_index] == 0))
  1024. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80);
  1025. break;
  1026. case MICB_PULLUP_DISABLE:
  1027. if (wcd937x->pullup_ref[micb_index] > 0)
  1028. wcd937x->pullup_ref[micb_index]--;
  1029. if ((wcd937x->pullup_ref[micb_index] == 0) &&
  1030. (wcd937x->micb_ref[micb_index] == 0))
  1031. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x00);
  1032. break;
  1033. case MICB_ENABLE:
  1034. wcd937x->micb_ref[micb_index]++;
  1035. if (wcd937x->micb_ref[micb_index] == 1) {
  1036. snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_DIG_CLK_CTL, 0xE0, 0xE0);
  1037. snd_soc_update_bits(codec, WCD937X_DIGITAL_CDC_ANA_CLK_CTL, 0x10, 0x10);
  1038. snd_soc_update_bits(codec, WCD937X_MICB1_TEST_CTL_2, 0x01, 0x01);
  1039. snd_soc_update_bits(codec, WCD937X_MICB2_TEST_CTL_2, 0x01, 0x01);
  1040. snd_soc_update_bits(codec, WCD937X_MICB3_TEST_CTL_2, 0x01, 0x01);
  1041. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x40);
  1042. if (post_on_event && wcd937x->mbhc)
  1043. blocking_notifier_call_chain(
  1044. &wcd937x->mbhc->notifier, post_on_event,
  1045. &wcd937x->mbhc->wcd_mbhc);
  1046. }
  1047. if (is_dapm && post_dapm_on && wcd937x->mbhc)
  1048. blocking_notifier_call_chain(
  1049. &wcd937x->mbhc->notifier, post_dapm_on,
  1050. &wcd937x->mbhc->wcd_mbhc);
  1051. break;
  1052. case MICB_DISABLE:
  1053. if (wcd937x->micb_ref[micb_index] > 0)
  1054. wcd937x->micb_ref[micb_index]--;
  1055. if ((wcd937x->micb_ref[micb_index] == 0) &&
  1056. (wcd937x->pullup_ref[micb_index] > 0))
  1057. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x80);
  1058. else if ((wcd937x->micb_ref[micb_index] == 0) &&
  1059. (wcd937x->pullup_ref[micb_index] == 0)) {
  1060. if (pre_off_event && wcd937x->mbhc)
  1061. blocking_notifier_call_chain(
  1062. &wcd937x->mbhc->notifier, pre_off_event,
  1063. &wcd937x->mbhc->wcd_mbhc);
  1064. snd_soc_update_bits(codec, micb_reg, 0xC0, 0x00);
  1065. if (post_off_event && wcd937x->mbhc)
  1066. blocking_notifier_call_chain(
  1067. &wcd937x->mbhc->notifier,
  1068. post_off_event,
  1069. &wcd937x->mbhc->wcd_mbhc);
  1070. }
  1071. if (is_dapm && post_dapm_off && wcd937x->mbhc)
  1072. blocking_notifier_call_chain(
  1073. &wcd937x->mbhc->notifier, post_dapm_off,
  1074. &wcd937x->mbhc->wcd_mbhc);
  1075. break;
  1076. };
  1077. dev_dbg(codec->dev, "%s: micb_num:%d, micb_ref: %d, pullup_ref: %d\n",
  1078. __func__, micb_num, wcd937x->micb_ref[micb_index],
  1079. wcd937x->pullup_ref[micb_index]);
  1080. mutex_unlock(&wcd937x->micb_lock);
  1081. return 0;
  1082. }
  1083. EXPORT_SYMBOL(wcd937x_micbias_control);
  1084. static int wcd937x_get_logical_addr(struct swr_device *swr_dev)
  1085. {
  1086. int ret = 0;
  1087. uint8_t devnum = 0;
  1088. ret = swr_get_logical_dev_num(swr_dev, swr_dev->addr, &devnum);
  1089. if (ret) {
  1090. dev_err(&swr_dev->dev,
  1091. "%s get devnum %d for dev addr %lx failed\n",
  1092. __func__, devnum, swr_dev->addr);
  1093. swr_remove_device(swr_dev);
  1094. return ret;
  1095. }
  1096. swr_dev->dev_num = devnum;
  1097. return 0;
  1098. }
  1099. static int wcd937x_event_notify(struct notifier_block *block,
  1100. unsigned long val,
  1101. void *data)
  1102. {
  1103. u16 event = (val & 0xffff);
  1104. u16 amic = (val >> 0x10);
  1105. u16 mask = 0x40, reg = 0x0;
  1106. int ret = 0;
  1107. struct wcd937x_priv *wcd937x = dev_get_drvdata((struct device *)data);
  1108. struct snd_soc_codec *codec = wcd937x->codec;
  1109. struct wcd_mbhc *mbhc;
  1110. switch (event) {
  1111. case BOLERO_WCD_EVT_TX_CH_HOLD_CLEAR:
  1112. if (amic == 0x1 || amic == 0x2)
  1113. reg = WCD937X_ANA_TX_CH2;
  1114. else if (amic == 0x3)
  1115. reg = WCD937X_ANA_TX_CH3_HPF;
  1116. else
  1117. return 0;
  1118. if (amic == 0x2)
  1119. mask = 0x20;
  1120. snd_soc_update_bits(codec, reg, mask, 0x00);
  1121. break;
  1122. case BOLERO_WCD_EVT_SSR_DOWN:
  1123. wcd937x_reset_low(wcd937x->dev);
  1124. break;
  1125. case BOLERO_WCD_EVT_SSR_UP:
  1126. wcd937x_reset(wcd937x->dev);
  1127. wcd937x_get_logical_addr(wcd937x->tx_swr_dev);
  1128. wcd937x_get_logical_addr(wcd937x->rx_swr_dev);
  1129. regcache_mark_dirty(wcd937x->regmap);
  1130. regcache_sync(wcd937x->regmap);
  1131. /* Initialize MBHC module */
  1132. mbhc = &wcd937x->mbhc->wcd_mbhc;
  1133. ret = wcd937x_mbhc_post_ssr_init(wcd937x->mbhc, codec);
  1134. if (ret) {
  1135. dev_err(codec->dev, "%s: mbhc initialization failed\n",
  1136. __func__);
  1137. } else {
  1138. wcd937x_mbhc_hs_detect(codec, mbhc->mbhc_cfg);
  1139. }
  1140. break;
  1141. default:
  1142. dev_err(codec->dev, "%s: invalid event %d\n", __func__, event);
  1143. break;
  1144. }
  1145. return 0;
  1146. }
  1147. static int __wcd937x_codec_enable_micbias(struct snd_soc_dapm_widget *w,
  1148. int event)
  1149. {
  1150. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  1151. int micb_num;
  1152. dev_dbg(codec->dev, "%s: wname: %s, event: %d\n",
  1153. __func__, w->name, event);
  1154. if (strnstr(w->name, "MIC BIAS1", sizeof("MIC BIAS1")))
  1155. micb_num = MIC_BIAS_1;
  1156. else if (strnstr(w->name, "MIC BIAS2", sizeof("MIC BIAS2")))
  1157. micb_num = MIC_BIAS_2;
  1158. else if (strnstr(w->name, "MIC BIAS3", sizeof("MIC BIAS3")))
  1159. micb_num = MIC_BIAS_3;
  1160. else
  1161. return -EINVAL;
  1162. switch (event) {
  1163. case SND_SOC_DAPM_PRE_PMU:
  1164. wcd937x_micbias_control(codec, micb_num, MICB_ENABLE, true);
  1165. break;
  1166. case SND_SOC_DAPM_POST_PMU:
  1167. usleep_range(1000, 1100);
  1168. break;
  1169. case SND_SOC_DAPM_POST_PMD:
  1170. wcd937x_micbias_control(codec, micb_num, MICB_DISABLE, true);
  1171. break;
  1172. };
  1173. return 0;
  1174. }
  1175. static int wcd937x_codec_enable_micbias(struct snd_soc_dapm_widget *w,
  1176. struct snd_kcontrol *kcontrol,
  1177. int event)
  1178. {
  1179. return __wcd937x_codec_enable_micbias(w, event);
  1180. }
  1181. static int wcd937x_rx_hph_mode_get(struct snd_kcontrol *kcontrol,
  1182. struct snd_ctl_elem_value *ucontrol)
  1183. {
  1184. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1185. struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec);
  1186. ucontrol->value.integer.value[0] = wcd937x->hph_mode;
  1187. return 0;
  1188. }
  1189. static int wcd937x_rx_hph_mode_put(struct snd_kcontrol *kcontrol,
  1190. struct snd_ctl_elem_value *ucontrol)
  1191. {
  1192. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1193. struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec);
  1194. u32 mode_val;
  1195. mode_val = ucontrol->value.enumerated.item[0];
  1196. dev_dbg(codec->dev, "%s: mode: %d\n", __func__, mode_val);
  1197. if (mode_val == 0) {
  1198. dev_warn(codec->dev, "%s:Invalid HPH Mode, default to class_AB\n",
  1199. __func__);
  1200. mode_val = 3; /* enum will be updated later */
  1201. }
  1202. wcd937x->hph_mode = mode_val;
  1203. return 0;
  1204. }
  1205. static int wcd937x_get_compander(struct snd_kcontrol *kcontrol,
  1206. struct snd_ctl_elem_value *ucontrol)
  1207. {
  1208. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1209. struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec);
  1210. bool hphr;
  1211. struct soc_multi_mixer_control *mc;
  1212. mc = (struct soc_multi_mixer_control *)(kcontrol->private_value);
  1213. hphr = mc->shift;
  1214. ucontrol->value.integer.value[0] = hphr ? wcd937x->comp2_enable :
  1215. wcd937x->comp1_enable;
  1216. return 0;
  1217. }
  1218. static int wcd937x_set_compander(struct snd_kcontrol *kcontrol,
  1219. struct snd_ctl_elem_value *ucontrol)
  1220. {
  1221. struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
  1222. struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec);
  1223. int value = ucontrol->value.integer.value[0];
  1224. bool hphr;
  1225. struct soc_multi_mixer_control *mc;
  1226. mc = (struct soc_multi_mixer_control *)(kcontrol->private_value);
  1227. hphr = mc->shift;
  1228. if (hphr)
  1229. wcd937x->comp2_enable = value;
  1230. else
  1231. wcd937x->comp1_enable = value;
  1232. return 0;
  1233. }
  1234. static int wcd937x_codec_enable_vdd_buck(struct snd_soc_dapm_widget *w,
  1235. struct snd_kcontrol *kcontrol,
  1236. int event)
  1237. {
  1238. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  1239. struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec);
  1240. struct wcd937x_pdata *pdata = NULL;
  1241. int ret = 0;
  1242. pdata = dev_get_platdata(wcd937x->dev);
  1243. if (!pdata) {
  1244. dev_err(codec->dev, "%s: pdata is NULL\n", __func__);
  1245. return -EINVAL;
  1246. }
  1247. dev_dbg(codec->dev, "%s wname: %s event: %d\n", __func__,
  1248. w->name, event);
  1249. switch (event) {
  1250. case SND_SOC_DAPM_PRE_PMU:
  1251. ret = msm_cdc_enable_ondemand_supply(wcd937x->dev,
  1252. wcd937x->supplies,
  1253. pdata->regulator,
  1254. pdata->num_supplies,
  1255. "cdc-vdd-buck");
  1256. if (ret == -EINVAL) {
  1257. dev_err(codec->dev, "%s: vdd buck is not enabled\n",
  1258. __func__);
  1259. return ret;
  1260. }
  1261. /*
  1262. * 200us sleep is required after LDO15 is enabled as per
  1263. * HW requirement
  1264. */
  1265. usleep_range(200, 250);
  1266. break;
  1267. case SND_SOC_DAPM_POST_PMD:
  1268. ret = msm_cdc_disable_ondemand_supply(wcd937x->dev,
  1269. wcd937x->supplies,
  1270. pdata->regulator,
  1271. pdata->num_supplies,
  1272. "cdc-vdd-buck");
  1273. if (ret == -EINVAL) {
  1274. dev_err(codec->dev, "%s: vdd buck is not enabled\n",
  1275. __func__);
  1276. return ret;
  1277. }
  1278. break;
  1279. }
  1280. return 0;
  1281. }
  1282. static const char * const rx_hph_mode_mux_text[] = {
  1283. "CLS_H_INVALID", "CLS_H_HIFI", "CLS_H_LP", "CLS_AB", "CLS_H_LOHIFI",
  1284. "CLS_H_ULP", "CLS_AB_HIFI",
  1285. };
  1286. static const struct soc_enum rx_hph_mode_mux_enum =
  1287. SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(rx_hph_mode_mux_text),
  1288. rx_hph_mode_mux_text);
  1289. static const struct snd_kcontrol_new wcd937x_snd_controls[] = {
  1290. SOC_ENUM_EXT("RX HPH Mode", rx_hph_mode_mux_enum,
  1291. wcd937x_rx_hph_mode_get, wcd937x_rx_hph_mode_put),
  1292. SOC_SINGLE_EXT("HPHL_COMP Switch", SND_SOC_NOPM, 0, 1, 0,
  1293. wcd937x_get_compander, wcd937x_set_compander),
  1294. SOC_SINGLE_EXT("HPHR_COMP Switch", SND_SOC_NOPM, 1, 1, 0,
  1295. wcd937x_get_compander, wcd937x_set_compander),
  1296. SOC_SINGLE_TLV("HPHL Volume", WCD937X_HPH_L_EN, 0, 20, 1, line_gain),
  1297. SOC_SINGLE_TLV("HPHR Volume", WCD937X_HPH_R_EN, 0, 20, 1, line_gain),
  1298. SOC_SINGLE_TLV("ADC1 Volume", WCD937X_ANA_TX_CH1, 0, 20, 0, analog_gain),
  1299. SOC_SINGLE_TLV("ADC2 Volume", WCD937X_ANA_TX_CH2, 0, 20, 0, analog_gain),
  1300. SOC_SINGLE_TLV("ADC3 Volume", WCD937X_ANA_TX_CH3, 0, 20, 0, analog_gain),
  1301. };
  1302. static const struct snd_kcontrol_new adc1_switch[] = {
  1303. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0)
  1304. };
  1305. static const struct snd_kcontrol_new adc2_switch[] = {
  1306. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0)
  1307. };
  1308. static const struct snd_kcontrol_new adc3_switch[] = {
  1309. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0)
  1310. };
  1311. static const struct snd_kcontrol_new dmic1_switch[] = {
  1312. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0)
  1313. };
  1314. static const struct snd_kcontrol_new dmic2_switch[] = {
  1315. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0)
  1316. };
  1317. static const struct snd_kcontrol_new dmic3_switch[] = {
  1318. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0)
  1319. };
  1320. static const struct snd_kcontrol_new dmic4_switch[] = {
  1321. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0)
  1322. };
  1323. static const struct snd_kcontrol_new dmic5_switch[] = {
  1324. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0)
  1325. };
  1326. static const struct snd_kcontrol_new dmic6_switch[] = {
  1327. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0)
  1328. };
  1329. static const struct snd_kcontrol_new ear_rdac_switch[] = {
  1330. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0)
  1331. };
  1332. static const struct snd_kcontrol_new aux_rdac_switch[] = {
  1333. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0)
  1334. };
  1335. static const struct snd_kcontrol_new hphl_rdac_switch[] = {
  1336. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0)
  1337. };
  1338. static const struct snd_kcontrol_new hphr_rdac_switch[] = {
  1339. SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 1, 0)
  1340. };
  1341. static const char * const adc2_mux_text[] = {
  1342. "INP2", "INP3"
  1343. };
  1344. static const char * const rdac3_mux_text[] = {
  1345. "RX1", "RX3"
  1346. };
  1347. static const struct soc_enum adc2_enum =
  1348. SOC_ENUM_SINGLE(WCD937X_TX_NEW_TX_CH2_SEL, 7,
  1349. ARRAY_SIZE(adc2_mux_text), adc2_mux_text);
  1350. static const struct soc_enum rdac3_enum =
  1351. SOC_ENUM_SINGLE(WCD937X_DIGITAL_CDC_EAR_PATH_CTL, 0,
  1352. ARRAY_SIZE(rdac3_mux_text), rdac3_mux_text);
  1353. static const struct snd_kcontrol_new tx_adc2_mux =
  1354. SOC_DAPM_ENUM("ADC2 MUX Mux", adc2_enum);
  1355. static const struct snd_kcontrol_new rx_rdac3_mux =
  1356. SOC_DAPM_ENUM("RDAC3_MUX Mux", rdac3_enum);
  1357. static const struct snd_soc_dapm_widget wcd937x_dapm_widgets[] = {
  1358. /*input widgets*/
  1359. SND_SOC_DAPM_INPUT("AMIC1"),
  1360. SND_SOC_DAPM_INPUT("AMIC2"),
  1361. SND_SOC_DAPM_INPUT("AMIC3"),
  1362. SND_SOC_DAPM_INPUT("IN1_HPHL"),
  1363. SND_SOC_DAPM_INPUT("IN2_HPHR"),
  1364. SND_SOC_DAPM_INPUT("IN3_AUX"),
  1365. /*tx widgets*/
  1366. SND_SOC_DAPM_ADC_E("ADC1", NULL, SND_SOC_NOPM, 0, 0,
  1367. wcd937x_codec_enable_adc,
  1368. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1369. SND_SOC_DAPM_ADC_E("ADC2", NULL, SND_SOC_NOPM, 1, 0,
  1370. wcd937x_codec_enable_adc,
  1371. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1372. SND_SOC_DAPM_MIXER_E("ADC1 REQ", SND_SOC_NOPM, 0, 0,
  1373. NULL, 0, wcd937x_enable_req,
  1374. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1375. SND_SOC_DAPM_MIXER_E("ADC2 REQ", SND_SOC_NOPM, 0, 0,
  1376. NULL, 0, wcd937x_enable_req,
  1377. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1378. SND_SOC_DAPM_MUX("ADC2 MUX", SND_SOC_NOPM, 0, 0,
  1379. &tx_adc2_mux),
  1380. /*tx mixers*/
  1381. SND_SOC_DAPM_MIXER_E("ADC1_MIXER", SND_SOC_NOPM, 0, 0,
  1382. adc1_switch, ARRAY_SIZE(adc1_switch),
  1383. wcd937x_tx_swr_ctrl, SND_SOC_DAPM_PRE_PMU |
  1384. SND_SOC_DAPM_POST_PMD),
  1385. SND_SOC_DAPM_MIXER_E("ADC2_MIXER", SND_SOC_NOPM, 0, 0,
  1386. adc2_switch, ARRAY_SIZE(adc2_switch),
  1387. wcd937x_tx_swr_ctrl, SND_SOC_DAPM_PRE_PMU |
  1388. SND_SOC_DAPM_POST_PMD),
  1389. /* micbias widgets*/
  1390. SND_SOC_DAPM_MICBIAS_E("MIC BIAS1", SND_SOC_NOPM, 0, 0,
  1391. wcd937x_codec_enable_micbias,
  1392. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1393. SND_SOC_DAPM_POST_PMD),
  1394. SND_SOC_DAPM_MICBIAS_E("MIC BIAS2", SND_SOC_NOPM, 0, 0,
  1395. wcd937x_codec_enable_micbias,
  1396. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1397. SND_SOC_DAPM_POST_PMD),
  1398. SND_SOC_DAPM_MICBIAS_E("MIC BIAS3", SND_SOC_NOPM, 0, 0,
  1399. wcd937x_codec_enable_micbias,
  1400. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1401. SND_SOC_DAPM_POST_PMD),
  1402. SND_SOC_DAPM_SUPPLY("VDD_BUCK", SND_SOC_NOPM, 0, 0,
  1403. wcd937x_codec_enable_vdd_buck,
  1404. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1405. /*rx widgets*/
  1406. SND_SOC_DAPM_PGA_E("EAR PGA", WCD937X_ANA_EAR, 7, 0, NULL, 0,
  1407. wcd937x_codec_enable_ear_pa,
  1408. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1409. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1410. SND_SOC_DAPM_PGA_E("AUX PGA", WCD937X_AUX_AUXPA, 7, 0, NULL, 0,
  1411. wcd937x_codec_enable_aux_pa,
  1412. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1413. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1414. SND_SOC_DAPM_PGA_E("HPHL PGA", WCD937X_ANA_HPH, 7, 0, NULL, 0,
  1415. wcd937x_codec_enable_hphl_pa,
  1416. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1417. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1418. SND_SOC_DAPM_PGA_E("HPHR PGA", WCD937X_ANA_HPH, 6, 0, NULL, 0,
  1419. wcd937x_codec_enable_hphr_pa,
  1420. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1421. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1422. SND_SOC_DAPM_DAC_E("RDAC1", NULL, SND_SOC_NOPM, 0, 0,
  1423. wcd937x_codec_hphl_dac_event,
  1424. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1425. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1426. SND_SOC_DAPM_DAC_E("RDAC2", NULL, SND_SOC_NOPM, 0, 0,
  1427. wcd937x_codec_hphr_dac_event,
  1428. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1429. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1430. SND_SOC_DAPM_DAC_E("RDAC3", NULL, SND_SOC_NOPM, 0, 0,
  1431. wcd937x_codec_ear_dac_event,
  1432. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1433. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1434. SND_SOC_DAPM_DAC_E("RDAC4", NULL, SND_SOC_NOPM, 0, 0,
  1435. wcd937x_codec_aux_dac_event,
  1436. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
  1437. SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD),
  1438. SND_SOC_DAPM_MUX("RDAC3_MUX", SND_SOC_NOPM, 0, 0, &rx_rdac3_mux),
  1439. SND_SOC_DAPM_MIXER_E("RX1", SND_SOC_NOPM, 0, 0, NULL, 0,
  1440. wcd937x_enable_rx1, SND_SOC_DAPM_PRE_PMU |
  1441. SND_SOC_DAPM_POST_PMD),
  1442. SND_SOC_DAPM_MIXER_E("RX2", SND_SOC_NOPM, 0, 0, NULL, 0,
  1443. wcd937x_enable_rx2, SND_SOC_DAPM_PRE_PMU |
  1444. SND_SOC_DAPM_POST_PMD),
  1445. SND_SOC_DAPM_MIXER_E("RX3", SND_SOC_NOPM, 0, 0, NULL, 0,
  1446. wcd937x_enable_rx3, SND_SOC_DAPM_PRE_PMU |
  1447. SND_SOC_DAPM_POST_PMD),
  1448. /* rx mixer widgets*/
  1449. SND_SOC_DAPM_MIXER("EAR_RDAC", SND_SOC_NOPM, 0, 0,
  1450. ear_rdac_switch, ARRAY_SIZE(ear_rdac_switch)),
  1451. SND_SOC_DAPM_MIXER("AUX_RDAC", SND_SOC_NOPM, 0, 0,
  1452. aux_rdac_switch, ARRAY_SIZE(aux_rdac_switch)),
  1453. SND_SOC_DAPM_MIXER("HPHL_RDAC", SND_SOC_NOPM, 0, 0,
  1454. hphl_rdac_switch, ARRAY_SIZE(hphl_rdac_switch)),
  1455. SND_SOC_DAPM_MIXER("HPHR_RDAC", SND_SOC_NOPM, 0, 0,
  1456. hphr_rdac_switch, ARRAY_SIZE(hphr_rdac_switch)),
  1457. /*output widgets tx*/
  1458. SND_SOC_DAPM_OUTPUT("ADC1_OUTPUT"),
  1459. SND_SOC_DAPM_OUTPUT("ADC2_OUTPUT"),
  1460. /*output widgets rx*/
  1461. SND_SOC_DAPM_OUTPUT("EAR"),
  1462. SND_SOC_DAPM_OUTPUT("AUX"),
  1463. SND_SOC_DAPM_OUTPUT("HPHL"),
  1464. SND_SOC_DAPM_OUTPUT("HPHR"),
  1465. };
  1466. static const struct snd_soc_dapm_widget wcd9375_dapm_widgets[] = {
  1467. /*input widgets*/
  1468. SND_SOC_DAPM_INPUT("AMIC4"),
  1469. /*tx widgets*/
  1470. SND_SOC_DAPM_ADC_E("ADC3", NULL, SND_SOC_NOPM, 2, 0,
  1471. wcd937x_codec_enable_adc,
  1472. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1473. SND_SOC_DAPM_MIXER_E("ADC3 REQ", SND_SOC_NOPM, 0, 0,
  1474. NULL, 0, wcd937x_enable_req,
  1475. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1476. SND_SOC_DAPM_ADC_E("DMIC1", NULL, SND_SOC_NOPM, 0, 0,
  1477. wcd937x_codec_enable_dmic,
  1478. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1479. SND_SOC_DAPM_ADC_E("DMIC2", NULL, SND_SOC_NOPM, 1, 0,
  1480. wcd937x_codec_enable_dmic,
  1481. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1482. SND_SOC_DAPM_ADC_E("DMIC3", NULL, SND_SOC_NOPM, 2, 0,
  1483. wcd937x_codec_enable_dmic,
  1484. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1485. SND_SOC_DAPM_ADC_E("DMIC4", NULL, SND_SOC_NOPM, 3, 0,
  1486. wcd937x_codec_enable_dmic,
  1487. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1488. SND_SOC_DAPM_ADC_E("DMIC5", NULL, SND_SOC_NOPM, 4, 0,
  1489. wcd937x_codec_enable_dmic,
  1490. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1491. SND_SOC_DAPM_ADC_E("DMIC6", NULL, SND_SOC_NOPM, 5, 0,
  1492. wcd937x_codec_enable_dmic,
  1493. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1494. /*tx mixer widgets*/
  1495. SND_SOC_DAPM_MIXER_E("DMIC1_MIXER", SND_SOC_NOPM, 0,
  1496. 0, dmic1_switch, ARRAY_SIZE(dmic1_switch),
  1497. wcd937x_tx_swr_ctrl, SND_SOC_DAPM_PRE_PMU |
  1498. SND_SOC_DAPM_POST_PMD),
  1499. SND_SOC_DAPM_MIXER_E("DMIC2_MIXER", SND_SOC_NOPM, 0,
  1500. 0, dmic2_switch, ARRAY_SIZE(dmic2_switch),
  1501. wcd937x_tx_swr_ctrl, SND_SOC_DAPM_PRE_PMU |
  1502. SND_SOC_DAPM_POST_PMD),
  1503. SND_SOC_DAPM_MIXER_E("DMIC3_MIXER", SND_SOC_NOPM, 0,
  1504. 0, dmic3_switch, ARRAY_SIZE(dmic3_switch),
  1505. wcd937x_tx_swr_ctrl, SND_SOC_DAPM_PRE_PMU |
  1506. SND_SOC_DAPM_POST_PMD),
  1507. SND_SOC_DAPM_MIXER_E("DMIC4_MIXER", SND_SOC_NOPM, 0,
  1508. 0, dmic4_switch, ARRAY_SIZE(dmic4_switch),
  1509. wcd937x_tx_swr_ctrl, SND_SOC_DAPM_PRE_PMU |
  1510. SND_SOC_DAPM_POST_PMD),
  1511. SND_SOC_DAPM_MIXER_E("DMIC5_MIXER", SND_SOC_NOPM, 0,
  1512. 0, dmic5_switch, ARRAY_SIZE(dmic5_switch),
  1513. wcd937x_tx_swr_ctrl, SND_SOC_DAPM_PRE_PMU |
  1514. SND_SOC_DAPM_POST_PMD),
  1515. SND_SOC_DAPM_MIXER_E("DMIC6_MIXER", SND_SOC_NOPM, 0,
  1516. 0, dmic6_switch, ARRAY_SIZE(dmic6_switch),
  1517. wcd937x_tx_swr_ctrl, SND_SOC_DAPM_PRE_PMU |
  1518. SND_SOC_DAPM_POST_PMD),
  1519. SND_SOC_DAPM_MIXER_E("ADC3_MIXER", SND_SOC_NOPM, 0, 0, adc3_switch,
  1520. ARRAY_SIZE(adc3_switch), wcd937x_tx_swr_ctrl,
  1521. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  1522. /*output widgets*/
  1523. SND_SOC_DAPM_OUTPUT("DMIC1_OUTPUT"),
  1524. SND_SOC_DAPM_OUTPUT("DMIC2_OUTPUT"),
  1525. SND_SOC_DAPM_OUTPUT("DMIC3_OUTPUT"),
  1526. SND_SOC_DAPM_OUTPUT("DMIC4_OUTPUT"),
  1527. SND_SOC_DAPM_OUTPUT("DMIC5_OUTPUT"),
  1528. SND_SOC_DAPM_OUTPUT("DMIC6_OUTPUT"),
  1529. SND_SOC_DAPM_OUTPUT("ADC3_OUTPUT"),
  1530. };
  1531. static const struct snd_soc_dapm_route wcd937x_audio_map[] = {
  1532. {"ADC1_OUTPUT", NULL, "ADC1_MIXER"},
  1533. {"ADC1_MIXER", "Switch", "ADC1 REQ"},
  1534. {"ADC1 REQ", NULL, "ADC1"},
  1535. {"ADC1", NULL, "AMIC1"},
  1536. {"ADC2_OUTPUT", NULL, "ADC2_MIXER"},
  1537. {"ADC2_MIXER", "Switch", "ADC2 REQ"},
  1538. {"ADC2 REQ", NULL, "ADC2"},
  1539. {"ADC2", NULL, "ADC2 MUX"},
  1540. {"ADC2 MUX", "INP3", "AMIC3"},
  1541. {"ADC2 MUX", "INP2", "AMIC2"},
  1542. {"RX1", NULL, "IN1_HPHL"},
  1543. {"RDAC1", NULL, "RX1"},
  1544. {"HPHL_RDAC", "Switch", "RDAC1"},
  1545. {"HPHL PGA", NULL, "HPHL_RDAC"},
  1546. {"HPHL", NULL, "HPHL PGA"},
  1547. {"RX2", NULL, "IN2_HPHR"},
  1548. {"RDAC2", NULL, "RX2"},
  1549. {"HPHR_RDAC", "Switch", "RDAC2"},
  1550. {"HPHR PGA", NULL, "HPHR_RDAC"},
  1551. {"HPHR", NULL, "HPHR PGA"},
  1552. {"RX3", NULL, "IN3_AUX"},
  1553. {"RDAC4", NULL, "RX3"},
  1554. {"AUX_RDAC", "Switch", "RDAC4"},
  1555. {"AUX PGA", NULL, "AUX_RDAC"},
  1556. {"AUX", NULL, "AUX PGA"},
  1557. {"RDAC3_MUX", "RX3", "RX3"},
  1558. {"RDAC3_MUX", "RX1", "RX1"},
  1559. {"RDAC3", NULL, "RDAC3_MUX"},
  1560. {"EAR_RDAC", "Switch", "RDAC3"},
  1561. {"EAR PGA", NULL, "EAR_RDAC"},
  1562. {"EAR", NULL, "EAR PGA"},
  1563. {"EAR", NULL, "VDD_BUCK"},
  1564. {"HPHR", NULL, "VDD_BUCK"},
  1565. {"HPHL", NULL, "VDD_BUCK"},
  1566. {"AUX", NULL, "VDD_BUCK"},
  1567. };
  1568. static const struct snd_soc_dapm_route wcd9375_audio_map[] = {
  1569. {"ADC3_OUTPUT", NULL, "ADC3_MIXER"},
  1570. {"ADC3_MIXER", "Switch", "ADC3 REQ"},
  1571. {"ADC3 REQ", NULL, "ADC3"},
  1572. {"ADC3", NULL, "AMIC4"},
  1573. {"DMIC1_OUTPUT", NULL, "DMIC1_MIXER"},
  1574. {"DMIC1_MIXER", "Switch", "DMIC1"},
  1575. {"DMIC2_OUTPUT", NULL, "DMIC2_MIXER"},
  1576. {"DMIC2_MIXER", "Switch", "DMIC2"},
  1577. {"DMIC3_OUTPUT", NULL, "DMIC3_MIXER"},
  1578. {"DMIC3_MIXER", "Switch", "DMIC3"},
  1579. {"DMIC4_OUTPUT", NULL, "DMIC4_MIXER"},
  1580. {"DMIC4_MIXER", "Switch", "DMIC4"},
  1581. {"DMIC5_OUTPUT", NULL, "DMIC5_MIXER"},
  1582. {"DMIC5_MIXER", "Switch", "DMIC5"},
  1583. {"DMIC6_OUTPUT", NULL, "DMIC6_MIXER"},
  1584. {"DMIC6_MIXER", "Switch", "DMIC6"},
  1585. };
  1586. static ssize_t wcd937x_version_read(struct snd_info_entry *entry,
  1587. void *file_private_data,
  1588. struct file *file,
  1589. char __user *buf, size_t count,
  1590. loff_t pos)
  1591. {
  1592. struct wcd937x_priv *priv;
  1593. char buffer[WCD937X_VERSION_ENTRY_SIZE];
  1594. int len = 0;
  1595. priv = (struct wcd937x_priv *) entry->private_data;
  1596. if (!priv) {
  1597. pr_err("%s: wcd937x priv is null\n", __func__);
  1598. return -EINVAL;
  1599. }
  1600. switch (priv->version) {
  1601. case WCD937X_VERSION_1_0:
  1602. len = snprintf(buffer, sizeof(buffer), "WCD937X_1_0\n");
  1603. break;
  1604. default:
  1605. len = snprintf(buffer, sizeof(buffer), "VER_UNDEFINED\n");
  1606. }
  1607. return simple_read_from_buffer(buf, count, &pos, buffer, len);
  1608. }
  1609. static struct snd_info_entry_ops wcd937x_info_ops = {
  1610. .read = wcd937x_version_read,
  1611. };
  1612. /*
  1613. * wcd937x_info_create_codec_entry - creates wcd937x module
  1614. * @codec_root: The parent directory
  1615. * @codec: Codec instance
  1616. *
  1617. * Creates wcd937x module and version entry under the given
  1618. * parent directory.
  1619. *
  1620. * Return: 0 on success or negative error code on failure.
  1621. */
  1622. int wcd937x_info_create_codec_entry(struct snd_info_entry *codec_root,
  1623. struct snd_soc_codec *codec)
  1624. {
  1625. struct snd_info_entry *version_entry;
  1626. struct wcd937x_priv *priv;
  1627. struct snd_soc_card *card;
  1628. if (!codec_root || !codec)
  1629. return -EINVAL;
  1630. priv = snd_soc_codec_get_drvdata(codec);
  1631. if (priv->entry) {
  1632. dev_dbg(priv->dev,
  1633. "%s:wcd937x module already created\n", __func__);
  1634. return 0;
  1635. }
  1636. card = codec->component.card;
  1637. priv->entry = snd_info_create_subdir(codec_root->module,
  1638. "wcd937x", codec_root);
  1639. if (!priv->entry) {
  1640. dev_dbg(codec->dev, "%s: failed to create wcd937x entry\n",
  1641. __func__);
  1642. return -ENOMEM;
  1643. }
  1644. version_entry = snd_info_create_card_entry(card->snd_card,
  1645. "version",
  1646. priv->entry);
  1647. if (!version_entry) {
  1648. dev_dbg(codec->dev, "%s: failed to create wcd937x version entry\n",
  1649. __func__);
  1650. return -ENOMEM;
  1651. }
  1652. version_entry->private_data = priv;
  1653. version_entry->size = WCD937X_VERSION_ENTRY_SIZE;
  1654. version_entry->content = SNDRV_INFO_CONTENT_DATA;
  1655. version_entry->c.ops = &wcd937x_info_ops;
  1656. if (snd_info_register(version_entry) < 0) {
  1657. snd_info_free_entry(version_entry);
  1658. return -ENOMEM;
  1659. }
  1660. priv->version_entry = version_entry;
  1661. return 0;
  1662. }
  1663. EXPORT_SYMBOL(wcd937x_info_create_codec_entry);
  1664. static int wcd937x_soc_codec_probe(struct snd_soc_codec *codec)
  1665. {
  1666. struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec);
  1667. struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
  1668. int variant;
  1669. int ret = -EINVAL;
  1670. dev_info(codec->dev, "%s()\n", __func__);
  1671. wcd937x = snd_soc_codec_get_drvdata(codec);
  1672. if (!wcd937x)
  1673. return -EINVAL;
  1674. wcd937x->codec = codec;
  1675. variant = (snd_soc_read(codec, WCD937X_DIGITAL_EFUSE_REG_0) & 0x0E) >> 1;
  1676. wcd937x->variant = variant;
  1677. wcd937x->fw_data = devm_kzalloc(codec->dev,
  1678. sizeof(*(wcd937x->fw_data)),
  1679. GFP_KERNEL);
  1680. if (!wcd937x->fw_data) {
  1681. dev_err(codec->dev, "Failed to allocate fw_data\n");
  1682. ret = -ENOMEM;
  1683. goto err;
  1684. }
  1685. set_bit(WCD9XXX_MBHC_CAL, wcd937x->fw_data->cal_bit);
  1686. ret = wcd_cal_create_hwdep(wcd937x->fw_data,
  1687. WCD9XXX_CODEC_HWDEP_NODE, codec);
  1688. if (ret < 0) {
  1689. dev_err(codec->dev, "%s hwdep failed %d\n", __func__, ret);
  1690. goto err_hwdep;
  1691. }
  1692. ret = wcd937x_mbhc_init(&wcd937x->mbhc, codec, wcd937x->fw_data);
  1693. if (ret) {
  1694. pr_err("%s: mbhc initialization failed\n", __func__);
  1695. goto err_hwdep;
  1696. }
  1697. snd_soc_dapm_ignore_suspend(dapm, "AMIC1");
  1698. snd_soc_dapm_ignore_suspend(dapm, "AMIC2");
  1699. snd_soc_dapm_ignore_suspend(dapm, "AMIC3");
  1700. snd_soc_dapm_ignore_suspend(dapm, "IN1_HPHL");
  1701. snd_soc_dapm_ignore_suspend(dapm, "IN2_HPHR");
  1702. snd_soc_dapm_ignore_suspend(dapm, "IN3_AUX");
  1703. snd_soc_dapm_ignore_suspend(dapm, "ADC1_OUTPUT");
  1704. snd_soc_dapm_ignore_suspend(dapm, "ADC2_OUTPUT");
  1705. snd_soc_dapm_ignore_suspend(dapm, "EAR");
  1706. snd_soc_dapm_ignore_suspend(dapm, "AUX");
  1707. snd_soc_dapm_ignore_suspend(dapm, "HPHL");
  1708. snd_soc_dapm_ignore_suspend(dapm, "HPHR");
  1709. snd_soc_dapm_sync(dapm);
  1710. wcd937x_init_reg(codec);
  1711. if (wcd937x->variant == WCD9375_VARIANT) {
  1712. ret = snd_soc_dapm_new_controls(dapm, wcd9375_dapm_widgets,
  1713. ARRAY_SIZE(wcd9375_dapm_widgets));
  1714. if (ret < 0) {
  1715. dev_err(codec->dev, "%s: Failed to add snd_ctls\n",
  1716. __func__);
  1717. goto err_hwdep;
  1718. }
  1719. ret = snd_soc_dapm_add_routes(dapm, wcd9375_audio_map,
  1720. ARRAY_SIZE(wcd9375_audio_map));
  1721. if (ret < 0) {
  1722. dev_err(codec->dev, "%s: Failed to add routes\n",
  1723. __func__);
  1724. goto err_hwdep;
  1725. }
  1726. snd_soc_dapm_ignore_suspend(dapm, "AMIC4");
  1727. snd_soc_dapm_ignore_suspend(dapm, "DMIC1_OUTPUT");
  1728. snd_soc_dapm_ignore_suspend(dapm, "DMIC2_OUTPUT");
  1729. snd_soc_dapm_ignore_suspend(dapm, "DMIC3_OUTPUT");
  1730. snd_soc_dapm_ignore_suspend(dapm, "DMIC4_OUTPUT");
  1731. snd_soc_dapm_ignore_suspend(dapm, "DMIC5_OUTPUT");
  1732. snd_soc_dapm_ignore_suspend(dapm, "DMIC6_OUTPUT");
  1733. snd_soc_dapm_ignore_suspend(dapm, "ADC3_OUTPUT");
  1734. snd_soc_dapm_sync(dapm);
  1735. }
  1736. wcd937x->version = WCD937X_VERSION_1_0;
  1737. /* Register event notifier */
  1738. wcd937x->nblock.notifier_call = wcd937x_event_notify;
  1739. if (wcd937x->register_notifier) {
  1740. ret = wcd937x->register_notifier(wcd937x->handle,
  1741. &wcd937x->nblock,
  1742. true);
  1743. if (ret) {
  1744. dev_err(codec->dev,
  1745. "%s: Failed to register notifier %d\n",
  1746. __func__, ret);
  1747. return ret;
  1748. }
  1749. }
  1750. return ret;
  1751. err_hwdep:
  1752. wcd937x->fw_data = NULL;
  1753. err:
  1754. return ret;
  1755. }
  1756. static int wcd937x_soc_codec_remove(struct snd_soc_codec *codec)
  1757. {
  1758. struct wcd937x_priv *wcd937x = snd_soc_codec_get_drvdata(codec);
  1759. if (!wcd937x)
  1760. return -EINVAL;
  1761. if (wcd937x->register_notifier)
  1762. return wcd937x->register_notifier(wcd937x->handle,
  1763. &wcd937x->nblock,
  1764. false);
  1765. return 0;
  1766. }
  1767. static struct regmap *wcd937x_get_regmap(struct device *dev)
  1768. {
  1769. struct wcd937x_priv *wcd937x = dev_get_drvdata(dev);
  1770. return wcd937x->regmap;
  1771. }
  1772. static struct snd_soc_codec_driver soc_codec_dev_wcd937x = {
  1773. .probe = wcd937x_soc_codec_probe,
  1774. .remove = wcd937x_soc_codec_remove,
  1775. .get_regmap = wcd937x_get_regmap,
  1776. .component_driver = {
  1777. .controls = wcd937x_snd_controls,
  1778. .num_controls = ARRAY_SIZE(wcd937x_snd_controls),
  1779. .dapm_widgets = wcd937x_dapm_widgets,
  1780. .num_dapm_widgets = ARRAY_SIZE(wcd937x_dapm_widgets),
  1781. .dapm_routes = wcd937x_audio_map,
  1782. .num_dapm_routes = ARRAY_SIZE(wcd937x_audio_map),
  1783. },
  1784. };
  1785. static int wcd937x_reset(struct device *dev)
  1786. {
  1787. struct wcd937x_priv *wcd937x = NULL;
  1788. int rc = 0;
  1789. int value = 0;
  1790. if (!dev)
  1791. return -ENODEV;
  1792. wcd937x = dev_get_drvdata(dev);
  1793. if (!wcd937x)
  1794. return -EINVAL;
  1795. if (!wcd937x->rst_np) {
  1796. dev_err(dev, "%s: reset gpio device node not specified\n",
  1797. __func__);
  1798. return -EINVAL;
  1799. }
  1800. value = msm_cdc_pinctrl_get_state(wcd937x->rst_np);
  1801. if (value > 0)
  1802. return 0;
  1803. rc = msm_cdc_pinctrl_select_sleep_state(wcd937x->rst_np);
  1804. if (rc) {
  1805. dev_err(dev, "%s: wcd sleep state request fail!\n",
  1806. __func__);
  1807. return rc;
  1808. }
  1809. /* 20ms sleep required after pulling the reset gpio to LOW */
  1810. usleep_range(20, 30);
  1811. rc = msm_cdc_pinctrl_select_active_state(wcd937x->rst_np);
  1812. if (rc) {
  1813. dev_err(dev, "%s: wcd active state request fail!\n",
  1814. __func__);
  1815. return rc;
  1816. }
  1817. /* 20ms sleep required after pulling the reset gpio to HIGH */
  1818. usleep_range(20, 30);
  1819. return rc;
  1820. }
  1821. static int wcd937x_read_of_property_u32(struct device *dev, const char *name,
  1822. u32 *val)
  1823. {
  1824. int rc = 0;
  1825. rc = of_property_read_u32(dev->of_node, name, val);
  1826. if (rc)
  1827. dev_err(dev, "%s: Looking up %s property in node %s failed\n",
  1828. __func__, name, dev->of_node->full_name);
  1829. return rc;
  1830. }
  1831. static void wcd937x_dt_parse_micbias_info(struct device *dev,
  1832. struct wcd937x_micbias_setting *mb)
  1833. {
  1834. u32 prop_val = 0;
  1835. int rc = 0;
  1836. /* MB1 */
  1837. if (of_find_property(dev->of_node, "qcom,cdc-micbias1-mv",
  1838. NULL)) {
  1839. rc = wcd937x_read_of_property_u32(dev,
  1840. "qcom,cdc-micbias1-mv",
  1841. &prop_val);
  1842. if (!rc)
  1843. mb->micb1_mv = prop_val;
  1844. } else {
  1845. dev_info(dev, "%s: Micbias1 DT property not found\n",
  1846. __func__);
  1847. }
  1848. /* MB2 */
  1849. if (of_find_property(dev->of_node, "qcom,cdc-micbias2-mv",
  1850. NULL)) {
  1851. rc = wcd937x_read_of_property_u32(dev,
  1852. "qcom,cdc-micbias2-mv",
  1853. &prop_val);
  1854. if (!rc)
  1855. mb->micb2_mv = prop_val;
  1856. } else {
  1857. dev_info(dev, "%s: Micbias2 DT property not found\n",
  1858. __func__);
  1859. }
  1860. /* MB3 */
  1861. if (of_find_property(dev->of_node, "qcom,cdc-micbias3-mv",
  1862. NULL)) {
  1863. rc = wcd937x_read_of_property_u32(dev,
  1864. "qcom,cdc-micbias3-mv",
  1865. &prop_val);
  1866. if (!rc)
  1867. mb->micb3_mv = prop_val;
  1868. } else {
  1869. dev_info(dev, "%s: Micbias3 DT property not found\n",
  1870. __func__);
  1871. }
  1872. }
  1873. static int wcd937x_reset_low(struct device *dev)
  1874. {
  1875. struct wcd937x_priv *wcd937x = NULL;
  1876. int rc = 0;
  1877. if (!dev)
  1878. return -ENODEV;
  1879. wcd937x = dev_get_drvdata(dev);
  1880. if (!wcd937x)
  1881. return -EINVAL;
  1882. if (!wcd937x->rst_np) {
  1883. dev_err(dev, "%s: reset gpio device node not specified\n",
  1884. __func__);
  1885. return -EINVAL;
  1886. }
  1887. rc = msm_cdc_pinctrl_select_sleep_state(wcd937x->rst_np);
  1888. if (rc) {
  1889. dev_err(dev, "%s: wcd sleep state request fail!\n",
  1890. __func__);
  1891. return rc;
  1892. }
  1893. /* 20ms sleep required after pulling the reset gpio to LOW */
  1894. usleep_range(20, 30);
  1895. return rc;
  1896. }
  1897. struct wcd937x_pdata *wcd937x_populate_dt_data(struct device *dev)
  1898. {
  1899. struct wcd937x_pdata *pdata = NULL;
  1900. pdata = devm_kzalloc(dev, sizeof(struct wcd937x_pdata),
  1901. GFP_KERNEL);
  1902. if (!pdata)
  1903. return NULL;
  1904. pdata->rst_np = of_parse_phandle(dev->of_node,
  1905. "qcom,wcd-rst-gpio-node", 0);
  1906. if (!pdata->rst_np) {
  1907. dev_err(dev, "%s: Looking up %s property in node %s failed\n",
  1908. __func__, "qcom,wcd-rst-gpio-node",
  1909. dev->of_node->full_name);
  1910. return NULL;
  1911. }
  1912. /* Parse power supplies */
  1913. msm_cdc_get_power_supplies(dev, &pdata->regulator,
  1914. &pdata->num_supplies);
  1915. if (!pdata->regulator || (pdata->num_supplies <= 0)) {
  1916. dev_err(dev, "%s: no power supplies defined for codec\n",
  1917. __func__);
  1918. return NULL;
  1919. }
  1920. pdata->rx_slave = of_parse_phandle(dev->of_node, "qcom,rx-slave", 0);
  1921. pdata->tx_slave = of_parse_phandle(dev->of_node, "qcom,tx-slave", 0);
  1922. wcd937x_dt_parse_micbias_info(dev, &pdata->micbias);
  1923. return pdata;
  1924. }
  1925. static int wcd937x_bind(struct device *dev)
  1926. {
  1927. int ret = 0, i = 0;
  1928. struct wcd937x_priv *wcd937x = NULL;
  1929. struct wcd937x_pdata *pdata = NULL;
  1930. struct wcd_ctrl_platform_data *plat_data = NULL;
  1931. wcd937x = devm_kzalloc(dev, sizeof(struct wcd937x_priv), GFP_KERNEL);
  1932. if (!wcd937x)
  1933. return -ENOMEM;
  1934. dev_set_drvdata(dev, wcd937x);
  1935. pdata = wcd937x_populate_dt_data(dev);
  1936. if (!pdata) {
  1937. dev_err(dev, "%s: Fail to obtain platform data\n", __func__);
  1938. return -EINVAL;
  1939. }
  1940. wcd937x->dev = dev;
  1941. wcd937x->dev->platform_data = pdata;
  1942. wcd937x->rst_np = pdata->rst_np;
  1943. ret = msm_cdc_init_supplies(dev, &wcd937x->supplies,
  1944. pdata->regulator, pdata->num_supplies);
  1945. if (!wcd937x->supplies) {
  1946. dev_err(dev, "%s: Cannot init wcd supplies\n",
  1947. __func__);
  1948. return ret;
  1949. }
  1950. plat_data = dev_get_platdata(dev->parent);
  1951. if (!plat_data) {
  1952. dev_err(dev, "%s: platform data from parent is NULL\n",
  1953. __func__);
  1954. return -EINVAL;
  1955. }
  1956. wcd937x->handle = (void *)plat_data->handle;
  1957. if (!wcd937x->handle) {
  1958. dev_err(dev, "%s: handle is NULL\n", __func__);
  1959. return -EINVAL;
  1960. }
  1961. wcd937x->update_wcd_event = plat_data->update_wcd_event;
  1962. if (!wcd937x->update_wcd_event) {
  1963. dev_err(dev, "%s: update_wcd_event api is null!\n",
  1964. __func__);
  1965. return -EINVAL;
  1966. }
  1967. wcd937x->register_notifier = plat_data->register_notifier;
  1968. if (!wcd937x->register_notifier) {
  1969. dev_err(dev, "%s: register_notifier api is null!\n",
  1970. __func__);
  1971. return -EINVAL;
  1972. }
  1973. ret = msm_cdc_enable_static_supplies(dev, wcd937x->supplies,
  1974. pdata->regulator,
  1975. pdata->num_supplies);
  1976. if (ret) {
  1977. dev_err(dev, "%s: wcd static supply enable failed!\n",
  1978. __func__);
  1979. return ret;
  1980. }
  1981. wcd937x_reset(dev);
  1982. /*
  1983. * Add 5msec delay to provide sufficient time for
  1984. * soundwire auto enumeration of slave devices as
  1985. * as per HW requirement.
  1986. */
  1987. usleep_range(5000, 5010);
  1988. ret = component_bind_all(dev, wcd937x);
  1989. if (ret) {
  1990. dev_err(dev, "%s: Slave bind failed, ret = %d\n",
  1991. __func__, ret);
  1992. return ret;
  1993. }
  1994. ret = wcd937x_parse_port_mapping(dev, "qcom,rx_swr_ch_map", CODEC_RX);
  1995. ret |= wcd937x_parse_port_mapping(dev, "qcom,tx_swr_ch_map", CODEC_TX);
  1996. if (ret) {
  1997. dev_err(dev, "Failed to read port mapping\n");
  1998. goto err;
  1999. }
  2000. wcd937x->rx_swr_dev = get_matching_swr_slave_device(pdata->rx_slave);
  2001. if (!wcd937x->rx_swr_dev) {
  2002. dev_err(dev, "%s: Could not find RX swr slave device\n",
  2003. __func__);
  2004. ret = -ENODEV;
  2005. goto err;
  2006. }
  2007. wcd937x->tx_swr_dev = get_matching_swr_slave_device(pdata->tx_slave);
  2008. if (!wcd937x->tx_swr_dev) {
  2009. dev_err(dev, "%s: Could not find TX swr slave device\n",
  2010. __func__);
  2011. ret = -ENODEV;
  2012. goto err;
  2013. }
  2014. wcd937x->regmap = devm_regmap_init_swr(wcd937x->tx_swr_dev,
  2015. &wcd937x_regmap_config);
  2016. if (!wcd937x->regmap) {
  2017. dev_err(dev, "%s: Regmap init failed\n",
  2018. __func__);
  2019. goto err;
  2020. }
  2021. /* Set all interupts as edge triggered */
  2022. for (i = 0; i < wcd937x_regmap_irq_chip.num_regs; i++)
  2023. regmap_write(wcd937x->regmap,
  2024. (WCD937X_DIGITAL_INTR_LEVEL_0 + i), 0);
  2025. wcd937x_regmap_irq_chip.irq_drv_data = wcd937x;
  2026. wcd937x->irq_info.wcd_regmap_irq_chip = &wcd937x_regmap_irq_chip;
  2027. wcd937x->irq_info.codec_name = "WCD937X";
  2028. wcd937x->irq_info.regmap = wcd937x->regmap;
  2029. wcd937x->irq_info.dev = dev;
  2030. ret = wcd_irq_init(&wcd937x->irq_info, &wcd937x->virq);
  2031. if (ret) {
  2032. dev_err(dev, "%s: IRQ init failed: %d\n",
  2033. __func__, ret);
  2034. goto err;
  2035. }
  2036. wcd937x->tx_swr_dev->slave_irq = wcd937x->virq;
  2037. mutex_init(&wcd937x->micb_lock);
  2038. ret = snd_soc_register_codec(dev, &soc_codec_dev_wcd937x,
  2039. NULL, 0);
  2040. if (ret) {
  2041. dev_err(dev, "%s: Codec registration failed\n",
  2042. __func__);
  2043. goto err_irq;
  2044. }
  2045. return ret;
  2046. err_irq:
  2047. wcd_irq_exit(&wcd937x->irq_info, wcd937x->virq);
  2048. err:
  2049. component_unbind_all(dev, wcd937x);
  2050. return ret;
  2051. }
  2052. static void wcd937x_unbind(struct device *dev)
  2053. {
  2054. struct wcd937x_priv *wcd937x = dev_get_drvdata(dev);
  2055. wcd_irq_exit(&wcd937x->irq_info, wcd937x->virq);
  2056. snd_soc_unregister_codec(dev);
  2057. component_unbind_all(dev, wcd937x);
  2058. mutex_destroy(&wcd937x->micb_lock);
  2059. }
  2060. static const struct of_device_id wcd937x_dt_match[] = {
  2061. { .compatible = "qcom,wcd937x-codec" },
  2062. {}
  2063. };
  2064. static const struct component_master_ops wcd937x_comp_ops = {
  2065. .bind = wcd937x_bind,
  2066. .unbind = wcd937x_unbind,
  2067. };
  2068. static int wcd937x_compare_of(struct device *dev, void *data)
  2069. {
  2070. return dev->of_node == data;
  2071. }
  2072. static void wcd937x_release_of(struct device *dev, void *data)
  2073. {
  2074. of_node_put(data);
  2075. }
  2076. static int wcd937x_add_slave_components(struct device *dev,
  2077. struct component_match **matchptr)
  2078. {
  2079. struct device_node *np, *rx_node, *tx_node;
  2080. np = dev->of_node;
  2081. rx_node = of_parse_phandle(np, "qcom,rx-slave", 0);
  2082. if (!rx_node) {
  2083. dev_err(dev, "%s: Rx-slave node not defined\n", __func__);
  2084. return -ENODEV;
  2085. }
  2086. of_node_get(rx_node);
  2087. component_match_add_release(dev, matchptr,
  2088. wcd937x_release_of,
  2089. wcd937x_compare_of,
  2090. rx_node);
  2091. tx_node = of_parse_phandle(np, "qcom,tx-slave", 0);
  2092. if (!tx_node) {
  2093. dev_err(dev, "%s: Tx-slave node not defined\n", __func__);
  2094. return -ENODEV;
  2095. }
  2096. of_node_get(tx_node);
  2097. component_match_add_release(dev, matchptr,
  2098. wcd937x_release_of,
  2099. wcd937x_compare_of,
  2100. tx_node);
  2101. return 0;
  2102. }
  2103. static int wcd937x_probe(struct platform_device *pdev)
  2104. {
  2105. struct component_match *match = NULL;
  2106. int ret;
  2107. ret = wcd937x_add_slave_components(&pdev->dev, &match);
  2108. if (ret)
  2109. return ret;
  2110. return component_master_add_with_match(&pdev->dev,
  2111. &wcd937x_comp_ops, match);
  2112. }
  2113. static int wcd937x_remove(struct platform_device *pdev)
  2114. {
  2115. component_master_del(&pdev->dev, &wcd937x_comp_ops);
  2116. return 0;
  2117. }
  2118. static struct platform_driver wcd937x_codec_driver = {
  2119. .probe = wcd937x_probe,
  2120. .remove = wcd937x_remove,
  2121. .driver = {
  2122. .name = "wcd937x_codec",
  2123. .owner = THIS_MODULE,
  2124. .of_match_table = of_match_ptr(wcd937x_dt_match),
  2125. },
  2126. };
  2127. module_platform_driver(wcd937x_codec_driver);
  2128. MODULE_DESCRIPTION("WCD937X Codec driver");
  2129. MODULE_LICENSE("GPL v2");