more changes on original files
[linux-2.4.git] / asm-ppc / ide.h
1 /*
2  *  linux/include/asm-ppc/ide.h
3  *
4  *  Copyright (C) 1994-1996 Linus Torvalds & authors */
5
6 /*
7  *  This file contains the ppc architecture specific IDE code.
8  */
9
10 #ifndef __ASMPPC_IDE_H
11 #define __ASMPPC_IDE_H
12
13 #ifdef __KERNEL__
14
15 #include <linux/sched.h>
16 #include <asm/processor.h>
17 #include <asm/mpc8xx.h>
18
19 #ifndef MAX_HWIFS
20 #define MAX_HWIFS       8
21 #endif
22
23 #include <asm/hdreg.h>
24
25 #include <linux/config.h>
26 #include <linux/hdreg.h>
27 #include <linux/ioport.h>
28 #include <asm/io.h>
29
30 struct ide_machdep_calls {
31         int         (*default_irq)(ide_ioreg_t base);
32         ide_ioreg_t (*default_io_base)(int index);
33         void        (*ide_init_hwif)(hw_regs_t *hw,
34                                      ide_ioreg_t data_port,
35                                      ide_ioreg_t ctrl_port,
36                                      int *irq);
37 };
38
39 extern struct ide_machdep_calls ppc_ide_md;
40
41 #undef  SUPPORT_SLOW_DATA_PORTS
42 #define SUPPORT_SLOW_DATA_PORTS 0
43 #undef  SUPPORT_VLB_SYNC
44 #define SUPPORT_VLB_SYNC        0
45
46 static __inline__ int ide_default_irq(ide_ioreg_t base)
47 {
48         if (ppc_ide_md.default_irq)
49                 return ppc_ide_md.default_irq(base);
50         return 0;
51 }
52
53 static __inline__ ide_ioreg_t ide_default_io_base(int index)
54 {
55         if (ppc_ide_md.default_io_base)
56                 return ppc_ide_md.default_io_base(index);
57         return 0;
58 }
59
60 static __inline__ void ide_init_hwif_ports(hw_regs_t *hw,
61                                            ide_ioreg_t data_port,
62                                            ide_ioreg_t ctrl_port, int *irq)
63 {
64         ide_ioreg_t reg = data_port;
65         int i;
66
67         if (ppc_ide_md.ide_init_hwif != NULL) {
68                 ppc_ide_md.ide_init_hwif(hw, data_port, ctrl_port, irq);
69                 return;
70         }
71         for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++)
72                 hw->io_ports[i] = reg++;
73         if (ctrl_port) {
74                 hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
75         } else {
76                 hw->io_ports[IDE_CONTROL_OFFSET] =
77                         hw->io_ports[IDE_DATA_OFFSET] + 0x206;
78         }
79         if (irq != NULL)
80                 *irq = 0;
81         hw->io_ports[IDE_IRQ_OFFSET] = 0;
82 }
83
84 static __inline__ void ide_init_default_hwifs(void)
85 {
86 #ifndef CONFIG_BLK_DEV_IDEPCI
87         hw_regs_t hw;
88         int index;
89         ide_ioreg_t base;
90
91         for (index = 0; index < MAX_HWIFS; index++) {
92                 base = ide_default_io_base(index);
93                 if (base == 0)
94                         continue;
95                 ide_init_hwif_ports(&hw, base, 0, NULL);
96                 hw.irq = ide_default_irq(base);
97                 ide_register_hw(&hw, NULL);
98         }
99 #endif /* CONFIG_BLK_DEV_IDEPCI */
100 }
101
102 #define __ide_mm_insw(p, a, c)  _insw_ns((volatile u16 *)(p), (a), (c))
103 #define __ide_mm_insl(p, a, c)  _insl_ns((volatile u32 *)(p), (a), (c))
104 #define __ide_mm_outsw(p, a, c) _outsw_ns((volatile u16 *)(p), (a), (c))
105 #define __ide_mm_outsl(p, a, c) _outsl_ns((volatile u32 *)(p), (a), (c))
106
107 /*
108  * The following are not needed for the non-m68k ports
109  * unless direct IDE on 8xx
110  */
111 #if (defined CONFIG_APUS || defined CONFIG_BLK_DEV_MPC8xx_IDE )
112 #define IDE_ARCH_ACK_INTR 1
113 #endif
114
115 #endif /* __KERNEL__ */
116
117 #endif /* __ASMPPC_IDE_H */