s3c-i2s-v2.c 15 KB

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