2 * Created 20 Oct 2004 by Mark Lord
4 * Basic support for Delkin/ASKA/Workbit Cardbus CompactFlash adapter
6 * Modeled after the 16-bit PCMCIA driver: ide-cs.c
8 * This is slightly peculiar, in that it is a PCI driver,
9 * but is NOT an IDE PCI driver -- the IDE layer does not directly
10 * support hot insertion/removal of PCI interfaces, so this driver
11 * is unable to use the IDE PCI interfaces. Instead, it uses the
12 * same interfaces as the ide-cs (PCMCIA) driver uses.
13 * On the plus side, the driver is also smaller/simpler this way.
15 * This file is subject to the terms and conditions of the GNU General Public
16 * License. See the file COPYING in the main directory of this archive for
19 #include <linux/autoconf.h>
20 #include <linux/types.h>
21 #include <linux/module.h>
23 #include <linux/blkdev.h>
24 #include <linux/hdreg.h>
25 #include <linux/ide.h>
26 #include <linux/init.h>
27 #include <linux/pci.h>
31 * No chip documentation has yet been found,
32 * so these configuration values were pulled from
33 * a running Win98 system using "debug".
34 * This gives around 3MByte/second read performance,
35 * which is about 2/3 of what the chip is capable of.
37 * There is also a 4KByte mmio region on the card,
38 * but its purpose has yet to be reverse-engineered.
40 static const u8 setup
[] = {
41 0x00, 0x05, 0xbe, 0x01, 0x20, 0x8f, 0x00, 0x00,
42 0xa4, 0x1f, 0xb3, 0x1b, 0x00, 0x00, 0x00, 0x80,
43 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44 0x00, 0x00, 0x00, 0x00, 0xa4, 0x83, 0x02, 0x13,
48 delkin_cb_probe (struct pci_dev
*dev
, const struct pci_device_id
*id
)
52 ide_hwif_t
*hwif
= NULL
;
56 rc
= pci_enable_device(dev
);
58 printk(KERN_ERR
"delkin_cb: pci_enable_device failed (%d)\n", rc
);
61 rc
= pci_request_regions(dev
, "delkin_cb");
63 printk(KERN_ERR
"delkin_cb: pci_request_regions failed (%d)\n", rc
);
64 pci_disable_device(dev
);
67 base
= pci_resource_start(dev
, 0);
68 outb(0x02, base
+ 0x1e); /* set nIEN to block interrupts */
69 inb(base
+ 0x17); /* read status to clear interrupts */
70 for (i
= 0; i
< sizeof(setup
); ++i
) {
72 outb(setup
[i
], base
+ i
);
74 pci_release_regions(dev
); /* IDE layer handles regions itself */
76 memset(&hw
, 0, sizeof(hw
));
77 ide_std_init_ports(&hw
, base
+ 0x10, base
+ 0x1e);
79 hw
.chipset
= ide_pci
; /* this enables IRQ sharing */
81 rc
= ide_register_hw(&hw
, &ide_undecoded_slave
, &hwif
);
83 printk(KERN_ERR
"delkin_cb: ide_register_hw failed (%d)\n", rc
);
84 pci_disable_device(dev
);
87 pci_set_drvdata(dev
, hwif
);
88 hwif
->dev
= &dev
->dev
;
89 drive
= &hwif
->drives
[0];
98 delkin_cb_remove (struct pci_dev
*dev
)
100 ide_hwif_t
*hwif
= pci_get_drvdata(dev
);
103 ide_unregister(hwif
->index
);
104 pci_disable_device(dev
);
107 static struct pci_device_id delkin_cb_pci_tbl
[] __devinitdata
= {
108 { 0x1145, 0xf021, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0},
109 { 0x1145, 0xf024, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0},
112 MODULE_DEVICE_TABLE(pci
, delkin_cb_pci_tbl
);
114 static struct pci_driver driver
= {
115 .name
= "Delkin-ASKA-Workbit Cardbus IDE",
116 .id_table
= delkin_cb_pci_tbl
,
117 .probe
= delkin_cb_probe
,
118 .remove
= delkin_cb_remove
,
122 delkin_cb_init (void)
124 return pci_register_driver(&driver
);
128 delkin_cb_exit (void)
130 pci_unregister_driver(&driver
);
133 module_init(delkin_cb_init
);
134 module_exit(delkin_cb_exit
);
136 MODULE_AUTHOR("Mark Lord");
137 MODULE_DESCRIPTION("Basic support for Delkin/ASKA/Workbit Cardbus IDE");
138 MODULE_LICENSE("GPL");