1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30#ifndef __BF5XX_SPORT_H__
31#define __BF5XX_SPORT_H__
32
33#include <linux/types.h>
34#include <linux/wait.h>
35#include <linux/workqueue.h>
36#include <linux/platform_device.h>
37#include <asm/dma.h>
38#include <asm/bfin_sport.h>
39
40#define DESC_ELEMENT_COUNT 9
41
42struct sport_device {
43 int num;
44 int dma_rx_chan;
45 int dma_tx_chan;
46 int err_irq;
47 const unsigned short *pin_req;
48 struct sport_register *regs;
49
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;
56 unsigned int wdsize;
57
58
59 void *dummy_buf;
60 unsigned int dummy_count;
61
62
63 struct dmasg *dma_rx_desc;
64 struct dmasg *dma_tx_desc;
65 unsigned int rx_desc_bytes;
66 unsigned int tx_desc_bytes;
67
68 unsigned int rx_run:1;
69 unsigned int tx_run:1;
70
71 struct dmasg *dummy_rx_desc;
72 struct dmasg *dummy_tx_desc;
73
74 struct dmasg *curr_rx_desc;
75 struct dmasg *curr_tx_desc;
76
77 int rx_curr_frag;
78 int tx_curr_frag;
79
80 unsigned int rcr1;
81 unsigned int rcr2;
82 int rx_tdm_count;
83
84 unsigned int tcr1;
85 unsigned int tcr2;
86 int tx_tdm_count;
87
88 void (*rx_callback)(void *data);
89 void *rx_data;
90 void (*tx_callback)(void *data);
91 void *tx_data;
92 void (*err_callback)(void *data);
93 void *err_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;
100 int rx_pos;
101 unsigned int tx_buffer_size;
102 unsigned int rx_buffer_size;
103 int tx_delay_pos;
104 int once;
105#endif
106 void *private_data;
107};
108
109struct sport_param {
110 int num;
111 int dma_rx_chan;
112 int dma_tx_chan;
113 int err_irq;
114 const unsigned short *pin_req;
115 struct sport_register *regs;
116 unsigned int wdsize;
117 unsigned int dummy_count;
118 void *private_data;
119};
120
121struct sport_device *sport_init(struct platform_device *pdev,
122 unsigned int wdsize, unsigned int dummy_count, size_t priv_size);
123
124void sport_done(struct sport_device *sport);
125
126
127
128
129
130int sport_set_multichannel(struct sport_device *sport, int tdm_count,
131 u32 tx_mask, u32 rx_mask, int packed);
132
133int sport_config_rx(struct sport_device *sport,
134 unsigned int rcr1, unsigned int rcr2,
135 unsigned int clkdiv, unsigned int fsdiv);
136
137int sport_config_tx(struct sport_device *sport,
138 unsigned int tcr1, unsigned int tcr2,
139 unsigned int clkdiv, unsigned int fsdiv);
140
141
142
143
144
145
146
147int sport_config_rx_dma(struct sport_device *sport, void *buf,
148 int fragcount, size_t fragsize_bytes);
149
150int sport_config_tx_dma(struct sport_device *sport, void *buf,
151 int fragcount, size_t fragsize_bytes);
152
153int sport_tx_start(struct sport_device *sport);
154int sport_tx_stop(struct sport_device *sport);
155int sport_rx_start(struct sport_device *sport);
156int sport_rx_stop(struct sport_device *sport);
157
158
159unsigned long sport_curr_offset_rx(struct sport_device *sport);
160unsigned long sport_curr_offset_tx(struct sport_device *sport);
161
162void sport_incfrag(struct sport_device *sport, int *frag, int tx);
163void sport_decfrag(struct sport_device *sport, int *frag, int tx);
164
165int sport_set_rx_callback(struct sport_device *sport,
166 void (*rx_callback)(void *), void *rx_data);
167int sport_set_tx_callback(struct sport_device *sport,
168 void (*tx_callback)(void *), void *tx_data);
169int sport_set_err_callback(struct sport_device *sport,
170 void (*err_callback)(void *), void *err_data);
171
172int sport_send_and_recv(struct sport_device *sport, u8 *out_data, \
173 u8 *in_data, int len);
174#endif
175