fsl_ssi.c 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169
  1. /*
  2. * Freescale SSI ALSA SoC Digital Audio Interface (DAI) driver
  3. *
  4. * Author: Timur Tabi <timur@freescale.com>
  5. *
  6. * Copyright 2007-2010 Freescale Semiconductor, Inc.
  7. *
  8. * This file is licensed under the terms of the GNU General Public License
  9. * version 2. This program is licensed "as is" without any warranty of any
  10. * kind, whether express or implied.
  11. *
  12. *
  13. * Some notes why imx-pcm-fiq is used instead of DMA on some boards:
  14. *
  15. * The i.MX SSI core has some nasty limitations in AC97 mode. While most
  16. * sane processor vendors have a FIFO per AC97 slot, the i.MX has only
  17. * one FIFO which combines all valid receive slots. We cannot even select
  18. * which slots we want to receive. The WM9712 with which this driver
  19. * was developed with always sends GPIO status data in slot 12 which
  20. * we receive in our (PCM-) data stream. The only chance we have is to
  21. * manually skip this data in the FIQ handler. With sampling rates different
  22. * from 48000Hz not every frame has valid receive data, so the ratio
  23. * between pcm data and GPIO status data changes. Our FIQ handler is not
  24. * able to handle this, hence this driver only works with 48000Hz sampling
  25. * rate.
  26. * Reading and writing AC97 registers is another challenge. The core
  27. * provides us status bits when the read register is updated with *another*
  28. * value. When we read the same register two times (and the register still
  29. * contains the same value) these status bits are not set. We work
  30. * around this by not polling these bits but only wait a fixed delay.
  31. */
  32. #include <linux/init.h>
  33. #include <linux/io.h>
  34. #include <linux/module.h>
  35. #include <linux/interrupt.h>
  36. #include <linux/clk.h>
  37. #include <linux/device.h>
  38. #include <linux/delay.h>
  39. #include <linux/slab.h>
  40. #include <linux/of_address.h>
  41. #include <linux/of_irq.h>
  42. #include <linux/of_platform.h>
  43. #include <sound/core.h>
  44. #include <sound/pcm.h>
  45. #include <sound/pcm_params.h>
  46. #include <sound/initval.h>
  47. #include <sound/soc.h>
  48. #include <sound/dmaengine_pcm.h>
  49. #include "fsl_ssi.h"
  50. #include "imx-pcm.h"
  51. #ifdef PPC
  52. #define read_ssi(addr) in_be32(addr)
  53. #define write_ssi(val, addr) out_be32(addr, val)
  54. #define write_ssi_mask(addr, clear, set) clrsetbits_be32(addr, clear, set)
  55. #else
  56. #define read_ssi(addr) readl(addr)
  57. #define write_ssi(val, addr) writel(val, addr)
  58. /*
  59. * FIXME: Proper locking should be added at write_ssi_mask caller level
  60. * to ensure this register read/modify/write sequence is race free.
  61. */
  62. static inline void write_ssi_mask(u32 __iomem *addr, u32 clear, u32 set)
  63. {
  64. u32 val = readl(addr);
  65. val = (val & ~clear) | set;
  66. writel(val, addr);
  67. }
  68. #endif
  69. /**
  70. * FSLSSI_I2S_RATES: sample rates supported by the I2S
  71. *
  72. * This driver currently only supports the SSI running in I2S slave mode,
  73. * which means the codec determines the sample rate. Therefore, we tell
  74. * ALSA that we support all rates and let the codec driver decide what rates
  75. * are really supported.
  76. */
  77. #define FSLSSI_I2S_RATES (SNDRV_PCM_RATE_5512 | SNDRV_PCM_RATE_8000_192000 | \
  78. SNDRV_PCM_RATE_CONTINUOUS)
  79. /**
  80. * FSLSSI_I2S_FORMATS: audio formats supported by the SSI
  81. *
  82. * This driver currently only supports the SSI running in I2S slave mode.
  83. *
  84. * The SSI has a limitation in that the samples must be in the same byte
  85. * order as the host CPU. This is because when multiple bytes are written
  86. * to the STX register, the bytes and bits must be written in the same
  87. * order. The STX is a shift register, so all the bits need to be aligned
  88. * (bit-endianness must match byte-endianness). Processors typically write
  89. * the bits within a byte in the same order that the bytes of a word are
  90. * written in. So if the host CPU is big-endian, then only big-endian
  91. * samples will be written to STX properly.
  92. */
  93. #ifdef __BIG_ENDIAN
  94. #define FSLSSI_I2S_FORMATS (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_BE | \
  95. SNDRV_PCM_FMTBIT_S18_3BE | SNDRV_PCM_FMTBIT_S20_3BE | \
  96. SNDRV_PCM_FMTBIT_S24_3BE | SNDRV_PCM_FMTBIT_S24_BE)
  97. #else
  98. #define FSLSSI_I2S_FORMATS (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_LE | \
  99. SNDRV_PCM_FMTBIT_S18_3LE | SNDRV_PCM_FMTBIT_S20_3LE | \
  100. SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S24_LE)
  101. #endif
  102. /* SIER bitflag of interrupts to enable */
  103. #define SIER_FLAGS (CCSR_SSI_SIER_TFRC_EN | CCSR_SSI_SIER_TDMAE | \
  104. CCSR_SSI_SIER_TIE | CCSR_SSI_SIER_TUE0_EN | \
  105. CCSR_SSI_SIER_TUE1_EN | CCSR_SSI_SIER_RFRC_EN | \
  106. CCSR_SSI_SIER_RDMAE | CCSR_SSI_SIER_RIE | \
  107. CCSR_SSI_SIER_ROE0_EN | CCSR_SSI_SIER_ROE1_EN)
  108. /**
  109. * fsl_ssi_private: per-SSI private data
  110. *
  111. * @ssi: pointer to the SSI's registers
  112. * @ssi_phys: physical address of the SSI registers
  113. * @irq: IRQ of this SSI
  114. * @first_stream: pointer to the stream that was opened first
  115. * @second_stream: pointer to second stream
  116. * @playback: the number of playback streams opened
  117. * @capture: the number of capture streams opened
  118. * @cpu_dai: the CPU DAI for this device
  119. * @dev_attr: the sysfs device attribute structure
  120. * @stats: SSI statistics
  121. * @name: name for this device
  122. */
  123. struct fsl_ssi_private {
  124. struct ccsr_ssi __iomem *ssi;
  125. dma_addr_t ssi_phys;
  126. unsigned int irq;
  127. struct snd_pcm_substream *first_stream;
  128. struct snd_pcm_substream *second_stream;
  129. unsigned int fifo_depth;
  130. struct snd_soc_dai_driver cpu_dai_drv;
  131. struct device_attribute dev_attr;
  132. struct platform_device *pdev;
  133. bool new_binding;
  134. bool ssi_on_imx;
  135. bool imx_ac97;
  136. bool use_dma;
  137. struct clk *clk;
  138. struct snd_dmaengine_dai_dma_data dma_params_tx;
  139. struct snd_dmaengine_dai_dma_data dma_params_rx;
  140. struct imx_dma_data filter_data_tx;
  141. struct imx_dma_data filter_data_rx;
  142. struct imx_pcm_fiq_params fiq_params;
  143. struct {
  144. unsigned int rfrc;
  145. unsigned int tfrc;
  146. unsigned int cmdau;
  147. unsigned int cmddu;
  148. unsigned int rxt;
  149. unsigned int rdr1;
  150. unsigned int rdr0;
  151. unsigned int tde1;
  152. unsigned int tde0;
  153. unsigned int roe1;
  154. unsigned int roe0;
  155. unsigned int tue1;
  156. unsigned int tue0;
  157. unsigned int tfs;
  158. unsigned int rfs;
  159. unsigned int tls;
  160. unsigned int rls;
  161. unsigned int rff1;
  162. unsigned int rff0;
  163. unsigned int tfe1;
  164. unsigned int tfe0;
  165. } stats;
  166. char name[1];
  167. };
  168. /**
  169. * fsl_ssi_isr: SSI interrupt handler
  170. *
  171. * Although it's possible to use the interrupt handler to send and receive
  172. * data to/from the SSI, we use the DMA instead. Programming is more
  173. * complicated, but the performance is much better.
  174. *
  175. * This interrupt handler is used only to gather statistics.
  176. *
  177. * @irq: IRQ of the SSI device
  178. * @dev_id: pointer to the ssi_private structure for this SSI device
  179. */
  180. static irqreturn_t fsl_ssi_isr(int irq, void *dev_id)
  181. {
  182. struct fsl_ssi_private *ssi_private = dev_id;
  183. struct ccsr_ssi __iomem *ssi = ssi_private->ssi;
  184. irqreturn_t ret = IRQ_NONE;
  185. __be32 sisr;
  186. __be32 sisr2 = 0;
  187. /* We got an interrupt, so read the status register to see what we
  188. were interrupted for. We mask it with the Interrupt Enable register
  189. so that we only check for events that we're interested in.
  190. */
  191. sisr = read_ssi(&ssi->sisr) & SIER_FLAGS;
  192. if (sisr & CCSR_SSI_SISR_RFRC) {
  193. ssi_private->stats.rfrc++;
  194. sisr2 |= CCSR_SSI_SISR_RFRC;
  195. ret = IRQ_HANDLED;
  196. }
  197. if (sisr & CCSR_SSI_SISR_TFRC) {
  198. ssi_private->stats.tfrc++;
  199. sisr2 |= CCSR_SSI_SISR_TFRC;
  200. ret = IRQ_HANDLED;
  201. }
  202. if (sisr & CCSR_SSI_SISR_CMDAU) {
  203. ssi_private->stats.cmdau++;
  204. ret = IRQ_HANDLED;
  205. }
  206. if (sisr & CCSR_SSI_SISR_CMDDU) {
  207. ssi_private->stats.cmddu++;
  208. ret = IRQ_HANDLED;
  209. }
  210. if (sisr & CCSR_SSI_SISR_RXT) {
  211. ssi_private->stats.rxt++;
  212. ret = IRQ_HANDLED;
  213. }
  214. if (sisr & CCSR_SSI_SISR_RDR1) {
  215. ssi_private->stats.rdr1++;
  216. ret = IRQ_HANDLED;
  217. }
  218. if (sisr & CCSR_SSI_SISR_RDR0) {
  219. ssi_private->stats.rdr0++;
  220. ret = IRQ_HANDLED;
  221. }
  222. if (sisr & CCSR_SSI_SISR_TDE1) {
  223. ssi_private->stats.tde1++;
  224. ret = IRQ_HANDLED;
  225. }
  226. if (sisr & CCSR_SSI_SISR_TDE0) {
  227. ssi_private->stats.tde0++;
  228. ret = IRQ_HANDLED;
  229. }
  230. if (sisr & CCSR_SSI_SISR_ROE1) {
  231. ssi_private->stats.roe1++;
  232. sisr2 |= CCSR_SSI_SISR_ROE1;
  233. ret = IRQ_HANDLED;
  234. }
  235. if (sisr & CCSR_SSI_SISR_ROE0) {
  236. ssi_private->stats.roe0++;
  237. sisr2 |= CCSR_SSI_SISR_ROE0;
  238. ret = IRQ_HANDLED;
  239. }
  240. if (sisr & CCSR_SSI_SISR_TUE1) {
  241. ssi_private->stats.tue1++;
  242. sisr2 |= CCSR_SSI_SISR_TUE1;
  243. ret = IRQ_HANDLED;
  244. }
  245. if (sisr & CCSR_SSI_SISR_TUE0) {
  246. ssi_private->stats.tue0++;
  247. sisr2 |= CCSR_SSI_SISR_TUE0;
  248. ret = IRQ_HANDLED;
  249. }
  250. if (sisr & CCSR_SSI_SISR_TFS) {
  251. ssi_private->stats.tfs++;
  252. ret = IRQ_HANDLED;
  253. }
  254. if (sisr & CCSR_SSI_SISR_RFS) {
  255. ssi_private->stats.rfs++;
  256. ret = IRQ_HANDLED;
  257. }
  258. if (sisr & CCSR_SSI_SISR_TLS) {
  259. ssi_private->stats.tls++;
  260. ret = IRQ_HANDLED;
  261. }
  262. if (sisr & CCSR_SSI_SISR_RLS) {
  263. ssi_private->stats.rls++;
  264. ret = IRQ_HANDLED;
  265. }
  266. if (sisr & CCSR_SSI_SISR_RFF1) {
  267. ssi_private->stats.rff1++;
  268. ret = IRQ_HANDLED;
  269. }
  270. if (sisr & CCSR_SSI_SISR_RFF0) {
  271. ssi_private->stats.rff0++;
  272. ret = IRQ_HANDLED;
  273. }
  274. if (sisr & CCSR_SSI_SISR_TFE1) {
  275. ssi_private->stats.tfe1++;
  276. ret = IRQ_HANDLED;
  277. }
  278. if (sisr & CCSR_SSI_SISR_TFE0) {
  279. ssi_private->stats.tfe0++;
  280. ret = IRQ_HANDLED;
  281. }
  282. /* Clear the bits that we set */
  283. if (sisr2)
  284. write_ssi(sisr2, &ssi->sisr);
  285. return ret;
  286. }
  287. static int fsl_ssi_setup(struct fsl_ssi_private *ssi_private)
  288. {
  289. struct ccsr_ssi __iomem *ssi = ssi_private->ssi;
  290. u8 i2s_mode;
  291. u8 wm;
  292. int synchronous = ssi_private->cpu_dai_drv.symmetric_rates;
  293. if (ssi_private->imx_ac97)
  294. i2s_mode = CCSR_SSI_SCR_I2S_MODE_NORMAL | CCSR_SSI_SCR_NET;
  295. else
  296. i2s_mode = CCSR_SSI_SCR_I2S_MODE_SLAVE;
  297. /*
  298. * Section 16.5 of the MPC8610 reference manual says that the SSI needs
  299. * to be disabled before updating the registers we set here.
  300. */
  301. write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_SSIEN, 0);
  302. /*
  303. * Program the SSI into I2S Slave Non-Network Synchronous mode. Also
  304. * enable the transmit and receive FIFO.
  305. *
  306. * FIXME: Little-endian samples require a different shift dir
  307. */
  308. write_ssi_mask(&ssi->scr,
  309. CCSR_SSI_SCR_I2S_MODE_MASK | CCSR_SSI_SCR_SYN,
  310. CCSR_SSI_SCR_TFR_CLK_DIS |
  311. i2s_mode |
  312. (synchronous ? CCSR_SSI_SCR_SYN : 0));
  313. write_ssi(CCSR_SSI_STCR_TXBIT0 | CCSR_SSI_STCR_TFEN0 |
  314. CCSR_SSI_STCR_TFSI | CCSR_SSI_STCR_TEFS |
  315. CCSR_SSI_STCR_TSCKP, &ssi->stcr);
  316. write_ssi(CCSR_SSI_SRCR_RXBIT0 | CCSR_SSI_SRCR_RFEN0 |
  317. CCSR_SSI_SRCR_RFSI | CCSR_SSI_SRCR_REFS |
  318. CCSR_SSI_SRCR_RSCKP, &ssi->srcr);
  319. /*
  320. * The DC and PM bits are only used if the SSI is the clock master.
  321. */
  322. /*
  323. * Set the watermark for transmit FIFI 0 and receive FIFO 0. We don't
  324. * use FIFO 1. We program the transmit water to signal a DMA transfer
  325. * if there are only two (or fewer) elements left in the FIFO. Two
  326. * elements equals one frame (left channel, right channel). This value,
  327. * however, depends on the depth of the transmit buffer.
  328. *
  329. * We set the watermark on the same level as the DMA burstsize. For
  330. * fiq it is probably better to use the biggest possible watermark
  331. * size.
  332. */
  333. if (ssi_private->use_dma)
  334. wm = ssi_private->fifo_depth - 2;
  335. else
  336. wm = ssi_private->fifo_depth;
  337. write_ssi(CCSR_SSI_SFCSR_TFWM0(wm) | CCSR_SSI_SFCSR_RFWM0(wm) |
  338. CCSR_SSI_SFCSR_TFWM1(wm) | CCSR_SSI_SFCSR_RFWM1(wm),
  339. &ssi->sfcsr);
  340. /*
  341. * For ac97 interrupts are enabled with the startup of the substream
  342. * because it is also running without an active substream. Normally SSI
  343. * is only enabled when there is a substream.
  344. */
  345. if (ssi_private->imx_ac97) {
  346. /*
  347. * Setup the clock control register
  348. */
  349. write_ssi(CCSR_SSI_SxCCR_WL(17) | CCSR_SSI_SxCCR_DC(13),
  350. &ssi->stccr);
  351. write_ssi(CCSR_SSI_SxCCR_WL(17) | CCSR_SSI_SxCCR_DC(13),
  352. &ssi->srccr);
  353. /*
  354. * Enable AC97 mode and startup the SSI
  355. */
  356. write_ssi(CCSR_SSI_SACNT_AC97EN | CCSR_SSI_SACNT_FV,
  357. &ssi->sacnt);
  358. write_ssi(0xff, &ssi->saccdis);
  359. write_ssi(0x300, &ssi->saccen);
  360. /*
  361. * Enable SSI, Transmit and Receive
  362. */
  363. write_ssi_mask(&ssi->scr, 0, CCSR_SSI_SCR_SSIEN |
  364. CCSR_SSI_SCR_TE | CCSR_SSI_SCR_RE);
  365. write_ssi(CCSR_SSI_SOR_WAIT(3), &ssi->sor);
  366. }
  367. return 0;
  368. }
  369. /**
  370. * fsl_ssi_startup: create a new substream
  371. *
  372. * This is the first function called when a stream is opened.
  373. *
  374. * If this is the first stream open, then grab the IRQ and program most of
  375. * the SSI registers.
  376. */
  377. static int fsl_ssi_startup(struct snd_pcm_substream *substream,
  378. struct snd_soc_dai *dai)
  379. {
  380. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  381. struct fsl_ssi_private *ssi_private =
  382. snd_soc_dai_get_drvdata(rtd->cpu_dai);
  383. int synchronous = ssi_private->cpu_dai_drv.symmetric_rates;
  384. /*
  385. * If this is the first stream opened, then request the IRQ
  386. * and initialize the SSI registers.
  387. */
  388. if (!ssi_private->first_stream) {
  389. ssi_private->first_stream = substream;
  390. /*
  391. * fsl_ssi_setup was already called by ac97_init earlier if
  392. * the driver is in ac97 mode.
  393. */
  394. if (!ssi_private->imx_ac97)
  395. fsl_ssi_setup(ssi_private);
  396. } else {
  397. if (synchronous) {
  398. struct snd_pcm_runtime *first_runtime =
  399. ssi_private->first_stream->runtime;
  400. /*
  401. * This is the second stream open, and we're in
  402. * synchronous mode, so we need to impose sample
  403. * sample size constraints. This is because STCCR is
  404. * used for playback and capture in synchronous mode,
  405. * so there's no way to specify different word
  406. * lengths.
  407. *
  408. * Note that this can cause a race condition if the
  409. * second stream is opened before the first stream is
  410. * fully initialized. We provide some protection by
  411. * checking to make sure the first stream is
  412. * initialized, but it's not perfect. ALSA sometimes
  413. * re-initializes the driver with a different sample
  414. * rate or size. If the second stream is opened
  415. * before the first stream has received its final
  416. * parameters, then the second stream may be
  417. * constrained to the wrong sample rate or size.
  418. */
  419. if (!first_runtime->sample_bits) {
  420. dev_err(substream->pcm->card->dev,
  421. "set sample size in %s stream first\n",
  422. substream->stream ==
  423. SNDRV_PCM_STREAM_PLAYBACK
  424. ? "capture" : "playback");
  425. return -EAGAIN;
  426. }
  427. snd_pcm_hw_constraint_minmax(substream->runtime,
  428. SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
  429. first_runtime->sample_bits,
  430. first_runtime->sample_bits);
  431. }
  432. ssi_private->second_stream = substream;
  433. }
  434. return 0;
  435. }
  436. /**
  437. * fsl_ssi_hw_params - program the sample size
  438. *
  439. * Most of the SSI registers have been programmed in the startup function,
  440. * but the word length must be programmed here. Unfortunately, programming
  441. * the SxCCR.WL bits requires the SSI to be temporarily disabled. This can
  442. * cause a problem with supporting simultaneous playback and capture. If
  443. * the SSI is already playing a stream, then that stream may be temporarily
  444. * stopped when you start capture.
  445. *
  446. * Note: The SxCCR.DC and SxCCR.PM bits are only used if the SSI is the
  447. * clock master.
  448. */
  449. static int fsl_ssi_hw_params(struct snd_pcm_substream *substream,
  450. struct snd_pcm_hw_params *hw_params, struct snd_soc_dai *cpu_dai)
  451. {
  452. struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai);
  453. struct ccsr_ssi __iomem *ssi = ssi_private->ssi;
  454. unsigned int sample_size =
  455. snd_pcm_format_width(params_format(hw_params));
  456. u32 wl = CCSR_SSI_SxCCR_WL(sample_size);
  457. int enabled = read_ssi(&ssi->scr) & CCSR_SSI_SCR_SSIEN;
  458. /*
  459. * If we're in synchronous mode, and the SSI is already enabled,
  460. * then STCCR is already set properly.
  461. */
  462. if (enabled && ssi_private->cpu_dai_drv.symmetric_rates)
  463. return 0;
  464. /*
  465. * FIXME: The documentation says that SxCCR[WL] should not be
  466. * modified while the SSI is enabled. The only time this can
  467. * happen is if we're trying to do simultaneous playback and
  468. * capture in asynchronous mode. Unfortunately, I have been enable
  469. * to get that to work at all on the P1022DS. Therefore, we don't
  470. * bother to disable/enable the SSI when setting SxCCR[WL], because
  471. * the SSI will stop anyway. Maybe one day, this will get fixed.
  472. */
  473. /* In synchronous mode, the SSI uses STCCR for capture */
  474. if ((substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ||
  475. ssi_private->cpu_dai_drv.symmetric_rates)
  476. write_ssi_mask(&ssi->stccr, CCSR_SSI_SxCCR_WL_MASK, wl);
  477. else
  478. write_ssi_mask(&ssi->srccr, CCSR_SSI_SxCCR_WL_MASK, wl);
  479. return 0;
  480. }
  481. /**
  482. * fsl_ssi_trigger: start and stop the DMA transfer.
  483. *
  484. * This function is called by ALSA to start, stop, pause, and resume the DMA
  485. * transfer of data.
  486. *
  487. * The DMA channel is in external master start and pause mode, which
  488. * means the SSI completely controls the flow of data.
  489. */
  490. static int fsl_ssi_trigger(struct snd_pcm_substream *substream, int cmd,
  491. struct snd_soc_dai *dai)
  492. {
  493. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  494. struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(rtd->cpu_dai);
  495. struct ccsr_ssi __iomem *ssi = ssi_private->ssi;
  496. unsigned int sier_bits;
  497. /*
  498. * Enable only the interrupts and DMA requests
  499. * that are needed for the channel. As the fiq
  500. * is polling for this bits, we have to ensure
  501. * that this are aligned with the preallocated
  502. * buffers
  503. */
  504. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
  505. if (ssi_private->use_dma)
  506. sier_bits = SIER_FLAGS;
  507. else
  508. sier_bits = CCSR_SSI_SIER_TIE | CCSR_SSI_SIER_TFE0_EN;
  509. } else {
  510. if (ssi_private->use_dma)
  511. sier_bits = SIER_FLAGS;
  512. else
  513. sier_bits = CCSR_SSI_SIER_RIE | CCSR_SSI_SIER_RFF0_EN;
  514. }
  515. switch (cmd) {
  516. case SNDRV_PCM_TRIGGER_START:
  517. case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
  518. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  519. write_ssi_mask(&ssi->scr, 0,
  520. CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_TE);
  521. else
  522. write_ssi_mask(&ssi->scr, 0,
  523. CCSR_SSI_SCR_SSIEN | CCSR_SSI_SCR_RE);
  524. break;
  525. case SNDRV_PCM_TRIGGER_STOP:
  526. case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
  527. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  528. write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_TE, 0);
  529. else
  530. write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_RE, 0);
  531. if (!ssi_private->imx_ac97 && (read_ssi(&ssi->scr) &
  532. (CCSR_SSI_SCR_TE | CCSR_SSI_SCR_RE)) == 0)
  533. write_ssi_mask(&ssi->scr, CCSR_SSI_SCR_SSIEN, 0);
  534. break;
  535. default:
  536. return -EINVAL;
  537. }
  538. write_ssi(sier_bits, &ssi->sier);
  539. return 0;
  540. }
  541. /**
  542. * fsl_ssi_shutdown: shutdown the SSI
  543. *
  544. * Shutdown the SSI if there are no other substreams open.
  545. */
  546. static void fsl_ssi_shutdown(struct snd_pcm_substream *substream,
  547. struct snd_soc_dai *dai)
  548. {
  549. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  550. struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(rtd->cpu_dai);
  551. if (ssi_private->first_stream == substream)
  552. ssi_private->first_stream = ssi_private->second_stream;
  553. ssi_private->second_stream = NULL;
  554. }
  555. static int fsl_ssi_dai_probe(struct snd_soc_dai *dai)
  556. {
  557. struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(dai);
  558. if (ssi_private->ssi_on_imx && ssi_private->use_dma) {
  559. dai->playback_dma_data = &ssi_private->dma_params_tx;
  560. dai->capture_dma_data = &ssi_private->dma_params_rx;
  561. }
  562. return 0;
  563. }
  564. static const struct snd_soc_dai_ops fsl_ssi_dai_ops = {
  565. .startup = fsl_ssi_startup,
  566. .hw_params = fsl_ssi_hw_params,
  567. .shutdown = fsl_ssi_shutdown,
  568. .trigger = fsl_ssi_trigger,
  569. };
  570. /* Template for the CPU dai driver structure */
  571. static struct snd_soc_dai_driver fsl_ssi_dai_template = {
  572. .probe = fsl_ssi_dai_probe,
  573. .playback = {
  574. /* The SSI does not support monaural audio. */
  575. .channels_min = 2,
  576. .channels_max = 2,
  577. .rates = FSLSSI_I2S_RATES,
  578. .formats = FSLSSI_I2S_FORMATS,
  579. },
  580. .capture = {
  581. .channels_min = 2,
  582. .channels_max = 2,
  583. .rates = FSLSSI_I2S_RATES,
  584. .formats = FSLSSI_I2S_FORMATS,
  585. },
  586. .ops = &fsl_ssi_dai_ops,
  587. };
  588. static const struct snd_soc_component_driver fsl_ssi_component = {
  589. .name = "fsl-ssi",
  590. };
  591. /**
  592. * fsl_ssi_ac97_trigger: start and stop the AC97 receive/transmit.
  593. *
  594. * This function is called by ALSA to start, stop, pause, and resume the
  595. * transfer of data.
  596. */
  597. static int fsl_ssi_ac97_trigger(struct snd_pcm_substream *substream, int cmd,
  598. struct snd_soc_dai *dai)
  599. {
  600. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  601. struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(
  602. rtd->cpu_dai);
  603. struct ccsr_ssi __iomem *ssi = ssi_private->ssi;
  604. switch (cmd) {
  605. case SNDRV_PCM_TRIGGER_START:
  606. case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
  607. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  608. write_ssi_mask(&ssi->sier, 0, CCSR_SSI_SIER_TIE |
  609. CCSR_SSI_SIER_TFE0_EN);
  610. else
  611. write_ssi_mask(&ssi->sier, 0, CCSR_SSI_SIER_RIE |
  612. CCSR_SSI_SIER_RFF0_EN);
  613. break;
  614. case SNDRV_PCM_TRIGGER_STOP:
  615. case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
  616. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  617. write_ssi_mask(&ssi->sier, CCSR_SSI_SIER_TIE |
  618. CCSR_SSI_SIER_TFE0_EN, 0);
  619. else
  620. write_ssi_mask(&ssi->sier, CCSR_SSI_SIER_RIE |
  621. CCSR_SSI_SIER_RFF0_EN, 0);
  622. break;
  623. default:
  624. return -EINVAL;
  625. }
  626. if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
  627. write_ssi(CCSR_SSI_SOR_TX_CLR, &ssi->sor);
  628. else
  629. write_ssi(CCSR_SSI_SOR_RX_CLR, &ssi->sor);
  630. return 0;
  631. }
  632. static const struct snd_soc_dai_ops fsl_ssi_ac97_dai_ops = {
  633. .startup = fsl_ssi_startup,
  634. .shutdown = fsl_ssi_shutdown,
  635. .trigger = fsl_ssi_ac97_trigger,
  636. };
  637. static struct snd_soc_dai_driver fsl_ssi_ac97_dai = {
  638. .ac97_control = 1,
  639. .playback = {
  640. .stream_name = "AC97 Playback",
  641. .channels_min = 2,
  642. .channels_max = 2,
  643. .rates = SNDRV_PCM_RATE_8000_48000,
  644. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  645. },
  646. .capture = {
  647. .stream_name = "AC97 Capture",
  648. .channels_min = 2,
  649. .channels_max = 2,
  650. .rates = SNDRV_PCM_RATE_48000,
  651. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  652. },
  653. .ops = &fsl_ssi_ac97_dai_ops,
  654. };
  655. static struct fsl_ssi_private *fsl_ac97_data;
  656. static void fsl_ssi_ac97_init(void)
  657. {
  658. fsl_ssi_setup(fsl_ac97_data);
  659. }
  660. void fsl_ssi_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
  661. unsigned short val)
  662. {
  663. struct ccsr_ssi *ssi = fsl_ac97_data->ssi;
  664. unsigned int lreg;
  665. unsigned int lval;
  666. if (reg > 0x7f)
  667. return;
  668. lreg = reg << 12;
  669. write_ssi(lreg, &ssi->sacadd);
  670. lval = val << 4;
  671. write_ssi(lval , &ssi->sacdat);
  672. write_ssi_mask(&ssi->sacnt, CCSR_SSI_SACNT_RDWR_MASK,
  673. CCSR_SSI_SACNT_WR);
  674. udelay(100);
  675. }
  676. unsigned short fsl_ssi_ac97_read(struct snd_ac97 *ac97,
  677. unsigned short reg)
  678. {
  679. struct ccsr_ssi *ssi = fsl_ac97_data->ssi;
  680. unsigned short val = -1;
  681. unsigned int lreg;
  682. lreg = (reg & 0x7f) << 12;
  683. write_ssi(lreg, &ssi->sacadd);
  684. write_ssi_mask(&ssi->sacnt, CCSR_SSI_SACNT_RDWR_MASK,
  685. CCSR_SSI_SACNT_RD);
  686. udelay(100);
  687. val = (read_ssi(&ssi->sacdat) >> 4) & 0xffff;
  688. return val;
  689. }
  690. static struct snd_ac97_bus_ops fsl_ssi_ac97_ops = {
  691. .read = fsl_ssi_ac97_read,
  692. .write = fsl_ssi_ac97_write,
  693. };
  694. /* Show the statistics of a flag only if its interrupt is enabled. The
  695. * compiler will optimze this code to a no-op if the interrupt is not
  696. * enabled.
  697. */
  698. #define SIER_SHOW(flag, name) \
  699. do { \
  700. if (SIER_FLAGS & CCSR_SSI_SIER_##flag) \
  701. length += sprintf(buf + length, #name "=%u\n", \
  702. ssi_private->stats.name); \
  703. } while (0)
  704. /**
  705. * fsl_sysfs_ssi_show: display SSI statistics
  706. *
  707. * Display the statistics for the current SSI device. To avoid confusion,
  708. * we only show those counts that are enabled.
  709. */
  710. static ssize_t fsl_sysfs_ssi_show(struct device *dev,
  711. struct device_attribute *attr, char *buf)
  712. {
  713. struct fsl_ssi_private *ssi_private =
  714. container_of(attr, struct fsl_ssi_private, dev_attr);
  715. ssize_t length = 0;
  716. SIER_SHOW(RFRC_EN, rfrc);
  717. SIER_SHOW(TFRC_EN, tfrc);
  718. SIER_SHOW(CMDAU_EN, cmdau);
  719. SIER_SHOW(CMDDU_EN, cmddu);
  720. SIER_SHOW(RXT_EN, rxt);
  721. SIER_SHOW(RDR1_EN, rdr1);
  722. SIER_SHOW(RDR0_EN, rdr0);
  723. SIER_SHOW(TDE1_EN, tde1);
  724. SIER_SHOW(TDE0_EN, tde0);
  725. SIER_SHOW(ROE1_EN, roe1);
  726. SIER_SHOW(ROE0_EN, roe0);
  727. SIER_SHOW(TUE1_EN, tue1);
  728. SIER_SHOW(TUE0_EN, tue0);
  729. SIER_SHOW(TFS_EN, tfs);
  730. SIER_SHOW(RFS_EN, rfs);
  731. SIER_SHOW(TLS_EN, tls);
  732. SIER_SHOW(RLS_EN, rls);
  733. SIER_SHOW(RFF1_EN, rff1);
  734. SIER_SHOW(RFF0_EN, rff0);
  735. SIER_SHOW(TFE1_EN, tfe1);
  736. SIER_SHOW(TFE0_EN, tfe0);
  737. return length;
  738. }
  739. /**
  740. * Make every character in a string lower-case
  741. */
  742. static void make_lowercase(char *s)
  743. {
  744. char *p = s;
  745. char c;
  746. while ((c = *p)) {
  747. if ((c >= 'A') && (c <= 'Z'))
  748. *p = c + ('a' - 'A');
  749. p++;
  750. }
  751. }
  752. static int fsl_ssi_probe(struct platform_device *pdev)
  753. {
  754. struct fsl_ssi_private *ssi_private;
  755. int ret = 0;
  756. struct device_attribute *dev_attr = NULL;
  757. struct device_node *np = pdev->dev.of_node;
  758. const char *p, *sprop;
  759. const uint32_t *iprop;
  760. struct resource res;
  761. char name[64];
  762. bool shared;
  763. bool ac97 = false;
  764. /* SSIs that are not connected on the board should have a
  765. * status = "disabled"
  766. * property in their device tree nodes.
  767. */
  768. if (!of_device_is_available(np))
  769. return -ENODEV;
  770. /* We only support the SSI in "I2S Slave" mode */
  771. sprop = of_get_property(np, "fsl,mode", NULL);
  772. if (!sprop) {
  773. dev_err(&pdev->dev, "fsl,mode property is necessary\n");
  774. return -EINVAL;
  775. }
  776. if (!strcmp(sprop, "ac97-slave")) {
  777. ac97 = true;
  778. } else if (strcmp(sprop, "i2s-slave")) {
  779. dev_notice(&pdev->dev, "mode %s is unsupported\n", sprop);
  780. return -ENODEV;
  781. }
  782. /* The DAI name is the last part of the full name of the node. */
  783. p = strrchr(np->full_name, '/') + 1;
  784. ssi_private = devm_kzalloc(&pdev->dev, sizeof(*ssi_private) + strlen(p),
  785. GFP_KERNEL);
  786. if (!ssi_private) {
  787. dev_err(&pdev->dev, "could not allocate DAI object\n");
  788. return -ENOMEM;
  789. }
  790. strcpy(ssi_private->name, p);
  791. ssi_private->use_dma = !of_property_read_bool(np,
  792. "fsl,fiq-stream-filter");
  793. if (ac97) {
  794. memcpy(&ssi_private->cpu_dai_drv, &fsl_ssi_ac97_dai,
  795. sizeof(fsl_ssi_ac97_dai));
  796. fsl_ac97_data = ssi_private;
  797. ssi_private->imx_ac97 = true;
  798. snd_soc_set_ac97_ops_of_reset(&fsl_ssi_ac97_ops, pdev);
  799. } else {
  800. /* Initialize this copy of the CPU DAI driver structure */
  801. memcpy(&ssi_private->cpu_dai_drv, &fsl_ssi_dai_template,
  802. sizeof(fsl_ssi_dai_template));
  803. }
  804. ssi_private->cpu_dai_drv.name = ssi_private->name;
  805. /* Get the addresses and IRQ */
  806. ret = of_address_to_resource(np, 0, &res);
  807. if (ret) {
  808. dev_err(&pdev->dev, "could not determine device resources\n");
  809. return ret;
  810. }
  811. ssi_private->ssi = of_iomap(np, 0);
  812. if (!ssi_private->ssi) {
  813. dev_err(&pdev->dev, "could not map device resources\n");
  814. return -ENOMEM;
  815. }
  816. ssi_private->ssi_phys = res.start;
  817. ssi_private->irq = irq_of_parse_and_map(np, 0);
  818. if (ssi_private->irq == NO_IRQ) {
  819. dev_err(&pdev->dev, "no irq for node %s\n", np->full_name);
  820. return -ENXIO;
  821. }
  822. /* Are the RX and the TX clocks locked? */
  823. if (!of_find_property(np, "fsl,ssi-asynchronous", NULL))
  824. ssi_private->cpu_dai_drv.symmetric_rates = 1;
  825. /* Determine the FIFO depth. */
  826. iprop = of_get_property(np, "fsl,fifo-depth", NULL);
  827. if (iprop)
  828. ssi_private->fifo_depth = be32_to_cpup(iprop);
  829. else
  830. /* Older 8610 DTs didn't have the fifo-depth property */
  831. ssi_private->fifo_depth = 8;
  832. if (of_device_is_compatible(pdev->dev.of_node, "fsl,imx21-ssi")) {
  833. u32 dma_events[2];
  834. ssi_private->ssi_on_imx = true;
  835. ssi_private->clk = devm_clk_get(&pdev->dev, NULL);
  836. if (IS_ERR(ssi_private->clk)) {
  837. ret = PTR_ERR(ssi_private->clk);
  838. dev_err(&pdev->dev, "could not get clock: %d\n", ret);
  839. goto error_irqmap;
  840. }
  841. ret = clk_prepare_enable(ssi_private->clk);
  842. if (ret) {
  843. dev_err(&pdev->dev, "clk_prepare_enable failed: %d\n",
  844. ret);
  845. goto error_irqmap;
  846. }
  847. /*
  848. * We have burstsize be "fifo_depth - 2" to match the SSI
  849. * watermark setting in fsl_ssi_startup().
  850. */
  851. ssi_private->dma_params_tx.maxburst =
  852. ssi_private->fifo_depth - 2;
  853. ssi_private->dma_params_rx.maxburst =
  854. ssi_private->fifo_depth - 2;
  855. ssi_private->dma_params_tx.addr =
  856. ssi_private->ssi_phys + offsetof(struct ccsr_ssi, stx0);
  857. ssi_private->dma_params_rx.addr =
  858. ssi_private->ssi_phys + offsetof(struct ccsr_ssi, srx0);
  859. ssi_private->dma_params_tx.filter_data =
  860. &ssi_private->filter_data_tx;
  861. ssi_private->dma_params_rx.filter_data =
  862. &ssi_private->filter_data_rx;
  863. if (!of_property_read_bool(pdev->dev.of_node, "dmas") &&
  864. ssi_private->use_dma) {
  865. /*
  866. * FIXME: This is a temporary solution until all
  867. * necessary dma drivers support the generic dma
  868. * bindings.
  869. */
  870. ret = of_property_read_u32_array(pdev->dev.of_node,
  871. "fsl,ssi-dma-events", dma_events, 2);
  872. if (ret && ssi_private->use_dma) {
  873. dev_err(&pdev->dev, "could not get dma events but fsl-ssi is configured to use DMA\n");
  874. goto error_clk;
  875. }
  876. }
  877. shared = of_device_is_compatible(of_get_parent(np),
  878. "fsl,spba-bus");
  879. imx_pcm_dma_params_init_data(&ssi_private->filter_data_tx,
  880. dma_events[0], shared ? IMX_DMATYPE_SSI_SP : IMX_DMATYPE_SSI);
  881. imx_pcm_dma_params_init_data(&ssi_private->filter_data_rx,
  882. dma_events[1], shared ? IMX_DMATYPE_SSI_SP : IMX_DMATYPE_SSI);
  883. } else if (ssi_private->use_dma) {
  884. /* The 'name' should not have any slashes in it. */
  885. ret = devm_request_irq(&pdev->dev, ssi_private->irq,
  886. fsl_ssi_isr, 0, ssi_private->name,
  887. ssi_private);
  888. if (ret < 0) {
  889. dev_err(&pdev->dev, "could not claim irq %u\n",
  890. ssi_private->irq);
  891. goto error_irqmap;
  892. }
  893. }
  894. /* Initialize the the device_attribute structure */
  895. dev_attr = &ssi_private->dev_attr;
  896. sysfs_attr_init(&dev_attr->attr);
  897. dev_attr->attr.name = "statistics";
  898. dev_attr->attr.mode = S_IRUGO;
  899. dev_attr->show = fsl_sysfs_ssi_show;
  900. ret = device_create_file(&pdev->dev, dev_attr);
  901. if (ret) {
  902. dev_err(&pdev->dev, "could not create sysfs %s file\n",
  903. ssi_private->dev_attr.attr.name);
  904. goto error_clk;
  905. }
  906. /* Register with ASoC */
  907. dev_set_drvdata(&pdev->dev, ssi_private);
  908. ret = snd_soc_register_component(&pdev->dev, &fsl_ssi_component,
  909. &ssi_private->cpu_dai_drv, 1);
  910. if (ret) {
  911. dev_err(&pdev->dev, "failed to register DAI: %d\n", ret);
  912. goto error_dev;
  913. }
  914. if (ssi_private->ssi_on_imx) {
  915. if (!ssi_private->use_dma) {
  916. /*
  917. * Some boards use an incompatible codec. To get it
  918. * working, we are using imx-fiq-pcm-audio, that
  919. * can handle those codecs. DMA is not possible in this
  920. * situation.
  921. */
  922. ssi_private->fiq_params.irq = ssi_private->irq;
  923. ssi_private->fiq_params.base = ssi_private->ssi;
  924. ssi_private->fiq_params.dma_params_rx =
  925. &ssi_private->dma_params_rx;
  926. ssi_private->fiq_params.dma_params_tx =
  927. &ssi_private->dma_params_tx;
  928. ret = imx_pcm_fiq_init(pdev, &ssi_private->fiq_params);
  929. if (ret)
  930. goto error_dev;
  931. } else {
  932. ret = imx_pcm_dma_init(pdev);
  933. if (ret)
  934. goto error_dev;
  935. }
  936. }
  937. /*
  938. * If codec-handle property is missing from SSI node, we assume
  939. * that the machine driver uses new binding which does not require
  940. * SSI driver to trigger machine driver's probe.
  941. */
  942. if (!of_get_property(np, "codec-handle", NULL)) {
  943. ssi_private->new_binding = true;
  944. goto done;
  945. }
  946. /* Trigger the machine driver's probe function. The platform driver
  947. * name of the machine driver is taken from /compatible property of the
  948. * device tree. We also pass the address of the CPU DAI driver
  949. * structure.
  950. */
  951. sprop = of_get_property(of_find_node_by_path("/"), "compatible", NULL);
  952. /* Sometimes the compatible name has a "fsl," prefix, so we strip it. */
  953. p = strrchr(sprop, ',');
  954. if (p)
  955. sprop = p + 1;
  956. snprintf(name, sizeof(name), "snd-soc-%s", sprop);
  957. make_lowercase(name);
  958. ssi_private->pdev =
  959. platform_device_register_data(&pdev->dev, name, 0, NULL, 0);
  960. if (IS_ERR(ssi_private->pdev)) {
  961. ret = PTR_ERR(ssi_private->pdev);
  962. dev_err(&pdev->dev, "failed to register platform: %d\n", ret);
  963. goto error_dai;
  964. }
  965. done:
  966. if (ssi_private->imx_ac97)
  967. fsl_ssi_ac97_init();
  968. return 0;
  969. error_dai:
  970. if (ssi_private->ssi_on_imx)
  971. imx_pcm_dma_exit(pdev);
  972. snd_soc_unregister_component(&pdev->dev);
  973. error_dev:
  974. device_remove_file(&pdev->dev, dev_attr);
  975. error_clk:
  976. if (ssi_private->ssi_on_imx)
  977. clk_disable_unprepare(ssi_private->clk);
  978. error_irqmap:
  979. irq_dispose_mapping(ssi_private->irq);
  980. return ret;
  981. }
  982. static int fsl_ssi_remove(struct platform_device *pdev)
  983. {
  984. struct fsl_ssi_private *ssi_private = dev_get_drvdata(&pdev->dev);
  985. if (!ssi_private->new_binding)
  986. platform_device_unregister(ssi_private->pdev);
  987. if (ssi_private->ssi_on_imx)
  988. imx_pcm_dma_exit(pdev);
  989. snd_soc_unregister_component(&pdev->dev);
  990. dev_set_drvdata(&pdev->dev, NULL);
  991. device_remove_file(&pdev->dev, &ssi_private->dev_attr);
  992. if (ssi_private->ssi_on_imx)
  993. clk_disable_unprepare(ssi_private->clk);
  994. irq_dispose_mapping(ssi_private->irq);
  995. return 0;
  996. }
  997. static const struct of_device_id fsl_ssi_ids[] = {
  998. { .compatible = "fsl,mpc8610-ssi", },
  999. { .compatible = "fsl,imx21-ssi", },
  1000. {}
  1001. };
  1002. MODULE_DEVICE_TABLE(of, fsl_ssi_ids);
  1003. static struct platform_driver fsl_ssi_driver = {
  1004. .driver = {
  1005. .name = "fsl-ssi-dai",
  1006. .owner = THIS_MODULE,
  1007. .of_match_table = fsl_ssi_ids,
  1008. },
  1009. .probe = fsl_ssi_probe,
  1010. .remove = fsl_ssi_remove,
  1011. };
  1012. module_platform_driver(fsl_ssi_driver);
  1013. MODULE_ALIAS("platform:fsl-ssi-dai");
  1014. MODULE_AUTHOR("Timur Tabi <timur@freescale.com>");
  1015. MODULE_DESCRIPTION("Freescale Synchronous Serial Interface (SSI) ASoC Driver");
  1016. MODULE_LICENSE("GPL v2");