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>
28 #include <linux/clk.h>
30 /* macro for building platform_device for McBSP ports */
31 #define OMAP_MCBSP_PLATFORM_DEVICE(port_nr) \
32 static struct platform_device omap_mcbsp##port_nr = { \
33 .name = "omap-mcbsp-dai", \
37 #define MCBSP_CONFIG_TYPE2 0x2
38 #define MCBSP_CONFIG_TYPE3 0x3
39 #define MCBSP_CONFIG_TYPE4 0x4
41 /* McBSP register numbers. Register address offset = num * reg_step */
43 /* Common registers */
44 OMAP_MCBSP_REG_SPCR2
= 4,
72 /* OMAP1-OMAP2420 registers */
73 OMAP_MCBSP_REG_DRR2
= 0,
78 /* OMAP2430 and onwards */
79 OMAP_MCBSP_REG_DRR
= 0,
80 OMAP_MCBSP_REG_DXR
= 2,
81 OMAP_MCBSP_REG_SYSCON
= 35,
82 OMAP_MCBSP_REG_THRSH2
,
83 OMAP_MCBSP_REG_THRSH1
,
84 OMAP_MCBSP_REG_IRQST
= 40,
86 OMAP_MCBSP_REG_WAKEUPEN
,
89 OMAP_MCBSP_REG_XBUFFSTAT
,
90 OMAP_MCBSP_REG_RBUFFSTAT
,
91 OMAP_MCBSP_REG_SSELCR
,
94 /* OMAP3 sidetone control registers */
95 #define OMAP_ST_REG_REV 0x00
96 #define OMAP_ST_REG_SYSCONFIG 0x10
97 #define OMAP_ST_REG_IRQSTATUS 0x18
98 #define OMAP_ST_REG_IRQENABLE 0x1C
99 #define OMAP_ST_REG_SGAINCR 0x24
100 #define OMAP_ST_REG_SFIRCR 0x28
101 #define OMAP_ST_REG_SSELCR 0x2C
103 /************************** McBSP SPCR1 bit definitions ***********************/
107 #define RSYNC_ERR 0x0008
108 #define RINTM(value) ((value)<<4) /* bits 4:5 */
111 #define CLKSTP(value) ((value)<<11) /* bits 11:12 */
112 #define RJUST(value) ((value)<<13) /* bits 13:14 */
116 /************************** McBSP SPCR2 bit definitions ***********************/
119 #define XEMPTY 0x0004
120 #define XSYNC_ERR 0x0008
121 #define XINTM(value) ((value)<<4) /* bits 4:5 */
127 /************************** McBSP PCR bit definitions *************************/
132 #define DR_STAT 0x0010
133 #define DX_STAT 0x0020
134 #define CLKS_STAT 0x0040
135 #define SCLKME 0x0080
142 #define IDLE_EN 0x4000
144 /************************** McBSP RCR1 bit definitions ************************/
145 #define RWDLEN1(value) ((value)<<5) /* Bits 5:7 */
146 #define RFRLEN1(value) ((value)<<8) /* Bits 8:14 */
148 /************************** McBSP XCR1 bit definitions ************************/
149 #define XWDLEN1(value) ((value)<<5) /* Bits 5:7 */
150 #define XFRLEN1(value) ((value)<<8) /* Bits 8:14 */
152 /*************************** McBSP RCR2 bit definitions ***********************/
153 #define RDATDLY(value) (value) /* Bits 0:1 */
155 #define RCOMPAND(value) ((value)<<3) /* Bits 3:4 */
156 #define RWDLEN2(value) ((value)<<5) /* Bits 5:7 */
157 #define RFRLEN2(value) ((value)<<8) /* Bits 8:14 */
158 #define RPHASE 0x8000
160 /*************************** McBSP XCR2 bit definitions ***********************/
161 #define XDATDLY(value) (value) /* Bits 0:1 */
163 #define XCOMPAND(value) ((value)<<3) /* Bits 3:4 */
164 #define XWDLEN2(value) ((value)<<5) /* Bits 5:7 */
165 #define XFRLEN2(value) ((value)<<8) /* Bits 8:14 */
166 #define XPHASE 0x8000
168 /************************* McBSP SRGR1 bit definitions ************************/
169 #define CLKGDV(value) (value) /* Bits 0:7 */
170 #define FWID(value) ((value)<<8) /* Bits 8:15 */
172 /************************* McBSP SRGR2 bit definitions ************************/
173 #define FPER(value) (value) /* Bits 0:11 */
179 /************************* McBSP MCR1 bit definitions *************************/
181 #define RCBLK(value) ((value)<<2) /* Bits 2:4 */
182 #define RPABLK(value) ((value)<<5) /* Bits 5:6 */
183 #define RPBBLK(value) ((value)<<7) /* Bits 7:8 */
185 /************************* McBSP MCR2 bit definitions *************************/
186 #define XMCM(value) (value) /* Bits 0:1 */
187 #define XCBLK(value) ((value)<<2) /* Bits 2:4 */
188 #define XPABLK(value) ((value)<<5) /* Bits 5:6 */
189 #define XPBBLK(value) ((value)<<7) /* Bits 7:8 */
191 /*********************** McBSP XCCR bit definitions *************************/
192 #define EXTCLKGATE 0x8000
193 #define PPCONNECT 0x4000
194 #define DXENDLY(value) ((value)<<12) /* Bits 12:13 */
195 #define XFULL_CYCLE 0x0800
197 #define XDMAEN 0x0008
198 #define XDISABLE 0x0001
200 /********************** McBSP RCCR bit definitions *************************/
201 #define RFULL_CYCLE 0x0800
202 #define RDMAEN 0x0008
203 #define RDISABLE 0x0001
205 /********************** McBSP SYSCONFIG bit definitions ********************/
206 #define CLOCKACTIVITY(value) ((value)<<8)
207 #define SIDLEMODE(value) ((value)<<3)
208 #define ENAWAKEUP 0x0004
209 #define SOFTRST 0x0002
211 /********************** McBSP SSELCR bit definitions ***********************/
212 #define SIDETONEEN 0x0400
214 /********************** McBSP Sidetone SYSCONFIG bit definitions ***********/
215 #define ST_AUTOIDLE 0x0001
217 /********************** McBSP Sidetone SGAINCR bit definitions *************/
218 #define ST_CH1GAIN(value) ((value<<16)) /* Bits 16:31 */
219 #define ST_CH0GAIN(value) (value) /* Bits 0:15 */
221 /********************** McBSP Sidetone SFIRCR bit definitions **************/
222 #define ST_FIRCOEFF(value) (value) /* Bits 0:15 */
224 /********************** McBSP Sidetone SSELCR bit definitions **************/
225 #define ST_COEFFWRDONE 0x0004
226 #define ST_COEFFWREN 0x0002
227 #define ST_SIDETONEEN 0x0001
229 /********************** McBSP DMA operating modes **************************/
230 #define MCBSP_DMA_MODE_ELEMENT 0
231 #define MCBSP_DMA_MODE_THRESHOLD 1
232 #define MCBSP_DMA_MODE_FRAME 2
234 /********************** McBSP WAKEUPEN bit definitions *********************/
235 #define XEMPTYEOFEN 0x4000
236 #define XRDYEN 0x0400
237 #define XEOFEN 0x0200
238 #define XFSXEN 0x0100
239 #define XSYNCERREN 0x0080
240 #define RRDYEN 0x0008
241 #define REOFEN 0x0004
242 #define RFSREN 0x0002
243 #define RSYNCERREN 0x0001
245 /* CLKR signal muxing options */
246 #define CLKR_SRC_CLKR 0
247 #define CLKR_SRC_CLKX 1
249 /* FSR signal muxing options */
250 #define FSR_SRC_FSR 0
251 #define FSR_SRC_FSX 1
253 /* McBSP functional clock sources */
254 #define MCBSP_CLKS_PRCM_SRC 0
255 #define MCBSP_CLKS_PAD_SRC 1
257 /* we don't do multichannel for now */
258 struct omap_mcbsp_reg_cfg
{
287 OMAP_MCBSP_WORD_8
= 0,
293 } omap_mcbsp_word_length
;
295 /* Platform specific configuration */
296 struct omap_mcbsp_ops
{
297 void (*request
)(unsigned int);
298 void (*free
)(unsigned int);
301 struct omap_mcbsp_platform_data
{
302 struct omap_mcbsp_ops
*ops
;
307 /* McBSP platform and instance specific features */
308 bool has_wakeup
; /* Wakeup capability */
309 bool has_ccr
; /* Transceiver has configuration control registers */
310 int (*enable_st_clock
)(unsigned int, bool);
311 int (*set_clk_src
)(struct device
*dev
, struct clk
*clk
, const char *src
);
312 int (*mux_signal
)(struct device
*dev
, const char *signal
, const char *src
);
315 struct omap_mcbsp_st_data
{
316 void __iomem
*io_base_st
;
319 s16 taps
[128]; /* Sidetone filter coefficients */
320 int nr_taps
; /* Number of filter coefficients in use */
327 unsigned long phys_base
;
328 unsigned long phys_dma_base
;
329 void __iomem
*io_base
;
340 /* Protect the field .free, while checking if the mcbsp is in use */
342 struct omap_mcbsp_platform_data
*pdata
;
344 struct omap_mcbsp_st_data
*st_data
;
353 * omap_mcbsp_dev_attr - OMAP McBSP device attributes for omap_hwmod
354 * @sidetone: name of the sidetone device
356 struct omap_mcbsp_dev_attr
{
357 const char *sidetone
;
360 extern struct omap_mcbsp
**mcbsp_ptr
;
361 extern int omap_mcbsp_count
;
363 int omap_mcbsp_init(void);
364 void omap_mcbsp_config(unsigned int id
, const struct omap_mcbsp_reg_cfg
* config
);
365 void omap_mcbsp_set_tx_threshold(unsigned int id
, u16 threshold
);
366 void omap_mcbsp_set_rx_threshold(unsigned int id
, u16 threshold
);
367 u16
omap_mcbsp_get_max_tx_threshold(unsigned int id
);
368 u16
omap_mcbsp_get_max_rx_threshold(unsigned int id
);
369 u16
omap_mcbsp_get_fifo_size(unsigned int id
);
370 u16
omap_mcbsp_get_tx_delay(unsigned int id
);
371 u16
omap_mcbsp_get_rx_delay(unsigned int id
);
372 int omap_mcbsp_get_dma_op_mode(unsigned int id
);
373 int omap_mcbsp_request(unsigned int id
);
374 void omap_mcbsp_free(unsigned int id
);
375 void omap_mcbsp_start(unsigned int id
, int tx
, int rx
);
376 void omap_mcbsp_stop(unsigned int id
, int tx
, int rx
);
378 /* McBSP functional clock source changing function */
379 extern int omap2_mcbsp_set_clks_src(u8 id
, u8 fck_src_id
);
381 /* McBSP signal muxing API */
382 void omap2_mcbsp1_mux_clkr_src(u8 mux
);
383 void omap2_mcbsp1_mux_fsr_src(u8 mux
);
385 int omap_mcbsp_dma_ch_params(unsigned int id
, unsigned int stream
);
386 int omap_mcbsp_dma_reg_params(unsigned int id
, unsigned int stream
);
388 /* Sidetone specific API */
389 int omap_st_set_chgain(unsigned int id
, int channel
, s16 chgain
);
390 int omap_st_get_chgain(unsigned int id
, int channel
, s16
*chgain
);
391 int omap_st_enable(unsigned int id
);
392 int omap_st_disable(unsigned int id
);
393 int omap_st_is_enabled(unsigned int id
);