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