4 * Author: Roy Huang <roy.huang@analog.com>
9 * Copyright 2004-2007 Analog Devices Inc.
11 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, see the file COPYING, or write
25 * to the Free Software Foundation, Inc.,
26 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 #ifndef __BF5XX_SPORT_H__
31 #define __BF5XX_SPORT_H__
33 #include <linux/types.h>
34 #include <linux/wait.h>
35 #include <linux/workqueue.h>
36 #include <linux/platform_device.h>
38 #include <asm/bfin_sport.h>
40 #define DESC_ELEMENT_COUNT 9
47 const unsigned short *pin_req;
48 struct sport_register *regs;
50 unsigned char *rx_buf;
51 unsigned char *tx_buf;
52 unsigned int rx_fragsize;
53 unsigned int tx_fragsize;
54 unsigned int rx_frags;
55 unsigned int tx_frags;
58 /* for dummy dma transfer */
60 unsigned int dummy_count;
62 /* DMA descriptor ring head of current audio stream*/
63 struct dmasg *dma_rx_desc;
64 struct dmasg *dma_tx_desc;
65 unsigned int rx_desc_bytes;
66 unsigned int tx_desc_bytes;
68 unsigned int rx_run:1; /* rx is running */
69 unsigned int tx_run:1; /* tx is running */
71 struct dmasg *dummy_rx_desc;
72 struct dmasg *dummy_tx_desc;
74 struct dmasg *curr_rx_desc;
75 struct dmasg *curr_tx_desc;
88 void (*rx_callback)(void *data);
90 void (*tx_callback)(void *data);
92 void (*err_callback)(void *data);
94 unsigned char *tx_dma_buf;
95 unsigned char *rx_dma_buf;
96 #ifdef CONFIG_SND_BF5XX_MMAP_SUPPORT
97 dma_addr_t tx_dma_phy;
98 dma_addr_t rx_dma_phy;
99 int tx_pos;/*pcm sample count*/
101 unsigned int tx_buffer_size;
102 unsigned int rx_buffer_size;
114 const unsigned short *pin_req;
115 struct sport_register *regs;
117 unsigned int dummy_count;
121 struct sport_device *sport_init(struct platform_device *pdev,
122 unsigned int wdsize, unsigned int dummy_count, size_t priv_size);
124 void sport_done(struct sport_device *sport);
126 /* first use these ...*/
128 /* note: multichannel is in units of 8 channels, tdm_count is number of channels
129 * NOT / 8 ! all channels are enabled by default */
130 int sport_set_multichannel(struct sport_device *sport, int tdm_count,
131 u32 tx_mask, u32 rx_mask, int packed);
133 int sport_config_rx(struct sport_device *sport,
134 unsigned int rcr1, unsigned int rcr2,
135 unsigned int clkdiv, unsigned int fsdiv);
137 int sport_config_tx(struct sport_device *sport,
138 unsigned int tcr1, unsigned int tcr2,
139 unsigned int clkdiv, unsigned int fsdiv);
141 /* ... then these: */
143 /* buffer size (in bytes) == fragcount * fragsize_bytes */
145 /* this is not a very general api, it sets the dma to 2d autobuffer mode */
147 int sport_config_rx_dma(struct sport_device *sport, void *buf,
148 int fragcount, size_t fragsize_bytes);
150 int sport_config_tx_dma(struct sport_device *sport, void *buf,
151 int fragcount, size_t fragsize_bytes);
153 int sport_tx_start(struct sport_device *sport);
154 int sport_tx_stop(struct sport_device *sport);
155 int sport_rx_start(struct sport_device *sport);
156 int sport_rx_stop(struct sport_device *sport);
158 /* for use in interrupt handler */
159 unsigned long sport_curr_offset_rx(struct sport_device *sport);
160 unsigned long sport_curr_offset_tx(struct sport_device *sport);
162 void sport_incfrag(struct sport_device *sport, int *frag, int tx);
163 void sport_decfrag(struct sport_device *sport, int *frag, int tx);
165 int sport_set_rx_callback(struct sport_device *sport,
166 void (*rx_callback)(void *), void *rx_data);
167 int sport_set_tx_callback(struct sport_device *sport,
168 void (*tx_callback)(void *), void *tx_data);
169 int sport_set_err_callback(struct sport_device *sport,
170 void (*err_callback)(void *), void *err_data);
172 int sport_send_and_recv(struct sport_device *sport, u8 *out_data, \
173 u8 *in_data, int len);
174 #endif /* BF53X_SPORT_H */