blob: f084b6acfbf2e99a1641df28c81dfea2a09de905 [file] [log] [blame]
Russell Kinga09e64f2008-08-05 16:14:15 +01001/*
2 * arch/arm/plat-omap/include/mach/mcbsp.h
3 *
4 * Defines for Multi-Channel Buffered Serial Port
5 *
6 * Copyright (C) 2002 RidgeRun, Inc.
7 * Author: Steve Johnson
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 */
24#ifndef __ASM_ARCH_OMAP_MCBSP_H
25#define __ASM_ARCH_OMAP_MCBSP_H
26
27#include <linux/completion.h>
28#include <linux/spinlock.h>
29
30#include <mach/hardware.h>
Tony Lindgrence491cf2009-10-20 09:40:47 -070031#include <plat/clock.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010032
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000033/* macro for building platform_device for McBSP ports */
34#define OMAP_MCBSP_PLATFORM_DEVICE(port_nr) \
35static struct platform_device omap_mcbsp##port_nr = { \
36 .name = "omap-mcbsp-dai", \
37 .id = OMAP_MCBSP##port_nr, \
38}
39
Charulatha V37801b32011-02-24 12:51:46 -080040#define MCBSP_CONFIG_TYPE2 0x2
Charulatha Vdc48e5f2011-02-24 15:16:49 +053041#define MCBSP_CONFIG_TYPE3 0x3
Charulatha V37801b32011-02-24 12:51:46 -080042
Alistair Buxton7c006922009-09-22 10:02:58 +010043#define OMAP7XX_MCBSP1_BASE 0xfffb1000
44#define OMAP7XX_MCBSP2_BASE 0xfffb1800
Russell Kinga09e64f2008-08-05 16:14:15 +010045
46#define OMAP1510_MCBSP1_BASE 0xe1011800
47#define OMAP1510_MCBSP2_BASE 0xfffb1000
48#define OMAP1510_MCBSP3_BASE 0xe1017000
49
50#define OMAP1610_MCBSP1_BASE 0xe1011800
51#define OMAP1610_MCBSP2_BASE 0xfffb1000
52#define OMAP1610_MCBSP3_BASE 0xe1017000
53
54#define OMAP24XX_MCBSP1_BASE 0x48074000
55#define OMAP24XX_MCBSP2_BASE 0x48076000
Jarkko Nikula05228c32008-10-08 10:01:40 +030056#define OMAP2430_MCBSP3_BASE 0x4808c000
57#define OMAP2430_MCBSP4_BASE 0x4808e000
58#define OMAP2430_MCBSP5_BASE 0x48096000
Russell Kinga09e64f2008-08-05 16:14:15 +010059
60#define OMAP34XX_MCBSP1_BASE 0x48074000
61#define OMAP34XX_MCBSP2_BASE 0x49022000
Eero Nurkkalad912fa92010-02-22 12:21:11 +000062#define OMAP34XX_MCBSP2_ST_BASE 0x49028000
63#define OMAP34XX_MCBSP3_BASE 0x49024000
64#define OMAP34XX_MCBSP3_ST_BASE 0x4902A000
Chandra Shekhar9c8e3a02008-10-08 10:01:40 +030065#define OMAP34XX_MCBSP3_BASE 0x49024000
66#define OMAP34XX_MCBSP4_BASE 0x49026000
67#define OMAP34XX_MCBSP5_BASE 0x48096000
Russell Kinga09e64f2008-08-05 16:14:15 +010068
Kishon Vijay Abraham I3cf32bb2011-02-24 12:51:45 -080069#define OMAP44XX_MCBSP1_BASE 0x40122000
70#define OMAP44XX_MCBSP1_DMA_BASE 0x49022000
71#define OMAP44XX_MCBSP2_BASE 0x40124000
72#define OMAP44XX_MCBSP2_DMA_BASE 0x49024000
73#define OMAP44XX_MCBSP3_BASE 0x40126000
74#define OMAP44XX_MCBSP3_DMA_BASE 0x49026000
Santosh Shilimkaraee44c32010-04-07 07:47:23 +000075#define OMAP44XX_MCBSP4_BASE 0x48096000
Syed Rafiuddina5b92cc2009-07-28 18:57:10 +053076
Alistair Buxtonbf1cb7e2009-09-22 06:49:35 +010077#if defined(CONFIG_ARCH_OMAP15XX) || defined(CONFIG_ARCH_OMAP16XX) || defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850)
Russell Kinga09e64f2008-08-05 16:14:15 +010078
79#define OMAP_MCBSP_REG_DRR2 0x00
80#define OMAP_MCBSP_REG_DRR1 0x02
81#define OMAP_MCBSP_REG_DXR2 0x04
82#define OMAP_MCBSP_REG_DXR1 0x06
83#define OMAP_MCBSP_REG_SPCR2 0x08
84#define OMAP_MCBSP_REG_SPCR1 0x0a
85#define OMAP_MCBSP_REG_RCR2 0x0c
86#define OMAP_MCBSP_REG_RCR1 0x0e
87#define OMAP_MCBSP_REG_XCR2 0x10
88#define OMAP_MCBSP_REG_XCR1 0x12
89#define OMAP_MCBSP_REG_SRGR2 0x14
90#define OMAP_MCBSP_REG_SRGR1 0x16
91#define OMAP_MCBSP_REG_MCR2 0x18
92#define OMAP_MCBSP_REG_MCR1 0x1a
93#define OMAP_MCBSP_REG_RCERA 0x1c
94#define OMAP_MCBSP_REG_RCERB 0x1e
95#define OMAP_MCBSP_REG_XCERA 0x20
96#define OMAP_MCBSP_REG_XCERB 0x22
97#define OMAP_MCBSP_REG_PCR0 0x24
98#define OMAP_MCBSP_REG_RCERC 0x26
99#define OMAP_MCBSP_REG_RCERD 0x28
100#define OMAP_MCBSP_REG_XCERC 0x2A
101#define OMAP_MCBSP_REG_XCERD 0x2C
102#define OMAP_MCBSP_REG_RCERE 0x2E
103#define OMAP_MCBSP_REG_RCERF 0x30
104#define OMAP_MCBSP_REG_XCERE 0x32
105#define OMAP_MCBSP_REG_XCERF 0x34
106#define OMAP_MCBSP_REG_RCERG 0x36
107#define OMAP_MCBSP_REG_RCERH 0x38
108#define OMAP_MCBSP_REG_XCERG 0x3A
109#define OMAP_MCBSP_REG_XCERH 0x3C
110
Tony Lindgren3127f8f2009-01-15 13:09:54 +0200111/* Dummy defines, these are not available on omap1 */
112#define OMAP_MCBSP_REG_XCCR 0x00
113#define OMAP_MCBSP_REG_RCCR 0x00
114
Tony Lindgren140455f2010-02-12 12:26:48 -0800115#else
Russell Kinga09e64f2008-08-05 16:14:15 +0100116
117#define OMAP_MCBSP_REG_DRR2 0x00
118#define OMAP_MCBSP_REG_DRR1 0x04
119#define OMAP_MCBSP_REG_DXR2 0x08
120#define OMAP_MCBSP_REG_DXR1 0x0C
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300121#define OMAP_MCBSP_REG_DRR 0x00
122#define OMAP_MCBSP_REG_DXR 0x08
Russell Kinga09e64f2008-08-05 16:14:15 +0100123#define OMAP_MCBSP_REG_SPCR2 0x10
124#define OMAP_MCBSP_REG_SPCR1 0x14
125#define OMAP_MCBSP_REG_RCR2 0x18
126#define OMAP_MCBSP_REG_RCR1 0x1C
127#define OMAP_MCBSP_REG_XCR2 0x20
128#define OMAP_MCBSP_REG_XCR1 0x24
129#define OMAP_MCBSP_REG_SRGR2 0x28
130#define OMAP_MCBSP_REG_SRGR1 0x2C
131#define OMAP_MCBSP_REG_MCR2 0x30
132#define OMAP_MCBSP_REG_MCR1 0x34
133#define OMAP_MCBSP_REG_RCERA 0x38
134#define OMAP_MCBSP_REG_RCERB 0x3C
135#define OMAP_MCBSP_REG_XCERA 0x40
136#define OMAP_MCBSP_REG_XCERB 0x44
137#define OMAP_MCBSP_REG_PCR0 0x48
138#define OMAP_MCBSP_REG_RCERC 0x4C
139#define OMAP_MCBSP_REG_RCERD 0x50
140#define OMAP_MCBSP_REG_XCERC 0x54
141#define OMAP_MCBSP_REG_XCERD 0x58
142#define OMAP_MCBSP_REG_RCERE 0x5C
143#define OMAP_MCBSP_REG_RCERF 0x60
144#define OMAP_MCBSP_REG_XCERE 0x64
145#define OMAP_MCBSP_REG_XCERF 0x68
146#define OMAP_MCBSP_REG_RCERG 0x6C
147#define OMAP_MCBSP_REG_RCERH 0x70
148#define OMAP_MCBSP_REG_XCERG 0x74
149#define OMAP_MCBSP_REG_XCERH 0x78
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300150#define OMAP_MCBSP_REG_SYSCON 0x8C
Eduardo Valentin946a49a2009-08-20 16:18:08 +0300151#define OMAP_MCBSP_REG_THRSH2 0x90
152#define OMAP_MCBSP_REG_THRSH1 0x94
153#define OMAP_MCBSP_REG_IRQST 0xA0
154#define OMAP_MCBSP_REG_IRQEN 0xA4
Eero Nurkkala2122fdc2009-08-20 16:18:15 +0300155#define OMAP_MCBSP_REG_WAKEUPEN 0xA8
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300156#define OMAP_MCBSP_REG_XCCR 0xAC
157#define OMAP_MCBSP_REG_RCCR 0xB0
Peter Ujfalusi7dc976e2010-03-03 15:08:08 +0200158#define OMAP_MCBSP_REG_XBUFFSTAT 0xB4
159#define OMAP_MCBSP_REG_RBUFFSTAT 0xB8
Eero Nurkkalad912fa92010-02-22 12:21:11 +0000160#define OMAP_MCBSP_REG_SSELCR 0xBC
161
162#define OMAP_ST_REG_REV 0x00
163#define OMAP_ST_REG_SYSCONFIG 0x10
164#define OMAP_ST_REG_IRQSTATUS 0x18
165#define OMAP_ST_REG_IRQENABLE 0x1C
166#define OMAP_ST_REG_SGAINCR 0x24
167#define OMAP_ST_REG_SFIRCR 0x28
168#define OMAP_ST_REG_SSELCR 0x2C
Russell Kinga09e64f2008-08-05 16:14:15 +0100169
Russell Kinga09e64f2008-08-05 16:14:15 +0100170#endif
171
Russell Kinga09e64f2008-08-05 16:14:15 +0100172/************************** McBSP SPCR1 bit definitions ***********************/
173#define RRST 0x0001
174#define RRDY 0x0002
175#define RFULL 0x0004
176#define RSYNC_ERR 0x0008
177#define RINTM(value) ((value)<<4) /* bits 4:5 */
178#define ABIS 0x0040
179#define DXENA 0x0080
180#define CLKSTP(value) ((value)<<11) /* bits 11:12 */
181#define RJUST(value) ((value)<<13) /* bits 13:14 */
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300182#define ALB 0x8000
Russell Kinga09e64f2008-08-05 16:14:15 +0100183#define DLB 0x8000
184
185/************************** McBSP SPCR2 bit definitions ***********************/
186#define XRST 0x0001
187#define XRDY 0x0002
188#define XEMPTY 0x0004
189#define XSYNC_ERR 0x0008
190#define XINTM(value) ((value)<<4) /* bits 4:5 */
191#define GRST 0x0040
192#define FRST 0x0080
193#define SOFT 0x0100
194#define FREE 0x0200
195
196/************************** McBSP PCR bit definitions *************************/
197#define CLKRP 0x0001
198#define CLKXP 0x0002
199#define FSRP 0x0004
200#define FSXP 0x0008
201#define DR_STAT 0x0010
202#define DX_STAT 0x0020
203#define CLKS_STAT 0x0040
204#define SCLKME 0x0080
205#define CLKRM 0x0100
206#define CLKXM 0x0200
207#define FSRM 0x0400
208#define FSXM 0x0800
209#define RIOEN 0x1000
210#define XIOEN 0x2000
211#define IDLE_EN 0x4000
212
213/************************** McBSP RCR1 bit definitions ************************/
214#define RWDLEN1(value) ((value)<<5) /* Bits 5:7 */
215#define RFRLEN1(value) ((value)<<8) /* Bits 8:14 */
216
217/************************** McBSP XCR1 bit definitions ************************/
218#define XWDLEN1(value) ((value)<<5) /* Bits 5:7 */
219#define XFRLEN1(value) ((value)<<8) /* Bits 8:14 */
220
221/*************************** McBSP RCR2 bit definitions ***********************/
222#define RDATDLY(value) (value) /* Bits 0:1 */
223#define RFIG 0x0004
224#define RCOMPAND(value) ((value)<<3) /* Bits 3:4 */
225#define RWDLEN2(value) ((value)<<5) /* Bits 5:7 */
226#define RFRLEN2(value) ((value)<<8) /* Bits 8:14 */
227#define RPHASE 0x8000
228
229/*************************** McBSP XCR2 bit definitions ***********************/
230#define XDATDLY(value) (value) /* Bits 0:1 */
231#define XFIG 0x0004
232#define XCOMPAND(value) ((value)<<3) /* Bits 3:4 */
233#define XWDLEN2(value) ((value)<<5) /* Bits 5:7 */
234#define XFRLEN2(value) ((value)<<8) /* Bits 8:14 */
235#define XPHASE 0x8000
236
237/************************* McBSP SRGR1 bit definitions ************************/
238#define CLKGDV(value) (value) /* Bits 0:7 */
239#define FWID(value) ((value)<<8) /* Bits 8:15 */
240
241/************************* McBSP SRGR2 bit definitions ************************/
242#define FPER(value) (value) /* Bits 0:11 */
243#define FSGM 0x1000
244#define CLKSM 0x2000
245#define CLKSP 0x4000
246#define GSYNC 0x8000
247
248/************************* McBSP MCR1 bit definitions *************************/
249#define RMCM 0x0001
250#define RCBLK(value) ((value)<<2) /* Bits 2:4 */
251#define RPABLK(value) ((value)<<5) /* Bits 5:6 */
252#define RPBBLK(value) ((value)<<7) /* Bits 7:8 */
253
254/************************* McBSP MCR2 bit definitions *************************/
255#define XMCM(value) (value) /* Bits 0:1 */
256#define XCBLK(value) ((value)<<2) /* Bits 2:4 */
257#define XPABLK(value) ((value)<<5) /* Bits 5:6 */
258#define XPBBLK(value) ((value)<<7) /* Bits 7:8 */
259
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300260/*********************** McBSP XCCR bit definitions *************************/
Tony Lindgren3127f8f2009-01-15 13:09:54 +0200261#define EXTCLKGATE 0x8000
262#define PPCONNECT 0x4000
263#define DXENDLY(value) ((value)<<12) /* Bits 12:13 */
264#define XFULL_CYCLE 0x0800
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300265#define DILB 0x0020
266#define XDMAEN 0x0008
267#define XDISABLE 0x0001
268
269/********************** McBSP RCCR bit definitions *************************/
Tony Lindgren3127f8f2009-01-15 13:09:54 +0200270#define RFULL_CYCLE 0x0800
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300271#define RDMAEN 0x0008
272#define RDISABLE 0x0001
273
274/********************** McBSP SYSCONFIG bit definitions ********************/
Eero Nurkkala2ba93f82009-08-20 16:18:17 +0300275#define CLOCKACTIVITY(value) ((value)<<8)
Eero Nurkkala2122fdc2009-08-20 16:18:15 +0300276#define SIDLEMODE(value) ((value)<<3)
277#define ENAWAKEUP 0x0004
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300278#define SOFTRST 0x0002
Russell Kinga09e64f2008-08-05 16:14:15 +0100279
Eero Nurkkalad912fa92010-02-22 12:21:11 +0000280/********************** McBSP SSELCR bit definitions ***********************/
281#define SIDETONEEN 0x0400
282
283/********************** McBSP Sidetone SYSCONFIG bit definitions ***********/
284#define ST_AUTOIDLE 0x0001
285
286/********************** McBSP Sidetone SGAINCR bit definitions *************/
287#define ST_CH1GAIN(value) ((value<<16)) /* Bits 16:31 */
288#define ST_CH0GAIN(value) (value) /* Bits 0:15 */
289
290/********************** McBSP Sidetone SFIRCR bit definitions **************/
291#define ST_FIRCOEFF(value) (value) /* Bits 0:15 */
292
293/********************** McBSP Sidetone SSELCR bit definitions **************/
294#define ST_COEFFWRDONE 0x0004
295#define ST_COEFFWREN 0x0002
296#define ST_SIDETONEEN 0x0001
297
Peter Ujfalusi98cb20e2009-08-20 16:18:14 +0300298/********************** McBSP DMA operating modes **************************/
299#define MCBSP_DMA_MODE_ELEMENT 0
300#define MCBSP_DMA_MODE_THRESHOLD 1
301#define MCBSP_DMA_MODE_FRAME 2
302
Eero Nurkkala2122fdc2009-08-20 16:18:15 +0300303/********************** McBSP WAKEUPEN bit definitions *********************/
304#define XEMPTYEOFEN 0x4000
305#define XRDYEN 0x0400
306#define XEOFEN 0x0200
307#define XFSXEN 0x0100
308#define XSYNCERREN 0x0080
309#define RRDYEN 0x0008
310#define REOFEN 0x0004
311#define RFSREN 0x0002
312#define RSYNCERREN 0x0001
Eero Nurkkala2122fdc2009-08-20 16:18:15 +0300313
Paul Walmsleycf4c87a2010-10-08 11:40:19 -0600314/* CLKR signal muxing options */
315#define CLKR_SRC_CLKR 0
316#define CLKR_SRC_CLKX 1
317
318/* FSR signal muxing options */
319#define FSR_SRC_FSR 0
320#define FSR_SRC_FSX 1
321
Paul Walmsleyd1358652010-10-08 11:40:19 -0600322/* McBSP functional clock sources */
Jarkko Nikulae4cc41d2010-10-08 11:40:21 -0600323#define MCBSP_CLKS_PRCM_SRC 0
324#define MCBSP_CLKS_PAD_SRC 1
Paul Walmsleyd1358652010-10-08 11:40:19 -0600325
Russell Kinga09e64f2008-08-05 16:14:15 +0100326/* we don't do multichannel for now */
327struct omap_mcbsp_reg_cfg {
328 u16 spcr2;
329 u16 spcr1;
330 u16 rcr2;
331 u16 rcr1;
332 u16 xcr2;
333 u16 xcr1;
334 u16 srgr2;
335 u16 srgr1;
336 u16 mcr2;
337 u16 mcr1;
338 u16 pcr0;
339 u16 rcerc;
340 u16 rcerd;
341 u16 xcerc;
342 u16 xcerd;
343 u16 rcere;
344 u16 rcerf;
345 u16 xcere;
346 u16 xcerf;
347 u16 rcerg;
348 u16 rcerh;
349 u16 xcerg;
350 u16 xcerh;
Tony Lindgren3127f8f2009-01-15 13:09:54 +0200351 u16 xccr;
352 u16 rccr;
Russell Kinga09e64f2008-08-05 16:14:15 +0100353};
354
355typedef enum {
356 OMAP_MCBSP1 = 0,
357 OMAP_MCBSP2,
358 OMAP_MCBSP3,
Chandra Shekhar9c8e3a02008-10-08 10:01:40 +0300359 OMAP_MCBSP4,
360 OMAP_MCBSP5
Russell Kinga09e64f2008-08-05 16:14:15 +0100361} omap_mcbsp_id;
362
363typedef int __bitwise omap_mcbsp_io_type_t;
364#define OMAP_MCBSP_IRQ_IO ((__force omap_mcbsp_io_type_t) 1)
365#define OMAP_MCBSP_POLL_IO ((__force omap_mcbsp_io_type_t) 2)
366
367typedef enum {
368 OMAP_MCBSP_WORD_8 = 0,
369 OMAP_MCBSP_WORD_12,
370 OMAP_MCBSP_WORD_16,
371 OMAP_MCBSP_WORD_20,
372 OMAP_MCBSP_WORD_24,
373 OMAP_MCBSP_WORD_32,
374} omap_mcbsp_word_length;
375
376typedef enum {
377 OMAP_MCBSP_CLK_RISING = 0,
378 OMAP_MCBSP_CLK_FALLING,
379} omap_mcbsp_clk_polarity;
380
381typedef enum {
382 OMAP_MCBSP_FS_ACTIVE_HIGH = 0,
383 OMAP_MCBSP_FS_ACTIVE_LOW,
384} omap_mcbsp_fs_polarity;
385
386typedef enum {
387 OMAP_MCBSP_CLK_STP_MODE_NO_DELAY = 0,
388 OMAP_MCBSP_CLK_STP_MODE_DELAY,
389} omap_mcbsp_clk_stp_mode;
390
391
392/******* SPI specific mode **********/
393typedef enum {
394 OMAP_MCBSP_SPI_MASTER = 0,
395 OMAP_MCBSP_SPI_SLAVE,
396} omap_mcbsp_spi_mode;
397
398struct omap_mcbsp_spi_cfg {
399 omap_mcbsp_spi_mode spi_mode;
400 omap_mcbsp_clk_polarity rx_clock_polarity;
401 omap_mcbsp_clk_polarity tx_clock_polarity;
402 omap_mcbsp_fs_polarity fsx_polarity;
403 u8 clk_div;
404 omap_mcbsp_clk_stp_mode clk_stp_mode;
405 omap_mcbsp_word_length word_length;
406};
407
408/* Platform specific configuration */
409struct omap_mcbsp_ops {
410 void (*request)(unsigned int);
411 void (*free)(unsigned int);
Paul Walmsleyd1358652010-10-08 11:40:19 -0600412 int (*set_clks_src)(u8, u8);
Russell Kinga09e64f2008-08-05 16:14:15 +0100413};
414
415struct omap_mcbsp_platform_data {
Russell King65846902008-09-03 23:46:18 +0100416 unsigned long phys_base;
Russell Kinga09e64f2008-08-05 16:14:15 +0100417 u8 dma_rx_sync, dma_tx_sync;
418 u16 rx_irq, tx_irq;
419 struct omap_mcbsp_ops *ops;
Tony Lindgrena8eb7ca2010-02-12 12:26:48 -0800420#ifdef CONFIG_ARCH_OMAP3
Eero Nurkkalad912fa92010-02-22 12:21:11 +0000421 /* Sidetone block for McBSP 2 and 3 */
422 unsigned long phys_base_st;
Eduardo Valentina1a56f5f2009-08-20 16:18:11 +0300423 u16 buffer_size;
424#endif
Russell Kinga09e64f2008-08-05 16:14:15 +0100425};
426
Eero Nurkkalad912fa92010-02-22 12:21:11 +0000427struct omap_mcbsp_st_data {
428 void __iomem *io_base_st;
429 bool running;
430 bool enabled;
431 s16 taps[128]; /* Sidetone filter coefficients */
432 int nr_taps; /* Number of filter coefficients in use */
433 s16 ch0gain;
434 s16 ch1gain;
435};
436
Russell Kinga09e64f2008-08-05 16:14:15 +0100437struct omap_mcbsp {
438 struct device *dev;
Russell King65846902008-09-03 23:46:18 +0100439 unsigned long phys_base;
Kishon Vijay Abraham I3cf32bb2011-02-24 12:51:45 -0800440 unsigned long phys_dma_base;
Russell Kingd592dd12008-09-04 14:25:42 +0100441 void __iomem *io_base;
Russell Kinga09e64f2008-08-05 16:14:15 +0100442 u8 id;
443 u8 free;
444 omap_mcbsp_word_length rx_word_length;
445 omap_mcbsp_word_length tx_word_length;
446
447 omap_mcbsp_io_type_t io_type; /* IRQ or poll */
448 /* IRQ based TX/RX */
449 int rx_irq;
450 int tx_irq;
451
452 /* DMA stuff */
453 u8 dma_rx_sync;
454 short dma_rx_lch;
455 u8 dma_tx_sync;
456 short dma_tx_lch;
457
458 /* Completion queues */
459 struct completion tx_irq_completion;
460 struct completion rx_irq_completion;
461 struct completion tx_dma_completion;
462 struct completion rx_dma_completion;
463
464 /* Protect the field .free, while checking if the mcbsp is in use */
465 spinlock_t lock;
466 struct omap_mcbsp_platform_data *pdata;
Russell Kingb820ce42009-01-23 10:26:46 +0000467 struct clk *iclk;
468 struct clk *fclk;
Tony Lindgrena8eb7ca2010-02-12 12:26:48 -0800469#ifdef CONFIG_ARCH_OMAP3
Eero Nurkkalad912fa92010-02-22 12:21:11 +0000470 struct omap_mcbsp_st_data *st_data;
Peter Ujfalusi98cb20e2009-08-20 16:18:14 +0300471 int dma_op_mode;
Eduardo Valentina1a56f5f2009-08-20 16:18:11 +0300472 u16 max_tx_thres;
473 u16 max_rx_thres;
474#endif
Janusz Krzysztofikc8c99692010-02-15 10:03:33 -0800475 void *reg_cache;
Russell Kinga09e64f2008-08-05 16:14:15 +0100476};
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300477extern struct omap_mcbsp **mcbsp_ptr;
Janusz Krzysztofikc8c99692010-02-15 10:03:33 -0800478extern int omap_mcbsp_count, omap_mcbsp_cache_size;
Russell Kinga09e64f2008-08-05 16:14:15 +0100479
Paul Walmsleyd1358652010-10-08 11:40:19 -0600480#define omap_mcbsp_check_valid_id(id) (id < omap_mcbsp_count)
481#define id_to_mcbsp_ptr(id) mcbsp_ptr[id];
482
Russell Kinga09e64f2008-08-05 16:14:15 +0100483int omap_mcbsp_init(void);
Kishon Vijay Abraham I3cf32bb2011-02-24 12:51:45 -0800484void omap_mcbsp_register_board_cfg(struct resource *res, int res_count,
485 struct omap_mcbsp_platform_data *config, int size);
Russell Kinga09e64f2008-08-05 16:14:15 +0100486void omap_mcbsp_config(unsigned int id, const struct omap_mcbsp_reg_cfg * config);
Tony Lindgrena8eb7ca2010-02-12 12:26:48 -0800487#ifdef CONFIG_ARCH_OMAP3
Eduardo Valentin7aa9ff52009-08-20 16:18:10 +0300488void omap_mcbsp_set_tx_threshold(unsigned int id, u16 threshold);
489void omap_mcbsp_set_rx_threshold(unsigned int id, u16 threshold);
Eduardo Valentina1a56f5f2009-08-20 16:18:11 +0300490u16 omap_mcbsp_get_max_tx_threshold(unsigned int id);
491u16 omap_mcbsp_get_max_rx_threshold(unsigned int id);
Peter Ujfalusi0acce822010-06-03 07:39:32 +0300492u16 omap_mcbsp_get_fifo_size(unsigned int id);
Peter Ujfalusi7dc976e2010-03-03 15:08:08 +0200493u16 omap_mcbsp_get_tx_delay(unsigned int id);
494u16 omap_mcbsp_get_rx_delay(unsigned int id);
Peter Ujfalusi98cb20e2009-08-20 16:18:14 +0300495int omap_mcbsp_get_dma_op_mode(unsigned int id);
Eduardo Valentin7aa9ff52009-08-20 16:18:10 +0300496#else
497static inline void omap_mcbsp_set_tx_threshold(unsigned int id, u16 threshold)
498{ }
499static inline void omap_mcbsp_set_rx_threshold(unsigned int id, u16 threshold)
500{ }
Eduardo Valentina1a56f5f2009-08-20 16:18:11 +0300501static inline u16 omap_mcbsp_get_max_tx_threshold(unsigned int id) { return 0; }
502static inline u16 omap_mcbsp_get_max_rx_threshold(unsigned int id) { return 0; }
Peter Ujfalusi0acce822010-06-03 07:39:32 +0300503static inline u16 omap_mcbsp_get_fifo_size(unsigned int id) { return 0; }
Peter Ujfalusi7dc976e2010-03-03 15:08:08 +0200504static inline u16 omap_mcbsp_get_tx_delay(unsigned int id) { return 0; }
505static inline u16 omap_mcbsp_get_rx_delay(unsigned int id) { return 0; }
Peter Ujfalusi98cb20e2009-08-20 16:18:14 +0300506static inline int omap_mcbsp_get_dma_op_mode(unsigned int id) { return 0; }
Eduardo Valentin7aa9ff52009-08-20 16:18:10 +0300507#endif
Russell Kinga09e64f2008-08-05 16:14:15 +0100508int omap_mcbsp_request(unsigned int id);
509void omap_mcbsp_free(unsigned int id);
Jarkko Nikulac12abc02009-08-07 09:59:47 +0300510void omap_mcbsp_start(unsigned int id, int tx, int rx);
511void omap_mcbsp_stop(unsigned int id, int tx, int rx);
Russell Kinga09e64f2008-08-05 16:14:15 +0100512void omap_mcbsp_xmit_word(unsigned int id, u32 word);
513u32 omap_mcbsp_recv_word(unsigned int id);
514
515int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer, unsigned int length);
516int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer, unsigned int length);
517int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word);
518int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 * word);
519
520
Paul Walmsleyd1358652010-10-08 11:40:19 -0600521/* McBSP functional clock source changing function */
522extern int omap2_mcbsp_set_clks_src(u8 id, u8 fck_src_id);
Russell Kinga09e64f2008-08-05 16:14:15 +0100523/* SPI specific API */
524void omap_mcbsp_set_spi_mode(unsigned int id, const struct omap_mcbsp_spi_cfg * spi_cfg);
525
526/* Polled read/write functions */
527int omap_mcbsp_pollread(unsigned int id, u16 * buf);
528int omap_mcbsp_pollwrite(unsigned int id, u16 buf);
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300529int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type);
Russell Kinga09e64f2008-08-05 16:14:15 +0100530
Paul Walmsleycf4c87a2010-10-08 11:40:19 -0600531/* McBSP signal muxing API */
532void omap2_mcbsp1_mux_clkr_src(u8 mux);
533void omap2_mcbsp1_mux_fsr_src(u8 mux);
534
Eero Nurkkalad912fa92010-02-22 12:21:11 +0000535#ifdef CONFIG_ARCH_OMAP3
536/* Sidetone specific API */
537int omap_st_set_chgain(unsigned int id, int channel, s16 chgain);
538int omap_st_get_chgain(unsigned int id, int channel, s16 *chgain);
539int omap_st_enable(unsigned int id);
540int omap_st_disable(unsigned int id);
541int omap_st_is_enabled(unsigned int id);
542#else
543static inline int omap_st_set_chgain(unsigned int id, int channel,
544 s16 chgain) { return 0; }
545static inline int omap_st_get_chgain(unsigned int id, int channel,
546 s16 *chgain) { return 0; }
547static inline int omap_st_enable(unsigned int id) { return 0; }
548static inline int omap_st_disable(unsigned int id) { return 0; }
549static inline int omap_st_is_enabled(unsigned int id) { return 0; }
550#endif
551
Russell Kinga09e64f2008-08-05 16:14:15 +0100552#endif