aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/ide.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/ide.h')
-rw-r--r--include/linux/ide.h125
1 files changed, 57 insertions, 68 deletions
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 9fed365a598b..edc93a6d931d 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -26,6 +26,9 @@
26#include <asm/io.h> 26#include <asm/io.h>
27#include <asm/mutex.h> 27#include <asm/mutex.h>
28 28
29/* for request_sense */
30#include <linux/cdrom.h>
31
29#if defined(CONFIG_CRIS) || defined(CONFIG_FRV) || defined(CONFIG_MN10300) 32#if defined(CONFIG_CRIS) || defined(CONFIG_FRV) || defined(CONFIG_MN10300)
30# define SUPPORT_VLB_SYNC 0 33# define SUPPORT_VLB_SYNC 0
31#else 34#else
@@ -154,12 +157,6 @@ enum {
154#define REQ_UNPARK_HEADS 0x23 157#define REQ_UNPARK_HEADS 0x23
155 158
156/* 159/*
157 * Check for an interrupt and acknowledge the interrupt status
158 */
159struct hwif_s;
160typedef int (ide_ack_intr_t)(struct hwif_s *);
161
162/*
163 * hwif_chipset_t is used to keep track of the specific hardware 160 * hwif_chipset_t is used to keep track of the specific hardware
164 * chipset used by each IDE interface, if known. 161 * chipset used by each IDE interface, if known.
165 */ 162 */
@@ -175,20 +172,18 @@ typedef u8 hwif_chipset_t;
175/* 172/*
176 * Structure to hold all information about the location of this port 173 * Structure to hold all information about the location of this port
177 */ 174 */
178typedef struct hw_regs_s { 175struct ide_hw {
179 union { 176 union {
180 struct ide_io_ports io_ports; 177 struct ide_io_ports io_ports;
181 unsigned long io_ports_array[IDE_NR_PORTS]; 178 unsigned long io_ports_array[IDE_NR_PORTS];
182 }; 179 };
183 180
184 int irq; /* our irq number */ 181 int irq; /* our irq number */
185 ide_ack_intr_t *ack_intr; /* acknowledge interrupt */
186 hwif_chipset_t chipset;
187 struct device *dev, *parent; 182 struct device *dev, *parent;
188 unsigned long config; 183 unsigned long config;
189} hw_regs_t; 184};
190 185
191static inline void ide_std_init_ports(hw_regs_t *hw, 186static inline void ide_std_init_ports(struct ide_hw *hw,
192 unsigned long io_addr, 187 unsigned long io_addr,
193 unsigned long ctl_addr) 188 unsigned long ctl_addr)
194{ 189{
@@ -215,21 +210,12 @@ static inline void ide_std_init_ports(hw_regs_t *hw,
215 210
216/* 211/*
217 * Special Driver Flags 212 * Special Driver Flags
218 *
219 * set_geometry : respecify drive geometry
220 * recalibrate : seek to cyl 0
221 * set_multmode : set multmode count
222 * reserved : unused
223 */ 213 */
224typedef union { 214enum {
225 unsigned all : 8; 215 IDE_SFLAG_SET_GEOMETRY = (1 << 0),
226 struct { 216 IDE_SFLAG_RECALIBRATE = (1 << 1),
227 unsigned set_geometry : 1; 217 IDE_SFLAG_SET_MULTMODE = (1 << 2),
228 unsigned recalibrate : 1; 218};
229 unsigned set_multmode : 1;
230 unsigned reserved : 5;
231 } b;
232} special_t;
233 219
234/* 220/*
235 * Status returned from various ide_ functions 221 * Status returned from various ide_ functions
@@ -324,7 +310,6 @@ struct ide_cmd {
324 unsigned int cursg_ofs; 310 unsigned int cursg_ofs;
325 311
326 struct request *rq; /* copy of request */ 312 struct request *rq; /* copy of request */
327 void *special; /* valid_t generally */
328}; 313};
329 314
330/* ATAPI packet command flags */ 315/* ATAPI packet command flags */
@@ -339,11 +324,6 @@ enum {
339 PC_FLAG_WRITING = (1 << 6), 324 PC_FLAG_WRITING = (1 << 6),
340}; 325};
341 326
342/*
343 * With each packet command, we allocate a buffer of IDE_PC_BUFFER_SIZE bytes.
344 * This is used for several packet commands (not for READ/WRITE commands).
345 */
346#define IDE_PC_BUFFER_SIZE 64
347#define ATAPI_WAIT_PC (60 * HZ) 327#define ATAPI_WAIT_PC (60 * HZ)
348 328
349struct ide_atapi_pc { 329struct ide_atapi_pc {
@@ -355,16 +335,6 @@ struct ide_atapi_pc {
355 335
356 /* bytes to transfer */ 336 /* bytes to transfer */
357 int req_xfer; 337 int req_xfer;
358 /* bytes actually transferred */
359 int xferred;
360
361 /* data buffer */
362 u8 *buf;
363 /* current buffer position */
364 u8 *cur_pos;
365 int buf_size;
366 /* missing/available data on the current buffer */
367 int b_count;
368 338
369 /* the corresponding request */ 339 /* the corresponding request */
370 struct request *rq; 340 struct request *rq;
@@ -375,12 +345,6 @@ struct ide_atapi_pc {
375 * those are more or less driver-specific and some of them are subject 345 * those are more or less driver-specific and some of them are subject
376 * to change/removal later. 346 * to change/removal later.
377 */ 347 */
378 u8 pc_buf[IDE_PC_BUFFER_SIZE];
379
380 /* idetape only */
381 struct idetape_bh *bh;
382 char *b_data;
383
384 unsigned long timeout; 348 unsigned long timeout;
385}; 349};
386 350
@@ -397,6 +361,7 @@ struct ide_drive_s;
397struct ide_disk_ops { 361struct ide_disk_ops {
398 int (*check)(struct ide_drive_s *, const char *); 362 int (*check)(struct ide_drive_s *, const char *);
399 int (*get_capacity)(struct ide_drive_s *); 363 int (*get_capacity)(struct ide_drive_s *);
364 u64 (*set_capacity)(struct ide_drive_s *, u64);
400 void (*setup)(struct ide_drive_s *); 365 void (*setup)(struct ide_drive_s *);
401 void (*flush)(struct ide_drive_s *); 366 void (*flush)(struct ide_drive_s *);
402 int (*init_media)(struct ide_drive_s *, struct gendisk *); 367 int (*init_media)(struct ide_drive_s *, struct gendisk *);
@@ -474,6 +439,8 @@ enum {
474 IDE_DFLAG_NICE1 = (1 << 5), 439 IDE_DFLAG_NICE1 = (1 << 5),
475 /* device is physically present */ 440 /* device is physically present */
476 IDE_DFLAG_PRESENT = (1 << 6), 441 IDE_DFLAG_PRESENT = (1 << 6),
442 /* disable Host Protected Area */
443 IDE_DFLAG_NOHPA = (1 << 7),
477 /* id read from device (synthetic if not set) */ 444 /* id read from device (synthetic if not set) */
478 IDE_DFLAG_ID_READ = (1 << 8), 445 IDE_DFLAG_ID_READ = (1 << 8),
479 IDE_DFLAG_NOPROBE = (1 << 9), 446 IDE_DFLAG_NOPROBE = (1 << 9),
@@ -512,6 +479,7 @@ enum {
512 /* write protect */ 479 /* write protect */
513 IDE_DFLAG_WP = (1 << 29), 480 IDE_DFLAG_WP = (1 << 29),
514 IDE_DFLAG_FORMAT_IN_PROGRESS = (1 << 30), 481 IDE_DFLAG_FORMAT_IN_PROGRESS = (1 << 30),
482 IDE_DFLAG_NIEN_QUIRK = (1 << 31),
515}; 483};
516 484
517struct ide_drive_s { 485struct ide_drive_s {
@@ -536,14 +504,13 @@ struct ide_drive_s {
536 unsigned long sleep; /* sleep until this time */ 504 unsigned long sleep; /* sleep until this time */
537 unsigned long timeout; /* max time to wait for irq */ 505 unsigned long timeout; /* max time to wait for irq */
538 506
539 special_t special; /* special action flags */ 507 u8 special_flags; /* special action flags */
540 508
541 u8 select; /* basic drive/head select reg value */ 509 u8 select; /* basic drive/head select reg value */
542 u8 retry_pio; /* retrying dma capable host in pio */ 510 u8 retry_pio; /* retrying dma capable host in pio */
543 u8 waiting_for_dma; /* dma currently in progress */ 511 u8 waiting_for_dma; /* dma currently in progress */
544 u8 dma; /* atapi dma flag */ 512 u8 dma; /* atapi dma flag */
545 513
546 u8 quirk_list; /* considered quirky, set for a specific host */
547 u8 init_speed; /* transfer rate set at boot */ 514 u8 init_speed; /* transfer rate set at boot */
548 u8 current_speed; /* current transfer rate set */ 515 u8 current_speed; /* current transfer rate set */
549 u8 desired_speed; /* desired transfer rate set */ 516 u8 desired_speed; /* desired transfer rate set */
@@ -565,11 +532,10 @@ struct ide_drive_s {
565 532
566 unsigned int bios_cyl; /* BIOS/fdisk/LILO number of cyls */ 533 unsigned int bios_cyl; /* BIOS/fdisk/LILO number of cyls */
567 unsigned int cyl; /* "real" number of cyls */ 534 unsigned int cyl; /* "real" number of cyls */
568 unsigned int drive_data; /* used by set_pio_mode/dev_select() */ 535 void *drive_data; /* used by set_pio_mode/dev_select() */
569 unsigned int failures; /* current failure count */ 536 unsigned int failures; /* current failure count */
570 unsigned int max_failures; /* maximum allowed failure count */ 537 unsigned int max_failures; /* maximum allowed failure count */
571 u64 probed_capacity;/* initial reported media capacity (ide-cd only currently) */ 538 u64 probed_capacity;/* initial/native media capacity */
572
573 u64 capacity64; /* total number of sectors */ 539 u64 capacity64; /* total number of sectors */
574 540
575 int lun; /* logical unit */ 541 int lun; /* logical unit */
@@ -593,16 +559,16 @@ struct ide_drive_s {
593 /* callback for packet commands */ 559 /* callback for packet commands */
594 int (*pc_callback)(struct ide_drive_s *, int); 560 int (*pc_callback)(struct ide_drive_s *, int);
595 561
596 void (*pc_update_buffers)(struct ide_drive_s *, struct ide_atapi_pc *);
597 int (*pc_io_buffers)(struct ide_drive_s *, struct ide_atapi_pc *,
598 unsigned int, int);
599
600 ide_startstop_t (*irq_handler)(struct ide_drive_s *); 562 ide_startstop_t (*irq_handler)(struct ide_drive_s *);
601 563
602 unsigned long atapi_flags; 564 unsigned long atapi_flags;
603 565
604 struct ide_atapi_pc request_sense_pc; 566 struct ide_atapi_pc request_sense_pc;
605 struct request request_sense_rq; 567
568 /* current sense rq and buffer */
569 bool sense_rq_armed;
570 struct request sense_rq;
571 struct request_sense sense_data;
606}; 572};
607 573
608typedef struct ide_drive_s ide_drive_t; 574typedef struct ide_drive_s ide_drive_t;
@@ -663,6 +629,7 @@ struct ide_port_ops {
663 void (*maskproc)(ide_drive_t *, int); 629 void (*maskproc)(ide_drive_t *, int);
664 void (*quirkproc)(ide_drive_t *); 630 void (*quirkproc)(ide_drive_t *);
665 void (*clear_irq)(ide_drive_t *); 631 void (*clear_irq)(ide_drive_t *);
632 int (*test_irq)(struct hwif_s *);
666 633
667 u8 (*mdma_filter)(ide_drive_t *); 634 u8 (*mdma_filter)(ide_drive_t *);
668 u8 (*udma_filter)(ide_drive_t *); 635 u8 (*udma_filter)(ide_drive_t *);
@@ -688,6 +655,10 @@ struct ide_dma_ops {
688 u8 (*dma_sff_read_status)(struct hwif_s *); 655 u8 (*dma_sff_read_status)(struct hwif_s *);
689}; 656};
690 657
658enum {
659 IDE_PFLAG_PROBING = (1 << 0),
660};
661
691struct ide_host; 662struct ide_host;
692 663
693typedef struct hwif_s { 664typedef struct hwif_s {
@@ -704,6 +675,8 @@ typedef struct hwif_s {
704 675
705 ide_drive_t *devices[MAX_DRIVES + 1]; 676 ide_drive_t *devices[MAX_DRIVES + 1];
706 677
678 unsigned long port_flags;
679
707 u8 major; /* our major number */ 680 u8 major; /* our major number */
708 u8 index; /* 0 for ide0; 1 for ide1; ... */ 681 u8 index; /* 0 for ide0; 1 for ide1; ... */
709 u8 channel; /* for dual-port chips: 0=primary, 1=secondary */ 682 u8 channel; /* for dual-port chips: 0=primary, 1=secondary */
@@ -722,8 +695,6 @@ typedef struct hwif_s {
722 695
723 struct device *dev; 696 struct device *dev;
724 697
725 ide_ack_intr_t *ack_intr;
726
727 void (*rw_disk)(ide_drive_t *, struct request *); 698 void (*rw_disk)(ide_drive_t *, struct request *);
728 699
729 const struct ide_tp_ops *tp_ops; 700 const struct ide_tp_ops *tp_ops;
@@ -1091,7 +1062,6 @@ int generic_ide_ioctl(ide_drive_t *, struct block_device *, unsigned, unsigned l
1091extern int ide_vlb_clk; 1062extern int ide_vlb_clk;
1092extern int ide_pci_clk; 1063extern int ide_pci_clk;
1093 1064
1094unsigned int ide_rq_bytes(struct request *);
1095int ide_end_rq(ide_drive_t *, struct request *, int, unsigned int); 1065int ide_end_rq(ide_drive_t *, struct request *, int, unsigned int);
1096void ide_kill_rq(ide_drive_t *, struct request *); 1066void ide_kill_rq(ide_drive_t *, struct request *);
1097 1067
@@ -1144,6 +1114,8 @@ void SELECT_MASK(ide_drive_t *, int);
1144u8 ide_read_error(ide_drive_t *); 1114u8 ide_read_error(ide_drive_t *);
1145void ide_read_bcount_and_ireason(ide_drive_t *, u16 *, u8 *); 1115void ide_read_bcount_and_ireason(ide_drive_t *, u16 *, u8 *);
1146 1116
1117int ide_check_ireason(ide_drive_t *, struct request *, int, int, int);
1118
1147int ide_check_atapi_device(ide_drive_t *, const char *); 1119int ide_check_atapi_device(ide_drive_t *, const char *);
1148 1120
1149void ide_init_pc(struct ide_atapi_pc *); 1121void ide_init_pc(struct ide_atapi_pc *);
@@ -1168,13 +1140,17 @@ enum {
1168 REQ_IDETAPE_WRITE = (1 << 3), 1140 REQ_IDETAPE_WRITE = (1 << 3),
1169}; 1141};
1170 1142
1171int ide_queue_pc_tail(ide_drive_t *, struct gendisk *, struct ide_atapi_pc *); 1143int ide_queue_pc_tail(ide_drive_t *, struct gendisk *, struct ide_atapi_pc *,
1144 void *, unsigned int);
1172 1145
1173int ide_do_test_unit_ready(ide_drive_t *, struct gendisk *); 1146int ide_do_test_unit_ready(ide_drive_t *, struct gendisk *);
1174int ide_do_start_stop(ide_drive_t *, struct gendisk *, int); 1147int ide_do_start_stop(ide_drive_t *, struct gendisk *, int);
1175int ide_set_media_lock(ide_drive_t *, struct gendisk *, int); 1148int ide_set_media_lock(ide_drive_t *, struct gendisk *, int);
1176void ide_create_request_sense_cmd(ide_drive_t *, struct ide_atapi_pc *); 1149void ide_create_request_sense_cmd(ide_drive_t *, struct ide_atapi_pc *);
1177void ide_retry_pc(ide_drive_t *, struct gendisk *); 1150void ide_retry_pc(ide_drive_t *drive);
1151
1152void ide_prep_sense(ide_drive_t *drive, struct request *rq);
1153int ide_queue_sense_rq(ide_drive_t *drive, void *special);
1178 1154
1179int ide_cd_expiry(ide_drive_t *); 1155int ide_cd_expiry(ide_drive_t *);
1180 1156
@@ -1225,7 +1201,7 @@ static inline int ide_pci_is_in_compatibility_mode(struct pci_dev *dev)
1225} 1201}
1226 1202
1227void ide_pci_setup_ports(struct pci_dev *, const struct ide_port_info *, 1203void ide_pci_setup_ports(struct pci_dev *, const struct ide_port_info *,
1228 hw_regs_t *, hw_regs_t **); 1204 struct ide_hw *, struct ide_hw **);
1229void ide_setup_pci_noise(struct pci_dev *, const struct ide_port_info *); 1205void ide_setup_pci_noise(struct pci_dev *, const struct ide_port_info *);
1230 1206
1231#ifdef CONFIG_BLK_DEV_IDEDMA_PCI 1207#ifdef CONFIG_BLK_DEV_IDEDMA_PCI
@@ -1384,7 +1360,6 @@ int ide_in_drive_list(u16 *, const struct drive_list_entry *);
1384#ifdef CONFIG_BLK_DEV_IDEDMA 1360#ifdef CONFIG_BLK_DEV_IDEDMA
1385int ide_dma_good_drive(ide_drive_t *); 1361int ide_dma_good_drive(ide_drive_t *);
1386int __ide_dma_bad_drive(ide_drive_t *); 1362int __ide_dma_bad_drive(ide_drive_t *);
1387int ide_id_dma_bug(ide_drive_t *);
1388 1363
1389u8 ide_find_dma_mode(ide_drive_t *, u8); 1364u8 ide_find_dma_mode(ide_drive_t *, u8);
1390 1365
@@ -1425,7 +1400,6 @@ void ide_dma_lost_irq(ide_drive_t *);
1425ide_startstop_t ide_dma_timeout_retry(ide_drive_t *, int); 1400ide_startstop_t ide_dma_timeout_retry(ide_drive_t *, int);
1426 1401
1427#else 1402#else
1428static inline int ide_id_dma_bug(ide_drive_t *drive) { return 0; }
1429static inline u8 ide_find_dma_mode(ide_drive_t *drive, u8 speed) { return 0; } 1403static inline u8 ide_find_dma_mode(ide_drive_t *drive, u8 speed) { return 0; }
1430static inline u8 ide_max_dma_mode(ide_drive_t *drive) { return 0; } 1404static inline u8 ide_max_dma_mode(ide_drive_t *drive) { return 0; }
1431static inline void ide_dma_off_quietly(ide_drive_t *drive) { ; } 1405static inline void ide_dma_off_quietly(ide_drive_t *drive) { ; }
@@ -1445,6 +1419,7 @@ static inline void ide_dma_unmap_sg(ide_drive_t *drive,
1445 1419
1446#ifdef CONFIG_BLK_DEV_IDEACPI 1420#ifdef CONFIG_BLK_DEV_IDEACPI
1447int ide_acpi_init(void); 1421int ide_acpi_init(void);
1422bool ide_port_acpi(ide_hwif_t *hwif);
1448extern int ide_acpi_exec_tfs(ide_drive_t *drive); 1423extern int ide_acpi_exec_tfs(ide_drive_t *drive);
1449extern void ide_acpi_get_timing(ide_hwif_t *hwif); 1424extern void ide_acpi_get_timing(ide_hwif_t *hwif);
1450extern void ide_acpi_push_timing(ide_hwif_t *hwif); 1425extern void ide_acpi_push_timing(ide_hwif_t *hwif);
@@ -1453,6 +1428,7 @@ void ide_acpi_port_init_devices(ide_hwif_t *);
1453extern void ide_acpi_set_state(ide_hwif_t *hwif, int on); 1428extern void ide_acpi_set_state(ide_hwif_t *hwif, int on);
1454#else 1429#else
1455static inline int ide_acpi_init(void) { return 0; } 1430static inline int ide_acpi_init(void) { return 0; }
1431static inline bool ide_port_acpi(ide_hwif_t *hwif) { return 0; }
1456static inline int ide_acpi_exec_tfs(ide_drive_t *drive) { return 0; } 1432static inline int ide_acpi_exec_tfs(ide_drive_t *drive) { return 0; }
1457static inline void ide_acpi_get_timing(ide_hwif_t *hwif) { ; } 1433static inline void ide_acpi_get_timing(ide_hwif_t *hwif) { ; }
1458static inline void ide_acpi_push_timing(ide_hwif_t *hwif) { ; } 1434static inline void ide_acpi_push_timing(ide_hwif_t *hwif) { ; }
@@ -1464,16 +1440,18 @@ static inline void ide_acpi_set_state(ide_hwif_t *hwif, int on) {}
1464void ide_register_region(struct gendisk *); 1440void ide_register_region(struct gendisk *);
1465void ide_unregister_region(struct gendisk *); 1441void ide_unregister_region(struct gendisk *);
1466 1442
1443void ide_check_nien_quirk_list(ide_drive_t *);
1467void ide_undecoded_slave(ide_drive_t *); 1444void ide_undecoded_slave(ide_drive_t *);
1468 1445
1469void ide_port_apply_params(ide_hwif_t *); 1446void ide_port_apply_params(ide_hwif_t *);
1470int ide_sysfs_register_port(ide_hwif_t *); 1447int ide_sysfs_register_port(ide_hwif_t *);
1471 1448
1472struct ide_host *ide_host_alloc(const struct ide_port_info *, hw_regs_t **); 1449struct ide_host *ide_host_alloc(const struct ide_port_info *, struct ide_hw **,
1450 unsigned int);
1473void ide_host_free(struct ide_host *); 1451void ide_host_free(struct ide_host *);
1474int ide_host_register(struct ide_host *, const struct ide_port_info *, 1452int ide_host_register(struct ide_host *, const struct ide_port_info *,
1475 hw_regs_t **); 1453 struct ide_hw **);
1476int ide_host_add(const struct ide_port_info *, hw_regs_t **, 1454int ide_host_add(const struct ide_port_info *, struct ide_hw **, unsigned int,
1477 struct ide_host **); 1455 struct ide_host **);
1478void ide_host_remove(struct ide_host *); 1456void ide_host_remove(struct ide_host *);
1479int ide_legacy_device_add(const struct ide_port_info *, unsigned long); 1457int ide_legacy_device_add(const struct ide_port_info *, unsigned long);
@@ -1533,6 +1511,7 @@ int ide_timing_compute(ide_drive_t *, u8, struct ide_timing *, int, int);
1533int ide_scan_pio_blacklist(char *); 1511int ide_scan_pio_blacklist(char *);
1534const char *ide_xfer_verbose(u8); 1512const char *ide_xfer_verbose(u8);
1535u8 ide_get_best_pio_mode(ide_drive_t *, u8, u8); 1513u8 ide_get_best_pio_mode(ide_drive_t *, u8, u8);
1514int ide_pio_need_iordy(ide_drive_t *, const u8);
1536int ide_set_pio_mode(ide_drive_t *, u8); 1515int ide_set_pio_mode(ide_drive_t *, u8);
1537int ide_set_dma_mode(ide_drive_t *, u8); 1516int ide_set_dma_mode(ide_drive_t *, u8);
1538void ide_set_pio(ide_drive_t *, u8); 1517void ide_set_pio(ide_drive_t *, u8);
@@ -1570,6 +1549,16 @@ static inline ide_drive_t *ide_get_pair_dev(ide_drive_t *drive)
1570 return (peer->dev_flags & IDE_DFLAG_PRESENT) ? peer : NULL; 1549 return (peer->dev_flags & IDE_DFLAG_PRESENT) ? peer : NULL;
1571} 1550}
1572 1551
1552static inline void *ide_get_drivedata(ide_drive_t *drive)
1553{
1554 return drive->drive_data;
1555}
1556
1557static inline void ide_set_drivedata(ide_drive_t *drive, void *data)
1558{
1559 drive->drive_data = data;
1560}
1561
1573#define ide_port_for_each_dev(i, dev, port) \ 1562#define ide_port_for_each_dev(i, dev, port) \
1574 for ((i) = 0; ((dev) = (port)->devices[i]) || (i) < MAX_DRIVES; (i)++) 1563 for ((i) = 0; ((dev) = (port)->devices[i]) || (i) < MAX_DRIVES; (i)++)
1575 1564