Merge with Linux 2.4.0-test3-pre2.
[linux-2.6/linux-mips.git] / include / asm-arm / arch-sa1100 / ide.h
blob3a9935c0b578e28df106afe772d321e7e81e2a5d
1 /*
2 * linux/include/asm-arm/arch-sa1100/ide.h
4 * Copyright (c) 1998 Hugo Fiennes & Nicolas Pitre
6 */
8 #include <linux/config.h>
10 #ifdef CONFIG_BLK_DEV_IDE
12 #include <asm/irq.h>
13 #include <asm/arch/hardware.h>
16 * Set up a hw structure for a specified data port, control port and IRQ.
17 * This should follow whatever the default interface uses.
19 static __inline__ void
20 ide_init_hwif_ports(hw_regs_t *hw, int data_port, int ctrl_port, int *irq)
22 ide_ioreg_t reg;
23 int i;
25 memset(hw, 0, sizeof(*hw));
27 #ifdef CONFIG_SA1100_EMPEG
28 /* The Empeg board has the first two address lines unused */
29 #define IO_SHIFT 2
30 #else
31 #define IO_SHIFT 0
32 #endif
34 reg = (ide_ioreg_t) (data_port << IO_SHIFT);
35 for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
36 hw->io_ports[i] = reg;
37 reg += (1 << IO_SHIFT);
39 hw->io_ports[IDE_CONTROL_OFFSET] = (ide_ioreg_t) (ctrl_port << IO_SHIFT);
40 if (irq)
41 *irq = 0;
45 * This registers the standard ports for this architecture with the IDE
46 * driver.
48 static __inline__ void
49 ide_init_default_hwifs(void)
51 hw_regs_t hw;
53 #if defined( CONFIG_SA1100_EMPEG )
54 /* First, do the SA1100 setup */
56 /* PCMCIA IO space */
57 MECR=0x21062106;
59 /* Issue 3 is much neater than issue 2 */
60 GPDR&=~(EMPEG_IDE1IRQ|EMPEG_IDE2IRQ);
62 /* Interrupts on rising edge: lines are inverted before they get to
63 the SA */
64 GRER&=~(EMPEG_IDE1IRQ|EMPEG_IDE2IRQ);
65 GFER|=(EMPEG_IDE1IRQ|EMPEG_IDE2IRQ);
67 /* Take hard drives out of reset */
68 GPSR=(EMPEG_IDERESET);
70 /* Clear GEDR */
71 GEDR=0xffffffff;
73 /* Sonja and her successors have two IDE ports. */
74 /* MAC 23/4/1999, swap these round so that the left hand
75 hard disk is hda when viewed from the front. This
76 doesn't match the silkscreen however. */
77 ide_init_hwif_ports(&hw,0x10,0x1e,NULL);
78 hw.irq = EMPEG_IRQ_IDE2;
79 ide_register_hw(&hw, NULL);
80 ide_init_hwif_ports(&hw,0x00,0x0e,NULL);
81 hw.irq = EMPEG_IRQ_IDE1;
82 ide_register_hw(&hw, NULL);
84 #elif defined( CONFIG_SA1100_VICTOR )
85 /* Enable appropriate GPIOs as interrupt lines */
86 GPDR &= ~GPIO_GPIO7;
87 GRER |= GPIO_GPIO7;
88 GFER &= ~GPIO_GPIO7;
89 GEDR = GPIO_GPIO7;
90 /* set the pcmcia interface timing */
91 MECR = 0x00060006;
93 ide_init_hwif_ports(&hw, 0x1f0, 0x3f6, NULL);
94 hw.irq = IRQ_GPIO7;
95 ide_register_hw(&hw, NULL);
96 #else
97 #error Missing IDE interface definition in include/asm/arch/ide.h
98 #endif
101 #endif