2 * linux/include/asm-arm/arch-omap/gpio.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 <asm/arch/hardware.h>
29 #define OMAP730_MCBSP1_BASE 0xfffb1000
30 #define OMAP730_MCBSP2_BASE 0xfffb1800
32 #define OMAP1510_MCBSP1_BASE 0xe1011800
33 #define OMAP1510_MCBSP2_BASE 0xfffb1000
34 #define OMAP1510_MCBSP3_BASE 0xe1017000
36 #define OMAP1610_MCBSP1_BASE 0xe1011800
37 #define OMAP1610_MCBSP2_BASE 0xfffb1000
38 #define OMAP1610_MCBSP3_BASE 0xe1017000
40 #define OMAP_MCBSP_REG_DRR2 0x00
41 #define OMAP_MCBSP_REG_DRR1 0x02
42 #define OMAP_MCBSP_REG_DXR2 0x04
43 #define OMAP_MCBSP_REG_DXR1 0x06
44 #define OMAP_MCBSP_REG_SPCR2 0x08
45 #define OMAP_MCBSP_REG_SPCR1 0x0a
46 #define OMAP_MCBSP_REG_RCR2 0x0c
47 #define OMAP_MCBSP_REG_RCR1 0x0e
48 #define OMAP_MCBSP_REG_XCR2 0x10
49 #define OMAP_MCBSP_REG_XCR1 0x12
50 #define OMAP_MCBSP_REG_SRGR2 0x14
51 #define OMAP_MCBSP_REG_SRGR1 0x16
52 #define OMAP_MCBSP_REG_MCR2 0x18
53 #define OMAP_MCBSP_REG_MCR1 0x1a
54 #define OMAP_MCBSP_REG_RCERA 0x1c
55 #define OMAP_MCBSP_REG_RCERB 0x1e
56 #define OMAP_MCBSP_REG_XCERA 0x20
57 #define OMAP_MCBSP_REG_XCERB 0x22
58 #define OMAP_MCBSP_REG_PCR0 0x24
59 #define OMAP_MCBSP_REG_RCERC 0x26
60 #define OMAP_MCBSP_REG_RCERD 0x28
61 #define OMAP_MCBSP_REG_XCERC 0x2A
62 #define OMAP_MCBSP_REG_XCERD 0x2C
63 #define OMAP_MCBSP_REG_RCERE 0x2E
64 #define OMAP_MCBSP_REG_RCERF 0x30
65 #define OMAP_MCBSP_REG_XCERE 0x32
66 #define OMAP_MCBSP_REG_XCERF 0x34
67 #define OMAP_MCBSP_REG_RCERG 0x36
68 #define OMAP_MCBSP_REG_RCERH 0x38
69 #define OMAP_MCBSP_REG_XCERG 0x3A
70 #define OMAP_MCBSP_REG_XCERH 0x3C
72 #define OMAP_MAX_MCBSP_COUNT 3
74 #define OMAP_MCBSP_READ(base, reg) __raw_readw((base) + OMAP_MCBSP_REG_##reg)
75 #define OMAP_MCBSP_WRITE(base, reg, val) __raw_writew((val), (base) + OMAP_MCBSP_REG_##reg)
77 /************************** McBSP SPCR1 bit definitions ***********************/
81 #define RSYNC_ERR 0x0008
82 #define RINTM(value) ((value)<<4) /* bits 4:5 */
85 #define CLKSTP(value) ((value)<<11) /* bits 11:12 */
86 #define RJUST(value) ((value)<<13) /* bits 13:14 */
89 /************************** McBSP SPCR2 bit definitions ***********************/
93 #define XSYNC_ERR 0x0008
94 #define XINTM(value) ((value)<<4) /* bits 4:5 */
100 /************************** McBSP PCR bit definitions *************************/
105 #define DR_STAT 0x0010
106 #define DX_STAT 0x0020
107 #define CLKS_STAT 0x0040
108 #define SCLKME 0x0080
115 #define IDLE_EN 0x4000
117 /************************** McBSP RCR1 bit definitions ************************/
118 #define RWDLEN1(value) ((value)<<5) /* Bits 5:7 */
119 #define RFRLEN1(value) ((value)<<8) /* Bits 8:14 */
121 /************************** McBSP XCR1 bit definitions ************************/
122 #define XWDLEN1(value) ((value)<<5) /* Bits 5:7 */
123 #define XFRLEN1(value) ((value)<<8) /* Bits 8:14 */
125 /*************************** McBSP RCR2 bit definitions ***********************/
126 #define RDATDLY(value) (value) /* Bits 0:1 */
128 #define RCOMPAND(value) ((value)<<3) /* Bits 3:4 */
129 #define RWDLEN2(value) ((value)<<5) /* Bits 5:7 */
130 #define RFRLEN2(value) ((value)<<8) /* Bits 8:14 */
131 #define RPHASE 0x8000
133 /*************************** McBSP XCR2 bit definitions ***********************/
134 #define XDATDLY(value) (value) /* Bits 0:1 */
136 #define XCOMPAND(value) ((value)<<3) /* Bits 3:4 */
137 #define XWDLEN2(value) ((value)<<5) /* Bits 5:7 */
138 #define XFRLEN2(value) ((value)<<8) /* Bits 8:14 */
139 #define XPHASE 0x8000
141 /************************* McBSP SRGR1 bit definitions ************************/
142 #define CLKGDV(value) (value) /* Bits 0:7 */
143 #define FWID(value) ((value)<<8) /* Bits 8:15 */
145 /************************* McBSP SRGR2 bit definitions ************************/
146 #define FPER(value) (value) /* Bits 0:11 */
152 /************************* McBSP MCR1 bit definitions *************************/
154 #define RCBLK(value) ((value)<<2) /* Bits 2:4 */
155 #define RPABLK(value) ((value)<<5) /* Bits 5:6 */
156 #define RPBBLK(value) ((value)<<7) /* Bits 7:8 */
158 /************************* McBSP MCR2 bit definitions *************************/
159 #define XMCM(value) (value) /* Bits 0:1 */
160 #define XCBLK(value) ((value)<<2) /* Bits 2:4 */
161 #define XPABLK(value) ((value)<<5) /* Bits 5:6 */
162 #define XPBBLK(value) ((value)<<7) /* Bits 7:8 */
165 /* we don't do multichannel for now */
166 struct omap_mcbsp_reg_cfg
{
199 OMAP_MCBSP_WORD_8
= 0,
205 } omap_mcbsp_word_length
;
208 OMAP_MCBSP_CLK_RISING
= 0,
209 OMAP_MCBSP_CLK_FALLING
,
210 } omap_mcbsp_clk_polarity
;
213 OMAP_MCBSP_FS_ACTIVE_HIGH
= 0,
214 OMAP_MCBSP_FS_ACTIVE_LOW
,
215 } omap_mcbsp_fs_polarity
;
218 OMAP_MCBSP_CLK_STP_MODE_NO_DELAY
= 0,
219 OMAP_MCBSP_CLK_STP_MODE_DELAY
,
220 } omap_mcbsp_clk_stp_mode
;
223 /******* SPI specific mode **********/
225 OMAP_MCBSP_SPI_MASTER
= 0,
226 OMAP_MCBSP_SPI_SLAVE
,
227 } omap_mcbsp_spi_mode
;
229 struct omap_mcbsp_spi_cfg
{
230 omap_mcbsp_spi_mode spi_mode
;
231 omap_mcbsp_clk_polarity rx_clock_polarity
;
232 omap_mcbsp_clk_polarity tx_clock_polarity
;
233 omap_mcbsp_fs_polarity fsx_polarity
;
235 omap_mcbsp_clk_stp_mode clk_stp_mode
;
236 omap_mcbsp_word_length word_length
;
239 void omap_mcbsp_config(unsigned int id
, const struct omap_mcbsp_reg_cfg
* config
);
240 int omap_mcbsp_request(unsigned int id
);
241 void omap_mcbsp_free(unsigned int id
);
242 void omap_mcbsp_start(unsigned int id
);
243 void omap_mcbsp_stop(unsigned int id
);
244 void omap_mcbsp_xmit_word(unsigned int id
, u32 word
);
245 u32
omap_mcbsp_recv_word(unsigned int id
);
247 int omap_mcbsp_xmit_buffer(unsigned int id
, dma_addr_t buffer
, unsigned int length
);
248 int omap_mcbsp_recv_buffer(unsigned int id
, dma_addr_t buffer
, unsigned int length
);
250 /* SPI specific API */
251 void omap_mcbsp_set_spi_mode(unsigned int id
, const struct omap_mcbsp_spi_cfg
* spi_cfg
);
253 /* Polled read/write functions */
254 int omap_mcbsp_pollread(unsigned int id
, u16
* buf
);
255 int omap_mcbsp_pollwrite(unsigned int id
, u16 buf
);