cs42l73.c 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415
  1. /*
  2. * cs42l73.c -- CS42L73 ALSA Soc Audio driver
  3. *
  4. * Copyright 2011 Cirrus Logic, Inc.
  5. *
  6. * Authors: Georgi Vlaev, Nucleus Systems Ltd, <joe@nucleusys.com>
  7. * Brian Austin, Cirrus Logic Inc, <brian.austin@cirrus.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. *
  13. */
  14. #include <linux/module.h>
  15. #include <linux/moduleparam.h>
  16. #include <linux/kernel.h>
  17. #include <linux/init.h>
  18. #include <linux/delay.h>
  19. #include <linux/of_gpio.h>
  20. #include <linux/pm.h>
  21. #include <linux/i2c.h>
  22. #include <linux/regmap.h>
  23. #include <linux/slab.h>
  24. #include <sound/core.h>
  25. #include <sound/pcm.h>
  26. #include <sound/pcm_params.h>
  27. #include <sound/soc.h>
  28. #include <sound/soc-dapm.h>
  29. #include <sound/initval.h>
  30. #include <sound/tlv.h>
  31. #include <sound/cs42l73.h>
  32. #include "cs42l73.h"
  33. struct sp_config {
  34. u8 spc, mmcc, spfs;
  35. u32 srate;
  36. };
  37. struct cs42l73_private {
  38. struct cs42l73_platform_data pdata;
  39. struct sp_config config[3];
  40. struct regmap *regmap;
  41. u32 sysclk;
  42. u8 mclksel;
  43. u32 mclk;
  44. int shutdwn_delay;
  45. };
  46. static const struct reg_default cs42l73_reg_defaults[] = {
  47. { 6, 0xF1 }, /* r06 - Power Ctl 1 */
  48. { 7, 0xDF }, /* r07 - Power Ctl 2 */
  49. { 8, 0x3F }, /* r08 - Power Ctl 3 */
  50. { 9, 0x50 }, /* r09 - Charge Pump Freq */
  51. { 10, 0x53 }, /* r0A - Output Load MicBias Short Detect */
  52. { 11, 0x00 }, /* r0B - DMIC Master Clock Ctl */
  53. { 12, 0x00 }, /* r0C - Aux PCM Ctl */
  54. { 13, 0x15 }, /* r0D - Aux PCM Master Clock Ctl */
  55. { 14, 0x00 }, /* r0E - Audio PCM Ctl */
  56. { 15, 0x15 }, /* r0F - Audio PCM Master Clock Ctl */
  57. { 16, 0x00 }, /* r10 - Voice PCM Ctl */
  58. { 17, 0x15 }, /* r11 - Voice PCM Master Clock Ctl */
  59. { 18, 0x00 }, /* r12 - Voice/Aux Sample Rate */
  60. { 19, 0x06 }, /* r13 - Misc I/O Path Ctl */
  61. { 20, 0x00 }, /* r14 - ADC Input Path Ctl */
  62. { 21, 0x00 }, /* r15 - MICA Preamp, PGA Volume */
  63. { 22, 0x00 }, /* r16 - MICB Preamp, PGA Volume */
  64. { 23, 0x00 }, /* r17 - Input Path A Digital Volume */
  65. { 24, 0x00 }, /* r18 - Input Path B Digital Volume */
  66. { 25, 0x00 }, /* r19 - Playback Digital Ctl */
  67. { 26, 0x00 }, /* r1A - HP/LO Left Digital Volume */
  68. { 27, 0x00 }, /* r1B - HP/LO Right Digital Volume */
  69. { 28, 0x00 }, /* r1C - Speakerphone Digital Volume */
  70. { 29, 0x00 }, /* r1D - Ear/SPKLO Digital Volume */
  71. { 30, 0x00 }, /* r1E - HP Left Analog Volume */
  72. { 31, 0x00 }, /* r1F - HP Right Analog Volume */
  73. { 32, 0x00 }, /* r20 - LO Left Analog Volume */
  74. { 33, 0x00 }, /* r21 - LO Right Analog Volume */
  75. { 34, 0x00 }, /* r22 - Stereo Input Path Advisory Volume */
  76. { 35, 0x00 }, /* r23 - Aux PCM Input Advisory Volume */
  77. { 36, 0x00 }, /* r24 - Audio PCM Input Advisory Volume */
  78. { 37, 0x00 }, /* r25 - Voice PCM Input Advisory Volume */
  79. { 38, 0x00 }, /* r26 - Limiter Attack Rate HP/LO */
  80. { 39, 0x7F }, /* r27 - Limter Ctl, Release Rate HP/LO */
  81. { 40, 0x00 }, /* r28 - Limter Threshold HP/LO */
  82. { 41, 0x00 }, /* r29 - Limiter Attack Rate Speakerphone */
  83. { 42, 0x3F }, /* r2A - Limter Ctl, Release Rate Speakerphone */
  84. { 43, 0x00 }, /* r2B - Limter Threshold Speakerphone */
  85. { 44, 0x00 }, /* r2C - Limiter Attack Rate Ear/SPKLO */
  86. { 45, 0x3F }, /* r2D - Limter Ctl, Release Rate Ear/SPKLO */
  87. { 46, 0x00 }, /* r2E - Limter Threshold Ear/SPKLO */
  88. { 47, 0x00 }, /* r2F - ALC Enable, Attack Rate Left/Right */
  89. { 48, 0x3F }, /* r30 - ALC Release Rate Left/Right */
  90. { 49, 0x00 }, /* r31 - ALC Threshold Left/Right */
  91. { 50, 0x00 }, /* r32 - Noise Gate Ctl Left/Right */
  92. { 51, 0x00 }, /* r33 - ALC/NG Misc Ctl */
  93. { 52, 0x18 }, /* r34 - Mixer Ctl */
  94. { 53, 0x3F }, /* r35 - HP/LO Left Mixer Input Path Volume */
  95. { 54, 0x3F }, /* r36 - HP/LO Right Mixer Input Path Volume */
  96. { 55, 0x3F }, /* r37 - HP/LO Left Mixer Aux PCM Volume */
  97. { 56, 0x3F }, /* r38 - HP/LO Right Mixer Aux PCM Volume */
  98. { 57, 0x3F }, /* r39 - HP/LO Left Mixer Audio PCM Volume */
  99. { 58, 0x3F }, /* r3A - HP/LO Right Mixer Audio PCM Volume */
  100. { 59, 0x3F }, /* r3B - HP/LO Left Mixer Voice PCM Mono Volume */
  101. { 60, 0x3F }, /* r3C - HP/LO Right Mixer Voice PCM Mono Volume */
  102. { 61, 0x3F }, /* r3D - Aux PCM Left Mixer Input Path Volume */
  103. { 62, 0x3F }, /* r3E - Aux PCM Right Mixer Input Path Volume */
  104. { 63, 0x3F }, /* r3F - Aux PCM Left Mixer Volume */
  105. { 64, 0x3F }, /* r40 - Aux PCM Left Mixer Volume */
  106. { 65, 0x3F }, /* r41 - Aux PCM Left Mixer Audio PCM L Volume */
  107. { 66, 0x3F }, /* r42 - Aux PCM Right Mixer Audio PCM R Volume */
  108. { 67, 0x3F }, /* r43 - Aux PCM Left Mixer Voice PCM Volume */
  109. { 68, 0x3F }, /* r44 - Aux PCM Right Mixer Voice PCM Volume */
  110. { 69, 0x3F }, /* r45 - Audio PCM Left Input Path Volume */
  111. { 70, 0x3F }, /* r46 - Audio PCM Right Input Path Volume */
  112. { 71, 0x3F }, /* r47 - Audio PCM Left Mixer Aux PCM L Volume */
  113. { 72, 0x3F }, /* r48 - Audio PCM Right Mixer Aux PCM R Volume */
  114. { 73, 0x3F }, /* r49 - Audio PCM Left Mixer Volume */
  115. { 74, 0x3F }, /* r4A - Audio PCM Right Mixer Volume */
  116. { 75, 0x3F }, /* r4B - Audio PCM Left Mixer Voice PCM Volume */
  117. { 76, 0x3F }, /* r4C - Audio PCM Right Mixer Voice PCM Volume */
  118. { 77, 0x3F }, /* r4D - Voice PCM Left Input Path Volume */
  119. { 78, 0x3F }, /* r4E - Voice PCM Right Input Path Volume */
  120. { 79, 0x3F }, /* r4F - Voice PCM Left Mixer Aux PCM L Volume */
  121. { 80, 0x3F }, /* r50 - Voice PCM Right Mixer Aux PCM R Volume */
  122. { 81, 0x3F }, /* r51 - Voice PCM Left Mixer Audio PCM L Volume */
  123. { 82, 0x3F }, /* r52 - Voice PCM Right Mixer Audio PCM R Volume */
  124. { 83, 0x3F }, /* r53 - Voice PCM Left Mixer Voice PCM Volume */
  125. { 84, 0x3F }, /* r54 - Voice PCM Right Mixer Voice PCM Volume */
  126. { 85, 0xAA }, /* r55 - Mono Mixer Ctl */
  127. { 86, 0x3F }, /* r56 - SPK Mono Mixer Input Path Volume */
  128. { 87, 0x3F }, /* r57 - SPK Mono Mixer Aux PCM Mono/L/R Volume */
  129. { 88, 0x3F }, /* r58 - SPK Mono Mixer Audio PCM Mono/L/R Volume */
  130. { 89, 0x3F }, /* r59 - SPK Mono Mixer Voice PCM Mono Volume */
  131. { 90, 0x3F }, /* r5A - SPKLO Mono Mixer Input Path Mono Volume */
  132. { 91, 0x3F }, /* r5B - SPKLO Mono Mixer Aux Mono/L/R Volume */
  133. { 92, 0x3F }, /* r5C - SPKLO Mono Mixer Audio Mono/L/R Volume */
  134. { 93, 0x3F }, /* r5D - SPKLO Mono Mixer Voice Mono Volume */
  135. { 94, 0x00 }, /* r5E - Interrupt Mask 1 */
  136. { 95, 0x00 }, /* r5F - Interrupt Mask 2 */
  137. };
  138. static bool cs42l73_volatile_register(struct device *dev, unsigned int reg)
  139. {
  140. switch (reg) {
  141. case CS42L73_IS1:
  142. case CS42L73_IS2:
  143. return true;
  144. default:
  145. return false;
  146. }
  147. }
  148. static bool cs42l73_readable_register(struct device *dev, unsigned int reg)
  149. {
  150. switch (reg) {
  151. case CS42L73_DEVID_AB ... CS42L73_DEVID_E:
  152. case CS42L73_REVID ... CS42L73_IM2:
  153. return true;
  154. default:
  155. return false;
  156. }
  157. }
  158. static const DECLARE_TLV_DB_RANGE(hpaloa_tlv,
  159. 0, 13, TLV_DB_SCALE_ITEM(-7600, 200, 0),
  160. 14, 75, TLV_DB_SCALE_ITEM(-4900, 100, 0)
  161. );
  162. static DECLARE_TLV_DB_SCALE(adc_boost_tlv, 0, 2500, 0);
  163. static DECLARE_TLV_DB_SCALE(hl_tlv, -10200, 50, 0);
  164. static DECLARE_TLV_DB_SCALE(ipd_tlv, -9600, 100, 0);
  165. static DECLARE_TLV_DB_SCALE(micpga_tlv, -600, 50, 0);
  166. static const DECLARE_TLV_DB_RANGE(limiter_tlv,
  167. 0, 2, TLV_DB_SCALE_ITEM(-3000, 600, 0),
  168. 3, 7, TLV_DB_SCALE_ITEM(-1200, 300, 0)
  169. );
  170. static const DECLARE_TLV_DB_SCALE(attn_tlv, -6300, 100, 1);
  171. static const char * const cs42l73_pgaa_text[] = { "Line A", "Mic 1" };
  172. static const char * const cs42l73_pgab_text[] = { "Line B", "Mic 2" };
  173. static SOC_ENUM_SINGLE_DECL(pgaa_enum,
  174. CS42L73_ADCIPC, 3,
  175. cs42l73_pgaa_text);
  176. static SOC_ENUM_SINGLE_DECL(pgab_enum,
  177. CS42L73_ADCIPC, 7,
  178. cs42l73_pgab_text);
  179. static const struct snd_kcontrol_new pgaa_mux =
  180. SOC_DAPM_ENUM("Left Analog Input Capture Mux", pgaa_enum);
  181. static const struct snd_kcontrol_new pgab_mux =
  182. SOC_DAPM_ENUM("Right Analog Input Capture Mux", pgab_enum);
  183. static const struct snd_kcontrol_new input_left_mixer[] = {
  184. SOC_DAPM_SINGLE("ADC Left Input", CS42L73_PWRCTL1,
  185. 5, 1, 1),
  186. SOC_DAPM_SINGLE("DMIC Left Input", CS42L73_PWRCTL1,
  187. 4, 1, 1),
  188. };
  189. static const struct snd_kcontrol_new input_right_mixer[] = {
  190. SOC_DAPM_SINGLE("ADC Right Input", CS42L73_PWRCTL1,
  191. 7, 1, 1),
  192. SOC_DAPM_SINGLE("DMIC Right Input", CS42L73_PWRCTL1,
  193. 6, 1, 1),
  194. };
  195. static const char * const cs42l73_ng_delay_text[] = {
  196. "50ms", "100ms", "150ms", "200ms" };
  197. static SOC_ENUM_SINGLE_DECL(ng_delay_enum,
  198. CS42L73_NGCAB, 0,
  199. cs42l73_ng_delay_text);
  200. static const char * const cs42l73_mono_mix_texts[] = {
  201. "Left", "Right", "Mono Mix"};
  202. static const unsigned int cs42l73_mono_mix_values[] = { 0, 1, 2 };
  203. static const struct soc_enum spk_asp_enum =
  204. SOC_VALUE_ENUM_SINGLE(CS42L73_MMIXCTL, 6, 3,
  205. ARRAY_SIZE(cs42l73_mono_mix_texts),
  206. cs42l73_mono_mix_texts,
  207. cs42l73_mono_mix_values);
  208. static const struct snd_kcontrol_new spk_asp_mixer =
  209. SOC_DAPM_ENUM("Route", spk_asp_enum);
  210. static const struct soc_enum spk_xsp_enum =
  211. SOC_VALUE_ENUM_SINGLE(CS42L73_MMIXCTL, 4, 3,
  212. ARRAY_SIZE(cs42l73_mono_mix_texts),
  213. cs42l73_mono_mix_texts,
  214. cs42l73_mono_mix_values);
  215. static const struct snd_kcontrol_new spk_xsp_mixer =
  216. SOC_DAPM_ENUM("Route", spk_xsp_enum);
  217. static const struct soc_enum esl_asp_enum =
  218. SOC_VALUE_ENUM_SINGLE(CS42L73_MMIXCTL, 2, 3,
  219. ARRAY_SIZE(cs42l73_mono_mix_texts),
  220. cs42l73_mono_mix_texts,
  221. cs42l73_mono_mix_values);
  222. static const struct snd_kcontrol_new esl_asp_mixer =
  223. SOC_DAPM_ENUM("Route", esl_asp_enum);
  224. static const struct soc_enum esl_xsp_enum =
  225. SOC_VALUE_ENUM_SINGLE(CS42L73_MMIXCTL, 0, 3,
  226. ARRAY_SIZE(cs42l73_mono_mix_texts),
  227. cs42l73_mono_mix_texts,
  228. cs42l73_mono_mix_values);
  229. static const struct snd_kcontrol_new esl_xsp_mixer =
  230. SOC_DAPM_ENUM("Route", esl_xsp_enum);
  231. static const char * const cs42l73_ip_swap_text[] = {
  232. "Stereo", "Mono A", "Mono B", "Swap A-B"};
  233. static SOC_ENUM_SINGLE_DECL(ip_swap_enum,
  234. CS42L73_MIOPC, 6,
  235. cs42l73_ip_swap_text);
  236. static const char * const cs42l73_spo_mixer_text[] = {"Mono", "Stereo"};
  237. static SOC_ENUM_SINGLE_DECL(vsp_output_mux_enum,
  238. CS42L73_MIXERCTL, 5,
  239. cs42l73_spo_mixer_text);
  240. static SOC_ENUM_SINGLE_DECL(xsp_output_mux_enum,
  241. CS42L73_MIXERCTL, 4,
  242. cs42l73_spo_mixer_text);
  243. static const struct snd_kcontrol_new vsp_output_mux =
  244. SOC_DAPM_ENUM("Route", vsp_output_mux_enum);
  245. static const struct snd_kcontrol_new xsp_output_mux =
  246. SOC_DAPM_ENUM("Route", xsp_output_mux_enum);
  247. static const struct snd_kcontrol_new hp_amp_ctl =
  248. SOC_DAPM_SINGLE("Switch", CS42L73_PWRCTL3, 0, 1, 1);
  249. static const struct snd_kcontrol_new lo_amp_ctl =
  250. SOC_DAPM_SINGLE("Switch", CS42L73_PWRCTL3, 1, 1, 1);
  251. static const struct snd_kcontrol_new spk_amp_ctl =
  252. SOC_DAPM_SINGLE("Switch", CS42L73_PWRCTL3, 2, 1, 1);
  253. static const struct snd_kcontrol_new spklo_amp_ctl =
  254. SOC_DAPM_SINGLE("Switch", CS42L73_PWRCTL3, 4, 1, 1);
  255. static const struct snd_kcontrol_new ear_amp_ctl =
  256. SOC_DAPM_SINGLE("Switch", CS42L73_PWRCTL3, 3, 1, 1);
  257. static const struct snd_kcontrol_new cs42l73_snd_controls[] = {
  258. SOC_DOUBLE_R_SX_TLV("Headphone Analog Playback Volume",
  259. CS42L73_HPAAVOL, CS42L73_HPBAVOL, 0,
  260. 0x41, 0x4B, hpaloa_tlv),
  261. SOC_DOUBLE_R_SX_TLV("LineOut Analog Playback Volume", CS42L73_LOAAVOL,
  262. CS42L73_LOBAVOL, 0, 0x41, 0x4B, hpaloa_tlv),
  263. SOC_DOUBLE_R_SX_TLV("Input PGA Analog Volume", CS42L73_MICAPREPGAAVOL,
  264. CS42L73_MICBPREPGABVOL, 0, 0x34,
  265. 0x24, micpga_tlv),
  266. SOC_DOUBLE_R("MIC Preamp Switch", CS42L73_MICAPREPGAAVOL,
  267. CS42L73_MICBPREPGABVOL, 6, 1, 1),
  268. SOC_DOUBLE_R_SX_TLV("Input Path Digital Volume", CS42L73_IPADVOL,
  269. CS42L73_IPBDVOL, 0, 0xA0, 0x6C, ipd_tlv),
  270. SOC_DOUBLE_R_SX_TLV("HL Digital Playback Volume",
  271. CS42L73_HLADVOL, CS42L73_HLBDVOL,
  272. 0, 0x34, 0xE4, hl_tlv),
  273. SOC_SINGLE_TLV("ADC A Boost Volume",
  274. CS42L73_ADCIPC, 2, 0x01, 1, adc_boost_tlv),
  275. SOC_SINGLE_TLV("ADC B Boost Volume",
  276. CS42L73_ADCIPC, 6, 0x01, 1, adc_boost_tlv),
  277. SOC_SINGLE_SX_TLV("Speakerphone Digital Volume",
  278. CS42L73_SPKDVOL, 0, 0x34, 0xE4, hl_tlv),
  279. SOC_SINGLE_SX_TLV("Ear Speaker Digital Volume",
  280. CS42L73_ESLDVOL, 0, 0x34, 0xE4, hl_tlv),
  281. SOC_DOUBLE_R("Headphone Analog Playback Switch", CS42L73_HPAAVOL,
  282. CS42L73_HPBAVOL, 7, 1, 1),
  283. SOC_DOUBLE_R("LineOut Analog Playback Switch", CS42L73_LOAAVOL,
  284. CS42L73_LOBAVOL, 7, 1, 1),
  285. SOC_DOUBLE("Input Path Digital Switch", CS42L73_ADCIPC, 0, 4, 1, 1),
  286. SOC_DOUBLE("HL Digital Playback Switch", CS42L73_PBDC, 0,
  287. 1, 1, 1),
  288. SOC_SINGLE("Speakerphone Digital Playback Switch", CS42L73_PBDC, 2, 1,
  289. 1),
  290. SOC_SINGLE("Ear Speaker Digital Playback Switch", CS42L73_PBDC, 3, 1,
  291. 1),
  292. SOC_SINGLE("PGA Soft-Ramp Switch", CS42L73_MIOPC, 3, 1, 0),
  293. SOC_SINGLE("Analog Zero Cross Switch", CS42L73_MIOPC, 2, 1, 0),
  294. SOC_SINGLE("Digital Soft-Ramp Switch", CS42L73_MIOPC, 1, 1, 0),
  295. SOC_SINGLE("Analog Output Soft-Ramp Switch", CS42L73_MIOPC, 0, 1, 0),
  296. SOC_DOUBLE("ADC Signal Polarity Switch", CS42L73_ADCIPC, 1, 5, 1,
  297. 0),
  298. SOC_SINGLE("HL Limiter Attack Rate", CS42L73_LIMARATEHL, 0, 0x3F,
  299. 0),
  300. SOC_SINGLE("HL Limiter Release Rate", CS42L73_LIMRRATEHL, 0,
  301. 0x3F, 0),
  302. SOC_SINGLE("HL Limiter Switch", CS42L73_LIMRRATEHL, 7, 1, 0),
  303. SOC_SINGLE("HL Limiter All Channels Switch", CS42L73_LIMRRATEHL, 6, 1,
  304. 0),
  305. SOC_SINGLE_TLV("HL Limiter Max Threshold Volume", CS42L73_LMAXHL, 5, 7,
  306. 1, limiter_tlv),
  307. SOC_SINGLE_TLV("HL Limiter Cushion Volume", CS42L73_LMAXHL, 2, 7, 1,
  308. limiter_tlv),
  309. SOC_SINGLE("SPK Limiter Attack Rate Volume", CS42L73_LIMARATESPK, 0,
  310. 0x3F, 0),
  311. SOC_SINGLE("SPK Limiter Release Rate Volume", CS42L73_LIMRRATESPK, 0,
  312. 0x3F, 0),
  313. SOC_SINGLE("SPK Limiter Switch", CS42L73_LIMRRATESPK, 7, 1, 0),
  314. SOC_SINGLE("SPK Limiter All Channels Switch", CS42L73_LIMRRATESPK,
  315. 6, 1, 0),
  316. SOC_SINGLE_TLV("SPK Limiter Max Threshold Volume", CS42L73_LMAXSPK, 5,
  317. 7, 1, limiter_tlv),
  318. SOC_SINGLE_TLV("SPK Limiter Cushion Volume", CS42L73_LMAXSPK, 2, 7, 1,
  319. limiter_tlv),
  320. SOC_SINGLE("ESL Limiter Attack Rate Volume", CS42L73_LIMARATEESL, 0,
  321. 0x3F, 0),
  322. SOC_SINGLE("ESL Limiter Release Rate Volume", CS42L73_LIMRRATEESL, 0,
  323. 0x3F, 0),
  324. SOC_SINGLE("ESL Limiter Switch", CS42L73_LIMRRATEESL, 7, 1, 0),
  325. SOC_SINGLE_TLV("ESL Limiter Max Threshold Volume", CS42L73_LMAXESL, 5,
  326. 7, 1, limiter_tlv),
  327. SOC_SINGLE_TLV("ESL Limiter Cushion Volume", CS42L73_LMAXESL, 2, 7, 1,
  328. limiter_tlv),
  329. SOC_SINGLE("ALC Attack Rate Volume", CS42L73_ALCARATE, 0, 0x3F, 0),
  330. SOC_SINGLE("ALC Release Rate Volume", CS42L73_ALCRRATE, 0, 0x3F, 0),
  331. SOC_DOUBLE("ALC Switch", CS42L73_ALCARATE, 6, 7, 1, 0),
  332. SOC_SINGLE_TLV("ALC Max Threshold Volume", CS42L73_ALCMINMAX, 5, 7, 0,
  333. limiter_tlv),
  334. SOC_SINGLE_TLV("ALC Min Threshold Volume", CS42L73_ALCMINMAX, 2, 7, 0,
  335. limiter_tlv),
  336. SOC_DOUBLE("NG Enable Switch", CS42L73_NGCAB, 6, 7, 1, 0),
  337. SOC_SINGLE("NG Boost Switch", CS42L73_NGCAB, 5, 1, 0),
  338. /*
  339. NG Threshold depends on NG_BOOTSAB, which selects
  340. between two threshold scales in decibels.
  341. Set linear values for now ..
  342. */
  343. SOC_SINGLE("NG Threshold", CS42L73_NGCAB, 2, 7, 0),
  344. SOC_ENUM("NG Delay", ng_delay_enum),
  345. SOC_DOUBLE_R_TLV("XSP-IP Volume",
  346. CS42L73_XSPAIPAA, CS42L73_XSPBIPBA, 0, 0x3F, 1,
  347. attn_tlv),
  348. SOC_DOUBLE_R_TLV("XSP-XSP Volume",
  349. CS42L73_XSPAXSPAA, CS42L73_XSPBXSPBA, 0, 0x3F, 1,
  350. attn_tlv),
  351. SOC_DOUBLE_R_TLV("XSP-ASP Volume",
  352. CS42L73_XSPAASPAA, CS42L73_XSPAASPBA, 0, 0x3F, 1,
  353. attn_tlv),
  354. SOC_DOUBLE_R_TLV("XSP-VSP Volume",
  355. CS42L73_XSPAVSPMA, CS42L73_XSPBVSPMA, 0, 0x3F, 1,
  356. attn_tlv),
  357. SOC_DOUBLE_R_TLV("ASP-IP Volume",
  358. CS42L73_ASPAIPAA, CS42L73_ASPBIPBA, 0, 0x3F, 1,
  359. attn_tlv),
  360. SOC_DOUBLE_R_TLV("ASP-XSP Volume",
  361. CS42L73_ASPAXSPAA, CS42L73_ASPBXSPBA, 0, 0x3F, 1,
  362. attn_tlv),
  363. SOC_DOUBLE_R_TLV("ASP-ASP Volume",
  364. CS42L73_ASPAASPAA, CS42L73_ASPBASPBA, 0, 0x3F, 1,
  365. attn_tlv),
  366. SOC_DOUBLE_R_TLV("ASP-VSP Volume",
  367. CS42L73_ASPAVSPMA, CS42L73_ASPBVSPMA, 0, 0x3F, 1,
  368. attn_tlv),
  369. SOC_DOUBLE_R_TLV("VSP-IP Volume",
  370. CS42L73_VSPAIPAA, CS42L73_VSPBIPBA, 0, 0x3F, 1,
  371. attn_tlv),
  372. SOC_DOUBLE_R_TLV("VSP-XSP Volume",
  373. CS42L73_VSPAXSPAA, CS42L73_VSPBXSPBA, 0, 0x3F, 1,
  374. attn_tlv),
  375. SOC_DOUBLE_R_TLV("VSP-ASP Volume",
  376. CS42L73_VSPAASPAA, CS42L73_VSPBASPBA, 0, 0x3F, 1,
  377. attn_tlv),
  378. SOC_DOUBLE_R_TLV("VSP-VSP Volume",
  379. CS42L73_VSPAVSPMA, CS42L73_VSPBVSPMA, 0, 0x3F, 1,
  380. attn_tlv),
  381. SOC_DOUBLE_R_TLV("HL-IP Volume",
  382. CS42L73_HLAIPAA, CS42L73_HLBIPBA, 0, 0x3F, 1,
  383. attn_tlv),
  384. SOC_DOUBLE_R_TLV("HL-XSP Volume",
  385. CS42L73_HLAXSPAA, CS42L73_HLBXSPBA, 0, 0x3F, 1,
  386. attn_tlv),
  387. SOC_DOUBLE_R_TLV("HL-ASP Volume",
  388. CS42L73_HLAASPAA, CS42L73_HLBASPBA, 0, 0x3F, 1,
  389. attn_tlv),
  390. SOC_DOUBLE_R_TLV("HL-VSP Volume",
  391. CS42L73_HLAVSPMA, CS42L73_HLBVSPMA, 0, 0x3F, 1,
  392. attn_tlv),
  393. SOC_SINGLE_TLV("SPK-IP Mono Volume",
  394. CS42L73_SPKMIPMA, 0, 0x3F, 1, attn_tlv),
  395. SOC_SINGLE_TLV("SPK-XSP Mono Volume",
  396. CS42L73_SPKMXSPA, 0, 0x3F, 1, attn_tlv),
  397. SOC_SINGLE_TLV("SPK-ASP Mono Volume",
  398. CS42L73_SPKMASPA, 0, 0x3F, 1, attn_tlv),
  399. SOC_SINGLE_TLV("SPK-VSP Mono Volume",
  400. CS42L73_SPKMVSPMA, 0, 0x3F, 1, attn_tlv),
  401. SOC_SINGLE_TLV("ESL-IP Mono Volume",
  402. CS42L73_ESLMIPMA, 0, 0x3F, 1, attn_tlv),
  403. SOC_SINGLE_TLV("ESL-XSP Mono Volume",
  404. CS42L73_ESLMXSPA, 0, 0x3F, 1, attn_tlv),
  405. SOC_SINGLE_TLV("ESL-ASP Mono Volume",
  406. CS42L73_ESLMASPA, 0, 0x3F, 1, attn_tlv),
  407. SOC_SINGLE_TLV("ESL-VSP Mono Volume",
  408. CS42L73_ESLMVSPMA, 0, 0x3F, 1, attn_tlv),
  409. SOC_ENUM("IP Digital Swap/Mono Select", ip_swap_enum),
  410. SOC_ENUM("VSPOUT Mono/Stereo Select", vsp_output_mux_enum),
  411. SOC_ENUM("XSPOUT Mono/Stereo Select", xsp_output_mux_enum),
  412. };
  413. static int cs42l73_spklo_spk_amp_event(struct snd_soc_dapm_widget *w,
  414. struct snd_kcontrol *kcontrol, int event)
  415. {
  416. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  417. struct cs42l73_private *priv = snd_soc_codec_get_drvdata(codec);
  418. switch (event) {
  419. case SND_SOC_DAPM_POST_PMD:
  420. /* 150 ms delay between setting PDN and MCLKDIS */
  421. priv->shutdwn_delay = 150;
  422. break;
  423. default:
  424. pr_err("Invalid event = 0x%x\n", event);
  425. }
  426. return 0;
  427. }
  428. static int cs42l73_ear_amp_event(struct snd_soc_dapm_widget *w,
  429. struct snd_kcontrol *kcontrol, int event)
  430. {
  431. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  432. struct cs42l73_private *priv = snd_soc_codec_get_drvdata(codec);
  433. switch (event) {
  434. case SND_SOC_DAPM_POST_PMD:
  435. /* 50 ms delay between setting PDN and MCLKDIS */
  436. if (priv->shutdwn_delay < 50)
  437. priv->shutdwn_delay = 50;
  438. break;
  439. default:
  440. pr_err("Invalid event = 0x%x\n", event);
  441. }
  442. return 0;
  443. }
  444. static int cs42l73_hp_amp_event(struct snd_soc_dapm_widget *w,
  445. struct snd_kcontrol *kcontrol, int event)
  446. {
  447. struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
  448. struct cs42l73_private *priv = snd_soc_codec_get_drvdata(codec);
  449. switch (event) {
  450. case SND_SOC_DAPM_POST_PMD:
  451. /* 30 ms delay between setting PDN and MCLKDIS */
  452. if (priv->shutdwn_delay < 30)
  453. priv->shutdwn_delay = 30;
  454. break;
  455. default:
  456. pr_err("Invalid event = 0x%x\n", event);
  457. }
  458. return 0;
  459. }
  460. static const struct snd_soc_dapm_widget cs42l73_dapm_widgets[] = {
  461. SND_SOC_DAPM_INPUT("DMICA"),
  462. SND_SOC_DAPM_INPUT("DMICB"),
  463. SND_SOC_DAPM_INPUT("LINEINA"),
  464. SND_SOC_DAPM_INPUT("LINEINB"),
  465. SND_SOC_DAPM_INPUT("MIC1"),
  466. SND_SOC_DAPM_SUPPLY("MIC1 Bias", CS42L73_PWRCTL2, 6, 1, NULL, 0),
  467. SND_SOC_DAPM_INPUT("MIC2"),
  468. SND_SOC_DAPM_SUPPLY("MIC2 Bias", CS42L73_PWRCTL2, 7, 1, NULL, 0),
  469. SND_SOC_DAPM_AIF_OUT("XSPOUTL", NULL, 0,
  470. CS42L73_PWRCTL2, 1, 1),
  471. SND_SOC_DAPM_AIF_OUT("XSPOUTR", NULL, 0,
  472. CS42L73_PWRCTL2, 1, 1),
  473. SND_SOC_DAPM_AIF_OUT("ASPOUTL", NULL, 0,
  474. CS42L73_PWRCTL2, 3, 1),
  475. SND_SOC_DAPM_AIF_OUT("ASPOUTR", NULL, 0,
  476. CS42L73_PWRCTL2, 3, 1),
  477. SND_SOC_DAPM_AIF_OUT("VSPINOUT", NULL, 0,
  478. CS42L73_PWRCTL2, 4, 1),
  479. SND_SOC_DAPM_PGA("PGA Left", SND_SOC_NOPM, 0, 0, NULL, 0),
  480. SND_SOC_DAPM_PGA("PGA Right", SND_SOC_NOPM, 0, 0, NULL, 0),
  481. SND_SOC_DAPM_MUX("PGA Left Mux", SND_SOC_NOPM, 0, 0, &pgaa_mux),
  482. SND_SOC_DAPM_MUX("PGA Right Mux", SND_SOC_NOPM, 0, 0, &pgab_mux),
  483. SND_SOC_DAPM_ADC("ADC Left", NULL, CS42L73_PWRCTL1, 7, 1),
  484. SND_SOC_DAPM_ADC("ADC Right", NULL, CS42L73_PWRCTL1, 5, 1),
  485. SND_SOC_DAPM_ADC("DMIC Left", NULL, CS42L73_PWRCTL1, 6, 1),
  486. SND_SOC_DAPM_ADC("DMIC Right", NULL, CS42L73_PWRCTL1, 4, 1),
  487. SND_SOC_DAPM_MIXER_NAMED_CTL("Input Left Capture", SND_SOC_NOPM,
  488. 0, 0, input_left_mixer,
  489. ARRAY_SIZE(input_left_mixer)),
  490. SND_SOC_DAPM_MIXER_NAMED_CTL("Input Right Capture", SND_SOC_NOPM,
  491. 0, 0, input_right_mixer,
  492. ARRAY_SIZE(input_right_mixer)),
  493. SND_SOC_DAPM_MIXER("ASPL Output Mixer", SND_SOC_NOPM, 0, 0, NULL, 0),
  494. SND_SOC_DAPM_MIXER("ASPR Output Mixer", SND_SOC_NOPM, 0, 0, NULL, 0),
  495. SND_SOC_DAPM_MIXER("XSPL Output Mixer", SND_SOC_NOPM, 0, 0, NULL, 0),
  496. SND_SOC_DAPM_MIXER("XSPR Output Mixer", SND_SOC_NOPM, 0, 0, NULL, 0),
  497. SND_SOC_DAPM_MIXER("VSP Output Mixer", SND_SOC_NOPM, 0, 0, NULL, 0),
  498. SND_SOC_DAPM_AIF_IN("XSPINL", NULL, 0,
  499. CS42L73_PWRCTL2, 0, 1),
  500. SND_SOC_DAPM_AIF_IN("XSPINR", NULL, 0,
  501. CS42L73_PWRCTL2, 0, 1),
  502. SND_SOC_DAPM_AIF_IN("XSPINM", NULL, 0,
  503. CS42L73_PWRCTL2, 0, 1),
  504. SND_SOC_DAPM_AIF_IN("ASPINL", NULL, 0,
  505. CS42L73_PWRCTL2, 2, 1),
  506. SND_SOC_DAPM_AIF_IN("ASPINR", NULL, 0,
  507. CS42L73_PWRCTL2, 2, 1),
  508. SND_SOC_DAPM_AIF_IN("ASPINM", NULL, 0,
  509. CS42L73_PWRCTL2, 2, 1),
  510. SND_SOC_DAPM_AIF_IN("VSPINOUT", NULL, 0,
  511. CS42L73_PWRCTL2, 4, 1),
  512. SND_SOC_DAPM_MIXER("HL Left Mixer", SND_SOC_NOPM, 0, 0, NULL, 0),
  513. SND_SOC_DAPM_MIXER("HL Right Mixer", SND_SOC_NOPM, 0, 0, NULL, 0),
  514. SND_SOC_DAPM_MIXER("SPK Mixer", SND_SOC_NOPM, 0, 0, NULL, 0),
  515. SND_SOC_DAPM_MIXER("ESL Mixer", SND_SOC_NOPM, 0, 0, NULL, 0),
  516. SND_SOC_DAPM_MUX("ESL-XSP Mux", SND_SOC_NOPM,
  517. 0, 0, &esl_xsp_mixer),
  518. SND_SOC_DAPM_MUX("ESL-ASP Mux", SND_SOC_NOPM,
  519. 0, 0, &esl_asp_mixer),
  520. SND_SOC_DAPM_MUX("SPK-ASP Mux", SND_SOC_NOPM,
  521. 0, 0, &spk_asp_mixer),
  522. SND_SOC_DAPM_MUX("SPK-XSP Mux", SND_SOC_NOPM,
  523. 0, 0, &spk_xsp_mixer),
  524. SND_SOC_DAPM_PGA("HL Left DAC", SND_SOC_NOPM, 0, 0, NULL, 0),
  525. SND_SOC_DAPM_PGA("HL Right DAC", SND_SOC_NOPM, 0, 0, NULL, 0),
  526. SND_SOC_DAPM_PGA("SPK DAC", SND_SOC_NOPM, 0, 0, NULL, 0),
  527. SND_SOC_DAPM_PGA("ESL DAC", SND_SOC_NOPM, 0, 0, NULL, 0),
  528. SND_SOC_DAPM_SWITCH_E("HP Amp", CS42L73_PWRCTL3, 0, 1,
  529. &hp_amp_ctl, cs42l73_hp_amp_event,
  530. SND_SOC_DAPM_POST_PMD),
  531. SND_SOC_DAPM_SWITCH("LO Amp", CS42L73_PWRCTL3, 1, 1,
  532. &lo_amp_ctl),
  533. SND_SOC_DAPM_SWITCH_E("SPK Amp", CS42L73_PWRCTL3, 2, 1,
  534. &spk_amp_ctl, cs42l73_spklo_spk_amp_event,
  535. SND_SOC_DAPM_POST_PMD),
  536. SND_SOC_DAPM_SWITCH_E("EAR Amp", CS42L73_PWRCTL3, 3, 1,
  537. &ear_amp_ctl, cs42l73_ear_amp_event,
  538. SND_SOC_DAPM_POST_PMD),
  539. SND_SOC_DAPM_SWITCH_E("SPKLO Amp", CS42L73_PWRCTL3, 4, 1,
  540. &spklo_amp_ctl, cs42l73_spklo_spk_amp_event,
  541. SND_SOC_DAPM_POST_PMD),
  542. SND_SOC_DAPM_OUTPUT("HPOUTA"),
  543. SND_SOC_DAPM_OUTPUT("HPOUTB"),
  544. SND_SOC_DAPM_OUTPUT("LINEOUTA"),
  545. SND_SOC_DAPM_OUTPUT("LINEOUTB"),
  546. SND_SOC_DAPM_OUTPUT("EAROUT"),
  547. SND_SOC_DAPM_OUTPUT("SPKOUT"),
  548. SND_SOC_DAPM_OUTPUT("SPKLINEOUT"),
  549. };
  550. static const struct snd_soc_dapm_route cs42l73_audio_map[] = {
  551. /* SPKLO EARSPK Paths */
  552. {"EAROUT", NULL, "EAR Amp"},
  553. {"SPKLINEOUT", NULL, "SPKLO Amp"},
  554. {"EAR Amp", "Switch", "ESL DAC"},
  555. {"SPKLO Amp", "Switch", "ESL DAC"},
  556. {"ESL DAC", "ESL-ASP Mono Volume", "ESL Mixer"},
  557. {"ESL DAC", "ESL-XSP Mono Volume", "ESL Mixer"},
  558. {"ESL DAC", "ESL-VSP Mono Volume", "VSPINOUT"},
  559. /* Loopback */
  560. {"ESL DAC", "ESL-IP Mono Volume", "Input Left Capture"},
  561. {"ESL DAC", "ESL-IP Mono Volume", "Input Right Capture"},
  562. {"ESL Mixer", NULL, "ESL-ASP Mux"},
  563. {"ESL Mixer", NULL, "ESL-XSP Mux"},
  564. {"ESL-ASP Mux", "Left", "ASPINL"},
  565. {"ESL-ASP Mux", "Right", "ASPINR"},
  566. {"ESL-ASP Mux", "Mono Mix", "ASPINM"},
  567. {"ESL-XSP Mux", "Left", "XSPINL"},
  568. {"ESL-XSP Mux", "Right", "XSPINR"},
  569. {"ESL-XSP Mux", "Mono Mix", "XSPINM"},
  570. /* Speakerphone Paths */
  571. {"SPKOUT", NULL, "SPK Amp"},
  572. {"SPK Amp", "Switch", "SPK DAC"},
  573. {"SPK DAC", "SPK-ASP Mono Volume", "SPK Mixer"},
  574. {"SPK DAC", "SPK-XSP Mono Volume", "SPK Mixer"},
  575. {"SPK DAC", "SPK-VSP Mono Volume", "VSPINOUT"},
  576. /* Loopback */
  577. {"SPK DAC", "SPK-IP Mono Volume", "Input Left Capture"},
  578. {"SPK DAC", "SPK-IP Mono Volume", "Input Right Capture"},
  579. {"SPK Mixer", NULL, "SPK-ASP Mux"},
  580. {"SPK Mixer", NULL, "SPK-XSP Mux"},
  581. {"SPK-ASP Mux", "Left", "ASPINL"},
  582. {"SPK-ASP Mux", "Mono Mix", "ASPINM"},
  583. {"SPK-ASP Mux", "Right", "ASPINR"},
  584. {"SPK-XSP Mux", "Left", "XSPINL"},
  585. {"SPK-XSP Mux", "Mono Mix", "XSPINM"},
  586. {"SPK-XSP Mux", "Right", "XSPINR"},
  587. /* HP LineOUT Paths */
  588. {"HPOUTA", NULL, "HP Amp"},
  589. {"HPOUTB", NULL, "HP Amp"},
  590. {"LINEOUTA", NULL, "LO Amp"},
  591. {"LINEOUTB", NULL, "LO Amp"},
  592. {"HP Amp", "Switch", "HL Left DAC"},
  593. {"HP Amp", "Switch", "HL Right DAC"},
  594. {"LO Amp", "Switch", "HL Left DAC"},
  595. {"LO Amp", "Switch", "HL Right DAC"},
  596. {"HL Left DAC", "HL-XSP Volume", "HL Left Mixer"},
  597. {"HL Right DAC", "HL-XSP Volume", "HL Right Mixer"},
  598. {"HL Left DAC", "HL-ASP Volume", "HL Left Mixer"},
  599. {"HL Right DAC", "HL-ASP Volume", "HL Right Mixer"},
  600. {"HL Left DAC", "HL-VSP Volume", "HL Left Mixer"},
  601. {"HL Right DAC", "HL-VSP Volume", "HL Right Mixer"},
  602. /* Loopback */
  603. {"HL Left DAC", "HL-IP Volume", "HL Left Mixer"},
  604. {"HL Right DAC", "HL-IP Volume", "HL Right Mixer"},
  605. {"HL Left Mixer", NULL, "Input Left Capture"},
  606. {"HL Right Mixer", NULL, "Input Right Capture"},
  607. {"HL Left Mixer", NULL, "ASPINL"},
  608. {"HL Right Mixer", NULL, "ASPINR"},
  609. {"HL Left Mixer", NULL, "XSPINL"},
  610. {"HL Right Mixer", NULL, "XSPINR"},
  611. {"HL Left Mixer", NULL, "VSPINOUT"},
  612. {"HL Right Mixer", NULL, "VSPINOUT"},
  613. {"ASPINL", NULL, "ASP Playback"},
  614. {"ASPINM", NULL, "ASP Playback"},
  615. {"ASPINR", NULL, "ASP Playback"},
  616. {"XSPINL", NULL, "XSP Playback"},
  617. {"XSPINM", NULL, "XSP Playback"},
  618. {"XSPINR", NULL, "XSP Playback"},
  619. {"VSPINOUT", NULL, "VSP Playback"},
  620. /* Capture Paths */
  621. {"MIC1", NULL, "MIC1 Bias"},
  622. {"PGA Left Mux", "Mic 1", "MIC1"},
  623. {"MIC2", NULL, "MIC2 Bias"},
  624. {"PGA Right Mux", "Mic 2", "MIC2"},
  625. {"PGA Left Mux", "Line A", "LINEINA"},
  626. {"PGA Right Mux", "Line B", "LINEINB"},
  627. {"PGA Left", NULL, "PGA Left Mux"},
  628. {"PGA Right", NULL, "PGA Right Mux"},
  629. {"ADC Left", NULL, "PGA Left"},
  630. {"ADC Right", NULL, "PGA Right"},
  631. {"DMIC Left", NULL, "DMICA"},
  632. {"DMIC Right", NULL, "DMICB"},
  633. {"Input Left Capture", "ADC Left Input", "ADC Left"},
  634. {"Input Right Capture", "ADC Right Input", "ADC Right"},
  635. {"Input Left Capture", "DMIC Left Input", "DMIC Left"},
  636. {"Input Right Capture", "DMIC Right Input", "DMIC Right"},
  637. /* Audio Capture */
  638. {"ASPL Output Mixer", NULL, "Input Left Capture"},
  639. {"ASPR Output Mixer", NULL, "Input Right Capture"},
  640. {"ASPOUTL", "ASP-IP Volume", "ASPL Output Mixer"},
  641. {"ASPOUTR", "ASP-IP Volume", "ASPR Output Mixer"},
  642. /* Auxillary Capture */
  643. {"XSPL Output Mixer", NULL, "Input Left Capture"},
  644. {"XSPR Output Mixer", NULL, "Input Right Capture"},
  645. {"XSPOUTL", "XSP-IP Volume", "XSPL Output Mixer"},
  646. {"XSPOUTR", "XSP-IP Volume", "XSPR Output Mixer"},
  647. {"XSPOUTL", NULL, "XSPL Output Mixer"},
  648. {"XSPOUTR", NULL, "XSPR Output Mixer"},
  649. /* Voice Capture */
  650. {"VSP Output Mixer", NULL, "Input Left Capture"},
  651. {"VSP Output Mixer", NULL, "Input Right Capture"},
  652. {"VSPINOUT", "VSP-IP Volume", "VSP Output Mixer"},
  653. {"VSPINOUT", NULL, "VSP Output Mixer"},
  654. {"ASP Capture", NULL, "ASPOUTL"},
  655. {"ASP Capture", NULL, "ASPOUTR"},
  656. {"XSP Capture", NULL, "XSPOUTL"},
  657. {"XSP Capture", NULL, "XSPOUTR"},
  658. {"VSP Capture", NULL, "VSPINOUT"},
  659. };
  660. struct cs42l73_mclk_div {
  661. u32 mclk;
  662. u32 srate;
  663. u8 mmcc;
  664. };
  665. static const struct cs42l73_mclk_div cs42l73_mclk_coeffs[] = {
  666. /* MCLK, Sample Rate, xMMCC[5:0] */
  667. {5644800, 11025, 0x30},
  668. {5644800, 22050, 0x20},
  669. {5644800, 44100, 0x10},
  670. {6000000, 8000, 0x39},
  671. {6000000, 11025, 0x33},
  672. {6000000, 12000, 0x31},
  673. {6000000, 16000, 0x29},
  674. {6000000, 22050, 0x23},
  675. {6000000, 24000, 0x21},
  676. {6000000, 32000, 0x19},
  677. {6000000, 44100, 0x13},
  678. {6000000, 48000, 0x11},
  679. {6144000, 8000, 0x38},
  680. {6144000, 12000, 0x30},
  681. {6144000, 16000, 0x28},
  682. {6144000, 24000, 0x20},
  683. {6144000, 32000, 0x18},
  684. {6144000, 48000, 0x10},
  685. {6500000, 8000, 0x3C},
  686. {6500000, 11025, 0x35},
  687. {6500000, 12000, 0x34},
  688. {6500000, 16000, 0x2C},
  689. {6500000, 22050, 0x25},
  690. {6500000, 24000, 0x24},
  691. {6500000, 32000, 0x1C},
  692. {6500000, 44100, 0x15},
  693. {6500000, 48000, 0x14},
  694. {6400000, 8000, 0x3E},
  695. {6400000, 11025, 0x37},
  696. {6400000, 12000, 0x36},
  697. {6400000, 16000, 0x2E},
  698. {6400000, 22050, 0x27},
  699. {6400000, 24000, 0x26},
  700. {6400000, 32000, 0x1E},
  701. {6400000, 44100, 0x17},
  702. {6400000, 48000, 0x16},
  703. };
  704. struct cs42l73_mclkx_div {
  705. u32 mclkx;
  706. u8 ratio;
  707. u8 mclkdiv;
  708. };
  709. static const struct cs42l73_mclkx_div cs42l73_mclkx_coeffs[] = {
  710. {5644800, 1, 0}, /* 5644800 */
  711. {6000000, 1, 0}, /* 6000000 */
  712. {6144000, 1, 0}, /* 6144000 */
  713. {11289600, 2, 2}, /* 5644800 */
  714. {12288000, 2, 2}, /* 6144000 */
  715. {12000000, 2, 2}, /* 6000000 */
  716. {13000000, 2, 2}, /* 6500000 */
  717. {19200000, 3, 3}, /* 6400000 */
  718. {24000000, 4, 4}, /* 6000000 */
  719. {26000000, 4, 4}, /* 6500000 */
  720. {38400000, 6, 5} /* 6400000 */
  721. };
  722. static int cs42l73_get_mclkx_coeff(int mclkx)
  723. {
  724. int i;
  725. for (i = 0; i < ARRAY_SIZE(cs42l73_mclkx_coeffs); i++) {
  726. if (cs42l73_mclkx_coeffs[i].mclkx == mclkx)
  727. return i;
  728. }
  729. return -EINVAL;
  730. }
  731. static int cs42l73_get_mclk_coeff(int mclk, int srate)
  732. {
  733. int i;
  734. for (i = 0; i < ARRAY_SIZE(cs42l73_mclk_coeffs); i++) {
  735. if (cs42l73_mclk_coeffs[i].mclk == mclk &&
  736. cs42l73_mclk_coeffs[i].srate == srate)
  737. return i;
  738. }
  739. return -EINVAL;
  740. }
  741. static int cs42l73_set_mclk(struct snd_soc_dai *dai, unsigned int freq)
  742. {
  743. struct snd_soc_codec *codec = dai->codec;
  744. struct cs42l73_private *priv = snd_soc_codec_get_drvdata(codec);
  745. int mclkx_coeff;
  746. u32 mclk = 0;
  747. u8 dmmcc = 0;
  748. /* MCLKX -> MCLK */
  749. mclkx_coeff = cs42l73_get_mclkx_coeff(freq);
  750. if (mclkx_coeff < 0)
  751. return mclkx_coeff;
  752. mclk = cs42l73_mclkx_coeffs[mclkx_coeff].mclkx /
  753. cs42l73_mclkx_coeffs[mclkx_coeff].ratio;
  754. dev_dbg(codec->dev, "MCLK%u %u <-> internal MCLK %u\n",
  755. priv->mclksel + 1, cs42l73_mclkx_coeffs[mclkx_coeff].mclkx,
  756. mclk);
  757. dmmcc = (priv->mclksel << 4) |
  758. (cs42l73_mclkx_coeffs[mclkx_coeff].mclkdiv << 1);
  759. snd_soc_write(codec, CS42L73_DMMCC, dmmcc);
  760. priv->sysclk = mclkx_coeff;
  761. priv->mclk = mclk;
  762. return 0;
  763. }
  764. static int cs42l73_set_sysclk(struct snd_soc_dai *dai,
  765. int clk_id, unsigned int freq, int dir)
  766. {
  767. struct snd_soc_codec *codec = dai->codec;
  768. struct cs42l73_private *priv = snd_soc_codec_get_drvdata(codec);
  769. switch (clk_id) {
  770. case CS42L73_CLKID_MCLK1:
  771. break;
  772. case CS42L73_CLKID_MCLK2:
  773. break;
  774. default:
  775. return -EINVAL;
  776. }
  777. if ((cs42l73_set_mclk(dai, freq)) < 0) {
  778. dev_err(codec->dev, "Unable to set MCLK for dai %s\n",
  779. dai->name);
  780. return -EINVAL;
  781. }
  782. priv->mclksel = clk_id;
  783. return 0;
  784. }
  785. static int cs42l73_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
  786. {
  787. struct snd_soc_codec *codec = codec_dai->codec;
  788. struct cs42l73_private *priv = snd_soc_codec_get_drvdata(codec);
  789. u8 id = codec_dai->id;
  790. unsigned int inv, format;
  791. u8 spc, mmcc;
  792. spc = snd_soc_read(codec, CS42L73_SPC(id));
  793. mmcc = snd_soc_read(codec, CS42L73_MMCC(id));
  794. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  795. case SND_SOC_DAIFMT_CBM_CFM:
  796. mmcc |= CS42L73_MS_MASTER;
  797. break;
  798. case SND_SOC_DAIFMT_CBS_CFS:
  799. mmcc &= ~CS42L73_MS_MASTER;
  800. break;
  801. default:
  802. return -EINVAL;
  803. }
  804. format = (fmt & SND_SOC_DAIFMT_FORMAT_MASK);
  805. inv = (fmt & SND_SOC_DAIFMT_INV_MASK);
  806. switch (format) {
  807. case SND_SOC_DAIFMT_I2S:
  808. spc &= ~CS42L73_SPDIF_PCM;
  809. break;
  810. case SND_SOC_DAIFMT_DSP_A:
  811. case SND_SOC_DAIFMT_DSP_B:
  812. if (mmcc & CS42L73_MS_MASTER) {
  813. dev_err(codec->dev,
  814. "PCM format in slave mode only\n");
  815. return -EINVAL;
  816. }
  817. if (id == CS42L73_ASP) {
  818. dev_err(codec->dev,
  819. "PCM format is not supported on ASP port\n");
  820. return -EINVAL;
  821. }
  822. spc |= CS42L73_SPDIF_PCM;
  823. break;
  824. default:
  825. return -EINVAL;
  826. }
  827. if (spc & CS42L73_SPDIF_PCM) {
  828. /* Clear PCM mode, clear PCM_BIT_ORDER bit for MSB->LSB */
  829. spc &= ~(CS42L73_PCM_MODE_MASK | CS42L73_PCM_BIT_ORDER);
  830. switch (format) {
  831. case SND_SOC_DAIFMT_DSP_B:
  832. if (inv == SND_SOC_DAIFMT_IB_IF)
  833. spc |= CS42L73_PCM_MODE0;
  834. if (inv == SND_SOC_DAIFMT_IB_NF)
  835. spc |= CS42L73_PCM_MODE1;
  836. break;
  837. case SND_SOC_DAIFMT_DSP_A:
  838. if (inv == SND_SOC_DAIFMT_IB_IF)
  839. spc |= CS42L73_PCM_MODE1;
  840. break;
  841. default:
  842. return -EINVAL;
  843. }
  844. }
  845. priv->config[id].spc = spc;
  846. priv->config[id].mmcc = mmcc;
  847. return 0;
  848. }
  849. static const unsigned int cs42l73_asrc_rates[] = {
  850. 8000, 11025, 12000, 16000, 22050,
  851. 24000, 32000, 44100, 48000
  852. };
  853. static unsigned int cs42l73_get_xspfs_coeff(u32 rate)
  854. {
  855. int i;
  856. for (i = 0; i < ARRAY_SIZE(cs42l73_asrc_rates); i++) {
  857. if (cs42l73_asrc_rates[i] == rate)
  858. return i + 1;
  859. }
  860. return 0; /* 0 = Don't know */
  861. }
  862. static void cs42l73_update_asrc(struct snd_soc_codec *codec, int id, int srate)
  863. {
  864. u8 spfs = 0;
  865. if (srate > 0)
  866. spfs = cs42l73_get_xspfs_coeff(srate);
  867. switch (id) {
  868. case CS42L73_XSP:
  869. snd_soc_update_bits(codec, CS42L73_VXSPFS, 0x0f, spfs);
  870. break;
  871. case CS42L73_ASP:
  872. snd_soc_update_bits(codec, CS42L73_ASPC, 0x3c, spfs << 2);
  873. break;
  874. case CS42L73_VSP:
  875. snd_soc_update_bits(codec, CS42L73_VXSPFS, 0xf0, spfs << 4);
  876. break;
  877. default:
  878. break;
  879. }
  880. }
  881. static int cs42l73_pcm_hw_params(struct snd_pcm_substream *substream,
  882. struct snd_pcm_hw_params *params,
  883. struct snd_soc_dai *dai)
  884. {
  885. struct snd_soc_codec *codec = dai->codec;
  886. struct cs42l73_private *priv = snd_soc_codec_get_drvdata(codec);
  887. int id = dai->id;
  888. int mclk_coeff;
  889. int srate = params_rate(params);
  890. if (priv->config[id].mmcc & CS42L73_MS_MASTER) {
  891. /* CS42L73 Master */
  892. /* MCLK -> srate */
  893. mclk_coeff =
  894. cs42l73_get_mclk_coeff(priv->mclk, srate);
  895. if (mclk_coeff < 0)
  896. return -EINVAL;
  897. dev_dbg(codec->dev,
  898. "DAI[%d]: MCLK %u, srate %u, MMCC[5:0] = %x\n",
  899. id, priv->mclk, srate,
  900. cs42l73_mclk_coeffs[mclk_coeff].mmcc);
  901. priv->config[id].mmcc &= 0xC0;
  902. priv->config[id].mmcc |= cs42l73_mclk_coeffs[mclk_coeff].mmcc;
  903. priv->config[id].spc &= 0xFC;
  904. /* Use SCLK=64*Fs if internal MCLK >= 6.4MHz */
  905. if (priv->mclk >= 6400000)
  906. priv->config[id].spc |= CS42L73_MCK_SCLK_64FS;
  907. else
  908. priv->config[id].spc |= CS42L73_MCK_SCLK_MCLK;
  909. } else {
  910. /* CS42L73 Slave */
  911. priv->config[id].spc &= 0xFC;
  912. priv->config[id].spc |= CS42L73_MCK_SCLK_64FS;
  913. }
  914. /* Update ASRCs */
  915. priv->config[id].srate = srate;
  916. snd_soc_write(codec, CS42L73_SPC(id), priv->config[id].spc);
  917. snd_soc_write(codec, CS42L73_MMCC(id), priv->config[id].mmcc);
  918. cs42l73_update_asrc(codec, id, srate);
  919. return 0;
  920. }
  921. static int cs42l73_set_bias_level(struct snd_soc_codec *codec,
  922. enum snd_soc_bias_level level)
  923. {
  924. struct cs42l73_private *cs42l73 = snd_soc_codec_get_drvdata(codec);
  925. switch (level) {
  926. case SND_SOC_BIAS_ON:
  927. snd_soc_update_bits(codec, CS42L73_DMMCC, CS42L73_MCLKDIS, 0);
  928. snd_soc_update_bits(codec, CS42L73_PWRCTL1, CS42L73_PDN, 0);
  929. break;
  930. case SND_SOC_BIAS_PREPARE:
  931. break;
  932. case SND_SOC_BIAS_STANDBY:
  933. if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) {
  934. regcache_cache_only(cs42l73->regmap, false);
  935. regcache_sync(cs42l73->regmap);
  936. }
  937. snd_soc_update_bits(codec, CS42L73_PWRCTL1, CS42L73_PDN, 1);
  938. break;
  939. case SND_SOC_BIAS_OFF:
  940. snd_soc_update_bits(codec, CS42L73_PWRCTL1, CS42L73_PDN, 1);
  941. if (cs42l73->shutdwn_delay > 0) {
  942. mdelay(cs42l73->shutdwn_delay);
  943. cs42l73->shutdwn_delay = 0;
  944. } else {
  945. mdelay(15); /* Min amount of time requred to power
  946. * down.
  947. */
  948. }
  949. snd_soc_update_bits(codec, CS42L73_DMMCC, CS42L73_MCLKDIS, 1);
  950. break;
  951. }
  952. return 0;
  953. }
  954. static int cs42l73_set_tristate(struct snd_soc_dai *dai, int tristate)
  955. {
  956. struct snd_soc_codec *codec = dai->codec;
  957. int id = dai->id;
  958. return snd_soc_update_bits(codec, CS42L73_SPC(id), CS42L73_SP_3ST,
  959. tristate << 7);
  960. }
  961. static const struct snd_pcm_hw_constraint_list constraints_12_24 = {
  962. .count = ARRAY_SIZE(cs42l73_asrc_rates),
  963. .list = cs42l73_asrc_rates,
  964. };
  965. static int cs42l73_pcm_startup(struct snd_pcm_substream *substream,
  966. struct snd_soc_dai *dai)
  967. {
  968. snd_pcm_hw_constraint_list(substream->runtime, 0,
  969. SNDRV_PCM_HW_PARAM_RATE,
  970. &constraints_12_24);
  971. return 0;
  972. }
  973. #define CS42L73_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
  974. SNDRV_PCM_FMTBIT_S24_LE)
  975. static const struct snd_soc_dai_ops cs42l73_ops = {
  976. .startup = cs42l73_pcm_startup,
  977. .hw_params = cs42l73_pcm_hw_params,
  978. .set_fmt = cs42l73_set_dai_fmt,
  979. .set_sysclk = cs42l73_set_sysclk,
  980. .set_tristate = cs42l73_set_tristate,
  981. };
  982. static struct snd_soc_dai_driver cs42l73_dai[] = {
  983. {
  984. .name = "cs42l73-xsp",
  985. .id = CS42L73_XSP,
  986. .playback = {
  987. .stream_name = "XSP Playback",
  988. .channels_min = 1,
  989. .channels_max = 2,
  990. .rates = SNDRV_PCM_RATE_KNOT,
  991. .formats = CS42L73_FORMATS,
  992. },
  993. .capture = {
  994. .stream_name = "XSP Capture",
  995. .channels_min = 1,
  996. .channels_max = 2,
  997. .rates = SNDRV_PCM_RATE_KNOT,
  998. .formats = CS42L73_FORMATS,
  999. },
  1000. .ops = &cs42l73_ops,
  1001. .symmetric_rates = 1,
  1002. },
  1003. {
  1004. .name = "cs42l73-asp",
  1005. .id = CS42L73_ASP,
  1006. .playback = {
  1007. .stream_name = "ASP Playback",
  1008. .channels_min = 2,
  1009. .channels_max = 2,
  1010. .rates = SNDRV_PCM_RATE_KNOT,
  1011. .formats = CS42L73_FORMATS,
  1012. },
  1013. .capture = {
  1014. .stream_name = "ASP Capture",
  1015. .channels_min = 2,
  1016. .channels_max = 2,
  1017. .rates = SNDRV_PCM_RATE_KNOT,
  1018. .formats = CS42L73_FORMATS,
  1019. },
  1020. .ops = &cs42l73_ops,
  1021. .symmetric_rates = 1,
  1022. },
  1023. {
  1024. .name = "cs42l73-vsp",
  1025. .id = CS42L73_VSP,
  1026. .playback = {
  1027. .stream_name = "VSP Playback",
  1028. .channels_min = 1,
  1029. .channels_max = 2,
  1030. .rates = SNDRV_PCM_RATE_KNOT,
  1031. .formats = CS42L73_FORMATS,
  1032. },
  1033. .capture = {
  1034. .stream_name = "VSP Capture",
  1035. .channels_min = 1,
  1036. .channels_max = 2,
  1037. .rates = SNDRV_PCM_RATE_KNOT,
  1038. .formats = CS42L73_FORMATS,
  1039. },
  1040. .ops = &cs42l73_ops,
  1041. .symmetric_rates = 1,
  1042. }
  1043. };
  1044. static int cs42l73_probe(struct snd_soc_codec *codec)
  1045. {
  1046. struct cs42l73_private *cs42l73 = snd_soc_codec_get_drvdata(codec);
  1047. /* Set Charge Pump Frequency */
  1048. if (cs42l73->pdata.chgfreq)
  1049. snd_soc_update_bits(codec, CS42L73_CPFCHC,
  1050. CS42L73_CHARGEPUMP_MASK,
  1051. cs42l73->pdata.chgfreq << 4);
  1052. /* MCLK1 as master clk */
  1053. cs42l73->mclksel = CS42L73_CLKID_MCLK1;
  1054. cs42l73->mclk = 0;
  1055. return 0;
  1056. }
  1057. static const struct snd_soc_codec_driver soc_codec_dev_cs42l73 = {
  1058. .probe = cs42l73_probe,
  1059. .set_bias_level = cs42l73_set_bias_level,
  1060. .suspend_bias_off = true,
  1061. .component_driver = {
  1062. .controls = cs42l73_snd_controls,
  1063. .num_controls = ARRAY_SIZE(cs42l73_snd_controls),
  1064. .dapm_widgets = cs42l73_dapm_widgets,
  1065. .num_dapm_widgets = ARRAY_SIZE(cs42l73_dapm_widgets),
  1066. .dapm_routes = cs42l73_audio_map,
  1067. .num_dapm_routes = ARRAY_SIZE(cs42l73_audio_map),
  1068. },
  1069. };
  1070. static const struct regmap_config cs42l73_regmap = {
  1071. .reg_bits = 8,
  1072. .val_bits = 8,
  1073. .max_register = CS42L73_MAX_REGISTER,
  1074. .reg_defaults = cs42l73_reg_defaults,
  1075. .num_reg_defaults = ARRAY_SIZE(cs42l73_reg_defaults),
  1076. .volatile_reg = cs42l73_volatile_register,
  1077. .readable_reg = cs42l73_readable_register,
  1078. .cache_type = REGCACHE_RBTREE,
  1079. };
  1080. static int cs42l73_i2c_probe(struct i2c_client *i2c_client,
  1081. const struct i2c_device_id *id)
  1082. {
  1083. struct cs42l73_private *cs42l73;
  1084. struct cs42l73_platform_data *pdata = dev_get_platdata(&i2c_client->dev);
  1085. int ret;
  1086. unsigned int devid = 0;
  1087. unsigned int reg;
  1088. u32 val32;
  1089. cs42l73 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs42l73_private),
  1090. GFP_KERNEL);
  1091. if (!cs42l73)
  1092. return -ENOMEM;
  1093. cs42l73->regmap = devm_regmap_init_i2c(i2c_client, &cs42l73_regmap);
  1094. if (IS_ERR(cs42l73->regmap)) {
  1095. ret = PTR_ERR(cs42l73->regmap);
  1096. dev_err(&i2c_client->dev, "regmap_init() failed: %d\n", ret);
  1097. return ret;
  1098. }
  1099. if (pdata) {
  1100. cs42l73->pdata = *pdata;
  1101. } else {
  1102. pdata = devm_kzalloc(&i2c_client->dev,
  1103. sizeof(struct cs42l73_platform_data),
  1104. GFP_KERNEL);
  1105. if (!pdata) {
  1106. dev_err(&i2c_client->dev, "could not allocate pdata\n");
  1107. return -ENOMEM;
  1108. }
  1109. if (i2c_client->dev.of_node) {
  1110. if (of_property_read_u32(i2c_client->dev.of_node,
  1111. "chgfreq", &val32) >= 0)
  1112. pdata->chgfreq = val32;
  1113. }
  1114. pdata->reset_gpio = of_get_named_gpio(i2c_client->dev.of_node,
  1115. "reset-gpio", 0);
  1116. cs42l73->pdata = *pdata;
  1117. }
  1118. i2c_set_clientdata(i2c_client, cs42l73);
  1119. if (cs42l73->pdata.reset_gpio) {
  1120. ret = devm_gpio_request_one(&i2c_client->dev,
  1121. cs42l73->pdata.reset_gpio,
  1122. GPIOF_OUT_INIT_HIGH,
  1123. "CS42L73 /RST");
  1124. if (ret < 0) {
  1125. dev_err(&i2c_client->dev, "Failed to request /RST %d: %d\n",
  1126. cs42l73->pdata.reset_gpio, ret);
  1127. return ret;
  1128. }
  1129. gpio_set_value_cansleep(cs42l73->pdata.reset_gpio, 0);
  1130. gpio_set_value_cansleep(cs42l73->pdata.reset_gpio, 1);
  1131. }
  1132. regcache_cache_bypass(cs42l73->regmap, true);
  1133. /* initialize codec */
  1134. ret = regmap_read(cs42l73->regmap, CS42L73_DEVID_AB, &reg);
  1135. devid = (reg & 0xFF) << 12;
  1136. ret = regmap_read(cs42l73->regmap, CS42L73_DEVID_CD, &reg);
  1137. devid |= (reg & 0xFF) << 4;
  1138. ret = regmap_read(cs42l73->regmap, CS42L73_DEVID_E, &reg);
  1139. devid |= (reg & 0xF0) >> 4;
  1140. if (devid != CS42L73_DEVID) {
  1141. ret = -ENODEV;
  1142. dev_err(&i2c_client->dev,
  1143. "CS42L73 Device ID (%X). Expected %X\n",
  1144. devid, CS42L73_DEVID);
  1145. return ret;
  1146. }
  1147. ret = regmap_read(cs42l73->regmap, CS42L73_REVID, &reg);
  1148. if (ret < 0) {
  1149. dev_err(&i2c_client->dev, "Get Revision ID failed\n");
  1150. return ret;;
  1151. }
  1152. dev_info(&i2c_client->dev,
  1153. "Cirrus Logic CS42L73, Revision: %02X\n", reg & 0xFF);
  1154. regcache_cache_bypass(cs42l73->regmap, false);
  1155. ret = snd_soc_register_codec(&i2c_client->dev,
  1156. &soc_codec_dev_cs42l73, cs42l73_dai,
  1157. ARRAY_SIZE(cs42l73_dai));
  1158. if (ret < 0)
  1159. return ret;
  1160. return 0;
  1161. }
  1162. static int cs42l73_i2c_remove(struct i2c_client *client)
  1163. {
  1164. snd_soc_unregister_codec(&client->dev);
  1165. return 0;
  1166. }
  1167. static const struct of_device_id cs42l73_of_match[] = {
  1168. { .compatible = "cirrus,cs42l73", },
  1169. {},
  1170. };
  1171. MODULE_DEVICE_TABLE(of, cs42l73_of_match);
  1172. static const struct i2c_device_id cs42l73_id[] = {
  1173. {"cs42l73", 0},
  1174. {}
  1175. };
  1176. MODULE_DEVICE_TABLE(i2c, cs42l73_id);
  1177. static struct i2c_driver cs42l73_i2c_driver = {
  1178. .driver = {
  1179. .name = "cs42l73",
  1180. .of_match_table = cs42l73_of_match,
  1181. },
  1182. .id_table = cs42l73_id,
  1183. .probe = cs42l73_i2c_probe,
  1184. .remove = cs42l73_i2c_remove,
  1185. };
  1186. module_i2c_driver(cs42l73_i2c_driver);
  1187. MODULE_DESCRIPTION("ASoC CS42L73 driver");
  1188. MODULE_AUTHOR("Georgi Vlaev, Nucleus Systems Ltd, <joe@nucleusys.com>");
  1189. MODULE_AUTHOR("Brian Austin, Cirrus Logic Inc, <brian.austin@cirrus.com>");
  1190. MODULE_LICENSE("GPL");