summaryrefslogtreecommitdiffstats
path: root/include/linux/cm206.h
blob: 671a46f3168ccdc4291ec60fe1ea3ac5c713d1a5 (plain)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
/* cm206.h Header file for cm206.c.
   Copyright (c) 1995 David van Leeuwen 
*/

#ifndef LINUX_CM206_H
#define LINUX_CM206_H

#include <linux/ioctl.h>

/* First, the cm260 stuff */
/* The ports and irq used. Although CM206_BASE and CM206_IRQ are defined
   below, the values are not used unless autoprobing is turned off and 
   no LILO boot options or module command line options are given. Change
   these values to your own as last resort if autoprobing and options
   don't work. */

#define CM206_BASE 0x340
#define CM206_IRQ 11

#define r_data_status (cm206_base)
#define r_uart_receive (cm206_base+0x2)
#define r_fifo_output_buffer (cm206_base+0x4)
#define r_line_status (cm206_base+0x6)
#define r_data_control (cm206_base+0x8)
#define r_uart_transmit (cm206_base+0xa)
#define r_test_clock (cm206_base+0xc)
#define r_test_control (cm206_base+0xe)

/* the data_status flags */
#define ds_ram_size 0x4000
#define ds_toc_ready 0x2000
#define ds_fifo_empty 0x1000
#define ds_sync_error 0x800
#define ds_crc_error 0x400
#define ds_data_error 0x200
#define ds_fifo_overflow 0x100
#define ds_data_ready 0x80

/* the line_status flags */
#define ls_attention 0x10
#define ls_parity_error 0x8
#define ls_overrun 0x4
#define ls_receive_buffer_full 0x2
#define ls_transmitter_buffer_empty 0x1

/* the data control register flags */
#define dc_read_q_channel 0x4000
#define dc_mask_sync_error 0x2000
#define dc_toc_enable 0x1000
#define dc_no_stop_on_error 0x800
#define dc_break 0x400
#define dc_initialize 0x200
#define dc_mask_transmit_ready 0x100
#define dc_flag_enable 0x80

/* Define the default data control register flags here */
#define dc_normal (dc_mask_sync_error | dc_no_stop_on_error | \
		   dc_mask_transmit_ready)

/* now some constants related to the cm206 */
/* another drive status byte, echoed by the cm206 on most commands */

#define dsb_error_condition 0x1
#define dsb_play_in_progress 0x4
#define dsb_possible_media_change 0x8
#define dsb_disc_present 0x10
#define dsb_drive_not_ready 0x20
#define dsb_tray_locked 0x40
#define dsb_tray_not_closed 0x80

#define dsb_not_useful (dsb_drive_not_ready | dsb_tray_not_closed)

/* the cm206 command set */

#define c_close_tray 0
#define c_lock_tray 0x01
#define c_unlock_tray 0x04
#define c_open_tray 0x05
#define c_seek 0x10
#define c_read_data 0x20
#define c_force_1x 0x21
#define c_force_2x 0x22
#define c_auto_mode 0x23
#define c_play 0x30
#define c_set_audio_mode 0x31
#define c_read_current_q 0x41
#define c_stream_q 0x42
#define c_drive_status 0x50
#define c_disc_status 0x51
#define c_audio_status 0x52
#define c_drive_configuration 0x53
#define c_read_upc 0x60
#define c_stop 0x70
#define c_calc_checksum 0xe5

#define c_gimme 0xf8

/* finally, the (error) condition that the drive can be in      *
 * OK, this is not always an error, but let's prefix it with e_ */

#define e_none 0
#define e_illegal_command 0x01
#define e_sync 0x02
#define e_seek 0x03
#define e_parity 0x04
#define e_focus 0x05
#define e_header_sync 0x06
#define e_code_incompatibility 0x07
#define e_reset_done 0x08
#define e_bad_parameter 0x09
#define e_radial 0x0a
#define e_sub_code 0x0b
#define e_no_data_track 0x0c
#define e_scan 0x0d
#define e_tray_open 0x0f
#define e_no_disc 0x10
#define e_tray stalled 0x11

/* drive configuration masks */

#define dcf_revision_code 0x7
#define dcf_transfer_rate 0x60
#define dcf_motorized_tray 0x80

/* disc status byte */

#define cds_multi_session 0x2
#define cds_all_audio 0x8
#define cds_xa_mode 0xf0

/* finally some ioctls for the driver */

#define CM206CTL_GET_STAT _IO( 0x20, 0 )
#define CM206CTL_GET_LAST_STAT _IO( 0x20, 1 )

/* for kernel 1.2.n */
#if !defined(CDROM_GET_UPC)
#define CDROM_GET_UPC _IO( 'S', 0x11 )
#define CDROMRESET _IO( 'S', 0x12 )
#endif

#ifdef STATISTICS

/* This is an ugly way to guarantee that the names of the statistics
 * are the same in the code and in the diagnostics program.  */

#ifdef __KERNEL__
#define x(a) st_ ## a
#define y enum
#else
#define x(a) #a
#define y char * stats_name[] = 
#endif

y {x(interrupt), x(data_ready), x(fifo_overflow), x(data_error),
     x(crc_error), x(sync_error), x(lost_intr), x(echo),
     x(write_timeout), x(receive_timeout), x(read_timeout),
     x(dsb_timeout), x(stop_0xff), x(back_read_timeout),
     x(sector_transferred), x(read_restarted), x(read_background),
     x(bh), x(open), x(ioctl_multisession), x(attention)
#ifdef __KERNEL__
     , x(last_entry)
#endif
 };

#ifdef __KERNEL__
#define NR_STATS st_last_entry
#else
#define NR_STATS (sizeof(stats_name)/sizeof(char*))
#endif

#undef y
#undef x

#endif STATISTICS

#endif LINUX_CM206_H