import of ftp.dlink.com/GPL/DSMG-600_reB/ppclinux.tar.gz
[linux-2.4.21-pre4.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 #define ide__sti()      __sti()
24
25 static __inline__ int ide_default_irq(ide_ioreg_t base)
26 {
27         switch (base) {
28 #ifdef CONFIG_SUPERIO
29                 case 0x1f0: 
30                 case 0x170:
31                         return superio_get_ide_irq();
32 #endif /* CONFIG_SUPERIO */
33                 default:
34                         return 0;
35         }
36 }
37
38 static __inline__ ide_ioreg_t ide_default_io_base(int index)
39 {
40         switch (index) {
41 #ifdef CONFIG_SUPERIO 
42                 case 0: return (superio_get_ide_irq() ? 0x1f0 : 0);
43                 case 1: return (superio_get_ide_irq() ? 0x170 : 0);
44 #endif /* CONFIG_SUPERIO */
45                 default:
46                         return 0;
47         }
48 }
49
50 static __inline__ void ide_init_hwif_ports(hw_regs_t *hw, ide_ioreg_t data_port, ide_ioreg_t ctrl_port, int *irq)
51 {
52         ide_ioreg_t reg = data_port;
53         int i;
54
55         for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
56                 hw->io_ports[i] = reg;
57                 reg += 1;
58         }
59         if (ctrl_port) {
60                 hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
61         } else {
62                 hw->io_ports[IDE_CONTROL_OFFSET] = hw->io_ports[IDE_DATA_OFFSET] + 0x206;
63         }
64         if (irq != NULL)
65                 *irq = 0;
66         hw->io_ports[IDE_IRQ_OFFSET] = 0;
67 }
68
69 static __inline__ void ide_init_default_hwifs(void)
70 {
71 #ifndef CONFIG_BLK_DEV_IDEPCI
72         hw_regs_t hw;
73         int index;
74
75         for(index = 0; index < MAX_HWIFS; index++) {
76                 ide_init_hwif_ports(&hw, ide_default_io_base(index), 0, NULL);
77                 hw.irq = ide_default_irq(ide_default_io_base(index));
78                 ide_register_hw(&hw, NULL);
79         }
80 #endif /* CONFIG_BLK_DEV_IDEPCI */
81 }
82
83 typedef union {
84         unsigned all                    : 8;    /* all of the bits together */
85         struct {
86                 unsigned bit7           : 1;    /* always 1 */
87                 unsigned lba            : 1;    /* using LBA instead of CHS */
88                 unsigned bit5           : 1;    /* always 1 */
89                 unsigned unit           : 1;    /* drive select number, 0 or 1 */
90                 unsigned head           : 4;    /* always zeros here */
91         } b;
92 } select_t;
93
94 typedef union {
95         unsigned all                    : 8;    /* all of the bits together */
96         struct {
97                 unsigned bit0           : 1;
98                 unsigned nIEN           : 1;    /* device INTRQ to host */
99                 unsigned SRST           : 1;    /* host soft reset bit */
100                 unsigned bit3           : 1;    /* ATA-2 thingy */
101                 unsigned reserved456    : 3;
102                 unsigned HOB            : 1;    /* 48-bit address ordering */
103         } b;
104 } control_t;
105
106 #endif /* __KERNEL__ */
107
108 #endif /* __ASM_PARISC_IDE_H */