wcd937x.c 68 KB

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