1 /*
2 * Copyright (C) 2001 Broadcom Corporation
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19 /* Derived loosely from ide-pmac.c, so:
20 *
21 * Copyright (C) 1998 Paul Mackerras.
22 * Copyright (C) 1995-1998 Mark Lord
23 */
24 #include <linux/config.h>
25 #include <linux/types.h>
26 #include <linux/kernel.h>
27 #include <linux/sched.h>
28 #include <linux/init.h>
29 #include <linux/delay.h>
30 #include <linux/ide.h>
31 #include <asm/irq.h>
32 #include <asm/io.h>
33 #include <asm/sibyte/sb1250_int.h>
34
35 #define __IDE_SWARM_C
36
37 #include <asm/sibyte/swarm_ide.h>
38
swarm_ide_probe(void)39 void __init swarm_ide_probe(void)
40 {
41 int i;
42 ide_hwif_t *hwif;
43 /*
44 * Find the first untaken slot in hwifs
45 */
46 for (i = 0; i < MAX_HWIFS; i++) {
47 if (!ide_hwifs[i].io_ports[IDE_DATA_OFFSET]) {
48 break;
49 }
50 }
51 if (i == MAX_HWIFS) {
52 printk("No space for SWARM onboard IDE driver in ide_hwifs[]. Not enabled.\n");
53 return;
54 }
55
56 /* Set up our stuff */
57 hwif = &ide_hwifs[i];
58 hwif->hw.io_ports[IDE_DATA_OFFSET] = SWARM_IDE_REG(0x1f0);
59 hwif->hw.io_ports[IDE_ERROR_OFFSET] = SWARM_IDE_REG(0x1f1);
60 hwif->hw.io_ports[IDE_NSECTOR_OFFSET] = SWARM_IDE_REG(0x1f2);
61 hwif->hw.io_ports[IDE_SECTOR_OFFSET] = SWARM_IDE_REG(0x1f3);
62 hwif->hw.io_ports[IDE_LCYL_OFFSET] = SWARM_IDE_REG(0x1f4);
63 hwif->hw.io_ports[IDE_HCYL_OFFSET] = SWARM_IDE_REG(0x1f5);
64 hwif->hw.io_ports[IDE_SELECT_OFFSET] = SWARM_IDE_REG(0x1f6);
65 hwif->hw.io_ports[IDE_STATUS_OFFSET] = SWARM_IDE_REG(0x1f7);
66 hwif->hw.io_ports[IDE_CONTROL_OFFSET] = SWARM_IDE_REG(0x3f6);
67 hwif->hw.io_ports[IDE_IRQ_OFFSET] = SWARM_IDE_REG(0x3f7);
68 // hwif->hw->ack_intr = swarm_ide_ack_intr;
69 hwif->hw.irq = SWARM_IDE_INT;
70 #if 0
71 hwif->iops = swarm_iops;
72 #else
73 hwif->OUTB = hwif->OUTBP = swarm_outb;
74 hwif->OUTW = hwif->OUTWP = swarm_outw;
75 hwif->OUTL = hwif->OUTLP = swarm_outl;
76 hwif->OUTSW = hwif->OUTSWP = swarm_outsw;
77 hwif->OUTSL = hwif->OUTSLP = swarm_outsl;
78 hwif->INB = hwif->INBP = swarm_inb;
79 hwif->INW = hwif->INWP = swarm_inw;
80 hwif->INL = hwif->INLP = swarm_inl;
81 hwif->INSW = hwif->INSWP = swarm_insw;
82 hwif->INSL = hwif->INSLP = swarm_insl;
83 #endif
84 #if 0
85 hwif->pioops = swarm_pio_ops;
86 #else
87 hwif->ata_input_data = swarm_ata_input_data;
88 hwif->ata_output_data = swarm_ata_output_data;
89 hwif->atapi_input_bytes = swarm_atapi_input_bytes;
90 hwif->atapi_output_bytes = swarm_atapi_output_bytes;
91 #endif
92 memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->io_ports));
93 hwif->irq = hwif->hw.irq;
94 printk("SWARM onboard IDE configured as device %i\n", i);
95
96 #ifndef HWIF_PROBE_CLASSIC_METHOD
97 probe_hwif_init(hwif->index);
98 #endif /* HWIF_PROBE_CLASSIC_METHOD */
99
100 }
101
102