update atp870u driver to 0.78 from D-Link source
[linux-2.4.git] / drivers / ide / legacy / sibyte.c
1 /*
2  * Copyright (C) 2001, 2002, 2003 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/kernel.h>
25 #include <linux/ide.h>
26
27 #include <asm/sibyte/board.h>
28
29 #define SIBYTE_IDE_BASE        (IO_SPACE_BASE + IDE_PHYS - mips_io_port_base)
30 #define SIBYTE_IDE_REG(pcaddr) (SIBYTE_IDE_BASE + ((pcaddr) << 5))
31
32 extern void sibyte_set_ideops(ide_hwif_t *hwif);
33
34 void __init sibyte_ide_probe(void)
35 {
36         int i;
37         ide_hwif_t *hwif = NULL;
38
39         /* 
40          * Find the first untaken slot in hwifs.  Also set the io ops
41          * to the non-swapping SiByte versions.  XXXKW It would be
42          * nice to find a safe place to do this outside of
43          * ide-sibyte.c so PCI-IDE would work without the SiByte
44          * driver.
45          */
46         for (i = 0; i < MAX_HWIFS; i++) {
47                 sibyte_set_ideops(&ide_hwifs[i]);
48                 if (!ide_hwifs[i].io_ports[IDE_DATA_OFFSET] && (hwif == NULL)) {
49                         hwif = &ide_hwifs[i];
50                 }
51         }
52         if (hwif == NULL) {
53                 printk("No space for SiByte onboard IDE driver in ide_hwifs[].  Not enabled.\n");
54                 return;
55         }
56
57         /*
58          * Set up our stuff; we're a little odd because our io_ports
59          * aren't in the usual place, and byte-swapping isn't
60          * necessary.
61          */
62         hwif->hw.io_ports[IDE_DATA_OFFSET]    = SIBYTE_IDE_REG(0x1f0);
63         hwif->hw.io_ports[IDE_ERROR_OFFSET]   = SIBYTE_IDE_REG(0x1f1);
64         hwif->hw.io_ports[IDE_NSECTOR_OFFSET] = SIBYTE_IDE_REG(0x1f2);
65         hwif->hw.io_ports[IDE_SECTOR_OFFSET]  = SIBYTE_IDE_REG(0x1f3);
66         hwif->hw.io_ports[IDE_LCYL_OFFSET]    = SIBYTE_IDE_REG(0x1f4);
67         hwif->hw.io_ports[IDE_HCYL_OFFSET]    = SIBYTE_IDE_REG(0x1f5);
68         hwif->hw.io_ports[IDE_SELECT_OFFSET]  = SIBYTE_IDE_REG(0x1f6);
69         hwif->hw.io_ports[IDE_STATUS_OFFSET]  = SIBYTE_IDE_REG(0x1f7);
70         hwif->hw.io_ports[IDE_CONTROL_OFFSET] = SIBYTE_IDE_REG(0x3f6);
71         hwif->hw.irq                          = K_INT_GB_IDE;
72         hwif->irq                             = hwif->hw.irq;
73         hwif->noprobe                         = 0;
74         hwif->hw.ack_intr                     = NULL;
75         hwif->mmio                            = 2;
76
77         memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->io_ports));
78         printk(KERN_INFO "SiByte onboard IDE configured as device %i\n", hwif-ide_hwifs);
79 }