ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / include / asm-arm / arch-sa1100 / ide.h
1 /*
2  * linux/include/asm-arm/arch-sa1100/ide.h
3  *
4  * Copyright (c) 1998 Hugo Fiennes & Nicolas Pitre
5  *
6  * 18-aug-2000: Cleanup by Erik Mouw (J.A.K.Mouw@its.tudelft.nl)
7  *              Get rid of the special ide_init_hwif_ports() functions
8  *              and make a generalised function that can be used by all
9  *              architectures.
10  */
11
12 #include <linux/config.h>
13 #include <asm/irq.h>
14 #include <asm/hardware.h>
15 #include <asm/mach-types.h>
16
17
18 /*
19  * Set up a hw structure for a specified data port, control port and IRQ.
20  * This should follow whatever the default interface uses.
21  */
22 static inline void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port,
23                                        unsigned long ctrl_port, int *irq)
24 {
25         unsigned long reg = data_port;
26         int i;
27         int regincr = 1;
28
29         /* The Empeg board has the first two address lines unused */
30         if (machine_is_empeg())
31                 regincr = 1 << 2;
32
33         /* The LART doesn't use A0 for IDE */
34         if (machine_is_lart())
35                 regincr = 1 << 1;
36
37         memset(hw, 0, sizeof(*hw));
38
39         for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
40                 hw->io_ports[i] = reg;
41                 reg += regincr;
42         }
43
44         hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
45
46         if (irq)
47                 *irq = 0;
48 }
49
50 #ifdef CONFIG_SA1100_TRIZEPS
51 #include <asm/arch/trizeps.h>
52 #endif
53
54 /*
55  * This registers the standard ports for this architecture with the IDE
56  * driver.
57  */
58 static __inline__ void
59 ide_init_default_hwifs(void)
60 {
61     if( machine_is_empeg() ){
62 #ifdef CONFIG_SA1100_EMPEG
63         hw_regs_t hw;
64
65         /* First, do the SA1100 setup */
66
67         /* PCMCIA IO space */
68         MECR=0x21062106;
69
70         /* Issue 3 is much neater than issue 2 */
71         GPDR&=~(EMPEG_IDE1IRQ|EMPEG_IDE2IRQ);
72
73         /* Interrupts on rising edge: lines are inverted before they get to
74            the SA */
75         set_GPIO_IRQ_edge( (EMPEG_IDE1IRQ|EMPEG_IDE2IRQ), GPIO_FALLING_EDGE );
76
77         /* Take hard drives out of reset */
78         GPSR=(EMPEG_IDERESET);
79
80         /* Sonja and her successors have two IDE ports. */
81         /* MAC 23/4/1999, swap these round so that the left hand
82            hard disk is hda when viewed from the front. This
83            doesn't match the silkscreen however. */
84         ide_init_hwif_ports(&hw, PCMCIA_IO_0_BASE + 0x40, PCMCIA_IO_0_BASE + 0x78, NULL);
85         hw.irq = EMPEG_IRQ_IDE2;
86         ide_register_hw(&hw);
87         ide_init_hwif_ports(&hw, PCMCIA_IO_0_BASE + 0x00, PCMCIA_IO_0_BASE + 0x38, NULL);
88         hw.irq = ,EMPEG_IRQ_IDE1;
89         ide_register_hw(&hw);
90 #endif
91     }
92
93     else if( machine_is_victor() ){
94 #ifdef CONFIG_SA1100_VICTOR
95         hw_regs_t hw;
96
97         /* Enable appropriate GPIOs as interrupt lines */
98         GPDR &= ~GPIO_GPIO7;
99         set_GPIO_IRQ_edge( GPIO_GPIO7, GPIO_RISING_EDGE );
100
101         /* set the pcmcia interface timing */
102         MECR = 0x00060006;
103
104         ide_init_hwif_ports(&hw, PCMCIA_IO_0_BASE + 0x1f0, PCMCIA_IO_0_BASE + 0x3f6, NULL);
105         hw.irq = IRQ_GPIO7;
106         ide_register_hw(&hw);
107 #endif
108     }
109     else if (machine_is_lart()) {
110 #ifdef CONFIG_SA1100_LART
111         hw_regs_t hw;
112
113         /* Enable GPIO as interrupt line */
114         GPDR &= ~LART_GPIO_IDE;
115         set_irq_type(LART_IRQ_IDE, IRQT_RISING);
116
117         /* set PCMCIA interface timing */
118         MECR = 0x00060006;
119
120         /* init the interface */
121         ide_init_hwif_ports(&hw, PCMCIA_IO_0_BASE + 0x0000, PCMCIA_IO_0_BASE + 0x1000, NULL);
122         hw.irq = LART_IRQ_IDE;
123         ide_register_hw(&hw);
124 #endif
125     }
126     else if( machine_is_trizeps() ){
127 #ifdef CONFIG_SA1100_TRIZEPS
128         hw_regs_t hw;
129
130         /* Enable appropriate GPIOs as interrupt lines */
131         GPDR &= ~GPIO_GPIO(TRIZEPS_IRQ_IDE);
132         set_irq_type( TRIZEPS_IRQ_IDE, IRQT_RISING );
133
134         /* set the pcmcia interface timing */
135         //MECR = 0x00060006; // Done on trizeps init
136
137         /* Take hard drives out of reset */
138         GPSR = GPIO_GPIO(TRIZEPS_IRQ_IDE);
139
140         ide_init_hwif_ports(&hw, TRIZEPS_IDE_CS0 + 0, TRIZEPS_IDE_CS1 + 6, NULL);
141         hw.irq = TRIZEPS_IRQ_IDE;
142         ide_register_hw(&hw, NULL);
143 #endif
144     }
145 }