tegra30_i2s.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * tegra30_i2s.c - Tegra30 I2S driver
  4. *
  5. * Author: Stephen Warren <swarren@nvidia.com>
  6. * Copyright (c) 2010-2012, NVIDIA CORPORATION. All rights reserved.
  7. *
  8. * Based on code copyright/by:
  9. *
  10. * Copyright (c) 2009-2010, NVIDIA Corporation.
  11. * Scott Peterson <speterson@nvidia.com>
  12. *
  13. * Copyright (C) 2010 Google, Inc.
  14. * Iliyan Malchev <malchev@google.com>
  15. */
  16. #include <linux/clk.h>
  17. #include <linux/device.h>
  18. #include <linux/io.h>
  19. #include <linux/module.h>
  20. #include <linux/of.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/pm_runtime.h>
  23. #include <linux/regmap.h>
  24. #include <linux/reset.h>
  25. #include <linux/slab.h>
  26. #include <sound/core.h>
  27. #include <sound/pcm.h>
  28. #include <sound/pcm_params.h>
  29. #include <sound/soc.h>
  30. #include <sound/dmaengine_pcm.h>
  31. #include "tegra30_ahub.h"
  32. #include "tegra30_i2s.h"
  33. #define DRV_NAME "tegra30-i2s"
  34. static __maybe_unused int tegra30_i2s_runtime_suspend(struct device *dev)
  35. {
  36. struct tegra30_i2s *i2s = dev_get_drvdata(dev);
  37. regcache_cache_only(i2s->regmap, true);
  38. clk_disable_unprepare(i2s->clk_i2s);
  39. return 0;
  40. }
  41. static __maybe_unused int tegra30_i2s_runtime_resume(struct device *dev)
  42. {
  43. struct tegra30_i2s *i2s = dev_get_drvdata(dev);
  44. int ret;
  45. ret = clk_prepare_enable(i2s->clk_i2s);
  46. if (ret) {
  47. dev_err(dev, "clk_enable failed: %d\n", ret);
  48. return ret;
  49. }
  50. regcache_cache_only(i2s->regmap, false);
  51. regcache_mark_dirty(i2s->regmap);
  52. ret = regcache_sync(i2s->regmap);
  53. if (ret)
  54. goto disable_clocks;
  55. return 0;
  56. disable_clocks:
  57. clk_disable_unprepare(i2s->clk_i2s);
  58. return ret;
  59. }
  60. static int tegra30_i2s_set_fmt(struct snd_soc_dai *dai,
  61. unsigned int fmt)
  62. {
  63. struct tegra30_i2s *i2s = snd_soc_dai_get_drvdata(dai);
  64. unsigned int mask = 0, val = 0;
  65. switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
  66. case SND_SOC_DAIFMT_NB_NF:
  67. break;
  68. default:
  69. return -EINVAL;
  70. }
  71. mask |= TEGRA30_I2S_CTRL_MASTER_ENABLE;
  72. switch (fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) {
  73. case SND_SOC_DAIFMT_BP_FP:
  74. val |= TEGRA30_I2S_CTRL_MASTER_ENABLE;
  75. break;
  76. case SND_SOC_DAIFMT_BC_FC:
  77. break;
  78. default:
  79. return -EINVAL;
  80. }
  81. mask |= TEGRA30_I2S_CTRL_FRAME_FORMAT_MASK |
  82. TEGRA30_I2S_CTRL_LRCK_MASK;
  83. switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
  84. case SND_SOC_DAIFMT_DSP_A:
  85. val |= TEGRA30_I2S_CTRL_FRAME_FORMAT_FSYNC;
  86. val |= TEGRA30_I2S_CTRL_LRCK_L_LOW;
  87. break;
  88. case SND_SOC_DAIFMT_DSP_B:
  89. val |= TEGRA30_I2S_CTRL_FRAME_FORMAT_FSYNC;
  90. val |= TEGRA30_I2S_CTRL_LRCK_R_LOW;
  91. break;
  92. case SND_SOC_DAIFMT_I2S:
  93. val |= TEGRA30_I2S_CTRL_FRAME_FORMAT_LRCK;
  94. val |= TEGRA30_I2S_CTRL_LRCK_L_LOW;
  95. break;
  96. case SND_SOC_DAIFMT_RIGHT_J:
  97. val |= TEGRA30_I2S_CTRL_FRAME_FORMAT_LRCK;
  98. val |= TEGRA30_I2S_CTRL_LRCK_L_LOW;
  99. break;
  100. case SND_SOC_DAIFMT_LEFT_J:
  101. val |= TEGRA30_I2S_CTRL_FRAME_FORMAT_LRCK;
  102. val |= TEGRA30_I2S_CTRL_LRCK_L_LOW;
  103. break;
  104. default:
  105. return -EINVAL;
  106. }
  107. pm_runtime_get_sync(dai->dev);
  108. regmap_update_bits(i2s->regmap, TEGRA30_I2S_CTRL, mask, val);
  109. pm_runtime_put(dai->dev);
  110. return 0;
  111. }
  112. static int tegra30_i2s_hw_params(struct snd_pcm_substream *substream,
  113. struct snd_pcm_hw_params *params,
  114. struct snd_soc_dai *dai)
  115. {
  116. struct device *dev = dai->dev;
  117. struct tegra30_i2s *i2s = snd_soc_dai_get_drvdata(dai);
  118. unsigned int mask, val, reg;
  119. int ret, sample_size, srate, i2sclock, bitcnt;
  120. struct tegra30_ahub_cif_conf cif_conf;
  121. if (params_channels(params) != 2)
  122. return -EINVAL;
  123. mask = TEGRA30_I2S_CTRL_BIT_SIZE_MASK;
  124. switch (params_format(params)) {
  125. case SNDRV_PCM_FORMAT_S16_LE:
  126. val = TEGRA30_I2S_CTRL_BIT_SIZE_16;
  127. sample_size = 16;
  128. break;
  129. default:
  130. return -EINVAL;
  131. }
  132. regmap_update_bits(i2s->regmap, TEGRA30_I2S_CTRL, mask, val);
  133. srate = params_rate(params);
  134. /* Final "* 2" required by Tegra hardware */
  135. i2sclock = srate * params_channels(params) * sample_size * 2;
  136. bitcnt = (i2sclock / (2 * srate)) - 1;
  137. if (bitcnt < 0 || bitcnt > TEGRA30_I2S_TIMING_CHANNEL_BIT_COUNT_MASK_US)
  138. return -EINVAL;
  139. ret = clk_set_rate(i2s->clk_i2s, i2sclock);
  140. if (ret) {
  141. dev_err(dev, "Can't set I2S clock rate: %d\n", ret);
  142. return ret;
  143. }
  144. val = bitcnt << TEGRA30_I2S_TIMING_CHANNEL_BIT_COUNT_SHIFT;
  145. if (i2sclock % (2 * srate))
  146. val |= TEGRA30_I2S_TIMING_NON_SYM_ENABLE;
  147. regmap_write(i2s->regmap, TEGRA30_I2S_TIMING, val);
  148. cif_conf.threshold = 0;
  149. cif_conf.audio_channels = 2;
  150. cif_conf.client_channels = 2;
  151. cif_conf.audio_bits = TEGRA30_AUDIOCIF_BITS_16;
  152. cif_conf.client_bits = TEGRA30_AUDIOCIF_BITS_16;
  153. cif_conf.expand = 0;
  154. cif_conf.stereo_conv = 0;
  155. cif_conf.replicate = 0;
  156. cif_conf.truncate = 0;
  157. cif_conf.mono_conv = 0;
  158. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  159. cif_conf.direction = TEGRA30_AUDIOCIF_DIRECTION_RX;
  160. reg = TEGRA30_I2S_CIF_RX_CTRL;
  161. } else {
  162. cif_conf.direction = TEGRA30_AUDIOCIF_DIRECTION_TX;
  163. reg = TEGRA30_I2S_CIF_TX_CTRL;
  164. }
  165. i2s->soc_data->set_audio_cif(i2s->regmap, reg, &cif_conf);
  166. val = (1 << TEGRA30_I2S_OFFSET_RX_DATA_OFFSET_SHIFT) |
  167. (1 << TEGRA30_I2S_OFFSET_TX_DATA_OFFSET_SHIFT);
  168. regmap_write(i2s->regmap, TEGRA30_I2S_OFFSET, val);
  169. return 0;
  170. }
  171. static void tegra30_i2s_start_playback(struct tegra30_i2s *i2s)
  172. {
  173. tegra30_ahub_enable_tx_fifo(i2s->playback_fifo_cif);
  174. regmap_update_bits(i2s->regmap, TEGRA30_I2S_CTRL,
  175. TEGRA30_I2S_CTRL_XFER_EN_TX,
  176. TEGRA30_I2S_CTRL_XFER_EN_TX);
  177. }
  178. static void tegra30_i2s_stop_playback(struct tegra30_i2s *i2s)
  179. {
  180. tegra30_ahub_disable_tx_fifo(i2s->playback_fifo_cif);
  181. regmap_update_bits(i2s->regmap, TEGRA30_I2S_CTRL,
  182. TEGRA30_I2S_CTRL_XFER_EN_TX, 0);
  183. }
  184. static void tegra30_i2s_start_capture(struct tegra30_i2s *i2s)
  185. {
  186. tegra30_ahub_enable_rx_fifo(i2s->capture_fifo_cif);
  187. regmap_update_bits(i2s->regmap, TEGRA30_I2S_CTRL,
  188. TEGRA30_I2S_CTRL_XFER_EN_RX,
  189. TEGRA30_I2S_CTRL_XFER_EN_RX);
  190. }
  191. static void tegra30_i2s_stop_capture(struct tegra30_i2s *i2s)
  192. {
  193. regmap_update_bits(i2s->regmap, TEGRA30_I2S_CTRL,
  194. TEGRA30_I2S_CTRL_XFER_EN_RX, 0);
  195. tegra30_ahub_disable_rx_fifo(i2s->capture_fifo_cif);
  196. }
  197. static int tegra30_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
  198. struct snd_soc_dai *dai)
  199. {
  200. struct tegra30_i2s *i2s = snd_soc_dai_get_drvdata(dai);
  201. switch (cmd) {
  202. case SNDRV_PCM_TRIGGER_START:
  203. case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
  204. case SNDRV_PCM_TRIGGER_RESUME:
  205. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  206. tegra30_i2s_start_playback(i2s);
  207. else
  208. tegra30_i2s_start_capture(i2s);
  209. break;
  210. case SNDRV_PCM_TRIGGER_STOP:
  211. case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
  212. case SNDRV_PCM_TRIGGER_SUSPEND:
  213. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  214. tegra30_i2s_stop_playback(i2s);
  215. else
  216. tegra30_i2s_stop_capture(i2s);
  217. break;
  218. default:
  219. return -EINVAL;
  220. }
  221. return 0;
  222. }
  223. static int tegra30_i2s_set_tdm(struct snd_soc_dai *dai,
  224. unsigned int tx_mask, unsigned int rx_mask,
  225. int slots, int slot_width)
  226. {
  227. struct tegra30_i2s *i2s = snd_soc_dai_get_drvdata(dai);
  228. unsigned int mask, val;
  229. dev_dbg(dai->dev, "%s: txmask=0x%08x rxmask=0x%08x slots=%d width=%d\n",
  230. __func__, tx_mask, rx_mask, slots, slot_width);
  231. mask = TEGRA30_I2S_SLOT_CTRL_TOTAL_SLOTS_MASK |
  232. TEGRA30_I2S_SLOT_CTRL_RX_SLOT_ENABLES_MASK |
  233. TEGRA30_I2S_SLOT_CTRL_TX_SLOT_ENABLES_MASK;
  234. val = (tx_mask << TEGRA30_I2S_SLOT_CTRL_TX_SLOT_ENABLES_SHIFT) |
  235. (rx_mask << TEGRA30_I2S_SLOT_CTRL_RX_SLOT_ENABLES_SHIFT) |
  236. ((slots - 1) << TEGRA30_I2S_SLOT_CTRL_TOTAL_SLOTS_SHIFT);
  237. pm_runtime_get_sync(dai->dev);
  238. regmap_update_bits(i2s->regmap, TEGRA30_I2S_SLOT_CTRL, mask, val);
  239. /* set the fsync width to minimum of 1 clock width */
  240. regmap_update_bits(i2s->regmap, TEGRA30_I2S_CH_CTRL,
  241. TEGRA30_I2S_CH_CTRL_FSYNC_WIDTH_MASK, 0x0);
  242. pm_runtime_put(dai->dev);
  243. return 0;
  244. }
  245. static int tegra30_i2s_probe(struct snd_soc_dai *dai)
  246. {
  247. struct tegra30_i2s *i2s = snd_soc_dai_get_drvdata(dai);
  248. snd_soc_dai_init_dma_data(dai, &i2s->playback_dma_data,
  249. &i2s->capture_dma_data);
  250. return 0;
  251. }
  252. static const struct snd_soc_dai_ops tegra30_i2s_dai_ops = {
  253. .probe = tegra30_i2s_probe,
  254. .set_fmt = tegra30_i2s_set_fmt,
  255. .hw_params = tegra30_i2s_hw_params,
  256. .trigger = tegra30_i2s_trigger,
  257. .set_tdm_slot = tegra30_i2s_set_tdm,
  258. };
  259. static const struct snd_soc_dai_driver tegra30_i2s_dai_template = {
  260. .playback = {
  261. .stream_name = "Playback",
  262. .channels_min = 2,
  263. .channels_max = 2,
  264. .rates = SNDRV_PCM_RATE_8000_96000,
  265. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  266. },
  267. .capture = {
  268. .stream_name = "Capture",
  269. .channels_min = 2,
  270. .channels_max = 2,
  271. .rates = SNDRV_PCM_RATE_8000_96000,
  272. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  273. },
  274. .ops = &tegra30_i2s_dai_ops,
  275. .symmetric_rate = 1,
  276. };
  277. static const struct snd_soc_component_driver tegra30_i2s_component = {
  278. .name = DRV_NAME,
  279. .legacy_dai_naming = 1,
  280. };
  281. static bool tegra30_i2s_wr_rd_reg(struct device *dev, unsigned int reg)
  282. {
  283. switch (reg) {
  284. case TEGRA30_I2S_CTRL:
  285. case TEGRA30_I2S_TIMING:
  286. case TEGRA30_I2S_OFFSET:
  287. case TEGRA30_I2S_CH_CTRL:
  288. case TEGRA30_I2S_SLOT_CTRL:
  289. case TEGRA30_I2S_CIF_RX_CTRL:
  290. case TEGRA30_I2S_CIF_TX_CTRL:
  291. case TEGRA30_I2S_FLOWCTL:
  292. case TEGRA30_I2S_TX_STEP:
  293. case TEGRA30_I2S_FLOW_STATUS:
  294. case TEGRA30_I2S_FLOW_TOTAL:
  295. case TEGRA30_I2S_FLOW_OVER:
  296. case TEGRA30_I2S_FLOW_UNDER:
  297. case TEGRA30_I2S_LCOEF_1_4_0:
  298. case TEGRA30_I2S_LCOEF_1_4_1:
  299. case TEGRA30_I2S_LCOEF_1_4_2:
  300. case TEGRA30_I2S_LCOEF_1_4_3:
  301. case TEGRA30_I2S_LCOEF_1_4_4:
  302. case TEGRA30_I2S_LCOEF_1_4_5:
  303. case TEGRA30_I2S_LCOEF_2_4_0:
  304. case TEGRA30_I2S_LCOEF_2_4_1:
  305. case TEGRA30_I2S_LCOEF_2_4_2:
  306. return true;
  307. default:
  308. return false;
  309. }
  310. }
  311. static bool tegra30_i2s_volatile_reg(struct device *dev, unsigned int reg)
  312. {
  313. switch (reg) {
  314. case TEGRA30_I2S_FLOW_STATUS:
  315. case TEGRA30_I2S_FLOW_TOTAL:
  316. case TEGRA30_I2S_FLOW_OVER:
  317. case TEGRA30_I2S_FLOW_UNDER:
  318. return true;
  319. default:
  320. return false;
  321. }
  322. }
  323. static const struct regmap_config tegra30_i2s_regmap_config = {
  324. .reg_bits = 32,
  325. .reg_stride = 4,
  326. .val_bits = 32,
  327. .max_register = TEGRA30_I2S_LCOEF_2_4_2,
  328. .writeable_reg = tegra30_i2s_wr_rd_reg,
  329. .readable_reg = tegra30_i2s_wr_rd_reg,
  330. .volatile_reg = tegra30_i2s_volatile_reg,
  331. .cache_type = REGCACHE_FLAT,
  332. };
  333. static const struct tegra30_i2s_soc_data tegra30_i2s_config = {
  334. .set_audio_cif = tegra30_ahub_set_cif,
  335. };
  336. static const struct tegra30_i2s_soc_data tegra124_i2s_config = {
  337. .set_audio_cif = tegra124_ahub_set_cif,
  338. };
  339. static const struct of_device_id tegra30_i2s_of_match[] = {
  340. { .compatible = "nvidia,tegra124-i2s", .data = &tegra124_i2s_config },
  341. { .compatible = "nvidia,tegra30-i2s", .data = &tegra30_i2s_config },
  342. {},
  343. };
  344. static int tegra30_i2s_platform_probe(struct platform_device *pdev)
  345. {
  346. struct tegra30_i2s *i2s;
  347. const struct tegra30_i2s_soc_data *soc_data;
  348. u32 cif_ids[2];
  349. void __iomem *regs;
  350. int ret;
  351. i2s = devm_kzalloc(&pdev->dev, sizeof(struct tegra30_i2s), GFP_KERNEL);
  352. if (!i2s) {
  353. ret = -ENOMEM;
  354. goto err;
  355. }
  356. dev_set_drvdata(&pdev->dev, i2s);
  357. soc_data = of_device_get_match_data(&pdev->dev);
  358. if (!soc_data) {
  359. dev_err(&pdev->dev, "Error: No device match found\n");
  360. ret = -ENODEV;
  361. goto err;
  362. }
  363. i2s->soc_data = soc_data;
  364. i2s->dai = tegra30_i2s_dai_template;
  365. i2s->dai.name = dev_name(&pdev->dev);
  366. ret = of_property_read_u32_array(pdev->dev.of_node,
  367. "nvidia,ahub-cif-ids", cif_ids,
  368. ARRAY_SIZE(cif_ids));
  369. if (ret < 0)
  370. goto err;
  371. i2s->playback_i2s_cif = cif_ids[0];
  372. i2s->capture_i2s_cif = cif_ids[1];
  373. i2s->clk_i2s = devm_clk_get(&pdev->dev, NULL);
  374. if (IS_ERR(i2s->clk_i2s)) {
  375. dev_err(&pdev->dev, "Can't retrieve i2s clock\n");
  376. ret = PTR_ERR(i2s->clk_i2s);
  377. goto err;
  378. }
  379. regs = devm_platform_ioremap_resource(pdev, 0);
  380. if (IS_ERR(regs)) {
  381. ret = PTR_ERR(regs);
  382. goto err;
  383. }
  384. i2s->regmap = devm_regmap_init_mmio(&pdev->dev, regs,
  385. &tegra30_i2s_regmap_config);
  386. if (IS_ERR(i2s->regmap)) {
  387. dev_err(&pdev->dev, "regmap init failed\n");
  388. ret = PTR_ERR(i2s->regmap);
  389. goto err;
  390. }
  391. regcache_cache_only(i2s->regmap, true);
  392. pm_runtime_enable(&pdev->dev);
  393. i2s->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
  394. i2s->playback_dma_data.maxburst = 4;
  395. ret = tegra30_ahub_allocate_tx_fifo(&i2s->playback_fifo_cif,
  396. i2s->playback_dma_chan,
  397. sizeof(i2s->playback_dma_chan),
  398. &i2s->playback_dma_data.addr);
  399. if (ret) {
  400. dev_err(&pdev->dev, "Could not alloc TX FIFO: %d\n", ret);
  401. goto err_pm_disable;
  402. }
  403. ret = tegra30_ahub_set_rx_cif_source(i2s->playback_i2s_cif,
  404. i2s->playback_fifo_cif);
  405. if (ret) {
  406. dev_err(&pdev->dev, "Could not route TX FIFO: %d\n", ret);
  407. goto err_free_tx_fifo;
  408. }
  409. i2s->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
  410. i2s->capture_dma_data.maxburst = 4;
  411. ret = tegra30_ahub_allocate_rx_fifo(&i2s->capture_fifo_cif,
  412. i2s->capture_dma_chan,
  413. sizeof(i2s->capture_dma_chan),
  414. &i2s->capture_dma_data.addr);
  415. if (ret) {
  416. dev_err(&pdev->dev, "Could not alloc RX FIFO: %d\n", ret);
  417. goto err_unroute_tx_fifo;
  418. }
  419. ret = tegra30_ahub_set_rx_cif_source(i2s->capture_fifo_cif,
  420. i2s->capture_i2s_cif);
  421. if (ret) {
  422. dev_err(&pdev->dev, "Could not route TX FIFO: %d\n", ret);
  423. goto err_free_rx_fifo;
  424. }
  425. ret = snd_soc_register_component(&pdev->dev, &tegra30_i2s_component,
  426. &i2s->dai, 1);
  427. if (ret) {
  428. dev_err(&pdev->dev, "Could not register DAI: %d\n", ret);
  429. ret = -ENOMEM;
  430. goto err_unroute_rx_fifo;
  431. }
  432. ret = tegra_pcm_platform_register_with_chan_names(&pdev->dev,
  433. &i2s->dma_config, i2s->playback_dma_chan,
  434. i2s->capture_dma_chan);
  435. if (ret) {
  436. dev_err(&pdev->dev, "Could not register PCM: %d\n", ret);
  437. goto err_unregister_component;
  438. }
  439. return 0;
  440. err_unregister_component:
  441. snd_soc_unregister_component(&pdev->dev);
  442. err_unroute_rx_fifo:
  443. tegra30_ahub_unset_rx_cif_source(i2s->capture_fifo_cif);
  444. err_free_rx_fifo:
  445. tegra30_ahub_free_rx_fifo(i2s->capture_fifo_cif);
  446. err_unroute_tx_fifo:
  447. tegra30_ahub_unset_rx_cif_source(i2s->playback_i2s_cif);
  448. err_free_tx_fifo:
  449. tegra30_ahub_free_tx_fifo(i2s->playback_fifo_cif);
  450. err_pm_disable:
  451. pm_runtime_disable(&pdev->dev);
  452. err:
  453. return ret;
  454. }
  455. static void tegra30_i2s_platform_remove(struct platform_device *pdev)
  456. {
  457. struct tegra30_i2s *i2s = dev_get_drvdata(&pdev->dev);
  458. tegra_pcm_platform_unregister(&pdev->dev);
  459. snd_soc_unregister_component(&pdev->dev);
  460. tegra30_ahub_unset_rx_cif_source(i2s->capture_fifo_cif);
  461. tegra30_ahub_free_rx_fifo(i2s->capture_fifo_cif);
  462. tegra30_ahub_unset_rx_cif_source(i2s->playback_i2s_cif);
  463. tegra30_ahub_free_tx_fifo(i2s->playback_fifo_cif);
  464. pm_runtime_disable(&pdev->dev);
  465. }
  466. static const struct dev_pm_ops tegra30_i2s_pm_ops = {
  467. SET_RUNTIME_PM_OPS(tegra30_i2s_runtime_suspend,
  468. tegra30_i2s_runtime_resume, NULL)
  469. SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
  470. pm_runtime_force_resume)
  471. };
  472. static struct platform_driver tegra30_i2s_driver = {
  473. .driver = {
  474. .name = DRV_NAME,
  475. .of_match_table = tegra30_i2s_of_match,
  476. .pm = &tegra30_i2s_pm_ops,
  477. },
  478. .probe = tegra30_i2s_platform_probe,
  479. .remove = tegra30_i2s_platform_remove,
  480. };
  481. module_platform_driver(tegra30_i2s_driver);
  482. MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>");
  483. MODULE_DESCRIPTION("Tegra30 I2S ASoC driver");
  484. MODULE_LICENSE("GPL");
  485. MODULE_ALIAS("platform:" DRV_NAME);
  486. MODULE_DEVICE_TABLE(of, tegra30_i2s_of_match);