cs42l73.c 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413
  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 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 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. .dapm_widgets = cs42l73_dapm_widgets,
  1062. .num_dapm_widgets = ARRAY_SIZE(cs42l73_dapm_widgets),
  1063. .dapm_routes = cs42l73_audio_map,
  1064. .num_dapm_routes = ARRAY_SIZE(cs42l73_audio_map),
  1065. .controls = cs42l73_snd_controls,
  1066. .num_controls = ARRAY_SIZE(cs42l73_snd_controls),
  1067. };
  1068. static const struct regmap_config cs42l73_regmap = {
  1069. .reg_bits = 8,
  1070. .val_bits = 8,
  1071. .max_register = CS42L73_MAX_REGISTER,
  1072. .reg_defaults = cs42l73_reg_defaults,
  1073. .num_reg_defaults = ARRAY_SIZE(cs42l73_reg_defaults),
  1074. .volatile_reg = cs42l73_volatile_register,
  1075. .readable_reg = cs42l73_readable_register,
  1076. .cache_type = REGCACHE_RBTREE,
  1077. };
  1078. static int cs42l73_i2c_probe(struct i2c_client *i2c_client,
  1079. const struct i2c_device_id *id)
  1080. {
  1081. struct cs42l73_private *cs42l73;
  1082. struct cs42l73_platform_data *pdata = dev_get_platdata(&i2c_client->dev);
  1083. int ret;
  1084. unsigned int devid = 0;
  1085. unsigned int reg;
  1086. u32 val32;
  1087. cs42l73 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs42l73_private),
  1088. GFP_KERNEL);
  1089. if (!cs42l73)
  1090. return -ENOMEM;
  1091. cs42l73->regmap = devm_regmap_init_i2c(i2c_client, &cs42l73_regmap);
  1092. if (IS_ERR(cs42l73->regmap)) {
  1093. ret = PTR_ERR(cs42l73->regmap);
  1094. dev_err(&i2c_client->dev, "regmap_init() failed: %d\n", ret);
  1095. return ret;
  1096. }
  1097. if (pdata) {
  1098. cs42l73->pdata = *pdata;
  1099. } else {
  1100. pdata = devm_kzalloc(&i2c_client->dev,
  1101. sizeof(struct cs42l73_platform_data),
  1102. GFP_KERNEL);
  1103. if (!pdata) {
  1104. dev_err(&i2c_client->dev, "could not allocate pdata\n");
  1105. return -ENOMEM;
  1106. }
  1107. if (i2c_client->dev.of_node) {
  1108. if (of_property_read_u32(i2c_client->dev.of_node,
  1109. "chgfreq", &val32) >= 0)
  1110. pdata->chgfreq = val32;
  1111. }
  1112. pdata->reset_gpio = of_get_named_gpio(i2c_client->dev.of_node,
  1113. "reset-gpio", 0);
  1114. cs42l73->pdata = *pdata;
  1115. }
  1116. i2c_set_clientdata(i2c_client, cs42l73);
  1117. if (cs42l73->pdata.reset_gpio) {
  1118. ret = devm_gpio_request_one(&i2c_client->dev,
  1119. cs42l73->pdata.reset_gpio,
  1120. GPIOF_OUT_INIT_HIGH,
  1121. "CS42L73 /RST");
  1122. if (ret < 0) {
  1123. dev_err(&i2c_client->dev, "Failed to request /RST %d: %d\n",
  1124. cs42l73->pdata.reset_gpio, ret);
  1125. return ret;
  1126. }
  1127. gpio_set_value_cansleep(cs42l73->pdata.reset_gpio, 0);
  1128. gpio_set_value_cansleep(cs42l73->pdata.reset_gpio, 1);
  1129. }
  1130. regcache_cache_bypass(cs42l73->regmap, true);
  1131. /* initialize codec */
  1132. ret = regmap_read(cs42l73->regmap, CS42L73_DEVID_AB, &reg);
  1133. devid = (reg & 0xFF) << 12;
  1134. ret = regmap_read(cs42l73->regmap, CS42L73_DEVID_CD, &reg);
  1135. devid |= (reg & 0xFF) << 4;
  1136. ret = regmap_read(cs42l73->regmap, CS42L73_DEVID_E, &reg);
  1137. devid |= (reg & 0xF0) >> 4;
  1138. if (devid != CS42L73_DEVID) {
  1139. ret = -ENODEV;
  1140. dev_err(&i2c_client->dev,
  1141. "CS42L73 Device ID (%X). Expected %X\n",
  1142. devid, CS42L73_DEVID);
  1143. return ret;
  1144. }
  1145. ret = regmap_read(cs42l73->regmap, CS42L73_REVID, &reg);
  1146. if (ret < 0) {
  1147. dev_err(&i2c_client->dev, "Get Revision ID failed\n");
  1148. return ret;;
  1149. }
  1150. dev_info(&i2c_client->dev,
  1151. "Cirrus Logic CS42L73, Revision: %02X\n", reg & 0xFF);
  1152. regcache_cache_bypass(cs42l73->regmap, false);
  1153. ret = snd_soc_register_codec(&i2c_client->dev,
  1154. &soc_codec_dev_cs42l73, cs42l73_dai,
  1155. ARRAY_SIZE(cs42l73_dai));
  1156. if (ret < 0)
  1157. return ret;
  1158. return 0;
  1159. }
  1160. static int cs42l73_i2c_remove(struct i2c_client *client)
  1161. {
  1162. snd_soc_unregister_codec(&client->dev);
  1163. return 0;
  1164. }
  1165. static const struct of_device_id cs42l73_of_match[] = {
  1166. { .compatible = "cirrus,cs42l73", },
  1167. {},
  1168. };
  1169. MODULE_DEVICE_TABLE(of, cs42l73_of_match);
  1170. static const struct i2c_device_id cs42l73_id[] = {
  1171. {"cs42l73", 0},
  1172. {}
  1173. };
  1174. MODULE_DEVICE_TABLE(i2c, cs42l73_id);
  1175. static struct i2c_driver cs42l73_i2c_driver = {
  1176. .driver = {
  1177. .name = "cs42l73",
  1178. .of_match_table = cs42l73_of_match,
  1179. },
  1180. .id_table = cs42l73_id,
  1181. .probe = cs42l73_i2c_probe,
  1182. .remove = cs42l73_i2c_remove,
  1183. };
  1184. module_i2c_driver(cs42l73_i2c_driver);
  1185. MODULE_DESCRIPTION("ASoC CS42L73 driver");
  1186. MODULE_AUTHOR("Georgi Vlaev, Nucleus Systems Ltd, <joe@nucleusys.com>");
  1187. MODULE_AUTHOR("Brian Austin, Cirrus Logic Inc, <brian.austin@cirrus.com>");
  1188. MODULE_LICENSE("GPL");