Blame view
drivers/ide/ide-floppy.c
15.7 KB
1da177e4c
|
1 |
/* |
d3f208488
|
2 3 |
* IDE ATAPI floppy driver. * |
59bca8cc9
|
4 5 6 |
* Copyright (C) 1996-1999 Gadi Oxman <gadio@netvision.net.il> * Copyright (C) 2000-2002 Paul Bristow <paul@paulbristow.net> * Copyright (C) 2005 Bartlomiej Zolnierkiewicz |
0571c7a4f
|
7 |
* |
1da177e4c
|
8 9 10 11 12 13 |
* This driver supports the following IDE floppy drives: * * LS-120/240 SuperDisk * Iomega Zip 100/250 * Iomega PC Card Clik!/PocketZip * |
d3f208488
|
14 15 |
* For a historical changelog see * Documentation/ide/ChangeLog.ide-floppy.1996-2002 |
1da177e4c
|
16 |
*/ |
1da177e4c
|
17 18 19 20 21 22 23 24 25 26 27 28 29 |
#include <linux/types.h> #include <linux/string.h> #include <linux/kernel.h> #include <linux/delay.h> #include <linux/timer.h> #include <linux/mm.h> #include <linux/interrupt.h> #include <linux/major.h> #include <linux/errno.h> #include <linux/genhd.h> #include <linux/slab.h> #include <linux/cdrom.h> #include <linux/ide.h> |
3ceca727f
|
30 |
#include <linux/hdreg.h> |
1da177e4c
|
31 |
#include <linux/bitops.h> |
cf8b8975c
|
32 |
#include <linux/mutex.h> |
b98b3409a
|
33 |
#include <linux/scatterlist.h> |
1da177e4c
|
34 |
|
89636af25
|
35 |
#include <scsi/scsi_ioctl.h> |
1da177e4c
|
36 |
#include <asm/byteorder.h> |
7e8b163b2
|
37 38 39 |
#include <linux/irq.h> #include <linux/uaccess.h> #include <linux/io.h> |
1da177e4c
|
40 |
#include <asm/unaligned.h> |
0127854d7
|
41 |
#include "ide-floppy.h" |
1da177e4c
|
42 |
/* |
0571c7a4f
|
43 44 |
* After each failed packet command we issue a request sense command and retry * the packet command IDEFLOPPY_MAX_PC_RETRIES times. |
1da177e4c
|
45 46 |
*/ #define IDEFLOPPY_MAX_PC_RETRIES 3 |
194ec0c07
|
47 |
/* format capacities descriptor codes */ |
1da177e4c
|
48 49 50 51 |
#define CAPACITY_INVALID 0x00 #define CAPACITY_UNFORMATTED 0x01 #define CAPACITY_CURRENT 0x02 #define CAPACITY_NO_CARTRIDGE 0x03 |
baf08f0be
|
52 53 54 55 56 |
/* * The following delay solves a problem with ATAPI Zip 100 drive where BSY bit * was apparently being deasserted before the unit was ready to receive data. */ #define IDEFLOPPY_PC_DELAY (HZ/20) /* default delay for ZIP 100 (50ms) */ |
1da177e4c
|
57 |
|
0571c7a4f
|
58 |
/* Error code returned in rq->errors to the higher part of the driver. */ |
1da177e4c
|
59 |
#define IDEFLOPPY_ERROR_GENERAL 101 |
1da177e4c
|
60 |
/* |
0571c7a4f
|
61 62 |
* Used to finish servicing a request. For read/write requests, we will call * ide_end_request to pass to the next buffer. |
1da177e4c
|
63 |
*/ |
806f80a6f
|
64 |
static int ide_floppy_end_request(ide_drive_t *drive, int uptodate, int nsecs) |
1da177e4c
|
65 |
{ |
0df962777
|
66 |
struct ide_disk_obj *floppy = drive->driver_data; |
b65fac32c
|
67 |
struct request *rq = drive->hwif->rq; |
1da177e4c
|
68 |
int error; |
7b3557262
|
69 70 |
ide_debug_log(IDE_DBG_FUNC, "Call %s ", __func__); |
1da177e4c
|
71 72 |
switch (uptodate) { |
7b3557262
|
73 74 75 76 77 78 79 80 81 82 |
case 0: error = IDEFLOPPY_ERROR_GENERAL; break; case 1: error = 0; break; default: error = uptodate; |
1da177e4c
|
83 |
} |
7b3557262
|
84 |
|
1da177e4c
|
85 86 87 88 89 |
if (error) floppy->failed_pc = NULL; /* Why does this happen? */ if (!rq) return 0; |
4aff5e233
|
90 |
if (!blk_special_request(rq)) { |
1da177e4c
|
91 92 93 94 95 96 97 98 99 |
/* our real local end request function */ ide_end_request(drive, uptodate, nsecs); return 0; } rq->errors = error; /* fixme: need to move this local also */ ide_end_drive_cmd(drive, 0, 0); return 0; } |
8e5551239
|
100 101 |
static void idefloppy_update_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc) |
1da177e4c
|
102 103 104 105 106 |
{ struct request *rq = pc->rq; struct bio *bio = rq->bio; while ((bio = rq->bio) != NULL) |
c84d9bbe7
|
107 |
ide_floppy_end_request(drive, 1, 0); |
1da177e4c
|
108 |
} |
b14c72127
|
109 |
static void ide_floppy_callback(ide_drive_t *drive, int dsc) |
1da177e4c
|
110 |
{ |
0df962777
|
111 |
struct ide_disk_obj *floppy = drive->driver_data; |
2b9efba48
|
112 |
struct ide_atapi_pc *pc = drive->pc; |
81f493823
|
113 |
int uptodate = pc->error ? 0 : 1; |
1da177e4c
|
114 |
|
7b3557262
|
115 116 |
ide_debug_log(IDE_DBG_FUNC, "Call %s ", __func__); |
bcc77d9cc
|
117 |
|
dd2e9a032
|
118 119 |
if (floppy->failed_pc == pc) floppy->failed_pc = NULL; |
81f493823
|
120 121 122 123 |
if (pc->c[0] == GPCMD_READ_10 || pc->c[0] == GPCMD_WRITE_10 || (pc->rq && blk_pc_request(pc->rq))) uptodate = 1; /* FIXME */ else if (pc->c[0] == GPCMD_REQUEST_SENSE) { |
2b9efba48
|
124 |
u8 *buf = pc->buf; |
a6ff2d3b0
|
125 |
|
81f493823
|
126 127 128 129 130 131 |
if (!pc->error) { floppy->sense_key = buf[2] & 0x0F; floppy->asc = buf[12]; floppy->ascq = buf[13]; floppy->progress_indication = buf[15] & 0x80 ? (u16)get_unaligned((u16 *)&buf[16]) : 0x10000; |
a6ff2d3b0
|
132 |
|
81f493823
|
133 |
if (floppy->failed_pc) |
7b3557262
|
134 135 |
ide_debug_log(IDE_DBG_PC, "pc = %x, ", floppy->failed_pc->c[0]); |
bcc77d9cc
|
136 |
|
7b3557262
|
137 138 139 140 |
ide_debug_log(IDE_DBG_SENSE, "sense key = %x, asc = %x," "ascq = %x ", floppy->sense_key, floppy->asc, floppy->ascq); |
81f493823
|
141 |
} else |
7b3557262
|
142 143 144 |
printk(KERN_ERR PFX "Error in REQUEST SENSE itself - " "Aborting request! "); |
81f493823
|
145 |
} |
1da177e4c
|
146 |
|
c84d9bbe7
|
147 |
ide_floppy_end_request(drive, uptodate, 0); |
1da177e4c
|
148 |
} |
0df962777
|
149 |
static void ide_floppy_report_error(struct ide_disk_obj *floppy, |
8e5551239
|
150 |
struct ide_atapi_pc *pc) |
1da177e4c
|
151 |
{ |
d652c1380
|
152 |
/* supress error messages resulting from Medium not present */ |
1da177e4c
|
153 154 155 |
if (floppy->sense_key == 0x02 && floppy->asc == 0x3a && floppy->ascq == 0x00) |
d652c1380
|
156 |
return; |
7b3557262
|
157 |
printk(KERN_ERR PFX "%s: I/O error, pc = %2x, key = %2x, " |
d652c1380
|
158 159 160 161 |
"asc = %2x, ascq = %2x ", floppy->drive->name, pc->c[0], floppy->sense_key, floppy->asc, floppy->ascq); |
1da177e4c
|
162 |
} |
0571c7a4f
|
163 |
static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive, |
8e5551239
|
164 |
struct ide_atapi_pc *pc) |
1da177e4c
|
165 |
{ |
0df962777
|
166 |
struct ide_disk_obj *floppy = drive->driver_data; |
1da177e4c
|
167 |
|
1da177e4c
|
168 |
if (floppy->failed_pc == NULL && |
30d670993
|
169 |
pc->c[0] != GPCMD_REQUEST_SENSE) |
1da177e4c
|
170 |
floppy->failed_pc = pc; |
2b9efba48
|
171 |
|
1da177e4c
|
172 |
/* Set the current packet command */ |
2b9efba48
|
173 |
drive->pc = pc; |
1da177e4c
|
174 |
|
757ced898
|
175 |
if (pc->retries > IDEFLOPPY_MAX_PC_RETRIES) { |
6e5fa7b88
|
176 |
if (!(pc->flags & PC_FLAG_SUPPRESS_ERROR)) |
757ced898
|
177 178 179 |
ide_floppy_report_error(floppy, pc); /* Giving up */ pc->error = IDEFLOPPY_ERROR_GENERAL; |
1da177e4c
|
180 |
floppy->failed_pc = NULL; |
b14c72127
|
181 |
drive->pc_callback(drive, 0); |
1da177e4c
|
182 183 |
return ide_stopped; } |
7b3557262
|
184 185 |
ide_debug_log(IDE_DBG_FUNC, "%s: Retry #%d ", __func__, pc->retries); |
1da177e4c
|
186 187 |
pc->retries++; |
1da177e4c
|
188 |
|
28ad91db7
|
189 |
return ide_issue_pc(drive); |
1da177e4c
|
190 |
} |
0127854d7
|
191 |
void ide_floppy_create_read_capacity_cmd(struct ide_atapi_pc *pc) |
1da177e4c
|
192 |
{ |
7bf7420a3
|
193 |
ide_init_pc(pc); |
30d670993
|
194 |
pc->c[0] = GPCMD_READ_FORMAT_CAPACITIES; |
1da177e4c
|
195 196 |
pc->c[7] = 255; pc->c[8] = 255; |
8e5551239
|
197 |
pc->req_xfer = 255; |
1da177e4c
|
198 |
} |
0571c7a4f
|
199 |
/* A mode sense command is used to "sense" floppy parameters. */ |
0127854d7
|
200 |
void ide_floppy_create_mode_sense_cmd(struct ide_atapi_pc *pc, u8 page_code) |
1da177e4c
|
201 |
{ |
24a5d7033
|
202 |
u16 length = 8; /* sizeof(Mode Parameter Header) = 8 Bytes */ |
0571c7a4f
|
203 |
|
7bf7420a3
|
204 |
ide_init_pc(pc); |
30d670993
|
205 |
pc->c[0] = GPCMD_MODE_SENSE_10; |
1da177e4c
|
206 |
pc->c[1] = 0; |
4de4b9e14
|
207 |
pc->c[2] = page_code; |
1da177e4c
|
208 209 |
switch (page_code) { |
0571c7a4f
|
210 211 212 213 214 215 216 |
case IDEFLOPPY_CAPABILITIES_PAGE: length += 12; break; case IDEFLOPPY_FLEXIBLE_DISK_PAGE: length += 32; break; default: |
7b3557262
|
217 218 |
printk(KERN_ERR PFX "unsupported page code in %s ", __func__); |
1da177e4c
|
219 |
} |
8f6224308
|
220 |
put_unaligned(cpu_to_be16(length), (u16 *) &pc->c[7]); |
8e5551239
|
221 |
pc->req_xfer = length; |
1da177e4c
|
222 |
} |
7b3557262
|
223 |
static void idefloppy_create_rw_cmd(ide_drive_t *drive, |
8e5551239
|
224 |
struct ide_atapi_pc *pc, struct request *rq, |
ae7e8ddc3
|
225 |
unsigned long sector) |
1da177e4c
|
226 |
{ |
0df962777
|
227 |
struct ide_disk_obj *floppy = drive->driver_data; |
1da177e4c
|
228 229 230 |
int block = sector / floppy->bs_factor; int blocks = rq->nr_sectors / floppy->bs_factor; int cmd = rq_data_dir(rq); |
7b3557262
|
231 232 233 |
ide_debug_log(IDE_DBG_FUNC, "%s: block: %d, blocks: %d ", __func__, block, blocks); |
1da177e4c
|
234 |
|
7bf7420a3
|
235 |
ide_init_pc(pc); |
ae7e8ddc3
|
236 237 |
pc->c[0] = cmd == READ ? GPCMD_READ_10 : GPCMD_WRITE_10; put_unaligned(cpu_to_be16(blocks), (unsigned short *)&pc->c[7]); |
8f6224308
|
238 |
put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[2]); |
ae7e8ddc3
|
239 |
|
20cd93be6
|
240 |
memcpy(rq->cmd, pc->c, 12); |
1da177e4c
|
241 |
pc->rq = rq; |
b98b3409a
|
242 |
pc->b_count = 0; |
4aff5e233
|
243 |
if (rq->cmd_flags & REQ_RW) |
6e5fa7b88
|
244 |
pc->flags |= PC_FLAG_WRITING; |
8e5551239
|
245 246 |
pc->buf = NULL; pc->req_xfer = pc->buf_size = blocks * floppy->block_size; |
5e3310958
|
247 |
pc->flags |= PC_FLAG_DMA_OK; |
1da177e4c
|
248 |
} |
0df962777
|
249 |
static void idefloppy_blockpc_cmd(struct ide_disk_obj *floppy, |
8e5551239
|
250 |
struct ide_atapi_pc *pc, struct request *rq) |
1da177e4c
|
251 |
{ |
7bf7420a3
|
252 |
ide_init_pc(pc); |
1da177e4c
|
253 |
memcpy(pc->c, rq->cmd, sizeof(pc->c)); |
3d6392cfb
|
254 |
pc->rq = rq; |
b98b3409a
|
255 |
pc->b_count = 0; |
3d6392cfb
|
256 |
if (rq->data_len && rq_data_dir(rq) == WRITE) |
6e5fa7b88
|
257 |
pc->flags |= PC_FLAG_WRITING; |
8e5551239
|
258 |
pc->buf = rq->data; |
3d6392cfb
|
259 |
if (rq->bio) |
5e3310958
|
260 |
pc->flags |= PC_FLAG_DMA_OK; |
3d6392cfb
|
261 262 263 264 |
/* * possibly problematic, doesn't look like ide-floppy correctly * handled scattered requests if dma fails... */ |
8e5551239
|
265 |
pc->req_xfer = pc->buf_size = rq->data_len; |
1da177e4c
|
266 |
} |
806f80a6f
|
267 268 |
static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive, struct request *rq, sector_t block) |
1da177e4c
|
269 |
{ |
0df962777
|
270 |
struct ide_disk_obj *floppy = drive->driver_data; |
b98b3409a
|
271 |
ide_hwif_t *hwif = drive->hwif; |
8e5551239
|
272 |
struct ide_atapi_pc *pc; |
1da177e4c
|
273 |
|
7b3557262
|
274 275 276 277 278 |
ide_debug_log(IDE_DBG_FUNC, "%s: dev: %s, cmd: 0x%x, cmd_type: %x, " "errors: %d ", __func__, rq->rq_disk ? rq->rq_disk->disk_name : "?", rq->cmd[0], rq->cmd_type, rq->errors); |
b98b3409a
|
279 |
|
7b3557262
|
280 281 282 283 284 |
ide_debug_log(IDE_DBG_FUNC, "%s: sector: %ld, nr_sectors: %ld, " "current_nr_sectors: %d ", __func__, (long)rq->sector, rq->nr_sectors, rq->current_nr_sectors); |
1da177e4c
|
285 286 |
if (rq->errors >= ERROR_MAX) { |
d652c1380
|
287 288 |
if (floppy->failed_pc) ide_floppy_report_error(floppy, floppy->failed_pc); |
1da177e4c
|
289 |
else |
7b3557262
|
290 291 |
printk(KERN_ERR PFX "%s: I/O error ", drive->name); |
c84d9bbe7
|
292 |
ide_floppy_end_request(drive, 0, 0); |
1da177e4c
|
293 294 |
return ide_stopped; } |
4aff5e233
|
295 |
if (blk_fs_request(rq)) { |
1da177e4c
|
296 297 |
if (((long)rq->sector % floppy->bs_factor) || (rq->nr_sectors % floppy->bs_factor)) { |
7b3557262
|
298 299 300 |
printk(KERN_ERR PFX "%s: unsupported r/w rq size ", drive->name); |
c84d9bbe7
|
301 |
ide_floppy_end_request(drive, 0, 0); |
1da177e4c
|
302 303 |
return ide_stopped; } |
2e8a6f89d
|
304 |
pc = &floppy->queued_pc; |
806f80a6f
|
305 |
idefloppy_create_rw_cmd(drive, pc, rq, (unsigned long)block); |
4aff5e233
|
306 |
} else if (blk_special_request(rq)) { |
8e5551239
|
307 |
pc = (struct ide_atapi_pc *) rq->buffer; |
4aff5e233
|
308 |
} else if (blk_pc_request(rq)) { |
2e8a6f89d
|
309 |
pc = &floppy->queued_pc; |
3d6392cfb
|
310 |
idefloppy_blockpc_cmd(floppy, pc, rq); |
1da177e4c
|
311 |
} else { |
7b3557262
|
312 |
blk_dump_rq_flags(rq, PFX "unsupported command in queue"); |
c84d9bbe7
|
313 |
ide_floppy_end_request(drive, 0, 0); |
1da177e4c
|
314 315 |
return ide_stopped; } |
3eb76c1cc
|
316 317 318 319 |
if (blk_fs_request(rq) || pc->req_xfer) { ide_init_sg_cmd(drive, rq); ide_map_sg(drive, rq); } |
b98b3409a
|
320 321 322 |
pc->sg = hwif->sg_table; pc->sg_cnt = hwif->sg_nents; |
1da177e4c
|
323 |
pc->rq = rq; |
5d41893c0
|
324 |
|
1da177e4c
|
325 326 327 328 |
return idefloppy_issue_pc(drive, pc); } /* |
8e81bbba7
|
329 330 |
* Look at the flexible disk page parameters. We ignore the CHS capacity * parameters and use the LBA parameters instead. |
1da177e4c
|
331 |
*/ |
07bd3f473
|
332 333 |
static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive, struct ide_atapi_pc *pc) |
1da177e4c
|
334 |
{ |
0df962777
|
335 |
struct ide_disk_obj *floppy = drive->driver_data; |
2ac07d920
|
336 |
struct gendisk *disk = floppy->disk; |
8e81bbba7
|
337 |
u8 *page; |
1da177e4c
|
338 |
int capacity, lba_capacity; |
8e81bbba7
|
339 340 |
u16 transfer_rate, sector_size, cyls, rpm; u8 heads, sectors; |
1da177e4c
|
341 |
|
07bd3f473
|
342 |
ide_floppy_create_mode_sense_cmd(pc, IDEFLOPPY_FLEXIBLE_DISK_PAGE); |
8e81bbba7
|
343 |
|
07bd3f473
|
344 |
if (ide_queue_pc_tail(drive, disk, pc)) { |
7b3557262
|
345 346 |
printk(KERN_ERR PFX "Can't get flexible disk page params "); |
1da177e4c
|
347 348 |
return 1; } |
49cac39e7
|
349 |
|
07bd3f473
|
350 |
if (pc->buf[3] & 0x80) |
da167876b
|
351 |
drive->dev_flags |= IDE_DFLAG_WP; |
49cac39e7
|
352 |
else |
da167876b
|
353 |
drive->dev_flags &= ~IDE_DFLAG_WP; |
49cac39e7
|
354 |
|
da167876b
|
355 |
set_disk_ro(disk, !!(drive->dev_flags & IDE_DFLAG_WP)); |
49cac39e7
|
356 |
|
07bd3f473
|
357 |
page = &pc->buf[8]; |
8e81bbba7
|
358 |
|
07bd3f473
|
359 360 361 362 363 364 |
transfer_rate = be16_to_cpup((__be16 *)&pc->buf[8 + 2]); sector_size = be16_to_cpup((__be16 *)&pc->buf[8 + 6]); cyls = be16_to_cpup((__be16 *)&pc->buf[8 + 8]); rpm = be16_to_cpup((__be16 *)&pc->buf[8 + 28]); heads = pc->buf[8 + 4]; sectors = pc->buf[8 + 5]; |
8e81bbba7
|
365 366 367 368 |
capacity = cyls * heads * sectors * sector_size; if (memcmp(page, &floppy->flexible_disk_page, 32)) |
7b3557262
|
369 |
printk(KERN_INFO PFX "%s: %dkB, %d/%d/%d CHS, %d kBps, " |
1da177e4c
|
370 371 |
"%d sector size, %d rpm ", |
8e81bbba7
|
372 373 374 375 376 377 378 |
drive->name, capacity / 1024, cyls, heads, sectors, transfer_rate / 8, sector_size, rpm); memcpy(&floppy->flexible_disk_page, page, 32); drive->bios_cyl = cyls; drive->bios_head = heads; drive->bios_sect = sectors; |
1da177e4c
|
379 |
lba_capacity = floppy->blocks * floppy->block_size; |
8e81bbba7
|
380 |
|
1da177e4c
|
381 |
if (capacity < lba_capacity) { |
7b3557262
|
382 |
printk(KERN_NOTICE PFX "%s: The disk reports a capacity of %d " |
1da177e4c
|
383 384 385 |
"bytes, but the drive only handles %d ", drive->name, lba_capacity, capacity); |
8e81bbba7
|
386 387 |
floppy->blocks = floppy->block_size ? capacity / floppy->block_size : 0; |
6f84083bb
|
388 |
drive->capacity64 = floppy->blocks * floppy->bs_factor; |
1da177e4c
|
389 |
} |
6f84083bb
|
390 |
|
1da177e4c
|
391 392 |
return 0; } |
1da177e4c
|
393 |
/* |
194ec0c07
|
394 395 |
* Determine if a media is present in the floppy drive, and if so, its LBA * capacity. |
1da177e4c
|
396 |
*/ |
806f80a6f
|
397 |
static int ide_floppy_get_capacity(ide_drive_t *drive) |
1da177e4c
|
398 |
{ |
0df962777
|
399 |
struct ide_disk_obj *floppy = drive->driver_data; |
2ac07d920
|
400 |
struct gendisk *disk = floppy->disk; |
8e5551239
|
401 |
struct ide_atapi_pc pc; |
194ec0c07
|
402 403 404 |
u8 *cap_desc; u8 header_len, desc_cnt; int i, rc = 1, blocks, length; |
1da177e4c
|
405 406 |
drive->bios_cyl = 0; drive->bios_head = drive->bios_sect = 0; |
fdb77da4c
|
407 408 |
floppy->blocks = 0; floppy->bs_factor = 1; |
6f84083bb
|
409 |
drive->capacity64 = 0; |
1da177e4c
|
410 |
|
0127854d7
|
411 |
ide_floppy_create_read_capacity_cmd(&pc); |
2ac07d920
|
412 |
if (ide_queue_pc_tail(drive, disk, &pc)) { |
7b3557262
|
413 414 |
printk(KERN_ERR PFX "Can't get floppy parameters "); |
1da177e4c
|
415 416 |
return 1; } |
8e5551239
|
417 418 |
header_len = pc.buf[3]; cap_desc = &pc.buf[4]; |
194ec0c07
|
419 420 421 422 |
desc_cnt = header_len / 8; /* capacity descriptor of 8 bytes */ for (i = 0; i < desc_cnt; i++) { unsigned int desc_start = 4 + i*8; |
85ae98a3d
|
423 424 |
blocks = be32_to_cpup((__be32 *)&pc.buf[desc_start]); length = be16_to_cpup((__be16 *)&pc.buf[desc_start + 6]); |
194ec0c07
|
425 |
|
7b3557262
|
426 427 428 429 |
ide_debug_log(IDE_DBG_PROBE, "Descriptor %d: %dkB, %d blocks, " "%d sector size ", i, blocks * length / 1024, blocks, length); |
1da177e4c
|
430 |
|
194ec0c07
|
431 432 433 434 435 |
if (i) continue; /* * the code below is valid only for the 1st descriptor, ie i=0 */ |
1da177e4c
|
436 |
|
8e5551239
|
437 |
switch (pc.buf[desc_start + 4] & 0x03) { |
1da177e4c
|
438 439 |
/* Clik! drive returns this instead of CAPACITY_CURRENT */ case CAPACITY_UNFORMATTED: |
ea68d270f
|
440 |
if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE)) |
0571c7a4f
|
441 |
/* |
1da177e4c
|
442 443 444 445 446 447 |
* If it is not a clik drive, break out * (maintains previous driver behaviour) */ break; case CAPACITY_CURRENT: /* Normal Zip/LS-120 disks */ |
194ec0c07
|
448 |
if (memcmp(cap_desc, &floppy->cap_desc, 8)) |
7b3557262
|
449 450 451 452 453 |
printk(KERN_INFO PFX "%s: %dkB, %d blocks, %d " "sector size ", drive->name, blocks * length / 1024, blocks, length); |
194ec0c07
|
454 |
memcpy(&floppy->cap_desc, cap_desc, 8); |
1da177e4c
|
455 |
if (!length || length % 512) { |
7b3557262
|
456 457 458 |
printk(KERN_NOTICE PFX "%s: %d bytes block size" " not supported ", drive->name, length); |
1da177e4c
|
459 |
} else { |
194ec0c07
|
460 461 462 463 |
floppy->blocks = blocks; floppy->block_size = length; floppy->bs_factor = length / 512; if (floppy->bs_factor != 1) |
7b3557262
|
464 465 466 467 468 |
printk(KERN_NOTICE PFX "%s: Warning: " "non 512 bytes block size not " "fully supported ", drive->name); |
6f84083bb
|
469 470 |
drive->capacity64 = floppy->blocks * floppy->bs_factor; |
194ec0c07
|
471 |
rc = 0; |
1da177e4c
|
472 473 474 475 476 477 478 |
} break; case CAPACITY_NO_CARTRIDGE: /* * This is a KERN_ERR so it appears on screen * for the user to see */ |
7b3557262
|
479 480 481 |
printk(KERN_ERR PFX "%s: No disk in drive ", drive->name); |
1da177e4c
|
482 483 |
break; case CAPACITY_INVALID: |
7b3557262
|
484 |
printk(KERN_ERR PFX "%s: Invalid capacity for disk " |
1da177e4c
|
485 486 487 488 |
"in drive ", drive->name); break; } |
7b3557262
|
489 490 491 |
ide_debug_log(IDE_DBG_PROBE, "Descriptor 0 Code: %d ", pc.buf[desc_start + 4] & 0x03); |
1da177e4c
|
492 493 494 |
} /* Clik! disk does not support get_flexible_disk_page */ |
ea68d270f
|
495 |
if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE)) |
07bd3f473
|
496 |
(void) ide_floppy_get_flexible_disk_page(drive, &pc); |
1da177e4c
|
497 |
|
1da177e4c
|
498 499 |
return rc; } |
806f80a6f
|
500 |
static void ide_floppy_setup(ide_drive_t *drive) |
1da177e4c
|
501 |
{ |
806f80a6f
|
502 |
struct ide_disk_obj *floppy = drive->driver_data; |
4dde4492d
|
503 |
u16 *id = drive->id; |
2e8a6f89d
|
504 |
|
85e39035c
|
505 506 507 |
drive->pc_callback = ide_floppy_callback; drive->pc_update_buffers = idefloppy_update_buffers; drive->pc_io_buffers = ide_io_buffers; |
3ad6776cc
|
508 |
|
1da177e4c
|
509 |
/* |
0571c7a4f
|
510 511 |
* We used to check revisions here. At this point however I'm giving up. * Just assume they are all broken, its easier. |
1da177e4c
|
512 |
* |
0571c7a4f
|
513 514 515 516 |
* The actual reason for the workarounds was likely a driver bug after * all rather than a firmware bug, and the workaround below used to hide * it. It should be fixed as of version 1.9, but to be on the safe side * we'll leave the limitation below for the 2.2.x tree. |
1da177e4c
|
517 |
*/ |
4dde4492d
|
518 |
if (!strncmp((char *)&id[ATA_ID_PROD], "IOMEGA ZIP 100 ATAPI", 20)) { |
ea68d270f
|
519 |
drive->atapi_flags |= IDE_AFLAG_ZIP_DRIVE; |
1da177e4c
|
520 |
/* This value will be visible in the /proc/ide/hdx/settings */ |
baf08f0be
|
521 |
drive->pc_delay = IDEFLOPPY_PC_DELAY; |
1da177e4c
|
522 523 524 525 |
blk_queue_max_sectors(drive->queue, 64); } /* |
0571c7a4f
|
526 527 528 |
* Guess what? The IOMEGA Clik! drive also needs the above fix. It makes * nasty clicking noises without it, so please don't remove this. */ |
4dde4492d
|
529 |
if (strncmp((char *)&id[ATA_ID_PROD], "IOMEGA Clik!", 11) == 0) { |
1da177e4c
|
530 |
blk_queue_max_sectors(drive->queue, 64); |
ea68d270f
|
531 |
drive->atapi_flags |= IDE_AFLAG_CLIK_DRIVE; |
0578042db
|
532 |
/* IOMEGA Clik! drives do not support lock/unlock commands */ |
42619d35c
|
533 |
drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING; |
1da177e4c
|
534 |
} |
194ec0c07
|
535 |
(void) ide_floppy_get_capacity(drive); |
1e874f448
|
536 537 |
ide_proc_register_driver(drive, floppy->driver); |
ae9f9f073
|
538 539 |
drive->dev_flags |= IDE_DFLAG_ATTACH; |
1da177e4c
|
540 |
} |
806f80a6f
|
541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 |
static void ide_floppy_flush(ide_drive_t *drive) { } static int ide_floppy_init_media(ide_drive_t *drive, struct gendisk *disk) { int ret = 0; if (ide_do_test_unit_ready(drive, disk)) ide_do_start_stop(drive, disk, 1); ret = ide_floppy_get_capacity(drive); set_capacity(disk, ide_gd_capacity(drive)); return ret; } const struct ide_disk_ops ide_atapi_disk_ops = { .check = ide_check_atapi_device, .get_capacity = ide_floppy_get_capacity, .setup = ide_floppy_setup, .flush = ide_floppy_flush, .init_media = ide_floppy_init_media, .set_doorlock = ide_set_media_lock, .do_request = ide_floppy_do_request, .end_request = ide_floppy_end_request, .ioctl = ide_floppy_ioctl, }; |