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__
12 #define SPORT_MAJOR 237
13 #define SPORT_NR_DEVS 2
15 /* Sport mode: it can be set to TDM, i2s or others */
20 /* Data format, normal, a-law or u-law */
21 #define NORM_FORMAT 0x0
22 #define ALAW_FORMAT 0x2
23 #define ULAW_FORMAT 0x3
25 /* Function driver which use sport must initialize the structure */
27 /* TDM (multichannels), I2S or other mode */
30 /* if TDM mode is selected, channels must be set */
31 int channels; /* Must be in 8 units */
32 unsigned int frame_delay:4; /* Delay between frame sync pulse and first bit */
35 unsigned int right_first:1; /* Right stereo channel first */
37 /* In mormal mode, the following item need to be set */
38 unsigned int lsb_first:1; /* order of transmit or receive data */
39 unsigned int fsync:1; /* Frame sync required */
40 unsigned int data_indep:1; /* data independent frame sync generated */
41 unsigned int act_low:1; /* Active low TFS */
42 unsigned int late_fsync:1; /* Late frame sync */
44 unsigned int sec_en:1; /* Secondary side enabled */
46 /* Choose clock source */
47 unsigned int int_clk:1; /* Internal or external clock */
49 /* If external clock is used, the following fields are ignored */
53 unsigned int data_format:2; /* Normal, u-law or a-law */
55 int word_len; /* How length of the word in bits, 3-32 bits */
59 /* Userspace interface */
60 #define SPORT_IOC_MAGIC 'P'
61 #define SPORT_IOC_CONFIG _IOWR('P', 0x01, struct sport_config)
65 struct sport_register {
67 unsigned short reserved0;
69 unsigned short reserved1;
70 unsigned short tclkdiv;
71 unsigned short reserved2;
72 unsigned short tfsdiv;
73 unsigned short reserved3;
75 unsigned long reserved_l0;
77 unsigned long reserved_l1;
79 unsigned short reserved4;
81 unsigned short reserved5;
82 unsigned short rclkdiv;
83 unsigned short reserved6;
84 unsigned short rfsdiv;
85 unsigned short reserved7;
87 unsigned short reserved8;
89 unsigned short reserved9;
91 unsigned short reserved10;
93 unsigned short reserved11;
105 struct cdev cdev; /* Char device structure */
113 unsigned char *rx_buf; /* Buffer store the received data */
114 int rx_len; /* How many bytes will be received */
115 int rx_received; /* How many bytes has been received */
118 const unsigned char *tx_buf;
124 struct mutex mutex; /* mutual exclusion semaphore */
125 struct task_struct *task;
127 wait_queue_head_t waitq;
129 struct sport_register *regs;
130 struct sport_config config;
137 #define SPORT_TCLKDIV 2
138 #define SPORT_TFSDIV 3
141 #define SPORT_RCLKDIV 10
142 #define SPORT_RFSDIV 11
143 #define SPORT_CHANNEL 13
144 #define SPORT_MCMC1 14
145 #define SPORT_MCMC2 15
146 #define SPORT_MTCS0 16
147 #define SPORT_MTCS1 17
148 #define SPORT_MTCS2 18
149 #define SPORT_MTCS3 19
150 #define SPORT_MRCS0 20
151 #define SPORT_MRCS1 21
152 #define SPORT_MRCS2 22
153 #define SPORT_MRCS3 23