blob: 94f1e46ca79b77366ccb82fd41dc0e972edaa6d2 [file] [log] [blame]
Chaithrika U Sb67f4482009-06-05 06:28:40 -04001/*
2 * ALSA SoC McASP Audio Layer for TI DAVINCI processor
3 *
4 * Multi-channel Audio Serial Port Driver
5 *
6 * Author: Nirmal Pandey <n-pandey@ti.com>,
7 * Suresh Rajashekara <suresh.r@ti.com>
8 * Steve Chen <schen@.mvista.com>
9 *
10 * Copyright: (C) 2009 MontaVista Software, Inc., <source@mvista.com>
11 * Copyright: (C) 2009 Texas Instruments, India
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2 as
15 * published by the Free Software Foundation.
16 */
17
18#include <linux/init.h>
19#include <linux/module.h>
20#include <linux/device.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090021#include <linux/slab.h>
Chaithrika U Sb67f4482009-06-05 06:28:40 -040022#include <linux/delay.h>
23#include <linux/io.h>
Hebbar, Gururaja10884342012-08-08 20:40:32 +053024#include <linux/pm_runtime.h>
Hebbar, Gururaja3e3b8c32012-08-27 18:56:42 +053025#include <linux/of.h>
26#include <linux/of_platform.h>
27#include <linux/of_device.h>
Chaithrika U Sb67f4482009-06-05 06:28:40 -040028
29#include <sound/core.h>
30#include <sound/pcm.h>
31#include <sound/pcm_params.h>
32#include <sound/initval.h>
33#include <sound/soc.h>
34
35#include "davinci-pcm.h"
36#include "davinci-mcasp.h"
37
38/*
39 * McASP register definitions
40 */
41#define DAVINCI_MCASP_PID_REG 0x00
42#define DAVINCI_MCASP_PWREMUMGT_REG 0x04
43
44#define DAVINCI_MCASP_PFUNC_REG 0x10
45#define DAVINCI_MCASP_PDIR_REG 0x14
46#define DAVINCI_MCASP_PDOUT_REG 0x18
47#define DAVINCI_MCASP_PDSET_REG 0x1c
48
49#define DAVINCI_MCASP_PDCLR_REG 0x20
50
51#define DAVINCI_MCASP_TLGC_REG 0x30
52#define DAVINCI_MCASP_TLMR_REG 0x34
53
54#define DAVINCI_MCASP_GBLCTL_REG 0x44
55#define DAVINCI_MCASP_AMUTE_REG 0x48
56#define DAVINCI_MCASP_LBCTL_REG 0x4c
57
58#define DAVINCI_MCASP_TXDITCTL_REG 0x50
59
60#define DAVINCI_MCASP_GBLCTLR_REG 0x60
61#define DAVINCI_MCASP_RXMASK_REG 0x64
62#define DAVINCI_MCASP_RXFMT_REG 0x68
63#define DAVINCI_MCASP_RXFMCTL_REG 0x6c
64
65#define DAVINCI_MCASP_ACLKRCTL_REG 0x70
66#define DAVINCI_MCASP_AHCLKRCTL_REG 0x74
67#define DAVINCI_MCASP_RXTDM_REG 0x78
68#define DAVINCI_MCASP_EVTCTLR_REG 0x7c
69
70#define DAVINCI_MCASP_RXSTAT_REG 0x80
71#define DAVINCI_MCASP_RXTDMSLOT_REG 0x84
72#define DAVINCI_MCASP_RXCLKCHK_REG 0x88
73#define DAVINCI_MCASP_REVTCTL_REG 0x8c
74
75#define DAVINCI_MCASP_GBLCTLX_REG 0xa0
76#define DAVINCI_MCASP_TXMASK_REG 0xa4
77#define DAVINCI_MCASP_TXFMT_REG 0xa8
78#define DAVINCI_MCASP_TXFMCTL_REG 0xac
79
80#define DAVINCI_MCASP_ACLKXCTL_REG 0xb0
81#define DAVINCI_MCASP_AHCLKXCTL_REG 0xb4
82#define DAVINCI_MCASP_TXTDM_REG 0xb8
83#define DAVINCI_MCASP_EVTCTLX_REG 0xbc
84
85#define DAVINCI_MCASP_TXSTAT_REG 0xc0
86#define DAVINCI_MCASP_TXTDMSLOT_REG 0xc4
87#define DAVINCI_MCASP_TXCLKCHK_REG 0xc8
88#define DAVINCI_MCASP_XEVTCTL_REG 0xcc
89
90/* Left(even TDM Slot) Channel Status Register File */
91#define DAVINCI_MCASP_DITCSRA_REG 0x100
92/* Right(odd TDM slot) Channel Status Register File */
93#define DAVINCI_MCASP_DITCSRB_REG 0x118
94/* Left(even TDM slot) User Data Register File */
95#define DAVINCI_MCASP_DITUDRA_REG 0x130
96/* Right(odd TDM Slot) User Data Register File */
97#define DAVINCI_MCASP_DITUDRB_REG 0x148
98
99/* Serializer n Control Register */
100#define DAVINCI_MCASP_XRSRCTL_BASE_REG 0x180
101#define DAVINCI_MCASP_XRSRCTL_REG(n) (DAVINCI_MCASP_XRSRCTL_BASE_REG + \
102 (n << 2))
103
104/* Transmit Buffer for Serializer n */
105#define DAVINCI_MCASP_TXBUF_REG 0x200
106/* Receive Buffer for Serializer n */
107#define DAVINCI_MCASP_RXBUF_REG 0x280
108
Chaithrika U S6a99fb52009-08-11 16:58:52 -0400109/* McASP FIFO Registers */
110#define DAVINCI_MCASP_WFIFOCTL (0x1010)
111#define DAVINCI_MCASP_WFIFOSTS (0x1014)
112#define DAVINCI_MCASP_RFIFOCTL (0x1018)
113#define DAVINCI_MCASP_RFIFOSTS (0x101C)
Hebbar, Gururajae5ec69d2012-09-03 13:40:40 +0530114#define MCASP_VER3_WFIFOCTL (0x1000)
115#define MCASP_VER3_WFIFOSTS (0x1004)
116#define MCASP_VER3_RFIFOCTL (0x1008)
117#define MCASP_VER3_RFIFOSTS (0x100C)
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400118
119/*
120 * DAVINCI_MCASP_PWREMUMGT_REG - Power Down and Emulation Management
121 * Register Bits
122 */
123#define MCASP_FREE BIT(0)
124#define MCASP_SOFT BIT(1)
125
126/*
127 * DAVINCI_MCASP_PFUNC_REG - Pin Function / GPIO Enable Register Bits
128 */
129#define AXR(n) (1<<n)
130#define PFUNC_AMUTE BIT(25)
131#define ACLKX BIT(26)
132#define AHCLKX BIT(27)
133#define AFSX BIT(28)
134#define ACLKR BIT(29)
135#define AHCLKR BIT(30)
136#define AFSR BIT(31)
137
138/*
139 * DAVINCI_MCASP_PDIR_REG - Pin Direction Register Bits
140 */
141#define AXR(n) (1<<n)
142#define PDIR_AMUTE BIT(25)
143#define ACLKX BIT(26)
144#define AHCLKX BIT(27)
145#define AFSX BIT(28)
146#define ACLKR BIT(29)
147#define AHCLKR BIT(30)
148#define AFSR BIT(31)
149
150/*
151 * DAVINCI_MCASP_TXDITCTL_REG - Transmit DIT Control Register Bits
152 */
153#define DITEN BIT(0) /* Transmit DIT mode enable/disable */
154#define VA BIT(2)
155#define VB BIT(3)
156
157/*
158 * DAVINCI_MCASP_TXFMT_REG - Transmit Bitstream Format Register Bits
159 */
160#define TXROT(val) (val)
161#define TXSEL BIT(3)
162#define TXSSZ(val) (val<<4)
163#define TXPBIT(val) (val<<8)
164#define TXPAD(val) (val<<13)
165#define TXORD BIT(15)
166#define FSXDLY(val) (val<<16)
167
168/*
169 * DAVINCI_MCASP_RXFMT_REG - Receive Bitstream Format Register Bits
170 */
171#define RXROT(val) (val)
172#define RXSEL BIT(3)
173#define RXSSZ(val) (val<<4)
174#define RXPBIT(val) (val<<8)
175#define RXPAD(val) (val<<13)
176#define RXORD BIT(15)
177#define FSRDLY(val) (val<<16)
178
179/*
180 * DAVINCI_MCASP_TXFMCTL_REG - Transmit Frame Control Register Bits
181 */
182#define FSXPOL BIT(0)
183#define AFSXE BIT(1)
184#define FSXDUR BIT(4)
185#define FSXMOD(val) (val<<7)
186
187/*
188 * DAVINCI_MCASP_RXFMCTL_REG - Receive Frame Control Register Bits
189 */
190#define FSRPOL BIT(0)
191#define AFSRE BIT(1)
192#define FSRDUR BIT(4)
193#define FSRMOD(val) (val<<7)
194
195/*
196 * DAVINCI_MCASP_ACLKXCTL_REG - Transmit Clock Control Register Bits
197 */
198#define ACLKXDIV(val) (val)
199#define ACLKXE BIT(5)
200#define TX_ASYNC BIT(6)
201#define ACLKXPOL BIT(7)
Daniel Mack4ed8c9b2012-10-04 15:08:39 +0200202#define ACLKXDIV_MASK 0x1f
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400203
204/*
205 * DAVINCI_MCASP_ACLKRCTL_REG Receive Clock Control Register Bits
206 */
207#define ACLKRDIV(val) (val)
208#define ACLKRE BIT(5)
209#define RX_ASYNC BIT(6)
210#define ACLKRPOL BIT(7)
Daniel Mack4ed8c9b2012-10-04 15:08:39 +0200211#define ACLKRDIV_MASK 0x1f
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400212
213/*
214 * DAVINCI_MCASP_AHCLKXCTL_REG - High Frequency Transmit Clock Control
215 * Register Bits
216 */
217#define AHCLKXDIV(val) (val)
218#define AHCLKXPOL BIT(14)
219#define AHCLKXE BIT(15)
Daniel Mack4ed8c9b2012-10-04 15:08:39 +0200220#define AHCLKXDIV_MASK 0xfff
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400221
222/*
223 * DAVINCI_MCASP_AHCLKRCTL_REG - High Frequency Receive Clock Control
224 * Register Bits
225 */
226#define AHCLKRDIV(val) (val)
227#define AHCLKRPOL BIT(14)
228#define AHCLKRE BIT(15)
Daniel Mack4ed8c9b2012-10-04 15:08:39 +0200229#define AHCLKRDIV_MASK 0xfff
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400230
231/*
232 * DAVINCI_MCASP_XRSRCTL_BASE_REG - Serializer Control Register Bits
233 */
234#define MODE(val) (val)
235#define DISMOD (val)(val<<2)
236#define TXSTATE BIT(4)
237#define RXSTATE BIT(5)
Michal Bachraty2952b272013-02-28 16:07:08 +0100238#define SRMOD_MASK 3
239#define SRMOD_INACTIVE 0
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400240
241/*
242 * DAVINCI_MCASP_LBCTL_REG - Loop Back Control Register Bits
243 */
244#define LBEN BIT(0)
245#define LBORD BIT(1)
246#define LBGENMODE(val) (val<<2)
247
248/*
249 * DAVINCI_MCASP_TXTDMSLOT_REG - Transmit TDM Slot Register configuration
250 */
251#define TXTDMS(n) (1<<n)
252
253/*
254 * DAVINCI_MCASP_RXTDMSLOT_REG - Receive TDM Slot Register configuration
255 */
256#define RXTDMS(n) (1<<n)
257
258/*
259 * DAVINCI_MCASP_GBLCTL_REG - Global Control Register Bits
260 */
261#define RXCLKRST BIT(0) /* Receiver Clock Divider Reset */
262#define RXHCLKRST BIT(1) /* Receiver High Frequency Clock Divider */
263#define RXSERCLR BIT(2) /* Receiver Serializer Clear */
264#define RXSMRST BIT(3) /* Receiver State Machine Reset */
265#define RXFSRST BIT(4) /* Frame Sync Generator Reset */
266#define TXCLKRST BIT(8) /* Transmitter Clock Divider Reset */
267#define TXHCLKRST BIT(9) /* Transmitter High Frequency Clock Divider*/
268#define TXSERCLR BIT(10) /* Transmit Serializer Clear */
269#define TXSMRST BIT(11) /* Transmitter State Machine Reset */
270#define TXFSRST BIT(12) /* Frame Sync Generator Reset */
271
272/*
273 * DAVINCI_MCASP_AMUTE_REG - Mute Control Register Bits
274 */
275#define MUTENA(val) (val)
276#define MUTEINPOL BIT(2)
277#define MUTEINENA BIT(3)
278#define MUTEIN BIT(4)
279#define MUTER BIT(5)
280#define MUTEX BIT(6)
281#define MUTEFSR BIT(7)
282#define MUTEFSX BIT(8)
283#define MUTEBADCLKR BIT(9)
284#define MUTEBADCLKX BIT(10)
285#define MUTERXDMAERR BIT(11)
286#define MUTETXDMAERR BIT(12)
287
288/*
289 * DAVINCI_MCASP_REVTCTL_REG - Receiver DMA Event Control Register bits
290 */
291#define RXDATADMADIS BIT(0)
292
293/*
294 * DAVINCI_MCASP_XEVTCTL_REG - Transmitter DMA Event Control Register bits
295 */
296#define TXDATADMADIS BIT(0)
297
Chaithrika U S6a99fb52009-08-11 16:58:52 -0400298/*
299 * DAVINCI_MCASP_W[R]FIFOCTL - Write/Read FIFO Control Register bits
300 */
301#define FIFO_ENABLE BIT(16)
302#define NUMEVT_MASK (0xFF << 8)
303#define NUMDMA_MASK (0xFF)
304
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400305#define DAVINCI_MCASP_NUM_SERIALIZER 16
306
307static inline void mcasp_set_bits(void __iomem *reg, u32 val)
308{
309 __raw_writel(__raw_readl(reg) | val, reg);
310}
311
312static inline void mcasp_clr_bits(void __iomem *reg, u32 val)
313{
314 __raw_writel((__raw_readl(reg) & ~(val)), reg);
315}
316
317static inline void mcasp_mod_bits(void __iomem *reg, u32 val, u32 mask)
318{
319 __raw_writel((__raw_readl(reg) & ~mask) | val, reg);
320}
321
322static inline void mcasp_set_reg(void __iomem *reg, u32 val)
323{
324 __raw_writel(val, reg);
325}
326
327static inline u32 mcasp_get_reg(void __iomem *reg)
328{
329 return (unsigned int)__raw_readl(reg);
330}
331
332static inline void mcasp_set_ctl_reg(void __iomem *regs, u32 val)
333{
334 int i = 0;
335
336 mcasp_set_bits(regs, val);
337
338 /* programming GBLCTL needs to read back from GBLCTL and verfiy */
339 /* loop count is to avoid the lock-up */
340 for (i = 0; i < 1000; i++) {
341 if ((mcasp_get_reg(regs) & val) == val)
342 break;
343 }
344
345 if (i == 1000 && ((mcasp_get_reg(regs) & val) != val))
346 printk(KERN_ERR "GBLCTL write error\n");
347}
348
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400349static void mcasp_start_rx(struct davinci_audio_dev *dev)
350{
351 mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLR_REG, RXHCLKRST);
352 mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLR_REG, RXCLKRST);
353 mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLR_REG, RXSERCLR);
354 mcasp_set_reg(dev->base + DAVINCI_MCASP_RXBUF_REG, 0);
355
356 mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLR_REG, RXSMRST);
357 mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLR_REG, RXFSRST);
358 mcasp_set_reg(dev->base + DAVINCI_MCASP_RXBUF_REG, 0);
359
360 mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLR_REG, RXSMRST);
361 mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLR_REG, RXFSRST);
362}
363
364static void mcasp_start_tx(struct davinci_audio_dev *dev)
365{
Chaithrika U S6a99fb52009-08-11 16:58:52 -0400366 u8 offset = 0, i;
367 u32 cnt;
368
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400369 mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLX_REG, TXHCLKRST);
370 mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLX_REG, TXCLKRST);
371 mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLX_REG, TXSERCLR);
372 mcasp_set_reg(dev->base + DAVINCI_MCASP_TXBUF_REG, 0);
373
374 mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLX_REG, TXSMRST);
375 mcasp_set_ctl_reg(dev->base + DAVINCI_MCASP_GBLCTLX_REG, TXFSRST);
376 mcasp_set_reg(dev->base + DAVINCI_MCASP_TXBUF_REG, 0);
Chaithrika U S6a99fb52009-08-11 16:58:52 -0400377 for (i = 0; i < dev->num_serializer; i++) {
378 if (dev->serial_dir[i] == TX_MODE) {
379 offset = i;
380 break;
381 }
382 }
383
384 /* wait for TX ready */
385 cnt = 0;
386 while (!(mcasp_get_reg(dev->base + DAVINCI_MCASP_XRSRCTL_REG(offset)) &
387 TXSTATE) && (cnt < 100000))
388 cnt++;
389
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400390 mcasp_set_reg(dev->base + DAVINCI_MCASP_TXBUF_REG, 0);
391}
392
393static void davinci_mcasp_start(struct davinci_audio_dev *dev, int stream)
394{
Chaithrika U S539d3d82009-09-23 10:12:08 -0400395 if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
Vaibhav Bedia0d624272012-08-08 20:40:31 +0530396 if (dev->txnumevt) { /* enable FIFO */
Hebbar, Gururajae5ec69d2012-09-03 13:40:40 +0530397 switch (dev->version) {
398 case MCASP_VERSION_3:
399 mcasp_clr_bits(dev->base + MCASP_VER3_WFIFOCTL,
Vaibhav Bedia0d624272012-08-08 20:40:31 +0530400 FIFO_ENABLE);
Hebbar, Gururajae5ec69d2012-09-03 13:40:40 +0530401 mcasp_set_bits(dev->base + MCASP_VER3_WFIFOCTL,
Chaithrika U S539d3d82009-09-23 10:12:08 -0400402 FIFO_ENABLE);
Hebbar, Gururajae5ec69d2012-09-03 13:40:40 +0530403 break;
404 default:
405 mcasp_clr_bits(dev->base +
406 DAVINCI_MCASP_WFIFOCTL, FIFO_ENABLE);
407 mcasp_set_bits(dev->base +
408 DAVINCI_MCASP_WFIFOCTL, FIFO_ENABLE);
409 }
Vaibhav Bedia0d624272012-08-08 20:40:31 +0530410 }
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400411 mcasp_start_tx(dev);
Chaithrika U S539d3d82009-09-23 10:12:08 -0400412 } else {
Vaibhav Bedia0d624272012-08-08 20:40:31 +0530413 if (dev->rxnumevt) { /* enable FIFO */
Hebbar, Gururajae5ec69d2012-09-03 13:40:40 +0530414 switch (dev->version) {
415 case MCASP_VERSION_3:
416 mcasp_clr_bits(dev->base + MCASP_VER3_RFIFOCTL,
Vaibhav Bedia0d624272012-08-08 20:40:31 +0530417 FIFO_ENABLE);
Hebbar, Gururajae5ec69d2012-09-03 13:40:40 +0530418 mcasp_set_bits(dev->base + MCASP_VER3_RFIFOCTL,
Chaithrika U S539d3d82009-09-23 10:12:08 -0400419 FIFO_ENABLE);
Hebbar, Gururajae5ec69d2012-09-03 13:40:40 +0530420 break;
421 default:
422 mcasp_clr_bits(dev->base +
423 DAVINCI_MCASP_RFIFOCTL, FIFO_ENABLE);
424 mcasp_set_bits(dev->base +
425 DAVINCI_MCASP_RFIFOCTL, FIFO_ENABLE);
426 }
Vaibhav Bedia0d624272012-08-08 20:40:31 +0530427 }
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400428 mcasp_start_rx(dev);
Chaithrika U S539d3d82009-09-23 10:12:08 -0400429 }
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400430}
431
432static void mcasp_stop_rx(struct davinci_audio_dev *dev)
433{
434 mcasp_set_reg(dev->base + DAVINCI_MCASP_GBLCTLR_REG, 0);
435 mcasp_set_reg(dev->base + DAVINCI_MCASP_RXSTAT_REG, 0xFFFFFFFF);
436}
437
438static void mcasp_stop_tx(struct davinci_audio_dev *dev)
439{
440 mcasp_set_reg(dev->base + DAVINCI_MCASP_GBLCTLX_REG, 0);
441 mcasp_set_reg(dev->base + DAVINCI_MCASP_TXSTAT_REG, 0xFFFFFFFF);
442}
443
444static void davinci_mcasp_stop(struct davinci_audio_dev *dev, int stream)
445{
Chaithrika U S539d3d82009-09-23 10:12:08 -0400446 if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
Hebbar, Gururajae5ec69d2012-09-03 13:40:40 +0530447 if (dev->txnumevt) { /* disable FIFO */
448 switch (dev->version) {
449 case MCASP_VERSION_3:
450 mcasp_clr_bits(dev->base + MCASP_VER3_WFIFOCTL,
Chaithrika U S539d3d82009-09-23 10:12:08 -0400451 FIFO_ENABLE);
Hebbar, Gururajae5ec69d2012-09-03 13:40:40 +0530452 break;
453 default:
454 mcasp_clr_bits(dev->base +
455 DAVINCI_MCASP_WFIFOCTL, FIFO_ENABLE);
456 }
457 }
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400458 mcasp_stop_tx(dev);
Chaithrika U S539d3d82009-09-23 10:12:08 -0400459 } else {
Hebbar, Gururajae5ec69d2012-09-03 13:40:40 +0530460 if (dev->rxnumevt) { /* disable FIFO */
461 switch (dev->version) {
462 case MCASP_VERSION_3:
463 mcasp_clr_bits(dev->base + MCASP_VER3_RFIFOCTL,
Chaithrika U S539d3d82009-09-23 10:12:08 -0400464 FIFO_ENABLE);
Hebbar, Gururajae5ec69d2012-09-03 13:40:40 +0530465 break;
466
467 default:
468 mcasp_clr_bits(dev->base +
469 DAVINCI_MCASP_RFIFOCTL, FIFO_ENABLE);
470 }
471 }
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400472 mcasp_stop_rx(dev);
Chaithrika U S539d3d82009-09-23 10:12:08 -0400473 }
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400474}
475
476static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai,
477 unsigned int fmt)
478{
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000479 struct davinci_audio_dev *dev = snd_soc_dai_get_drvdata(cpu_dai);
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400480 void __iomem *base = dev->base;
481
Daniel Mack5296cf22012-10-04 15:08:42 +0200482 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
483 case SND_SOC_DAIFMT_DSP_B:
484 case SND_SOC_DAIFMT_AC97:
485 mcasp_clr_bits(dev->base + DAVINCI_MCASP_TXFMCTL_REG, FSXDUR);
486 mcasp_clr_bits(dev->base + DAVINCI_MCASP_RXFMCTL_REG, FSRDUR);
487 break;
488 default:
489 /* configure a full-word SYNC pulse (LRCLK) */
490 mcasp_set_bits(dev->base + DAVINCI_MCASP_TXFMCTL_REG, FSXDUR);
491 mcasp_set_bits(dev->base + DAVINCI_MCASP_RXFMCTL_REG, FSRDUR);
492
493 /* make 1st data bit occur one ACLK cycle after the frame sync */
494 mcasp_set_bits(dev->base + DAVINCI_MCASP_TXFMT_REG, FSXDLY(1));
495 mcasp_set_bits(dev->base + DAVINCI_MCASP_RXFMT_REG, FSRDLY(1));
496 break;
497 }
498
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400499 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
500 case SND_SOC_DAIFMT_CBS_CFS:
501 /* codec is clock and frame slave */
502 mcasp_set_bits(base + DAVINCI_MCASP_ACLKXCTL_REG, ACLKXE);
503 mcasp_set_bits(base + DAVINCI_MCASP_TXFMCTL_REG, AFSXE);
504
505 mcasp_set_bits(base + DAVINCI_MCASP_ACLKRCTL_REG, ACLKRE);
506 mcasp_set_bits(base + DAVINCI_MCASP_RXFMCTL_REG, AFSRE);
507
Marek Belisko81ee6832013-04-26 14:38:11 +0200508 mcasp_set_bits(base + DAVINCI_MCASP_PDIR_REG,
509 ACLKX | ACLKR);
510 mcasp_set_bits(base + DAVINCI_MCASP_PDIR_REG,
511 AFSX | AFSR);
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400512 break;
Chaithrika U S517ee6c2009-08-11 16:59:12 -0400513 case SND_SOC_DAIFMT_CBM_CFS:
514 /* codec is clock master and frame slave */
Ben Gardinera90f5492011-04-21 14:19:03 -0400515 mcasp_clr_bits(base + DAVINCI_MCASP_ACLKXCTL_REG, ACLKXE);
Chaithrika U S517ee6c2009-08-11 16:59:12 -0400516 mcasp_set_bits(base + DAVINCI_MCASP_TXFMCTL_REG, AFSXE);
517
Ben Gardinera90f5492011-04-21 14:19:03 -0400518 mcasp_clr_bits(base + DAVINCI_MCASP_ACLKRCTL_REG, ACLKRE);
Chaithrika U S517ee6c2009-08-11 16:59:12 -0400519 mcasp_set_bits(base + DAVINCI_MCASP_RXFMCTL_REG, AFSRE);
520
Ben Gardinerdb92f432011-04-21 14:19:04 -0400521 mcasp_clr_bits(base + DAVINCI_MCASP_PDIR_REG,
522 ACLKX | ACLKR);
Ben Gardiner9595c8f2011-04-21 14:19:02 -0400523 mcasp_set_bits(base + DAVINCI_MCASP_PDIR_REG,
Ben Gardinerdb92f432011-04-21 14:19:04 -0400524 AFSX | AFSR);
Chaithrika U S517ee6c2009-08-11 16:59:12 -0400525 break;
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400526 case SND_SOC_DAIFMT_CBM_CFM:
527 /* codec is clock and frame master */
528 mcasp_clr_bits(base + DAVINCI_MCASP_ACLKXCTL_REG, ACLKXE);
529 mcasp_clr_bits(base + DAVINCI_MCASP_TXFMCTL_REG, AFSXE);
530
531 mcasp_clr_bits(base + DAVINCI_MCASP_ACLKRCTL_REG, ACLKRE);
532 mcasp_clr_bits(base + DAVINCI_MCASP_RXFMCTL_REG, AFSRE);
533
Ben Gardiner9595c8f2011-04-21 14:19:02 -0400534 mcasp_clr_bits(base + DAVINCI_MCASP_PDIR_REG,
535 ACLKX | AHCLKX | AFSX | ACLKR | AHCLKR | AFSR);
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400536 break;
537
538 default:
539 return -EINVAL;
540 }
541
542 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
543 case SND_SOC_DAIFMT_IB_NF:
544 mcasp_clr_bits(base + DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL);
545 mcasp_clr_bits(base + DAVINCI_MCASP_TXFMCTL_REG, FSXPOL);
546
547 mcasp_set_bits(base + DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL);
548 mcasp_clr_bits(base + DAVINCI_MCASP_RXFMCTL_REG, FSRPOL);
549 break;
550
551 case SND_SOC_DAIFMT_NB_IF:
552 mcasp_set_bits(base + DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL);
553 mcasp_set_bits(base + DAVINCI_MCASP_TXFMCTL_REG, FSXPOL);
554
555 mcasp_clr_bits(base + DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL);
556 mcasp_set_bits(base + DAVINCI_MCASP_RXFMCTL_REG, FSRPOL);
557 break;
558
559 case SND_SOC_DAIFMT_IB_IF:
560 mcasp_clr_bits(base + DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL);
561 mcasp_set_bits(base + DAVINCI_MCASP_TXFMCTL_REG, FSXPOL);
562
563 mcasp_set_bits(base + DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL);
564 mcasp_set_bits(base + DAVINCI_MCASP_RXFMCTL_REG, FSRPOL);
565 break;
566
567 case SND_SOC_DAIFMT_NB_NF:
568 mcasp_set_bits(base + DAVINCI_MCASP_ACLKXCTL_REG, ACLKXPOL);
569 mcasp_clr_bits(base + DAVINCI_MCASP_TXFMCTL_REG, FSXPOL);
570
Marek Beliskodf4a4ee2013-05-03 07:37:36 +0200571 mcasp_set_bits(base + DAVINCI_MCASP_ACLKRCTL_REG, ACLKRPOL);
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400572 mcasp_clr_bits(base + DAVINCI_MCASP_RXFMCTL_REG, FSRPOL);
573 break;
574
575 default:
576 return -EINVAL;
577 }
578
579 return 0;
580}
581
Daniel Mack4ed8c9b2012-10-04 15:08:39 +0200582static int davinci_mcasp_set_clkdiv(struct snd_soc_dai *dai, int div_id, int div)
583{
584 struct davinci_audio_dev *dev = snd_soc_dai_get_drvdata(dai);
585
586 switch (div_id) {
587 case 0: /* MCLK divider */
588 mcasp_mod_bits(dev->base + DAVINCI_MCASP_AHCLKXCTL_REG,
589 AHCLKXDIV(div - 1), AHCLKXDIV_MASK);
590 mcasp_mod_bits(dev->base + DAVINCI_MCASP_AHCLKRCTL_REG,
591 AHCLKRDIV(div - 1), AHCLKRDIV_MASK);
592 break;
593
594 case 1: /* BCLK divider */
595 mcasp_mod_bits(dev->base + DAVINCI_MCASP_ACLKXCTL_REG,
596 ACLKXDIV(div - 1), ACLKXDIV_MASK);
597 mcasp_mod_bits(dev->base + DAVINCI_MCASP_ACLKRCTL_REG,
598 ACLKRDIV(div - 1), ACLKRDIV_MASK);
599 break;
600
Daniel Mack1b3bc062012-12-05 18:20:38 +0100601 case 2: /* BCLK/LRCLK ratio */
602 dev->bclk_lrclk_ratio = div;
603 break;
604
Daniel Mack4ed8c9b2012-10-04 15:08:39 +0200605 default:
606 return -EINVAL;
607 }
608
609 return 0;
610}
611
Daniel Mack5b66aa22012-10-04 15:08:41 +0200612static int davinci_mcasp_set_sysclk(struct snd_soc_dai *dai, int clk_id,
613 unsigned int freq, int dir)
614{
615 struct davinci_audio_dev *dev = snd_soc_dai_get_drvdata(dai);
616
617 if (dir == SND_SOC_CLOCK_OUT) {
618 mcasp_set_bits(dev->base + DAVINCI_MCASP_AHCLKXCTL_REG, AHCLKXE);
619 mcasp_set_bits(dev->base + DAVINCI_MCASP_AHCLKRCTL_REG, AHCLKRE);
620 mcasp_set_bits(dev->base + DAVINCI_MCASP_PDIR_REG, AHCLKX);
621 } else {
622 mcasp_clr_bits(dev->base + DAVINCI_MCASP_AHCLKXCTL_REG, AHCLKXE);
623 mcasp_clr_bits(dev->base + DAVINCI_MCASP_AHCLKRCTL_REG, AHCLKRE);
624 mcasp_clr_bits(dev->base + DAVINCI_MCASP_PDIR_REG, AHCLKX);
625 }
626
627 return 0;
628}
629
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400630static int davinci_config_channel_size(struct davinci_audio_dev *dev,
Daniel Mackba764b32012-12-05 18:20:37 +0100631 int word_length)
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400632{
Daniel Mackba764b32012-12-05 18:20:37 +0100633 u32 fmt;
Michal Bachratydde109f2013-01-18 10:17:00 +0100634 u32 rotate = (word_length / 4) & 0x7;
Daniel Mackba764b32012-12-05 18:20:37 +0100635 u32 mask = (1ULL << word_length) - 1;
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400636
Daniel Mack1b3bc062012-12-05 18:20:38 +0100637 /*
638 * if s BCLK-to-LRCLK ratio has been configured via the set_clkdiv()
639 * callback, take it into account here. That allows us to for example
640 * send 32 bits per channel to the codec, while only 16 of them carry
641 * audio payload.
Michal Bachratyd486fea2013-04-19 15:28:44 +0200642 * The clock ratio is given for a full period of data (for I2S format
643 * both left and right channels), so it has to be divided by number of
644 * tdm-slots (for I2S - divided by 2).
Daniel Mack1b3bc062012-12-05 18:20:38 +0100645 */
646 if (dev->bclk_lrclk_ratio)
Michal Bachratyd486fea2013-04-19 15:28:44 +0200647 word_length = dev->bclk_lrclk_ratio / dev->tdm_slots;
Daniel Mack1b3bc062012-12-05 18:20:38 +0100648
Daniel Mackba764b32012-12-05 18:20:37 +0100649 /* mapping of the XSSZ bit-field as described in the datasheet */
650 fmt = (word_length >> 1) - 1;
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400651
Yegor Yefremovf5023af2013-04-04 16:13:20 +0200652 if (dev->op_mode != DAVINCI_MCASP_DIT_MODE) {
653 mcasp_mod_bits(dev->base + DAVINCI_MCASP_RXFMT_REG,
654 RXSSZ(fmt), RXSSZ(0x0F));
655 mcasp_mod_bits(dev->base + DAVINCI_MCASP_TXFMT_REG,
656 TXSSZ(fmt), TXSSZ(0x0F));
657 mcasp_mod_bits(dev->base + DAVINCI_MCASP_TXFMT_REG,
658 TXROT(rotate), TXROT(7));
659 mcasp_mod_bits(dev->base + DAVINCI_MCASP_RXFMT_REG,
660 RXROT(rotate), RXROT(7));
661 mcasp_set_reg(dev->base + DAVINCI_MCASP_RXMASK_REG,
662 mask);
663 }
664
Chaithrika U S0c31cf32009-09-15 18:13:29 -0400665 mcasp_set_reg(dev->base + DAVINCI_MCASP_TXMASK_REG, mask);
Chaithrika U S0c31cf32009-09-15 18:13:29 -0400666
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400667 return 0;
668}
669
Michal Bachraty2952b272013-02-28 16:07:08 +0100670static int davinci_hw_common_param(struct davinci_audio_dev *dev, int stream,
671 int channels)
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400672{
673 int i;
Chaithrika U S6a99fb52009-08-11 16:58:52 -0400674 u8 tx_ser = 0;
675 u8 rx_ser = 0;
Michal Bachraty2952b272013-02-28 16:07:08 +0100676 u8 ser;
677 u8 slots = dev->tdm_slots;
678 u8 max_active_serializers = (channels + slots - 1) / slots;
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400679 /* Default configuration */
680 mcasp_set_bits(dev->base + DAVINCI_MCASP_PWREMUMGT_REG, MCASP_SOFT);
681
682 /* All PINS as McASP */
683 mcasp_set_reg(dev->base + DAVINCI_MCASP_PFUNC_REG, 0x00000000);
684
685 if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
686 mcasp_set_reg(dev->base + DAVINCI_MCASP_TXSTAT_REG, 0xFFFFFFFF);
687 mcasp_clr_bits(dev->base + DAVINCI_MCASP_XEVTCTL_REG,
688 TXDATADMADIS);
689 } else {
690 mcasp_set_reg(dev->base + DAVINCI_MCASP_RXSTAT_REG, 0xFFFFFFFF);
691 mcasp_clr_bits(dev->base + DAVINCI_MCASP_REVTCTL_REG,
692 RXDATADMADIS);
693 }
694
695 for (i = 0; i < dev->num_serializer; i++) {
696 mcasp_set_bits(dev->base + DAVINCI_MCASP_XRSRCTL_REG(i),
697 dev->serial_dir[i]);
Michal Bachraty2952b272013-02-28 16:07:08 +0100698 if (dev->serial_dir[i] == TX_MODE &&
699 tx_ser < max_active_serializers) {
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400700 mcasp_set_bits(dev->base + DAVINCI_MCASP_PDIR_REG,
701 AXR(i));
Chaithrika U S6a99fb52009-08-11 16:58:52 -0400702 tx_ser++;
Michal Bachraty2952b272013-02-28 16:07:08 +0100703 } else if (dev->serial_dir[i] == RX_MODE &&
704 rx_ser < max_active_serializers) {
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400705 mcasp_clr_bits(dev->base + DAVINCI_MCASP_PDIR_REG,
706 AXR(i));
Chaithrika U S6a99fb52009-08-11 16:58:52 -0400707 rx_ser++;
Michal Bachraty2952b272013-02-28 16:07:08 +0100708 } else {
709 mcasp_mod_bits(dev->base + DAVINCI_MCASP_XRSRCTL_REG(i),
710 SRMOD_INACTIVE, SRMOD_MASK);
Chaithrika U S6a99fb52009-08-11 16:58:52 -0400711 }
712 }
713
Daniel Mackecf327c2013-03-08 14:19:38 +0100714 if (stream == SNDRV_PCM_STREAM_PLAYBACK)
715 ser = tx_ser;
716 else
717 ser = rx_ser;
718
719 if (ser < max_active_serializers) {
720 dev_warn(dev->dev, "stream has more channels (%d) than are "
721 "enabled in mcasp (%d)\n", channels, ser * slots);
722 return -EINVAL;
723 }
724
Chaithrika U S6a99fb52009-08-11 16:58:52 -0400725 if (dev->txnumevt && stream == SNDRV_PCM_STREAM_PLAYBACK) {
726 if (dev->txnumevt * tx_ser > 64)
727 dev->txnumevt = 1;
728
Hebbar, Gururajae5ec69d2012-09-03 13:40:40 +0530729 switch (dev->version) {
730 case MCASP_VERSION_3:
731 mcasp_mod_bits(dev->base + MCASP_VER3_WFIFOCTL, tx_ser,
Chaithrika U S6a99fb52009-08-11 16:58:52 -0400732 NUMDMA_MASK);
Hebbar, Gururajae5ec69d2012-09-03 13:40:40 +0530733 mcasp_mod_bits(dev->base + MCASP_VER3_WFIFOCTL,
Chaithrika U S6a99fb52009-08-11 16:58:52 -0400734 ((dev->txnumevt * tx_ser) << 8), NUMEVT_MASK);
Hebbar, Gururajae5ec69d2012-09-03 13:40:40 +0530735 break;
736 default:
737 mcasp_mod_bits(dev->base + DAVINCI_MCASP_WFIFOCTL,
738 tx_ser, NUMDMA_MASK);
739 mcasp_mod_bits(dev->base + DAVINCI_MCASP_WFIFOCTL,
740 ((dev->txnumevt * tx_ser) << 8), NUMEVT_MASK);
741 }
Chaithrika U S6a99fb52009-08-11 16:58:52 -0400742 }
743
744 if (dev->rxnumevt && stream == SNDRV_PCM_STREAM_CAPTURE) {
745 if (dev->rxnumevt * rx_ser > 64)
746 dev->rxnumevt = 1;
Hebbar, Gururajae5ec69d2012-09-03 13:40:40 +0530747 switch (dev->version) {
748 case MCASP_VERSION_3:
749 mcasp_mod_bits(dev->base + MCASP_VER3_RFIFOCTL, rx_ser,
Chaithrika U S6a99fb52009-08-11 16:58:52 -0400750 NUMDMA_MASK);
Hebbar, Gururajae5ec69d2012-09-03 13:40:40 +0530751 mcasp_mod_bits(dev->base + MCASP_VER3_RFIFOCTL,
Chaithrika U S6a99fb52009-08-11 16:58:52 -0400752 ((dev->rxnumevt * rx_ser) << 8), NUMEVT_MASK);
Hebbar, Gururajae5ec69d2012-09-03 13:40:40 +0530753 break;
754 default:
755 mcasp_mod_bits(dev->base + DAVINCI_MCASP_RFIFOCTL,
756 rx_ser, NUMDMA_MASK);
757 mcasp_mod_bits(dev->base + DAVINCI_MCASP_RFIFOCTL,
758 ((dev->rxnumevt * rx_ser) << 8), NUMEVT_MASK);
759 }
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400760 }
Michal Bachraty2952b272013-02-28 16:07:08 +0100761
762 return 0;
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400763}
764
765static void davinci_hw_param(struct davinci_audio_dev *dev, int stream)
766{
767 int i, active_slots;
768 u32 mask = 0;
769
770 active_slots = (dev->tdm_slots > 31) ? 32 : dev->tdm_slots;
771 for (i = 0; i < active_slots; i++)
772 mask |= (1 << i);
773
Chaithrika U S6a99fb52009-08-11 16:58:52 -0400774 mcasp_clr_bits(dev->base + DAVINCI_MCASP_ACLKXCTL_REG, TX_ASYNC);
775
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400776 if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
777 /* bit stream is MSB first with no delay */
778 /* DSP_B mode */
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400779 mcasp_set_reg(dev->base + DAVINCI_MCASP_TXTDM_REG, mask);
780 mcasp_set_bits(dev->base + DAVINCI_MCASP_TXFMT_REG, TXORD);
781
Ben Gardiner049cfaa2011-04-21 14:19:01 -0400782 if ((dev->tdm_slots >= 2) && (dev->tdm_slots <= 32))
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400783 mcasp_mod_bits(dev->base + DAVINCI_MCASP_TXFMCTL_REG,
784 FSXMOD(dev->tdm_slots), FSXMOD(0x1FF));
785 else
786 printk(KERN_ERR "playback tdm slot %d not supported\n",
787 dev->tdm_slots);
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400788 } else {
789 /* bit stream is MSB first with no delay */
790 /* DSP_B mode */
791 mcasp_set_bits(dev->base + DAVINCI_MCASP_RXFMT_REG, RXORD);
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400792 mcasp_set_reg(dev->base + DAVINCI_MCASP_RXTDM_REG, mask);
793
Ben Gardiner049cfaa2011-04-21 14:19:01 -0400794 if ((dev->tdm_slots >= 2) && (dev->tdm_slots <= 32))
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400795 mcasp_mod_bits(dev->base + DAVINCI_MCASP_RXFMCTL_REG,
796 FSRMOD(dev->tdm_slots), FSRMOD(0x1FF));
797 else
798 printk(KERN_ERR "capture tdm slot %d not supported\n",
799 dev->tdm_slots);
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400800 }
801}
802
803/* S/PDIF */
804static void davinci_hw_dit_param(struct davinci_audio_dev *dev)
805{
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400806 /* Set the TX format : 24 bit right rotation, 32 bit slot, Pad 0
807 and LSB first */
808 mcasp_set_bits(dev->base + DAVINCI_MCASP_TXFMT_REG,
809 TXROT(6) | TXSSZ(15));
810
811 /* Set TX frame synch : DIT Mode, 1 bit width, internal, rising edge */
812 mcasp_set_reg(dev->base + DAVINCI_MCASP_TXFMCTL_REG,
813 AFSXE | FSXMOD(0x180));
814
815 /* Set the TX tdm : for all the slots */
816 mcasp_set_reg(dev->base + DAVINCI_MCASP_TXTDM_REG, 0xFFFFFFFF);
817
818 /* Set the TX clock controls : div = 1 and internal */
819 mcasp_set_bits(dev->base + DAVINCI_MCASP_ACLKXCTL_REG,
820 ACLKXE | TX_ASYNC);
821
822 mcasp_clr_bits(dev->base + DAVINCI_MCASP_XEVTCTL_REG, TXDATADMADIS);
823
824 /* Only 44100 and 48000 are valid, both have the same setting */
825 mcasp_set_bits(dev->base + DAVINCI_MCASP_AHCLKXCTL_REG, AHCLKXDIV(3));
826
827 /* Enable the DIT */
828 mcasp_set_bits(dev->base + DAVINCI_MCASP_TXDITCTL_REG, DITEN);
829}
830
831static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream,
832 struct snd_pcm_hw_params *params,
833 struct snd_soc_dai *cpu_dai)
834{
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000835 struct davinci_audio_dev *dev = snd_soc_dai_get_drvdata(cpu_dai);
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400836 struct davinci_pcm_dma_params *dma_params =
Troy Kisky92e2a6f2009-09-11 14:29:03 -0700837 &dev->dma_params[substream->stream];
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400838 int word_length;
Chaithrika U S4fa9c1a2009-09-30 17:32:27 -0400839 u8 fifo_level;
Michal Bachraty2952b272013-02-28 16:07:08 +0100840 u8 slots = dev->tdm_slots;
Michal Bachraty7c21a782013-04-19 15:28:03 +0200841 u8 active_serializers;
Michal Bachraty2952b272013-02-28 16:07:08 +0100842 int channels;
843 struct snd_interval *pcm_channels = hw_param_interval(params,
844 SNDRV_PCM_HW_PARAM_CHANNELS);
845 channels = pcm_channels->min;
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400846
Michal Bachraty7c21a782013-04-19 15:28:03 +0200847 active_serializers = (channels + slots - 1) / slots;
848
Michal Bachraty2952b272013-02-28 16:07:08 +0100849 if (davinci_hw_common_param(dev, substream->stream, channels) == -EINVAL)
850 return -EINVAL;
Chaithrika U S6a99fb52009-08-11 16:58:52 -0400851 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
Michal Bachraty7c21a782013-04-19 15:28:03 +0200852 fifo_level = dev->txnumevt * active_serializers;
Chaithrika U S6a99fb52009-08-11 16:58:52 -0400853 else
Michal Bachraty7c21a782013-04-19 15:28:03 +0200854 fifo_level = dev->rxnumevt * active_serializers;
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400855
856 if (dev->op_mode == DAVINCI_MCASP_DIT_MODE)
857 davinci_hw_dit_param(dev);
858 else
859 davinci_hw_param(dev, substream->stream);
860
861 switch (params_format(params)) {
Ben Gardiner0a9d1382011-08-26 12:02:44 -0400862 case SNDRV_PCM_FORMAT_U8:
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400863 case SNDRV_PCM_FORMAT_S8:
864 dma_params->data_type = 1;
Daniel Mackba764b32012-12-05 18:20:37 +0100865 word_length = 8;
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400866 break;
867
Ben Gardiner0a9d1382011-08-26 12:02:44 -0400868 case SNDRV_PCM_FORMAT_U16_LE:
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400869 case SNDRV_PCM_FORMAT_S16_LE:
870 dma_params->data_type = 2;
Daniel Mackba764b32012-12-05 18:20:37 +0100871 word_length = 16;
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400872 break;
873
Daniel Mack21eb24d2012-10-09 09:35:16 +0200874 case SNDRV_PCM_FORMAT_U24_3LE:
875 case SNDRV_PCM_FORMAT_S24_3LE:
Daniel Mack21eb24d2012-10-09 09:35:16 +0200876 dma_params->data_type = 3;
Daniel Mackba764b32012-12-05 18:20:37 +0100877 word_length = 24;
Daniel Mack21eb24d2012-10-09 09:35:16 +0200878 break;
879
Daniel Mack6b7fa012012-10-09 11:56:40 +0200880 case SNDRV_PCM_FORMAT_U24_LE:
881 case SNDRV_PCM_FORMAT_S24_LE:
Ben Gardiner0a9d1382011-08-26 12:02:44 -0400882 case SNDRV_PCM_FORMAT_U32_LE:
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400883 case SNDRV_PCM_FORMAT_S32_LE:
884 dma_params->data_type = 4;
Daniel Mackba764b32012-12-05 18:20:37 +0100885 word_length = 32;
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400886 break;
887
888 default:
889 printk(KERN_WARNING "davinci-mcasp: unsupported PCM format");
890 return -EINVAL;
891 }
Chaithrika U S6a99fb52009-08-11 16:58:52 -0400892
Chaithrika U S4fa9c1a2009-09-30 17:32:27 -0400893 if (dev->version == MCASP_VERSION_2 && !fifo_level)
894 dma_params->acnt = 4;
895 else
Chaithrika U S6a99fb52009-08-11 16:58:52 -0400896 dma_params->acnt = dma_params->data_type;
897
Chaithrika U S4fa9c1a2009-09-30 17:32:27 -0400898 dma_params->fifo_level = fifo_level;
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400899 davinci_config_channel_size(dev, word_length);
900
901 return 0;
902}
903
904static int davinci_mcasp_trigger(struct snd_pcm_substream *substream,
905 int cmd, struct snd_soc_dai *cpu_dai)
906{
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000907 struct davinci_audio_dev *dev = snd_soc_dai_get_drvdata(cpu_dai);
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400908 int ret = 0;
909
910 switch (cmd) {
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400911 case SNDRV_PCM_TRIGGER_RESUME:
Chaithrika U Se473b842010-01-20 17:06:33 +0530912 case SNDRV_PCM_TRIGGER_START:
913 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
Hebbar, Gururaja10884342012-08-08 20:40:32 +0530914 ret = pm_runtime_get_sync(dev->dev);
915 if (IS_ERR_VALUE(ret))
916 dev_err(dev->dev, "pm_runtime_get_sync() failed\n");
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400917 davinci_mcasp_start(dev, substream->stream);
918 break;
919
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400920 case SNDRV_PCM_TRIGGER_SUSPEND:
Chaithrika U Sa47979b2009-12-03 18:56:56 +0530921 davinci_mcasp_stop(dev, substream->stream);
Hebbar, Gururaja10884342012-08-08 20:40:32 +0530922 ret = pm_runtime_put_sync(dev->dev);
923 if (IS_ERR_VALUE(ret))
924 dev_err(dev->dev, "pm_runtime_put_sync() failed\n");
Chaithrika U Sa47979b2009-12-03 18:56:56 +0530925 break;
926
927 case SNDRV_PCM_TRIGGER_STOP:
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400928 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
929 davinci_mcasp_stop(dev, substream->stream);
930 break;
931
932 default:
933 ret = -EINVAL;
934 }
935
936 return ret;
937}
938
Chris Paulson-Ellisbedad0c2010-11-16 12:27:09 +0000939static int davinci_mcasp_startup(struct snd_pcm_substream *substream,
940 struct snd_soc_dai *dai)
941{
942 struct davinci_audio_dev *dev = snd_soc_dai_get_drvdata(dai);
943
944 snd_soc_dai_set_dma_data(dai, substream, dev->dma_params);
945 return 0;
946}
947
Lars-Peter Clausen85e76522011-11-23 11:40:40 +0100948static const struct snd_soc_dai_ops davinci_mcasp_dai_ops = {
Chris Paulson-Ellisbedad0c2010-11-16 12:27:09 +0000949 .startup = davinci_mcasp_startup,
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400950 .trigger = davinci_mcasp_trigger,
951 .hw_params = davinci_mcasp_hw_params,
952 .set_fmt = davinci_mcasp_set_dai_fmt,
Daniel Mack4ed8c9b2012-10-04 15:08:39 +0200953 .set_clkdiv = davinci_mcasp_set_clkdiv,
Daniel Mack5b66aa22012-10-04 15:08:41 +0200954 .set_sysclk = davinci_mcasp_set_sysclk,
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400955};
956
Ben Gardiner0a9d1382011-08-26 12:02:44 -0400957#define DAVINCI_MCASP_PCM_FMTS (SNDRV_PCM_FMTBIT_S8 | \
958 SNDRV_PCM_FMTBIT_U8 | \
959 SNDRV_PCM_FMTBIT_S16_LE | \
960 SNDRV_PCM_FMTBIT_U16_LE | \
Daniel Mack21eb24d2012-10-09 09:35:16 +0200961 SNDRV_PCM_FMTBIT_S24_LE | \
962 SNDRV_PCM_FMTBIT_U24_LE | \
963 SNDRV_PCM_FMTBIT_S24_3LE | \
964 SNDRV_PCM_FMTBIT_U24_3LE | \
Ben Gardiner0a9d1382011-08-26 12:02:44 -0400965 SNDRV_PCM_FMTBIT_S32_LE | \
966 SNDRV_PCM_FMTBIT_U32_LE)
967
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000968static struct snd_soc_dai_driver davinci_mcasp_dai[] = {
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400969 {
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000970 .name = "davinci-mcasp.0",
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400971 .playback = {
972 .channels_min = 2,
Michal Bachraty2952b272013-02-28 16:07:08 +0100973 .channels_max = 32 * 16,
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400974 .rates = DAVINCI_MCASP_RATES,
Ben Gardiner0a9d1382011-08-26 12:02:44 -0400975 .formats = DAVINCI_MCASP_PCM_FMTS,
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400976 },
977 .capture = {
978 .channels_min = 2,
Michal Bachraty2952b272013-02-28 16:07:08 +0100979 .channels_max = 32 * 16,
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400980 .rates = DAVINCI_MCASP_RATES,
Ben Gardiner0a9d1382011-08-26 12:02:44 -0400981 .formats = DAVINCI_MCASP_PCM_FMTS,
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400982 },
983 .ops = &davinci_mcasp_dai_ops,
984
985 },
986 {
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000987 "davinci-mcasp.1",
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400988 .playback = {
989 .channels_min = 1,
990 .channels_max = 384,
991 .rates = DAVINCI_MCASP_RATES,
Ben Gardiner0a9d1382011-08-26 12:02:44 -0400992 .formats = DAVINCI_MCASP_PCM_FMTS,
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400993 },
994 .ops = &davinci_mcasp_dai_ops,
995 },
996
997};
Chaithrika U Sb67f4482009-06-05 06:28:40 -0400998
Kuninori Morimotoeeef0ed2013-03-21 03:31:19 -0700999static const struct snd_soc_component_driver davinci_mcasp_component = {
1000 .name = "davinci-mcasp",
1001};
1002
Hebbar, Gururaja3e3b8c32012-08-27 18:56:42 +05301003static const struct of_device_id mcasp_dt_ids[] = {
1004 {
1005 .compatible = "ti,dm646x-mcasp-audio",
1006 .data = (void *)MCASP_VERSION_1,
1007 },
1008 {
1009 .compatible = "ti,da830-mcasp-audio",
1010 .data = (void *)MCASP_VERSION_2,
1011 },
Hebbar, Gururajae5ec69d2012-09-03 13:40:40 +05301012 {
1013 .compatible = "ti,omap2-mcasp-audio",
1014 .data = (void *)MCASP_VERSION_3,
1015 },
Hebbar, Gururaja3e3b8c32012-08-27 18:56:42 +05301016 { /* sentinel */ }
1017};
1018MODULE_DEVICE_TABLE(of, mcasp_dt_ids);
1019
1020static struct snd_platform_data *davinci_mcasp_set_pdata_from_of(
1021 struct platform_device *pdev)
1022{
1023 struct device_node *np = pdev->dev.of_node;
1024 struct snd_platform_data *pdata = NULL;
1025 const struct of_device_id *match =
Sachin Kamatea421eb2013-05-22 16:53:37 +05301026 of_match_device(mcasp_dt_ids, &pdev->dev);
Hebbar, Gururaja3e3b8c32012-08-27 18:56:42 +05301027
1028 const u32 *of_serial_dir32;
1029 u8 *of_serial_dir;
1030 u32 val;
1031 int i, ret = 0;
1032
1033 if (pdev->dev.platform_data) {
1034 pdata = pdev->dev.platform_data;
1035 return pdata;
1036 } else if (match) {
1037 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
1038 if (!pdata) {
1039 ret = -ENOMEM;
1040 goto nodata;
1041 }
1042 } else {
1043 /* control shouldn't reach here. something is wrong */
1044 ret = -EINVAL;
1045 goto nodata;
1046 }
1047
1048 if (match->data)
1049 pdata->version = (u8)((int)match->data);
1050
1051 ret = of_property_read_u32(np, "op-mode", &val);
1052 if (ret >= 0)
1053 pdata->op_mode = val;
1054
1055 ret = of_property_read_u32(np, "tdm-slots", &val);
Michal Bachraty2952b272013-02-28 16:07:08 +01001056 if (ret >= 0) {
1057 if (val < 2 || val > 32) {
1058 dev_err(&pdev->dev,
1059 "tdm-slots must be in rage [2-32]\n");
1060 ret = -EINVAL;
1061 goto nodata;
1062 }
1063
Hebbar, Gururaja3e3b8c32012-08-27 18:56:42 +05301064 pdata->tdm_slots = val;
Michal Bachraty2952b272013-02-28 16:07:08 +01001065 }
Hebbar, Gururaja3e3b8c32012-08-27 18:56:42 +05301066
1067 ret = of_property_read_u32(np, "num-serializer", &val);
1068 if (ret >= 0)
1069 pdata->num_serializer = val;
1070
1071 of_serial_dir32 = of_get_property(np, "serial-dir", &val);
1072 val /= sizeof(u32);
1073 if (val != pdata->num_serializer) {
1074 dev_err(&pdev->dev,
1075 "num-serializer(%d) != serial-dir size(%d)\n",
1076 pdata->num_serializer, val);
1077 ret = -EINVAL;
1078 goto nodata;
1079 }
1080
1081 if (of_serial_dir32) {
1082 of_serial_dir = devm_kzalloc(&pdev->dev,
1083 (sizeof(*of_serial_dir) * val),
1084 GFP_KERNEL);
1085 if (!of_serial_dir) {
1086 ret = -ENOMEM;
1087 goto nodata;
1088 }
1089
1090 for (i = 0; i < pdata->num_serializer; i++)
1091 of_serial_dir[i] = be32_to_cpup(&of_serial_dir32[i]);
1092
1093 pdata->serial_dir = of_serial_dir;
1094 }
1095
1096 ret = of_property_read_u32(np, "tx-num-evt", &val);
1097 if (ret >= 0)
1098 pdata->txnumevt = val;
1099
1100 ret = of_property_read_u32(np, "rx-num-evt", &val);
1101 if (ret >= 0)
1102 pdata->rxnumevt = val;
1103
1104 ret = of_property_read_u32(np, "sram-size-playback", &val);
1105 if (ret >= 0)
1106 pdata->sram_size_playback = val;
1107
1108 ret = of_property_read_u32(np, "sram-size-capture", &val);
1109 if (ret >= 0)
1110 pdata->sram_size_capture = val;
1111
1112 return pdata;
1113
1114nodata:
1115 if (ret < 0) {
1116 dev_err(&pdev->dev, "Error populating platform data, err %d\n",
1117 ret);
1118 pdata = NULL;
1119 }
1120 return pdata;
1121}
1122
Chaithrika U Sb67f4482009-06-05 06:28:40 -04001123static int davinci_mcasp_probe(struct platform_device *pdev)
1124{
1125 struct davinci_pcm_dma_params *dma_data;
1126 struct resource *mem, *ioarea, *res;
1127 struct snd_platform_data *pdata;
1128 struct davinci_audio_dev *dev;
Julia Lawall96d31e22011-12-29 17:51:21 +01001129 int ret;
Chaithrika U Sb67f4482009-06-05 06:28:40 -04001130
Hebbar, Gururaja3e3b8c32012-08-27 18:56:42 +05301131 if (!pdev->dev.platform_data && !pdev->dev.of_node) {
1132 dev_err(&pdev->dev, "No platform data supplied\n");
1133 return -EINVAL;
1134 }
1135
Julia Lawall96d31e22011-12-29 17:51:21 +01001136 dev = devm_kzalloc(&pdev->dev, sizeof(struct davinci_audio_dev),
1137 GFP_KERNEL);
Chaithrika U Sb67f4482009-06-05 06:28:40 -04001138 if (!dev)
1139 return -ENOMEM;
1140
Hebbar, Gururaja3e3b8c32012-08-27 18:56:42 +05301141 pdata = davinci_mcasp_set_pdata_from_of(pdev);
1142 if (!pdata) {
1143 dev_err(&pdev->dev, "no platform data\n");
1144 return -EINVAL;
1145 }
1146
Chaithrika U Sb67f4482009-06-05 06:28:40 -04001147 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1148 if (!mem) {
1149 dev_err(&pdev->dev, "no mem resource?\n");
Julia Lawall96d31e22011-12-29 17:51:21 +01001150 return -ENODEV;
Chaithrika U Sb67f4482009-06-05 06:28:40 -04001151 }
1152
Julia Lawall96d31e22011-12-29 17:51:21 +01001153 ioarea = devm_request_mem_region(&pdev->dev, mem->start,
Vaibhav Bediad852f4462011-02-09 18:39:52 +05301154 resource_size(mem), pdev->name);
Chaithrika U Sb67f4482009-06-05 06:28:40 -04001155 if (!ioarea) {
1156 dev_err(&pdev->dev, "Audio region already claimed\n");
Julia Lawall96d31e22011-12-29 17:51:21 +01001157 return -EBUSY;
Chaithrika U Sb67f4482009-06-05 06:28:40 -04001158 }
1159
Hebbar, Gururaja10884342012-08-08 20:40:32 +05301160 pm_runtime_enable(&pdev->dev);
Chaithrika U Sb67f4482009-06-05 06:28:40 -04001161
Hebbar, Gururaja10884342012-08-08 20:40:32 +05301162 ret = pm_runtime_get_sync(&pdev->dev);
1163 if (IS_ERR_VALUE(ret)) {
1164 dev_err(&pdev->dev, "pm_runtime_get_sync() failed\n");
1165 return ret;
1166 }
Chaithrika U Sb67f4482009-06-05 06:28:40 -04001167
Julia Lawall96d31e22011-12-29 17:51:21 +01001168 dev->base = devm_ioremap(&pdev->dev, mem->start, resource_size(mem));
Vaibhav Bedia4f82f022011-02-09 18:39:54 +05301169 if (!dev->base) {
1170 dev_err(&pdev->dev, "ioremap failed\n");
1171 ret = -ENOMEM;
1172 goto err_release_clk;
1173 }
1174
Chaithrika U Sb67f4482009-06-05 06:28:40 -04001175 dev->op_mode = pdata->op_mode;
1176 dev->tdm_slots = pdata->tdm_slots;
1177 dev->num_serializer = pdata->num_serializer;
1178 dev->serial_dir = pdata->serial_dir;
Chaithrika U S6a99fb52009-08-11 16:58:52 -04001179 dev->version = pdata->version;
1180 dev->txnumevt = pdata->txnumevt;
1181 dev->rxnumevt = pdata->rxnumevt;
Hebbar, Gururaja10884342012-08-08 20:40:32 +05301182 dev->dev = &pdev->dev;
Chaithrika U Sb67f4482009-06-05 06:28:40 -04001183
Troy Kisky92e2a6f2009-09-11 14:29:03 -07001184 dma_data = &dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK];
Sekhar Nori48519f02010-07-19 12:31:16 +05301185 dma_data->asp_chan_q = pdata->asp_chan_q;
1186 dma_data->ram_chan_q = pdata->ram_chan_q;
Matt Porterb8ec56d2012-10-17 16:08:03 +02001187 dma_data->sram_pool = pdata->sram_pool;
Ben Gardinera0c83262011-05-18 09:27:45 -04001188 dma_data->sram_size = pdata->sram_size_playback;
Troy Kisky92e2a6f2009-09-11 14:29:03 -07001189 dma_data->dma_addr = (dma_addr_t) (pdata->tx_dma_offset +
Vaibhav Bedia4f82f022011-02-09 18:39:54 +05301190 mem->start);
Chaithrika U Sb67f4482009-06-05 06:28:40 -04001191
1192 /* first TX, then RX */
1193 res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
1194 if (!res) {
1195 dev_err(&pdev->dev, "no DMA resource\n");
Julia Lawall02ffc5f2010-10-18 16:11:13 +02001196 ret = -ENODEV;
Julia Lawall96d31e22011-12-29 17:51:21 +01001197 goto err_release_clk;
Chaithrika U Sb67f4482009-06-05 06:28:40 -04001198 }
1199
Troy Kisky92e2a6f2009-09-11 14:29:03 -07001200 dma_data->channel = res->start;
1201
1202 dma_data = &dev->dma_params[SNDRV_PCM_STREAM_CAPTURE];
Sekhar Nori48519f02010-07-19 12:31:16 +05301203 dma_data->asp_chan_q = pdata->asp_chan_q;
1204 dma_data->ram_chan_q = pdata->ram_chan_q;
Matt Porterb8ec56d2012-10-17 16:08:03 +02001205 dma_data->sram_pool = pdata->sram_pool;
Ben Gardinera0c83262011-05-18 09:27:45 -04001206 dma_data->sram_size = pdata->sram_size_capture;
Troy Kisky92e2a6f2009-09-11 14:29:03 -07001207 dma_data->dma_addr = (dma_addr_t)(pdata->rx_dma_offset +
Vaibhav Bedia4f82f022011-02-09 18:39:54 +05301208 mem->start);
Chaithrika U Sb67f4482009-06-05 06:28:40 -04001209
1210 res = platform_get_resource(pdev, IORESOURCE_DMA, 1);
1211 if (!res) {
1212 dev_err(&pdev->dev, "no DMA resource\n");
Julia Lawall02ffc5f2010-10-18 16:11:13 +02001213 ret = -ENODEV;
Julia Lawall96d31e22011-12-29 17:51:21 +01001214 goto err_release_clk;
Chaithrika U Sb67f4482009-06-05 06:28:40 -04001215 }
1216
Troy Kisky92e2a6f2009-09-11 14:29:03 -07001217 dma_data->channel = res->start;
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +00001218 dev_set_drvdata(&pdev->dev, dev);
Kuninori Morimotoeeef0ed2013-03-21 03:31:19 -07001219 ret = snd_soc_register_component(&pdev->dev, &davinci_mcasp_component,
1220 &davinci_mcasp_dai[pdata->op_mode], 1);
Chaithrika U Sb67f4482009-06-05 06:28:40 -04001221
1222 if (ret != 0)
Julia Lawall96d31e22011-12-29 17:51:21 +01001223 goto err_release_clk;
Hebbar, Gururajaf08095a2012-08-27 18:56:39 +05301224
1225 ret = davinci_soc_platform_register(&pdev->dev);
1226 if (ret) {
1227 dev_err(&pdev->dev, "register PCM failed: %d\n", ret);
Kuninori Morimotoeeef0ed2013-03-21 03:31:19 -07001228 goto err_unregister_component;
Hebbar, Gururajaf08095a2012-08-27 18:56:39 +05301229 }
1230
Chaithrika U Sb67f4482009-06-05 06:28:40 -04001231 return 0;
1232
Kuninori Morimotoeeef0ed2013-03-21 03:31:19 -07001233err_unregister_component:
1234 snd_soc_unregister_component(&pdev->dev);
Vaibhav Bediaeef6d7b2011-02-09 18:39:53 +05301235err_release_clk:
Hebbar, Gururaja10884342012-08-08 20:40:32 +05301236 pm_runtime_put_sync(&pdev->dev);
1237 pm_runtime_disable(&pdev->dev);
Chaithrika U Sb67f4482009-06-05 06:28:40 -04001238 return ret;
1239}
1240
1241static int davinci_mcasp_remove(struct platform_device *pdev)
1242{
Chaithrika U Sb67f4482009-06-05 06:28:40 -04001243
Kuninori Morimotoeeef0ed2013-03-21 03:31:19 -07001244 snd_soc_unregister_component(&pdev->dev);
Hebbar, Gururajaf08095a2012-08-27 18:56:39 +05301245 davinci_soc_platform_unregister(&pdev->dev);
Hebbar, Gururaja10884342012-08-08 20:40:32 +05301246
1247 pm_runtime_put_sync(&pdev->dev);
1248 pm_runtime_disable(&pdev->dev);
Chaithrika U Sb67f4482009-06-05 06:28:40 -04001249
Chaithrika U Sb67f4482009-06-05 06:28:40 -04001250 return 0;
1251}
1252
1253static struct platform_driver davinci_mcasp_driver = {
1254 .probe = davinci_mcasp_probe,
1255 .remove = davinci_mcasp_remove,
1256 .driver = {
1257 .name = "davinci-mcasp",
1258 .owner = THIS_MODULE,
Sachin Kamatea421eb2013-05-22 16:53:37 +05301259 .of_match_table = mcasp_dt_ids,
Chaithrika U Sb67f4482009-06-05 06:28:40 -04001260 },
1261};
1262
Axel Linf9b8a512011-11-25 10:09:27 +08001263module_platform_driver(davinci_mcasp_driver);
Chaithrika U Sb67f4482009-06-05 06:28:40 -04001264
1265MODULE_AUTHOR("Steve Chen");
1266MODULE_DESCRIPTION("TI DAVINCI McASP SoC Interface");
1267MODULE_LICENSE("GPL");
1268