s3c-i2s-v2.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. /* sound/soc/s3c24xx/s3c-i2c-v2.c
  2. *
  3. * ALSA Soc Audio Layer - I2S core for newer Samsung SoCs.
  4. *
  5. * Copyright (c) 2006 Wolfson Microelectronics PLC.
  6. * Graeme Gregory graeme.gregory@wolfsonmicro.com
  7. * linux@wolfsonmicro.com
  8. *
  9. * Copyright (c) 2008, 2007, 2004-2005 Simtec Electronics
  10. * http://armlinux.simtec.co.uk/
  11. * Ben Dooks <ben@simtec.co.uk>
  12. *
  13. * This program is free software; you can redistribute it and/or modify it
  14. * under the terms of the GNU General Public License as published by the
  15. * Free Software Foundation; either version 2 of the License, or (at your
  16. * option) any later version.
  17. */
  18. #include <linux/init.h>
  19. #include <linux/module.h>
  20. #include <linux/device.h>
  21. #include <linux/delay.h>
  22. #include <linux/clk.h>
  23. #include <linux/kernel.h>
  24. #include <linux/io.h>
  25. #include <sound/core.h>
  26. #include <sound/pcm.h>
  27. #include <sound/pcm_params.h>
  28. #include <sound/initval.h>
  29. #include <sound/soc.h>
  30. #include <plat/regs-s3c2412-iis.h>
  31. #include <plat/audio.h>
  32. #include <mach/dma.h>
  33. #include "s3c-i2s-v2.h"
  34. #define S3C2412_I2S_DEBUG_CON 0
  35. #define S3C2412_I2S_DEBUG 0
  36. #if S3C2412_I2S_DEBUG
  37. #define DBG(x...) printk(KERN_INFO x)
  38. #else
  39. #define DBG(x...) do { } while (0)
  40. #endif
  41. static inline struct s3c_i2sv2_info *to_info(struct snd_soc_dai *cpu_dai)
  42. {
  43. return cpu_dai->private_data;
  44. }
  45. #define bit_set(v, b) (((v) & (b)) ? 1 : 0)
  46. #if S3C2412_I2S_DEBUG_CON
  47. static void dbg_showcon(const char *fn, u32 con)
  48. {
  49. printk(KERN_DEBUG "%s: LRI=%d, TXFEMPT=%d, RXFEMPT=%d, TXFFULL=%d, RXFFULL=%d\n", fn,
  50. bit_set(con, S3C2412_IISCON_LRINDEX),
  51. bit_set(con, S3C2412_IISCON_TXFIFO_EMPTY),
  52. bit_set(con, S3C2412_IISCON_RXFIFO_EMPTY),
  53. bit_set(con, S3C2412_IISCON_TXFIFO_FULL),
  54. bit_set(con, S3C2412_IISCON_RXFIFO_FULL));
  55. printk(KERN_DEBUG "%s: PAUSE: TXDMA=%d, RXDMA=%d, TXCH=%d, RXCH=%d\n",
  56. fn,
  57. bit_set(con, S3C2412_IISCON_TXDMA_PAUSE),
  58. bit_set(con, S3C2412_IISCON_RXDMA_PAUSE),
  59. bit_set(con, S3C2412_IISCON_TXCH_PAUSE),
  60. bit_set(con, S3C2412_IISCON_RXCH_PAUSE));
  61. printk(KERN_DEBUG "%s: ACTIVE: TXDMA=%d, RXDMA=%d, IIS=%d\n", fn,
  62. bit_set(con, S3C2412_IISCON_TXDMA_ACTIVE),
  63. bit_set(con, S3C2412_IISCON_RXDMA_ACTIVE),
  64. bit_set(con, S3C2412_IISCON_IIS_ACTIVE));
  65. }
  66. #else
  67. static inline void dbg_showcon(const char *fn, u32 con)
  68. {
  69. }
  70. #endif
  71. /* Turn on or off the transmission path. */
  72. void s3c2412_snd_txctrl(struct s3c_i2sv2_info *i2s, int on)
  73. {
  74. void __iomem *regs = i2s->regs;
  75. u32 fic, con, mod;
  76. DBG("%s(%d)\n", __func__, on);
  77. fic = readl(regs + S3C2412_IISFIC);
  78. con = readl(regs + S3C2412_IISCON);
  79. mod = readl(regs + S3C2412_IISMOD);
  80. DBG("%s: IIS: CON=%x MOD=%x FIC=%x\n", __func__, con, mod, fic);
  81. if (on) {
  82. con |= S3C2412_IISCON_TXDMA_ACTIVE | S3C2412_IISCON_IIS_ACTIVE;
  83. con &= ~S3C2412_IISCON_TXDMA_PAUSE;
  84. con &= ~S3C2412_IISCON_TXCH_PAUSE;
  85. switch (mod & S3C2412_IISMOD_MODE_MASK) {
  86. case S3C2412_IISMOD_MODE_TXONLY:
  87. case S3C2412_IISMOD_MODE_TXRX:
  88. /* do nothing, we are in the right mode */
  89. break;
  90. case S3C2412_IISMOD_MODE_RXONLY:
  91. mod &= ~S3C2412_IISMOD_MODE_MASK;
  92. mod |= S3C2412_IISMOD_MODE_TXRX;
  93. break;
  94. default:
  95. dev_err(i2s->dev, "TXEN: Invalid MODE in IISMOD\n");
  96. }
  97. writel(con, regs + S3C2412_IISCON);
  98. writel(mod, regs + S3C2412_IISMOD);
  99. } else {
  100. /* Note, we do not have any indication that the FIFO problems
  101. * tha the S3C2410/2440 had apply here, so we should be able
  102. * to disable the DMA and TX without resetting the FIFOS.
  103. */
  104. con |= S3C2412_IISCON_TXDMA_PAUSE;
  105. con |= S3C2412_IISCON_TXCH_PAUSE;
  106. con &= ~S3C2412_IISCON_TXDMA_ACTIVE;
  107. switch (mod & S3C2412_IISMOD_MODE_MASK) {
  108. case S3C2412_IISMOD_MODE_TXRX:
  109. mod &= ~S3C2412_IISMOD_MODE_MASK;
  110. mod |= S3C2412_IISMOD_MODE_RXONLY;
  111. break;
  112. case S3C2412_IISMOD_MODE_TXONLY:
  113. mod &= ~S3C2412_IISMOD_MODE_MASK;
  114. con &= ~S3C2412_IISCON_IIS_ACTIVE;
  115. break;
  116. default:
  117. dev_err(i2s->dev, "TXDIS: Invalid MODE in IISMOD\n");
  118. }
  119. writel(mod, regs + S3C2412_IISMOD);
  120. writel(con, regs + S3C2412_IISCON);
  121. }
  122. fic = readl(regs + S3C2412_IISFIC);
  123. dbg_showcon(__func__, con);
  124. DBG("%s: IIS: CON=%x MOD=%x FIC=%x\n", __func__, con, mod, fic);
  125. }
  126. EXPORT_SYMBOL_GPL(s3c2412_snd_txctrl);
  127. void s3c2412_snd_rxctrl(struct s3c_i2sv2_info *i2s, int on)
  128. {
  129. void __iomem *regs = i2s->regs;
  130. u32 fic, con, mod;
  131. DBG("%s(%d)\n", __func__, on);
  132. fic = readl(regs + S3C2412_IISFIC);
  133. con = readl(regs + S3C2412_IISCON);
  134. mod = readl(regs + S3C2412_IISMOD);
  135. DBG("%s: IIS: CON=%x MOD=%x FIC=%x\n", __func__, con, mod, fic);
  136. if (on) {
  137. con |= S3C2412_IISCON_RXDMA_ACTIVE | S3C2412_IISCON_IIS_ACTIVE;
  138. con &= ~S3C2412_IISCON_RXDMA_PAUSE;
  139. con &= ~S3C2412_IISCON_RXCH_PAUSE;
  140. switch (mod & S3C2412_IISMOD_MODE_MASK) {
  141. case S3C2412_IISMOD_MODE_TXRX:
  142. case S3C2412_IISMOD_MODE_RXONLY:
  143. /* do nothing, we are in the right mode */
  144. break;
  145. case S3C2412_IISMOD_MODE_TXONLY:
  146. mod &= ~S3C2412_IISMOD_MODE_MASK;
  147. mod |= S3C2412_IISMOD_MODE_TXRX;
  148. break;
  149. default:
  150. dev_err(i2s->dev, "RXEN: Invalid MODE in IISMOD\n");
  151. }
  152. writel(mod, regs + S3C2412_IISMOD);
  153. writel(con, regs + S3C2412_IISCON);
  154. } else {
  155. /* See txctrl notes on FIFOs. */
  156. con &= ~S3C2412_IISCON_RXDMA_ACTIVE;
  157. con |= S3C2412_IISCON_RXDMA_PAUSE;
  158. con |= S3C2412_IISCON_RXCH_PAUSE;
  159. switch (mod & S3C2412_IISMOD_MODE_MASK) {
  160. case S3C2412_IISMOD_MODE_RXONLY:
  161. con &= ~S3C2412_IISCON_IIS_ACTIVE;
  162. mod &= ~S3C2412_IISMOD_MODE_MASK;
  163. break;
  164. case S3C2412_IISMOD_MODE_TXRX:
  165. mod &= ~S3C2412_IISMOD_MODE_MASK;
  166. mod |= S3C2412_IISMOD_MODE_TXONLY;
  167. break;
  168. default:
  169. dev_err(i2s->dev, "RXEN: Invalid MODE in IISMOD\n");
  170. }
  171. writel(con, regs + S3C2412_IISCON);
  172. writel(mod, regs + S3C2412_IISMOD);
  173. }
  174. fic = readl(regs + S3C2412_IISFIC);
  175. DBG("%s: IIS: CON=%x MOD=%x FIC=%x\n", __func__, con, mod, fic);
  176. }
  177. EXPORT_SYMBOL_GPL(s3c2412_snd_rxctrl);
  178. /*
  179. * Wait for the LR signal to allow synchronisation to the L/R clock
  180. * from the codec. May only be needed for slave mode.
  181. */
  182. static int s3c2412_snd_lrsync(struct s3c_i2sv2_info *i2s)
  183. {
  184. u32 iiscon;
  185. unsigned long timeout = jiffies + msecs_to_jiffies(5);
  186. DBG("Entered %s\n", __func__);
  187. while (1) {
  188. iiscon = readl(i2s->regs + S3C2412_IISCON);
  189. if (iiscon & S3C2412_IISCON_LRINDEX)
  190. break;
  191. if (timeout < jiffies) {
  192. printk(KERN_ERR "%s: timeout\n", __func__);
  193. return -ETIMEDOUT;
  194. }
  195. }
  196. return 0;
  197. }
  198. /*
  199. * Set S3C2412 I2S DAI format
  200. */
  201. static int s3c2412_i2s_set_fmt(struct snd_soc_dai *cpu_dai,
  202. unsigned int fmt)
  203. {
  204. struct s3c_i2sv2_info *i2s = to_info(cpu_dai);
  205. u32 iismod;
  206. DBG("Entered %s\n", __func__);
  207. iismod = readl(i2s->regs + S3C2412_IISMOD);
  208. DBG("hw_params r: IISMOD: %x \n", iismod);
  209. #if defined(CONFIG_CPU_S3C2412) || defined(CONFIG_CPU_S3C2413)
  210. #define IISMOD_MASTER_MASK S3C2412_IISMOD_MASTER_MASK
  211. #define IISMOD_SLAVE S3C2412_IISMOD_SLAVE
  212. #define IISMOD_MASTER S3C2412_IISMOD_MASTER_INTERNAL
  213. #endif
  214. #if defined(CONFIG_PLAT_S3C64XX)
  215. /* From Rev1.1 datasheet, we have two master and two slave modes:
  216. * IMS[11:10]:
  217. * 00 = master mode, fed from PCLK
  218. * 01 = master mode, fed from CLKAUDIO
  219. * 10 = slave mode, using PCLK
  220. * 11 = slave mode, using I2SCLK
  221. */
  222. #define IISMOD_MASTER_MASK (1 << 11)
  223. #define IISMOD_SLAVE (1 << 11)
  224. #define IISMOD_MASTER (0x0)
  225. #endif
  226. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  227. case SND_SOC_DAIFMT_CBM_CFM:
  228. i2s->master = 0;
  229. iismod &= ~IISMOD_MASTER_MASK;
  230. iismod |= IISMOD_SLAVE;
  231. break;
  232. case SND_SOC_DAIFMT_CBS_CFS:
  233. i2s->master = 1;
  234. iismod &= ~IISMOD_MASTER_MASK;
  235. iismod |= IISMOD_MASTER;
  236. break;
  237. default:
  238. DBG("unknwon master/slave format\n");
  239. return -EINVAL;
  240. }
  241. iismod &= ~S3C2412_IISMOD_SDF_MASK;
  242. switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
  243. case SND_SOC_DAIFMT_RIGHT_J:
  244. iismod |= S3C2412_IISMOD_SDF_MSB;
  245. break;
  246. case SND_SOC_DAIFMT_LEFT_J:
  247. iismod |= S3C2412_IISMOD_SDF_LSB;
  248. break;
  249. case SND_SOC_DAIFMT_I2S:
  250. iismod |= S3C2412_IISMOD_SDF_IIS;
  251. break;
  252. default:
  253. DBG("Unknown data format\n");
  254. return -EINVAL;
  255. }
  256. writel(iismod, i2s->regs + S3C2412_IISMOD);
  257. DBG("hw_params w: IISMOD: %x \n", iismod);
  258. return 0;
  259. }
  260. static int s3c2412_i2s_hw_params(struct snd_pcm_substream *substream,
  261. struct snd_pcm_hw_params *params,
  262. struct snd_soc_dai *socdai)
  263. {
  264. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  265. struct snd_soc_dai_link *dai = rtd->dai;
  266. struct s3c_i2sv2_info *i2s = to_info(dai->cpu_dai);
  267. u32 iismod;
  268. DBG("Entered %s\n", __func__);
  269. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  270. dai->cpu_dai->dma_data = i2s->dma_playback;
  271. else
  272. dai->cpu_dai->dma_data = i2s->dma_capture;
  273. /* Working copies of register */
  274. iismod = readl(i2s->regs + S3C2412_IISMOD);
  275. DBG("%s: r: IISMOD: %x\n", __func__, iismod);
  276. switch (params_format(params)) {
  277. case SNDRV_PCM_FORMAT_S8:
  278. iismod |= S3C2412_IISMOD_8BIT;
  279. break;
  280. case SNDRV_PCM_FORMAT_S16_LE:
  281. iismod &= ~S3C2412_IISMOD_8BIT;
  282. break;
  283. }
  284. writel(iismod, i2s->regs + S3C2412_IISMOD);
  285. DBG("%s: w: IISMOD: %x\n", __func__, iismod);
  286. return 0;
  287. }
  288. static int s3c2412_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
  289. struct snd_soc_dai *dai)
  290. {
  291. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  292. struct s3c_i2sv2_info *i2s = to_info(rtd->dai->cpu_dai);
  293. int capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE);
  294. unsigned long irqs;
  295. int ret = 0;
  296. DBG("Entered %s\n", __func__);
  297. switch (cmd) {
  298. case SNDRV_PCM_TRIGGER_START:
  299. /* On start, ensure that the FIFOs are cleared and reset. */
  300. writel(capture ? S3C2412_IISFIC_RXFLUSH : S3C2412_IISFIC_TXFLUSH,
  301. i2s->regs + S3C2412_IISFIC);
  302. /* clear again, just in case */
  303. writel(0x0, i2s->regs + S3C2412_IISFIC);
  304. case SNDRV_PCM_TRIGGER_RESUME:
  305. case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
  306. if (!i2s->master) {
  307. ret = s3c2412_snd_lrsync(i2s);
  308. if (ret)
  309. goto exit_err;
  310. }
  311. local_irq_save(irqs);
  312. if (capture)
  313. s3c2412_snd_rxctrl(i2s, 1);
  314. else
  315. s3c2412_snd_txctrl(i2s, 1);
  316. local_irq_restore(irqs);
  317. break;
  318. case SNDRV_PCM_TRIGGER_STOP:
  319. case SNDRV_PCM_TRIGGER_SUSPEND:
  320. case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
  321. local_irq_save(irqs);
  322. if (capture)
  323. s3c2412_snd_rxctrl(i2s, 0);
  324. else
  325. s3c2412_snd_txctrl(i2s, 0);
  326. local_irq_restore(irqs);
  327. break;
  328. default:
  329. ret = -EINVAL;
  330. break;
  331. }
  332. exit_err:
  333. return ret;
  334. }
  335. /*
  336. * Set S3C2412 Clock dividers
  337. */
  338. static int s3c2412_i2s_set_clkdiv(struct snd_soc_dai *cpu_dai,
  339. int div_id, int div)
  340. {
  341. struct s3c_i2sv2_info *i2s = to_info(cpu_dai);
  342. u32 reg;
  343. DBG("%s(%p, %d, %d)\n", __func__, cpu_dai, div_id, div);
  344. switch (div_id) {
  345. case S3C_I2SV2_DIV_BCLK:
  346. reg = readl(i2s->regs + S3C2412_IISMOD);
  347. reg &= ~S3C2412_IISMOD_BCLK_MASK;
  348. writel(reg | div, i2s->regs + S3C2412_IISMOD);
  349. DBG("%s: MOD=%08x\n", __func__, readl(i2s->regs + S3C2412_IISMOD));
  350. break;
  351. case S3C_I2SV2_DIV_RCLK:
  352. if (div > 3) {
  353. /* convert value to bit field */
  354. switch (div) {
  355. case 256:
  356. div = S3C2412_IISMOD_RCLK_256FS;
  357. break;
  358. case 384:
  359. div = S3C2412_IISMOD_RCLK_384FS;
  360. break;
  361. case 512:
  362. div = S3C2412_IISMOD_RCLK_512FS;
  363. break;
  364. case 768:
  365. div = S3C2412_IISMOD_RCLK_768FS;
  366. break;
  367. default:
  368. return -EINVAL;
  369. }
  370. }
  371. reg = readl(i2s->regs + S3C2412_IISMOD);
  372. reg &= ~S3C2412_IISMOD_RCLK_MASK;
  373. writel(reg | div, i2s->regs + S3C2412_IISMOD);
  374. DBG("%s: MOD=%08x\n", __func__, readl(i2s->regs + S3C2412_IISMOD));
  375. break;
  376. case S3C_I2SV2_DIV_PRESCALER:
  377. if (div >= 0) {
  378. writel((div << 8) | S3C2412_IISPSR_PSREN,
  379. i2s->regs + S3C2412_IISPSR);
  380. } else {
  381. writel(0x0, i2s->regs + S3C2412_IISPSR);
  382. }
  383. DBG("%s: PSR=%08x\n", __func__, readl(i2s->regs + S3C2412_IISPSR));
  384. break;
  385. default:
  386. return -EINVAL;
  387. }
  388. return 0;
  389. }
  390. /* default table of all avaialable root fs divisors */
  391. static unsigned int iis_fs_tab[] = { 256, 512, 384, 768 };
  392. int s3c2412_iis_calc_rate(struct s3c_i2sv2_rate_calc *info,
  393. unsigned int *fstab,
  394. unsigned int rate, struct clk *clk)
  395. {
  396. unsigned long clkrate = clk_get_rate(clk);
  397. unsigned int div;
  398. unsigned int fsclk;
  399. unsigned int actual;
  400. unsigned int fs;
  401. unsigned int fsdiv;
  402. signed int deviation = 0;
  403. unsigned int best_fs = 0;
  404. unsigned int best_div = 0;
  405. unsigned int best_rate = 0;
  406. unsigned int best_deviation = INT_MAX;
  407. if (fstab == NULL)
  408. fstab = iis_fs_tab;
  409. for (fs = 0; fs < ARRAY_SIZE(iis_fs_tab); fs++) {
  410. fsdiv = iis_fs_tab[fs];
  411. fsclk = clkrate / fsdiv;
  412. div = fsclk / rate;
  413. if ((fsclk % rate) > (rate / 2))
  414. div++;
  415. if (div <= 1)
  416. continue;
  417. actual = clkrate / (fsdiv * div);
  418. deviation = actual - rate;
  419. printk(KERN_DEBUG "%dfs: div %d => result %d, deviation %d\n",
  420. fsdiv, div, actual, deviation);
  421. deviation = abs(deviation);
  422. if (deviation < best_deviation) {
  423. best_fs = fsdiv;
  424. best_div = div;
  425. best_rate = actual;
  426. best_deviation = deviation;
  427. }
  428. if (deviation == 0)
  429. break;
  430. }
  431. printk(KERN_DEBUG "best: fs=%d, div=%d, rate=%d\n",
  432. best_fs, best_div, best_rate);
  433. info->fs_div = best_fs;
  434. info->clk_div = best_div;
  435. return 0;
  436. }
  437. EXPORT_SYMBOL_GPL(s3c2412_iis_calc_rate);
  438. int s3c_i2sv2_probe(struct platform_device *pdev,
  439. struct snd_soc_dai *dai,
  440. struct s3c_i2sv2_info *i2s,
  441. unsigned long base)
  442. {
  443. struct device *dev = &pdev->dev;
  444. i2s->dev = dev;
  445. /* record our i2s structure for later use in the callbacks */
  446. dai->private_data = i2s;
  447. i2s->regs = ioremap(base, 0x100);
  448. if (i2s->regs == NULL) {
  449. dev_err(dev, "cannot ioremap registers\n");
  450. return -ENXIO;
  451. }
  452. i2s->iis_pclk = clk_get(dev, "iis");
  453. if (i2s->iis_pclk == NULL) {
  454. DBG("failed to get iis_clock\n");
  455. iounmap(i2s->regs);
  456. return -ENOENT;
  457. }
  458. clk_enable(i2s->iis_pclk);
  459. s3c2412_snd_txctrl(i2s, 0);
  460. s3c2412_snd_rxctrl(i2s, 0);
  461. return 0;
  462. }
  463. EXPORT_SYMBOL_GPL(s3c_i2sv2_probe);
  464. #ifdef CONFIG_PM
  465. static int s3c2412_i2s_suspend(struct snd_soc_dai *dai)
  466. {
  467. struct s3c_i2sv2_info *i2s = to_info(dai);
  468. u32 iismod;
  469. if (dai->active) {
  470. i2s->suspend_iismod = readl(i2s->regs + S3C2412_IISMOD);
  471. i2s->suspend_iiscon = readl(i2s->regs + S3C2412_IISCON);
  472. i2s->suspend_iispsr = readl(i2s->regs + S3C2412_IISPSR);
  473. /* some basic suspend checks */
  474. iismod = readl(i2s->regs + S3C2412_IISMOD);
  475. if (iismod & S3C2412_IISCON_RXDMA_ACTIVE)
  476. pr_warning("%s: RXDMA active?\n", __func__);
  477. if (iismod & S3C2412_IISCON_TXDMA_ACTIVE)
  478. pr_warning("%s: TXDMA active?\n", __func__);
  479. if (iismod & S3C2412_IISCON_IIS_ACTIVE)
  480. pr_warning("%s: IIS active\n", __func__);
  481. }
  482. return 0;
  483. }
  484. static int s3c2412_i2s_resume(struct snd_soc_dai *dai)
  485. {
  486. struct s3c_i2sv2_info *i2s = to_info(dai);
  487. pr_info("dai_active %d, IISMOD %08x, IISCON %08x\n",
  488. dai->active, i2s->suspend_iismod, i2s->suspend_iiscon);
  489. if (dai->active) {
  490. writel(i2s->suspend_iiscon, i2s->regs + S3C2412_IISCON);
  491. writel(i2s->suspend_iismod, i2s->regs + S3C2412_IISMOD);
  492. writel(i2s->suspend_iispsr, i2s->regs + S3C2412_IISPSR);
  493. writel(S3C2412_IISFIC_RXFLUSH | S3C2412_IISFIC_TXFLUSH,
  494. i2s->regs + S3C2412_IISFIC);
  495. ndelay(250);
  496. writel(0x0, i2s->regs + S3C2412_IISFIC);
  497. }
  498. return 0;
  499. }
  500. #else
  501. #define s3c2412_i2s_suspend NULL
  502. #define s3c2412_i2s_resume NULL
  503. #endif
  504. int s3c_i2sv2_register_dai(struct snd_soc_dai *dai)
  505. {
  506. dai->ops.trigger = s3c2412_i2s_trigger;
  507. dai->ops.hw_params = s3c2412_i2s_hw_params;
  508. dai->ops.set_fmt = s3c2412_i2s_set_fmt;
  509. dai->ops.set_clkdiv = s3c2412_i2s_set_clkdiv;
  510. dai->suspend = s3c2412_i2s_suspend;
  511. dai->resume = s3c2412_i2s_resume;
  512. return snd_soc_register_dai(dai);
  513. }
  514. EXPORT_SYMBOL_GPL(s3c_i2sv2_register_dai);