adau17x1.c 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Common code for ADAU1X61 and ADAU1X81 codecs
  4. *
  5. * Copyright 2011-2014 Analog Devices Inc.
  6. * Author: Lars-Peter Clausen <[email protected]>
  7. */
  8. #include <linux/module.h>
  9. #include <linux/init.h>
  10. #include <linux/clk.h>
  11. #include <linux/delay.h>
  12. #include <linux/slab.h>
  13. #include <sound/core.h>
  14. #include <sound/pcm.h>
  15. #include <sound/pcm_params.h>
  16. #include <sound/soc.h>
  17. #include <sound/tlv.h>
  18. #include <linux/gcd.h>
  19. #include <linux/i2c.h>
  20. #include <linux/spi/spi.h>
  21. #include <linux/regmap.h>
  22. #include <asm/unaligned.h>
  23. #include "sigmadsp.h"
  24. #include "adau17x1.h"
  25. #include "adau-utils.h"
  26. #define ADAU17X1_SAFELOAD_TARGET_ADDRESS 0x0006
  27. #define ADAU17X1_SAFELOAD_TRIGGER 0x0007
  28. #define ADAU17X1_SAFELOAD_DATA 0x0001
  29. #define ADAU17X1_SAFELOAD_DATA_SIZE 20
  30. #define ADAU17X1_WORD_SIZE 4
  31. static const char * const adau17x1_capture_mixer_boost_text[] = {
  32. "Normal operation", "Boost Level 1", "Boost Level 2", "Boost Level 3",
  33. };
  34. static SOC_ENUM_SINGLE_DECL(adau17x1_capture_boost_enum,
  35. ADAU17X1_REC_POWER_MGMT, 5, adau17x1_capture_mixer_boost_text);
  36. static const char * const adau17x1_mic_bias_mode_text[] = {
  37. "Normal operation", "High performance",
  38. };
  39. static SOC_ENUM_SINGLE_DECL(adau17x1_mic_bias_mode_enum,
  40. ADAU17X1_MICBIAS, 3, adau17x1_mic_bias_mode_text);
  41. static const DECLARE_TLV_DB_MINMAX(adau17x1_digital_tlv, -9563, 0);
  42. static const struct snd_kcontrol_new adau17x1_controls[] = {
  43. SOC_DOUBLE_R_TLV("Digital Capture Volume",
  44. ADAU17X1_LEFT_INPUT_DIGITAL_VOL,
  45. ADAU17X1_RIGHT_INPUT_DIGITAL_VOL,
  46. 0, 0xff, 1, adau17x1_digital_tlv),
  47. SOC_DOUBLE_R_TLV("Digital Playback Volume", ADAU17X1_DAC_CONTROL1,
  48. ADAU17X1_DAC_CONTROL2, 0, 0xff, 1, adau17x1_digital_tlv),
  49. SOC_SINGLE("ADC High Pass Filter Switch", ADAU17X1_ADC_CONTROL,
  50. 5, 1, 0),
  51. SOC_SINGLE("Playback De-emphasis Switch", ADAU17X1_DAC_CONTROL0,
  52. 2, 1, 0),
  53. SOC_ENUM("Capture Boost", adau17x1_capture_boost_enum),
  54. SOC_ENUM("Mic Bias Mode", adau17x1_mic_bias_mode_enum),
  55. };
  56. static int adau17x1_setup_firmware(struct snd_soc_component *component,
  57. unsigned int rate);
  58. static int adau17x1_pll_event(struct snd_soc_dapm_widget *w,
  59. struct snd_kcontrol *kcontrol, int event)
  60. {
  61. struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
  62. struct adau *adau = snd_soc_component_get_drvdata(component);
  63. if (SND_SOC_DAPM_EVENT_ON(event)) {
  64. adau->pll_regs[5] = 1;
  65. } else {
  66. adau->pll_regs[5] = 0;
  67. /* Bypass the PLL when disabled, otherwise registers will become
  68. * inaccessible. */
  69. regmap_update_bits(adau->regmap, ADAU17X1_CLOCK_CONTROL,
  70. ADAU17X1_CLOCK_CONTROL_CORECLK_SRC_PLL, 0);
  71. }
  72. /* The PLL register is 6 bytes long and can only be written at once. */
  73. regmap_raw_write(adau->regmap, ADAU17X1_PLL_CONTROL,
  74. adau->pll_regs, ARRAY_SIZE(adau->pll_regs));
  75. if (SND_SOC_DAPM_EVENT_ON(event)) {
  76. mdelay(5);
  77. regmap_update_bits(adau->regmap, ADAU17X1_CLOCK_CONTROL,
  78. ADAU17X1_CLOCK_CONTROL_CORECLK_SRC_PLL,
  79. ADAU17X1_CLOCK_CONTROL_CORECLK_SRC_PLL);
  80. }
  81. return 0;
  82. }
  83. static int adau17x1_adc_fixup(struct snd_soc_dapm_widget *w,
  84. struct snd_kcontrol *kcontrol, int event)
  85. {
  86. struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
  87. struct adau *adau = snd_soc_component_get_drvdata(component);
  88. /*
  89. * If we are capturing, toggle the ADOSR bit in Converter Control 0 to
  90. * avoid losing SNR (workaround from ADI). This must be done after
  91. * the ADC(s) have been enabled. According to the data sheet, it is
  92. * normally illegal to set this bit when the sampling rate is 96 kHz,
  93. * but according to ADI it is acceptable for this workaround.
  94. */
  95. regmap_update_bits(adau->regmap, ADAU17X1_CONVERTER0,
  96. ADAU17X1_CONVERTER0_ADOSR, ADAU17X1_CONVERTER0_ADOSR);
  97. regmap_update_bits(adau->regmap, ADAU17X1_CONVERTER0,
  98. ADAU17X1_CONVERTER0_ADOSR, 0);
  99. return 0;
  100. }
  101. static const char * const adau17x1_mono_stereo_text[] = {
  102. "Stereo",
  103. "Mono Left Channel (L+R)",
  104. "Mono Right Channel (L+R)",
  105. "Mono (L+R)",
  106. };
  107. static SOC_ENUM_SINGLE_DECL(adau17x1_dac_mode_enum,
  108. ADAU17X1_DAC_CONTROL0, 6, adau17x1_mono_stereo_text);
  109. static const struct snd_kcontrol_new adau17x1_dac_mode_mux =
  110. SOC_DAPM_ENUM("DAC Mono-Stereo-Mode", adau17x1_dac_mode_enum);
  111. static const struct snd_soc_dapm_widget adau17x1_dapm_widgets[] = {
  112. SND_SOC_DAPM_SUPPLY_S("PLL", 3, SND_SOC_NOPM, 0, 0, adau17x1_pll_event,
  113. SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
  114. SND_SOC_DAPM_SUPPLY("AIFCLK", SND_SOC_NOPM, 0, 0, NULL, 0),
  115. SND_SOC_DAPM_SUPPLY("MICBIAS", ADAU17X1_MICBIAS, 0, 0, NULL, 0),
  116. SND_SOC_DAPM_SUPPLY("Left Playback Enable", ADAU17X1_PLAY_POWER_MGMT,
  117. 0, 0, NULL, 0),
  118. SND_SOC_DAPM_SUPPLY("Right Playback Enable", ADAU17X1_PLAY_POWER_MGMT,
  119. 1, 0, NULL, 0),
  120. SND_SOC_DAPM_MUX("Left DAC Mode Mux", SND_SOC_NOPM, 0, 0,
  121. &adau17x1_dac_mode_mux),
  122. SND_SOC_DAPM_MUX("Right DAC Mode Mux", SND_SOC_NOPM, 0, 0,
  123. &adau17x1_dac_mode_mux),
  124. SND_SOC_DAPM_ADC_E("Left Decimator", NULL, ADAU17X1_ADC_CONTROL, 0, 0,
  125. adau17x1_adc_fixup, SND_SOC_DAPM_POST_PMU),
  126. SND_SOC_DAPM_ADC("Right Decimator", NULL, ADAU17X1_ADC_CONTROL, 1, 0),
  127. SND_SOC_DAPM_DAC("Left DAC", NULL, ADAU17X1_DAC_CONTROL0, 0, 0),
  128. SND_SOC_DAPM_DAC("Right DAC", NULL, ADAU17X1_DAC_CONTROL0, 1, 0),
  129. };
  130. static const struct snd_soc_dapm_route adau17x1_dapm_routes[] = {
  131. { "Left Decimator", NULL, "SYSCLK" },
  132. { "Right Decimator", NULL, "SYSCLK" },
  133. { "Left DAC", NULL, "SYSCLK" },
  134. { "Right DAC", NULL, "SYSCLK" },
  135. { "Capture", NULL, "SYSCLK" },
  136. { "Playback", NULL, "SYSCLK" },
  137. { "Left DAC", NULL, "Left DAC Mode Mux" },
  138. { "Right DAC", NULL, "Right DAC Mode Mux" },
  139. { "Capture", NULL, "AIFCLK" },
  140. { "Playback", NULL, "AIFCLK" },
  141. };
  142. static const struct snd_soc_dapm_route adau17x1_dapm_pll_route = {
  143. "SYSCLK", NULL, "PLL",
  144. };
  145. /*
  146. * The MUX register for the Capture and Playback MUXs selects either DSP as
  147. * source/destination or one of the TDM slots. The TDM slot is selected via
  148. * snd_soc_dai_set_tdm_slot(), so we only expose whether to go to the DSP or
  149. * directly to the DAI interface with this control.
  150. */
  151. static int adau17x1_dsp_mux_enum_put(struct snd_kcontrol *kcontrol,
  152. struct snd_ctl_elem_value *ucontrol)
  153. {
  154. struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol);
  155. struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
  156. struct adau *adau = snd_soc_component_get_drvdata(component);
  157. struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
  158. struct snd_soc_dapm_update update = {};
  159. unsigned int stream = e->shift_l;
  160. unsigned int val, change;
  161. int reg;
  162. if (ucontrol->value.enumerated.item[0] >= e->items)
  163. return -EINVAL;
  164. switch (ucontrol->value.enumerated.item[0]) {
  165. case 0:
  166. val = 0;
  167. adau->dsp_bypass[stream] = false;
  168. break;
  169. default:
  170. val = (adau->tdm_slot[stream] * 2) + 1;
  171. adau->dsp_bypass[stream] = true;
  172. break;
  173. }
  174. if (stream == SNDRV_PCM_STREAM_PLAYBACK)
  175. reg = ADAU17X1_SERIAL_INPUT_ROUTE;
  176. else
  177. reg = ADAU17X1_SERIAL_OUTPUT_ROUTE;
  178. change = snd_soc_component_test_bits(component, reg, 0xff, val);
  179. if (change) {
  180. update.kcontrol = kcontrol;
  181. update.mask = 0xff;
  182. update.reg = reg;
  183. update.val = val;
  184. snd_soc_dapm_mux_update_power(dapm, kcontrol,
  185. ucontrol->value.enumerated.item[0], e, &update);
  186. }
  187. return change;
  188. }
  189. static int adau17x1_dsp_mux_enum_get(struct snd_kcontrol *kcontrol,
  190. struct snd_ctl_elem_value *ucontrol)
  191. {
  192. struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol);
  193. struct adau *adau = snd_soc_component_get_drvdata(component);
  194. struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
  195. unsigned int stream = e->shift_l;
  196. unsigned int reg, val;
  197. int ret;
  198. if (stream == SNDRV_PCM_STREAM_PLAYBACK)
  199. reg = ADAU17X1_SERIAL_INPUT_ROUTE;
  200. else
  201. reg = ADAU17X1_SERIAL_OUTPUT_ROUTE;
  202. ret = regmap_read(adau->regmap, reg, &val);
  203. if (ret)
  204. return ret;
  205. if (val != 0)
  206. val = 1;
  207. ucontrol->value.enumerated.item[0] = val;
  208. return 0;
  209. }
  210. #define DECLARE_ADAU17X1_DSP_MUX_CTRL(_name, _label, _stream, _text) \
  211. const struct snd_kcontrol_new _name = \
  212. SOC_DAPM_ENUM_EXT(_label, (const struct soc_enum)\
  213. SOC_ENUM_SINGLE(SND_SOC_NOPM, _stream, \
  214. ARRAY_SIZE(_text), _text), \
  215. adau17x1_dsp_mux_enum_get, adau17x1_dsp_mux_enum_put)
  216. static const char * const adau17x1_dac_mux_text[] = {
  217. "DSP",
  218. "AIFIN",
  219. };
  220. static const char * const adau17x1_capture_mux_text[] = {
  221. "DSP",
  222. "Decimator",
  223. };
  224. static DECLARE_ADAU17X1_DSP_MUX_CTRL(adau17x1_dac_mux, "DAC Playback Mux",
  225. SNDRV_PCM_STREAM_PLAYBACK, adau17x1_dac_mux_text);
  226. static DECLARE_ADAU17X1_DSP_MUX_CTRL(adau17x1_capture_mux, "Capture Mux",
  227. SNDRV_PCM_STREAM_CAPTURE, adau17x1_capture_mux_text);
  228. static const struct snd_soc_dapm_widget adau17x1_dsp_dapm_widgets[] = {
  229. SND_SOC_DAPM_PGA("DSP", ADAU17X1_DSP_RUN, 0, 0, NULL, 0),
  230. SND_SOC_DAPM_SIGGEN("DSP Siggen"),
  231. SND_SOC_DAPM_MUX("DAC Playback Mux", SND_SOC_NOPM, 0, 0,
  232. &adau17x1_dac_mux),
  233. SND_SOC_DAPM_MUX("Capture Mux", SND_SOC_NOPM, 0, 0,
  234. &adau17x1_capture_mux),
  235. };
  236. static const struct snd_soc_dapm_route adau17x1_dsp_dapm_routes[] = {
  237. { "DAC Playback Mux", "DSP", "DSP" },
  238. { "DAC Playback Mux", "AIFIN", "Playback" },
  239. { "Left DAC Mode Mux", "Stereo", "DAC Playback Mux" },
  240. { "Left DAC Mode Mux", "Mono (L+R)", "DAC Playback Mux" },
  241. { "Left DAC Mode Mux", "Mono Left Channel (L+R)", "DAC Playback Mux" },
  242. { "Right DAC Mode Mux", "Stereo", "DAC Playback Mux" },
  243. { "Right DAC Mode Mux", "Mono (L+R)", "DAC Playback Mux" },
  244. { "Right DAC Mode Mux", "Mono Right Channel (L+R)", "DAC Playback Mux" },
  245. { "Capture Mux", "DSP", "DSP" },
  246. { "Capture Mux", "Decimator", "Left Decimator" },
  247. { "Capture Mux", "Decimator", "Right Decimator" },
  248. { "Capture", NULL, "Capture Mux" },
  249. { "DSP", NULL, "DSP Siggen" },
  250. { "DSP", NULL, "Left Decimator" },
  251. { "DSP", NULL, "Right Decimator" },
  252. { "DSP", NULL, "Playback" },
  253. };
  254. static const struct snd_soc_dapm_route adau17x1_no_dsp_dapm_routes[] = {
  255. { "Left DAC Mode Mux", "Stereo", "Playback" },
  256. { "Left DAC Mode Mux", "Mono (L+R)", "Playback" },
  257. { "Left DAC Mode Mux", "Mono Left Channel (L+R)", "Playback" },
  258. { "Right DAC Mode Mux", "Stereo", "Playback" },
  259. { "Right DAC Mode Mux", "Mono (L+R)", "Playback" },
  260. { "Right DAC Mode Mux", "Mono Right Channel (L+R)", "Playback" },
  261. { "Capture", NULL, "Left Decimator" },
  262. { "Capture", NULL, "Right Decimator" },
  263. };
  264. static bool adau17x1_has_dsp(struct adau *adau)
  265. {
  266. switch (adau->type) {
  267. case ADAU1761:
  268. case ADAU1381:
  269. case ADAU1781:
  270. return true;
  271. default:
  272. return false;
  273. }
  274. }
  275. /* Chip has a DSP but we're pretending it doesn't. */
  276. static bool adau17x1_has_disused_dsp(struct adau *adau)
  277. {
  278. switch (adau->type) {
  279. case ADAU1761_AS_1361:
  280. return true;
  281. default:
  282. return false;
  283. }
  284. }
  285. static bool adau17x1_has_safeload(struct adau *adau)
  286. {
  287. switch (adau->type) {
  288. case ADAU1761:
  289. case ADAU1781:
  290. return true;
  291. default:
  292. return false;
  293. }
  294. }
  295. static int adau17x1_set_dai_pll(struct snd_soc_dai *dai, int pll_id,
  296. int source, unsigned int freq_in, unsigned int freq_out)
  297. {
  298. struct snd_soc_component *component = dai->component;
  299. struct adau *adau = snd_soc_component_get_drvdata(component);
  300. int ret;
  301. if (freq_in < 8000000 || freq_in > 27000000)
  302. return -EINVAL;
  303. ret = adau_calc_pll_cfg(freq_in, freq_out, adau->pll_regs);
  304. if (ret < 0)
  305. return ret;
  306. /* The PLL register is 6 bytes long and can only be written at once. */
  307. ret = regmap_raw_write(adau->regmap, ADAU17X1_PLL_CONTROL,
  308. adau->pll_regs, ARRAY_SIZE(adau->pll_regs));
  309. if (ret)
  310. return ret;
  311. adau->pll_freq = freq_out;
  312. return 0;
  313. }
  314. static int adau17x1_set_dai_sysclk(struct snd_soc_dai *dai,
  315. int clk_id, unsigned int freq, int dir)
  316. {
  317. struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(dai->component);
  318. struct adau *adau = snd_soc_component_get_drvdata(dai->component);
  319. bool is_pll;
  320. bool was_pll;
  321. switch (clk_id) {
  322. case ADAU17X1_CLK_SRC_MCLK:
  323. is_pll = false;
  324. break;
  325. case ADAU17X1_CLK_SRC_PLL_AUTO:
  326. if (!adau->mclk)
  327. return -EINVAL;
  328. fallthrough;
  329. case ADAU17X1_CLK_SRC_PLL:
  330. is_pll = true;
  331. break;
  332. default:
  333. return -EINVAL;
  334. }
  335. switch (adau->clk_src) {
  336. case ADAU17X1_CLK_SRC_MCLK:
  337. was_pll = false;
  338. break;
  339. case ADAU17X1_CLK_SRC_PLL:
  340. case ADAU17X1_CLK_SRC_PLL_AUTO:
  341. was_pll = true;
  342. break;
  343. default:
  344. return -EINVAL;
  345. }
  346. adau->sysclk = freq;
  347. if (is_pll != was_pll) {
  348. if (is_pll) {
  349. snd_soc_dapm_add_routes(dapm,
  350. &adau17x1_dapm_pll_route, 1);
  351. } else {
  352. snd_soc_dapm_del_routes(dapm,
  353. &adau17x1_dapm_pll_route, 1);
  354. }
  355. }
  356. adau->clk_src = clk_id;
  357. return 0;
  358. }
  359. static int adau17x1_auto_pll(struct snd_soc_dai *dai,
  360. struct snd_pcm_hw_params *params)
  361. {
  362. struct adau *adau = snd_soc_dai_get_drvdata(dai);
  363. unsigned int pll_rate;
  364. switch (params_rate(params)) {
  365. case 48000:
  366. case 8000:
  367. case 12000:
  368. case 16000:
  369. case 24000:
  370. case 32000:
  371. case 96000:
  372. pll_rate = 48000 * 1024;
  373. break;
  374. case 44100:
  375. case 7350:
  376. case 11025:
  377. case 14700:
  378. case 22050:
  379. case 29400:
  380. case 88200:
  381. pll_rate = 44100 * 1024;
  382. break;
  383. default:
  384. return -EINVAL;
  385. }
  386. return adau17x1_set_dai_pll(dai, ADAU17X1_PLL, ADAU17X1_PLL_SRC_MCLK,
  387. clk_get_rate(adau->mclk), pll_rate);
  388. }
  389. static int adau17x1_hw_params(struct snd_pcm_substream *substream,
  390. struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
  391. {
  392. struct snd_soc_component *component = dai->component;
  393. struct adau *adau = snd_soc_component_get_drvdata(component);
  394. unsigned int val, div, dsp_div;
  395. unsigned int freq;
  396. int ret;
  397. switch (adau->clk_src) {
  398. case ADAU17X1_CLK_SRC_PLL_AUTO:
  399. ret = adau17x1_auto_pll(dai, params);
  400. if (ret)
  401. return ret;
  402. fallthrough;
  403. case ADAU17X1_CLK_SRC_PLL:
  404. freq = adau->pll_freq;
  405. break;
  406. default:
  407. freq = adau->sysclk;
  408. break;
  409. }
  410. if (freq % params_rate(params) != 0)
  411. return -EINVAL;
  412. switch (freq / params_rate(params)) {
  413. case 1024: /* fs */
  414. div = 0;
  415. dsp_div = 1;
  416. break;
  417. case 6144: /* fs / 6 */
  418. div = 1;
  419. dsp_div = 6;
  420. break;
  421. case 4096: /* fs / 4 */
  422. div = 2;
  423. dsp_div = 5;
  424. break;
  425. case 3072: /* fs / 3 */
  426. div = 3;
  427. dsp_div = 4;
  428. break;
  429. case 2048: /* fs / 2 */
  430. div = 4;
  431. dsp_div = 3;
  432. break;
  433. case 1536: /* fs / 1.5 */
  434. div = 5;
  435. dsp_div = 2;
  436. break;
  437. case 512: /* fs / 0.5 */
  438. div = 6;
  439. dsp_div = 0;
  440. break;
  441. default:
  442. return -EINVAL;
  443. }
  444. regmap_update_bits(adau->regmap, ADAU17X1_CONVERTER0,
  445. ADAU17X1_CONVERTER0_CONVSR_MASK, div);
  446. if (adau17x1_has_dsp(adau) || adau17x1_has_disused_dsp(adau))
  447. regmap_write(adau->regmap, ADAU17X1_SERIAL_SAMPLING_RATE, div);
  448. if (adau17x1_has_dsp(adau))
  449. regmap_write(adau->regmap, ADAU17X1_DSP_SAMPLING_RATE, dsp_div);
  450. if (adau->sigmadsp) {
  451. ret = adau17x1_setup_firmware(component, params_rate(params));
  452. if (ret < 0)
  453. return ret;
  454. }
  455. if (adau->dai_fmt != SND_SOC_DAIFMT_RIGHT_J)
  456. return 0;
  457. switch (params_width(params)) {
  458. case 16:
  459. val = ADAU17X1_SERIAL_PORT1_DELAY16;
  460. break;
  461. case 24:
  462. val = ADAU17X1_SERIAL_PORT1_DELAY8;
  463. break;
  464. case 32:
  465. val = ADAU17X1_SERIAL_PORT1_DELAY0;
  466. break;
  467. default:
  468. return -EINVAL;
  469. }
  470. return regmap_update_bits(adau->regmap, ADAU17X1_SERIAL_PORT1,
  471. ADAU17X1_SERIAL_PORT1_DELAY_MASK, val);
  472. }
  473. static int adau17x1_set_dai_fmt(struct snd_soc_dai *dai,
  474. unsigned int fmt)
  475. {
  476. struct adau *adau = snd_soc_component_get_drvdata(dai->component);
  477. unsigned int ctrl0, ctrl1;
  478. unsigned int ctrl0_mask;
  479. int lrclk_pol;
  480. switch (fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) {
  481. case SND_SOC_DAIFMT_CBP_CFP:
  482. ctrl0 = ADAU17X1_SERIAL_PORT0_MASTER;
  483. adau->master = true;
  484. break;
  485. case SND_SOC_DAIFMT_CBC_CFC:
  486. ctrl0 = 0;
  487. adau->master = false;
  488. break;
  489. default:
  490. return -EINVAL;
  491. }
  492. switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
  493. case SND_SOC_DAIFMT_I2S:
  494. lrclk_pol = 0;
  495. ctrl1 = ADAU17X1_SERIAL_PORT1_DELAY1;
  496. break;
  497. case SND_SOC_DAIFMT_LEFT_J:
  498. case SND_SOC_DAIFMT_RIGHT_J:
  499. lrclk_pol = 1;
  500. ctrl1 = ADAU17X1_SERIAL_PORT1_DELAY0;
  501. break;
  502. case SND_SOC_DAIFMT_DSP_A:
  503. lrclk_pol = 1;
  504. ctrl0 |= ADAU17X1_SERIAL_PORT0_PULSE_MODE;
  505. ctrl1 = ADAU17X1_SERIAL_PORT1_DELAY1;
  506. break;
  507. case SND_SOC_DAIFMT_DSP_B:
  508. lrclk_pol = 1;
  509. ctrl0 |= ADAU17X1_SERIAL_PORT0_PULSE_MODE;
  510. ctrl1 = ADAU17X1_SERIAL_PORT1_DELAY0;
  511. break;
  512. default:
  513. return -EINVAL;
  514. }
  515. switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
  516. case SND_SOC_DAIFMT_NB_NF:
  517. break;
  518. case SND_SOC_DAIFMT_IB_NF:
  519. ctrl0 |= ADAU17X1_SERIAL_PORT0_BCLK_POL;
  520. break;
  521. case SND_SOC_DAIFMT_NB_IF:
  522. lrclk_pol = !lrclk_pol;
  523. break;
  524. case SND_SOC_DAIFMT_IB_IF:
  525. ctrl0 |= ADAU17X1_SERIAL_PORT0_BCLK_POL;
  526. lrclk_pol = !lrclk_pol;
  527. break;
  528. default:
  529. return -EINVAL;
  530. }
  531. if (lrclk_pol)
  532. ctrl0 |= ADAU17X1_SERIAL_PORT0_LRCLK_POL;
  533. /* Set the mask to update all relevant bits in ADAU17X1_SERIAL_PORT0 */
  534. ctrl0_mask = ADAU17X1_SERIAL_PORT0_MASTER |
  535. ADAU17X1_SERIAL_PORT0_LRCLK_POL |
  536. ADAU17X1_SERIAL_PORT0_BCLK_POL |
  537. ADAU17X1_SERIAL_PORT0_PULSE_MODE;
  538. regmap_update_bits(adau->regmap, ADAU17X1_SERIAL_PORT0, ctrl0_mask,
  539. ctrl0);
  540. regmap_update_bits(adau->regmap, ADAU17X1_SERIAL_PORT1,
  541. ADAU17X1_SERIAL_PORT1_DELAY_MASK, ctrl1);
  542. adau->dai_fmt = fmt & SND_SOC_DAIFMT_FORMAT_MASK;
  543. return 0;
  544. }
  545. static int adau17x1_set_dai_tdm_slot(struct snd_soc_dai *dai,
  546. unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width)
  547. {
  548. struct adau *adau = snd_soc_component_get_drvdata(dai->component);
  549. unsigned int ser_ctrl0, ser_ctrl1;
  550. unsigned int conv_ctrl0, conv_ctrl1;
  551. /* I2S mode */
  552. if (slots == 0) {
  553. slots = 2;
  554. rx_mask = 3;
  555. tx_mask = 3;
  556. slot_width = 32;
  557. }
  558. switch (slots) {
  559. case 2:
  560. ser_ctrl0 = ADAU17X1_SERIAL_PORT0_STEREO;
  561. break;
  562. case 4:
  563. ser_ctrl0 = ADAU17X1_SERIAL_PORT0_TDM4;
  564. break;
  565. case 8:
  566. if (adau->type == ADAU1361)
  567. return -EINVAL;
  568. ser_ctrl0 = ADAU17X1_SERIAL_PORT0_TDM8;
  569. break;
  570. default:
  571. return -EINVAL;
  572. }
  573. switch (slot_width * slots) {
  574. case 32:
  575. if (adau->type == ADAU1761 || adau->type == ADAU1761_AS_1361)
  576. return -EINVAL;
  577. ser_ctrl1 = ADAU17X1_SERIAL_PORT1_BCLK32;
  578. break;
  579. case 64:
  580. ser_ctrl1 = ADAU17X1_SERIAL_PORT1_BCLK64;
  581. break;
  582. case 48:
  583. ser_ctrl1 = ADAU17X1_SERIAL_PORT1_BCLK48;
  584. break;
  585. case 128:
  586. ser_ctrl1 = ADAU17X1_SERIAL_PORT1_BCLK128;
  587. break;
  588. case 256:
  589. if (adau->type == ADAU1361)
  590. return -EINVAL;
  591. ser_ctrl1 = ADAU17X1_SERIAL_PORT1_BCLK256;
  592. break;
  593. default:
  594. return -EINVAL;
  595. }
  596. switch (rx_mask) {
  597. case 0x03:
  598. conv_ctrl1 = ADAU17X1_CONVERTER1_ADC_PAIR(1);
  599. adau->tdm_slot[SNDRV_PCM_STREAM_CAPTURE] = 0;
  600. break;
  601. case 0x0c:
  602. conv_ctrl1 = ADAU17X1_CONVERTER1_ADC_PAIR(2);
  603. adau->tdm_slot[SNDRV_PCM_STREAM_CAPTURE] = 1;
  604. break;
  605. case 0x30:
  606. conv_ctrl1 = ADAU17X1_CONVERTER1_ADC_PAIR(3);
  607. adau->tdm_slot[SNDRV_PCM_STREAM_CAPTURE] = 2;
  608. break;
  609. case 0xc0:
  610. conv_ctrl1 = ADAU17X1_CONVERTER1_ADC_PAIR(4);
  611. adau->tdm_slot[SNDRV_PCM_STREAM_CAPTURE] = 3;
  612. break;
  613. default:
  614. return -EINVAL;
  615. }
  616. switch (tx_mask) {
  617. case 0x03:
  618. conv_ctrl0 = ADAU17X1_CONVERTER0_DAC_PAIR(1);
  619. adau->tdm_slot[SNDRV_PCM_STREAM_PLAYBACK] = 0;
  620. break;
  621. case 0x0c:
  622. conv_ctrl0 = ADAU17X1_CONVERTER0_DAC_PAIR(2);
  623. adau->tdm_slot[SNDRV_PCM_STREAM_PLAYBACK] = 1;
  624. break;
  625. case 0x30:
  626. conv_ctrl0 = ADAU17X1_CONVERTER0_DAC_PAIR(3);
  627. adau->tdm_slot[SNDRV_PCM_STREAM_PLAYBACK] = 2;
  628. break;
  629. case 0xc0:
  630. conv_ctrl0 = ADAU17X1_CONVERTER0_DAC_PAIR(4);
  631. adau->tdm_slot[SNDRV_PCM_STREAM_PLAYBACK] = 3;
  632. break;
  633. default:
  634. return -EINVAL;
  635. }
  636. regmap_update_bits(adau->regmap, ADAU17X1_CONVERTER0,
  637. ADAU17X1_CONVERTER0_DAC_PAIR_MASK, conv_ctrl0);
  638. regmap_update_bits(adau->regmap, ADAU17X1_CONVERTER1,
  639. ADAU17X1_CONVERTER1_ADC_PAIR_MASK, conv_ctrl1);
  640. regmap_update_bits(adau->regmap, ADAU17X1_SERIAL_PORT0,
  641. ADAU17X1_SERIAL_PORT0_TDM_MASK, ser_ctrl0);
  642. regmap_update_bits(adau->regmap, ADAU17X1_SERIAL_PORT1,
  643. ADAU17X1_SERIAL_PORT1_BCLK_MASK, ser_ctrl1);
  644. if (!adau17x1_has_dsp(adau) && !adau17x1_has_disused_dsp(adau))
  645. return 0;
  646. if (adau->dsp_bypass[SNDRV_PCM_STREAM_PLAYBACK]) {
  647. regmap_write(adau->regmap, ADAU17X1_SERIAL_INPUT_ROUTE,
  648. (adau->tdm_slot[SNDRV_PCM_STREAM_PLAYBACK] * 2) + 1);
  649. }
  650. if (adau->dsp_bypass[SNDRV_PCM_STREAM_CAPTURE]) {
  651. regmap_write(adau->regmap, ADAU17X1_SERIAL_OUTPUT_ROUTE,
  652. (adau->tdm_slot[SNDRV_PCM_STREAM_CAPTURE] * 2) + 1);
  653. }
  654. return 0;
  655. }
  656. static int adau17x1_startup(struct snd_pcm_substream *substream,
  657. struct snd_soc_dai *dai)
  658. {
  659. struct adau *adau = snd_soc_component_get_drvdata(dai->component);
  660. if (adau->sigmadsp)
  661. return sigmadsp_restrict_params(adau->sigmadsp, substream);
  662. return 0;
  663. }
  664. const struct snd_soc_dai_ops adau17x1_dai_ops = {
  665. .hw_params = adau17x1_hw_params,
  666. .set_sysclk = adau17x1_set_dai_sysclk,
  667. .set_fmt = adau17x1_set_dai_fmt,
  668. .set_pll = adau17x1_set_dai_pll,
  669. .set_tdm_slot = adau17x1_set_dai_tdm_slot,
  670. .startup = adau17x1_startup,
  671. };
  672. EXPORT_SYMBOL_GPL(adau17x1_dai_ops);
  673. int adau17x1_set_micbias_voltage(struct snd_soc_component *component,
  674. enum adau17x1_micbias_voltage micbias)
  675. {
  676. struct adau *adau = snd_soc_component_get_drvdata(component);
  677. switch (micbias) {
  678. case ADAU17X1_MICBIAS_0_90_AVDD:
  679. case ADAU17X1_MICBIAS_0_65_AVDD:
  680. break;
  681. default:
  682. return -EINVAL;
  683. }
  684. return regmap_write(adau->regmap, ADAU17X1_MICBIAS, micbias << 2);
  685. }
  686. EXPORT_SYMBOL_GPL(adau17x1_set_micbias_voltage);
  687. bool adau17x1_precious_register(struct device *dev, unsigned int reg)
  688. {
  689. /* SigmaDSP parameter memory */
  690. if (reg < 0x400)
  691. return true;
  692. return false;
  693. }
  694. EXPORT_SYMBOL_GPL(adau17x1_precious_register);
  695. bool adau17x1_readable_register(struct device *dev, unsigned int reg)
  696. {
  697. /* SigmaDSP parameter memory */
  698. if (reg < 0x400)
  699. return true;
  700. switch (reg) {
  701. case ADAU17X1_CLOCK_CONTROL:
  702. case ADAU17X1_PLL_CONTROL:
  703. case ADAU17X1_REC_POWER_MGMT:
  704. case ADAU17X1_MICBIAS:
  705. case ADAU17X1_SERIAL_PORT0:
  706. case ADAU17X1_SERIAL_PORT1:
  707. case ADAU17X1_CONVERTER0:
  708. case ADAU17X1_CONVERTER1:
  709. case ADAU17X1_LEFT_INPUT_DIGITAL_VOL:
  710. case ADAU17X1_RIGHT_INPUT_DIGITAL_VOL:
  711. case ADAU17X1_ADC_CONTROL:
  712. case ADAU17X1_PLAY_POWER_MGMT:
  713. case ADAU17X1_DAC_CONTROL0:
  714. case ADAU17X1_DAC_CONTROL1:
  715. case ADAU17X1_DAC_CONTROL2:
  716. case ADAU17X1_SERIAL_PORT_PAD:
  717. case ADAU17X1_CONTROL_PORT_PAD0:
  718. case ADAU17X1_CONTROL_PORT_PAD1:
  719. case ADAU17X1_DSP_SAMPLING_RATE:
  720. case ADAU17X1_SERIAL_INPUT_ROUTE:
  721. case ADAU17X1_SERIAL_OUTPUT_ROUTE:
  722. case ADAU17X1_DSP_ENABLE:
  723. case ADAU17X1_DSP_RUN:
  724. case ADAU17X1_SERIAL_SAMPLING_RATE:
  725. return true;
  726. default:
  727. break;
  728. }
  729. return false;
  730. }
  731. EXPORT_SYMBOL_GPL(adau17x1_readable_register);
  732. bool adau17x1_volatile_register(struct device *dev, unsigned int reg)
  733. {
  734. /* SigmaDSP parameter and program memory */
  735. if (reg < 0x4000)
  736. return true;
  737. switch (reg) {
  738. /* The PLL register is 6 bytes long */
  739. case ADAU17X1_PLL_CONTROL:
  740. case ADAU17X1_PLL_CONTROL + 1:
  741. case ADAU17X1_PLL_CONTROL + 2:
  742. case ADAU17X1_PLL_CONTROL + 3:
  743. case ADAU17X1_PLL_CONTROL + 4:
  744. case ADAU17X1_PLL_CONTROL + 5:
  745. return true;
  746. default:
  747. break;
  748. }
  749. return false;
  750. }
  751. EXPORT_SYMBOL_GPL(adau17x1_volatile_register);
  752. static int adau17x1_setup_firmware(struct snd_soc_component *component,
  753. unsigned int rate)
  754. {
  755. int ret;
  756. int dspsr, dsp_run;
  757. struct adau *adau = snd_soc_component_get_drvdata(component);
  758. struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
  759. /* Check if sample rate is the same as before. If it is there is no
  760. * point in performing the below steps as the call to
  761. * sigmadsp_setup(...) will return directly when it finds the sample
  762. * rate to be the same as before. By checking this we can prevent an
  763. * audiable popping noise which occours when toggling DSP_RUN.
  764. */
  765. if (adau->sigmadsp->current_samplerate == rate)
  766. return 0;
  767. snd_soc_dapm_mutex_lock(dapm);
  768. ret = regmap_read(adau->regmap, ADAU17X1_DSP_SAMPLING_RATE, &dspsr);
  769. if (ret)
  770. goto err;
  771. ret = regmap_read(adau->regmap, ADAU17X1_DSP_RUN, &dsp_run);
  772. if (ret)
  773. goto err;
  774. regmap_write(adau->regmap, ADAU17X1_DSP_ENABLE, 1);
  775. regmap_write(adau->regmap, ADAU17X1_DSP_SAMPLING_RATE, 0xf);
  776. regmap_write(adau->regmap, ADAU17X1_DSP_RUN, 0);
  777. ret = sigmadsp_setup(adau->sigmadsp, rate);
  778. if (ret) {
  779. regmap_write(adau->regmap, ADAU17X1_DSP_ENABLE, 0);
  780. goto err;
  781. }
  782. regmap_write(adau->regmap, ADAU17X1_DSP_SAMPLING_RATE, dspsr);
  783. regmap_write(adau->regmap, ADAU17X1_DSP_RUN, dsp_run);
  784. err:
  785. snd_soc_dapm_mutex_unlock(dapm);
  786. return ret;
  787. }
  788. int adau17x1_add_widgets(struct snd_soc_component *component)
  789. {
  790. struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
  791. struct adau *adau = snd_soc_component_get_drvdata(component);
  792. int ret;
  793. ret = snd_soc_add_component_controls(component, adau17x1_controls,
  794. ARRAY_SIZE(adau17x1_controls));
  795. if (ret)
  796. return ret;
  797. ret = snd_soc_dapm_new_controls(dapm, adau17x1_dapm_widgets,
  798. ARRAY_SIZE(adau17x1_dapm_widgets));
  799. if (ret)
  800. return ret;
  801. if (adau17x1_has_dsp(adau)) {
  802. ret = snd_soc_dapm_new_controls(dapm, adau17x1_dsp_dapm_widgets,
  803. ARRAY_SIZE(adau17x1_dsp_dapm_widgets));
  804. if (ret)
  805. return ret;
  806. if (!adau->sigmadsp)
  807. return 0;
  808. ret = sigmadsp_attach(adau->sigmadsp, component);
  809. if (ret) {
  810. dev_err(component->dev, "Failed to attach firmware: %d\n",
  811. ret);
  812. return ret;
  813. }
  814. }
  815. return 0;
  816. }
  817. EXPORT_SYMBOL_GPL(adau17x1_add_widgets);
  818. int adau17x1_add_routes(struct snd_soc_component *component)
  819. {
  820. struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
  821. struct adau *adau = snd_soc_component_get_drvdata(component);
  822. int ret;
  823. ret = snd_soc_dapm_add_routes(dapm, adau17x1_dapm_routes,
  824. ARRAY_SIZE(adau17x1_dapm_routes));
  825. if (ret)
  826. return ret;
  827. if (adau17x1_has_dsp(adau)) {
  828. ret = snd_soc_dapm_add_routes(dapm, adau17x1_dsp_dapm_routes,
  829. ARRAY_SIZE(adau17x1_dsp_dapm_routes));
  830. } else {
  831. ret = snd_soc_dapm_add_routes(dapm, adau17x1_no_dsp_dapm_routes,
  832. ARRAY_SIZE(adau17x1_no_dsp_dapm_routes));
  833. }
  834. if (adau->clk_src != ADAU17X1_CLK_SRC_MCLK)
  835. snd_soc_dapm_add_routes(dapm, &adau17x1_dapm_pll_route, 1);
  836. return ret;
  837. }
  838. EXPORT_SYMBOL_GPL(adau17x1_add_routes);
  839. int adau17x1_resume(struct snd_soc_component *component)
  840. {
  841. struct adau *adau = snd_soc_component_get_drvdata(component);
  842. if (adau->switch_mode)
  843. adau->switch_mode(component->dev);
  844. regcache_sync(adau->regmap);
  845. return 0;
  846. }
  847. EXPORT_SYMBOL_GPL(adau17x1_resume);
  848. static int adau17x1_safeload(struct sigmadsp *sigmadsp, unsigned int addr,
  849. const uint8_t bytes[], size_t len)
  850. {
  851. uint8_t buf[ADAU17X1_WORD_SIZE];
  852. uint8_t data[ADAU17X1_SAFELOAD_DATA_SIZE];
  853. unsigned int addr_offset;
  854. unsigned int nbr_words;
  855. int ret;
  856. /* write data to safeload addresses. Check if len is not a multiple of
  857. * 4 bytes, if so we need to zero pad.
  858. */
  859. nbr_words = len / ADAU17X1_WORD_SIZE;
  860. if ((len - nbr_words * ADAU17X1_WORD_SIZE) == 0) {
  861. ret = regmap_raw_write(sigmadsp->control_data,
  862. ADAU17X1_SAFELOAD_DATA, bytes, len);
  863. } else {
  864. nbr_words++;
  865. memset(data, 0, ADAU17X1_SAFELOAD_DATA_SIZE);
  866. memcpy(data, bytes, len);
  867. ret = regmap_raw_write(sigmadsp->control_data,
  868. ADAU17X1_SAFELOAD_DATA, data,
  869. nbr_words * ADAU17X1_WORD_SIZE);
  870. }
  871. if (ret < 0)
  872. return ret;
  873. /* Write target address, target address is offset by 1 */
  874. addr_offset = addr - 1;
  875. put_unaligned_be32(addr_offset, buf);
  876. ret = regmap_raw_write(sigmadsp->control_data,
  877. ADAU17X1_SAFELOAD_TARGET_ADDRESS, buf, ADAU17X1_WORD_SIZE);
  878. if (ret < 0)
  879. return ret;
  880. /* write nbr of words to trigger address */
  881. put_unaligned_be32(nbr_words, buf);
  882. ret = regmap_raw_write(sigmadsp->control_data,
  883. ADAU17X1_SAFELOAD_TRIGGER, buf, ADAU17X1_WORD_SIZE);
  884. if (ret < 0)
  885. return ret;
  886. return 0;
  887. }
  888. static const struct sigmadsp_ops adau17x1_sigmadsp_ops = {
  889. .safeload = adau17x1_safeload,
  890. };
  891. int adau17x1_probe(struct device *dev, struct regmap *regmap,
  892. enum adau17x1_type type, void (*switch_mode)(struct device *dev),
  893. const char *firmware_name)
  894. {
  895. struct adau *adau;
  896. int ret;
  897. if (IS_ERR(regmap))
  898. return PTR_ERR(regmap);
  899. adau = devm_kzalloc(dev, sizeof(*adau), GFP_KERNEL);
  900. if (!adau)
  901. return -ENOMEM;
  902. adau->mclk = devm_clk_get(dev, "mclk");
  903. if (IS_ERR(adau->mclk)) {
  904. if (PTR_ERR(adau->mclk) != -ENOENT)
  905. return PTR_ERR(adau->mclk);
  906. /* Clock is optional (for the driver) */
  907. adau->mclk = NULL;
  908. } else if (adau->mclk) {
  909. adau->clk_src = ADAU17X1_CLK_SRC_PLL_AUTO;
  910. /*
  911. * Any valid PLL output rate will work at this point, use one
  912. * that is likely to be chosen later as well. The register will
  913. * be written when the PLL is powered up for the first time.
  914. */
  915. ret = adau_calc_pll_cfg(clk_get_rate(adau->mclk), 48000 * 1024,
  916. adau->pll_regs);
  917. if (ret < 0)
  918. return ret;
  919. ret = clk_prepare_enable(adau->mclk);
  920. if (ret)
  921. return ret;
  922. }
  923. adau->regmap = regmap;
  924. adau->switch_mode = switch_mode;
  925. adau->type = type;
  926. dev_set_drvdata(dev, adau);
  927. if (firmware_name) {
  928. if (adau17x1_has_safeload(adau)) {
  929. adau->sigmadsp = devm_sigmadsp_init_regmap(dev, regmap,
  930. &adau17x1_sigmadsp_ops, firmware_name);
  931. } else {
  932. adau->sigmadsp = devm_sigmadsp_init_regmap(dev, regmap,
  933. NULL, firmware_name);
  934. }
  935. if (IS_ERR(adau->sigmadsp)) {
  936. dev_warn(dev, "Could not find firmware file: %ld\n",
  937. PTR_ERR(adau->sigmadsp));
  938. adau->sigmadsp = NULL;
  939. }
  940. }
  941. if (switch_mode)
  942. switch_mode(dev);
  943. return 0;
  944. }
  945. EXPORT_SYMBOL_GPL(adau17x1_probe);
  946. void adau17x1_remove(struct device *dev)
  947. {
  948. struct adau *adau = dev_get_drvdata(dev);
  949. clk_disable_unprepare(adau->mclk);
  950. }
  951. EXPORT_SYMBOL_GPL(adau17x1_remove);
  952. MODULE_DESCRIPTION("ASoC ADAU1X61/ADAU1X81 common code");
  953. MODULE_AUTHOR("Lars-Peter Clausen <[email protected]>");
  954. MODULE_LICENSE("GPL");