cleanup
[linux-2.4.21-pre4.git] / include / asm-cris / ide.h
1 /*
2  *  linux/include/asm-cris/ide.h
3  *
4  *  Copyright (C) 2000, 2001, 2002  Axis Communications AB
5  *
6  *  Authors:    Bjorn Wesen
7  *
8  */
9
10 /*
11  *  This file contains the ETRAX 100LX specific IDE code.
12  */
13
14 #ifndef __ASMCRIS_IDE_H
15 #define __ASMCRIS_IDE_H
16
17 #ifdef __KERNEL__
18
19 #include <asm/svinto.h>
20
21 /* ETRAX 100 can support 4 IDE busses on the same pins (serialized) */
22
23 #define MAX_HWIFS       4
24
25 extern __inline__ int ide_default_irq(ide_ioreg_t base)
26 {
27         /* all IDE busses share the same IRQ, number 4.
28          * this has the side-effect that ide-probe.c will cluster our 4 interfaces
29          * together in a hwgroup, and will serialize accesses. this is good, because
30          * we can't access more than one interface at the same time on ETRAX100.
31          */
32         return 4; 
33 }
34
35 extern __inline__ ide_ioreg_t ide_default_io_base(int index)
36 {
37         /* we have no real I/O base address per interface, since all go through the
38          * same register. but in a bitfield in that register, we have the i/f number.
39          * so we can use the io_base to remember that bitfield.
40          */
41         static const unsigned long io_bases[MAX_HWIFS] = {
42                 IO_FIELD(R_ATA_CTRL_DATA, sel, 0),
43                 IO_FIELD(R_ATA_CTRL_DATA, sel, 1),
44                 IO_FIELD(R_ATA_CTRL_DATA, sel, 2),
45                 IO_FIELD(R_ATA_CTRL_DATA, sel, 3)
46         };
47         return io_bases[index];
48 }
49
50 /* this is called once for each interface, to setup the port addresses. data_port is the result
51  * of the ide_default_io_base call above. ctrl_port will be 0, but that is don't care for us.
52  */
53
54 extern __inline__ void ide_init_hwif_ports(hw_regs_t *hw, ide_ioreg_t data_port, ide_ioreg_t ctrl_port, int *irq)
55 {
56         int i;
57
58         /* fill in ports for ATA addresses 0 to 7 */
59
60         for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
61                 hw->io_ports[i] = data_port | 
62                         IO_FIELD(R_ATA_CTRL_DATA, addr, i) | 
63                         IO_STATE(R_ATA_CTRL_DATA, cs0, active);
64         }
65
66         /* the IDE control register is at ATA address 6, with CS1 active instead of CS0 */
67
68         hw->io_ports[IDE_CONTROL_OFFSET] = data_port |
69                         IO_FIELD(R_ATA_CTRL_DATA, addr, 6) | 
70                         IO_STATE(R_ATA_CTRL_DATA, cs1, active);
71
72         /* whats this for ? */
73
74         hw->io_ports[IDE_IRQ_OFFSET] = 0;
75 }
76
77 extern __inline__ void ide_init_default_hwifs(void)
78 {
79         hw_regs_t hw;
80         int index;
81
82         for(index = 0; index < MAX_HWIFS; index++) {
83                 ide_init_hwif_ports(&hw, ide_default_io_base(index), 0, NULL);
84                 hw.irq = ide_default_irq(ide_default_io_base(index));
85                 ide_register_hw(&hw, NULL);
86         }
87 }
88
89 /* some configuration options we don't need */
90
91 #undef SUPPORT_VLB_SYNC
92 #define SUPPORT_VLB_SYNC 0
93
94 #endif /* __KERNEL__ */
95
96 #endif /* __ASMCRIS_IDE_H */