plat-nomadik: support secondary GPIO interrupts
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / sound / soc / blackfin / bf5xx-sport.h
bloba86e8cc0b2d30ab45b36e7ab489e8cbc7d7e8f2f
1 /*
2 * File: bf5xx_ac97_sport.h
3 * Based on:
4 * Author: Roy Huang <roy.huang@analog.com>
6 * Created:
7 * Description:
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 <asm/dma.h>
37 #include <asm/bfin_sport.h>
39 #define DESC_ELEMENT_COUNT 9
41 struct sport_device {
42 int dma_rx_chan;
43 int dma_tx_chan;
44 int err_irq;
45 struct sport_register *regs;
47 unsigned char *rx_buf;
48 unsigned char *tx_buf;
49 unsigned int rx_fragsize;
50 unsigned int tx_fragsize;
51 unsigned int rx_frags;
52 unsigned int tx_frags;
53 unsigned int wdsize;
55 /* for dummy dma transfer */
56 void *dummy_buf;
57 unsigned int dummy_count;
59 /* DMA descriptor ring head of current audio stream*/
60 struct dmasg *dma_rx_desc;
61 struct dmasg *dma_tx_desc;
62 unsigned int rx_desc_bytes;
63 unsigned int tx_desc_bytes;
65 unsigned int rx_run:1; /* rx is running */
66 unsigned int tx_run:1; /* tx is running */
68 struct dmasg *dummy_rx_desc;
69 struct dmasg *dummy_tx_desc;
71 struct dmasg *curr_rx_desc;
72 struct dmasg *curr_tx_desc;
74 int rx_curr_frag;
75 int tx_curr_frag;
77 unsigned int rcr1;
78 unsigned int rcr2;
79 int rx_tdm_count;
81 unsigned int tcr1;
82 unsigned int tcr2;
83 int tx_tdm_count;
85 void (*rx_callback)(void *data);
86 void *rx_data;
87 void (*tx_callback)(void *data);
88 void *tx_data;
89 void (*err_callback)(void *data);
90 void *err_data;
91 unsigned char *tx_dma_buf;
92 unsigned char *rx_dma_buf;
93 #ifdef CONFIG_SND_BF5XX_MMAP_SUPPORT
94 dma_addr_t tx_dma_phy;
95 dma_addr_t rx_dma_phy;
96 int tx_pos;/*pcm sample count*/
97 int rx_pos;
98 unsigned int tx_buffer_size;
99 unsigned int rx_buffer_size;
100 int tx_delay_pos;
101 int once;
102 #endif
103 void *private_data;
106 extern struct sport_device *sport_handle;
108 struct sport_param {
109 int dma_rx_chan;
110 int dma_tx_chan;
111 int err_irq;
112 struct sport_register *regs;
115 struct sport_device *sport_init(struct sport_param *param, unsigned wdsize,
116 unsigned dummy_count, void *private_data);
118 void sport_done(struct sport_device *sport);
120 /* first use these ...*/
122 /* note: multichannel is in units of 8 channels, tdm_count is number of channels
123 * NOT / 8 ! all channels are enabled by default */
124 int sport_set_multichannel(struct sport_device *sport, int tdm_count,
125 u32 mask, int packed);
127 int sport_config_rx(struct sport_device *sport,
128 unsigned int rcr1, unsigned int rcr2,
129 unsigned int clkdiv, unsigned int fsdiv);
131 int sport_config_tx(struct sport_device *sport,
132 unsigned int tcr1, unsigned int tcr2,
133 unsigned int clkdiv, unsigned int fsdiv);
135 /* ... then these: */
137 /* buffer size (in bytes) == fragcount * fragsize_bytes */
139 /* this is not a very general api, it sets the dma to 2d autobuffer mode */
141 int sport_config_rx_dma(struct sport_device *sport, void *buf,
142 int fragcount, size_t fragsize_bytes);
144 int sport_config_tx_dma(struct sport_device *sport, void *buf,
145 int fragcount, size_t fragsize_bytes);
147 int sport_tx_start(struct sport_device *sport);
148 int sport_tx_stop(struct sport_device *sport);
149 int sport_rx_start(struct sport_device *sport);
150 int sport_rx_stop(struct sport_device *sport);
152 /* for use in interrupt handler */
153 unsigned long sport_curr_offset_rx(struct sport_device *sport);
154 unsigned long sport_curr_offset_tx(struct sport_device *sport);
156 void sport_incfrag(struct sport_device *sport, int *frag, int tx);
157 void sport_decfrag(struct sport_device *sport, int *frag, int tx);
159 int sport_set_rx_callback(struct sport_device *sport,
160 void (*rx_callback)(void *), void *rx_data);
161 int sport_set_tx_callback(struct sport_device *sport,
162 void (*tx_callback)(void *), void *tx_data);
163 int sport_set_err_callback(struct sport_device *sport,
164 void (*err_callback)(void *), void *err_data);
166 int sport_send_and_recv(struct sport_device *sport, u8 *out_data, \
167 u8 *in_data, int len);
168 #endif /* BF53X_SPORT_H */