tegra30_i2s.c 15 KB

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