1/* 2 * linux/include/asm-x86_64/ide.h 3 * 4 * Copyright (C) 1994-1996 Linus Torvalds & authors 5 */ 6 7/* 8 * This file contains the x86_64 architecture specific IDE code. 9 */ 10 11#ifndef __ASMx86_64_IDE_H 12#define __ASMx86_64_IDE_H 13 14#ifdef __KERNEL__ 15 16#include <linux/config.h> 17 18#ifndef MAX_HWIFS 19# ifdef CONFIG_BLK_DEV_IDEPCI 20#define MAX_HWIFS 10 21# else 22#define MAX_HWIFS 6 23# endif 24#endif 25 26#define ide__sti() __sti() 27 28static __inline__ int ide_default_irq(ide_ioreg_t base) 29{ 30 switch (base) { 31 case 0x1f0: return 14; 32 case 0x170: return 15; 33 case 0x1e8: return 11; 34 case 0x168: return 10; 35 case 0x1e0: return 8; 36 case 0x160: return 12; 37 default: 38 return 0; 39 } 40} 41 42static __inline__ ide_ioreg_t ide_default_io_base(int index) 43{ 44 switch (index) { 45 case 0: return 0x1f0; 46 case 1: return 0x170; 47 case 2: return 0x1e8; 48 case 3: return 0x168; 49 case 4: return 0x1e0; 50 case 5: return 0x160; 51 default: 52 return 0; 53 } 54} 55 56static __inline__ void ide_init_hwif_ports(hw_regs_t *hw, ide_ioreg_t data_port, ide_ioreg_t ctrl_port, int *irq) 57{ 58 ide_ioreg_t reg = data_port; 59 int i; 60 61 for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) { 62 hw->io_ports[i] = reg; 63 reg += 1; 64 } 65 if (ctrl_port) { 66 hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port; 67 } else { 68 hw->io_ports[IDE_CONTROL_OFFSET] = hw->io_ports[IDE_DATA_OFFSET] + 0x206; 69 } 70 if (irq != NULL) 71 *irq = 0; 72 hw->io_ports[IDE_IRQ_OFFSET] = 0; 73} 74 75static __inline__ void ide_init_default_hwifs(void) 76{ 77#ifndef CONFIG_BLK_DEV_IDEPCI 78 hw_regs_t hw; 79 int index; 80 81 for(index = 0; index < MAX_HWIFS; index++) { 82 ide_init_hwif_ports(&hw, ide_default_io_base(index), 0, NULL); 83 hw.irq = ide_default_irq(ide_default_io_base(index)); 84 ide_register_hw(&hw, NULL); 85 } 86#endif /* CONFIG_BLK_DEV_IDEPCI */ 87} 88 89typedef union { 90 unsigned all : 8; /* all of the bits together */ 91 struct { 92 unsigned head : 4; /* always zeros here */ 93 unsigned unit : 1; /* drive select number, 0 or 1 */ 94 unsigned bit5 : 1; /* always 1 */ 95 unsigned lba : 1; /* using LBA instead of CHS */ 96 unsigned bit7 : 1; /* always 1 */ 97 } b; 98} select_t; 99 100typedef union { 101 unsigned all : 8; /* all of the bits together */ 102 struct { 103 unsigned bit0 : 1; 104 unsigned nIEN : 1; /* device INTRQ to host */ 105 unsigned SRST : 1; /* host soft reset bit */ 106 unsigned bit3 : 1; /* ATA-2 thingy */ 107 unsigned reserved456 : 3; 108 unsigned HOB : 1; /* 48-bit address ordering */ 109 } b; 110} control_t; 111 112#define ide_request_irq(irq,hand,flg,dev,id) request_irq((irq),(hand),(flg),(dev),(id)) 113#define ide_free_irq(irq,dev_id) free_irq((irq), (dev_id)) 114#define ide_check_region(from,extent) check_region((from), (extent)) 115#define ide_request_region(from,extent,name) request_region((from), (extent), (name)) 116#define ide_release_region(from,extent) release_region((from), (extent)) 117 118/* 119 * The following are not needed for the non-m68k ports 120 */ 121#define ide_ack_intr(hwif) (1) 122#define ide_fix_driveid(id) do {} while (0) 123#define ide_release_lock(lock) do {} while (0) 124#define ide_get_lock(lock, hdlr, data) do {} while (0) 125 126#endif /* __KERNEL__ */ 127 128#endif /* __ASMx86_64_IDE_H */ 129