jz4740-i2s.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. /*
  2. * Copyright (C) 2010, Lars-Peter Clausen <lars@metafoo.de>
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License as published by the
  6. * Free Software Foundation; either version 2 of the License, or (at your
  7. * option) any later version.
  8. *
  9. * You should have received a copy of the GNU General Public License along
  10. * with this program; if not, write to the Free Software Foundation, Inc.,
  11. * 675 Mass Ave, Cambridge, MA 02139, USA.
  12. *
  13. */
  14. #include <linux/init.h>
  15. #include <linux/io.h>
  16. #include <linux/of.h>
  17. #include <linux/of_device.h>
  18. #include <linux/kernel.h>
  19. #include <linux/module.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/slab.h>
  22. #include <linux/clk.h>
  23. #include <linux/delay.h>
  24. #include <linux/dma-mapping.h>
  25. #include <sound/core.h>
  26. #include <sound/pcm.h>
  27. #include <sound/pcm_params.h>
  28. #include <sound/soc.h>
  29. #include <sound/initval.h>
  30. #include <sound/dmaengine_pcm.h>
  31. #include "jz4740-i2s.h"
  32. #define JZ4740_DMA_TYPE_AIC_TRANSMIT 24
  33. #define JZ4740_DMA_TYPE_AIC_RECEIVE 25
  34. #define JZ_REG_AIC_CONF 0x00
  35. #define JZ_REG_AIC_CTRL 0x04
  36. #define JZ_REG_AIC_I2S_FMT 0x10
  37. #define JZ_REG_AIC_FIFO_STATUS 0x14
  38. #define JZ_REG_AIC_I2S_STATUS 0x1c
  39. #define JZ_REG_AIC_CLK_DIV 0x30
  40. #define JZ_REG_AIC_FIFO 0x34
  41. #define JZ_AIC_CONF_FIFO_RX_THRESHOLD_MASK (0xf << 12)
  42. #define JZ_AIC_CONF_FIFO_TX_THRESHOLD_MASK (0xf << 8)
  43. #define JZ_AIC_CONF_OVERFLOW_PLAY_LAST BIT(6)
  44. #define JZ_AIC_CONF_INTERNAL_CODEC BIT(5)
  45. #define JZ_AIC_CONF_I2S BIT(4)
  46. #define JZ_AIC_CONF_RESET BIT(3)
  47. #define JZ_AIC_CONF_BIT_CLK_MASTER BIT(2)
  48. #define JZ_AIC_CONF_SYNC_CLK_MASTER BIT(1)
  49. #define JZ_AIC_CONF_ENABLE BIT(0)
  50. #define JZ_AIC_CONF_FIFO_RX_THRESHOLD_OFFSET 12
  51. #define JZ_AIC_CONF_FIFO_TX_THRESHOLD_OFFSET 8
  52. #define JZ4780_AIC_CONF_FIFO_RX_THRESHOLD_OFFSET 24
  53. #define JZ4780_AIC_CONF_FIFO_TX_THRESHOLD_OFFSET 16
  54. #define JZ4780_AIC_CONF_FIFO_RX_THRESHOLD_MASK \
  55. (0xf << JZ4780_AIC_CONF_FIFO_RX_THRESHOLD_OFFSET)
  56. #define JZ4780_AIC_CONF_FIFO_TX_THRESHOLD_MASK \
  57. (0x1f << JZ4780_AIC_CONF_FIFO_TX_THRESHOLD_OFFSET)
  58. #define JZ_AIC_CTRL_OUTPUT_SAMPLE_SIZE_MASK (0x7 << 19)
  59. #define JZ_AIC_CTRL_INPUT_SAMPLE_SIZE_MASK (0x7 << 16)
  60. #define JZ_AIC_CTRL_ENABLE_RX_DMA BIT(15)
  61. #define JZ_AIC_CTRL_ENABLE_TX_DMA BIT(14)
  62. #define JZ_AIC_CTRL_MONO_TO_STEREO BIT(11)
  63. #define JZ_AIC_CTRL_SWITCH_ENDIANNESS BIT(10)
  64. #define JZ_AIC_CTRL_SIGNED_TO_UNSIGNED BIT(9)
  65. #define JZ_AIC_CTRL_FLUSH BIT(8)
  66. #define JZ_AIC_CTRL_ENABLE_ROR_INT BIT(6)
  67. #define JZ_AIC_CTRL_ENABLE_TUR_INT BIT(5)
  68. #define JZ_AIC_CTRL_ENABLE_RFS_INT BIT(4)
  69. #define JZ_AIC_CTRL_ENABLE_TFS_INT BIT(3)
  70. #define JZ_AIC_CTRL_ENABLE_LOOPBACK BIT(2)
  71. #define JZ_AIC_CTRL_ENABLE_PLAYBACK BIT(1)
  72. #define JZ_AIC_CTRL_ENABLE_CAPTURE BIT(0)
  73. #define JZ_AIC_CTRL_OUTPUT_SAMPLE_SIZE_OFFSET 19
  74. #define JZ_AIC_CTRL_INPUT_SAMPLE_SIZE_OFFSET 16
  75. #define JZ_AIC_I2S_FMT_DISABLE_BIT_CLK BIT(12)
  76. #define JZ_AIC_I2S_FMT_DISABLE_BIT_ICLK BIT(13)
  77. #define JZ_AIC_I2S_FMT_ENABLE_SYS_CLK BIT(4)
  78. #define JZ_AIC_I2S_FMT_MSB BIT(0)
  79. #define JZ_AIC_I2S_STATUS_BUSY BIT(2)
  80. #define JZ_AIC_CLK_DIV_MASK 0xf
  81. #define I2SDIV_DV_SHIFT 8
  82. #define I2SDIV_DV_MASK (0xf << I2SDIV_DV_SHIFT)
  83. #define I2SDIV_IDV_SHIFT 8
  84. #define I2SDIV_IDV_MASK (0xf << I2SDIV_IDV_SHIFT)
  85. enum jz47xx_i2s_version {
  86. JZ_I2S_JZ4740,
  87. JZ_I2S_JZ4780,
  88. };
  89. struct jz4740_i2s {
  90. struct resource *mem;
  91. void __iomem *base;
  92. dma_addr_t phys_base;
  93. struct clk *clk_aic;
  94. struct clk *clk_i2s;
  95. struct snd_dmaengine_dai_dma_data playback_dma_data;
  96. struct snd_dmaengine_dai_dma_data capture_dma_data;
  97. enum jz47xx_i2s_version version;
  98. };
  99. static inline uint32_t jz4740_i2s_read(const struct jz4740_i2s *i2s,
  100. unsigned int reg)
  101. {
  102. return readl(i2s->base + reg);
  103. }
  104. static inline void jz4740_i2s_write(const struct jz4740_i2s *i2s,
  105. unsigned int reg, uint32_t value)
  106. {
  107. writel(value, i2s->base + reg);
  108. }
  109. static int jz4740_i2s_startup(struct snd_pcm_substream *substream,
  110. struct snd_soc_dai *dai)
  111. {
  112. struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai);
  113. uint32_t conf, ctrl;
  114. if (dai->active)
  115. return 0;
  116. ctrl = jz4740_i2s_read(i2s, JZ_REG_AIC_CTRL);
  117. ctrl |= JZ_AIC_CTRL_FLUSH;
  118. jz4740_i2s_write(i2s, JZ_REG_AIC_CTRL, ctrl);
  119. clk_prepare_enable(i2s->clk_i2s);
  120. conf = jz4740_i2s_read(i2s, JZ_REG_AIC_CONF);
  121. conf |= JZ_AIC_CONF_ENABLE;
  122. jz4740_i2s_write(i2s, JZ_REG_AIC_CONF, conf);
  123. return 0;
  124. }
  125. static void jz4740_i2s_shutdown(struct snd_pcm_substream *substream,
  126. struct snd_soc_dai *dai)
  127. {
  128. struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai);
  129. uint32_t conf;
  130. if (dai->active)
  131. return;
  132. conf = jz4740_i2s_read(i2s, JZ_REG_AIC_CONF);
  133. conf &= ~JZ_AIC_CONF_ENABLE;
  134. jz4740_i2s_write(i2s, JZ_REG_AIC_CONF, conf);
  135. clk_disable_unprepare(i2s->clk_i2s);
  136. }
  137. static int jz4740_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
  138. struct snd_soc_dai *dai)
  139. {
  140. struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai);
  141. uint32_t ctrl;
  142. uint32_t mask;
  143. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  144. mask = JZ_AIC_CTRL_ENABLE_PLAYBACK | JZ_AIC_CTRL_ENABLE_TX_DMA;
  145. else
  146. mask = JZ_AIC_CTRL_ENABLE_CAPTURE | JZ_AIC_CTRL_ENABLE_RX_DMA;
  147. ctrl = jz4740_i2s_read(i2s, JZ_REG_AIC_CTRL);
  148. switch (cmd) {
  149. case SNDRV_PCM_TRIGGER_START:
  150. case SNDRV_PCM_TRIGGER_RESUME:
  151. case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
  152. ctrl |= mask;
  153. break;
  154. case SNDRV_PCM_TRIGGER_STOP:
  155. case SNDRV_PCM_TRIGGER_SUSPEND:
  156. case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
  157. ctrl &= ~mask;
  158. break;
  159. default:
  160. return -EINVAL;
  161. }
  162. jz4740_i2s_write(i2s, JZ_REG_AIC_CTRL, ctrl);
  163. return 0;
  164. }
  165. static int jz4740_i2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
  166. {
  167. struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai);
  168. uint32_t format = 0;
  169. uint32_t conf;
  170. conf = jz4740_i2s_read(i2s, JZ_REG_AIC_CONF);
  171. conf &= ~(JZ_AIC_CONF_BIT_CLK_MASTER | JZ_AIC_CONF_SYNC_CLK_MASTER);
  172. switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
  173. case SND_SOC_DAIFMT_CBS_CFS:
  174. conf |= JZ_AIC_CONF_BIT_CLK_MASTER | JZ_AIC_CONF_SYNC_CLK_MASTER;
  175. format |= JZ_AIC_I2S_FMT_ENABLE_SYS_CLK;
  176. break;
  177. case SND_SOC_DAIFMT_CBM_CFS:
  178. conf |= JZ_AIC_CONF_SYNC_CLK_MASTER;
  179. break;
  180. case SND_SOC_DAIFMT_CBS_CFM:
  181. conf |= JZ_AIC_CONF_BIT_CLK_MASTER;
  182. break;
  183. case SND_SOC_DAIFMT_CBM_CFM:
  184. break;
  185. default:
  186. return -EINVAL;
  187. }
  188. switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
  189. case SND_SOC_DAIFMT_MSB:
  190. format |= JZ_AIC_I2S_FMT_MSB;
  191. break;
  192. case SND_SOC_DAIFMT_I2S:
  193. break;
  194. default:
  195. return -EINVAL;
  196. }
  197. switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
  198. case SND_SOC_DAIFMT_NB_NF:
  199. break;
  200. default:
  201. return -EINVAL;
  202. }
  203. jz4740_i2s_write(i2s, JZ_REG_AIC_CONF, conf);
  204. jz4740_i2s_write(i2s, JZ_REG_AIC_I2S_FMT, format);
  205. return 0;
  206. }
  207. static int jz4740_i2s_hw_params(struct snd_pcm_substream *substream,
  208. struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
  209. {
  210. struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai);
  211. unsigned int sample_size;
  212. uint32_t ctrl, div_reg;
  213. int div;
  214. ctrl = jz4740_i2s_read(i2s, JZ_REG_AIC_CTRL);
  215. div_reg = jz4740_i2s_read(i2s, JZ_REG_AIC_CLK_DIV);
  216. div = clk_get_rate(i2s->clk_i2s) / (64 * params_rate(params));
  217. switch (params_format(params)) {
  218. case SNDRV_PCM_FORMAT_S8:
  219. sample_size = 0;
  220. break;
  221. case SNDRV_PCM_FORMAT_S16:
  222. sample_size = 1;
  223. break;
  224. default:
  225. return -EINVAL;
  226. }
  227. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  228. ctrl &= ~JZ_AIC_CTRL_OUTPUT_SAMPLE_SIZE_MASK;
  229. ctrl |= sample_size << JZ_AIC_CTRL_OUTPUT_SAMPLE_SIZE_OFFSET;
  230. if (params_channels(params) == 1)
  231. ctrl |= JZ_AIC_CTRL_MONO_TO_STEREO;
  232. else
  233. ctrl &= ~JZ_AIC_CTRL_MONO_TO_STEREO;
  234. div_reg &= ~I2SDIV_DV_MASK;
  235. div_reg |= (div - 1) << I2SDIV_DV_SHIFT;
  236. } else {
  237. ctrl &= ~JZ_AIC_CTRL_INPUT_SAMPLE_SIZE_MASK;
  238. ctrl |= sample_size << JZ_AIC_CTRL_INPUT_SAMPLE_SIZE_OFFSET;
  239. if (i2s->version >= JZ_I2S_JZ4780) {
  240. div_reg &= ~I2SDIV_IDV_MASK;
  241. div_reg |= (div - 1) << I2SDIV_IDV_SHIFT;
  242. } else {
  243. div_reg &= ~I2SDIV_DV_MASK;
  244. div_reg |= (div - 1) << I2SDIV_DV_SHIFT;
  245. }
  246. }
  247. jz4740_i2s_write(i2s, JZ_REG_AIC_CTRL, ctrl);
  248. jz4740_i2s_write(i2s, JZ_REG_AIC_CLK_DIV, div_reg);
  249. return 0;
  250. }
  251. static int jz4740_i2s_set_sysclk(struct snd_soc_dai *dai, int clk_id,
  252. unsigned int freq, int dir)
  253. {
  254. struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai);
  255. struct clk *parent;
  256. int ret = 0;
  257. switch (clk_id) {
  258. case JZ4740_I2S_CLKSRC_EXT:
  259. parent = clk_get(NULL, "ext");
  260. clk_set_parent(i2s->clk_i2s, parent);
  261. break;
  262. case JZ4740_I2S_CLKSRC_PLL:
  263. parent = clk_get(NULL, "pll half");
  264. clk_set_parent(i2s->clk_i2s, parent);
  265. ret = clk_set_rate(i2s->clk_i2s, freq);
  266. break;
  267. default:
  268. return -EINVAL;
  269. }
  270. clk_put(parent);
  271. return ret;
  272. }
  273. static int jz4740_i2s_suspend(struct snd_soc_dai *dai)
  274. {
  275. struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai);
  276. uint32_t conf;
  277. if (dai->active) {
  278. conf = jz4740_i2s_read(i2s, JZ_REG_AIC_CONF);
  279. conf &= ~JZ_AIC_CONF_ENABLE;
  280. jz4740_i2s_write(i2s, JZ_REG_AIC_CONF, conf);
  281. clk_disable_unprepare(i2s->clk_i2s);
  282. }
  283. clk_disable_unprepare(i2s->clk_aic);
  284. return 0;
  285. }
  286. static int jz4740_i2s_resume(struct snd_soc_dai *dai)
  287. {
  288. struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai);
  289. uint32_t conf;
  290. clk_prepare_enable(i2s->clk_aic);
  291. if (dai->active) {
  292. clk_prepare_enable(i2s->clk_i2s);
  293. conf = jz4740_i2s_read(i2s, JZ_REG_AIC_CONF);
  294. conf |= JZ_AIC_CONF_ENABLE;
  295. jz4740_i2s_write(i2s, JZ_REG_AIC_CONF, conf);
  296. }
  297. return 0;
  298. }
  299. static void jz4740_i2c_init_pcm_config(struct jz4740_i2s *i2s)
  300. {
  301. struct snd_dmaengine_dai_dma_data *dma_data;
  302. /* Playback */
  303. dma_data = &i2s->playback_dma_data;
  304. dma_data->maxburst = 16;
  305. dma_data->slave_id = JZ4740_DMA_TYPE_AIC_TRANSMIT;
  306. dma_data->addr = i2s->phys_base + JZ_REG_AIC_FIFO;
  307. /* Capture */
  308. dma_data = &i2s->capture_dma_data;
  309. dma_data->maxburst = 16;
  310. dma_data->slave_id = JZ4740_DMA_TYPE_AIC_RECEIVE;
  311. dma_data->addr = i2s->phys_base + JZ_REG_AIC_FIFO;
  312. }
  313. static int jz4740_i2s_dai_probe(struct snd_soc_dai *dai)
  314. {
  315. struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai);
  316. uint32_t conf;
  317. clk_prepare_enable(i2s->clk_aic);
  318. jz4740_i2c_init_pcm_config(i2s);
  319. snd_soc_dai_init_dma_data(dai, &i2s->playback_dma_data,
  320. &i2s->capture_dma_data);
  321. if (i2s->version >= JZ_I2S_JZ4780) {
  322. conf = (7 << JZ4780_AIC_CONF_FIFO_RX_THRESHOLD_OFFSET) |
  323. (8 << JZ4780_AIC_CONF_FIFO_TX_THRESHOLD_OFFSET) |
  324. JZ_AIC_CONF_OVERFLOW_PLAY_LAST |
  325. JZ_AIC_CONF_I2S |
  326. JZ_AIC_CONF_INTERNAL_CODEC;
  327. } else {
  328. conf = (7 << JZ_AIC_CONF_FIFO_RX_THRESHOLD_OFFSET) |
  329. (8 << JZ_AIC_CONF_FIFO_TX_THRESHOLD_OFFSET) |
  330. JZ_AIC_CONF_OVERFLOW_PLAY_LAST |
  331. JZ_AIC_CONF_I2S |
  332. JZ_AIC_CONF_INTERNAL_CODEC;
  333. }
  334. jz4740_i2s_write(i2s, JZ_REG_AIC_CONF, JZ_AIC_CONF_RESET);
  335. jz4740_i2s_write(i2s, JZ_REG_AIC_CONF, conf);
  336. return 0;
  337. }
  338. static int jz4740_i2s_dai_remove(struct snd_soc_dai *dai)
  339. {
  340. struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai);
  341. clk_disable_unprepare(i2s->clk_aic);
  342. return 0;
  343. }
  344. static const struct snd_soc_dai_ops jz4740_i2s_dai_ops = {
  345. .startup = jz4740_i2s_startup,
  346. .shutdown = jz4740_i2s_shutdown,
  347. .trigger = jz4740_i2s_trigger,
  348. .hw_params = jz4740_i2s_hw_params,
  349. .set_fmt = jz4740_i2s_set_fmt,
  350. .set_sysclk = jz4740_i2s_set_sysclk,
  351. };
  352. #define JZ4740_I2S_FMTS (SNDRV_PCM_FMTBIT_S8 | \
  353. SNDRV_PCM_FMTBIT_S16_LE)
  354. static struct snd_soc_dai_driver jz4740_i2s_dai = {
  355. .probe = jz4740_i2s_dai_probe,
  356. .remove = jz4740_i2s_dai_remove,
  357. .playback = {
  358. .channels_min = 1,
  359. .channels_max = 2,
  360. .rates = SNDRV_PCM_RATE_8000_48000,
  361. .formats = JZ4740_I2S_FMTS,
  362. },
  363. .capture = {
  364. .channels_min = 2,
  365. .channels_max = 2,
  366. .rates = SNDRV_PCM_RATE_8000_48000,
  367. .formats = JZ4740_I2S_FMTS,
  368. },
  369. .symmetric_rates = 1,
  370. .ops = &jz4740_i2s_dai_ops,
  371. .suspend = jz4740_i2s_suspend,
  372. .resume = jz4740_i2s_resume,
  373. };
  374. static struct snd_soc_dai_driver jz4780_i2s_dai = {
  375. .probe = jz4740_i2s_dai_probe,
  376. .remove = jz4740_i2s_dai_remove,
  377. .playback = {
  378. .channels_min = 1,
  379. .channels_max = 2,
  380. .rates = SNDRV_PCM_RATE_8000_48000,
  381. .formats = JZ4740_I2S_FMTS,
  382. },
  383. .capture = {
  384. .channels_min = 2,
  385. .channels_max = 2,
  386. .rates = SNDRV_PCM_RATE_8000_48000,
  387. .formats = JZ4740_I2S_FMTS,
  388. },
  389. .ops = &jz4740_i2s_dai_ops,
  390. .suspend = jz4740_i2s_suspend,
  391. .resume = jz4740_i2s_resume,
  392. };
  393. static const struct snd_soc_component_driver jz4740_i2s_component = {
  394. .name = "jz4740-i2s",
  395. };
  396. #ifdef CONFIG_OF
  397. static const struct of_device_id jz4740_of_matches[] = {
  398. { .compatible = "ingenic,jz4740-i2s", .data = (void *)JZ_I2S_JZ4740 },
  399. { .compatible = "ingenic,jz4780-i2s", .data = (void *)JZ_I2S_JZ4780 },
  400. { /* sentinel */ }
  401. };
  402. MODULE_DEVICE_TABLE(of, jz4740_of_matches);
  403. #endif
  404. static int jz4740_i2s_dev_probe(struct platform_device *pdev)
  405. {
  406. struct jz4740_i2s *i2s;
  407. struct resource *mem;
  408. int ret;
  409. const struct of_device_id *match;
  410. i2s = devm_kzalloc(&pdev->dev, sizeof(*i2s), GFP_KERNEL);
  411. if (!i2s)
  412. return -ENOMEM;
  413. match = of_match_device(jz4740_of_matches, &pdev->dev);
  414. if (match)
  415. i2s->version = (enum jz47xx_i2s_version)match->data;
  416. mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  417. i2s->base = devm_ioremap_resource(&pdev->dev, mem);
  418. if (IS_ERR(i2s->base))
  419. return PTR_ERR(i2s->base);
  420. i2s->phys_base = mem->start;
  421. i2s->clk_aic = devm_clk_get(&pdev->dev, "aic");
  422. if (IS_ERR(i2s->clk_aic))
  423. return PTR_ERR(i2s->clk_aic);
  424. i2s->clk_i2s = devm_clk_get(&pdev->dev, "i2s");
  425. if (IS_ERR(i2s->clk_i2s))
  426. return PTR_ERR(i2s->clk_i2s);
  427. platform_set_drvdata(pdev, i2s);
  428. if (i2s->version == JZ_I2S_JZ4780)
  429. ret = devm_snd_soc_register_component(&pdev->dev,
  430. &jz4740_i2s_component, &jz4780_i2s_dai, 1);
  431. else
  432. ret = devm_snd_soc_register_component(&pdev->dev,
  433. &jz4740_i2s_component, &jz4740_i2s_dai, 1);
  434. if (ret)
  435. return ret;
  436. return devm_snd_dmaengine_pcm_register(&pdev->dev, NULL,
  437. SND_DMAENGINE_PCM_FLAG_COMPAT);
  438. }
  439. static struct platform_driver jz4740_i2s_driver = {
  440. .probe = jz4740_i2s_dev_probe,
  441. .driver = {
  442. .name = "jz4740-i2s",
  443. .of_match_table = of_match_ptr(jz4740_of_matches)
  444. },
  445. };
  446. module_platform_driver(jz4740_i2s_driver);
  447. MODULE_AUTHOR("Lars-Peter Clausen, <lars@metafoo.de>");
  448. MODULE_DESCRIPTION("Ingenic JZ4740 SoC I2S driver");
  449. MODULE_LICENSE("GPL");
  450. MODULE_ALIAS("platform:jz4740-i2s");