1 #ifndef _FDC_IO_H
2 #define _FDC_IO_H
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 #include <linux/fdreg.h>
35
36 #define FDC_SK_BIT (0x20)
37 #define FDC_MT_BIT (0x80)
38
39 #define FDC_READ (FD_READ & ~(FDC_SK_BIT | FDC_MT_BIT))
40 #define FDC_WRITE (FD_WRITE & ~FDC_MT_BIT)
41 #define FDC_READ_DELETED (0x4c)
42 #define FDC_WRITE_DELETED (0x49)
43 #define FDC_READID (0x4a)
44 #define FDC_SENSED (0x04)
45 #define FDC_SENSEI (FD_SENSEI)
46 #define FDC_RECAL (FD_RECALIBRATE)
47 #define FDC_SEEK (FD_SEEK)
48 #define FDC_SPECIFY (FD_SPECIFY)
49 #define FDC_RECALIBR (FD_RECALIBRATE)
50 #define FDC_VERSION (FD_VERSION)
51 #define FDC_PERPEND (FD_PERPENDICULAR)
52 #define FDC_DUMPREGS (FD_DUMPREGS)
53 #define FDC_LOCK (FD_LOCK)
54 #define FDC_UNLOCK (FD_UNLOCK)
55 #define FDC_CONFIGURE (FD_CONFIGURE)
56 #define FDC_DRIVE_SPEC (0x8e)
57 #define FDC_PARTID (0x18)
58 #define FDC_SAVE (0x2e)
59 #define FDC_RESTORE (0x4e)
60
61 #define FDC_STATUS_MASK (STATUS_BUSY | STATUS_DMA | STATUS_DIR | STATUS_READY)
62 #define FDC_DATA_READY (STATUS_READY)
63 #define FDC_DATA_OUTPUT (STATUS_DIR)
64 #define FDC_DATA_READY_MASK (STATUS_READY | STATUS_DIR)
65 #define FDC_DATA_OUT_READY (STATUS_READY | STATUS_DIR)
66 #define FDC_DATA_IN_READY (STATUS_READY)
67 #define FDC_BUSY (STATUS_BUSY)
68 #define FDC_CLK48_BIT (0x80)
69 #define FDC_SEL3V_BIT (0x40)
70
71 #define ST0_INT_MASK (ST0_INTR)
72 #define FDC_INT_NORMAL (ST0_INTR & 0x00)
73 #define FDC_INT_ABNORMAL (ST0_INTR & 0x40)
74 #define FDC_INT_INVALID (ST0_INTR & 0x80)
75 #define FDC_INT_READYCH (ST0_INTR & 0xC0)
76 #define ST0_SEEK_END (ST0_SE)
77 #define ST3_TRACK_0 (ST3_TZ)
78
79 #define FDC_RESET_NOT (0x04)
80 #define FDC_DMA_MODE (0x08)
81 #define FDC_MOTOR_0 (0x10)
82 #define FDC_MOTOR_1 (0x20)
83
84 typedef struct {
85 void (**hook) (void);
86 enum {
87 no_fdc, i8272, i82077, i82077AA, fc10,
88 i82078, i82078_1
89 } type;
90 unsigned char irq;
91 unsigned char dma;
92 unsigned short sra;
93 unsigned short srb;
94 unsigned short dor;
95 unsigned short tdr;
96
97 unsigned short msr;
98 unsigned short dsr;
99 unsigned short fifo;
100 unsigned short dir;
101 unsigned short ccr;
102 unsigned short dor2;
103
104 } fdc_config_info;
105
106 typedef enum {
107 fdc_data_rate_250 = 2,
108 fdc_data_rate_500 = 0,
109 fdc_data_rate_1000 = 3,
110 fdc_data_rate_2000 = 1,
111 } fdc_data_rate_type;
112
113 typedef enum {
114 waiting = 0,
115 reading,
116 writing,
117 done,
118 error,
119 } buffer_state_enum;
120
121 typedef volatile enum {
122 fdc_idle = 0,
123 fdc_reading_data = FDC_READ,
124 fdc_seeking = FDC_SEEK,
125 fdc_writing_data = FDC_WRITE,
126 fdc_reading_id = FDC_READID,
127 fdc_recalibrating = FDC_RECAL,
128 } fdc_mode_enum;
129
130
131
132
133 extern fdc_mode_enum fdc_mode;
134 extern volatile enum runner_status_enum runner_status;
135 extern int old_vfo;
136 extern volatile int head;
137 extern volatile int tail;
138 extern int fdc_setup_error;
139 extern struct wait_queue *wait_intr;
140 extern volatile unsigned int next_segment;
141 extern int ftape_unit;
142 extern int ftape_motor;
143 extern int current_cylinder;
144 extern volatile byte fdc_head;
145 extern volatile byte fdc_cyl;
146 extern volatile byte fdc_sect;
147 extern fdc_config_info fdc;
148
149
150
151
152 extern void fdc_catch_stray_interrupts(unsigned count);
153 extern int fdc_ready_wait(int timeout);
154 extern int fdc_write(byte data);
155 extern int fdc_read(byte * data);
156 extern int fdc_command(byte * cmd_data, int cmd_len);
157 extern int fdc_result(byte * res_data, int res_len);
158 extern int fdc_issue_command(byte * out_data, int out_count, \
159 byte * in_data, int in_count);
160 extern void fdc_isr(void);
161 extern int fdc_interrupt_wait(int time);
162 extern void fdt_sleep(unsigned int time);
163 extern int fdc_specify(int head_unload_time, int seek_rate,
164 int head_load_time, int non_dma);
165 extern int fdc_set_seek_rate(int seek_rate);
166 extern int fdc_seek(int track);
167 extern int fdc_sense_drive_status(int *st3);
168 extern void fdc_motor(int motor);
169 extern void fdc_reset(void);
170 extern int fdc_recalibrate(void);
171 extern void fdc_disable(void);
172 extern int fdc_wait_calibrate(void);
173 extern int fdc_sense_interrupt_status(int *st0, int *current_cylinder);
174 extern void fdc_save_drive_specs(void);
175 extern void fdc_restore_drive_specs(void);
176 extern void fdc_set_data_rate(int rate);
177 extern int fdc_release_irq_and_dma(void);
178 extern int fdc_init(void);
179 extern int fdc_uninit(void);
180 extern void fdc_set_write_precomp(int precomp);
181
182 #endif