import of ftp.dlink.com/GPL/DSMG-600_reB/ppclinux.tar.gz
[linux-2.4.21-pre4.git] / drivers / ide / arm / rapide.c
1 /*
2  * linux/drivers/ide/rapide.c
3  *
4  * Copyright (c) 1996-1998 Russell King.
5  *
6  * Changelog:
7  *  08-06-1996  RMK     Created
8  *  13-04-1998  RMK     Added manufacturer and product IDs
9  */
10
11 #include <linux/module.h>
12 #include <linux/slab.h>
13 #include <linux/blkdev.h>
14 #include <linux/errno.h>
15 #include <linux/ide.h>
16 #include <linux/init.h>
17
18 #include <asm/ecard.h>
19
20 static card_ids __init rapide_cids[] = {
21         { MANU_YELLOWSTONE, PROD_YELLOWSTONE_RAPIDE32 },
22         { 0xffff, 0xffff }
23 };
24
25 static struct expansion_card *ec[MAX_ECARDS];
26 static int result[MAX_ECARDS];
27
28 static inline int rapide_register(struct expansion_card *ec)
29 {
30         unsigned long port = ecard_address (ec, ECARD_MEMC, 0);
31         hw_regs_t hw;
32
33         int i;
34
35         memset(&hw, 0, sizeof(hw));
36
37         for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
38                 hw.io_ports[i] = (ide_ioreg_t)port;
39                 port += 1 << 4;
40         }
41         hw.io_ports[IDE_CONTROL_OFFSET] = port + 0x206;
42         hw.irq = ec->irq;
43         hw.chipset = ide_generic;
44
45         return ide_register_hw(&hw, NULL);
46 }
47
48 int __init rapide_init(void)
49 {
50         int i;
51
52         for (i = 0; i < MAX_ECARDS; i++)
53                 ec[i] = NULL;
54
55         ecard_startfind();
56
57         for (i = 0; ; i++) {
58                 if ((ec[i] = ecard_find(0, rapide_cids)) == NULL)
59                         break;
60
61                 ecard_claim(ec[i]);
62                 result[i] = rapide_register(ec[i]);
63         }
64         for (i = 0; i < MAX_ECARDS; i++)
65                 if (ec[i] && result[i] < 0) {
66                         ecard_release(ec[i]);
67                         ec[i] = NULL;
68         }
69         return 0;
70 }
71
72 #ifdef MODULE
73 MODULE_LICENSE("GPL");
74
75 int init_module (void)
76 {
77         return rapide_init();
78 }
79
80 void cleanup_module (void)
81 {
82         int i;
83
84         for (i = 0; i < MAX_ECARDS; i++)
85                 if (ec[i]) {
86                         unsigned long port;
87                         port = ecard_address(ec[i], ECARD_MEMC, 0);
88
89                         ide_unregister_port(port, ec[i]->irq, 16);
90                         ecard_release(ec[i]);
91                         ec[i] = NULL;
92                 }
93 }
94 #endif
95