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