1 /*
2  * This file is subject to the terms and conditions of the GNU General Public
3  * License.  See the file "COPYING" in the main directory of this archive
4  * for more details.
5  *
6  * IDE routines for typical pc-like standard configurations.
7  *
8  * Copyright (C) 1998, 1999, 2001 by Ralf Baechle
9  */
10 #include <linux/sched.h>
11 #include <linux/ide.h>
12 #include <linux/ioport.h>
13 #include <linux/hdreg.h>
14 #include <asm/ptrace.h>
15 #include <asm/hdreg.h>
16 
std_ide_default_irq(ide_ioreg_t base)17 static int std_ide_default_irq(ide_ioreg_t base)
18 {
19 	switch (base) {
20 		case 0x1f0: return 14;
21 		case 0x170: return 15;
22 		case 0x1e8: return 11;
23 		case 0x168: return 10;
24 		case 0x1e0: return 8;
25 		case 0x160: return 12;
26 		default:
27 			return 0;
28 	}
29 }
30 
std_ide_default_io_base(int index)31 static ide_ioreg_t std_ide_default_io_base(int index)
32 {
33 	switch (index) {
34 		case 0:	return 0x1f0;
35 		case 1:	return 0x170;
36 		case 2: return 0x1e8;
37 		case 3: return 0x168;
38 		case 4: return 0x1e0;
39 		case 5: return 0x160;
40 		default:
41 			return 0;
42 	}
43 }
44 
std_ide_init_hwif_ports(hw_regs_t * hw,ide_ioreg_t data_port,ide_ioreg_t ctrl_port,int * irq)45 static void std_ide_init_hwif_ports (hw_regs_t *hw, ide_ioreg_t data_port,
46                                      ide_ioreg_t ctrl_port, int *irq)
47 {
48 	ide_ioreg_t reg = data_port;
49 	int i;
50 
51 	for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
52 		hw->io_ports[i] = reg;
53 		reg += 1;
54 	}
55 	if (ctrl_port) {
56 		hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
57 	} else {
58 		hw->io_ports[IDE_CONTROL_OFFSET] = hw->io_ports[IDE_DATA_OFFSET] + 0x206;
59 	}
60 	if (irq != NULL)
61 		*irq = 0;
62 	hw->io_ports[IDE_IRQ_OFFSET] = 0;
63 }
64 
65 struct ide_ops std_ide_ops = {
66 	&std_ide_default_irq,
67 	&std_ide_default_io_base,
68 	&std_ide_init_hwif_ports
69 };
70