1 /*
2 * linux/drivers/ide/arm/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
rapide_register(struct expansion_card * ec)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
44 return ide_register_hw(&hw, NULL);
45 }
46
rapide_init(void)47 int __init rapide_init(void)
48 {
49 int i;
50
51 for (i = 0; i < MAX_ECARDS; i++)
52 ec[i] = NULL;
53
54 ecard_startfind();
55
56 for (i = 0; ; i++) {
57 if ((ec[i] = ecard_find(0, rapide_cids)) == NULL)
58 break;
59
60 ecard_claim(ec[i]);
61 result[i] = rapide_register(ec[i]);
62 }
63 for (i = 0; i < MAX_ECARDS; i++)
64 if (ec[i] && result[i] < 0) {
65 ecard_release(ec[i]);
66 ec[i] = NULL;
67 }
68 return 0;
69 }
70
71 #ifdef MODULE
72 MODULE_LICENSE("GPL");
73
init_module(void)74 int init_module (void)
75 {
76 return rapide_init();
77 }
78
cleanup_module(void)79 void cleanup_module (void)
80 {
81 int i;
82
83 for (i = 0; i < MAX_ECARDS; i++)
84 if (ec[i]) {
85 unsigned long port;
86 port = ecard_address(ec[i], ECARD_MEMC, 0);
87
88 ide_unregister_port(port, ec[i]->irq, 16);
89 ecard_release(ec[i]);
90 ec[i] = NULL;
91 }
92 }
93 #endif
94
95