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 /* McBSP register numbers. Register address offset = num * reg_step */
56 /* Common registers */
57 OMAP_MCBSP_REG_SPCR2 = 4,
85 /* OMAP1-OMAP2420 registers */
86 OMAP_MCBSP_REG_DRR2 = 0,
91 /* OMAP2430 and onwards */
92 OMAP_MCBSP_REG_DRR = 0,
93 OMAP_MCBSP_REG_DXR = 2,
94 OMAP_MCBSP_REG_SYSCON = 35,
95 OMAP_MCBSP_REG_THRSH2,
96 OMAP_MCBSP_REG_THRSH1,
97 OMAP_MCBSP_REG_IRQST = 40,
99 OMAP_MCBSP_REG_WAKEUPEN,
102 OMAP_MCBSP_REG_XBUFFSTAT,
103 OMAP_MCBSP_REG_RBUFFSTAT,
104 OMAP_MCBSP_REG_SSELCR,
107 /* OMAP3 sidetone control registers */
108 #define OMAP_ST_REG_REV 0x00
109 #define OMAP_ST_REG_SYSCONFIG 0x10
110 #define OMAP_ST_REG_IRQSTATUS 0x18
111 #define OMAP_ST_REG_IRQENABLE 0x1C
112 #define OMAP_ST_REG_SGAINCR 0x24
113 #define OMAP_ST_REG_SFIRCR 0x28
114 #define OMAP_ST_REG_SSELCR 0x2C
116 /************************** McBSP SPCR1 bit definitions ***********************/
120 #define RSYNC_ERR 0x0008
121 #define RINTM(value) ((value)<<4) /* bits 4:5 */
124 #define CLKSTP(value) ((value)<<11) /* bits 11:12 */
125 #define RJUST(value) ((value)<<13) /* bits 13:14 */
129 /************************** McBSP SPCR2 bit definitions ***********************/
132 #define XEMPTY 0x0004
133 #define XSYNC_ERR 0x0008
134 #define XINTM(value) ((value)<<4) /* bits 4:5 */
140 /************************** McBSP PCR bit definitions *************************/
145 #define DR_STAT 0x0010
146 #define DX_STAT 0x0020
147 #define CLKS_STAT 0x0040
148 #define SCLKME 0x0080
155 #define IDLE_EN 0x4000
157 /************************** McBSP RCR1 bit definitions ************************/
158 #define RWDLEN1(value) ((value)<<5) /* Bits 5:7 */
159 #define RFRLEN1(value) ((value)<<8) /* Bits 8:14 */
161 /************************** McBSP XCR1 bit definitions ************************/
162 #define XWDLEN1(value) ((value)<<5) /* Bits 5:7 */
163 #define XFRLEN1(value) ((value)<<8) /* Bits 8:14 */
165 /*************************** McBSP RCR2 bit definitions ***********************/
166 #define RDATDLY(value) (value) /* Bits 0:1 */
168 #define RCOMPAND(value) ((value)<<3) /* Bits 3:4 */
169 #define RWDLEN2(value) ((value)<<5) /* Bits 5:7 */
170 #define RFRLEN2(value) ((value)<<8) /* Bits 8:14 */
171 #define RPHASE 0x8000
173 /*************************** McBSP XCR2 bit definitions ***********************/
174 #define XDATDLY(value) (value) /* Bits 0:1 */
176 #define XCOMPAND(value) ((value)<<3) /* Bits 3:4 */
177 #define XWDLEN2(value) ((value)<<5) /* Bits 5:7 */
178 #define XFRLEN2(value) ((value)<<8) /* Bits 8:14 */
179 #define XPHASE 0x8000
181 /************************* McBSP SRGR1 bit definitions ************************/
182 #define CLKGDV(value) (value) /* Bits 0:7 */
183 #define FWID(value) ((value)<<8) /* Bits 8:15 */
185 /************************* McBSP SRGR2 bit definitions ************************/
186 #define FPER(value) (value) /* Bits 0:11 */
192 /************************* McBSP MCR1 bit definitions *************************/
194 #define RCBLK(value) ((value)<<2) /* Bits 2:4 */
195 #define RPABLK(value) ((value)<<5) /* Bits 5:6 */
196 #define RPBBLK(value) ((value)<<7) /* Bits 7:8 */
198 /************************* McBSP MCR2 bit definitions *************************/
199 #define XMCM(value) (value) /* Bits 0:1 */
200 #define XCBLK(value) ((value)<<2) /* Bits 2:4 */
201 #define XPABLK(value) ((value)<<5) /* Bits 5:6 */
202 #define XPBBLK(value) ((value)<<7) /* Bits 7:8 */
204 /*********************** McBSP XCCR bit definitions *************************/
205 #define EXTCLKGATE 0x8000
206 #define PPCONNECT 0x4000
207 #define DXENDLY(value) ((value)<<12) /* Bits 12:13 */
208 #define XFULL_CYCLE 0x0800
210 #define XDMAEN 0x0008
211 #define XDISABLE 0x0001
213 /********************** McBSP RCCR bit definitions *************************/
214 #define RFULL_CYCLE 0x0800
215 #define RDMAEN 0x0008
216 #define RDISABLE 0x0001
218 /********************** McBSP SYSCONFIG bit definitions ********************/
219 #define CLOCKACTIVITY(value) ((value)<<8)
220 #define SIDLEMODE(value) ((value)<<3)
221 #define ENAWAKEUP 0x0004
222 #define SOFTRST 0x0002
224 /********************** McBSP SSELCR bit definitions ***********************/
225 #define SIDETONEEN 0x0400
227 /********************** McBSP Sidetone SYSCONFIG bit definitions ***********/
228 #define ST_AUTOIDLE 0x0001
230 /********************** McBSP Sidetone SGAINCR bit definitions *************/
231 #define ST_CH1GAIN(value) ((value<<16)) /* Bits 16:31 */
232 #define ST_CH0GAIN(value) (value) /* Bits 0:15 */
234 /********************** McBSP Sidetone SFIRCR bit definitions **************/
235 #define ST_FIRCOEFF(value) (value) /* Bits 0:15 */
237 /********************** McBSP Sidetone SSELCR bit definitions **************/
238 #define ST_COEFFWRDONE 0x0004
239 #define ST_COEFFWREN 0x0002
240 #define ST_SIDETONEEN 0x0001
242 /********************** McBSP DMA operating modes **************************/
243 #define MCBSP_DMA_MODE_ELEMENT 0
244 #define MCBSP_DMA_MODE_THRESHOLD 1
245 #define MCBSP_DMA_MODE_FRAME 2
247 /********************** McBSP WAKEUPEN bit definitions *********************/
248 #define XEMPTYEOFEN 0x4000
249 #define XRDYEN 0x0400
250 #define XEOFEN 0x0200
251 #define XFSXEN 0x0100
252 #define XSYNCERREN 0x0080
253 #define RRDYEN 0x0008
254 #define REOFEN 0x0004
255 #define RFSREN 0x0002
256 #define RSYNCERREN 0x0001
258 /* CLKR signal muxing options */
259 #define CLKR_SRC_CLKR 0
260 #define CLKR_SRC_CLKX 1
262 /* FSR signal muxing options */
263 #define FSR_SRC_FSR 0
264 #define FSR_SRC_FSX 1
266 /* McBSP functional clock sources */
267 #define MCBSP_CLKS_PRCM_SRC 0
268 #define MCBSP_CLKS_PAD_SRC 1
270 /* we don't do multichannel for now */
271 struct omap_mcbsp_reg_cfg {
300 OMAP_MCBSP_WORD_8 = 0,
306 } omap_mcbsp_word_length;
308 /* Platform specific configuration */
309 struct omap_mcbsp_ops {
310 void (*request)(unsigned int);
311 void (*free)(unsigned int);
312 int (*set_clks_src)(u8, u8);
315 struct omap_mcbsp_platform_data {
316 struct omap_mcbsp_ops *ops;
321 /* McBSP platform and instance specific features */
322 bool has_wakeup; /* Wakeup capability */
323 bool has_ccr; /* Transceiver has configuration control registers */
326 struct omap_mcbsp_st_data {
327 void __iomem *io_base_st;
330 s16 taps[128]; /* Sidetone filter coefficients */
331 int nr_taps; /* Number of filter coefficients in use */
338 unsigned long phys_base;
339 unsigned long phys_dma_base;
340 void __iomem *io_base;
351 /* Protect the field .free, while checking if the mcbsp is in use */
353 struct omap_mcbsp_platform_data *pdata;
355 #ifdef CONFIG_ARCH_OMAP3
356 struct omap_mcbsp_st_data *st_data;
366 * omap_mcbsp_dev_attr - OMAP McBSP device attributes for omap_hwmod
367 * @sidetone: name of the sidetone device
369 struct omap_mcbsp_dev_attr {
370 const char *sidetone;
373 extern struct omap_mcbsp **mcbsp_ptr;
374 extern int omap_mcbsp_count;
376 #define omap_mcbsp_check_valid_id(id) (id < omap_mcbsp_count)
377 #define id_to_mcbsp_ptr(id) mcbsp_ptr[id];
379 int omap_mcbsp_init(void);
380 void omap_mcbsp_config(unsigned int id, const struct omap_mcbsp_reg_cfg * config);
381 void omap_mcbsp_set_tx_threshold(unsigned int id, u16 threshold);
382 void omap_mcbsp_set_rx_threshold(unsigned int id, u16 threshold);
383 u16 omap_mcbsp_get_max_tx_threshold(unsigned int id);
384 u16 omap_mcbsp_get_max_rx_threshold(unsigned int id);
385 u16 omap_mcbsp_get_fifo_size(unsigned int id);
386 u16 omap_mcbsp_get_tx_delay(unsigned int id);
387 u16 omap_mcbsp_get_rx_delay(unsigned int id);
388 int omap_mcbsp_get_dma_op_mode(unsigned int id);
389 int omap_mcbsp_request(unsigned int id);
390 void omap_mcbsp_free(unsigned int id);
391 void omap_mcbsp_start(unsigned int id, int tx, int rx);
392 void omap_mcbsp_stop(unsigned int id, int tx, int rx);
394 /* McBSP functional clock source changing function */
395 extern int omap2_mcbsp_set_clks_src(u8 id, u8 fck_src_id);
397 /* McBSP signal muxing API */
398 void omap2_mcbsp1_mux_clkr_src(u8 mux);
399 void omap2_mcbsp1_mux_fsr_src(u8 mux);
401 int omap_mcbsp_dma_ch_params(unsigned int id, unsigned int stream);
402 int omap_mcbsp_dma_reg_params(unsigned int id, unsigned int stream);
404 #ifdef CONFIG_ARCH_OMAP3
405 /* Sidetone specific API */
406 int omap_st_set_chgain(unsigned int id, int channel, s16 chgain);
407 int omap_st_get_chgain(unsigned int id, int channel, s16 *chgain);
408 int omap_st_enable(unsigned int id);
409 int omap_st_disable(unsigned int id);
410 int omap_st_is_enabled(unsigned int id);
412 static inline int omap_st_set_chgain(unsigned int id, int channel,
413 s16 chgain) { return 0; }
414 static inline int omap_st_get_chgain(unsigned int id, int channel,
415 s16 *chgain) { return 0; }
416 static inline int omap_st_enable(unsigned int id) { return 0; }
417 static inline int omap_st_disable(unsigned int id) { return 0; }
418 static inline int omap_st_is_enabled(unsigned int id) { return 0; }