lm49453.c 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472
  1. /*
  2. * lm49453.c - LM49453 ALSA Soc Audio driver
  3. *
  4. * Copyright (c) 2012 Texas Instruments, Inc
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; version 2 of the License.
  9. *
  10. * Initially based on sound/soc/codecs/wm8350.c
  11. */
  12. #include <linux/module.h>
  13. #include <linux/moduleparam.h>
  14. #include <linux/kernel.h>
  15. #include <linux/init.h>
  16. #include <linux/delay.h>
  17. #include <linux/pm.h>
  18. #include <linux/i2c.h>
  19. #include <linux/regmap.h>
  20. #include <linux/slab.h>
  21. #include <sound/core.h>
  22. #include <sound/pcm.h>
  23. #include <sound/pcm_params.h>
  24. #include <sound/soc.h>
  25. #include <sound/soc-dapm.h>
  26. #include <sound/tlv.h>
  27. #include <sound/jack.h>
  28. #include <sound/initval.h>
  29. #include <asm/div64.h>
  30. #include "lm49453.h"
  31. static const struct reg_default lm49453_reg_defs[] = {
  32. { 0, 0x00 },
  33. { 1, 0x00 },
  34. { 2, 0x00 },
  35. { 3, 0x00 },
  36. { 4, 0x00 },
  37. { 5, 0x00 },
  38. { 6, 0x00 },
  39. { 7, 0x00 },
  40. { 8, 0x00 },
  41. { 9, 0x00 },
  42. { 10, 0x00 },
  43. { 11, 0x00 },
  44. { 12, 0x00 },
  45. { 13, 0x00 },
  46. { 14, 0x00 },
  47. { 15, 0x00 },
  48. { 16, 0x00 },
  49. { 17, 0x00 },
  50. { 18, 0x00 },
  51. { 19, 0x00 },
  52. { 20, 0x00 },
  53. { 21, 0x00 },
  54. { 22, 0x00 },
  55. { 23, 0x00 },
  56. { 32, 0x00 },
  57. { 33, 0x00 },
  58. { 35, 0x00 },
  59. { 36, 0x00 },
  60. { 37, 0x00 },
  61. { 46, 0x00 },
  62. { 48, 0x00 },
  63. { 49, 0x00 },
  64. { 51, 0x00 },
  65. { 56, 0x00 },
  66. { 58, 0x00 },
  67. { 59, 0x00 },
  68. { 60, 0x00 },
  69. { 61, 0x00 },
  70. { 62, 0x00 },
  71. { 63, 0x00 },
  72. { 64, 0x00 },
  73. { 65, 0x00 },
  74. { 66, 0x00 },
  75. { 67, 0x00 },
  76. { 68, 0x00 },
  77. { 69, 0x00 },
  78. { 70, 0x00 },
  79. { 71, 0x00 },
  80. { 72, 0x00 },
  81. { 73, 0x00 },
  82. { 74, 0x00 },
  83. { 75, 0x00 },
  84. { 76, 0x00 },
  85. { 77, 0x00 },
  86. { 78, 0x00 },
  87. { 79, 0x00 },
  88. { 80, 0x00 },
  89. { 81, 0x00 },
  90. { 82, 0x00 },
  91. { 83, 0x00 },
  92. { 85, 0x00 },
  93. { 85, 0x00 },
  94. { 86, 0x00 },
  95. { 87, 0x00 },
  96. { 88, 0x00 },
  97. { 89, 0x00 },
  98. { 90, 0x00 },
  99. { 91, 0x00 },
  100. { 92, 0x00 },
  101. { 93, 0x00 },
  102. { 94, 0x00 },
  103. { 95, 0x00 },
  104. { 96, 0x01 },
  105. { 97, 0x00 },
  106. { 98, 0x00 },
  107. { 99, 0x00 },
  108. { 100, 0x00 },
  109. { 101, 0x00 },
  110. { 102, 0x00 },
  111. { 103, 0x01 },
  112. { 104, 0x01 },
  113. { 105, 0x00 },
  114. { 106, 0x01 },
  115. { 107, 0x00 },
  116. { 108, 0x00 },
  117. { 109, 0x00 },
  118. { 110, 0x00 },
  119. { 111, 0x02 },
  120. { 112, 0x02 },
  121. { 113, 0x00 },
  122. { 121, 0x80 },
  123. { 122, 0xBB },
  124. { 123, 0x80 },
  125. { 124, 0xBB },
  126. { 128, 0x00 },
  127. { 130, 0x00 },
  128. { 131, 0x00 },
  129. { 132, 0x00 },
  130. { 133, 0x0A },
  131. { 134, 0x0A },
  132. { 135, 0x0A },
  133. { 136, 0x0F },
  134. { 137, 0x00 },
  135. { 138, 0x73 },
  136. { 139, 0x33 },
  137. { 140, 0x73 },
  138. { 141, 0x33 },
  139. { 142, 0x73 },
  140. { 143, 0x33 },
  141. { 144, 0x73 },
  142. { 145, 0x33 },
  143. { 146, 0x73 },
  144. { 147, 0x33 },
  145. { 148, 0x73 },
  146. { 149, 0x33 },
  147. { 150, 0x73 },
  148. { 151, 0x33 },
  149. { 152, 0x00 },
  150. { 153, 0x00 },
  151. { 154, 0x00 },
  152. { 155, 0x00 },
  153. { 176, 0x00 },
  154. { 177, 0x00 },
  155. { 178, 0x00 },
  156. { 179, 0x00 },
  157. { 180, 0x00 },
  158. { 181, 0x00 },
  159. { 182, 0x00 },
  160. { 183, 0x00 },
  161. { 184, 0x00 },
  162. { 185, 0x00 },
  163. { 186, 0x00 },
  164. { 187, 0x00 },
  165. { 188, 0x00 },
  166. { 189, 0x00 },
  167. { 208, 0x06 },
  168. { 209, 0x00 },
  169. { 210, 0x08 },
  170. { 211, 0x54 },
  171. { 212, 0x14 },
  172. { 213, 0x0d },
  173. { 214, 0x0d },
  174. { 215, 0x14 },
  175. { 216, 0x60 },
  176. { 221, 0x00 },
  177. { 222, 0x00 },
  178. { 223, 0x00 },
  179. { 224, 0x00 },
  180. { 248, 0x00 },
  181. { 249, 0x00 },
  182. { 250, 0x00 },
  183. { 255, 0x00 },
  184. };
  185. /* codec private data */
  186. struct lm49453_priv {
  187. struct regmap *regmap;
  188. };
  189. /* capture path controls */
  190. static const char *lm49453_mic2mode_text[] = {"Single Ended", "Differential"};
  191. static SOC_ENUM_SINGLE_DECL(lm49453_mic2mode_enum, LM49453_P0_MICR_REG, 5,
  192. lm49453_mic2mode_text);
  193. static const char *lm49453_dmic_cfg_text[] = {"DMICDAT1", "DMICDAT2"};
  194. static SOC_ENUM_SINGLE_DECL(lm49453_dmic12_cfg_enum,
  195. LM49453_P0_DIGITAL_MIC1_CONFIG_REG, 7,
  196. lm49453_dmic_cfg_text);
  197. static SOC_ENUM_SINGLE_DECL(lm49453_dmic34_cfg_enum,
  198. LM49453_P0_DIGITAL_MIC2_CONFIG_REG, 7,
  199. lm49453_dmic_cfg_text);
  200. /* MUX Controls */
  201. static const char *lm49453_adcl_mux_text[] = { "MIC1", "Aux_L" };
  202. static const char *lm49453_adcr_mux_text[] = { "MIC2", "Aux_R" };
  203. static SOC_ENUM_SINGLE_DECL(lm49453_adcl_enum,
  204. LM49453_P0_ANALOG_MIXER_ADC_REG, 0,
  205. lm49453_adcl_mux_text);
  206. static SOC_ENUM_SINGLE_DECL(lm49453_adcr_enum,
  207. LM49453_P0_ANALOG_MIXER_ADC_REG, 1,
  208. lm49453_adcr_mux_text);
  209. static const struct snd_kcontrol_new lm49453_adcl_mux_control =
  210. SOC_DAPM_ENUM("ADC Left Mux", lm49453_adcl_enum);
  211. static const struct snd_kcontrol_new lm49453_adcr_mux_control =
  212. SOC_DAPM_ENUM("ADC Right Mux", lm49453_adcr_enum);
  213. static const struct snd_kcontrol_new lm49453_headset_left_mixer[] = {
  214. SOC_DAPM_SINGLE("Port1_1 Switch", LM49453_P0_DACHPL1_REG, 0, 1, 0),
  215. SOC_DAPM_SINGLE("Port1_2 Switch", LM49453_P0_DACHPL1_REG, 1, 1, 0),
  216. SOC_DAPM_SINGLE("Port1_3 Switch", LM49453_P0_DACHPL1_REG, 2, 1, 0),
  217. SOC_DAPM_SINGLE("Port1_4 Switch", LM49453_P0_DACHPL1_REG, 3, 1, 0),
  218. SOC_DAPM_SINGLE("Port1_5 Switch", LM49453_P0_DACHPL1_REG, 4, 1, 0),
  219. SOC_DAPM_SINGLE("Port1_6 Switch", LM49453_P0_DACHPL1_REG, 5, 1, 0),
  220. SOC_DAPM_SINGLE("Port1_7 Switch", LM49453_P0_DACHPL1_REG, 6, 1, 0),
  221. SOC_DAPM_SINGLE("Port1_8 Switch", LM49453_P0_DACHPL1_REG, 7, 1, 0),
  222. SOC_DAPM_SINGLE("DMIC1L Switch", LM49453_P0_DACHPL2_REG, 0, 1, 0),
  223. SOC_DAPM_SINGLE("DMIC1R Switch", LM49453_P0_DACHPL2_REG, 1, 1, 0),
  224. SOC_DAPM_SINGLE("DMIC2L Switch", LM49453_P0_DACHPL2_REG, 2, 1, 0),
  225. SOC_DAPM_SINGLE("DMIC2R Switch", LM49453_P0_DACHPL2_REG, 3, 1, 0),
  226. SOC_DAPM_SINGLE("ADCL Switch", LM49453_P0_DACHPL2_REG, 4, 1, 0),
  227. SOC_DAPM_SINGLE("ADCR Switch", LM49453_P0_DACHPL2_REG, 5, 1, 0),
  228. SOC_DAPM_SINGLE("Port2_1 Switch", LM49453_P0_DACHPL2_REG, 6, 1, 0),
  229. SOC_DAPM_SINGLE("Port2_2 Switch", LM49453_P0_DACHPL2_REG, 7, 1, 0),
  230. SOC_DAPM_SINGLE("Sidetone Switch", LM49453_P0_STN_SEL_REG, 0, 0, 0),
  231. };
  232. static const struct snd_kcontrol_new lm49453_headset_right_mixer[] = {
  233. SOC_DAPM_SINGLE("Port1_1 Switch", LM49453_P0_DACHPR1_REG, 0, 1, 0),
  234. SOC_DAPM_SINGLE("Port1_2 Switch", LM49453_P0_DACHPR1_REG, 1, 1, 0),
  235. SOC_DAPM_SINGLE("Port1_3 Switch", LM49453_P0_DACHPR1_REG, 2, 1, 0),
  236. SOC_DAPM_SINGLE("Port1_4 Switch", LM49453_P0_DACHPR1_REG, 3, 1, 0),
  237. SOC_DAPM_SINGLE("Port1_5 Switch", LM49453_P0_DACHPR1_REG, 4, 1, 0),
  238. SOC_DAPM_SINGLE("Port1_6 Switch", LM49453_P0_DACHPR1_REG, 5, 1, 0),
  239. SOC_DAPM_SINGLE("Port1_7 Switch", LM49453_P0_DACHPR1_REG, 6, 1, 0),
  240. SOC_DAPM_SINGLE("Port1_8 Switch", LM49453_P0_DACHPR1_REG, 7, 1, 0),
  241. SOC_DAPM_SINGLE("DMIC1L Switch", LM49453_P0_DACHPR2_REG, 0, 1, 0),
  242. SOC_DAPM_SINGLE("DMIC1R Switch", LM49453_P0_DACHPR2_REG, 1, 1, 0),
  243. SOC_DAPM_SINGLE("DMIC2L Switch", LM49453_P0_DACHPR2_REG, 2, 1, 0),
  244. SOC_DAPM_SINGLE("DMIC2R Switch", LM49453_P0_DACHPR2_REG, 3, 1, 0),
  245. SOC_DAPM_SINGLE("ADCL Switch", LM49453_P0_DACHPR2_REG, 4, 1, 0),
  246. SOC_DAPM_SINGLE("ADCR Switch", LM49453_P0_DACHPR2_REG, 5, 1, 0),
  247. SOC_DAPM_SINGLE("Port2_1 Switch", LM49453_P0_DACHPR2_REG, 6, 1, 0),
  248. SOC_DAPM_SINGLE("Port2_2 Switch", LM49453_P0_DACHPR2_REG, 7, 1, 0),
  249. SOC_DAPM_SINGLE("Sidetone Switch", LM49453_P0_STN_SEL_REG, 1, 0, 0),
  250. };
  251. static const struct snd_kcontrol_new lm49453_speaker_left_mixer[] = {
  252. SOC_DAPM_SINGLE("Port1_1 Switch", LM49453_P0_DACLSL1_REG, 0, 1, 0),
  253. SOC_DAPM_SINGLE("Port1_2 Switch", LM49453_P0_DACLSL1_REG, 1, 1, 0),
  254. SOC_DAPM_SINGLE("Port1_3 Switch", LM49453_P0_DACLSL1_REG, 2, 1, 0),
  255. SOC_DAPM_SINGLE("Port1_4 Switch", LM49453_P0_DACLSL1_REG, 3, 1, 0),
  256. SOC_DAPM_SINGLE("Port1_5 Switch", LM49453_P0_DACLSL1_REG, 4, 1, 0),
  257. SOC_DAPM_SINGLE("Port1_6 Switch", LM49453_P0_DACLSL1_REG, 5, 1, 0),
  258. SOC_DAPM_SINGLE("Port1_7 Switch", LM49453_P0_DACLSL1_REG, 6, 1, 0),
  259. SOC_DAPM_SINGLE("Port1_8 Switch", LM49453_P0_DACLSL1_REG, 7, 1, 0),
  260. SOC_DAPM_SINGLE("DMIC1L Switch", LM49453_P0_DACLSL2_REG, 0, 1, 0),
  261. SOC_DAPM_SINGLE("DMIC1R Switch", LM49453_P0_DACLSL2_REG, 1, 1, 0),
  262. SOC_DAPM_SINGLE("DMIC2L Switch", LM49453_P0_DACLSL2_REG, 2, 1, 0),
  263. SOC_DAPM_SINGLE("DMIC2R Switch", LM49453_P0_DACLSL2_REG, 3, 1, 0),
  264. SOC_DAPM_SINGLE("ADCL Switch", LM49453_P0_DACLSL2_REG, 4, 1, 0),
  265. SOC_DAPM_SINGLE("ADCR Switch", LM49453_P0_DACLSL2_REG, 5, 1, 0),
  266. SOC_DAPM_SINGLE("Port2_1 Switch", LM49453_P0_DACLSL2_REG, 6, 1, 0),
  267. SOC_DAPM_SINGLE("Port2_2 Switch", LM49453_P0_DACLSL2_REG, 7, 1, 0),
  268. SOC_DAPM_SINGLE("Sidetone Switch", LM49453_P0_STN_SEL_REG, 2, 0, 0),
  269. };
  270. static const struct snd_kcontrol_new lm49453_speaker_right_mixer[] = {
  271. SOC_DAPM_SINGLE("Port1_1 Switch", LM49453_P0_DACLSR1_REG, 0, 1, 0),
  272. SOC_DAPM_SINGLE("Port1_2 Switch", LM49453_P0_DACLSR1_REG, 1, 1, 0),
  273. SOC_DAPM_SINGLE("Port1_3 Switch", LM49453_P0_DACLSR1_REG, 2, 1, 0),
  274. SOC_DAPM_SINGLE("Port1_4 Switch", LM49453_P0_DACLSR1_REG, 3, 1, 0),
  275. SOC_DAPM_SINGLE("Port1_5 Switch", LM49453_P0_DACLSR1_REG, 4, 1, 0),
  276. SOC_DAPM_SINGLE("Port1_6 Switch", LM49453_P0_DACLSR1_REG, 5, 1, 0),
  277. SOC_DAPM_SINGLE("Port1_7 Switch", LM49453_P0_DACLSR1_REG, 6, 1, 0),
  278. SOC_DAPM_SINGLE("Port1_8 Switch", LM49453_P0_DACLSR1_REG, 7, 1, 0),
  279. SOC_DAPM_SINGLE("DMIC1L Switch", LM49453_P0_DACLSR2_REG, 0, 1, 0),
  280. SOC_DAPM_SINGLE("DMIC1R Switch", LM49453_P0_DACLSR2_REG, 1, 1, 0),
  281. SOC_DAPM_SINGLE("DMIC2L Switch", LM49453_P0_DACLSR2_REG, 2, 1, 0),
  282. SOC_DAPM_SINGLE("DMIC2R Switch", LM49453_P0_DACLSR2_REG, 3, 1, 0),
  283. SOC_DAPM_SINGLE("ADCL Switch", LM49453_P0_DACLSR2_REG, 4, 1, 0),
  284. SOC_DAPM_SINGLE("ADCR Switch", LM49453_P0_DACLSR2_REG, 5, 1, 0),
  285. SOC_DAPM_SINGLE("Port2_1 Switch", LM49453_P0_DACLSR2_REG, 6, 1, 0),
  286. SOC_DAPM_SINGLE("Port2_2 Switch", LM49453_P0_DACLSR2_REG, 7, 1, 0),
  287. SOC_DAPM_SINGLE("Sidetone Switch", LM49453_P0_STN_SEL_REG, 3, 0, 0),
  288. };
  289. static const struct snd_kcontrol_new lm49453_haptic_left_mixer[] = {
  290. SOC_DAPM_SINGLE("Port1_1 Switch", LM49453_P0_DACHAL1_REG, 0, 1, 0),
  291. SOC_DAPM_SINGLE("Port1_2 Switch", LM49453_P0_DACHAL1_REG, 1, 1, 0),
  292. SOC_DAPM_SINGLE("Port1_3 Switch", LM49453_P0_DACHAL1_REG, 2, 1, 0),
  293. SOC_DAPM_SINGLE("Port1_4 Switch", LM49453_P0_DACHAL1_REG, 3, 1, 0),
  294. SOC_DAPM_SINGLE("Port1_5 Switch", LM49453_P0_DACHAL1_REG, 4, 1, 0),
  295. SOC_DAPM_SINGLE("Port1_6 Switch", LM49453_P0_DACHAL1_REG, 5, 1, 0),
  296. SOC_DAPM_SINGLE("Port1_7 Switch", LM49453_P0_DACHAL1_REG, 6, 1, 0),
  297. SOC_DAPM_SINGLE("Port1_8 Switch", LM49453_P0_DACHAL1_REG, 7, 1, 0),
  298. SOC_DAPM_SINGLE("DMIC1L Switch", LM49453_P0_DACHAL2_REG, 0, 1, 0),
  299. SOC_DAPM_SINGLE("DMIC1R Switch", LM49453_P0_DACHAL2_REG, 1, 1, 0),
  300. SOC_DAPM_SINGLE("DMIC2L Switch", LM49453_P0_DACHAL2_REG, 2, 1, 0),
  301. SOC_DAPM_SINGLE("DMIC2R Switch", LM49453_P0_DACHAL2_REG, 3, 1, 0),
  302. SOC_DAPM_SINGLE("ADCL Switch", LM49453_P0_DACHAL2_REG, 4, 1, 0),
  303. SOC_DAPM_SINGLE("ADCR Switch", LM49453_P0_DACHAL2_REG, 5, 1, 0),
  304. SOC_DAPM_SINGLE("Port2_1 Switch", LM49453_P0_DACHAL2_REG, 6, 1, 0),
  305. SOC_DAPM_SINGLE("Port2_2 Switch", LM49453_P0_DACHAL2_REG, 7, 1, 0),
  306. SOC_DAPM_SINGLE("Sidetone Switch", LM49453_P0_STN_SEL_REG, 4, 0, 0),
  307. };
  308. static const struct snd_kcontrol_new lm49453_haptic_right_mixer[] = {
  309. SOC_DAPM_SINGLE("Port1_1 Switch", LM49453_P0_DACHAR1_REG, 0, 1, 0),
  310. SOC_DAPM_SINGLE("Port1_2 Switch", LM49453_P0_DACHAR1_REG, 1, 1, 0),
  311. SOC_DAPM_SINGLE("Port1_3 Switch", LM49453_P0_DACHAR1_REG, 2, 1, 0),
  312. SOC_DAPM_SINGLE("Port1_4 Switch", LM49453_P0_DACHAR1_REG, 3, 1, 0),
  313. SOC_DAPM_SINGLE("Port1_5 Switch", LM49453_P0_DACHAR1_REG, 4, 1, 0),
  314. SOC_DAPM_SINGLE("Port1_6 Switch", LM49453_P0_DACHAR1_REG, 5, 1, 0),
  315. SOC_DAPM_SINGLE("Port1_7 Switch", LM49453_P0_DACHAR1_REG, 6, 1, 0),
  316. SOC_DAPM_SINGLE("Port1_8 Switch", LM49453_P0_DACHAR1_REG, 7, 1, 0),
  317. SOC_DAPM_SINGLE("DMIC1L Switch", LM49453_P0_DACHAR2_REG, 0, 1, 0),
  318. SOC_DAPM_SINGLE("DMIC1R Switch", LM49453_P0_DACHAR2_REG, 1, 1, 0),
  319. SOC_DAPM_SINGLE("DMIC2L Switch", LM49453_P0_DACHAR2_REG, 2, 1, 0),
  320. SOC_DAPM_SINGLE("DMIC2R Switch", LM49453_P0_DACHAR2_REG, 3, 1, 0),
  321. SOC_DAPM_SINGLE("ADCL Switch", LM49453_P0_DACHAR2_REG, 4, 1, 0),
  322. SOC_DAPM_SINGLE("ADCR Switch", LM49453_P0_DACHAR2_REG, 5, 1, 0),
  323. SOC_DAPM_SINGLE("Port2_1 Switch", LM49453_P0_DACHAR2_REG, 6, 1, 0),
  324. SOC_DAPM_SINGLE("Port2_2 Switch", LM49453_P0_DACHAR2_REG, 7, 1, 0),
  325. SOC_DAPM_SINGLE("Sidetone Switch", LM49453_P0_STN_SEL_REG, 5, 0, 0),
  326. };
  327. static const struct snd_kcontrol_new lm49453_lineout_left_mixer[] = {
  328. SOC_DAPM_SINGLE("Port1_1 Switch", LM49453_P0_DACLOL1_REG, 0, 1, 0),
  329. SOC_DAPM_SINGLE("Port1_2 Switch", LM49453_P0_DACLOL1_REG, 1, 1, 0),
  330. SOC_DAPM_SINGLE("Port1_3 Switch", LM49453_P0_DACLOL1_REG, 2, 1, 0),
  331. SOC_DAPM_SINGLE("Port1_4 Switch", LM49453_P0_DACLOL1_REG, 3, 1, 0),
  332. SOC_DAPM_SINGLE("Port1_5 Switch", LM49453_P0_DACLOL1_REG, 4, 1, 0),
  333. SOC_DAPM_SINGLE("Port1_6 Switch", LM49453_P0_DACLOL1_REG, 5, 1, 0),
  334. SOC_DAPM_SINGLE("Port1_7 Switch", LM49453_P0_DACLOL1_REG, 6, 1, 0),
  335. SOC_DAPM_SINGLE("Port1_8 Switch", LM49453_P0_DACLOL1_REG, 7, 1, 0),
  336. SOC_DAPM_SINGLE("DMIC1L Switch", LM49453_P0_DACLOL2_REG, 0, 1, 0),
  337. SOC_DAPM_SINGLE("DMIC1R Switch", LM49453_P0_DACLOL2_REG, 1, 1, 0),
  338. SOC_DAPM_SINGLE("DMIC2L Switch", LM49453_P0_DACLOL2_REG, 2, 1, 0),
  339. SOC_DAPM_SINGLE("DMIC2R Switch", LM49453_P0_DACLOL2_REG, 3, 1, 0),
  340. SOC_DAPM_SINGLE("ADCL Switch", LM49453_P0_DACLOL2_REG, 4, 1, 0),
  341. SOC_DAPM_SINGLE("ADCR Switch", LM49453_P0_DACLOL2_REG, 5, 1, 0),
  342. SOC_DAPM_SINGLE("Port2_1 Switch", LM49453_P0_DACLOL2_REG, 6, 1, 0),
  343. SOC_DAPM_SINGLE("Port2_2 Switch", LM49453_P0_DACLOL2_REG, 7, 1, 0),
  344. SOC_DAPM_SINGLE("Sidetone Switch", LM49453_P0_STN_SEL_REG, 6, 0, 0),
  345. };
  346. static const struct snd_kcontrol_new lm49453_lineout_right_mixer[] = {
  347. SOC_DAPM_SINGLE("Port1_1 Switch", LM49453_P0_DACLOR1_REG, 0, 1, 0),
  348. SOC_DAPM_SINGLE("Port1_2 Switch", LM49453_P0_DACLOR1_REG, 1, 1, 0),
  349. SOC_DAPM_SINGLE("Port1_3 Switch", LM49453_P0_DACLOR1_REG, 2, 1, 0),
  350. SOC_DAPM_SINGLE("Port1_4 Switch", LM49453_P0_DACLOR1_REG, 3, 1, 0),
  351. SOC_DAPM_SINGLE("Port1_5 Switch", LM49453_P0_DACLOR1_REG, 4, 1, 0),
  352. SOC_DAPM_SINGLE("Port1_6 Switch", LM49453_P0_DACLOR1_REG, 5, 1, 0),
  353. SOC_DAPM_SINGLE("Port1_7 Switch", LM49453_P0_DACLOR1_REG, 6, 1, 0),
  354. SOC_DAPM_SINGLE("Port1_8 Switch", LM49453_P0_DACLOR1_REG, 7, 1, 0),
  355. SOC_DAPM_SINGLE("DMIC1L Switch", LM49453_P0_DACLOR2_REG, 0, 1, 0),
  356. SOC_DAPM_SINGLE("DMIC1R Switch", LM49453_P0_DACLOR2_REG, 1, 1, 0),
  357. SOC_DAPM_SINGLE("DMIC2L Switch", LM49453_P0_DACLOR2_REG, 2, 1, 0),
  358. SOC_DAPM_SINGLE("DMIC2R Switch", LM49453_P0_DACLOR2_REG, 3, 1, 0),
  359. SOC_DAPM_SINGLE("ADCL Switch", LM49453_P0_DACLOR2_REG, 4, 1, 0),
  360. SOC_DAPM_SINGLE("ADCR Switch", LM49453_P0_DACLOR2_REG, 5, 1, 0),
  361. SOC_DAPM_SINGLE("Port2_1 Switch", LM49453_P0_DACLOR2_REG, 6, 1, 0),
  362. SOC_DAPM_SINGLE("Port2_2 Switch", LM49453_P0_DACLOR2_REG, 7, 1, 0),
  363. SOC_DAPM_SINGLE("Sidetone Switch", LM49453_P0_STN_SEL_REG, 7, 0, 0),
  364. };
  365. static const struct snd_kcontrol_new lm49453_port1_tx1_mixer[] = {
  366. SOC_DAPM_SINGLE("DMIC1L Switch", LM49453_P0_PORT1_TX1_REG, 0, 1, 0),
  367. SOC_DAPM_SINGLE("DMIC1R Switch", LM49453_P0_PORT1_TX1_REG, 1, 1, 0),
  368. SOC_DAPM_SINGLE("DMIC2L Switch", LM49453_P0_PORT1_TX1_REG, 2, 1, 0),
  369. SOC_DAPM_SINGLE("DMIC2R Switch", LM49453_P0_PORT1_TX1_REG, 3, 1, 0),
  370. SOC_DAPM_SINGLE("ADCL Switch", LM49453_P0_PORT1_TX1_REG, 4, 1, 0),
  371. SOC_DAPM_SINGLE("ADCR Switch", LM49453_P0_PORT1_TX1_REG, 5, 1, 0),
  372. SOC_DAPM_SINGLE("Port1_1 Switch", LM49453_P0_PORT1_TX1_REG, 6, 1, 0),
  373. SOC_DAPM_SINGLE("Port2_1 Switch", LM49453_P0_PORT1_TX1_REG, 7, 1, 0),
  374. };
  375. static const struct snd_kcontrol_new lm49453_port1_tx2_mixer[] = {
  376. SOC_DAPM_SINGLE("DMIC1L Switch", LM49453_P0_PORT1_TX2_REG, 0, 1, 0),
  377. SOC_DAPM_SINGLE("DMIC1R Switch", LM49453_P0_PORT1_TX2_REG, 1, 1, 0),
  378. SOC_DAPM_SINGLE("DMIC2L Switch", LM49453_P0_PORT1_TX2_REG, 2, 1, 0),
  379. SOC_DAPM_SINGLE("DMIC2R Switch", LM49453_P0_PORT1_TX2_REG, 3, 1, 0),
  380. SOC_DAPM_SINGLE("ADCL Switch", LM49453_P0_PORT1_TX2_REG, 4, 1, 0),
  381. SOC_DAPM_SINGLE("ADCR Switch", LM49453_P0_PORT1_TX2_REG, 5, 1, 0),
  382. SOC_DAPM_SINGLE("Port1_2 Switch", LM49453_P0_PORT1_TX2_REG, 6, 1, 0),
  383. SOC_DAPM_SINGLE("Port2_2 Switch", LM49453_P0_PORT1_TX2_REG, 7, 1, 0),
  384. };
  385. static const struct snd_kcontrol_new lm49453_port1_tx3_mixer[] = {
  386. SOC_DAPM_SINGLE("DMIC1L Switch", LM49453_P0_PORT1_TX3_REG, 0, 1, 0),
  387. SOC_DAPM_SINGLE("DMIC1R Switch", LM49453_P0_PORT1_TX3_REG, 1, 1, 0),
  388. SOC_DAPM_SINGLE("DMIC2L Switch", LM49453_P0_PORT1_TX3_REG, 2, 1, 0),
  389. SOC_DAPM_SINGLE("DMIC2R Switch", LM49453_P0_PORT1_TX3_REG, 3, 1, 0),
  390. SOC_DAPM_SINGLE("ADCL Switch", LM49453_P0_PORT1_TX3_REG, 4, 1, 0),
  391. SOC_DAPM_SINGLE("ADCR Switch", LM49453_P0_PORT1_TX3_REG, 5, 1, 0),
  392. SOC_DAPM_SINGLE("Port1_3 Switch", LM49453_P0_PORT1_TX3_REG, 6, 1, 0),
  393. };
  394. static const struct snd_kcontrol_new lm49453_port1_tx4_mixer[] = {
  395. SOC_DAPM_SINGLE("DMIC1L Switch", LM49453_P0_PORT1_TX4_REG, 0, 1, 0),
  396. SOC_DAPM_SINGLE("DMIC1R Switch", LM49453_P0_PORT1_TX4_REG, 1, 1, 0),
  397. SOC_DAPM_SINGLE("DMIC2L Switch", LM49453_P0_PORT1_TX4_REG, 2, 1, 0),
  398. SOC_DAPM_SINGLE("DMIC2R Switch", LM49453_P0_PORT1_TX4_REG, 3, 1, 0),
  399. SOC_DAPM_SINGLE("ADCL Switch", LM49453_P0_PORT1_TX4_REG, 4, 1, 0),
  400. SOC_DAPM_SINGLE("ADCR Switch", LM49453_P0_PORT1_TX4_REG, 5, 1, 0),
  401. SOC_DAPM_SINGLE("Port1_4 Switch", LM49453_P0_PORT1_TX4_REG, 6, 1, 0),
  402. };
  403. static const struct snd_kcontrol_new lm49453_port1_tx5_mixer[] = {
  404. SOC_DAPM_SINGLE("DMIC1L Switch", LM49453_P0_PORT1_TX5_REG, 0, 1, 0),
  405. SOC_DAPM_SINGLE("DMIC1R Switch", LM49453_P0_PORT1_TX5_REG, 1, 1, 0),
  406. SOC_DAPM_SINGLE("DMIC2L Switch", LM49453_P0_PORT1_TX5_REG, 2, 1, 0),
  407. SOC_DAPM_SINGLE("DMIC2R Switch", LM49453_P0_PORT1_TX5_REG, 3, 1, 0),
  408. SOC_DAPM_SINGLE("ADCL Switch", LM49453_P0_PORT1_TX5_REG, 4, 1, 0),
  409. SOC_DAPM_SINGLE("ADCR Switch", LM49453_P0_PORT1_TX5_REG, 5, 1, 0),
  410. SOC_DAPM_SINGLE("Port1_5 Switch", LM49453_P0_PORT1_TX5_REG, 6, 1, 0),
  411. };
  412. static const struct snd_kcontrol_new lm49453_port1_tx6_mixer[] = {
  413. SOC_DAPM_SINGLE("DMIC1L Switch", LM49453_P0_PORT1_TX6_REG, 0, 1, 0),
  414. SOC_DAPM_SINGLE("DMIC1R Switch", LM49453_P0_PORT1_TX6_REG, 1, 1, 0),
  415. SOC_DAPM_SINGLE("DMIC2L Switch", LM49453_P0_PORT1_TX6_REG, 2, 1, 0),
  416. SOC_DAPM_SINGLE("DMIC2R Switch", LM49453_P0_PORT1_TX6_REG, 3, 1, 0),
  417. SOC_DAPM_SINGLE("ADCL Switch", LM49453_P0_PORT1_TX6_REG, 4, 1, 0),
  418. SOC_DAPM_SINGLE("ADCR Switch", LM49453_P0_PORT1_TX6_REG, 5, 1, 0),
  419. SOC_DAPM_SINGLE("Port1_6 Switch", LM49453_P0_PORT1_TX6_REG, 6, 1, 0),
  420. };
  421. static const struct snd_kcontrol_new lm49453_port1_tx7_mixer[] = {
  422. SOC_DAPM_SINGLE("DMIC1L Switch", LM49453_P0_PORT1_TX7_REG, 0, 1, 0),
  423. SOC_DAPM_SINGLE("DMIC1R Switch", LM49453_P0_PORT1_TX7_REG, 1, 1, 0),
  424. SOC_DAPM_SINGLE("DMIC2L Switch", LM49453_P0_PORT1_TX7_REG, 2, 1, 0),
  425. SOC_DAPM_SINGLE("DMIC2R Switch", LM49453_P0_PORT1_TX7_REG, 3, 1, 0),
  426. SOC_DAPM_SINGLE("ADCL Switch", LM49453_P0_PORT1_TX7_REG, 4, 1, 0),
  427. SOC_DAPM_SINGLE("ADCR Switch", LM49453_P0_PORT1_TX7_REG, 5, 1, 0),
  428. SOC_DAPM_SINGLE("Port1_7 Switch", LM49453_P0_PORT1_TX7_REG, 6, 1, 0),
  429. };
  430. static const struct snd_kcontrol_new lm49453_port1_tx8_mixer[] = {
  431. SOC_DAPM_SINGLE("DMIC1L Switch", LM49453_P0_PORT1_TX8_REG, 0, 1, 0),
  432. SOC_DAPM_SINGLE("DMIC1R Switch", LM49453_P0_PORT1_TX8_REG, 1, 1, 0),
  433. SOC_DAPM_SINGLE("DMIC2L Switch", LM49453_P0_PORT1_TX8_REG, 2, 1, 0),
  434. SOC_DAPM_SINGLE("DMIC2R Switch", LM49453_P0_PORT1_TX8_REG, 3, 1, 0),
  435. SOC_DAPM_SINGLE("ADCL Switch", LM49453_P0_PORT1_TX8_REG, 4, 1, 0),
  436. SOC_DAPM_SINGLE("ADCR Switch", LM49453_P0_PORT1_TX8_REG, 5, 1, 0),
  437. SOC_DAPM_SINGLE("Port1_8 Switch", LM49453_P0_PORT1_TX8_REG, 6, 1, 0),
  438. };
  439. static const struct snd_kcontrol_new lm49453_port2_tx1_mixer[] = {
  440. SOC_DAPM_SINGLE("DMIC1L Switch", LM49453_P0_PORT2_TX1_REG, 0, 1, 0),
  441. SOC_DAPM_SINGLE("DMIC1R Switch", LM49453_P0_PORT2_TX1_REG, 1, 1, 0),
  442. SOC_DAPM_SINGLE("DMIC2L Switch", LM49453_P0_PORT2_TX1_REG, 2, 1, 0),
  443. SOC_DAPM_SINGLE("DMIC2R Switch", LM49453_P0_PORT2_TX1_REG, 3, 1, 0),
  444. SOC_DAPM_SINGLE("ADCL Switch", LM49453_P0_PORT2_TX1_REG, 4, 1, 0),
  445. SOC_DAPM_SINGLE("ADCR Switch", LM49453_P0_PORT2_TX1_REG, 5, 1, 0),
  446. SOC_DAPM_SINGLE("Port1_1 Switch", LM49453_P0_PORT2_TX1_REG, 6, 1, 0),
  447. SOC_DAPM_SINGLE("Port2_1 Switch", LM49453_P0_PORT2_TX1_REG, 7, 1, 0),
  448. };
  449. static const struct snd_kcontrol_new lm49453_port2_tx2_mixer[] = {
  450. SOC_DAPM_SINGLE("DMIC1L Switch", LM49453_P0_PORT2_TX2_REG, 0, 1, 0),
  451. SOC_DAPM_SINGLE("DMIC1R Switch", LM49453_P0_PORT2_TX2_REG, 1, 1, 0),
  452. SOC_DAPM_SINGLE("DMIC2L Switch", LM49453_P0_PORT2_TX2_REG, 2, 1, 0),
  453. SOC_DAPM_SINGLE("DMIC2R Switch", LM49453_P0_PORT2_TX2_REG, 3, 1, 0),
  454. SOC_DAPM_SINGLE("ADCL Switch", LM49453_P0_PORT2_TX2_REG, 4, 1, 0),
  455. SOC_DAPM_SINGLE("ADCR Switch", LM49453_P0_PORT2_TX2_REG, 5, 1, 0),
  456. SOC_DAPM_SINGLE("Port1_2 Switch", LM49453_P0_PORT2_TX2_REG, 6, 1, 0),
  457. SOC_DAPM_SINGLE("Port2_2 Switch", LM49453_P0_PORT2_TX2_REG, 7, 1, 0),
  458. };
  459. /* TLV Declarations */
  460. static const DECLARE_TLV_DB_SCALE(adc_dac_tlv, -7650, 150, 1);
  461. static const DECLARE_TLV_DB_SCALE(mic_tlv, 0, 200, 1);
  462. static const DECLARE_TLV_DB_SCALE(port_tlv, -1800, 600, 0);
  463. static const DECLARE_TLV_DB_SCALE(stn_tlv, -7200, 150, 0);
  464. static const struct snd_kcontrol_new lm49453_sidetone_mixer_controls[] = {
  465. /* Sidetone supports mono only */
  466. SOC_DAPM_SINGLE_TLV("Sidetone ADCL Volume", LM49453_P0_STN_VOL_ADCL_REG,
  467. 0, 0x3F, 0, stn_tlv),
  468. SOC_DAPM_SINGLE_TLV("Sidetone ADCR Volume", LM49453_P0_STN_VOL_ADCR_REG,
  469. 0, 0x3F, 0, stn_tlv),
  470. SOC_DAPM_SINGLE_TLV("Sidetone DMIC1L Volume", LM49453_P0_STN_VOL_DMIC1L_REG,
  471. 0, 0x3F, 0, stn_tlv),
  472. SOC_DAPM_SINGLE_TLV("Sidetone DMIC1R Volume", LM49453_P0_STN_VOL_DMIC1R_REG,
  473. 0, 0x3F, 0, stn_tlv),
  474. SOC_DAPM_SINGLE_TLV("Sidetone DMIC2L Volume", LM49453_P0_STN_VOL_DMIC2L_REG,
  475. 0, 0x3F, 0, stn_tlv),
  476. SOC_DAPM_SINGLE_TLV("Sidetone DMIC2R Volume", LM49453_P0_STN_VOL_DMIC2R_REG,
  477. 0, 0x3F, 0, stn_tlv),
  478. };
  479. static const struct snd_kcontrol_new lm49453_snd_controls[] = {
  480. /* mic1 and mic2 supports mono only */
  481. SOC_SINGLE_TLV("Mic1 Volume", LM49453_P0_MICL_REG, 0, 15, 0, mic_tlv),
  482. SOC_SINGLE_TLV("Mic2 Volume", LM49453_P0_MICR_REG, 0, 15, 0, mic_tlv),
  483. SOC_SINGLE_TLV("ADCL Volume", LM49453_P0_ADC_LEVELL_REG, 0, 63,
  484. 0, adc_dac_tlv),
  485. SOC_SINGLE_TLV("ADCR Volume", LM49453_P0_ADC_LEVELR_REG, 0, 63,
  486. 0, adc_dac_tlv),
  487. SOC_DOUBLE_R_TLV("DMIC1 Volume", LM49453_P0_DMIC1_LEVELL_REG,
  488. LM49453_P0_DMIC1_LEVELR_REG, 0, 63, 0, adc_dac_tlv),
  489. SOC_DOUBLE_R_TLV("DMIC2 Volume", LM49453_P0_DMIC2_LEVELL_REG,
  490. LM49453_P0_DMIC2_LEVELR_REG, 0, 63, 0, adc_dac_tlv),
  491. SOC_DAPM_ENUM("Mic2Mode", lm49453_mic2mode_enum),
  492. SOC_DAPM_ENUM("DMIC12 SRC", lm49453_dmic12_cfg_enum),
  493. SOC_DAPM_ENUM("DMIC34 SRC", lm49453_dmic34_cfg_enum),
  494. /* Capture path filter enable */
  495. SOC_SINGLE("DMIC1 HPFilter Switch", LM49453_P0_ADC_FX_ENABLES_REG,
  496. 0, 1, 0),
  497. SOC_SINGLE("DMIC2 HPFilter Switch", LM49453_P0_ADC_FX_ENABLES_REG,
  498. 1, 1, 0),
  499. SOC_SINGLE("ADC HPFilter Switch", LM49453_P0_ADC_FX_ENABLES_REG,
  500. 2, 1, 0),
  501. SOC_DOUBLE_R_TLV("DAC HP Volume", LM49453_P0_DAC_HP_LEVELL_REG,
  502. LM49453_P0_DAC_HP_LEVELR_REG, 0, 63, 0, adc_dac_tlv),
  503. SOC_DOUBLE_R_TLV("DAC LO Volume", LM49453_P0_DAC_LO_LEVELL_REG,
  504. LM49453_P0_DAC_LO_LEVELR_REG, 0, 63, 0, adc_dac_tlv),
  505. SOC_DOUBLE_R_TLV("DAC LS Volume", LM49453_P0_DAC_LS_LEVELL_REG,
  506. LM49453_P0_DAC_LS_LEVELR_REG, 0, 63, 0, adc_dac_tlv),
  507. SOC_DOUBLE_R_TLV("DAC HA Volume", LM49453_P0_DAC_HA_LEVELL_REG,
  508. LM49453_P0_DAC_HA_LEVELR_REG, 0, 63, 0, adc_dac_tlv),
  509. SOC_SINGLE_TLV("EP Volume", LM49453_P0_DAC_LS_LEVELL_REG,
  510. 0, 63, 0, adc_dac_tlv),
  511. SOC_SINGLE_TLV("PORT1_1_RX_LVL Volume", LM49453_P0_PORT1_RX_LVL1_REG,
  512. 0, 3, 0, port_tlv),
  513. SOC_SINGLE_TLV("PORT1_2_RX_LVL Volume", LM49453_P0_PORT1_RX_LVL1_REG,
  514. 2, 3, 0, port_tlv),
  515. SOC_SINGLE_TLV("PORT1_3_RX_LVL Volume", LM49453_P0_PORT1_RX_LVL1_REG,
  516. 4, 3, 0, port_tlv),
  517. SOC_SINGLE_TLV("PORT1_4_RX_LVL Volume", LM49453_P0_PORT1_RX_LVL1_REG,
  518. 6, 3, 0, port_tlv),
  519. SOC_SINGLE_TLV("PORT1_5_RX_LVL Volume", LM49453_P0_PORT1_RX_LVL2_REG,
  520. 0, 3, 0, port_tlv),
  521. SOC_SINGLE_TLV("PORT1_6_RX_LVL Volume", LM49453_P0_PORT1_RX_LVL2_REG,
  522. 2, 3, 0, port_tlv),
  523. SOC_SINGLE_TLV("PORT1_7_RX_LVL Volume", LM49453_P0_PORT1_RX_LVL2_REG,
  524. 4, 3, 0, port_tlv),
  525. SOC_SINGLE_TLV("PORT1_8_RX_LVL Volume", LM49453_P0_PORT1_RX_LVL2_REG,
  526. 6, 3, 0, port_tlv),
  527. SOC_SINGLE_TLV("PORT2_1_RX_LVL Volume", LM49453_P0_PORT2_RX_LVL_REG,
  528. 0, 3, 0, port_tlv),
  529. SOC_SINGLE_TLV("PORT2_2_RX_LVL Volume", LM49453_P0_PORT2_RX_LVL_REG,
  530. 2, 3, 0, port_tlv),
  531. SOC_SINGLE("Port1 Playback Switch", LM49453_P0_AUDIO_PORT1_BASIC_REG,
  532. 1, 1, 0),
  533. SOC_SINGLE("Port2 Playback Switch", LM49453_P0_AUDIO_PORT2_BASIC_REG,
  534. 1, 1, 0),
  535. SOC_SINGLE("Port1 Capture Switch", LM49453_P0_AUDIO_PORT1_BASIC_REG,
  536. 2, 1, 0),
  537. SOC_SINGLE("Port2 Capture Switch", LM49453_P0_AUDIO_PORT2_BASIC_REG,
  538. 2, 1, 0)
  539. };
  540. /* DAPM widgets */
  541. static const struct snd_soc_dapm_widget lm49453_dapm_widgets[] = {
  542. /* All end points HP,EP, LS, Lineout and Haptic */
  543. SND_SOC_DAPM_OUTPUT("HPOUTL"),
  544. SND_SOC_DAPM_OUTPUT("HPOUTR"),
  545. SND_SOC_DAPM_OUTPUT("EPOUT"),
  546. SND_SOC_DAPM_OUTPUT("LSOUTL"),
  547. SND_SOC_DAPM_OUTPUT("LSOUTR"),
  548. SND_SOC_DAPM_OUTPUT("LOOUTR"),
  549. SND_SOC_DAPM_OUTPUT("LOOUTL"),
  550. SND_SOC_DAPM_OUTPUT("HAOUTL"),
  551. SND_SOC_DAPM_OUTPUT("HAOUTR"),
  552. SND_SOC_DAPM_INPUT("AMIC1"),
  553. SND_SOC_DAPM_INPUT("AMIC2"),
  554. SND_SOC_DAPM_INPUT("DMIC1DAT"),
  555. SND_SOC_DAPM_INPUT("DMIC2DAT"),
  556. SND_SOC_DAPM_INPUT("AUXL"),
  557. SND_SOC_DAPM_INPUT("AUXR"),
  558. SND_SOC_DAPM_PGA("PORT1_1_RX", SND_SOC_NOPM, 0, 0, NULL, 0),
  559. SND_SOC_DAPM_PGA("PORT1_2_RX", SND_SOC_NOPM, 0, 0, NULL, 0),
  560. SND_SOC_DAPM_PGA("PORT1_3_RX", SND_SOC_NOPM, 0, 0, NULL, 0),
  561. SND_SOC_DAPM_PGA("PORT1_4_RX", SND_SOC_NOPM, 0, 0, NULL, 0),
  562. SND_SOC_DAPM_PGA("PORT1_5_RX", SND_SOC_NOPM, 0, 0, NULL, 0),
  563. SND_SOC_DAPM_PGA("PORT1_6_RX", SND_SOC_NOPM, 0, 0, NULL, 0),
  564. SND_SOC_DAPM_PGA("PORT1_7_RX", SND_SOC_NOPM, 0, 0, NULL, 0),
  565. SND_SOC_DAPM_PGA("PORT1_8_RX", SND_SOC_NOPM, 0, 0, NULL, 0),
  566. SND_SOC_DAPM_PGA("PORT2_1_RX", SND_SOC_NOPM, 0, 0, NULL, 0),
  567. SND_SOC_DAPM_PGA("PORT2_2_RX", SND_SOC_NOPM, 0, 0, NULL, 0),
  568. SND_SOC_DAPM_SUPPLY("AMIC1Bias", LM49453_P0_MICL_REG, 6, 0, NULL, 0),
  569. SND_SOC_DAPM_SUPPLY("AMIC2Bias", LM49453_P0_MICR_REG, 6, 0, NULL, 0),
  570. /* playback path driver enables */
  571. SND_SOC_DAPM_OUT_DRV("Headset Switch",
  572. LM49453_P0_PMC_SETUP_REG, 0, 0, NULL, 0),
  573. SND_SOC_DAPM_OUT_DRV("Earpiece Switch",
  574. LM49453_P0_EP_REG, 0, 0, NULL, 0),
  575. SND_SOC_DAPM_OUT_DRV("Speaker Left Switch",
  576. LM49453_P0_DIS_PKVL_FB_REG, 0, 1, NULL, 0),
  577. SND_SOC_DAPM_OUT_DRV("Speaker Right Switch",
  578. LM49453_P0_DIS_PKVL_FB_REG, 1, 1, NULL, 0),
  579. SND_SOC_DAPM_OUT_DRV("Haptic Left Switch",
  580. LM49453_P0_DIS_PKVL_FB_REG, 2, 1, NULL, 0),
  581. SND_SOC_DAPM_OUT_DRV("Haptic Right Switch",
  582. LM49453_P0_DIS_PKVL_FB_REG, 3, 1, NULL, 0),
  583. /* DAC */
  584. SND_SOC_DAPM_DAC("HPL DAC", "Headset", SND_SOC_NOPM, 0, 0),
  585. SND_SOC_DAPM_DAC("HPR DAC", "Headset", SND_SOC_NOPM, 0, 0),
  586. SND_SOC_DAPM_DAC("LSL DAC", "Speaker", SND_SOC_NOPM, 0, 0),
  587. SND_SOC_DAPM_DAC("LSR DAC", "Speaker", SND_SOC_NOPM, 0, 0),
  588. SND_SOC_DAPM_DAC("HAL DAC", "Haptic", SND_SOC_NOPM, 0, 0),
  589. SND_SOC_DAPM_DAC("HAR DAC", "Haptic", SND_SOC_NOPM, 0, 0),
  590. SND_SOC_DAPM_DAC("LOL DAC", "Lineout", SND_SOC_NOPM, 0, 0),
  591. SND_SOC_DAPM_DAC("LOR DAC", "Lineout", SND_SOC_NOPM, 0, 0),
  592. SND_SOC_DAPM_PGA("AUXL Input",
  593. LM49453_P0_ANALOG_MIXER_ADC_REG, 2, 0, NULL, 0),
  594. SND_SOC_DAPM_PGA("AUXR Input",
  595. LM49453_P0_ANALOG_MIXER_ADC_REG, 3, 0, NULL, 0),
  596. SND_SOC_DAPM_PGA("Sidetone", SND_SOC_NOPM, 0, 0, NULL, 0),
  597. /* ADC */
  598. SND_SOC_DAPM_ADC("DMIC1 Left", "Capture", SND_SOC_NOPM, 1, 0),
  599. SND_SOC_DAPM_ADC("DMIC1 Right", "Capture", SND_SOC_NOPM, 1, 0),
  600. SND_SOC_DAPM_ADC("DMIC2 Left", "Capture", SND_SOC_NOPM, 1, 0),
  601. SND_SOC_DAPM_ADC("DMIC2 Right", "Capture", SND_SOC_NOPM, 1, 0),
  602. SND_SOC_DAPM_ADC("ADC Left", "Capture", SND_SOC_NOPM, 1, 0),
  603. SND_SOC_DAPM_ADC("ADC Right", "Capture", SND_SOC_NOPM, 0, 0),
  604. SND_SOC_DAPM_MUX("ADCL Mux", SND_SOC_NOPM, 0, 0,
  605. &lm49453_adcl_mux_control),
  606. SND_SOC_DAPM_MUX("ADCR Mux", SND_SOC_NOPM, 0, 0,
  607. &lm49453_adcr_mux_control),
  608. SND_SOC_DAPM_MUX("Mic1 Input",
  609. SND_SOC_NOPM, 0, 0, &lm49453_adcl_mux_control),
  610. SND_SOC_DAPM_MUX("Mic2 Input",
  611. SND_SOC_NOPM, 0, 0, &lm49453_adcr_mux_control),
  612. /* AIF */
  613. SND_SOC_DAPM_AIF_IN("PORT1_SDI", NULL, 0,
  614. LM49453_P0_PULL_CONFIG1_REG, 2, 0),
  615. SND_SOC_DAPM_AIF_IN("PORT2_SDI", NULL, 0,
  616. LM49453_P0_PULL_CONFIG1_REG, 6, 0),
  617. SND_SOC_DAPM_AIF_OUT("PORT1_SDO", NULL, 0,
  618. LM49453_P0_PULL_CONFIG1_REG, 3, 0),
  619. SND_SOC_DAPM_AIF_OUT("PORT2_SDO", NULL, 0,
  620. LM49453_P0_PULL_CONFIG1_REG, 7, 0),
  621. /* Port1 TX controls */
  622. SND_SOC_DAPM_OUT_DRV("P1_1_TX", SND_SOC_NOPM, 0, 0, NULL, 0),
  623. SND_SOC_DAPM_OUT_DRV("P1_2_TX", SND_SOC_NOPM, 0, 0, NULL, 0),
  624. SND_SOC_DAPM_OUT_DRV("P1_3_TX", SND_SOC_NOPM, 0, 0, NULL, 0),
  625. SND_SOC_DAPM_OUT_DRV("P1_4_TX", SND_SOC_NOPM, 0, 0, NULL, 0),
  626. SND_SOC_DAPM_OUT_DRV("P1_5_TX", SND_SOC_NOPM, 0, 0, NULL, 0),
  627. SND_SOC_DAPM_OUT_DRV("P1_6_TX", SND_SOC_NOPM, 0, 0, NULL, 0),
  628. SND_SOC_DAPM_OUT_DRV("P1_7_TX", SND_SOC_NOPM, 0, 0, NULL, 0),
  629. SND_SOC_DAPM_OUT_DRV("P1_8_TX", SND_SOC_NOPM, 0, 0, NULL, 0),
  630. /* Port2 TX controls */
  631. SND_SOC_DAPM_OUT_DRV("P2_1_TX", SND_SOC_NOPM, 0, 0, NULL, 0),
  632. SND_SOC_DAPM_OUT_DRV("P2_2_TX", SND_SOC_NOPM, 0, 0, NULL, 0),
  633. /* Sidetone Mixer */
  634. SND_SOC_DAPM_MIXER("Sidetone Mixer", SND_SOC_NOPM, 0, 0,
  635. lm49453_sidetone_mixer_controls,
  636. ARRAY_SIZE(lm49453_sidetone_mixer_controls)),
  637. /* DAC MIXERS */
  638. SND_SOC_DAPM_MIXER("HPL Mixer", SND_SOC_NOPM, 0, 0,
  639. lm49453_headset_left_mixer,
  640. ARRAY_SIZE(lm49453_headset_left_mixer)),
  641. SND_SOC_DAPM_MIXER("HPR Mixer", SND_SOC_NOPM, 0, 0,
  642. lm49453_headset_right_mixer,
  643. ARRAY_SIZE(lm49453_headset_right_mixer)),
  644. SND_SOC_DAPM_MIXER("LOL Mixer", SND_SOC_NOPM, 0, 0,
  645. lm49453_lineout_left_mixer,
  646. ARRAY_SIZE(lm49453_lineout_left_mixer)),
  647. SND_SOC_DAPM_MIXER("LOR Mixer", SND_SOC_NOPM, 0, 0,
  648. lm49453_lineout_right_mixer,
  649. ARRAY_SIZE(lm49453_lineout_right_mixer)),
  650. SND_SOC_DAPM_MIXER("LSL Mixer", SND_SOC_NOPM, 0, 0,
  651. lm49453_speaker_left_mixer,
  652. ARRAY_SIZE(lm49453_speaker_left_mixer)),
  653. SND_SOC_DAPM_MIXER("LSR Mixer", SND_SOC_NOPM, 0, 0,
  654. lm49453_speaker_right_mixer,
  655. ARRAY_SIZE(lm49453_speaker_right_mixer)),
  656. SND_SOC_DAPM_MIXER("HAL Mixer", SND_SOC_NOPM, 0, 0,
  657. lm49453_haptic_left_mixer,
  658. ARRAY_SIZE(lm49453_haptic_left_mixer)),
  659. SND_SOC_DAPM_MIXER("HAR Mixer", SND_SOC_NOPM, 0, 0,
  660. lm49453_haptic_right_mixer,
  661. ARRAY_SIZE(lm49453_haptic_right_mixer)),
  662. /* Capture Mixer */
  663. SND_SOC_DAPM_MIXER("Port1_1 Mixer", SND_SOC_NOPM, 0, 0,
  664. lm49453_port1_tx1_mixer,
  665. ARRAY_SIZE(lm49453_port1_tx1_mixer)),
  666. SND_SOC_DAPM_MIXER("Port1_2 Mixer", SND_SOC_NOPM, 0, 0,
  667. lm49453_port1_tx2_mixer,
  668. ARRAY_SIZE(lm49453_port1_tx2_mixer)),
  669. SND_SOC_DAPM_MIXER("Port1_3 Mixer", SND_SOC_NOPM, 0, 0,
  670. lm49453_port1_tx3_mixer,
  671. ARRAY_SIZE(lm49453_port1_tx3_mixer)),
  672. SND_SOC_DAPM_MIXER("Port1_4 Mixer", SND_SOC_NOPM, 0, 0,
  673. lm49453_port1_tx4_mixer,
  674. ARRAY_SIZE(lm49453_port1_tx4_mixer)),
  675. SND_SOC_DAPM_MIXER("Port1_5 Mixer", SND_SOC_NOPM, 0, 0,
  676. lm49453_port1_tx5_mixer,
  677. ARRAY_SIZE(lm49453_port1_tx5_mixer)),
  678. SND_SOC_DAPM_MIXER("Port1_6 Mixer", SND_SOC_NOPM, 0, 0,
  679. lm49453_port1_tx6_mixer,
  680. ARRAY_SIZE(lm49453_port1_tx6_mixer)),
  681. SND_SOC_DAPM_MIXER("Port1_7 Mixer", SND_SOC_NOPM, 0, 0,
  682. lm49453_port1_tx7_mixer,
  683. ARRAY_SIZE(lm49453_port1_tx7_mixer)),
  684. SND_SOC_DAPM_MIXER("Port1_8 Mixer", SND_SOC_NOPM, 0, 0,
  685. lm49453_port1_tx8_mixer,
  686. ARRAY_SIZE(lm49453_port1_tx8_mixer)),
  687. SND_SOC_DAPM_MIXER("Port2_1 Mixer", SND_SOC_NOPM, 0, 0,
  688. lm49453_port2_tx1_mixer,
  689. ARRAY_SIZE(lm49453_port2_tx1_mixer)),
  690. SND_SOC_DAPM_MIXER("Port2_2 Mixer", SND_SOC_NOPM, 0, 0,
  691. lm49453_port2_tx2_mixer,
  692. ARRAY_SIZE(lm49453_port2_tx2_mixer)),
  693. };
  694. static const struct snd_soc_dapm_route lm49453_audio_map[] = {
  695. /* Port SDI mapping */
  696. { "PORT1_1_RX", "Port1 Playback Switch", "PORT1_SDI" },
  697. { "PORT1_2_RX", "Port1 Playback Switch", "PORT1_SDI" },
  698. { "PORT1_3_RX", "Port1 Playback Switch", "PORT1_SDI" },
  699. { "PORT1_4_RX", "Port1 Playback Switch", "PORT1_SDI" },
  700. { "PORT1_5_RX", "Port1 Playback Switch", "PORT1_SDI" },
  701. { "PORT1_6_RX", "Port1 Playback Switch", "PORT1_SDI" },
  702. { "PORT1_7_RX", "Port1 Playback Switch", "PORT1_SDI" },
  703. { "PORT1_8_RX", "Port1 Playback Switch", "PORT1_SDI" },
  704. { "PORT2_1_RX", "Port2 Playback Switch", "PORT2_SDI" },
  705. { "PORT2_2_RX", "Port2 Playback Switch", "PORT2_SDI" },
  706. /* HP mapping */
  707. { "HPL Mixer", "Port1_1 Switch", "PORT1_1_RX" },
  708. { "HPL Mixer", "Port1_2 Switch", "PORT1_2_RX" },
  709. { "HPL Mixer", "Port1_3 Switch", "PORT1_3_RX" },
  710. { "HPL Mixer", "Port1_4 Switch", "PORT1_4_RX" },
  711. { "HPL Mixer", "Port1_5 Switch", "PORT1_5_RX" },
  712. { "HPL Mixer", "Port1_6 Switch", "PORT1_6_RX" },
  713. { "HPL Mixer", "Port1_7 Switch", "PORT1_7_RX" },
  714. { "HPL Mixer", "Port1_8 Switch", "PORT1_8_RX" },
  715. { "HPL Mixer", "Port2_1 Switch", "PORT2_1_RX" },
  716. { "HPL Mixer", "Port2_2 Switch", "PORT2_2_RX" },
  717. { "HPL Mixer", "ADCL Switch", "ADC Left" },
  718. { "HPL Mixer", "ADCR Switch", "ADC Right" },
  719. { "HPL Mixer", "DMIC1L Switch", "DMIC1 Left" },
  720. { "HPL Mixer", "DMIC1R Switch", "DMIC1 Right" },
  721. { "HPL Mixer", "DMIC2L Switch", "DMIC2 Left" },
  722. { "HPL Mixer", "DMIC2R Switch", "DMIC2 Right" },
  723. { "HPL Mixer", "Sidetone Switch", "Sidetone" },
  724. { "HPL DAC", NULL, "HPL Mixer" },
  725. { "HPR Mixer", "Port1_1 Switch", "PORT1_1_RX" },
  726. { "HPR Mixer", "Port1_2 Switch", "PORT1_2_RX" },
  727. { "HPR Mixer", "Port1_3 Switch", "PORT1_3_RX" },
  728. { "HPR Mixer", "Port1_4 Switch", "PORT1_4_RX" },
  729. { "HPR Mixer", "Port1_5 Switch", "PORT1_5_RX" },
  730. { "HPR Mixer", "Port1_6 Switch", "PORT1_6_RX" },
  731. { "HPR Mixer", "Port1_7 Switch", "PORT1_7_RX" },
  732. { "HPR Mixer", "Port1_8 Switch", "PORT1_8_RX" },
  733. /* Port 2 */
  734. { "HPR Mixer", "Port2_1 Switch", "PORT2_1_RX" },
  735. { "HPR Mixer", "Port2_2 Switch", "PORT2_2_RX" },
  736. { "HPR Mixer", "ADCL Switch", "ADC Left" },
  737. { "HPR Mixer", "ADCR Switch", "ADC Right" },
  738. { "HPR Mixer", "DMIC1L Switch", "DMIC1 Left" },
  739. { "HPR Mixer", "DMIC1R Switch", "DMIC1 Right" },
  740. { "HPR Mixer", "DMIC2L Switch", "DMIC2 Left" },
  741. { "HPR Mixer", "DMIC2L Switch", "DMIC2 Right" },
  742. { "HPR Mixer", "Sidetone Switch", "Sidetone" },
  743. { "HPR DAC", NULL, "HPR Mixer" },
  744. { "HPOUTL", "Headset Switch", "HPL DAC"},
  745. { "HPOUTR", "Headset Switch", "HPR DAC"},
  746. /* EP map */
  747. { "EPOUT", "Earpiece Switch", "HPL DAC" },
  748. /* Speaker map */
  749. { "LSL Mixer", "Port1_1 Switch", "PORT1_1_RX" },
  750. { "LSL Mixer", "Port1_2 Switch", "PORT1_2_RX" },
  751. { "LSL Mixer", "Port1_3 Switch", "PORT1_3_RX" },
  752. { "LSL Mixer", "Port1_4 Switch", "PORT1_4_RX" },
  753. { "LSL Mixer", "Port1_5 Switch", "PORT1_5_RX" },
  754. { "LSL Mixer", "Port1_6 Switch", "PORT1_6_RX" },
  755. { "LSL Mixer", "Port1_7 Switch", "PORT1_7_RX" },
  756. { "LSL Mixer", "Port1_8 Switch", "PORT1_8_RX" },
  757. /* Port 2 */
  758. { "LSL Mixer", "Port2_1 Switch", "PORT2_1_RX" },
  759. { "LSL Mixer", "Port2_2 Switch", "PORT2_2_RX" },
  760. { "LSL Mixer", "ADCL Switch", "ADC Left" },
  761. { "LSL Mixer", "ADCR Switch", "ADC Right" },
  762. { "LSL Mixer", "DMIC1L Switch", "DMIC1 Left" },
  763. { "LSL Mixer", "DMIC1R Switch", "DMIC1 Right" },
  764. { "LSL Mixer", "DMIC2L Switch", "DMIC2 Left" },
  765. { "LSL Mixer", "DMIC2R Switch", "DMIC2 Right" },
  766. { "LSL Mixer", "Sidetone Switch", "Sidetone" },
  767. { "LSL DAC", NULL, "LSL Mixer" },
  768. { "LSR Mixer", "Port1_1 Switch", "PORT1_1_RX" },
  769. { "LSR Mixer", "Port1_2 Switch", "PORT1_2_RX" },
  770. { "LSR Mixer", "Port1_3 Switch", "PORT1_3_RX" },
  771. { "LSR Mixer", "Port1_4 Switch", "PORT1_4_RX" },
  772. { "LSR Mixer", "Port1_5 Switch", "PORT1_5_RX" },
  773. { "LSR Mixer", "Port1_6 Switch", "PORT1_6_RX" },
  774. { "LSR Mixer", "Port1_7 Switch", "PORT1_7_RX" },
  775. { "LSR Mixer", "Port1_8 Switch", "PORT1_8_RX" },
  776. /* Port 2 */
  777. { "LSR Mixer", "Port2_1 Switch", "PORT2_1_RX" },
  778. { "LSR Mixer", "Port2_2 Switch", "PORT2_2_RX" },
  779. { "LSR Mixer", "ADCL Switch", "ADC Left" },
  780. { "LSR Mixer", "ADCR Switch", "ADC Right" },
  781. { "LSR Mixer", "DMIC1L Switch", "DMIC1 Left" },
  782. { "LSR Mixer", "DMIC1R Switch", "DMIC1 Right" },
  783. { "LSR Mixer", "DMIC2L Switch", "DMIC2 Left" },
  784. { "LSR Mixer", "DMIC2R Switch", "DMIC2 Right" },
  785. { "LSR Mixer", "Sidetone Switch", "Sidetone" },
  786. { "LSR DAC", NULL, "LSR Mixer" },
  787. { "LSOUTL", "Speaker Left Switch", "LSL DAC"},
  788. { "LSOUTR", "Speaker Left Switch", "LSR DAC"},
  789. /* Haptic map */
  790. { "HAL Mixer", "Port1_1 Switch", "PORT1_1_RX" },
  791. { "HAL Mixer", "Port1_2 Switch", "PORT1_2_RX" },
  792. { "HAL Mixer", "Port1_3 Switch", "PORT1_3_RX" },
  793. { "HAL Mixer", "Port1_4 Switch", "PORT1_4_RX" },
  794. { "HAL Mixer", "Port1_5 Switch", "PORT1_5_RX" },
  795. { "HAL Mixer", "Port1_6 Switch", "PORT1_6_RX" },
  796. { "HAL Mixer", "Port1_7 Switch", "PORT1_7_RX" },
  797. { "HAL Mixer", "Port1_8 Switch", "PORT1_8_RX" },
  798. /* Port 2 */
  799. { "HAL Mixer", "Port2_1 Switch", "PORT2_1_RX" },
  800. { "HAL Mixer", "Port2_2 Switch", "PORT2_2_RX" },
  801. { "HAL Mixer", "ADCL Switch", "ADC Left" },
  802. { "HAL Mixer", "ADCR Switch", "ADC Right" },
  803. { "HAL Mixer", "DMIC1L Switch", "DMIC1 Left" },
  804. { "HAL Mixer", "DMIC1R Switch", "DMIC1 Right" },
  805. { "HAL Mixer", "DMIC2L Switch", "DMIC2 Left" },
  806. { "HAL Mixer", "DMIC2R Switch", "DMIC2 Right" },
  807. { "HAL Mixer", "Sidetone Switch", "Sidetone" },
  808. { "HAL DAC", NULL, "HAL Mixer" },
  809. { "HAR Mixer", "Port1_1 Switch", "PORT1_1_RX" },
  810. { "HAR Mixer", "Port1_2 Switch", "PORT1_2_RX" },
  811. { "HAR Mixer", "Port1_3 Switch", "PORT1_3_RX" },
  812. { "HAR Mixer", "Port1_4 Switch", "PORT1_4_RX" },
  813. { "HAR Mixer", "Port1_5 Switch", "PORT1_5_RX" },
  814. { "HAR Mixer", "Port1_6 Switch", "PORT1_6_RX" },
  815. { "HAR Mixer", "Port1_7 Switch", "PORT1_7_RX" },
  816. { "HAR Mixer", "Port1_8 Switch", "PORT1_8_RX" },
  817. /* Port 2 */
  818. { "HAR Mixer", "Port2_1 Switch", "PORT2_1_RX" },
  819. { "HAR Mixer", "Port2_2 Switch", "PORT2_2_RX" },
  820. { "HAR Mixer", "ADCL Switch", "ADC Left" },
  821. { "HAR Mixer", "ADCR Switch", "ADC Right" },
  822. { "HAR Mixer", "DMIC1L Switch", "DMIC1 Left" },
  823. { "HAR Mixer", "DMIC1R Switch", "DMIC1 Right" },
  824. { "HAR Mixer", "DMIC2L Switch", "DMIC2 Left" },
  825. { "HAR Mixer", "DMIC2R Switch", "DMIC2 Right" },
  826. { "HAR Mixer", "Sideton Switch", "Sidetone" },
  827. { "HAR DAC", NULL, "HAR Mixer" },
  828. { "HAOUTL", "Haptic Left Switch", "HAL DAC" },
  829. { "HAOUTR", "Haptic Right Switch", "HAR DAC" },
  830. /* Lineout map */
  831. { "LOL Mixer", "Port1_1 Switch", "PORT1_1_RX" },
  832. { "LOL Mixer", "Port1_2 Switch", "PORT1_2_RX" },
  833. { "LOL Mixer", "Port1_3 Switch", "PORT1_3_RX" },
  834. { "LOL Mixer", "Port1_4 Switch", "PORT1_4_RX" },
  835. { "LOL Mixer", "Port1_5 Switch", "PORT1_5_RX" },
  836. { "LOL Mixer", "Port1_6 Switch", "PORT1_6_RX" },
  837. { "LOL Mixer", "Port1_7 Switch", "PORT1_7_RX" },
  838. { "LOL Mixer", "Port1_8 Switch", "PORT1_8_RX" },
  839. /* Port 2 */
  840. { "LOL Mixer", "Port2_1 Switch", "PORT2_1_RX" },
  841. { "LOL Mixer", "Port2_2 Switch", "PORT2_2_RX" },
  842. { "LOL Mixer", "ADCL Switch", "ADC Left" },
  843. { "LOL Mixer", "ADCR Switch", "ADC Right" },
  844. { "LOL Mixer", "DMIC1L Switch", "DMIC1 Left" },
  845. { "LOL Mixer", "DMIC1R Switch", "DMIC1 Right" },
  846. { "LOL Mixer", "DMIC2L Switch", "DMIC2 Left" },
  847. { "LOL Mixer", "DMIC2R Switch", "DMIC2 Right" },
  848. { "LOL Mixer", "Sidetone Switch", "Sidetone" },
  849. { "LOL DAC", NULL, "LOL Mixer" },
  850. { "LOR Mixer", "Port1_1 Switch", "PORT1_1_RX" },
  851. { "LOR Mixer", "Port1_2 Switch", "PORT1_2_RX" },
  852. { "LOR Mixer", "Port1_3 Switch", "PORT1_3_RX" },
  853. { "LOR Mixer", "Port1_4 Switch", "PORT1_4_RX" },
  854. { "LOR Mixer", "Port1_5 Switch", "PORT1_5_RX" },
  855. { "LOR Mixer", "Port1_6 Switch", "PORT1_6_RX" },
  856. { "LOR Mixer", "Port1_7 Switch", "PORT1_7_RX" },
  857. { "LOR Mixer", "Port1_8 Switch", "PORT1_8_RX" },
  858. /* Port 2 */
  859. { "LOR Mixer", "Port2_1 Switch", "PORT2_1_RX" },
  860. { "LOR Mixer", "Port2_2 Switch", "PORT2_2_RX" },
  861. { "LOR Mixer", "ADCL Switch", "ADC Left" },
  862. { "LOR Mixer", "ADCR Switch", "ADC Right" },
  863. { "LOR Mixer", "DMIC1L Switch", "DMIC1 Left" },
  864. { "LOR Mixer", "DMIC1R Switch", "DMIC1 Right" },
  865. { "LOR Mixer", "DMIC2L Switch", "DMIC2 Left" },
  866. { "LOR Mixer", "DMIC2R Switch", "DMIC2 Right" },
  867. { "LOR Mixer", "Sidetone Switch", "Sidetone" },
  868. { "LOR DAC", NULL, "LOR Mixer" },
  869. { "LOOUTL", NULL, "LOL DAC" },
  870. { "LOOUTR", NULL, "LOR DAC" },
  871. /* TX map */
  872. /* Port1 mappings */
  873. { "Port1_1 Mixer", "ADCL Switch", "ADC Left" },
  874. { "Port1_1 Mixer", "ADCR Switch", "ADC Right" },
  875. { "Port1_1 Mixer", "DMIC1L Switch", "DMIC1 Left" },
  876. { "Port1_1 Mixer", "DMIC1R Switch", "DMIC1 Right" },
  877. { "Port1_1 Mixer", "DMIC2L Switch", "DMIC2 Left" },
  878. { "Port1_1 Mixer", "DMIC2R Switch", "DMIC2 Right" },
  879. { "Port1_2 Mixer", "ADCL Switch", "ADC Left" },
  880. { "Port1_2 Mixer", "ADCR Switch", "ADC Right" },
  881. { "Port1_2 Mixer", "DMIC1L Switch", "DMIC1 Left" },
  882. { "Port1_2 Mixer", "DMIC1R Switch", "DMIC1 Right" },
  883. { "Port1_2 Mixer", "DMIC2L Switch", "DMIC2 Left" },
  884. { "Port1_2 Mixer", "DMIC2R Switch", "DMIC2 Right" },
  885. { "Port1_3 Mixer", "ADCL Switch", "ADC Left" },
  886. { "Port1_3 Mixer", "ADCR Switch", "ADC Right" },
  887. { "Port1_3 Mixer", "DMIC1L Switch", "DMIC1 Left" },
  888. { "Port1_3 Mixer", "DMIC1R Switch", "DMIC1 Right" },
  889. { "Port1_3 Mixer", "DMIC2L Switch", "DMIC2 Left" },
  890. { "Port1_3 Mixer", "DMIC2R Switch", "DMIC2 Right" },
  891. { "Port1_4 Mixer", "ADCL Switch", "ADC Left" },
  892. { "Port1_4 Mixer", "ADCR Switch", "ADC Right" },
  893. { "Port1_4 Mixer", "DMIC1L Switch", "DMIC1 Left" },
  894. { "Port1_4 Mixer", "DMIC1R Switch", "DMIC1 Right" },
  895. { "Port1_4 Mixer", "DMIC2L Switch", "DMIC2 Left" },
  896. { "Port1_4 Mixer", "DMIC2R Switch", "DMIC2 Right" },
  897. { "Port1_5 Mixer", "ADCL Switch", "ADC Left" },
  898. { "Port1_5 Mixer", "ADCR Switch", "ADC Right" },
  899. { "Port1_5 Mixer", "DMIC1L Switch", "DMIC1 Left" },
  900. { "Port1_5 Mixer", "DMIC1R Switch", "DMIC1 Right" },
  901. { "Port1_5 Mixer", "DMIC2L Switch", "DMIC2 Left" },
  902. { "Port1_5 Mixer", "DMIC2R Switch", "DMIC2 Right" },
  903. { "Port1_6 Mixer", "ADCL Switch", "ADC Left" },
  904. { "Port1_6 Mixer", "ADCR Switch", "ADC Right" },
  905. { "Port1_6 Mixer", "DMIC1L Switch", "DMIC1 Left" },
  906. { "Port1_6 Mixer", "DMIC1R Switch", "DMIC1 Right" },
  907. { "Port1_6 Mixer", "DMIC2L Switch", "DMIC2 Left" },
  908. { "Port1_6 Mixer", "DMIC2R Switch", "DMIC2 Right" },
  909. { "Port1_7 Mixer", "ADCL Switch", "ADC Left" },
  910. { "Port1_7 Mixer", "ADCR Switch", "ADC Right" },
  911. { "Port1_7 Mixer", "DMIC1L Switch", "DMIC1 Left" },
  912. { "Port1_7 Mixer", "DMIC1R Switch", "DMIC1 Right" },
  913. { "Port1_7 Mixer", "DMIC2L Switch", "DMIC2 Left" },
  914. { "Port1_7 Mixer", "DMIC2R Switch", "DMIC2 Right" },
  915. { "Port1_8 Mixer", "ADCL Switch", "ADC Left" },
  916. { "Port1_8 Mixer", "ADCR Switch", "ADC Right" },
  917. { "Port1_8 Mixer", "DMIC1L Switch", "DMIC1 Left" },
  918. { "Port1_8 Mixer", "DMIC1R Switch", "DMIC1 Right" },
  919. { "Port1_8 Mixer", "DMIC2L Switch", "DMIC2 Left" },
  920. { "Port1_8 Mixer", "DMIC2R Switch", "DMIC2 Right" },
  921. { "Port2_1 Mixer", "ADCL Switch", "ADC Left" },
  922. { "Port2_1 Mixer", "ADCR Switch", "ADC Right" },
  923. { "Port2_1 Mixer", "DMIC1L Switch", "DMIC1 Left" },
  924. { "Port2_1 Mixer", "DMIC1R Switch", "DMIC1 Right" },
  925. { "Port2_1 Mixer", "DMIC2L Switch", "DMIC2 Left" },
  926. { "Port2_1 Mixer", "DMIC2R Switch", "DMIC2 Right" },
  927. { "Port2_2 Mixer", "ADCL Switch", "ADC Left" },
  928. { "Port2_2 Mixer", "ADCR Switch", "ADC Right" },
  929. { "Port2_2 Mixer", "DMIC1L Switch", "DMIC1 Left" },
  930. { "Port2_2 Mixer", "DMIC1R Switch", "DMIC1 Right" },
  931. { "Port2_2 Mixer", "DMIC2L Switch", "DMIC2 Left" },
  932. { "Port2_2 Mixer", "DMIC2R Switch", "DMIC2 Right" },
  933. { "P1_1_TX", NULL, "Port1_1 Mixer" },
  934. { "P1_2_TX", NULL, "Port1_2 Mixer" },
  935. { "P1_3_TX", NULL, "Port1_3 Mixer" },
  936. { "P1_4_TX", NULL, "Port1_4 Mixer" },
  937. { "P1_5_TX", NULL, "Port1_5 Mixer" },
  938. { "P1_6_TX", NULL, "Port1_6 Mixer" },
  939. { "P1_7_TX", NULL, "Port1_7 Mixer" },
  940. { "P1_8_TX", NULL, "Port1_8 Mixer" },
  941. { "P2_1_TX", NULL, "Port2_1 Mixer" },
  942. { "P2_2_TX", NULL, "Port2_2 Mixer" },
  943. { "PORT1_SDO", "Port1 Capture Switch", "P1_1_TX"},
  944. { "PORT1_SDO", "Port1 Capture Switch", "P1_2_TX"},
  945. { "PORT1_SDO", "Port1 Capture Switch", "P1_3_TX"},
  946. { "PORT1_SDO", "Port1 Capture Switch", "P1_4_TX"},
  947. { "PORT1_SDO", "Port1 Capture Switch", "P1_5_TX"},
  948. { "PORT1_SDO", "Port1 Capture Switch", "P1_6_TX"},
  949. { "PORT1_SDO", "Port1 Capture Switch", "P1_7_TX"},
  950. { "PORT1_SDO", "Port1 Capture Switch", "P1_8_TX"},
  951. { "PORT2_SDO", "Port2 Capture Switch", "P2_1_TX"},
  952. { "PORT2_SDO", "Port2 Capture Switch", "P2_2_TX"},
  953. { "Mic1 Input", NULL, "AMIC1" },
  954. { "Mic2 Input", NULL, "AMIC2" },
  955. { "AUXL Input", NULL, "AUXL" },
  956. { "AUXR Input", NULL, "AUXR" },
  957. /* AUX connections */
  958. { "ADCL Mux", "Aux_L", "AUXL Input" },
  959. { "ADCL Mux", "MIC1", "Mic1 Input" },
  960. { "ADCR Mux", "Aux_R", "AUXR Input" },
  961. { "ADCR Mux", "MIC2", "Mic2 Input" },
  962. /* ADC connection */
  963. { "ADC Left", NULL, "ADCL Mux"},
  964. { "ADC Right", NULL, "ADCR Mux"},
  965. { "DMIC1 Left", NULL, "DMIC1DAT"},
  966. { "DMIC1 Right", NULL, "DMIC1DAT"},
  967. { "DMIC2 Left", NULL, "DMIC2DAT"},
  968. { "DMIC2 Right", NULL, "DMIC2DAT"},
  969. /* Sidetone map */
  970. { "Sidetone Mixer", NULL, "ADC Left" },
  971. { "Sidetone Mixer", NULL, "ADC Right" },
  972. { "Sidetone Mixer", NULL, "DMIC1 Left" },
  973. { "Sidetone Mixer", NULL, "DMIC1 Right" },
  974. { "Sidetone Mixer", NULL, "DMIC2 Left" },
  975. { "Sidetone Mixer", NULL, "DMIC2 Right" },
  976. { "Sidetone", "Sidetone Switch", "Sidetone Mixer" },
  977. };
  978. static int lm49453_hw_params(struct snd_pcm_substream *substream,
  979. struct snd_pcm_hw_params *params,
  980. struct snd_soc_dai *dai)
  981. {
  982. struct snd_soc_codec *codec = dai->codec;
  983. u16 clk_div = 0;
  984. /* Setting DAC clock dividers based on substream sample rate. */
  985. switch (params_rate(params)) {
  986. case 8000:
  987. case 16000:
  988. case 32000:
  989. case 24000:
  990. case 48000:
  991. clk_div = 256;
  992. break;
  993. case 11025:
  994. case 22050:
  995. case 44100:
  996. clk_div = 216;
  997. break;
  998. case 96000:
  999. clk_div = 127;
  1000. break;
  1001. default:
  1002. return -EINVAL;
  1003. }
  1004. snd_soc_write(codec, LM49453_P0_ADC_CLK_DIV_REG, clk_div);
  1005. snd_soc_write(codec, LM49453_P0_DAC_HP_CLK_DIV_REG, clk_div);
  1006. return 0;
  1007. }
  1008. static int lm49453_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
  1009. {
  1010. struct snd_soc_codec *codec = codec_dai->codec;
  1011. u16 aif_val;
  1012. int mode = 0;
  1013. int clk_phase = 0;
  1014. int clk_shift = 0;
  1015. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  1016. case SND_SOC_DAIFMT_CBS_CFS:
  1017. aif_val = 0;
  1018. break;
  1019. case SND_SOC_DAIFMT_CBS_CFM:
  1020. aif_val = LM49453_AUDIO_PORT1_BASIC_SYNC_MS;
  1021. break;
  1022. case SND_SOC_DAIFMT_CBM_CFS:
  1023. aif_val = LM49453_AUDIO_PORT1_BASIC_CLK_MS;
  1024. break;
  1025. case SND_SOC_DAIFMT_CBM_CFM:
  1026. aif_val = LM49453_AUDIO_PORT1_BASIC_CLK_MS |
  1027. LM49453_AUDIO_PORT1_BASIC_SYNC_MS;
  1028. break;
  1029. default:
  1030. return -EINVAL;
  1031. }
  1032. switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
  1033. case SND_SOC_DAIFMT_I2S:
  1034. break;
  1035. case SND_SOC_DAIFMT_DSP_A:
  1036. mode = 1;
  1037. clk_phase = (1 << 5);
  1038. clk_shift = 1;
  1039. break;
  1040. case SND_SOC_DAIFMT_DSP_B:
  1041. mode = 1;
  1042. clk_phase = (1 << 5);
  1043. clk_shift = 0;
  1044. break;
  1045. default:
  1046. return -EINVAL;
  1047. }
  1048. snd_soc_update_bits(codec, LM49453_P0_AUDIO_PORT1_BASIC_REG,
  1049. LM49453_AUDIO_PORT1_BASIC_FMT_MASK|BIT(0)|BIT(5),
  1050. (aif_val | mode | clk_phase));
  1051. snd_soc_write(codec, LM49453_P0_AUDIO_PORT1_RX_MSB_REG, clk_shift);
  1052. return 0;
  1053. }
  1054. static int lm49453_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id,
  1055. unsigned int freq, int dir)
  1056. {
  1057. struct snd_soc_codec *codec = dai->codec;
  1058. u16 pll_clk = 0;
  1059. switch (freq) {
  1060. case 12288000:
  1061. case 26000000:
  1062. case 19200000:
  1063. /* pll clk slection */
  1064. pll_clk = 0;
  1065. break;
  1066. case 48000:
  1067. case 32576:
  1068. /* fll clk slection */
  1069. pll_clk = BIT(4);
  1070. return 0;
  1071. default:
  1072. return -EINVAL;
  1073. }
  1074. snd_soc_update_bits(codec, LM49453_P0_PMC_SETUP_REG, BIT(4), pll_clk);
  1075. return 0;
  1076. }
  1077. static int lm49453_hp_mute(struct snd_soc_dai *dai, int mute)
  1078. {
  1079. snd_soc_update_bits(dai->codec, LM49453_P0_DAC_DSP_REG, BIT(1)|BIT(0),
  1080. (mute ? (BIT(1)|BIT(0)) : 0));
  1081. return 0;
  1082. }
  1083. static int lm49453_lo_mute(struct snd_soc_dai *dai, int mute)
  1084. {
  1085. snd_soc_update_bits(dai->codec, LM49453_P0_DAC_DSP_REG, BIT(3)|BIT(2),
  1086. (mute ? (BIT(3)|BIT(2)) : 0));
  1087. return 0;
  1088. }
  1089. static int lm49453_ls_mute(struct snd_soc_dai *dai, int mute)
  1090. {
  1091. snd_soc_update_bits(dai->codec, LM49453_P0_DAC_DSP_REG, BIT(5)|BIT(4),
  1092. (mute ? (BIT(5)|BIT(4)) : 0));
  1093. return 0;
  1094. }
  1095. static int lm49453_ep_mute(struct snd_soc_dai *dai, int mute)
  1096. {
  1097. snd_soc_update_bits(dai->codec, LM49453_P0_DAC_DSP_REG, BIT(4),
  1098. (mute ? BIT(4) : 0));
  1099. return 0;
  1100. }
  1101. static int lm49453_ha_mute(struct snd_soc_dai *dai, int mute)
  1102. {
  1103. snd_soc_update_bits(dai->codec, LM49453_P0_DAC_DSP_REG, BIT(7)|BIT(6),
  1104. (mute ? (BIT(7)|BIT(6)) : 0));
  1105. return 0;
  1106. }
  1107. static int lm49453_set_bias_level(struct snd_soc_codec *codec,
  1108. enum snd_soc_bias_level level)
  1109. {
  1110. struct lm49453_priv *lm49453 = snd_soc_codec_get_drvdata(codec);
  1111. switch (level) {
  1112. case SND_SOC_BIAS_ON:
  1113. case SND_SOC_BIAS_PREPARE:
  1114. break;
  1115. case SND_SOC_BIAS_STANDBY:
  1116. if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF)
  1117. regcache_sync(lm49453->regmap);
  1118. snd_soc_update_bits(codec, LM49453_P0_PMC_SETUP_REG,
  1119. LM49453_PMC_SETUP_CHIP_EN, LM49453_CHIP_EN);
  1120. break;
  1121. case SND_SOC_BIAS_OFF:
  1122. snd_soc_update_bits(codec, LM49453_P0_PMC_SETUP_REG,
  1123. LM49453_PMC_SETUP_CHIP_EN, 0);
  1124. break;
  1125. }
  1126. return 0;
  1127. }
  1128. /* Formates supported by LM49453 driver. */
  1129. #define LM49453_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
  1130. SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
  1131. static const struct snd_soc_dai_ops lm49453_headset_dai_ops = {
  1132. .hw_params = lm49453_hw_params,
  1133. .set_sysclk = lm49453_set_dai_sysclk,
  1134. .set_fmt = lm49453_set_dai_fmt,
  1135. .digital_mute = lm49453_hp_mute,
  1136. };
  1137. static const struct snd_soc_dai_ops lm49453_speaker_dai_ops = {
  1138. .hw_params = lm49453_hw_params,
  1139. .set_sysclk = lm49453_set_dai_sysclk,
  1140. .set_fmt = lm49453_set_dai_fmt,
  1141. .digital_mute = lm49453_ls_mute,
  1142. };
  1143. static const struct snd_soc_dai_ops lm49453_haptic_dai_ops = {
  1144. .hw_params = lm49453_hw_params,
  1145. .set_sysclk = lm49453_set_dai_sysclk,
  1146. .set_fmt = lm49453_set_dai_fmt,
  1147. .digital_mute = lm49453_ha_mute,
  1148. };
  1149. static const struct snd_soc_dai_ops lm49453_ep_dai_ops = {
  1150. .hw_params = lm49453_hw_params,
  1151. .set_sysclk = lm49453_set_dai_sysclk,
  1152. .set_fmt = lm49453_set_dai_fmt,
  1153. .digital_mute = lm49453_ep_mute,
  1154. };
  1155. static const struct snd_soc_dai_ops lm49453_lineout_dai_ops = {
  1156. .hw_params = lm49453_hw_params,
  1157. .set_sysclk = lm49453_set_dai_sysclk,
  1158. .set_fmt = lm49453_set_dai_fmt,
  1159. .digital_mute = lm49453_lo_mute,
  1160. };
  1161. /* LM49453 dai structure. */
  1162. static struct snd_soc_dai_driver lm49453_dai[] = {
  1163. {
  1164. .name = "LM49453 Headset",
  1165. .playback = {
  1166. .stream_name = "Headset",
  1167. .channels_min = 2,
  1168. .channels_max = 2,
  1169. .rates = SNDRV_PCM_RATE_8000_192000,
  1170. .formats = LM49453_FORMATS,
  1171. },
  1172. .capture = {
  1173. .stream_name = "Capture",
  1174. .channels_min = 1,
  1175. .channels_max = 5,
  1176. .rates = SNDRV_PCM_RATE_8000_192000,
  1177. .formats = LM49453_FORMATS,
  1178. },
  1179. .ops = &lm49453_headset_dai_ops,
  1180. .symmetric_rates = 1,
  1181. },
  1182. {
  1183. .name = "LM49453 Speaker",
  1184. .playback = {
  1185. .stream_name = "Speaker",
  1186. .channels_min = 2,
  1187. .channels_max = 2,
  1188. .rates = SNDRV_PCM_RATE_8000_192000,
  1189. .formats = LM49453_FORMATS,
  1190. },
  1191. .ops = &lm49453_speaker_dai_ops,
  1192. },
  1193. {
  1194. .name = "LM49453 Haptic",
  1195. .playback = {
  1196. .stream_name = "Haptic",
  1197. .channels_min = 2,
  1198. .channels_max = 2,
  1199. .rates = SNDRV_PCM_RATE_8000_192000,
  1200. .formats = LM49453_FORMATS,
  1201. },
  1202. .ops = &lm49453_haptic_dai_ops,
  1203. },
  1204. {
  1205. .name = "LM49453 Earpiece",
  1206. .playback = {
  1207. .stream_name = "Earpiece",
  1208. .channels_min = 1,
  1209. .channels_max = 1,
  1210. .rates = SNDRV_PCM_RATE_8000_192000,
  1211. .formats = LM49453_FORMATS,
  1212. },
  1213. .ops = &lm49453_ep_dai_ops,
  1214. },
  1215. {
  1216. .name = "LM49453 line out",
  1217. .playback = {
  1218. .stream_name = "Lineout",
  1219. .channels_min = 2,
  1220. .channels_max = 2,
  1221. .rates = SNDRV_PCM_RATE_8000_192000,
  1222. .formats = LM49453_FORMATS,
  1223. },
  1224. .ops = &lm49453_lineout_dai_ops,
  1225. },
  1226. };
  1227. static struct snd_soc_codec_driver soc_codec_dev_lm49453 = {
  1228. .set_bias_level = lm49453_set_bias_level,
  1229. .component_driver = {
  1230. .controls = lm49453_snd_controls,
  1231. .num_controls = ARRAY_SIZE(lm49453_snd_controls),
  1232. .dapm_widgets = lm49453_dapm_widgets,
  1233. .num_dapm_widgets = ARRAY_SIZE(lm49453_dapm_widgets),
  1234. .dapm_routes = lm49453_audio_map,
  1235. .num_dapm_routes = ARRAY_SIZE(lm49453_audio_map),
  1236. },
  1237. .idle_bias_off = true,
  1238. };
  1239. static const struct regmap_config lm49453_regmap_config = {
  1240. .reg_bits = 8,
  1241. .val_bits = 8,
  1242. .max_register = LM49453_MAX_REGISTER,
  1243. .reg_defaults = lm49453_reg_defs,
  1244. .num_reg_defaults = ARRAY_SIZE(lm49453_reg_defs),
  1245. .cache_type = REGCACHE_RBTREE,
  1246. };
  1247. static int lm49453_i2c_probe(struct i2c_client *i2c,
  1248. const struct i2c_device_id *id)
  1249. {
  1250. struct lm49453_priv *lm49453;
  1251. int ret = 0;
  1252. lm49453 = devm_kzalloc(&i2c->dev, sizeof(struct lm49453_priv),
  1253. GFP_KERNEL);
  1254. if (lm49453 == NULL)
  1255. return -ENOMEM;
  1256. i2c_set_clientdata(i2c, lm49453);
  1257. lm49453->regmap = devm_regmap_init_i2c(i2c, &lm49453_regmap_config);
  1258. if (IS_ERR(lm49453->regmap)) {
  1259. ret = PTR_ERR(lm49453->regmap);
  1260. dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
  1261. ret);
  1262. return ret;
  1263. }
  1264. ret = snd_soc_register_codec(&i2c->dev,
  1265. &soc_codec_dev_lm49453,
  1266. lm49453_dai, ARRAY_SIZE(lm49453_dai));
  1267. if (ret < 0)
  1268. dev_err(&i2c->dev, "Failed to register codec: %d\n", ret);
  1269. return ret;
  1270. }
  1271. static int lm49453_i2c_remove(struct i2c_client *client)
  1272. {
  1273. snd_soc_unregister_codec(&client->dev);
  1274. return 0;
  1275. }
  1276. static const struct i2c_device_id lm49453_i2c_id[] = {
  1277. { "lm49453", 0 },
  1278. { }
  1279. };
  1280. MODULE_DEVICE_TABLE(i2c, lm49453_i2c_id);
  1281. static struct i2c_driver lm49453_i2c_driver = {
  1282. .driver = {
  1283. .name = "lm49453",
  1284. },
  1285. .probe = lm49453_i2c_probe,
  1286. .remove = lm49453_i2c_remove,
  1287. .id_table = lm49453_i2c_id,
  1288. };
  1289. module_i2c_driver(lm49453_i2c_driver);
  1290. MODULE_DESCRIPTION("ASoC LM49453 driver");
  1291. MODULE_AUTHOR("M R Swami Reddy <MR.Swami.Reddy@ti.com>");
  1292. MODULE_LICENSE("GPL v2");