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.h174
1 files changed, 103 insertions, 71 deletions
diff --git a/include/linux/ide.h b/include/linux/ide.h
index bc26b2f27359..6c39482fd1a1 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -82,24 +82,10 @@ typedef unsigned char byte; /* used everywhere */
82 82
83#define IDE_FEATURE_OFFSET IDE_ERROR_OFFSET 83#define IDE_FEATURE_OFFSET IDE_ERROR_OFFSET
84#define IDE_COMMAND_OFFSET IDE_STATUS_OFFSET 84#define IDE_COMMAND_OFFSET IDE_STATUS_OFFSET
85 85#define IDE_ALTSTATUS_OFFSET IDE_CONTROL_OFFSET
86#define IDE_DATA_REG (HWIF(drive)->io_ports[IDE_DATA_OFFSET]) 86#define IDE_IREASON_OFFSET IDE_NSECTOR_OFFSET
87#define IDE_ERROR_REG (HWIF(drive)->io_ports[IDE_ERROR_OFFSET]) 87#define IDE_BCOUNTL_OFFSET IDE_LCYL_OFFSET
88#define IDE_NSECTOR_REG (HWIF(drive)->io_ports[IDE_NSECTOR_OFFSET]) 88#define IDE_BCOUNTH_OFFSET IDE_HCYL_OFFSET
89#define IDE_SECTOR_REG (HWIF(drive)->io_ports[IDE_SECTOR_OFFSET])
90#define IDE_LCYL_REG (HWIF(drive)->io_ports[IDE_LCYL_OFFSET])
91#define IDE_HCYL_REG (HWIF(drive)->io_ports[IDE_HCYL_OFFSET])
92#define IDE_SELECT_REG (HWIF(drive)->io_ports[IDE_SELECT_OFFSET])
93#define IDE_STATUS_REG (HWIF(drive)->io_ports[IDE_STATUS_OFFSET])
94#define IDE_CONTROL_REG (HWIF(drive)->io_ports[IDE_CONTROL_OFFSET])
95#define IDE_IRQ_REG (HWIF(drive)->io_ports[IDE_IRQ_OFFSET])
96
97#define IDE_FEATURE_REG IDE_ERROR_REG
98#define IDE_COMMAND_REG IDE_STATUS_REG
99#define IDE_ALTSTATUS_REG IDE_CONTROL_REG
100#define IDE_IREASON_REG IDE_NSECTOR_REG
101#define IDE_BCOUNTL_REG IDE_LCYL_REG
102#define IDE_BCOUNTH_REG IDE_HCYL_REG
103 89
104#define OK_STAT(stat,good,bad) (((stat)&((good)|(bad)))==(good)) 90#define OK_STAT(stat,good,bad) (((stat)&((good)|(bad)))==(good))
105#define BAD_R_STAT (BUSY_STAT | ERR_STAT) 91#define BAD_R_STAT (BUSY_STAT | ERR_STAT)
@@ -169,7 +155,7 @@ enum { ide_unknown, ide_generic, ide_pci,
169 ide_rz1000, ide_trm290, 155 ide_rz1000, ide_trm290,
170 ide_cmd646, ide_cy82c693, ide_4drives, 156 ide_cmd646, ide_cy82c693, ide_4drives,
171 ide_pmac, ide_etrax100, ide_acorn, 157 ide_pmac, ide_etrax100, ide_acorn,
172 ide_au1xxx, ide_palm3710, ide_forced 158 ide_au1xxx, ide_palm3710
173}; 159};
174 160
175typedef u8 hwif_chipset_t; 161typedef u8 hwif_chipset_t;
@@ -186,14 +172,9 @@ typedef struct hw_regs_s {
186} hw_regs_t; 172} hw_regs_t;
187 173
188struct hwif_s * ide_find_port(unsigned long); 174struct hwif_s * ide_find_port(unsigned long);
189struct hwif_s *ide_deprecated_find_port(unsigned long);
190void ide_init_port_data(struct hwif_s *, unsigned int); 175void ide_init_port_data(struct hwif_s *, unsigned int);
191void ide_init_port_hw(struct hwif_s *, hw_regs_t *); 176void ide_init_port_hw(struct hwif_s *, hw_regs_t *);
192 177
193struct ide_drive_s;
194int ide_register_hw(hw_regs_t *, void (*)(struct ide_drive_s *),
195 struct hwif_s **);
196
197static inline void ide_std_init_ports(hw_regs_t *hw, 178static inline void ide_std_init_ports(hw_regs_t *hw,
198 unsigned long io_addr, 179 unsigned long io_addr,
199 unsigned long ctl_addr) 180 unsigned long ctl_addr)
@@ -213,45 +194,6 @@ static inline void ide_std_init_ports(hw_regs_t *hw,
213#define MAX_HWIFS CONFIG_IDE_MAX_HWIFS 194#define MAX_HWIFS CONFIG_IDE_MAX_HWIFS
214#endif 195#endif
215 196
216/* needed on alpha, x86/x86_64, ia64, mips, ppc32 and sh */
217#ifndef IDE_ARCH_OBSOLETE_DEFAULTS
218# define ide_default_io_base(index) (0)
219# define ide_default_irq(base) (0)
220# define ide_init_default_irq(base) (0)
221#endif
222
223#ifdef CONFIG_IDE_ARCH_OBSOLETE_INIT
224static inline void ide_init_hwif_ports(hw_regs_t *hw,
225 unsigned long io_addr,
226 unsigned long ctl_addr,
227 int *irq)
228{
229 if (!ctl_addr)
230 ide_std_init_ports(hw, io_addr, ide_default_io_ctl(io_addr));
231 else
232 ide_std_init_ports(hw, io_addr, ctl_addr);
233
234 if (irq)
235 *irq = 0;
236
237 hw->io_ports[IDE_IRQ_OFFSET] = 0;
238
239#ifdef CONFIG_PPC32
240 if (ppc_ide_md.ide_init_hwif)
241 ppc_ide_md.ide_init_hwif(hw, io_addr, ctl_addr, irq);
242#endif
243}
244#else
245static inline void ide_init_hwif_ports(hw_regs_t *hw,
246 unsigned long io_addr,
247 unsigned long ctl_addr,
248 int *irq)
249{
250 if (io_addr || ctl_addr)
251 printk(KERN_WARNING "%s: must not be called\n", __FUNCTION__);
252}
253#endif /* CONFIG_IDE_ARCH_OBSOLETE_INIT */
254
255/* Currently only m68k, apus and m8xx need it */ 197/* Currently only m68k, apus and m8xx need it */
256#ifndef IDE_ARCH_ACK_INTR 198#ifndef IDE_ARCH_ACK_INTR
257# define ide_ack_intr(hwif) (1) 199# define ide_ack_intr(hwif) (1)
@@ -406,7 +348,7 @@ typedef struct ide_drive_s {
406 u8 wcache; /* status of write cache */ 348 u8 wcache; /* status of write cache */
407 u8 acoustic; /* acoustic management */ 349 u8 acoustic; /* acoustic management */
408 u8 media; /* disk, cdrom, tape, floppy, ... */ 350 u8 media; /* disk, cdrom, tape, floppy, ... */
409 u8 ctl; /* "normal" value for IDE_CONTROL_REG */ 351 u8 ctl; /* "normal" value for Control register */
410 u8 ready_stat; /* min status value for drive ready */ 352 u8 ready_stat; /* min status value for drive ready */
411 u8 mult_count; /* current multiple sector setting */ 353 u8 mult_count; /* current multiple sector setting */
412 u8 mult_req; /* requested multiple sector setting */ 354 u8 mult_req; /* requested multiple sector setting */
@@ -507,8 +449,6 @@ typedef struct hwif_s {
507 void (*maskproc)(ide_drive_t *, int); 449 void (*maskproc)(ide_drive_t *, int);
508 /* check host's drive quirk list */ 450 /* check host's drive quirk list */
509 void (*quirkproc)(ide_drive_t *); 451 void (*quirkproc)(ide_drive_t *);
510 /* driver soft-power interface */
511 int (*busproc)(ide_drive_t *, int);
512#endif 452#endif
513 u8 (*mdma_filter)(ide_drive_t *); 453 u8 (*mdma_filter)(ide_drive_t *);
514 u8 (*udma_filter)(ide_drive_t *); 454 u8 (*udma_filter)(ide_drive_t *);
@@ -578,7 +518,6 @@ typedef struct hwif_s {
578 518
579 unsigned noprobe : 1; /* don't probe for this interface */ 519 unsigned noprobe : 1; /* don't probe for this interface */
580 unsigned present : 1; /* this interface exists */ 520 unsigned present : 1; /* this interface exists */
581 unsigned hold : 1; /* this interface is always present */
582 unsigned serialized : 1; /* serialized all channel operation */ 521 unsigned serialized : 1; /* serialized all channel operation */
583 unsigned sharing_irq: 1; /* 1 = sharing irq with another hwif */ 522 unsigned sharing_irq: 1; /* 1 = sharing irq with another hwif */
584 unsigned reset : 1; /* reset after probe */ 523 unsigned reset : 1; /* reset after probe */
@@ -586,7 +525,9 @@ typedef struct hwif_s {
586 unsigned mmio : 1; /* host uses MMIO */ 525 unsigned mmio : 1; /* host uses MMIO */
587 unsigned straight8 : 1; /* Alan's straight 8 check */ 526 unsigned straight8 : 1; /* Alan's straight 8 check */
588 527
589 struct device gendev; 528 struct device gendev;
529 struct device *portdev;
530
590 struct completion gendev_rel_comp; /* To deal with device release() */ 531 struct completion gendev_rel_comp; /* To deal with device release() */
591 532
592 void *hwif_data; /* extra hwif data */ 533 void *hwif_data; /* extra hwif data */
@@ -647,6 +588,68 @@ int set_io_32bit(ide_drive_t *, int);
647int set_pio_mode(ide_drive_t *, int); 588int set_pio_mode(ide_drive_t *, int);
648int set_using_dma(ide_drive_t *, int); 589int set_using_dma(ide_drive_t *, int);
649 590
591/* ATAPI packet command flags */
592enum {
593 /* set when an error is considered normal - no retry (ide-tape) */
594 PC_FLAG_ABORT = (1 << 0),
595 PC_FLAG_SUPPRESS_ERROR = (1 << 1),
596 PC_FLAG_WAIT_FOR_DSC = (1 << 2),
597 PC_FLAG_DMA_OK = (1 << 3),
598 PC_FLAG_DMA_RECOMMENDED = (1 << 4),
599 PC_FLAG_DMA_IN_PROGRESS = (1 << 5),
600 PC_FLAG_DMA_ERROR = (1 << 6),
601 PC_FLAG_WRITING = (1 << 7),
602 /* command timed out */
603 PC_FLAG_TIMEDOUT = (1 << 8),
604};
605
606struct ide_atapi_pc {
607 /* actual packet bytes */
608 u8 c[12];
609 /* incremented on each retry */
610 int retries;
611 int error;
612
613 /* bytes to transfer */
614 int req_xfer;
615 /* bytes actually transferred */
616 int xferred;
617
618 /* data buffer */
619 u8 *buf;
620 /* current buffer position */
621 u8 *cur_pos;
622 int buf_size;
623 /* missing/available data on the current buffer */
624 int b_count;
625
626 /* the corresponding request */
627 struct request *rq;
628
629 unsigned long flags;
630
631 /*
632 * those are more or less driver-specific and some of them are subject
633 * to change/removal later.
634 */
635 u8 pc_buf[256];
636 void (*idefloppy_callback) (ide_drive_t *);
637 ide_startstop_t (*idetape_callback) (ide_drive_t *);
638
639 /* idetape only */
640 struct idetape_bh *bh;
641 char *b_data;
642
643 /* idescsi only for now */
644 struct scatterlist *sg;
645 unsigned int sg_cnt;
646
647 struct scsi_cmnd *scsi_cmd;
648 void (*done) (struct scsi_cmnd *);
649
650 unsigned long timeout;
651};
652
650#ifdef CONFIG_IDE_PROC_FS 653#ifdef CONFIG_IDE_PROC_FS
651/* 654/*
652 * configurable drive settings 655 * configurable drive settings
@@ -691,6 +694,7 @@ void proc_ide_create(void);
691void proc_ide_destroy(void); 694void proc_ide_destroy(void);
692void ide_proc_register_port(ide_hwif_t *); 695void ide_proc_register_port(ide_hwif_t *);
693void ide_proc_port_register_devices(ide_hwif_t *); 696void ide_proc_port_register_devices(ide_hwif_t *);
697void ide_proc_unregister_device(ide_drive_t *);
694void ide_proc_unregister_port(ide_hwif_t *); 698void ide_proc_unregister_port(ide_hwif_t *);
695void ide_proc_register_driver(ide_drive_t *, ide_driver_t *); 699void ide_proc_register_driver(ide_drive_t *, ide_driver_t *);
696void ide_proc_unregister_driver(ide_drive_t *, ide_driver_t *); 700void ide_proc_unregister_driver(ide_drive_t *, ide_driver_t *);
@@ -724,6 +728,7 @@ static inline void proc_ide_create(void) { ; }
724static inline void proc_ide_destroy(void) { ; } 728static inline void proc_ide_destroy(void) { ; }
725static inline void ide_proc_register_port(ide_hwif_t *hwif) { ; } 729static inline void ide_proc_register_port(ide_hwif_t *hwif) { ; }
726static inline void ide_proc_port_register_devices(ide_hwif_t *hwif) { ; } 730static inline void ide_proc_port_register_devices(ide_hwif_t *hwif) { ; }
731static inline void ide_proc_unregister_device(ide_drive_t *drive) { ; }
727static inline void ide_proc_unregister_port(ide_hwif_t *hwif) { ; } 732static inline void ide_proc_unregister_port(ide_hwif_t *hwif) { ; }
728static inline void ide_proc_register_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } 733static inline void ide_proc_register_driver(ide_drive_t *drive, ide_driver_t *driver) { ; }
729static inline void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } 734static inline void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver) { ; }
@@ -990,7 +995,6 @@ extern void do_ide_request(struct request_queue *);
990void ide_init_disk(struct gendisk *, ide_drive_t *); 995void ide_init_disk(struct gendisk *, ide_drive_t *);
991 996
992#ifdef CONFIG_IDEPCI_PCIBUS_ORDER 997#ifdef CONFIG_IDEPCI_PCIBUS_ORDER
993extern int ide_scan_direction;
994extern int __ide_pci_register_driver(struct pci_driver *driver, struct module *owner, const char *mod_name); 998extern int __ide_pci_register_driver(struct pci_driver *driver, struct module *owner, const char *mod_name);
995#define ide_pci_register_driver(d) __ide_pci_register_driver(d, THIS_MODULE, KBUILD_MODNAME) 999#define ide_pci_register_driver(d) __ide_pci_register_driver(d, THIS_MODULE, KBUILD_MODNAME)
996#else 1000#else
@@ -1195,7 +1199,7 @@ static inline void ide_acpi_set_state(ide_hwif_t *hwif, int on) {}
1195void ide_remove_port_from_hwgroup(ide_hwif_t *); 1199void ide_remove_port_from_hwgroup(ide_hwif_t *);
1196extern int ide_hwif_request_regions(ide_hwif_t *hwif); 1200extern int ide_hwif_request_regions(ide_hwif_t *hwif);
1197extern void ide_hwif_release_regions(ide_hwif_t* hwif); 1201extern void ide_hwif_release_regions(ide_hwif_t* hwif);
1198void ide_unregister(unsigned int, int, int); 1202void ide_unregister(unsigned int);
1199 1203
1200void ide_register_region(struct gendisk *); 1204void ide_register_region(struct gendisk *);
1201void ide_unregister_region(struct gendisk *); 1205void ide_unregister_region(struct gendisk *);
@@ -1204,6 +1208,8 @@ void ide_undecoded_slave(ide_drive_t *);
1204 1208
1205int ide_device_add_all(u8 *idx, const struct ide_port_info *); 1209int ide_device_add_all(u8 *idx, const struct ide_port_info *);
1206int ide_device_add(u8 idx[4], const struct ide_port_info *); 1210int ide_device_add(u8 idx[4], const struct ide_port_info *);
1211void ide_port_unregister_devices(ide_hwif_t *);
1212void ide_port_scan(ide_hwif_t *);
1207 1213
1208static inline void *ide_get_hwifdata (ide_hwif_t * hwif) 1214static inline void *ide_get_hwifdata (ide_hwif_t * hwif)
1209{ 1215{
@@ -1279,6 +1285,7 @@ extern struct mutex ide_cfg_mtx;
1279#define local_irq_set(flags) do { local_save_flags((flags)); local_irq_enable_in_hardirq(); } while (0) 1285#define local_irq_set(flags) do { local_save_flags((flags)); local_irq_enable_in_hardirq(); } while (0)
1280 1286
1281extern struct bus_type ide_bus_type; 1287extern struct bus_type ide_bus_type;
1288extern struct class *ide_port_class;
1282 1289
1283/* check if CACHE FLUSH (EXT) command is supported (bits defined in ATA-6) */ 1290/* check if CACHE FLUSH (EXT) command is supported (bits defined in ATA-6) */
1284#define ide_id_has_flush_cache(id) ((id)->cfs_enable_2 & 0x3000) 1291#define ide_id_has_flush_cache(id) ((id)->cfs_enable_2 & 0x3000)
@@ -1307,7 +1314,10 @@ static inline ide_drive_t *ide_get_paired_drive(ide_drive_t *drive)
1307 1314
1308static inline void ide_set_irq(ide_drive_t *drive, int on) 1315static inline void ide_set_irq(ide_drive_t *drive, int on)
1309{ 1316{
1310 drive->hwif->OUTB(drive->ctl | (on ? 0 : 2), IDE_CONTROL_REG); 1317 ide_hwif_t *hwif = drive->hwif;
1318
1319 hwif->OUTB(drive->ctl | (on ? 0 : 2),
1320 hwif->io_ports[IDE_CONTROL_OFFSET]);
1311} 1321}
1312 1322
1313static inline u8 ide_read_status(ide_drive_t *drive) 1323static inline u8 ide_read_status(ide_drive_t *drive)
@@ -1331,4 +1341,26 @@ static inline u8 ide_read_error(ide_drive_t *drive)
1331 return hwif->INB(hwif->io_ports[IDE_ERROR_OFFSET]); 1341 return hwif->INB(hwif->io_ports[IDE_ERROR_OFFSET]);
1332} 1342}
1333 1343
1344/*
1345 * Too bad. The drive wants to send us data which we are not ready to accept.
1346 * Just throw it away.
1347 */
1348static inline void ide_atapi_discard_data(ide_drive_t *drive, unsigned bcount)
1349{
1350 ide_hwif_t *hwif = drive->hwif;
1351
1352 /* FIXME: use ->atapi_input_bytes */
1353 while (bcount--)
1354 (void)hwif->INB(hwif->io_ports[IDE_DATA_OFFSET]);
1355}
1356
1357static inline void ide_atapi_write_zeros(ide_drive_t *drive, unsigned bcount)
1358{
1359 ide_hwif_t *hwif = drive->hwif;
1360
1361 /* FIXME: use ->atapi_output_bytes */
1362 while (bcount--)
1363 hwif->OUTB(0, hwif->io_ports[IDE_DATA_OFFSET]);
1364}
1365
1334#endif /* _IDE_H */ 1366#endif /* _IDE_H */