2 * bfin_sport.h - userspace header for bfin sport driver
4 * Copyright 2004-2008 Analog Devices Inc.
6 * Licensed under the GPL-2 or later.
9 #ifndef __BFIN_SPORT_H__
10 #define __BFIN_SPORT_H__
13 #include <linux/cdev.h>
14 #include <linux/mutex.h>
15 #include <linux/sched.h>
16 #include <linux/wait.h>
19 #define SPORT_MAJOR 237
20 #define SPORT_NR_DEVS 2
22 /* Sport mode: it can be set to TDM, i2s or others */
27 /* Data format, normal, a-law or u-law */
28 #define NORM_FORMAT 0x0
29 #define ALAW_FORMAT 0x2
30 #define ULAW_FORMAT 0x3
32 /* Function driver which use sport must initialize the structure */
34 /* TDM (multichannels), I2S or other mode */
37 /* if TDM mode is selected, channels must be set */
38 int channels
; /* Must be in 8 units */
39 unsigned int frame_delay
:4; /* Delay between frame sync pulse and first bit */
42 unsigned int right_first
:1; /* Right stereo channel first */
44 /* In mormal mode, the following item need to be set */
45 unsigned int lsb_first
:1; /* order of transmit or receive data */
46 unsigned int fsync
:1; /* Frame sync required */
47 unsigned int data_indep
:1; /* data independent frame sync generated */
48 unsigned int act_low
:1; /* Active low TFS */
49 unsigned int late_fsync
:1; /* Late frame sync */
51 unsigned int sec_en
:1; /* Secondary side enabled */
53 /* Choose clock source */
54 unsigned int int_clk
:1; /* Internal or external clock */
56 /* If external clock is used, the following fields are ignored */
60 unsigned int data_format
:2; /* Normal, u-law or a-law */
62 int word_len
; /* How length of the word in bits, 3-32 bits */
66 /* Userspace interface */
67 #define SPORT_IOC_MAGIC 'P'
68 #define SPORT_IOC_CONFIG _IOWR('P', 0x01, struct sport_config)
72 struct sport_register
{
74 unsigned short reserved0
;
76 unsigned short reserved1
;
77 unsigned short tclkdiv
;
78 unsigned short reserved2
;
79 unsigned short tfsdiv
;
80 unsigned short reserved3
;
82 unsigned long reserved_l0
;
84 unsigned long reserved_l1
;
86 unsigned short reserved4
;
88 unsigned short reserved5
;
89 unsigned short rclkdiv
;
90 unsigned short reserved6
;
91 unsigned short rfsdiv
;
92 unsigned short reserved7
;
94 unsigned short reserved8
;
96 unsigned short reserved9
;
98 unsigned short reserved10
;
100 unsigned short reserved11
;
112 struct cdev cdev
; /* Char device structure */
120 unsigned char *rx_buf
; /* Buffer store the received data */
121 int rx_len
; /* How many bytes will be received */
122 int rx_received
; /* How many bytes has been received */
125 const unsigned char *tx_buf
;
131 struct mutex mutex
; /* mutual exclusion semaphore */
132 struct task_struct
*task
;
134 wait_queue_head_t waitq
;
136 struct sport_register
*regs
;
137 struct sport_config config
;
144 #define SPORT_TCLKDIV 2
145 #define SPORT_TFSDIV 3
148 #define SPORT_RCLKDIV 10
149 #define SPORT_RFSDIV 11
150 #define SPORT_CHANNEL 13
151 #define SPORT_MCMC1 14
152 #define SPORT_MCMC2 15
153 #define SPORT_MTCS0 16
154 #define SPORT_MTCS1 17
155 #define SPORT_MTCS2 18
156 #define SPORT_MTCS3 19
157 #define SPORT_MRCS0 20
158 #define SPORT_MRCS1 21
159 #define SPORT_MRCS2 22
160 #define SPORT_MRCS3 23