blob: 21c9b104c615887a768a17f626ab2878dd06ffa2 [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
Kishon Vijay Abraham Icb7e9de2011-02-24 15:16:50 +053042#define MCBSP_CONFIG_TYPE4 0x4
Charulatha V37801b32011-02-24 12:51:46 -080043
Alistair Buxton7c006922009-09-22 10:02:58 +010044#define OMAP7XX_MCBSP1_BASE 0xfffb1000
45#define OMAP7XX_MCBSP2_BASE 0xfffb1800
Russell Kinga09e64f2008-08-05 16:14:15 +010046
47#define OMAP1510_MCBSP1_BASE 0xe1011800
48#define OMAP1510_MCBSP2_BASE 0xfffb1000
49#define OMAP1510_MCBSP3_BASE 0xe1017000
50
51#define OMAP1610_MCBSP1_BASE 0xe1011800
52#define OMAP1610_MCBSP2_BASE 0xfffb1000
53#define OMAP1610_MCBSP3_BASE 0xe1017000
54
55#define OMAP24XX_MCBSP1_BASE 0x48074000
56#define OMAP24XX_MCBSP2_BASE 0x48076000
Jarkko Nikula05228c32008-10-08 10:01:40 +030057#define OMAP2430_MCBSP3_BASE 0x4808c000
58#define OMAP2430_MCBSP4_BASE 0x4808e000
59#define OMAP2430_MCBSP5_BASE 0x48096000
Russell Kinga09e64f2008-08-05 16:14:15 +010060
61#define OMAP34XX_MCBSP1_BASE 0x48074000
62#define OMAP34XX_MCBSP2_BASE 0x49022000
Eero Nurkkalad912fa92010-02-22 12:21:11 +000063#define OMAP34XX_MCBSP2_ST_BASE 0x49028000
64#define OMAP34XX_MCBSP3_BASE 0x49024000
65#define OMAP34XX_MCBSP3_ST_BASE 0x4902A000
Chandra Shekhar9c8e3a02008-10-08 10:01:40 +030066#define OMAP34XX_MCBSP3_BASE 0x49024000
67#define OMAP34XX_MCBSP4_BASE 0x49026000
68#define OMAP34XX_MCBSP5_BASE 0x48096000
Russell Kinga09e64f2008-08-05 16:14:15 +010069
Kishon Vijay Abraham I3cf32bb2011-02-24 12:51:45 -080070#define OMAP44XX_MCBSP1_BASE 0x40122000
71#define OMAP44XX_MCBSP1_DMA_BASE 0x49022000
72#define OMAP44XX_MCBSP2_BASE 0x40124000
73#define OMAP44XX_MCBSP2_DMA_BASE 0x49024000
74#define OMAP44XX_MCBSP3_BASE 0x40126000
75#define OMAP44XX_MCBSP3_DMA_BASE 0x49026000
Santosh Shilimkaraee44c32010-04-07 07:47:23 +000076#define OMAP44XX_MCBSP4_BASE 0x48096000
Syed Rafiuddina5b92cc2009-07-28 18:57:10 +053077
Alistair Buxtonbf1cb7e2009-09-22 06:49:35 +010078#if defined(CONFIG_ARCH_OMAP15XX) || defined(CONFIG_ARCH_OMAP16XX) || defined(CONFIG_ARCH_OMAP730) || defined(CONFIG_ARCH_OMAP850)
Russell Kinga09e64f2008-08-05 16:14:15 +010079
80#define OMAP_MCBSP_REG_DRR2 0x00
81#define OMAP_MCBSP_REG_DRR1 0x02
82#define OMAP_MCBSP_REG_DXR2 0x04
83#define OMAP_MCBSP_REG_DXR1 0x06
Kishon Vijay Abraham I9504ba62011-02-24 15:16:55 +053084#define OMAP_MCBSP_REG_DRR 0x02
85#define OMAP_MCBSP_REG_DXR 0x06
Russell Kinga09e64f2008-08-05 16:14:15 +010086#define OMAP_MCBSP_REG_SPCR2 0x08
87#define OMAP_MCBSP_REG_SPCR1 0x0a
88#define OMAP_MCBSP_REG_RCR2 0x0c
89#define OMAP_MCBSP_REG_RCR1 0x0e
90#define OMAP_MCBSP_REG_XCR2 0x10
91#define OMAP_MCBSP_REG_XCR1 0x12
92#define OMAP_MCBSP_REG_SRGR2 0x14
93#define OMAP_MCBSP_REG_SRGR1 0x16
94#define OMAP_MCBSP_REG_MCR2 0x18
95#define OMAP_MCBSP_REG_MCR1 0x1a
96#define OMAP_MCBSP_REG_RCERA 0x1c
97#define OMAP_MCBSP_REG_RCERB 0x1e
98#define OMAP_MCBSP_REG_XCERA 0x20
99#define OMAP_MCBSP_REG_XCERB 0x22
100#define OMAP_MCBSP_REG_PCR0 0x24
101#define OMAP_MCBSP_REG_RCERC 0x26
102#define OMAP_MCBSP_REG_RCERD 0x28
103#define OMAP_MCBSP_REG_XCERC 0x2A
104#define OMAP_MCBSP_REG_XCERD 0x2C
105#define OMAP_MCBSP_REG_RCERE 0x2E
106#define OMAP_MCBSP_REG_RCERF 0x30
107#define OMAP_MCBSP_REG_XCERE 0x32
108#define OMAP_MCBSP_REG_XCERF 0x34
109#define OMAP_MCBSP_REG_RCERG 0x36
110#define OMAP_MCBSP_REG_RCERH 0x38
111#define OMAP_MCBSP_REG_XCERG 0x3A
112#define OMAP_MCBSP_REG_XCERH 0x3C
113
Tony Lindgren3127f8f2009-01-15 13:09:54 +0200114/* Dummy defines, these are not available on omap1 */
115#define OMAP_MCBSP_REG_XCCR 0x00
116#define OMAP_MCBSP_REG_RCCR 0x00
117
Tony Lindgren140455f2010-02-12 12:26:48 -0800118#else
Russell Kinga09e64f2008-08-05 16:14:15 +0100119
120#define OMAP_MCBSP_REG_DRR2 0x00
121#define OMAP_MCBSP_REG_DRR1 0x04
122#define OMAP_MCBSP_REG_DXR2 0x08
123#define OMAP_MCBSP_REG_DXR1 0x0C
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300124#define OMAP_MCBSP_REG_DRR 0x00
125#define OMAP_MCBSP_REG_DXR 0x08
Russell Kinga09e64f2008-08-05 16:14:15 +0100126#define OMAP_MCBSP_REG_SPCR2 0x10
127#define OMAP_MCBSP_REG_SPCR1 0x14
128#define OMAP_MCBSP_REG_RCR2 0x18
129#define OMAP_MCBSP_REG_RCR1 0x1C
130#define OMAP_MCBSP_REG_XCR2 0x20
131#define OMAP_MCBSP_REG_XCR1 0x24
132#define OMAP_MCBSP_REG_SRGR2 0x28
133#define OMAP_MCBSP_REG_SRGR1 0x2C
134#define OMAP_MCBSP_REG_MCR2 0x30
135#define OMAP_MCBSP_REG_MCR1 0x34
136#define OMAP_MCBSP_REG_RCERA 0x38
137#define OMAP_MCBSP_REG_RCERB 0x3C
138#define OMAP_MCBSP_REG_XCERA 0x40
139#define OMAP_MCBSP_REG_XCERB 0x44
140#define OMAP_MCBSP_REG_PCR0 0x48
141#define OMAP_MCBSP_REG_RCERC 0x4C
142#define OMAP_MCBSP_REG_RCERD 0x50
143#define OMAP_MCBSP_REG_XCERC 0x54
144#define OMAP_MCBSP_REG_XCERD 0x58
145#define OMAP_MCBSP_REG_RCERE 0x5C
146#define OMAP_MCBSP_REG_RCERF 0x60
147#define OMAP_MCBSP_REG_XCERE 0x64
148#define OMAP_MCBSP_REG_XCERF 0x68
149#define OMAP_MCBSP_REG_RCERG 0x6C
150#define OMAP_MCBSP_REG_RCERH 0x70
151#define OMAP_MCBSP_REG_XCERG 0x74
152#define OMAP_MCBSP_REG_XCERH 0x78
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300153#define OMAP_MCBSP_REG_SYSCON 0x8C
Eduardo Valentin946a49a2009-08-20 16:18:08 +0300154#define OMAP_MCBSP_REG_THRSH2 0x90
155#define OMAP_MCBSP_REG_THRSH1 0x94
156#define OMAP_MCBSP_REG_IRQST 0xA0
157#define OMAP_MCBSP_REG_IRQEN 0xA4
Eero Nurkkala2122fdc2009-08-20 16:18:15 +0300158#define OMAP_MCBSP_REG_WAKEUPEN 0xA8
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300159#define OMAP_MCBSP_REG_XCCR 0xAC
160#define OMAP_MCBSP_REG_RCCR 0xB0
Peter Ujfalusi7dc976e2010-03-03 15:08:08 +0200161#define OMAP_MCBSP_REG_XBUFFSTAT 0xB4
162#define OMAP_MCBSP_REG_RBUFFSTAT 0xB8
Eero Nurkkalad912fa92010-02-22 12:21:11 +0000163#define OMAP_MCBSP_REG_SSELCR 0xBC
164
165#define OMAP_ST_REG_REV 0x00
166#define OMAP_ST_REG_SYSCONFIG 0x10
167#define OMAP_ST_REG_IRQSTATUS 0x18
168#define OMAP_ST_REG_IRQENABLE 0x1C
169#define OMAP_ST_REG_SGAINCR 0x24
170#define OMAP_ST_REG_SFIRCR 0x28
171#define OMAP_ST_REG_SSELCR 0x2C
Russell Kinga09e64f2008-08-05 16:14:15 +0100172
Russell Kinga09e64f2008-08-05 16:14:15 +0100173#endif
174
Russell Kinga09e64f2008-08-05 16:14:15 +0100175/************************** McBSP SPCR1 bit definitions ***********************/
176#define RRST 0x0001
177#define RRDY 0x0002
178#define RFULL 0x0004
179#define RSYNC_ERR 0x0008
180#define RINTM(value) ((value)<<4) /* bits 4:5 */
181#define ABIS 0x0040
182#define DXENA 0x0080
183#define CLKSTP(value) ((value)<<11) /* bits 11:12 */
184#define RJUST(value) ((value)<<13) /* bits 13:14 */
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300185#define ALB 0x8000
Russell Kinga09e64f2008-08-05 16:14:15 +0100186#define DLB 0x8000
187
188/************************** McBSP SPCR2 bit definitions ***********************/
189#define XRST 0x0001
190#define XRDY 0x0002
191#define XEMPTY 0x0004
192#define XSYNC_ERR 0x0008
193#define XINTM(value) ((value)<<4) /* bits 4:5 */
194#define GRST 0x0040
195#define FRST 0x0080
196#define SOFT 0x0100
197#define FREE 0x0200
198
199/************************** McBSP PCR bit definitions *************************/
200#define CLKRP 0x0001
201#define CLKXP 0x0002
202#define FSRP 0x0004
203#define FSXP 0x0008
204#define DR_STAT 0x0010
205#define DX_STAT 0x0020
206#define CLKS_STAT 0x0040
207#define SCLKME 0x0080
208#define CLKRM 0x0100
209#define CLKXM 0x0200
210#define FSRM 0x0400
211#define FSXM 0x0800
212#define RIOEN 0x1000
213#define XIOEN 0x2000
214#define IDLE_EN 0x4000
215
216/************************** McBSP RCR1 bit definitions ************************/
217#define RWDLEN1(value) ((value)<<5) /* Bits 5:7 */
218#define RFRLEN1(value) ((value)<<8) /* Bits 8:14 */
219
220/************************** McBSP XCR1 bit definitions ************************/
221#define XWDLEN1(value) ((value)<<5) /* Bits 5:7 */
222#define XFRLEN1(value) ((value)<<8) /* Bits 8:14 */
223
224/*************************** McBSP RCR2 bit definitions ***********************/
225#define RDATDLY(value) (value) /* Bits 0:1 */
226#define RFIG 0x0004
227#define RCOMPAND(value) ((value)<<3) /* Bits 3:4 */
228#define RWDLEN2(value) ((value)<<5) /* Bits 5:7 */
229#define RFRLEN2(value) ((value)<<8) /* Bits 8:14 */
230#define RPHASE 0x8000
231
232/*************************** McBSP XCR2 bit definitions ***********************/
233#define XDATDLY(value) (value) /* Bits 0:1 */
234#define XFIG 0x0004
235#define XCOMPAND(value) ((value)<<3) /* Bits 3:4 */
236#define XWDLEN2(value) ((value)<<5) /* Bits 5:7 */
237#define XFRLEN2(value) ((value)<<8) /* Bits 8:14 */
238#define XPHASE 0x8000
239
240/************************* McBSP SRGR1 bit definitions ************************/
241#define CLKGDV(value) (value) /* Bits 0:7 */
242#define FWID(value) ((value)<<8) /* Bits 8:15 */
243
244/************************* McBSP SRGR2 bit definitions ************************/
245#define FPER(value) (value) /* Bits 0:11 */
246#define FSGM 0x1000
247#define CLKSM 0x2000
248#define CLKSP 0x4000
249#define GSYNC 0x8000
250
251/************************* McBSP MCR1 bit definitions *************************/
252#define RMCM 0x0001
253#define RCBLK(value) ((value)<<2) /* Bits 2:4 */
254#define RPABLK(value) ((value)<<5) /* Bits 5:6 */
255#define RPBBLK(value) ((value)<<7) /* Bits 7:8 */
256
257/************************* McBSP MCR2 bit definitions *************************/
258#define XMCM(value) (value) /* Bits 0:1 */
259#define XCBLK(value) ((value)<<2) /* Bits 2:4 */
260#define XPABLK(value) ((value)<<5) /* Bits 5:6 */
261#define XPBBLK(value) ((value)<<7) /* Bits 7:8 */
262
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300263/*********************** McBSP XCCR bit definitions *************************/
Tony Lindgren3127f8f2009-01-15 13:09:54 +0200264#define EXTCLKGATE 0x8000
265#define PPCONNECT 0x4000
266#define DXENDLY(value) ((value)<<12) /* Bits 12:13 */
267#define XFULL_CYCLE 0x0800
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300268#define DILB 0x0020
269#define XDMAEN 0x0008
270#define XDISABLE 0x0001
271
272/********************** McBSP RCCR bit definitions *************************/
Tony Lindgren3127f8f2009-01-15 13:09:54 +0200273#define RFULL_CYCLE 0x0800
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300274#define RDMAEN 0x0008
275#define RDISABLE 0x0001
276
277/********************** McBSP SYSCONFIG bit definitions ********************/
Eero Nurkkala2ba93f82009-08-20 16:18:17 +0300278#define CLOCKACTIVITY(value) ((value)<<8)
Eero Nurkkala2122fdc2009-08-20 16:18:15 +0300279#define SIDLEMODE(value) ((value)<<3)
280#define ENAWAKEUP 0x0004
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300281#define SOFTRST 0x0002
Russell Kinga09e64f2008-08-05 16:14:15 +0100282
Eero Nurkkalad912fa92010-02-22 12:21:11 +0000283/********************** McBSP SSELCR bit definitions ***********************/
284#define SIDETONEEN 0x0400
285
286/********************** McBSP Sidetone SYSCONFIG bit definitions ***********/
287#define ST_AUTOIDLE 0x0001
288
289/********************** McBSP Sidetone SGAINCR bit definitions *************/
290#define ST_CH1GAIN(value) ((value<<16)) /* Bits 16:31 */
291#define ST_CH0GAIN(value) (value) /* Bits 0:15 */
292
293/********************** McBSP Sidetone SFIRCR bit definitions **************/
294#define ST_FIRCOEFF(value) (value) /* Bits 0:15 */
295
296/********************** McBSP Sidetone SSELCR bit definitions **************/
297#define ST_COEFFWRDONE 0x0004
298#define ST_COEFFWREN 0x0002
299#define ST_SIDETONEEN 0x0001
300
Peter Ujfalusi98cb20e2009-08-20 16:18:14 +0300301/********************** McBSP DMA operating modes **************************/
302#define MCBSP_DMA_MODE_ELEMENT 0
303#define MCBSP_DMA_MODE_THRESHOLD 1
304#define MCBSP_DMA_MODE_FRAME 2
305
Eero Nurkkala2122fdc2009-08-20 16:18:15 +0300306/********************** McBSP WAKEUPEN bit definitions *********************/
307#define XEMPTYEOFEN 0x4000
308#define XRDYEN 0x0400
309#define XEOFEN 0x0200
310#define XFSXEN 0x0100
311#define XSYNCERREN 0x0080
312#define RRDYEN 0x0008
313#define REOFEN 0x0004
314#define RFSREN 0x0002
315#define RSYNCERREN 0x0001
Eero Nurkkala2122fdc2009-08-20 16:18:15 +0300316
Paul Walmsleycf4c87a2010-10-08 11:40:19 -0600317/* CLKR signal muxing options */
318#define CLKR_SRC_CLKR 0
319#define CLKR_SRC_CLKX 1
320
321/* FSR signal muxing options */
322#define FSR_SRC_FSR 0
323#define FSR_SRC_FSX 1
324
Paul Walmsleyd1358652010-10-08 11:40:19 -0600325/* McBSP functional clock sources */
Jarkko Nikulae4cc41d2010-10-08 11:40:21 -0600326#define MCBSP_CLKS_PRCM_SRC 0
327#define MCBSP_CLKS_PAD_SRC 1
Paul Walmsleyd1358652010-10-08 11:40:19 -0600328
Russell Kinga09e64f2008-08-05 16:14:15 +0100329/* we don't do multichannel for now */
330struct omap_mcbsp_reg_cfg {
331 u16 spcr2;
332 u16 spcr1;
333 u16 rcr2;
334 u16 rcr1;
335 u16 xcr2;
336 u16 xcr1;
337 u16 srgr2;
338 u16 srgr1;
339 u16 mcr2;
340 u16 mcr1;
341 u16 pcr0;
342 u16 rcerc;
343 u16 rcerd;
344 u16 xcerc;
345 u16 xcerd;
346 u16 rcere;
347 u16 rcerf;
348 u16 xcere;
349 u16 xcerf;
350 u16 rcerg;
351 u16 rcerh;
352 u16 xcerg;
353 u16 xcerh;
Tony Lindgren3127f8f2009-01-15 13:09:54 +0200354 u16 xccr;
355 u16 rccr;
Russell Kinga09e64f2008-08-05 16:14:15 +0100356};
357
358typedef enum {
359 OMAP_MCBSP1 = 0,
360 OMAP_MCBSP2,
361 OMAP_MCBSP3,
Chandra Shekhar9c8e3a02008-10-08 10:01:40 +0300362 OMAP_MCBSP4,
363 OMAP_MCBSP5
Russell Kinga09e64f2008-08-05 16:14:15 +0100364} omap_mcbsp_id;
365
366typedef int __bitwise omap_mcbsp_io_type_t;
367#define OMAP_MCBSP_IRQ_IO ((__force omap_mcbsp_io_type_t) 1)
368#define OMAP_MCBSP_POLL_IO ((__force omap_mcbsp_io_type_t) 2)
369
370typedef enum {
371 OMAP_MCBSP_WORD_8 = 0,
372 OMAP_MCBSP_WORD_12,
373 OMAP_MCBSP_WORD_16,
374 OMAP_MCBSP_WORD_20,
375 OMAP_MCBSP_WORD_24,
376 OMAP_MCBSP_WORD_32,
377} omap_mcbsp_word_length;
378
379typedef enum {
380 OMAP_MCBSP_CLK_RISING = 0,
381 OMAP_MCBSP_CLK_FALLING,
382} omap_mcbsp_clk_polarity;
383
384typedef enum {
385 OMAP_MCBSP_FS_ACTIVE_HIGH = 0,
386 OMAP_MCBSP_FS_ACTIVE_LOW,
387} omap_mcbsp_fs_polarity;
388
389typedef enum {
390 OMAP_MCBSP_CLK_STP_MODE_NO_DELAY = 0,
391 OMAP_MCBSP_CLK_STP_MODE_DELAY,
392} omap_mcbsp_clk_stp_mode;
393
394
395/******* SPI specific mode **********/
396typedef enum {
397 OMAP_MCBSP_SPI_MASTER = 0,
398 OMAP_MCBSP_SPI_SLAVE,
399} omap_mcbsp_spi_mode;
400
401struct omap_mcbsp_spi_cfg {
402 omap_mcbsp_spi_mode spi_mode;
403 omap_mcbsp_clk_polarity rx_clock_polarity;
404 omap_mcbsp_clk_polarity tx_clock_polarity;
405 omap_mcbsp_fs_polarity fsx_polarity;
406 u8 clk_div;
407 omap_mcbsp_clk_stp_mode clk_stp_mode;
408 omap_mcbsp_word_length word_length;
409};
410
411/* Platform specific configuration */
412struct omap_mcbsp_ops {
413 void (*request)(unsigned int);
414 void (*free)(unsigned int);
Paul Walmsleyd1358652010-10-08 11:40:19 -0600415 int (*set_clks_src)(u8, u8);
Russell Kinga09e64f2008-08-05 16:14:15 +0100416};
417
418struct omap_mcbsp_platform_data {
Russell King65846902008-09-03 23:46:18 +0100419 unsigned long phys_base;
Russell Kinga09e64f2008-08-05 16:14:15 +0100420 u8 dma_rx_sync, dma_tx_sync;
421 u16 rx_irq, tx_irq;
422 struct omap_mcbsp_ops *ops;
Tony Lindgrena8eb7ca2010-02-12 12:26:48 -0800423#ifdef CONFIG_ARCH_OMAP3
Eero Nurkkalad912fa92010-02-22 12:21:11 +0000424 /* Sidetone block for McBSP 2 and 3 */
425 unsigned long phys_base_st;
Eduardo Valentina1a56f5f2009-08-20 16:18:11 +0300426#endif
Kishon Vijay Abraham I64bcbd32011-02-24 15:16:52 +0530427 u16 buffer_size;
Kishon Vijay Abraham I9504ba62011-02-24 15:16:55 +0530428 unsigned int mcbsp_config_type;
Russell Kinga09e64f2008-08-05 16:14:15 +0100429};
430
Eero Nurkkalad912fa92010-02-22 12:21:11 +0000431struct omap_mcbsp_st_data {
432 void __iomem *io_base_st;
433 bool running;
434 bool enabled;
435 s16 taps[128]; /* Sidetone filter coefficients */
436 int nr_taps; /* Number of filter coefficients in use */
437 s16 ch0gain;
438 s16 ch1gain;
439};
440
Russell Kinga09e64f2008-08-05 16:14:15 +0100441struct omap_mcbsp {
442 struct device *dev;
Russell King65846902008-09-03 23:46:18 +0100443 unsigned long phys_base;
Kishon Vijay Abraham I3cf32bb2011-02-24 12:51:45 -0800444 unsigned long phys_dma_base;
Russell Kingd592dd12008-09-04 14:25:42 +0100445 void __iomem *io_base;
Russell Kinga09e64f2008-08-05 16:14:15 +0100446 u8 id;
447 u8 free;
448 omap_mcbsp_word_length rx_word_length;
449 omap_mcbsp_word_length tx_word_length;
450
451 omap_mcbsp_io_type_t io_type; /* IRQ or poll */
452 /* IRQ based TX/RX */
453 int rx_irq;
454 int tx_irq;
455
456 /* DMA stuff */
457 u8 dma_rx_sync;
458 short dma_rx_lch;
459 u8 dma_tx_sync;
460 short dma_tx_lch;
461
462 /* Completion queues */
463 struct completion tx_irq_completion;
464 struct completion rx_irq_completion;
465 struct completion tx_dma_completion;
466 struct completion rx_dma_completion;
467
468 /* Protect the field .free, while checking if the mcbsp is in use */
469 spinlock_t lock;
470 struct omap_mcbsp_platform_data *pdata;
Russell Kingb820ce42009-01-23 10:26:46 +0000471 struct clk *fclk;
Tony Lindgrena8eb7ca2010-02-12 12:26:48 -0800472#ifdef CONFIG_ARCH_OMAP3
Eero Nurkkalad912fa92010-02-22 12:21:11 +0000473 struct omap_mcbsp_st_data *st_data;
Peter Ujfalusi98cb20e2009-08-20 16:18:14 +0300474 int dma_op_mode;
Eduardo Valentina1a56f5f2009-08-20 16:18:11 +0300475 u16 max_tx_thres;
476 u16 max_rx_thres;
477#endif
Janusz Krzysztofikc8c99692010-02-15 10:03:33 -0800478 void *reg_cache;
Kishon Vijay Abraham I9504ba62011-02-24 15:16:55 +0530479 unsigned int mcbsp_config_type;
Russell Kinga09e64f2008-08-05 16:14:15 +0100480};
Kishon Vijay Abraham I8b1906f2011-02-24 15:16:51 +0530481
482/**
483 * omap_mcbsp_dev_attr - OMAP McBSP device attributes for omap_hwmod
484 * @sidetone: name of the sidetone device
485 */
486struct omap_mcbsp_dev_attr {
487 const char *sidetone;
488};
489
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300490extern struct omap_mcbsp **mcbsp_ptr;
Janusz Krzysztofikc8c99692010-02-15 10:03:33 -0800491extern int omap_mcbsp_count, omap_mcbsp_cache_size;
Russell Kinga09e64f2008-08-05 16:14:15 +0100492
Paul Walmsleyd1358652010-10-08 11:40:19 -0600493#define omap_mcbsp_check_valid_id(id) (id < omap_mcbsp_count)
494#define id_to_mcbsp_ptr(id) mcbsp_ptr[id];
495
Russell Kinga09e64f2008-08-05 16:14:15 +0100496int omap_mcbsp_init(void);
Kishon Vijay Abraham I3cf32bb2011-02-24 12:51:45 -0800497void omap_mcbsp_register_board_cfg(struct resource *res, int res_count,
498 struct omap_mcbsp_platform_data *config, int size);
Russell Kinga09e64f2008-08-05 16:14:15 +0100499void omap_mcbsp_config(unsigned int id, const struct omap_mcbsp_reg_cfg * config);
Tony Lindgrena8eb7ca2010-02-12 12:26:48 -0800500#ifdef CONFIG_ARCH_OMAP3
Eduardo Valentin7aa9ff52009-08-20 16:18:10 +0300501void omap_mcbsp_set_tx_threshold(unsigned int id, u16 threshold);
502void omap_mcbsp_set_rx_threshold(unsigned int id, u16 threshold);
Eduardo Valentina1a56f5f2009-08-20 16:18:11 +0300503u16 omap_mcbsp_get_max_tx_threshold(unsigned int id);
504u16 omap_mcbsp_get_max_rx_threshold(unsigned int id);
Peter Ujfalusi0acce822010-06-03 07:39:32 +0300505u16 omap_mcbsp_get_fifo_size(unsigned int id);
Peter Ujfalusi7dc976e2010-03-03 15:08:08 +0200506u16 omap_mcbsp_get_tx_delay(unsigned int id);
507u16 omap_mcbsp_get_rx_delay(unsigned int id);
Peter Ujfalusi98cb20e2009-08-20 16:18:14 +0300508int omap_mcbsp_get_dma_op_mode(unsigned int id);
Eduardo Valentin7aa9ff52009-08-20 16:18:10 +0300509#else
510static inline void omap_mcbsp_set_tx_threshold(unsigned int id, u16 threshold)
511{ }
512static inline void omap_mcbsp_set_rx_threshold(unsigned int id, u16 threshold)
513{ }
Eduardo Valentina1a56f5f2009-08-20 16:18:11 +0300514static inline u16 omap_mcbsp_get_max_tx_threshold(unsigned int id) { return 0; }
515static inline u16 omap_mcbsp_get_max_rx_threshold(unsigned int id) { return 0; }
Peter Ujfalusi0acce822010-06-03 07:39:32 +0300516static inline u16 omap_mcbsp_get_fifo_size(unsigned int id) { return 0; }
Peter Ujfalusi7dc976e2010-03-03 15:08:08 +0200517static inline u16 omap_mcbsp_get_tx_delay(unsigned int id) { return 0; }
518static inline u16 omap_mcbsp_get_rx_delay(unsigned int id) { return 0; }
Peter Ujfalusi98cb20e2009-08-20 16:18:14 +0300519static inline int omap_mcbsp_get_dma_op_mode(unsigned int id) { return 0; }
Eduardo Valentin7aa9ff52009-08-20 16:18:10 +0300520#endif
Russell Kinga09e64f2008-08-05 16:14:15 +0100521int omap_mcbsp_request(unsigned int id);
522void omap_mcbsp_free(unsigned int id);
Jarkko Nikulac12abc02009-08-07 09:59:47 +0300523void omap_mcbsp_start(unsigned int id, int tx, int rx);
524void omap_mcbsp_stop(unsigned int id, int tx, int rx);
Russell Kinga09e64f2008-08-05 16:14:15 +0100525void omap_mcbsp_xmit_word(unsigned int id, u32 word);
526u32 omap_mcbsp_recv_word(unsigned int id);
527
528int omap_mcbsp_xmit_buffer(unsigned int id, dma_addr_t buffer, unsigned int length);
529int omap_mcbsp_recv_buffer(unsigned int id, dma_addr_t buffer, unsigned int length);
530int omap_mcbsp_spi_master_xmit_word_poll(unsigned int id, u32 word);
531int omap_mcbsp_spi_master_recv_word_poll(unsigned int id, u32 * word);
532
533
Paul Walmsleyd1358652010-10-08 11:40:19 -0600534/* McBSP functional clock source changing function */
535extern int omap2_mcbsp_set_clks_src(u8 id, u8 fck_src_id);
Russell Kinga09e64f2008-08-05 16:14:15 +0100536/* SPI specific API */
537void omap_mcbsp_set_spi_mode(unsigned int id, const struct omap_mcbsp_spi_cfg * spi_cfg);
538
539/* Polled read/write functions */
540int omap_mcbsp_pollread(unsigned int id, u16 * buf);
541int omap_mcbsp_pollwrite(unsigned int id, u16 buf);
Chandra Shekharb4b58f52008-10-08 10:01:39 +0300542int omap_mcbsp_set_io_type(unsigned int id, omap_mcbsp_io_type_t io_type);
Russell Kinga09e64f2008-08-05 16:14:15 +0100543
Paul Walmsleycf4c87a2010-10-08 11:40:19 -0600544/* McBSP signal muxing API */
545void omap2_mcbsp1_mux_clkr_src(u8 mux);
546void omap2_mcbsp1_mux_fsr_src(u8 mux);
547
Kishon Vijay Abraham I9504ba62011-02-24 15:16:55 +0530548int omap_mcbsp_dma_ch_params(unsigned int id, unsigned int stream);
549int omap_mcbsp_dma_reg_params(unsigned int id, unsigned int stream);
550
Eero Nurkkalad912fa92010-02-22 12:21:11 +0000551#ifdef CONFIG_ARCH_OMAP3
552/* Sidetone specific API */
553int omap_st_set_chgain(unsigned int id, int channel, s16 chgain);
554int omap_st_get_chgain(unsigned int id, int channel, s16 *chgain);
555int omap_st_enable(unsigned int id);
556int omap_st_disable(unsigned int id);
557int omap_st_is_enabled(unsigned int id);
558#else
559static inline int omap_st_set_chgain(unsigned int id, int channel,
560 s16 chgain) { return 0; }
561static inline int omap_st_get_chgain(unsigned int id, int channel,
562 s16 *chgain) { return 0; }
563static inline int omap_st_enable(unsigned int id) { return 0; }
564static inline int omap_st_disable(unsigned int id) { return 0; }
565static inline int omap_st_is_enabled(unsigned int id) { return 0; }
566#endif
567
Russell Kinga09e64f2008-08-05 16:14:15 +0100568#endif