more changes on original files
[linux-2.4.git] / include / asm-parisc / ide.h
1 /*
2  *  linux/include/asm-parisc/ide.h
3  *
4  *  Copyright (C) 1994-1996  Linus Torvalds & authors
5  */
6
7 /*
8  *  This file contains the PARISC architecture specific IDE code.
9  */
10
11 #ifndef __ASM_PARISC_IDE_H
12 #define __ASM_PARISC_IDE_H
13
14 #ifdef __KERNEL__
15
16 #include <linux/config.h>
17 #include <asm/superio.h>
18
19 #ifndef MAX_HWIFS
20 #define MAX_HWIFS       2
21 #endif
22
23 static __inline__ int ide_default_irq(ide_ioreg_t base)
24 {
25         switch (base) {
26 #ifdef CONFIG_SUPERIO
27                 case 0x1f0: 
28                 case 0x170:
29                         return superio_get_ide_irq();
30 #endif /* CONFIG_SUPERIO */
31                 default:
32                         return 0;
33         }
34 }
35
36 static __inline__ ide_ioreg_t ide_default_io_base(int index)
37 {
38         switch (index) {
39 #ifdef CONFIG_SUPERIO 
40                 case 0: return (superio_get_ide_irq() ? 0x1f0 : 0);
41                 case 1: return (superio_get_ide_irq() ? 0x170 : 0);
42 #endif /* CONFIG_SUPERIO */
43                 default:
44                         return 0;
45         }
46 }
47
48 static __inline__ void ide_init_hwif_ports(hw_regs_t *hw, ide_ioreg_t data_port, ide_ioreg_t ctrl_port, int *irq)
49 {
50         ide_ioreg_t reg = data_port;
51         int i;
52
53         for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
54                 hw->io_ports[i] = reg;
55                 reg += 1;
56         }
57         if (ctrl_port) {
58                 hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
59         } else {
60                 hw->io_ports[IDE_CONTROL_OFFSET] = hw->io_ports[IDE_DATA_OFFSET] + 0x206;
61         }
62         if (irq != NULL)
63                 *irq = 0;
64         hw->io_ports[IDE_IRQ_OFFSET] = 0;
65 }
66
67 static __inline__ void ide_init_default_hwifs(void)
68 {
69 #ifndef CONFIG_BLK_DEV_IDEPCI
70         hw_regs_t hw;
71         int index;
72
73         for(index = 0; index < MAX_HWIFS; index++) {
74                 ide_init_hwif_ports(&hw, ide_default_io_base(index), 0, NULL);
75                 hw.irq = ide_default_irq(ide_default_io_base(index));
76                 ide_register_hw(&hw, NULL);
77         }
78 #endif /* CONFIG_BLK_DEV_IDEPCI */
79 }
80
81 #include <asm-generic/ide_iops.h>
82
83 #endif /* __KERNEL__ */
84
85 #endif /* __ASM_PARISC_IDE_H */