2 * arch/arm/plat-omap/include/mach/mcbsp.h
4 * Defines for Multi-Channel Buffered Serial Port
6 * Copyright (C) 2002 RidgeRun, Inc.
7 * Author: Steve Johnson
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.
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.
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
24 #ifndef __ASM_ARCH_OMAP_MCBSP_H
25 #define __ASM_ARCH_OMAP_MCBSP_H
27 #include <linux/spinlock.h>
29 #include <mach/hardware.h>
30 #include <plat/clock.h>
32 /* macro for building platform_device for McBSP ports */
33 #define OMAP_MCBSP_PLATFORM_DEVICE(port_nr) \
34 static struct platform_device omap_mcbsp##port_nr = { \
35 .name = "omap-mcbsp-dai", \
39 #define MCBSP_CONFIG_TYPE2 0x2
40 #define MCBSP_CONFIG_TYPE3 0x3
41 #define MCBSP_CONFIG_TYPE4 0x4
43 #define OMAP7XX_MCBSP1_BASE 0xfffb1000
44 #define OMAP7XX_MCBSP2_BASE 0xfffb1800
46 #define OMAP1510_MCBSP1_BASE 0xe1011800
47 #define OMAP1510_MCBSP2_BASE 0xfffb1000
48 #define OMAP1510_MCBSP3_BASE 0xe1017000
50 #define OMAP1610_MCBSP1_BASE 0xe1011800
51 #define OMAP1610_MCBSP2_BASE 0xfffb1000
52 #define OMAP1610_MCBSP3_BASE 0xe1017000
54 #ifdef CONFIG_ARCH_OMAP1
56 #define OMAP_MCBSP_REG_DRR2 0x00
57 #define OMAP_MCBSP_REG_DRR1 0x02
58 #define OMAP_MCBSP_REG_DXR2 0x04
59 #define OMAP_MCBSP_REG_DXR1 0x06
60 #define OMAP_MCBSP_REG_DRR 0x02
61 #define OMAP_MCBSP_REG_DXR 0x06
62 #define OMAP_MCBSP_REG_SPCR2 0x08
63 #define OMAP_MCBSP_REG_SPCR1 0x0a
64 #define OMAP_MCBSP_REG_RCR2 0x0c
65 #define OMAP_MCBSP_REG_RCR1 0x0e
66 #define OMAP_MCBSP_REG_XCR2 0x10
67 #define OMAP_MCBSP_REG_XCR1 0x12
68 #define OMAP_MCBSP_REG_SRGR2 0x14
69 #define OMAP_MCBSP_REG_SRGR1 0x16
70 #define OMAP_MCBSP_REG_MCR2 0x18
71 #define OMAP_MCBSP_REG_MCR1 0x1a
72 #define OMAP_MCBSP_REG_RCERA 0x1c
73 #define OMAP_MCBSP_REG_RCERB 0x1e
74 #define OMAP_MCBSP_REG_XCERA 0x20
75 #define OMAP_MCBSP_REG_XCERB 0x22
76 #define OMAP_MCBSP_REG_PCR0 0x24
77 #define OMAP_MCBSP_REG_RCERC 0x26
78 #define OMAP_MCBSP_REG_RCERD 0x28
79 #define OMAP_MCBSP_REG_XCERC 0x2A
80 #define OMAP_MCBSP_REG_XCERD 0x2C
81 #define OMAP_MCBSP_REG_RCERE 0x2E
82 #define OMAP_MCBSP_REG_RCERF 0x30
83 #define OMAP_MCBSP_REG_XCERE 0x32
84 #define OMAP_MCBSP_REG_XCERF 0x34
85 #define OMAP_MCBSP_REG_RCERG 0x36
86 #define OMAP_MCBSP_REG_RCERH 0x38
87 #define OMAP_MCBSP_REG_XCERG 0x3A
88 #define OMAP_MCBSP_REG_XCERH 0x3C
90 /* Dummy defines, these are not available on omap1 */
91 #define OMAP_MCBSP_REG_XCCR 0x00
92 #define OMAP_MCBSP_REG_RCCR 0x00
96 #define OMAP_MCBSP_REG_DRR2 0x00
97 #define OMAP_MCBSP_REG_DRR1 0x04
98 #define OMAP_MCBSP_REG_DXR2 0x08
99 #define OMAP_MCBSP_REG_DXR1 0x0C
100 #define OMAP_MCBSP_REG_DRR 0x00
101 #define OMAP_MCBSP_REG_DXR 0x08
102 #define OMAP_MCBSP_REG_SPCR2 0x10
103 #define OMAP_MCBSP_REG_SPCR1 0x14
104 #define OMAP_MCBSP_REG_RCR2 0x18
105 #define OMAP_MCBSP_REG_RCR1 0x1C
106 #define OMAP_MCBSP_REG_XCR2 0x20
107 #define OMAP_MCBSP_REG_XCR1 0x24
108 #define OMAP_MCBSP_REG_SRGR2 0x28
109 #define OMAP_MCBSP_REG_SRGR1 0x2C
110 #define OMAP_MCBSP_REG_MCR2 0x30
111 #define OMAP_MCBSP_REG_MCR1 0x34
112 #define OMAP_MCBSP_REG_RCERA 0x38
113 #define OMAP_MCBSP_REG_RCERB 0x3C
114 #define OMAP_MCBSP_REG_XCERA 0x40
115 #define OMAP_MCBSP_REG_XCERB 0x44
116 #define OMAP_MCBSP_REG_PCR0 0x48
117 #define OMAP_MCBSP_REG_RCERC 0x4C
118 #define OMAP_MCBSP_REG_RCERD 0x50
119 #define OMAP_MCBSP_REG_XCERC 0x54
120 #define OMAP_MCBSP_REG_XCERD 0x58
121 #define OMAP_MCBSP_REG_RCERE 0x5C
122 #define OMAP_MCBSP_REG_RCERF 0x60
123 #define OMAP_MCBSP_REG_XCERE 0x64
124 #define OMAP_MCBSP_REG_XCERF 0x68
125 #define OMAP_MCBSP_REG_RCERG 0x6C
126 #define OMAP_MCBSP_REG_RCERH 0x70
127 #define OMAP_MCBSP_REG_XCERG 0x74
128 #define OMAP_MCBSP_REG_XCERH 0x78
129 #define OMAP_MCBSP_REG_SYSCON 0x8C
130 #define OMAP_MCBSP_REG_THRSH2 0x90
131 #define OMAP_MCBSP_REG_THRSH1 0x94
132 #define OMAP_MCBSP_REG_IRQST 0xA0
133 #define OMAP_MCBSP_REG_IRQEN 0xA4
134 #define OMAP_MCBSP_REG_WAKEUPEN 0xA8
135 #define OMAP_MCBSP_REG_XCCR 0xAC
136 #define OMAP_MCBSP_REG_RCCR 0xB0
137 #define OMAP_MCBSP_REG_XBUFFSTAT 0xB4
138 #define OMAP_MCBSP_REG_RBUFFSTAT 0xB8
139 #define OMAP_MCBSP_REG_SSELCR 0xBC
141 #define OMAP_ST_REG_REV 0x00
142 #define OMAP_ST_REG_SYSCONFIG 0x10
143 #define OMAP_ST_REG_IRQSTATUS 0x18
144 #define OMAP_ST_REG_IRQENABLE 0x1C
145 #define OMAP_ST_REG_SGAINCR 0x24
146 #define OMAP_ST_REG_SFIRCR 0x28
147 #define OMAP_ST_REG_SSELCR 0x2C
151 /************************** McBSP SPCR1 bit definitions ***********************/
155 #define RSYNC_ERR 0x0008
156 #define RINTM(value) ((value)<<4) /* bits 4:5 */
159 #define CLKSTP(value) ((value)<<11) /* bits 11:12 */
160 #define RJUST(value) ((value)<<13) /* bits 13:14 */
164 /************************** McBSP SPCR2 bit definitions ***********************/
167 #define XEMPTY 0x0004
168 #define XSYNC_ERR 0x0008
169 #define XINTM(value) ((value)<<4) /* bits 4:5 */
175 /************************** McBSP PCR bit definitions *************************/
180 #define DR_STAT 0x0010
181 #define DX_STAT 0x0020
182 #define CLKS_STAT 0x0040
183 #define SCLKME 0x0080
190 #define IDLE_EN 0x4000
192 /************************** McBSP RCR1 bit definitions ************************/
193 #define RWDLEN1(value) ((value)<<5) /* Bits 5:7 */
194 #define RFRLEN1(value) ((value)<<8) /* Bits 8:14 */
196 /************************** McBSP XCR1 bit definitions ************************/
197 #define XWDLEN1(value) ((value)<<5) /* Bits 5:7 */
198 #define XFRLEN1(value) ((value)<<8) /* Bits 8:14 */
200 /*************************** McBSP RCR2 bit definitions ***********************/
201 #define RDATDLY(value) (value) /* Bits 0:1 */
203 #define RCOMPAND(value) ((value)<<3) /* Bits 3:4 */
204 #define RWDLEN2(value) ((value)<<5) /* Bits 5:7 */
205 #define RFRLEN2(value) ((value)<<8) /* Bits 8:14 */
206 #define RPHASE 0x8000
208 /*************************** McBSP XCR2 bit definitions ***********************/
209 #define XDATDLY(value) (value) /* Bits 0:1 */
211 #define XCOMPAND(value) ((value)<<3) /* Bits 3:4 */
212 #define XWDLEN2(value) ((value)<<5) /* Bits 5:7 */
213 #define XFRLEN2(value) ((value)<<8) /* Bits 8:14 */
214 #define XPHASE 0x8000
216 /************************* McBSP SRGR1 bit definitions ************************/
217 #define CLKGDV(value) (value) /* Bits 0:7 */
218 #define FWID(value) ((value)<<8) /* Bits 8:15 */
220 /************************* McBSP SRGR2 bit definitions ************************/
221 #define FPER(value) (value) /* Bits 0:11 */
227 /************************* McBSP MCR1 bit definitions *************************/
229 #define RCBLK(value) ((value)<<2) /* Bits 2:4 */
230 #define RPABLK(value) ((value)<<5) /* Bits 5:6 */
231 #define RPBBLK(value) ((value)<<7) /* Bits 7:8 */
233 /************************* McBSP MCR2 bit definitions *************************/
234 #define XMCM(value) (value) /* Bits 0:1 */
235 #define XCBLK(value) ((value)<<2) /* Bits 2:4 */
236 #define XPABLK(value) ((value)<<5) /* Bits 5:6 */
237 #define XPBBLK(value) ((value)<<7) /* Bits 7:8 */
239 /*********************** McBSP XCCR bit definitions *************************/
240 #define EXTCLKGATE 0x8000
241 #define PPCONNECT 0x4000
242 #define DXENDLY(value) ((value)<<12) /* Bits 12:13 */
243 #define XFULL_CYCLE 0x0800
245 #define XDMAEN 0x0008
246 #define XDISABLE 0x0001
248 /********************** McBSP RCCR bit definitions *************************/
249 #define RFULL_CYCLE 0x0800
250 #define RDMAEN 0x0008
251 #define RDISABLE 0x0001
253 /********************** McBSP SYSCONFIG bit definitions ********************/
254 #define CLOCKACTIVITY(value) ((value)<<8)
255 #define SIDLEMODE(value) ((value)<<3)
256 #define ENAWAKEUP 0x0004
257 #define SOFTRST 0x0002
259 /********************** McBSP SSELCR bit definitions ***********************/
260 #define SIDETONEEN 0x0400
262 /********************** McBSP Sidetone SYSCONFIG bit definitions ***********/
263 #define ST_AUTOIDLE 0x0001
265 /********************** McBSP Sidetone SGAINCR bit definitions *************/
266 #define ST_CH1GAIN(value) ((value<<16)) /* Bits 16:31 */
267 #define ST_CH0GAIN(value) (value) /* Bits 0:15 */
269 /********************** McBSP Sidetone SFIRCR bit definitions **************/
270 #define ST_FIRCOEFF(value) (value) /* Bits 0:15 */
272 /********************** McBSP Sidetone SSELCR bit definitions **************/
273 #define ST_COEFFWRDONE 0x0004
274 #define ST_COEFFWREN 0x0002
275 #define ST_SIDETONEEN 0x0001
277 /********************** McBSP DMA operating modes **************************/
278 #define MCBSP_DMA_MODE_ELEMENT 0
279 #define MCBSP_DMA_MODE_THRESHOLD 1
280 #define MCBSP_DMA_MODE_FRAME 2
282 /********************** McBSP WAKEUPEN bit definitions *********************/
283 #define XEMPTYEOFEN 0x4000
284 #define XRDYEN 0x0400
285 #define XEOFEN 0x0200
286 #define XFSXEN 0x0100
287 #define XSYNCERREN 0x0080
288 #define RRDYEN 0x0008
289 #define REOFEN 0x0004
290 #define RFSREN 0x0002
291 #define RSYNCERREN 0x0001
293 /* CLKR signal muxing options */
294 #define CLKR_SRC_CLKR 0
295 #define CLKR_SRC_CLKX 1
297 /* FSR signal muxing options */
298 #define FSR_SRC_FSR 0
299 #define FSR_SRC_FSX 1
301 /* McBSP functional clock sources */
302 #define MCBSP_CLKS_PRCM_SRC 0
303 #define MCBSP_CLKS_PAD_SRC 1
305 /* we don't do multichannel for now */
306 struct omap_mcbsp_reg_cfg
{
335 OMAP_MCBSP_WORD_8
= 0,
341 } omap_mcbsp_word_length
;
343 /* Platform specific configuration */
344 struct omap_mcbsp_ops
{
345 void (*request
)(unsigned int);
346 void (*free
)(unsigned int);
347 int (*set_clks_src
)(u8
, u8
);
350 struct omap_mcbsp_platform_data
{
351 unsigned long phys_base
;
352 u8 dma_rx_sync
, dma_tx_sync
;
354 struct omap_mcbsp_ops
*ops
;
355 #ifdef CONFIG_ARCH_OMAP3
356 /* Sidetone block for McBSP 2 and 3 */
357 unsigned long phys_base_st
;
360 unsigned int mcbsp_config_type
;
363 struct omap_mcbsp_st_data
{
364 void __iomem
*io_base_st
;
367 s16 taps
[128]; /* Sidetone filter coefficients */
368 int nr_taps
; /* Number of filter coefficients in use */
375 unsigned long phys_base
;
376 unsigned long phys_dma_base
;
377 void __iomem
*io_base
;
388 /* Protect the field .free, while checking if the mcbsp is in use */
390 struct omap_mcbsp_platform_data
*pdata
;
392 #ifdef CONFIG_ARCH_OMAP3
393 struct omap_mcbsp_st_data
*st_data
;
399 unsigned int mcbsp_config_type
;
403 * omap_mcbsp_dev_attr - OMAP McBSP device attributes for omap_hwmod
404 * @sidetone: name of the sidetone device
406 struct omap_mcbsp_dev_attr
{
407 const char *sidetone
;
410 extern struct omap_mcbsp
**mcbsp_ptr
;
411 extern int omap_mcbsp_count
, omap_mcbsp_cache_size
;
413 #define omap_mcbsp_check_valid_id(id) (id < omap_mcbsp_count)
414 #define id_to_mcbsp_ptr(id) mcbsp_ptr[id];
416 int omap_mcbsp_init(void);
417 void omap_mcbsp_register_board_cfg(struct resource
*res
, int res_count
,
418 struct omap_mcbsp_platform_data
*config
, int size
);
419 void omap_mcbsp_config(unsigned int id
, const struct omap_mcbsp_reg_cfg
* config
);
420 #ifdef CONFIG_ARCH_OMAP3
421 void omap_mcbsp_set_tx_threshold(unsigned int id
, u16 threshold
);
422 void omap_mcbsp_set_rx_threshold(unsigned int id
, u16 threshold
);
423 u16
omap_mcbsp_get_max_tx_threshold(unsigned int id
);
424 u16
omap_mcbsp_get_max_rx_threshold(unsigned int id
);
425 u16
omap_mcbsp_get_fifo_size(unsigned int id
);
426 u16
omap_mcbsp_get_tx_delay(unsigned int id
);
427 u16
omap_mcbsp_get_rx_delay(unsigned int id
);
428 int omap_mcbsp_get_dma_op_mode(unsigned int id
);
430 static inline void omap_mcbsp_set_tx_threshold(unsigned int id
, u16 threshold
)
432 static inline void omap_mcbsp_set_rx_threshold(unsigned int id
, u16 threshold
)
434 static inline u16
omap_mcbsp_get_max_tx_threshold(unsigned int id
) { return 0; }
435 static inline u16
omap_mcbsp_get_max_rx_threshold(unsigned int id
) { return 0; }
436 static inline u16
omap_mcbsp_get_fifo_size(unsigned int id
) { return 0; }
437 static inline u16
omap_mcbsp_get_tx_delay(unsigned int id
) { return 0; }
438 static inline u16
omap_mcbsp_get_rx_delay(unsigned int id
) { return 0; }
439 static inline int omap_mcbsp_get_dma_op_mode(unsigned int id
) { return 0; }
441 int omap_mcbsp_request(unsigned int id
);
442 void omap_mcbsp_free(unsigned int id
);
443 void omap_mcbsp_start(unsigned int id
, int tx
, int rx
);
444 void omap_mcbsp_stop(unsigned int id
, int tx
, int rx
);
446 /* McBSP functional clock source changing function */
447 extern int omap2_mcbsp_set_clks_src(u8 id
, u8 fck_src_id
);
449 /* McBSP signal muxing API */
450 void omap2_mcbsp1_mux_clkr_src(u8 mux
);
451 void omap2_mcbsp1_mux_fsr_src(u8 mux
);
453 int omap_mcbsp_dma_ch_params(unsigned int id
, unsigned int stream
);
454 int omap_mcbsp_dma_reg_params(unsigned int id
, unsigned int stream
);
456 #ifdef CONFIG_ARCH_OMAP3
457 /* Sidetone specific API */
458 int omap_st_set_chgain(unsigned int id
, int channel
, s16 chgain
);
459 int omap_st_get_chgain(unsigned int id
, int channel
, s16
*chgain
);
460 int omap_st_enable(unsigned int id
);
461 int omap_st_disable(unsigned int id
);
462 int omap_st_is_enabled(unsigned int id
);
464 static inline int omap_st_set_chgain(unsigned int id
, int channel
,
465 s16 chgain
) { return 0; }
466 static inline int omap_st_get_chgain(unsigned int id
, int channel
,
467 s16
*chgain
) { return 0; }
468 static inline int omap_st_enable(unsigned int id
) { return 0; }
469 static inline int omap_st_disable(unsigned int id
) { return 0; }
470 static inline int omap_st_is_enabled(unsigned int id
) { return 0; }